[evolution] Bug #577322 - Rename of a system ESource doesn't persist



commit 16efd93e3d26759add0f30d4e33eb21094b29aa8
Author: Milan Crha <mcrha redhat com>
Date:   Wed Dec 7 13:22:58 2011 +0100

    Bug #577322 - Rename of a system ESource doesn't persist

 calendar/gui/dialogs/calendar-setup.c      |   16 +++++++++++++++-
 modules/addressbook/addressbook-config.c   |    5 +++++
 modules/addressbook/e-book-shell-backend.c |    2 +-
 modules/calendar/e-cal-shell-backend.c     |    4 ++--
 modules/calendar/e-memo-shell-backend.c    |    2 +-
 modules/calendar/e-task-shell-backend.c    |    2 +-
 6 files changed, 25 insertions(+), 6 deletions(-)
---
diff --git a/calendar/gui/dialogs/calendar-setup.c b/calendar/gui/dialogs/calendar-setup.c
index 0ffdb4c..8aa82c2 100644
--- a/calendar/gui/dialogs/calendar-setup.c
+++ b/calendar/gui/dialogs/calendar-setup.c
@@ -224,7 +224,21 @@ name_changed (GtkEntry *entry,
               ECalConfigTargetSource *t)
 {
 	ESource *source = t->source;
-	e_source_set_name (source, gtk_entry_get_text (GTK_ENTRY (entry)));
+	ESourceGroup *group;
+	gboolean is_birthdays = FALSE;
+	gboolean changed;
+	const gchar *name;
+
+	name = gtk_entry_get_text (GTK_ENTRY (entry));
+
+	changed = g_strcmp0 (name, e_source_peek_name (source)) != 0;
+	e_source_set_name (source, name);
+
+	group = e_source_peek_group (source);
+	is_birthdays = group && g_strcmp0 (e_source_group_peek_base_uri (group), "contacts://") == 0;
+
+	if (changed && (g_strcmp0 ("system", e_source_peek_relative_uri (source)) == 0 || is_birthdays))
+		e_source_set_property (source, "name-changed", "true");
 }
 
 static GtkWidget *
diff --git a/modules/addressbook/addressbook-config.c b/modules/addressbook/addressbook-config.c
index e312024..028b750 100644
--- a/modules/addressbook/addressbook-config.c
+++ b/modules/addressbook/addressbook-config.c
@@ -564,12 +564,17 @@ name_changed_cb (GtkWidget *w,
 {
 	const gchar *text;
 	gchar *stripped_name;
+	gboolean changed;
 
 	text = gtk_entry_get_text (GTK_ENTRY (sdialog->display_name));
 
 	stripped_name = g_strstrip (g_strdup (text));
+	changed = g_strcmp0 (stripped_name, e_source_peek_name (sdialog->source)) != 0;
 	e_source_set_name (sdialog->source, stripped_name);
 	g_free (stripped_name);
+
+	if (changed && g_strcmp0 ("system", e_source_peek_relative_uri (sdialog->source)) == 0)
+		e_source_set_property (sdialog->source, "name-changed", "true");
 }
 
 static GtkWidget *
diff --git a/modules/addressbook/e-book-shell-backend.c b/modules/addressbook/e-book-shell-backend.c
index 8ea434d..ea65ce3 100644
--- a/modules/addressbook/e-book-shell-backend.c
+++ b/modules/addressbook/e-book-shell-backend.c
@@ -128,7 +128,7 @@ book_shell_backend_ensure_sources (EShellBackend *shell_backend)
 		e_source_set_property (source, "completion", "true");
 		g_object_unref (source);
 		e_source_list_sync (priv->source_list, NULL);		
-	} else {
+	} else if (!e_source_get_property (personal, "name-changed")) {
 		/* Force the source name to the current locale. */
 		e_source_set_name (personal, name);
 		e_source_list_sync (priv->source_list, NULL);		
diff --git a/modules/calendar/e-cal-shell-backend.c b/modules/calendar/e-cal-shell-backend.c
index af1ca21..74bc62d 100644
--- a/modules/calendar/e-cal-shell-backend.c
+++ b/modules/calendar/e-cal-shell-backend.c
@@ -169,7 +169,7 @@ cal_shell_backend_ensure_sources (EShellBackend *shell_backend)
 		g_slist_foreach (selected, (GFunc) g_free, NULL);
 		g_slist_free (selected);
 		g_free (primary);
-	} else {
+	} else if (!e_source_get_property (personal, "name-changed")) {
 		/* Force the source name to the current locale. */
 		e_source_set_name (personal, name);
 	}
@@ -215,7 +215,7 @@ cal_shell_backend_ensure_sources (EShellBackend *shell_backend)
 
 		/* This is now a borrowed reference. */
 		birthdays = source;
-	} else {
+	} else if (!e_source_get_property (birthdays, "name-changed")) {
 		/* Force the source name to the current locale. */
 		e_source_set_name (birthdays, name);
 	}
diff --git a/modules/calendar/e-memo-shell-backend.c b/modules/calendar/e-memo-shell-backend.c
index c31689f..c83c0fd 100644
--- a/modules/calendar/e-memo-shell-backend.c
+++ b/modules/calendar/e-memo-shell-backend.c
@@ -153,7 +153,7 @@ memo_shell_backend_ensure_sources (EShellBackend *shell_backend)
 		g_slist_foreach (selected, (GFunc) g_free, NULL);
 		g_slist_free (selected);
 		g_free (primary);
-	} else {
+	} else if (!e_source_get_property (personal, "name-changed")) {
 		/* Force the source name to the current locale. */
 		e_source_set_name (personal, name);
 	}
diff --git a/modules/calendar/e-task-shell-backend.c b/modules/calendar/e-task-shell-backend.c
index deca594..84500e4 100644
--- a/modules/calendar/e-task-shell-backend.c
+++ b/modules/calendar/e-task-shell-backend.c
@@ -153,7 +153,7 @@ task_shell_backend_ensure_sources (EShellBackend *shell_backend)
 		g_slist_foreach (selected, (GFunc) g_free, NULL);
 		g_slist_free (selected);
 		g_free (primary);
-	} else {
+	} else if (!e_source_get_property (personal, "name-changed")) {
 		/* Force the source name to the current locale. */
 		e_source_set_name (personal, name);
 	}



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]