]> git.0d.be Git - empathy.git/commitdiff
Re-enable changing individuals' groups
authorPhilip Withnall <philip.withnall@collabora.co.uk>
Fri, 2 Jul 2010 10:29:05 +0000 (11:29 +0100)
committerTravis Reitter <treitter@gmail.com>
Tue, 20 Jul 2010 23:12:36 +0000 (16:12 -0700)
This introduces a hacky function to return the individual for a given
EmpathyContact, which should go away once we break the assumption that
individuals are 1:1 with contacts.

libempathy-gtk/empathy-contact-widget.c
libempathy/empathy-utils.c
libempathy/empathy-utils.h

index 0241281515c6bc6c2b6f59f383cabb6afda6a142..82b6381828d5a8fd6931423f79d8c4f719123a16 100644 (file)
@@ -579,18 +579,15 @@ contact_widget_cell_toggled (GtkCellRendererToggle *cell,
 
   if (group)
     {
-      if (enabled)
-        {
-          empathy_contact_list_remove_from_group (
-              EMPATHY_CONTACT_LIST (information->manager), information->contact,
-              group);
-        }
-      else
+      FolksIndividual *individual = folks_individual_from_empathy_contact (
+          information->contact);
+
+      if (individual)
         {
-          empathy_contact_list_add_to_group (
-              EMPATHY_CONTACT_LIST (information->manager), information->contact,
-              group);
+          folks_groups_change_group (FOLKS_GROUPS (individual), group, !enabled);
+          g_object_unref (individual);
         }
+
       g_free (group);
     }
 }
@@ -797,6 +794,7 @@ contact_widget_button_group_clicked_cb (GtkButton *button,
   GtkTreeView *view;
   GtkListStore *store;
   GtkTreeIter iter;
+  FolksIndividual *individual;
   const gchar *group;
 
   view = GTK_TREE_VIEW (information->treeview_groups);
@@ -810,9 +808,13 @@ contact_widget_button_group_clicked_cb (GtkButton *button,
       COL_ENABLED, TRUE,
       -1);
 
-  empathy_contact_list_add_to_group (
-      EMPATHY_CONTACT_LIST (information->manager), information->contact,
-      group);
+  individual = folks_individual_from_empathy_contact (information->contact);
+
+  if (individual)
+    {
+      folks_groups_change_group (FOLKS_GROUPS (individual), group, TRUE);
+      g_object_unref (individual);
+    }
 }
 
 static void
index d80aad57377ccd146b84bc13bc84588f35c9b83a..ddf56f7088a1e55ad32a6ba4f7c23b851a58be7b 100644 (file)
@@ -43,6 +43,7 @@
 
 #include "empathy-utils.h"
 #include "empathy-contact-manager.h"
+#include "empathy-individual-manager.h"
 #include "empathy-dispatcher.h"
 #include "empathy-dispatch-operation.h"
 #include "empathy-idle.h"
@@ -620,3 +621,31 @@ empathy_contact_from_folks_individual (FolksIndividual *individual)
 
   return contact;
 }
+
+/* TODO: This also needs to be eliminated, and is horrifically slow. */
+FolksIndividual *
+folks_individual_from_empathy_contact (EmpathyContact *contact)
+{
+  EmpathyIndividualManager *manager;
+  FolksIndividual *individual = NULL;
+  GList *individuals, *l;
+
+  manager = empathy_individual_manager_dup_singleton ();
+  individuals = empathy_individual_manager_get_members (manager);
+
+  for (l = individuals; (l != NULL) && (individual == NULL); l = l->next)
+    {
+      FolksIndividual *i = FOLKS_INDIVIDUAL (l->data);
+      EmpathyContact *c = empathy_contact_from_folks_individual (i);
+
+      if (c == contact)
+        individual = g_object_ref (i);
+
+      g_object_unref (c);
+    }
+
+  g_list_free (individuals);
+  g_object_unref (manager);
+
+  return individual;
+}
index c6de97a8fdb4c1acb21e5b66c27d8ff0ad0d4a4b..a07f575d8dec61fc92c3c10101454c7644c0586c 100644 (file)
@@ -93,6 +93,7 @@ void empathy_connect_new_account (TpAccount *account,
 TpConnectionPresenceType empathy_folks_presence_type_to_tp (FolksPresenceType type);
 gboolean empathy_folks_individual_contains_contact (FolksIndividual *individual);
 EmpathyContact * empathy_contact_from_folks_individual (FolksIndividual *individual);
+FolksIndividual *folks_individual_from_empathy_contact (EmpathyContact *contact);
 
 G_END_DECLS