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;
29 private PannableArea pannable;
31 private bool portrait_mode;
33 public MovieWindow.with_movie (Movie movie, MovieListStore store) {
34 set_title (movie.title);
37 menu = new MovieMenu (movie, store, this);
44 if (movie.poster != null && movie.poster.pixbuf != null) {
45 image.pixbuf = movie.poster.pixbuf;
47 movie.notify.connect (this.on_movie_changed);
48 if (movie.poster != null && movie.poster.thumbnail != null) {
50 image.pixbuf = movie.poster.thumbnail.scale_simple (268, 424, Gdk.InterpType.BILINEAR);
53 if (no_poster == null) try {
54 no_poster = new Gdk.Pixbuf.from_file ("/usr/share/icons/hicolor/124x124/hildon/general_video.png");
56 critical ("Missing general_video icon: %s\n", e.message);
58 image.pixbuf = no_poster;
61 poster_factory = MoviePoster.Factory.get_instance ();
62 poster_factory.queue (movie, receive_poster);
64 warning ("Failed to queue poster request: %s\n", e.message);
69 string year = movie.year > 0 ? " (%d)".printf (movie.year) : "";
70 string text = "<big><b>%s</b></big>%s\n<small>%s</small>".printf (movie.title, year, movie.secondary);
71 var label = new Label (text);
73 label.use_markup = true;
74 label.set_alignment (0.0f, 0.0f);
76 var header = new HBox (false, 0);
77 header.pack_start (label, true, true, 0);
78 if (movie.rating > 0) {
79 text = "<big><b>%d.%d</b></big>".printf (movie.rating / 10, movie.rating % 10);
80 var rating = new Label (text);
81 rating.use_markup = true;
82 rating.set_alignment (0.5f, 0.0f);
83 header.pack_start (rating, false, false, MARGIN_DOUBLE);
86 plot = new Label (movie.get_plot ());
88 plot.set_alignment (0.0f, 0.0f);
90 details = new VBox (false, MARGIN_DOUBLE);
91 details.pack_start (header, false, false, 0);
92 details.pack_start (plot, false, false, 0);
94 var pannable = new PannableArea ();
95 var eventbox = new EventBox ();
96 eventbox.add (details);
97 eventbox.above_child = true;
98 pannable.add_with_viewport (eventbox);
100 hbox = new HBox (false, 0);
101 hbox.pack_start (pannable, true, true, 0);
103 portrait_mode = CinaestProgram.orientation.portrait;
105 details.pack_start (image, false, false, 0);
106 details.reorder_child (image, 0);
107 plot.set_size_request (480 - 2 * MARGIN_DOUBLE, -1);
109 hbox.pack_start (image, false, false, MARGIN_DOUBLE);
110 hbox.reorder_child (image, 0);
111 plot.set_size_request (800 - 268 /* image */ - 3 * MARGIN_DOUBLE, -1);
112 pannable.set_size_request (-1, 424);
119 menu.movie_deleted.connect (() => { destroy (); });
120 Gdk.Screen.get_default ().size_changed.connect (on_orientation_changed);
123 private void receive_poster (Gdk.Pixbuf pixbuf, Movie movie) {
124 var poster = new Poster();
126 poster.pixbuf = pixbuf;
127 if (movie.poster != null)
128 poster.thumbnail = movie.poster.thumbnail;
129 movie.poster = poster;
132 private void on_movie_changed (GLib.Object source, GLib.ParamSpec spec) {
133 var movie = (Movie) source;
135 if ((spec.name == "poster") && (movie.poster != null) && (movie.poster.pixbuf != null)) {
136 image.pixbuf = movie.poster.pixbuf;
140 private void on_orientation_changed (Gdk.Screen screen) {
141 if (CinaestProgram.orientation.portrait == portrait_mode)
144 portrait_mode = CinaestProgram.orientation.portrait;
147 details.pack_start (image, false, false, 0);
148 details.reorder_child (image, 0);
149 plot.set_size_request (480 - 2 * MARGIN_DOUBLE, -1);
150 pannable.set_size_request (-1, -1);
152 details.remove (image);
153 hbox.pack_start (image, false, false, MARGIN_DOUBLE);
154 hbox.reorder_child (image, 0);
155 pannable.set_size_request (-1, 424);
156 plot.set_size_request (800 - 268 /* image */ - 3 * MARGIN_DOUBLE, -1);