BlinkGTK Settings API Reference

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


About this page

APIs that change how a BlinkWebView behaves: JavaScript execution, image loading, local
storage, and the User-Agent.

How to use them

Call them right after blink_web_view_new(), before loading a page.

GtkWidget *view = blink_web_view_new();

blink_web_view_set_javascript_enabled(BLINK_WEB_VIEW(view), FALSE);
blink_web_view_set_images_enabled(BLINK_WEB_VIEW(view), FALSE);

blink_web_view_load_uri(BLINK_WEB_VIEW(view), "https://example.com/");

Settings are per BlinkWebView.

At a glance

Setting Set Get Default
JavaScript blink_web_view_set_javascript_enabled() blink_web_view_get_javascript_enabled() enabled
Image loading blink_web_view_set_images_enabled() blink_web_view_get_images_enabled() enabled
Local storage blink_web_view_set_local_storage_enabled() blink_web_view_get_local_storage_enabled() enabled
User-Agent blink_web_view_set_user_agent() blink_web_view_get_user_agent() Chromium default

The same settings are available from Python (PyGObject) and Rust (gtk-rs).

Coming from WebKitGTK

WebKitGTK goes through a WebKitSettings object; BlinkGTK sets things on the BlinkWebView
directly. The function names and the call style both differ. There is a mapping table later
on this page.


JavaScript Control

Enables or disables JavaScript.

Signature:

void blink_web_view_set_javascript_enabled(BlinkWebView* web_view, gboolean enabled);

Parameters:
| Parameter | Type | Description |
|-----------|---|------|
| web_view | BlinkWebView* | BlinkWebView widget |
| enabled | gboolean | TRUE = enabled, FALSE = disabled |

Return value: None

Default value: TRUE (enabled)

Example:

#include <blink_gtk/blink_gtk.h>

// Display secure content with JavaScript disabled
GtkWidget* web_view = blink_web_view_new();
blink_web_view_set_javascript_enabled(web_view, FALSE);
blink_web_view_load_uri(web_view, "https://example.com");

WebKitGTK equivalent:

// WebKitGTK
WebKitSettings* settings = webkit_web_view_get_settings(WEBKIT_WEB_VIEW(web_view));
webkit_settings_set_enable_javascript(settings, FALSE);

// BlinkGTK (equivalent)
blink_web_view_set_javascript_enabled(web_view, FALSE);

Available since: v1.1.0 or later


Gets whether JavaScript is enabled.

Signature:

gboolean blink_web_view_get_javascript_enabled(BlinkWebView* web_view);

Parameters:
| Parameter | Type | Description |
|-----------|---|------|
| web_view | BlinkWebView* | BlinkWebView widget |

Return value: gboolean - TRUE = enabled, FALSE = disabled

Example:

if (blink_web_view_get_javascript_enabled(web_view)) {
    g_print("JavaScript is enabled\n");
} else {
    g_print("JavaScript is disabled\n");
}

Available since: v1.1.0 or later


User-Agent Control

Sets a custom User-Agent string.

Signature:

void blink_web_view_set_user_agent(BlinkWebView* web_view, const char* user_agent);

Parameters:
| Parameter | Type | Description |
|-----------|---|------|
| web_view | BlinkWebView* | BlinkWebView widget |
| user_agent | const char* | User-Agent string |

Return value: None

Default value: Chromium's default User-Agent

Example:

// Set a custom User-Agent
blink_web_view_set_user_agent(web_view, "MyApp/1.0 (Linux; BlinkGTK)");
blink_web_view_load_uri(web_view, "https://httpbin.org/user-agent");

Practical example - mobile User-Agent:

// Behave as a mobile device
const char* mobile_ua = "Mozilla/5.0 (Linux; Android 10) "
                        "AppleWebKit/537.36 (KHTML, like Gecko) "
                        "Chrome/151.0.0.0 Mobile Safari/537.36";
blink_web_view_set_user_agent(web_view, mobile_ua);

WebKitGTK equivalent:

// WebKitGTK
WebKitSettings* settings = webkit_web_view_get_settings(WEBKIT_WEB_VIEW(web_view));
webkit_settings_set_user_agent(settings, "MyApp/1.0");

// BlinkGTK (equivalent)
blink_web_view_set_user_agent(web_view, "MyApp/1.0");

Available since: v1.1.0 or later


Gets the current User-Agent string.

Signature:

gchar* blink_web_view_get_user_agent(BlinkWebView* web_view);

Parameters:
| Parameter | Type | Description |
|-----------|---|------|
| web_view | BlinkWebView* | BlinkWebView widget |

Return value: char* - User-Agent string (the caller must free it with g_free())

Example:

char* user_agent = blink_web_view_get_user_agent(web_view);
g_print("Current User-Agent: %s\n", user_agent);
g_free(user_agent);  // Important: free the memory

Memory management:
Important: The return value must be freed by the caller with g_free().

Available since: v1.1.0 or later


Image Loading Control

Controls automatic image loading.

Signature:

void blink_web_view_set_images_enabled(BlinkWebView* web_view, gboolean enabled);

Parameters:
| Parameter | Type | Description |
|-----------|---|------|
| web_view | BlinkWebView* | BlinkWebView widget |
| enabled | gboolean | TRUE = auto-load, FALSE = disabled |

Return value: None

Default value: TRUE (auto-loading enabled)

Example:

// Disable image loading (display text only)
blink_web_view_set_images_enabled(web_view, FALSE);
blink_web_view_load_uri(web_view, "https://example.com");

Practical example - lightweight browsing:

// Data-usage reduction mode
void enable_data_saver_mode(GtkWidget* web_view) {
    blink_web_view_set_images_enabled(web_view, FALSE);
    blink_web_view_set_javascript_enabled(web_view, FALSE);
    g_print("Data saver mode enabled\n");
}

WebKitGTK equivalent:

// WebKitGTK
webkit_settings_set_auto_load_images(settings, FALSE);

// BlinkGTK (equivalent)
blink_web_view_set_images_enabled(web_view, FALSE);

Available since: v1.1.0 or later


Gets the automatic image loading setting.

Signature:

gboolean blink_web_view_get_images_enabled(BlinkWebView* web_view);

Parameters:
| Parameter | Type | Description |
|-----------|---|------|
| web_view | BlinkWebView* | BlinkWebView widget |

Return value: gboolean - TRUE = auto-loading enabled, FALSE = disabled

Example:

if (blink_web_view_get_images_enabled(web_view)) {
    g_print("Images will be loaded\n");
} else {
    g_print("Images are blocked\n");
}

Available since: v1.1.0 or later


Local Storage Control

Enables or disables HTML5 LocalStorage.

Signature:

void blink_web_view_set_local_storage_enabled(BlinkWebView* web_view, gboolean enabled);

Parameters:
| Parameter | Type | Description |
|-----------|---|------|
| web_view | BlinkWebView* | BlinkWebView widget |
| enabled | gboolean | TRUE = enabled, FALSE = disabled |

Return value: None

Default value: TRUE (enabled)

Example:

// Disable local storage (privacy protection)
blink_web_view_set_local_storage_enabled(web_view, FALSE);
blink_web_view_load_uri(web_view, "https://example.com");

Practical example - privacy mode:

// Privacy protection mode
void enable_privacy_mode(GtkWidget* web_view) {
    blink_web_view_set_javascript_enabled(web_view, FALSE);
    blink_web_view_set_local_storage_enabled(web_view, FALSE);
    g_print("Privacy mode enabled\n");
}

WebKitGTK equivalent:

// WebKitGTK
webkit_settings_set_enable_local_storage(settings, FALSE);

// BlinkGTK (equivalent)
blink_web_view_set_local_storage_enabled(web_view, FALSE);

Available since: v1.1.0 or later


Gets the LocalStorage setting.

Signature:

gboolean blink_web_view_get_local_storage_enabled(BlinkWebView* web_view);

Parameters:
| Parameter | Type | Description |
|-----------|---|------|
| web_view | BlinkWebView* | BlinkWebView widget |

Return value: gboolean - TRUE = enabled, FALSE = disabled

Example:

if (blink_web_view_get_local_storage_enabled(web_view)) {
    g_print("LocalStorage is enabled\n");
} else {
    g_print("LocalStorage is disabled\n");
}

Available since: v1.1.0 or later


Modes and policies

GPU mode

Reads and sets the rendering path. The default (software) works everywhere.

typedef enum {
  BLINK_GPU_MODE_SOFTWARE    = 0,  /* CPU rendering (default, no GPU needed) */
  BLINK_GPU_MODE_SWIFTSHADER = 1,  /* CPU-based GL emulation (WebGL/WebGPU) */
  BLINK_GPU_MODE_EGL         = 2,  /* native GPU rendering (WebGL/WebGPU, GPU required) */
} BlinkGpuMode;

GtkWidget*   blink_web_view_new_with_gpu_mode(BlinkGpuMode mode);
BlinkGpuMode blink_web_view_get_gpu_mode(BlinkWebView* web_view);

The GPU mode is chosen when the WebView is created (use
new_with_gpu_mode() instead of blink_web_view_new()). It cannot be
switched afterwards. In the current implementation the mode is
process-wide: with multiple WebViews of different modes in one process,
the first WebView's mode wins.

Content policy

Bit flags that forbid copy, save, print, selection, and so on — for ebook
readers and kiosks that must guarantee content-protection behaviour.

blink_web_view_set_content_policy(view, BLINK_CONTENT_POLICY_EBOOK_READER);

BlinkContentPolicy p = blink_web_view_get_content_policy(view);
Main flags Forbids
BLINK_CONTENT_POLICY_ALLOW_ALL (no restrictions, default)
BLINK_CONTENT_POLICY_NO_COPY Copying to the clipboard
BLINK_CONTENT_POLICY_NO_SAVE Saving the page
BLINK_CONTENT_POLICY_NO_IMAGE_SAVE Saving images
BLINK_CONTENT_POLICY_NO_SELECTION Text selection
BLINK_CONTENT_POLICY_EBOOK_READER Preset for ebook readers
BLINK_CONTENT_POLICY_KIOSK Preset for kiosks

See BlinkContentPolicy in the blink_gtk.h header for the full list.


Practical Combined Examples

Data Saver Mode

When you want to conserve bandwidth:

void setup_data_saver(GtkWidget* web_view) {
    blink_web_view_set_images_enabled(web_view, FALSE);
    blink_web_view_set_javascript_enabled(web_view, FALSE);
}

Maximum Security Mode

When security is the top priority:

void setup_secure_mode(GtkWidget* web_view) {
    blink_web_view_set_javascript_enabled(web_view, FALSE);
    blink_web_view_set_local_storage_enabled(web_view, FALSE);
    blink_web_view_set_images_enabled(web_view, FALSE);
}

Mobile Emulation

When behaving as a mobile device:

void setup_mobile_emulation(GtkWidget* web_view) {
    const char* mobile_ua = "Mozilla/5.0 (Linux; Android 10) "
                            "AppleWebKit/537.36 Chrome/151.0.0.0 Mobile";
    blink_web_view_set_user_agent(web_view, mobile_ua);
}

WebKitGTK Migration Guide

API Mapping

WebKitGTK BlinkGTK Compatibility
webkit_settings_set_enable_javascript() blink_web_view_set_javascript_enabled() Fully compatible
webkit_settings_get_enable_javascript() blink_web_view_get_javascript_enabled() Fully compatible
webkit_settings_set_user_agent() blink_web_view_set_user_agent() Fully compatible
webkit_settings_get_user_agent() blink_web_view_get_user_agent() Fully compatible
webkit_settings_set_auto_load_images() blink_web_view_set_images_enabled() Fully compatible
webkit_settings_get_auto_load_images() blink_web_view_get_images_enabled() Fully compatible
webkit_settings_set_enable_local_storage() blink_web_view_set_local_storage_enabled() Fully compatible
webkit_settings_get_enable_local_storage() blink_web_view_get_local_storage_enabled() Fully compatible

Migration Code Example

Before (WebKitGTK):

WebKitWebView* web_view = webkit_web_view_new();
WebKitSettings* settings = webkit_web_view_get_settings(web_view);
webkit_settings_set_enable_javascript(settings, FALSE);
webkit_settings_set_user_agent(settings, "MyApp/1.0");

After (BlinkGTK):

GtkWidget* web_view = blink_web_view_new();
blink_web_view_set_javascript_enabled(web_view, FALSE);
blink_web_view_set_user_agent(web_view, "MyApp/1.0");

Differences:


When to apply settings

Apply settings right after blink_web_view_new(), before loading a URL.

GtkWidget *view = blink_web_view_new();

/* Configure before loading a page */
blink_web_view_set_javascript_enabled(BLINK_WEB_VIEW(view), FALSE);
blink_web_view_set_images_enabled(BLINK_WEB_VIEW(view), FALSE);
blink_web_view_set_user_agent(BLINK_WEB_VIEW(view), "MyApp/1.0");

blink_web_view_load_uri(BLINK_WEB_VIEW(view), "https://example.com/");

The bundled blinkgtk_browser sample is minimal and changes no settings. To try these out, add the
calls above and rebuild it (the Makefile in examples/ builds it as is).


API Reference

Tutorials

Migration Guide


Version History

Version Release date Changes
v0.9.28-dev 2026-01-01 Build 174: Cross-links added
v0.9.27-dev 2026-01-01 Build 173: Settings API documentation completed
v0.9.26-dev 2025-12-31 Build 172: Image loading and local storage control added
v0.9.25-dev 2025-12-31 Build 171: JavaScript control and User-Agent settings added

License: BSD-3-Clause
Project: BlinkGTK
Maintainer: BlinkGTK Project daisy19@gmail.com