From 33c2c02cde435e0bbf7699d5ace7b66bb4c4d233 Mon Sep 17 00:00:00 2001 From: Yann Leboulanger <asterix@lagaule.org> Date: Sat, 19 Mar 2005 11:32:29 +0000 Subject: [PATCH] remove empty groups from roster.groups dict --- plugins/gtkgui/dialogs.py | 9 ++++----- plugins/gtkgui/roster_window.py | 9 +++++++++ 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/plugins/gtkgui/dialogs.py b/plugins/gtkgui/dialogs.py index da3ecd530a..36dbe40f7f 100644 --- a/plugins/gtkgui/dialogs.py +++ b/plugins/gtkgui/dialogs.py @@ -227,12 +227,12 @@ class Edit_groups_dialog: def run(self): self.dialog.run() self.dialog.destroy() - #TODO: send to the core + #TODO: do not send if unnecesary + self.plugin.send('UPDUSER', self.account, (self.user.jid, \ + self.user.name, self.user.groups)) def update_user(self): - luser = self.plugin.roster.contacts[self.account][self.user.jid] - for u in luser: - self.plugin.roster.remove_user(u, self.account) + self.plugin.roster.remove_user(self.user, self.account) self.plugin.roster.add_user_to_roster(self.user.jid, self.account) def on_add_button_clicked(self, widget): @@ -255,7 +255,6 @@ class Edit_groups_dialog: if model[path][1] and len(self.user.groups) == 1: # we try to remove # the latest group Error_dialog(_('There must be at least one group for each contact')) - #TODO: re-set the checkbutton return model[path][1] = not model[path][1] if model[path][1]: diff --git a/plugins/gtkgui/roster_window.py b/plugins/gtkgui/roster_window.py index af8988df06..54a59a39fe 100644 --- a/plugins/gtkgui/roster_window.py +++ b/plugins/gtkgui/roster_window.py @@ -163,9 +163,18 @@ class roster_window: model = self.tree.get_model() for i in self.get_user_iter(user.jid, account): parent_i = model.iter_parent(i) + group = model.get_value(parent_i, 3) model.remove(i) if model.iter_n_children(parent_i) == 0: model.remove(parent_i) + # We need to check all contacts, even offline contacts + group_empty = True + for jid in self.contacts[account]: + if group in self.contacts[account][jid][0].groups: + group_empty = False + break + if group_empty: + del self.groups[account][group] def redraw_jid(self, jid, account): """draw the correct pixbuf and name""" -- GitLab