[evolution/gnome-3-28] [EContactEditor] Do not store empty values in vCard



commit 3b1b6f612ace8b5b652e051a13201116bdea0d62
Author: Milan Crha <mcrha redhat com>
Date:   Thu Jun 21 17:14:05 2018 +0200

    [EContactEditor] Do not store empty values in vCard
    
    Simple values like Notes, Nickname, URLs and so on could be stored
    in the vCard on Save even when they had been empty, which is not
    needed, thus better to skip them and remove attributes instead,
    if needed.

 src/addressbook/gui/contact-editor/e-contact-editor.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)
---
diff --git a/src/addressbook/gui/contact-editor/e-contact-editor.c 
b/src/addressbook/gui/contact-editor/e-contact-editor.c
index 571be7dde9..32183a1baf 100644
--- a/src/addressbook/gui/contact-editor/e-contact-editor.c
+++ b/src/addressbook/gui/contact-editor/e-contact-editor.c
@@ -2845,7 +2845,7 @@ extract_simple_field (EContactEditor *editor,
 
        if (GTK_IS_ENTRY (widget)) {
                const gchar *text = gtk_entry_get_text (GTK_ENTRY (widget));
-               e_contact_set (contact, field_id, (gchar *) text);
+               e_contact_set (contact, field_id, (text && *text) ? (gchar *) text : NULL);
 
        } else if (GTK_IS_COMBO_BOX_TEXT (widget)) {
                gchar *text = NULL;
@@ -2859,7 +2859,7 @@ extract_simple_field (EContactEditor *editor,
                if (!text)
                        text = gtk_combo_box_text_get_active_text (GTK_COMBO_BOX_TEXT (widget));
 
-               e_contact_set (contact, field_id, text);
+               e_contact_set (contact, field_id, (text && *text) ? text : NULL);
 
                g_free (text);
        } else if (GTK_IS_COMBO_BOX (widget)) {
@@ -2885,7 +2885,7 @@ extract_simple_field (EContactEditor *editor,
                                -1);
                }
 
-               e_contact_set (contact, field_id, text);
+               e_contact_set (contact, field_id, (text && *text) ? text : NULL);
 
                g_free (text);
 
@@ -2897,12 +2897,12 @@ extract_simple_field (EContactEditor *editor,
                gtk_text_buffer_get_start_iter (buffer, &start);
                gtk_text_buffer_get_end_iter   (buffer, &end);
                text = gtk_text_buffer_get_text (buffer, &start, &end, FALSE);
-               e_contact_set (contact, field_id, text);
+               e_contact_set (contact, field_id, (text && *text) ? text : NULL);
                g_free (text);
 
        } else if (E_IS_URL_ENTRY (widget)) {
                const gchar *text = gtk_entry_get_text (GTK_ENTRY (widget));
-               e_contact_set (contact, field_id, (gchar *) text);
+               e_contact_set (contact, field_id, (text && *text) ? (gchar *) text : NULL);
 
        } else if (E_IS_DATE_EDIT (widget)) {
                EContactDate date;


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