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): |
47 | 47 | self._can_scroll_next = False |
48 | 48 | self._can_scroll_prev = False |
49 | 49 | |
50 | | GObject.GObject.__init__(self) |
| 50 | Gtk.Viewport.__init__(self) |
51 | 51 | |
52 | 52 | self.set_shadow_type(Gtk.ShadowType.NONE) |
53 | 53 | |
… |
… |
class _TrayViewport(Gtk.Viewport): |
138 | 138 | |
139 | 139 | def _size_allocate_cb(self, viewport, allocation): |
140 | 140 | bar_minimum, bar_natural = self.traybar.get_preferred_size() |
| 141 | |
141 | 142 | if self.orientation == Gtk.Orientation.HORIZONTAL: |
142 | 143 | scrollable = bar_minimum.width > allocation.width |
143 | 144 | else: |
… |
… |
class _TrayViewport(Gtk.Viewport): |
170 | 171 | |
171 | 172 | class _TrayScrollButton(ToolButton): |
172 | 173 | |
| 174 | __gtype_name__ = 'SugarTrayScrollButton' |
| 175 | |
173 | 176 | def __init__(self, icon_name, scroll_direction): |
174 | 177 | ToolButton.__init__(self) |
175 | 178 | self._viewport = None |
… |
… |
ALIGN_TO_START = 0 |
224 | 227 | ALIGN_TO_END = 1 |
225 | 228 | |
226 | 229 | |
227 | | class HTray(Gtk.HBox): |
| 230 | class HTray(Gtk.EventBox): |
228 | 231 | |
229 | 232 | __gtype_name__ = 'SugarHTray' |
230 | 233 | |
… |
… |
class HTray(Gtk.HBox): |
238 | 241 | self._drag_active = False |
239 | 242 | self.align = ALIGN_TO_START |
240 | 243 | |
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() |
242 | 249 | |
243 | 250 | 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) |
245 | 252 | |
246 | 253 | 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) |
248 | 255 | self._viewport.show() |
249 | 256 | |
250 | 257 | 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) |
252 | 259 | |
253 | 260 | scroll_left.viewport = self._viewport |
254 | 261 | scroll_right.viewport = self._viewport |
… |
… |
class HTray(Gtk.HBox): |
310 | 317 | self._viewport.scroll_to_item(item) |
311 | 318 | |
312 | 319 | |
313 | | class VTray(Gtk.VBox): |
| 320 | class VTray(Gtk.EventBox): |
314 | 321 | |
315 | 322 | __gtype_name__ = 'SugarVTray' |
316 | 323 | |
… |
… |
class VTray(Gtk.VBox): |
324 | 331 | self._drag_active = False |
325 | 332 | self.align = ALIGN_TO_START |
326 | 333 | |
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() |
328 | 339 | |
329 | 340 | 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) |
331 | 342 | |
332 | 343 | 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) |
334 | 345 | self._viewport.show() |
335 | 346 | |
336 | 347 | 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) |
338 | 349 | |
339 | 350 | scroll_up.viewport = self._viewport |
340 | 351 | scroll_down.viewport = self._viewport |
… |
… |
class _IconWidget(Gtk.EventBox): |
407 | 418 | __gtype_name__ = 'SugarTrayIconWidget' |
408 | 419 | |
409 | 420 | def __init__(self, icon_name=None, xo_color=None): |
410 | | GObject.GObject.__init__(self) |
| 421 | Gtk.EventBox.__init__(self) |
411 | 422 | |
412 | 423 | self.set_app_paintable(True) |
413 | 424 | self.add_events(Gdk.EventMask.BUTTON_PRESS_MASK | |