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.
This commit is contained in:
Jean-Marie Traissard 2006-05-14 16:19:04 +00:00
parent 1dfd15631b
commit 8decfc44a2
2 changed files with 13 additions and 6 deletions

View File

@ -159,7 +159,7 @@
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="hscrollbar_policy">GTK_POLICY_AUTOMATIC</property>
<property name="vscrollbar_policy">GTK_POLICY_AUTOMATIC</property>
<property name="vscrollbar_policy">GTK_POLICY_NEVER</property>
<property name="shadow_type">GTK_SHADOW_IN</property>
<property name="window_placement">GTK_CORNER_TOP_LEFT</property>

View File

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