diff options
author | Ted Gould <ted@gould.cx> | 2011-02-17 23:24:41 -0600 |
---|---|---|
committer | Ted Gould <ted@gould.cx> | 2011-02-17 23:24:41 -0600 |
commit | 5c0f6f04e9be75e273049bf5b4134185c12d32c1 (patch) | |
tree | 8a8fa94402faba74a1a490e68f5e683fda9fb017 /libdbusmenu-glib/enum-types.c.in | |
parent | f80eb0bcc21a8e1917b290b50ef400e2c8fb090f (diff) | |
download | libdbusmenu-5c0f6f04e9be75e273049bf5b4134185c12d32c1.tar.gz libdbusmenu-5c0f6f04e9be75e273049bf5b4134185c12d32c1.tar.bz2 libdbusmenu-5c0f6f04e9be75e273049bf5b4134185c12d32c1.zip |
Adding a get_nick function for our enums
Diffstat (limited to 'libdbusmenu-glib/enum-types.c.in')
-rw-r--r-- | libdbusmenu-glib/enum-types.c.in | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/libdbusmenu-glib/enum-types.c.in b/libdbusmenu-glib/enum-types.c.in index d572d44..b0756d9 100644 --- a/libdbusmenu-glib/enum-types.c.in +++ b/libdbusmenu-glib/enum-types.c.in @@ -64,4 +64,29 @@ GType return etype; } +/** + @enum_name@_get_nick: + @value: The value of @EnumName@ to get the nick of + + Looks up in the enum table for the nick of @value. + + Return value: The nick for the given value or #NULL on error +*/ +const gchar * +@enum_name@_get_nick (@EnumName@ value) +{ + GEnumClass * class = G_ENUM_CLASS(g_type_class_ref(@enum_name@_get_type())); + g_return_val_if_fail(class != NULL, NULL); + + const gchar * ret = NULL; + GEnumValue * val = g_enum_get_value(class, value); + if (val != NULL) { + ret = val->value_nick; + } + + g_type_class_unref(class); + return ret; +} + + /*** END value-tail ***/ |