[glib/wip/swilmet/improve-doc: 1/2] docs: code example for enumeration types
- From: Sébastien Wilmet <swilmet src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glib/wip/swilmet/improve-doc: 1/2] docs: code example for enumeration types
- Date: Sun, 8 Feb 2015 15:18:51 +0000 (UTC)
commit 9a4e5a77c4963181fc3df9a12ec6002b084e9427
Author: Sébastien Wilmet <swilmet gnome org>
Date: Thu Sep 18 17:16:59 2014 +0200
docs: code example for enumeration types
I had to read the GTK+ code recently to have an example.
gobject/genums.c | 13 +++++++++++++
1 files changed, 13 insertions(+), 0 deletions(-)
---
diff --git a/gobject/genums.c b/gobject/genums.c
index d6dc559..a4f22c9 100644
--- a/gobject/genums.c
+++ b/gobject/genums.c
@@ -50,6 +50,19 @@
* GObject ships with a utility called [glib-mkenums][glib-mkenums],
* that can construct suitable type registration functions from C enumeration
* definitions.
+ *
+ * Example of how to get a string representation of an enum value:
+ * |[<!-- language="C" -->
+ * GEnumClass *enum_class;
+ * GEnumValue *enum_value;
+ *
+ * enum_class = g_type_class_ref (MAMAN_TYPE_MY_ENUM);
+ * enum_value = g_enum_get_value (enum_class, MAMAN_MY_ENUM_FOO);
+ *
+ * g_print ("Name: %s\n", enum_value->value_name);
+ *
+ * g_type_class_unref (enum_class);
+ * ]|
*/
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]