Unify update_mood, update_tune, update_activity by using a single update_pep(pep_type) method.

This commit is contained in:
Stephan Erb 2009-11-15 22:54:20 +01:00
parent 4c03c1ab85
commit 338cb11dcc
3 changed files with 22 additions and 41 deletions

View File

@ -1279,14 +1279,12 @@ class ChatControl(ChatControlBase):
self.video_state = self.JINGLE_STATE_NOT_AVAILABLE
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
@ -1430,38 +1428,22 @@ class ChatControl(ChatControlBase):
self._convert_to_gc_button.set_sensitive(True)
else:
self._convert_to_gc_button.set_sensitive(False)
def update_all_pep_types(self):
for pep_type in ('tune', 'mood', 'activity'):
self.update_pep(pep_type)
def update_mood(self):
def update_pep(self, pep_type):
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()
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._mood_image.hide()
def update_activity(self):
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()
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'):

View File

@ -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:

View File

@ -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: