diff options
-rw-r--r-- | libempathy-gtk/empathy-individual-store.c | 41 | ||||
-rw-r--r-- | libempathy-gtk/empathy-individual-view.c | 7 | ||||
-rw-r--r-- | libempathy/empathy-individual-manager.c | 22 |
3 files changed, 43 insertions, 27 deletions
diff --git a/libempathy-gtk/empathy-individual-store.c b/libempathy-gtk/empathy-individual-store.c index a1a07a32c..95f236a13 100644 --- a/libempathy-gtk/empathy-individual-store.c +++ b/libempathy-gtk/empathy-individual-store.c @@ -794,6 +794,24 @@ individual_store_members_changed_cb (EmpathyIndividualManager *manager, } static void +individual_store_favourites_changed_cb (EmpathyIndividualManager *manager, + FolksIndividual *individual, + gboolean is_favourite, + EmpathyIndividualStore *self) +{ + EmpathyIndividualStorePriv *priv; + + priv = GET_PRIV (self); + + DEBUG ("Individual %s is %s a favourite", + folks_individual_get_id (individual), + is_favourite ? "now" : "no longer"); + + individual_store_remove_individual (self, individual); + individual_store_add_individual (self, individual); +} + +static void individual_store_groups_changed_cb (EmpathyIndividualManager *manager, FolksIndividual *individual, gchar *group, @@ -835,8 +853,9 @@ individual_store_manager_setup (gpointer user_data) "members-changed", G_CALLBACK (individual_store_members_changed_cb), self); - /* TODO: implement */ - DEBUG ("handling individual favourite status changes unimplemented"); + g_signal_connect (priv->manager, + "favourites-changed", + G_CALLBACK (individual_store_favourites_changed_cb), self); g_signal_connect (priv->manager, "groups-changed", @@ -891,24 +910,6 @@ individual_store_member_renamed_cb (EmpathyIndividualManager *manager, } static void -individual_store_favourites_changed_cb (EmpathyIndividualManager *manager, - FolksIndividual *individual, - gboolean is_favourite, - EmpathyIndividualStore *self) -{ - EmpathyIndividualStorePriv *priv; - - priv = GET_PRIV (self); - - DEBUG ("Individual %s is %s a favourite", - folks_individual_get_id (individual), - is_favourite ? "now" : "no longer"); - - individual_store_remove_individual (self, individual); - individual_store_add_individual (self, individual); -} - -static void individual_store_dispose (GObject *object) { EmpathyIndividualStorePriv *priv = GET_PRIV (object); diff --git a/libempathy-gtk/empathy-individual-view.c b/libempathy-gtk/empathy-individual-view.c index 067fb60a0..218590940 100644 --- a/libempathy-gtk/empathy-individual-view.c +++ b/libempathy-gtk/empathy-individual-view.c @@ -346,10 +346,6 @@ individual_view_handle_drag (EmpathyIndividualView *self, { /* Mark contact as favourite */ folks_favourite_set_is_favourite (FOLKS_FAVOURITE (individual), TRUE); - - /* TODO: implement this */ - DEBUG ("adding individual to favourites not fully implemented"); - return; } @@ -358,9 +354,6 @@ individual_view_handle_drag (EmpathyIndividualView *self, /* Remove contact as favourite */ folks_favourite_set_is_favourite (FOLKS_FAVOURITE (individual), FALSE); - /* TODO: implement this */ - DEBUG ("removing individual from favourites not fully " "implemented"); - /* Don't try to remove it */ old_group = NULL; } diff --git a/libempathy/empathy-individual-manager.c b/libempathy/empathy-individual-manager.c index 53843ce93..f162ba353 100644 --- a/libempathy/empathy-individual-manager.c +++ b/libempathy/empathy-individual-manager.c @@ -66,6 +66,16 @@ individual_group_changed_cb (FolksIndividual *individual, } static void +individual_notify_is_favourite_cb (FolksIndividual *individual, + GParamSpec *pspec, + EmpathyIndividualManager *self) +{ + gboolean is_favourite = folks_favourite_get_is_favourite ( + FOLKS_FAVOURITE (individual)); + g_signal_emit_by_name (self, "favourites-changed", individual, is_favourite); +} + +static void aggregator_individuals_added_cb (FolksIndividualAggregator *aggregator, GList *individuals, EmpathyIndividualManager *self) @@ -76,6 +86,8 @@ aggregator_individuals_added_cb (FolksIndividualAggregator *aggregator, { g_signal_connect (l->data, "group-changed", G_CALLBACK (individual_group_changed_cb), self); + g_signal_connect (l->data, "notify::is-favourite", + G_CALLBACK (individual_notify_is_favourite_cb), self); } /* TODO: don't hard-code the reason or message */ @@ -95,6 +107,8 @@ aggregator_individuals_removed_cb (FolksIndividualAggregator *aggregator, { g_signal_handlers_disconnect_by_func (l->data, individual_group_changed_cb, self); + g_signal_handlers_disconnect_by_func (l->data, + individual_notify_is_favourite_cb, self); } /* TODO: don't hard-code the reason or message */ @@ -175,6 +189,14 @@ empathy_individual_manager_class_init (EmpathyIndividualManagerClass *klass) _empathy_marshal_VOID__OBJECT_STRING_BOOLEAN, G_TYPE_NONE, 3, FOLKS_TYPE_INDIVIDUAL, G_TYPE_STRING, G_TYPE_BOOLEAN); + g_signal_new ("favourites-changed", + G_TYPE_FROM_CLASS (klass), + G_SIGNAL_RUN_LAST, + 0, + NULL, NULL, + _empathy_marshal_VOID__OBJECT_BOOLEAN, + G_TYPE_NONE, 2, FOLKS_TYPE_INDIVIDUAL, G_TYPE_BOOLEAN); + g_signal_new ("members-changed", G_TYPE_FROM_CLASS (klass), G_SIGNAL_RUN_LAST, |