From 807947399f7a865a46014bd2818c064e966fce22 Mon Sep 17 00:00:00 2001 From: Chris Jones Date: Sat, 20 Aug 2011 23:18:56 +0100 Subject: [PATCH] Improved drag&drop support to be more generic and correct. Fixes LP #643425 --- ChangeLog | 8 ++++---- terminatorlib/terminal.py | 15 +++++++++++---- 2 files changed, 15 insertions(+), 8 deletions(-) diff --git a/ChangeLog b/ChangeLog index 65f2c86f..6775d614 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,12 +1,12 @@ terminator 0.96: * Unity support for opening new windows (Lucian Adrian Grijincu) - * Fix searching with infinite scrollback (Julien Thewys #755077) - * Fix searching on Ubuntu 10.10 and 11.04, and implement searching - by regular expression (Roberto Aguilar #709018) + * Fix searching with infinite scrollback (Julien Thewys #755077) + * Fix searching on Ubuntu 10.10 and 11.04, and implement searching + by regular expression (Roberto Aguilar #709018) * Optimise various low level components so they are dramatically faster (Stephen Boddy) * Fix various bugs (Stephen Boddy) - * Fix cursor colours (#700969) and a cursor blink issue (Tony Baker) + * Fix cursor colours (#700969) and a cursor blink issue (Tony Baker) terminator 0.95: * Add a configuration option to enable a DBus server diff --git a/terminatorlib/terminal.py b/terminatorlib/terminal.py index 940dbd23..17a64879 100755 --- a/terminatorlib/terminal.py +++ b/terminatorlib/terminal.py @@ -305,7 +305,11 @@ for %s (%s)' % (name, urlplugin.__class__.__name__)) srcvtetargets = [("vte", gtk.TARGET_SAME_APP, self.TARGET_TYPE_VTE)] dsttargets = [("vte", gtk.TARGET_SAME_APP, self.TARGET_TYPE_VTE), - ('text/plain', 0, 0), ('STRING', 0, 0), ('COMPOUND_TEXT', 0, 0)] + ('text/x-moz-url', 0, 0), + ('_NETSCAPE_URL', 0, 0)] + dsttargets = gtk.target_list_add_text_targets(dsttargets) + dsttargets = gtk.target_list_add_uri_targets(dsttargets) + dbg('Finalised drag targets: %s' % dsttargets) for (widget, mask) in [ (self.vte, gtk.gdk.CONTROL_MASK | gtk.gdk.BUTTON3_MASK), @@ -314,7 +318,7 @@ for %s (%s)' % (name, urlplugin.__class__.__name__)) self.vte.drag_dest_set(gtk.DEST_DEFAULT_MOTION | gtk.DEST_DEFAULT_HIGHLIGHT | gtk.DEST_DEFAULT_DROP, - dsttargets, gtk.gdk.ACTION_MOVE) + dsttargets, gtk.gdk.ACTION_COPY | gtk.gdk.ACTION_MOVE) for widget in [self.vte, self.titlebar]: widget.connect('drag-begin', self.on_drag_begin, self) @@ -831,7 +835,8 @@ for %s (%s)' % (name, urlplugin.__class__.__name__)) def on_drag_motion(self, widget, drag_context, x, y, _time, _data): """*shrug*""" - if 'text/plain' in drag_context.targets: + if gtk.targets_include_text(drag_context.targets) or \ + gtk.targets_include_uri(drag_context.targets): # copy text from another widget return srcwidget = drag_context.get_source_widget() @@ -900,7 +905,9 @@ for %s (%s)' % (name, urlplugin.__class__.__name__)) _info, _time, data): """Something has been dragged into the terminal. Handle it as either a URL or another terminal.""" - if selection_data.type == 'text/plain': + dbg('drag data received of type: %s' % selection_data.type) + if gtk.targets_include_text(drag_context.targets) or \ + gtk.targets_include_uri(drag_context.targets): # copy text to destination txt = selection_data.data.strip() if txt[0:7] == 'file://':