Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDan Williams <dcbw@localhost.localdomain>2006-09-25 14:57:26 (GMT)
committer Dan Williams <dcbw@localhost.localdomain>2006-09-25 14:57:26 (GMT)
commitde231589798eb580d6b000f4024610331bed0c1e (patch)
treea9516ca50a607c7a0e431bafd2cc871020128442
parent85d70f2383b4df61d95d62f8de4ce037d0dd69c8 (diff)
parent2ee61e447569e31d2bc5ba67ac624d4b1f63752a (diff)
Merge branch 'master' of git+ssh://dev.laptop.org/git/sugar
-rw-r--r--shell/view/home/MeshGroup.py57
-rw-r--r--sugar/canvas/SnowflakeLayout.py15
2 files changed, 65 insertions, 7 deletions
diff --git a/shell/view/home/MeshGroup.py b/shell/view/home/MeshGroup.py
index 89f8f4e..985d18d 100644
--- a/shell/view/home/MeshGroup.py
+++ b/shell/view/home/MeshGroup.py
@@ -6,6 +6,23 @@ import conf
from sugar.canvas.IconItem import IconItem
from view.home.IconLayout import IconLayout
from view.BuddyIcon import BuddyIcon
+from sugar.canvas.SnowflakeLayout import SnowflakeLayout
+
+class ActivityView(goocanvas.Group):
+ def __init__(self, shell, menu_shell, model):
+ goocanvas.Group.__init__(self)
+
+ self._model = model
+ self._layout = SnowflakeLayout()
+
+ icon = IconItem(icon_name=model.get_icon_name(),
+ color=model.get_color(), size=80)
+ self.add_child(icon)
+ self._layout.set_root(icon)
+
+ def get_size_request(self):
+ size = self._layout.get_size()
+ return [size, size]
class MeshGroup(goocanvas.Group):
def __init__(self, shell, menu_shell):
@@ -15,16 +32,54 @@ class MeshGroup(goocanvas.Group):
self._menu_shell = menu_shell
self._model = shell.get_model().get_mesh()
self._layout = IconLayout(shell.get_grid())
+ self._buddies = {}
+ self._activities = {}
for buddy_model in self._model.get_buddies():
self._add_buddy(buddy_model)
self._model.connect('buddy-added', self._buddy_added_cb)
+ self._model.connect('buddy-removed', self._buddy_removed_cb)
+
+ for activity_model in self._model.get_activities():
+ self._add_activity(activity_model)
+
+ self._model.connect('activity-added', self._activity_added_cb)
+ self._model.connect('activity-removed', self._activity_removed_cb)
def _buddy_added_cb(self, model, buddy_model):
- self._add_buddy(buddy_model)
+ self._add_buddy(buddy_model)
+
+ def _buddy_removed_cb(self, model, buddy_model):
+ self._remove_buddy(buddy_model)
+
+ def _activity_added_cb(self, model, activity_model):
+ self._add_activity(activity_model)
+
+ def _activity_removed_cb(self, model, activity_model):
+ self._remove_activity(activity_model)
def _add_buddy(self, buddy_model):
icon = BuddyIcon(self._shell, self._menu_shell, buddy_model)
+ icon.props.size = 80
self.add_child(icon)
+
+ self._buddies[buddy_model.get_name()] = icon
self._layout.add_icon(icon)
+
+ def _remove_buddy(self, buddy_model):
+ icon = self._buddies[buddy_model.get_name()]
+ self.remove_child(icon)
+ del self._buddies[buddy_model.get_name()]
+
+ def _add_activity(self, activity_model):
+ icon = ActivityView(self._shell, self._menu_shell, activity_model)
+ self.add_child(icon)
+
+ self._activities[activity_model.get_id()] = icon
+ self._layout.add_icon(icon)
+
+ def _remove_activity(self, activity_model):
+ icon = self._activities[activity_model.get_id()]
+ self.remove_child(icon)
+ del self._activities[activity_model.get_id()]
diff --git a/sugar/canvas/SnowflakeLayout.py b/sugar/canvas/SnowflakeLayout.py
index aae7d07..9a0c709 100644
--- a/sugar/canvas/SnowflakeLayout.py
+++ b/sugar/canvas/SnowflakeLayout.py
@@ -11,6 +11,7 @@ class SnowflakeLayout:
def __init__(self):
self._root = None
self._children = []
+ self._size = 0
def set_root(self, icon):
self._root = icon
@@ -27,7 +28,7 @@ class SnowflakeLayout:
[width, height] = self._root.get_size_request()
matrix = cairo.Matrix(1, 0, 0, 1, 0, 0)
- matrix.translate(self._cx, self._cy)
+ matrix.translate(self._cx - (width / 2), self._cy - (height / 2))
self._root.set_transform(matrix)
def _layout_child(self, child, index):
@@ -44,15 +45,17 @@ class SnowflakeLayout:
matrix.translate(x, y)
child.set_transform(matrix)
+ def get_size(self):
+ return self._size
+
def _layout(self):
self._r = SnowflakeLayout._BASE_RADIUS + \
SnowflakeLayout._CHILDREN_FACTOR * len(self._children)
+ self._size = self._r * 2 + SnowflakeLayout._BORDER + \
+ SnowflakeLayout._FLAKE_DISTANCE * 2
- c = self._r + SnowflakeLayout._BORDER + \
- SnowflakeLayout._FLAKE_DISTANCE * 2
-
- self._cx = c
- self._cy = c
+ self._cx = self._size / 2
+ self._cy = self._size / 2
self._layout_root()