Add GVariant API to ease using enum values for "radio" GActions
@murrayc
Submitted by Murray Cumming Assigned to Allison (desrt)
Link to original bug (#705483)
Description
It would be helpful, and would encourage good GMenu code, to have API to get a string state value for an enum.
Some suggestions from Ryan on irc:
<desrt>
would it help if we have utility functions to convert string-typed GVariants into enum values of a given GType?
we do this conversion logic internally for gsettings already
<desrt>
it's a bit magic, but it clearly has the potential to be useful
<desrt>
so we would have g_variant_get_enum (v, G_TYPE_FOO) and g_variant_new_enum (G_TYPE_FOO, x);
<desrt>
then you could switch (g_variant_get_enum (v, G_TYPE_FOO) { case G_FOO_X: case G_FOO_Y: ... }
<desrt>
just unsure what to do about the case where we have no match.... return -1 or something, i guess
maybe with g_warning
Personally, I think g_variant_get_enum_from_string() and g_variant_new_string_from_enum() would be clearer, as it's a string-based variant that we'll be dealing with, because a GVariant can't hold enum types.(Other than as ints and those would be vulnerable to changes in the enum value order).