From 95e1dfc1fafc16f6d75d035ef9a0c65bb4c76615 Mon Sep 17 00:00:00 2001 From: Philipp Zabel Date: Thu, 5 Aug 2010 20:26:58 +0200 Subject: [PATCH] Movie list view: disconnect model from unused view, workaround for switching Connect the model only to the visible view for performance reasons. Jumping to 0, 0 and manually checking the first few posters is a workaround for posters not being displayed until the user scrolls after switching to the poster grid mode. --- src/movie-list-view.vala | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/src/movie-list-view.vala b/src/movie-list-view.vala index d469148..0b695cf 100644 --- a/src/movie-list-view.vala +++ b/src/movie-list-view.vala @@ -30,6 +30,8 @@ public class MovieListView : PannableArea { private CellRendererText rating_renderer; private CellRendererText date_renderer; private MoviePoster.Factory poster_factory; + private int last_a = -1; + private int last_b = -1; private bool poster_mode_; public bool poster_mode { @@ -39,12 +41,27 @@ public class MovieListView : PannableArea { set { if (value & !poster_mode_) { remove (tree); + tree.set_model (null); + icons.set_model (store); + store.view = (Widget) icons; add (icons); } else if (!value & poster_mode_) { remove (icons); + icons.set_model (null); + tree.set_model (store); + store.view = (Widget) tree; add (tree); } - poster_mode_ = value; + if (value != poster_mode_) { + poster_mode_ = value; + last_a = -1; + last_b = -1; + + // FIXME - just calling on_adjustment_value_changed () here doesn't work + // because icons.get_visible_range () returns wrong paths. + check_posters (0, 10); + jump_to (0, 0); + } } } @@ -138,7 +155,7 @@ public class MovieListView : PannableArea { } private Gtk.IconView create_iconview () { - var iconview = (Gtk.IconView) Hildon.gtk_icon_view_new_with_model (Hildon.UIMode.NORMAL, store); + var iconview = (Gtk.IconView) Hildon.gtk_icon_view_new (Hildon.UIMode.NORMAL); iconview.set_column_spacing (0); iconview.set_pixbuf_column (MovieListStore.Columns.POSTER); iconview.margin = 0; @@ -247,8 +264,6 @@ public class MovieListView : PannableArea { // TODO: after scrolling down 80% of the list, load more // results if available. - int last_a = 0; - int last_b = 0; private void on_adjustment_value_changed () { if (more_movies_available) { var vadj = get_vadjustment (); -- 1.7.9.5