Andre K�ster <[EMAIL PROTECTED]> writes:
> void main(int argc, int *argv[]) {
> GSList * group;
> GtkWidget *window,*rb,*box;
> int i ;
>
> gtk_init(&argc, &argv);
> window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
> box = gtk_hbox_new(TRUE, 0);
> for (i=1;i<=5;i++) {
> if (i==1) {
> rb = gtk_radio_button_new_with_label(NULL,"test123");
> group = gtk_radio_button_group(GTK_RADIO_BUTTON(rb));
> }
> else rb = gtk_radio_button_new_with_label(group,"test123");
> gtk_box_pack_start_defaults(GTK_BOX(box),GTK_WIDGET(rb));
> }
> gtk_widget_show_all(box);
> gtk_container_add(GTK_CONTAINER(window),box);
> gtk_widget_show_all(window);
> gtk_main();
> return 0;
> }
>
> Where is my mistake? First I found this in gtk-1.3.5 but I could also reproduce it
> in the current stable version...
>
The basic problem is crappy design in the RadioButton API.
Mistake #1 in RadioButton is using GSList for groups, instead of
some sort of special group type or at least GList.
This is compounded by Mistake #2: new group members are prepended,
changing the head of the list. When you add a button to a group, it
prepends that button, and changes rb->group for all other buttons in
the group. This keeps your code from working.
The basic solution is that you want to gtk_radio_button_get_group() on
one of the previous buttons every time, instead of storing the first
group you get and reusing it. On the third run of your loop, "group"
is no longer the head of the list, and isn't the same as
gtk_radio_button_get_group(first_radio_button_created).
Havoc
_______________________________________________
gtk-list mailing list
[EMAIL PROTECTED]
http://mail.gnome.org/mailman/listinfo/gtk-list