summaryrefslogtreecommitdiffstats
path: root/src/gui
diff options
context:
space:
mode:
Diffstat (limited to 'src/gui')
-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();
+ });
+ }
+ }
}