[devhelp] Window: better use the GtkSearchEntry API
- From: Sébastien Wilmet <swilmet src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [devhelp] Window: better use the GtkSearchEntry API
- Date: Fri, 9 Feb 2018 21:05:55 +0000 (UTC)
commit ec490feef4fcc817b60b5cbd513f9af0f0fe8fcf
Author: Sébastien Wilmet <swilmet gnome org>
Date: Fri Feb 9 22:01:32 2018 +0100
Window: better use the GtkSearchEntry API
To use standard keybindings for search prev/next.
src/dh-window.c | 51 ++++++++++++++++++++++-----------------------------
1 files changed, 22 insertions(+), 29 deletions(-)
---
diff --git a/src/dh-window.c b/src/dh-window.c
index 7533bbb..c4924cd 100644
--- a/src/dh-window.c
+++ b/src/dh-window.c
@@ -673,38 +673,31 @@ search_changed_cb (GtkEntry *entry,
}
static void
-search_prev_button_clicked_cb (GtkButton *search_prev_button,
- DhWindow *window)
+search_previous_match_cb (GtkSearchEntry *entry,
+ DhWindow *window)
{
search_previous_in_active_web_view (window);
}
static void
-search_next_button_clicked_cb (GtkButton *search_next_button,
- DhWindow *window)
+search_next_match_cb (GtkSearchEntry *entry,
+ DhWindow *window)
{
search_next_in_active_web_view (window);
}
static void
-search_entry_activate_cb (GtkEntry *entry,
- DhWindow *window)
+search_prev_button_clicked_cb (GtkButton *search_prev_button,
+ DhWindow *window)
{
- search_next_in_active_web_view (window);
+ search_previous_in_active_web_view (window);
}
-static gboolean
-search_entry_key_press_event_cb (GtkEntry *entry,
- GdkEventKey *event,
- DhWindow *window)
+static void
+search_next_button_clicked_cb (GtkButton *search_next_button,
+ DhWindow *window)
{
- if (event->keyval == GDK_KEY_Return &&
- event->state & GDK_SHIFT_MASK) {
- search_previous_in_active_web_view (window);
- return GDK_EVENT_STOP;
- }
-
- return GDK_EVENT_PROPAGATE;
+ search_next_in_active_web_view (window);
}
static void
@@ -788,6 +781,16 @@ dh_window_init (DhWindow *window)
G_CALLBACK (search_changed_cb),
window);
+ g_signal_connect (priv->search_entry,
+ "previous-match",
+ G_CALLBACK (search_previous_match_cb),
+ window);
+
+ g_signal_connect (priv->search_entry,
+ "next-match",
+ G_CALLBACK (search_next_match_cb),
+ window);
+
g_signal_connect (priv->search_prev_button,
"clicked",
G_CALLBACK (search_prev_button_clicked_cb),
@@ -798,16 +801,6 @@ dh_window_init (DhWindow *window)
G_CALLBACK (search_next_button_clicked_cb),
window);
- g_signal_connect (priv->search_entry,
- "activate",
- G_CALLBACK (search_entry_activate_cb),
- window);
-
- g_signal_connect (priv->search_entry,
- "key-press-event",
- G_CALLBACK (search_entry_key_press_event_cb),
- window);
-
/* HTML tabs GtkNotebook */
g_signal_connect_after (priv->notebook,
"switch-page",
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]