[evolution] I#190 - [Meeting editor] Show email addresses when needed



commit 09a7a16a5f2e6595a773c3804f08f10986137b17
Author: Milan Crha <mcrha redhat com>
Date:   Mon Oct 22 14:38:50 2018 +0200

    I#190 - [Meeting editor] Show email addresses when needed
    
    Closes https://gitlab.gnome.org/GNOME/evolution/issues/190

 src/calendar/gui/e-meeting-attendee.c           | 24 +++++++
 src/calendar/gui/e-meeting-attendee.h           |  3 +
 src/calendar/gui/e-meeting-list-view.c          | 14 +++-
 src/calendar/gui/e-meeting-store.c              | 85 +++++++++++++++++++++++--
 src/calendar/gui/e-meeting-store.h              |  3 +
 src/modules/settings/e-settings-meeting-store.c |  9 +++
 6 files changed, 133 insertions(+), 5 deletions(-)
---
diff --git a/src/calendar/gui/e-meeting-attendee.c b/src/calendar/gui/e-meeting-attendee.c
index abca018ee7..3c50466daf 100644
--- a/src/calendar/gui/e-meeting-attendee.c
+++ b/src/calendar/gui/e-meeting-attendee.c
@@ -51,6 +51,7 @@ struct _EMeetingAttendeePrivate {
 
        EMeetingAttendeeEditLevel edit_level;
 
+       gboolean show_address;
        gboolean has_calendar_info;
 
        GArray *busy_periods;
@@ -176,6 +177,7 @@ e_meeting_attendee_init (EMeetingAttendee *ia)
        ia->priv->language = string_test (NULL);
 
        ia->priv->edit_level = E_MEETING_ATTENDEE_EDIT_FULL;
+       ia->priv->show_address = FALSE;
        ia->priv->has_calendar_info = FALSE;
 
        ia->priv->busy_periods = g_array_new (FALSE, FALSE, sizeof (EMeetingFreeBusyPeriod));
@@ -720,6 +722,28 @@ ensure_periods_sorted (EMeetingAttendee *ia)
        priv->busy_periods_sorted = TRUE;
 }
 
+gboolean
+e_meeting_attendee_get_show_address (EMeetingAttendee *ia)
+{
+       g_return_val_if_fail (E_IS_MEETING_ATTENDEE (ia), FALSE);
+
+       return ia->priv->show_address;
+}
+
+void
+e_meeting_attendee_set_show_address (EMeetingAttendee *ia,
+                                    gboolean show_address)
+{
+       g_return_if_fail (E_IS_MEETING_ATTENDEE (ia));
+
+       if ((ia->priv->show_address ? 1 : 0) == (show_address ? 1 : 0))
+               return;
+
+       ia->priv->show_address = show_address;
+
+       notify_changed (ia);
+}
+
 gboolean
 e_meeting_attendee_get_has_calendar_info (EMeetingAttendee *ia)
 {
diff --git a/src/calendar/gui/e-meeting-attendee.h b/src/calendar/gui/e-meeting-attendee.h
index 581e1b5612..a345ff6b42 100644
--- a/src/calendar/gui/e-meeting-attendee.h
+++ b/src/calendar/gui/e-meeting-attendee.h
@@ -122,6 +122,9 @@ EMeetingAttendeeType e_meeting_attendee_get_atype (EMeetingAttendee *ia);
 EMeetingAttendeeEditLevel e_meeting_attendee_get_edit_level (EMeetingAttendee *ia);
 void e_meeting_attendee_set_edit_level (EMeetingAttendee *ia, EMeetingAttendeeEditLevel level);
 
+gboolean e_meeting_attendee_get_show_address (EMeetingAttendee *ia);
+void e_meeting_attendee_set_show_address (EMeetingAttendee *ia, gboolean show_address);
+
 gboolean e_meeting_attendee_get_has_calendar_info (EMeetingAttendee *ia);
 void e_meeting_attendee_set_has_calendar_info (EMeetingAttendee *ia, gboolean has_calendar_info);
 
diff --git a/src/calendar/gui/e-meeting-list-view.c b/src/calendar/gui/e-meeting-list-view.c
index 083d71f763..6ba763f78e 100644
--- a/src/calendar/gui/e-meeting-list-view.c
+++ b/src/calendar/gui/e-meeting-list-view.c
@@ -390,6 +390,7 @@ attendee_edited_cb (GtkCellRenderer *renderer,
                                e_meeting_attendee_set_status (attendee, ICAL_PARTSTAT_NEEDSACTION);
                                e_meeting_attendee_set_delfrom (attendee, g_strdup 
(e_meeting_attendee_get_delfrom (existing_attendee)));
                                e_meeting_attendee_set_fburi (attendee, g_strdup 
(e_meeting_attendee_get_fburi (existing_attendee)));
+                               e_meeting_attendee_set_show_address (attendee, 
e_meeting_attendee_get_show_address (existing_attendee));
                        }
                        e_meeting_list_view_add_attendee_to_name_selector (E_MEETING_LIST_VIEW (view), 
attendee);
                        g_signal_emit_by_name (view, "attendee_added", (gpointer) attendee);
@@ -946,6 +947,7 @@ process_section (EMeetingListView *view,
                        EDestination *dest = l->data;
                        EContact *contact;
                        gchar *fburi = NULL, *name = NULL, *email_addr = NULL;
+                       gboolean show_address = FALSE;
 
                        email_addr = g_strdup (e_destination_get_email (dest));
                        if (email_addr && *email_addr) {
@@ -972,9 +974,18 @@ process_section (EMeetingListView *view,
                        }
 
                        contact = e_destination_get_contact (dest);
-                       if (contact)
+                       if (contact) {
                                fburi = e_contact_get (contact, E_CONTACT_FREEBUSY_URL);
 
+                               if (!e_contact_get (contact, E_CONTACT_IS_LIST)) {
+                                       GList *email_list;
+
+                                       email_list = e_contact_get (contact, E_CONTACT_EMAIL);
+                                       show_address = email_list && email_list->next;
+                                       g_list_free_full (email_list, g_free);
+                               }
+                       }
+
                        if (e_meeting_store_find_attendee (priv->store, email_addr, NULL) == NULL) {
                                EMeetingAttendee *ia = e_meeting_store_add_attendee_with_defaults 
(priv->store);
 
@@ -983,6 +994,7 @@ process_section (EMeetingListView *view,
                                if (role == ICAL_ROLE_NONPARTICIPANT)
                                        e_meeting_attendee_set_cutype (ia, ICAL_CUTYPE_RESOURCE);
                                e_meeting_attendee_set_cn (ia, g_strdup (name));
+                               e_meeting_attendee_set_show_address (ia, show_address);
 
                                if (fburi) {
                                        e_meeting_attendee_set_fburi (ia, fburi);
diff --git a/src/calendar/gui/e-meeting-store.c b/src/calendar/gui/e-meeting-store.c
index 724c1cd62b..a7e7b6e7e6 100644
--- a/src/calendar/gui/e-meeting-store.c
+++ b/src/calendar/gui/e-meeting-store.c
@@ -63,6 +63,8 @@ struct _EMeetingStorePrivate {
 
        guint num_threads;
        guint num_queries;
+
+       gboolean show_address;
 };
 
 #define BUF_SIZE 1024
@@ -90,6 +92,7 @@ enum {
        PROP_DEFAULT_REMINDER_INTERVAL,
        PROP_DEFAULT_REMINDER_UNITS,
        PROP_FREE_BUSY_TEMPLATE,
+       PROP_SHOW_ADDRESS,
        PROP_TIMEZONE
 };
 
@@ -396,18 +399,30 @@ get_value (GtkTreeModel *model,
        case E_MEETING_STORE_ATTENDEE_COL:
                g_value_init (value, G_TYPE_STRING);
                cn = e_meeting_attendee_get_cn (attendee);
-               if (strcmp (cn, ""))
-                       g_value_set_string (value, cn);
-               else
+               if (cn && *cn) {
+                       if (e_meeting_store_get_show_address (store) ||
+                           e_meeting_attendee_get_show_address (attendee)) {
+                               const gchar *email = itip_strip_mailto (e_meeting_attendee_get_address 
(attendee));
+
+                               if (email && *email) {
+                                       g_value_take_string (value, camel_internet_address_format_address 
(cn, email));
+                               } else {
+                                       g_value_set_string (value, cn);
+                               }
+                       } else {
+                               g_value_set_string (value, cn);
+                       }
+               } else {
                        g_value_set_string (
                                value, itip_strip_mailto (
                                e_meeting_attendee_get_address (attendee)));
+               }
                break;
        case E_MEETING_STORE_ATTENDEE_UNDERLINE_COL:
                cn = e_meeting_attendee_get_cn (attendee);
                g_value_init (value, PANGO_TYPE_UNDERLINE);
                g_value_set_enum (
-                       value, strcmp ("", cn) == 0 ?
+                       value, (!cn || !*cn) ?
                        PANGO_UNDERLINE_NONE : PANGO_UNDERLINE_SINGLE);
        }
 }
@@ -656,6 +671,12 @@ meeting_store_set_property (GObject *object,
                                g_value_get_string (value));
                        return;
 
+               case PROP_SHOW_ADDRESS:
+                       e_meeting_store_set_show_address (
+                               E_MEETING_STORE (object),
+                               g_value_get_boolean (value));
+                       return;
+
                case PROP_TIMEZONE:
                        e_meeting_store_set_timezone (
                                E_MEETING_STORE (object),
@@ -701,6 +722,13 @@ meeting_store_get_property (GObject *object,
                                E_MEETING_STORE (object)));
                        return;
 
+               case PROP_SHOW_ADDRESS:
+                       g_value_set_boolean (
+                               value,
+                               e_meeting_store_get_show_address (
+                               E_MEETING_STORE (object)));
+                       return;
+
                case PROP_TIMEZONE:
                        g_value_set_pointer (
                                value,
@@ -800,6 +828,17 @@ e_meeting_store_class_init (EMeetingStoreClass *class)
                        NULL,
                        G_PARAM_READWRITE));
 
+       g_object_class_install_property (
+               object_class,
+               PROP_SHOW_ADDRESS,
+               g_param_spec_boolean (
+                       "show-address",
+                       "Show email addresses",
+                       NULL,
+                       FALSE,
+                       G_PARAM_READWRITE |
+                       G_PARAM_CONSTRUCT));
+
        g_object_class_install_property (
                object_class,
                PROP_TIMEZONE,
@@ -952,6 +991,44 @@ e_meeting_store_set_timezone (EMeetingStore *store,
        g_object_notify (G_OBJECT (store), "timezone");
 }
 
+gboolean
+e_meeting_store_get_show_address (EMeetingStore *store)
+{
+       g_return_val_if_fail (E_IS_MEETING_STORE (store), FALSE);
+
+       return store->priv->show_address;
+}
+
+void
+e_meeting_store_set_show_address (EMeetingStore *store,
+                                 gboolean show_address)
+{
+       GtkTreeModel *model;
+       guint ii;
+
+       g_return_if_fail (E_IS_MEETING_STORE (store));
+
+       if ((store->priv->show_address ? 1 : 0) == (show_address ? 1 : 0))
+               return;
+
+       store->priv->show_address = show_address;
+
+       model = GTK_TREE_MODEL (store);
+
+       for (ii = 0; ii < store->priv->attendees->len; ii++) {
+               GtkTreePath *path;
+               GtkTreeIter iter;
+
+               path = gtk_tree_path_new ();
+               gtk_tree_path_append_index (path, ii);
+               get_iter (model, &iter, path);
+               gtk_tree_model_row_changed (model, path, &iter);
+               gtk_tree_path_free (path);
+       }
+
+       g_object_notify (G_OBJECT (store), "show-address");
+}
+
 static void
 attendee_changed_cb (EMeetingAttendee *attendee,
                      gpointer data)
diff --git a/src/calendar/gui/e-meeting-store.h b/src/calendar/gui/e-meeting-store.h
index 364f0e02f8..c587d78e96 100644
--- a/src/calendar/gui/e-meeting-store.h
+++ b/src/calendar/gui/e-meeting-store.h
@@ -108,6 +108,9 @@ void                e_meeting_store_set_free_busy_template
 icaltimezone * e_meeting_store_get_timezone    (EMeetingStore *meeting_store);
 void           e_meeting_store_set_timezone    (EMeetingStore *meeting_store,
                                                 icaltimezone *timezone);
+gboolean       e_meeting_store_get_show_address(EMeetingStore *store);
+void           e_meeting_store_set_show_address(EMeetingStore *store,
+                                                gboolean show_address);
 void           e_meeting_store_add_attendee    (EMeetingStore *meeting_store,
                                                 EMeetingAttendee *attendee);
 EMeetingAttendee *
diff --git a/src/modules/settings/e-settings-meeting-store.c b/src/modules/settings/e-settings-meeting-store.c
index 525995976c..dc9a6a44bb 100644
--- a/src/modules/settings/e-settings-meeting-store.c
+++ b/src/modules/settings/e-settings-meeting-store.c
@@ -100,6 +100,15 @@ settings_meeting_store_constructed (GObject *object)
 
        g_object_unref (settings);
 
+       settings = e_util_ref_settings ("org.gnome.evolution.addressbook");
+
+       g_settings_bind (
+               settings, "completion-show-address",
+               extensible, "show-address",
+               G_SETTINGS_BIND_GET);
+
+       g_object_unref (settings);
+
        /* Chain up to parent's constructed() method. */
        G_OBJECT_CLASS (e_settings_meeting_store_parent_class)->constructed (object);
 }


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