[glade] Automatically generate enum types.
- From: Tristan Van Berkom <tvb src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glade] Automatically generate enum types.
- Date: Sat, 13 Apr 2013 17:51:03 +0000 (UTC)
commit e6f537591d1f5ee14c37ca703b68fd41e9f622a8
Author: Tristan Van Berkom <tristan van berkom gmail com>
Date: Sat Apr 13 20:49:45 2013 +0900
Automatically generate enum types.
configure.ac | 1 +
gladeui/Makefile.am | 21 ++++++++++++++++++--
gladeui/glade-builtins.c | 22 ---------------------
gladeui/glade-builtins.h | 2 --
gladeui/glade-palette.c | 1 +
gladeui/glade-project.c | 21 +-------------------
gladeui/glade-project.h | 2 --
gladeui/glade-widget-adaptor.c | 22 ---------------------
gladeui/glade-widget-adaptor.h | 3 ---
gladeui/glade.h | 1 +
gladeui/gladeui-enum-types.c.template | 36 +++++++++++++++++++++++++++++++++++
gladeui/gladeui-enum-types.h.template | 25 ++++++++++++++++++++++++
12 files changed, 84 insertions(+), 73 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index cab7fce..13735e9 100644
--- a/configure.ac
+++ b/configure.ac
@@ -44,6 +44,7 @@ LT_INIT([dlopen win32-dll disable-static])
AC_PATH_PROG(GLIB_COMPILE_RESOURCES, glib-compile-resources)
AC_PATH_PROG(GLIB_GENMARSHAL, glib-genmarshal)
+AC_PATH_PROG(GLIB_MKENUMS, glib-mkenums)
AC_PATH_PROG(DLLTOOL, dlltool)
# If the source code has changed at all, increment GLADE_REVISION
diff --git a/gladeui/Makefile.am b/gladeui/Makefile.am
index 543206c..3be90a9 100644
--- a/gladeui/Makefile.am
+++ b/gladeui/Makefile.am
@@ -48,7 +48,10 @@ BUILT_SOURCES = \
glade-marshallers.c \
glade-marshallers.h \
gladeui-resources.c \
- gladeui-resources.h
+ gladeui-resources.h \
+ gladeui-enum-types.c \
+ gladeui-enum-types.h
+
UI_FILES = \
glade-editor.ui \
@@ -66,7 +69,10 @@ EXTRA_DIST = \
gladeui.rc.in \
icon-naming-spec.c \
glade-previewer.rc.in \
- gladeui-resources.gresource.xml
+ gladeui-resources.gresource.xml \
+ gladeui-enum-types.c.template \
+ gladeui-enum-types.h.template
+
# The glade core library
libgladeui_2_la_SOURCES = \
@@ -208,6 +214,17 @@ glade-marshallers.c: glade-marshallers.list $(GLIB_GENMARSHAL)
&& mv glade-marshallers-c.tmp glade-marshallers.c \
|| ( rm -f glade-marshallers-c.tmp && exit 1 )
+#
+# Enum type generation
+#
+gladeui-enum-types.h: gladeui-enum-types.h.template $(libgladeuiinclude_HEADERS) $(GLIB_MKENUMS)
+ $(AM_V_GEN) (cd $(srcdir) && $(GLIB_MKENUMS) --template $ template \
+ $(libgladeuiinclude_HEADERS)) > $@
+
+gladeui-enum-types.c: gladeui-enum-types.c.template $(libgladeuiinclude_HEADERS) $(GLIB_MKENUMS)
+ $(AM_V_GEN) (cd $(srcdir) && $(GLIB_MKENUMS) --template $ template \
+ $(libgladeuiinclude_HEADERS)) > $@
+
CLEANFILES = $(BUILT_SOURCES)
#
diff --git a/gladeui/glade-builtins.c b/gladeui/glade-builtins.c
index 50bfb89..6a07441 100644
--- a/gladeui/glade-builtins.c
+++ b/gladeui/glade-builtins.c
@@ -564,25 +564,3 @@ glade_standard_boolean_spec (void)
return g_param_spec_boolean ("boolean", "Boolean",
"A boolean value", FALSE, G_PARAM_READWRITE);
}
-
-GType
-glade_item_appearance_get_type (void)
-{
- static GType etype = 0;
-
- if (etype == 0)
- {
- static const GEnumValue values[] = {
- {GLADE_ITEM_ICON_AND_LABEL, "GLADE_ITEM_ICON_AND_LABEL",
- "icon-and-label"},
- {GLADE_ITEM_ICON_ONLY, "GLADE_ITEM_ICON_ONLY", "icon-only"},
- {GLADE_ITEM_LABEL_ONLY, "GLADE_ITEM_LABEL_ONLY", "label-only"},
- {0, NULL, NULL}
- };
-
- etype = g_enum_register_static ("GladeItemAppearance", values);
-
- }
-
- return etype;
-}
diff --git a/gladeui/glade-builtins.h b/gladeui/glade-builtins.h
index 16723ad..7edabd3 100644
--- a/gladeui/glade-builtins.h
+++ b/gladeui/glade-builtins.h
@@ -13,7 +13,6 @@ typedef struct _GladeParamSpecObjects GladeParamSpecObjects;
#define GLADE_TYPE_STOCK_IMAGE (glade_standard_stock_image_get_type())
#define GLADE_TYPE_GLIST (glade_glist_get_type())
#define GLADE_TYPE_PARAM_OBJECTS (glade_param_objects_get_type())
-#define GLADE_TYPE_ITEM_APPEARANCE (glade_item_appearance_get_type())
#define GLADE_IS_STOCK(pspec) \
(G_TYPE_CHECK_INSTANCE_TYPE ((pspec), GLADE_TYPE_STOCK))
@@ -32,7 +31,6 @@ GType glade_standard_stock_get_type (void) G_GNUC_CONST;
GType glade_standard_stock_image_get_type (void) G_GNUC_CONST;
GType glade_glist_get_type (void) G_GNUC_CONST;
GType glade_param_objects_get_type (void) G_GNUC_CONST;
-GType glade_item_appearance_get_type (void) G_GNUC_CONST;
GParamSpec *glade_param_spec_objects (const gchar *name,
const gchar *nick,
diff --git a/gladeui/glade-palette.c b/gladeui/glade-palette.c
index e738a26..7d4d79e 100644
--- a/gladeui/glade-palette.c
+++ b/gladeui/glade-palette.c
@@ -38,6 +38,7 @@
*/
#include "glade.h"
+#include "gladeui-enum-types.h"
#include "glade-app.h"
#include "glade-palette.h"
#include "glade-catalog.h"
diff --git a/gladeui/glade-project.c b/gladeui/glade-project.c
index e0b79e0..3f310f4 100644
--- a/gladeui/glade-project.c
+++ b/gladeui/glade-project.c
@@ -39,6 +39,7 @@
#include <glib/gstdio.h>
#include "glade.h"
+#include "gladeui-enum-types.h"
#include "glade-widget.h"
#include "glade-id-allocator.h"
#include "glade-app.h"
@@ -179,26 +180,6 @@ typedef struct
gint position;
} CatalogInfo;
-GType
-glade_pointer_mode_get_type (void)
-{
- static GType etype = 0;
-
- if (etype == 0)
- {
- static const GEnumValue values[] = {
- {GLADE_POINTER_SELECT, "select", "Select-widgets"},
- {GLADE_POINTER_ADD_WIDGET, "add", "Add-widgets"},
- {GLADE_POINTER_DRAG_RESIZE, "drag-resize", "Drag-and-resize-widgets"},
- {GLADE_POINTER_MARGIN_EDIT, "margin-edit", "Edit-widget-margins"},
- {GLADE_POINTER_ALIGN_EDIT, "align-edit", "Edit-widget-alignment"},
- {0, NULL, NULL}
- };
- etype = g_enum_register_static ("GladePointerMode", values);
- }
- return etype;
-}
-
static void glade_project_target_version_for_adaptor (GladeProject *project,
GladeWidgetAdaptor *adaptor,
gint *major,
diff --git a/gladeui/glade-project.h b/gladeui/glade-project.h
index e11b425..a78ab26 100644
--- a/gladeui/glade-project.h
+++ b/gladeui/glade-project.h
@@ -13,7 +13,6 @@ G_BEGIN_DECLS
#define GLADE_IS_PROJECT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GLADE_TYPE_PROJECT))
#define GLADE_IS_PROJECT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GLADE_TYPE_PROJECT))
#define GLADE_PROJECT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GLADE_TYPE_PROJECT,
GladeProjectClass))
-#define GLADE_TYPE_POINTER_MODE (glade_pointer_mode_get_type())
typedef struct _GladeProjectPrivate GladeProjectPrivate;
typedef struct _GladeProjectClass GladeProjectClass;
@@ -128,7 +127,6 @@ struct _GladeProjectClass
};
-GType glade_pointer_mode_get_type (void) G_GNUC_CONST;
GType glade_project_get_type (void) G_GNUC_CONST;
GladeProject *glade_project_new (void);
diff --git a/gladeui/glade-widget-adaptor.c b/gladeui/glade-widget-adaptor.c
index 6fa6e43..27d3375 100644
--- a/gladeui/glade-widget-adaptor.c
+++ b/gladeui/glade-widget-adaptor.c
@@ -1485,28 +1485,6 @@ glade_widget_adaptor_class_init (GladeWidgetAdaptorClass *adaptor_class)
g_type_class_add_private (adaptor_class, sizeof (GladeWidgetAdaptorPrivate));
}
-GType
-glade_create_reason_get_type (void)
-{
- static GType etype = 0;
-
- if (etype == 0)
- {
- static const GEnumValue values[] = {
- {GLADE_CREATE_USER, "GLADE_CREATE_USER", "create-user"},
- {GLADE_CREATE_COPY, "GLADE_CREATE_COPY", "create-copy"},
- {GLADE_CREATE_LOAD, "GLADE_CREATE_LOAD", "create-load"},
- {GLADE_CREATE_REBUILD, "GLADE_CREATE_REBUILD", "create-rebuild"},
- {0, NULL, NULL}
- };
-
- etype = g_enum_register_static ("GladeCreateReason", values);
-
- }
-
- return etype;
-}
-
/*******************************************************************************
Synthetic Object Derivation
*******************************************************************************/
diff --git a/gladeui/glade-widget-adaptor.h b/gladeui/glade-widget-adaptor.h
index 8cb9c01..ecbe19e 100644
--- a/gladeui/glade-widget-adaptor.h
+++ b/gladeui/glade-widget-adaptor.h
@@ -170,8 +170,6 @@ typedef enum
GLADE_CREATE_REASONS
} GladeCreateReason;
-#define GLADE_TYPE_CREATE_REASON (glade_create_reason_get_type())
-
/**
* GladeSetPropertyFunc:
* @adaptor: A #GladeWidgetAdaptor
@@ -697,7 +695,6 @@ struct _GladeWidgetAdaptorClass
GType glade_widget_adaptor_get_type (void) G_GNUC_CONST;
-GType glade_create_reason_get_type (void) G_GNUC_CONST;
GType glade_widget_adaptor_get_object_type (GladeWidgetAdaptor *adaptor);
G_CONST_RETURN gchar *glade_widget_adaptor_get_name (GladeWidgetAdaptor *adaptor);
diff --git a/gladeui/glade.h b/gladeui/glade.h
index ddfb178..a6195e4 100644
--- a/gladeui/glade.h
+++ b/gladeui/glade.h
@@ -27,6 +27,7 @@
#include <gladeui/glade-property-class.h>
#include <gladeui/glade-property.h>
#include <gladeui/glade-signal-class.h>
+#include <gladeui/glade-signal-model.h>
#include <gladeui/glade-signal.h>
#include <gladeui/glade-project.h>
#include <gladeui/glade-app.h>
diff --git a/gladeui/gladeui-enum-types.c.template b/gladeui/gladeui-enum-types.c.template
new file mode 100644
index 0000000..2979cd0
--- /dev/null
+++ b/gladeui/gladeui-enum-types.c.template
@@ -0,0 +1,36 @@
+/*** BEGIN file-header ***/
+#include <gladeui/glade.h>
+#include <gladeui/gladeui-enum-types.h>
+
+/*** END file-header ***/
+
+/*** BEGIN file-production ***/
+/* enumerations from "@filename@" */
+/*** END file-production ***/
+
+/*** BEGIN value-header ***/
+GType
+ enum_name@_get_type (void)
+{
+ static GType etype = 0;
+ if (G_UNLIKELY(etype == 0)) {
+ static const G Type@Value values[] = {
+/*** END value-header ***/
+
+/*** BEGIN value-production ***/
+ { @VALUENAME@, "@VALUENAME@", "@valuenick@" },
+/*** END value-production ***/
+
+/*** BEGIN value-tail ***/
+ { 0, NULL, NULL }
+ };
+ etype = g_ type@_register_static (g_intern_static_string ("@EnumName@"), values);
+ }
+ return etype;
+}
+
+/*** END value-tail ***/
+
+/*** BEGIN file-tail ***/
+
+/*** END file-tail ***/
diff --git a/gladeui/gladeui-enum-types.h.template b/gladeui/gladeui-enum-types.h.template
new file mode 100644
index 0000000..bed70fd
--- /dev/null
+++ b/gladeui/gladeui-enum-types.h.template
@@ -0,0 +1,25 @@
+/*** BEGIN file-header ***/
+#ifndef __GLADEUI_ENUM_TYPES_H__
+#define __GLADEUI_ENUM_TYPES_H__
+
+#include <glib-object.h>
+#include <gladeui/glade.h>
+
+G_BEGIN_DECLS
+/*** END file-header ***/
+
+/*** BEGIN file-production ***/
+
+/* enumerations from "@filename@" */
+/*** END file-production ***/
+
+/*** BEGIN value-header ***/
+GType @enum_name _get_type (void) G_GNUC_CONST;
+#define @ENUMPREFIX _TYPE_@ENUMSHORT@ (@enum_name _get_type ())
+/*** END value-header ***/
+
+/*** BEGIN file-tail ***/
+G_END_DECLS
+
+#endif /* __GLADEUI_ENUM_TYPES_H__ */
+/*** END file-tail ***/
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]