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

Manuel Quiñones manuq at laptop.org
Thu Sep 13 10:52:26 EDT 2012


2012/9/13 Simon (erikos) Schampijer <simon at laptop.org>:
> 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.

Yes those are the problems of not marking it as insensitive.  I did
another round to try to fix the icon keeping the toolitem insensitive,
but no news yet.  So as you agree I will add a comment about this and
push.

Visually yes they are now like the palettes in the gtk2 shell.

> 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.

Yes you are right, I will keep it consistent with the other code.

>
>> +        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.

Thanks!

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



-- 
.. manuq ..


More information about the Sugar-devel mailing list