Blame SOURCES/evolution-3.28.5-mail-account-name-sync-in-wizard.patch

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