From 43c134b5c587e3698eaf97cb5e5bd5089f62f939 Mon Sep 17 00:00:00 2001 From: Stephen Boddy Date: Mon, 13 Jul 2015 00:39:09 +0200 Subject: [PATCH] =?UTF-8?q?(trunk-1575)=20Fix=20drag=20and=20drop=20of=20f?= =?UTF-8?q?iles=20(Schplurtz=20le=20D=C3=A9boulonn=C3=A9,=20LP#1311481)=20?= =?UTF-8?q?and=20some=20tweaks=20(Steve=20Boddy)=20Schplurtz=20le=20D?= =?UTF-8?q?=C3=A9boulonn=C3=A9=20=20=20=20=20-=20multiple=20files=20can=20?= =?UTF-8?q?be=20dropped=20in=20terminal=20=20=20=20=20-=20correctly=20sh-q?= =?UTF-8?q?uote=20filenames,=20even=20those=20with=20'=20=20=20=20=20-=20a?= =?UTF-8?q?lso=20fixes=20LP#1311481=20(\n=20after=20dropped=20filename)=20?= =?UTF-8?q?Steve=20Boddy=20=20=20=20=20-=20changes=20to=20the=20logic,=20w?= =?UTF-8?q?here=20all=20lines=20are=20now=20checked=20for=20the=20file://?= =?UTF-8?q?=20prefix=20=20=20=20=20-=20text=20blocks=20now=20insert=20in?= =?UTF-8?q?=20full,=20not=20just=20first=20line=20=20=20=20=20-=20Oddly=20?= =?UTF-8?q?gtk3=20changes=20dropped=20text=20blocks=20from=20'\n'=20to=20'?= =?UTF-8?q?\r\n'=20(gtk2->gtk3)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- terminatorlib/terminal.py | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/terminatorlib/terminal.py b/terminatorlib/terminal.py index bdc3efed..9197ee15 100755 --- a/terminatorlib/terminal.py +++ b/terminatorlib/terminal.py @@ -1024,12 +1024,24 @@ class Terminal(Gtk.VBox): dbg('drag data received of type: %s' % (selection_data.get_data_type())) if Gtk.targets_include_text(drag_context.list_targets()) or \ Gtk.targets_include_uri(drag_context.list_targets()): - # copy text to destination - txt = selection_data.get_data().strip(' ') - if txt[0:7] == 'file://': - txt = "'%s'" % urllib.unquote(txt[7:]) - else: - txt = txt.split('\n')[0] + # copy text with no modification yet to destination + txt = selection_data.get_data() + txt_lines = txt.split( "\r\n" ) + if txt_lines[-1] == '': + for line in txt_lines[:-1]: + if line[0:7] != 'file://': + txt = txt.replace('\r\n','\n') + break + else: + # It is a list of crlf terminated file:// URL. let's + # iterate over all elements except the last one. + str='' + for fname in txt_lines[:-1]: + dbg('drag data fname: %s' % fname) + fname = "'%s'" % urllib.unquote(fname[7:].replace("'", + '\'\\\'\'')) + str += fname + ' ' + txt=str for term in self.terminator.get_target_terms(self): term.feed(txt) return