GNOME Bugzilla – Bug 172345
Gtk::RadioAction, unable to specifiy initial activated entry without emitting signals.
Last modified: 2005-12-14 14:19:50 UTC
Under gtkmm it's not possible to specifiy the initial activated entry for Gtk::RadioAction's. Always the first inserted Gtk::RadioAction is the initial activated. Under gtk+ it's done by gtk_action_group_add_radio_actions() (the value argument).
You can store the action and activate it. Can you suggest some other API?
Anything?
Sorry for the delay ... Yes, you can activate the action. But it's not the same semantic as it can be done with the C interface. With the C interface you can set the default action without activating anything. If you activate the action the attached signals are called out thus doing something that normally only the user initiate. This can also be difficult if you setup the actions in a constructor as you need to verify the action can be safely activated from this place.
Can you suggest some other API?
Gtk::RadioAction have a method get_current_value() to obtain the value property of the currently active member of the group. What about a set_current_value() to set the active member? Helpful is then also an additional constructor to specify the value property (and/or get/set methods for the value property).
I tried to implement set_current_value in gtkmm (see patch), but there is no public GTK+ API to get the GtkActionGroup from the GtkRadioAction/GtkAction. I requested an implementation in GTK+ in bug #323007.
Created attachment 55518 [details] [review] radio_action_set_current_value.patch Unfinished patch.
> With the C interface you can set the default action > without activating anything. If you activate the action the attached signals are > called out thus doing something that normally only the user initiate. gtk_action_group_add_radio_action() does this by activating the action before connecting the signal. You can do that too in the C++ API, by calling RadioAction::set_active() before calling ActionGroup::add(action, *). Maybe it would help to add a bool active parameter to RadioAction::create(), but it already has lots of parameters.
Thoughts?
So, please reopen if RadioAction::set_active() (before adding to the group) isn't useful enough.