[gnome-contacts] ContactEditor: Move string constants from Contact
- From: Philip Withnall <pwithnall src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-contacts] ContactEditor: Move string constants from Contact
- Date: Thu, 21 Aug 2014 15:38:20 +0000 (UTC)
commit df2f2b02d87567e681a6bd88a846a7846f0d2d50
Author: Philip Withnall <philip withnall collabora co uk>
Date: Thu Aug 21 16:33:38 2014 +0100
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
src/contacts-contact-editor.vala | 11 +++++++----
src/contacts-contact.vala | 3 ---
2 files changed, 7 insertions(+), 7 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);
diff --git a/src/contacts-contact.vala b/src/contacts-contact.vala
index 83c80b0..d89718b 100644
--- a/src/contacts-contact.vala
+++ b/src/contacts-contact.vala
@@ -670,9 +670,6 @@ public class Contacts.Contact : GLib.Object {
return res;
}
- public static 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 static string[] format_address (PostalAddress addr) {
string[] lines = {};
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]