GNOME Bugzilla – Bug 722503
GSimpleAction: add default activate handler
Last modified: 2014-01-21 20:15:57 UTC
If the action is stateful and the user doesn't have their own activate handler then do some reasonable things for ourselves. After a lot of experience using stateful GSimpleAction it turns out that people almost always end up using it in the same ways: A boolean-typed stateful action with no parameter is most likely going to want to be toggled. Any other type of action that has the parameter type equal to the state type probably intends for activation to represent a request to change the state. This patch implements those two cases. This will let people stop writing their own trivial handlers over and over.
Created attachment 266618 [details] [review] GSimpleAction: add default activate handler
Review of attachment 266618 [details] [review]: Looks fine to me, given that we already use g_signal_has_handler_pending for change-state. Would be great to a) update some of our examples to use this, and b) add tests that trigger the default handling ::: gio/gsimpleaction.c @@ +367,3 @@ + * Since GLib 2.40, if no handler is connected to this signal then the + * default behaviour for boolean-stated actions with a %NULL parameter + * type is to toggle them via the change-action signal. For stateful #GSimpleAction::change-state,you mean ? @@ +369,3 @@ + * type is to toggle them via the change-action signal. For stateful + * actions where the state type is equal to the parameter type, the + * default is to forward them directly to change-action. This should And here too
Comment on attachment 266618 [details] [review] GSimpleAction: add default activate handler Attachment 266618 [details] pushed as 1ec7114 - GSimpleAction: add default activate handler
Created attachment 266626 [details] [review] test default GSimpleAction activation Test the default handling of the "activate" signal on GSimpleAction.
Review of attachment 266626 [details] [review]: looks good
Attachment 266626 [details] pushed as 829464a - test default GSimpleAction activation