Drag and drop from the navigator to the viewframes now work.
This commit is contained in:
@@ -59,6 +59,13 @@ class ViewFrame (gtk.Frame):
|
||||
else:
|
||||
self.unfocus()
|
||||
|
||||
# Get dropped views
|
||||
self.drag_dest_set(gtk.DEST_DEFAULT_ALL,
|
||||
[("GTK_TREE_MODEL_ROW", gtk.TARGET_SAME_APP, 7)],
|
||||
gtk.gdk.ACTION_LINK)
|
||||
self.connect("drag-data-received", self.on_drag_data_received)
|
||||
|
||||
|
||||
# Set view
|
||||
self._view = self.empty_view
|
||||
self._view.connect("button-press-event", self.on_button_press_event)
|
||||
@@ -79,7 +86,7 @@ class ViewFrame (gtk.Frame):
|
||||
return self
|
||||
|
||||
def unfocus(self):
|
||||
"""Removes focus from the ViewFrame if it is focused."""
|
||||
"""Removes focus from the ViewFrame. Does nothing if unfocused."""
|
||||
if not self.focused:
|
||||
return
|
||||
|
||||
@@ -88,6 +95,7 @@ class ViewFrame (gtk.Frame):
|
||||
|
||||
def set_view(self, view):
|
||||
"""Set view to view or to empty view if parameter is None"""
|
||||
|
||||
# if None is passed, use empty view
|
||||
if view == None:
|
||||
view = self.empty_view
|
||||
@@ -104,6 +112,7 @@ class ViewFrame (gtk.Frame):
|
||||
# switch which widget we are listening to
|
||||
if self._button_event:
|
||||
self._view.disconnect(self._button_event)
|
||||
|
||||
self._button_event = view.connect("button-press-event", self.on_button_press_event)
|
||||
|
||||
# remove old view, set new view
|
||||
@@ -124,6 +133,14 @@ class ViewFrame (gtk.Frame):
|
||||
if not self.focused:
|
||||
self.focus()
|
||||
|
||||
def on_drag_data_received(self, widget, drag_context, x, y, selection, info, timestamp):
|
||||
treestore, path = selection.tree_get_row_drag_data()
|
||||
iter = treestore.get_iter(path)
|
||||
obj = treestore.get_value(iter,2)
|
||||
if isinstance(obj, Plot):
|
||||
self.set_view(obj)
|
||||
|
||||
|
||||
class MainView (gtk.Notebook):
|
||||
def __init__(self):
|
||||
gtk.Notebook.__init__(self)
|
||||
|
Reference in New Issue
Block a user