Hi
I am really baffled by this but....I have a GSList
that I use to group my Radio buttons and I have another normal button that when
clicked passes a structure that contains my GSList to a function called by the
normal button. The first time I click the button the GSList is intact and I can
detect which radio button is selected. The second time I click the normal button
the GSList is corrupted and all its contents are lost. This is my code can
anyone tell me what this is happening?
typedef struct {
GSList * group;
GtkWidget * radio;
GtkWidget * button;
} screen_controls;
int main ( int argc, char *argv[] )
{
screen_controls *sc = new
screen_controls;
sc->group =
NULL;
sc->radio =
gtk_radio_button_new_with_label(sc->group, "Insert Counts");
sc->group =
gtk_radio_button_group ( GTK_RADIO_BUTTON ( sc->group ) );
sc->radio =
gtk_radio_button_new_with_label(sc->group, "Find Counts");
sc->group =
gtk_radio_button_group ( GTK_RADIO_BUTTON ( sc->group ) );
sc->radio =
gtk_radio_button_new_with_label(sc->group, "Both");
sc->group =
gtk_radio_button_group ( GTK_RADIO_BUTTON ( sc->group )
); sc->button =
gtk_button_new_with_label( "Send");
.........build the screen etc.
etc.
gtk_signal_connect (GTK_OBJECT
(sc->button), "clicked",
GTK_SIGNAL_FUN ( SendMessage
),
sc);
.........etc. etc.
gtk_main ();
}
void SendMessage(GtkWidget * button,
screen_controls * sc)
{
int i = 0;
sc->group = g_slist_nth(
sc->group, i );
while ( sc->group != NULL
&& i < 3)
{
if
(GTK_TOGGLE_BUTTON (sc->group->data)->active == TRUE)
{
cout << i << endl;
}
sc->group
= g_slist_next ( sc->group );
i++;
}
}
Any help would be kewl as this is doing my head
in.
Thanks in advance
Oh and cheers Carlos for the help with the Radio
Buttons.
|