don't redraw several time the contacts when redrawing the full roster. See #7125

This commit is contained in:
Yann Leboulanger 2013-07-25 08:54:35 +02:00
parent 5b1a1927e4
commit c3f784ce59
1 changed files with 19 additions and 12 deletions

View File

@ -261,17 +261,20 @@ class RosterWindow:
self.draw_account(account) self.draw_account(account)
def add_account_contacts(self, account): def add_account_contacts(self, account, improve_speed=True,
draw_contacts=True):
""" """
Add all contacts and groups of the given account to roster, draw them Add all contacts and groups of the given account to roster, draw them
and account and account
""" """
if improve_speed:
self._before_fill() self._before_fill()
jids = gajim.contacts.get_jid_list(account) jids = gajim.contacts.get_jid_list(account)
for jid in jids: for jid in jids:
self.add_contact(jid, account) self.add_contact(jid, account)
if draw_contacts:
# Do not freeze the GUI when drawing the contacts # Do not freeze the GUI when drawing the contacts
if jids: if jids:
# Overhead is big, only invoke when needed # Overhead is big, only invoke when needed
@ -282,6 +285,7 @@ class RosterWindow:
self.draw_group(group, account) self.draw_group(group, account)
self.draw_account(account) self.draw_account(account)
if improve_speed:
self._after_fill() self._after_fill()
def _add_group_iter(self, account, group): def _add_group_iter(self, account, group):
@ -1451,9 +1455,12 @@ class RosterWindow:
for acct in gajim.contacts.get_accounts(): for acct in gajim.contacts.get_accounts():
self._iters[acct] = {'account': None, 'groups': {}, 'contacts': {}} self._iters[acct] = {'account': None, 'groups': {}, 'contacts': {}}
self._before_fill()
for acct in gajim.contacts.get_accounts(): for acct in gajim.contacts.get_accounts():
self.add_account(acct) self.add_account(acct)
self.add_account_contacts(acct) self.add_account_contacts(acct, improve_speed=False,
draw_contacts=False)
self._after_fill()
# Recalculate column width for ellipsizing # Recalculate column width for ellipsizing
self.tree.columns_autosize() self.tree.columns_autosize()