diff options
author | Jonny Lamb <jonnylamb@gnome.org> | 2010-04-19 01:10:15 +0800 |
---|---|---|
committer | Jonny Lamb <jonnylamb@gnome.org> | 2010-04-19 17:25:26 +0800 |
commit | 1cb13f899d7d6a22db3e54a58f5dca2753da0637 (patch) | |
tree | 239a521c2806188c7bb98de8c2f9c5de9f71af4d | |
parent | 60597b2520aebd3b13a5e576ec72d53febc15a5f (diff) | |
download | gsoc2013-empathy-1cb13f899d7d6a22db3e54a58f5dca2753da0637.tar gsoc2013-empathy-1cb13f899d7d6a22db3e54a58f5dca2753da0637.tar.gz gsoc2013-empathy-1cb13f899d7d6a22db3e54a58f5dca2753da0637.tar.bz2 gsoc2013-empathy-1cb13f899d7d6a22db3e54a58f5dca2753da0637.tar.lz gsoc2013-empathy-1cb13f899d7d6a22db3e54a58f5dca2753da0637.tar.xz gsoc2013-empathy-1cb13f899d7d6a22db3e54a58f5dca2753da0637.tar.zst gsoc2013-empathy-1cb13f899d7d6a22db3e54a58f5dca2753da0637.zip |
contact list store: order contacts by alias, ID, protocol then account ID (fixes #612864)
Signed-off-by: Jonny Lamb <jonnylamb@gnome.org>
-rw-r--r-- | libempathy-gtk/empathy-contact-list-store.c | 45 |
1 files changed, 42 insertions, 3 deletions
diff --git a/libempathy-gtk/empathy-contact-list-store.c b/libempathy-gtk/empathy-contact-list-store.c index 16169347b..dc1d8aa2f 100644 --- a/libempathy-gtk/empathy-contact-list-store.c +++ b/libempathy-gtk/empathy-contact-list-store.c @@ -1621,6 +1621,45 @@ compare_separator_and_groups (gboolean is_separator_a, } static gint +contact_list_store_contact_sort (EmpathyContact *contact_a, + EmpathyContact *contact_b) +{ + TpAccount *account_a, *account_b; + gint ret_val; + + /* alias */ + ret_val = g_utf8_collate (empathy_contact_get_name (contact_a), + empathy_contact_get_name (contact_b)); + + if (ret_val != 0) + goto out; + + /* identifier */ + ret_val = g_utf8_collate (empathy_contact_get_id (contact_a), + empathy_contact_get_id (contact_b)); + + if (ret_val != 0) + goto out; + + account_a = empathy_contact_get_account (contact_a); + account_b = empathy_contact_get_account (contact_b); + + /* protocol */ + ret_val = strcmp (tp_account_get_protocol (account_a), + tp_account_get_protocol (account_a)); + + if (ret_val != 0) + goto out; + + /* account ID */ + ret_val = strcmp (tp_proxy_get_object_path (account_a), + tp_proxy_get_object_path (account_a)); + +out: + return ret_val; +} + +static gint contact_list_store_state_sort_func (GtkTreeModel *model, GtkTreeIter *iter_a, GtkTreeIter *iter_b, @@ -1660,8 +1699,8 @@ contact_list_store_state_sort_func (GtkTreeModel *model, empathy_contact_get_presence (EMPATHY_CONTACT (contact_b))); if (ret_val == 0) { - /* Fallback: compare by name */ - ret_val = g_utf8_collate (name_a, name_b); + /* Fallback: compare by name et al. */ + ret_val = contact_list_store_contact_sort (contact_a, contact_b); } free_and_out: @@ -1708,7 +1747,7 @@ contact_list_store_name_sort_func (GtkTreeModel *model, name_a, name_b, contact_a, contact_b, fake_group_a, fake_group_b); if (ret_val == 0) - ret_val = g_utf8_collate (name_a, name_b); + ret_val = contact_list_store_contact_sort (contact_a, contact_b); if (contact_a) { g_object_unref (contact_a); |