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

index a7d73ad..9bc5d32 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -25,6 +25,7 @@ led_pattern_editor_VALASOURCES = \
        src/led-pattern-rx51.vala \
        src/led-pattern-dialog.vala \
        src/led-pattern-view.vala \
+       src/led-program-dialog.vala \
        src/mce-ini-parse.vala
 
 led_pattern_editor_VALAFLAGS = --pkg hildon-1 --pkg libosso
index 9946997..b11594b 100644 (file)
@@ -37,6 +37,8 @@ class LedPatternDialog : Gtk.Dialog {
 
                        var lpv = new LedPatternView (pattern);
                        lpv.set_size_request (200, -1);
+                       button.set_data ("pattern", pattern);
+                       button.clicked.connect (on_pattern_clicked);
                        hbox.pack_start (lpv, false, false, 0);
 
                        var label = new Gtk.Label (pattern.name.has_prefix ("Pattern") ?
@@ -54,4 +56,15 @@ class LedPatternDialog : Gtk.Dialog {
 
                add_button ("Save", Gtk.ResponseType.OK);
        }
+
+       void on_pattern_clicked (Gtk.Button button) {
+               var pattern = (LedPatternRX51) button.get_data ("pattern");
+               var dialog = new LedProgramDialog (pattern);
+               dialog.set_transient_for (this);
+
+               int response = 0;
+               while (response >= 0)
+                       response = dialog.run ();
+               dialog.destroy ();
+       }
 }
diff --git a/src/led-program-dialog.vala b/src/led-program-dialog.vala
new file mode 100644 (file)
index 0000000..bb7c4ff
--- /dev/null
@@ -0,0 +1,66 @@
+/* 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 LedProgramDialog : Gtk.Dialog {
+       LedPatternView lpv;
+       LedPatternRX51 pattern;
+
+       public LedProgramDialog (LedPatternRX51 _pattern) {
+               pattern = _pattern;
+               set_title ("LED pattern editor - " +
+                          (pattern.name.has_prefix ("Pattern") ?
+                           pattern.name.offset (7) : pattern.name) + " pattern");
+
+               var content = (Gtk.VBox) get_content_area ();
+               content.set_size_request (-1, 5*70);
+
+               lpv = new LedPatternView (pattern.copy ());
+               lpv.set_size_request (-1, 70);
+               content.pack_start (lpv, false, false, 0);
+
+               var pannable = new Hildon.PannableArea ();
+               var vbox = new Gtk.VBox (false, 0);
+
+               foreach (LedCommandRX51 command in lpv.pattern.engine1) {
+                       var label = new Gtk.Label ("0x%04x".printf (command.code));
+
+                       vbox.pack_start (label, false, false, 0);
+               }
+
+               pannable.add_with_viewport (vbox);
+               content.pack_start (pannable, true, true, 0);
+
+               content.show_all ();
+
+               add_button ("Test", 1);
+               add_button ("Done", Gtk.ResponseType.ACCEPT);
+
+               response.connect (on_response);
+       }
+
+       void on_response (int response) {
+               if (response == 1) {
+                       // Test pattern
+               }
+               if (response == Gtk.ResponseType.ACCEPT) {
+                       if (pattern.dump () != lpv.pattern.dump ()) {
+                               pattern.replace_with (lpv.pattern);
+                       }
+               }
+       }
+}