Should ToggleButton grouping/state tracking be done via Actions, as recommended for CheckButton?

The documentation for GtkCheckButton states:

When the code must keep track of the state of a group of radio buttons, it is recommended to keep track of such state through a stateful GAction with a target for each button. Using the toggled signals to keep track of the group changes and state is discouraged.

The documentation for GtkToggleButton has no such advice, but I presume it should, if actions are indeed recommended over groups/::toggled to track the currently active button within a ‘group’?

Related, the doc for gtk_checkbutton_set_group() says:

Note that the same effect can be achieved via the GtkActionable API, by using the same action with parameter type and state type ‘s’ for all buttons in the group, and giving each button its own target value.

And the equivalent for ToggleButton does repeat that, unlike the OP.

Must the state type be 's'? I have a situation where it would make more sense to use integers. Maybe we could just recommend a unique target value and leave it at that, or is there any reason to use a string?

Also, it appears that using actions instead of a group is not equivalent, because only when using a group does keynav with arrow keys work as expected; when using an action it does not. So I don’t see it as being ready as a drop-in replacement, when presumably we’ll have to add custom code to make keynav work again.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.