]> git.0d.be Git - empathy.git/commitdiff
Cut out the concept of a special Favourites group
authorTravis Reitter <treitter@gmail.com>
Sat, 6 Mar 2010 01:45:44 +0000 (17:45 -0800)
committerGuillaume Desmottes <guillaume.desmottes@collabora.co.uk>
Mon, 15 Mar 2010 08:28:40 +0000 (09:28 +0100)
libempathy-gtk/empathy-contact-list-store.c
libempathy-gtk/empathy-contact-list-view.c
libempathy/empathy-contact-list.c
libempathy/empathy-contact-list.h

index 72ba746959411349aaec9aeb18b3906068eee4fa..c68edb16d4f164efb501737bae4f4e49f017560a 100644 (file)
@@ -1446,22 +1446,6 @@ contact_list_store_get_group (EmpathyContactListStore *store,
                                    EMPATHY_CONTACT_LIST_STORE_COL_IS_SEPARATOR, TRUE,
                                    -1);
 
-#if HAVE_FAVOURITE_CONTACTS
-               /* add a second separator for the favourite contacts group, to
-                * always be sorted at the end. This will provide a visual
-                * distinction between the end of the favourites and the
-                * beginning of the ungrouped contacts */
-               if (!g_strcmp0 (name, EMPATHY_GROUP_FAVOURITES)) {
-                       gtk_tree_store_append (GTK_TREE_STORE (store),
-                                       &iter_separator,
-                                       &iter_group);
-                       gtk_tree_store_set (GTK_TREE_STORE (store), &iter_separator,
-                                       EMPATHY_CONTACT_LIST_STORE_COL_NAME, EMPATHY_GROUP_FAVOURITES,
-                                       EMPATHY_CONTACT_LIST_STORE_COL_IS_SEPARATOR, TRUE,
-                                       -1);
-               }
-#endif /* HAVE_FAVOURITE_CONTACTS */
-
                if (iter_separator_to_set) {
                        *iter_separator_to_set = iter_separator;
                }
@@ -1515,27 +1499,9 @@ contact_list_store_state_sort_func (GtkTreeModel *model,
        /* Separator, favourites group, or other group? */
        if (is_separator_a || is_separator_b) {
                if (is_separator_a) {
-#if HAVE_FAVOURITE_CONTACTS
-                       /* sort the special favourites group 2nd separator at
-                        * the end */
-                       if (!g_strcmp0 (name_a, EMPATHY_GROUP_FAVOURITES)) {
-                               ret_val = 1;
-                       } else {
-                               ret_val = -1;
-                       }
-#else
                         ret_val = -1;
-#endif /* HAVE_FAVOURITE_CONTACTS */
                } else if (is_separator_b) {
-#if HAVE_FAVOURITE_CONTACTS
-                       if (!g_strcmp0 (name_b, EMPATHY_GROUP_FAVOURITES)) {
-                               ret_val = -1;
-                       } else {
-                               ret_val = 1;
-                       }
-#else
                         ret_val = 1;
-#endif /* HAVE_FAVOURITE_CONTACTS */
                }
 #if HAVE_FAVOURITE_CONTACTS
        } else if (!contact_a && !g_strcmp0 (name_a,
@@ -1611,36 +1577,14 @@ contact_list_store_name_sort_func (GtkTreeModel *model,
 
        if (is_separator_a || is_separator_b) {
                if (is_separator_a) {
-#if HAVE_FAVOURITE_CONTACTS
-                       /* sort the special favourites group 2nd separator at
-                        * the end */
-                       if (!g_strcmp0 (name_a, EMPATHY_GROUP_FAVOURITES)) {
-                               ret_val = 1;
-                       } else {
-                               ret_val = -1;
-                       }
-#else
                         ret_val = -1;
-#endif /* HAVE_FAVOURITE_CONTACTS */
                } else if (is_separator_b) {
-#if HAVE_FAVOURITE_CONTACTS
-                       if (!g_strcmp0 (name_b, EMPATHY_GROUP_FAVOURITES)) {
-                               ret_val = -1;
-                       } else {
-                               ret_val = 1;
-                       }
-#else
                         ret_val = 1;
-#endif /* HAVE_FAVOURITE_CONTACTS */
                }
-#if HAVE_FAVOURITE_CONTACTS
-       } else if (!contact_a && !g_strcmp0 (name_a,
-                               EMPATHY_GROUP_FAVOURITES)) {
+       } else if (is_favourite_a && !is_favourite_b) {
                ret_val = -1;
-       } else if (!contact_b && !g_strcmp0 (name_b,
-                               EMPATHY_GROUP_FAVOURITES)) {
+       } else if (!is_favourite_a && is_favourite_b) {
                ret_val = 1;
-#endif /* HAVE_FAVOURITE_CONTACTS */
        } else if (!contact_a && contact_b) {
                ret_val = 1;
        } else if (contact_a && !contact_b) {
index bd432f2614f49104f1cf7b8c6c898a1f74c6c67b..15d0926e77af852714f065f66b213976b252b423 100644 (file)
@@ -992,13 +992,6 @@ contact_list_view_text_cell_data_func (GtkTreeViewColumn     *tree_column,
                            EMPATHY_CONTACT_LIST_STORE_COL_NAME, &name,
                            -1);
 
-#if HAVE_FAVOURITE_CONTACTS
-        if (is_group && !g_strcmp0 (name, EMPATHY_GROUP_FAVOURITES)) {
-                g_free (name);
-                name = g_strdup (_(EMPATHY_GROUP_FAVOURITES));
-        }
-#endif /* HAVE_FAVOURITE_CONTACTS */
-
        g_object_set (cell,
                      "show-status", show_status,
                      "text", name,
index a46fc8db4a8bbc5a9bf7a8df3de7d10010a969b5..611a40fe54f006300ac752a8ae603df822c6f1f9 100644 (file)
@@ -250,21 +250,42 @@ empathy_contact_list_get_flags (EmpathyContactList *list)
        }
 }
 
-/* XXX: this should be an EmpathyContact function, but it would likely require
- * some awkward refactoring */
 gboolean
-empathy_contact_list_contact_is_favourite (EmpathyContactList *list,
-                                           EmpathyContact     *contact)
+empathy_contact_list_is_favourite (EmpathyContactList *list,
+                                   EmpathyContact     *contact)
 {
 #if HAVE_FAVOURITE_CONTACTS
-        GList *groups, *l;
-
-        groups = empathy_contact_list_get_groups (list, contact);
-        for (l = groups; l; l = l->next)
-                if (!g_strcmp0 (l->data, EMPATHY_GROUP_FAVOURITES))
-                        return TRUE;
+       if (EMPATHY_CONTACT_LIST_GET_IFACE (list)->is_favourite) {
+               return EMPATHY_CONTACT_LIST_GET_IFACE (list)->is_favourite (
+                                list, contact);
+       }
 #endif /* HAVE_FAVOURITE_CONTACTS */
 
         return FALSE;
 }
 
+void
+empathy_contact_list_add_to_favourites (EmpathyContactList *list,
+                                        EmpathyContact     *contact)
+{
+#if HAVE_FAVOURITE_CONTACTS
+       if (EMPATHY_CONTACT_LIST_GET_IFACE (list)->add_favourite) {
+                EMPATHY_CONTACT_LIST_GET_IFACE (list)->add_favourite (list,
+                                contact);
+       }
+#endif /* HAVE_FAVOURITE_CONTACTS */
+}
+
+void
+empathy_contact_list_remove_from_favourites (EmpathyContactList *list,
+                                             EmpathyContact     *contact)
+{
+#if HAVE_FAVOURITE_CONTACTS
+       if (EMPATHY_CONTACT_LIST_GET_IFACE (list)->remove_favourite) {
+                EMPATHY_CONTACT_LIST_GET_IFACE (list)->remove_favourite (list,
+                                contact);
+       }
+#endif /* HAVE_FAVOURITE_CONTACTS */
+}
+
+
index c3fff727112631963cf1abfda45d5bd7f0fa48f7..080a89584660b3549a641e808afd0d32d2644f9a 100644 (file)
@@ -34,9 +34,6 @@ G_BEGIN_DECLS
 #define EMPATHY_IS_CONTACT_LIST(o)        (G_TYPE_CHECK_INSTANCE_TYPE ((o), EMPATHY_TYPE_CONTACT_LIST))
 #define EMPATHY_CONTACT_LIST_GET_IFACE(o) (G_TYPE_INSTANCE_GET_INTERFACE ((o), EMPATHY_TYPE_CONTACT_LIST, EmpathyContactListIface))
 
-/* The favourites are just in a specially-handled group */
-#define EMPATHY_GROUP_FAVOURITES "Favorites"
-
 typedef enum {
        EMPATHY_CONTACT_LIST_CAN_ADD            = 1 << 0,
        EMPATHY_CONTACT_LIST_CAN_REMOVE         = 1 << 1,