diff --git a/shell/view/devices/network/wireless.py b/shell/view/devices/network/wireless.py index 0387156c..dd079cca 100644 --- a/shell/view/devices/network/wireless.py +++ b/shell/view/devices/network/wireless.py @@ -19,13 +19,13 @@ from sugar.graphics import canvasicon from sugar.graphics import color from sugar.graphics import units from model.devices.network import wireless -from view.pulsingicon import PulsingIcon +from sugar.graphics.canvasicon import CanvasIcon _ICON_NAME = 'device-network-wireless' -class DeviceView(PulsingIcon): +class DeviceView(CanvasIcon): def __init__(self, model): - PulsingIcon.__init__(self, scale=units.MEDIUM_ICON_SCALE) + CanvasIcon.__init__(self, scale=units.MEDIUM_ICON_SCALE) self._model = model model.connect('notify::name', self._name_changed_cb) diff --git a/shell/view/home/MeshBox.py b/shell/view/home/MeshBox.py index a1e9c5dc..6e02edfe 100644 --- a/shell/view/home/MeshBox.py +++ b/shell/view/home/MeshBox.py @@ -55,15 +55,8 @@ class AccessPointView(PulsingIcon): sh.update(data) h = hash(sh.digest()) idx = h % len(xocolor._colors) - self._inactive_stroke_color = xocolor._colors[idx][0] - self._inactive_fill_color = xocolor._colors[idx][1] - - self.props.colors = [ - [ None, None ], - [ color.HTMLColor(self._inactive_stroke_color), - color.HTMLColor(self._inactive_fill_color) - ] - ] + self._device_stroke = xocolor._colors[idx][0] + self._device_fill = xocolor._colors[idx][1] self._update_icon() self._update_name() @@ -96,15 +89,27 @@ class AccessPointView(PulsingIcon): def _update_state(self): if self._model.props.state == accesspointmodel.STATE_CONNECTING: - self.props.pulsing = True + self.props.pulse_time = 0.75 + self.props.colors = [ + [ color.HTMLColor(self._device_stroke), + color.HTMLColor(self._device_fill) ], + [ color.HTMLColor(self._device_stroke), + color.HTMLColor('#e2e2e2') ] + ] elif self._model.props.state == accesspointmodel.STATE_CONNECTED: - self.props.pulsing = False - self.props.fill_color = None - self.props.stroke_color = None + self.props.pulse_time = 1.5 + self.props.colors = [ + [ color.HTMLColor(self._device_stroke), + color.HTMLColor(self._device_fill) ], + [ color.HTMLColor('#ffffff'), + color.HTMLColor(self._device_fill) ] + ] elif self._model.props.state == accesspointmodel.STATE_NOTCONNECTED: - self.props.pulsing = False - self.props.fill_color = color.HTMLColor(self._inactive_fill_color) - self.props.stroke_color = color.HTMLColor(self._inactive_stroke_color) + self.props.pulse_time = 0.0 + self.props.colors = [ + [ color.HTMLColor(self._device_stroke), + color.HTMLColor(self._device_fill) ] + ] class MeshDeviceView(CanvasIcon): def __init__(self, nm_device): diff --git a/shell/view/pulsingicon.py b/shell/view/pulsingicon.py index 035301f4..d2e41f78 100644 --- a/shell/view/pulsingicon.py +++ b/shell/view/pulsingicon.py @@ -20,14 +20,15 @@ from sugar.graphics.canvasicon import CanvasIcon class PulsingIcon(CanvasIcon): __gproperties__ = { - 'colors' : (object, None, None, - gobject.PARAM_READWRITE), - 'pulsing' : (bool, None, None, False, - gobject.PARAM_READWRITE) + 'colors' : (object, None, None, + gobject.PARAM_READWRITE), + 'pulse-time' : (float, None, None, + 0.0, 500.0, 0.0, + gobject.PARAM_READWRITE), } def __init__(self, **kwargs): - self._pulsing = False + self._puls_time = 0.0 self._colors = None self._pulse_sid = 0 self._pos = 0 @@ -37,31 +38,32 @@ class PulsingIcon(CanvasIcon): def do_set_property(self, pspec, value): CanvasIcon.do_set_property(self, pspec, value) - if pspec.name == 'pulsing': - self._pulsing = value - if self._pulsing: + if pspec.name == 'pulse-time': + self._pulse_time = value + self._stop() + if self._pulse_time > 0.0: self._start() - else: - self._stop() elif pspec.name == 'colors': self._colors = value self._pos = 0 + self._update_colors() def do_get_property(self, pspec): CanvasIcon.do_get_property(self, pspec) - if pspec.name == 'pulsing': - return self._pulsing + if pspec.name == 'pulse-time': + return self._pulse_time elif pspec.name == 'colors': return self._colors - def _pulse_timeout(self): - if not self._colors: - return - + def _update_colors(self): self.props.stroke_color = self._colors[self._pos][0] self.props.fill_color = self._colors[self._pos][1] + def _pulse_timeout(self): + if self._colors: + self._update_colors() + self._pos += 1 if self._pos == len(self._colors): self._pos = 0 @@ -70,7 +72,8 @@ class PulsingIcon(CanvasIcon): def _start(self): if self._pulse_sid == 0: - self._pulse_sid = gobject.timeout_add(1000, self._pulse_timeout) + self._pulse_sid = gobject.timeout_add( + self._pulse_time * 1000, self._pulse_timeout) def _stop(self): if self._pulse_sid: diff --git a/sugar/presence/PresenceService.py b/sugar/presence/PresenceService.py index a8cfd4d2..4c779c67 100644 --- a/sugar/presence/PresenceService.py +++ b/sugar/presence/PresenceService.py @@ -19,7 +19,7 @@ import dbus, dbus.glib, gobject import Buddy, Service, Activity -_ENABLED = False +_ENABLED = True class ObjectCache(object): def __init__(self):