DescriptionButton, ShareButton: set the toggle_palette option to True

Setting this option will popup the Palette on left click or tap
and popdown the Palette if it is up. This functionality has been
added with c4165967d5e05607db8b3e0969b516da87855431.

The ShareButton, which derrives from the RadioMenuButton, had the
desired behavior already overriding the on_clicked method, we
do this now in the invoker.

The DescriptionButton did only handle the popup part so far, with
this change the Palette will also popdown when the button is clicked
and the Palette is up.

Since both are Toolbuttons we have to set the hide_tooltip_on_click
property to False otherwise the popdown part would not function, see
1a8f89226b for more info.

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-06 08:39:27 +01:00
parent f0fe248e30
commit 2834344b98
2 changed files with 5 additions and 14 deletions

View File

@ -226,6 +226,8 @@ class DescriptionItem(Gtk.ToolItem):
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()
description_box = Gtk.HBox()
@ -249,8 +251,6 @@ class DescriptionItem(Gtk.ToolItem):
description_box.show_all()
self.add(description_button)
description_button.connect('clicked',
self.__description_button_clicked_cb)
activity.metadata.connect('updated', self.__jobject_updated_cb)
@ -270,9 +270,6 @@ class DescriptionItem(Gtk.ToolItem):
buf = self._text_view.get_buffer()
buf.set_text(jobject['description'])
def __description_button_clicked_cb(self, button):
self._palette.popup(immediate=True, state=1)
def __description_changed_cb(self, widget, event, activity):
description = self._get_text_from_buffer()
if 'description' in activity.metadata and \

View File

@ -27,6 +27,9 @@ class RadioMenuButton(ToolButton):
ToolButton.__init__(self, **kwargs)
self.selected_button = None
self.palette_invoker.props.toggle_palette = True
self.props.hide_tooltip_on_click = False
if self.props.palette:
self.__palette_cb(None, None)
@ -37,15 +40,6 @@ class RadioMenuButton(ToolButton):
return
self.props.palette.update_button()
def do_clicked(self):
if self.palette is None:
return
if self.palette.is_up() and \
self.palette.palette_state == Palette.SECONDARY:
self.palette.popdown(immediate=True)
else:
self.palette.popup(immediate=True, state=Palette.SECONDARY)
class RadioToolsButton(RadioMenuButton):