# HG changeset patch # User Gary Kramlich # Date 1691126942 18000 # Node ID 642478e32820424765b5b4190f3b2c0e66fdfd9f # Parent 079039216f5848c11ecf7b48c2f61d869b51d717 Fix a number of bugs in the account editor This fixes the protocol not being the first one in the list as well as the username still being populate from a previous account when a new account is being created. All login options are now set to insensitive when an account is online and are properly made sensitive when the account is offline. However, these properties aren't bound yet, because there's no property to bind to. See PIDGIN-17815. Testing Done: Opened the account editor for an existing online account and verified that the protocol, username, and all user splits were insensitive. Hit the back button, hit the add button and verified that the protocol was at Bonjour (the first in the list) and that the username was empty and that those 2 and all of the user splits were sensitive. Bugs closed: PIDGIN-17813 Reviewed at https://reviews.imfreedom.org/r/2540/ diff -r 079039216f58 -r 642478e32820 pidgin/pidginaccounteditor.c --- a/pidgin/pidginaccounteditor.c Thu Aug 03 23:15:26 2023 -0500 +++ b/pidgin/pidginaccounteditor.c Fri Aug 04 00:29:02 2023 -0500 @@ -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 -r 079039216f58 -r 642478e32820 pidgin/pidginaccountmanager.c --- a/pidgin/pidginaccountmanager.c Thu Aug 03 23:15:26 2023 -0500 +++ b/pidgin/pidginaccountmanager.c Fri Aug 04 00:29:02 2023 -0500 @@ -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); } } @@ -236,6 +230,9 @@ g_return_if_fail(PIDGIN_IS_ACCOUNT_MANAGER(manager)); gtk_stack_set_visible_child_name(GTK_STACK(manager->stack), "overview"); + + pidgin_account_editor_set_account(PIDGIN_ACCOUNT_EDITOR(manager->editor), + NULL); } void