Re: referencing widgets



John Cupitt <john cupitt ng-london org uk> writes:

> HaB balicious wrote:
> > My question is this.  In the function I call via the OK buttons "clicked"
> > event, is there a way to reference each of the entry widgets separately?
> > IOW, since they were all created with the same declared var, 'entry', is
> > there a way to tell which is which once I am in another func?  Or do I have
> > to create them all separately, passing each one's variable out to the verify
> > func?  Make them global?
> 
> Hiya, the usual way to do this is to make a struct with a member for
> each of your widgets. g_new() one of your structs when you build the
> dialog, set the members as you build the widgets, pass the address of
> the struct to the callback, and free the struct on destroy.

Another possibility is to add the widget pointers to the OK button 
using gtk_object_set_data (object, "some_descriptive_name, pointer)
and retrieving them in the callback using gtk_object_get_data().


Salut, Sven





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