X-Git-Url: http://vcs.maemo.org/git/?a=blobdiff_plain;f=src%2Fmovie-list-window.vala;h=5d702ef3fd1855721f1c60ecf4b4df7aeee2403e;hb=46d20e0c5a837fd0f54b357f4f3ed704d098d94d;hp=acc9bce375aeb87ad923e31decd38829fc87e2f7;hpb=a0bcf1e4d6b7f4cbba2cd7d16be74c5499194f01;p=cinaest diff --git a/src/movie-list-window.vala b/src/movie-list-window.vala index acc9bce..5d702ef 100644 --- a/src/movie-list-window.vala +++ b/src/movie-list-window.vala @@ -34,10 +34,11 @@ public class MovieListWindow : StackableWindow { private Alignment alignment; private int count; private MovieSource source; + private bool portrait_mode; public MovieListWindow (MovieSource source_) { source = source_; - set_title (source.get_description ()); + set_title (source.get_name ()); // View menu menu = new MovieListMenu (this); @@ -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); @@ -118,7 +123,7 @@ public class MovieListWindow : StackableWindow { filter = new MovieFilter (); menu.filter = filter; filter.title = ""; - if (SourceFlags.ONLINE in source.get_flags ()) { + if (SourceFlags.NOEMPTY in source.get_flags ()) { no_movies.hide (); search_bar_visible = true; search_bar.show (); @@ -147,10 +152,10 @@ public class MovieListWindow : StackableWindow { markup.prepend ("".printf (color.to_string ())); markup.append (""); } - markup.prepend (source.get_description ()); + markup.prepend (source.get_name ()); set_markup (markup.str); } else { - set_markup (source.get_description ()); + set_markup (source.get_name ()); } start_search (); @@ -161,13 +166,12 @@ public class MovieListWindow : StackableWindow { edit_toolbar.show (); movie_list.set_hildon_ui_mode (UIMode.EDIT); - var selection = movie_list.get_selection (); - selection.unselect_all (); + movie_list.unselect_all (); } private void on_delete_button_clicked () { - var selection = movie_list.get_selection (); - int count = selection.count_selected_rows (); + var movies = movie_list.get_selected_movies (); + int count = (int) movies.length (); if (count == 0) { Banner.show_information (this, null, _("No movies selected")); leave_edit_mode (); @@ -178,25 +182,7 @@ public class MovieListWindow : StackableWindow { var res = dialog.run (); if (res == Gtk.ResponseType.OK) { - weak TreeModel model; - var rows = selection.get_selected_rows (out model); - - var movies = new List (); - - // get selected movies from the store - foreach (TreePath path in rows) { - TreeIter iter; - - if (model.get_iter (out iter, path)) { - Movie movie; - - model.get (iter, MovieListStore.Columns.MOVIE, out movie); - if (movie != null) { - movies.append (movie); - } - } - } - // and remove them + // Remove selected movies foreach (Movie movie in movies) { store.remove (movie); } @@ -255,11 +241,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) { @@ -295,5 +315,9 @@ public class MovieListWindow : StackableWindow { no_movies.show (); } } + + public unowned MovieListView get_movie_list_view () { + return movie_list; + } }