From fe5407907a8ab020f68246199527b39b99f1303a Mon Sep 17 00:00:00 2001 From: Yann Leboulanger Date: Sun, 15 Oct 2006 21:47:35 +0000 Subject: [PATCH] do not take into account offline resources in vcard / roster and tooltips. They may stay here if they are awaiting events. --- src/roster_window.py | 17 ++++++++++++++--- src/vcard.py | 11 +++++++++-- 2 files changed, 23 insertions(+), 5 deletions(-) diff --git a/src/roster_window.py b/src/roster_window.py index bb5ebaa16..595cec37f 100644 --- a/src/roster_window.py +++ b/src/roster_window.py @@ -471,8 +471,12 @@ class RosterWindow: return name = gtkgui_helpers.escape_for_pango_markup(contact.get_shown_name()) - if len(contact_instances) > 1: - name += ' (' + unicode(len(contact_instances)) + ')' + nb_connected_contact = 0 + for c in contact_instances: + if c.show not in ('error', 'offline'): + nb_connected_contact += 1 + if nb_connected_contact > 1: + name += ' (' + unicode(nb_connected_contact) + ')' # show (account_name) if there are 2 contact with same jid in merged mode if self.regroup: @@ -1175,8 +1179,15 @@ class RosterWindow: if self.tooltip.timeout == 0 or self.tooltip.id != props[0]: self.tooltip.id = row contacts = gajim.contacts.get_contact(account, jid) + connected_contacts = [] + for c in contacts: + if c.show not in ('offline', 'error'): + connected_contacts.append(c) + if not connected_contacts: + # no connected contacts, show the ofline one + connected_contacts = contacts self.tooltip.timeout = gobject.timeout_add(500, - self.show_tooltip, contacts) + self.show_tooltip, connected_contacts) elif model[iter][C_TYPE] == 'account': # we're on an account entry in the roster account = model[iter][C_ACCOUNT].decode('utf-8') diff --git a/src/vcard.py b/src/vcard.py index 157f91d6d..c6b699f08 100644 --- a/src/vcard.py +++ b/src/vcard.py @@ -213,11 +213,18 @@ class VcardWindow: if self.xml.get_widget('information_notebook').get_n_pages() < 4: return contact_list = gajim.contacts.get_contact(self.account, self.contact.jid) + connected_contact_list = [] + for c in contact_list: + if c.show not in ('offline', 'error'): + connected_contact_list.append(c) + if not connected_contact_list: + # no connected contact, get the offline one + connected_contact_list = contact_list # stats holds show and status message stats = '' one = True # Are we adding the first line ? - if contact_list: - for c in contact_list: + if connected_contact_list: + for c in connected_contact_list: if not one: stats += '\n' stats += helpers.get_uf_show(c.show)