From: Damon Chaplin (damon@karuna.freeserve.co.uk)
Date: Sun Sep 26 1999 - 06:58:18 EDT
Chuck Lidderdale wrote:
>
> Is there a trick I've missed or ...
>
> I build a app, with buttons - gladesig.c has the callbacks - but
> gladesig.c
> has no knowledge of any other widgets - so todate I've cut the:
> GtkWidget *window1;
> GtkWidget *vbox1;
> GtkWidget *menubar1;
> GtkWidget *File;
> GtkWidget *Edit;
> GtkWidget *item3;
> ...
> out of "create_window1 ()"
> and moved it to common area in both src.c and sig.c - now sig.c know
> about
> all of my other widgets.
>
> How do you do it?
Glade provides the lookup_widget() function to get pointers to widgets
from within signal handlers.
>From the FAQ:
3.4 How do I get a pointer to a widget from within a signal handler?
Use the lookup_widget() function provided. (It can be found in support.c)
You pass it a pointer to any widget in a window, and the name of the widget
that you want to get. Usually in signal handlers you can use the first argument
to the signal handler as the first parameter to lookup_widget(), e.g.
void
on_button1_clicked (GtkButton *button,
gpointer user_data)
{
GtkWidget *entry1;
entry1 = lookup_widget (GTK_WIDGET (button), "entry1");
...
}
To get pointers to other windows/dialogs you would use the gtk_object_set_data()
and gtk_object_get_data() functions. I think the example editor code uses this.
Damon
+---------------------------------------------------------------------+
To unsubscribe from this list, send a message to majordomo@ncis.pn.org
with the line "unsubscribe glade-devel" in the body of the message.
This archive was generated by hypermail 2b29 : Tue Aug 01 2000 - 19:23:17 EDT