Re: Traversing through widget tree.




Tomi Ollila <Tomi.Ollila@tfi.net> writes:

> Hi
> 
> I'd like to know how it is possible traversing trough a widget tree and
> execute some code while doing so...
> 
> After studying the available documentation and gtk header files (just
> downloaded the GTK source archive to study that where needed), and figured
> out that something the following could be possible:
> 
> Note that this is just sample code, don't know whether it would be
> compilable. 
> 
> (In this example I assume `gtk_container_foreach' calls `callback' function
>  to each children widget of the current widget (does any other widget class
>  that container (and it's derived classes) has possible children widgets.)
> 
> void show_gtk_widgets(GtkWidget * widget)
> {
>    /* show first the tail widgets and then come up on the widget tree */
> 
>     if (GTK_TYPE_IS_A(widget, GTK_CONTAINER_TYPE))

[ or      GTK_IS_CONTAINER (widget) ]

>         gtk_container_foreach(widget, (GtkCallback *)show_gtk_widgets, NULL); 
> 
>     gtk_widget_show(widget);
> }

It looks to me like you are reinventing gtk_widget_show_all(). ;-)

(Which does work internally pretty much as you've shown. Traversing
 the widget heirarchy using gtk_container_foreach is done in a number
 of places in GTK+)

Regards,
                                        Owen



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]