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>
This commit is contained in:
parent
e49f621110
commit
f5fee8a144
@ -33,6 +33,7 @@ from sugar3.graphics import style
|
|||||||
from sugar3.graphics.icon import Icon
|
from sugar3.graphics.icon import Icon
|
||||||
from sugar3.graphics.palettewindow import PaletteWindow, \
|
from sugar3.graphics.palettewindow import PaletteWindow, \
|
||||||
_PaletteWindowWidget, _PaletteMenuWidget
|
_PaletteWindowWidget, _PaletteMenuWidget
|
||||||
|
from sugar3.graphics.palettemenu import PaletteMenuItem
|
||||||
|
|
||||||
# DEPRECATED
|
# DEPRECATED
|
||||||
# Import these for backwards compatibility
|
# Import these for backwards compatibility
|
||||||
@ -342,6 +343,8 @@ class Palette(PaletteWindow):
|
|||||||
self._content.remove(self._content.get_children()[0])
|
self._content.remove(self._content.get_children()[0])
|
||||||
|
|
||||||
if widget is not None:
|
if widget is not None:
|
||||||
|
widget.connect('button-release-event',
|
||||||
|
self.__widget_button_release_cb)
|
||||||
self._content.add(widget)
|
self._content.add(widget)
|
||||||
self._content.show()
|
self._content.show()
|
||||||
else:
|
else:
|
||||||
@ -352,6 +355,12 @@ class Palette(PaletteWindow):
|
|||||||
self._update_accept_focus()
|
self._update_accept_focus()
|
||||||
self._update_separators()
|
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):
|
def get_label_width(self):
|
||||||
# Gtk.AccelLabel request doesn't include the accelerator.
|
# Gtk.AccelLabel request doesn't include the accelerator.
|
||||||
label_width = self._label_alignment.get_preferred_width()[1] + \
|
label_width = self._label_alignment.get_preferred_width()[1] + \
|
||||||
|
Loading…
Reference in New Issue
Block a user