I’m struggling a bit with a GTK 4 migration, currently my topic is subclassing.
The general direction of our API changes has been to emphasize delegation over subclassing. One of the motivations for this is to make writing your own widgets easier and less error-prone. As a consequence, you will see a lot more auxiliary objects that take over aspects of functionality from core widget classes. And many widgets are now final classes – deriving directly from GtkWidget is expected.
Frankly I don’t understand why it’s easier to write your own widgets if you can’t build on top of existing ones. I have a widget derived from GtkScrolledWindow, the important part is of course its content, a waveform in this case. In GTK 4 this is a final type. I understand I have to take my content, add scrollbars myself and do all the things that make up a GtkScrolledWindow. That’s much more error-prone than before. – Or should I derive from GtkWidget and add a GtkScrolledWindow as a child?
I also have a custom GtkAssistant. Nothing fancy, GtkAssistant is just a template for all the content of my assistant. Like it’s a common pattern for preference dialogs to subclass GtkDialog or GtkWindow as MyNamespacePreferences. Or almost every app has its MyNamespaceWindow derived from GtkApplicationWindow. Why is it bad to subclass GtkAssistant in the same way? Is there an advantage in maintaining GTK or is better for users – or maybe even both, but why?