Traversing through widget tree.
- From: Tomi Ollila <Tomi Ollila tfi net>
- To: gtk-list redhat com
- Subject: Traversing through widget tree.
- Date: Mon, 1 Jun 1998 15:58:11 +0300 (EET DST)
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))
gtk_container_foreach(widget, (GtkCallback *)show_gtk_widgets, NULL);
gtk_widget_show(widget);
}
/* at the above, it is assumed that classes such as `menu' which doesn't
need `gtk_widget_show()' calls, however, provides this method as a
no-op. */
void hide_gtk_widgets(GtkWidget * widget)
{
/* hide first root and then go down on the widget tree */
gtk_widget_hide(widget);
if (GTK_TYPE_IS_A(widget, GTK_CONTAINER_TYPE))
gtk_container_foreach(widget, (GtkCallback *)show_gtk_widgets, NULL);
}
/* ... and perhaps the following (Would this be useful, or is there
mechanism for deleting a whole widget tree) ... */
void delete_gtk_widgets(GtkWidget * widget)
{
/* delete first the tail widgets and then come up on the widget tree */
if (GTK_TYPE_IS_A(widget, GTK_CONTAINER_TYPE))
gtk_container_foreach(widget, (GtkCallback *)delete_gtk_widgets, NULL);
gtk_delete_widget(widget); /* or is it destroy or something else,
haven't got to any program coding yet */
}
Tomi
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]