Add LED pattern dialog
authorPhilipp Zabel <philipp.zabel@gmail.com>
Wed, 24 Feb 2010 16:54:17 +0000 (17:54 +0100)
committerPhilipp Zabel <philipp.zabel@gmail.com>
Wed, 24 Feb 2010 17:55:50 +0000 (18:55 +0100)
Makefile
src/led-pattern-dialog.vala [new file with mode: 0644]
src/led-pattern-editor.vala

index 18a8ae6..d817137 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -23,6 +23,7 @@ led_pattern_editor_VALASOURCES = \
        src/led-pattern-editor.vala \
        src/led-pattern.vala \
        src/led-pattern-rx51.vala \
+       src/led-pattern-dialog.vala \
        src/mce-ini-parse.vala
 
 led_pattern_editor_VALAFLAGS = --pkg hildon-1 --pkg libosso
diff --git a/src/led-pattern-dialog.vala b/src/led-pattern-dialog.vala
new file mode 100644 (file)
index 0000000..e6e5f18
--- /dev/null
@@ -0,0 +1,50 @@
+/* This file is part of LED Pattern Editor.
+ *
+ * Copyright (C) 2010 Philipp Zabel
+ *
+ * LED Pattern Editor 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.
+ *
+ * LED Pattern Editor 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 LED Pattern Editor. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+class LedPatternDialog : Gtk.Dialog {
+       unowned List<LedPatternRX51> list;
+
+       public LedPatternDialog (List<LedPatternRX51> _list) {
+               list = _list;
+               set_title ("LED Patterns");
+
+               var content = (Gtk.VBox) get_content_area ();
+               content.set_size_request (-1, 5*70);
+
+               var pannable = new Hildon.PannableArea ();
+               var vbox = new Gtk.VBox (false, 0);
+
+               foreach (LedPatternRX51 pattern in list) {
+                       var button = new Gtk.Button ();
+                       Hildon.gtk_widget_set_theme_size (button, Hildon.SizeType.FINGER_HEIGHT);
+
+                       var label = new Gtk.Label (pattern.name.has_prefix ("Pattern") ?
+                                                  pattern.name.offset (7) : pattern.name);
+                       label.set_alignment (0.0f, 0.5f);
+                       button.add (label);
+
+                       vbox.pack_start (button, false, false, 0);
+               }
+
+               pannable.add_with_viewport (vbox);
+               content.pack_start (pannable, true, true, 0);
+               content.show_all ();
+
+               add_button ("Save", Gtk.ResponseType.OK);
+       }
+}
index 249a311..b008040 100644 (file)
 public static Osso.Status execute (Osso.Context osso, void* data, bool user_activated) {
        var window = data as Gtk.Window;
 
-       // Load mce.ini
+       var list = mce_ini_parse ();
 
-       var dialog = new Gtk.Dialog ();
+       var dialog = new LedPatternDialog (list);
        dialog.set_transient_for (window);
 
        int response = dialog.run ();
        dialog.destroy ();
        if (response == Gtk.ResponseType.OK) {
-               // Save mce.ini
+               mce_ini_store (list);
        }
 
        return Osso.Status.OK;