Port a few widgets to use new style properties.
This commit is contained in:
parent
80190bf944
commit
204e4f233a
@ -425,13 +425,6 @@ class Activity(Window, gtk.Container):
|
||||
'joined': (gobject.SIGNAL_RUN_FIRST, gobject.TYPE_NONE, ([]))
|
||||
}
|
||||
|
||||
__gproperties__ = {
|
||||
'active' : (bool, None, None, False,
|
||||
gobject.PARAM_READWRITE),
|
||||
'max-participants': (int, None, None, 0, 1000, 0,
|
||||
gobject.PARAM_READWRITE)
|
||||
}
|
||||
|
||||
def __init__(self, handle, create_jobject=True):
|
||||
"""Initialise the Activity
|
||||
|
||||
@ -570,24 +563,27 @@ class Activity(Window, gtk.Container):
|
||||
# https://dev.laptop.org/ticket/3071
|
||||
datastore.write(self._jobject)
|
||||
|
||||
def do_set_property(self, pspec, value):
|
||||
if pspec.name == 'active':
|
||||
if self._active != value:
|
||||
self._active = value
|
||||
if not self._active and self._jobject:
|
||||
self.save()
|
||||
elif pspec.name == 'max-participants':
|
||||
self._max_participants = value
|
||||
else:
|
||||
Window.do_set_property(self, pspec, value)
|
||||
def get_active(self):
|
||||
return self._active
|
||||
|
||||
def do_get_property(self, pspec):
|
||||
if pspec.name == 'active':
|
||||
return self._active
|
||||
elif pspec.name == 'max-participants':
|
||||
return self._max_participants
|
||||
else:
|
||||
return Window.do_get_property(self, pspec)
|
||||
def set_active(self, active):
|
||||
if self._active != active:
|
||||
self._active = active
|
||||
if not self._active and self._jobject:
|
||||
self.save()
|
||||
|
||||
active = gobject.property(
|
||||
type=bool, default=False, getter=get_active, setter=set_active)
|
||||
|
||||
def get_max_participants(self):
|
||||
return self._max_participants
|
||||
|
||||
def set_max_participants(self, participants):
|
||||
self._max_participants = participants
|
||||
|
||||
max_participants = gobject.property(
|
||||
type=int, default=0, getter=get_max_participants,
|
||||
setter=set_max_participants)
|
||||
|
||||
def get_id(self):
|
||||
"""Returns the activity id of the current instance of your activity.
|
||||
|
@ -21,10 +21,6 @@ import gtk
|
||||
class ComboBox(gtk.ComboBox):
|
||||
__gtype_name__ = 'SugarComboBox'
|
||||
|
||||
__gproperties__ = {
|
||||
'value' : (object, None, None,
|
||||
gobject.PARAM_READABLE)
|
||||
}
|
||||
def __init__(self):
|
||||
gtk.ComboBox.__init__(self)
|
||||
|
||||
@ -39,14 +35,14 @@ class ComboBox(gtk.ComboBox):
|
||||
|
||||
self.set_row_separator_func(self._is_separator)
|
||||
|
||||
def do_get_property(self, pspec):
|
||||
if pspec.name == 'value':
|
||||
row = self.get_active_item()
|
||||
if not row:
|
||||
return None
|
||||
return row[0]
|
||||
else:
|
||||
return gtk.ComboBox.do_get_property(self, pspec)
|
||||
def get_value(self):
|
||||
row = self.get_active_item()
|
||||
if not row:
|
||||
return None
|
||||
return row[0]
|
||||
|
||||
value = gobject.property(
|
||||
type=object, getter=get_value, setter=None)
|
||||
|
||||
def _get_real_name_from_theme(self, name, size):
|
||||
icon_theme = gtk.icon_theme_get_default()
|
||||
|
@ -293,17 +293,6 @@ class _IconBuffer(object):
|
||||
class Icon(gtk.Image):
|
||||
__gtype_name__ = 'SugarIcon'
|
||||
|
||||
__gproperties__ = {
|
||||
'xo-color' : (object, None, None,
|
||||
gobject.PARAM_WRITABLE),
|
||||
'fill-color' : (object, None, None,
|
||||
gobject.PARAM_READWRITE),
|
||||
'stroke-color' : (object, None, None,
|
||||
gobject.PARAM_READWRITE),
|
||||
'badge-name' : (str, None, None, None,
|
||||
gobject.PARAM_READWRITE)
|
||||
}
|
||||
|
||||
def __init__(self, **kwargs):
|
||||
self._buffer = _IconBuffer()
|
||||
|
||||
@ -368,35 +357,46 @@ class Icon(gtk.Image):
|
||||
cr.set_source_surface(surface, x, y)
|
||||
cr.paint()
|
||||
|
||||
def do_set_property(self, pspec, value):
|
||||
if pspec.name == 'xo-color':
|
||||
if self._buffer.xo_color != value:
|
||||
self._buffer.xo_color = value
|
||||
self.queue_draw()
|
||||
elif pspec.name == 'fill-color':
|
||||
if self._buffer.fill_color != value:
|
||||
self._buffer.fill_color = value
|
||||
self.queue_draw()
|
||||
elif pspec.name == 'stroke-color':
|
||||
if self._buffer.stroke_color != value:
|
||||
self._buffer.stroke_color = value
|
||||
self.queue_draw()
|
||||
elif pspec.name == 'badge-name':
|
||||
if self._buffer.badge_name != value:
|
||||
self._buffer.badge_name = value
|
||||
self.queue_resize()
|
||||
else:
|
||||
gtk.Image.do_set_property(self, pspec, value)
|
||||
def set_xo_color(self, value):
|
||||
if self._buffer.xo_color != value:
|
||||
self._buffer.xo_color = value
|
||||
self.queue_draw()
|
||||
|
||||
def do_get_property(self, pspec):
|
||||
if pspec.name == 'fill-color':
|
||||
return self._buffer.fill_color
|
||||
elif pspec.name == 'stroke-color':
|
||||
return self._buffer.stroke_color
|
||||
elif pspec.name == 'badge-name':
|
||||
return self._buffer.badge_name
|
||||
else:
|
||||
return gtk.Image.do_get_property(self, pspec)
|
||||
xo_color = gobject.property(
|
||||
type=object, getter=None, setter=set_xo_color)
|
||||
|
||||
def set_fill_color(self, value):
|
||||
if self._buffer.fill_color != value:
|
||||
self._buffer.fill_color = value
|
||||
self.queue_draw()
|
||||
|
||||
def get_fill_color(self):
|
||||
return self._buffer.fill_color
|
||||
|
||||
fill_color = gobject.property(
|
||||
type=object, getter=get_fill_color, setter=set_fill_color)
|
||||
|
||||
def set_stroke_color(self, value):
|
||||
if self._buffer.stroke_color != value:
|
||||
self._buffer.stroke_color = value
|
||||
self.queue_draw()
|
||||
|
||||
def get_stroke_color(self):
|
||||
return self._buffer.stroke_color
|
||||
|
||||
stroke_color = gobject.property(
|
||||
type=object, getter=get_stroke_color, setter=set_stroke_color)
|
||||
|
||||
def set_badge_name(self, value):
|
||||
if self._buffer.badge_name != value:
|
||||
self._buffer.badge_name = value
|
||||
self.queue_resize()
|
||||
|
||||
def get_badge_name(self):
|
||||
return self._buffer.badge_name
|
||||
|
||||
badge_name = gobject.property(
|
||||
type=str, getter=get_badge_name, setter=set_badge_name)
|
||||
|
||||
class CanvasIcon(hippo.CanvasBox, hippo.CanvasItem):
|
||||
__gtype_name__ = 'CanvasIcon'
|
||||
|
Loading…
Reference in New Issue
Block a user