[go: up one dir, main page]

Change Gio::Action 'transform-translate' to use a tuple Glib::Variant (dd).

One problem with the current Gio::Action setup is that complex arguments are given as strings. For example, the argument for 'transform-translate' requires two doubles, but we read in a string and then try to parse it in the function called by the action.

It would be better if we utilize Glib::Variants to specify the exact format expected for complex arguments. In the case of 'transform-translate' this would be "(d, d)", where the parentheses indicate a tuple and the 'd's indicate doubles.

See https://developer.gnome.org/glib/stable/gvariant-format-strings.html for how to describe arbitrary formats.

Not part of this merge request:

We currently use a syntax where actions are separated by ';' and arguments are separated from action names by ':'. We might consider changing the latter to use the syntax used by "detailed actions names", which uses parentheses to enclose the argument, e.g. 'transform-translate((50.0, 25.0))' (the outer parentheses enclose the argument while the inner ones indicate a tuple). This would allow us to directly parse the "detailed action name" into the action name plus a Glib::Variant of the matching type using Gio::Action::parse_detailed_name_variant(). One problem with parsing "detailed action names" via this function is that the Glib::Variant created is not always of the correct type. For example 'transform-translate((50,25))' is parsed as a tuple of two int's (i, i). We would have to check the parsed type against the expected type and then make modifications if necessary (something not hard to do).

Merge request reports

Loading