[gnome-contacts] Support adding new postal addresses



commit 7907d6ea74229a1e1f8438f232eff90c804230e4
Author: Alexander Larsson <alexl redhat com>
Date:   Tue Aug 16 22:16:09 2011 +0200

    Support adding new postal addresses

 src/contacts-contact-pane.vala |   41 ++++++++++++++++++++++++++-------------
 1 files changed, 27 insertions(+), 14 deletions(-)
---
diff --git a/src/contacts-contact-pane.vala b/src/contacts-contact-pane.vala
index 8a8441d..21a9a91 100644
--- a/src/contacts-contact-pane.vala
+++ b/src/contacts-contact-pane.vala
@@ -428,6 +428,24 @@ public class Contacts.ContactPane : EventBox {
     add_detail_remove (detail_set, detail, property_name, false);
   }
 
+  private void add_postal_editor (Set<PostalAddressFieldDetails> detail_set,
+				  PostalAddressFieldDetails detail) {
+    string[] props = {"street", "extension", "locality", "region", "postal_code", "po_box", "country"};
+    string[] nice = {_("Street"), _("Extension"), _("City"), _("State/Province"), _("Zip/Postal Code"), _("PO box"), _("Country")};
+
+    detail_set.add (detail);
+    add_detail_combo (TypeSet.general, detail_set, detail, "postal_addresses");
+
+    for (int i = 0; i < props.length; i++) {
+      add_detail_postal_entry (detail_set,
+			       detail,
+			       props[i],
+			       "postal_addresses",
+			       nice[i]);
+    }
+    add_detail_remove (detail_set, detail, "postal_addresses");
+  }
+
   private void update_edit_details (ContactFrame image_frame, Persona persona, bool new_contact) {
     layout.reset (false);
     image_frame.set_image (persona as AvatarDetails);
@@ -491,20 +509,8 @@ public class Contacts.ContactPane : EventBox {
     if (postal_details != null) {
       var postals = postal_details.postal_addresses;
       foreach (var _addr in postals) {
-	var addr = new PostalAddressFieldDetails(_addr.value, _addr.parameters);
-	editing_postals.add (addr);
-	add_detail_combo (TypeSet.general, editing_postals, addr, "postal_addresses");
-
-	string[] props = {"street", "extension", "locality", "region", "postal_code", "po_box", "country"};
-	string[] nice = {_("Street"), _("Extension"), _("City"), _("State/Province"), _("Zip/Postal Code"), _("PO box"), _("Country")};
-	for (int i = 0; i < props.length; i++) {
-	  add_detail_postal_entry (editing_postals,
-				   addr,
-				   props[i],
-				   "postal_addresses",
-				   nice[i]);
-	}
-	add_detail_remove (editing_postals, addr, "postal_addresses");
+	add_postal_editor (editing_postals,
+			   new PostalAddressFieldDetails(_addr.value, _addr.parameters));
       }
     }
 
@@ -551,6 +557,13 @@ public class Contacts.ContactPane : EventBox {
 	  fields_grid.show_all ();
 	  end_row = layout.save_state ();
 	});
+      Utils.add_menu_item (menu, _("Postal Address")).activate.connect ( () => {
+	  layout.load_state (end_row);
+	  add_postal_editor (editing_postals,
+			     new PostalAddressFieldDetails(new PostalAddress (null, null, null, null, null, null, null, null, null), null));
+	  fields_grid.show_all ();
+	  end_row = layout.save_state ();
+	});
       Utils.add_menu_item (menu,_("Link")).activate.connect ( () => {
 	  if (url_row != null) {
 	    layout.load_state (url_row);



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