Infrastructure for the home page devices
This commit is contained in:
parent
e24193c551
commit
e0dd1f5232
@ -117,9 +117,11 @@ services/datastore/Makefile
|
|||||||
shell/Makefile
|
shell/Makefile
|
||||||
shell/data/Makefile
|
shell/data/Makefile
|
||||||
shell/view/Makefile
|
shell/view/Makefile
|
||||||
shell/view/home/Makefile
|
shell/view/devices/Makefile
|
||||||
shell/view/frame/Makefile
|
shell/view/frame/Makefile
|
||||||
|
shell/view/home/Makefile
|
||||||
shell/model/Makefile
|
shell/model/Makefile
|
||||||
|
shell/model/devices/Makefile
|
||||||
services/console/lib/Makefile
|
services/console/lib/Makefile
|
||||||
services/console/lib/procmem/Makefile
|
services/console/lib/procmem/Makefile
|
||||||
services/console/Makefile
|
services/console/Makefile
|
||||||
|
@ -1,3 +1,5 @@
|
|||||||
|
SUBDIRS = devices
|
||||||
|
|
||||||
sugardir = $(pkgdatadir)/shell/model
|
sugardir = $(pkgdatadir)/shell/model
|
||||||
sugar_PYTHON = \
|
sugar_PYTHON = \
|
||||||
__init__.py \
|
__init__.py \
|
||||||
|
@ -24,6 +24,7 @@ from model.Friends import Friends
|
|||||||
from model.MeshModel import MeshModel
|
from model.MeshModel import MeshModel
|
||||||
from model.homemodel import HomeModel
|
from model.homemodel import HomeModel
|
||||||
from model.Owner import ShellOwner
|
from model.Owner import ShellOwner
|
||||||
|
from model.devices.devicesmodel import DevicesModel
|
||||||
from sugar import env
|
from sugar import env
|
||||||
|
|
||||||
class ShellModel(gobject.GObject):
|
class ShellModel(gobject.GObject):
|
||||||
@ -54,6 +55,7 @@ class ShellModel(gobject.GObject):
|
|||||||
self._friends = Friends()
|
self._friends = Friends()
|
||||||
self._mesh = MeshModel(self._bundle_registry)
|
self._mesh = MeshModel(self._bundle_registry)
|
||||||
self._home = HomeModel(self._bundle_registry)
|
self._home = HomeModel(self._bundle_registry)
|
||||||
|
self._devices = DevicesModel()
|
||||||
|
|
||||||
for path in env.get_data_dirs():
|
for path in env.get_data_dirs():
|
||||||
bundles_path = os.path.join(path, 'activities')
|
bundles_path = os.path.join(path, 'activities')
|
||||||
@ -86,3 +88,6 @@ class ShellModel(gobject.GObject):
|
|||||||
|
|
||||||
def get_owner(self):
|
def get_owner(self):
|
||||||
return self._owner
|
return self._owner
|
||||||
|
|
||||||
|
def get_devices(self):
|
||||||
|
return self._devices
|
||||||
|
7
shell/model/devices/Makefile.am
Normal file
7
shell/model/devices/Makefile.am
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
sugardir = $(pkgdatadir)/shell/model/devices
|
||||||
|
sugar_PYTHON = \
|
||||||
|
__init__.py \
|
||||||
|
device.py \
|
||||||
|
devicesmodel.py \
|
||||||
|
battery.py \
|
||||||
|
network.py
|
0
shell/model/devices/__init__.py
Normal file
0
shell/model/devices/__init__.py
Normal file
11
shell/model/devices/battery.py
Normal file
11
shell/model/devices/battery.py
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
from model.devices import device
|
||||||
|
|
||||||
|
class Device(device.Device):
|
||||||
|
def __init__(self):
|
||||||
|
device.Device.__init__(self)
|
||||||
|
|
||||||
|
def get_type(self):
|
||||||
|
return 'network'
|
||||||
|
|
||||||
|
def get_level(self):
|
||||||
|
return 0
|
11
shell/model/devices/device.py
Normal file
11
shell/model/devices/device.py
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
from sugar import util
|
||||||
|
|
||||||
|
class Device(object):
|
||||||
|
def __init__(self):
|
||||||
|
self._id = util.unique_id()
|
||||||
|
|
||||||
|
def get_type(self):
|
||||||
|
return 'unknown'
|
||||||
|
|
||||||
|
def get_id(self):
|
||||||
|
return self._id
|
29
shell/model/devices/devicesmodel.py
Normal file
29
shell/model/devices/devicesmodel.py
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
import gobject
|
||||||
|
|
||||||
|
from model.devices import device
|
||||||
|
from model.devices import network
|
||||||
|
from model.devices import battery
|
||||||
|
|
||||||
|
class DevicesModel(gobject.GObject):
|
||||||
|
__gsignals__ = {
|
||||||
|
'device-appeared' : (gobject.SIGNAL_RUN_FIRST,
|
||||||
|
gobject.TYPE_NONE,
|
||||||
|
([gobject.TYPE_PYOBJECT])),
|
||||||
|
'device-disappeared': (gobject.SIGNAL_RUN_FIRST,
|
||||||
|
gobject.TYPE_NONE,
|
||||||
|
([gobject.TYPE_PYOBJECT]))
|
||||||
|
}
|
||||||
|
|
||||||
|
def __init__(self):
|
||||||
|
gobject.GObject.__init__(self)
|
||||||
|
|
||||||
|
self._devices = []
|
||||||
|
|
||||||
|
self.add_device(network.Device())
|
||||||
|
self.add_device(battery.Device())
|
||||||
|
|
||||||
|
def __iter__(self):
|
||||||
|
return iter(self._devices)
|
||||||
|
|
||||||
|
def add_device(self, device):
|
||||||
|
self._devices.append(device)
|
11
shell/model/devices/network.py
Normal file
11
shell/model/devices/network.py
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
from model.devices import device
|
||||||
|
|
||||||
|
class Device(device.Device):
|
||||||
|
def __init__(self):
|
||||||
|
device.Device.__init__(self)
|
||||||
|
|
||||||
|
def get_type(self):
|
||||||
|
return 'network'
|
||||||
|
|
||||||
|
def get_level(self):
|
||||||
|
return 0
|
@ -1,6 +1,6 @@
|
|||||||
SUBDIRS = frame home
|
SUBDIRS = devices frame home
|
||||||
|
|
||||||
sugardir = $(pkgdatadir)/shell/view
|
sugardir = $(pkgdatadir)/shell/view/devices
|
||||||
sugar_PYTHON = \
|
sugar_PYTHON = \
|
||||||
__init__.py \
|
__init__.py \
|
||||||
ActivityHost.py \
|
ActivityHost.py \
|
||||||
|
6
shell/view/devices/Makefile.am
Normal file
6
shell/view/devices/Makefile.am
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
sugardir = $(pkgdatadir)/shell/view/devices
|
||||||
|
sugar_PYTHON = \
|
||||||
|
__init__.py \
|
||||||
|
battery.py \
|
||||||
|
deviceview.py \
|
||||||
|
network.py
|
0
shell/view/devices/__init__.py
Normal file
0
shell/view/devices/__init__.py
Normal file
6
shell/view/devices/battery.py
Normal file
6
shell/view/devices/battery.py
Normal file
@ -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
shell/view/devices/deviceview.py
Normal file
16
shell/view/devices/deviceview.py
Normal file
@ -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)
|
6
shell/view/devices/network.py
Normal file
6
shell/view/devices/network.py
Normal file
@ -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
|
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 import units
|
||||||
from sugar.graphics.iconcolor import IconColor
|
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):
|
class HomeBox(hippo.CanvasBox, hippo.CanvasItem):
|
||||||
__gtype_name__ = 'SugarHomeBox'
|
__gtype_name__ = 'SugarHomeBox'
|
||||||
|
|
||||||
@ -36,8 +38,16 @@ class HomeBox(hippo.CanvasBox, hippo.CanvasItem):
|
|||||||
self._my_icon = MyIcon(units.XLARGE_ICON_SCALE)
|
self._my_icon = MyIcon(units.XLARGE_ICON_SCALE)
|
||||||
self.append(self._my_icon, hippo.PACK_FIXED)
|
self.append(self._my_icon, hippo.PACK_FIXED)
|
||||||
|
|
||||||
shell.get_model().connect('notify::state',
|
shell_model = shell.get_model()
|
||||||
self._shell_state_changed_cb)
|
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):
|
def _shell_state_changed_cb(self, model, pspec):
|
||||||
# FIXME handle all possible mode switches
|
# FIXME handle all possible mode switches
|
||||||
|
Loading…
Reference in New Issue
Block a user