I am doing a dynamic application on GTK, and so it turns out that at first I only have one widget to put on the screen, which I do:
gtk_container_add(GTK_CONTAINER(window), widget); But then you can create another widget, which also needs to be placed on the screen. In GTK, for this you need to create a box, pack a widget into it and add the box to the screen:
GtkWidget *box = gtk_vbox_new(0, 0); gtk_box_pack_start(GTK_BOX(box), widget, 0, 0, 0); gtk_box_pack_start(GTK_BOX(box), widget2, 0, 0, 0); gtk_container_add(GTK_CONTAINER(window), box); But at this moment I don’t have access to the widget, only widget2, and it should be placed on the screen at the very beginning, therefore it would be logical to make a box at the beginning and place the first widget there. And then, when necessary, create a second widget and pack it in the same box.
GtkWidget *box = gtk_vbox_new(0, 0); gtk_box_pack_start(GTK_BOX(box), widget, 0, 0, 0); gtk_container_add(GTK_CONTAINER(window), box); ... ... gtk_box_pack_start(GTK_BOX(box), widget2, 0, 0, 0); Now the problem: Boxing can be either only vertical or only horizontal, one of two things, but how exactly I need to put on the screen widget2 I can not know.
In the example above, I’ll get two widgets vertically. But if you need to place them horizontally? No And if you need to put two widgets vertically, and under them the third? No way too.
The only solution I see is to pack everything at the end, when all the widgets are known, but it does not suit me. I can say if there is one central object on which I want to gradually sculpt other objects from any sides. In GTK, is it possible?