add_button ("Test", 1);
add_button ("Done", Gtk.ResponseType.ACCEPT);
+ key_press_event.connect (on_key_pressed);
response.connect (on_response);
}
+ private bool on_key_pressed (Gdk.EventKey event) {
+ if (Gdk.ModifierType.CONTROL_MASK in event.state) {
+ string key = Gdk.keyval_name (event.keyval);
+ if (key == "c")
+ copy ();
+ else if (key == "v")
+ paste ();
+ }
+ return true;
+ }
+
private Gtk.Widget led_command_list (int engine) {
var pannable = new Hildon.PannableArea ();
var vbox = new Gtk.VBox (false, 0);
if (response == 1) {
Timeout.add (200, delayed_spawn);
} 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");
+ copy ();
} else if (response == Gtk.ResponseType.ACCEPT) {
if (pattern.dump () != lpv.pattern.dump ()) {
pattern.replace_with (lpv.pattern);
}
}
+ void copy () {
+ var clipboard = Gtk.Clipboard.@get (Gdk.SELECTION_CLIPBOARD);
+
+ clipboard.set_text (lpv.pattern.dump (), -1);
+ clipboard.store ();
+ Hildon.Banner.show_information (null, null, "Copied");
+ }
+
+ void paste () {
+ var clipboard = Gtk.Clipboard.@get (Gdk.SELECTION_CLIPBOARD);
+
+ clipboard.request_text (on_text_received);
+ }
+
+ void on_text_received (Gtk.Clipboard clipboard, string text) {
+ var clip_pattern = new LedPatternRX51 ();
+ if (clip_pattern.parse (text)) {
+ lpv.pattern.replace_with (clip_pattern);
+ } else {
+ Hildon.Banner.show_information (null, null, "Not a valid pattern");
+ }
+ }
+
bool delayed_spawn () {
try {
int exit_status;