diff --git a/src/sugar3/graphics/palette.py b/src/sugar3/graphics/palette.py
index 0e49e35..bd7942f 100644
a
|
b
|
|
22 | 22 | """ |
23 | 23 | STABLE. |
24 | 24 | """ |
25 | | |
26 | 25 | from gi.repository import Gtk |
27 | 26 | from gi.repository import GObject |
28 | 27 | from gi.repository import Pango |
… |
… |
from sugar3.graphics import style |
33 | 32 | from sugar3.graphics.icon import Icon |
34 | 33 | from sugar3.graphics.palettewindow import PaletteWindow, \ |
35 | 34 | _PaletteWindowWidget, _PaletteMenuWidget |
| 35 | from sugar3.graphics.palettemenu import PaletteMenuBox |
36 | 36 | |
37 | 37 | # DEPRECATED |
38 | 38 | # Import these for backwards compatibility |
… |
… |
class Palette(PaletteWindow): |
342 | 342 | self._content.remove(self._content.get_children()[0]) |
343 | 343 | |
344 | 344 | if widget is not None: |
| 345 | if isinstance(widget, PaletteMenuBox): |
| 346 | widget.connect('item-activate', self.__item_activate_cb) |
345 | 347 | self._content.add(widget) |
346 | 348 | self._content.show() |
347 | 349 | else: |
… |
… |
class Palette(PaletteWindow): |
414 | 416 | |
415 | 417 | menu = GObject.property(type=object, getter=get_menu) |
416 | 418 | |
| 419 | def __item_activate_cb(self, widget): |
| 420 | self.popdown(immediate=True) |
| 421 | |
417 | 422 | |
418 | 423 | class PaletteActionBar(Gtk.HButtonBox): |
419 | 424 | |
diff --git a/src/sugar3/graphics/palettemenu.py b/src/sugar3/graphics/palettemenu.py
index 2bf7227..64aa38e 100644
a
|
b
|
from sugar3.graphics import style |
24 | 24 | |
25 | 25 | |
26 | 26 | class PaletteMenuBox(Gtk.VBox): |
| 27 | |
| 28 | __gsignals__ = { |
| 29 | 'item-activate': (GObject.SignalFlags.RUN_FIRST, None, []) |
| 30 | } |
| 31 | |
27 | 32 | def __init__(self): |
28 | 33 | Gtk.VBox.__init__(self) |
29 | 34 | |
… |
… |
class PaletteMenuBox(Gtk.VBox): |
37 | 42 | item = self._wrap_widget(item_or_widget, horizontal_padding, |
38 | 43 | vertical_padding) |
39 | 44 | |
| 45 | if isinstance(item, PaletteMenuItem): |
| 46 | item.connect('activate', self.__item_activated_cb) |
| 47 | |
40 | 48 | self.pack_start(item, False, False, 0) |
41 | 49 | |
42 | 50 | def _wrap_widget(self, widget, horizontal_padding, vertical_padding): |
… |
… |
class PaletteMenuBox(Gtk.VBox): |
56 | 64 | hbox.pack_start(widget, True, True, horizontal_padding) |
57 | 65 | return vbox |
58 | 66 | |
| 67 | def __item_activated_cb(self, item): |
| 68 | self.emit('item-activate') |
| 69 | |
59 | 70 | |
60 | 71 | class PaletteMenuItemSeparator(Gtk.EventBox): |
61 | 72 | """Contains a HSeparator and has the proper height for the menu.""" |