Re: gtk_entry




>  I'm just learning gtk and need some help. I need to pass the contents of 
> three entry boxes to a button signal callback. How would I do this?
> Is there a way to access a widget which is on another widget which is 
> on yet another widget?  such as WindowWidget->hbox->entry to access the 
> entry widget on the hbox on the window? or is this a stupid thing to wanna
> do?   

There is no (easy) way to access the children of an HBox in a simple
manner. (For widgets, like ListItems or Buttons that have only a
single child, you can do: GTK_BIN(widget)->child)

You're best bet is probably to create a structure

typedef struct {
   GtkWidget *entry1;
   GtkWidget *entry2;
   GtkWidget *entry3;
} ThreeEntries;

fill in the fields, and pass that as the data to the callback. You can
then set up a "destroy" handler for the thing containing the entries
that frees the structure.

  entries_struct = g_new(ThreeEntries, 1);
  entries_struct->1 = my_first_entry;

  gtk_signal_connect (GTK_OBJECT(button), "clicked", 
                      GTK_SIGNAL_FUNC (my_handler), &entries_struct);

  gtk_signal_connect_object (hbox, "destroy", 
                             GTK_SIGNAL_FUNC (g_free), &entries_struct);

(connect_object() is used so that g_free() gets entries_struct as its first
 argument, not hbox)
 
Hope this helps,
                                        Owen



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