Add settings dialog
authorPhilipp Zabel <philipp.zabel@gmail.com>
Mon, 9 Nov 2009 18:25:01 +0000 (19:25 +0100)
committerPhilipp Zabel <philipp.zabel@gmail.com>
Wed, 11 Nov 2009 18:08:27 +0000 (19:08 +0100)
A settings dialog to change global as well as plugin specific settings.

Makefile.am
po/POTFILES.in
src/movie-list-menu.vala
src/settings-dialog.vala [new file with mode: 0644]

index ff47cbe..b688508 100644 (file)
@@ -34,6 +34,7 @@ cinaest_SOURCES = \
         src/movie-list-window.c \
         src/plugin-interface.c \
        src/plugin-registrar.c \
+       src/settings-dialog.c \
        src/source-dialog.c
 
 cinaest_VALASOURCES = \
@@ -47,6 +48,7 @@ cinaest_VALASOURCES = \
         src/movie-list-window.vala \
         src/plugin-interface.vala \
        src/plugin-registrar.vala \
+       src/settings-dialog.vala \
        src/source-dialog.vala
 
 ${cinaest_SOURCES}: ${cinaest_VALASOURCES}
index 23d3a0a..6e5fca9 100644 (file)
@@ -1,4 +1,5 @@
 src/main.vala
 src/movie-list-menu.vala
 src/movie-list-window.vala
+src/settings-dialog.vala
 src/source-dialog.vala
index 2b7713f..7069d20 100644 (file)
@@ -62,13 +62,16 @@ public class MovieListMenu : AppMenu {
 
                // Add view menu buttons
                select_source = new Hildon.Button.with_text (SizeType.FINGER_HEIGHT, ButtonArrangement.VERTICAL, _("Source"), _("None"));
+               var settings = new Gtk.Button.with_label (_("Settings"));
 
                select_source.set_style (ButtonStyle.PICKER);
 
                // Connect signals
                select_source.clicked.connect (on_select_source_clicked);
+               settings.clicked.connect (on_settings_clicked);
 
                append (select_source);
+               append (settings);
 
                show_all ();
        }
@@ -87,4 +90,10 @@ public class MovieListMenu : AppMenu {
 
                select_source.value = source.get_name ();
        }
+
+       public void on_settings_clicked (Gtk.Button button) {
+               var dialog = new SettingsDialog (movie_list_window);
+
+               dialog.run ();
+       }
 }
diff --git a/src/settings-dialog.vala b/src/settings-dialog.vala
new file mode 100644 (file)
index 0000000..d84d947
--- /dev/null
@@ -0,0 +1,86 @@
+/* This file is part of Cinaest.
+ *
+ * Copyright (C) 2009 Philipp Zabel
+ *
+ * Cinaest is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Cinaest is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Cinaest. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+using Hildon;
+using Gtk;
+
+class SettingsDialog : Gtk.Dialog {
+       List<Gtk.Button> buttons;
+       Gtk.Window movie_list_window;
+
+       public SettingsDialog (Gtk.Window window) {
+               movie_list_window = window;
+               set_transient_for (window);
+       }
+
+       construct {
+               set_title (_("Settings"));
+
+               VBox vbox;
+               if (CinaestProgram.plugins.length () > 5) {
+                       vbox = new VBox (true, 0);
+
+                       var pannable = new PannableArea ();
+                       pannable.add_with_viewport (vbox);
+
+                       VBox area = (VBox) get_content_area ();
+                       area.pack_start (pannable, true, true, 0);
+                       area.set_size_request (-1, 5*70);
+               } else {
+                       vbox = (VBox) get_content_area ();
+               }
+
+               buttons = new List<Hildon.Button> ();
+               foreach (Plugin plugin in CinaestProgram.plugins) {
+                       var button = new Gtk.Button.with_label (plugin.get_name ());
+
+                       Hildon.gtk_widget_set_theme_size (button, SizeType.FINGER_HEIGHT);
+                       button.set_alignment(0, 0.5f);
+
+                       vbox.pack_start (button, true, true, 0);
+
+                       button.clicked.connect (on_plugin_settings);
+
+                       buttons.append (button);
+               }
+       }
+
+       public void on_plugin_settings (Gtk.Button button) {
+               int n = buttons.index (button);
+
+               response (n);
+       }
+
+       public new int run () {
+               int res = 0;
+
+               show_all ();
+
+               do {
+                       res = base.run ();
+                       if (res >= 0) {
+                               var plugin = CinaestProgram.plugins.nth_data (res);
+                               plugin.settings_dialog (movie_list_window);
+                       }
+               } while (res >= 0);
+
+               destroy ();
+
+               return res;
+       }
+}