* cleaned up on_drag_motion

This commit is contained in:
Emmanuel Bretelle 2008-03-04 20:25:51 +00:00
parent ed3f695669
commit 9ebbc671ed
1 changed files with 41 additions and 30 deletions

View File

@ -259,48 +259,58 @@ 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 ",
parent = widget.get_parent() srcwidget = drag_context.get_source_widget()
rect = gtk.gdk.Rectangle(0, 0, parent.allocation.width, parent.allocation.height) if widget == srcwidget:
allocation = widget.allocation #on self
return
alloc = widget.allocation
rect = gtk.gdk.Rectangle(0, 0, alloc.width, alloc.height)
widget.window.invalidate_rect(rect, True) widget.window.invalidate_rect(rect, True)
widget.window.process_updates(True) widget.window.process_updates(True)
context = widget.window.cairo_create() context = widget.window.cairo_create()
context.set_source_rgba(1, 0, 0, 0.5) #red if self.gconf_client.get_bool (self.profile + "/use_theme_colors"):
color = self._vte.get_style ().text[gtk.STATE_NORMAL]
else:
color = gtk.gdk.color_parse (self.reconf ('foreground_color'))
#color = gtk.gdk.color_parse(self.reconf ('foreground_color'))
#print "%dx%d -> %dx%d" % (parent.allocation.width, parent.allocation.height , x, y)
context.set_source_rgba(color.red, color.green, color.blue, 0.5) #red
coef1 = float(parent.allocation.height)/float(parent.allocation.width)
coef2 = -float(parent.allocation.height)/float(parent.allocation.width) coef1 = float(alloc.height)/float(alloc.width)
coef2 = -float(alloc.height)/float(alloc.width)
b1 = 0 b1 = 0
b2 = parent.allocation.height b2 = alloc.height
topleft = (0,0)
topright = (alloc.width,0)
bottomleft = (0, alloc.height)
bottomright = (alloc.width,alloc.height)
middle = (alloc.width/2, alloc.height/2)
#print "%f %f %d %d" %(coef1, coef2, b1,b2) #print "%f %f %d %d" %(coef1, coef2, b1,b2)
coord = ()
if (x*coef1 + b1 > y ) and (x*coef2 + b2 < y ): if (x*coef1 + b1 > y ) and (x*coef2 + b2 < y ):
#print "right" #print "right"
pos1 = (allocation.width,0) coord = (topright, middle, bottomright)
pos2 = (allocation.width/2, allocation.height/2)
pos3 = (allocation.width,allocation.height)
if (x*coef1 + b1 > y ) and (x*coef2 + b2 > y ): if (x*coef1 + b1 > y ) and (x*coef2 + b2 > y ):
#print "top" #print "top"
pos1 = (0,0) coord = (topleft, middle, topright)
pos2 = (allocation.width/2, allocation.height/2)
pos3 = (allocation.width,0)
if (x*coef1 + b1 < y ) and (x*coef2 + b2 > y ): if (x*coef1 + b1 < y ) and (x*coef2 + b2 > y ):
#print "left" #print "left"
pos1 = (0,0) coord = (topleft, middle, bottomleft)
pos2 = (allocation.width/2, allocation.height/2)
pos3 = (0,allocation.height)
if (x*coef1 + b1 < y ) and (x*coef2 + b2 < y ): if (x*coef1 + b1 < y ) and (x*coef2 + b2 < y ):
#print "bottom" #print "bottom"
pos1 = (0,allocation.height) coord = (bottomleft, middle, bottomright)
pos2 = (allocation.width/2, allocation.height/2)
pos3 = (allocation.width,allocation.height) if len(coord) > 0 :
context.move_to(coord[2][0],coord[2][1])
for i in coord:
context.line_to(i[0],i[1])
context.move_to(pos1[0],pos1[1]) context.fill()
context.line_to(pos2[0],pos2[1])
context.line_to(pos3[0],pos3[1])
context.line_to(pos1[0],pos1[1])
context.fill()
def on_drag_drop(self, widget, drag_context, x, y, time): def on_drag_drop(self, widget, drag_context, x, y, time):
@ -311,14 +321,15 @@ 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 "
widgetsrc = data.terminator.term_list[int(selection_data.data)] widgetsrc = data.terminator.term_list[int(selection_data.data)]
srchbox = widgetsrc.get_box() srcvte = drag_context.get_source_widget()
dsthbox = widget.get_parent().get_parent()
#check if computation requireds #check if computation requireds
if dsthbox == srchbox: if srcvte == widget:
print "on itself" print "on itself"
return return
srchbox = widgetsrc.get_box()
dsthbox = widget.get_parent().get_parent()
dstpaned = dsthbox.get_parent() dstpaned = dsthbox.get_parent()
srcpaned = srchbox.get_parent() srcpaned = srchbox.get_parent()
if isinstance(dstpaned, gtk.Window) and isinstance(srcpaned, gtk.Window): if isinstance(dstpaned, gtk.Window) and isinstance(srcpaned, gtk.Window):