[devhelp] Window: clear search in all GtkNotebook tabs
- From: Sébastien Wilmet <swilmet src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [devhelp] Window: clear search in all GtkNotebook tabs
- Date: Fri, 2 Feb 2018 18:02:27 +0000 (UTC)
commit 2f0543a86f15340dbb32902353aa281942c97a0e
Author: Sébastien Wilmet <swilmet gnome org>
Date: Fri Feb 2 17:56:39 2018 +0100
Window: clear search in all GtkNotebook tabs
The search was cleared only in the active tab.
src/dh-window.c | 48 ++++++++++++++++++++++++++++--------------------
1 files changed, 28 insertions(+), 20 deletions(-)
---
diff --git a/src/dh-window.c b/src/dh-window.c
index 3c57957..6f5105d 100644
--- a/src/dh-window.c
+++ b/src/dh-window.c
@@ -82,9 +82,6 @@ static void findbar_find_next (DhWindow *window);
static void window_find_previous_cb (GtkWidget *widget,
DhWindow *window);
static void findbar_find_previous (DhWindow *window);
-static void on_search_mode_enabled_changed (GtkSearchBar *search_bar,
- GParamSpec *pspec,
- DhWindow *window);
static void on_search_entry_activated (GtkEntry *entry,
DhWindow *window);
static gboolean on_search_entry_key_press (GtkEntry *entry,
@@ -612,6 +609,33 @@ sidebar_link_selected_cb (DhSidebar *sidebar,
}
static void
+search_mode_enabled_notify_cb (GtkSearchBar *search_bar,
+ GParamSpec *pspec,
+ DhWindow *window)
+{
+ DhWindowPrivate *priv = dh_window_get_instance_private (window);
+ gint n_pages;
+ gint page_num;
+
+ if (gtk_search_bar_get_search_mode (search_bar))
+ return;
+
+ n_pages = gtk_notebook_get_n_pages (priv->notebook);
+
+ for (page_num = 0; page_num < n_pages; page_num++) {
+ GtkWidget *page;
+ WebKitWebView *view;
+ WebKitFindController *find_controller;
+
+ page = gtk_notebook_get_nth_page (priv->notebook, page_num);
+ view = g_object_get_data (G_OBJECT (page), TAB_WEB_VIEW_KEY);
+
+ find_controller = webkit_web_view_get_find_controller (view);
+ webkit_find_controller_search_finish (find_controller);
+ }
+}
+
+static void
notebook_switch_page_after_cb (GtkNotebook *notebook,
GtkWidget *new_page,
guint new_page_num,
@@ -676,7 +700,7 @@ dh_window_init (DhWindow *window)
g_signal_connect (priv->search_bar,
"notify::search-mode-enabled",
- G_CALLBACK (on_search_mode_enabled_changed),
+ G_CALLBACK (search_mode_enabled_notify_cb),
window);
g_signal_connect (priv->search_entry,
@@ -1059,22 +1083,6 @@ window_find_previous_cb (GtkWidget *widget,
}
static void
-on_search_mode_enabled_changed (GtkSearchBar *search_bar,
- GParamSpec *pspec,
- DhWindow *window)
-{
- if (!gtk_search_bar_get_search_mode (search_bar)) {
- WebKitWebView *view;
- WebKitFindController *find_controller;
-
- view = window_get_active_web_view (window);
-
- find_controller = webkit_web_view_get_find_controller (view);
- webkit_find_controller_search_finish (find_controller);
- }
-}
-
-static void
on_search_entry_activated (GtkEntry *entry,
DhWindow *window)
{
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]