Movie list store: remove poster loading leftovers
[cinaest] / src / movie-list-store.vala
index b7c85e2..d30105c 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,24 +191,12 @@ 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) {
-               var poster = new Poster ();
-               poster.icon = pixbuf;
-               movie.poster = poster;
-       }
-
-       private void receive_poster_small (Gdk.Pixbuf pixbuf, Movie movie) {
-               var poster = new Poster ();
-               if (movie.poster != null && movie.poster.icon != null)
-                       poster.icon = movie.poster.icon;
-               poster.small = pixbuf;
-               movie.poster = poster;
-       }
-
        // Implement TreeModel interface
        public virtual GLib.Type get_column_type (int index_) {
                return_val_if_fail (index_ >= 0 && index_ < Columns.N_COLUMNS, 0);