[empathy] empathy-roster-model: New virtual method _get_groups_for_individual empathy-roster-model-manager: im
- From: Guillaume Desmottes <gdesmott src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [empathy] empathy-roster-model: New virtual method _get_groups_for_individual empathy-roster-model-manager: im
- Date: Mon, 23 Jul 2012 14:11:45 +0000 (UTC)
commit f7200ee068d8f959608521737872254f20c5ee55
Author: Laurent Contzen <lcontzen gmail com>
Date: Wed Jul 4 15:29:41 2012 +0200
empathy-roster-model: New virtual method _get_groups_for_individual empathy-roster-model-manager: implemented _get_groups_for_individual empathy-roster-view.c: using _get_groups_for_individual
https://bugzilla.gnome.org/show_bug.cgi?id=680302
libempathy-gtk/empathy-roster-model-manager.c | 27 ++++++++++++++++++++++--
libempathy-gtk/empathy-roster-model.c | 14 +++++++++++++
libempathy-gtk/empathy-roster-model.h | 5 ++++
libempathy-gtk/empathy-roster-view.c | 22 +++++++-------------
4 files changed, 51 insertions(+), 17 deletions(-)
---
diff --git a/libempathy-gtk/empathy-roster-model-manager.c b/libempathy-gtk/empathy-roster-model-manager.c
index 2684d27..7d74732 100644
--- a/libempathy-gtk/empathy-roster-model-manager.c
+++ b/libempathy-gtk/empathy-roster-model-manager.c
@@ -85,9 +85,7 @@ groups_changed_cb (EmpathyIndividualManager *manager,
EmpathyRosterModelManager *self)
{
empathy_roster_model_fire_groups_changed (EMPATHY_ROSTER_MODEL (self),
- individual,
- group,
- is_member);
+ individual, group, is_member);
}
static void
@@ -218,8 +216,31 @@ empathy_roster_model_manager_get_individuals (EmpathyRosterModel *model)
return empathy_individual_manager_get_members (self->priv->manager);
}
+static GList *
+empathy_roster_model_manager_get_groups_for_individual (EmpathyRosterModel *model,
+ FolksIndividual *individual)
+{
+ GList *groups_list = NULL;
+ GeeSet *groups_set;
+
+ groups_set = folks_group_details_get_groups (FOLKS_GROUP_DETAILS (individual));
+ if (gee_collection_get_size (GEE_COLLECTION (groups_set)) > 0)
+ {
+ GeeIterator *iter = gee_iterable_iterator (GEE_ITERABLE (groups_set));
+
+ while (iter != NULL && gee_iterator_next (iter))
+ {
+ groups_list = g_list_prepend (groups_list, gee_iterator_get (iter));
+ }
+ g_clear_object (&iter);
+ }
+
+ return groups_list;
+}
+
static void
roster_model_iface_init (EmpathyRosterModelInterface *iface)
{
iface->get_individuals = empathy_roster_model_manager_get_individuals;
+ iface->get_groups_for_individual = empathy_roster_model_manager_get_groups_for_individual;
}
diff --git a/libempathy-gtk/empathy-roster-model.c b/libempathy-gtk/empathy-roster-model.c
index eaceca5..d8671f2 100644
--- a/libempathy-gtk/empathy-roster-model.c
+++ b/libempathy-gtk/empathy-roster-model.c
@@ -102,3 +102,17 @@ empathy_roster_model_get_individuals (EmpathyRosterModel *self)
return (* iface->get_individuals) (self);
}
+
+GList *
+empathy_roster_model_get_groups_for_individual (EmpathyRosterModel *self,
+ FolksIndividual *individual)
+{
+ EmpathyRosterModelInterface *iface;
+
+ g_return_val_if_fail (EMPATHY_IS_ROSTER_MODEL (self), NULL);
+
+ iface = EMPATHY_ROSTER_MODEL_GET_IFACE (self);
+ g_return_val_if_fail (iface->get_groups_for_individual != NULL, NULL);
+
+ return (* iface->get_groups_for_individual) (self, individual);
+}
diff --git a/libempathy-gtk/empathy-roster-model.h b/libempathy-gtk/empathy-roster-model.h
index 59db96f..9d60008 100644
--- a/libempathy-gtk/empathy-roster-model.h
+++ b/libempathy-gtk/empathy-roster-model.h
@@ -36,6 +36,8 @@ struct _EmpathyRosterModelInterface
/* Virtual table */
GList * (* get_individuals) (EmpathyRosterModel *self);
+ GList * (*get_groups_for_individual) (EmpathyRosterModel *self,
+ FolksIndividual *individual);
};
GType empathy_roster_model_get_type (void);
@@ -71,6 +73,9 @@ void empathy_roster_model_fire_groups_changed (EmpathyRosterModel *self,
/* Public API */
GList * empathy_roster_model_get_individuals (EmpathyRosterModel *self);
+GList * empathy_roster_model_get_groups_for_individual (EmpathyRosterModel *self,
+ FolksIndividual *individual);
+
G_END_DECLS
#endif /* #ifndef __EMPATHY_ROSTER_MODEL_H__*/
diff --git a/libempathy-gtk/empathy-roster-view.c b/libempathy-gtk/empathy-roster-view.c
index b07a4b2..42b8afe 100644
--- a/libempathy-gtk/empathy-roster-view.c
+++ b/libempathy-gtk/empathy-roster-view.c
@@ -338,7 +338,7 @@ individual_added (EmpathyRosterView *self,
}
else
{
- GeeSet *groups;
+ GList *groups, *l;
GList *tops;
tops = empathy_individual_manager_get_top_individuals (
@@ -351,29 +351,23 @@ individual_added (EmpathyRosterView *self,
add_to_group (self, individual, EMPATHY_ROSTER_VIEW_GROUP_TOP_GROUP);
}
- groups = folks_group_details_get_groups (
- FOLKS_GROUP_DETAILS (individual));
+ groups = empathy_roster_model_get_groups_for_individual (self->priv->model,
+ individual);
- if (gee_collection_get_size (GEE_COLLECTION (groups)) > 0)
+ if (g_list_length (groups) > 0)
{
- GeeIterator *iter = gee_iterable_iterator (GEE_ITERABLE (groups));
-
- while (iter != NULL && gee_iterator_next (iter))
+ for (l = groups; l != NULL; l = g_list_next (l))
{
- gchar *group = gee_iterator_get (iter);
-
- add_to_group (self, individual, group);
-
- g_free (group);
+ add_to_group (self, individual, l->data);
}
-
- g_clear_object (&iter);
}
else
{
/* No group, adds to Ungrouped */
add_to_group (self, individual, EMPATHY_ROSTER_VIEW_GROUP_UNGROUPED);
}
+
+ g_list_free (groups);
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]