Drag and drop of files fine-tuning based on Schplurtz le déboulonné's fix.
* Slight changes to the logic, where all lines are now checked for the file:// prefix. * Fix dropping of a block of text which was previously broken (only inserts one line)
This commit is contained in:
parent
a1aecab22e
commit
306bf03f67
|
@ -1012,19 +1012,21 @@ class Terminal(gtk.VBox):
|
||||||
gtk.targets_include_uri(drag_context.targets):
|
gtk.targets_include_uri(drag_context.targets):
|
||||||
# copy text with no modification yet to destination
|
# copy text with no modification yet to destination
|
||||||
txt = selection_data.data
|
txt = selection_data.data
|
||||||
if txt[0:7] == 'file://':
|
txt_lines = txt.split( "\r\n" )
|
||||||
# It is a list of crlf terminated file:// URL. let's iterate
|
if txt_lines[-1] == '':
|
||||||
# over all elements.
|
for line in txt_lines[:-1]:
|
||||||
str=''
|
if line[0:7] != 'file://':
|
||||||
for fname in txt.split( "\r\n" ):
|
break
|
||||||
dbg('drag data fname: %s' % fname)
|
else:
|
||||||
if fname == '':
|
# It is a list of crlf terminated file:// URL. let's
|
||||||
break # last elem is empty since each URL is terminated bye crlf
|
# iterate over all elements except the last one.
|
||||||
fname = "'%s'" % urllib.unquote(fname[7:].replace( "'", '\'\\\'\''))
|
str=''
|
||||||
str += fname + ' '
|
for fname in txt_lines[:-1]:
|
||||||
txt=str
|
dbg('drag data fname: %s' % fname)
|
||||||
else:
|
fname = "'%s'" % urllib.unquote(fname[7:].replace("'",
|
||||||
txt = txt.strip(' ').split('\n')[0]
|
'\'\\\'\''))
|
||||||
|
str += fname + ' '
|
||||||
|
txt=str
|
||||||
for term in self.terminator.get_target_terms(self):
|
for term in self.terminator.get_target_terms(self):
|
||||||
term.feed(txt)
|
term.feed(txt)
|
||||||
return
|
return
|
||||||
|
|
Loading…
Reference in New Issue