Add initial activities & protect against addition/removal of buddies we don't know about

This commit is contained in:
Dan Williams 2006-10-19 15:06:01 -04:00
parent cacb967ec3
commit 4a09253f5f

View File

@ -37,9 +37,16 @@ class FriendsBox(hippo.CanvasBox):
self._pservice.connect('activity-appeared', self._pservice.connect('activity-appeared',
self.__activity_appeared_cb) self.__activity_appeared_cb)
# Add initial activities the PS knows about
for activity in self._pservice.get_activities():
self.__activity_appeared_cb(self._pservice, activity)
shell.connect('activity-changed', self.__activity_changed_cb) shell.connect('activity-changed', self.__activity_changed_cb)
def add_buddy(self, buddy): def add_buddy(self, buddy):
if self._buddies.has_key(buddy.get_name()):
return
model = BuddyModel(buddy=buddy) model = BuddyModel(buddy=buddy)
icon = BuddyIcon(self._shell, self._menu_shell, model) icon = BuddyIcon(self._shell, self._menu_shell, model)
style.apply_stylesheet(icon, 'frame.BuddyIcon') style.apply_stylesheet(icon, 'frame.BuddyIcon')
@ -48,6 +55,9 @@ class FriendsBox(hippo.CanvasBox):
self._buddies[buddy.get_name()] = icon self._buddies[buddy.get_name()] = icon
def remove_buddy(self, buddy): def remove_buddy(self, buddy):
if not self._buddies.has_key(buddy.get_name()):
return
self.remove(self._buddies[buddy.get_name()]) self.remove(self._buddies[buddy.get_name()])
def clear(self): def clear(self):