[empathy] Use the new FolksFavourite interface for favourites support



commit 315a71325f98d86722d7c313d726828f767cef82
Author: Philip Withnall <philip withnall collabora co uk>
Date:   Wed Jun 23 16:46:38 2010 +0100

    Use the new FolksFavourite interface for favourites support

 libempathy-gtk/empathy-individual-menu.c  |    9 +++------
 libempathy-gtk/empathy-individual-store.c |    4 +---
 libempathy-gtk/empathy-individual-view.c  |    2 ++
 libempathy/empathy-individual-manager.c   |   28 ++++------------------------
 libempathy/empathy-individual-manager.h   |    4 ----
 5 files changed, 10 insertions(+), 37 deletions(-)
---
diff --git a/libempathy-gtk/empathy-individual-menu.c b/libempathy-gtk/empathy-individual-menu.c
index 98afbc5..c618d2c 100644
--- a/libempathy-gtk/empathy-individual-menu.c
+++ b/libempathy-gtk/empathy-individual-menu.c
@@ -516,10 +516,8 @@ favourite_menu_item_toggled_cb (GtkCheckMenuItem *item,
   manager = empathy_individual_manager_dup_singleton ();
   list = EMPATHY_INDIVIDUAL_MANAGER (manager);
 
-  if (gtk_check_menu_item_get_active (item))
-    empathy_individual_manager_add_to_favourites (list, individual);
-  else
-    empathy_individual_manager_remove_from_favourites (list, individual);
+  folks_favourite_set_is_favourite (FOLKS_FAVOURITE (individual),
+      gtk_check_menu_item_get_active (item));
 
   g_object_unref (manager);
 }
@@ -534,8 +532,7 @@ empathy_individual_favourite_menu_item_new (FolksIndividual *individual)
 
   manager = empathy_individual_manager_dup_singleton ();
   gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (item),
-      empathy_individual_manager_is_favourite (
-          EMPATHY_INDIVIDUAL_MANAGER (manager), individual));
+      folks_favourite_get_is_favourite (FOLKS_FAVOURITE (individual)));
 
   g_signal_connect (item, "toggled",
       G_CALLBACK (favourite_menu_item_toggled_cb), individual);
diff --git a/libempathy-gtk/empathy-individual-store.c b/libempathy-gtk/empathy-individual-store.c
index 1931106..976053c 100644
--- a/libempathy-gtk/empathy-individual-store.c
+++ b/libempathy-gtk/empathy-individual-store.c
@@ -412,9 +412,8 @@ individual_store_add_individual (EmpathyIndividualStore *self,
   if (group_set != NULL)
     g_hash_table_unref (group_set);
 
-#ifdef HAVE_FAVOURITE_CONTACTS
   if (priv->show_groups &&
-      empathy_individual_manager_is_favourite (priv->manager, individual))
+      folks_favourite_get_is_favourite (FOLKS_FAVOURITE (individual)))
     {
       /* Add contact to the fake 'Favorites' group */
       GtkTreeIter iter_group;
@@ -425,7 +424,6 @@ individual_store_add_individual (EmpathyIndividualStore *self,
       add_individual_to_store (GTK_TREE_STORE (self), &iter, &iter_group,
           individual, flags);
     }
-#endif
 
   individual_store_contact_update (self, individual);
 }
diff --git a/libempathy-gtk/empathy-individual-view.c b/libempathy-gtk/empathy-individual-view.c
index 5a0a566..067fb60 100644
--- a/libempathy-gtk/empathy-individual-view.c
+++ b/libempathy-gtk/empathy-individual-view.c
@@ -345,6 +345,7 @@ individual_view_handle_drag (EmpathyIndividualView *self,
   if (!tp_strdiff (new_group, EMPATHY_INDIVIDUAL_STORE_FAVORITE))
     {
       /* Mark contact as favourite */
+      folks_favourite_set_is_favourite (FOLKS_FAVOURITE (individual), TRUE);
 
       /* TODO: implement this */
       DEBUG ("adding individual to favourites not fully implemented");
@@ -355,6 +356,7 @@ individual_view_handle_drag (EmpathyIndividualView *self,
   if (!tp_strdiff (old_group, EMPATHY_INDIVIDUAL_STORE_FAVORITE))
     {
       /* Remove contact as favourite */
+      folks_favourite_set_is_favourite (FOLKS_FAVOURITE (individual), FALSE);
 
       /* TODO: implement this */
       DEBUG ("removing individual from favourites not fully " "implemented");
diff --git a/libempathy/empathy-individual-manager.c b/libempathy/empathy-individual-manager.c
index 0af191a..95955d6 100644
--- a/libempathy/empathy-individual-manager.c
+++ b/libempathy/empathy-individual-manager.c
@@ -48,10 +48,6 @@ typedef struct
   FolksIndividualAggregator *aggregator;
   EmpathyContactManager *contact_manager;
   TpProxy *logger;
-  /* account object path (gchar *) => GHashTable containing favorite contacts
-   * (contact ID (gchar *) => TRUE) */
-  GHashTable *favourites;
-  TpProxySignalConnection *favourite_contacts_changed_signal;
 } EmpathyIndividualManagerPriv;
 
 G_DEFINE_TYPE (EmpathyIndividualManager, empathy_individual_manager,
@@ -112,9 +108,6 @@ individual_manager_finalize (GObject *object)
 {
   EmpathyIndividualManagerPriv *priv = GET_PRIV (object);
 
-  tp_proxy_signal_connection_disconnect (
-      priv->favourite_contacts_changed_signal);
-
   if (priv->logger != NULL)
     g_object_unref (priv->logger);
 
@@ -123,8 +116,6 @@ individual_manager_finalize (GObject *object)
 
   if (priv->aggregator != NULL)
     g_object_unref (priv->aggregator);
-
-  g_hash_table_destroy (priv->favourites);
 }
 
 static GObject *
@@ -208,22 +199,11 @@ empathy_individual_manager_init (EmpathyIndividualManager *self)
   self->priv = priv;
   priv->contact_manager = empathy_contact_manager_dup_singleton ();
 
-  priv->favourites = g_hash_table_new_full (g_str_hash, g_str_equal,
-      (GDestroyNotify) g_free, (GDestroyNotify) g_hash_table_unref);
-
   priv->aggregator = folks_individual_aggregator_new ();
-  if (error == NULL)
-    {
-      g_signal_connect (priv->aggregator, "individuals-added",
-          G_CALLBACK (aggregator_individuals_added_cb), self);
-      g_signal_connect (priv->aggregator, "individuals-removed",
-          G_CALLBACK (aggregator_individuals_removed_cb), self);
-    }
-  else
-    {
-      DEBUG ("Failed to get individual aggregator: %s", error->message);
-      g_clear_error (&error);
-    }
+  g_signal_connect (priv->aggregator, "individuals-added",
+      G_CALLBACK (aggregator_individuals_added_cb), self);
+  g_signal_connect (priv->aggregator, "individuals-removed",
+      G_CALLBACK (aggregator_individuals_removed_cb), self);
 
   bus = tp_dbus_daemon_dup (&error);
 
diff --git a/libempathy/empathy-individual-manager.h b/libempathy/empathy-individual-manager.h
index be95ab3..030ea81 100644
--- a/libempathy/empathy-individual-manager.h
+++ b/libempathy/empathy-individual-manager.h
@@ -75,10 +75,6 @@ void empathy_individual_manager_remove (EmpathyIndividualManager *manager,
     FolksIndividual *individual,
     const gchar *message);
 
-gboolean empathy_individual_manager_is_favourite (
-    EmpathyIndividualManager *manager,
-    FolksIndividual *individual);
-
 EmpathyIndividualManagerFlags
 empathy_individual_manager_get_flags_for_connection (
     EmpathyIndividualManager *manager,



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]