show correct image icon for multiple resources

This commit is contained in:
Dimitur Kirov 2006-02-28 16:12:59 +00:00
parent 182490359c
commit 981cb163f2
1 changed files with 15 additions and 2 deletions

View File

@ -84,6 +84,18 @@ class BaseTooltip:
self.win.connect('motion-notify-event', self.motion_notify_event) self.win.connect('motion-notify-event', self.motion_notify_event)
self.screen = self.win.get_screen() self.screen = self.win.get_screen()
def _get_icon_name_for_tooltip(self, contact):
''' helper function used for tooltip contacts/acounts
Tooltip on account has fake contact with sub == '', in this case we show
real status of the account
'''
if contact.ask == 'subscribe':
return 'requested'
elif contact.sub in ('both', 'to', ''):
return contact.show
return 'not in roster'
def motion_notify_event(self, widget, event): def motion_notify_event(self, widget, event):
self.hide_tooltip() self.hide_tooltip()
@ -421,7 +433,7 @@ class RosterTooltip(NotificationAreaTooltip):
prim_contact = gajim.contacts.get_highest_prio_contact_from_contacts( prim_contact = gajim.contacts.get_highest_prio_contact_from_contacts(
contacts) contacts)
# try to find the image for the contact status # try to find the image for the contact status
icon_name = prim_contact.show icon_name = self._get_icon_name_for_tooltip(prim_contact)
state_file = icon_name.replace(' ', '_') state_file = icon_name.replace(' ', '_')
transport = gajim.get_transport_name_from_jid(prim_contact.jid) transport = gajim.get_transport_name_from_jid(prim_contact.jid)
if transport: if transport:
@ -472,7 +484,8 @@ class RosterTooltip(NotificationAreaTooltip):
if contact.resource: if contact.resource:
status_line = self.get_status_info(contact.resource, status_line = self.get_status_info(contact.resource,
contact.priority, contact.show, contact.status) contact.priority, contact.show, contact.status)
icon_name = helpers.get_icon_name_to_show(contact)
icon_name = self._get_icon_name_for_tooltip(contact)
self.add_status_row(file_path, icon_name, status_line, self.add_status_row(file_path, icon_name, status_line,
contact.last_status_time) contact.last_status_time)