diff options
author | Guillaume Desmottes <guillaume.desmottes@collabora.co.uk> | 2012-09-28 14:38:14 +0800 |
---|---|---|
committer | Guillaume Desmottes <guillaume.desmottes@collabora.co.uk> | 2012-10-03 18:05:43 +0800 |
commit | 5206421264c993ab34599c63b3744e4a7f9e075a (patch) | |
tree | 6ae5ec1453f6c08196c7f2f848711abe5d98139f /src/empathy-chat-manager.c | |
parent | 257011e356f9f293e5df5032159b9e79cf70d9d6 (diff) | |
download | gsoc2013-empathy-5206421264c993ab34599c63b3744e4a7f9e075a.tar gsoc2013-empathy-5206421264c993ab34599c63b3744e4a7f9e075a.tar.gz gsoc2013-empathy-5206421264c993ab34599c63b3744e4a7f9e075a.tar.bz2 gsoc2013-empathy-5206421264c993ab34599c63b3744e4a7f9e075a.tar.lz gsoc2013-empathy-5206421264c993ab34599c63b3744e4a7f9e075a.tar.xz gsoc2013-empathy-5206421264c993ab34599c63b3744e4a7f9e075a.tar.zst gsoc2013-empathy-5206421264c993ab34599c63b3744e4a7f9e075a.zip |
chat-manager: cache the individual mgr
We want to keep it alive during the whole lifetime of empathy-chat.
Diffstat (limited to 'src/empathy-chat-manager.c')
-rw-r--r-- | src/empathy-chat-manager.c | 32 |
1 files changed, 31 insertions, 1 deletions
diff --git a/src/empathy-chat-manager.c b/src/empathy-chat-manager.c index 6a163aaae..f93b90235 100644 --- a/src/empathy-chat-manager.c +++ b/src/empathy-chat-manager.c @@ -25,6 +25,7 @@ #include <libempathy/empathy-chatroom-manager.h> #include <libempathy/empathy-request-util.h> #include <libempathy/empathy-utils.h> +#include <libempathy/empathy-individual-manager.h> #include <libempathy-gtk/empathy-ui-utils.h> @@ -70,6 +71,11 @@ struct _EmpathyChatManagerPriv GHashTable *messages; TpBaseClient *handler; + + /* Cached to keep Folks in memory while empathy-chat is running; we don't + * want to reload it each time the last chat window is closed + * and re-opened. */ + EmpathyIndividualManager *individual_mgr; }; #define GET_PRIV(o) \ @@ -152,6 +158,20 @@ join_cb (GObject *source, } static void +individual_mgr_cb (EmpathyChatWindow *window, + GParamSpec *spec, + EmpathyChatManager *self) +{ + EmpathyChatManagerPriv *priv = GET_PRIV (self); + + if (priv->individual_mgr != NULL) + return; + + priv->individual_mgr = empathy_chat_window_get_individual_manager (window); + g_object_ref (priv->individual_mgr); +} + +static void process_tp_chat (EmpathyChatManager *self, EmpathyTpChat *tp_chat, TpAccount *account, @@ -160,6 +180,7 @@ process_tp_chat (EmpathyChatManager *self, EmpathyChatManagerPriv *priv = GET_PRIV (self); EmpathyChat *chat = NULL; const gchar *id; + EmpathyChatWindow *window; id = empathy_tp_chat_get_id (tp_chat); if (!tp_str_empty (id)) @@ -203,7 +224,15 @@ process_tp_chat (EmpathyChatManager *self, g_object_weak_ref ((GObject *) chat, chat_destroyed_cb, self); } - empathy_chat_window_present_chat (chat, user_action_time); + + window = empathy_chat_window_present_chat (chat, user_action_time); + + if (priv->individual_mgr == NULL) + { + /* We want to cache it as soon it's created */ + tp_g_signal_connect_object (window, "notify::individual-manager", + G_CALLBACK (individual_mgr_cb), self, 0); + } if (empathy_tp_chat_is_invited (tp_chat, NULL)) { @@ -308,6 +337,7 @@ empathy_chat_manager_finalize (GObject *object) tp_clear_object (&priv->handler); tp_clear_object (&priv->chatroom_mgr); + tp_clear_object (&priv->individual_mgr); G_OBJECT_CLASS (empathy_chat_manager_parent_class)->finalize (object); } |