[Xfce4-commits] [apps/mousepad] 10/45: Make GSettings keyfile backend a separate compile-time option

noreply at xfce.org noreply at xfce.org
Fri Jul 11 13:03:15 CEST 2014


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

mbrush pushed a commit to branch master
in repository apps/mousepad.

commit ad1c4398007177ec8b95c67b205d4b9cf208b070
Author: Matthew Brush <mbrush at codebrainz.ca>
Date:   Sun Jul 6 16:32:21 2014 -0700

    Make GSettings keyfile backend a separate compile-time option
    
    Rather than using the DBus configure option since the default backend
    may not use DBus but Windows registry, or OSX User Defaults, etc.
---
 configure.ac.in              |   10 ++++++++++
 mousepad/Makefile.am         |    8 ++++++--
 mousepad/mousepad-settings.c |   29 ++++++++++++++++-------------
 3 files changed, 32 insertions(+), 15 deletions(-)

diff --git a/configure.ac.in b/configure.ac.in
index e4c46aa..bcbd94c 100644
--- a/configure.ac.in
+++ b/configure.ac.in
@@ -92,6 +92,15 @@ dnl *** Enable support for GSettings ***
 dnl ************************************
 GLIB_GSETTINGS
 
+AC_ARG_ENABLE([keyfile-settings],
+              [AS_HELP_STRING([--enable-keyfile-settings],
+                              [Use the GSettings keyfile backend rather than the default])],
+              [enable_keyfile_settings="yes"],
+              [enable_keyfile_settings="default"])
+
+AM_CONDITIONAL([WITH_KEYFILE_SETTINGS],
+               [test "x$enable_keyfile_settings" = "xyes"])
+
 dnl **********************************
 dnl *** Optional support for D-BUS ***
 dnl **********************************
@@ -139,4 +148,5 @@ else
 echo "* D-BUS support:             no"
 fi
 echo "* Debug Support:             $enable_debug"
+echo "* Use keyfile backend:       $enable_keyfile_settings"
 echo
diff --git a/mousepad/Makefile.am b/mousepad/Makefile.am
index 8c6a235..1e61781 100644
--- a/mousepad/Makefile.am
+++ b/mousepad/Makefile.am
@@ -80,13 +80,17 @@ mousepad_dbus_sources = \
 
 mousepad_CFLAGS += \
 	-DDBUS_API_SUBJECT_TO_CHANGE \
-	$(DBUS_CFLAGS) \
-	-DMOUSEPAD_GSETTINGS_USE_DBUS=1
+	$(DBUS_CFLAGS)
 
 mousepad_LDADD +=	\
 	$(DBUS_LIBS)
 endif
 
+if WITH_KEYFILE_SETTINGS
+mousepad_CFLAGS += \
+	-DMOUSEPAD_SETTINGS_KEYFILE_BACKEND=1
+endif
+
 if MAINTAINER_MODE
 DISTCLEANFILES = \
 	$(mousepad_built_sources) \
diff --git a/mousepad/mousepad-settings.c b/mousepad/mousepad-settings.c
index d80bf9e..526a77c 100644
--- a/mousepad/mousepad-settings.c
+++ b/mousepad/mousepad-settings.c
@@ -2,10 +2,11 @@
 #include <mousepad/mousepad-settings.h>
 #include <stdlib.h>
 
+#ifdef MOUSEPAD_SETTINGS_KEYFILE_BACKEND
 /* Needed to use keyfile GSettings backend */
 # define G_SETTINGS_ENABLE_BACKEND
-#include <gio/gsettingsbackend.h>
-
+# include <gio/gsettingsbackend.h>
+#endif
 
 
 struct MousepadSettings_
@@ -120,14 +121,14 @@ mousepad_settings_get_default (void)
 
   if (g_once_init_enter (&default_initialized))
     {
-      GSettingsBackend *backend;
 
       /* If we're installed in an unusual location, we still want to load
        * the schema so enforce this with the relevant environment variable. */
       mousepad_settings_update_gsettings_schema_dir ();
 
-#ifndef MOUSEPAD_GSETTINGS_USE_DBUS
+#ifdef MOUSEPAD_SETTINGS_KEYFILE_BACKEND
 {
+      GSettingsBackend *backend;
       gchar *conf_file;
 
       /* Path inside user's config directory */
@@ -136,21 +137,23 @@ mousepad_settings_get_default (void)
                                     "settings.conf",
                                     NULL);
 
-      /* Always use the keyfile backend */
+      /* Create a keyfile backend */
       backend = g_keyfile_settings_backend_new (conf_file, "/", NULL);
       g_free (conf_file);
+
+      /* Construct the singleton instance with the keyfile backend */
+      default_settings = g_object_new (MOUSEPAD_TYPE_SETTINGS,
+                                       "backend", backend /* give ref to settings object */,
+                                       "schema-id", "org.xfce.Mousepad",
+                                       NULL);
 }
 #else
-      backend = g_settings_backend_get_default ();
+      /* Use the default GSettings backend (eg. registry, dconf, user-defaults, etc) */
+      default_settings = g_object_new (MOUSEPAD_TYPE_SETTINGS,
+                                       "schema-id", "org.xfce.Mousepad",
+                                       NULL);
 #endif
 
-      /* Construct the singleton instance */
-      default_settings = g_object_new (
-        MOUSEPAD_TYPE_SETTINGS,
-        "backend", backend /* give ref to settings object */,
-        "schema-id", "org.xfce.Mousepad",
-        NULL);
-
       /* Auto-cleanup at exit */
       atexit (mousepad_settings_cleanup_default);
 

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


More information about the Xfce4-commits mailing list