Similar to update_pep, unify towards draw_pep of the RosterWindow.

This commit is contained in:
Stephan Erb 2009-11-15 23:23:56 +01:00
parent 28161dc33c
commit aa53988fd1
4 changed files with 34 additions and 32 deletions

View File

@ -1430,12 +1430,14 @@ class ChatControl(ChatControlBase):
self._convert_to_gc_button.set_sensitive(False) self._convert_to_gc_button.set_sensitive(False)
def update_all_pep_types(self): def update_all_pep_types(self):
for pep_type in ('tune', 'mood', 'activity'): for pep_type in self._pep_images:
self.update_pep(pep_type) self.update_pep(pep_type)
def update_pep(self, pep_type): def update_pep(self, pep_type):
if isinstance(self.contact, GC_Contact): if isinstance(self.contact, GC_Contact):
return return
if pep_type not in self._pep_images:
return
pep = self.contact.pep pep = self.contact.pep
img = self._pep_images[pep_type] img = self._pep_images[pep_type]
if pep_type in pep: if pep_type in pep:

View File

@ -584,9 +584,7 @@ def delete_pep(jid, name):
if jid == common.gajim.get_jid_from_account(name): if jid == common.gajim.get_jid_from_account(name):
common.gajim.interface.roster.draw_account(name) common.gajim.interface.roster.draw_account(name)
common.gajim.interface.roster.draw_activity(user, name) common.gajim.interface.roster.draw_all_pep_types(jid, name)
common.gajim.interface.roster.draw_tune(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_all_pep_types() ctrl.update_all_pep_types()

View File

@ -1998,25 +1998,17 @@ class Interface:
if jid == common.gajim.get_jid_from_account(account): if jid == common.gajim.get_jid_from_account(account):
self.roster.draw_account(account) self.roster.draw_account(account)
if pep_type == 'mood': if pep_type == 'nickname':
self.roster.draw_mood(jid, account)
if ctrl:
ctrl.update_pep(pep_type)
elif pep_type == 'tune':
self.roster.draw_tune(jid, account)
if ctrl:
ctrl.update_pep(pep_type)
elif pep_type == 'activity':
self.roster.draw_activity(jid, account)
if ctrl:
ctrl.update_pep(pep_type)
elif pep_type == 'nickname':
self.roster.draw_contact(jid, account) self.roster.draw_contact(jid, account)
if ctrl: if ctrl:
ctrl.update_ui() ctrl.update_ui()
win = ctrl.parent_win win = ctrl.parent_win
win.redraw_tab(ctrl) win.redraw_tab(ctrl)
win.show_title() win.show_title()
else:
self.roster.draw_pep(jid, account, pep_type)
if ctrl:
ctrl.update_pep(pep_type)
def register_handler(self, event, handler): def register_handler(self, event, handler):
if event not in self.handlers: if event not in self.handlers:

View File

@ -1242,19 +1242,27 @@ class RosterWindow:
return False return False
def draw_mood(self, jid, account): def _is_pep_shown_in_roster(self, pep_type):
if gajim.config.get('show_mood_in_roster'): if pep_type == 'mood':
self._draw_pep(jid, account, 'mood', C_MOOD_PIXBUF) return gajim.config.get('show_mood_in_roster')
elif pep_type == 'activity':
def draw_activity(self, jid, account): return gajim.config.get('show_activity_in_roster')
if gajim.config.get('show_activity_in_roster'): elif pep_type == 'tune':
self._draw_pep(jid, account, 'activity', C_ACTIVITY_PIXBUF) return gajim.config.get('show_tunes_in_roster')
else:
def draw_tune(self, jid, account): return False
if gajim.config.get('show_tunes_in_roster'):
self._draw_pep(jid, account, 'tune', C_TUNE_PIXBUF) def draw_all_pep_types(self, jid, account):
for pep_type in self._pep_type_to_model_column:
self.draw_pep(jid, account, pep_type)
def _draw_pep(self, jid, account, pep_type, model_column): def draw_pep(self, jid, account, pep_type):
if pep_type not in self._pep_type_to_model_column:
return
if not self._is_pep_shown_in_roster(pep_type):
return
model_column = self._pep_type_to_model_column[pep_type]
iters = self._get_contact_iter(jid, account, model=self.model) iters = self._get_contact_iter(jid, account, model=self.model)
if not iters: if not iters:
return return
@ -1285,9 +1293,7 @@ class RosterWindow:
def draw_completely(self, jid, account): def draw_completely(self, jid, account):
self.draw_contact(jid, account) self.draw_contact(jid, account)
self.draw_mood(jid, account) self.draw_all_pep_types(jid, account)
self.draw_activity(jid, account)
self.draw_tune(jid, account)
self.draw_avatar(jid, account) self.draw_avatar(jid, account)
def adjust_and_draw_contact_context(self, jid, account): def adjust_and_draw_contact_context(self, jid, account):
@ -5753,6 +5759,10 @@ class RosterWindow:
col.add_attribute(render_pixbuf, 'pixbuf', C_TUNE_PIXBUF) col.add_attribute(render_pixbuf, 'pixbuf', C_TUNE_PIXBUF)
col.set_cell_data_func(render_pixbuf, col.set_cell_data_func(render_pixbuf,
self._fill_pep_pixbuf_renderer, C_TUNE_PIXBUF) self._fill_pep_pixbuf_renderer, C_TUNE_PIXBUF)
self._pep_type_to_model_column = {'mood': C_MOOD_PIXBUF,
'activity': C_ACTIVITY_PIXBUF,
'tune': C_ACTIVITY_PIXBUF}
if gajim.config.get('avatar_position_in_roster') == 'right': if gajim.config.get('avatar_position_in_roster') == 'right':
add_avatar_renderer() add_avatar_renderer()