Complete the UI for the battery
This commit is contained in:
parent
a1411040f1
commit
158d933a10
@ -1,11 +1,20 @@
|
|||||||
|
import gobject
|
||||||
|
|
||||||
from model.devices import device
|
from model.devices import device
|
||||||
|
|
||||||
class Device(device.Device):
|
class Device(device.Device):
|
||||||
|
__gproperties__ = {
|
||||||
|
'level' : (int, None, None, 0, 100, 0,
|
||||||
|
gobject.PARAM_READABLE)
|
||||||
|
}
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
device.Device.__init__(self)
|
device.Device.__init__(self)
|
||||||
|
self._level = 0
|
||||||
|
|
||||||
|
def do_get_property(self, pspec):
|
||||||
|
if pspec.name == 'level':
|
||||||
|
return self._level
|
||||||
|
|
||||||
def get_type(self):
|
def get_type(self):
|
||||||
return 'battery'
|
return 'battery'
|
||||||
|
|
||||||
def get_level(self):
|
|
||||||
return 0
|
|
||||||
|
@ -21,7 +21,7 @@ class DevicesModel(gobject.GObject):
|
|||||||
gobject.GObject.__init__(self)
|
gobject.GObject.__init__(self)
|
||||||
|
|
||||||
self._devices = {}
|
self._devices = {}
|
||||||
#self.add_device(battery.Device())
|
self.add_device(battery.Device())
|
||||||
|
|
||||||
self._observe_network_manager()
|
self._observe_network_manager()
|
||||||
|
|
||||||
|
@ -7,5 +7,14 @@ class DeviceView(canvasicon.CanvasIcon):
|
|||||||
canvasicon.CanvasIcon.__init__(self)
|
canvasicon.CanvasIcon.__init__(self)
|
||||||
self._model = model
|
self._model = model
|
||||||
|
|
||||||
icon_name = canvasicon.get_icon_state(_ICON_NAME, 60)
|
model.connect('notify::strength', self._level_changed_cb)
|
||||||
self.props.icon_name = icon_name
|
|
||||||
|
self._update_level()
|
||||||
|
|
||||||
|
def _update_level(self):
|
||||||
|
self.props.icon_name = canvasicon.get_icon_state(
|
||||||
|
_ICON_NAME, self._model.props.level)
|
||||||
|
|
||||||
|
def _level_changed_cb(self, pspec):
|
||||||
|
self._update_level()
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user