add twiter icon to disco, better irc detection, use address when identidy doesn't help enough. Fixes #7396
This commit is contained in:
parent
6a9ea72f9d
commit
d23da77a42
32
src/disco.py
32
src/disco.py
|
@ -94,6 +94,7 @@ def _gen_agent_type_info():
|
||||||
# Transports
|
# Transports
|
||||||
('conference', 'irc'): (ToplevelAgentBrowser, 'irc'),
|
('conference', 'irc'): (ToplevelAgentBrowser, 'irc'),
|
||||||
('_jid', 'irc'): (False, 'irc'),
|
('_jid', 'irc'): (False, 'irc'),
|
||||||
|
('gateway', 'irc'): (False, 'irc'),
|
||||||
('gateway', 'aim'): (False, 'aim'),
|
('gateway', 'aim'): (False, 'aim'),
|
||||||
('_jid', 'aim'): (False, 'aim'),
|
('_jid', 'aim'): (False, 'aim'),
|
||||||
('gateway', 'gadu-gadu'): (False, 'gadu-gadu'),
|
('gateway', 'gadu-gadu'): (False, 'gadu-gadu'),
|
||||||
|
@ -113,6 +114,7 @@ def _gen_agent_type_info():
|
||||||
('gateway', 'facebook'): (False, 'facebook'),
|
('gateway', 'facebook'): (False, 'facebook'),
|
||||||
('_jid', 'facebook'): (False, 'facebook'),
|
('_jid', 'facebook'): (False, 'facebook'),
|
||||||
('gateway', 'tv'): (False, 'tv'),
|
('gateway', 'tv'): (False, 'tv'),
|
||||||
|
('gateway', 'twitter'): (False, 'twitter'),
|
||||||
}
|
}
|
||||||
|
|
||||||
# Category type to "human-readable" description string, and sort priority
|
# Category type to "human-readable" description string, and sort priority
|
||||||
|
@ -292,11 +294,12 @@ class ServicesCache:
|
||||||
if not self._cbs[cbkey]:
|
if not self._cbs[cbkey]:
|
||||||
del self._cbs[cbkey]
|
del self._cbs[cbkey]
|
||||||
|
|
||||||
def get_icon(self, identities = []):
|
def get_icon(self, identities = [], addr=''):
|
||||||
"""
|
"""
|
||||||
Return the icon for an agent
|
Return the icon for an agent
|
||||||
"""
|
"""
|
||||||
# Grab the first identity with an icon
|
# Grab the first identity with an icon
|
||||||
|
quiet = False
|
||||||
for identity in identities:
|
for identity in identities:
|
||||||
try:
|
try:
|
||||||
cat, type_ = identity['category'], identity['type']
|
cat, type_ = identity['category'], identity['type']
|
||||||
|
@ -308,17 +311,22 @@ class ServicesCache:
|
||||||
break
|
break
|
||||||
else:
|
else:
|
||||||
# Loop fell through, default to unknown
|
# Loop fell through, default to unknown
|
||||||
info = _agent_type_info[(0, 0)]
|
filename = addr.split('.')[0]
|
||||||
filename = info[1]
|
quiet = True
|
||||||
if not filename: # we don't have an image to show for this type
|
|
||||||
filename = 'jabber'
|
|
||||||
# Use the cache if possible
|
# Use the cache if possible
|
||||||
if filename in _icon_cache:
|
if filename in _icon_cache:
|
||||||
return _icon_cache[filename]
|
return _icon_cache[filename]
|
||||||
# Or load it
|
# Or load it
|
||||||
pix = gtkgui_helpers.get_icon_pixmap('gajim-agent-' + filename, size=32)
|
pix = gtkgui_helpers.get_icon_pixmap('gajim-agent-' + filename, size=32,
|
||||||
# Store in cache
|
quiet=quiet)
|
||||||
_icon_cache[filename] = pix
|
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
|
return pix
|
||||||
|
|
||||||
def get_browser(self, identities=[], features=[]):
|
def get_browser(self, identities=[], features=[]):
|
||||||
|
@ -942,7 +950,7 @@ class AgentBrowser:
|
||||||
self.window._set_window_banner_text(self._get_agent_address(), name)
|
self.window._set_window_banner_text(self._get_agent_address(), name)
|
||||||
|
|
||||||
# Add an icon to the banner.
|
# 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.set_from_pixbuf(pix)
|
||||||
self.window.banner_icon.show()
|
self.window.banner_icon.show()
|
||||||
|
|
||||||
|
@ -1211,7 +1219,7 @@ class ToplevelAgentBrowser(AgentBrowser):
|
||||||
identity = {'category': '_jid', 'type': type_}
|
identity = {'category': '_jid', 'type': type_}
|
||||||
identities.append(identity)
|
identities.append(identity)
|
||||||
# Set the pixmap for the row
|
# 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))
|
self.model.append(None, (self.jid, self.node, pix, descr, 1))
|
||||||
# Grab info on the service
|
# Grab info on the service
|
||||||
self.cache.get_info(self.jid, self.node, self._agent_info, force=False)
|
self.cache.get_info(self.jid, self.node, self._agent_info, force=False)
|
||||||
|
@ -1699,7 +1707,7 @@ class ToplevelAgentBrowser(AgentBrowser):
|
||||||
# Put it in the 'other' category for now
|
# Put it in the 'other' category for now
|
||||||
cat_args = ('other',)
|
cat_args = ('other',)
|
||||||
# Set the pixmap for the row
|
# 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
|
# Put it in the right category
|
||||||
cat = self._find_category(*cat_args)
|
cat = self._find_category(*cat_args)
|
||||||
if not cat:
|
if not cat:
|
||||||
|
@ -1731,7 +1739,7 @@ class ToplevelAgentBrowser(AgentBrowser):
|
||||||
self._update_progressbar()
|
self._update_progressbar()
|
||||||
|
|
||||||
# Search for an icon and category we can display
|
# 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
|
cat, type_ = None, None
|
||||||
for identity in identities:
|
for identity in identities:
|
||||||
try:
|
try:
|
||||||
|
|
Loading…
Reference in New Issue