load disco items slowly to now freeze with long list.
This commit is contained in:
parent
1b803b7780
commit
adb1039993
17
src/disco.py
17
src/disco.py
|
@ -1106,16 +1106,29 @@ class AgentBrowser:
|
|||
_('This service does not contain any items to browse.'))
|
||||
return
|
||||
# We got a list of items
|
||||
self.window.services_treeview.set_model(None)
|
||||
def fill_partial_rows(items):
|
||||
'''Generator to fill the listmodel of a treeview progressively.'''
|
||||
self.window.services_treeview.freeze_child_notify()
|
||||
for item in items:
|
||||
if self.window.dying:
|
||||
yield False
|
||||
jid_ = item['jid']
|
||||
node_ = item.get('node', '')
|
||||
# If such an item is already here: don't add it
|
||||
if self._find_item(jid_, node_):
|
||||
continue
|
||||
self._total_items += 1
|
||||
print 'adding item #', self._total_items
|
||||
self._add_item(jid_, node_, node, item, force)
|
||||
self.window.services_treeview.set_model(self.model)
|
||||
if (self._total_items % 10) == 0:
|
||||
self.window.services_treeview.thaw_child_notify()
|
||||
yield True
|
||||
self.window.services_treeview.freeze_child_notify()
|
||||
self.window.services_treeview.thaw_child_notify()
|
||||
#stop idle_add()
|
||||
yield False
|
||||
loader = fill_partial_rows(items)
|
||||
gobject.idle_add(loader.next)
|
||||
|
||||
def _agent_info(self, jid, node, identities, features, data):
|
||||
"""
|
||||
|
|
Loading…
Reference in New Issue