From 09328ae39c6c1bd22282783c459d7f851086d9fb Mon Sep 17 00:00:00 2001 From: Xavier Claessens Date: Thu, 17 Jan 2008 16:19:08 +0000 Subject: [PATCH] Fix state order to have offline contacts last. Fixes bug #509906. svn path=/trunk/; revision=574 --- libempathy-gtk/empathy-contact-list-store.c | 28 ++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/libempathy-gtk/empathy-contact-list-store.c b/libempathy-gtk/empathy-contact-list-store.c index 820db5b1..3536f6bb 100644 --- a/libempathy-gtk/empathy-contact-list-store.c +++ b/libempathy-gtk/empathy-contact-list-store.c @@ -1213,6 +1213,28 @@ contact_list_store_get_group (EmpathyContactListStore *store, } } +static guint +contact_list_store_ordered_presence (McPresence state) +{ + switch (state) { + case MC_PRESENCE_UNSET: + case MC_PRESENCE_OFFLINE: + return 5; + case MC_PRESENCE_AVAILABLE: + return 0; + case MC_PRESENCE_AWAY: + return 2; + case MC_PRESENCE_EXTENDED_AWAY: + return 3; + case MC_PRESENCE_HIDDEN: + return 4; + case MC_PRESENCE_DO_NOT_DISTURB: + return 1; + default: + g_return_val_if_reached (6); + } +} + static gint contact_list_store_state_sort_func (GtkTreeModel *model, GtkTreeIter *iter_a, @@ -1224,7 +1246,6 @@ contact_list_store_state_sort_func (GtkTreeModel *model, gboolean is_separator_a, is_separator_b; EmpathyContact *contact_a, *contact_b; EmpathyPresence *presence_a, *presence_b; - McPresence state_a, state_b; gtk_tree_model_get (model, iter_a, EMPATHY_CONTACT_LIST_STORE_COL_NAME, &name_a, @@ -1271,9 +1292,14 @@ contact_list_store_state_sort_func (GtkTreeModel *model, /* Both offline, sort by name */ ret_val = g_utf8_collate (name_a, name_b); } else { + guint state_a, state_b; + state_a = empathy_presence_get_state (presence_a); state_b = empathy_presence_get_state (presence_b); + state_a = contact_list_store_ordered_presence (state_a); + state_b = contact_list_store_ordered_presence (state_b); + if (state_a < state_b) { ret_val = -1; } else if (state_a > state_b) { -- 2.39.2