]> git.0d.be Git - empathy.git/commitdiff
log-window: wait that the accounts chooser is ready before selecting the chat
authorGuillaume Desmottes <guillaume.desmottes@collabora.co.uk>
Fri, 13 Nov 2009 15:37:03 +0000 (15:37 +0000)
committerGuillaume Desmottes <guillaume.desmottes@collabora.co.uk>
Mon, 16 Nov 2009 10:13:36 +0000 (10:13 +0000)
If we don't wait, the combobox is empty and so
log_window_chats_set_selected can't find the chat (#601807).

libempathy-gtk/empathy-log-window.c

index 247a99806e737c1ea9a61280ba61ee9cd18ddeff..f6f6ef17f8691eca02505082dd546f65e9c205ac 100644 (file)
@@ -72,6 +72,11 @@ typedef struct {
        gchar             *last_find;
 
        EmpathyLogManager *log_manager;
        gchar             *last_find;
 
        EmpathyLogManager *log_manager;
+
+       /* Those are only used while waiting for the account chooser to be ready */
+       TpAccount         *selected_account;
+       gchar             *selected_chat_id;
+       gboolean          selected_is_chatroom;
 } EmpathyLogWindow;
 
 static void     log_window_destroy_cb                      (GtkWidget        *widget,
 } EmpathyLogWindow;
 
 static void     log_window_destroy_cb                      (GtkWidget        *widget,
@@ -165,6 +170,15 @@ account_manager_prepared_cb (GObject *source_object,
        }
 }
 
        }
 }
 
+static void
+account_chooser_ready_cb (EmpathyAccountChooser *chooser,
+                       EmpathyLogWindow *window)
+{
+       gtk_notebook_set_current_page (GTK_NOTEBOOK (window->notebook), 1);
+       log_window_chats_set_selected (window, window->selected_account,
+                                      window->selected_chat_id, window->selected_is_chatroom);
+}
+
 GtkWidget *
 empathy_log_window_show (TpAccount  *account,
                        const gchar *chat_id,
 GtkWidget *
 empathy_log_window_show (TpAccount  *account,
                        const gchar *chat_id,
@@ -271,11 +285,13 @@ empathy_log_window_show (TpAccount  *account,
        log_window_chats_setup (window);
        log_window_chats_populate (window);
 
        log_window_chats_setup (window);
        log_window_chats_populate (window);
 
-       /* Select chat */
+       /* Chat will be selected once the account chooser is ready */
        if (account && chat_id) {
        if (account && chat_id) {
-               gtk_notebook_set_current_page (GTK_NOTEBOOK (window->notebook), 1);
-               log_window_chats_set_selected (window, account,
-                                              chat_id, is_chatroom);
+               g_signal_connect (account_chooser, "ready",
+                                 G_CALLBACK (account_chooser_ready_cb), window);
+               window->selected_account = account;
+               window->selected_chat_id = g_strdup (chat_id);
+               window->selected_is_chatroom = is_chatroom;
        }
 
        if (parent) {
        }
 
        if (parent) {
@@ -294,6 +310,7 @@ log_window_destroy_cb (GtkWidget       *widget,
 {
        g_free (window->last_find);
        g_object_unref (window->log_manager);
 {
        g_free (window->last_find);
        g_object_unref (window->log_manager);
+       g_free (window->selected_chat_id);
 
        g_free (window);
 }
 
        g_free (window);
 }