[evolution/gnome-3-2] Bug #659876 - Make automatic contact address formatting optional



commit 3218a0ae85011e050b678043942136cfc6746c4c
Author: Dan VrÃtil <dvratil redhat com>
Date:   Fri Oct 7 14:44:05 2011 +0200

    Bug #659876 - Make automatic contact address formatting optional
    
    Added only GConf option to schema, GUI option will be available in
    Evolution 3.4.

 addressbook/gui/contact-editor/e-contact-editor.c  |   26 ++++++++++++++++---
 .../apps_evolution_addressbook.schemas.in          |   12 +++++++++
 2 files changed, 34 insertions(+), 4 deletions(-)
---
diff --git a/addressbook/gui/contact-editor/e-contact-editor.c b/addressbook/gui/contact-editor/e-contact-editor.c
index 6ce9524..19e247f 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>



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