Re: passing #define'd value to callback



Peter Wurmsdobler wrote:

If the variable off/on is declared inside the create function,
it works sometimes. However, I would prefer something without
extra declaration of each value passed, like:

The variable gets out of scope and its reserved memory is not
reserved anymore.

    gtk_signal_connect(
        GTK_OBJECT( mm_off_radiobutton ), "clicked",
        GTK_SIGNAL_FUNC( mm_state_radiobutton_clicked ),
        &(OFF) );

Any ideas?

void mm_spin_radiobutton_clicked( GtkButton *button, gpointer data )
{
  gint state = GPOINTER_TO_INT (data);
  ...
}

...

gtk_signal_connect( 
        GTK_OBJECT( mm_off_radiobutton ), "clicked",
        GTK_SIGNAL_FUNC( mm_state_radiobutton_clicked ), 
        GINT_TO_POINTER (OFF) );


Regards,
WL




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