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

Re: Accessing multiple widgets



Make a struct that contains pointers to all the widgets you need, then
either pass a pointer to that struct as the user_data to your callback
or attach it to the widget using gtk_object_set_user_data().

If you are lazy, just attach the data to the top-level widget and use a
function like this to get it back from any widget within the window:

gpointer 
widget_get_application_data(GtkWidget *widget)
{
    GtkWidget *parent;

    for (;;) {
	if (GTK_IS_MENU(widget))
	    parent = gtk_menu_get_attach_widget(GTK_MENU(widget));
	else
	    parent = widget->parent;
	if (parent == NULL)
	    break;
	widget = parent;
    }

    return gtk_object_get_user_data(GTK_OBJECT(widget));
}


Dieter Oelofse wrote:
> 
> I am new to GTK+ development. My problem is how to access multiple widgets from
> a callback. I want to take the text of two entry boxes, do some processing in
> the callback function that belongs to a button and put the result in a third
> entrybox. I just can't seem to figure out how to access these entry boxes from a
> callback that does not own any reference to these entry boxes. I don't think
> declaring these boxes globally is a good idea, but it might solve my problem.


-- 
René Seindal (rene@seindal.dk)			http://www.seindal.dk/rene/



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