Make icon_name api consistent between the different toolbuttons

As discused in the mailing list [1] the api to set the icon in sugar
ToolButton, RadioToolButton and ToggleToolButton is inconsistent,
and with the port to GTK+ 3 the differences are visible (SL #3849).

This patch changes the API of ToolButton, RadioToolButton and
ToggleToolButton to override the icon-name property and add an
Icon instance with the set_icon_widget method.

Signed-off-by: Gonzalo Odiard <gonzalo@laptop.org>
Acked-by: Simon Schampijer <simon@laptop.org>

[1] http://lists.sugarlabs.org/archive/sugar-devel/2012-September/039624.html
This commit is contained in:
Gonzalo Odiard
2012-09-19 17:25:30 -03:00
committed by Simon Schampijer
parent fe4667f0f5
commit fe11a3aa23
3 changed files with 19 additions and 20 deletions
+8 -13
View File
@@ -36,7 +36,7 @@ class RadioToolButton(Gtk.RadioToolButton):
__gtype_name__ = 'SugarRadioToolButton'
def __init__(self, **kwargs):
def __init__(self, icon_name=None, **kwargs):
self._accelerator = None
self._tooltip = None
self._xo_color = None
@@ -46,6 +46,9 @@ class RadioToolButton(Gtk.RadioToolButton):
self._palette_invoker.attach_tool(self)
if icon_name:
self.set_icon_name(icon_name)
self.connect('destroy', self.__destroy_cb)
def __destroy_cb(self, icon):
@@ -115,21 +118,13 @@ class RadioToolButton(Gtk.RadioToolButton):
accelerator = GObject.property(type=str, setter=set_accelerator,
getter=get_accelerator)
def set_named_icon(self, named_icon):
icon = Icon(icon_name=named_icon,
xo_color=self._xo_color,
icon_size=Gtk.IconSize.LARGE_TOOLBAR)
def set_icon_name(self, icon_name):
icon = Icon(icon_name=icon_name,
xo_color=self._xo_color)
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 = GObject.property(type=str, setter=set_icon_name)
def set_xo_color(self, xo_color):
if self._xo_color != xo_color: