Ticket #3565: 0001-Tray-wrap-them-in-EventBoxes-in-order-to-make-them-t.patch

File 0001-Tray-wrap-them-in-EventBoxes-in-order-to-make-them-t.patch, 4.3 KB (added by manuq, 11 years ago)

Candidate patch for 1.

  • src/sugar3/graphics/tray.py

    From 76f77b2a13b474423d4832913081c24ff10ff198 Mon Sep 17 00:00:00 2001
    From: =?UTF-8?q?Manuel=20Qui=C3=B1ones?= <manuq@laptop.org>
    Date: Wed, 28 Nov 2012 18:47:24 -0300
    Subject: [PATCH toolkit] Tray: wrap them in EventBoxes in order to make them
     themeable - SL #3565
    MIME-Version: 1.0
    Content-Type: text/plain; charset=UTF-8
    Content-Transfer-Encoding: 8bit
    Mail-Followup-To: <sugar-devel@lists.sugarlabs.org>
    
    We have to convert the boxes to EventBoxes because otherwise the
    background is not themeable [1]
    
    [1] https://bugzilla.gnome.org/show_bug.cgi?id=678790
    
    Signed-off-by: Manuel Quiñones <manuq@laptop.org>
    ---
     src/sugar3/graphics/tray.py | 35 +++++++++++++++++++++++------------
     1 file changed, 23 insertions(+), 12 deletions(-)
    
    diff --git a/src/sugar3/graphics/tray.py b/src/sugar3/graphics/tray.py
    index 0b3ca9a..9d12883 100644
    a b class _TrayViewport(Gtk.Viewport): 
    4747        self._can_scroll_next = False
    4848        self._can_scroll_prev = False
    4949
    50         GObject.GObject.__init__(self)
     50        Gtk.Viewport.__init__(self)
    5151
    5252        self.set_shadow_type(Gtk.ShadowType.NONE)
    5353
    class _TrayViewport(Gtk.Viewport): 
    138138
    139139    def _size_allocate_cb(self, viewport, allocation):
    140140        bar_minimum, bar_natural = self.traybar.get_preferred_size()
     141
    141142        if self.orientation == Gtk.Orientation.HORIZONTAL:
    142143            scrollable = bar_minimum.width > allocation.width
    143144        else:
    class _TrayViewport(Gtk.Viewport): 
    170171
    171172class _TrayScrollButton(ToolButton):
    172173
     174    __gtype_name__ = 'SugarTrayScrollButton'
     175
    173176    def __init__(self, icon_name, scroll_direction):
    174177        ToolButton.__init__(self)
    175178        self._viewport = None
    ALIGN_TO_START = 0 
    224227ALIGN_TO_END = 1
    225228
    226229
    227 class HTray(Gtk.HBox):
     230class HTray(Gtk.EventBox):
    228231
    229232    __gtype_name__ = 'SugarHTray'
    230233
    class HTray(Gtk.HBox): 
    238241        self._drag_active = False
    239242        self.align = ALIGN_TO_START
    240243
    241         GObject.GObject.__init__(self, **kwargs)
     244        Gtk.EventBox.__init__(self, **kwargs)
     245
     246        self._box = Gtk.HBox()
     247        self.add(self._box)
     248        self._box.show()
    242249
    243250        scroll_left = _TrayScrollButton('go-left', _PREVIOUS_PAGE)
    244         self.pack_start(scroll_left, False, False, 0)
     251        self._box.pack_start(scroll_left, False, False, 0)
    245252
    246253        self._viewport = _TrayViewport(Gtk.Orientation.HORIZONTAL)
    247         self.pack_start(self._viewport, True, True, 0)
     254        self._box.pack_start(self._viewport, True, True, 0)
    248255        self._viewport.show()
    249256
    250257        scroll_right = _TrayScrollButton('go-right', _NEXT_PAGE)
    251         self.pack_start(scroll_right, False, False, 0)
     258        self._box.pack_start(scroll_right, False, False, 0)
    252259
    253260        scroll_left.viewport = self._viewport
    254261        scroll_right.viewport = self._viewport
    class HTray(Gtk.HBox): 
    310317        self._viewport.scroll_to_item(item)
    311318
    312319
    313 class VTray(Gtk.VBox):
     320class VTray(Gtk.EventBox):
    314321
    315322    __gtype_name__ = 'SugarVTray'
    316323
    class VTray(Gtk.VBox): 
    324331        self._drag_active = False
    325332        self.align = ALIGN_TO_START
    326333
    327         GObject.GObject.__init__(self, **kwargs)
     334        Gtk.EventBox.__init__(self, **kwargs)
     335
     336        self._box = Gtk.VBox()
     337        self.add(self._box)
     338        self._box.show()
    328339
    329340        scroll_up = _TrayScrollButton('go-up', _PREVIOUS_PAGE)
    330         self.pack_start(scroll_up, False, False, 0)
     341        self._box.pack_start(scroll_up, False, False, 0)
    331342
    332343        self._viewport = _TrayViewport(Gtk.Orientation.VERTICAL)
    333         self.pack_start(self._viewport, True, True, 0)
     344        self._box.pack_start(self._viewport, True, True, 0)
    334345        self._viewport.show()
    335346
    336347        scroll_down = _TrayScrollButton('go-down', _NEXT_PAGE)
    337         self.pack_start(scroll_down, False, False, 0)
     348        self._box.pack_start(scroll_down, False, False, 0)
    338349
    339350        scroll_up.viewport = self._viewport
    340351        scroll_down.viewport = self._viewport
    class _IconWidget(Gtk.EventBox): 
    407418    __gtype_name__ = 'SugarTrayIconWidget'
    408419
    409420    def __init__(self, icon_name=None, xo_color=None):
    410         GObject.GObject.__init__(self)
     421        Gtk.EventBox.__init__(self)
    411422
    412423        self.set_app_paintable(True)
    413424        self.add_events(Gdk.EventMask.BUTTON_PRESS_MASK |