From 4a9f8ce93031e9555a695750cde3cb22fd1d87cf Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Manuel=20Qui=C3=B1ones?= <manuq@laptop.org>
Date: Thu, 13 Sep 2012 00:39:55 -0300
Subject: [PATCH sugar-toolkit-gtk3] Style the palette menu header - SL #3879
#3836
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Mail-Followup-To: <sugar-devel@lists.sugarlabs.org>
- Make the first item of the menu a custom class, to make the children
widget allocate using all the available space. And so it can be
styled in the theme.
- Remove the set_sensitive(False) from the header item, this was just
for styling to make it look like an informational, unclickeable
item. But this will be done in the theme instead.
- Add a separator below the header. Is a custom class so it can be
styled in the theme.
Signed-off-by: Manuel Quiñones <manuq@laptop.org>
---
src/sugar3/graphics/palette.py | 44 +++++++++++++++++++++++++++++++-----------
1 file changed, 33 insertions(+), 11 deletions(-)
diff --git a/src/sugar3/graphics/palette.py b/src/sugar3/graphics/palette.py
index 4bb72ce..8b98f9f 100644
a
|
b
|
from sugar3.graphics.palettewindow import MouseSpeedDetector, Invoker, \ |
40 | 40 | WidgetInvoker, CursorInvoker, ToolInvoker, CellRendererInvoker |
41 | 41 | |
42 | 42 | |
| 43 | class _HeaderItem(Gtk.MenuItem): |
| 44 | """ |
| 45 | A MenuItem with a custom child widget that gets all the available |
| 46 | space. |
| 47 | |
| 48 | """ |
| 49 | |
| 50 | __gtype_name__ = 'SugarPaletteHeader' |
| 51 | |
| 52 | def __init__(self, widget): |
| 53 | super(_HeaderItem, self).__init__() |
| 54 | if self.get_child() is not None: |
| 55 | self.remove(self.get_child()) |
| 56 | self.add(widget) |
| 57 | |
| 58 | def do_size_allocate(self, allocation): |
| 59 | self.set_allocation(allocation) |
| 60 | self.get_child().size_allocate(allocation) |
| 61 | |
| 62 | |
| 63 | class _HeaderSeparator(Gtk.SeparatorMenuItem): |
| 64 | |
| 65 | __gtype_name__ = 'SugarPaletteHeaderSeparator' |
| 66 | |
| 67 | def __init__(self): |
| 68 | super(_HeaderSeparator, self).__init__() |
| 69 | |
| 70 | |
43 | 71 | class Palette(PaletteWindow): |
44 | 72 | """ |
45 | 73 | Floating palette implementation. |
… |
… |
class Palette(PaletteWindow): |
375 | 403 | |
376 | 404 | self._widget = _PaletteMenuWidget() |
377 | 405 | |
378 | | self._label_menuitem = Gtk.MenuItem() |
379 | | child = self._label_menuitem.get_child() |
380 | | if child is not None: |
381 | | self._label_menuitem.remove(child) |
382 | | self._label_menuitem.add(self._primary_box) |
383 | | |
384 | | # Mark the menuitem as insensitive so that it appears as an |
385 | | # informational element, rather than a clickable item in the menu. |
386 | | # TODO: see if we can do this better in GTK. |
387 | | self._label_menuitem.set_sensitive(False) |
388 | | |
| 406 | self._label_menuitem = _HeaderItem(self._primary_box) |
389 | 407 | self._label_menuitem.show() |
390 | 408 | self._widget.append(self._label_menuitem) |
391 | 409 | |
| 410 | separator = _HeaderSeparator() |
| 411 | self._widget.append(separator) |
| 412 | separator.show() |
| 413 | |
392 | 414 | self._setup_widget() |
393 | 415 | |
394 | 416 | return self._widget |