From b21a1e248923dee6ee71b877c5a36028e62addf0 Mon Sep 17 00:00:00 2001 From: Brendan Taylor Date: Thu, 26 Jun 2008 23:37:12 +0000 Subject: [PATCH] win.get_controls() isn't needed anymore --- src/gajim.py | 19 ++++++++----------- src/groupchat_control.py | 2 +- src/message_window.py | 6 ------ src/roster_window.py | 8 +++++--- 4 files changed, 14 insertions(+), 21 deletions(-) diff --git a/src/gajim.py b/src/gajim.py index 057f62fe0..5d8a0d463 100755 --- a/src/gajim.py +++ b/src/gajim.py @@ -1034,17 +1034,15 @@ class Interface: win.set_values(vcard) # show avatar in chat - ctrls = [] if resource and self.msg_win_mgr.has_window(fjid, account): win = self.msg_win_mgr.get_window(fjid, account) - ctrls = win.get_controls(fjid, account) + ctrl = win.get_control(fjid, account) elif self.msg_win_mgr.has_window(jid, account): win = self.msg_win_mgr.get_window(jid, account) - ctrls = win.get_controls(jid, account) + ctrl = win.get_control(jid, account) - for ctrl in ctrls: - if ctrl.type_id != message_control.TYPE_GC: - ctrl.show_avatar() + if ctrl and ctrl.type_id != message_control.TYPE_GC: + ctrl.show_avatar() # Show avatar in roster or gc_roster gc_ctrl = self.msg_win_mgr.get_gc_control(jid, account) @@ -2605,9 +2603,7 @@ class Interface: win = self.msg_win_mgr.get_window(fjid, account) if win: - ctrls = win.get_controls(fjid, account) - if ctrls: - ctrl = ctrls[0] + ctrl = win.get_control(fjid, account) if not ctrl: ctrl = self.new_chat(contact, account, @@ -2620,8 +2616,9 @@ class Interface: win.set_active_tab(ctrl) if gajim.connections[account].is_zeroconf and \ - gajim.connections[account].status in ('offline', 'invisible'): - for ctrl in win.get_controls(fjid, account): + gajim.connections[account].status in ('offline', 'invisible'): + ctrl = win.get_control(fjid, account) + if ctrl: ctrl.got_disconnected() ################################################################################ diff --git a/src/groupchat_control.py b/src/groupchat_control.py index 542561ef0..fe4a142f7 100644 --- a/src/groupchat_control.py +++ b/src/groupchat_control.py @@ -2076,7 +2076,7 @@ class GroupchatControl(ChatControlBase): gajim.interface.new_private_chat(gc_c, self.account) win = gajim.interface.msg_win_mgr.get_window(nick_jid, self.account) - ctrl = win.get_controls(nick_jid, self.account)[0] + ctrl = win.get_control(nick_jid, self.account) win.set_active_tab(ctrl) diff --git a/src/message_window.py b/src/message_window.py index be2816920..013e51942 100644 --- a/src/message_window.py +++ b/src/message_window.py @@ -586,12 +586,6 @@ class MessageWindow(object): def has_control(self, jid, acct): return (acct in self._controls and jid in self._controls[acct]) - def get_controls(self, jid, acct): - try: - return self._controls[acct][jid] - except KeyError: - return [] - def change_key(self, old_jid, new_jid, acct): '''Change the JID key of a control''' try: diff --git a/src/roster_window.py b/src/roster_window.py index c22b66909..6d467e130 100644 --- a/src/roster_window.py +++ b/src/roster_window.py @@ -1812,7 +1812,7 @@ class RosterWindow: if len(contact_instances) > 1: if contact.resource != '': name += '/' + contact.resource - + # Remove resource when going offline if show in ('offline', 'error') and \ len(gajim.events.get_events(account, contact.get_full_jid())) == 0: @@ -1821,7 +1821,8 @@ class RosterWindow: account): win = gajim.interface.msg_win_mgr.get_window(jid_with_resource, account) - for ctrl in win.get_controls(jid_with_resource, account): + ctrl = win.get_control(jid_with_resource, account) + if ctrl: ctrl.update_ui() win.redraw_tab(ctrl) gajim.contacts.remove_contact(account, contact) @@ -1836,7 +1837,8 @@ class RosterWindow: win = gajim.interface.msg_win_mgr.get_window(contact.jid, account) uf_show = helpers.get_uf_show(show) - for ctrl in win.get_controls(contact.jid, account): + ctrl = win.get_control(contact.jid, account) + if ctrl: ctrl.contact = gajim.contacts.get_contact_with_highest_priority( account, contact.jid) ctrl.update_ui()