Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSimon Schampijer <simon@laptop.org>2012-12-10 14:47:52 (GMT)
committer Simon Schampijer <simon@laptop.org>2012-12-10 17:35:45 (GMT)
commitf5fee8a1445f76d3b04497671a93179329fe1efb (patch)
treee5f2392e23fd92eb1aafe4744883c5b0b72852df
parente49f6211108b88c086fbf98f83d3442f1c666b2f (diff)
Popdown the palette if an item in the content box gets activated, SL #4191 and SL #4253
The Palette is popped down when an item is activated. We can listen on the 'button-release-event' on that widget. We make sure the widget is of type PaletteMenuItem. This is similar to what the GtkMenu is doing, see gtk_menu_shell_button_release [1]. [1] http://git.gnome.org/browse/gtk+/tree/gtk/gtkmenushell.c#n915 Signed-off-by: Simon Schampijer <simon@laptop.org> Acked-by: Manuel QuiƱones <manuq@laptop.org>
-rw-r--r--src/sugar3/graphics/palette.py9
1 files changed, 9 insertions, 0 deletions
diff --git a/src/sugar3/graphics/palette.py b/src/sugar3/graphics/palette.py
index 0e49e35..a085fa9 100644
--- a/src/sugar3/graphics/palette.py
+++ b/src/sugar3/graphics/palette.py
@@ -33,6 +33,7 @@ from sugar3.graphics import style
from sugar3.graphics.icon import Icon
from sugar3.graphics.palettewindow import PaletteWindow, \
_PaletteWindowWidget, _PaletteMenuWidget
+from sugar3.graphics.palettemenu import PaletteMenuItem
# DEPRECATED
# Import these for backwards compatibility
@@ -342,6 +343,8 @@ class Palette(PaletteWindow):
self._content.remove(self._content.get_children()[0])
if widget is not None:
+ widget.connect('button-release-event',
+ self.__widget_button_release_cb)
self._content.add(widget)
self._content.show()
else:
@@ -352,6 +355,12 @@ class Palette(PaletteWindow):
self._update_accept_focus()
self._update_separators()
+ def __widget_button_release_cb(self, widget, event):
+ event_widget = Gtk.get_event_widget(event)
+ if isinstance(event_widget, PaletteMenuItem):
+ self.popdown(immediate=True)
+ return False
+
def get_label_width(self):
# Gtk.AccelLabel request doesn't include the accelerator.
label_width = self._label_alignment.get_preferred_width()[1] + \