[empathy] log-window: wait that the accounts chooser is ready before selecting the chat



commit dc392002e18aad2efd7806f84ac94a94fa28cd61
Author: Guillaume Desmottes <guillaume desmottes collabora co uk>
Date:   Fri Nov 13 15:37:03 2009 +0000

    log-window: wait that the accounts chooser is ready before selecting the chat
    
    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 |   25 +++++++++++++++++++++----
 1 files changed, 21 insertions(+), 4 deletions(-)
---
diff --git a/libempathy-gtk/empathy-log-window.c b/libempathy-gtk/empathy-log-window.c
index 247a998..f6f6ef1 100644
--- a/libempathy-gtk/empathy-log-window.c
+++ b/libempathy-gtk/empathy-log-window.c
@@ -72,6 +72,11 @@ typedef struct {
 	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,
@@ -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,
@@ -271,11 +285,13 @@ empathy_log_window_show (TpAccount  *account,
 	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) {
-		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) {
@@ -294,6 +310,7 @@ log_window_destroy_cb (GtkWidget       *widget,
 {
 	g_free (window->last_find);
 	g_object_unref (window->log_manager);
+	g_free (window->selected_chat_id);
 
 	g_free (window);
 }



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