diff options
author | Chris Toshok <toshok@ximian.com> | 2004-04-18 15:01:50 +0800 |
---|---|---|
committer | Chris Toshok <toshok@src.gnome.org> | 2004-04-18 15:01:50 +0800 |
commit | 415fbd7101ccee054ca4b86d0a2d6ebfaaf736f2 (patch) | |
tree | e09de06a168361f618d780b33b9b1510114771ac /addressbook | |
parent | fb719d2e33d2a72736f02c7d53f4d1efe05e9848 (diff) | |
download | gsoc2013-evolution-415fbd7101ccee054ca4b86d0a2d6ebfaaf736f2.tar.gz gsoc2013-evolution-415fbd7101ccee054ca4b86d0a2d6ebfaaf736f2.tar.zst gsoc2013-evolution-415fbd7101ccee054ca4b86d0a2d6ebfaaf736f2.zip |
new macro. (extract_email): only create/add the attribute if the email
2004-04-18 Chris Toshok <toshok@ximian.com>
* gui/contact-editor/e-contact-editor.c (nonempty): new macro.
(extract_email): only create/add the attribute if the email
address is nonempty.
(extract_im): same, but for im accounts.
(extract_address_record): same, but for addresses.
svn path=/trunk/; revision=25502
Diffstat (limited to 'addressbook')
-rw-r--r-- | addressbook/ChangeLog | 8 | ||||
-rw-r--r-- | addressbook/gui/contact-editor/e-contact-editor.c | 50 |
2 files changed, 42 insertions, 16 deletions
diff --git a/addressbook/ChangeLog b/addressbook/ChangeLog index 21d28f873d..faeb5ac6ab 100644 --- a/addressbook/ChangeLog +++ b/addressbook/ChangeLog @@ -1,3 +1,11 @@ +2004-04-18 Chris Toshok <toshok@ximian.com> + + * gui/contact-editor/e-contact-editor.c (nonempty): new macro. + (extract_email): only create/add the attribute if the email + address is nonempty. + (extract_im): same, but for im accounts. + (extract_address_record): same, but for addresses. + 2004-04-16 Hans Petter Jansson <hpj@ximian.com> * gui/contact-editor/contact-editor.glade: Add "wants HTML" checkbox. diff --git a/addressbook/gui/contact-editor/e-contact-editor.c b/addressbook/gui/contact-editor/e-contact-editor.c index e1e0980dcd..1e25e06b54 100644 --- a/addressbook/gui/contact-editor/e-contact-editor.c +++ b/addressbook/gui/contact-editor/e-contact-editor.c @@ -190,6 +190,8 @@ im_location [] = { "OTHER", N_ ("Other") } }; +#define nonempty(x) ((x) && *(x)) + GType e_contact_editor_get_type (void) { @@ -439,22 +441,26 @@ extract_email (EContactEditor *editor) gint i; for (i = 1; i <= 4; i++) { - EVCardAttribute *attr; gchar *address; gint location; extract_email_record (editor, i, &address, &location); - attr = e_vcard_attribute_new ("", e_contact_vcard_attribute (E_CONTACT_EMAIL)); + if (nonempty (address)) { + EVCardAttribute *attr; + attr = e_vcard_attribute_new ("", e_contact_vcard_attribute (E_CONTACT_EMAIL)); - if (location >= 0) - e_vcard_attribute_add_param_with_value (attr, - e_vcard_attribute_param_new (EVC_TYPE), - email_index_to_location (location)); + if (location >= 0) + e_vcard_attribute_add_param_with_value (attr, + e_vcard_attribute_param_new (EVC_TYPE), + email_index_to_location (location)); - e_vcard_attribute_add_value (attr, address); + e_vcard_attribute_add_value (attr, address); + + attr_list = g_list_append (attr_list, attr); + } - attr_list = g_list_append (attr_list, attr); + g_free (address); } e_contact_set_attributes (editor->contact, E_CONTACT_EMAIL, attr_list); @@ -633,16 +639,20 @@ extract_im (EContactEditor *editor) extract_im_record (editor, i, &service, &name, &location); - attr = e_vcard_attribute_new ("", e_contact_vcard_attribute (im_service [service].field)); + if (nonempty (name)) { + attr = e_vcard_attribute_new ("", e_contact_vcard_attribute (im_service [service].field)); - if (location >= 0) - e_vcard_attribute_add_param_with_value (attr, - e_vcard_attribute_param_new (EVC_TYPE), - im_index_to_location (location)); + if (location >= 0) + e_vcard_attribute_add_param_with_value (attr, + e_vcard_attribute_param_new (EVC_TYPE), + im_index_to_location (location)); - e_vcard_attribute_add_value (attr, name); + e_vcard_attribute_add_value (attr, name); - service_attr_list [service] = g_list_append (service_attr_list [service], attr); + service_attr_list [service] = g_list_append (service_attr_list [service], attr); + } + + g_free (name); } for (i = 0; i < G_N_ELEMENTS (im_service); i++) { @@ -753,7 +763,15 @@ extract_address_record (EContactEditor *editor, gint record) address->code = extract_address_field (editor, record, "zip"); address->country = extract_address_field (editor, record, "country"); - e_contact_set (editor->contact, addresses [record], address); + if (nonempty (address->street) || + nonempty (address->ext) || + nonempty (address->locality) || + nonempty (address->region) || + nonempty (address->code) || + nonempty (address->country)) + e_contact_set (editor->contact, addresses [record], address); + else + e_contact_set (editor->contact, addresses [record], NULL); g_boxed_free (e_contact_address_get_type (), address); } |