From c81df8ab054c353d3e799a70ace287321cd16467 Mon Sep 17 00:00:00 2001 From: Emmanuel Bretelle Date: Thu, 6 Mar 2008 14:54:31 +0000 Subject: [PATCH] fiddling around with text dnd --- terminator | 32 ++++++++++++++++++++++++++++---- 1 file changed, 28 insertions(+), 4 deletions(-) diff --git a/terminator b/terminator index 8e6a63b7..06a23ee5 100755 --- a/terminator +++ b/terminator @@ -215,10 +215,11 @@ class TerminatorTerm: self._vte.connect ("popup-menu", self.on_vte_popup_menu) """drag and drop""" - target = [ ( "vte", 0, 81 ), ('text/plain', 0, 0) ] - self._vte.drag_source_set( gtk.gdk.CONTROL_MASK | gtk.gdk.BUTTON3_MASK, target, gtk.gdk.ACTION_COPY) - #self._vte.drag_dest_set(gtk.DEST_DEFAULT_MOTION | gtk.DEST_DEFAULT_HIGHLIGHT |gtk.DEST_DEFAULT_DROP ,target, gtk.gdk.ACTION_COPY) - self._vte.drag_dest_set(gtk.DEST_DEFAULT_MOTION | gtk.DEST_DEFAULT_HIGHLIGHT |gtk.DEST_DEFAULT_DROP ,target, gtk.gdk.ACTION_COPY) + srctargets = [ ( "vte", 0, 81 ) ] + dsttargets = [ ( "vte", 0, 81 ), ('text/plain', 0, 0) , ("STRING", 0, 0), ("COMPOUND_TEXT", 0, 0)] + self._vte.drag_source_set( gtk.gdk.CONTROL_MASK | gtk.gdk.BUTTON3_MASK, srctargets, gtk.gdk.ACTION_COPY) + #self._vte.drag_dest_set(gtk.DEST_DEFAULT_MOTION | gtk.DEST_DEFAULT_HIGHLIGHT |gtk.DEST_DEFAULT_DROP ,dsttargets, gtk.gdk.ACTION_COPY) + self._vte.drag_dest_set(gtk.DEST_DEFAULT_MOTION | gtk.DEST_DEFAULT_HIGHLIGHT |gtk.DEST_DEFAULT_DROP ,dsttargets, gtk.gdk.ACTION_COPY) self._vte.connect("drag-data-get", self.on_drag_data_get, self) #for testing purpose: drag-motion @@ -261,6 +262,22 @@ class TerminatorTerm: def on_drag_motion(self, widget, drag_context, x, y, time, data): #print "Drag Motion on ", + """ +x-special/gnome-icon-list +text/uri-list +UTF8_STRING +COMPOUND_TEXT +TEXT +STRING +text/plain;charset=utf-8 +text/plain;charset=UTF-8 +text/plain + """ + print "motion" + + if 'text/plain' in drag_context.targets: + #copy text from another widget + return srcwidget = drag_context.get_source_widget() if widget == srcwidget: #on self @@ -340,6 +357,13 @@ class TerminatorTerm: def on_drag_data_received(self, widget, drag_context, x, y, selection_data, info, time, data): print "Drag Data Received on " + if selection_data.type == 'text/plain': + #copy text to destination + txt = selection_data.data.strip() + if txt[0:7] == "file://": + txt = txt[7:] + self._vte.feed_child("'%s'" % txt) + return widgetsrc = data.terminator.term_list[int(selection_data.data)] srcvte = drag_context.get_source_widget() #check if computation requireds