referencing widgets



Greetings all...

I'm fairly new to GTK and to C for that matter, but I cannot seem to find an example, or docs that describe exactly what I'm trying to do.

The accepted MO I see most often for adding multiples of any object to a window seems to be something along the line of:

GtkWidget *CreateWindow ( void )
{
 GtkWidget *window;
 GtkWidget *label;
 GtkWidget *entry;

 /* toplevel window creation code omitted for
  * space conservation purposes  */

 label = gtk_label_new ("First Name: ");
 entry = gtk_entry_new ( );

 /* Pack and show the above 2 widgets, then... */

 label = gtk_label_new ("Last Name: ");
 entry = gtk_entry_new ( );

 /* pack and show....repeat as needed */

 /* create, pack and show OK and cancel buttons, then: */
 gtk_widget_show (window);

 return ( window );
}


My question is this... Let's say this window is a dialog box, that contains entries for First name, last name, and phone number. After the user clicks the 'OK' button, I wish to call a sub to verify the data entered (no blank fields, no funny business with escape chars, etc).

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?

My intuition was that this was what gtk_widget_set_name() was for. Like...after creating the entry, before creating another, I call gtk_widget_set_name on it, then in my verify func, I could refer to them according to parent-><entry name>. Apparently this is not the case. Could someone shed some light on this for me?

Thanks...

-HaB

_________________________________________________________________
Get your FREE download of MSN Explorer at http://explorer.msn.com





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