Add support for locking Palettes, SL #4008

This adds a property that indicates that a Palette should
behave in a locking manner. The behaviour is the same
as with the secondary Toolbars: when you hover over the invoking
widget the Palette will popdown and react to mouse movements,
leaving the invoker area or the Palette itself will popdown
the Palette again. When you click the invoking widget
the Palette will be locked. You have to unlock it again
to pop it down.

This patch makes the DescriptionButton and the Colorbutton
work.

If the DescriptionButton or the Colorbutton are placed in
the primary toolbar they will share the locked state with
the secondary toolbars. Only one can be locked at a time.

When a secondary toolbar is unlocked we do force that the
open Palettes are closed. Having a locking Palette in
a subtoolbar will also work (Activity Toolbar case or
ColorButton case in a few examples). There is no state
sharing implemented here at the moment, but so far we
do only have cases with one lockable Palette in a
subtoolbar.

This will also fix the case where we want to use the
OSK to edit the description of the activity SL #3887.

Signed-off-by: Simon Schampijer <simon@laptop.org>
Acked-by: Manuel Quiñones <manuq@laptop.org>
This commit is contained in:
Simon Schampijer
2012-11-15 18:09:00 +01:00
parent 2d9e9ec526
commit 6064fb30cc
4 changed files with 105 additions and 25 deletions
+30 -11
View File
@@ -219,17 +219,15 @@ class TitleEntry(Gtk.ToolItem):
shared_activity.props.name = title
class DescriptionItem(Gtk.ToolItem):
class DescriptionItem(ToolButton):
def __init__(self, activity, **kwargs):
Gtk.ToolItem.__init__(self)
description_button = ToolButton('edit-description')
description_button.show()
description_button.set_tooltip(_('Description'))
description_button.palette_invoker.props.toggle_palette = True
description_button.props.hide_tooltip_on_click = False
self._palette = description_button.get_palette()
ToolButton.__init__(self, 'edit-description', **kwargs)
self.set_tooltip(_('Description'))
self.palette_invoker.props.toggle_palette = True
self.palette_invoker.props.lock_palette = True
self.props.hide_tooltip_on_click = False
self._palette = self.get_palette()
description_box = PaletteMenuBox()
sw = Gtk.ScrolledWindow()
@@ -251,10 +249,31 @@ class DescriptionItem(Gtk.ToolItem):
self._palette.set_content(description_box)
description_box.show_all()
self.add(description_button)
activity.metadata.connect('updated', self.__jobject_updated_cb)
def set_expanded(self, expanded):
box = self.toolbar_box
if not box:
return
if not expanded:
self.palette_invoker.notify_popdown()
return
if box.expanded_button is not None:
box.expanded_button.queue_draw()
if box.expanded_button != self:
box.expanded_button.set_expanded(False)
box.expanded_button = self
def get_toolbar_box(self):
parent = self.get_parent()
if not hasattr(parent, 'owner'):
return None
return parent.owner
toolbar_box = property(get_toolbar_box)
def _get_text_from_buffer(self):
buf = self._text_view.get_buffer()
start_iter = buf.get_start_iter()