Projects/laydi
Projects
/
laydi
Archived
7
0
Fork 0

Drag and drop from the navigator to the viewframes now work.

This commit is contained in:
Einar Ryeng 2006-05-29 19:14:48 +00:00
parent 581cef75ae
commit 0670c42bd4
2 changed files with 92 additions and 4 deletions

View File

@ -177,6 +177,77 @@
<widget class="GtkMenuItem" id="view1">
<property name="visible">True</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>
</child>
@ -305,7 +376,7 @@
<child>
<widget class="GtkToolButton" id="zoom_in_button">
<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_vertical">True</property>
<property name="is_important">False</property>
@ -320,7 +391,7 @@
<child>
<widget class="GtkToolButton" id="zoom_out_button">
<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_vertical">True</property>
<property name="is_important">False</property>
@ -380,7 +451,7 @@
<widget class="GtkVPaned" id="vpaned1">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="position">300</property>
<property name="position">370</property>
<child>
<widget class="GtkHPaned" id="hpaned1">

View File

@ -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)