GTK4 odin bindings

Hello odin-community,

I want to share with you the GTK bindings that I was working on in the last month. You can find them on github: GitHub - PucklaJ/odin-gtk: Odin Bindings to GTK4
They have been generated using runic which is a bindings generator that I wrote. You can also find it on github: GitHub - Samudevv/runic: Bindings Generator and Intermediate Format for languages using the C-ABI

These bindings provide the following libraries:

Library Path License
glib glib LGPL 2.1
gobject glib/gobject LGPL 2.1
gmodule glib/gmodule LGPL 2.1
gio glib/gio LGPL 2.1
girepository glib/girepository LGPL 2.1
gdk-pixbuf gdk-pixbuf LGPL 2.1
pango pango LGPL 2
pangocairo pango/pangocairo LGPL 2
cairo cairo LGPL 2.1
graphene graphene MIT
gtk gtk LGPL 2.1
gtk4-layer-shell gtk/layer-shell MIT

Feel free to use these bindings however you want. But I need to mention that they currently only support Linux x86_64 and arm64. I am currently not able to work on Windows support, but I ident to do this in the future.

9 Likes

Oh, thank you so much!

1 Like

I follow the instructions, I get this:

just setup && just wrapper
cd shared/glib && meson setup --default-library static -Dman-pages=disabled -Ddtrace=disabled -Dsystemtap=disabled -Dsysprof=disabled -Dtests=false -Dglib_debug=disabled -Dintrospection=disabled _build

ERROR: Neither source directory '_build' nor build directory None contain a build file meson.build.
error: Recipe `glib-setup` failed on line 30 with exit code 1

But it seems to work that way.

The instructions might be a little bit unclear. But you don’t have to build the wrapper anymore. Static libraries are provided. But thanks for pointing out this issue. I will fix it.

1 Like

It seems that you forgot to checkout the submodules:

git submodule init
git submodule update

But as I said you don’t need to do this anymore, if you just want to build the wrapper.

1 Like

great. Now someone please convince elemantary/gnome guys to rewrite their stuff in odin :laughing:

2 Likes

I now added libadwaita bindings Release GTK4 4.17.2 + libadwaita 1.6.2 · PucklaJ/odin-gtk · GitHub

1 Like

Hi!
I just recently started learning Odin so this is still a bit out of my scope atm, but I really appreciate the bindings. Big fan of Adwaita and I cannot wait to write an app in Odin.

Thanks!!

1 Like

No problem. If you have any issues or questions concerning the bindings just leave a reply here or open an issue on the repo.

Hello,

trying to build the last tagged version on today
got

% git checkout 4.17.2-2
% git submodule init
% git submodule update
% just setup
% just wrapper
...
cc -c -o lib/linux/x86_64/gtk-wrapper.o -Ishared/gtk -Ishared/glib -Ishared/glib/glib -Ishared/glib/gmodule -Ishared/glib/_build -Ishared/glib/_build/glib -Ishared/gtk/_build -Ishared/cairo/src -Ishared/cairo/_build/src -Ishared/pango -Ishared/pango/_build -Ishared/gdk-pixbuf -Ishared/gdk-pixbuf/_build -Ishared/graphene/include -Ishared/graphene/_build/include -I/usr/include/harfbuzz gtk/gtk-wrapper.c
In file included from gtk/../shared/gtk/gtk/gtk.h:29,
                 from gtk/gtk-wrapper.h:3,
                 from gtk/gtk-wrapper.c:1:
shared/gtk/gtk/css/gtkcss.h:30:10: fatal error: gdk/version/gdkversionmacros.h: No such file or directory
   30 | #include <gdk/version/gdkversionmacros.h>
      |          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
compilation terminated.
error: Recipe `gtk-wrapper` failed on line 375 with exit code 1

You don’t need to build the wrapper. There are already static libraries provided. Note that the bindings only support Linux and Windows.

1 Like

Okay, I found the issue. You need to call just gtk-setup manually. I forgot to add it to just setup. Thanks for the bug report.

1 Like

Thanks, with just gtk-setup it is built successfully