Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/shell
diff options
context:
space:
mode:
authorMarco Pesenti Gritti <marco@localhost.localdomain>2006-10-06 09:11:38 (GMT)
committer Marco Pesenti Gritti <marco@localhost.localdomain>2006-10-06 09:11:38 (GMT)
commitb33a1c141f8e47b7d57a033baa9f0a44ea8d8834 (patch)
tree2bdb87dc43fdecf9c90dad58f359b733fb339b03 /shell
parentf216f7bc0a20b446bc9723e7a1e50486931ebbac (diff)
Move the layouts to be box and subclass them.
Diffstat (limited to 'shell')
-rw-r--r--shell/view/home/FriendsBox.py16
-rw-r--r--shell/view/home/MeshBox.py33
2 files changed, 20 insertions, 29 deletions
diff --git a/shell/view/home/FriendsBox.py b/shell/view/home/FriendsBox.py
index cb8b3f6..ed722f4 100644
--- a/shell/view/home/FriendsBox.py
+++ b/shell/view/home/FriendsBox.py
@@ -1,20 +1,20 @@
import random
import hippo
+import gobject
-from sugar.graphics.spreadlayout import SpreadLayout
+from sugar.graphics.spreadbox import SpreadBox
from sugar.graphics import style
from view.home.MyIcon import MyIcon
from view.home.FriendView import FriendView
-class FriendsBox(hippo.CanvasBox, hippo.CanvasItem):
+class FriendsBox(SpreadBox, hippo.CanvasItem):
__gtype_name__ = 'SugarFriendsBox'
def __init__(self, shell, menu_shell):
- hippo.CanvasBox.__init__(self, background_color=0xe2e2e2ff)
+ SpreadBox.__init__(self, background_color=0xe2e2e2ff)
self._shell = shell
self._menu_shell = menu_shell
- self._layout = SpreadLayout()
self._friends = {}
self._my_icon = MyIcon()
@@ -29,9 +29,11 @@ class FriendsBox(hippo.CanvasBox, hippo.CanvasItem):
friends.connect('friend-added', self._friend_added_cb)
friends.connect('friend-removed', self._friend_removed_cb)
+ gobject.idle_add(self.spread)
+
def add_friend(self, buddy_info):
icon = FriendView(self._shell, self._menu_shell, buddy_info)
- self.append(icon, hippo.PACK_FIXED)
+ self.add(icon)
self._friends[buddy_info.get_name()] = icon
@@ -43,9 +45,7 @@ class FriendsBox(hippo.CanvasBox, hippo.CanvasItem):
del self._friends[name]
def do_allocate(self, width, height):
- hippo.CanvasBox.do_allocate(self, width, height)
-
- self._layout.layout(self)
+ SpreadBox.do_allocate(self, width, height)
[icon_width, icon_height] = self._my_icon.get_allocation()
self.move(self._my_icon, (width - icon_width) / 2,
diff --git a/shell/view/home/MeshBox.py b/shell/view/home/MeshBox.py
index 9b3ce3c..be47f7e 100644
--- a/shell/view/home/MeshBox.py
+++ b/shell/view/home/MeshBox.py
@@ -1,28 +1,27 @@
import random
import hippo
+import gobject
-from sugar.graphics.spreadlayout import SpreadLayout
+from sugar.graphics.spreadbox import SpreadBox
+from sugar.graphics.snowflakebox import SnowflakeBox
from sugar.graphics.canvasicon import CanvasIcon
from view.BuddyIcon import BuddyIcon
-from sugar.graphics.snowflakelayout import SnowflakeLayout
import conf
-class ActivityView(hippo.CanvasBox, hippo.CanvasItem):
- __gtype_name__ = 'SugarActivityView'
+class ActivityView(SnowflakeBox):
def __init__(self, shell, menu_shell, model):
- hippo.CanvasBox.__init__(self)
+ SnowflakeBox.__init__(self)
self._shell = shell
self._model = model
- self._layout = SnowflakeLayout()
self._icons = {}
icon = CanvasIcon(icon_name=model.get_icon_name(),
color=model.get_color(), size=80)
icon.connect('activated', self._clicked_cb)
self.append(icon, hippo.PACK_FIXED)
- self._layout.set_root(icon)
+ self.set_root(icon)
def has_buddy_icon(self, name):
return self._icons.has_key(name)
@@ -42,19 +41,13 @@ class ActivityView(hippo.CanvasBox, hippo.CanvasItem):
bundle = registry.get_activity_from_type(default_type)
self._shell.join_activity(bundle.get_id(), self._model.get_id())
- def do_allocate(self, width, height):
- hippo.CanvasBox.do_allocate(self, width, height)
- self._layout.layout(self)
-
-class MeshBox(hippo.CanvasBox, hippo.CanvasItem):
- __gtype_name__ = 'SugarMeshBox'
+class MeshBox(SpreadBox):
def __init__(self, shell, menu_shell):
- hippo.CanvasBox.__init__(self, background_color=0xe2e2e2ff)
+ SpreadBox.__init__(self, background_color=0xe2e2e2ff)
self._shell = shell
self._menu_shell = menu_shell
self._model = shell.get_model().get_mesh()
- self._layout = SpreadLayout()
self._buddies = {}
self._activities = {}
self._buddy_to_activity = {}
@@ -72,6 +65,8 @@ class MeshBox(hippo.CanvasBox, hippo.CanvasItem):
self._model.connect('activity-added', self._activity_added_cb)
self._model.connect('activity-removed', self._activity_removed_cb)
+ gobject.idle_add(self.spread)
+
def _buddy_added_cb(self, model, buddy_model):
self._add_alone_buddy(buddy_model)
@@ -90,7 +85,7 @@ class MeshBox(hippo.CanvasBox, hippo.CanvasItem):
def _add_alone_buddy(self, buddy_model):
icon = BuddyIcon(self._shell, self._menu_shell, buddy_model)
icon.props.size = 80
- self.append(icon, hippo.PACK_FIXED)
+ self.add(icon)
self._buddies[buddy_model.get_name()] = icon
@@ -124,7 +119,7 @@ class MeshBox(hippo.CanvasBox, hippo.CanvasItem):
def _add_activity(self, activity_model):
icon = ActivityView(self._shell, self._menu_shell, activity_model)
- self.append(icon, hippo.PACK_FIXED)
+ self.add(icon)
self._activities[activity_model.get_id()] = icon
@@ -132,7 +127,3 @@ class MeshBox(hippo.CanvasBox, hippo.CanvasItem):
icon = self._activities[activity_model.get_id()]
self.remove(icon)
del self._activities[activity_model.get_id()]
-
- def do_allocate(self, width, height):
- hippo.CanvasBox.do_allocate(self, width, height)
- self._layout.layout(self)