fiddling around with text dnd

This commit is contained in:
Emmanuel Bretelle 2008-03-06 14:54:31 +00:00
parent 6322a5ba0d
commit c81df8ab05
1 changed files with 28 additions and 4 deletions

View File

@ -215,10 +215,11 @@ class TerminatorTerm:
self._vte.connect ("popup-menu", self.on_vte_popup_menu) self._vte.connect ("popup-menu", self.on_vte_popup_menu)
"""drag and drop""" """drag and drop"""
target = [ ( "vte", 0, 81 ), ('text/plain', 0, 0) ] srctargets = [ ( "vte", 0, 81 ) ]
self._vte.drag_source_set( gtk.gdk.CONTROL_MASK | gtk.gdk.BUTTON3_MASK, target, gtk.gdk.ACTION_COPY) dsttargets = [ ( "vte", 0, 81 ), ('text/plain', 0, 0) , ("STRING", 0, 0), ("COMPOUND_TEXT", 0, 0)]
#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_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 ,target, 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) self._vte.connect("drag-data-get", self.on_drag_data_get, self)
#for testing purpose: drag-motion #for testing purpose: drag-motion
@ -261,6 +262,22 @@ class TerminatorTerm:
def on_drag_motion(self, widget, drag_context, x, y, time, data): def on_drag_motion(self, widget, drag_context, x, y, time, data):
#print "Drag Motion on ", #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() srcwidget = drag_context.get_source_widget()
if widget == srcwidget: if widget == srcwidget:
#on self #on self
@ -340,6 +357,13 @@ class TerminatorTerm:
def on_drag_data_received(self, widget, drag_context, x, y, selection_data, info, time, data): def on_drag_data_received(self, widget, drag_context, x, y, selection_data, info, time, data):
print "Drag Data Received on " 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)] widgetsrc = data.terminator.term_list[int(selection_data.data)]
srcvte = drag_context.get_source_widget() srcvte = drag_context.get_source_widget()
#check if computation requireds #check if computation requireds