[Glade-users] Window communication.

On 16 Aug 2001 13:16:28 -0700, James Campbell wrote:

I'm running into an interesting problem that I thought was covered
in the FAQ.

I've got an ATM networking application that spawns off multiple
window threads to actually display sending and receiving ATM

The spawned windows are normal GTK top level windows, with
gnome_less widgets in them displaying from a buffer.

The problem I'm getting into is having the main callback functions
be able to hit the non-global widgets in the spawned windows.

I've tried the solution in the glade faq, but I can't seem to get it
to work properly.

Example (simplified):

1. main_window = lookup_widget(GTK_WIDGET(button), "main_window");
2. window = create_window();
3. gtk_widget_show(window);
4. gtk_object_set_data(GTK_OBJECT(main_window), "window" window);
5. windows = gtk_object_get_data(GTK_OBJECT(main_window), "window");
6. window_less = lookup_widget(windows, "windowless");

Here is what I think I'm doing:

Creating a pointer from the main window (and subsequent callback functions)
to one of the spawned windows (4).

Then calling the pointer to get data about the spawned window and set it to
a variable (5).

Finally using lookup_widget on the pointer I get from (5) to find the
widget "windowless" that is in one of the toplevel windows.

I know I'm getting something back from all that mess, as lookup_widget doesn't
barf, but when I try to display something on the widget, it crashes without
much explaination.

The idea looks OK. Note that you have to be careful that you don't try
to use these pointers after the windows are destroyed.

I'd suggest using debugging messages like

  g_print ("Window: %p\n", window);

to see whereabouts it is going wrong.

Didn't the stack trace give any clue?


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