Today we explored with Simon different alternatives:<div><div><br></div><div>- override the icon-name property and fallback to what we do in set_named_icon</div><div>- override the icon-name property and print a warning to use 'named_icon'</div>
<div>- 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)</div></div><div>
<br></div><div>In toolbutton, we are using the icon_name property:</div><div><br></div><div><div>    def __init__(self, icon_name=None, **kwargs):</div><div>        .....</div><div>        if icon_name:</div><div>            self.set_icon(icon_name)</div>
</div><div><br></div><div><div>    def set_icon(self, icon_name):</div><div>        icon = Icon(icon_name=icon_name)</div><div>        self.set_icon_widget(icon)</div><div>        icon.show()</div><div><br></div><div>    icon_name = GObject.property(type=str, setter=set_icon)</div>
</div><div><br>In toogletoolbutton we are using named_icon and can be set as a parameter when created,</div><div>there are a set_named_icon but there are not a property:</div><div><br></div><div><div>    def __init__(self, named_icon=None):</div>
<div>        ....</div><div>        self.set_named_icon(named_icon)</div><br><div>    def set_named_icon(self, named_icon):</div><div>        icon = Icon(icon_name=named_icon)</div><div>        self.set_icon_widget(icon)</div>
<div>        icon.show()</div><div><br></div><div>And in radiotoolbutton there are a property and a method named_icon, but can't be set at creation time:</div><div><br></div><div><div>    def __init__(self, **kwargs):</div>
</div><div><br></div><div><div>    def set_named_icon(self, named_icon):</div><div>        icon = Icon(icon_name=named_icon,</div><div>                    xo_color=self._xo_color,</div><div>                    icon_size=Gtk.IconSize.LARGE_TOOLBAR)</div>
<div>        self.set_icon_widget(icon)</div><div>        icon.show()</div><div><br></div><div>    def get_named_icon(self):</div><div>        if self.props.icon_widget is not None:</div><div>            return self.props.icon_widget.props.icon_name</div>
<div>        else:</div><div>            return None</div><div><br></div><div>    named_icon = GObject.property(type=str, setter=set_named_icon,</div><div>                                  getter=get_named_icon)</div></div>
<div><br></div><div>(icon_name is a property of Gtk.Gtk.RadioToolButton, but is not set in the same way,</div><div>and the button looks bigger)</div><div><br></div><div>I think we should have a consistent API, doing the same than in toolbutton.</div>
<div><br></div><div>Questions:</div><div><br></div><div>1) Do you agree with have a consistent API and do the change now in gtk3 toolkit?</div><div>2) What should we do with the old named_icon properties? Remove it?</div>
<div>Mark as deprecated? </div><div>How?</div><div><br></div><div>For reference, this is the use of named_icon in activities, remember this is a change for gtk3 only, gtk2 activities don't need to do changes:</div><div>
<br></div><div><div>[gonzalo@nautilus honey]$ grep -rn named_icon * --include=*.py</div><div>abacus/mainline/toolbar_utils.py:90:    button.set_named_icon(button_name)</div><div>abacus/abacus-gtk3/toolbar_utils.py:45:    button.set_named_icon(icon_name)</div>
<div>calculate/mainline/toolbars.py:66:            self.set_named_icon(items[0]['icon'])</div><div>calculate/mainline/toolbars.py:79:            self.set_named_icon(but['icon'])</div><div>clock/mainline/clock.py:262:        button1 = RadioToolButton(named_icon="simple-clock")</div>
<div>clock/mainline/clock.py:267:        button2 = RadioToolButton(named_icon="nice-clock",</div><div>clock/mainline/clock.py:273:        button3 = RadioToolButton(named_icon="digital-clock",</div><div>
implode/mainline/implodeactivity.py:175:                button = RadioToolButton(named_icon=icon_name,</div><div>implode/mainline/implodeactivity.py:178:                button = RadioToolButton(named_icon=icon_name)</div>
<div>labyrinth/mainline/labyrinthactivity.py:353:        self._parent.mods[1] = RadioToolButton(named_icon='text-mode')</div><div>labyrinth/mainline/labyrinthactivity.py:361:        self._parent.mods[2] = RadioToolButton(named_icon='image-mode')</div>
<div>labyrinth/mainline/labyrinthactivity.py:369:        self._parent.mods[3] = RadioToolButton(named_icon='draw-mode')</div><div>labyrinth/mainline/labyrinthactivity.py:377:        self._parent.mods[5] = RadioToolButton(named_icon='label-mode')</div>
<div>measure/mainline/sensor_toolbar.py:88:        self.time.set_named_icon('media-audio')</div><div>measure/mainline/sensor_toolbar.py:96:        self.resistance.set_named_icon('resistance')</div><div>measure/mainline/sensor_toolbar.py:107:        self.voltage.set_named_icon('voltage')</div>
<div>memorize/mainline/createtoolbar.py:101:            self._equal_pairs.set_named_icon('pair-equals')</div><div>memorize/mainline/createtoolbar.py:105:            self._equal_pairs.set_named_icon('pair-non-equals')</div>
<div>memorize/mainline/createtoolbar.py:114:            self._grouped.set_named_icon('grouped_game2')</div><div>memorize/mainline/createtoolbar.py:118:            self._grouped.set_named_icon('grouped_game1')</div>
<div>memorize/mainline/createcardpanel.py:332:                    named_icon='speak')</div><div>memorize/mainline/activity.py:215:            button.set_named_icon('player_play')</div><div>memorize/mainline/activity.py:219:            button.set_named_icon('view-source')</div>
<div>paint/mainline/toolbox.py:232:        RadioToolButton.__init__(self, named_icon=icon_name)</div><div>physics/mainline/activity.py:151:            button = RadioToolButton(named_icon=c.icon)</div><div>portfolio/portfolio/toolbar_utils.py:90:    button.set_named_icon(button_name)</div>
<div>read/mainline/speechtoolbar.py:132:        self.play_btn.set_named_icon('media-playback-start')</div><div>read/mainline/speechtoolbar.py:138:            self.play_btn.set_named_icon('media-playback-pause')</div>
<div>read/mainline/speechtoolbar.py:142:            self.play_btn.set_named_icon('media-playback-start')</div><div>read/mainline/speechtoolbar.py:147:        self.play_btn.set_named_icon('media-playback-start')</div>
<div>speak/mainline/activity.py:134:                named_icon='mode-type',</div><div>speak/mainline/activity.py:140:                named_icon='mode-robot',</div><div>speak/mainline/activity.py:148:                named_icon='mode-chat',</div>
<div>tamtam/mainline/TamTamSynthLab.activity/SynthLab/SynthLabToolbars.py:121:        self.preset1Button.set_named_icon('preset1')</div><div>tamtam/mainline/TamTamSynthLab.activity/SynthLab/SynthLabToolbars.py:128:        self.preset2Button.set_named_icon('preset2')</div>
<div>tamtam/mainline/TamTamSynthLab.activity/SynthLab/SynthLabToolbars.py:135:        self.preset3Button.set_named_icon('preset3')</div><div>tamtam/mainline/TamTamSynthLab.activity/SynthLab/SynthLabToolbars.py:142:        self.preset4Button.set_named_icon('preset4')</div>
<div>tamtam/mainline/TamTamSynthLab.activity/SynthLab/SynthLabToolbars.py:149:        self.preset5Button.set_named_icon('preset5')</div><div>tamtam/mainline/TamTamSynthLab.activity/SynthLab/SynthLabToolbars.py:156:        self.preset6Button.set_named_icon('preset6')</div>
<div>tamtam/mainline/TamTamSynthLab.activity/SynthLab/SynthLabToolbars.py:163:        self.preset7Button.set_named_icon('preset7')</div><div>tamtam/mainline/TamTamSynthLab.activity/SynthLab/SynthLabToolbars.py:170:        self.preset8Button.set_named_icon('preset8')</div>
<div>tamtam/mainline/TamTamSynthLab.activity/SynthLab/SynthLabToolbars.py:177:        self.preset9Button.set_named_icon('preset9')</div><div>tamtam/mainline/TamTamSynthLab.activity/SynthLab/SynthLabToolbars.py:184:        self.preset10Button.set_named_icon('preset10')</div>
<div>tamtam/mainline/TamTamJam.activity/Jam/Toolbars.py:161:        btn.set_named_icon('beats')</div><div>tamtam/mainline/TamTamJam.activity/Jam/Toolbars.py:169:            btn.set_named_icon('beats')</div>
<div>tamtam/mainline/TamTamJam.activity/Jam/Toolbars.py:271:        btn.set_named_icon('preset1')</div><div>tamtam/mainline/TamTamJam.activity/Jam/Toolbars.py:279:            btn.set_named_icon('preset%d'%i)</div>
<div>tamtam/mainline/TamTamEdit.activity/Edit/EditToolbars.py:89:        self.pointerButton.set_named_icon('edit-pointer')</div><div>tamtam/mainline/TamTamEdit.activity/Edit/EditToolbars.py:98:        self.drawButton.set_named_icon('edit-pencil')</div>
<div>tamtam/mainline/TamTamEdit.activity/Edit/EditToolbars.py:107:        self.paintButton.set_named_icon('edit-brush')</div><div>tamtam/tamtam/Edit/EditToolbars.py:73:    toolbar.pointerButton.set_named_icon('edit-pointer')</div>
<div>tamtam/tamtam/Edit/EditToolbars.py:82:    toolbar.drawButton.set_named_icon('edit-pencil')</div><div>tamtam/tamtam/Edit/EditToolbars.py:91:    toolbar.paintButton.set_named_icon('edit-brush')</div><div>
tamtam/tamtam/Jam/Toolbars.py:188:        btn.set_named_icon('beats')</div><div>tamtam/tamtam/Jam/Toolbars.py:196:            btn.set_named_icon('beats')</div><div>tamtam/tamtam/Jam/Toolbars.py:282:        btn.set_named_icon('jam-preset1')</div>
<div>tamtam/tamtam/Jam/Toolbars.py:290:            btn.set_named_icon('jam-preset%d' % i)</div><div>tamtam/tamtam/SynthLab/SynthLabToolbars.py:165:            button.set_named_icon(name)</div><div>tamtam/tamtam.olpc/TamTamSynthLab.activity/SynthLab/SynthLabToolbars.py:120:        self.preset1Button.set_named_icon('preset1')</div>
<div>tamtam/tamtam.olpc/TamTamSynthLab.activity/SynthLab/SynthLabToolbars.py:127:        self.preset2Button.set_named_icon('preset2')</div><div>tamtam/tamtam.olpc/TamTamSynthLab.activity/SynthLab/SynthLabToolbars.py:134:        self.preset3Button.set_named_icon('preset3')</div>
<div>tamtam/tamtam.olpc/TamTamSynthLab.activity/SynthLab/SynthLabToolbars.py:141:        self.preset4Button.set_named_icon('preset4')</div><div>tamtam/tamtam.olpc/TamTamSynthLab.activity/SynthLab/SynthLabToolbars.py:148:        self.preset5Button.set_named_icon('preset5')</div>
<div>tamtam/tamtam.olpc/TamTamSynthLab.activity/SynthLab/SynthLabToolbars.py:155:        self.preset6Button.set_named_icon('preset6')</div><div>tamtam/tamtam.olpc/TamTamSynthLab.activity/SynthLab/SynthLabToolbars.py:162:        self.preset7Button.set_named_icon('preset7')</div>
<div>tamtam/tamtam.olpc/TamTamSynthLab.activity/SynthLab/SynthLabToolbars.py:169:        self.preset8Button.set_named_icon('preset8')</div><div>tamtam/tamtam.olpc/TamTamSynthLab.activity/SynthLab/SynthLabToolbars.py:176:        self.preset9Button.set_named_icon('preset9')</div>
<div>tamtam/tamtam.olpc/TamTamSynthLab.activity/SynthLab/SynthLabToolbars.py:183:        self.preset10Button.set_named_icon('preset10')</div><div>tamtam/tamtam.olpc/TamTamJam.activity/Jam/Toolbars.py:160:        btn.set_named_icon('beats')</div>
<div>tamtam/tamtam.olpc/TamTamJam.activity/Jam/Toolbars.py:168:            btn.set_named_icon('beats')</div><div>tamtam/tamtam.olpc/TamTamJam.activity/Jam/Toolbars.py:270:        btn.set_named_icon('preset1')</div>
<div>tamtam/tamtam.olpc/TamTamJam.activity/Jam/Toolbars.py:278:            btn.set_named_icon('preset%d'%i)</div><div>tamtam/tamtam.olpc/TamTamEdit.activity/Edit/EditToolbars.py:90:        self.pointerButton.set_named_icon('edit-pointer')</div>
<div>tamtam/tamtam.olpc/TamTamEdit.activity/Edit/EditToolbars.py:99:        self.drawButton.set_named_icon('edit-pencil')</div><div>tamtam/tamtam.olpc/TamTamEdit.activity/Edit/EditToolbars.py:108:        self.paintButton.set_named_icon('edit-brush')</div>
<div>turtleart/mainline/TurtleArtActivity.py:1244:        button.set_named_icon(button_name)</div><div>write/mainline/speechtoolbar.py:158:        self.play_btn.set_named_icon('media-playback-start')</div><div>write/mainline/speechtoolbar.py:166:            self.play_btn.set_named_icon('media-playback-pause')</div>
<div>write/mainline/speechtoolbar.py:185:            self.play_btn.set_named_icon('media-playback-start')</div><div>write/mainline/speechtoolbar.py:191:        self.play_btn.set_named_icon('media-playback-start')</div>
</div><div><br></div><div>Gonzalo</div><br><br><div class="gmail_quote">On Tue, Sep 18, 2012 at 1:35 PM, Manuel Quiñones <span dir="ltr"><<a href="mailto:manuq@laptop.org" target="_blank">manuq@laptop.org</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Oh wait I overlooked this.  What's the benefit of having two<br>
properties exactly the same? I would vote to use named_icon as in the<br>
constructor, and change Paint.<br>
<br>
2012/9/18 Manuel Quiñones <<a href="mailto:manuq@laptop.org">manuq@laptop.org</a>>:<br>
<div class="HOEnZb"><div class="h5">> Thanks Gonzalo.  Yes this fixes the regression, which was affecting<br>
> Paint, and may affect other ports so I vote for adding this instead of<br>
> deprecating the API.  So now both:<br>
><br>
> radial_button = RadioToolButton(named_icon='view-radial')<br>
><br>
> and:<br>
><br>
> radial_button = RadioToolButton()<br>
> radial_button.props.icon_name = 'view-radial'<br>
><br>
> works.  Great.<br>
><br>
> 2012/9/18  <<a href="mailto:godiard@sugarlabs.org">godiard@sugarlabs.org</a>>:<br>
>> From: Gonzalo Odiard <<a href="mailto:godiard@gmail.com">godiard@gmail.com</a>><br>
>><br>
>> With g-i bindings, setting the property don't change the size<br>
>> and the button is bigger than should be.<br>
>> Now we have two properties for the same, icon_name and named_icon,<br>
>> maybe one should be deprecated.<br>
>><br>
>> Signed-off-by: Gonzalo Odiard <<a href="mailto:gonzalo@laptop.org">gonzalo@laptop.org</a>><br>
><br>
> Acked-by: Manuel Quiñones <<a href="mailto:manuq@laptop.org">manuq@laptop.org</a>><br>
><br>
>> ---<br>
>>  src/sugar3/graphics/radiotoolbutton.py | 3 +++<br>
>>  1 file changed, 3 insertions(+)<br>
>><br>
>> diff --git a/src/sugar3/graphics/radiotoolbutton.py b/src/sugar3/graphics/radiotoolbutton.py<br>
>> index 006d167..0c44347 100644<br>
>> --- a/src/sugar3/graphics/radiotoolbutton.py<br>
>> +++ b/src/sugar3/graphics/radiotoolbutton.py<br>
>> @@ -131,6 +131,9 @@ class RadioToolButton(Gtk.RadioToolButton):<br>
>>      named_icon = GObject.property(type=str, setter=set_named_icon,<br>
>>                                    getter=get_named_icon)<br>
>><br>
>> +    icon_name = GObject.property(type=str, setter=set_named_icon,<br>
>> +                                  getter=get_named_icon)<br>
><br>
> I will take care of the indentation here before pushing.<br>
><br>
>> +<br>
>>      def set_xo_color(self, xo_color):<br>
>>          if self._xo_color != xo_color:<br>
>>              self._xo_color = xo_color<br>
>> --<br>
>> 1.7.11.4<br>
>><br>
>> _______________________________________________<br>
>> Sugar-devel mailing list<br>
>> <a href="mailto:Sugar-devel@lists.sugarlabs.org">Sugar-devel@lists.sugarlabs.org</a><br>
>> <a href="http://lists.sugarlabs.org/listinfo/sugar-devel" target="_blank">http://lists.sugarlabs.org/listinfo/sugar-devel</a><br>
><br>
><br>
><br>
> --<br>
> .. manuq ..<br>
<br>
<br>
<br>
</div></div><span class="HOEnZb"><font color="#888888">--<br>
.. manuq ..<br>
</font></span></blockquote></div><br><br clear="all"><div><br></div>-- <br>Gonzalo Odiard<br>SugarLabs Argentina<br><br>
</div>