aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--libdbusmenu-glib/enum-types.c.in25
-rw-r--r--libdbusmenu-glib/enum-types.h.in2
2 files changed, 27 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 ***/
diff --git a/libdbusmenu-glib/enum-types.h.in b/libdbusmenu-glib/enum-types.h.in
index 83b4bd2..eb24453 100644
--- a/libdbusmenu-glib/enum-types.h.in
+++ b/libdbusmenu-glib/enum-types.h.in
@@ -44,10 +44,12 @@ G_END_DECLS
/*** BEGIN file-production ***/
/* Enumerations from file: "@filename@" */
+#include "@filename@"
/*** END file-production ***/
/*** BEGIN value-header ***/
GType @enum_name@_get_type (void) G_GNUC_CONST;
+const gchar * @enum_name@_get_nick (@EnumName@ value) G_GNUC_CONST;
#define DBUSMENU_TYPE_@ENUMSHORT@ (@enum_name@_get_type())
/*** END value-header ***/