ability to reload service discovery window by pressing ctrl + R. Fixes #5882

This commit is contained in:
Yann Leboulanger 2010-09-08 14:05:21 +02:00
parent 402881aac2
commit 2a941132b1
1 changed files with 30 additions and 12 deletions

View File

@ -360,7 +360,7 @@ class ServicesCache:
"""
addr = get_agent_address(jid, node)
# Check the cache
if addr in self._info:
if addr in self._info and not force:
args = self._info[addr] + args
cb(jid, node, *args)
return
@ -384,7 +384,7 @@ class ServicesCache:
"""
addr = get_agent_address(jid, node)
# Check the cache
if addr in self._items:
if addr in self._items and not force:
args = (self._items[addr],) + args
cb(jid, node, *args)
return
@ -505,6 +505,7 @@ class ServiceDiscoveryWindow(object):
self.children = []
self.dying = False
self.node = None
self.reloading = False
# Check connection
if gajim.connections[account].connected < 2:
@ -564,6 +565,12 @@ _('Without a connection, you can not browse available services'))
address_table.set_no_show_all(True)
address_table.hide()
accel_group = gtk.AccelGroup()
keyval, mod = gtk.accelerator_parse('<Control>r')
accel_group.connect_group(keyval, mod, gtk.ACCEL_VISIBLE,
self.accel_group_func)
self.window.add_accel_group(accel_group)
self._initial_state()
self.xml.connect_signals(self)
self.travel(jid, node)
@ -580,6 +587,10 @@ _('Without a connection, you can not browse available services'))
if self.browser:
self.browser.account = value
def accel_group_func(self, accel_group, acceleratable, keyval, modifier):
if (modifier & gtk.gdk.CONTROL_MASK) and (keyval == gtk.keysyms.r):
self.reload()
def _initial_state(self):
"""
Set some initial state on the window. Separated in a method because it's
@ -709,6 +720,12 @@ _('Without a connection, you can not browse available services'))
else:
self.cache.cleanup()
def reload(self):
if not self.jid:
return
self.reloading = True
self.travel(self.jid, self.node)
def travel(self, jid, node):
"""
Travel to an agent within the current services window
@ -726,7 +743,7 @@ _('Without a connection, you can not browse available services'))
# We need to store these, self.browser is not always available.
self.jid = jid
self.node = node
self.cache.get_info(jid, node, self._travel)
self.cache.get_info(jid, node, self._travel, force=self.reloading)
def _travel(self, jid, node, identities, features, data):
"""
@ -750,7 +767,8 @@ _('This type of service does not contain any items to browse.'))
klass = AgentBrowser
self.browser = klass(self.account, jid, node)
self.browser.prepare_window(self)
self.browser.browse()
self.browser.browse(force=self.reloading)
self.reloading = False
def open(self, jid, node):
"""