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: Wed, 20 Jan 1999 14:30:28 +0100 (CET)
On Tue, 19 Jan 1999, Shawn T . Amundson wrote:
> Currently using gtk_radio_button_set_group requires you to
> set the radio button to inactive, like this:
>
> 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);
> gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (rb_b), FALSE);
>
> radiogroup = gtk_radio_button_group (GTK_RADIO_BUTTON (rb_a));
> gtk_radio_button_set_group (GTK_RADIO_BUTTON (rb_c), radiogroup);
> gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (rb_a), FALSE);
>
> It would seem better to not require it, so the same would like look
> this:
>
> 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);
>
> This simple patch changes all added radio buttons to have active
> set to FALSE when using gtk_radio_button_set_group(). I couldn't
> find any code that actually uses gtk_radio_button_set_group(), and
> I suspect nothing would break with this patch even if it was used.
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.
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);
---
ciaoTJ
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]