aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGuillaume Desmottes <guillaume.desmottes@collabora.co.uk>2012-09-27 18:31:06 +0800
committerGuillaume Desmottes <guillaume.desmottes@collabora.co.uk>2012-10-03 18:04:15 +0800
commit11e0514f64c70770393f22b410c9e23153c132b3 (patch)
tree566393027c3f57f2551642f240576ad9ba450ddd
parent197e45140f3d79cca9bb3290b094a7055de24f74 (diff)
downloadgsoc2013-empathy-11e0514f64c70770393f22b410c9e23153c132b3.tar
gsoc2013-empathy-11e0514f64c70770393f22b410c9e23153c132b3.tar.gz
gsoc2013-empathy-11e0514f64c70770393f22b410c9e23153c132b3.tar.bz2
gsoc2013-empathy-11e0514f64c70770393f22b410c9e23153c132b3.tar.lz
gsoc2013-empathy-11e0514f64c70770393f22b410c9e23153c132b3.tar.xz
gsoc2013-empathy-11e0514f64c70770393f22b410c9e23153c132b3.tar.zst
gsoc2013-empathy-11e0514f64c70770393f22b410c9e23153c132b3.zip
chat-window: load the individual mgr when the chat window is focused out
Dirty hack to cope with Folks being slow as hell and blocking the main loop while preparing.
-rw-r--r--src/empathy-chat-window.c46
1 files changed, 35 insertions, 11 deletions
diff --git a/src/empathy-chat-window.c b/src/empathy-chat-window.c
index edc654796..9dfe225b0 100644
--- a/src/empathy-chat-window.c
+++ b/src/empathy-chat-window.c
@@ -1915,6 +1915,34 @@ chat_window_focus_in_event_cb (GtkWidget *widget,
}
static gboolean
+chat_window_focus_out_event_cb (GtkWidget *widget,
+ GdkEvent *event,
+ EmpathyChatWindow *self)
+{
+ if (self->priv->individual_mgr != NULL)
+ return FALSE;
+
+ /* Keep the individual manager alive so we won't fetch everything from Folks
+ * each time we need to use it. Loading FolksAggregator can takes quite a
+ * while (if user has a huge LDAP abook for example) and it blocks
+ * the mainloop during most of this loading. We workaround this by loading
+ * it when the chat window has been unfocused and so, hopefully, not impact
+ * the reactivity of the chat window too much.
+ *
+ * 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 ();
+
+ return FALSE;
+}
+
+static gboolean
chat_window_drag_drop (GtkWidget *widget,
GdkDragContext *context,
int x,
@@ -2033,6 +2061,11 @@ drag_data_received_individual_id (EmpathyChatWindow *self,
goto out;
}
+ if (self->priv->individual_mgr == NULL)
+ /* Not likely as we have to focus out the chat window in order to start
+ * the DnD but best to be safe. */
+ goto out;
+
individual = empathy_individual_manager_lookup_member (
self->priv->individual_mgr, id);
if (individual == NULL)
@@ -2330,17 +2363,6 @@ 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 ();
@@ -2395,6 +2417,8 @@ empathy_chat_window_init (EmpathyChatWindow *self)
G_CALLBACK (chat_window_delete_event_cb), self);
g_signal_connect (self->priv->dialog, "focus_in_event",
G_CALLBACK (chat_window_focus_in_event_cb), self);
+ g_signal_connect (self->priv->dialog, "focus_out_event",
+ G_CALLBACK (chat_window_focus_out_event_cb), self);
g_signal_connect_after (self->priv->notebook, "switch_page",
G_CALLBACK (chat_window_page_switched_cb), self);
g_signal_connect (self->priv->notebook, "page_added",