summaryrefslogtreecommitdiffstats
path: root/src/tab-chrome.c
diff options
context:
space:
mode:
authorPatrick McDermott <pj@pehjota.net>2017-10-08 03:38:23 (EDT)
committer Patrick McDermott <pj@pehjota.net>2017-10-08 03:38:23 (EDT)
commit66b94a7112f6379b0e30ad7a8917ab146e374a20 (patch)
treefb6ce37ee7862588d471d2d545800688840957cb /src/tab-chrome.c
parent268478883c505394b223fbc7c34d1966f8f61867 (diff)
downloadmarquee-66b94a7112f6379b0e30ad7a8917ab146e374a20.zip
marquee-66b94a7112f6379b0e30ad7a8917ab146e374a20.tar.gz
marquee-66b94a7112f6379b0e30ad7a8917ab146e374a20.tar.bz2
MqTabChrome: Add match count label to find bar
Diffstat (limited to 'src/tab-chrome.c')
-rw-r--r--src/tab-chrome.c34
1 files changed, 34 insertions, 0 deletions
diff --git a/src/tab-chrome.c b/src/tab-chrome.c
index e9f5cc7..39efff7 100644
--- a/src/tab-chrome.c
+++ b/src/tab-chrome.c
@@ -586,6 +586,7 @@ find_close(MqTabChrome *chrome)
{
gtk_revealer_set_reveal_child(GTK_REVEALER(chrome->find_revealer),
FALSE);
+ gtk_label_set_text(GTK_LABEL(chrome->find_matches_label), NULL);
find_search_finished(chrome);
}
@@ -690,6 +691,9 @@ find_toolbar_new(MqTabChrome *chrome)
g_signal_connect(match_case_button, "toggled",
G_CALLBACK(find_match_case_toggled_cb), chrome);
+ /* Matches label */
+ chrome->find_matches_label = gtk_label_new(NULL);
+
/* Close button */
close_button = gtk_button_new_from_icon_name("window-close",
GTK_ICON_SIZE_BUTTON);
@@ -706,6 +710,8 @@ find_toolbar_new(MqTabChrome *chrome)
gtk_box_pack_start(GTK_BOX(box), prev_button, FALSE, FALSE, 0);
gtk_box_pack_start(GTK_BOX(box), next_button, FALSE, FALSE, 0);
gtk_box_pack_start(GTK_BOX(box), match_case_button, FALSE, FALSE, 0);
+ gtk_box_pack_start(GTK_BOX(box), chrome->find_matches_label,
+ FALSE, FALSE, 0);
gtk_box_pack_end(GTK_BOX(box), close_button, FALSE, FALSE, 0);
/* Revealer */
@@ -925,6 +931,29 @@ back_forward_list_changed_cb(
}
static void
+find_found_text_cb(WebKitFindController G_GNUC_UNUSED *find_controller,
+ guint match_count, MqTabChrome *chrome)
+{
+ 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(chrome->find_matches_label), text);
+ g_free(text);
+
+}
+
+static void
+find_failed_to_find_text_cb(WebKitFindController G_GNUC_UNUSED *find_controller,
+ MqTabChrome *chrome)
+{
+ gtk_label_set_text(GTK_LABEL(chrome->find_matches_label), "No matches");
+}
+
+static void
connect_web_view(MqTabChrome *chrome)
{
chrome->hovered_link_uri = NULL;
@@ -944,6 +973,11 @@ connect_web_view(MqTabChrome *chrome)
g_signal_connect(
webkit_web_view_get_back_forward_list(chrome->web_view),
"changed", G_CALLBACK(back_forward_list_changed_cb), chrome);
+
+ g_signal_connect(chrome->find_controller, "found-text",
+ G_CALLBACK(find_found_text_cb), chrome);
+ g_signal_connect(chrome->find_controller, "failed-to-find-text",
+ G_CALLBACK(find_failed_to_find_text_cb), chrome);
}
void