load disco items slowly to now freeze with long list.

This commit is contained in:
Yann Leboulanger 2013-07-08 14:51:50 +02:00
parent 9cbf796ae1
commit d360d67f9a
1 changed files with 23 additions and 10 deletions

View File

@ -1109,16 +1109,29 @@ class AgentBrowser:
_('This service does not contain any items to browse.')) _('This service does not contain any items to browse.'))
return return
# We got a list of items # We got a list of items
self.window.services_treeview.set_model(None) def fill_partial_rows(items):
for item in items: '''Generator to fill the listmodel of a treeview progressively.'''
jid_ = item['jid'] self.window.services_treeview.freeze_child_notify()
node_ = item.get('node', '') for item in items:
# If such an item is already here: don't add it if self.window.dying:
if self._find_item(jid_, node_): yield False
continue jid_ = item['jid']
self._total_items += 1 node_ = item.get('node', '')
self._add_item(jid_, node_, node, item, force) # If such an item is already here: don't add it
self.window.services_treeview.set_model(self.model) 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)
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): def _agent_info(self, jid, node, identities, features, data):
""" """