From b3de522e275aa85f85b4f18f9b0650e4b5d853a5 Mon Sep 17 00:00:00 2001 From: Alex Mauer Date: Wed, 14 Sep 2005 23:11:13 +0000 Subject: [PATCH] Comment code better; use references more often for greater efficiency --- src/roster_window.py | 24 +++++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-) diff --git a/src/roster_window.py b/src/roster_window.py index 1e2cf185e..b1c93bb27 100644 --- a/src/roster_window.py +++ b/src/roster_window.py @@ -663,6 +663,7 @@ class RosterWindow: self.tooltip.hide_tooltip() return if model[iter][C_TYPE] == 'contact': + # we're on a contact entry in the roster account = model[iter][C_ACCOUNT].decode('utf-8') jid = model[iter][C_JID].decode('utf-8') if self.tooltip.timeout == 0 or self.tooltip.id != props[0]: @@ -670,16 +671,29 @@ class RosterWindow: self.tooltip.timeout = gobject.timeout_add(500, self.show_tooltip, gajim.contacts[account][jid]) elif model[iter][C_TYPE] == 'account': + # we're on an account entry in the roster account = model[iter][C_NAME].decode('utf-8') jid = gajim.get_jid_from_account(account) contacts = [] - contact = Contact(jid=jid, name=account, show=gajim.connections[account].get_status(), status=gajim.connections[account].status, resource=gajim.config.get_per('accounts', gajim.connections[account].name, 'resource'), keyID=gajim.config.get_per('accounts', gajim.connections[account].name, 'keyid')) + connection = gajim.connections[account] + # get our current contact info + contact = Contact(jid=jid, name=account, + show=connection.get_status(), + status=connection.status, + resource=gajim.config.get_per('accounts', connection.name, 'resource'), + keyID=gajim.config.get_per('accounts', connection.name, 'keyid')) contacts.append(contact) - if gajim.connections[account].connection: - if gajim.connections[account].connection.getRoster().getItem(jid): - resources = gajim.connections[account].connection.getRoster().getResources(jid) + # if we're online ... + if connection.connection: + roster = connection.connection.getRoster() + if roster.getItem(jid): + resources = roster.getResources(jid) + # ...get the contact info for our other online resources for resource in resources: - contact = Contact(jid=jid, name=account, show=gajim.connections[account].connection.getRoster().getShow(jid+'/'+resource), status=gajim.connections[account].connection.getRoster().getStatus(jid+'/'+resource), resource=resource, priority=gajim.connections[account].connection.getRoster().getPriority(jid+'/'+resource)) + contact = Contact(jid=jid, name=account, + show=roster.getShow(jid+'/'+resource), + status=roster.getStatus(jid+'/'+resource), resource=resource, + priority=roster.getPriority(jid+'/'+resource)) contacts.append(contact) if self.tooltip.timeout == 0 or self.tooltip.id != props[0]: self.tooltip.id = row