LED program dialog: add a Copy button to copy pattern to clipboard
authorPhilipp Zabel <philipp.zabel@gmail.com>
Mon, 1 Mar 2010 11:00:50 +0000 (12:00 +0100)
committerPhilipp Zabel <philipp.zabel@gmail.com>
Mon, 1 Mar 2010 16:09:32 +0000 (17:09 +0100)
src/led-program-dialog.vala

index ff47d6a..a1cec5e 100644 (file)
@@ -75,6 +75,7 @@ class LedProgramDialog : Gtk.Dialog {
 
                action_area.show_all ();
 
+               add_button ("Copy", 2);
                add_button ("Test", 1);
                add_button ("Done", Gtk.ResponseType.ACCEPT);
 
@@ -112,9 +113,13 @@ class LedProgramDialog : Gtk.Dialog {
        void on_response (int response) {
                if (response == 1) {
                        Timeout.add (200, delayed_spawn);
-                       return;
-               }
-               if (response == Gtk.ResponseType.ACCEPT) {
+               } else if (response == 2) {
+                       var clipboard = Gtk.Clipboard.@get (Gdk.SELECTION_CLIPBOARD);
+
+                       clipboard.set_text (lpv.pattern.dump (), -1);
+                       clipboard.store ();
+                       Hildon.Banner.show_information (null, null, "Copied");
+               } else if (response == Gtk.ResponseType.ACCEPT) {
                        if (pattern.dump () != lpv.pattern.dump ()) {
                                pattern.replace_with (lpv.pattern);
                        }