Re: Traversing a container's children..



Audrey Vernon wrote:

Hey everyone,

Is there a way to recursively search a containers children? I have vboxes containing notebooks containing tables, etc. gtk_container_foreach only does one level of widgets. I need a way to do a similar function for each widget. Actually, I am trying to do a cut routine, and I want to find all things that derive from gtk_editablea nd use gtk_editable_cut_text. I just have no clue how to traverse everything, and how to check if it is a gtk_editable once I do.

Audrey

The "C" sample code you may want to use looks like:

static re_curse_container(GtkContainer *container, gboolean include_internals);

static void pop_on_child(GtkWidget *widget, gboolean include_internals)
{
   if (GTK_IS_CONTAINER(widget)) {
   /* you've got another container */
       re_curse_container(GTK_CONTAINER(widget), include_internals);
   }
   else {
   /* this's a non-container child widget */
   }
}

static void re_curse_container(GtkContainer *container, gboolean include_internals)
{
   if (!include_internals)
gtk_container_foreach(container, pop_on_child, include_internals);
   else gtk_container_forall(container, pop_on_child, include_internals);
}

Olexiy





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