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 class SettingsDialog : Gtk.Dialog {
23 List<Gtk.Button> buttons;
24 Gtk.Window movie_list_window;
25 private Hildon.CheckButton download_posters;
26 private Hildon.CheckButton start_movies;
27 private Hildon.Button default_source;
29 public SettingsDialog (Gtk.Window window) {
30 movie_list_window = window;
31 set_transient_for (window);
35 set_title (_("Settings"));
38 if (CinaestProgram.plugins.length () > 4) {
39 vbox = new VBox (true, 0);
41 var pannable = new PannableArea ();
42 pannable.add_with_viewport (vbox);
44 VBox area = (VBox) get_content_area ();
45 area.pack_start (pannable, true, true, 0);
46 area.set_size_request (-1, 5*70);
48 vbox = (VBox) get_content_area ();
51 download_posters = new Hildon.CheckButton (SizeType.FINGER_HEIGHT);
52 download_posters.set_label (_("Download movie posters"));
53 vbox.pack_start (download_posters, true, true, 0);
55 start_movies = new Hildon.CheckButton (SizeType.FINGER_HEIGHT);
56 start_movies.set_label (_("Show movie list on startup"));
57 vbox.pack_start (start_movies, true, true, 0);
59 default_source = new Hildon.Button.with_text (SizeType.FINGER_HEIGHT, ButtonArrangement.VERTICAL, _("Default movie source"), _("None"));
60 default_source.set_style (ButtonStyle.PICKER);
61 default_source.set_alignment (0, 0.5f, 0, 0.5f);
62 vbox.pack_start (default_source, true, true, 0);
64 start_movies.toggled.connect (on_start_movies_toggled);
65 default_source.clicked.connect (on_default_source_clicked);
69 buttons = new List<Hildon.Button> ();
70 foreach (Plugin plugin in CinaestProgram.plugins) {
71 var button = new Gtk.Button.with_label (plugin.get_name ());
73 Hildon.gtk_widget_set_theme_size (button, SizeType.FINGER_HEIGHT);
74 button.set_alignment(0, 0.5f);
77 hbox = new HBox (true, 0);
78 vbox.pack_start (hbox, true, true, 0);
82 hbox.pack_start (button, true, true, 0);
84 button.clicked.connect (on_plugin_settings);
86 buttons.append (button);
89 add_button (_("Done"), ResponseType.ACCEPT);
92 public void on_start_movies_toggled () {
93 default_source.set_sensitive (start_movies.get_active ());
96 public void on_default_source_clicked (Gtk.Button button) {
97 var default_source = (Hildon.Button) button;
98 var dialog = new SourceDialog (movie_list_window);
100 MovieSource source = null;
101 dialog.run (ref source);
103 if (source != null) {
104 default_source.set_value (source.get_name ());
108 public void on_plugin_settings (Gtk.Button button) {
109 int n = buttons.index (button);
114 public new int run () {
116 var gc = GConf.Client.get_default ();
119 download_posters.set_active (gc.get_bool ("/apps/cinaest/download_posters"));
120 start_movies.set_active (gc.get_bool ("/apps/cinaest/start_movies"));
121 default_source.set_sensitive (start_movies.get_active ());
122 string source = gc.get_string ("/apps/cinaest/default_source");
123 if (source != null && source != "")
124 default_source.set_value (source);
126 stdout.printf ("Error getting GConf option: %s\n", e.message);
134 var plugin = CinaestProgram.plugins.nth_data (res);
135 plugin.settings_dialog (movie_list_window);
139 if (res == ResponseType.ACCEPT) try {
140 gc.set_bool ("/apps/cinaest/download_posters", download_posters.get_active ());
141 gc.set_bool ("/apps/cinaest/start_movies", start_movies.get_active ());
142 gc.set_string ("/apps/cinaest/default_source", default_source.get_value ());
144 stdout.printf ("Error setting GConf option: %s\n", e.message);