2007-02-20 11:48:03 +01:00
|
|
|
from view.devices import deviceview
|
|
|
|
|
|
|
|
class DeviceView(deviceview.DeviceView):
|
|
|
|
def __init__(self, model):
|
|
|
|
deviceview.DeviceView.__init__(self, model)
|
2007-02-25 14:30:17 +01:00
|
|
|
self._model = model
|
|
|
|
|
2007-02-25 17:34:15 +01:00
|
|
|
model.connect('notify::name', self._name_changed_cb)
|
2007-02-25 14:30:17 +01:00
|
|
|
model.connect('notify::strength', self._strength_changed_cb)
|
|
|
|
|
2007-02-25 17:34:15 +01:00
|
|
|
self._update_name()
|
2007-02-25 15:24:04 +01:00
|
|
|
self._update_icon()
|
|
|
|
|
2007-02-25 14:30:17 +01:00
|
|
|
def _strength_changed_cb(self, model, pspec):
|
|
|
|
self._update_icon()
|
|
|
|
|
2007-02-25 17:34:15 +01:00
|
|
|
def _name_changed_cb(self, model, pspec):
|
|
|
|
self._update_name()
|
|
|
|
|
|
|
|
def _update_name(self):
|
|
|
|
self.props.tooltip = self._model.props.name
|
|
|
|
|
2007-02-25 14:30:17 +01:00
|
|
|
def _update_icon(self):
|
|
|
|
strength = self._model.props.strength
|
|
|
|
if strength < 21:
|
|
|
|
self.props.icon_name = 'theme:stock-net-wireless-00'
|
|
|
|
elif strength < 41:
|
|
|
|
self.props.icon_name = 'theme:stock-net-wireless-21-40'
|
|
|
|
elif strength < 61:
|
|
|
|
self.props.icon_name = 'theme:stock-net-wireless-41-60'
|
|
|
|
elif strength < 81:
|
|
|
|
self.props.icon_name = 'theme:stock-net-wireless-61-80'
|
|
|
|
else:
|
|
|
|
self.props.icon_name = 'theme:stock-net-wireless-81-100'
|