[gnome-latex] Search: take advantage of the GtkSearchEntry signals
- From: Sébastien Wilmet <swilmet src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-latex] Search: take advantage of the GtkSearchEntry signals
- Date: Sat, 23 Jun 2018 09:55:01 +0000 (UTC)
commit ac6fe5aada834afa15ad49937fa57922c4836b85
Author: Thomas Kluth <t kluth posteo de>
Date: Tue Jun 19 09:22:46 2018 +0200
Search: take advantage of the GtkSearchEntry signals
To make the Ctrl+G and Ctrl+Shift+G shortcuts work.
Fixes https://gitlab.gnome.org/GNOME/gnome-latex/issues/41
src/search.vala | 47 ++++++++++++++++++++++++-----------------------
1 file changed, 24 insertions(+), 23 deletions(-)
---
diff --git a/src/search.vala b/src/search.vala
index ab346d4..263faad 100644
--- a/src/search.vala
+++ b/src/search.vala
@@ -222,27 +222,12 @@ public class SearchAndReplace : GLib.Object
button_close.clicked.connect (hide);
- button_previous.clicked.connect (() =>
- {
- if (_search_context == null)
- return;
-
- TextIter iter;
- TextIter match_start;
- TextIter match_end;
-
- Document doc = _search_context.get_buffer () as Document;
- doc.get_selection_bounds (out iter, null);
-
- if (_search_context.backward (iter, out match_start, out match_end, null))
- {
- doc.select_range (match_start, match_end);
- doc.tab.view.scroll_to_cursor ();
- }
- });
-
button_next.clicked.connect (search_forward);
_entry_find.activate.connect (search_forward);
+ _entry_find.next_match.connect (search_forward);
+
+ button_previous.clicked.connect (search_backward);
+ _entry_find.previous_match.connect (search_backward);
_entry_find.changed.connect (() =>
{
@@ -275,6 +260,7 @@ public class SearchAndReplace : GLib.Object
}
});
+ _entry_find.stop_search.connect (hide);
_entry_find.key_press_event.connect ((event) =>
{
switch (event.keyval)
@@ -285,10 +271,6 @@ public class SearchAndReplace : GLib.Object
_entry_replace.grab_focus ();
return true;
- case Gdk.Key.Escape:
- hide ();
- return true;
-
default:
// propagate the event further
return false;
@@ -512,6 +494,25 @@ public class SearchAndReplace : GLib.Object
}
}
+ private void search_backward ()
+ {
+ if (_search_context == null)
+ return;
+
+ TextIter iter;
+ TextIter match_start;
+ TextIter match_end;
+
+ Document doc = _search_context.get_buffer () as Document;
+ doc.get_selection_bounds (out iter, null);
+
+ if (_search_context.backward (iter, out match_start, out match_end, null))
+ {
+ doc.select_range (match_start, match_end);
+ doc.tab.view.scroll_to_cursor ();
+ }
+ }
+
private void replace ()
{
if (_search_context == null)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]