diff options
Diffstat (limited to 'terminal.vala')
-rw-r--r-- | terminal.vala | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/terminal.vala b/terminal.vala index 67256d4..fcb456c 100644 --- a/terminal.vala +++ b/terminal.vala @@ -70,6 +70,13 @@ class Terminal : Gtk.Overlay { uri_context_menu.attach_to_widget(vte, null); standard_context_menu.attach_to_widget(vte, null); + Gtk.TargetList targets = new Gtk.TargetList({}); + targets.add_text_targets(0); + targets.add_uri_targets(1); + + Gtk.drag_dest_set(vte, Gtk.DestDefaults.ALL, {}, Gdk.DragAction.COPY); + Gtk.drag_dest_set_target_list(vte, targets); + clipboard = Gtk.Clipboard.get_default(window.get_display()); primary = Gtk.Clipboard.get_for_display(window.get_display(), Gdk.SELECTION_PRIMARY); @@ -591,4 +598,31 @@ class Terminal : Gtk.Overlay { window.set_urgency_hint(false); window.set_urgency_hint(true); } + + [GtkCallback] + void vte_drag_data_received(Gdk.DragContext context, int x, int y, Gtk.SelectionData selection_data, uint info, uint time_) { + if (info == 0) { + string text = selection_data.get_text(); + + if (text != null) { + vte.paste_text(text); + } + } else if (info == 1) { + string[] uris = selection_data.get_uris(); + string text = ""; + + foreach (var uri in uris) { + if (uri == null || uri.length == 0) + continue; + + if (uri.has_prefix("file://")) { + uri = Shell.quote(Uri.unescape_string(uri.substring(7))); + } + + text = string.join(" ", text, uri); + } + + vte.paste_text(text.strip()); + } + } } |