[evolution] Bug #659876 - Make automatic contact address formatting optional



commit d2232a718dc86dda4182d154a7fdfe1d218229dc
Author: Dan VrÃtil <dvratil redhat com>
Date:   Fri Oct 7 14:40:55 2011 +0200

    Bug #659876 - Make automatic contact address formatting optional
    
    Make behavior introduced in bug #636809 optional by adding checkbox
    to Preferences->Contacts.

 addressbook/gui/contact-editor/e-contact-editor.c  |   26 ++++++++++++++++---
 .../apps_evolution_addressbook.schemas.in          |   12 +++++++++
 modules/addressbook/autocompletion-config.c        |   12 +++++++++
 modules/addressbook/e-book-shell-settings.c        |    4 +++
 4 files changed, 50 insertions(+), 4 deletions(-)
---
diff --git a/addressbook/gui/contact-editor/e-contact-editor.c b/addressbook/gui/contact-editor/e-contact-editor.c
index e2dc21c..28b5b63 100644
--- a/addressbook/gui/contact-editor/e-contact-editor.c
+++ b/addressbook/gui/contact-editor/e-contact-editor.c
@@ -2301,17 +2301,35 @@ set_address_label (EContact *contact,
                    EContactAddress *address)
 {
 	gchar *address_label = NULL;
+	gboolean format_address;
+	GConfClient *client;
+	GConfValue *value;
 
 	if (!address) {
 		e_contact_set (contact, field, NULL);
 		return;
 	}
 
-	address_label = eab_format_address (contact,
-				(field == E_CONTACT_ADDRESS_LABEL_WORK) ? E_CONTACT_ADDRESS_WORK :
-									  E_CONTACT_ADDRESS_HOME);
 
-	if (!address_label) {
+	client = gconf_client_get_default ();
+	value = gconf_client_get (client,
+		"/apps/evolution/addressbook/display/address_formatting", NULL);
+	g_object_unref (client);
+
+	if (value) {
+		format_address = gconf_value_get_bool (value);
+		gconf_value_free (value);
+	} else {
+		format_address = TRUE;
+	}
+
+	if (format_address) {
+		address_label = eab_format_address (contact,
+					(field == E_CONTACT_ADDRESS_LABEL_WORK) ? E_CONTACT_ADDRESS_WORK :
+										  E_CONTACT_ADDRESS_HOME);
+	}
+
+	if (!format_address || !address_label) {
 		address_label = append_to_address_label (
 			address_label, address->street, TRUE);
 		address_label = append_to_address_label (
diff --git a/modules/addressbook/apps_evolution_addressbook.schemas.in b/modules/addressbook/apps_evolution_addressbook.schemas.in
index a6506d7..8241225 100644
--- a/modules/addressbook/apps_evolution_addressbook.schemas.in
+++ b/modules/addressbook/apps_evolution_addressbook.schemas.in
@@ -139,5 +139,17 @@
       </locale>
     </schema>
 
+    <schema>
+      <key>/schemas/apps/evolution/addressbook/display/address_formatting</key>
+      <applyto>/apps/evolution/addressbook/display/address_formatting</applyto>
+      <owner>evolution-addressbook</owner>
+      <type>bool</type>
+      <default>true</default>
+      <locale name="C">
+        <short>Enable address formatting</short>
+        <long>Wheter addresses should be formatted according to standard in their destination country.</long>
+      </locale>
+    </schema>
+
   </schemalist>
 </gconfschemafile>
diff --git a/modules/addressbook/autocompletion-config.c b/modules/addressbook/autocompletion-config.c
index 020ad1d..be9ddcc 100644
--- a/modules/addressbook/autocompletion-config.c
+++ b/modules/addressbook/autocompletion-config.c
@@ -194,6 +194,18 @@ acc_get_general_page (EConfig *ec,
 		DTFormatKindDateTime, _("_Table column:"));
 	gtk_widget_show (widget);
 
+	itembox = add_section (vbox, _("Address formatting"), FALSE);
+
+	widget = gtk_check_button_new_with_label (
+		_("_Format address according to standard of its destination country"));
+	g_object_bind_property (
+		shell_settings, "enable-address-formatting",
+		widget, "active",
+		G_BINDING_BIDIRECTIONAL |
+		G_BINDING_SYNC_CREATE);
+	gtk_box_pack_start (GTK_BOX (itembox), widget, FALSE, FALSE, 0);
+	gtk_widget_show (widget);
+
 	itembox = add_section (vbox, _("Autocompletion"), TRUE);
 
 	widget = gtk_check_button_new_with_mnemonic (
diff --git a/modules/addressbook/e-book-shell-settings.c b/modules/addressbook/e-book-shell-settings.c
index 6be121d..ae2e4f0 100644
--- a/modules/addressbook/e-book-shell-settings.c
+++ b/modules/addressbook/e-book-shell-settings.c
@@ -35,4 +35,8 @@ e_book_shell_backend_init_settings (EShell *shell)
 	e_shell_settings_install_property_for_key (
 		"book-primary-selection",
 		"/apps/evolution/addressbook/display/primary_addressbook");
+
+	e_shell_settings_install_property_for_key (
+		"enable-address-formatting",
+		"/apps/evolution/addressbook/display/address_formatting");
 }



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