I'm trying to figure out how to access a list of child widgets of a widget.
Specifically GtkTable child widgets to destroy them with GtkTable itself.
I'm not using Glade, I'm creating each widget "manually" from code and I can't store a pointer of each one (well, actually I could but I don't need this pointers except for its destruction after using them).
I found the function gtk_container_get_children and I tried to use it.
The structure I have is next:
|-each cell has:
Then, at user action I need to erase the complete table and create the same structure (with diferent values).
This is the code I wrote to try to destroy gtktable and its children
if( table!=NULL )
GList* children = gtk_container_get_children( GTK_CONTAINER( table ) );
guint num_child = g_list_length( children );
cout << "NUM CHILDREN="<<num_child<<endl;
while( i<num_child )
cout << "deleting child n:"<<i<<endl;
gtk_widget_destroy( GTK_WIDGET( children->data ) );
children = children->next;
gtk_widget_destroy( GTK_WIDGET( table ) );
But the first time the code tries to erase throws me a lot of asserts:
gtk_box_pack_start: assertion `child->parent==NULLÂ´ failed.
Maybe has to do with that if( table!=NULL )
? Is it ok the way I check if table already exists?