Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://gitlab.com/jeang3nie/zig-gtk3
Some convenience methods to use gtk3 from Zig
https://gitlab.com/jeang3nie/zig-gtk3
gtk library zig
Last synced: 3 months ago
JSON representation
Some convenience methods to use gtk3 from Zig
- Host: gitlab.com
- URL: https://gitlab.com/jeang3nie/zig-gtk3
- Owner: jeang3nie
- License: mit
- Created: 2021-06-10T23:08:03.323Z (over 3 years ago)
- Default Branch: odin
- Last Synced: 2024-07-30T21:08:52.032Z (6 months ago)
- Topics: gtk, library, zig
- Stars: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- License: LICENSE.md
Awesome Lists containing this project
README
# zig-gtk3
This package contains some convenience functions and wrappers around the C api
of both the Gtk+ and Vte libraries for developing Gui applications using Zig.## Usage
We track zig-master, so you will need the current master compiler. In your
```build.zig``` file, add the package path:
```Zig
const exe = b.addExecutable("exe-name", "path-to-source.zig");
exe.addPackagePath("zig-gtk3", "path/to/zig-gtk3/lib.zig");
exe.linkLibC();
exe.linkSystemLibrary("gtk+-3.0");
```
The Gtk wrappers are namespaced to gtk, and the C functions to c.
```Zig
const GTK @import("zig-gtk3");
const c = GTK.c;
const gtk = GTK.gtk;
const std = @import("std");const Gui = struct {
window: gtk.Window,fn init(app: *c.GtkApplication) Gui {
...
```
There are a number of examples in the "examples" subdirectory which can be built
with by running `zig build` in this directory.## Rationale
It is entirely possible to call C functions directly from Zig. However, Zig's
translate-c function, which is used to import C code into Zig, is still somewhat
immature and tends to fail with heavily macro dependent code. This happens for
certain parts of Gtk+ that make working around it quite difficult.Additionally, the C Api to Gtk (and Vte), due to limitations of the language, can
be incredibly verbose as well as quite clumsy at times. A better Api is both
possible and desireable in a language such as Zig.