LED program dialog: add a Copy button to copy pattern to clipboard
[led-pattern-ed] / 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);
                        }