1 /* This file is part of Cinaest.
3 * Copyright (C) 2009 Philipp Zabel
5 * Cinaest is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation, either version 3 of the License, or
8 * (at your option) any later version.
10 * Cinaest is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with Cinaest. If not, see <http://www.gnu.org/licenses/>.
22 public class MovieWindow : StackableWindow {
23 private MovieMenu menu;
24 private Gdk.Pixbuf no_poster;
25 private MoviePoster.Factory poster_factory;
28 public MovieWindow.with_movie (Movie movie, MovieListStore store) {
29 set_title (movie.title);
32 menu = new MovieMenu (movie);
38 image.set_size_request (268, 424);
40 if (movie.poster != null && movie.poster.pixbuf != null) {
41 image.pixbuf = movie.poster.pixbuf;
43 movie.notify.connect (this.on_movie_changed);
44 if (movie.poster != null && movie.poster.thumbnail != null) {
46 image.pixbuf = movie.poster.thumbnail.scale_simple (244, 400, Gdk.InterpType.BILINEAR);
49 if (no_poster == null) try {
50 no_poster = new Gdk.Pixbuf.from_file ("/usr/share/icons/hicolor/124x124/hildon/general_video.png");
52 critical ("Missing general_video icon: %s\n", e.message);
54 image.pixbuf = no_poster;
57 poster_factory = MoviePoster.Factory.get_instance ();
58 poster_factory.queue (movie, receive_poster);
60 warning ("Failed to queue poster request: %s\n", e.message);
65 string genres = movie.genres.to_string ();
66 string year = movie.year > 0 ? " (%d)".printf (movie.year) : "";
67 string text = "<b>%s</b>%s".printf (genres, year);
69 var label = new Label (text);
71 label.use_markup = true;
72 label.set_alignment (0.0f, 0.0f);
74 var hbox = new HBox (false, 0);
75 hbox.pack_start (image, false, true, 0);
76 hbox.pack_start (label, true, true, MARGIN_DOUBLE);
78 var vbox = new VBox (false, 0);
79 vbox.pack_start (hbox, true, true, MARGIN_DOUBLE);
84 private void receive_poster (Gdk.Pixbuf pixbuf, Movie movie) {
85 var poster = new Poster();
87 poster.pixbuf = pixbuf;
88 if (movie.poster != null)
89 poster.thumbnail = movie.poster.thumbnail;
90 movie.poster = poster;
93 private void on_movie_changed (GLib.Object source, GLib.ParamSpec spec) {
94 var movie = (Movie) source;
96 if ((spec.name == "poster") && (movie.poster != null) && (movie.poster.pixbuf != null)) {
97 image.pixbuf = movie.poster.pixbuf;