Movie list window: make the "more movies available" warning less obtrusive
authorPhilipp Zabel <philipp.zabel@gmail.com>
Sat, 10 Jul 2010 19:23:57 +0000 (21:23 +0200)
committerPhilipp Zabel <philipp.zabel@gmail.com>
Wed, 14 Jul 2010 21:34:09 +0000 (23:34 +0200)
Instead of showing it immediately, only show it after scrolling down 80%
of the list. In the future, this could load more results instead, as the
Conversations program does.

src/movie-list-view.vala
src/movie-list-window.vala

index e0d1ad3..e41e0cc 100644 (file)
@@ -24,6 +24,8 @@ public class MovieListView : PannableArea {
        TreeView tree;
        public TreeSortable sorted_store;
 
+       private bool more_movies_available;
+
        public signal void movie_activated (Movie movie);
 
        public MovieListView (Gtk.Window window) {
@@ -126,7 +128,9 @@ public class MovieListView : PannableArea {
                tree.append_column (rating_column);
 
                // Connect signals
+               get_vadjustment ().value_changed.connect (on_adjustment_value_changed);
                tree.row_activated.connect (on_row_activated);
+               store.search_finished.connect (on_search_finished);
        }
 
        public void set_hildon_ui_mode (UIMode mode) {
@@ -145,6 +149,18 @@ public class MovieListView : PannableArea {
                return tree.get_selection ();
        }
 
+       // TODO: after scrolling down 80% of the list, load more
+       //       results if available.
+       private void on_adjustment_value_changed () {
+               if (more_movies_available) {
+                       var vadj = get_vadjustment ();
+                       if (vadj.value > 0.8 * vadj.upper) {
+                               Banner.show_information (this, null, _("More results available - refine search to reduce the dataset"));
+                               more_movies_available = false;
+                       }
+               }
+       }
+
        private void on_row_activated (TreeView tree, TreePath path_, TreeViewColumn column) {
                TreePath path = path_.copy (); // FIXME - calling model.get_iter with path_ directly causes a C qualifier warning
                TreeModel model = tree.model;
@@ -157,6 +173,10 @@ public class MovieListView : PannableArea {
                }
        }
 
+       private void on_search_finished (int movies) {
+               more_movies_available = (movies > 100); // FIXME
+       }
+
        private void vbox_data_func (CellLayout cell_layout, CellRenderer cell, TreeModel model, TreeIter iter) {
                Movie movie;
                CellRendererText renderer;
index a723ac4..bc415e1 100644 (file)
@@ -231,9 +231,6 @@ public class MovieListWindow : StackableWindow {
                        alignment.right_padding = MARGIN_DEFAULT;
                else
                        alignment.right_padding = MARGIN_DOUBLE;
-               if (movies > 100) {
-                       Banner.show_information (this, null, _("More results available - refine search to reduce the dataset"));
-               }
        }
 
        private void on_movie_activated (Movie movie) {