BlinkGTK Find-in-Page and Zoom API Reference

Version: 1.2.0-build2
Last updated: 2026-07-29
Language: English |

日本語


About this page

APIs for text search in the displayed page (highlighting and cycling
through matches) and for zoom (changing and reading the display scale).
A reader application's "search the text" box and "make the text bigger"
button are built from these four calls.

Usage

/* Search the page for "layout" and highlight matches */
blink_web_view_find_in_page(view, "layout", TRUE, FALSE, FALSE);

/* Jump to the next match (call repeatedly with find_next=TRUE) */
blink_web_view_find_in_page(view, "layout", TRUE, FALSE, TRUE);

/* Finish searching (TRUE also clears the highlights) */
blink_web_view_stop_finding(view, TRUE);

/* Display at 150% */
blink_web_view_set_zoom_level(view, 1.5);

Overview

What you want API
Search the page and highlight blink_web_view_find_in_page()
Finish searching blink_web_view_stop_finding()
Change the display scale blink_web_view_set_zoom_level()
Read the current scale blink_web_view_get_zoom_level()

Zoom scales the whole page. To change only the body text size, use
blink_web_view_set_default_font_size() from the Settings API.


Find in page

Searches the page for a string and highlights the matches.

Signature:

void blink_web_view_find_in_page(BlinkWebView* web_view,
                                 const char* search_text,
                                 gboolean forward,
                                 gboolean match_case,
                                 gboolean find_next);
Argument Meaning
search_text The text to search for
forward TRUE to search forward (towards the end of the document)
match_case TRUE for a case-sensitive search
find_next TRUE to continue the previous search and move to the next match

Make the first call with find_next=FALSE; for a "find next" button, keep the
same text and call with find_next=TRUE. After the last match it wraps around
to the first.

Ends the search.

Signature:

void blink_web_view_stop_finding(BlinkWebView* web_view,
                                 gboolean clear_selection);

Pass TRUE for clear_selection to remove the highlights. Pass FALSE to
keep the current match selected (useful when closing the search bar should
still show where the match was).


Zoom

Sets the display scale. 1.0 is 100%, 1.5 is 150%, 0.5 is 50%.

Signature:

void blink_web_view_set_zoom_level(BlinkWebView* web_view, gdouble zoom_level);

Returns the current display scale.

Signature:

gdouble blink_web_view_get_zoom_level(BlinkWebView* web_view);

Implementing zoom-in / zoom-out buttons (relative to the current value):

static void on_zoom_in(GtkButton *button, gpointer user_data) {
    BlinkWebView *view = BLINK_WEB_VIEW(user_data);
    gdouble z = blink_web_view_get_zoom_level(view);
    blink_web_view_set_zoom_level(view, z + 0.1);
}

#include <blink_gtk/blink_gtk.h>
#include <gtk/gtk.h>

static BlinkWebView *g_view = NULL;
static GtkEntry *g_entry = NULL;

static void on_search(GtkButton *button, gpointer user_data) {
    gboolean is_next = GPOINTER_TO_INT(user_data);
    const char *text = gtk_editable_get_text(GTK_EDITABLE(g_entry));
    if (text && *text)
        blink_web_view_find_in_page(g_view, text, TRUE, FALSE, is_next);
}

int main(int argc, char **argv) {
    blink_gtk_init(&argc, &argv);

    GtkWidget *win = gtk_window_new();
    gtk_window_set_default_size(GTK_WINDOW(win), 1024, 768);

    GtkWidget *box = gtk_box_new(GTK_ORIENTATION_VERTICAL, 0);
    GtkWidget *bar = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 6);

    GtkWidget *entry = gtk_entry_new();
    GtkWidget *find = gtk_button_new_with_label("Find");
    GtkWidget *next = gtk_button_new_with_label("Next");
    gtk_widget_set_hexpand(entry, TRUE);
    gtk_box_append(GTK_BOX(bar), entry);
    gtk_box_append(GTK_BOX(bar), find);
    gtk_box_append(GTK_BOX(bar), next);

    GtkWidget *view = blink_web_view_new();
    gtk_widget_set_vexpand(view, TRUE);
    gtk_box_append(GTK_BOX(box), bar);
    gtk_box_append(GTK_BOX(box), view);
    gtk_window_set_child(GTK_WINDOW(win), box);

    g_view = BLINK_WEB_VIEW(view);
    g_entry = GTK_ENTRY(entry);
    g_signal_connect(find, "clicked", G_CALLBACK(on_search), GINT_TO_POINTER(0));
    g_signal_connect(next, "clicked", G_CALLBACK(on_search), GINT_TO_POINTER(1));

    gtk_window_present(GTK_WINDOW(win));
    blink_web_view_load_uri(g_view, "https://example.com/");

    return blink_gtk_run_main_loop();
}

Build:

cc -o search-viewer search-viewer.c $(pkg-config --cflags --libs blinkgtk-0.1)

Change history

Version Change
v1.1.0 First version of this page (the APIs themselves ship since v1.0)