[Sugar-devel] [PATCH sugar-toolkit-gtk3] Style the palette menu header - SL #3879 #3836

Simon Schampijer simon at schampijer.de
Thu Sep 13 03:53:03 EDT 2012


Excellent, thanks for looking into this!

On 09/13/2012 06:26 AM, Manuel Quiñones wrote:
 > - 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.

Visually I like it much better now. It is a bit cheeky as the header is 
still a sensitive menu item but the hovering is not visible. It still 
acts as a menuitem for example: if you raise the owner Palette and use 
the cursor keys to navigate the header is still the first item. Also 
clicking on the item does bring the Palette down. Let's note this as 
well in the description.

All that said, I think this is the best we can get for now, I actually 
looked at this myself for a while how to make the menuitem non sensitive 
but do not gray it out when drawing. Better ideas welcome.

 > - 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 at 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/src/sugar3/graphics/palette.py
 > +++ b/src/sugar3/graphics/palette.py
 > @@ -40,6 +40,34 @@ from sugar3.graphics.palettewindow import 
MouseSpeedDetector, Invoker, \
 >           WidgetInvoker, CursorInvoker, ToolInvoker, CellRendererInvoker
 >
 >
 > +class _HeaderItem(Gtk.MenuItem):
 > +    """
 > +    A MenuItem with a custom child widget that gets all the available
 > +    space.
 > +
 > +    """
 > +
 > +    __gtype_name__ = 'SugarPaletteHeader'
 > +
 > +    def __init__(self, widget):
 > +        super(_HeaderItem, self).__init__()

Are there any major advantages than doing "Gtk.MenuItem.__init__(self)" 
as we so in the rest of our code?  a) I think the style we currently do 
is easier to read. b) it is good to stick to one style.

 > +        if self.get_child() is not None:
 > +            self.remove(self.get_child())
 > +        self.add(widget)
 > +
 > +    def do_size_allocate(self, allocation):
 > +        self.set_allocation(allocation)
 > +        self.get_child().size_allocate(allocation)
 > +
 > +
 > +class _HeaderSeparator(Gtk.SeparatorMenuItem):
 > +
 > +    __gtype_name__ = 'SugarPaletteHeaderSeparator'
 > +
 > +    def __init__(self):
 > +        super(_HeaderSeparator, self).__init__()

Same here.

I have attached a follow up patch that does change it and adds another 
doc string.

Thanks,
    Simon

-------------- next part --------------
A non-text attachment was scrubbed...
Name: follow_up.patch
Type: text/x-patch
Size: 1189 bytes
Desc: not available
URL: <http://lists.sugarlabs.org/archive/sugar-devel/attachments/20120913/e470b745/attachment-0001.bin>


More information about the Sugar-devel mailing list