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 MovieListWindow : StackableWindow {
23 private Hildon.Entry search_field;
24 private Toolbar search_bar;
25 private uint source_id;
26 private MovieListView movie_list;
27 public MovieListStore store;
28 private Label no_movies;
32 var menu = new MovieListMenu ();
37 search_field = new Hildon.Entry (SizeType.FINGER_HEIGHT);
39 var search_field_item = new ToolItem ();
40 search_field_item.set_expand (true);
41 search_field_item.add (search_field);
43 var close_image = new Image.from_file("/usr/share/icons/hicolor/48x48/hildon/general_close.png");
44 var close_button = new ToolButton (close_image, _("Close"));
46 search_bar = new Toolbar ();
47 search_bar.insert (search_field_item, 0);
48 search_bar.insert (close_button, 1);
50 add_toolbar (search_bar);
52 // Movie list - connected to menu for sorting
53 movie_list = new MovieListView ();
54 menu.sortable = movie_list.sorted_store;
55 store = movie_list.store;
57 no_movies = new Label (_("No movies"));
58 Hildon.helper_set_logical_font (no_movies, "LargeSystemFont");
59 Hildon.helper_set_logical_color (no_movies, RcFlags.FG, StateType.NORMAL, "SecondaryTextColor");
60 no_movies.set_size_request (-1, 6 * 70);
61 no_movies.set_alignment ((float) 0.5, (float) 0.42);
63 var vbox = new VBox (false, 0);
64 vbox.pack_start (movie_list, true, true, 0);
65 vbox.pack_start (no_movies, false, false, 0);
70 search_field.changed.connect (on_search_field_changed);
71 close_button.clicked.connect (on_close_button_clicked);
72 key_press_event.connect (on_key_press_event);
74 store.notify["update-running"].connect (on_update_running_changed);
76 search_field.set_flags (WidgetFlags.CAN_DEFAULT);
77 search_field.grab_default ();
84 private void on_close_button_clicked () {
85 search_field.set_text ("");
89 private bool on_key_press_event (Widget widget, Gdk.EventKey event) {
90 if (event.str != "") {
91 if (!search_bar.visible) {
94 search_field.grab_focus ();
100 private void on_search_field_changed () {
101 if (search_field.get_text () == "") {
108 // With every change we reset the timer to 500ms
109 if (source_id != 0) {
110 Source.remove (source_id);
112 source_id = Timeout.add (500, start_search);
115 private bool start_search () {
116 if (store.start_search (search_field.get_text ())) {
125 private void on_update_running_changed (GLib.Object source, ParamSpec spec) {
126 Hildon.gtk_window_set_progress_indicator (this, (int) store.update_running);