Dan Mueth <[EMAIL PROTECTED]> wrote
> ...
> Does one have to define external variables for this, or is there a nicer
> way?
Yes, there is a (nicer?) way:
Suppose you have a main window 'mainwin' and some other toplevel windows
'subwin1', 'subwin2', ...
Then glade generates the code in the file interface.c
in create_mainwin()
...
gtk_object_set_data(GTK_OBJECT(mainwin),mainwin,"mainwin");
...
in create_subwin1()
...
gtk_object_set_data(GTK_OBJECT(subwin1),subwin1,"subwin1");
...
and in the file main.c:
mainwin = create_mainwin();
subwin1 = create_subwin1();
...
Then you can add the following lines (still in main())
gtk_object_set_data(GTK_OBJECT(mainwin),subwin1,"subwin1");
gtk_object_set_data(GTK_OBJECT(mainwin),subwin2,"subwin2");
gtk_object_set_data(GTK_OBJECT(subwin1),mainwin,"mainwin");
gtk_object_set_data(GTK_OBJECT(subwin2),mainwin,"mainwin");
Now if you want to reference a widget "combo1" defined in subwin1
from within a callback on_button1_clicked where button1 is defined
in within subwin2 you use the following sequence:
void on_button1_clicked (GtkButton *button, gpointer user_data)
{
GtkWidget *subwin1, *subwin2, *mainwin, *combo1;
subwin2 = lookup_widget(GTK_WIDGET(button),"subwin2");
mainwin = lookup_widget(GTK_WIDGET(subwin2),"mainwin");
subwin1 = lookup_widget(GTK_WIDGET(mainwin),"subwin1");
combo1 = lookup_widget(GTK_WIDGET(subwin1),"combo1");
}
Alternativly you could also add lines
gtk_object_set_data(GTK_OBJECT(subwin1),subwin2,"subwin2");
gtk_object_set_data(GTK_OBJECT(subwin2),subwin1,"subwin1");
in main.c thereby avoiding the detour using always the 'mainwin'.
But this has the drawback that you need n^2 gtk_object_set_data
calls instaed of 2*n for n toplevel windows.
Gerhard
+---------------------------------------------------------------------+
To unsubscribe from this list, send a message to [EMAIL PROTECTED]
with the line "unsubscribe glade-devel" in the body of the message.