Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorManuel Quiñones <manuq@laptop.org>2012-09-13 03:39:55 (GMT)
committer Manuel Quiñones <manuq@laptop.org>2012-09-13 15:10:43 (GMT)
commitdbe32ec7cfe896c0c99d8f2bf80ab7883eabbeff (patch)
treef1e7dc334181e9e5082a929c5ac09608c8ca7b94
parent5cb4a48c5bc17a5fea14446919259c0a5e12ec6a (diff)
Style the palette menu header - SL #3879 #3836
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, because the icon was greyed out. This was to make it an informational, unclickeable item. I am making it look like an informational item in the theme instead. This has the problem that its still navigateable with keyboard and clickeable, so it has to be fixed later. 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> Acked-by: Simon Schampijer <simon@laptop.org>
-rw-r--r--src/sugar3/graphics/palette.py51
1 files changed, 38 insertions, 13 deletions
diff --git a/src/sugar3/graphics/palette.py b/src/sugar3/graphics/palette.py
index 4bb72ce..284c84b 100644
--- a/src/sugar3/graphics/palette.py
+++ b/src/sugar3/graphics/palette.py
@@ -40,9 +40,40 @@ from sugar3.graphics.palettewindow import MouseSpeedDetector, Invoker, \
WidgetInvoker, CursorInvoker, ToolInvoker, CellRendererInvoker
-class Palette(PaletteWindow):
+class _HeaderItem(Gtk.MenuItem):
+ """A MenuItem with a custom child widget that gets all the
+ available space.
+
"""
- Floating palette implementation.
+
+ __gtype_name__ = 'SugarPaletteHeader'
+
+ def __init__(self, widget):
+ Gtk.MenuItem.__init__(self)
+ if self.get_child() is not None:
+ self.remove(self.get_child())
+ self.add(widget)
+ # FIXME we have to mark it as insensitive again to make it an
+ # informational element, when we realize how to get the icon
+ # displayed correctly - SL #3836
+ # self.set_sensitive(False)
+
+ def do_size_allocate(self, allocation):
+ self.set_allocation(allocation)
+ self.get_child().size_allocate(allocation)
+
+
+class _HeaderSeparator(Gtk.SeparatorMenuItem):
+ """A SeparatorMenuItem that can be styled in the theme."""
+
+ __gtype_name__ = 'SugarPaletteHeaderSeparator'
+
+ def __init__(self):
+ Gtk.SeparatorMenuItem.__init__(self)
+
+
+class Palette(PaletteWindow):
+ """Floating palette implementation.
This class dynamically switches between one of two encapsulated child
widget types: a _PaletteWindowWidget or a _PaletteMenuWidget.
@@ -375,20 +406,14 @@ class Palette(PaletteWindow):
self._widget = _PaletteMenuWidget()
- self._label_menuitem = Gtk.MenuItem()
- child = self._label_menuitem.get_child()
- if child is not None:
- self._label_menuitem.remove(child)
- self._label_menuitem.add(self._primary_box)
-
- # Mark the menuitem as insensitive so that it appears as an
- # informational element, rather than a clickable item in the menu.
- # TODO: see if we can do this better in GTK.
- self._label_menuitem.set_sensitive(False)
-
+ self._label_menuitem = _HeaderItem(self._primary_box)
self._label_menuitem.show()
self._widget.append(self._label_menuitem)
+ separator = _HeaderSeparator()
+ self._widget.append(separator)
+ separator.show()
+
self._setup_widget()
return self._widget