Movie list view: add poster view mode, shows a 5x2 poster grid
[cinaest] / src / movie-list-store.vala
index 852690f..cd26e0e 100644 (file)
@@ -24,6 +24,7 @@ public class MovieListStore : ListStore, TreeModel {
                YEAR,
                RATING,
                POSTER,
+               ICON,
                MOVIE,
                MARKUP,
                N_COLUMNS
@@ -33,6 +34,7 @@ public class MovieListStore : ListStore, TreeModel {
                typeof (int),
                typeof (string),
                typeof (Gdk.Pixbuf),
+               typeof (Gdk.Pixbuf),
                typeof (Movie),
                typeof (string)
        };
@@ -182,16 +184,25 @@ public class MovieListStore : ListStore, TreeModel {
                foreach (Movie movie in movies) {
                        add (movie, out iter);
                        try {
-                               poster_factory.queue_thumbnail (movie, 64, 64, false, receive_poster_thumbnail);
+                               poster_factory.queue_thumbnail (movie, Poster.ICON_WIDTH, Poster.ICON_HEIGHT, false, receive_poster_icon);
+                               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);
                        }
                }
        }
 
-       private void receive_poster_thumbnail (Gdk.Pixbuf pixbuf, Movie movie) {
+       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 ();
-               poster.thumbnail = pixbuf;
+               if (movie.poster != null && movie.poster.icon != null)
+                       poster.icon = movie.poster.icon;
+               poster.small = pixbuf;
                movie.poster = poster;
        }
 
@@ -247,8 +258,15 @@ public class MovieListStore : ListStore, TreeModel {
                        break;
 
                case Columns.POSTER:
-                       if ((movie.poster != null) && (movie.poster.thumbnail != null))
-                               value.set_object (movie.poster.thumbnail);
+                       if ((movie.poster != null) && (movie.poster.small != null))
+                               value.set_object (movie.poster.small);
+                       else
+                               value.set_object (no_poster);
+                       break;
+
+               case Columns.ICON:
+                       if ((movie.poster != null) && (movie.poster.icon != null))
+                               value.set_object (movie.poster.icon);
                        else
                                value.set_object (no_poster);
                        break;