summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorPatrick McDermott <pj@pehjota.net>2017-10-12 14:29:49 (EDT)
committer Patrick McDermott <pj@pehjota.net>2017-10-12 14:29:49 (EDT)
commit81c8f142f03fc304258eb671df9a92b89ecefc46 (patch)
treee05c091c979c23df0c104e67489ad9f30ffe9c65 /src
parentc7fb0dbb261a23cb5b14fb96ea7c96b8ff5b4676 (diff)
downloadmarquee-81c8f142f03fc304258eb671df9a92b89ecefc46.zip
marquee-81c8f142f03fc304258eb671df9a92b89ecefc46.tar.gz
marquee-81c8f142f03fc304258eb671df9a92b89ecefc46.tar.bz2
MqFindToolbar: Add WebKitFindController signal callbacks
Diffstat (limited to 'src')
-rw-r--r--src/find-toolbar.c28
1 files changed, 28 insertions, 0 deletions
diff --git a/src/find-toolbar.c b/src/find-toolbar.c
index 3a2daad..31b5bc4 100644
--- a/src/find-toolbar.c
+++ b/src/find-toolbar.c
@@ -188,6 +188,30 @@ close_clicked_cb(GtkButton G_GNUC_UNUSED *button, MqFindToolbar *find_toolbar)
}
static void
+found_text_cb(WebKitFindController G_GNUC_UNUSED *find_controller,
+ guint match_count, MqFindToolbar *find_toolbar)
+{
+ gchar *text;
+
+ if (match_count == 1) {
+ text = g_strdup("1 match");
+ } else {
+ text = g_strdup_printf("%u matches", match_count);
+ }
+ gtk_label_set_text(GTK_LABEL(find_toolbar->matches_label), text);
+ g_free(text);
+
+}
+
+static void
+failed_to_find_text_cb(WebKitFindController G_GNUC_UNUSED *find_controller,
+ MqFindToolbar *find_toolbar)
+{
+ gtk_label_set_text(GTK_LABEL(find_toolbar->matches_label),
+ "No matches");
+}
+
+static void
mq_find_toolbar_class_init(MqFindToolbarClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS(klass);
@@ -278,6 +302,10 @@ mq_find_toolbar_init(MqFindToolbar *find_toolbar)
find_toolbar->searching = FALSE;
find_toolbar->find_controller = webkit_web_view_get_find_controller(
WEBKIT_WEB_VIEW(find_toolbar->web_view));
+ g_signal_connect(find_toolbar->find_controller, "found-text",
+ G_CALLBACK(found_text_cb), find_toolbar);
+ g_signal_connect(find_toolbar->find_controller, "failed-to-find-text",
+ G_CALLBACK(failed_to_find_text_cb), find_toolbar);
}
GtkWidget *