add twiter icon to disco, better irc detection, use address when identidy doesn't help enough. Fixes #7396

This commit is contained in:
Yann Leboulanger 2013-09-08 18:11:53 +02:00
parent 7745ea8f95
commit 75472935cd
1 changed files with 20 additions and 12 deletions

View File

@ -96,6 +96,7 @@ def _gen_agent_type_info():
# Transports
('conference', 'irc'): (ToplevelAgentBrowser, 'irc'),
('_jid', 'irc'): (False, 'irc'),
('gateway', 'irc'): (False, 'irc'),
('gateway', 'aim'): (False, 'aim'),
('_jid', 'aim'): (False, 'aim'),
('gateway', 'gadu-gadu'): (False, 'gadu-gadu'),
@ -115,6 +116,7 @@ def _gen_agent_type_info():
('gateway', 'facebook'): (False, 'facebook'),
('_jid', 'facebook'): (False, 'facebook'),
('gateway', 'tv'): (False, 'tv'),
('gateway', 'twitter'): (False, 'twitter'),
}
# Category type to "human-readable" description string, and sort priority
@ -293,11 +295,12 @@ class ServicesCache:
if not self._cbs[cbkey]:
del self._cbs[cbkey]
def get_icon(self, identities = []):
def get_icon(self, identities = [], addr=''):
"""
Return the icon for an agent
"""
# Grab the first identity with an icon
quiet = False
for identity in identities:
try:
cat, type_ = identity['category'], identity['type']
@ -309,17 +312,22 @@ class ServicesCache:
break
else:
# Loop fell through, default to unknown
info = _agent_type_info[(0, 0)]
filename = info[1]
if not filename: # we don't have an image to show for this type
filename = 'jabber'
filename = addr.split('.')[0]
quiet = True
# Use the cache if possible
if filename in _icon_cache:
return _icon_cache[filename]
# Or load it
pix = gtkgui_helpers.get_icon_pixmap('gajim-agent-' + filename, size=32)
# Store in cache
_icon_cache[filename] = pix
pix = gtkgui_helpers.get_icon_pixmap('gajim-agent-' + filename, size=32,
quiet=quiet)
if pix:
# Store in cache
_icon_cache[filename] = pix
return pix
if 'jabber' in _icon_cache:
return _icon_cache['jabber']
pix = gtkgui_helpers.get_icon_pixmap('gajim-agent-jabber', size=32)
_icon_cache['jabber'] = pix
return pix
def get_browser(self, identities=[], features=[]):
@ -948,7 +956,7 @@ class AgentBrowser:
self.window._set_window_banner_text(self._get_agent_address(), name)
# Add an icon to the banner.
pix = self.cache.get_icon(identities)
pix = self.cache.get_icon(identities, addr=self._get_agent_address())
self.window.banner_icon.set_from_pixbuf(pix)
self.window.banner_icon.show()
@ -1217,7 +1225,7 @@ class ToplevelAgentBrowser(AgentBrowser):
identity = {'category': '_jid', 'type': type_}
identities.append(identity)
# Set the pixmap for the row
pix = self.cache.get_icon(identities)
pix = self.cache.get_icon(identities, addr=addr)
self.model.append(None, (self.jid, self.node, pix, descr, 1))
# Grab info on the service
self.cache.get_info(self.jid, self.node, self._agent_info, force=False)
@ -1709,7 +1717,7 @@ class ToplevelAgentBrowser(AgentBrowser):
# Put it in the 'other' category for now
cat_args = ('other',)
# Set the pixmap for the row
pix = self.cache.get_icon(identities)
pix = self.cache.get_icon(identities, addr=addr)
# Put it in the right category
cat = self._find_category(*cat_args)
if not cat:
@ -1741,7 +1749,7 @@ class ToplevelAgentBrowser(AgentBrowser):
self._update_progressbar()
# Search for an icon and category we can display
pix = self.cache.get_icon(identities)
pix = self.cache.get_icon(identities, addr=addr)
cat, type_ = None, None
for identity in identities:
try: