Re: GTKRadioButton groups breakage/weirdness
- From: Owen Taylor <otaylor redhat com>
- To: Tim Janik <timj gtk org>
- Cc: Joel Becker <jlbec evilplan org>, Gtk+ Developers <gtk-devel-list gnome org>
- Subject: Re: GTKRadioButton groups breakage/weirdness
- Date: 29 Oct 2001 09:09:31 -0500
Tim Janik <timj gtk org> writes:
> On Sat, 27 Oct 2001, Joel Becker wrote:
>
> > GTKers,
> > So, the following code does not work:
> >
> > GtkWidget *a, *b, *c, *d;
> > GSList *group = NULL;
> > a = gtk_radio_button_new_with_label(NULL, "a");
> > group = gtk_radio_button_group(GTK_RADIO_BUTTON(a));
> > b = gtk_radio_button_new_with_label(group, "b");
> > c = gtk_radio_button_new_with_label(group, "c");
> > d = gtk_radio_button_new_with_label(group, "d");
> >
> > Because of the gyrations in gtk_radio_button_set_group, these
> > buttons end up in different groups. The following code does work
> > though:
> >
> > GtkWidget *a, *b, *c, *d;
> > GSList *group = NULL;
> > a = gtk_radio_button_new_with_label(NULL, "a");
> > group = gtk_radio_button_group(GTK_RADIO_BUTTON(a));
> > b = gtk_radio_button_new_with_label(group, "b");
> > group = gtk_radio_button_group(GTK_RADIO_BUTTON(b));
> > c = gtk_radio_button_new_with_label(group, "c");
> > group = gtk_radio_button_group(GTK_RADIO_BUTTON(c));
> > d = gtk_radio_button_new_with_label(group, "d");
> >
> > It appears you have to consider your group pointer invalid after
> > every addition, because of the way the list is recalculated. This is
> > non-obvious, and I'd consider broken. However, simply documenting this
> > limitation would suffice. But you have to peruse the source quite
> > heavily to see where this happens.
>
> jup, this is actually bad API.
Well, yes, that's been known for a long time, which is why
gtk_radio_button_new_from_widget() was added.
> i guess i'd accept a patch that changed radio button groups from GSList
> into GList (and walked group->prev in gtk_radio_button_new_with_label), as
> 1) walking a GList* cast into a GSList* and just accessing ->data will work
> fine
I really think this is too major a change to make at this point, even
if it would have been desirable a few months ago. A spot check in LXR
reveals thousands of uses of gtk_radio_button_group(), virtually all of
which involve assignment to a variable.
If we were going to change it, I'd make GtkRadioButtonGroup an
opaque data type, or even a GObject, so you could have things
like "gtk_radio_button_group_get_active_widget().
But we really have to cut off major and even minor changes at this
point.
Regards,
Owen
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]