[evolution/gnome-41] I#1609 - EMinicard: Hide Nickname, when matches Full name



commit a4a74afb9f9cf52292837336a29681685f930fa4
Author: Milan Crha <mcrha redhat com>
Date:   Fri Sep 17 12:06:47 2021 +0200

    I#1609 - EMinicard: Hide Nickname, when matches Full name
    
    Closes https://gitlab.gnome.org/GNOME/evolution/-/issues/1609

 .../gui/widgets/e-addressbook-reflow-adapter.c        |  3 +++
 src/addressbook/gui/widgets/e-minicard.c              |  3 +++
 src/addressbook/gui/widgets/eab-gui-util.c            | 19 +++++++++++++++++++
 src/addressbook/gui/widgets/eab-gui-util.h            |  1 +
 4 files changed, 26 insertions(+)
---
diff --git a/src/addressbook/gui/widgets/e-addressbook-reflow-adapter.c 
b/src/addressbook/gui/widgets/e-addressbook-reflow-adapter.c
index 01363106d1..299dfcd01c 100644
--- a/src/addressbook/gui/widgets/e-addressbook-reflow-adapter.c
+++ b/src/addressbook/gui/widgets/e-addressbook-reflow-adapter.c
@@ -175,6 +175,9 @@ addressbook_height (EReflowModel *erm,
                if (field == E_CONTACT_FAMILY_NAME || field == E_CONTACT_GIVEN_NAME)
                        continue;
 
+               if (field == E_CONTACT_NICKNAME && eab_fullname_matches_nickname (contact))
+                       continue;
+
                string = e_contact_get (contact, field);
                if (string && *string) {
                        gint this_height;
diff --git a/src/addressbook/gui/widgets/e-minicard.c b/src/addressbook/gui/widgets/e-minicard.c
index d765ce1434..91c87eb7c3 100644
--- a/src/addressbook/gui/widgets/e-minicard.c
+++ b/src/addressbook/gui/widgets/e-minicard.c
@@ -1046,6 +1046,9 @@ remodel (EMinicard *e_minicard)
                        if (field == E_CONTACT_FULL_NAME && is_list)
                                continue;
 
+                       if (field == E_CONTACT_NICKNAME && eab_fullname_matches_nickname 
(e_minicard->contact))
+                               continue;
+
                        if (field == E_CONTACT_EMAIL_1 || field == E_CONTACT_EMAIL_2 || field == 
E_CONTACT_EMAIL_3 || field == E_CONTACT_EMAIL_4) {
                                if (email_rendered)
                                        continue;
diff --git a/src/addressbook/gui/widgets/eab-gui-util.c b/src/addressbook/gui/widgets/eab-gui-util.c
index 6d41d4b401..11397a9915 100644
--- a/src/addressbook/gui/widgets/eab-gui-util.c
+++ b/src/addressbook/gui/widgets/eab-gui-util.c
@@ -1114,3 +1114,22 @@ eab_format_address (EContact *contact,
 
        return result;
 }
+
+gboolean
+eab_fullname_matches_nickname (EContact *contact)
+{
+       gchar *nickname, *fullname;
+       gboolean same;
+
+       g_return_val_if_fail (E_IS_CONTACT (contact), FALSE);
+
+       nickname = e_contact_get (contact, E_CONTACT_NICKNAME);
+       fullname = e_contact_get (contact, E_CONTACT_FULL_NAME);
+       same = g_strcmp0 (nickname && *nickname ? nickname : NULL,
+                         fullname && *fullname ? fullname : NULL) == 0;
+
+       g_free (nickname);
+       g_free (fullname);
+
+       return same;
+}
diff --git a/src/addressbook/gui/widgets/eab-gui-util.h b/src/addressbook/gui/widgets/eab-gui-util.h
index f808aca68d..98c3f7c03e 100644
--- a/src/addressbook/gui/widgets/eab-gui-util.h
+++ b/src/addressbook/gui/widgets/eab-gui-util.h
@@ -56,6 +56,7 @@ ESource *     eab_select_source               (ESourceRegistry *registry,
 
 gchar *                eab_format_address              (EContact *contact,
                                                 EContactField address_type);
+gboolean       eab_fullname_matches_nickname   (EContact *contact);
 
 G_END_DECLS
 


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