passing #define'd value to callback



Hello,

When I want to pass a usual variable to a handler connected
to an object, only the following code works:
----------common.h----------
#define OFF         ( 0 )
#define ON          ( 1 )
-------------x.c------------
static int off = OFF;
static int on  = ON;
void mm_spin_radiobutton_clicked( GtkButton *button, gpointer data ) {
    if ( GTK_TOGGLE_BUTTON(button)->active )
        do_something(data);
    }
void create( void ) {
    :
    gtk_signal_connect( 
        GTK_OBJECT( mm_off_radiobutton ), "clicked",
        GTK_SIGNAL_FUNC( mm_state_radiobutton_clicked ), &off );
    gtk_signal_connect( 
        GTK_OBJECT( mm_on_radiobutton ), "clicked",
        GTK_SIGNAL_FUNC( mm_state_radiobutton_clicked ), &on );
    :
    }

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:

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

Any ideas?
-- 
Dr. Peter Wurmsdobler

      CTM - Centre de Transfert des Microtechniques
39, av. de l'Observatoire, BP-1445, 25007 Besancon CEDEX 3
TELEPHONE: +33 3 81 47 70 20  TELECOPIE: +33 3 81 47 70 21
         E-mail: peter wurmsdobler ctm-france com

                  Ceterum censeo MIRCOSOFTem esse delendam.




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