]> git.0d.be Git - empathy.git/blobdiff - libempathy-gtk/empathy-groups-widget.c
Reorder header inclusions accordingly to the Telepathy coding style
[empathy.git] / libempathy-gtk / empathy-groups-widget.c
index fee9f8fdb6142e1478c17bf5e60c60d4d9143b49..d1a6febfade8829a1539ee2a1431781567e7e817 100644 (file)
  *          Philip Withnall <philip.withnall@collabora.co.uk>
  */
 
-#include <config.h>
-
-#include <string.h>
-#include <stdlib.h>
+#include "config.h"
+#include "empathy-groups-widget.h"
 
-#include <gtk/gtk.h>
 #include <glib/gi18n-lib.h>
 
-#include <telepathy-glib/util.h>
-
-#include <folks/folks.h>
-
-#include <libempathy/empathy-utils.h>
-#include <libempathy/empathy-contact-manager.h>
-
-#include "empathy-groups-widget.h"
-#include "empathy-ui-utils.h"
+#include "empathy-utils.h"
+#include "empathy-connection-aggregator.h"
 
 /**
  * SECTION:empathy-groups-widget
@@ -150,39 +140,36 @@ static void
 populate_data (EmpathyGroupsWidget *self)
 {
   EmpathyGroupsWidgetPriv *priv = GET_PRIV (self);
-  EmpathyContactManager *manager;
-  GtkTreeIter iter;
-  GHashTable *my_groups;
+  EmpathyConnectionAggregator *aggregator;
+  GeeSet *member_groups;
   GList *all_groups, *l;
 
   /* Remove the old groups */
   gtk_list_store_clear (priv->group_store);
 
-  /* FIXME: We have to get the whole group list from EmpathyContactManager, as
-   * libfolks hasn't grown API to get the whole group list yet. (bgo#627398) */
-  manager = empathy_contact_manager_dup_singleton ();
-  all_groups = empathy_contact_list_get_all_groups (
-      EMPATHY_CONTACT_LIST (manager));
-  g_object_unref (manager);
+  /* FIXME: We have to get the whole group list from
+   * EmpathyConnectionAggregator, as libfolks hasn't grown API to get the whole
+   * group list yet. (bgo#627398) */
+  aggregator = empathy_connection_aggregator_dup_singleton ();
+  all_groups = empathy_connection_aggregator_get_all_groups (aggregator);
+  g_object_unref (aggregator);
 
   /* Get the list of groups that this #FolksGroupDetails is currently in */
-  my_groups = folks_group_details_get_groups (priv->group_details);
+  member_groups = folks_group_details_get_groups (priv->group_details);
 
   for (l = all_groups; l != NULL; l = l->next)
     {
       const gchar *group_str = l->data;
       gboolean enabled;
 
-      enabled = GPOINTER_TO_UINT (g_hash_table_lookup (my_groups, group_str));
+      enabled = gee_collection_contains (GEE_COLLECTION (member_groups),
+          group_str);
 
-      gtk_list_store_append (priv->group_store, &iter);
-      gtk_list_store_set (priv->group_store, &iter,
+      gtk_list_store_insert_with_values (priv->group_store, NULL, -1,
           COL_NAME, group_str,
           COL_EDITABLE, TRUE,
           COL_ENABLED, enabled,
           -1);
-
-      g_free (l->data);
     }
 
   g_list_free (all_groups);
@@ -237,13 +224,11 @@ add_group_button_clicked_cb (GtkButton *button,
    EmpathyGroupsWidget *self)
 {
   EmpathyGroupsWidgetPriv *priv = GET_PRIV (self);
-  GtkTreeIter iter;
   const gchar *group;
 
   group = gtk_entry_get_text (GTK_ENTRY (priv->add_group_entry));
 
-  gtk_list_store_append (priv->group_store, &iter);
-  gtk_list_store_set (priv->group_store, &iter,
+  gtk_list_store_insert_with_values (priv->group_store, NULL, -1,
       COL_NAME, group,
       COL_ENABLED, TRUE,
       -1);
@@ -339,7 +324,7 @@ set_up (EmpathyGroupsWidget *self)
   alignment = gtk_alignment_new (0.5, 0.5, 1.0, 1.0);
   gtk_alignment_set_padding (GTK_ALIGNMENT (alignment), 0, 0, 12, 0);
 
-  vbox = GTK_BOX (gtk_vbox_new (FALSE, 6));
+  vbox = GTK_BOX (gtk_box_new (GTK_ORIENTATION_VERTICAL, 6));
 
   label = gtk_label_new (_("Select the groups you want this contact to appear "
       "in.  Note that you can select more than one group or no groups."));
@@ -349,7 +334,7 @@ set_up (EmpathyGroupsWidget *self)
   gtk_box_pack_start (vbox, label, FALSE, FALSE, 0);
   gtk_widget_show (label);
 
-  hbox = GTK_BOX (gtk_hbox_new (FALSE, 12));
+  hbox = GTK_BOX (gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 12));
 
   priv->add_group_entry = gtk_entry_new ();
   g_signal_connect (priv->add_group_entry, "changed",
@@ -468,10 +453,6 @@ set_property (GObject *object,
     const GValue *value,
     GParamSpec *pspec)
 {
-  EmpathyGroupsWidgetPriv *priv;
-
-  priv = GET_PRIV (object);
-
   switch (param_id)
     {
       case PROP_GROUP_DETAILS: