X-Git-Url: https://vcs.maemo.org/git/?a=blobdiff_plain;f=src%2Fmovie-list-window.vala;h=c4f992ba69c440bcb7c9d53ff8845bc1b144f74e;hb=6819b07617e7a7bb5c8eed272abc9c5deddb66c2;hp=0765af12d61d1e9beab66adf4aa7d74e8085412f;hpb=33b60d8785c0d02593e3541972cb144d46611f9a;p=cinaest diff --git a/src/movie-list-window.vala b/src/movie-list-window.vala index 0765af1..c4f992b 100644 --- a/src/movie-list-window.vala +++ b/src/movie-list-window.vala @@ -34,6 +34,7 @@ public class MovieListWindow : StackableWindow { private Alignment alignment; private int count; private MovieSource source; + private bool portrait_mode; public MovieListWindow (MovieSource source_) { source = source_; @@ -68,7 +69,7 @@ public class MovieListWindow : StackableWindow { // Movie list - connected to menu for sorting movie_list = new MovieListView (this, source.get_name () == _("Watched movies")); - menu.sortable = movie_list.store; + menu.store = movie_list.store; store = movie_list.store; store.source = source; @@ -84,8 +85,11 @@ public class MovieListWindow : StackableWindow { alignment = new Alignment (0.0f, 0.0f, 1.0f, 1.0f); alignment.top_padding = MARGIN_HALF; - alignment.left_padding = MARGIN_DOUBLE; - alignment.right_padding = MARGIN_DOUBLE; + + // Reduced padding in portrait mode to fit 3 posters in width + int padding = portrait_mode ? MARGIN_DEFAULT : MARGIN_DOUBLE; + alignment.left_padding = padding; + alignment.right_padding = padding; alignment.add (vbox); add (alignment); @@ -103,6 +107,7 @@ public class MovieListWindow : StackableWindow { movie_list.movie_activated.connect (on_movie_activated); store.row_deleted.connect (on_row_deleted); store.row_inserted.connect (on_row_inserted); + Gdk.Screen.get_default ().size_changed.connect (on_orientation_changed); store.search_finished.connect (on_search_finished); store.notify["update-running"].connect (on_update_running_changed); @@ -173,7 +178,10 @@ public class MovieListWindow : StackableWindow { return; } - var dialog = new Note.confirmation (this, _("Delete %d movies?").printf (count)); + var dialog = new Note.confirmation (this, + ngettext ("Delete %d movie?", + "Delete %d movies?", + count).printf (count)); var res = dialog.run (); if (res == Gtk.ResponseType.OK) { @@ -236,11 +244,45 @@ public class MovieListWindow : StackableWindow { return false; } + private void on_orientation_changed (Gdk.Screen screen) { + if (CinaestProgram.orientation.portrait == portrait_mode) + return; + + portrait_mode = CinaestProgram.orientation.portrait; + + // Reduced padding in portrait mode to fit 3 posters in width + int padding = portrait_mode ? MARGIN_DEFAULT : MARGIN_DOUBLE; + alignment.left_padding = padding; + + // Make space for the pannable area's scroll position indicator + if (count > movies_per_screen ()) + padding -= MARGIN_DEFAULT; + alignment.right_padding = padding; + } + private void on_search_finished (int movies) { - if (movies > 6) - alignment.right_padding = MARGIN_DEFAULT; - else - alignment.right_padding = MARGIN_DOUBLE; + int padding = portrait_mode ? MARGIN_DEFAULT : MARGIN_DOUBLE; + + // Make space for the pannable area's scroll position indicator + if (count > movies_per_screen ()) + padding -= MARGIN_DEFAULT; + alignment.right_padding = padding; + } + + private int movies_per_screen () { + if (portrait_mode) { + // 3x3 full posters or 10 full list items, + // 10 full list items in list mode without search bar + return (search_bar_visible || movie_list.poster_mode) ? 9 : 10; + } else { + if (search_bar_visible) { + // 5x1 full posters or 5 list items + return 5; + } else { + // 5x2 posters or 6 list items + return movie_list.poster_mode ? 10 : 6; + } + } } private void on_movie_activated (Movie movie) {