aboutsummaryrefslogtreecommitdiffstats
path: root/libempathy-gtk
diff options
context:
space:
mode:
authorTravis Reitter <treitter@gmail.com>2010-03-06 10:58:17 +0800
committerGuillaume Desmottes <guillaume.desmottes@collabora.co.uk>2010-03-15 16:28:40 +0800
commitc66e6c536d776414f6bfada650dc25d97dc95803 (patch)
tree9604690224776a95843126ef1c9deb348a53ea70 /libempathy-gtk
parent79ef79c4d92cc4978dd12528d5bb6c3673a6b0f9 (diff)
downloadgsoc2013-empathy-c66e6c536d776414f6bfada650dc25d97dc95803.tar
gsoc2013-empathy-c66e6c536d776414f6bfada650dc25d97dc95803.tar.gz
gsoc2013-empathy-c66e6c536d776414f6bfada650dc25d97dc95803.tar.bz2
gsoc2013-empathy-c66e6c536d776414f6bfada650dc25d97dc95803.tar.lz
gsoc2013-empathy-c66e6c536d776414f6bfada650dc25d97dc95803.tar.xz
gsoc2013-empathy-c66e6c536d776414f6bfada650dc25d97dc95803.tar.zst
gsoc2013-empathy-c66e6c536d776414f6bfada650dc25d97dc95803.zip
Rebase the favourites support upon the telepathy-logger instead of a specially-named favourites group.
Diffstat (limited to 'libempathy-gtk')
-rw-r--r--libempathy-gtk/empathy-contact-list-store.c66
-rw-r--r--libempathy-gtk/empathy-contact-list-view.c10
2 files changed, 62 insertions, 14 deletions
diff --git a/libempathy-gtk/empathy-contact-list-store.c b/libempathy-gtk/empathy-contact-list-store.c
index c68edb16d..ca776682f 100644
--- a/libempathy-gtk/empathy-contact-list-store.c
+++ b/libempathy-gtk/empathy-contact-list-store.c
@@ -105,6 +105,10 @@ static void contact_list_store_members_changed_cb (EmpathyCon
gchar *message,
gboolean is_member,
EmpathyContactListStore *store);
+static void contact_list_store_favourites_changed_cb (EmpathyContactList *list_iface,
+ EmpathyContact *contact,
+ gboolean is_favourite,
+ EmpathyContactListStore *store);
static void contact_list_store_member_renamed_cb (EmpathyContactList *list_iface,
EmpathyContact *old_contact,
EmpathyContact *new_contact,
@@ -192,6 +196,10 @@ contact_list_store_iface_setup (gpointer user_data)
G_CALLBACK (contact_list_store_members_changed_cb),
store);
g_signal_connect (priv->list,
+ "favourites-changed",
+ G_CALLBACK (contact_list_store_favourites_changed_cb),
+ store);
+ g_signal_connect (priv->list,
"groups-changed",
G_CALLBACK (contact_list_store_groups_changed_cb),
store);
@@ -338,6 +346,9 @@ contact_list_store_dispose (GObject *object)
G_CALLBACK (contact_list_store_members_changed_cb),
object);
g_signal_handlers_disconnect_by_func (priv->list,
+ G_CALLBACK (contact_list_store_favourites_changed_cb),
+ object);
+ g_signal_handlers_disconnect_by_func (priv->list,
G_CALLBACK (contact_list_store_groups_changed_cb),
object);
g_object_unref (priv->list);
@@ -918,6 +929,43 @@ contact_list_store_members_changed_cb (EmpathyContactList *list_iface,
}
static void
+contact_list_store_change_contact_favourite_status (EmpathyContactListStore *store,
+ EmpathyContact *contact,
+ gboolean is_favourite)
+{
+ GList *iters, *l;
+
+ iters = contact_list_store_find_contact (store, contact);
+ for (l = iters; l; l = l->next) {
+ gtk_tree_store_set (GTK_TREE_STORE (store), l->data,
+ EMPATHY_CONTACT_LIST_STORE_COL_IS_FAVOURITE,
+ is_favourite,
+ -1);
+ }
+
+ g_list_foreach (iters, (GFunc) gtk_tree_iter_free, NULL);
+ g_list_free (iters);
+}
+
+static void
+contact_list_store_favourites_changed_cb (EmpathyContactList *list_iface,
+ EmpathyContact *contact,
+ gboolean is_favourite,
+ EmpathyContactListStore *store)
+{
+ EmpathyContactListStorePriv *priv;
+
+ priv = GET_PRIV (store);
+
+ DEBUG ("Contact %s (%d) is %s a favourite",
+ empathy_contact_get_id (contact),
+ empathy_contact_get_handle (contact),
+ is_favourite ? "now" : "no longer");
+
+ contact_list_store_change_contact_favourite_status (store, contact, is_favourite);
+}
+
+static void
contact_list_store_member_renamed_cb (EmpathyContactList *list_iface,
EmpathyContact *old_contact,
EmpathyContact *new_contact,
@@ -1104,7 +1152,7 @@ list_store_contact_is_favourite (EmpathyContactListStore *store,
priv = GET_PRIV (store);
- return empathy_contact_list_contact_is_favourite (priv->list, contact);
+ return empathy_contact_list_is_favourite (priv->list, contact);
}
static void
@@ -1483,17 +1531,20 @@ contact_list_store_state_sort_func (GtkTreeModel *model,
gint ret_val = 0;
gchar *name_a, *name_b;
gboolean is_separator_a, is_separator_b;
+ gboolean is_favourite_a, is_favourite_b;
EmpathyContact *contact_a, *contact_b;
gtk_tree_model_get (model, iter_a,
EMPATHY_CONTACT_LIST_STORE_COL_NAME, &name_a,
EMPATHY_CONTACT_LIST_STORE_COL_CONTACT, &contact_a,
EMPATHY_CONTACT_LIST_STORE_COL_IS_SEPARATOR, &is_separator_a,
+ EMPATHY_CONTACT_LIST_STORE_COL_IS_FAVOURITE, &is_favourite_a,
-1);
gtk_tree_model_get (model, iter_b,
EMPATHY_CONTACT_LIST_STORE_COL_NAME, &name_b,
EMPATHY_CONTACT_LIST_STORE_COL_CONTACT, &contact_b,
EMPATHY_CONTACT_LIST_STORE_COL_IS_SEPARATOR, &is_separator_b,
+ EMPATHY_CONTACT_LIST_STORE_COL_IS_FAVOURITE, &is_favourite_b,
-1);
/* Separator, favourites group, or other group? */
@@ -1503,14 +1554,10 @@ contact_list_store_state_sort_func (GtkTreeModel *model,
} else if (is_separator_b) {
ret_val = 1;
}
-#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) {
@@ -1559,18 +1606,21 @@ contact_list_store_name_sort_func (GtkTreeModel *model,
{
gchar *name_a, *name_b;
EmpathyContact *contact_a, *contact_b;
- gboolean is_separator_a, is_separator_b;
+ gboolean is_separator_a = FALSE, is_separator_b = FALSE;
+ gboolean is_favourite_a, is_favourite_b;
gint ret_val;
gtk_tree_model_get (model, iter_a,
EMPATHY_CONTACT_LIST_STORE_COL_NAME, &name_a,
EMPATHY_CONTACT_LIST_STORE_COL_CONTACT, &contact_a,
EMPATHY_CONTACT_LIST_STORE_COL_IS_SEPARATOR, &is_separator_a,
+ EMPATHY_CONTACT_LIST_STORE_COL_IS_FAVOURITE, &is_favourite_a,
-1);
gtk_tree_model_get (model, iter_b,
EMPATHY_CONTACT_LIST_STORE_COL_NAME, &name_b,
EMPATHY_CONTACT_LIST_STORE_COL_CONTACT, &contact_b,
EMPATHY_CONTACT_LIST_STORE_COL_IS_SEPARATOR, &is_separator_b,
+ EMPATHY_CONTACT_LIST_STORE_COL_IS_FAVOURITE, &is_favourite_b,
-1);
/* If contact is NULL it means it's a group. */
diff --git a/libempathy-gtk/empathy-contact-list-view.c b/libempathy-gtk/empathy-contact-list-view.c
index 15d0926e7..b95f05580 100644
--- a/libempathy-gtk/empathy-contact-list-view.c
+++ b/libempathy-gtk/empathy-contact-list-view.c
@@ -34,6 +34,7 @@
#include <telepathy-glib/account-manager.h>
#include <telepathy-glib/util.h>
+#include <extensions/extensions.h>
#include <libempathy/empathy-call-factory.h>
#include <libempathy/empathy-tp-contact-factory.h>
#include <libempathy/empathy-contact-list.h>
@@ -840,13 +841,10 @@ contact_list_view_favourite_toggled_cb (
return;
list = empathy_contact_list_store_get_list_iface (priv->store);
-
- if (empathy_contact_list_contact_is_favourite (list, contact)) {
- empathy_contact_list_remove_from_group (list, contact,
- EMPATHY_GROUP_FAVOURITES);
+ if (empathy_contact_list_is_favourite (list, contact)) {
+ empathy_contact_list_remove_from_favourites (list, contact);
} else {
- empathy_contact_list_add_to_group (list, contact,
- EMPATHY_GROUP_FAVOURITES);
+ empathy_contact_list_add_to_favourites (list, contact);
}
g_object_unref (contact);