]> git.0d.be Git - empathy.git/commitdiff
chat-window: load the individual mgr when the chat window is focused out
authorGuillaume Desmottes <guillaume.desmottes@collabora.co.uk>
Thu, 27 Sep 2012 10:31:06 +0000 (12:31 +0200)
committerGuillaume Desmottes <guillaume.desmottes@collabora.co.uk>
Wed, 3 Oct 2012 10:04:15 +0000 (12:04 +0200)
Dirty hack to cope with Folks being slow as hell and blocking the main loop
while preparing.

src/empathy-chat-window.c

index edc654796c503ebcc6ca685de08c4cc9f28edd73..9dfe225b0cb49101d8611a8c7528b64f114e9a18 100644 (file)
@@ -1914,6 +1914,34 @@ chat_window_focus_in_event_cb (GtkWidget *widget,
   return FALSE;
 }
 
+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,
@@ -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",