Movie list view: poster update on row-inserted signal
[cinaest] / src / movie-list-view.vala
index 0b695cf..9bf23f3 100644 (file)
@@ -191,6 +191,7 @@ public class MovieListView : PannableArea {
                tree.row_activated.connect (on_row_activated);
                icons.item_activated.connect (on_item_activated);
                store.row_changed.connect (on_row_changed);
+               store.row_inserted.connect (on_row_changed);
                store.search_finished.connect (on_search_finished);
        }
 
@@ -307,23 +308,33 @@ public class MovieListView : PannableArea {
                for (int i = a; i <= b; i++) {
                        var path = new TreePath.from_indices (i);
                        TreeIter iter;
-                       if (store.get_iter (out iter, path)) {
-                               Movie movie;
-                               store.get (iter, MovieListStore.Columns.MOVIE, out movie);
-                               if (movie != null) {
-                                       if (poster_mode_) {
-                                               if (movie.poster == null || movie.poster.small == null) try {
-                                                       poster_factory.queue_thumbnail (movie, Poster.SMALL_WIDTH, Poster.SMALL_HEIGHT, false, receive_poster_small);
-                                               } catch (Error e) {
-                                                       warning ("Failed to queue poster request: %s\n", e.message);
-                                               }
-                                       } else {
-                                               if (movie.poster == null || movie.poster.icon == null) try {
-                                                       poster_factory.queue_thumbnail (movie, Poster.ICON_WIDTH, Poster.ICON_HEIGHT, false, receive_poster_icon);
-                                               } catch (Error e) {
-                                                       warning ("Failed to queue poster request: %s\n", e.message);
-                                               }
-                                       }
+                       if (!store.get_iter (out iter, path))
+                               continue;
+
+                       Movie movie;
+                       store.get (iter, MovieListStore.Columns.MOVIE, out movie);
+                       if (movie == null)
+                               continue;
+
+                       if (poster_mode_) {
+                               if (movie.poster == null || movie.poster.small == null) try {
+                                       poster_factory.queue (movie,
+                                                             Poster.SMALL_WIDTH,
+                                                             Poster.SMALL_HEIGHT,
+                                                             true,
+                                                             receive_poster_small);
+                               } catch (Error e) {
+                                       warning ("Failed to queue poster request: %s\n", e.message);
+                               }
+                       } else {
+                               if (movie.poster == null || movie.poster.icon == null) try {
+                                       poster_factory.queue (movie,
+                                                             Poster.ICON_WIDTH,
+                                                             Poster.ICON_HEIGHT,
+                                                             true,
+                                                             receive_poster_icon);
+                               } catch (Error e) {
+                                       warning ("Failed to queue poster request: %s\n", e.message);
                                }
                        }
                }
@@ -373,6 +384,7 @@ public class MovieListView : PannableArea {
                else
                        poster = new Poster ();
                poster.small = pixbuf;
+               // Notify store of the poster change
                movie.poster = poster;
        }
 
@@ -383,6 +395,7 @@ public class MovieListView : PannableArea {
                else
                        poster = new Poster ();
                poster.icon = pixbuf;
+               // Notify store of the poster change
                movie.poster = poster;
        }