]> git.0d.be Git - empathy.git/blobdiff - libempathy-gtk/empathy-contact-list-store.c
Merge call branch from Elliot Fairweather with cleanups from Xavier Claessens.
[empathy.git] / libempathy-gtk / empathy-contact-list-store.c
index b430addd8aa1528a7e91581c0c38e22b1cf1b665..7cabea78f810af5a7a5c0629c5f5e8713d3fb4a6 100644 (file)
@@ -394,14 +394,12 @@ contact_list_store_set_property (GObject      *object,
 }
 
 EmpathyContactListStore *
-empathy_contact_list_store_new (EmpathyContactList *list_iface,
-                               gboolean            show_groups)
+empathy_contact_list_store_new (EmpathyContactList *list_iface)
 {
        g_return_val_if_fail (EMPATHY_IS_CONTACT_LIST (list_iface), NULL);
 
        return g_object_new (EMPATHY_TYPE_CONTACT_LIST_STORE,
                             "contact-list", list_iface,
-                            "show-groups", show_groups,
                             NULL);
 }
 
@@ -822,6 +820,9 @@ contact_list_store_members_changed_cb (EmpathyContactList      *list_iface,
                g_signal_connect (contact, "notify::presence",
                                  G_CALLBACK (contact_list_store_contact_updated_cb),
                                  store);
+               g_signal_connect (contact, "notify::presence-message",
+                                 G_CALLBACK (contact_list_store_contact_updated_cb),
+                                 store);
                g_signal_connect (contact, "notify::name",
                                  G_CALLBACK (contact_list_store_contact_updated_cb),
                                  store);
@@ -1353,8 +1354,8 @@ contact_list_store_state_sort_func (GtkTreeModel *model,
        gint            ret_val = 0;
        gchar          *name_a, *name_b;
        gboolean        is_separator_a, is_separator_b;
-       EmpathyContact  *contact_a, *contact_b;
-       EmpathyPresence *presence_a, *presence_b;
+       EmpathyContact *contact_a, *contact_b;
+       guint           presence_a, presence_b;
 
        gtk_tree_model_get (model, iter_a,
                            EMPATHY_CONTACT_LIST_STORE_COL_NAME, &name_a,
@@ -1391,32 +1392,17 @@ contact_list_store_state_sort_func (GtkTreeModel *model,
         * the presences.
         */
        presence_a = empathy_contact_get_presence (EMPATHY_CONTACT (contact_a));
+       presence_a = contact_list_store_ordered_presence (presence_a);
        presence_b = empathy_contact_get_presence (EMPATHY_CONTACT (contact_b));
+       presence_b = contact_list_store_ordered_presence (presence_b);
 
-       if (!presence_a && presence_b) {
-               ret_val = 1;
-       } else if (presence_a && !presence_b) {
+       if (presence_a < presence_b) {
                ret_val = -1;
-       } else if (!presence_a && !presence_b) {
-               /* Both offline, sort by name */
-               ret_val = g_utf8_collate (name_a, name_b);
+       } else if (presence_a > presence_b) {
+               ret_val = 1;
        } 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) {
-                       ret_val = 1;
-               } else {
-                       /* Fallback: compare by name */
-                       ret_val = g_utf8_collate (name_a, name_b);
-               }
+               /* Fallback: compare by name */
+               ret_val = g_utf8_collate (name_a, name_b);
        }
 
 free_and_out: