Do we already have a ~/gtk/tests/testgaction.c without XML?

Last winter I wrote the Nim version of testgaction.c, see

GTK4 for Graphical User Interfaces

and told the reader that I would provide a XML free variant soon. From the API docs I think that it should be possible to construct the menu with API calls without XML use, so the reader would have the opportunity to see which variant he likes better. Unfortunately I never managed to get the XML free version working. Before I try again, has someone already managed it? In Nim, C, Python, or maybe in another language? Or do we at least have an idea how to do the conversion? I think in last winter I was already on a good way, but I have not saved the files and can not remember details.

I’ve converted your example to work with SML bindings (example.sml) and then produced a version that doesn’t use XML (example.sml). Although these examples are for GTK 3, they don’t use deprecated features of GTK 3 so the differences from GTK 4 shouldn’t matter here.

Notably, the version without GtkBuilder defines a recursive data type for menus and a function to build a menu from this in MenuBuilder.sml. In any language with suitably expressive sum types, this technique can be applied to create ad hoc types that enable a declarative description of an interface. In this example, instead of the XML representation, we get a declarative SML representation.

1 Like

Nice. I think when it was possible in Standard ML language, then it will be possible in other languages like C, Nim and Python as well.

Will try to create the Nim GTK4 version really soon. Thanks.

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