Small cleanups to roster and modelfilter.

* rename draw_roster to better express its functionality
 * remove unnecessary call of refilter()
 * directly remove groups when there is only one child left and we want to remove it

Note: in gtkTreeStore iters persist as long as the row isn't removed. Iters in Modelfilter persist as long as the model is unchanged.
This commit is contained in:
Stephan Erb 2008-06-01 22:46:41 +00:00
parent c6aa116db8
commit 82edfdf42e
2 changed files with 17 additions and 22 deletions

View File

@ -515,11 +515,11 @@ class PreferencesWindow:
def on_sort_by_show_checkbutton_toggled(self, widget):
self.on_checkbutton_toggled(widget, 'sort_by_show')
gajim.interface.roster.draw_roster()
gajim.interface.roster.setup_and_draw_roster()
def on_show_avatars_in_roster_checkbutton_toggled(self, widget):
self.on_checkbutton_toggled(widget, 'show_avatars_in_roster')
gajim.interface.roster.draw_roster()
gajim.interface.roster.setup_and_draw_roster()
# Redraw connected groupchats (in an ugly way)
for account in gajim.connections:
if gajim.connections[account].connected:
@ -530,14 +530,14 @@ class PreferencesWindow:
def on_show_status_msgs_in_roster_checkbutton_toggled(self, widget):
self.on_checkbutton_toggled(widget, 'show_status_msgs_in_roster')
gajim.interface.roster.draw_roster()
gajim.interface.roster.setup_and_draw_roster()
for ctl in gajim.interface.msg_win_mgr.controls():
if ctl.type_id == message_control.TYPE_GC:
ctl.update_ui()
def on_sort_by_show_checkbutton_toggled(self, widget):
self.on_checkbutton_toggled(widget, 'sort_by_show')
gajim.interface.roster.draw_roster()
gajim.interface.roster.setup_and_draw_roster()
def on_emoticons_combobox_changed(self, widget):
active = widget.get_active()
@ -570,7 +570,7 @@ class PreferencesWindow:
ctl.chat_buttons_set_visible(active)
gajim.config.set('compact_view', active)
gajim.interface.save_config()
gajim.interface.roster.draw_roster()
gajim.interface.roster.setup_and_draw_roster()
def on_xhtml_checkbutton_toggled(self, widget):
self.on_checkbutton_toggled(widget, 'ignore_incoming_xhtml')
@ -1753,7 +1753,7 @@ class AccountsWindow:
if self.current_account == old_name:
self.current_account = new_name
# refresh roster
gajim.interface.roster.draw_roster()
gajim.interface.roster.setup_and_draw_roster()
self.init_accounts()
self.select_account(new_name)
@ -2077,7 +2077,7 @@ class AccountsWindow:
gajim.interface.roster.regroup = gajim.config.get('mergeaccounts')
else:
gajim.interface.roster.regroup = False
gajim.interface.roster.draw_roster()
gajim.interface.roster.setup_and_draw_roster()
def on_enable_zeroconf_checkbutton2_toggled(self, widget):
# don't do anything if there is an account with the local name but is a
@ -2119,7 +2119,7 @@ class AccountsWindow:
gajim.interface.roster.regroup = gajim.config.get('mergeaccounts')
else:
gajim.interface.roster.regroup = False
gajim.interface.roster.draw_roster()
gajim.interface.roster.setup_and_draw_roster()
gajim.interface.roster.set_actions_menu_needs_rebuild()
elif not gajim.config.get('enable_zeroconf') and widget.get_active():
@ -2156,7 +2156,7 @@ class AccountsWindow:
gajim.interface.roster.regroup = gajim.config.get('mergeaccounts')
else:
gajim.interface.roster.regroup = False
gajim.interface.roster.draw_roster()
gajim.interface.roster.setup_and_draw_roster()
gajim.interface.roster.set_actions_menu_needs_rebuild()
gajim.interface.save_config()
@ -2587,7 +2587,7 @@ class RemoveAccountWindow:
gajim.interface.roster.regroup = gajim.config.get('mergeaccounts')
else:
gajim.interface.roster.regroup = False
gajim.interface.roster.draw_roster()
gajim.interface.roster.setup_and_draw_roster()
gajim.interface.roster.set_actions_menu_needs_rebuild()
if gajim.interface.instances.has_key('accounts'):
gajim.interface.instances['accounts'].init_accounts()
@ -3421,7 +3421,7 @@ class AccountCreationWizardWindow:
gajim.interface.roster.regroup = gajim.config.get('mergeaccounts')
else:
gajim.interface.roster.regroup = False
gajim.interface.roster.draw_roster()
gajim.interface.roster.setup_and_draw_roster()
gajim.interface.roster.set_actions_menu_needs_rebuild()
gajim.interface.save_config()

View File

@ -382,7 +382,6 @@ class RosterWindow:
added_iters.append(i_)
# Restore the group expand state
# FIXME path may be invalid at this point!
path = self.model.get_path(child_iterG)
if account + group in self.collapsed_rows:
is_expanded = False
@ -432,14 +431,14 @@ class RosterWindow:
# Remove us and empty groups from the model
for i in iters:
parent_i = self.model.iter_parent(i)
self.model.remove(i)
if parent_type == 'group' and \
self.model.iter_n_children(parent_i) == 0:
self.model.iter_n_children(parent_i) == 1:
group = self.model[parent_i][C_JID].decode('utf-8')
if gajim.groups[account].has_key(group):
del gajim.groups[account][group]
self.model.remove(parent_i)
else:
self.model.remove(i)
return True
@ -552,10 +551,6 @@ class RosterWindow:
assert not self.model.iter_children(iters[0]),\
"Old Big Brother %s still has children" % old_big_jid
# This one is strange but necessary:
# Refilter filtered model to not crash hard. It thinks it still has children.
self.refilter_shown_roster_items()
ok = self._remove_entity(old_big_contact, old_big_account)
assert ok, "Old Big Brother %s not removed" % old_big_jid
assert len(self._get_contact_iter(old_big_jid, old_big_account, old_big_contact,
@ -1237,7 +1232,7 @@ class RosterWindow:
task = _draw_all_contacts(jids, account, t)
gobject.idle_add(task.next)
def draw_roster(self):
def setup_and_draw_roster(self):
'''create new empty model and draw roster'''
#(icon, name, type, jid, account, editable, avatar_pixbuf, padlock_pixbuf)
self.model = gtk.TreeStore(gtk.Image, str, str, str, str, gtk.gdk.Pixbuf,
@ -3938,7 +3933,7 @@ class RosterWindow:
def update_jabber_state_images(self):
# Update the roster
self.draw_roster()
self.setup_and_draw_roster()
# Update the status combobox
model = self.status_combobox.get_model()
titer = model.get_iter_root()
@ -5942,7 +5937,7 @@ class RosterWindow:
self.tooltip = tooltips.RosterTooltip()
# Workaroung: For strange reasons signal is behaving like row-changed
self._toggeling_row = False
self.draw_roster()
self.setup_and_draw_roster()
for account in gajim.connections:
if gajim.config.get_per('accounts', account, 'publish_tune'):