views:

10

answers:

1

Hello,

I have 4 gtkradiobuttons in my C/gtk+ application. But all of them are active.

My code:

radio_button1 = gtk_radio_button_new_with_label(radio_list, "radio1"); 
radio_button2 = gtk_radio_button_new_with_label(radio_list, "radio2"); 
radio_button3 = gtk_radio_button_new_with_label(radio_list, "radio3"); 
radio_button4 = gtk_radio_button_new_with_label(radio_list, "radio4");

I read man but not found solution, How can make that in one time only one radiobutton be active.

Thank you

+2  A: 

From the Gtk Docs:

void create_radio_buttons (void) {

   GtkWidget *window, *radio1, *radio2, *box, *entry;
   window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
   box = gtk_vbox_new (TRUE, 2);

   /* Create a radio button with a GtkEntry widget */
   radio1 = gtk_radio_button_new (NULL);
   entry = gtk_entry_new ();
   gtk_container_add (GTK_CONTAINER (radio1), entry);


   /* Create a radio button with a label */
   radio2 = gtk_radio_button_new_with_label_from_widget (GTK_RADIO_BUTTON (radio1),
                                                         "I'm the second radio button.");

   /* Pack them into a box, then show all the widgets */
   gtk_box_pack_start (GTK_BOX (box), radio1, TRUE, TRUE, 2);
   gtk_box_pack_start (GTK_BOX (box), radio2, TRUE, TRUE, 2);
   gtk_container_add (GTK_CONTAINER (window), box);
   gtk_widget_show_all (window);
   return;
}
DoR