Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/shell
diff options
context:
space:
mode:
authorMarco Pesenti Gritti <mpg@redhat.com>2007-03-29 15:25:47 (GMT)
committer Marco Pesenti Gritti <mpg@redhat.com>2007-03-29 15:25:47 (GMT)
commitf59fab783f44850ad8217fa8081e5f43c50e7432 (patch)
tree21d70a4e8d63a36446e9d9ccfafc6988cd3a05ca /shell
parentd0fdf59486984d29e37def27fa917caffd1bdb87 (diff)
Change the feedback for connected/connecting/disconnected access point,
using two different types of pulsing.
Diffstat (limited to 'shell')
-rw-r--r--shell/view/devices/network/wireless.py6
-rw-r--r--shell/view/home/MeshBox.py37
-rw-r--r--shell/view/pulsingicon.py37
3 files changed, 44 insertions, 36 deletions
diff --git a/shell/view/devices/network/wireless.py b/shell/view/devices/network/wireless.py
index 0387156..dd079cc 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 a1e9c5d..6e02edf 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 035301f..d2e41f7 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: