Re: Getting widgets children
- From: John Cupitt <john cupitt ng-london org uk>
- To: Vicki Stanfield <vicki dialupnet com>
- Cc: GTK-List <gtk-list gnome org>
- Subject: Re: Getting widgets children
- Date: Wed, 20 Jun 2001 17:37:45 +0100
Vicki Stanfield wrote:
> I know that I can get the parent of a widget, but if I have only the
> parent widget, can I get the children? I need to unrealize most of the
> widgets to change the window.
Hi, if it's a subclass of container, you can loop over widget->children.
Something like:
/* Set a name for a widget and all its children.
*/
void
set_name( GtkWidget *widget, const char *name )
{
gtk_widget_set_name( widget, name );
if( GTK_IS_CONTAINER( widget ) )
gtk_container_foreach( GTK_CONTAINER( widget ),
(GtkCallback) set_name, (char *) name );
}
You can do a for(;;) loop as well (slightly less clean):
if( GTK_IS_CONTAINER( widget ) ) {
GSList *p;
for( p = GTK_CONTAINER( widget )->children; p; p = p->next ) {
GtkWidget *child = GTK_WIDGET( p->data );
...
}
}
That's what I do anyway.
John
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]