From 44fbd35658e842a146daf31c53d8dbd670dd21bb Mon Sep 17 00:00:00 2001 From: Milan Crha Date: Tue, 3 Dec 2019 12:05:25 +0100 Subject: [PATCH] I#729 - New Mail account wizard ignores email address change Closes https://gitlab.gnome.org/GNOME/evolution/issues/729 --- src/mail/e-mail-config-assistant.c | 25 +++++++++++++++++++++++-- src/mail/e-mail-config-summary-page.c | 23 ++++++++++++++++++++--- src/mail/e-mail-config-summary-page.h | 2 ++ 3 files changed, 45 insertions(+), 5 deletions(-) diff --git a/src/mail/e-mail-config-assistant.c b/src/mail/e-mail-config-assistant.c index 5307f1f90e..0c8da3c015 100644 --- a/src/mail/e-mail-config-assistant.c +++ b/src/mail/e-mail-config-assistant.c @@ -1069,7 +1069,26 @@ mail_config_assistant_prepare (GtkAssistant *assistant, e_named_parameters_free (params); } - if (E_IS_MAIL_CONFIG_RECEIVING_PAGE (page) && first_visit) { + if (!first_visit && E_IS_MAIL_CONFIG_IDENTITY_PAGE (page)) { + ESource *source; + ESourceMailIdentity *extension; + const gchar *email_address; + const gchar *extension_name; + + source = priv->identity_source; + extension_name = E_SOURCE_EXTENSION_MAIL_IDENTITY; + extension = e_source_get_extension (source, extension_name); + email_address = e_source_mail_identity_get_address (extension); + + /* Set the value to an empty string when going back to the identity page, + thus when moving away from it the source's display name is updated + with the new address, in case it changed. Do not modify the display + name when the user changed it. */ + if (g_strcmp0 (e_mail_config_summary_page_get_account_name (priv->summary_page), email_address) == 0) + e_source_set_display_name (source, ""); + } + + if (E_IS_MAIL_CONFIG_RECEIVING_PAGE (page)) { ESource *source; ESourceMailIdentity *extension; const gchar *email_address; @@ -1084,7 +1103,9 @@ mail_config_assistant_prepare (GtkAssistant *assistant, extension_name = E_SOURCE_EXTENSION_MAIL_IDENTITY; extension = e_source_get_extension (source, extension_name); email_address = e_source_mail_identity_get_address (extension); - e_source_set_display_name (source, email_address); + + if (first_visit || g_strcmp0 (e_source_get_display_name (source), "") == 0) + e_source_set_display_name (source, email_address); } if (first_visit && ( diff --git a/src/mail/e-mail-config-summary-page.c b/src/mail/e-mail-config-summary-page.c index fb0306d3e1..20c669ad65 100644 --- a/src/mail/e-mail-config-summary-page.c +++ b/src/mail/e-mail-config-summary-page.c @@ -53,6 +53,8 @@ struct _EMailConfigSummaryPagePrivate { GtkLabel *send_user_label; GtkLabel *send_security_label; GtkEntry *account_name_entry; + + GBinding *account_name_binding; }; enum { @@ -549,9 +551,6 @@ mail_config_summary_page_refresh (EMailConfigSummaryPage *page) const gchar *extension_name; const gchar *value; - value = e_source_get_display_name (source); - gtk_entry_set_text (priv->account_name_entry, value); - extension_name = E_SOURCE_EXTENSION_MAIL_IDENTITY; extension = e_source_get_extension (source, extension_name); @@ -830,6 +829,14 @@ e_mail_config_summary_page_get_internal_box (EMailConfigSummaryPage *page) return page->priv->main_box; } +const gchar * +e_mail_config_summary_page_get_account_name (EMailConfigSummaryPage *page) +{ + g_return_val_if_fail (E_IS_MAIL_CONFIG_SUMMARY_PAGE (page), NULL); + + return gtk_entry_get_text (page->priv->account_name_entry); +} + void e_mail_config_summary_page_refresh (EMailConfigSummaryPage *page) { @@ -934,6 +941,11 @@ e_mail_config_summary_page_set_identity_source (EMailConfigSummaryPage *page, page->priv->identity_source = identity_source; page->priv->identity_source_changed_id = 0; + if (page->priv->account_name_binding) { + g_binding_unbind (page->priv->account_name_binding); + page->priv->account_name_binding = NULL; + } + if (identity_source != NULL) { gulong handler_id; @@ -943,6 +955,11 @@ e_mail_config_summary_page_set_identity_source (EMailConfigSummaryPage *page, page); page->priv->identity_source_changed_id = handler_id; + + page->priv->account_name_binding = + e_binding_bind_property (identity_source, "display-name", + page->priv->account_name_entry, "text", + G_BINDING_BIDIRECTIONAL | G_BINDING_SYNC_CREATE); } g_object_notify (G_OBJECT (page), "identity-source"); diff --git a/src/mail/e-mail-config-summary-page.h b/src/mail/e-mail-config-summary-page.h index af793dc8b6..64d0af875c 100644 --- a/src/mail/e-mail-config-summary-page.h +++ b/src/mail/e-mail-config-summary-page.h @@ -68,6 +68,8 @@ EMailConfigPage * e_mail_config_summary_page_new (void); GtkBox * e_mail_config_summary_page_get_internal_box (EMailConfigSummaryPage *page); +const gchar * e_mail_config_summary_page_get_account_name + (EMailConfigSummaryPage *page); void e_mail_config_summary_page_refresh (EMailConfigSummaryPage *page); EMailConfigServiceBackend * -- 2.21.0