[evolution] Bug 724647 - Add option to Show full mail addresses in message preview



commit 2f4a3d549bf3ada14131500afc68d8b3406f8ad0
Author: Milan Crha <mcrha redhat com>
Date:   Tue Apr 10 15:01:43 2018 +0200

    Bug 724647 - Add option to Show full mail addresses in message preview

 data/org.gnome.evolution.mail.gschema.xml.in |    5 +++++
 src/em-format/e-mail-formatter-utils.c       |   17 +++++++++++------
 src/libemail-engine/mail-config.c            |   14 ++++++++++++++
 src/libemail-engine/mail-config.h            |    2 ++
 src/mail/mail-config.ui                      |   19 ++++++++++++++++++-
 src/modules/mail/em-mailer-prefs.c           |    6 ++++++
 6 files changed, 56 insertions(+), 7 deletions(-)
---
diff --git a/data/org.gnome.evolution.mail.gschema.xml.in b/data/org.gnome.evolution.mail.gschema.xml.in
index 9400ec8..02f8e2d 100644
--- a/data/org.gnome.evolution.mail.gschema.xml.in
+++ b/data/org.gnome.evolution.mail.gschema.xml.in
@@ -416,6 +416,11 @@
       <_summary>Number of addresses to display in TO/CC/BCC</_summary>
       <_description>This sets the number of addresses to show in default message list view, beyond which a 
“...” is shown.</_description>
     </key>
+    <key name="show-mails-in-preview" type="b">
+      <default>true</default>
+      <_summary>Show mails in headers part of the message preview when name is available</_summary>
+      <_description>When set to false, the mail addresses which contain both the name and the email parts in 
headers like To/Cc/Bcc will be shown only with the name part, without the actual email, with the name made 
clickable.</_description>
+    </key>
     <key name="thread-subject" type="b">
       <default>false</default>
       <_summary>Thread the message-list based on Subject</_summary>
diff --git a/src/em-format/e-mail-formatter-utils.c b/src/em-format/e-mail-formatter-utils.c
index 352f880..c43aec3 100644
--- a/src/em-format/e-mail-formatter-utils.c
+++ b/src/em-format/e-mail-formatter-utils.c
@@ -125,6 +125,7 @@ e_mail_formatter_format_address (EMailFormatter *formatter,
        gint i = 0;
        gchar *str = NULL;
        gint limit = mail_config_get_address_count ();
+       gboolean show_mails = mail_config_get_show_mails_in_preview ();
 
        g_return_val_if_fail (E_IS_MAIL_FORMATTER (formatter), NULL);
        g_return_val_if_fail (out != NULL, NULL);
@@ -143,12 +144,14 @@ e_mail_formatter_format_address (EMailFormatter *formatter,
                        if (name != NULL && *name != '\0') {
                                gchar *real, *mailaddr;
 
-                               if (strchr (a->name, ',') || strchr (a->name, ';'))
-                                       g_string_append_printf (out, "&quot;%s&quot;", name);
-                               else
-                                       g_string_append (out, name);
+                               if (show_mails || no_links) {
+                                       if (strchr (a->name, ',') || strchr (a->name, ';'))
+                                               g_string_append_printf (out, "&quot;%s&quot;", name);
+                                       else
+                                               g_string_append (out, name);
 
-                               g_string_append (out, " &lt;");
+                                       g_string_append (out, " &lt;");
+                               }
 
                                /* rfc2368 for mailto syntax and url encoding extras */
                                if ((real = camel_header_encode_phrase ((guchar *) a->name))) {
@@ -165,12 +168,14 @@ e_mail_formatter_format_address (EMailFormatter *formatter,
                        addr = camel_text_to_html (a->v.addr, flags, 0);
                        if (no_links)
                                g_string_append_printf (out, "%s", addr);
+                       else if (!show_mails && name && *name)
+                               g_string_append_printf (out, "<a href=\"mailto:%s\";>%s</a>", mailto, name);
                        else
                                g_string_append_printf (out, "<a href=\"mailto:%s\";>%s</a>", mailto, addr);
                        g_free (mailto);
                        g_free (addr);
 
-                       if (name != NULL && *name != '\0')
+                       if (name != NULL && *name != '\0' && (show_mails || no_links))
                                g_string_append (out, "&gt;");
                        break;
                case CAMEL_HEADER_ADDRESS_GROUP:
diff --git a/src/libemail-engine/mail-config.c b/src/libemail-engine/mail-config.c
index 8834745..9b9c3bc 100644
--- a/src/libemail-engine/mail-config.c
+++ b/src/libemail-engine/mail-config.c
@@ -37,6 +37,7 @@ typedef struct {
 
        gboolean address_compress;
        gint address_count;
+       gboolean show_mails_in_preview;
 
        GSList *jh_header;
        gboolean jh_check;
@@ -166,6 +167,12 @@ mail_config_get_address_count (void)
        return config->address_count;
 }
 
+gboolean
+mail_config_get_show_mails_in_preview (void)
+{
+       return config->show_mails_in_preview;
+}
+
 /* timeout interval, in seconds, when to call server update */
 gint
 mail_config_get_sync_timeout (void)
@@ -283,6 +290,13 @@ mail_config_init (EMailSession *session)
        config->address_count = g_settings_get_int (
                mail_settings, "address-count");
 
+       g_signal_connect (
+               mail_settings, "changed::show-mails-in-preview",
+               G_CALLBACK (settings_bool_value_changed),
+               &config->show_mails_in_preview);
+       config->show_mails_in_preview = g_settings_get_boolean (
+               mail_settings, "show-mails-in-preview");
+
        /* Junk Configuration */
 
        g_signal_connect (
diff --git a/src/libemail-engine/mail-config.h b/src/libemail-engine/mail-config.h
index 5e440ef..fd42e89 100644
--- a/src/libemail-engine/mail-config.h
+++ b/src/libemail-engine/mail-config.h
@@ -36,6 +36,8 @@ void          mail_config_init                (EMailSession *session);
 /* General Accessor functions */
 
 gint           mail_config_get_address_count   (void);
+gboolean       mail_config_get_show_mails_in_preview
+                                               (void);
 
 /* static utility functions */
 gchar *                mail_config_folder_to_cachename (CamelFolder *folder,
diff --git a/src/mail/mail-config.ui b/src/mail/mail-config.ui
index 3613380..fbf80f4 100644
--- a/src/mail/mail-config.ui
+++ b/src/mail/mail-config.ui
@@ -2870,6 +2870,23 @@
               </packing>
             </child>
             <child>
+              <object class="GtkCheckButton" id="chkShowMailsInPreview">
+                <property name="label" translatable="yes">Show _full mail addresses in message 
preview</property>
+                <property name="visible">True</property>
+                <property name="can_focus">True</property>
+                <property name="receives_default">False</property>
+                <property name="use_underline">True</property>
+                <property name="xalign">0</property>
+                <property name="draw_indicator">True</property>
+                <property name="margin-left">12</property>
+              </object>
+              <packing>
+                <property name="expand">False</property>
+                <property name="fill">False</property>
+                <property name="position">1</property>
+              </packing>
+            </child>
+            <child>
               <object class="GtkAlignment" id="message-headers-alignment">
                 <property name="visible">True</property>
                 <property name="can_focus">False</property>
@@ -2977,7 +2994,7 @@
               <packing>
                 <property name="expand">True</property>
                 <property name="fill">True</property>
-                <property name="position">1</property>
+                <property name="position">2</property>
               </packing>
             </child>
           </object>
diff --git a/src/modules/mail/em-mailer-prefs.c b/src/modules/mail/em-mailer-prefs.c
index 3dea3d4..138287c 100644
--- a/src/modules/mail/em-mailer-prefs.c
+++ b/src/modules/mail/em-mailer-prefs.c
@@ -1409,6 +1409,12 @@ em_mailer_prefs_construct (EMMailerPrefs *prefs,
                widget, "sensitive",
                G_SETTINGS_BIND_GET);
 
+       widget = e_builder_get_widget (prefs->priv->builder, "chkShowMailsInPreview");
+       g_settings_bind (
+               settings, "show-mails-in-preview",
+               widget, "active",
+               G_SETTINGS_BIND_DEFAULT);
+
        container = e_builder_get_widget (prefs->priv->builder, "archive-mail-hbox");
        widget = em_folder_selection_button_new (session, "", _("Choose a folder to archive messages to."));
        gtk_widget_set_hexpand (widget, FALSE);


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