More Shell fixes for new PS
This commit is contained in:
parent
76a0f45aa8
commit
508a59b99b
@ -59,17 +59,17 @@ class BuddyModel(gobject.GObject):
|
||||
|
||||
# If successful, copy properties from the PS buddy object
|
||||
if buddy:
|
||||
self.__update_buddy(buddy)
|
||||
self._update_buddy(buddy)
|
||||
else:
|
||||
# Otherwise, connect to the PS's buddy-appeared signal and
|
||||
# wait for the buddy to appear
|
||||
self._ba_handler = self._pservice.connect('buddy-appeared',
|
||||
self.__buddy_appeared_cb)
|
||||
self._buddy_appeared_cb)
|
||||
self._name = name
|
||||
# Set color to 'inactive'/'disconnected'
|
||||
self.__set_color_from_string(_NOT_PRESENT_COLOR)
|
||||
self._set_color_from_string(_NOT_PRESENT_COLOR)
|
||||
|
||||
def __set_color_from_string(self, color_string):
|
||||
def _set_color_from_string(self, color_string):
|
||||
self._color = XoColor(color_string)
|
||||
|
||||
def get_name(self):
|
||||
@ -88,23 +88,21 @@ class BuddyModel(gobject.GObject):
|
||||
|
||||
def get_current_activity(self):
|
||||
if self._buddy:
|
||||
return self._buddy.get_current_activity()
|
||||
return self._buddy.props.current_activity
|
||||
return None
|
||||
|
||||
def __update_buddy(self, buddy):
|
||||
def _update_buddy(self, buddy):
|
||||
if not buddy:
|
||||
raise ValueError("Buddy cannot be None.")
|
||||
|
||||
self._buddy = buddy
|
||||
self._name = self._buddy.get_name()
|
||||
self.__set_color_from_string(self._buddy.get_color())
|
||||
self._name = self._buddy.props.nick
|
||||
self._set_color_from_string(self._buddy.props.color)
|
||||
|
||||
self._pc_handler = self._buddy.connect('property-changed', self.__buddy_property_changed_cb)
|
||||
self._dis_handler = self._buddy.connect('disappeared', self.__buddy_disappeared_cb)
|
||||
self._bic_handler = self._buddy.connect('icon-changed', self.__buddy_icon_changed_cb)
|
||||
self._cac_handler = self._buddy.connect('current-activity-changed', self.__buddy_current_activity_changed_cb)
|
||||
self._pc_handler = self._buddy.connect('property-changed', self._buddy_property_changed_cb)
|
||||
self._bic_handler = self._buddy.connect('icon-changed', self._buddy_icon_changed_cb)
|
||||
|
||||
def __buddy_appeared_cb(self, pservice, buddy):
|
||||
def _buddy_appeared_cb(self, pservice, buddy):
|
||||
# FIXME: use public key rather than buddy name
|
||||
if self._buddy or buddy.get_name() != self._name:
|
||||
return
|
||||
@ -115,31 +113,31 @@ class BuddyModel(gobject.GObject):
|
||||
self._pservice.disconnect(self._ba_handler)
|
||||
self._ba_handler = None
|
||||
|
||||
self.__update_buddy(buddy)
|
||||
self._update_buddy(buddy)
|
||||
self.emit('appeared')
|
||||
|
||||
def __buddy_property_changed_cb(self, buddy, keys):
|
||||
def _buddy_property_changed_cb(self, buddy, keys):
|
||||
if not self._buddy:
|
||||
return
|
||||
if 'color' in keys:
|
||||
self.__set_color_from_string(self._buddy.get_color())
|
||||
self._set_color_from_string(self._buddy.props.color)
|
||||
self.emit('color-changed', self.get_color())
|
||||
|
||||
def __buddy_disappeared_cb(self, buddy):
|
||||
def _buddy_disappeared_cb(self, buddy):
|
||||
if buddy != self._buddy:
|
||||
return
|
||||
self._buddy.disconnect(self._pc_handler)
|
||||
self._buddy.disconnect(self._dis_handler)
|
||||
self._buddy.disconnect(self._bic_handler)
|
||||
self._buddy.disconnect(self._cac_handler)
|
||||
self.__set_color_from_string(_NOT_PRESENT_COLOR)
|
||||
self._set_color_from_string(_NOT_PRESENT_COLOR)
|
||||
self.emit('disappeared')
|
||||
self._buddy = None
|
||||
|
||||
def __buddy_icon_changed_cb(self, buddy):
|
||||
def _buddy_icon_changed_cb(self, buddy):
|
||||
self.emit('icon-changed')
|
||||
|
||||
def __buddy_current_activity_changed_cb(self, buddy, activity=None):
|
||||
def _buddy_current_activity_changed_cb(self, buddy, activity=None):
|
||||
if not self._buddy:
|
||||
return
|
||||
self.emit('current-activity-changed', activity)
|
||||
|
@ -159,9 +159,9 @@ class MeshModel(gobject.GObject):
|
||||
return self._buddies.values()
|
||||
|
||||
def _buddy_activity_changed_cb(self, buddy, cur_activity):
|
||||
if not self._buddies.has_key(buddy.get_name()):
|
||||
if not self._buddies.has_key(buddy.props.nick):
|
||||
return
|
||||
buddy_model = self._buddies[buddy.get_name()]
|
||||
buddy_model = self._buddies[buddy.props.nick]
|
||||
if cur_activity == None:
|
||||
self.emit('buddy-moved', buddy_model, None)
|
||||
else:
|
||||
@ -183,15 +183,15 @@ class MeshModel(gobject.GObject):
|
||||
self._buddies[model.get_name()] = model
|
||||
self.emit('buddy-added', model)
|
||||
|
||||
cur_activity = buddy.get_current_activity()
|
||||
cur_activity = buddy.props.current_activity
|
||||
if cur_activity:
|
||||
self._notify_buddy_change(model, cur_activity)
|
||||
|
||||
def _buddy_disappeared_cb(self, pservice, buddy):
|
||||
if not self._buddies.has_key(buddy.get_name()):
|
||||
if not self._buddies.has_key(buddy.props.nick):
|
||||
return
|
||||
self.emit('buddy-removed', buddy)
|
||||
del self._buddies[buddy.get_name()]
|
||||
del self._buddies[buddy.props.nick]
|
||||
|
||||
def _activity_appeared_cb(self, pservice, activity):
|
||||
self._check_activity(activity)
|
||||
|
Loading…
Reference in New Issue
Block a user