[geary/mjog/233-entry-undo: 5/5] Add undo support for MainWindow search and find entries



commit 13d71dc73a7437d014ae25c24c6b9784a8418b9f
Author: Michael Gratton <mike vee net>
Date:   Thu Nov 7 12:48:45 2019 +1100

    Add undo support for MainWindow search and find entries

 src/client/components/search-bar.vala                   | 12 +++++++++++-
 src/client/conversation-viewer/conversation-viewer.vala |  6 ++++++
 2 files changed, 17 insertions(+), 1 deletion(-)
---
diff --git a/src/client/components/search-bar.vala b/src/client/components/search-bar.vala
index db1c7920..d79cc8f4 100644
--- a/src/client/components/search-bar.vala
+++ b/src/client/components/search-bar.vala
@@ -11,6 +11,7 @@ public class SearchBar : Gtk.SearchBar {
     public bool search_entry_has_focus { get { return search_entry.has_focus; } }
 
     private Gtk.SearchEntry search_entry = new Gtk.SearchEntry();
+    private Components.EntryUndo search_undo;
     private Geary.ProgressMonitor? search_upgrade_progress_monitor = null;
     private MonitoredProgressBar search_upgrade_progress_bar = new MonitoredProgressBar();
     private Geary.Account? current_account = null;
@@ -29,6 +30,10 @@ public class SearchBar : Gtk.SearchBar {
         });
         search_entry.has_focus = true;
 
+        this.search_undo = new Components.EntryUndo(this.search_entry);
+
+        this.notify["search-mode-enabled"].connect(on_search_mode_changed);
+
         // Search upgrade progress bar.
         search_upgrade_progress_bar.show_text = true;
         search_upgrade_progress_bar.visible = false;
@@ -41,7 +46,7 @@ public class SearchBar : Gtk.SearchBar {
     }
 
     public void set_search_text(string text) {
-        search_entry.text = text;
+        this.search_entry.text = text;
     }
 
     public void give_search_focus() {
@@ -110,4 +115,9 @@ public class SearchBar : Gtk.SearchBar {
             _("Search %s account").printf(current_account.information.display_name));
     }
 
+    private void on_search_mode_changed() {
+        if (!this.search_mode_enabled) {
+            this.search_undo.reset();
+        }
+    }
 }
diff --git a/src/client/conversation-viewer/conversation-viewer.vala 
b/src/client/conversation-viewer/conversation-viewer.vala
index d1386ab6..f7dcde19 100644
--- a/src/client/conversation-viewer/conversation-viewer.vala
+++ b/src/client/conversation-viewer/conversation-viewer.vala
@@ -52,6 +52,7 @@ public class ConversationViewer : Gtk.Stack, Geary.BaseInterface {
 
     [GtkChild]
     internal Gtk.SearchEntry conversation_find_entry;
+    private Components.EntryUndo conversation_find_undo;
 
     [GtkChild]
     private Gtk.Button conversation_find_next;
@@ -126,6 +127,10 @@ public class ConversationViewer : Gtk.Stack, Geary.BaseInterface {
         );
         this.empty_search_page.add(empty_search);
 
+        this.conversation_find_undo = new Components.EntryUndo(
+            this.conversation_find_entry
+        );
+
         // XXX GTK+ Bug 778190 workaround
         new_conversation_scroller();
 
@@ -431,6 +436,7 @@ public class ConversationViewer : Gtk.Stack, Geary.BaseInterface {
                     this.current_list.conversation.base_folder
                     as Geary.SearchFolder
                 );
+                this.conversation_find_undo.reset();
                 if (search_folder != null) {
                     Geary.SearchQuery? search_query = search_folder.search_query;
                     if (search_query != null) {


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