Commit ac6fe5aa authored by kartoffelsalat's avatar kartoffelsalat Committed by Sébastien Wilmet

Search: take advantage of the GtkSearchEntry signals

To make the Ctrl+G and Ctrl+Shift+G shortcuts work.

Fixes #41
parent 10d842c7
......@@ -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)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment