zig-gobject is a project to generate Zig bindings to GObject, GTK, and a bunch of other libraries using GObject introspection metadata. This metadata gives much richer information about the associated APIs than their C header files, including type nullability, class hierarchy, signals, and more, allowing safer and more usable bindings to be created than what zig translate-c
can provide.
The generated bindings are supplemented with some extensions to make common tasks simpler, such as defining new classes in the GObject type system. For a more detailed overview of how the bindings are structured, there is documentation on the binding strategy in the repository.
There is more documentation and an example project in the repository, and my Nonograms application uses these bindings and provides a more complete example of how they can be integrated into a real project.
My plans for the future of this project include a bunch of stuff detailed in the issue tracker. In particular,
-
Documentation: more detailed documentation for how to use the bindings in a real project, and a tutorial for users unfamiliar with GTK or C programming. I’d also like to publish API documentation, but my initial attempts at using Autodoc for this have failed. I have some nebulous ideas around improving Zig documentation tooling which I may explore to help with this.
-
Ecosystem tooling: once Zig 0.12 is released, I’d like to get a more stable development environment set up using Flatpak (my ziglang-master Flatpak is a stop-gap solution which I don’t want to maintain in the long term) and focus on how to provide all the tools and build setup needed by real projects (Flatpak creation, internationalization, etc.).
-
Continued expansion of extension functionality to make more use-cases easier.
Side note: this was actually one of the first Zig projects I started on, but it’s only become really usable recently due to the fantastic improvements in the Zig build system and package manager. Thank you to all their contributors for making this project possible.