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;
26 private HBox landscape;
27 private VBox portrait;
30 private bool portrait_mode;
32 public MovieWindow.with_movie (Movie movie, MovieListStore store) {
33 set_title (movie.title);
36 menu = new MovieMenu (movie, store, this);
43 if (movie.poster != null && movie.poster.pixbuf != null) {
44 image.pixbuf = movie.poster.pixbuf;
46 movie.notify.connect (this.on_movie_changed);
47 if (movie.poster != null && movie.poster.thumbnail != null) {
49 image.pixbuf = movie.poster.thumbnail.scale_simple (268, 424, Gdk.InterpType.BILINEAR);
52 if (no_poster == null) try {
53 no_poster = new Gdk.Pixbuf.from_file ("/usr/share/icons/hicolor/124x124/hildon/general_video.png");
55 critical ("Missing general_video icon: %s\n", e.message);
57 image.pixbuf = no_poster;
60 poster_factory = MoviePoster.Factory.get_instance ();
61 poster_factory.queue (movie, receive_poster);
63 warning ("Failed to queue poster request: %s\n", e.message);
68 string genres = movie.genres.to_string ();
69 string year = movie.year > 0 ? " (%d)".printf (movie.year) : "";
70 string text = "<b>%s</b>%s".printf (genres, year);
72 label = new Label (text);
74 label.use_markup = true;
75 label.set_alignment (0.0f, 0.0f);
77 landscape = new HBox (false, 0);
78 portrait = new VBox (false, 0);
80 var vbox = new VBox (false, 0);
81 vbox.pack_start (landscape, true, true, MARGIN_DOUBLE);
82 vbox.pack_start (portrait, true, true, MARGIN_DOUBLE);
84 portrait_mode = CinaestProgram.orientation.portrait;
86 portrait.pack_start (image, false, false, 0);
87 portrait.pack_start (label, true, true, MARGIN_DOUBLE);
89 landscape.pack_start (image, false, true, 0);
90 landscape.pack_start (label, true, true, MARGIN_DOUBLE);
97 menu.movie_deleted.connect (() => { destroy (); });
98 Gdk.Screen.get_default ().size_changed.connect (on_orientation_changed);
101 private void receive_poster (Gdk.Pixbuf pixbuf, Movie movie) {
102 var poster = new Poster();
104 poster.pixbuf = pixbuf;
105 if (movie.poster != null)
106 poster.thumbnail = movie.poster.thumbnail;
107 movie.poster = poster;
110 private void on_movie_changed (GLib.Object source, GLib.ParamSpec spec) {
111 var movie = (Movie) source;
113 if ((spec.name == "poster") && (movie.poster != null) && (movie.poster.pixbuf != null)) {
114 image.pixbuf = movie.poster.pixbuf;
118 private void on_orientation_changed (Gdk.Screen screen) {
119 if (CinaestProgram.orientation.portrait == portrait_mode)
122 portrait_mode = CinaestProgram.orientation.portrait;
124 landscape.remove (label);
125 landscape.remove (image);
126 portrait.pack_start (image, false, false, 0);
127 portrait.pack_start (label, true, true, MARGIN_DOUBLE);
129 portrait.remove (label);
130 portrait.remove (image);
131 landscape.pack_start (image, false, true, 0);
132 landscape.pack_start (label, true, true, MARGIN_DOUBLE);