From 2834344b985ae9645627ce55c4204a4556db3385 Mon Sep 17 00:00:00 2001 From: Simon Schampijer Date: Tue, 06 Nov 2012 07:39:27 +0000 Subject: 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 1a8f89226b4f979000d80edc7123b7d22b23dc91 for more info. Signed-off-by: Simon Schampijer Acked-by: Manuel QuiƱones --- diff --git a/src/sugar3/activity/widgets.py b/src/sugar3/activity/widgets.py index 0d9c9e2..699674c 100644 --- a/src/sugar3/activity/widgets.py +++ b/src/sugar3/activity/widgets.py @@ -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 \ diff --git a/src/sugar3/graphics/radiopalette.py b/src/sugar3/graphics/radiopalette.py index 29f4159..b1e4679 100644 --- a/src/sugar3/graphics/radiopalette.py +++ b/src/sugar3/graphics/radiopalette.py @@ -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): -- cgit v0.9.1