api
linux.ch
Declarations in linux.ch
1 declarationswebview
Declarations
Public only
webview#
Publicnamespace
namespace webview
Linux webview using GTK3 + WebKit2GTK via C API
GtkWindow#
Publictypealias
type GtkWindow = GtkWindow
GTK types — reuse the window library's declarations so the two modules
GtkContainer#
Publictypealias
type GtkContainer = GtkContainer
GtkBox#
Publicstruct
struct GtkBox
GtkFixed#
Publicstruct
struct GtkFixed
GtkBin#
Publicstruct
struct GtkBin
WebKitWebView#
Publicstruct
struct WebKitWebView
WebKitSettings#
Publicstruct
struct WebKitSettings
WebKitUserContentManager#
Publicstruct
struct WebKitUserContentManager
WebKitUserScript#
Publicstruct
struct WebKitUserScript
WebKitWebContext#
Publicstruct
struct WebKitWebContext
gtk_init#
Publicfunction
func gtk_init(argc : *int, argv : ***char) : int
The injected WebKitUserScript is owned by the user content manager for the
gtk_main#
Publicfunction
func gtk_main() : void
gtk_main_quit#
Publicfunction
func gtk_main_quit() : void
gtk_main_iteration#
Publicfunction
func gtk_main_iteration() : int
gtk_events_pending#
Publicfunction
func gtk_events_pending() : int
gtk_widget_set_size_request#
Publicfunction
func gtk_widget_set_size_request(widget : *GtkWidget, width : int, height : int) : void
gtk_window_set_title#
Publicfunction
func gtk_window_set_title(window : *GtkWindow, title : *char) : void
gtk_window_set_default_size#
Publicfunction
func gtk_window_set_default_size(window : *GtkWindow, width : int, height : int) : void
gtk_window_set_position#
Publicfunction
func gtk_window_set_position(window : *GtkWindow, position : int) : void
gtk_window_set_resizable#
Publicfunction
func gtk_window_set_resizable(window : *GtkWindow, resizable : int) : void
g_idle_add#
Publicfunction
func g_idle_add(function : *void, data : *void) : u32
gtk_window_get_type#
Publicfunction
func gtk_window_get_type() : size_t
gtk_box_pack_start#
Publicfunction
gtk_fixed_new#
Publicfunction
func gtk_fixed_new() : *GtkWidget
GtkFixed: absolute-positioning container used by webview_attach to place the
gtk_fixed_put#
Publicfunction
gtk_fixed_move#
Publicfunction
webkit_web_view_get_type#
Publicfunction
func webkit_web_view_get_type() : size_t
webkit_web_view_load_uri#
Publicfunction
func webkit_web_view_load_uri(web_view : *WebKitWebView, uri : *char) : void
webkit_web_view_load_html#
Publicfunction
func webkit_web_view_load_html(web_view : *WebKitWebView, content : *char, base_uri : *char) : void
webkit_web_view_run_javascript#
Publicfunction
func webkit_web_view_run_javascript(web_view : *WebKitWebView, script : *char, cancellable : *void, callback : *void, user_data : *void) : void
webkit_web_view_get_title#
Publicfunction
func webkit_web_view_get_title(web_view : *WebKitWebView) : *char
webkit_web_view_get_settings#
Publicfunction
webkit_settings_set_allow_file_access_from_file_urls#
Publicfunction
func webkit_settings_set_allow_file_access_from_file_urls(settings : *WebKitSettings, allowed : int) : void
webkit_web_view_evaluate_javascript#
Publicfunction
func webkit_web_view_evaluate_javascript(web_view : *WebKitWebView, script : *char, length : isize, source_uri : *char, cancellable : *void, callback : *void, user_data : *void) : void
g_signal_connect_data#
Publicfunction
func g_signal_connect_data(instance : *void, signal : *char, handler : *void, data : *void, destroy_data : *void, connect_flags : int) : u64
GLib signal connection
JSGlobalContextRef#
Publicstruct
struct JSGlobalContextRef
WebKitJavascriptResult#
Publicstruct
struct WebKitJavascriptResult
WebKit async JS result (webkit_web_view_run_javascript_finish)
webkit_web_view_run_javascript_finish#
Publicfunction
func webkit_web_view_run_javascript_finish(web_view : *WebKitWebView, res : *void, error : **void) : *WebKitJavascriptResult
webkit_javascript_result_get_js_value#
Publicfunction
webkit_javascript_result_unref#
Publicfunction
webkit_web_view_get_user_content_manager#
Publicfunction
func webkit_web_view_get_user_content_manager(web_view : *WebKitWebView) : *WebKitUserContentManager
User content manager + script-message-received (JS<->native bridge) APIs
webkit_user_content_manager_new#
Publicfunction
func webkit_user_content_manager_new() : *WebKitUserContentManager
webkit_user_content_manager_add_script#
Publicfunction
func webkit_user_content_manager_add_script(manager : *WebKitUserContentManager, script : *WebKitUserScript) : void
webkit_user_content_manager_register_script_message_handler#
Publicfunction
func webkit_user_content_manager_register_script_message_handler(manager : *WebKitUserContentManager, name : *char) : int
webkit_user_script_new#
Publicfunction
func webkit_user_script_new(source : *char, injected_frames : int, injection_time : int, allow_list : **void, block_list : **void) : *WebKitUserScript
JsEvalHandler#
Publicstruct
Per-call context for webview_evaluate_js_result (freed in the callback).
WebView#
Publicstruct
struct WebView {
var win : Window
var web_view : *GtkWidget
var box : *GtkWidget
var attached : bool
var parent_win : *Window
var fixed : *GtkWidget
var bounds_x : int
var bounds_y : int
var bounds_w : int
var bounds_h : int
var title : string
var width : int
var height : int
var visible : bool
var initialized : bool
var bind_signal_connected : bool
var bind_ctx : *JsBindHolder
var bind_handler_set : bool
}
---------------------------------------------------------------------------
linux_on_window_destroy#
function
func linux_on_window_destroy(widget : *GtkWidget, data : *void) : void
webview_create#
Publicfunction
webview_inject_bridge#
function
func webview_inject_bridge(wv : *WebView) : void
Inject the JS<->native bridge stub into every page the webview loads and wire
JsBindHolder#
Publicstruct
Heap-allocated holder for a bound JS<->native handler. Exists because a
set#
Publicfunction
delete#
function
func delete(self : *JsBindHolder) : void
Heap-allocated holder for a bound JS<->native handler. Exists because a
linux_on_script_message#
function
func linux_on_script_message(manager : *WebKitUserContentManager, js_result : *WebKitJavascriptResult, data : *void) : void
signal. The JS side posts a string via
linux_json_value#
function
Extract the JSON value for `key` (e.g. "\"params\":") from a bridge message.
linux_json_escape#
function
Escape a string into a JSON string literal (with surrounding quotes). Used to
linux_run_js#
function
func linux_run_js(wv : *WebView, script : *char) : void
gtk_main_iteration), so it is safe to call from inside a signal handler such
linux_store_large_result#
function
func linux_store_large_result(id_str : *char, data : *char, size : size_t) : void
linux_clear_large_result#
function
func linux_clear_large_result() : void
linux_json_int_field#
function
func linux_json_int_field(params_view : string_view, key : *char) : size_t
Parse an integer field from a JSON params string.
linux_deliver_large_result#
function
Deliver a large result (already stored in g_lr_buf) to JS by queuing a short
linux_on_message#
function
func linux_on_message(wv : *WebView, msg : *char) : void
Process an incoming bridge message (JSON from JS). Parses {id, method,
webview_bind#
Publicfunction
Bind a native handler to the JS window.webview_bridge.call(method, args).
gtk_container_add#
function
NOTE: @extern does not take a separate linkage name — the emitted C symbol
webview_attach#
Publicfunction
func webview_attach(wv : *WebView, parent : *Window, x : int, y : int, width : int, height : int) : Result<Unit, WebViewError>
Attach the webview to an app-owned window::Window instead of creating its
webview_set_bounds#
Publicfunction
func webview_set_bounds(wv : *WebView, x : int, y : int, width : int, height : int) : void
Move/resize the webview section inside the attached parent window (in the
linux_js_callback#
function
func linux_js_callback(web_view : *WebKitWebView, res : *void, user_data : *void) : void
null. The callback runs on the GLib main loop.
webview_evaluate_js_result#
Publicfunction
func webview_evaluate_js_result(wv : *WebView, script : *char, cb : JsResultCallback, user_data : *void) : void
webview_set_size#
Publicfunction
func webview_set_size(wv : *WebView, width : int, height : int) : void
webview_run_async#
Publicfunction
func webview_run_async(wv : *WebView) : void
Like webview_run, but the event loop also drives the async executor
webview_window#
Publicfunction
Access the webview's underlying window (from the window library). In
DispatchClosure#
struct
===========================================================================
linux_dispatch_idle#
function
func linux_dispatch_idle(data : *void) : i32
GLib GSourceFunc: runs the closure on the GTK main loop (one-shot).
webview_dispatch#
Publicfunction
Schedule a function to run on the GTK main loop. Thread-safe.
webview_set_size_hints#
Publicfunction
func webview_set_size_hints(wv : *WebView, width : int, height : int, hint : int) : void
Set window size with a hint (none / min / max / fixed).
webview_init#
Publicfunction
func webview_init(wv : *WebView, js : *char) : void
Inject JavaScript that runs on every page load.
webview_unbind#
Publicfunction
func webview_unbind(wv : *WebView, name : *char) : void
Remove a binding (single global handler on this backend).
webview_return#
Publicfunction
func webview_return(wv : *WebView, id : *char, status : int, result : *char) : void
Respond to an async binding call (used by handlers invoked from other threads).
webview_get_native_handle#
Publicfunction
func webview_get_native_handle(wv : *WebView, kind : int) : *void
Get a native handle by kind.
webview_version#
Publicfunction
func webview_version() : WebViewVersion
Get the library version information.
gtk_file_chooser_native_new#
Publicfunction
func gtk_file_chooser_native_new(title : *char, parent : *GtkWindow, action : int, accept_label : *char, cancel_label : *char) : *GtkFileChooserNative
gtk_native_dialog_run#
Publicfunction
func gtk_native_dialog_run(dialog : *GtkFileChooserNative) : int
gtk_file_chooser_get_filename#
Publicfunction
func gtk_file_chooser_get_filename(chooser : *void) : *char
g_object_unref#
Publicfunction
func g_object_unref(object : *void) : void