diff options
author | Guillaume Desmottes <guillaume.desmottes@collabora.co.uk> | 2012-05-25 21:21:46 +0800 |
---|---|---|
committer | Guillaume Desmottes <guillaume.desmottes@collabora.co.uk> | 2012-06-14 15:21:48 +0800 |
commit | ad12e6ef47f56a291e9cc46496a5f27620701242 (patch) | |
tree | be69a9afbb14a88eebc80d01e7152105cb2286a4 | |
parent | cdb76a5ad9845785bc29fe67533201489f2adbea (diff) | |
download | gsoc2013-empathy-ad12e6ef47f56a291e9cc46496a5f27620701242.tar gsoc2013-empathy-ad12e6ef47f56a291e9cc46496a5f27620701242.tar.gz gsoc2013-empathy-ad12e6ef47f56a291e9cc46496a5f27620701242.tar.bz2 gsoc2013-empathy-ad12e6ef47f56a291e9cc46496a5f27620701242.tar.lz gsoc2013-empathy-ad12e6ef47f56a291e9cc46496a5f27620701242.tar.xz gsoc2013-empathy-ad12e6ef47f56a291e9cc46496a5f27620701242.tar.zst gsoc2013-empathy-ad12e6ef47f56a291e9cc46496a5f27620701242.zip |
roster-view: allow to store more than one widget per Individual
With groups we may have more than once the same individual in the list.
-rw-r--r-- | libempathy-gtk/empathy-roster-view.c | 32 |
1 files changed, 23 insertions, 9 deletions
diff --git a/libempathy-gtk/empathy-roster-view.c b/libempathy-gtk/empathy-roster-view.c index 09d59517f..eff7fbdbb 100644 --- a/libempathy-gtk/empathy-roster-view.c +++ b/libempathy-gtk/empathy-roster-view.c @@ -28,7 +28,8 @@ struct _EmpathyRosterViewPriv { EmpathyIndividualManager *manager; - /* FolksIndividual (borrowed) -> EmpathyRosterContact (borrowed) */ + /* FolksIndividual (borrowed) -> GHashTable (used as a set) of + * EmpathyRosterContact (borrowed) */ GHashTable *roster_contacts; gboolean show_offline; @@ -121,27 +122,39 @@ individual_added (EmpathyRosterView *self, FolksIndividual *individual) { GtkWidget *contact; + GHashTable *contacts; - contact = g_hash_table_lookup (self->priv->roster_contacts, individual); - if (contact != NULL) + contacts = g_hash_table_lookup (self->priv->roster_contacts, individual); + if (contacts != NULL) return; + contacts = g_hash_table_new (NULL, NULL); + contact = add_roster_contact (self, individual); + g_hash_table_add (contacts, contact); - g_hash_table_insert (self->priv->roster_contacts, individual, contact); + g_hash_table_insert (self->priv->roster_contacts, individual, contacts); } static void individual_removed (EmpathyRosterView *self, FolksIndividual *individual) { - GtkWidget *contact; + GHashTable *contacts; + GHashTableIter iter; + gpointer key; - contact = g_hash_table_lookup (self->priv->roster_contacts, individual); - if (contact == NULL) + contacts = g_hash_table_lookup (self->priv->roster_contacts, individual); + if (contacts == NULL) return; - gtk_container_remove (GTK_CONTAINER (self), contact); + g_hash_table_iter_init (&iter, contacts); + while (g_hash_table_iter_next (&iter, &key, NULL)) + { + GtkWidget *contact = key; + + gtk_container_remove (GTK_CONTAINER (self), contact); + } g_hash_table_remove (self->priv->roster_contacts, individual); } @@ -329,7 +342,8 @@ empathy_roster_view_init (EmpathyRosterView *self) self->priv = G_TYPE_INSTANCE_GET_PRIVATE (self, EMPATHY_TYPE_ROSTER_VIEW, EmpathyRosterViewPriv); - self->priv->roster_contacts = g_hash_table_new (NULL, NULL); + self->priv->roster_contacts = g_hash_table_new_full (NULL, NULL, + NULL, (GDestroyNotify) g_hash_table_unref); } GtkWidget * |