summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMatthias Schiffer <mschiffer@universe-factory.net>2010-08-17 01:03:25 +0200
committerMatthias Schiffer <mschiffer@universe-factory.net>2010-08-17 01:03:25 +0200
commit2081f6c62d3c149be5cb0b9ca04f3325098e3af2 (patch)
tree74a46e6d526e949bdd0d1c528f280ef6f27db01c /src
parent6ec7efc36f44dfddff4c9d843cd4c70cffb95837 (diff)
downloadephraim-2081f6c62d3c149be5cb0b9ca04f3325098e3af2.tar
ephraim-2081f6c62d3c149be5cb0b9ca04f3325098e3af2.zip
Sort roster entries and groups correctly
Diffstat (limited to 'src')
-rw-r--r--src/gui/Roster.vala28
1 files changed, 26 insertions, 2 deletions
diff --git a/src/gui/Roster.vala b/src/gui/Roster.vala
index 32bdb6d..75e6631 100644
--- a/src/gui/Roster.vala
+++ b/src/gui/Roster.vala
@@ -11,7 +11,7 @@ public class Roster {
contactList = new ContactListModel(this);
model = new RosterModel(contactList);
- rosterView.set_model(new RosterFilter(this, model));
+ rosterView.set_model(new RosterFilter(this, new RosterSorter(model)));
rosterView.query_tooltip.connect((x, y, keyboard_tip, tooltip) => {
Gtk.TreeModel model;
@@ -57,7 +57,7 @@ public class Roster {
});
rosterView.model.row_inserted.connect((path, iter) => {
- rosterView.expand_to_path(path);
+ Idle.add(() => {rosterView.expand_to_path(path); return false;});
});
Gtk.TreeViewColumn contactColumn = new Gtk.TreeViewColumn.with_attributes(null, new CellRendererContact(), "data", 0, null);
@@ -698,4 +698,28 @@ public class Roster {
});
}
}
+
+ private class RosterSorter : Gtk.TreeModelSort {
+ public RosterSorter(Gtk.TreeModel childModel) {
+ Object(model: childModel);
+
+ set_sort_column_id(0, Gtk.SortType.ASCENDING);
+ set_sort_func(0, (model, itera, iterb) => {
+ Value value;
+ model.get_value(itera, 0, out value);
+ Object a = value.get_object();
+ model.get_value(iterb, 0, out value);
+ Object b = value.get_object();
+
+ if(a is String && b is String) {
+ return (a as String).data.collate((b as String).data);
+ }
+ else if(a is Contact && b is Contact) {
+ return (a as Contact).display_string.collate((b as Contact).display_string);
+ }
+
+ assert_not_reached();
+ });
+ }
+ }
}