remove empty groups from roster.groups dict

This commit is contained in:
Yann Leboulanger 2005-03-19 11:32:29 +00:00
parent 8b753589ce
commit 33c2c02cde
2 changed files with 13 additions and 5 deletions

View File

@ -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]:

View File

@ -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"""