Hi all.
I'm try to make an application with gtk-2.16.6 using Glade 3.6.6 with VC express 9.0.
All the sdk is installed from this setup: glade3-3.6.7-with-GTK+.exe
I'd like to make the gui part with Glade, and create a custom widget (often a container) which load the layout from glade file.
First I put the structure of the project.
Inside glade file
Code:
GtkVBox [name=sublayer1]
GtkLabel [name=label1]
GtkButton [name=button1]
I create the custom widget sublayer1 derived from a GtkFrame.
In sublayer1_init i load the sublayer1 from gladefile with
Code:
void sublayer1_init(SubLayer1 *self)
{
GObject *object = gtk_builder_get_object(BUILDER, "sublayer1");
gtk_widget_set(GTK_WIDGET(self), "child", object, NULL); /* [1] */
}
GtkWidget *sublayer1_new()
{
return gtk_widget_new(sublayer1_get_type(), NULL);
}
This happens.
I add the sublayer1 to a GtkHBox:
Code:
...
sublay = sublayer1_new();
gtk_widget_show(sublay);
gtk_box_pack_start(GTK_BOX(top), sublay, TRUE,TRUE, 0);
...
Inside the callback 'remove_layer' of a signal "clicked" I remove the sublay from GtkHBox.
Inside another callback 'add_layer' I readd sublay = sublayer1_new(); [2]
When I readd the sublayer1 the GtkVBox inside glade file has not children widgets.
I dump the GtkVBox tree before [1].
This is the result
Code:
GtkVBox ref_count=2
GtkLabel ref_count=2
GtkButton ref_count=2
GtkALignment ref_count=1
GtkHBox ref_count=1
GtkImage ref_count=1
GtkLabel ref_count=1
Then I dump the parent for GtkLabel label1 and GtkButton button1
Code:
GtkLabel label1 parent=0084e000 ref_count=2
GtkButton button1 parent=0084e000 ref_count=2
After [2] I dump the sublayer1 tree
Code:
GtkVBox ref_count=2
and the parents are
Code:
GtkLabel label1 parent=00000000 ref_count=2
GtkButton button1 parent=00000000 ref_count=2
label1 and button1 has lost the parent.
Why?
There are function to add a reference for each childs of GtkVBox sublayer1 defined in the glade file?
If you run mainwind.exe from bin folder in the console you the read the behaviours.
I have to click Add1, Remove1, Add1.
After the second Add1 I can see only the GtkFrame.
Best regards,
Mauro