[libegg] Generate enums for wrapbox



commit 0eff0aac0c95069404064275115739ebf1b61a2a
Author: David King <davidk openismus com>
Date:   Mon Apr 4 15:26:58 2011 +0200

    Generate enums for wrapbox

 libegg/wrapbox/Makefile.am  |   40 +++++++++++++++++++++++++++++++++++++++-
 libegg/wrapbox/eggwrapbox.c |    3 ++-
 2 files changed, 41 insertions(+), 2 deletions(-)
---
diff --git a/libegg/wrapbox/Makefile.am b/libegg/wrapbox/Makefile.am
index bd6d63b..1f31091 100644
--- a/libegg/wrapbox/Makefile.am
+++ b/libegg/wrapbox/Makefile.am
@@ -6,12 +6,50 @@ noinst_LTLIBRARIES = libegg-wrapbox.la
 libegg_wrapbox_la_LIBADD = $(EGG_30_LIBS)
 
 libegg_wrapbox_la_SOURCES = \
-	eggwrapbox.h \
+	$(enum_data) \
+	$(eggwrapbox_header) \
 	eggwrapbox.c
 
+eggwrapbox_header = eggwrapbox.h
+
+enum_data = \
+	eggwrapbox-enums.c \
+	eggwrapbox-enums.h
+
+eggwrapbox-enums.c: $(eggwrapbox_header) eggwrapbox-enums.h
+	$(AM_V_GEN)$(GLIB_MKENUMS) \
+		--fhead "#include \"eggwrapbox-enums.h\"\n\n" \
+		--fprod "/* enumerations from \"@filename \" */\n" \
+		--fprod "#include \"@filename \"\n" \
+		--vhead "GType\n enum_name@_get_type (void)\n{\n" \
+		--vhead "  static GType type = 0;\n\n" \
+		--vhead "  if (!type)\n  {\n" \
+		--vhead "    static const G Type@Value _ enum_name@_values[] = {" \
+		--vprod "      { @VALUENAME@, \"@VALUENAME \", \"@valuenick \" }," \
+		--vtail "      { 0, NULL, NULL }\n    };\n\n" \
+		--vtail "    type = g_ type@_register_static (\"@EnumName \", _ enum_name@_values);\n  }\n\n" \
+		--vtail "  return type;\n}\n\n" \
+		$(eggwrapbox_header) > $@
+
+eggwrapbox-enums.h: $(eggwrapbox_header)
+	$(AM_V_GEN)$(GLIB_MKENUMS) \
+		--fhead "#ifndef EGG_WRAPBOX_ENUMS_H_\n" \
+		--fhead "#define EGG_WRAPBOX_ENUMS_H_\n\n" \
+		--fhead "#include <glib-object.h>\n\n" \
+		--fhead "G_BEGIN_DECLS\n\n" \
+		--fprod "/* enumerations from @filename@ */\n" \
+		--vhead "GType @enum_name _get_type (void) G_GNUC_CONST;\n" \
+		--vhead "#define EGG_TYPE_ ENUMSHORT@ (@enum_name _get_type())\n" \
+		--ftail "G_END_DECLS\n\n" \
+		--ftail "#endif /* EGG_WRAPBOX_ENUMS_H_ */" \
+		$(eggwrapbox_header) > $@
+
+
 noinst_PROGRAMS = testwrapbox
 
 testwrapbox_SOURCES = testwrapbox.c
 
 testwrapbox_LDADD = $(EGG_30_LIBS) \
 	libegg-wrapbox.la
+
+CLEANFILES = $(enum_data)
diff --git a/libegg/wrapbox/eggwrapbox.c b/libegg/wrapbox/eggwrapbox.c
index 6f900af..3934f05 100644
--- a/libegg/wrapbox/eggwrapbox.c
+++ b/libegg/wrapbox/eggwrapbox.c
@@ -45,6 +45,7 @@
 #endif
 
 #include "eggwrapbox.h"
+#include "eggwrapbox-enums.h"
 
 #define P_(msgid) (msgid)
 #define GTK_PARAM_READWRITE (G_PARAM_READABLE | G_PARAM_WRITABLE)
@@ -319,7 +320,7 @@ egg_wrap_box_class_init (EggWrapBoxClass *class)
                                               ("packing",
                                                P_("Packing"),
                                                P_("The packing options to use for this child"),
-                                               GTK_TYPE_WRAP_BOX_PACKING, 0,
+                                               EGG_TYPE_WRAP_BOX_PACKING, 0,
                                                GTK_PARAM_READWRITE));
 
   g_type_class_add_private (class, sizeof (EggWrapBoxPrivate));



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]