I am currently trying to convert a GTK3 program to GTK4. As Glade is not available for GTK4 and a lot has changed in XML between the two versions, is there a document which explains what is available in GTK4? I know it is recommended to use gtk4-builder-tool, however I find it very buggy and it still doesn’t explain, what parameter are available in GTK4.
For custom elements, you should refer to the documentation of each class—for instance GtkWidget. Custom elements are defined by each implementation of the GtkBuildable interface, which means each implementation needs to document them.
Finally, the migration guide contains references and additional information on migrating a UI definition file from GTK3 to GTK4.
Please, file an issue every time you find a bug, making sure to attach the UI definition file that caused the issue.
The migrating docs that exist are very good (particularly the porting guide, although I found information lacking particularly in the removal of <packing></packing> for GtkGrid and GtkBox. Eventually I chanced upon some discussion for GtkGrid and found that layout is inserted in the child widget of the grid, rather than after its object (this is a good thing ). In the gjs docs there is reference to GtkGridLayout but not how it’s related to its use in xml,
The other parameter whose documentation is lacking related to <packing> is the position parameter related to GtkBox. it seems in gtk4 there is no way to specify the row or column for a box child (depending on its orientation) you just have to manually reorder the children inside the box.
What would be awesome after delving into this (and coming from the relative naive obscurity of glade ) is a gnome builder plugin to more easily edit xml (collapsible elements, auto-completion and insertion of things like <object class='' id=''></property> and <property name=''></property>. Auto selection of available object class values (GtkLabel, GtkGrid, GtkBox, GtkImage, …) and property names for those class objects is another thing that could really speed up manual editing of xml without being aware of the niceties of its syntax, or the available object properties. and beautifying with tabs/spaces/etc.
Just a bit of a dump there this morning, sorry if I got carried away.
Correct. The position in the UI file determines the position in the box.
If you’re rearranging the children of a GtkBox, you should likely not be using a UI file, though.
Those are not the GJS docs: they are the porting guide for extensions. You should probably file a bug about adding a note to the porting guide.
The GJS documentation is generated from the C API reference, but it seems it’s still using GTK 4.0 when 4.2 is out. You can see an example of the layout properties in the latest documentation for GtkGrid.
Glade allows one to reorder GtkBox children using packing/position. Gtk4 does not have a layout equivalent, that was my only point.
not sure what you mean by “If you’re rearranging the children of a GtkBox, you should likely not be using a UI file, though.” What should one by using in this instance?
I meant manually building the Box widget in your code; you can still define each child widget in the UI definition file, but the Box widget and its contents are defined in code, instead of using XML.