improve tooltip code a little bit
This commit is contained in:
		
							parent
							
								
									e9f050d787
								
							
						
					
					
						commit
						5b48225d0c
					
				
					 1 changed files with 60 additions and 57 deletions
				
			
		|  | @ -2768,9 +2768,9 @@ class RosterWindow: | ||||||
|                 return |                 return | ||||||
|             if model[titer][C_TYPE] in ('contact', 'self_contact'): |             if model[titer][C_TYPE] in ('contact', 'self_contact'): | ||||||
|                 # we're on a contact entry in the roster |                 # we're on a contact entry in the roster | ||||||
|                 account = model[titer][C_ACCOUNT].decode('utf-8') |  | ||||||
|                 jid = model[titer][C_JID].decode('utf-8') |  | ||||||
|                 if self.tooltip.timeout == 0 or self.tooltip.id != props[0]: |                 if self.tooltip.timeout == 0 or self.tooltip.id != props[0]: | ||||||
|  |                     account = model[titer][C_ACCOUNT].decode('utf-8') | ||||||
|  |                     jid = model[titer][C_JID].decode('utf-8') | ||||||
|                     self.tooltip.id = row |                     self.tooltip.id = row | ||||||
|                     contacts = gajim.contacts.get_contacts(account, jid) |                     contacts = gajim.contacts.get_contacts(account, jid) | ||||||
|                     connected_contacts = [] |                     connected_contacts = [] | ||||||
|  | @ -2782,76 +2782,79 @@ class RosterWindow: | ||||||
|                         connected_contacts = contacts |                         connected_contacts = contacts | ||||||
|                     self.tooltip.account = account |                     self.tooltip.account = account | ||||||
|                     self.tooltip.timeout = gobject.timeout_add(500, |                     self.tooltip.timeout = gobject.timeout_add(500, | ||||||
|                             self.show_tooltip, connected_contacts) |                         self.show_tooltip, connected_contacts) | ||||||
|             elif model[titer][C_TYPE] == 'groupchat': |             elif model[titer][C_TYPE] == 'groupchat': | ||||||
|                 account = model[titer][C_ACCOUNT].decode('utf-8') |  | ||||||
|                 jid = model[titer][C_JID].decode('utf-8') |  | ||||||
|                 if self.tooltip.timeout == 0 or self.tooltip.id != props[0]: |                 if self.tooltip.timeout == 0 or self.tooltip.id != props[0]: | ||||||
|  |                     account = model[titer][C_ACCOUNT].decode('utf-8') | ||||||
|  |                     jid = model[titer][C_JID].decode('utf-8') | ||||||
|                     self.tooltip.id = row |                     self.tooltip.id = row | ||||||
|                     contact = gajim.contacts.get_contacts(account, jid) |                     contact = gajim.contacts.get_contacts(account, jid) | ||||||
|                     self.tooltip.account = account |                     self.tooltip.account = account | ||||||
|                     self.tooltip.timeout = gobject.timeout_add(500, |                     self.tooltip.timeout = gobject.timeout_add(500, | ||||||
|                             self.show_tooltip, contact) |                         self.show_tooltip, contact) | ||||||
|             elif model[titer][C_TYPE] == 'account': |             elif model[titer][C_TYPE] == 'account': | ||||||
|                 # we're on an account entry in the roster |                 # we're on an account entry in the roster | ||||||
|                 account = model[titer][C_ACCOUNT].decode('utf-8') |                 if self.tooltip.timeout == 0 or self.tooltip.id != props[0]: | ||||||
|                 if account == 'all': |                     account = model[titer][C_ACCOUNT].decode('utf-8') | ||||||
|                     if self.tooltip.timeout == 0 or self.tooltip.id != props[0]: |                     if account == 'all': | ||||||
|                         self.tooltip.id = row |                         self.tooltip.id = row | ||||||
|                         self.tooltip.account = None |                         self.tooltip.account = None | ||||||
|                         self.tooltip.timeout = gobject.timeout_add(500, |                         self.tooltip.timeout = gobject.timeout_add(500, | ||||||
|                                 self.show_tooltip, []) |                             self.show_tooltip, []) | ||||||
|                     return |                         return | ||||||
|                 jid = gajim.get_jid_from_account(account) |                     jid = gajim.get_jid_from_account(account) | ||||||
|                 contacts = [] |                     contacts = [] | ||||||
|                 connection = gajim.connections[account] |                     connection = gajim.connections[account] | ||||||
|                 # get our current contact info |                     # get our current contact info | ||||||
| 
 | 
 | ||||||
|                 nbr_on, nbr_total = gajim.contacts.get_nb_online_total_contacts( |                     nbr_on, nbr_total = gajim.\ | ||||||
|                         accounts = [account]) |                         contacts.get_nb_online_total_contacts( | ||||||
|                 account_name = account |                         accounts=[account]) | ||||||
|                 if gajim.account_is_connected(account): |                     account_name = account | ||||||
|                     account_name += ' (%s/%s)' % (repr(nbr_on), repr(nbr_total)) |                     if gajim.account_is_connected(account): | ||||||
|                 contact = gajim.contacts.create_self_contact(jid=jid, |                         account_name += ' (%s/%s)' % (repr(nbr_on), | ||||||
|                     account=account, name=account_name, |                             repr(nbr_total)) | ||||||
|                     show=connection.get_status(), status=connection.status, |                     contact = gajim.contacts.create_self_contact(jid=jid, | ||||||
|                     resource=connection.server_resource, |                         account=account, name=account_name, | ||||||
|                     priority=connection.priority) |                         show=connection.get_status(), status=connection.status, | ||||||
|                 if gajim.connections[account].gpg: |                         resource=connection.server_resource, | ||||||
|                     contact.keyID = gajim.config.get_per('accounts', |                         priority=connection.priority) | ||||||
|                         connection.name, 'keyid') |                     if gajim.connections[account].gpg: | ||||||
|                 contacts.append(contact) |                         contact.keyID = gajim.config.get_per('accounts', | ||||||
|                 # if we're online ... |                             connection.name, 'keyid') | ||||||
|                 if connection.connection: |                     contacts.append(contact) | ||||||
|                     roster = connection.connection.getRoster() |                     # if we're online ... | ||||||
|                     # in threadless connection when no roster stanza is sent, |                     if connection.connection: | ||||||
|                     # 'roster' is None |                         roster = connection.connection.getRoster() | ||||||
|                     if roster and roster.getItem(jid): |                         # in threadless connection when no roster stanza is sent | ||||||
|                         resources = roster.getResources(jid) |                         # 'roster' is None | ||||||
|                         # ...get the contact info for our other online resources |                         if roster and roster.getItem(jid): | ||||||
|                         for resource in resources: |                             resources = roster.getResources(jid) | ||||||
|                             # Check if we already have this resource |                             # ...get the contact info for our other online | ||||||
|                             found = False |                             # resources | ||||||
|                             for contact_ in contacts: |                             for resource in resources: | ||||||
|                                 if contact_.resource == resource: |                                 # Check if we already have this resource | ||||||
|                                     found = True |                                 found = False | ||||||
|                                     break |                                 for contact_ in contacts: | ||||||
|                             if found: |                                     if contact_.resource == resource: | ||||||
|                                 continue |                                         found = True | ||||||
|                             show = roster.getShow(jid+'/'+resource) |                                         break | ||||||
|                             if not show: |                                 if found: | ||||||
|                                 show = 'online' |                                     continue | ||||||
|                             contact = gajim.contacts.create_self_contact( |                                 show = roster.getShow(jid+'/'+resource) | ||||||
|                                 jid=jid, account=account, show=show, |                                 if not show: | ||||||
|                                 status=roster.getStatus(jid + '/' + resource), |                                     show = 'online' | ||||||
|                                 priority=roster.getPriority( |                                 contact = gajim.contacts.create_self_contact( | ||||||
|                                 jid + '/' + resource), resource=resource) |                                     jid=jid, account=account, show=show, | ||||||
|                             contacts.append(contact) |                                     status=roster.getStatus( | ||||||
|                 if self.tooltip.timeout == 0 or self.tooltip.id != props[0]: |                                     jid + '/' + resource), | ||||||
|  |                                     priority=roster.getPriority( | ||||||
|  |                                     jid + '/' + resource), resource=resource) | ||||||
|  |                                 contacts.append(contact) | ||||||
|                     self.tooltip.id = row |                     self.tooltip.id = row | ||||||
|                     self.tooltip.account = None |                     self.tooltip.account = None | ||||||
|                     self.tooltip.timeout = gobject.timeout_add(500, |                     self.tooltip.timeout = gobject.timeout_add(500, | ||||||
|                             self.show_tooltip, contacts) |                         self.show_tooltip, contacts) | ||||||
| 
 | 
 | ||||||
|     def on_agent_logging(self, widget, jid, state, account): |     def on_agent_logging(self, widget, jid, state, account): | ||||||
|         """ |         """ | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		
		Reference in a new issue