Fix a race in the spread box. Adapt to api change.
This commit is contained in:
parent
6eafa73922
commit
4f81f305b2
@ -134,7 +134,7 @@ class MeshModel(gobject.GObject):
|
|||||||
name = buddy.get_name()
|
name = buddy.get_name()
|
||||||
if cur_activity == activity and self._buddies.has_key(name):
|
if cur_activity == activity and self._buddies.has_key(name):
|
||||||
buddy_model = self._buddies[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):
|
def _activity_disappeared_cb(self, pservice, activity):
|
||||||
if self._activities.has_key(activity.get_id()):
|
if self._activities.has_key(activity.get_id()):
|
||||||
|
@ -47,7 +47,7 @@ class FriendsBox(SpreadBox, hippo.CanvasItem):
|
|||||||
|
|
||||||
def add_friend(self, buddy_info):
|
def add_friend(self, buddy_info):
|
||||||
icon = FriendView(self._shell, self._menu_shell, 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
|
self._friends[buddy_info.get_name()] = icon
|
||||||
|
|
||||||
@ -55,7 +55,7 @@ class FriendsBox(SpreadBox, hippo.CanvasItem):
|
|||||||
self.add_friend(buddy_info)
|
self.add_friend(buddy_info)
|
||||||
|
|
||||||
def _friend_removed_cb(self, data_model, name):
|
def _friend_removed_cb(self, data_model, name):
|
||||||
self.remove(self._friends[name])
|
self.remove_item(self._friends[name])
|
||||||
del self._friends[name]
|
del self._friends[name]
|
||||||
|
|
||||||
def do_allocate(self, width, height):
|
def do_allocate(self, width, height):
|
||||||
|
@ -99,13 +99,13 @@ class MeshBox(SpreadBox):
|
|||||||
def _add_alone_buddy(self, buddy_model):
|
def _add_alone_buddy(self, buddy_model):
|
||||||
icon = BuddyIcon(self._shell, self._menu_shell, buddy_model)
|
icon = BuddyIcon(self._shell, self._menu_shell, buddy_model)
|
||||||
icon.props.size = 80
|
icon.props.size = 80
|
||||||
self.add(icon)
|
self.add_item(icon)
|
||||||
|
|
||||||
self._buddies[buddy_model.get_name()] = icon
|
self._buddies[buddy_model.get_name()] = icon
|
||||||
|
|
||||||
def _remove_alone_buddy(self, buddy_model):
|
def _remove_alone_buddy(self, buddy_model):
|
||||||
icon = self._buddies[buddy_model.get_name()]
|
icon = self._buddies[buddy_model.get_name()]
|
||||||
self.remove(icon)
|
self.remove_item(icon)
|
||||||
del self._buddies[buddy_model.get_name()]
|
del self._buddies[buddy_model.get_name()]
|
||||||
|
|
||||||
def _remove_buddy(self, buddy_model):
|
def _remove_buddy(self, buddy_model):
|
||||||
@ -133,11 +133,11 @@ class MeshBox(SpreadBox):
|
|||||||
|
|
||||||
def _add_activity(self, activity_model):
|
def _add_activity(self, activity_model):
|
||||||
icon = ActivityView(self._shell, self._menu_shell, 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
|
self._activities[activity_model.get_id()] = icon
|
||||||
|
|
||||||
def _remove_activity(self, activity_model):
|
def _remove_activity(self, activity_model):
|
||||||
icon = self._activities[activity_model.get_id()]
|
icon = self._activities[activity_model.get_id()]
|
||||||
self.remove(icon)
|
self.remove_item(icon)
|
||||||
del self._activities[activity_model.get_id()]
|
del self._activities[activity_model.get_id()]
|
||||||
|
@ -33,10 +33,15 @@ class SpreadBox(hippo.CanvasBox, hippo.CanvasItem):
|
|||||||
self._spread_on_add = False
|
self._spread_on_add = False
|
||||||
self._stable = False
|
self._stable = False
|
||||||
|
|
||||||
def add(self, item):
|
def add_item(self, item):
|
||||||
self._items_to_position.append(item)
|
self._items_to_position.append(item)
|
||||||
self.append(item, hippo.PACK_FIXED)
|
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):
|
def _get_distance(self, icon1, icon2):
|
||||||
[icon1_x, icon1_y] = self.get_position(icon1)
|
[icon1_x, icon1_y] = self.get_position(icon1)
|
||||||
[icon2_x, icon2_y] = self.get_position(icon2)
|
[icon2_x, icon2_y] = self.get_position(icon2)
|
||||||
|
Loading…
Reference in New Issue
Block a user