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

RE: radiobutton callback



I believe the 2 callbacks are due to changing the state of two buttons (i.e.
once for the newly selected button and once for the previously selected button).
To tell the difference between the two, try using the following code in your
callback;

if ( GTK_TOGGLE_BUTTON(radio_Button)->active )
{
}

Hope this helps.



				-- Stupid Genius


> ----------
> From: 	Peter Wurmsdobler[SMTP:peter.wurmsdobler@ctm-france.com]
> Sent: 	Tuesday, October 03, 2000 11:01 AM
> To: 	gtk-app-devel-list@gnome.org
> Subject: 	radiobutton callback
> 
> Hello,
> 
> Actually I want to pass different predefined values to
> a single callback for two radiobuttons, but the callback
> seems to be called twice for a single mouse click, and
> in addition the passed data changes. I do:
> 
> void spin_radiobutton_clicked( GtkButton *button, gpointer data )
>     {
>     int *x = data;
>     printf("*x = %d\n", *x );
>     }
> 
> void create(void)
>     {
>     int spin_right = RIGHT;
>     int spin_left  = LEFT;
> 
>     spin_group = NULL;
>     spin_left_radiobutton = 
>         gtk_radio_button_new_with_label( spin_group, 
>         LEFT_RADIOBUTTON_TEXT );
>     spin_group = gtk_radio_button_group( 
>         GTK_RADIO_BUTTON( spin_left_radiobutton) );
>     gtk_signal_connect( 
>         GTK_OBJECT( spin_left_radiobutton ), "clicked",
>         GTK_SIGNAL_FUNC( spin_radiobutton_clicked ),
>         &spin_left );
> 
>     spin_right_radiobutton = 
>         gtk_radio_button_new_with_label( spin_group, 
>         RIGHT_RADIOBUTTON_TEXT );
>     spin_group = gtk_radio_button_group( 
>         GTK_RADIO_BUTTON( spin_right_radiobutton) );
>     gtk_signal_connect( 
>         GTK_OBJECT( spin_right_radiobutton ), "clicked",
>         GTK_SIGNAL_FUNC( spin_radiobutton_clicked ),
>         &spin_right );
>     }
> 
> Even though I thought of using something like &RIGHT instead
> of using an extra int spin_right = RIGHT; anyway, the debug
> messages show:
> 
> *x = -1073743848
> *x = 134836864
> 
> *x = 134836864
> *x = 0
> 
> *x = 0
> *x = 134836864
> 
> So, sometimes it works, sometimes not, which makes me
> think that a pointer is freed sometimes. Any hints?
> peterw
> -- 
> 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.
> 
> _______________________________________________
> gtk-app-devel-list mailing list
> gtk-app-devel-list@gnome.org
> http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
> 




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