# HG changeset patch
# Node ID d8bf594a7d0c
# Parent  31743d477d97
diff --git a/pidgin/pidginaccounteditor.c b/pidgin/pidginaccounteditor.c
--- a/pidgin/pidginaccounteditor.c
+++ b/pidgin/pidginaccounteditor.c
@@ -106,12 +106,23 @@
 
 	if(!purple_account_user_split_is_constant(split)) {
 		GtkWidget *row = NULL;
+		gboolean sensitive = TRUE;
+
+		if(PURPLE_IS_ACCOUNT(editor->account)) {
+			if(purple_account_is_connected(editor->account)) {
+				sensitive = FALSE;
+			}
+		}
 
 		row = adw_entry_row_new();
 		editor->user_split_rows = g_list_append(editor->user_split_rows, row);
 		gtk_list_box_append(GTK_LIST_BOX(editor->user_splits), row);
 
 		gtk_widget_set_focusable(row, FALSE);
+		if(!sensitive) {
+			gtk_widget_set_sensitive(row, sensitive);
+		}
+
 		adw_preferences_row_set_title(ADW_PREFERENCES_ROW(row),
 		                              purple_account_user_split_get_text(split));
 	}
@@ -129,6 +140,31 @@
 	gboolean require_password = FALSE;
 	gboolean ret = FALSE;
 
+	/* Make the username field sensitive as it may have previously be made
+	 * insensitive.
+	 */
+	gtk_widget_set_sensitive(editor->username, TRUE);
+
+	/* If we have an account, populate its values. */
+	if(PURPLE_IS_ACCOUNT(editor->account)) {
+		/* The username will be split apart below and eventually set as the text
+		 * in the username entry.
+		 */
+		PurpleContactInfo *info = PURPLE_CONTACT_INFO(editor->account);
+
+		username = g_strdup(purple_contact_info_get_username(info));
+		require_password = purple_account_get_require_password(editor->account);
+
+		if(purple_account_is_connected(editor->account)) {
+			gtk_widget_set_sensitive(editor->username, FALSE);
+		}
+	} else {
+		/* If we don't have an account reset the fields that are static. */
+		pidgin_protocol_chooser_set_protocol(PIDGIN_PROTOCOL_CHOOSER(editor->protocol),
+		                                     NULL);
+		gtk_editable_set_text(GTK_EDITABLE(editor->username), "");
+	}
+
 	/* Now remove the rows we added to the preference group for each non
 	 * constant user split.
 	 */
@@ -144,16 +180,6 @@
 	user_splits = purple_protocol_get_user_splits(protocol);
 	g_list_foreach(user_splits, pidgin_account_editor_add_user_split, editor);
 
-	/* If we have an account, populate its values. */
-	if(PURPLE_IS_ACCOUNT(editor->account)) {
-		/* The username will be split apart below and eventually set as the text
-		 * in the username entry.
-		 */
-		PurpleContactInfo *info = PURPLE_CONTACT_INFO(editor->account);
-
-		username = g_strdup(purple_contact_info_get_username(info));
-	}
-
 	/* Filling out the user splits is a pain. If we have an account, we created
 	 * a copy of the username above. We then iterate the user splits backwards
 	 * so we can insert a null terminator at the start of each split we find in
@@ -214,9 +240,6 @@
 	gtk_widget_set_visible(editor->require_password_row,
 	                       options & OPT_PROTO_PASSWORD_OPTIONAL);
 
-	if(PURPLE_IS_ACCOUNT(editor->account)) {
-		require_password = purple_account_get_require_password(editor->account);
-	}
 	gtk_switch_set_active(GTK_SWITCH(editor->require_password),
 	                      require_password);
 
@@ -652,11 +675,11 @@
 	PurpleProtocol *protocol = NULL;
 	gboolean sensitive = FALSE;
 
+	/* Reset the sensitivity of the protocol chooser to sensitive. */
+	gtk_widget_set_sensitive(editor->protocol, TRUE);
 	if(PURPLE_IS_ACCOUNT(editor->account)) {
-		PurpleConnection *connection = NULL;
-
-		connection = purple_account_get_connection(editor->account);
-		if(PURPLE_IS_CONNECTION(connection)) {
+		if(purple_account_is_connected(editor->account)) {
+			/* If the account is connected, disable the protocol chooser. */
 			gtk_widget_set_sensitive(editor->protocol, FALSE);
 		}
 	}
diff --git a/pidgin/pidginaccountmanager.c b/pidgin/pidginaccountmanager.c
--- a/pidgin/pidginaccountmanager.c
+++ b/pidgin/pidginaccountmanager.c
@@ -151,12 +151,6 @@
 	adw_preferences_page_scroll_to_top(ADW_PREFERENCES_PAGE(manager->editor));
 #endif
 
-	/* Disconnect the account which will remove all of the account options as
-	 * well.
-	 */
-	pidgin_account_editor_set_account(PIDGIN_ACCOUNT_EDITOR(manager->editor),
-	                                  NULL);
-
 	pidgin_account_manager_show_overview(manager);
 }
 
@@ -171,7 +165,7 @@
 	if(manager->edit_only) {
 		gtk_window_destroy(GTK_WINDOW(manager));
 	} else {
-		gtk_stack_set_visible_child_name(GTK_STACK(manager->stack), "overview");
+		pidgin_account_manager_show_overview(manager);
 	}
 }
 
@@ -235,6 +229,9 @@
 pidgin_account_manager_show_overview(PidginAccountManager *manager) {
 	g_return_if_fail(PIDGIN_IS_ACCOUNT_MANAGER(manager));
 
+	pidgin_account_editor_set_account(PIDGIN_ACCOUNT_EDITOR(manager->editor),
+	                                  NULL);
+
 	gtk_stack_set_visible_child_name(GTK_STACK(manager->stack), "overview");
 }
 
