Make xo_color, named_icon and group properties instead of constructor args

This commit is contained in:
Tomeu Vizoso 2008-06-19 20:53:12 +02:00
parent 039206f194
commit b71bf4476c

View File

@ -24,23 +24,18 @@ from sugar.graphics.palette import Palette, ToolInvoker
from sugar.graphics import toolbutton from sugar.graphics import toolbutton
class RadioToolButton(gtk.RadioToolButton): class RadioToolButton(gtk.RadioToolButton):
__gtype_name__ = "SugarRadioToolButton" __gtype_name__ = 'SugarRadioToolButton'
def __init__(self, named_icon=None, group=None, xo_color=None, **kwargs): def __init__(self, **kwargs):
self._accelerator = None self._accelerator = None
self._tooltip = None self._tooltip = None
self._xo_color = xo_color self._xo_color = None
self._palette_invoker = ToolInvoker() self._palette_invoker = ToolInvoker()
gobject.GObject.__init__(self, **kwargs) gobject.GObject.__init__(self, **kwargs)
self._palette_invoker.attach_tool(self) self._palette_invoker.attach_tool(self)
if named_icon:
self.set_named_icon(named_icon)
if group:
self.props.group = group
def set_tooltip(self, tooltip): def set_tooltip(self, tooltip):
""" Set a simple palette with just a single label. """ Set a simple palette with just a single label.
""" """
@ -76,6 +71,27 @@ class RadioToolButton(gtk.RadioToolButton):
self.set_icon_widget(icon) self.set_icon_widget(icon)
icon.show() 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)
def set_xo_color(self, xo_color):
if self._xo_color != xo_color:
self._xo_color = xo_color
if self.props.icon_widget is not None:
self.props.icon_widget.props.xo_color = xo_color
def get_xo_color(self):
return self._xo_color
xo_color = gobject.property(type=str, setter=set_xo_color,
getter=get_xo_color)
def create_palette(self): def create_palette(self):
return None return None