[Xfce4-commits] [xfce/libxfce4util] 01/01: Add support for GOBJECT-INTROSPECTION (Bug #12159)
noreply at xfce.org
noreply at xfce.org
Sat May 20 16:22:55 CEST 2017
This is an automated email from the git hooks/post-receive script.
o c h o s i p u s h e d a c o m m i t t o b r a n c h m a s t e r
in repository xfce/libxfce4util.
commit f8e35f0889ad9c7bf6a6ccacce1592a4f0060cef
Author: Eric Koegel <eric.koegel at gmail.com>
Date: Fri Jul 8 10:02:27 2016 +0300
Add support for GOBJECT-INTROSPECTION (Bug #12159)
GOjbect Introspection allows various other languages to automatically
generate bindings they can use. For details see:
https://wiki.gnome.org/action/show/Projects/GObjectIntrospection
To support this, we need to add a gobject and introspection
dependency. The introspection one is optional and it is what
determines if the libxfce4util-1.0 gir is created.
Additionally, the Kiosk was converted to a GObject to better
work with this method of use, but retains the exact same
functionality externally.
Signed-off-by: Simon Steinbeiss <simon.steinbeiss at elfenbeinturm.at>
---
.gitignore | 49 ++++++++++++++++++++++++
Makefile.am | 6 ++-
configure.ac.in | 11 ++++++
libxfce4util/Makefile.am | 40 +++++++++++++++++++-
libxfce4util/xfce-kiosk.c | 43 +++++++++++++++------
libxfce4util/xfce-kiosk.h | 4 +-
m4/introspection.m4 | 96 +++++++++++++++++++++++++++++++++++++++++++++++
7 files changed, 233 insertions(+), 16 deletions(-)
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..2b94efd
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,49 @@
+# Files generated by autogen.sh
+INSTALL
+aclocal.m4
+autom4te.cache/
+compile
+config.*
+configure
+configure.ac
+depcomp
+docs/version.xml
+gtk-doc.m4
+gtk-doc.make
+install-sh
+intltool-*.in
+libtool
+ltmain.sh
+m4/
+missing
+po/Makefile.in.in
+po/POTFILES
+po/stamp-it
+po/.intltool-merge-cache
+stamp-h1
+test-driver
+.deps/
+Makefile
+Makefile.in
+
+# files generated by make
+ChangeLog
+mkinstalldirs
+.libs/
+po/*.gmo
+po/libxfce4util.pot
+*.la
+*.lo
+*.stamp
+libxfce4util-*.tar.bz2
+libxfce4util/abicheck.sh.log
+libxfce4util/abicheck.sh.trs
+libxfce4util/libxfce4util-1.0.gir
+libxfce4util/libxfce4util-1.0.pc
+libxfce4util/libxfce4util-1.0.typelib
+libxfce4util/libxfce4util-alias.h
+libxfce4util/libxfce4util-aliasdef.c
+libxfce4util/libxfce4util-config.h
+libxfce4util/test-suite.log
+xfce4-kiosk-query/xfce4-kiosk-query
+xfce4-kiosk-query/xfce4_kiosk_query-main.o
diff --git a/Makefile.am b/Makefile.am
index e7be4ec..c32790d 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -1,5 +1,8 @@
# $Id$
+ACLOCAL_AMFLAGS = -I m4 ${ACLOCAL_FLAGS}
+DISTCHECK_CONFIGURE_FLAGS = --enable-introspection
+
SUBDIRS = \
libxfce4util \
docs \
@@ -25,7 +28,8 @@ EXTRA_DIST = \
gtk-doc.make \
intltool-extract.in \
intltool-merge.in \
- intltool-update.in
+ intltool-update.in \
+ m4/introspection.m4
DISTCLEANFILES = \
intltool-extract \
diff --git a/configure.ac.in b/configure.ac.in
index 552d11c..fd9fd87 100644
--- a/configure.ac.in
+++ b/configure.ac.in
@@ -49,6 +49,7 @@ dnl ***************************
LIBXFCE4UTIL_VERSION=libxfce4util_version()
AM_INIT_AUTOMAKE([1.8 dist-bzip2 tar-ustar no-dist-gzip])
AC_CONFIG_HEADERS([config.h])
+AC_CONFIG_MACRO_DIR([m4])
AM_MAINTAINER_MODE()
m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])])
@@ -112,6 +113,11 @@ dnl *** Check for i18n support ***
dnl ******************************
XDT_I18N([@LINGUAS@])
+dnl ***********************************
+dnl *** Check for GObject installed ***
+dnl ***********************************
+XDT_CHECK_PACKAGE([GOBJECT], [gobject-2.0], [2.30.0])
+
dnl ********************************
dnl *** Check for GLib installed ***
dnl ********************************
@@ -122,6 +128,11 @@ dnl *** Check for gtk-doc ***
dnl *************************
GTK_DOC_CHECK([1.0])
+dnl ***************************************
+dnl *** Check for gobject-introspection ***
+dnl ***************************************
+GOBJECT_INTROSPECTION_CHECK([1.30.0])
+
dnl ****************************************************************************
dnl *** Check for a broken putenv(3) implementation that requires strings ***
dnl *** to be malloced and not freed after a successfully call to putenv(3). ***
diff --git a/libxfce4util/Makefile.am b/libxfce4util/Makefile.am
index 9ea0f9b..7439171 100644
--- a/libxfce4util/Makefile.am
+++ b/libxfce4util/Makefile.am
@@ -63,7 +63,8 @@ libxfce4util_la_SOURCES = \
xfce-utf8.c
libxfce4util_la_CFLAGS = \
- $(GLIB_CFLAGS)
+ $(GLIB_CFLAGS) \
+ $(GOBJECT_CFLAGS)
libxfce4util_la_LDFLAGS = \
-export-dynamic \
@@ -72,7 +73,8 @@ libxfce4util_la_LDFLAGS = \
-no-undefined
libxfce4util_la_LIBADD = \
- $(GLIB_LIBS)
+ $(GLIB_LIBS) \
+ $(GOBJECT_LIBS)
pkgconfigdir = $(libdir)/pkgconfig
pkgconfig_DATA = libxfce4util-1.0.pc
@@ -103,6 +105,40 @@ libxfce4util-alias.h: make-libxfce4util-alias.pl libxfce4util.symbols
libxfce4util-aliasdef.c: make-libxfce4util-alias.pl libxfce4util.symbols
$(AM_V_GEN) $(PERL) $(srcdir)/make-libxfce4util-alias.pl -def < $(srcdir)/libxfce4util.symbols > libxfce4util-aliasdef.c
+
+include $(INTROSPECTION_MAKEFILE)
+INTROSPECTION_GIRS =
+INTROSPECTION_SCANNER_ENV = CC="$(CC)"
+INTROSPECTION_SCANNER_ARGS = \
+ --add-include-path=$(srcdir) \
+ --warn-all \
+ --identifier-prefix=xfce \
+ --identifier-prefix=Xfce \
+ --identifier-prefix=libxfce
+INTROSPECTION_COMPILER_ARGS = \
+ --includedir=$(srcdir) \
+ --includedir=.
+
+if HAVE_INTROSPECTION
+introspection_sources = $(filter-out %private.h %.c, $(libxfce4util_la_SOURCES))
+
+libxfce4util-1.0.gir: libxfce4util.la Makefile
+libxfce4util_1_0_gir_INCLUDES = GObject-2.0 GLib-2.0
+libxfce4util_1_0_gir_CFLAGS = $(AM_CPPFLAGS)
+libxfce4util_1_0_gir_LIBS = libxfce4util.la
+libxfce4util_1_0_gir_FILES = $(introspection_sources)
+libxfce4util_1_0_gir_EXPORT_PACKAGES = libxfce4util-1.0
+INTROSPECTION_GIRS += libxfce4util-1.0.gir
+
+girdir = $(datadir)/gir-1.0
+gir_DATA = $(INTROSPECTION_GIRS)
+
+typelibdir = $(libdir)/girepository-1.0
+typelib_DATA = $(INTROSPECTION_GIRS:.gir=.typelib)
+
+CLEANFILES += $(gir_DATA) $(typelib_DATA)
+endif
+
endif
# required for gtk-doc
diff --git a/libxfce4util/xfce-kiosk.c b/libxfce4util/xfce-kiosk.c
index 4fe4c3c..67d48eb 100644
--- a/libxfce4util/xfce-kiosk.c
+++ b/libxfce4util/xfce-kiosk.c
@@ -59,6 +59,8 @@
struct _XfceKiosk
{
+ GObject __parent__;
+
gchar *module_name;
XfceRc *module_rc;
};
@@ -67,8 +69,8 @@ struct _XfceKiosk
static const gchar *xfce_kiosk_lookup (const XfceKiosk *kiosk,
const gchar *capability);
static gboolean xfce_kiosk_chkgrp (const gchar *group);
-static void xfce_kiosk_init (void);
static time_t mtime (const gchar *path);
+static void xfce_kiosk_finalize (GObject *object);
static gchar *usrname = NULL;
@@ -77,10 +79,19 @@ static time_t kiosktime = 0;
static const gchar *kioskdef = NULL;
static XfceRc *kioskrc = NULL;
-
+G_DEFINE_TYPE (XfceKiosk, xfce_kiosk, G_TYPE_OBJECT)
G_LOCK_DEFINE_STATIC (kiosk_lock);
+static void
+xfce_kiosk_class_init (XfceKioskClass *klass)
+{
+ GObjectClass *gobject_class;
+
+ gobject_class = G_OBJECT_CLASS (klass);
+ gobject_class->finalize = xfce_kiosk_finalize;
+}
+
/**
* xfce_kiosk_new:
* @module:
@@ -98,11 +109,9 @@ xfce_kiosk_new (const gchar *module)
g_return_val_if_fail (module != NULL, NULL);
g_return_val_if_fail (strcmp (module, "General") != 0, NULL);
- xfce_kiosk_init ();
-
g_snprintf (path, 1024, "%s/%s.kioskrc", KIOSKDIR, module);
- kiosk = g_new (XfceKiosk, 1);
+ kiosk = g_object_new (XFCE_TYPE_KIOSK, NULL);
kiosk->module_name = g_strdup (module);
kiosk->module_rc = xfce_rc_simple_open (path, TRUE);
@@ -179,6 +188,19 @@ xfce_kiosk_query (const XfceKiosk *kiosk,
}
+static void
+xfce_kiosk_finalize (GObject *object)
+{
+ XfceKiosk *kiosk = XFCE_KIOSK (object);
+
+ g_return_if_fail (kiosk != NULL);
+
+ if (kiosk->module_rc != NULL)
+ xfce_rc_close (kiosk->module_rc);
+ g_free (kiosk->module_name);
+}
+
+
/**
* xfce_kiosk_free:
* @kiosk: A #XfceKiosk.
@@ -190,12 +212,9 @@ xfce_kiosk_query (const XfceKiosk *kiosk,
void
xfce_kiosk_free (XfceKiosk *kiosk)
{
- g_return_if_fail (kiosk != NULL);
-
- if (kiosk->module_rc != NULL)
- xfce_rc_close (kiosk->module_rc);
- g_free (kiosk->module_name);
- g_free (kiosk);
+ /* finalize takes care of things in case the consumer calls unref
+ * themselves instead of this function */
+ g_object_unref (kiosk);
}
@@ -243,7 +262,7 @@ xfce_kiosk_chkgrp (const gchar *group)
static void
-xfce_kiosk_init (void)
+xfce_kiosk_init (XfceKiosk *kiosk)
{
struct passwd *pw;
struct group *gr;
diff --git a/libxfce4util/xfce-kiosk.h b/libxfce4util/xfce-kiosk.h
index 8b56243..ba9e59f 100644
--- a/libxfce4util/xfce-kiosk.h
+++ b/libxfce4util/xfce-kiosk.h
@@ -27,10 +27,12 @@
#define __XFCE_KIOSK_H__
#include <glib.h>
+#include <glib-object.h>
G_BEGIN_DECLS
-#define XFCE_KIOSK(obj) ((XfceKiosk *)(obj))
+#define XFCE_TYPE_KIOSK xfce_kiosk_get_type ()
+G_DECLARE_FINAL_TYPE (XfceKiosk, xfce_kiosk, XFCE, KIOSK, GObject)
typedef struct _XfceKiosk XfceKiosk;
diff --git a/m4/introspection.m4 b/m4/introspection.m4
new file mode 100644
index 0000000..d89c3d9
--- /dev/null
+++ b/m4/introspection.m4
@@ -0,0 +1,96 @@
+dnl -*- mode: autoconf -*-
+dnl Copyright 2009 Johan Dahlin
+dnl
+dnl This file is free software; the author(s) gives unlimited
+dnl permission to copy and/or distribute it, with or without
+dnl modifications, as long as this notice is preserved.
+dnl
+
+# serial 1
+
+m4_define([_GOBJECT_INTROSPECTION_CHECK_INTERNAL],
+[
+ AC_BEFORE([AC_PROG_LIBTOOL],[$0])dnl setup libtool first
+ AC_BEFORE([AM_PROG_LIBTOOL],[$0])dnl setup libtool first
+ AC_BEFORE([LT_INIT],[$0])dnl setup libtool first
+
+ dnl enable/disable introspection
+ m4_if([$2], [require],
+ [dnl
+ enable_introspection=yes
+ ],[dnl
+ AC_ARG_ENABLE(introspection,
+ AS_HELP_STRING([--enable-introspection[=@<:@no/auto/yes@:>@]],
+ [Enable introspection for this build]),,
+ [enable_introspection=auto])
+ ])dnl
+
+ AC_MSG_CHECKING([for gobject-introspection])
+
+ dnl presence/version checking
+ AS_CASE([$enable_introspection],
+ [no], [dnl
+ found_introspection="no (disabled, use --enable-introspection to enable)"
+ ],dnl
+ [yes],[dnl
+ PKG_CHECK_EXISTS([gobject-introspection-1.0],,
+ AC_MSG_ERROR([gobject-introspection-1.0 is not installed]))
+ PKG_CHECK_EXISTS([gobject-introspection-1.0 >= $1],
+ found_introspection=yes,
+ AC_MSG_ERROR([You need to have gobject-introspection >= $1 installed to build AC_PACKAGE_NAME]))
+ ],dnl
+ [auto],[dnl
+ PKG_CHECK_EXISTS([gobject-introspection-1.0 >= $1], found_introspection=yes, found_introspection=no)
+ dnl Canonicalize enable_introspection
+ enable_introspection=$found_introspection
+ ],dnl
+ [dnl
+ AC_MSG_ERROR([invalid argument passed to --enable-introspection, should be one of @<:@no/auto/yes@:>@])
+ ])dnl
+
+ AC_MSG_RESULT([$found_introspection])
+
+ INTROSPECTION_SCANNER=
+ INTROSPECTION_COMPILER=
+ INTROSPECTION_GENERATE=
+ INTROSPECTION_GIRDIR=
+ INTROSPECTION_TYPELIBDIR=
+ if test "x$found_introspection" = "xyes"; then
+ INTROSPECTION_SCANNER=`$PKG_CONFIG --variable=g_ir_scanner gobject-introspection-1.0`
+ INTROSPECTION_COMPILER=`$PKG_CONFIG --variable=g_ir_compiler gobject-introspection-1.0`
+ INTROSPECTION_GENERATE=`$PKG_CONFIG --variable=g_ir_generate gobject-introspection-1.0`
+ INTROSPECTION_GIRDIR=`$PKG_CONFIG --variable=girdir gobject-introspection-1.0`
+ INTROSPECTION_TYPELIBDIR="$($PKG_CONFIG --variable=typelibdir gobject-introspection-1.0)"
+ INTROSPECTION_CFLAGS=`$PKG_CONFIG --cflags gobject-introspection-1.0`
+ INTROSPECTION_LIBS=`$PKG_CONFIG --libs gobject-introspection-1.0`
+ INTROSPECTION_MAKEFILE=`$PKG_CONFIG --variable=datadir gobject-introspection-1.0`/gobject-introspection-1.0/Makefile.introspection
+ fi
+ AC_SUBST(INTROSPECTION_SCANNER)
+ AC_SUBST(INTROSPECTION_COMPILER)
+ AC_SUBST(INTROSPECTION_GENERATE)
+ AC_SUBST(INTROSPECTION_GIRDIR)
+ AC_SUBST(INTROSPECTION_TYPELIBDIR)
+ AC_SUBST(INTROSPECTION_CFLAGS)
+ AC_SUBST(INTROSPECTION_LIBS)
+ AC_SUBST(INTROSPECTION_MAKEFILE)
+
+ AM_CONDITIONAL(HAVE_INTROSPECTION, test "x$found_introspection" = "xyes")
+])
+
+
+dnl Usage:
+dnl GOBJECT_INTROSPECTION_CHECK([minimum-g-i-version])
+
+AC_DEFUN([GOBJECT_INTROSPECTION_CHECK],
+[
+ _GOBJECT_INTROSPECTION_CHECK_INTERNAL([$1])
+])
+
+dnl Usage:
+dnl GOBJECT_INTROSPECTION_REQUIRE([minimum-g-i-version])
+
+
+AC_DEFUN([GOBJECT_INTROSPECTION_REQUIRE],
+[
+ _GOBJECT_INTROSPECTION_CHECK_INTERNAL([$1], [require])
+])
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
More information about the Xfce4-commits
mailing list