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 {
24 private MovieMenu menu;
25 private Gdk.Pixbuf no_poster;
26 private MoviePoster.Factory poster_factory;
29 public MovieWindow.with_movie (Movie movie_) {
31 set_title (movie.title);
34 menu = new MovieMenu (movie);
40 image.set_size_request (268, 424);
42 if (movie.poster != null && movie.poster.pixbuf != null) {
43 image.pixbuf = movie.poster.pixbuf;
45 movie.notify.connect (this.on_movie_changed);
46 if (movie.poster != null && movie.poster.thumbnail != null) {
48 image.pixbuf = movie.poster.thumbnail.scale_simple (244, 400, Gdk.InterpType.BILINEAR);
51 if (no_poster == null) try {
52 no_poster = new Gdk.Pixbuf.from_file ("/usr/share/icons/hicolor/124x124/hildon/general_video.png");
54 critical ("Missing general_video icon: %s\n", e.message);
56 image.pixbuf = no_poster;
59 poster_factory = MoviePoster.Factory.get_instance ();
60 poster_factory.queue (movie, receive_poster);
62 warning ("Failed to queue poster request: %s\n", e.message);
67 string genres = movie.genres.to_string ();
68 string year = movie.year > 0 ? " (%d)".printf (movie.year) : "";
69 string text = "<b>%s</b>%s".printf (genres, year);
71 var label = new Label (text);
73 label.use_markup = true;
74 label.set_alignment (0.0f, 0.0f);
76 var hbox = new HBox (false, 0);
77 hbox.pack_start (image, false, true, 0);
78 hbox.pack_start (label, true, true, MARGIN_DOUBLE);
80 var vbox = new VBox (false, 0);
81 vbox.pack_start (hbox, true, true, MARGIN_DOUBLE);
86 private void receive_poster (Gdk.Pixbuf pixbuf, Movie movie) {
87 var poster = new Poster();
89 poster.pixbuf = pixbuf;
90 if (movie.poster != null)
91 poster.thumbnail = movie.poster.thumbnail;
92 movie.poster = poster;
95 private void on_movie_changed (GLib.Object source, GLib.ParamSpec spec) {
96 var movie = (Movie) source;
98 if ((spec.name == "poster") && (movie.poster != null) && (movie.poster.pixbuf != null)) {
99 image.pixbuf = movie.poster.pixbuf;