GNOME Bugzilla – Bug 728712
Add a 'find the active one' function into GtkRadioButton
Last modified: 2017-08-24 22:53:16 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.
Created attachment 274873 [details] [review] Add that function. Patch against 3.12.1.
Thanks for your patch!
(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.
(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
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 ***