+
+ private void on_search_field_changed () {
+ // With every change we reset the timer to 500ms
+ if (source_id != 0) {
+ Source.remove (source_id);
+ }
+ source_id = Timeout.add (500, start_search);
+ }
+
+ private bool start_search () {
+ filter.title = search_field.get_text ();
+ if (store.start_search (filter)) {
+ movie_list.show ();
+ no_movies.hide ();
+ }
+
+ // One-shot only
+ 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) {
+ 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;
+
+ if (count == 1 && auto_open_movie_window) {
+ TreeIter iter;
+ if (store.get_iter_first (out iter)) {
+ Movie movie;
+ store.get (iter, MovieListStore.Columns.MOVIE, out movie);
+ on_movie_activated (movie);
+ }
+ }
+ }
+
+ 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) {
+ if (movie_window != null)
+ return;
+
+ movie_window = new MovieWindow.with_movie (movie, store);
+ movie_window.destroy.connect (() => { movie_window = null; });
+ get_stack ().push_1 (movie_window);
+ }
+
+ private void on_row_deleted (TreePath path) {
+ if (--count == 0) {
+ no_movies.show ();
+ movie_list.hide ();
+ }
+ }
+
+ private void on_row_inserted (TreePath path, TreeIter iter) {
+ if (count++ == 0) {
+ no_movies.hide ();
+ movie_list.show ();
+ }
+ }
+
+ private void on_update_running_changed (GLib.Object source, ParamSpec spec) {
+ TreeIter iter;
+
+ Hildon.gtk_window_set_progress_indicator (this, (int) store.update_running);
+ // Update finished, but store still empty?
+ if (!store.update_running && !store.get_iter_first (out iter)) {
+ movie_list.hide ();
+ no_movies.show ();
+ }
+ }
+
+ public unowned MovieListView get_movie_list_view () {
+ return movie_list;
+ }