Drag and drop from the navigator to the viewframes now work.
This commit is contained in:
parent
581cef75ae
commit
0670c42bd4
|
@ -177,6 +177,77 @@
|
||||||
<widget class="GtkMenuItem" id="view1">
|
<widget class="GtkMenuItem" id="view1">
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
<property name="stock_item">GNOMEUIINFO_MENU_VIEW_TREE</property>
|
<property name="stock_item">GNOMEUIINFO_MENU_VIEW_TREE</property>
|
||||||
|
|
||||||
|
<child>
|
||||||
|
<widget class="GtkMenu" id="view1_menu">
|
||||||
|
|
||||||
|
<child>
|
||||||
|
<widget class="GtkMenuItem" id="large_view1">
|
||||||
|
<property name="visible">True</property>
|
||||||
|
<property name="label" translatable="yes">Large View</property>
|
||||||
|
<property name="use_underline">True</property>
|
||||||
|
<signal name="activate" handler="on_large_view1_activate" last_modification_time="Fri, 26 May 2006 12:15:59 GMT"/>
|
||||||
|
<accelerator key="plus" modifiers="GDK_CONTROL_MASK" signal="activate"/>
|
||||||
|
</widget>
|
||||||
|
</child>
|
||||||
|
|
||||||
|
<child>
|
||||||
|
<widget class="GtkMenuItem" id="small_view1">
|
||||||
|
<property name="visible">True</property>
|
||||||
|
<property name="label" translatable="yes">Small View</property>
|
||||||
|
<property name="use_underline">True</property>
|
||||||
|
<signal name="activate" handler="on_small_view1_activate" last_modification_time="Fri, 26 May 2006 12:15:59 GMT"/>
|
||||||
|
<accelerator key="minus" modifiers="GDK_CONTROL_MASK" signal="activate"/>
|
||||||
|
</widget>
|
||||||
|
</child>
|
||||||
|
|
||||||
|
<child>
|
||||||
|
<widget class="GtkSeparatorMenuItem" id="separator4">
|
||||||
|
<property name="visible">True</property>
|
||||||
|
</widget>
|
||||||
|
</child>
|
||||||
|
|
||||||
|
<child>
|
||||||
|
<widget class="GtkMenuItem" id="left1">
|
||||||
|
<property name="visible">True</property>
|
||||||
|
<property name="label" translatable="yes">Left</property>
|
||||||
|
<property name="use_underline">True</property>
|
||||||
|
<signal name="activate" handler="on_left1_activate" last_modification_time="Fri, 26 May 2006 13:04:33 GMT"/>
|
||||||
|
<accelerator key="Left" modifiers="GDK_CONTROL_MASK" signal="activate"/>
|
||||||
|
</widget>
|
||||||
|
</child>
|
||||||
|
|
||||||
|
<child>
|
||||||
|
<widget class="GtkMenuItem" id="right1">
|
||||||
|
<property name="visible">True</property>
|
||||||
|
<property name="label" translatable="yes">Right</property>
|
||||||
|
<property name="use_underline">True</property>
|
||||||
|
<signal name="activate" handler="on_right1_activate" last_modification_time="Fri, 26 May 2006 13:04:33 GMT"/>
|
||||||
|
<accelerator key="Right" modifiers="GDK_CONTROL_MASK" signal="activate"/>
|
||||||
|
</widget>
|
||||||
|
</child>
|
||||||
|
|
||||||
|
<child>
|
||||||
|
<widget class="GtkMenuItem" id="up1">
|
||||||
|
<property name="visible">True</property>
|
||||||
|
<property name="label" translatable="yes">Up</property>
|
||||||
|
<property name="use_underline">True</property>
|
||||||
|
<signal name="activate" handler="on_up1_activate" last_modification_time="Fri, 26 May 2006 13:04:33 GMT"/>
|
||||||
|
<accelerator key="Up" modifiers="GDK_CONTROL_MASK" signal="activate"/>
|
||||||
|
</widget>
|
||||||
|
</child>
|
||||||
|
|
||||||
|
<child>
|
||||||
|
<widget class="GtkMenuItem" id="down1">
|
||||||
|
<property name="visible">True</property>
|
||||||
|
<property name="label" translatable="yes">Down</property>
|
||||||
|
<property name="use_underline">True</property>
|
||||||
|
<signal name="activate" handler="on_down1_activate" last_modification_time="Fri, 26 May 2006 13:04:33 GMT"/>
|
||||||
|
<accelerator key="Down" modifiers="GDK_CONTROL_MASK" signal="activate"/>
|
||||||
|
</widget>
|
||||||
|
</child>
|
||||||
|
</widget>
|
||||||
|
</child>
|
||||||
</widget>
|
</widget>
|
||||||
</child>
|
</child>
|
||||||
|
|
||||||
|
@ -305,7 +376,7 @@
|
||||||
<child>
|
<child>
|
||||||
<widget class="GtkToolButton" id="zoom_in_button">
|
<widget class="GtkToolButton" id="zoom_in_button">
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
<property name="stock_id">gtk-zoom-in</property>
|
<property name="stock_id">gtk-fullscreen</property>
|
||||||
<property name="visible_horizontal">True</property>
|
<property name="visible_horizontal">True</property>
|
||||||
<property name="visible_vertical">True</property>
|
<property name="visible_vertical">True</property>
|
||||||
<property name="is_important">False</property>
|
<property name="is_important">False</property>
|
||||||
|
@ -320,7 +391,7 @@
|
||||||
<child>
|
<child>
|
||||||
<widget class="GtkToolButton" id="zoom_out_button">
|
<widget class="GtkToolButton" id="zoom_out_button">
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
<property name="stock_id">gtk-zoom-out</property>
|
<property name="stock_id">gtk-leave-fullscreen</property>
|
||||||
<property name="visible_horizontal">True</property>
|
<property name="visible_horizontal">True</property>
|
||||||
<property name="visible_vertical">True</property>
|
<property name="visible_vertical">True</property>
|
||||||
<property name="is_important">False</property>
|
<property name="is_important">False</property>
|
||||||
|
@ -380,7 +451,7 @@
|
||||||
<widget class="GtkVPaned" id="vpaned1">
|
<widget class="GtkVPaned" id="vpaned1">
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
<property name="can_focus">True</property>
|
<property name="can_focus">True</property>
|
||||||
<property name="position">300</property>
|
<property name="position">370</property>
|
||||||
|
|
||||||
<child>
|
<child>
|
||||||
<widget class="GtkHPaned" id="hpaned1">
|
<widget class="GtkHPaned" id="hpaned1">
|
|
@ -59,6 +59,13 @@ class ViewFrame (gtk.Frame):
|
||||||
else:
|
else:
|
||||||
self.unfocus()
|
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
|
# Set view
|
||||||
self._view = self.empty_view
|
self._view = self.empty_view
|
||||||
self._view.connect("button-press-event", self.on_button_press_event)
|
self._view.connect("button-press-event", self.on_button_press_event)
|
||||||
|
@ -79,7 +86,7 @@ class ViewFrame (gtk.Frame):
|
||||||
return self
|
return self
|
||||||
|
|
||||||
def unfocus(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:
|
if not self.focused:
|
||||||
return
|
return
|
||||||
|
|
||||||
|
@ -88,6 +95,7 @@ class ViewFrame (gtk.Frame):
|
||||||
|
|
||||||
def set_view(self, view):
|
def set_view(self, view):
|
||||||
"""Set view to view or to empty view if parameter is None"""
|
"""Set view to view or to empty view if parameter is None"""
|
||||||
|
|
||||||
# if None is passed, use empty view
|
# if None is passed, use empty view
|
||||||
if view == None:
|
if view == None:
|
||||||
view = self.empty_view
|
view = self.empty_view
|
||||||
|
@ -104,6 +112,7 @@ class ViewFrame (gtk.Frame):
|
||||||
# switch which widget we are listening to
|
# switch which widget we are listening to
|
||||||
if self._button_event:
|
if self._button_event:
|
||||||
self._view.disconnect(self._button_event)
|
self._view.disconnect(self._button_event)
|
||||||
|
|
||||||
self._button_event = view.connect("button-press-event", self.on_button_press_event)
|
self._button_event = view.connect("button-press-event", self.on_button_press_event)
|
||||||
|
|
||||||
# remove old view, set new view
|
# remove old view, set new view
|
||||||
|
@ -124,6 +133,14 @@ class ViewFrame (gtk.Frame):
|
||||||
if not self.focused:
|
if not self.focused:
|
||||||
self.focus()
|
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):
|
class MainView (gtk.Notebook):
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
gtk.Notebook.__init__(self)
|
gtk.Notebook.__init__(self)
|
||||||
|
|
Reference in New Issue