glib
| Kind | ffi-zig |
|---|---|
| Capabilities | ffi file |
| Categories | gui runtime ffi |
| Keywords | glib gobject gio gtk linux zig-ffi |
GLib/GObject main loop and signal foundation for Kit GUI packages
Files
| File | Description |
|---|---|
.editorconfig | Editor formatting configuration |
.gitignore | Git ignore rules for build artifacts and dependencies |
.tool-versions | asdf tool versions (Zig, Kit) |
LICENSE | MIT license file |
README.md | This file |
examples/main-loop.kit | Minimal GLib main-loop example |
kit.toml | Package manifest with metadata and native requirements |
src/glib.kit | Public Kit API for GLib, GObject, and Gio bindings |
tests/main-loop.test.kit | Package tests |
zig/glib.zig | Zig FFI implementation |
zig/kit_ffi.zig | Shared Zig FFI helpers |
Dependencies
No Kit package dependencies.
System packages:
- macOS:
brew install glib pkg-config - Ubuntu:
apt install libglib2.0-dev pkg-config - Fedora:
dnf install glib2-devel pkgconf-pkg-config
Installation
kit add gitlab.com/kit-lang/packages/kit-glib.gitUsage
import GLib
unwrap-or-panic = fn(result) =>
match result
| Ok value -> value
| Err err -> panic (show err)
main = fn =>
loop = unwrap-or-panic (GLib.MainLoop.new no-op)
GLib.MainLoop.timeout-add 50 (fn(_) =>
println "tick"
unwrap-or-panic (GLib.MainLoop.quit loop)
false
) |> Result.unwrap
GLib.MainLoop.run loop |> Result.unwrap
GLib.MainLoop.unref loop |> Result.unwrap
mainThe current API surface includes:
GLib.MainLoopandGLib.MainContextGLib.Objectreference helpersGLib.Signalconnection helpersGLib.ApplicationandGLib.ActionGLib.File,GLib.Settings,GLib.Bytes, andGLib.Variant
Development
Running Examples
Run the example with the interpreter:
kit run examples/main-loop.kit --allow=ffi,fileCompile the example to a native binary:
kit build examples/main-loop.kit -o main-loop --allow=ffi,file && ./main-loopRunning Tests
Run the test suite:
kit test tests/Running kit dev
Run the standard development workflow:
kit devThis will:
- Format and check Kit source files
- Run package tests
- Run Zig tests when applicable
Cleaning Build Artifacts
Remove generated files, caches, and native build outputs:
kit task cleanLocal Installation
To install this package locally for development:
kit installThis installs the package to ~/.kit/packages/@kit/glib/, making it available for import as GLib in other projects.
License
This package is released under the MIT License. See LICENSE for details.
Exported Functions & Types
GLibError
GLib main-loop bindings for Kit.
Phase 1 focuses on the event loop and source scheduling primitives that higher-level GTK bindings will need.
Variants
GLibError {message}MainLoopRef
Opaque reference to a native GMainLoop.
Variants
MainLoopRef {handle}MainContextRef
Opaque reference to a native GMainContext.
Variants
MainContextRef {handle}ApplicationRef
Opaque reference to a native GApplication.
Variants
ApplicationRef {handle}ActionRef
Opaque reference to a native GSimpleAction.
Variants
ActionRef {handle}ActionGroupRef
Opaque reference to a native GSimpleActionGroup.
Variants
ActionGroupRef {handle}MenuModelRef
Opaque reference to a native GMenuModel.
Variants
MenuModelRef {handle}MenuRef
Opaque reference to a native GMenu.
Variants
MenuRef {handle}MenuItemRef
Opaque reference to a native GMenuItem.
Variants
MenuItemRef {handle}AppInfoRef
Opaque reference to a native GAppInfo.
Variants
AppInfoRef {handle}FileRef
Opaque reference to a native GFile.
Variants
FileRef {handle}SettingsRef
Opaque reference to a native GSettings.
Variants
SettingsRef {handle}BytesRef
Opaque reference to a native GBytes.
Variants
BytesRef {handle}VariantRef
Opaque reference to a native GVariant.
Variants
VariantRef {handle}SourceId
Opaque identifier for a registered GLib source.
Variants
SourceId {handle}SignalHandlerId
Opaque identifier for a connected GLib signal handler.
Variants
SignalHandlerId {handle}SignalProbeRef
Opaque reference to an internal probe object used for signal marshaling tests.
Variants
SignalProbeRef {handle}MainLoop
Main-loop API used by GUI packages and GLib-based background tasks.
MainContext
Main-context helpers for driving queued work without a full loop run.
Priority
Common GLib main-loop priority constants.
Object
Generic helpers for supported GObject-backed refs.
Bytes
Byte-buffer helpers for the first GLib data transport slice.
Variant
Narrow GVariant helpers for strings, bools, and ints.
Signal
Generic no-extra-arg signal helpers for supported GObject-backed refs.
Application
Gio application helpers for the current GTK app lifecycle slice.
Action
Simple Gio action helpers for action-map and shortcut plumbing.
ActionGroup
Simple Gio action-group helpers for namespaced menu routing.
Menu
Minimal Gio menu-model helpers for menu-backed widgets.
MenuItem
Minimal Gio menu-item helpers for namespaced menu sections.
AppInfo
Narrow Gio application-info helpers for desktop integration queries.
File
Narrow Gio file helpers built around local path access and byte loading.
Settings
Narrow Gio settings helpers for desktop-app configuration reads.
SignalProbe
Internal probe helpers for verifying signal callback marshaling.
Source
Source lifecycle helpers for timers and idle callbacks.