Hi David,

On 28.05.25 00:25, David Pirotte wrote:
Hello Zelphir,
[...]

~~~~
;; A UI XML string can be processed by a GtkBuilder.
I have little experience using gtk builder, upstream developers
convinced me to switch to (always) use templates.

I wonder why that is though. I imagine (I don't know that for sure at all, so some Dunning-Kruger chance here) that internally Gtk probably uses the same machinery to process the XML as the builder, when one passes a file. I mean, it seems to be the difference of parsing a string and parsing a file (which will also need to be read and then its contained string be processed). Even GTK's own docs, even in version 4 suggest using a UI string. See for example:

https://docs.gtk.org/gtk4/class.ApplicationWindow.html#a-gtkapplicationwindow-with-a-menubar

(This time GTK4 docs ; ))

You can see there in the docs:

~~~~
GMenuModel *menubar = G_MENU_MODEL (gtk_builder_get_object (builder, 
"menubar"));
~~~~

I think that is, what I have done in my menu bar example code, which I linked to earlier.

To be clear: I want to specify many parts of the app via SXML. Just not sure it can all be done statically and all in one tree structure (say for example modal dialogs, like settings/preferences and so on), and some of the UI might only be determined when the widgets are created. So it would be good to have a general way of creating widgets from SXML. GtkBuilder processes UI XML and would seem to lend itself to achieving just that. I thought I have found the general way in using GtkBuilder.

Am I misunderstanding GtkBuilder's role?

What is the reason you are convinced to not use the GtkBuilder?

How could I create the GMenu from a UI file instead? Does it also have the `#:template` argument? In that case it would be easier to use than doing any GtkBuilder shenanigans, of course.

Best regards,
Zelphir

--
repositories:https://notabug.org/ZelphirKaltstahl,https://codeberg.org/ZelphirKaltstahl

Reply via email to