Optimize xo_color property set and share more code.
This commit is contained in:
parent
d757126a19
commit
97451c5466
@ -179,6 +179,14 @@ class _IconBuffer(object):
|
|||||||
|
|
||||||
return info
|
return info
|
||||||
|
|
||||||
|
def set_xo_color(self, xo_color):
|
||||||
|
if xo_color:
|
||||||
|
self.stroke_color = xo_color.get_stroke_color()
|
||||||
|
self.fill_color = xo_color.get_fill_color()
|
||||||
|
else:
|
||||||
|
self.stroke_color = None
|
||||||
|
self.fill_color = None
|
||||||
|
|
||||||
def get_surface(self):
|
def get_surface(self):
|
||||||
cache_key = self._get_cache_key()
|
cache_key = self._get_cache_key()
|
||||||
if cache_key in self._surface_cache:
|
if cache_key in self._surface_cache:
|
||||||
@ -309,12 +317,7 @@ class Icon(gtk.Image):
|
|||||||
|
|
||||||
def do_set_property(self, pspec, value):
|
def do_set_property(self, pspec, value):
|
||||||
if pspec.name == 'xo-color':
|
if pspec.name == 'xo-color':
|
||||||
if value is None:
|
self._buffer.set_xo_color(value)
|
||||||
self.props.fill_color = None
|
|
||||||
self.props.stroke_color = None
|
|
||||||
else:
|
|
||||||
self.props.fill_color = value.get_fill_color()
|
|
||||||
self.props.stroke_color = value.get_stroke_color()
|
|
||||||
elif pspec.name == 'fill-color':
|
elif pspec.name == 'fill-color':
|
||||||
self._buffer.fill_color = value
|
self._buffer.fill_color = value
|
||||||
elif pspec.name == 'stroke-color':
|
elif pspec.name == 'stroke-color':
|
||||||
@ -373,12 +376,8 @@ class CanvasIcon(hippo.CanvasBox, hippo.CanvasItem):
|
|||||||
self._buffer.icon_name = value
|
self._buffer.icon_name = value
|
||||||
self.emit_paint_needed(0, 0, -1, -1)
|
self.emit_paint_needed(0, 0, -1, -1)
|
||||||
elif pspec.name == 'xo-color':
|
elif pspec.name == 'xo-color':
|
||||||
if value is None:
|
self._buffer.set_xo_color(value)
|
||||||
self.props.fill_color = None
|
self.emit_paint_needed(0, 0, -1, -1)
|
||||||
self.props.stroke_color = None
|
|
||||||
else:
|
|
||||||
self.props.fill_color = value.get_fill_color()
|
|
||||||
self.props.stroke_color = value.get_stroke_color()
|
|
||||||
elif pspec.name == 'fill-color':
|
elif pspec.name == 'fill-color':
|
||||||
self._buffer.fill_color = value
|
self._buffer.fill_color = value
|
||||||
self.emit_paint_needed(0, 0, -1, -1)
|
self.emit_paint_needed(0, 0, -1, -1)
|
||||||
|
Loading…
Reference in New Issue
Block a user