I’m interested in migrating to Gtk4, but am rather stumped about how to adapt to its new restrictions on inheritance when working with composite widgets.
In existing Gtk3 code I have one class per file with classes corresponding to logical units of functionality: tab responsible for uploading images, tab with misc. functionality, etc… Each of classes utilizes composite templates for loading Gtk interface. For example:
[GtkTemplate (ui = "/org/v1993/geohashingwikihelper/GalleryTab.ui")]
public class GalleryTab : Gtk.Paned {
[GtkChild]
private unowned Gtk.Button upload_button;
[GtkChild]
private unowned Gtk.Container uploading_part_container;
[GtkChild]
private unowned Gtk.Entry filename;
[GtkChild]
private unowned Gtk.Entry description;
...
}
However, Gtk4 makes it impossible to derive from Gtk.Paned
- which makes sense to me, since my class isn’t really an extension of it but rather a widget on its own. But the issue is that the suggested alternative of deriving directly from Gtk.Widget
and having Gtk.Paned
as its child does not seem viable to me in this case since it’s impossible to have GtkWidget as top-level template in Cambalache (and GtkWidget itself can’t be a composite template at all due to being abstract class if I got it right).
Now, it looks like an alternative it to have top-level Gtk.Box
with actual widgets as its single child, since it is not declared final/sealed, but it appears to be more of a hack rather than an actual intended solution, given that reason for having it as non-sealed class is to avoid breaking too many applications at time of the initial migration AFAIK.
Is there already a nice solution to this problem? If not, it seems like having a simple “wrapper” widget that has a single child and can be derived from explicitly for the purpose of being a base for composite template widgets would work well.