aboutsummaryrefslogtreecommitdiff
path: root/libdbusmenu-glib/enum-types.c.in
diff options
context:
space:
mode:
authorTed Gould <ted@gould.cx>2011-02-18 12:48:23 -0600
committerTed Gould <ted@gould.cx>2011-02-18 12:48:23 -0600
commitb7434b48401a4049facc3eb455bb1075e1ad78ca (patch)
tree079279464dc425267bd7c0de857b3989a81105f9 /libdbusmenu-glib/enum-types.c.in
parent796c5d6a0a13c7429b32607625eb0cde2503c50f (diff)
downloadlibdbusmenu-b7434b48401a4049facc3eb455bb1075e1ad78ca.tar.gz
libdbusmenu-b7434b48401a4049facc3eb455bb1075e1ad78ca.tar.bz2
libdbusmenu-b7434b48401a4049facc3eb455bb1075e1ad78ca.zip
Adding a nick to value translator
Diffstat (limited to 'libdbusmenu-glib/enum-types.c.in')
-rw-r--r--libdbusmenu-glib/enum-types.c.in24
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 ***/