[geary/wip/765516-gtk-widget-conversation-viewer: 130/142] Set GTK CSS classes on conversation email for sent, starred and unread.



commit a1e3c2ddc5990adea3ec7fb5c51e984038995205
Author: Michael James Gratton <mike vee net>
Date:   Wed Aug 17 22:23:22 2016 +1000

    Set GTK CSS classes on conversation email for sent, starred and unread.

 .../conversation-viewer/conversation-email.vala    |   23 +++++++++++--------
 .../conversation-viewer/conversation-listbox.vala  |   16 +++++++++++++
 .../conversation-viewer/conversation-viewer.vala   |    1 +
 3 files changed, 30 insertions(+), 10 deletions(-)
---
diff --git a/src/client/conversation-viewer/conversation-email.vala 
b/src/client/conversation-viewer/conversation-email.vala
index 14f136a..fd39aec 100644
--- a/src/client/conversation-viewer/conversation-email.vala
+++ b/src/client/conversation-viewer/conversation-email.vala
@@ -223,6 +223,9 @@ public class ConversationEmail : Gtk.Box {
     private const string ACTION_VIEW_SOURCE = "view_source";
 
     private const string MANUAL_READ_CLASS = "geary-manual-read";
+    private const string SENT_CLASS = "geary-sent";
+    private const string STARRED_CLASS = "geary-starred";
+    private const string UNREAD_CLASS = "geary-unread";
 
     /** The specific email that is displayed by this view. */
     public Geary.Email email { get; private set; }
@@ -364,10 +367,15 @@ public class ConversationEmail : Gtk.Box {
      */
     public ConversationEmail(Geary.Email email,
                              Geary.ContactStore contact_store,
+                             bool is_sent,
                              bool is_draft) {
         this.email = email;
         this.contact_store = contact_store;
 
+        if (is_sent) {
+            get_style_context().add_class(SENT_CLASS);
+        }
+
         add_action(ACTION_FORWARD).activate.connect(() => {
                 forward_message();
             });
@@ -454,16 +462,11 @@ public class ConversationEmail : Gtk.Box {
 
         this.primary_message.infobars.add(this.not_saved_infobar);
 
-        // if (email.from != null && email.from.contains_normalized(current_account_information.email)) {
-        //  // XXX set a RO property?
-        //  get_style_context().add_class("geary_sent");
-        // }
-
         pack_start(this.primary_message, true, true, 0);
         update_email_state();
 
         // Add sub_messages container and message viewers if any
-        
+
         Gee.List<Geary.RFC822.Message> sub_messages = message.get_sub_messages();
         if (sub_messages.size > 0) {
             this.primary_message.body.pack_start(
@@ -610,20 +613,20 @@ public class ConversationEmail : Gtk.Box {
         set_action_enabled(ACTION_MARK_UNREAD, !is_unread);
         set_action_enabled(ACTION_MARK_UNREAD_DOWN, !is_unread);
         if (is_unread) {
-            style.add_class("geary_unread");
+            style.add_class(UNREAD_CLASS);
         } else {
-            style.remove_class("geary_unread");
+            style.remove_class(UNREAD_CLASS);
         }
 
         bool is_flagged = (flags != null && flags.is_flagged());
         set_action_enabled(ACTION_STAR, !this.is_collapsed && !is_flagged);
         set_action_enabled(ACTION_UNSTAR, !this.is_collapsed && is_flagged);
         if (is_flagged) {
-            style.add_class("geary_starred");
+            style.add_class(STARRED_CLASS);
             star_button.hide();
             unstar_button.show();
         } else {
-            style.remove_class("geary_starred");
+            style.remove_class(STARRED_CLASS);
             star_button.show();
             unstar_button.hide();
         }
diff --git a/src/client/conversation-viewer/conversation-listbox.vala 
b/src/client/conversation-viewer/conversation-listbox.vala
index 4a3a294..58bac60 100644
--- a/src/client/conversation-viewer/conversation-listbox.vala
+++ b/src/client/conversation-viewer/conversation-listbox.vala
@@ -136,6 +136,9 @@ public class ConversationListBox : Gtk.ListBox {
 
     private Geary.App.EmailStore email_store;
 
+    // Contacts for the account this conversation exists in
+    private Geary.AccountInformation account_info;
+
     // Was this conversation loaded from the drafts folder?
     private bool is_draft_folder;
 
@@ -169,11 +172,13 @@ public class ConversationListBox : Gtk.ListBox {
     public ConversationListBox(Geary.App.Conversation conversation,
                                Geary.ContactStore contact_store,
                                Geary.App.EmailStore? email_store,
+                               Geary.AccountInformation account_info,
                                bool is_draft_folder,
                                Gtk.Adjustment adjustment) {
         this.conversation = conversation;
         this.contact_store = contact_store;
         this.email_store = email_store;
+        this.account_info = account_info;
         this.is_draft_folder = is_draft_folder;
 
         get_style_context().add_class("background");
@@ -509,9 +514,20 @@ public class ConversationListBox : Gtk.ListBox {
         // folder"
         bool is_draft = (this.is_draft_folder && is_in_folder);
 
+        bool is_sent = false;
+        if (email.from != null) {
+            foreach (Geary.RFC822.MailboxAddress from in email.from) {
+                if (this.account_info.has_email_address(from)) {
+                    is_sent = true;
+                    break;
+                }
+            }
+        }
+
         ConversationEmail view = new ConversationEmail(
             email,
             this.contact_store,
+            is_sent,
             is_draft
         );
         view.mark_email.connect(on_mark_email);
diff --git a/src/client/conversation-viewer/conversation-viewer.vala 
b/src/client/conversation-viewer/conversation-viewer.vala
index e98e8c9..62a453b 100644
--- a/src/client/conversation-viewer/conversation-viewer.vala
+++ b/src/client/conversation-viewer/conversation-viewer.vala
@@ -241,6 +241,7 @@ public class ConversationViewer : Gtk.Stack {
             conversation,
             account.get_contact_store(),
             new Geary.App.EmailStore(account),
+            account.information,
             location.special_folder_type == Geary.SpecialFolderType.DRAFTS,
             conversation_page.get_vadjustment()
         );


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