Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarco Pesenti Gritti <marco@localhost.localdomain>2006-10-19 14:49:53 (GMT)
committer Marco Pesenti Gritti <marco@localhost.localdomain>2006-10-19 14:49:53 (GMT)
commit4f81f305b2da8098f323d22bae78e0239c88188f (patch)
treee73b38bb5f8f22348b5842185299afce7fc1726f
parent6eafa739223ad00b27957d158b6e188c8b9e37db (diff)
Fix a race in the spread box. Adapt to api change.
-rw-r--r--shell/model/MeshModel.py2
-rw-r--r--shell/view/home/FriendsBox.py4
-rw-r--r--shell/view/home/MeshBox.py8
-rw-r--r--sugar/graphics/spreadbox.py7
4 files changed, 13 insertions, 8 deletions
diff --git a/shell/model/MeshModel.py b/shell/model/MeshModel.py
index 908a5f9..2d48143 100644
--- a/shell/model/MeshModel.py
+++ b/shell/model/MeshModel.py
@@ -134,7 +134,7 @@ class MeshModel(gobject.GObject):
name = buddy.get_name()
if cur_activity == activity and self._buddies.has_key(name):
buddy_model = self._buddies[name]
- self.emit('buddy-moved', buddy, model)
+ self.emit('buddy-moved', buddy_model, model)
def _activity_disappeared_cb(self, pservice, activity):
if self._activities.has_key(activity.get_id()):
diff --git a/shell/view/home/FriendsBox.py b/shell/view/home/FriendsBox.py
index c92be7d..28a745e 100644
--- a/shell/view/home/FriendsBox.py
+++ b/shell/view/home/FriendsBox.py
@@ -47,7 +47,7 @@ class FriendsBox(SpreadBox, hippo.CanvasItem):
def add_friend(self, buddy_info):
icon = FriendView(self._shell, self._menu_shell, buddy_info)
- self.add(icon)
+ self.add_item(icon)
self._friends[buddy_info.get_name()] = icon
@@ -55,7 +55,7 @@ class FriendsBox(SpreadBox, hippo.CanvasItem):
self.add_friend(buddy_info)
def _friend_removed_cb(self, data_model, name):
- self.remove(self._friends[name])
+ self.remove_item(self._friends[name])
del self._friends[name]
def do_allocate(self, width, height):
diff --git a/shell/view/home/MeshBox.py b/shell/view/home/MeshBox.py
index a4e9906..c2682c0 100644
--- a/shell/view/home/MeshBox.py
+++ b/shell/view/home/MeshBox.py
@@ -99,13 +99,13 @@ class MeshBox(SpreadBox):
def _add_alone_buddy(self, buddy_model):
icon = BuddyIcon(self._shell, self._menu_shell, buddy_model)
icon.props.size = 80
- self.add(icon)
+ self.add_item(icon)
self._buddies[buddy_model.get_name()] = icon
def _remove_alone_buddy(self, buddy_model):
icon = self._buddies[buddy_model.get_name()]
- self.remove(icon)
+ self.remove_item(icon)
del self._buddies[buddy_model.get_name()]
def _remove_buddy(self, buddy_model):
@@ -133,11 +133,11 @@ class MeshBox(SpreadBox):
def _add_activity(self, activity_model):
icon = ActivityView(self._shell, self._menu_shell, activity_model)
- self.add(icon)
+ self.add_item(icon)
self._activities[activity_model.get_id()] = icon
def _remove_activity(self, activity_model):
icon = self._activities[activity_model.get_id()]
- self.remove(icon)
+ self.remove_item(icon)
del self._activities[activity_model.get_id()]
diff --git a/sugar/graphics/spreadbox.py b/sugar/graphics/spreadbox.py
index 43bf126..13ee99d 100644
--- a/sugar/graphics/spreadbox.py
+++ b/sugar/graphics/spreadbox.py
@@ -33,10 +33,15 @@ class SpreadBox(hippo.CanvasBox, hippo.CanvasItem):
self._spread_on_add = False
self._stable = False
- def add(self, item):
+ def add_item(self, item):
self._items_to_position.append(item)
self.append(item, hippo.PACK_FIXED)
+ def remove_item(self, item):
+ if self._items_to_position.count(item) > 0:
+ self._items_to_position.remove(item)
+ self.remove(item)
+
def _get_distance(self, icon1, icon2):
[icon1_x, icon1_y] = self.get_position(icon1)
[icon2_x, icon2_y] = self.get_position(icon2)