if (cancellable.is_cancelled ())
return;
- foreach (Movie movie in movies) {
+ foreach (Movie movie in movies)
add (movie, out iter);
- try {
- 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_icon (Gdk.Pixbuf pixbuf, Movie movie) {
public virtual void get_value (TreeIter iter, int column, out GLib.Value value) {
Movie movie;
- // FIXME
- if (no_poster == null) try {
- no_poster = new Gdk.Pixbuf.from_file ("/usr/share/icons/hicolor/64x64/hildon/general_video.png");
- } catch (Error e) {
- critical ("Missing general_video icon: %s\n", e.message);
- }
-
return_if_fail (column >= 0 && column < Columns.N_COLUMNS);
// Get the Movie from our parent's storage
break;
case Columns.POSTER:
- if ((movie.poster != null) && (movie.poster.small != null))
+ if ((movie.poster != null) && (movie.poster.small != null)) {
value.set_object (movie.poster.small);
- else
+ } else {
+ // FIXME
+ if (no_poster == null) try {
+ // var no_pic = new Gdk.Pixbuf.from_file ("/usr/share/icons/hicolor/64x64/hildon/imageviewer_no_pic.png");
+ var no_pic = new Gdk.Pixbuf.from_file ("/usr/share/icons/hicolor/64x64/hildon/general_no_thumbnail.png");
+ no_poster = new Gdk.Pixbuf (Gdk.Colorspace.RGB, true, 8, Poster.SMALL_WIDTH, Poster.SMALL_HEIGHT);
+ no_poster.fill (0);
+ no_pic.copy_area (0, 0, no_pic.width, no_pic.height, no_poster,
+ (Poster.SMALL_WIDTH - no_pic.width) / 2, (Poster.SMALL_HEIGHT - no_pic.height) / 2);
+ } catch (Error e) {
+ critical ("Missing general_video icon: %s\n", e.message);
+ }
value.set_object (no_poster);
+ }
break;
case Columns.ICON:
- if ((movie.poster != null) && (movie.poster.icon != null))
+ if ((movie.poster != null) && (movie.poster.icon != null)) {
value.set_object (movie.poster.icon);
- else
- value.set_object (no_poster);
+ } else {
+ value.set_object (null);
+ }
break;
case Columns.MOVIE:
private CellRendererText secondary_renderer;
private CellRendererText rating_renderer;
private CellRendererText date_renderer;
+ private MoviePoster.Factory poster_factory;
private bool poster_mode_;
public bool poster_mode {
get_vadjustment ().value_changed.connect (on_adjustment_value_changed);
tree.row_activated.connect (on_row_activated);
icons.item_activated.connect (on_item_activated);
+ store.row_changed.connect (on_row_changed);
store.search_finished.connect (on_search_finished);
}
construct {
hscrollbar_policy = Gtk.PolicyType.NEVER;
+
+ poster_factory = MoviePoster.Factory.get_instance ();
}
public void set_hildon_ui_mode (UIMode mode) {
// TODO: after scrolling down 80% of the list, load more
// results if available.
+ int last_a = 0;
+ int last_b = 0;
private void on_adjustment_value_changed () {
if (more_movies_available) {
var vadj = get_vadjustment ();
more_movies_available = false;
}
}
+
+ TreePath a_;
+ TreePath b_;
+ bool range;
+ if (poster_mode_) {
+ range = icons.get_visible_range (out a_, out b_);
+ } else {
+ range = tree.get_visible_range (out a_, out b_);
+ }
+ if (range) {
+ // We know the list store is flat
+ int a = a_.get_indices ()[0];
+ int b = b_.get_indices ()[0];
+ assert (a <= b);
+
+ if (a == last_a && b == last_b)
+ return;
+
+ if (a > last_b || b < last_a) {
+ check_posters (a, b);
+ } else if (a >= last_a && b > last_b) {
+ check_posters (last_b + 1, b);
+ } else if (b <= last_b && a < last_a) {
+ check_posters (a, last_a - 1);
+ }
+
+ last_a = a;
+ last_b = b;
+ }
+ }
+
+ private void check_posters (int a, int b) {
+ 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);
+ }
+ }
+ }
+ }
+ }
}
private void on_row_activated (TreeView tree, TreePath path, TreeViewColumn column) {
}
}
+ private void on_row_changed (TreePath path, TreeIter iter) {
+ TreePath a;
+ TreePath b;
+ bool range;
+
+ if (poster_mode_) {
+ range = icons.get_visible_range (out a, out b);
+ } else {
+ range = tree.get_visible_range (out a, out b);
+ }
+ if (!range ||
+ (range && path.compare (a) >= 0 && path.compare (b) <= 0)) {
+ Movie movie;
+
+ store.get (iter, MovieListStore.Columns.MOVIE, out movie);
+ if (movie == null)
+ return;
+
+ int i = path.get_indices ()[0];
+ check_posters (i, i);
+ }
+ }
+
+ private void receive_poster_small (Gdk.Pixbuf pixbuf, Movie movie) {
+ Poster poster;
+ if (movie.poster != null)
+ poster = movie.poster;
+ else
+ poster = new Poster ();
+ poster.small = pixbuf;
+ movie.poster = poster;
+ }
+
+ private void receive_poster_icon (Gdk.Pixbuf pixbuf, Movie movie) {
+ Poster poster;
+ if (movie.poster != null)
+ poster = movie.poster;
+ else
+ poster = new Poster ();
+ poster.icon = pixbuf;
+ movie.poster = poster;
+ }
+
private void on_search_finished (int movies) {
more_movies_available = (movies > 100); // FIXME
}