Start trying to deal with current activity changes

This commit is contained in:
Dan Williams 2006-09-21 16:49:25 -04:00
parent ab7ef75518
commit 3c11feca6f

View File

@ -6,6 +6,10 @@ class BuddyModel:
if buddy: if buddy:
self.set_name(buddy.get_name()) self.set_name(buddy.get_name())
self.set_color(buddy.get_color()) self.set_color(buddy.get_color())
self._buddy = buddy
self._cur_activity = None
self._pservice = PresenceService.get_instance()
self._pservice.connect('buddy-appeared', self.__buddy_appeared_cb)
def set_name(self, name): def set_name(self, name):
self._name = name self._name = name
@ -20,5 +24,18 @@ class BuddyModel:
return self._color return self._color
def get_buddy(self): def get_buddy(self):
pservice = PresenceService.get_instance() if not self._buddy:
return pservice.get_buddy_by_name(self._name) self._buddy = self._pservice.get_buddy_by_name(self._name)
if self._buddy:
self._buddy.connect('property-changed',
self.__buddy_property_changed_cb)
return self._buddy
def __buddy_appeared_cb(self, pservice, buddy):
if not self._buddy and buddy.get_name() == self._name:
self.get_buddy()
def __buddy_property_changed_cb(self, buddy, keys):
curact = self._buddy.get_current_activity()
self._cur_activity = self._pservice.get_activity(curact)