From d418d1cbdd44953e4b8ea146a8195ed1651ce03e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Manuel=20Qui=C3=B1ones?= Date: Wed, 28 Nov 2012 18:47:24 -0300 Subject: [PATCH] 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 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 Acked-by: Simon Schampijer --- 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 0b3ca9ab..9d128836 100644 --- a/src/sugar3/graphics/tray.py +++ b/src/sugar3/graphics/tray.py @@ -47,7 +47,7 @@ class _TrayViewport(Gtk.Viewport): self._can_scroll_next = False self._can_scroll_prev = False - GObject.GObject.__init__(self) + Gtk.Viewport.__init__(self) self.set_shadow_type(Gtk.ShadowType.NONE) @@ -138,6 +138,7 @@ class _TrayViewport(Gtk.Viewport): def _size_allocate_cb(self, viewport, allocation): bar_minimum, bar_natural = self.traybar.get_preferred_size() + if self.orientation == Gtk.Orientation.HORIZONTAL: scrollable = bar_minimum.width > allocation.width else: @@ -170,6 +171,8 @@ class _TrayViewport(Gtk.Viewport): class _TrayScrollButton(ToolButton): + __gtype_name__ = 'SugarTrayScrollButton' + def __init__(self, icon_name, scroll_direction): ToolButton.__init__(self) self._viewport = None @@ -224,7 +227,7 @@ ALIGN_TO_START = 0 ALIGN_TO_END = 1 -class HTray(Gtk.HBox): +class HTray(Gtk.EventBox): __gtype_name__ = 'SugarHTray' @@ -238,17 +241,21 @@ class HTray(Gtk.HBox): self._drag_active = False self.align = ALIGN_TO_START - GObject.GObject.__init__(self, **kwargs) + Gtk.EventBox.__init__(self, **kwargs) + + self._box = Gtk.HBox() + self.add(self._box) + self._box.show() scroll_left = _TrayScrollButton('go-left', _PREVIOUS_PAGE) - self.pack_start(scroll_left, False, False, 0) + self._box.pack_start(scroll_left, False, False, 0) self._viewport = _TrayViewport(Gtk.Orientation.HORIZONTAL) - self.pack_start(self._viewport, True, True, 0) + self._box.pack_start(self._viewport, True, True, 0) self._viewport.show() scroll_right = _TrayScrollButton('go-right', _NEXT_PAGE) - self.pack_start(scroll_right, False, False, 0) + self._box.pack_start(scroll_right, False, False, 0) scroll_left.viewport = self._viewport scroll_right.viewport = self._viewport @@ -310,7 +317,7 @@ class HTray(Gtk.HBox): self._viewport.scroll_to_item(item) -class VTray(Gtk.VBox): +class VTray(Gtk.EventBox): __gtype_name__ = 'SugarVTray' @@ -324,17 +331,21 @@ class VTray(Gtk.VBox): self._drag_active = False self.align = ALIGN_TO_START - GObject.GObject.__init__(self, **kwargs) + Gtk.EventBox.__init__(self, **kwargs) + + self._box = Gtk.VBox() + self.add(self._box) + self._box.show() scroll_up = _TrayScrollButton('go-up', _PREVIOUS_PAGE) - self.pack_start(scroll_up, False, False, 0) + self._box.pack_start(scroll_up, False, False, 0) self._viewport = _TrayViewport(Gtk.Orientation.VERTICAL) - self.pack_start(self._viewport, True, True, 0) + self._box.pack_start(self._viewport, True, True, 0) self._viewport.show() scroll_down = _TrayScrollButton('go-down', _NEXT_PAGE) - self.pack_start(scroll_down, False, False, 0) + self._box.pack_start(scroll_down, False, False, 0) scroll_up.viewport = self._viewport scroll_down.viewport = self._viewport @@ -407,7 +418,7 @@ class _IconWidget(Gtk.EventBox): __gtype_name__ = 'SugarTrayIconWidget' def __init__(self, icon_name=None, xo_color=None): - GObject.GObject.__init__(self) + Gtk.EventBox.__init__(self) self.set_app_paintable(True) self.add_events(Gdk.EventMask.BUTTON_PRESS_MASK |