From 765db7cfd0a0aa7aea9f0f717a7762ad79e14ef9 Mon Sep 17 00:00:00 2001 From: Laurent Contzen Date: Sat, 4 Aug 2012 13:33:14 +0200 Subject: roster-model now catches notify::favourites-changed empathy-roster-model: catches notify::favourites-changed and emits favourites-changed empathy-roster-model-manager: implemented this empathy-roster-view: now catches favourites-changed from the model --- libempathy-gtk/empathy-roster-model-manager.c | 12 ++++++++++++ libempathy-gtk/empathy-roster-model.c | 19 +++++++++++++++++++ libempathy-gtk/empathy-roster-model.h | 4 ++++ libempathy-gtk/empathy-roster-view.c | 4 ++-- 4 files changed, 37 insertions(+), 2 deletions(-) diff --git a/libempathy-gtk/empathy-roster-model-manager.c b/libempathy-gtk/empathy-roster-model-manager.c index b9e993aea..f507173c8 100644 --- a/libempathy-gtk/empathy-roster-model-manager.c +++ b/libempathy-gtk/empathy-roster-model-manager.c @@ -124,6 +124,16 @@ top_individuals_changed_cb (EmpathyIndividualManager *manager, EMPATHY_ROSTER_MODEL (self)); } +static void +favourites_changed_cb (EmpathyIndividualManager *manager, + FolksIndividual *individual, + gboolean favourite, + EmpathyRosterModelManager *self) +{ + empathy_roster_model_fire_favourites_changed (EMPATHY_ROSTER_MODEL (self), + individual, favourite); +} + static void empathy_roster_model_manager_get_property (GObject *object, guint property_id, @@ -181,6 +191,8 @@ empathy_roster_model_manager_constructed (GObject *object) G_CALLBACK (groups_changed_cb), self, 0); tp_g_signal_connect_object (self->priv->manager, "notify::top-individuals", G_CALLBACK (top_individuals_changed_cb), self, 0); + tp_g_signal_connect_object (self->priv->manager, "notify::favourites-changed", + G_CALLBACK (favourites_changed_cb), self, 0); } static void diff --git a/libempathy-gtk/empathy-roster-model.c b/libempathy-gtk/empathy-roster-model.c index 198c644c5..671f4b191 100644 --- a/libempathy-gtk/empathy-roster-model.c +++ b/libempathy-gtk/empathy-roster-model.c @@ -29,6 +29,7 @@ enum SIG_INDIVIDUAL_REMOVED, SIG_GROUPS_CHANGED, SIG_TOP_INDIVIDUALS_CHANGED, + SIG_FAVOURITES_CHANGED, LAST_SIGNAL }; @@ -69,6 +70,15 @@ empathy_roster_model_default_init (EmpathyRosterModelInterface *iface) G_SIGNAL_RUN_LAST, 0, NULL, NULL, NULL, G_TYPE_NONE, 0); + + signals[SIG_FAVOURITES_CHANGED] = + g_signal_new ("favourites-changed", + EMPATHY_TYPE_ROSTER_MODEL, + G_SIGNAL_RUN_LAST, + 0, NULL, NULL, NULL, + G_TYPE_NONE, 2, + FOLKS_TYPE_INDIVIDUAL, + G_TYPE_BOOLEAN); } /***** Restricted *****/ @@ -102,6 +112,15 @@ empathy_roster_model_fire_top_individuals_changed (EmpathyRosterModel *self) g_signal_emit (self, signals[SIG_TOP_INDIVIDUALS_CHANGED], 0); } +void +empathy_roster_model_fire_favourites_changed (EmpathyRosterModel *self, + FolksIndividual *individual, + gboolean favourite) +{ + g_signal_emit (self, signals[SIG_FAVOURITES_CHANGED], 0, individual, favourite); +} + + /***** Public *****/ /** diff --git a/libempathy-gtk/empathy-roster-model.h b/libempathy-gtk/empathy-roster-model.h index 507f49d18..d4737b785 100644 --- a/libempathy-gtk/empathy-roster-model.h +++ b/libempathy-gtk/empathy-roster-model.h @@ -74,6 +74,10 @@ void empathy_roster_model_fire_groups_changed (EmpathyRosterModel *self, void empathy_roster_model_fire_top_individuals_changed ( EmpathyRosterModel *self); +void empathy_roster_model_fire_favourites_changed (EmpathyRosterModel *self, + FolksIndividual *individual, + gboolean favourite); + /* Public API */ GList * empathy_roster_model_get_individuals (EmpathyRosterModel *self); diff --git a/libempathy-gtk/empathy-roster-view.c b/libempathy-gtk/empathy-roster-view.c index c157a12d0..2b8154ecc 100644 --- a/libempathy-gtk/empathy-roster-view.c +++ b/libempathy-gtk/empathy-roster-view.c @@ -1035,7 +1035,7 @@ top_individuals_changed_cb (EmpathyRosterModel *model, } static void -favourites_changed_cb (EmpathyIndividualManager *manager, +favourites_changed_cb (EmpathyRosterModel *model, FolksIndividual *individual, gboolean favourite, EmpathyRosterView *self) @@ -1089,7 +1089,7 @@ empathy_roster_view_constructed (GObject *object) G_CALLBACK (groups_changed_cb), self, 0); tp_g_signal_connect_object (self->priv->model, "top-individuals-changed", G_CALLBACK (top_individuals_changed_cb), self, 0); - tp_g_signal_connect_object (self->priv->manager, "notify::favourites-changed", + tp_g_signal_connect_object (self->priv->model, "favourites-changed", G_CALLBACK (favourites_changed_cb), self, 0); egg_list_box_set_sort_func (EGG_LIST_BOX (self), -- cgit v1.2.1