Starting with a GtkWindow, I want a function that returns the total number of GtkLabels that appear in the window at all levels. I tried this:
static void recursive_label_count(void *widget, unsigned int *cptr)
*cptr += 1 ;
else if (GTK_IS_CONTAINER(widget))
gtk_container_foreach(widget, (GtkCallback)recursive_label_count, cptr) ;
unsigned int container_label_count(void *container)
unsigned int count = 0 ;
recursive_label_count(container, &count) ;
return count ;
I created a window and added a GtkMenuBar. The menu bar has three menus, each with multiple items.
If I use "container_label_count" on the window, it return 3.
If I use the function on the menu bar itself, it returns 3.
If I use the function on the individual menus, it return the number of GtkLabels inside each menu.
Why doesn't the function return the recursive total when applied to the window itself or to the menu bar?
Aren't the menus children (at some level) of the menu bar?
I also tried using gtk_container_forall, but it made no different.
Thanks for any insight.