diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/tab-chrome.c | 39 |
1 files changed, 28 insertions, 11 deletions
diff --git a/src/tab-chrome.c b/src/tab-chrome.c index 72b42ba..4a0e076 100644 --- a/src/tab-chrome.c +++ b/src/tab-chrome.c @@ -557,7 +557,7 @@ navigation_toolbar_new(MqTabChrome *chrome, const gchar *uri) } static void -find_search(MqTabChrome *chrome) +find_search(MqTabChrome *chrome, gboolean forward) { guint32 find_options; @@ -565,6 +565,9 @@ find_search(MqTabChrome *chrome) if (!chrome->find_match_case) { find_options |= WEBKIT_FIND_OPTIONS_CASE_INSENSITIVE; } + if (!forward) { + find_options |= WEBKIT_FIND_OPTIONS_BACKWARDS; + } webkit_find_controller_search(chrome->find_controller, gtk_entry_get_text(GTK_ENTRY(chrome->find_search_entry)), find_options, G_MAXUINT); @@ -581,13 +584,27 @@ find_search_finished(MqTabChrome *chrome) static void find_search_changed_cb(GtkSearchEntry G_GNUC_UNUSED *entry, MqTabChrome *chrome) { - find_search(chrome); + find_search(chrome, TRUE); } -static void -find_search_activate_cb(GtkEntry G_GNUC_UNUSED *entry, MqTabChrome *chrome) -{ - find_search(chrome); +static gboolean +find_search_key_press_event_cb(GtkSearchEntry G_GNUC_UNUSED *entry, + GdkEventKey *event, MqTabChrome *chrome) +{ + switch (event->keyval) { + case GDK_KEY_Escape: + gtk_revealer_set_reveal_child( + GTK_REVEALER(chrome->find_revealer), FALSE); + find_search_finished(chrome); + return TRUE; + case GDK_KEY_Return: + case GDK_KEY_KP_Enter: + case GDK_KEY_ISO_Enter: + find_search(chrome, !(event->state & GDK_SHIFT_MASK)); + return TRUE; + default: + return FALSE; + } } static void @@ -598,7 +615,7 @@ find_prev_clicked_cb(GtkButton G_GNUC_UNUSED *button, MqTabChrome *chrome) if (chrome->find_searching) { webkit_find_controller_search_previous(chrome->find_controller); } else { - find_search(chrome); + find_search(chrome, FALSE); } } @@ -610,7 +627,7 @@ find_next_clicked_cb(GtkButton G_GNUC_UNUSED *button, MqTabChrome *chrome) if (chrome->find_searching) { webkit_find_controller_search_next(chrome->find_controller); } else { - find_search(chrome); + find_search(chrome, TRUE); } } @@ -618,7 +635,7 @@ static void find_match_case_toggled_cb(GtkToggleButton *toggle_button, MqTabChrome *chrome) { chrome->find_match_case = gtk_toggle_button_get_active(toggle_button); - find_search(chrome); + find_search(chrome, TRUE); } static void @@ -642,8 +659,8 @@ find_toolbar_new(MqTabChrome *chrome) chrome->find_search_entry = gtk_search_entry_new(); g_signal_connect(chrome->find_search_entry, "search-changed", G_CALLBACK(find_search_changed_cb), chrome); - g_signal_connect(chrome->find_search_entry, "activate", - G_CALLBACK(find_search_activate_cb), chrome); + g_signal_connect(chrome->find_search_entry, "key-press-event", + G_CALLBACK(find_search_key_press_event_cb), chrome); /* Previous button */ prev_button = gtk_button_new_from_icon_name("go-up", |