Re: radiobutton callback
- From: "Joshua Horvath" <Josh_Horvath-AJH051 email mot com>
- To: Peter Wurmsdobler <peter wurmsdobler ctm-france com>
- Cc: gtk-app-devel-list gnome org
- Subject: Re: radiobutton callback
- Date: Wed, 04 Oct 2000 15:32:08 -0500
I would expect the callback to be called twice when you click on one of the
radiobuttons. Since clicking on one button de-selects the other, GTK probably emits
an extra 'clicked' signal for the button that is being de-selected.
If you want to check to see which button was selected, use something like
pressed = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(button))
which will return true if the button is pressed in.
As for the bad value you get initially, you probably need to make one of the buttons
active before you handle the clicks. Try putting a
gtk_togglebutton_set_active(GTK_TOGGLE_BUTTON(button), TRUE) in your create function
and see if that helps.
-Josh
Peter Wurmsdobler wrote:
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]