[geary/wip/765516-gtk-widget-conversation-viewer: 182/207] Explicitly handle find bar being closed, update search terms if set.



commit 124273da456546b46f50938816eba8dfd283fe76
Author: Michael James Gratton <mike vee net>
Date:   Mon Sep 12 20:55:10 2016 +1000

    Explicitly handle find bar being closed, update search terms if set.

 .../conversation-viewer/conversation-viewer.vala   |   27 +++++++++----------
 ui/conversation-viewer.ui                          |    4 +-
 2 files changed, 15 insertions(+), 16 deletions(-)
---
diff --git a/src/client/conversation-viewer/conversation-viewer.vala 
b/src/client/conversation-viewer/conversation-viewer.vala
index 0866206..7c1617c 100644
--- a/src/client/conversation-viewer/conversation-viewer.vala
+++ b/src/client/conversation-viewer/conversation-viewer.vala
@@ -282,9 +282,10 @@ public class ConversationViewer : Gtk.Stack {
     }
 
     [GtkCallback]
-    private void on_find_search_started(Object obj, ParamSpec param) {
-        if (this.conversation_find_bar.get_search_mode()) {
-            if (this.current_list != null) {
+    private void on_find_mode_changed(Object obj, ParamSpec param) {
+        if (this.current_list != null) {
+            if (this.conversation_find_bar.get_search_mode()) {
+                // Find was enabled
                 ConversationEmail? email_view =
                     this.current_list.get_selection_view();
                 if (email_view != null) {
@@ -294,12 +295,20 @@ public class ConversationViewer : Gtk.Stack {
                         this.conversation_find_entry.select_region(0, -1);
                     }
                 }
+            } else {
+                // Find was disabled
+                this.current_list.unmark_search_terms();
+                if (!(this.current_list.location is Geary.SearchFolder)) {
+                    //this.current_list.update_collapsed_state();
+                } else {
+                    this.current_list.load_search_terms.begin();
+                }
             }
         }
     }
 
     [GtkCallback]
-    private void on_find_search_changed(Gtk.SearchEntry entry) {
+    private void on_find_text_changed(Gtk.SearchEntry entry) {
         this.conversation_find_next.set_sensitive(false);
         this.conversation_find_prev.set_sensitive(false);
         if (this.current_list != null) {
@@ -308,16 +317,6 @@ public class ConversationViewer : Gtk.Stack {
                 // Have a search string
                 this.current_list.highlight_search_terms(terms);
                 // XXX scroll to first match
-            } else {
-                // Have no search string
-                // if (location is Geary.SearchFolder) {
-                //     // Re-display the search results
-                //     yield this.current_list.load_search_terms(
-                //         (Geary.SearchFolder) location
-                //     );
-                // } else {
-                    this.current_list.unmark_search_terms();
-                // }
             }
         }
     }
diff --git a/ui/conversation-viewer.ui b/ui/conversation-viewer.ui
index 3ccb870..1c0ac63 100644
--- a/ui/conversation-viewer.ui
+++ b/ui/conversation-viewer.ui
@@ -41,7 +41,7 @@
             <property name="app_paintable">True</property>
             <property name="can_focus">False</property>
             <property name="hexpand">True</property>
-            <signal name="notify::search-mode-enabled" handler="on_find_search_started" swapped="no"/>
+            <signal name="notify::search-mode-enabled" handler="on_find_mode_changed" swapped="no"/>
             <child>
               <object class="GtkGrid">
                 <property name="visible">True</property>
@@ -56,7 +56,7 @@
                     <property name="placeholder_text" translatable="yes">Find in conversation</property>
                     <signal name="next-match" handler="on_find_next" swapped="no"/>
                     <signal name="previous-match" handler="on_find_prev" swapped="no"/>
-                    <signal name="search-changed" handler="on_find_search_changed" swapped="no"/>
+                    <signal name="search-changed" handler="on_find_text_changed" swapped="no"/>
                   </object>
                   <packing>
                     <property name="left_attach">0</property>


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