From 8decfc44a24bdc8988468a8a837103e4cdd3cca7 Mon Sep 17 00:00:00 2001 From: Jean-Marie Traissard Date: Sun, 14 May 2006 16:19:04 +0000 Subject: [PATCH] Sort groups in edit group dialog, even when adding one. Note that it doesn't lower groupname before sort. Make edit group window longer but with no vscroolbar if necessary. --- data/glade/edit_groups_dialog.glade | 2 +- src/dialogs.py | 17 ++++++++++++----- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/data/glade/edit_groups_dialog.glade b/data/glade/edit_groups_dialog.glade index 95d7b43ae..5cbdf5947 100644 --- a/data/glade/edit_groups_dialog.glade +++ b/data/glade/edit_groups_dialog.glade @@ -159,7 +159,7 @@ True True GTK_POLICY_AUTOMATIC - GTK_POLICY_AUTOMATIC + GTK_POLICY_NEVER GTK_SHADOW_IN GTK_CORNER_TOP_LEFT diff --git a/src/dialogs.py b/src/dialogs.py index cc52684cd..c15e473a9 100644 --- a/src/dialogs.py +++ b/src/dialogs.py @@ -140,6 +140,7 @@ class EditGroupsDialog: model.append((group, True)) self.add_group(group) self.update_contact() + self.init_list() # Re-draw list to sort new item def group_toggled_cb(self, cell, path): self.changes_made = True @@ -155,15 +156,21 @@ class EditGroupsDialog: def init_list(self): store = gtk.ListStore(str, bool) self.list.set_model(store) + for column in self.list.get_columns(): # Clear treeview when re-drawing + self.list.remove_column(column) + groups = [] # Store accounts in a list so we can sort them for g in gajim.groups[self.account].keys(): if g in helpers.special_groups: continue - iter = store.append() - store.set(iter, 0, g) + in_group = False if g in self.user.groups: - store.set(iter, 1, True) - else: - store.set(iter, 1, False) + in_group = True + groups.append([g, in_group]) + groups.sort() + for group in groups: + iter = store.append() + store.set(iter, 0, group[0]) # Group name + store.set(iter, 1, group[1]) # In group boolean column = gtk.TreeViewColumn(_('Group')) column.set_expand(True) self.list.append_column(column)