veko doc
Self-Contained API Reference • Gradual Types • Capabilities • Wasm Sandbox

ui/gtk4_linux

lib/ui/gtk4_linux.vk

lib/ui/gtk4_linux.vk Pure-Veko Linux GTK 4 / libadwaita 22-widget desktop backend (ui/gtk4_linux). - Zero top-level mut globals: all library handles, symbol pointers, and window state live inside owned GtkRuntime and GtkWinInfo structs. - Direct ffi/* builtins (no use [ffi]), operating under allow-caps = [.ui] - Deterministic headless simulation when VEKO_HEADLESS=1 or no display server is present - Clean fallback (fallback_surface = true) when libgtk-4.so.1 is absent

GtkRuntime struct
signature
GtkRuntime = struct { headless bool = ..., has_adw bool = ..., has_gtk4 bool = ..., fallback_surface bool = ..., lib_gtk i64 = ..., lib_adw i64 = ..., lib_glib i64 = ..., lib_gobj i64 = ..., syms map = ... }
GtkWinInfo struct
signature
GtkWinInfo = struct { id str, gtk_win i64 = ..., fixed_box i64 = ..., header_bar i64 = ..., width i64 = ..., height i64 = ..., dpi_scale i64 = ..., fallback bool = ... }
gtk-headless-env? fn caps: .env .fs
signature
gtk-headless-env? = fn [] bool

Returns true when running headless (VEKO_HEADLESS=1|true), on Windows/macOS, or without X11/Wayland.

gtk-init fn caps: .ffi
signature
gtk-init = fn [headless bool] GtkRuntime

Initializes libgtk-4.so.1 (+ optional libadwaita-1.so.0), GLib, and GObject, or returns a deterministic headless/fallback runtime descriptor.

signature
gtk-shutdown = fn [mut rt GtkRuntime]

Releases loaded GTK4 / libadwaita / GLib / GObject shared library handles and resets rt.

signature
gtk-open-window = fn [mut rt GtkRuntime, id str, title str, w i64, h i64, props map] GtkWinInfo

Opens a GTK4 (GtkWindow + GtkFixed) or libadwaita (AdwApplicationWindow + AdwToolbarView + AdwHeaderBar) window.

signature
gtk-close-window = fn [rt GtkRuntime, gtk_win i64]

Destroys a GTK4 / Adwaita window handle.

signature
gtk-create-widget = fn [rt GtkRuntime, fixed_box i64, kind enum, text str, value_s str, value_n i64, flag bool, items block, props map] map

Creates a GTK4 widget for kind inside fixed_box and returns { widget = i64, sub_widgets = [...] }.

signature
gtk-update-widget = fn [rt GtkRuntime, widget i64, kind enum, text str, value_s str, value_n i64, flag bool, items block, props map]

Updates an existing GTK4 widget in place without recreating its handle.

signature
gtk-destroy-widget = fn [rt GtkRuntime, widget i64, sub_widgets block, kind enum]

Detaches widget and any child sub-widgets from their GTK4 parent containers.

signature
gtk-set-frame = fn [rt GtkRuntime, fixed_box i64, widget i64, x i64, y i64, w i64, h i64]

Moves and sizes widget inside fixed_box using gtk_fixed_move + gtk_widget_set_size_request.

signature
gtk-focus-widget = fn [rt GtkRuntime, widget i64]

Requests keyboard focus on widget.

signature
gtk-read-text = fn [rt GtkRuntime, widget i64, kind enum] str

Reads the current plain-text value of a GTK4 widget.

gtk-read-secret fn .secret caps: .ffi
signature
gtk-read-secret = fn [rt GtkRuntime, widget i64] secret str

Reads a GtkPasswordEntry (gtk_editable_get_text char*) byte-by-byte directly into a .secret slab (bytes/with-secret 0), never materializing a plain str.

signature
gtk-wake-addr = fn [rt GtkRuntime] i64

Returns the C function pointer for g_main_context_wakeup (0 when headless/fallback).

signature
gtk-wake-main = fn [rt GtkRuntime]

Wakes the default GLib main loop (g_main_context_wakeup(g_main_context_default())).

signature
gtk-pump-events = fn [rt GtkRuntime, blocking bool]

Pumps pending GLib/GTK4 main-context events (g_main_context_iteration(0, blocking)).

signature
gtk-present-canvas = fn [rt GtkRuntime, pic i64, c any]

Draws RGBA pixels from a ui/canvas value into a GTK4 GtkPicture (.canvas_slot).

signature
gtk-set-headerbar-menus = fn [rt GtkRuntime, hbar i64, menus block]

Packs flat menu bar buttons into an AdwHeaderBar when running live on GTK4 / libadwaita.