From: Philipp Zabel Date: Tue, 5 Jan 2010 18:37:10 +0000 (+0100) Subject: Movie window: add basic orientation awareness X-Git-Tag: v0.0.9~3 X-Git-Url: http://vcs.maemo.org/git/?a=commitdiff_plain;h=8c67addb1869bdcad0782a5c3b2d3d6d50ad7df9;p=cinaest Movie window: add basic orientation awareness Also remove size request on image, which is needed for portrait mode. --- diff --git a/src/main.vala b/src/main.vala index 0b9f0eb..752997c 100644 --- a/src/main.vala +++ b/src/main.vala @@ -21,7 +21,7 @@ using Hildon; public class CinaestProgram : Hildon.Program { SourceListWindow window; public static List plugins; - private Orientation orientation; + public static Orientation orientation; construct { Environment.set_application_name ("Cinæst"); diff --git a/src/movie-list-window.vala b/src/movie-list-window.vala index e545244..1bcc7ec 100644 --- a/src/movie-list-window.vala +++ b/src/movie-list-window.vala @@ -207,8 +207,8 @@ public class MovieListWindow : StackableWindow { private void on_movie_activated (Movie movie) { var window = new MovieWindow.with_movie (movie, store); - window.show_all (); + window.show (); } private void on_update_running_changed (GLib.Object source, ParamSpec spec) { diff --git a/src/movie-window.vala b/src/movie-window.vala index 1eecbd4..42d6f74 100644 --- a/src/movie-window.vala +++ b/src/movie-window.vala @@ -23,7 +23,11 @@ public class MovieWindow : StackableWindow { private MovieMenu menu; private Gdk.Pixbuf no_poster; private MoviePoster.Factory poster_factory; + private HBox landscape; + private VBox portrait; private Image image; + private Label label; + private bool portrait_mode; public MovieWindow.with_movie (Movie movie, MovieListStore store) { set_title (movie.title); @@ -35,7 +39,6 @@ public class MovieWindow : StackableWindow { // Poster image = new Image (); - image.set_size_request (268, 424); if (movie.poster != null && movie.poster.pixbuf != null) { image.pixbuf = movie.poster.pixbuf; @@ -66,22 +69,33 @@ public class MovieWindow : StackableWindow { string year = movie.year > 0 ? " (%d)".printf (movie.year) : ""; string text = "%s%s".printf (genres, year); - var label = new Label (text); + label = new Label (text); label.wrap = true; label.use_markup = true; label.set_alignment (0.0f, 0.0f); - var hbox = new HBox (false, 0); - hbox.pack_start (image, false, true, 0); - hbox.pack_start (label, true, true, MARGIN_DOUBLE); + landscape = new HBox (false, 0); + portrait = new VBox (false, 0); var vbox = new VBox (false, 0); - vbox.pack_start (hbox, true, true, MARGIN_DOUBLE); + vbox.pack_start (landscape, true, true, MARGIN_DOUBLE); + vbox.pack_start (portrait, true, true, MARGIN_DOUBLE); + portrait_mode = CinaestProgram.orientation.portrait; + if (portrait_mode) { + portrait.pack_start (image, false, false, 0); + portrait.pack_start (label, true, true, MARGIN_DOUBLE); + } else { + landscape.pack_start (image, false, true, 0); + landscape.pack_start (label, true, true, MARGIN_DOUBLE); + } + + vbox.show_all (); add (vbox); // Connect signals menu.movie_deleted.connect (() => { destroy (); }); + Gdk.Screen.get_default ().size_changed.connect (on_orientation_changed); } private void receive_poster (Gdk.Pixbuf pixbuf, Movie movie) { @@ -100,5 +114,23 @@ public class MovieWindow : StackableWindow { image.pixbuf = movie.poster.pixbuf; } } + + private void on_orientation_changed (Gdk.Screen screen) { + if (CinaestProgram.orientation.portrait == portrait_mode) + return; + + portrait_mode = CinaestProgram.orientation.portrait; + if (portrait_mode) { + landscape.remove (label); + landscape.remove (image); + portrait.pack_start (image, false, false, 0); + portrait.pack_start (label, true, true, MARGIN_DOUBLE); + } else { + portrait.remove (label); + portrait.remove (image); + landscape.pack_start (image, false, true, 0); + landscape.pack_start (label, true, true, MARGIN_DOUBLE); + } + } }