Re: [patch] adding radio buttons to radio groups
- From: "Shawn T . Amundson" <amundson gimp org>
- To: gtk-devel-list redhat com
- Subject: Re: [patch] adding radio buttons to radio groups
- Date: Wed, 20 Jan 1999 17:51:06 -0800
On Wed, Jan 20, 1999 at 02:30:28PM +0100, Tim Janik wrote:
...
> >
> > rb_a = gtk_radio_button_new_with_label (NULL, "A");
> > rb_b = gtk_radio_button_new_with_label (NULL, "B");
> > rb_c = gtk_radio_button_new_with_label (NULL, "C");
> >
> > radiogroup = gtk_radio_button_group (GTK_RADIO_BUTTON (rb_a));
> > gtk_radio_button_set_group (GTK_RADIO_BUTTON (rb_b), radiogroup);
> >
> > radiogroup = gtk_radio_button_group (GTK_RADIO_BUTTON (rb_a));
> > gtk_radio_button_set_group (GTK_RADIO_BUTTON (rb_c), radiogroup);
> >
...
>
> nope, the current code is actually intentional, if you connect multiple
> buttons together, there should be only one of them active. in your above
> example you should link the buttons together with _set_group() calls and
> then use gtk_toggle_button_set_active() only once if you need
> to change the active button.
In the above code, I create three active buttons initially. When I
add them all into the one group, I should still end up with only one
active. That's what is broken.
The patch I suggest ensures that items added to a group are set inactive
unless it is the first one being added. I don't think it makes sense
to allow new active items into a group since you are guarenteed that
there is already an active item in any given group.
> the current code tries to achive that, but fails due to a bug in the state
> setting code, the second part of gtk_radio_button_set_group should actually
> read:
>
> [...]
> if (group)
> {
> GSList *slist;
>
> for (slist = group; slist; slist = slist->next)
> {
> GtkRadioButton *tmp_button;
>
> tmp_button = slist->data;
>
> tmp_button->group = radio_button->group;
> }
> }
> else
> - {
> - GTK_TOGGLE_BUTTON (radio_button)->active = TRUE;
> - gtk_widget_set_state (GTK_WIDGET (radio_button), GTK_STATE_ACTIVE);
> - }
> + gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (radio_button), TRUE);
This doesn't fix the problem, since this only gets called when there
isn't anything in the group.
--
Shawn T. Amundson
amundson@gimp.org http://www.gimp.org/~amundson
"The assumption that the universe looks the same in every
direction is clearly not true in reality." - Stephen Hawking
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]