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