After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 705483 - Add GVariant API to ease using enum values for "radio" GActions
Add GVariant API to ease using enum values for "radio" GActions
Status: RESOLVED OBSOLETE
Product: glib
Classification: Platform
Component: gvariant
unspecified
Other Linux
: Normal enhancement
: ---
Assigned To: Allison Karlitskaya (desrt)
gtkdev
Depends on:
Blocks:
 
 
Reported: 2013-08-05 09:05 UTC by Murray Cumming
Modified: 2018-05-24 15:35 UTC
See Also:
GNOME target: ---
GNOME version: ---



Description Murray Cumming 2013-08-05 09:05:23 UTC
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).
Comment 1 GNOME Infrastructure Team 2018-05-24 15:35:40 UTC
-- GitLab Migration Automatic Message --

This bug has been migrated to GNOME's GitLab instance and has been closed from further activity.

You can subscribe and participate further through the new bug through this link to our GitLab instance: https://gitlab.gnome.org/GNOME/glib/issues/741.