Ticket #4253: activate-item-toolkit.patch

File activate-item-toolkit.patch, 2.4 KB (added by manuq, 10 years ago)

Trying a more general solution, toolkit patch.

  • src/sugar3/graphics/palette.py

    diff --git a/src/sugar3/graphics/palette.py b/src/sugar3/graphics/palette.py
    index 0e49e35..bd7942f 100644
    a b  
    2222"""
    2323STABLE.
    2424"""
    25 
    2625from gi.repository import Gtk
    2726from gi.repository import GObject
    2827from gi.repository import Pango
    from sugar3.graphics import style 
    3332from sugar3.graphics.icon import Icon
    3433from sugar3.graphics.palettewindow import PaletteWindow, \
    3534    _PaletteWindowWidget, _PaletteMenuWidget
     35from sugar3.graphics.palettemenu import PaletteMenuBox
    3636
    3737# DEPRECATED
    3838# Import these for backwards compatibility
    class Palette(PaletteWindow): 
    342342            self._content.remove(self._content.get_children()[0])
    343343
    344344        if widget is not None:
     345            if isinstance(widget, PaletteMenuBox):
     346                widget.connect('item-activate', self.__item_activate_cb)
    345347            self._content.add(widget)
    346348            self._content.show()
    347349        else:
    class Palette(PaletteWindow): 
    414416
    415417    menu = GObject.property(type=object, getter=get_menu)
    416418
     419    def __item_activate_cb(self, widget):
     420        self.popdown(immediate=True)
     421
    417422
    418423class PaletteActionBar(Gtk.HButtonBox):
    419424
  • src/sugar3/graphics/palettemenu.py

    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 
    2424
    2525
    2626class PaletteMenuBox(Gtk.VBox):
     27
     28    __gsignals__ = {
     29        'item-activate': (GObject.SignalFlags.RUN_FIRST, None, [])
     30    }
     31
    2732    def __init__(self):
    2833        Gtk.VBox.__init__(self)
    2934
    class PaletteMenuBox(Gtk.VBox): 
    3742            item = self._wrap_widget(item_or_widget, horizontal_padding,
    3843                                     vertical_padding)
    3944
     45        if isinstance(item, PaletteMenuItem):
     46            item.connect('activate', self.__item_activated_cb)
     47
    4048        self.pack_start(item, False, False, 0)
    4149
    4250    def _wrap_widget(self, widget, horizontal_padding, vertical_padding):
    class PaletteMenuBox(Gtk.VBox): 
    5664        hbox.pack_start(widget, True, True, horizontal_padding)
    5765        return vbox
    5866
     67    def __item_activated_cb(self, item):
     68        self.emit('item-activate')
     69
    5970
    6071class PaletteMenuItemSeparator(Gtk.EventBox):
    6172    """Contains a HSeparator and has the proper height for the menu."""