diff options
author | Guillaume Desmottes <guillaume.desmottes@collabora.co.uk> | 2012-02-03 23:11:47 +0800 |
---|---|---|
committer | Guillaume Desmottes <guillaume.desmottes@collabora.co.uk> | 2012-02-14 17:34:45 +0800 |
commit | 6ef0203c6af78e37a6e7de79dd2bae7de870d62d (patch) | |
tree | 235e1787f7edf4d9a740881028c98b18fd5cfac4 /libempathy | |
parent | 45fea3c1ff003d49510819a9dd713b5d23a18244 (diff) | |
download | gsoc2013-empathy-6ef0203c6af78e37a6e7de79dd2bae7de870d62d.tar gsoc2013-empathy-6ef0203c6af78e37a6e7de79dd2bae7de870d62d.tar.gz gsoc2013-empathy-6ef0203c6af78e37a6e7de79dd2bae7de870d62d.tar.bz2 gsoc2013-empathy-6ef0203c6af78e37a6e7de79dd2bae7de870d62d.tar.lz gsoc2013-empathy-6ef0203c6af78e37a6e7de79dd2bae7de870d62d.tar.xz gsoc2013-empathy-6ef0203c6af78e37a6e7de79dd2bae7de870d62d.tar.zst gsoc2013-empathy-6ef0203c6af78e37a6e7de79dd2bae7de870d62d.zip |
individual-manager: add API to know when contacts have been loaded from folks
https://bugzilla.gnome.org/show_bug.cgi?id=656097
Diffstat (limited to 'libempathy')
-rw-r--r-- | libempathy/empathy-individual-manager.c | 43 | ||||
-rw-r--r-- | libempathy/empathy-individual-manager.h | 3 |
2 files changed, 46 insertions, 0 deletions
diff --git a/libempathy/empathy-individual-manager.c b/libempathy/empathy-individual-manager.c index b391d3ca9..a1ca269c6 100644 --- a/libempathy/empathy-individual-manager.c +++ b/libempathy/empathy-individual-manager.c @@ -50,6 +50,7 @@ typedef struct { FolksIndividualAggregator *aggregator; GHashTable *individuals; /* Individual.id -> Individual */ + gboolean contacts_loaded; } EmpathyIndividualManagerPriv; enum @@ -57,6 +58,7 @@ enum FAVOURITES_CHANGED, GROUPS_CHANGED, MEMBERS_CHANGED, + CONTACTS_LOADED, LAST_SIGNAL }; @@ -334,11 +336,42 @@ empathy_individual_manager_class_init (EmpathyIndividualManagerClass *klass) G_TYPE_NONE, 4, G_TYPE_STRING, G_TYPE_POINTER, G_TYPE_POINTER, G_TYPE_UINT); + signals[CONTACTS_LOADED] = + g_signal_new ("contacts-loaded", + G_TYPE_FROM_CLASS (klass), + G_SIGNAL_RUN_LAST, + 0, + NULL, NULL, + g_cclosure_marshal_generic, + G_TYPE_NONE, + 0); + g_type_class_add_private (object_class, sizeof (EmpathyIndividualManagerPriv)); } static void +aggregator_is_quiescent_notify_cb (FolksIndividualAggregator *aggregator, + GParamSpec *spec, + EmpathyIndividualManager *self) +{ + EmpathyIndividualManagerPriv *priv = GET_PRIV (self); + gboolean is_quiescent; + + if (priv->contacts_loaded) + return; + + g_object_get (aggregator, "is-quiescent", &is_quiescent, NULL); + + if (!is_quiescent) + return; + + priv->contacts_loaded = TRUE; + + g_signal_emit (self, signals[CONTACTS_LOADED], 0); +} + +static void empathy_individual_manager_init (EmpathyIndividualManager *self) { EmpathyIndividualManagerPriv *priv = G_TYPE_INSTANCE_GET_PRIVATE (self, @@ -351,6 +384,8 @@ empathy_individual_manager_init (EmpathyIndividualManager *self) priv->aggregator = folks_individual_aggregator_new (); g_signal_connect (priv->aggregator, "individuals-changed-detailed", G_CALLBACK (aggregator_individuals_changed_cb), self); + g_signal_connect (priv->aggregator, "notify::is-quiescent", + G_CALLBACK (aggregator_is_quiescent_notify_cb), self); folks_individual_aggregator_prepare (priv->aggregator, NULL, NULL); } @@ -720,3 +755,11 @@ empathy_individual_manager_unlink_individual (EmpathyIndividualManager *self, folks_individual_aggregator_unlink_individual (priv->aggregator, individual, (GAsyncReadyCallback) unlink_individual_cb, NULL); } + +gboolean +empathy_individual_manager_get_contacts_loaded (EmpathyIndividualManager *self) +{ + EmpathyIndividualManagerPriv *priv = GET_PRIV (self); + + return priv->contacts_loaded; +} diff --git a/libempathy/empathy-individual-manager.h b/libempathy/empathy-individual-manager.h index 0d5cc74d4..ec7603882 100644 --- a/libempathy/empathy-individual-manager.h +++ b/libempathy/empathy-individual-manager.h @@ -90,5 +90,8 @@ void empathy_individual_manager_set_blocked (EmpathyIndividualManager *self, gboolean blocked, gboolean abusive); +gboolean empathy_individual_manager_get_contacts_loaded ( + EmpathyIndividualManager *self); + G_END_DECLS #endif /* __EMPATHY_INDIVIDUAL_MANAGER_H__ */ |