[gtk-vnc] Use glib-mkenums to automatically create GTypes from C enums.
- From: Jonh Wendell <jwendell src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [gtk-vnc] Use glib-mkenums to automatically create GTypes from C enums.
- Date: Thu, 17 Sep 2009 13:12:41 +0000 (UTC)
commit b0ad95afe6986939f726db49b3a9b337ddd2fe81
Author: Jonh Wendell <jwendell gnome org>
Date: Mon Aug 31 15:57:40 2009 -0300
Use glib-mkenums to automatically create GTypes from C enums.
configure.ac | 13 +++++++++++++
src/Makefile.am | 36 +++++++++++++++++++++++++++++++++---
src/vnc.override | 1 +
src/vncdisplay.c | 37 ++-----------------------------------
src/vncdisplay.h | 4 ----
5 files changed, 49 insertions(+), 42 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index d405db5..1fdf977 100644
--- a/configure.ac
+++ b/configure.ac
@@ -274,6 +274,19 @@ if test "x$enable_plugin" = "xyes"; then
AC_SUBST(FIREFOX_PLUGIN_LIBS)
fi
+dnl define a MAINT-like variable REBUILD which is set
+dnl if Perl, so autogenerated sources can be rebuilt
+AC_PATH_PROGS(PERL, perl5 perl)
+AC_ARG_ENABLE(rebuilds, [ --disable-rebuilds disable all source autogeneration rules],,enable_rebuilds=yes)
+REBUILD=\#
+if test "x$enable_rebuilds" = "xyes" && \
+ test -n "$PERL" && \
+ $PERL -e 'exit !($] >= 5.002)' > /dev/null 2>&1 ; then
+ REBUILD=
+fi
+AC_SUBST(REBUILD)
+
+
AM_CONDITIONAL(WITH_PYTHON, [test "$WITH_PYTHON" = "yes"])
AM_CONDITIONAL(WITH_EXAMPLES, [test "$WITH_EXAMPLES" = "yes"])
diff --git a/src/Makefile.am b/src/Makefile.am
index 3d60df5..cae7406 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -26,6 +26,7 @@ libgtk_vnc_1_0_la_SOURCES = blt.h blt1.h \
vncdisplay.h vncdisplay.c \
vncmarshal.h vncmarshal.c \
x_keymap.h x_keymap.c vnc_keycodes.h \
+ enums.h enums.c \
utils.h
if WITH_UCONTEXT
@@ -36,6 +37,35 @@ libgtk_vnc_1_0_la_SOURCES += coroutine_gthread.c
EXTRA_DIST += continuation.h continuation.c coroutine_ucontext.c
endif
+enum_headers = \
+ $(top_srcdir)/src/vncdisplay.h
+
+enums.c: @REBUILD@ $(enum_headers)
+ glib-mkenums --fhead "#include <glib-object.h>\n" \
+ --fhead "#include \"enums.h\"\n\n" \
+ --fprod "\n/* enumerations from \"@filename \" */" \
+ --fprod "\n#include \"@filename \"\n" \
+ --vhead "static const G Type@Value _ enum_name@_values[] = {" \
+ --vprod " { @VALUENAME@, \"@VALUENAME \", \"@valuenick \" }," \
+ --vtail " { 0, NULL, NULL }\n};\n\n" \
+ --vtail "GType\n enum_name@_get_type (void)\n{\n" \
+ --vtail " static GType type = 0;\n\n" \
+ --vtail " if (!type)\n" \
+ --vtail " type = g_ type@_register_static (\"@EnumName \", _ enum_name@_values);\n\n" \
+ --vtail " return type;\n}\n\n" \
+ $(enum_headers) > $@
+
+enums.h: @REBUILD@ $(enum_headers)
+ glib-mkenums --fhead "#ifndef __GTK_VNC_ENUMS_H__\n" \
+ --fhead "#define __GTK_VNC_ENUMS_H__ 1\n\n" \
+ --fhead "G_BEGIN_DECLS\n\n" \
+ --ftail "G_END_DECLS\n\n" \
+ --ftail "#endif /* __GTK_VNC_ENUMS_H__ */\n" \
+ --fprod "\n/* --- @filename@ --- */" \
+ --eprod "#define VNC_TYPE_ ENUMSHORT@ @enum_name _get_type()\n" \
+ --eprod "GType @enum_name _get_type (void);\n" \
+ $(enum_headers) > $@
+
vncmarshal.c: vncmarshal.txt
echo "#include \"vncmarshal.h\"" > $@ && \
glib-genmarshal --body $< >> $@ || (rm -f $@ && exit 1)
@@ -43,9 +73,9 @@ vncmarshal.c: vncmarshal.txt
vncmarshal.h: vncmarshal.txt
glib-genmarshal --header $< > $@ || (rm -f $@ && exit 1)
-vncdisplay.c:: vncmarshal.h
+vncdisplay.c:: vncmarshal.h enums.h
-CLEANFILES = vncmarshal.c vncmarshal.h
+CLEANFILES = vncmarshal.c vncmarshal.h enums.h enums.c
if WITH_PYTHON
pyexec_LTLIBRARIES = gtkvnc.la
@@ -59,7 +89,7 @@ gtkvnc_la_SOURCES = vncmodule.c vncmodule.defs.c
CODEGENDIR = $(shell pkg-config --variable=codegendir pygtk-2.0)
DEFSDIR = $(shell pkg-config --variable=defsdir pygtk-2.0)
-vnc.defs: vncdisplay.h
+vnc.defs: vncdisplay.h enums.h
$(PYTHON) $(CODEGENDIR)/h2def.py $< > $@
vncmodule.defs.c: vnc.override vnc.defs
diff --git a/src/vnc.override b/src/vnc.override
index dc823d6..35ca029 100644
--- a/src/vnc.override
+++ b/src/vnc.override
@@ -3,6 +3,7 @@ headers
#include <Python.h>
#include "pygobject.h"
#include "vncdisplay.h"
+#include "enums.h"
%%
modulename gtkvnc
%%
diff --git a/src/vncdisplay.c b/src/vncdisplay.c
index 1f080fe..a8f67d9 100644
--- a/src/vncdisplay.c
+++ b/src/vncdisplay.c
@@ -28,6 +28,7 @@
#include "vncmarshal.h"
#include "config.h"
#include "x_keymap.h"
+#include "enums.h"
#include <gtk/gtk.h>
#include <glib/gi18n.h>
@@ -1720,7 +1721,7 @@ static void vnc_display_class_init(VncDisplayClass *klass)
signalCredParam = g_param_spec_enum("credential",
"credential",
"credential",
- vnc_display_credential_get_type(),
+ VNC_TYPE_DISPLAY_CREDENTIAL,
0,
G_PARAM_READABLE);
@@ -2047,40 +2048,6 @@ void vnc_display_set_read_only(VncDisplay *obj, gboolean enable)
obj->priv->read_only = enable;
}
-GType vnc_display_credential_get_type(void)
-{
- static GType etype = 0;
-
- if (etype == 0) {
- static const GEnumValue values[] = {
- { VNC_DISPLAY_CREDENTIAL_PASSWORD, "VNC_DISPLAY_CREDENTIAL_PASSWORD", "password" },
- { VNC_DISPLAY_CREDENTIAL_USERNAME, "VNC_DISPLAY_CREDENTIAL_USERNAME", "username" },
- { VNC_DISPLAY_CREDENTIAL_CLIENTNAME, "VNC_DISPLAY_CREDENTIAL_CLIENTNAME", "clientname" },
- { 0, NULL, NULL }
- };
- etype = g_enum_register_static ("VncDisplayCredentialType", values );
- }
-
- return etype;
-}
-
-GType vnc_display_key_event_get_type(void)
-{
- static GType etype = 0;
-
- if (etype == 0) {
- static const GEnumValue values[] = {
- { VNC_DISPLAY_KEY_EVENT_PRESS, "VNC_DISPLAY_KEY_EVENT_PRESS", "press" },
- { VNC_DISPLAY_KEY_EVENT_RELEASE, "VNC_DISPLAY_KEY_EVENT_RELEASE", "release" },
- { VNC_DISPLAY_KEY_EVENT_CLICK, "VNC_DISPLAY_KEY_EVENT_CLICK", "click" },
- { 0, NULL, NULL }
- };
- etype = g_enum_register_static ("VncDisplayKeyEvents", values );
- }
-
- return etype;
-}
-
GdkPixbuf *vnc_display_get_pixbuf(VncDisplay *obj)
{
VncDisplayPrivate *priv = obj->priv;
diff --git a/src/vncdisplay.h b/src/vncdisplay.h
index 7c6a64e..acfd228 100644
--- a/src/vncdisplay.h
+++ b/src/vncdisplay.h
@@ -29,8 +29,6 @@ typedef struct _VncDisplayPrivate VncDisplayPrivate;
#include <glib.h>
#define VNC_TYPE_DISPLAY (vnc_display_get_type())
-#define VNC_TYPE_DISPLAY_CREDENTIAL (vnc_display_credential_get_type())
-#define VNC_TYPE_DISPLAY_KEY_EVENT (vnc_display_key_event_get_type())
#define VNC_DISPLAY(obj) \
(G_TYPE_CHECK_INSTANCE_CAST((obj), VNC_TYPE_DISPLAY, VncDisplay))
@@ -82,8 +80,6 @@ typedef enum
G_BEGIN_DECLS
GType vnc_display_get_type(void);
-GType vnc_display_credential_get_type(void);
-GType vnc_display_key_event_get_type(void);
GtkWidget * vnc_display_new(void);
gboolean vnc_display_open_fd(VncDisplay *obj, int fd);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]