Bloatpad.c example for non C languages?

Recently I was looking for some more GTK3/4 examples to extend the Nim language example collection. (As you may know already, we got Nim 1.0 release some days ago :slight_smile:

Bloatpad seems to be an interesting example for GTK3 App style, but unfortunately the C code uses C macros which may be not available for language bindings out of the box.

I think I was struggling with this issue years ago when I created the old low level Nim bindings – Nim is a compiled language with metaprogramming (macro) support, so it can “simulate” C macros in some way, but GTK macros can be hard, so it is not much fun, and I can not remember details.

At least current gobject-introspection high level Nim bindings do not cover these GTK macros, so I wonder if there is a way to avoid them. Indeed I can currently not remember why Bloatpad app calls G_DEFINE_TYPE (BloatPad, bloat_pad, GTK_TYPE_APPLICATION) at all – is that important and a real benefit? Maybe some of you can remember?

EDIT: It is really ugly and not intended that whenever I cite a link to a github file a large code block is inserted by the forum software. Is there a way to have only a plain link?

It’s just subclassing GApplication, are you not able to subclass in Nim?

Alternatively you can just create a normal GtkApplication and connect to its signals, like gtk4-widget-factory is doing: https://gitlab.gnome.org/GNOME/gtk/blob/master/demos/widget-factory/widget-factory.c#L2024

Thanks for your explanation.

For Nim’s GTK binding currently we do subclassing for the proxy object as described in

which is is fine in most cases, but which does not register a true native GTK class. I do admit that this is an issue when someone wants to create or extent gtk native libraries.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.