[geary/wip/135-contact-popovers: 10/13] Use client contacts in ContactPopover



commit c8e49ca109d1c0e107f1c9e08424c593bdede538
Author: Michael Gratton <mike vee net>
Date:   Thu Mar 14 22:10:55 2019 +1100

    Use client contacts in ContactPopover
    
    Take the contact's display name, but use the original email address
    since that will be copied, pasted, etc.

 .../conversation-contact-popover.vala                | 20 ++++++++++++++------
 .../conversation-viewer/conversation-message.vala    |  5 +++++
 2 files changed, 19 insertions(+), 6 deletions(-)
---
diff --git a/src/client/conversation-viewer/conversation-contact-popover.vala 
b/src/client/conversation-viewer/conversation-contact-popover.vala
index c781a9dc..24f87002 100644
--- a/src/client/conversation-viewer/conversation-contact-popover.vala
+++ b/src/client/conversation-viewer/conversation-contact-popover.vala
@@ -12,6 +12,8 @@
 public class Conversation.ContactPopover : Gtk.Popover {
 
 
+    public Application.Contact contact { get; private set; }
+
     public Geary.RFC822.MailboxAddress mailbox { get; private set; }
 
     private GLib.Cancellable load_cancellable = new GLib.Cancellable();
@@ -30,17 +32,21 @@ public class Conversation.ContactPopover : Gtk.Popover {
 
 
     public ContactPopover(Gtk.Widget relative_to,
+                          Application.Contact contact,
                           Geary.RFC822.MailboxAddress mailbox) {
         this.relative_to = relative_to;
+        this.contact = contact;
         this.mailbox = mailbox;
-        if (Geary.String.is_empty_or_whitespace(mailbox.name)) {
-            this.contact_name.set_text(mailbox.address);
+
+        string? display_name = contact.display_name;
+        this.contact_name.set_text(display_name);
+
+        if (!contact.display_name_is_email) {
+            this.contact_address.set_text(mailbox.address);
+        } else {
             this.contact_name.vexpand = true;
             this.contact_name.valign = FILL;
             this.contact_address.hide();
-        } else {
-            this.contact_name.set_text(mailbox.name);
-            this.contact_address.set_text(mailbox.address);
         }
     }
 
@@ -82,7 +88,9 @@ public class Conversation.ContactPopover : Gtk.Popover {
             int pixel_size = Application.AvatarStore.PIXEL_SIZE * window_scale;
             try {
                 Gdk.Pixbuf? avatar_buf = yield loader.load(
-                    this.mailbox, pixel_size, this.load_cancellable
+                    this.mailbox,
+                    pixel_size,
+                    this.load_cancellable
                 );
                 if (avatar_buf != null) {
                     this.avatar.set_from_surface(
diff --git a/src/client/conversation-viewer/conversation-message.vala 
b/src/client/conversation-viewer/conversation-message.vala
index 84c8fb73..15d789ef 100644
--- a/src/client/conversation-viewer/conversation-message.vala
+++ b/src/client/conversation-viewer/conversation-message.vala
@@ -169,6 +169,9 @@ public class ConversationMessage : Gtk.Grid, Geary.BaseInterface {
     /** HTML view that displays the message body. */
     internal ConversationWebView web_view { get; private set; }
 
+    private Application.ContactStore contacts;
+
+
     [GtkChild]
     private Gtk.Image avatar;
 
@@ -353,6 +356,7 @@ public class ConversationMessage : Gtk.Grid, Geary.BaseInterface {
                                 Configuration config) {
         base_ref();
         this.load_remote_resources = load_remote_resources;
+        this.contacts = contacts;
 
         if (primary_originator != null) {
             this.primary_originator = contacts.get(primary_originator);
@@ -992,6 +996,7 @@ public class ConversationMessage : Gtk.Grid, Geary.BaseInterface {
 
             Conversation.ContactPopover popover = new Conversation.ContactPopover(
                 address_child,
+                this.contacts.get(address),
                 address
             );
             popover.load_avatar.begin();


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