[Xfce4-commits] [xfce/xfconf] 01/10: Added skeleton file to GSettings backend support.

noreply at xfce.org noreply at xfce.org
Sun Oct 21 12:05:08 CEST 2018


This is an automated email from the git hooks/post-receive script.

a   l   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/xfconf.

commit 05fe7967666170ad4ef8f7623c107857b41e5b56
Author: Ali Abdallah <ali at xfce.org>
Date:   Fri Jul 13 21:07:27 2018 +0200

    Added skeleton file to GSettings backend support.
---
 Makefile.am                                  |   4 +
 configure.ac.in                              |  36 +++++++++
 gsettings-backend/Makefile.am                |  26 ++++++
 gsettings-backend/xfconf-giomodule.c         |  64 +++++++++++++++
 gsettings-backend/xfconf-gsettings-backend.c | 116 +++++++++++++++++++++++++++
 gsettings-backend/xfconf-gsettings-backend.h |  50 ++++++++++++
 6 files changed, 296 insertions(+)

diff --git a/Makefile.am b/Makefile.am
index 62f200b..754067a 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -10,6 +10,10 @@ SUBDIRS = \
 	docs \
 	tests
 
+if XFCONF_ENABLE_GSETTINGS_BACKEND
+SUBDIRS += gsettings-backend
+endif
+
 .PHONY: ChangeLog
 
 ChangeLog: Makefile
diff --git a/configure.ac.in b/configure.ac.in
index a736b95..cc73403 100644
--- a/configure.ac.in
+++ b/configure.ac.in
@@ -181,6 +181,22 @@ if test "x$xfconf_backend_perchannel_xml" = "xyes"; then
               [Define if the perchannel-xml backend should be built])
 fi
 
+dnl check for GSettings backend support
+AC_ARG_ENABLE([gsettings_backend], AC_HELP_STRING([--disable-gsettings-backend], [Don't build GSettings backend module]),
+  [ac_gsettings_backend=$enableval], [ac_gsettings_backend=yes])
+AC_MSG_CHECKING([whether to build the GSettings backend module])
+AM_CONDITIONAL([XFCONF_ENABLE_GSETTINGS_BACKEND], [test x"$ac_gsettings_backend" = x"yes"])
+AC_MSG_RESULT([$ac_gsettings_backend])
+
+dnl GModule is required in order to build the GSettings backend module
+if test "x$ac_gsettings_backend"; then
+	XDT_CHECK_PACKAGE([GMODULE], [gmodule-2.0], [2.30.0])
+	GIO_MODULE_DIR="`$PKG_CONFIG --variable=giomoduledir gio-2.0`"
+	AC_DEFINE_UNQUOTED(GIO_MODULE_DIR, "$GIO_MODULE_DIR",
+     [The GIO modules directory.])
+    AC_SUBST(GIO_MODULE_DIR)
+fi
+
 dnl check for debugging support
 XDT_FEATURE_DEBUG([xfconf_default_debug])
 dnl gtk-doc is broken
@@ -199,6 +215,14 @@ fi
 dnl check whether the compiler supports the visibility attribute
 XDT_FEATURE_VISIBILITY
 
+if test "x$have_gnuc_visibility" = "xyes"; then
+AC_DEFINE([XFCONF_EXPORT], [__attribute__((visibility("default")))],
+  [defines how to decorate public symbols while building])
+else
+AC_DEFINE([XFCONF_EXPORT], [],
+  [defines how to decorate public symbols while building])
+fi
+
 dnl add -O1 and --as-needed to LDFLAGS if supported
 XDT_FEATURE_LINKER_OPTS
 
@@ -236,4 +260,16 @@ xfconf-perl/Xfconf.pm
 xfconf-perl/xs/Makefile
 xfconf-query/Makefile
 xfconfd/Makefile
+gsettings-backend/Makefile
 ])
+
+dnl ***************************
+dnl *** Print configuration ***
+dnl ***************************
+echo
+echo "Build Configuration:"
+echo
+echo "  * GSettings Backend:         $ac_gsettings_backend"
+echo
+echo "  * Debug:                     $enable_debug"
+echo
diff --git a/gsettings-backend/Makefile.am b/gsettings-backend/Makefile.am
new file mode 100644
index 0000000..cafee4a
--- /dev/null
+++ b/gsettings-backend/Makefile.am
@@ -0,0 +1,26 @@
+giomodule_LTLIBRARIES= libxfconfgsettingsbackend.la
+
+giomoduledir = $(GIO_MODULE_DIR)
+
+libxfconfgsettingsbackend_la_SOURCES =		\
+	xfconf-giomodule.c			\
+	xfconf-gsettings-backend.c		\
+	xfconf-gsettings-backend.h
+
+libxfconfgsettingsbackend_la_CFLAGS =		\
+	-I$(top_srcdir) 			\
+	-I$(top_builddir) 			\
+	$(GIO_CFLAGS)				\
+	$(GMODULE_CFLAGS)
+
+libxfconfgsettingsbackend_la_LDFLAGS =		\
+	-export-dynamic				\
+	-avoid-version				\
+	-module 				\
+	-export-symbols-regex "^[^_].*"
+
+libxfconfgsettingsbackend_la_LIBADD =		\
+	$(top_builddir)/xfconf/libxfconf-0.la 	\
+	$(GIO_LDFLAGS)				\
+	$(GMODULE_LDFLAGS)
+
diff --git a/gsettings-backend/xfconf-giomodule.c b/gsettings-backend/xfconf-giomodule.c
new file mode 100644
index 0000000..6ca44fd
--- /dev/null
+++ b/gsettings-backend/xfconf-giomodule.c
@@ -0,0 +1,64 @@
+/*
+ * Copyright (C) 2018 - Ali Abdallah <ali at xfce.org>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
+ *
+ */
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#ifdef HAVE_STRING_H
+#include <string.h>
+#endif
+
+#include <gio/gio.h>
+
+#include "xfconf-gsettings-backend.h"
+#include "xfconf/xfconf.h"
+
+G_MODULE_EXPORT XFCONF_EXPORT void g_io_module_load (GIOModule *module)
+{
+  GError *error = NULL;
+
+  if (!xfconf_init (&error)) {
+    g_critical ("Failed to get connection to xfconfd: %s", error->message);
+    g_error_free (error);
+    return;
+  }
+
+  g_type_module_use(G_TYPE_MODULE(module));
+
+  g_io_extension_point_implement(G_SETTINGS_BACKEND_EXTENSION_POINT_NAME,
+                                 xfconf_gsettings_backend_get_type(),
+                                 "xfconf",
+                                 -1);
+}
+
+G_MODULE_EXPORT XFCONF_EXPORT void g_io_module_unload (GIOModule *module)
+{
+  xfconf_shutdown();
+}
+
+/* Module query */
+G_MODULE_EXPORT XFCONF_EXPORT gchar** g_io_module_query (void)
+{
+  char *eps[] = {
+    G_SETTINGS_BACKEND_EXTENSION_POINT_NAME,
+    NULL
+  };
+  return g_strdupv (eps);
+}
+
diff --git a/gsettings-backend/xfconf-gsettings-backend.c b/gsettings-backend/xfconf-gsettings-backend.c
new file mode 100644
index 0000000..f6e63c1
--- /dev/null
+++ b/gsettings-backend/xfconf-gsettings-backend.c
@@ -0,0 +1,116 @@
+/*
+ * Copyright (C) 2018 - Ali Abdallah <ali at xfce.org>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <stdlib.h>
+
+#include <glib.h>
+
+#include "xfconf/xfconf.h"
+
+#include "xfconf-gsettings-backend.h"
+
+
+struct _XfconfGsettingsBackend
+{
+  GSettingsBackend __parent__;
+
+  XfconfChannel    *channel;
+};
+
+G_DEFINE_TYPE (XfconfGsettingsBackend, xfconf_gsettings_backend, G_TYPE_SETTINGS_BACKEND);
+
+static GVariant *
+xfconf_gsettings_backend_read (GSettingsBackend   *backend,
+                               const gchar        *key,
+                               const GVariantType *expected_type,
+                               gboolean            default_value)
+{
+  return NULL;
+}
+
+static void
+xfconf_gsettings_backend_reset (GSettingsBackend   *backend,
+                                const gchar        *key,
+                                gpointer            origin_tag)
+{
+}
+
+static gboolean
+xfconf_gsettings_backend_get_writable (GSettingsBackend *backend,
+                                       const gchar      *key)
+{
+  return FALSE;
+}
+
+static gboolean
+xfconf_gsettings_backend_write_tree (GSettingsBackend *backend,
+                                     GTree            *tree,
+                                     gpointer          origin_tag)
+{
+  return FALSE;
+}
+
+static gboolean
+xfconf_gsettings_backend_write (GSettingsBackend *backend,
+                                const gchar      *key,
+                                GVariant         *value,
+                                gpointer          origin_tag)
+{
+
+  return FALSE;
+}
+
+static void
+xfconf_gsettings_backend_finalize (XfconfGsettingsBackend *self)
+{
+}
+
+static void
+xfconf_gsettings_backend_init (XfconfGsettingsBackend *self)
+{
+  const gchar *prg_name;
+
+  prg_name = g_get_prgname();
+
+  self->channel = xfconf_channel_new (prg_name);
+}
+
+static void
+xfconf_gsettings_backend_class_init (XfconfGsettingsBackendClass *klass)
+{
+  GObjectClass *object_class = G_OBJECT_CLASS (klass);
+  GSettingsBackendClass *gsettings_class = G_SETTINGS_BACKEND_CLASS (klass);
+
+  gsettings_class->read = xfconf_gsettings_backend_read;
+  gsettings_class->reset = xfconf_gsettings_backend_reset;
+  gsettings_class->get_writable = xfconf_gsettings_backend_get_writable;
+  gsettings_class->write_tree = xfconf_gsettings_backend_write_tree;
+  gsettings_class->write = xfconf_gsettings_backend_write;
+
+  object_class->finalize = (void (*) (GObject *object)) xfconf_gsettings_backend_finalize;
+}
+
+XfconfGsettingsBackend* xfconf_gsettings_backend_new (void)
+{
+  XfconfGsettingsBackend *xfconf_gsettings = g_object_new (XFCONF_GSETTINGS_BACKEND_TYPE, NULL);
+  return xfconf_gsettings;
+}
diff --git a/gsettings-backend/xfconf-gsettings-backend.h b/gsettings-backend/xfconf-gsettings-backend.h
new file mode 100644
index 0000000..4d4912f
--- /dev/null
+++ b/gsettings-backend/xfconf-gsettings-backend.h
@@ -0,0 +1,50 @@
+/*
+ * Copyright (C) 2018 - Ali Abdallah <ali at xfce.org>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
+ *
+ */
+
+#ifndef __XFCONF_GSETTINGS_BACKEND_H__
+#define __XFCONF_GSETTINGS_BACKEND_H__
+
+#define G_SETTINGS_ENABLE_BACKEND
+#include <gio/gsettingsbackend.h>
+
+#define XFCONF_GSETTINGS_BACKEND_TYPE (xfconf_gsettings_backend_get_type ())
+#define XFCONF_GSETTINGS_BACKEND(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), XFCONF_GSETTINGS_BACKEND_TYPE, XfconfGsettingsBackend))
+#define XFCONF_GSETTINGS_BACKEND_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), XFCONF_GSETTINGS_BACKEND_TYPE, XfconfGsettingsBackendClass))
+#define IS_XFCONF_GSETTINGS_BACKEND(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), XFCONF_GSETTINGS_BACKEND_TYPE))
+#define IS_XFCONF_GSETTINGS_BACKEND_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), XFCONF_GSETTINGS_BACKEND_TYPE))
+#define XFCONF_GSETTINGS_BACKEND_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), XFCONF_GSETTINGS_BACKEND_TYPE, XfconfGsettingsBackendClass))
+
+G_BEGIN_DECLS
+
+typedef struct _XfconfGsettingsBackend XfconfGsettingsBackend;
+
+typedef struct
+{
+  GSettingsBackendClass parent_class;
+
+} XfconfGsettingsBackendClass;
+
+GType xfconf_gsettings_backend_get_type (void) G_GNUC_CONST;
+
+XfconfGsettingsBackend *xfconf_gsettings_backend_new (void);
+
+G_END_DECLS
+
+#endif /* __XFCONF_GSETTINGS_BACKEND_H__ */
+

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.


More information about the Xfce4-commits mailing list