[geary] Fix matching message subject not being highlighted in find/search.



commit 928189f36d6a872bcfa7a0d3acdcae949a175956
Author: Michael James Gratton <mike vee net>
Date:   Thu Feb 23 11:06:05 2017 +1100

    Fix matching message subject not being highlighted in find/search.
    
    Bug 778033
    
    * src/client/conversation-viewer/conversation-message.vala
      (ConversationMessage::highlight_search_terms): Also check the subject
      for matching items and highlight if found.
    
    * src/client/conversation-viewer/conversation-list-box.vala
      (ConversationListBox::EmailRow): Update matching row class to
      disambiguate from matching headers.
    
    * ui/geary.css: Ensure matching subject labels get highlighted.

 .../conversation-viewer/conversation-list-box.vala |    2 +-
 .../conversation-viewer/conversation-message.vala  |   11 +++++++++--
 ui/geary.css                                       |    3 +--
 3 files changed, 11 insertions(+), 5 deletions(-)
---
diff --git a/src/client/conversation-viewer/conversation-list-box.vala 
b/src/client/conversation-viewer/conversation-list-box.vala
index 3073105..30a59c1 100644
--- a/src/client/conversation-viewer/conversation-list-box.vala
+++ b/src/client/conversation-viewer/conversation-list-box.vala
@@ -160,7 +160,7 @@ public class ConversationListBox : Gtk.ListBox {
     private class EmailRow : ConversationRow {
 
 
-        private const string MATCH_CLASS = "geary-match";
+        private const string MATCH_CLASS = "geary-matched";
 
 
         // Has the row been temporarily expanded to show search matches?
diff --git a/src/client/conversation-viewer/conversation-message.vala 
b/src/client/conversation-viewer/conversation-message.vala
index e6a1361..7de0fd2 100644
--- a/src/client/conversation-viewer/conversation-message.vala
+++ b/src/client/conversation-viewer/conversation-message.vala
@@ -19,6 +19,7 @@ public class ConversationMessage : Gtk.Grid {
 
 
     private const string FROM_CLASS = "geary-from";
+    private const string MATCH_CLASS = "geary-match";
     private const string REPLACED_CID_TEMPLATE = "replaced_%02u@geary";
     private const string REPLACED_IMAGE_CLASS = "geary_replaced_inline_image";
 
@@ -39,7 +40,6 @@ public class ConversationMessage : Gtk.Grid {
     private class AddressFlowBoxChild : Gtk.FlowBoxChild {
 
         private const string PRIMARY_CLASS = "geary-primary";
-        private const string MATCH_CLASS = "geary-match";
 
         public enum Type { FROM, OTHER; }
 
@@ -170,6 +170,7 @@ public class ConversationMessage : Gtk.Grid {
     private Gtk.FlowBox from;
     [GtkChild]
     private Gtk.Label subject;
+    private string subject_searchable = "";
     [GtkChild]
     private Gtk.Label date;
 
@@ -362,6 +363,7 @@ public class ConversationMessage : Gtk.Grid {
         if (this.message.subject != null) {
             this.subject.set_text(this.message.subject.value);
             this.subject.set_visible(true);
+            this.subject_searchable = this.message.subject.value.casefold();
         }
         fill_header_addresses(this.to_header, this.message.to);
         fill_header_addresses(this.cc_header, this.message.cc);
@@ -496,7 +498,12 @@ public class ConversationMessage : Gtk.Grid {
         foreach(string raw_match in search_matches) {
             string match = raw_match.casefold();
 
-            debug("Matching: %s", match);
+            if (this.subject_searchable.contains(match)) {
+                this.subject.get_style_context().add_class(MATCH_CLASS);
+                ++headers_found;
+            } else {
+                this.subject.get_style_context().remove_class(MATCH_CLASS);
+            }
 
             foreach (AddressFlowBoxChild address in this.searchable_addresses) {
                 if (address.highlight_search_term(match)) {
diff --git a/ui/geary.css b/ui/geary.css
index c743b0d..5e5bd5e 100644
--- a/ui/geary.css
+++ b/ui/geary.css
@@ -94,8 +94,7 @@ row.geary-folder-popover-list-row > label {
   margin-bottom: 6px;
   border-bottom-width: 1px;
 }
-.conversation-listbox > .list-row.geary-match GtkFlowBox > *.geary-match, /* GTK < 3.20 */
-.conversation-listbox > row.geary-match flowboxchild.geary-match {
+.conversation-listbox *.geary-matched *.geary-match {
   color: @theme_selected_fg_color;
   background: @theme_selected_bg_color;
 }


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