<BEGIN>

Using Zig with GTK


I wouldn't necessarily recommend doing this. Getting started by using the actual c libraries isn't too terribly complicated (I promise), or you can save yourself a whole lot of trouble and use webui, which took me barely a couple of minutes and lets you write your frontend in html.

If you'd like to continue and follow along, use this:
https://github.com/ianprime0509/zig-gobject/

I downloaded the appropriate release (it was marked as a 0.12 dev version but it works fine on 0.12.0) and put the unpacked folder in the top level of my project: 

├── bindings/ ├── build.zig ├── build.zig.zon ├── src/ ├── zig-cache/ └── zig-out/

and then ran zig build in the bindings folder. i don't know if that actually did anything.
modify your build.zig.zon (this is *assuming* a default build.zig.zon generated with `zig init` 0.12.0):

{
  //... defaults ...
  //add (under .dependencies):
        .gobject = .{
            //you can put the bindings folder wherever you like,
            //so change this to the actual location
            .path = "./bindings",
        },
}


`
modify your build.zig (this is *assuming* a default build.zig generated with zig init 0.12.0):

//... defaults ...
// add (before the const exe declaration):
const gobject = b.dependency("gobject", .{
        .target = target,
        .optimize = optimize,
});

and then just before the b.installArtifact(exe) line:

exe.root_module.addImport("glib", gobject.module("glib-2.0"));
exe.root_module.addImport("gobject", gobject.module("gobject-2.0"));
exe.root_module.addImport("gio", gobject.module("gio-2.0"));
exe.root_module.addImport("cairo", gobject.module("cairo-1.0"));
exe.root_module.addImport("pango", gobject.module("pango-1.0"));
exe.root_module.addImport("pangocairo", gobject.module("pangocairo-1.0"));
exe.root_module.addImport("gdk", gobject.module("gdk-4.0"));
exe.root_module.addImport("gtk", gobject.module("gtk-4.0"));

You won't be able to run your code with zig run, you'll need to do zig build run instead. This is a hello world you can try running to see if everything is working correctly. Otherwise, you should be up and running, and now you "just" have to actually learn the bindings. See here for that.

<END>