Drag'n'drop for plots
This commit is contained in:
@@ -62,6 +62,11 @@ class Plot (gtk.Frame):
|
||||
self.title = title
|
||||
self.selection_listener = None
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
def get_title(self):
|
||||
return self.title
|
||||
|
||||
@@ -115,6 +120,26 @@ class SmallView (gtk.Table):
|
||||
child.parent_signalling = child.connect('button_press_event', self.__view_button_event__)
|
||||
self.attach(child, x, x+1, y, y+1)
|
||||
|
||||
# drag'n'drop
|
||||
for views in self.child_views:
|
||||
for view in views:
|
||||
view.drag_dest_set(gtk.DEST_DEFAULT_ALL, [("GTK_TREE_MODEL_ROW",gtk.TARGET_SAME_APP,7)],gtk.gdk.ACTION_LINK)
|
||||
view.connect("drag-data-received",self.drag_received_by_view,view)
|
||||
|
||||
|
||||
def drag_received_by_view(self, widget, drag_context, x, y, selection, info, timestamp, view):
|
||||
treestore, path = selection.tree_get_row_drag_data()
|
||||
iter = treestore.get_iter(path)
|
||||
obj = treestore.get_value(iter,2)
|
||||
|
||||
loc = self.find_child(view)
|
||||
|
||||
if loc and isinstance(obj, Plot) and (not self.find_child(obj)):
|
||||
self.set_child(obj,loc[0],loc[1])
|
||||
|
||||
|
||||
|
||||
|
||||
def set_view_listener(self, listener):
|
||||
self._listener = listener
|
||||
|
||||
|
Reference in New Issue
Block a user