diff options
author | Travis Reitter <travis.reitter@collabora.co.uk> | 2011-04-30 04:33:04 +0800 |
---|---|---|
committer | Travis Reitter <travis.reitter@collabora.co.uk> | 2011-06-07 00:30:52 +0800 |
commit | 736b4f3d04f1e826dd8252fed88a7445b52ad461 (patch) | |
tree | e043a1787299eed54393477c1d540fe56710538c /libempathy-gtk/empathy-individual-linker.c | |
parent | faa40483fd000099a0593c09d0e92b938beaaaa7 (diff) | |
download | gsoc2013-empathy-736b4f3d04f1e826dd8252fed88a7445b52ad461.tar gsoc2013-empathy-736b4f3d04f1e826dd8252fed88a7445b52ad461.tar.gz gsoc2013-empathy-736b4f3d04f1e826dd8252fed88a7445b52ad461.tar.bz2 gsoc2013-empathy-736b4f3d04f1e826dd8252fed88a7445b52ad461.tar.lz gsoc2013-empathy-736b4f3d04f1e826dd8252fed88a7445b52ad461.tar.xz gsoc2013-empathy-736b4f3d04f1e826dd8252fed88a7445b52ad461.tar.zst gsoc2013-empathy-736b4f3d04f1e826dd8252fed88a7445b52ad461.zip |
Adapt to API break in folks_individual_get_personas.
Helps: bgo#648822 - Port Empathy to Folks 0.5.1
Diffstat (limited to 'libempathy-gtk/empathy-individual-linker.c')
-rw-r--r-- | libempathy-gtk/empathy-individual-linker.c | 70 |
1 files changed, 43 insertions, 27 deletions
diff --git a/libempathy-gtk/empathy-individual-linker.c b/libempathy-gtk/empathy-individual-linker.c index a291a6dee..3a1551a70 100644 --- a/libempathy-gtk/empathy-individual-linker.c +++ b/libempathy-gtk/empathy-individual-linker.c @@ -141,21 +141,34 @@ link_individual (EmpathyIndividualLinker *self, FolksIndividual *individual) { EmpathyIndividualLinkerPriv *priv = GET_PRIV (self); - GList *new_persona_list; + GeeSet *old_personas, *new_personas; + GeeHashSet *final_personas; + gboolean personas_changed; /* Add the individual to the link */ g_hash_table_insert (priv->changed_individuals, individual, GUINT_TO_POINTER (TRUE)); - /* Add personas which are in @individual to priv->new_individual, appending - * them to the list of personas. - * This is rather slow. */ - new_persona_list = g_list_copy (folks_individual_get_personas ( - priv->new_individual)); - new_persona_list = g_list_concat (new_persona_list, - g_list_copy (folks_individual_get_personas (individual))); - folks_individual_set_personas (priv->new_individual, new_persona_list); - g_list_free (new_persona_list); + /* Add personas which are in @individual to priv->new_individual, adding them + * to the set of personas. */ + old_personas = folks_individual_get_personas (individual); + new_personas = folks_individual_get_personas (priv->new_individual); + final_personas = gee_hash_set_new (FOLKS_TYPE_PERSONA, g_object_ref, + g_object_unref, g_direct_hash, g_direct_equal); + gee_collection_add_all (GEE_COLLECTION (final_personas), + GEE_COLLECTION (old_personas)); + personas_changed = gee_collection_add_all (GEE_COLLECTION (final_personas), + GEE_COLLECTION (new_personas)); + + /* avoid updating all values in the Individual if the set of personas doesn't + * actually change */ + if (personas_changed) + { + folks_individual_set_personas (priv->new_individual, + GEE_SET (final_personas)); + } + + g_clear_object (&final_personas); /* Update the toggle renderers, so that if this Individual is listed in * another group in the EmpathyIndividualView, the toggle button for that @@ -170,28 +183,31 @@ unlink_individual (EmpathyIndividualLinker *self, FolksIndividual *individual) { EmpathyIndividualLinkerPriv *priv = GET_PRIV (self); - GList *new_persona_list, *old_persona_list, *removing_personas, *l; + GeeSet *removed_personas, *old_personas; + GeeHashSet *final_personas; + gboolean personas_changed; /* Remove the individual from the link */ g_hash_table_remove (priv->changed_individuals, individual); - /* Remove personas which are in @individual from priv->new_individual. - * This is rather slow. */ - old_persona_list = folks_individual_get_personas (priv->new_individual); - removing_personas = folks_individual_get_personas (individual); - new_persona_list = NULL; + /* Remove personas which are in @individual from priv->new_individual. */ + old_personas = folks_individual_get_personas (priv->new_individual); + removed_personas = folks_individual_get_personas (individual); - for (l = old_persona_list; l != NULL; l = l->next) - { - GList *removing = g_list_find (removing_personas, l->data); + final_personas = gee_hash_set_new (FOLKS_TYPE_PERSONA, g_object_ref, + g_object_unref, g_direct_hash, g_direct_equal); + gee_collection_add_all (GEE_COLLECTION (final_personas), + GEE_COLLECTION (old_personas)); + personas_changed = gee_collection_remove_all (GEE_COLLECTION (final_personas), + GEE_COLLECTION (removed_personas)); - if (removing == NULL) - new_persona_list = g_list_prepend (new_persona_list, l->data); + if (personas_changed) + { + folks_individual_set_personas (priv->new_individual, + GEE_SET (final_personas)); } - new_persona_list = g_list_reverse (new_persona_list); - folks_individual_set_personas (priv->new_individual, new_persona_list); - g_list_free (new_persona_list); + g_clear_object (&final_personas); /* Update the toggle renderers, so that if this Individual is listed in * another group in the EmpathyIndividualView, the toggle button for that @@ -732,14 +748,14 @@ empathy_individual_linker_set_start_individual (EmpathyIndividualLinker *self, * * The return value is guaranteed to contain at least one element. * - * Return value: (transfer none) (element-type Folks.Persona): a list of + * Return value: (transfer none) (element-type Folks.Persona): a set of * #FolksPersona<!-- -->s to link together */ -GList * +GeeSet * empathy_individual_linker_get_linked_personas (EmpathyIndividualLinker *self) { EmpathyIndividualLinkerPriv *priv; - GList *personas; + GeeSet *personas; g_return_val_if_fail (EMPATHY_IS_INDIVIDUAL_LINKER (self), NULL); |