Wrapper functions for using Gtk+ and Vte in Zig programs.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Nathan Fisher e9db1b0934 Implement `ActionBar` widget 6 days ago
examples Fixed remaining `allocgate` casualties 7 months ago
src Implement `ActionBar` widget 6 days ago
.gitignore Add `Popover` class 2 months ago
CONTRIBUTING.md Expanded `CONTRIBUTING.md` 5 months ago
LICENSE.md Added MIT license 6 months ago
README.md Update README 2 months ago
STATUS.md Implement `ActionBar` widget 6 days ago
build.zig Build library and examples from build.zig 2 months ago
button.zig Merge contributions from github user Garret Hale 1 month ago
frame.zig Merge contributions from github user Garret Hale 1 month ago
gyro.zzz vte.zig - fixed typo @intToEnum 1 year ago
lib.zig Initial commit 1 year ago
zig.mod Fixed unused param issues in example program 11 months ago

README.md

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:

    const exe = b.addExecutable("exe-name", "path-to-source.zig");
    exe.addPackagePath("zig-gtk3", "path/to/zig-vte/lib.zig");
    exe.linkLibC();
    exe.linkSystemLibrary("gtk+-3.0");
    exe.linkSystemLibrary("vte-2.91");

The Gtk wrappers are namespaced to gtk, the C functions to c, and Vte to vte.

const GTK = @import("zig-vte");
const c = GTK.c;
const gtk = GTK.gtk;
const vte = GTK.vte;
const std = @import("std");

const Gui = struct {
    window: gtk.Window,
    term: vte.Terminal,

    fn init(app: *c.GtkApplication) Gui {
...

There are several gtk examples and one vte example in the examples subdirectory.

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.