diff options
Diffstat (limited to 'libdbusmenu-glib/enum-types.c.in')
-rw-r--r-- | libdbusmenu-glib/enum-types.c.in | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/libdbusmenu-glib/enum-types.c.in b/libdbusmenu-glib/enum-types.c.in index b0756d9..9395f5f 100644 --- a/libdbusmenu-glib/enum-types.c.in +++ b/libdbusmenu-glib/enum-types.c.in @@ -88,5 +88,29 @@ const gchar * return ret; } +/** + @enum_name@_get_value_from_nick: + @nick: The enum nick to lookup + + Looks up in the enum table for the value of @nick. + + Return value: The value for the given @nick +*/ +@EnumName@ +@enum_name@_get_value_from_nick (const gchar * nick) +{ + GEnumClass * class = G_ENUM_CLASS(g_type_class_ref(@enum_name@_get_type())); + g_return_val_if_fail(class != NULL, 0); + + @EnumName@ ret = 0; + GEnumValue * val = g_enum_get_value_by_nick(class, nick); + if (val != NULL) { + ret = val->value; + } + + g_type_class_unref(class); + return ret; +} + /*** END value-tail ***/ |