Add activate, activates-default to spinbutton
This adds the activate
signal and activates-default
property back to GtkSpinButton
, which accidentally got removed when GtkEntry
ceased to be a base class.
To see why this feature is useful, here are some examples in Inkscape:
-
In the guides dialog, hitting Enter after editing a spinbutton is supposed to dismiss the dialog:
This can be achieved with the
activates-default
property. -
In the colour picker, hitting Enter after editing a spinbutton is supposed to defocus the dialog:
This requires the
activate
signal.
There are also other pieces of software (e.g. dune3d) which have had to reinvent the missing functionality.
To test this MR, I used it to generate both videos.
The semantics of the new activate
signal is as follows. When the user presses enter, the activate
signal is only emitted if there isn't any text pending to be committed to the spinbutton. This is done by keeping track of an edited
flag - not by comparing the new and the old value to see if it changed, because we also want to consider an edit where the user changes their mind and enters the same old value to still be an edit.
Although this is slightly different to the GTK3 behaviour of simply considering activation to happen whenever the user presses enter, I'd argue that it's actually better, and was also what was requested by another user in https://discourse.gnome.org/t/spinbutton-activation-after-user-entry/5192.
/cc @ebassi due to involvement in https://discourse.gnome.org/t/where-is-activate-for-spinbuttons/17935/1.