Infrastructure for the home page devices
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
SUBDIRS = frame home
|
||||
SUBDIRS = devices frame home
|
||||
|
||||
sugardir = $(pkgdatadir)/shell/view
|
||||
sugardir = $(pkgdatadir)/shell/view/devices
|
||||
sugar_PYTHON = \
|
||||
__init__.py \
|
||||
ActivityHost.py \
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
sugardir = $(pkgdatadir)/shell/view/devices
|
||||
sugar_PYTHON = \
|
||||
__init__.py \
|
||||
battery.py \
|
||||
deviceview.py \
|
||||
network.py
|
||||
@@ -0,0 +1,6 @@
|
||||
from view.devices import deviceview
|
||||
|
||||
class DeviceView(deviceview.DeviceView)
|
||||
def __init__(self, model):
|
||||
deviceview.DeviceView.__init__(self, model)
|
||||
self.props.icon_name = 'theme:stock-close'
|
||||
@@ -0,0 +1,16 @@
|
||||
from sugar.graphics.canvasicon import CanvasIcon
|
||||
|
||||
class DeviceView(CanvasIcon):
|
||||
def __init__(self, model):
|
||||
CanvasIcon.__init__(self)
|
||||
self.model = model
|
||||
|
||||
def create(model):
|
||||
name = 'view.devices.' + model.get_type()
|
||||
|
||||
mod = __import__(name)
|
||||
components = name.split('.')
|
||||
for comp in components[1:]:
|
||||
mod = getattr(mod, comp)
|
||||
|
||||
return mod.DeviceView(model)
|
||||
@@ -0,0 +1,6 @@
|
||||
from view.devices import deviceview
|
||||
|
||||
class DeviceView(deviceview.DeviceView):
|
||||
def __init__(self, model):
|
||||
deviceview.DeviceView.__init__(self, model)
|
||||
self.props.icon_name = 'theme:stock-close'
|
||||
@@ -16,12 +16,14 @@
|
||||
|
||||
import hippo
|
||||
|
||||
from view.home.activitiesdonut import ActivitiesDonut
|
||||
from view.home.MyIcon import MyIcon
|
||||
from model.ShellModel import ShellModel
|
||||
from sugar.graphics import units
|
||||
from sugar.graphics.iconcolor import IconColor
|
||||
|
||||
from view.home.activitiesdonut import ActivitiesDonut
|
||||
from view.devices import deviceview
|
||||
from view.home.MyIcon import MyIcon
|
||||
from model.ShellModel import ShellModel
|
||||
|
||||
class HomeBox(hippo.CanvasBox, hippo.CanvasItem):
|
||||
__gtype_name__ = 'SugarHomeBox'
|
||||
|
||||
@@ -36,8 +38,16 @@ class HomeBox(hippo.CanvasBox, hippo.CanvasItem):
|
||||
self._my_icon = MyIcon(units.XLARGE_ICON_SCALE)
|
||||
self.append(self._my_icon, hippo.PACK_FIXED)
|
||||
|
||||
shell.get_model().connect('notify::state',
|
||||
self._shell_state_changed_cb)
|
||||
shell_model = shell.get_model()
|
||||
shell_model.connect('notify::state',
|
||||
self._shell_state_changed_cb)
|
||||
|
||||
for device in shell_model.get_devices():
|
||||
self._add_device(device)
|
||||
|
||||
def _add_device(self, device):
|
||||
view = deviceview.create(device)
|
||||
self.append(view, hippo.PACK_FIXED)
|
||||
|
||||
def _shell_state_changed_cb(self, model, pspec):
|
||||
# FIXME handle all possible mode switches
|
||||
|
||||
Reference in New Issue
Block a user