summaryrefslogtreecommitdiff
path: root/src/contacts-contact-editor.vala
diff options
context:
space:
mode:
authorPhilip Withnall <philip.withnall@collabora.co.uk>2014-08-21 16:33:38 +0100
committerPhilip Withnall <philip.withnall@collabora.co.uk>2014-08-21 16:37:30 +0100
commitdf2f2b02d87567e681a6bd88a846a7846f0d2d50 (patch)
tree2840b9fd354595f24c2aa0f7b6245723621d65d2 /src/contacts-contact-editor.vala
parent002eb3d779b3dd2424d069ec6c289dbea1a70549 (diff)
downloadgnome-contacts-df2f2b02d87567e681a6bd88a846a7846f0d2d50.tar.gz
ContactEditor: Move string constants from Contact
This fixes a crash when creating a new contact in an empty address book, caused by the string arrays only being populated when the Contact class is initialised — which doesn’t happen if the address book is empty. These arrays were only used in the ContactEditor class, so they shouldn’t have been in the Contact class in the first place. https://bugzilla.gnome.org/show_bug.cgi?id=735168
Diffstat (limited to 'src/contacts-contact-editor.vala')
-rw-r--r--src/contacts-contact-editor.vala11
1 files changed, 7 insertions, 4 deletions
diff --git a/src/contacts-contact-editor.vala b/src/contacts-contact-editor.vala
index 0b4c77c..f3a8f81 100644
--- a/src/contacts-contact-editor.vala
+++ b/src/contacts-contact-editor.vala
@@ -21,9 +21,12 @@ using Folks;
using Gee;
public class Contacts.AddressEditor : Box {
- public Entry? entries[7];
+ public Entry? entries[7]; /* must be the number of elements in postal_element_props */
public PostalAddressFieldDetails details;
+ public static const string[] postal_element_props = {"street", "extension", "locality", "region", "postal_code", "po_box", "country"};
+ public static string[] postal_element_names = {_("Street"), _("Extension"), _("City"), _("State/Province"), _("Zip/Postal Code"), _("PO box"), _("Country")};
+
public signal void changed ();
public AddressEditor (PostalAddressFieldDetails _details) {
@@ -34,11 +37,11 @@ public class Contacts.AddressEditor : Box {
for (int i = 0; i < entries.length; i++) {
string postal_part;
- details.value.get (Contact.postal_element_props[i], out postal_part);
+ details.value.get (AddressEditor.postal_element_props[i], out postal_part);
entries[i] = new Entry ();
entries[i].set_hexpand (true);
- entries[i].set ("placeholder-text", Contact.postal_element_names[i]);
+ entries[i].set ("placeholder-text", AddressEditor.postal_element_names[i]);
if (postal_part != null)
entries[i].set_text (postal_part);
@@ -227,7 +230,7 @@ public class Contacts.ContactEditor : Grid {
addr_editor.details.value.address_format,
addr_editor.details.id);
for (int i = 0; i < addr_editor.entries.length; i++)
- new_value.set (Contact.postal_element_props[i], addr_editor.entries[i].get_text ());
+ new_value.set (AddressEditor.postal_element_props[i], addr_editor.entries[i].get_text ());
var details = new PostalAddressFieldDetails(new_value, row_entry.value.details.parameters);
new_details.add (details);