Re: [patch] adding radio buttons to radio groups
- From: Tim Janik <timj gtk org>
- To: "Shawn T . Amundson" <amundson gimp org>
- cc: Gtk+ Developers <gtk-devel-list redhat com>
- Subject: Re: [patch] adding radio buttons to radio groups
- Date: Fri, 22 Jan 1999 04:24:31 +0100 (CET)
On Wed, 20 Jan 1999, Shawn T . Amundson wrote:
> 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.
yeah, you are right, actually radio buttons were meant to be inactive
upon initial creation, but the unconditional call to
gtk_radio_button_set_group (group) even for group==NULL in gtk_radio_button_new
causes automated activation of the radio button upon creation.
i think the proper fix to this is to really check out the buttons state
and eventually reset it gtk_radio_button_set_group() so there's always only
one button active. additionally, we shouldn't call
gtk_radio_button_set_group (NULL) from gtk_radio_button_new() anymore, and
need to use gtk_toggle_button_set_active() for the state changes.
i'll hack something up later this night.
>
> > 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
>
>
> --
> To unsubscribe: mail gtk-devel-list-request@redhat.com with
> "unsubscribe" as the Subject.
>
>
---
ciaoTJ
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]