# HG changeset patch
# Node ID 27d0a79220ba
# Parent  a51ff7ecf053
diff --git a/pidgin/gtkconn.c b/pidgin/gtkconn.c
--- a/pidgin/gtkconn.c
+++ b/pidgin/gtkconn.c
@@ -47,28 +47,11 @@
 static GHashTable *auto_reconns = NULL;
 
 static void
-pidgin_connection_connect_progress(PurpleConnection *gc,
-		const char *text, size_t step, size_t step_count)
-{
-	PidginBuddyList *gtkblist = pidgin_blist_get_default_gtk_blist();
-	if (!gtkblist)
-		return;
-	pidgin_status_box_set_connecting(PIDGIN_STATUS_BOX(gtkblist->statusbox),
-					   (purple_connections_get_connecting() != NULL));
-}
-
-static void
 pidgin_connection_connected(PurpleConnection *gc)
 {
 	PurpleAccount *account;
-	PidginBuddyList *gtkblist;
 
 	account  = purple_connection_get_account(gc);
-	gtkblist = pidgin_blist_get_default_gtk_blist();
-
-	if (gtkblist != NULL)
-		pidgin_status_box_set_connecting(PIDGIN_STATUS_BOX(gtkblist->statusbox),
-					   (purple_connections_get_connecting() != NULL));
 
 	g_hash_table_remove(auto_reconns, account);
 }
@@ -76,12 +59,6 @@
 static void
 pidgin_connection_disconnected(PurpleConnection *gc)
 {
-	PidginBuddyList *gtkblist = pidgin_blist_get_default_gtk_blist();
-	if (!gtkblist)
-		return;
-	pidgin_status_box_set_connecting(PIDGIN_STATUS_BOX(gtkblist->statusbox),
-					   (purple_connections_get_connecting() != NULL));
-
 	if (purple_connections_get_all() != NULL)
 		return;
 
@@ -195,7 +172,7 @@
 
 static PurpleConnectionUiOps conn_ui_ops =
 {
-	pidgin_connection_connect_progress,
+	NULL,
 	pidgin_connection_connected,
 	pidgin_connection_disconnected,
 	pidgin_connection_notice,
diff --git a/pidgin/gtkstatusbox.c b/pidgin/gtkstatusbox.c
--- a/pidgin/gtkstatusbox.c
+++ b/pidgin/gtkstatusbox.c
@@ -118,6 +118,8 @@
 	GtkWidget *tree_view;
 	gboolean popup_in_progress;
 	GtkTreeRowReference *active_row;
+
+	GList *connections_in_progress;
 };
 
 static void pidgin_status_box_add(PidginStatusBox *status_box, PidginStatusBoxItemType type, GdkPixbuf *pixbuf, const char *text, const char *sec_text, gpointer data);
@@ -308,6 +310,42 @@
 }
 
 static void
+connection_start_cb(PurpleConnection *connection, gpointer data) {
+	PidginStatusBox *status_box = data;
+
+	status_box->connections_in_progress =
+		g_list_append(status_box->connections_in_progress, connection);
+
+	pidgin_status_box_set_connecting(status_box, TRUE);
+}
+
+static void
+connection_finish_cb(PurpleConnection *connection, gpointer data) {
+	PidginStatusBox *status_box = data;
+
+	status_box->connections_in_progress =
+		g_list_remove(status_box->connections_in_progress, connection);
+
+	if(status_box->connections_in_progress == NULL) {
+		pidgin_status_box_set_connecting(status_box, FALSE);
+	}
+}
+
+static void
+connection_error_cb(PurpleConnection *connection, G_GNUC_UNUSED gint conn_err,
+                    G_GNUC_UNUSED const gchar *conn_message, gpointer data)
+{
+	PidginStatusBox *status_box = data;
+
+	status_box->connections_in_progress =
+		g_list_remove(status_box->connections_in_progress, connection);
+
+	if(status_box->connections_in_progress == NULL) {
+		pidgin_status_box_set_connecting(status_box, FALSE);
+	}
+}
+
+static void
 pidgin_status_box_set_property(GObject *object, guint param_id,
                                const GValue *value, GParamSpec *pspec)
 {
@@ -1255,6 +1293,7 @@
 	GtkWidget *toplevel;
 	GtkTreeSelection *sel;
 	gboolean network_available = FALSE;
+	gpointer handle;
 
 	gtk_widget_set_has_window(GTK_WIDGET(status_box), FALSE);
 	status_box->editor_visible = FALSE;
@@ -1385,28 +1424,38 @@
 
 	pidgin_status_box_regenerate(status_box, TRUE);
 
-	purple_signal_connect(purple_savedstatuses_get_handle(), "savedstatus-changed",
-						status_box,
-						PURPLE_CALLBACK(current_savedstatus_changed_cb),
-						status_box);
-	purple_signal_connect(purple_savedstatuses_get_handle(),
-			"savedstatus-added", status_box,
-			PURPLE_CALLBACK(saved_status_updated_cb), status_box);
-	purple_signal_connect(purple_savedstatuses_get_handle(),
-			"savedstatus-deleted", status_box,
-			PURPLE_CALLBACK(saved_status_updated_cb), status_box);
-	purple_signal_connect(purple_savedstatuses_get_handle(),
-			"savedstatus-modified", status_box,
-			PURPLE_CALLBACK(saved_status_updated_cb), status_box);
-	purple_signal_connect(purple_accounts_get_handle(), "account-enabled", status_box,
-						PURPLE_CALLBACK(account_enabled_cb),
-						status_box);
-	purple_signal_connect(purple_accounts_get_handle(), "account-disabled", status_box,
-						PURPLE_CALLBACK(account_enabled_cb),
-						status_box);
-	purple_signal_connect(purple_accounts_get_handle(), "account-status-changed", status_box,
-						PURPLE_CALLBACK(account_status_changed_cb),
-						status_box);
+	handle = purple_savedstatuses_get_handle();
+	purple_signal_connect(handle, "savedstatus-changed", status_box,
+	                      PURPLE_CALLBACK(current_savedstatus_changed_cb),
+	                      status_box);
+	purple_signal_connect(handle, "savedstatus-added", status_box,
+	                      PURPLE_CALLBACK(saved_status_updated_cb), status_box);
+	purple_signal_connect(handle, "savedstatus-deleted", status_box,
+	                      PURPLE_CALLBACK(saved_status_updated_cb), status_box);
+	purple_signal_connect(handle, "savedstatus-modified", status_box,
+	                      PURPLE_CALLBACK(saved_status_updated_cb), status_box);
+
+	handle = purple_accounts_get_handle();
+	purple_signal_connect(handle, "account-enabled", status_box,
+	                      PURPLE_CALLBACK(account_enabled_cb), status_box);
+	purple_signal_connect(handle, "account-disabled", status_box,
+	                      PURPLE_CALLBACK(account_enabled_cb), status_box);
+	purple_signal_connect(handle, "account-status-changed", status_box,
+	                      PURPLE_CALLBACK(account_status_changed_cb),
+	                      status_box);
+
+	handle = purple_connections_get_handle();
+	purple_signal_connect(handle, "signing-on", status_box,
+	                      PURPLE_CALLBACK(connection_start_cb),
+	                      status_box);
+	purple_signal_connect(handle, "signed-on", status_box,
+	                      PURPLE_CALLBACK(connection_finish_cb),
+	                      status_box);
+	purple_signal_connect(handle, "signing-off", status_box,
+	                      PURPLE_CALLBACK(connection_finish_cb),
+	                      status_box);
+	purple_signal_connect(handle, "connection-error", status_box,
+	                      PURPLE_CALLBACK(connection_error_cb), status_box);
 
 	monitor = g_network_monitor_get_default();
 	g_signal_connect(G_OBJECT(monitor), "network-changed",
