Unify update_mood, update_tune, update_activity by using a single update_pep(pep_type) method.
This commit is contained in:
parent
4c03c1ab85
commit
338cb11dcc
|
@ -1280,13 +1280,11 @@ class ChatControl(ChatControlBase):
|
|||
|
||||
self.update_toolbar()
|
||||
|
||||
self._mood_image = self.xml.get_widget('mood_image')
|
||||
self._activity_image = self.xml.get_widget('activity_image')
|
||||
self._tune_image = self.xml.get_widget('tune_image')
|
||||
|
||||
self.update_mood()
|
||||
self.update_activity()
|
||||
self.update_tune()
|
||||
self._pep_images = {}
|
||||
self._pep_images['mood'] = self.xml.get_widget('mood_image')
|
||||
self._pep_images['activity'] = self.xml.get_widget('activity_image')
|
||||
self._pep_images['tune'] = self.xml.get_widget('tune_image')
|
||||
self.update_all_pep_types()
|
||||
|
||||
# keep timeout id and window obj for possible big avatar
|
||||
# it is on enter-notify and leave-notify so no need to be
|
||||
|
@ -1431,37 +1429,21 @@ class ChatControl(ChatControlBase):
|
|||
else:
|
||||
self._convert_to_gc_button.set_sensitive(False)
|
||||
|
||||
def update_mood(self):
|
||||
if isinstance(self.contact, GC_Contact):
|
||||
return
|
||||
pep = self.contact.pep
|
||||
if 'mood' in pep:
|
||||
self._mood_image.set_from_pixbuf(pep['mood'].asPixbufIcon())
|
||||
self._mood_image.set_tooltip_markup(pep['mood'].asMarkupText())
|
||||
self._mood_image.show()
|
||||
else:
|
||||
self._mood_image.hide()
|
||||
def update_all_pep_types(self):
|
||||
for pep_type in ('tune', 'mood', 'activity'):
|
||||
self.update_pep(pep_type)
|
||||
|
||||
def update_activity(self):
|
||||
def update_pep(self, pep_type):
|
||||
if isinstance(self.contact, GC_Contact):
|
||||
return
|
||||
pep = self.contact.pep
|
||||
if 'activity' in pep:
|
||||
self._activity_image.set_from_pixbuf(pep['activity'].asPixbufIcon())
|
||||
self._activity_image.set_tooltip_markup(pep['activity'].asMarkupText())
|
||||
self._activity_image.show()
|
||||
img = self._pep_images[pep_type]
|
||||
if pep_type in pep:
|
||||
img.set_from_pixbuf(pep[pep_type].asPixbufIcon())
|
||||
img.set_tooltip_markup(pep[pep_type].asMarkupText())
|
||||
img.show()
|
||||
else:
|
||||
self._activity_image.hide()
|
||||
|
||||
def update_tune(self):
|
||||
if isinstance(self.contact, GC_Contact):
|
||||
return
|
||||
pep = self.contact.pep
|
||||
if 'tune' in pep:
|
||||
self._tune_image.set_tooltip_markup(pep['tune'].asMarkupText())
|
||||
self._tune_image.show()
|
||||
else:
|
||||
self._tune_image.hide()
|
||||
img.hide()
|
||||
|
||||
def _update_jingle(self, jingle_type):
|
||||
if jingle_type not in ('audio', 'video'):
|
||||
|
|
|
@ -594,8 +594,7 @@ def delete_pep(jid, name):
|
|||
common.gajim.interface.roster.draw_mood(user, name)
|
||||
ctrl = common.gajim.interface.msg_win_mgr.get_control(user, name)
|
||||
if ctrl:
|
||||
ctrl.update_activity()
|
||||
ctrl.update_tune()
|
||||
ctrl.update_mood()
|
||||
ctrl.update_all_pep_types()
|
||||
|
||||
|
||||
# vim: se ts=3:
|
||||
|
|
|
@ -2001,15 +2001,15 @@ class Interface:
|
|||
if pep_type == 'mood':
|
||||
self.roster.draw_mood(jid, account)
|
||||
if ctrl:
|
||||
ctrl.update_mood()
|
||||
ctrl.update_pep(pep_type)
|
||||
elif pep_type == 'tune':
|
||||
self.roster.draw_tune(jid, account)
|
||||
if ctrl:
|
||||
ctrl.update_tune()
|
||||
ctrl.update_pep(pep_type)
|
||||
elif pep_type == 'activity':
|
||||
self.roster.draw_activity(jid, account)
|
||||
if ctrl:
|
||||
ctrl.update_activity()
|
||||
ctrl.update_pep(pep_type)
|
||||
elif pep_type == 'nickname':
|
||||
self.roster.draw_contact(jid, account)
|
||||
if ctrl:
|
||||
|
|
Loading…
Reference in New Issue