[Sugar-devel] [sugar-toolkit-gtk3] Set getter an setter in icon_name property - SL #3849
Simon Schampijer
simon at schampijer.de
Wed Sep 19 15:48:47 EDT 2012
Hi Gonzalo,
thanks for this great writeup!
On 09/19/2012 09:13 PM, Gonzalo Odiard wrote:
> Today we explored with Simon different alternatives:
>
> - override the icon-name property and fallback to what we do in
> set_named_icon
> - override the icon-name property and print a warning to use 'named_icon'
> - override the icon-name property, do what we do in set_named_icon and
> remove the named_icon property (there is not a better moment to do
the last
> one than now, if we think this is the right thing to do)
>
> In toolbutton, we are using the icon_name property:
>
> def __init__(self, icon_name=None, **kwargs):
> .....
> if icon_name:
> self.set_icon(icon_name)
>
> def set_icon(self, icon_name):
> icon = Icon(icon_name=icon_name)
> self.set_icon_widget(icon)
> icon.show()
>
> icon_name = GObject.property(type=str, setter=set_icon)
>
> In toogletoolbutton we are using named_icon and can be set as a parameter
> when created,
> there are a set_named_icon but there are not a property:
>
> def __init__(self, named_icon=None):
> ....
> self.set_named_icon(named_icon)
>
> def set_named_icon(self, named_icon):
> icon = Icon(icon_name=named_icon)
> self.set_icon_widget(icon)
> icon.show()
>
> And in radiotoolbutton there are a property and a method named_icon, but
> can't be set at creation time:
>
> def __init__(self, **kwargs):
>
> def set_named_icon(self, named_icon):
> icon = Icon(icon_name=named_icon,
> xo_color=self._xo_color,
> icon_size=Gtk.IconSize.LARGE_TOOLBAR)
> self.set_icon_widget(icon)
> icon.show()
>
> def get_named_icon(self):
> if self.props.icon_widget is not None:
> return self.props.icon_widget.props.icon_name
> else:
> return None
>
> named_icon = GObject.property(type=str, setter=set_named_icon,
> getter=get_named_icon)
>
> (icon_name is a property of Gtk.Gtk.RadioToolButton, but is not set
in the
> same way,
> and the button looks bigger)
>
> I think we should have a consistent API, doing the same than in
toolbutton.
Agreed!
> Questions:
>
> 1) Do you agree with have a consistent API and do the change now in gtk3
> toolkit?
Yes, we should do the change now, before we have more activities to be
ported over.
> 2) What should we do with the old named_icon properties? Remove it?
> Mark as deprecated?
> How?
The activities in your list are not all ported yet (e.g. TamTam) so that
can be part of the porting.
If an API is considered stable you would normally announce the
deprecation and add warnings. See for example how we handled the keep
button. Then after a some time you remove the API completely. In this
case as the toolkit-gtk3 is new and the state is arguable we might get
away in doing it a bit more radical.
If we only keep the 'icon-name' property and remove 'named-icon' is it
doable form the existing ported activities side? If too heavy we go the
deprecated step. In any case, we should make all that API the same.
Regards,
Simon
More information about the Sugar-devel
mailing list