[empathy] move the individual mgr reference to empathy-chat-window



commit 197e45140f3d79cca9bb3290b094a7055de24f74
Author: Guillaume Desmottes <guillaume desmottes collabora co uk>
Date:   Thu Sep 27 12:22:04 2012 +0200

    move the individual mgr reference to empathy-chat-window
    
    The chat window is the one actually using the manager so it makes sense to
    move it there. It's a singleton so the same instance will be shared between
    windows anyway.

 src/empathy-chat-window.c |   20 +++++++++++++++-----
 src/empathy-chat.c        |   14 --------------
 2 files changed, 15 insertions(+), 19 deletions(-)
---
diff --git a/src/empathy-chat-window.c b/src/empathy-chat-window.c
index a8c5b6b..edc6547 100644
--- a/src/empathy-chat-window.c
+++ b/src/empathy-chat-window.c
@@ -75,6 +75,7 @@ struct _EmpathyChatWindowPriv
   gboolean dnd_same_window;
   EmpathyChatroomManager *chatroom_manager;
   EmpathyNotifyManager *notify_mgr;
+  EmpathyIndividualManager *individual_mgr;
   GtkWidget *dialog;
   GtkWidget *notebook;
   NotifyNotification *notification;
@@ -2008,7 +2009,6 @@ drag_data_received_individual_id (EmpathyChatWindow *self,
     guint time_)
 {
   const gchar *id;
-  EmpathyIndividualManager *manager = NULL;
   FolksIndividual *individual;
   EmpathyTpChat *chat;
   TpContact *tp_contact;
@@ -2033,9 +2033,8 @@ drag_data_received_individual_id (EmpathyChatWindow *self,
       goto out;
     }
 
-  manager = empathy_individual_manager_dup_singleton ();
-
-  individual = empathy_individual_manager_lookup_member (manager, id);
+  individual = empathy_individual_manager_lookup_member (
+          self->priv->individual_mgr, id);
   if (individual == NULL)
     {
       DEBUG ("Failed to find individual %s", id);
@@ -2060,7 +2059,6 @@ drag_data_received_individual_id (EmpathyChatWindow *self,
 
 out:
   gtk_drag_finish (context, TRUE, FALSE, time_);
-  tp_clear_object (&manager);
 }
 
 static void
@@ -2223,6 +2221,7 @@ chat_window_finalize (GObject *object)
   g_object_unref (self->priv->gsettings_notif);
   g_object_unref (self->priv->gsettings_ui);
   g_object_unref (self->priv->sound_mgr);
+  g_clear_object (&self->priv->individual_mgr);
 
   if (self->priv->notification != NULL)
     {
@@ -2331,6 +2330,17 @@ empathy_chat_window_init (EmpathyChatWindow *self)
   self->priv->gsettings_ui = g_settings_new (EMPATHY_PREFS_UI_SCHEMA);
   self->priv->chatroom_manager = empathy_chatroom_manager_dup_singleton (NULL);
 
+  /* Keep the individual manager alive so we won't fetch everything from Folks
+   * each time we need to use it. The individual manager (and so Folks) is
+   * needed to know to which FolksIndividual a TpContact belongs, including:
+   * - empathy_chat_get_contact_menu: to list all the personas of the contact
+   * - empathy_display_individual_info: to invoke gnome-contacts with the
+   *   FolksIndividual.id of the contact
+   * - drag_data_received_individual_id: to find the individual associated
+   *   with the ID we received from the DnD in order to invite him.
+   */
+  self->priv->individual_mgr = empathy_individual_manager_dup_singleton ();
+
   self->priv->sound_mgr = empathy_sound_manager_dup_singleton ();
 
   self->priv->notebook = gtk_notebook_new ();
diff --git a/src/empathy-chat.c b/src/empathy-chat.c
index 4da3f0a..da69a8e 100644
--- a/src/empathy-chat.c
+++ b/src/empathy-chat.c
@@ -29,7 +29,6 @@
 #include <libnotify/notify.h>
 
 #include <libempathy/empathy-presence-manager.h>
-#include <libempathy/empathy-individual-manager.h>
 
 #include <libempathy-gtk/empathy-theme-manager.h>
 #include <libempathy-gtk/empathy-ui-utils.h>
@@ -99,7 +98,6 @@ main (int argc,
   EmpathyPresenceManager *presence_mgr;
   EmpathyThemeManager *theme_mgr;
   gint retval;
-  EmpathyIndividualManager *individual_mgr;
 
   optcontext = g_option_context_new (N_("- Empathy Chat Client"));
   g_option_context_add_group (optcontext, gtk_get_option_group (TRUE));
@@ -141,17 +139,6 @@ main (int argc,
   /* Keep the theme manager alive as it does some caching */
   theme_mgr = empathy_theme_manager_dup_singleton ();
 
-  /* Keep the individual manager alive so we won't fetch everything from Folks
-   * each time we need to use it. The individual manager (and so Folks) is
-   * needed to know to which FolksIndividual a TpContact belongs, including:
-   * - empathy_chat_get_contact_menu: to list all the personas of the contact
-   * - empathy_display_individual_info: to invoke gnome-contacts with the
-   *   FolksIndividual.id of the contact
-   * - chat-window:drag_data_received_individual_id: to find the individual
-   *   associated with the ID we received from the DnD in order to invite him.
-   */
-  individual_mgr = empathy_individual_manager_dup_singleton ();
-
   if (g_getenv ("EMPATHY_PERSIST") != NULL)
     {
       DEBUG ("Disable timer");
@@ -172,7 +159,6 @@ main (int argc,
   g_object_unref (presence_mgr);
   g_object_unref (theme_mgr);
   tp_clear_object (&chat_mgr);
-  g_object_unref (individual_mgr);
 
 #ifdef ENABLE_DEBUG
   g_object_unref (debug_sender);



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