Re: Problem with callback functions...



James Vanns wrote:

> Okay. I have a function called create_toogle_window (). Within this
function
> I have a few GtkWidgets initiated as GtkToggleButtons (3 of) and then one
OK
> button.
> 
> I have also a struct defined as within a header file:
> 
> typedef struct _options {
>    gboolean bss;
>    gboolean caf;
>    gboolean sb;
> } options;
> 
> and an instance of it (automatic not pointer) within the named function
> above.


The automatic bit is probably your problem. By the time the OK button is 
pressed, the stack frame you allocated your struct on has long since gone.

The usual technique is to have a struct for every window in your 
program. The struct keeps a pointer to each of your widgets, plus any 
other data you need to manage the display.

Make a new struct with g_new() when you build a window, free the struct 
on a "destroy" signal, and pass a pointer to the struct with every 
signal connect for widgets in that window.

An even better technique is to use gtk's class mechanism and do every 
window as a widget. There's an example in the tutorial.

http://www.gtk.org/tutorial/sec-creatingacompositewidget.html

HTH, John



========================================================== 
Renaissance Autumn at the National Gallery 
A season of exhibitions, displays and events with a Renaissance theme. 

Pisanello: Painter to the Renaissance Court (24 October - 13 January 2002) 

For information and tickets: 
http://www.nationalgallery.org.uk/what/news/ren_autumn.htm



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