[geary/wip/714922-multiple-addresses] Respect multiple addresses for "Me" in conv. list



commit 9c2b3602d0c549c3d18478cf6c05ae0419b5981d
Author: Charles Lindsay <chaz yorba org>
Date:   Fri Mar 21 17:21:13 2014 -0700

    Respect multiple addresses for "Me" in conv. list

 src/client/application/geary-controller.vala       |    7 ++--
 .../conversation-list/conversation-list-store.vala |    4 +-
 .../formatted-conversation-data.vala               |   30 ++++++++++---------
 3 files changed, 22 insertions(+), 19 deletions(-)
---
diff --git a/src/client/application/geary-controller.vala b/src/client/application/geary-controller.vala
index 01b2d47..d5edcfc 100644
--- a/src/client/application/geary-controller.vala
+++ b/src/client/application/geary-controller.vala
@@ -859,8 +859,9 @@ public class GearyController : Geary.BaseObject {
         account.sending_monitor.start.disconnect(on_sending_started);
         account.sending_monitor.finish.disconnect(on_sending_finished);
         
-        if (main_window.conversation_list_store.account_owner_email == account.information.email)
-            main_window.conversation_list_store.account_owner_email = null;
+        if (main_window.conversation_list_store.account_owner_emails != null
+            && account.information.email in main_window.conversation_list_store.account_owner_emails)
+            main_window.conversation_list_store.account_owner_emails = null;
         main_window.folder_list.remove_account(account);
         
         if (inboxes.has_key(account)) {
@@ -1045,7 +1046,7 @@ public class GearyController : Geary.BaseObject {
             previous_non_search_folder = current_folder;
         
         main_window.conversation_list_store.set_current_folder(current_folder, conversation_cancellable);
-        main_window.conversation_list_store.account_owner_email = current_account.information.email;
+        main_window.conversation_list_store.account_owner_emails = 
current_account.information.get_all_email_addresses();
         
         main_window.main_toolbar.copy_folder_menu.clear();
         main_window.main_toolbar.move_folder_menu.clear();
diff --git a/src/client/conversation-list/conversation-list-store.vala 
b/src/client/conversation-list/conversation-list-store.vala
index 2444f7c..62e1a71 100644
--- a/src/client/conversation-list/conversation-list-store.vala
+++ b/src/client/conversation-list/conversation-list-store.vala
@@ -35,7 +35,7 @@ public class ConversationListStore : Gtk.ListStore {
         }
     }
     
-    public string? account_owner_email { get; set; default = null; }
+    public Gee.List<string>? account_owner_emails { get; set; default = null; }
     public Geary.ProgressMonitor preview_monitor { get; private set; default = 
         new Geary.SimpleProgressMonitor(Geary.ProgressType.ACTIVITY); }
     
@@ -251,7 +251,7 @@ public class ConversationListStore : Gtk.ListStore {
     
     private void set_row(Gtk.TreeIter iter, Geary.App.Conversation conversation, Geary.Email preview) {
         FormattedConversationData conversation_data = new FormattedConversationData(conversation,
-            preview, current_folder, account_owner_email);
+            preview, current_folder, account_owner_emails);
         set(iter,
             Column.CONVERSATION_DATA, conversation_data,
             Column.CONVERSATION_OBJECT, conversation);
diff --git a/src/client/conversation-list/formatted-conversation-data.vala 
b/src/client/conversation-list/formatted-conversation-data.vala
index 65e02ae..209e04f 100644
--- a/src/client/conversation-list/formatted-conversation-data.vala
+++ b/src/client/conversation-list/formatted-conversation-data.vala
@@ -30,12 +30,12 @@ public class FormattedConversationData : Geary.BaseObject {
             this.is_unread = is_unread;
         }
         
-        public string get_full_markup(string normalized_account_key) {
-            return get_as_markup((key == normalized_account_key) ? ME : address.get_short_address());
+        public string get_full_markup(Gee.List<string> normalized_account_emails) {
+            return get_as_markup((key in normalized_account_emails) ? ME : address.get_short_address());
         }
         
-        public string get_short_markup(string normalized_account_key) {
-            if (key == normalized_account_key)
+        public string get_short_markup(Gee.List<string> normalized_account_emails) {
+            if (key in normalized_account_emails)
                 return get_as_markup(ME);
             
             string short_address = address.get_short_address().strip();
@@ -45,17 +45,17 @@ public class FormattedConversationData : Geary.BaseObject {
                 string[] tokens = short_address.split(", ", 2);
                 short_address = tokens[1].strip();
                 if (Geary.String.is_empty(short_address))
-                    return get_full_markup(normalized_account_key);
+                    return get_full_markup(normalized_account_emails);
             }
             
             // use first name as delimited by a space
             string[] tokens = short_address.split(" ", 2);
             if (tokens.length < 1)
-                return get_full_markup(normalized_account_key);
+                return get_full_markup(normalized_account_emails);
             
             string first_name = tokens[0].strip();
             if (Geary.String.is_empty_or_whitespace(first_name))
-                return get_full_markup(normalized_account_key);
+                return get_full_markup(normalized_account_emails);
             
             return get_as_markup(first_name);
         }
@@ -89,17 +89,17 @@ public class FormattedConversationData : Geary.BaseObject {
     public Geary.Email? preview { get; private set; default = null; }
     
     private Geary.App.Conversation? conversation = null;
-    private string? account_owner_email = null;
+    private Gee.List<string>? account_owner_emails = null;
     private bool use_to = true;
     private CountBadge count_badge = new CountBadge(2);
     
     // Creates a formatted message data from an e-mail.
     public FormattedConversationData(Geary.App.Conversation conversation, Geary.Email preview,
-        Geary.Folder folder, string account_owner_email) {
+        Geary.Folder folder, Gee.List<string> account_owner_emails) {
         assert(preview.fields.fulfills(ConversationListStore.REQUIRED_FIELDS));
         
         this.conversation = conversation;
-        this.account_owner_email = account_owner_email;
+        this.account_owner_emails = account_owner_emails;
         use_to = (folder != null) && folder.special_folder_type.is_outgoing();
         
         // Load preview-related data.
@@ -173,10 +173,12 @@ public class FormattedConversationData : Geary.BaseObject {
     }
     
     private string get_participants_markup(Gtk.Widget widget, bool selected) {
-        if (conversation == null || account_owner_email == null)
+        if (conversation == null || account_owner_emails == null || account_owner_emails.size == 0)
             return "";
         
-        string normalized_account_owner_email = account_owner_email.normalize().casefold();
+        Gee.ArrayList<string> normalized_account_owner_emails = Geary.traverse<string>(account_owner_emails)
+            .map<string>(e => e.normalize().casefold())
+            .to_array_list();
         
         // Build chronological list of AuthorDisplay records, setting to unread if any message by
         // that author is unread
@@ -210,14 +212,14 @@ public class FormattedConversationData : Geary.BaseObject {
             rgba_to_markup(get_foreground_rgba(widget, selected))));
         if (list.size == 1) {
             // if only one participant, use full name
-            builder.append(list[0].get_full_markup(normalized_account_owner_email));
+            builder.append(list[0].get_full_markup(normalized_account_owner_emails));
         } else {
             bool first = true;
             foreach (ParticipantDisplay participant in list) {
                 if (!first)
                     builder.append(", ");
                 
-                builder.append(participant.get_short_markup(normalized_account_owner_email));
+                builder.append(participant.get_short_markup(normalized_account_owner_emails));
                 first = false;
             }
         }


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