Re: Question? Broadcast to widget in a window



Carsten Rasmussen wrote:
I am new in GUI programming!
I just want to know if the is a function in GTK which can broadcast a signal to all member widget of the Window.

What do you mean by "broadcast a signal" ?

Do you just want a function to be called for every widget in
a container ?

You can use gtk_container_foreach with a recursive callback like so:

==================================================
gtk_container_foreach (GTK_CONTAINER (window),
                       recursive_foreach,
                       func_to_call);

void
recursive_foreach (GtkWidget *widget,
                   gpointer data)
{
     func_to_call = (cast *)data;

     func_to_call (widget); // Call the callback for this widget

     if (GTK_IS_CONTAINER (widget)) {
         gtk_container_foreach (GTK_CONTAINER (window),
                       recursive_foreach,
                       func_to_call);
     }
}
==================================================

Cheers,
                                 -Tristan



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