Movie list menu: use hildon-fm-2 file chooser dialog to import files
[cinaest] / src / movie-list-store.vala
index b7c85e2..52a3c3d 100644 (file)
@@ -49,6 +49,7 @@ public class MovieListStore : ListStore, TreeModel {
        public bool update_running { get; set; }
        public string year_markup = "<span size=\"small\">[%d]</span>";
        private Cancellable cancellable;
+       public Widget view;
 
        public signal void search_finished (int movies);
 
@@ -80,16 +81,25 @@ public class MovieListStore : ListStore, TreeModel {
                        markup.append_printf (year_markup, movie.year);
                }
 
-               append (out iter1);
-               base.set (iter1, 0, movie,
-                                1, markup.str,
-                                2, (movie.rating >= 0) ? "%d.%d".printf (movie.rating / 10, movie.rating % 10) : null);
+               base.insert_with_values (out iter1, -1,
+                                        0, movie,
+                                        1, markup.str,
+                                        2, rating_string (movie.rating));
 
                movie.notify.connect (this.on_movie_changed);
 
                iter = iter1;
        }
 
+       private string? rating_string (int rating) {
+               if (rating >= 0) {
+                       return "%d.%d".printf (rating / 10,
+                                              rating % 10);
+               } else {
+                       return null;
+               }
+       }
+
        public new bool remove (Movie movie) {
                TreeIter iter;
 
@@ -181,8 +191,10 @@ public class MovieListStore : ListStore, TreeModel {
                if (cancellable.is_cancelled ())
                        return;
 
+               view.freeze_child_notify ();
                foreach (Movie movie in movies)
                        add (movie, out iter);
+               view.thaw_child_notify ();
        }
 
        private void receive_poster_icon (Gdk.Pixbuf pixbuf, Movie movie) {