Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/shell/view
diff options
context:
space:
mode:
authorMarco Pesenti Gritti <mpg@redhat.com>2007-02-20 10:48:03 (GMT)
committer Marco Pesenti Gritti <mpg@redhat.com>2007-02-20 10:48:03 (GMT)
commite0dd1f52322090687410cc20a4255a8eb00f8928 (patch)
tree6a3b86d69d2f484b891320bd76ba9227e6234f5d /shell/view
parente24193c5511ac236c1f3014debf797d07f56dae2 (diff)
Infrastructure for the home page devices
Diffstat (limited to 'shell/view')
-rw-r--r--shell/view/Makefile.am4
-rw-r--r--shell/view/devices/Makefile.am6
-rw-r--r--shell/view/devices/__init__.py0
-rw-r--r--shell/view/devices/battery.py6
-rw-r--r--shell/view/devices/deviceview.py16
-rw-r--r--shell/view/devices/network.py6
-rw-r--r--shell/view/home/HomeBox.py18
7 files changed, 50 insertions, 6 deletions
diff --git a/shell/view/Makefile.am b/shell/view/Makefile.am
index 302c953..39307db 100644
--- a/shell/view/Makefile.am
+++ b/shell/view/Makefile.am
@@ -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 \
diff --git a/shell/view/devices/Makefile.am b/shell/view/devices/Makefile.am
new file mode 100644
index 0000000..54290e0
--- /dev/null
+++ b/shell/view/devices/Makefile.am
@@ -0,0 +1,6 @@
+sugardir = $(pkgdatadir)/shell/view/devices
+sugar_PYTHON = \
+ __init__.py \
+ battery.py \
+ deviceview.py \
+ network.py
diff --git a/shell/view/devices/__init__.py b/shell/view/devices/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/shell/view/devices/__init__.py
diff --git a/shell/view/devices/battery.py b/shell/view/devices/battery.py
new file mode 100644
index 0000000..149e9b2
--- /dev/null
+++ b/shell/view/devices/battery.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'
diff --git a/shell/view/devices/deviceview.py b/shell/view/devices/deviceview.py
new file mode 100644
index 0000000..f35f082
--- /dev/null
+++ b/shell/view/devices/deviceview.py
@@ -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)
diff --git a/shell/view/devices/network.py b/shell/view/devices/network.py
new file mode 100644
index 0000000..a13304e
--- /dev/null
+++ b/shell/view/devices/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'
diff --git a/shell/view/home/HomeBox.py b/shell/view/home/HomeBox.py
index bdc6621..13032a6 100644
--- a/shell/view/home/HomeBox.py
+++ b/shell/view/home/HomeBox.py
@@ -16,11 +16,13 @@
import hippo
+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
-from sugar.graphics import units
-from sugar.graphics.iconcolor import IconColor
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