I am trying to make Common Lisp work with Gtk4 and I have a few questions. Using typelib introspection, I was able to reproduce all the basic examples of the Gtk4 intro, up to, and including, the use of the Builder.
The next step would be to do subclassing and use the templating facility, but it looks like this requires a good integration with GObject. I can bind to the GObject (GLib) library with typelib/introspection, and I am able to register a new type, but it is not clear to me how to create an instance of the new type (which is a subclass of a Gtk widget). The problem is that none of the constructors for GObject are available to language bindings, except
g_object_newv, which is deprecated.
What is the expectation for language bindings to GObject?
- Do the class building and object instantiation “manually”, calling the constructors/destructors along the inheritance tree? That seems contrary to the philosophy of GObject, which is supposed to do all that for us.
- Write a C blob that can bind to the language and can access the GObject constructors? It looks like this is the approach of pygobject, Guile and Lua bindings, and probably many others. But Lisp has a foreign function interface that normally spares you the need to do that.
- Bind to the GObject constructors without going through introspection?
As an extra question, what are the advantages of a tight integration with GObject (i.e. the possibility of having derived classes in the language that are registered to and mirrored in the GObject type system), besides the access to the XML templating facility?