0

I have calls of gtk_container_class_install_child_property in GTK3, that I want to port to GTK4. How is this following call being done in GTK4 (since there is no more GtkContainer)?

gtk_container_class_install_child_property (container_class,
                                              CHILD_PROP_SOCKET_ID,
                                              g_param_spec_uint ("socketid",
                                                                 "numeric socket identifier",
                                                                 "numeric socket identifier",
                                                                 0, G_MAXUINT, 0,
                                                                 GTK_NODES_VIEW_PARAM_RW));

1 Answer 1

1

GTK4 still has container widgets, but they're different than in GTK3. In GTK4, container widgets are those that manage multiple child widgets and determine their size and location. Some examples of container widgets in GTK4 are GtkBox, GtkGrid, GtkStack, GtkPaned, and GtkFixed.

However, GTK4 has removed or replaced some container widgets from GTK3, such as GtkContainer, GtkBin, GtkAlignment, GtkButtonBox, GtkAspectFrame, and GtkTable. These widgets were either considered unnecessary or too specific for certain use cases. Instead, GTK4 provides more general mechanisms to control the layout and appearance of widgets, such as GtkLayoutManager and GtkConstraintLayout.

So, if you want to port your GTK3 application to GTK4, you may need to replace or customize some of your container widgets with others.

An example of how to design a user interface with GTK4, GtkConstraintLayout and VFL can be found in the question:

https://stackoverflow.com/a/77619798/22768315

For your purposes, the GtkCustomLayout is probably the most suitable. "A GtkCustomLayout uses closures matching to the old GtkWidget virtual functions for size negotiation, as a convenience API to ease the porting towards the corresponding `GtkLayoutManager virtual functions. " : Quote from the official description.

Layout Manager GtkCustomLayout with GTK4 and C

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.