After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 728712 - Add a 'find the active one' function into GtkRadioButton
Add a 'find the active one' function into GtkRadioButton
Status: RESOLVED DUPLICATE of bug 166995
Product: gtk+
Classification: Platform
Component: Widget: GtkButton
3.12.x
Other All
: Normal enhancement
: ---
Assigned To: gtk-bugs
gtk-bugs
Depends on:
Blocks:
 
 
Reported: 2014-04-22 09:36 UTC by Wesley Chan
Modified: 2017-08-24 22:53 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Add that function. (1.39 KB, patch)
2014-04-22 09:39 UTC, Wesley Chan
none Details | Review

Description Wesley Chan 2014-04-22 09:36:20 UTC
There's a discussion here.
GTK+ How do I find which radio button is selected?
http://stackoverflow.com/questions/8812389/gtk-how-do-i-find-which-radio-button-is-selected

No one seems to give a good answer. They all suggest him to hunt down the toggled signal and save it to a variable.
I don't agree with them. Actually, it's available. Just get the GSList and enumerate them. See if any one is active.
But what if I want to do a lot of this action? I don't think it reasonable to enumerate them all in user's code. This should be one of the functions within GtkRadioButton itself.

To make it more easy to use, I suggest putting this one into GtkRadioButton. I've tested it and it's working. I'm no profession of GTK+ so if it's wrong, please excuse me.
Comment 1 Wesley Chan 2014-04-22 09:39:11 UTC
Created attachment 274873 [details] [review]
Add that function.

Patch against 3.12.1.
Comment 2 André Klapper 2014-04-23 16:08:59 UTC
Thanks for your patch!
Comment 3 Wesley Chan 2014-04-23 20:36:30 UTC
(In reply to comment #2)
> Thanks for your patch!

May I ask a question, sir?
I want to know about you, the GTK+ team's attitude of this kind of function. I found them handy, useful, and would live a hard life without them. Another example is, the way a user want to find out how many instances are there in a GtkComboBox. One need to get its tree model and get n iter. That's a chore. Users don't likely to care about tree model or flower model. They just want that number. It would be nice if there's a gtk_combo_box_get_item_amount() in it.
So I want to know the reason that there isn't such a function. Is it not implemented yet, or you want to keep the functions of widgets as simple as possible? In other words, I want to know if my suggestion would be accepted (even you will not add it recently, at least you accept it) or not.
Thank you.
Comment 4 André Klapper 2014-04-24 06:11:46 UTC
(In reply to comment #3)
> I want to know about you, the GTK+ team's attitude of this kind of function.

You might want to ask on https://mail.gnome.org/mailman/listinfo/gtk-devel-list
Comment 5 Daniel Boles 2017-08-24 22:53:16 UTC
Let's just have one thread for this. Feel free to post there.

I will say generally that if something is 'easy enough' to do, regardless of not a one-liner as you would like, then many libraries - not just GTK+ or GNOME ones - are reluctant to add every possible convenience function under the sun. Yes, it would be great if users had API for everything - for the users. That would be a tremendous coding and maintenance burden for the maintainers.

However, I think this - getting the active index and/or widget in a RadioButtonGroup - leans towards the side of being a bit too unintuitive and tedious to implement as a user, so it would be nice to see API for it. Personally I'd put it in GtkRadioButtonGroup, though.

Anyway, that's just my opinion; I have no idea either way whether any maintainer will want to merge it in. But it's worth a try, and that old bug isn't WONTFIX yet, so there's still hope. :P

*** This bug has been marked as a duplicate of bug 166995 ***