From 4ead7ba3bb5d4813a28418b9dd312313480aa054 Mon Sep 17 00:00:00 2001 From: Stephen Boddy Date: Wed, 2 Dec 2015 19:40:11 +0100 Subject: [PATCH] Fix drag and drop of a link from Firefox / Chrome --- terminatorlib/terminal.py | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/terminatorlib/terminal.py b/terminatorlib/terminal.py index ded12510..f5d9f3f6 100755 --- a/terminatorlib/terminal.py +++ b/terminatorlib/terminal.py @@ -76,6 +76,7 @@ class Terminal(gtk.VBox): } TARGET_TYPE_VTE = 8 + TARGET_TYPE_MOZ = 9 MOUSEBUTTON_LEFT = 1 MOUSEBUTTON_MIDDLE = 2 @@ -265,7 +266,7 @@ class Terminal(gtk.VBox): userchars = "-A-Za-z0-9" passchars = "-A-Za-z0-9,?;.:/!%$^*&~\"#'" hostchars = "-A-Za-z0-9" - pathchars = "-A-Za-z0-9_$.+!*(),;:@&=?/~#%'\"" + pathchars = "-A-Za-z0-9_$.+!*(),;:@&=?/~#%'" schemes = "(news:|telnet:|nntp:|file:/|https?:|ftps?:|webcal:)" user = "[" + userchars + "]+(:[" + passchars + "]+)?" urlpath = "/[" + pathchars + "]*[^]'.}>) \t\r\n,\\\"]" @@ -355,7 +356,7 @@ class Terminal(gtk.VBox): srcvtetargets = [("vte", gtk.TARGET_SAME_APP, self.TARGET_TYPE_VTE)] dsttargets = [("vte", gtk.TARGET_SAME_APP, self.TARGET_TYPE_VTE), - ('text/x-moz-url', 0, 0), + ('text/x-moz-url', 0, self.TARGET_TYPE_MOZ), ('_NETSCAPE_URL', 0, 0)] dsttargets = gtk.target_list_add_text_targets(dsttargets) dsttargets = gtk.target_list_add_uri_targets(dsttargets) @@ -1081,7 +1082,7 @@ class Terminal(gtk.VBox): return(False) def on_drag_data_received(self, widget, drag_context, x, y, selection_data, - _info, _time, data): + info, _time, data): """Something has been dragged into the terminal. Handle it as either a URL or another terminal.""" dbg('drag data received of type: %s' % selection_data.type) @@ -1089,6 +1090,12 @@ class Terminal(gtk.VBox): gtk.targets_include_uri(drag_context.targets): # copy text with no modification yet to destination txt = selection_data.data + + # https://bugs.launchpad.net/terminator/+bug/1518705 + if info == self.TARGET_TYPE_MOZ: + txt = txt.decode('utf-16').encode('utf-8') + txt = txt.split('\n')[0] + txt_lines = txt.split( "\r\n" ) if txt_lines[-1] == '': for line in txt_lines[:-1]: