]> git.0d.be Git - empathy.git/blobdiff - libempathy-gtk/empathy-contact-list-store.c
Remove EmpathyPresence object and have "presence" and "presence-message" properties...
[empathy.git] / libempathy-gtk / empathy-contact-list-store.c
index bd5e9bc5e95535e9c82abfcf5182d56e9a85cce4..7cabea78f810af5a7a5c0629c5f5e8713d3fb4a6 100644 (file)
@@ -820,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);
@@ -1351,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,
@@ -1389,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: