tooltip to show multiple resources [thanks Dimitur Kirov!!]

This commit is contained in:
Nikos Kouremenos 2005-07-08 00:04:59 +00:00
parent b75562490b
commit 4fe2414534
2 changed files with 54 additions and 32 deletions

View File

@ -565,41 +565,67 @@ class RosterTooltip(gtk.Window):
self.hide() self.hide()
self.path = None self.path = None
def populate(self, contact, img): def populate(self, contacts, img):
if img: if img:
self.image.set_from_pixbuf(img.get_pixbuf()) self.image.set_from_pixbuf(img.get_pixbuf())
else: else:
self.image.set_from_pixbuf(None) self.image.set_from_pixbuf(None)
info = '<span size="large" weight="bold">' + contact.jid + '</span>' #self.image = img # why this doesn't work? MYSTERY! [maybe I need to sleep]
if not contacts or len(contacts) == 0:
return
# default resource of the contact
prim_contact = None # primary contact
for contact in contacts:
if prim_contact == None or contact.priority > prim_contact.priority:
prim_contact = contact
info = '<span size="large" weight="bold">' + prim_contact.jid + '</span>'
info += '\n<span weight="bold">' + _('Name: ') + '</span>' + \ info += '\n<span weight="bold">' + _('Name: ') + '</span>' + \
contact.name prim_contact.name
info += '\n<span weight="bold">' + _('Subscription: ') + '</span>' + \ info += '\n<span weight="bold">' + _('Subscription: ') + '</span>' + \
contact.sub prim_contact.sub
if contact.keyID:
if prim_contact.keyID:
keyID = None keyID = None
if len(contact.keyID) == 8: if len(prim_contact.keyID) == 8:
keyID = contact.keyID keyID = prim_contact.keyID
elif len(contact.keyID) == 16: elif len(prim_contact.keyID) == 16:
keyID = contact.keyID[8:] keyID = prim_contact.keyID[8:]
if keyID: if keyID:
info += '\n<span weight="bold">' + _('OpenPGP: ') + '</span>' + \ info += '\n<span weight="bold">' + _('OpenPGP: ') + \
keyID '</span>' + keyID
resource_str, status_str, multiple_resource, multiple_status =\
'', '', False, False
for contact in contacts:
if contact.resource: if contact.resource:
info += '\n<span weight="bold">' + _('Resource: ') + '</span>' + \ if resource_str != '':
contact.resource + ' (' + str(contact.priority) + ')' multiple_resource = True
#FIXME: we need the account resource_str += '\n\t' + contact.resource + \
# lcontact = self.plugin.roster.contacts[acct][contact.jid] '(' + str(contact.priority) + ')'
# if len(lcontact) > 1:
# for c in lcontact:
# if c == contact:
# continue
# info += '\n<span weight="bold">' + ' ' * len(_('Resource: ')) + \
# '</span>' + c.resource + ' (' + str(c.priority) + ')'
if contact.show: if contact.show:
info += '\n<span weight="bold">' + _('Status: ') + '</span>' + \ if status_str != '':
helpers.get_uf_show(contact.show) multiple_status = True
status_str += '\n\t' + helpers.get_uf_show(contact.show)
if contact.status: if contact.status:
info += ' - ' + contact.status status_str += ' - ' + contact.status
if resource_str != '':
info += '\n<span weight="bold">' + _('Resource: ') + '</span>'
if multiple_resource:
info += resource_str
else:
# show the status on the same line
info += resource_str[2:]
if status_str != '':
info += '\n<span weight="bold">' + _('Status: ') + '</span>'
if not multiple_status:
# show the resource on the same line
info += status_str[2:]
else:
info += status_str
self.account.set_markup(info) self.account.set_markup(info)
class InputDialog: class InputDialog:

View File

@ -565,15 +565,11 @@ class RosterWindow:
if model.get_value(iter, 2) == 'contact': if model.get_value(iter, 2) == 'contact':
account = model.get_value(iter, 4) account = model.get_value(iter, 4)
jid = model.get_value(iter, 3) jid = model.get_value(iter, 3)
contact = None
for resource in self.contacts[account][jid]:
if contact == None or resource.priority > contact.priority:
contact = resource
img = model.get_value(iter, 0) img = model.get_value(iter, 0)
if self.tooltip.timeout == 0 or self.tooltip.path != props[0]: if self.tooltip.timeout == 0 or self.tooltip.path != props[0]:
self.tooltip.path = row self.tooltip.path = row
self.tooltip.timeout = gobject.timeout_add(500, self.tooltip.timeout = gobject.timeout_add(500,
self.show_tooltip, contact, img) self.show_tooltip, self.contacts[account][jid], img)
def on_agent_logging(self, widget, jid, state, account): def on_agent_logging(self, widget, jid, state, account):
'''When an agent is requested to log in or off''' '''When an agent is requested to log in or off'''