r23222 - gnucash/trunk/src - Refactor preferences

Geert Janssens gjanssens at code.gnucash.org
Mon Oct 7 10:06:24 EDT 2013


Author: gjanssens
Date: 2013-10-07 10:06:23 -0400 (Mon, 07 Oct 2013)
New Revision: 23222
Trac: http://svn.gnucash.org/trac/changeset/23222

Added:
   gnucash/trunk/src/app-utils/gnc-prefs-utils.c
   gnucash/trunk/src/app-utils/gnc-prefs-utils.h
   gnucash/trunk/src/core-utils/gnc-prefs-p.h
   gnucash/trunk/src/core-utils/gnc-prefs.c
   gnucash/trunk/src/core-utils/gnc-prefs.h
Removed:
   gnucash/trunk/src/app-utils/gnc-prefs.c
   gnucash/trunk/src/app-utils/gnc-prefs.h
   gnucash/trunk/src/core-utils/gnc-core-prefs.c
   gnucash/trunk/src/core-utils/gnc-core-prefs.h
Modified:
   gnucash/trunk/src/app-utils/Makefile.am
   gnucash/trunk/src/app-utils/app-utils.i
   gnucash/trunk/src/app-utils/gnc-gconf-utils.c
   gnucash/trunk/src/app-utils/gnc-gconf-utils.h
   gnucash/trunk/src/app-utils/gnc-gsettings.c
   gnucash/trunk/src/app-utils/gnc-gsettings.h
   gnucash/trunk/src/app-utils/gncmod-app-utils.c
   gnucash/trunk/src/backend/dbi/test/test-backend-dbi-basic.c
   gnucash/trunk/src/backend/dbi/test/test-dbi-stuff.c
   gnucash/trunk/src/backend/sql/gnc-backend-sql.c
   gnucash/trunk/src/backend/xml/gnc-backend-xml.c
   gnucash/trunk/src/bin/gnucash-bin.c
   gnucash/trunk/src/business/business-gnome/gnc-plugin-business.c
   gnucash/trunk/src/core-utils/Makefile.am
   gnucash/trunk/src/core-utils/core-utils.i
   gnucash/trunk/src/core-utils/core-utils.scm
   gnucash/trunk/src/engine/gnc-commodity.c
   gnucash/trunk/src/gnc/main.cpp
   gnucash/trunk/src/gnome-utils/gnc-gnome-utils.c
   gnucash/trunk/src/gnome-utils/gnc-main-window.c
   gnucash/trunk/src/optional/python-bindings/Makefile.am
   gnucash/trunk/src/optional/python-bindings/gnucash_core.i
   gnucash/trunk/src/python/init.py
Log:
Refactor preferences

- rename core-utils/gnc-core-prefs* to core-utils/gnc-prefs*
- rename app-utils/gnc-prefs* to app-utils/gnc-prefs-utils*
- move preferences initialization fuctions to gnc-prefs-utils*
- define a gnc_prefs_* api that is independent of any
  settings backend
- refactor gnc_gsettings_* api to serve as a backend for the
  gnc_prefs_* api

Modified: gnucash/trunk/src/app-utils/Makefile.am
===================================================================
--- gnucash/trunk/src/app-utils/Makefile.am	2013-10-07 14:06:02 UTC (rev 23221)
+++ gnucash/trunk/src/app-utils/Makefile.am	2013-10-07 14:06:23 UTC (rev 23222)
@@ -56,7 +56,7 @@
   gnc-gettext-util.c \
   gnc-gsettings.c \
   gnc-helpers.c \
-  gnc-prefs.c \
+  gnc-prefs-utils.c \
   gnc-sx-instance-model.c \
   gncmod-app-utils.c \
   gnc-ui-balances.c \
@@ -84,7 +84,7 @@
   gnc-gsettings.h \
   gnc-help-utils.h \
   gnc-helpers.h \
-  gnc-prefs.h \
+  gnc-prefs-utils.h \
   gnc-sx-instance-model.h \
   gnc-ui-balances.h \
   gnc-ui-util.h \

Modified: gnucash/trunk/src/app-utils/app-utils.i
===================================================================
--- gnucash/trunk/src/app-utils/app-utils.i	2013-10-07 14:06:02 UTC (rev 23221)
+++ gnucash/trunk/src/app-utils/app-utils.i	2013-10-07 14:06:23 UTC (rev 23222)
@@ -8,7 +8,7 @@
 #include <gnc-exp-parser.h>
 #include <gnc-ui-util.h>
 #include <gnc-gettext-util.h>
-#include <gnc-prefs.h>
+#include <gnc-prefs-utils.h>
 #include <gnc-helpers.h>
 #include <gnc-accounting-period.h>
 #include <gnc-session.h>

Modified: gnucash/trunk/src/app-utils/gnc-gconf-utils.c
===================================================================
--- gnucash/trunk/src/app-utils/gnc-gconf-utils.c	2013-10-07 14:06:02 UTC (rev 23221)
+++ gnucash/trunk/src/app-utils/gnc-gconf-utils.c	2013-10-07 14:06:23 UTC (rev 23222)
@@ -26,15 +26,12 @@
 
 #include <stdio.h>
 #include <string.h>
-#include "gnc-core-prefs.h"
 #include "gnc-gconf-utils.h"
-#include "backend/xml/gnc-backend-xml.h"
+#include "gnc-prefs.h"
 
 #define CLIENT_TAG  "%s-%s-client"
 #define NOTIFY_TAG  "%s-%s-notify_id"
 
-static QofLogModule log_module = G_LOG_DOMAIN;
-
 static GConfClient *our_client = NULL;
 static guint gconf_general_cb_id = 0;
 
@@ -992,68 +989,3 @@
                                         NULL);
     return TRUE;
 }
-
-/***************************************************************
- * Initialization                                              *
- ***************************************************************/
-static void
-file_retain_changed_cb(GConfEntry *entry, gpointer user_data)
-{
-    gint days = (int)gnc_gconf_get_float(GCONF_GENERAL, KEY_RETAIN_DAYS, NULL);
-    gnc_core_prefs_set_file_retention_days (days);
-}
-
-static void
-file_retain_type_changed_cb(GConfEntry *entry, gpointer user_data)
-{
-    XMLFileRetentionType type;
-    gchar *choice = gnc_gconf_get_string(GCONF_GENERAL, KEY_RETAIN_TYPE, NULL);
-    if (!choice)
-        choice = g_strdup("days");
-
-    if (g_strcmp0 (choice, "never") == 0)
-        type = XML_RETAIN_NONE;
-    else if (g_strcmp0 (choice, "forever") == 0)
-        type = XML_RETAIN_ALL;
-    else
-    {
-        if (g_strcmp0 (choice, "days") != 0)
-            PERR("bad value '%s'", choice ? choice : "(null)");
-        type = XML_RETAIN_DAYS;
-    }
-    gnc_core_prefs_set_file_retention_policy (type);
-
-    g_free (choice);
-}
-
-static void
-file_compression_changed_cb(GConfEntry *entry, gpointer user_data)
-{
-    gboolean file_compression = gnc_gconf_get_bool(GCONF_GENERAL, KEY_FILE_COMPRESSION, NULL);
-    gnc_core_prefs_set_file_save_compressed (file_compression);
-}
-
-void gnc_gconf_prefs_init (void)
-{
-    /* Add hooks to update core preferences whenever the associated gconf key changes */
-    gnc_gconf_general_register_cb(KEY_RETAIN_DAYS, file_retain_changed_cb, NULL);
-    gnc_gconf_general_register_cb(KEY_RETAIN_TYPE, file_retain_type_changed_cb, NULL);
-    gnc_gconf_general_register_cb(KEY_FILE_COMPRESSION, file_compression_changed_cb, NULL);
-
-    /* Call the hooks once manually to initialize the core preferences */
-    file_retain_changed_cb (NULL, NULL);
-    file_retain_type_changed_cb (NULL, NULL);
-    file_compression_changed_cb (NULL, NULL);
-
-    /* Backwards compatibility code. Pre 2.3.15, 0 retain_days meant
-     * "keep forever". From 2.3.15 on this is controlled via a multiple
-     * choice ("retain_type"). So if we find a 0 retain_days value with
-     * a "days" retain_type, we should interpret it as if we got a
-     * "forever" retain_type.
-     */
-    if ( (gnc_core_prefs_get_file_retention_policy () == XML_RETAIN_DAYS) &&
-            (gnc_core_prefs_get_file_retention_days () == 0 ) )
-    {
-        gnc_gconf_set_string (GCONF_GENERAL, KEY_RETAIN_TYPE, "forever", NULL);
-    }
-}

Modified: gnucash/trunk/src/app-utils/gnc-gconf-utils.h
===================================================================
--- gnucash/trunk/src/app-utils/gnc-gconf-utils.h	2013-10-07 14:06:02 UTC (rev 23221)
+++ gnucash/trunk/src/app-utils/gnc-gconf-utils.h	2013-10-07 14:06:23 UTC (rev 23222)
@@ -83,11 +83,6 @@
  @{
 */
 
-/** This function is called early in the load process
- *  to preload a number of preferences from gconf
- */
-void gnc_gconf_prefs_init (void);
-
 /** This function takes an enum value and returns its nickname.
  *
  *  @param type The value defining the enum class.  For example,

Modified: gnucash/trunk/src/app-utils/gnc-gsettings.c
===================================================================
--- gnucash/trunk/src/app-utils/gnc-gsettings.c	2013-10-07 14:06:02 UTC (rev 23221)
+++ gnucash/trunk/src/app-utils/gnc-gsettings.c	2013-10-07 14:06:23 UTC (rev 23222)
@@ -28,6 +28,7 @@
 #include <string.h>
 #include "gnc-gsettings.h"
 #include "libqof/qof/qof.h"
+#include "gnc-prefs-p.h"
 
 #define CLIENT_TAG  "%s-%s-client"
 #define NOTIFY_TAG  "%s-%s-notify_id"
@@ -134,7 +135,7 @@
 gulong
 gnc_gsettings_register_cb (const gchar *schema,
                            const gchar *key,
-                           GCallback func,
+                           gpointer func,
                            gpointer user_data)
 {
     gulong retval = 0;
@@ -142,6 +143,7 @@
 
     GSettings *schema_ptr = gnc_gsettings_get_schema_ptr (schema);
     g_return_val_if_fail (G_IS_SETTINGS (schema_ptr), retval);
+    g_return_val_if_fail (func, retval);
 
     if ((!key) || (*key == '\0'))
         signal = g_strdup ("changed");
@@ -151,7 +153,7 @@
             signal = g_strconcat ("changed::", key, NULL);
     }
 
-    retval = g_signal_connect (schema_ptr, signal, func, user_data);
+    retval = g_signal_connect (schema_ptr, signal, G_CALLBACK (func), user_data);
 
     g_free (signal);
 
@@ -162,7 +164,7 @@
 void
 gnc_gsettings_remove_cb_by_func (const gchar *schema,
                                  const gchar *key,
-                                 GCallback func,
+                                 gpointer func,
                                  gpointer user_data)
 {
     gint matched = 0;
@@ -170,6 +172,7 @@
 
     GSettings *schema_ptr = gnc_gsettings_get_schema_ptr (schema);
     g_return_if_fail (G_IS_SETTINGS (schema_ptr));
+    g_return_if_fail (func);
 
     if ((!key) || (*key == '\0'))
         signal = g_strdup ("changed");
@@ -185,7 +188,7 @@
             0, /* signal_id */
             g_quark_from_string (signal),   /* signal_detail */
             NULL, /* closure */
-            func, /* callback function */
+            G_CALLBACK (func), /* callback function */
             user_data);
     DEBUG ("Removed %d handlers for signal '%s' from schema '%s'", matched, signal, schema);
 
@@ -206,7 +209,7 @@
 
 guint
 gnc_gsettings_register_any_cb (const gchar *schema,
-                               GCallback func,
+                               gpointer func,
                                gpointer user_data)
 {
     return gnc_gsettings_register_cb (schema, NULL, func, user_data);
@@ -215,7 +218,7 @@
 
 void
 gnc_gsettings_remove_any_cb_by_func (const gchar *schema,
-                                     GCallback func,
+                                     gpointer func,
                                      gpointer user_data)
 {
     gnc_gsettings_remove_cb_by_func (schema, NULL, func, user_data);
@@ -496,3 +499,27 @@
 
     g_strfreev (keys);
 }
+
+void gnc_gsettings_load_backend (void)
+{
+    prefsbackend.register_cb = gnc_gsettings_register_cb;
+    prefsbackend.remove_cb_by_func = gnc_gsettings_remove_cb_by_func;
+    prefsbackend.remove_cb_by_id = gnc_gsettings_remove_cb_by_id;
+    prefsbackend.register_group_cb = gnc_gsettings_register_any_cb;
+    prefsbackend.remove_group_cb_by_func = gnc_gsettings_remove_any_cb_by_func;
+    prefsbackend.bind = gnc_gsettings_bind;
+    prefsbackend.get_bool = gnc_gsettings_get_bool;
+    prefsbackend.get_int = gnc_gsettings_get_int;
+    prefsbackend.get_float = gnc_gsettings_get_float;
+    prefsbackend.get_string = gnc_gsettings_get_string;
+    prefsbackend.get_enum = gnc_gsettings_get_enum;
+    prefsbackend.get_value = gnc_gsettings_get_value;
+    prefsbackend.set_bool = gnc_gsettings_set_bool;
+    prefsbackend.set_int = gnc_gsettings_set_int;
+    prefsbackend.set_float = gnc_gsettings_set_float;
+    prefsbackend.set_string = gnc_gsettings_set_string;
+    prefsbackend.set_enum = gnc_gsettings_set_enum;
+    prefsbackend.set_value = gnc_gsettings_set_value;
+    prefsbackend.reset = gnc_gsettings_reset;
+    prefsbackend.reset_group = gnc_gsettings_reset_schema;
+}

Modified: gnucash/trunk/src/app-utils/gnc-gsettings.h
===================================================================
--- gnucash/trunk/src/app-utils/gnc-gsettings.h	2013-10-07 14:06:02 UTC (rev 23221)
+++ gnucash/trunk/src/app-utils/gnc-gsettings.h	2013-10-07 14:06:23 UTC (rev 23222)
@@ -35,6 +35,11 @@
     -# convert gnucash internal schema names into full gsettings schema id's, and
     -# optionally take care of error checking on return values.
 
+    Note that this api should not be called directly. Instead use
+    the gnc_gsettings_load_backend function to configure gsettings
+    as backend for the gnucash preferences api and then use
+    the gnc_prefs_* functions instead to work with preferences.
+
     @{ */
 /** @file gnc-gsettings.h
  *  @brief GSettings helper routines.
@@ -47,36 +52,8 @@
 
 #include <gio/gio.h>
 
-/* Schema ids used across multiple modules */
 #define GSET_SCHEMA_PREFIX            "org.gnucash"
-#define GSET_SCHEMA_GENERAL           "general"
-#define GSET_SCHEMA_GENERAL_REGISTER  "general.register"
-#define GSET_SCHEMA_GENERAL_REPORT    "general.report"
-#define GSET_SCHEMA_WARNINGS          "general.warnings"
-#define GSET_SCHEMA_WARNINGS_TEMP     "general.warnings.temporary"
-#define GSET_SCHEMA_WARNINGS_PERM     "general.warnings.permanent"
 
-/* Keys used across multiple modules */
-/* Currently the first one conflicts with same definition in gnc-gconf-utils.h
- * Only load it if gnc-gconf-utils.h isn't loaded yet.
- */
-#ifndef GNC_GCONF_UTILS_H
-#define DESKTOP_GNOME_INTERFACE "/desktop/gnome/interface"
-#endif /* GNC_GCONF_UTILS_H */
-#define GSET_KEY_TOOLBAR_STYLE       "toolbar_style"
-#define GSET_KEY_SAVE_GEOMETRY       "save_window_geometry"
-#define GSET_KEY_LAST_PATH           "last_path"
-#define GSET_KEY_USE_NEW             "use_new_window"
-#define GSET_KEY_ACCOUNTING_LABELS   "use_accounting_labels"
-#define GSET_KEY_ACCOUNT_SEPARATOR   "account_separator"
-#define GSET_KEY_NEGATIVE_IN_RED     "negative_in_red"
-#define GSET_KEY_NUM_SOURCE          "num_source"
-#define GSET_KEY_ENABLE_EURO         "enable_euro"
-#define GSET_KEY_DATE_FORMAT         "date_format"
-#define GSET_KEY_DATE_COMPLETION     "date_completion"
-#define GSET_KEY_DATE_BACKMONTHS     "date_backmonths"
-#define GSET_KEY_SHOW_LEAF_ACCT_NAMES "show_leaf_account_names"
-
 /** Convert a partial schema name into a complete gsettings schema name.
  *
  *  This function takes a partial gsettings schema name and converts
@@ -135,7 +112,7 @@
  */
 gulong gnc_gsettings_register_cb (const char *schema,
                                   const gchar *key,
-                                  GCallback func,
+                                  gpointer func,
                                   gpointer user_data);
 
 
@@ -158,7 +135,7 @@
  */
 void gnc_gsettings_remove_cb_by_func (const gchar *schema,
                                       const gchar *key,
-                                      GCallback func,
+                                      gpointer func,
                                       gpointer user_data);
 
 
@@ -192,7 +169,7 @@
  *  function.
  */
 guint gnc_gsettings_register_any_cb (const gchar *schema,
-                                     GCallback func,
+                                     gpointer func,
                                      gpointer user_data);
 
 
@@ -217,7 +194,7 @@
  *  by its handler id.
  */
 void gnc_gsettings_remove_any_cb_by_func (const gchar *schema,
-                                          GCallback func,
+                                          gpointer func,
                                           gpointer user_data);
 
 
@@ -614,6 +591,10 @@
 /** @} */
 
 
+/** Configure gsettings as the backend for the gnucash preferences api.
+ */
+void gnc_gsettings_load_backend (void);
+
 #endif /* GNC_GSETTINGS_H */
 /** @} */
 /** @} */

Added: gnucash/trunk/src/app-utils/gnc-prefs-utils.c
===================================================================
--- gnucash/trunk/src/app-utils/gnc-prefs-utils.c	                        (rev 0)
+++ gnucash/trunk/src/app-utils/gnc-prefs-utils.c	2013-10-07 14:06:23 UTC (rev 23222)
@@ -0,0 +1,100 @@
+/********************************************************************\
+ * gnc-prefs-utils.c -- utility functions for preferences management*
+ * Copyright (C) 2013 Geert Janssens <geert at kobaltwit.be>           *
+ *                                                                  *
+ * 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, contact:                        *
+ *                                                                  *
+ * Free Software Foundation           Voice:  +1-617-542-5942       *
+ * 51 Franklin Street, Fifth Floor    Fax:    +1-617-542-2652       *
+ * Boston, MA  02110-1301,  USA       gnu at gnu.org                   *
+ *                                                                  *
+\********************************************************************/
+
+#include "config.h"
+
+#include "gnc-gconf-utils.h"
+#include "gnc-gsettings.h"
+#include "gnc-prefs-utils.h"
+#include "gnc-prefs.h"
+#include "backend/xml/gnc-backend-xml.h"
+
+static QofLogModule log_module = G_LOG_DOMAIN;
+
+/***************************************************************
+ * Initialization                                              *
+ ***************************************************************/
+static void
+file_retain_changed_cb(GConfEntry *entry, gpointer user_data)
+{
+    gint days = (int)gnc_gconf_get_float(GCONF_GENERAL, KEY_RETAIN_DAYS, NULL);
+    gnc_prefs_set_file_retention_days (days);
+}
+
+static void
+file_retain_type_changed_cb(GConfEntry *entry, gpointer user_data)
+{
+    XMLFileRetentionType type;
+    gchar *choice = gnc_gconf_get_string(GCONF_GENERAL, KEY_RETAIN_TYPE, NULL);
+    if (!choice)
+        choice = g_strdup("days");
+
+    if (g_strcmp0 (choice, "never") == 0)
+        type = XML_RETAIN_NONE;
+    else if (g_strcmp0 (choice, "forever") == 0)
+        type = XML_RETAIN_ALL;
+    else
+    {
+        if (g_strcmp0 (choice, "days") != 0)
+            PERR("bad value '%s'", choice ? choice : "(null)");
+        type = XML_RETAIN_DAYS;
+    }
+    gnc_prefs_set_file_retention_policy (type);
+
+    g_free (choice);
+}
+
+static void
+file_compression_changed_cb(GConfEntry *entry, gpointer user_data)
+{
+    gboolean file_compression = gnc_gconf_get_bool(GCONF_GENERAL, KEY_FILE_COMPRESSION, NULL);
+    gnc_prefs_set_file_save_compressed (file_compression);
+}
+
+
+void gnc_prefs_init (void)
+{
+    gnc_gsettings_load_backend();
+
+    /* Add hooks to update core preferences whenever the associated gconf key changes */
+    gnc_gconf_general_register_cb(KEY_RETAIN_DAYS, file_retain_changed_cb, NULL);
+    gnc_gconf_general_register_cb(KEY_RETAIN_TYPE, file_retain_type_changed_cb, NULL);
+    gnc_gconf_general_register_cb(KEY_FILE_COMPRESSION, file_compression_changed_cb, NULL);
+
+    /* Call the hooks once manually to initialize the core preferences */
+    file_retain_changed_cb (NULL, NULL);
+    file_retain_type_changed_cb (NULL, NULL);
+    file_compression_changed_cb (NULL, NULL);
+
+    /* Backwards compatibility code. Pre 2.3.15, 0 retain_days meant
+     * "keep forever". From 2.3.15 on this is controlled via a multiple
+     * choice ("retain_type"). So if we find a 0 retain_days value with
+     * a "days" retain_type, we should interpret it as if we got a
+     * "forever" retain_type.
+     */
+    if ( (gnc_prefs_get_file_retention_policy () == XML_RETAIN_DAYS) &&
+            (gnc_prefs_get_file_retention_days () == 0 ) )
+    {
+        gnc_gconf_set_string (GCONF_GENERAL, KEY_RETAIN_TYPE, "forever", NULL);
+    }
+}

Copied: gnucash/trunk/src/app-utils/gnc-prefs-utils.h (from rev 23221, gnucash/trunk/src/app-utils/gnc-prefs.h)
===================================================================
--- gnucash/trunk/src/app-utils/gnc-prefs-utils.h	                        (rev 0)
+++ gnucash/trunk/src/app-utils/gnc-prefs-utils.h	2013-10-07 14:06:23 UTC (rev 23222)
@@ -0,0 +1,53 @@
+/********************************************************************\
+ * gnc-prefs-utils.h -- utility functions for preferences management*
+ *                                                                  *
+ * Copyright (C) 2013 Geert Janssens <geert at kobaltwit.be>           *
+ *                                                                  *
+ * 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, contact:                        *
+ *                                                                  *
+ * Free Software Foundation           Voice:  +1-617-542-5942       *
+ * 51 Franklin Street, Fifth Floor    Fax:    +1-617-542-2652       *
+ * Boston, MA  02110-1301,  USA       gnu at gnu.org                   *
+ *                                                                  *
+\********************************************************************/
+
+/** @addtogroup GLib
+    @{ */
+/** @addtogroup Preferences Generic Preference Utilities
+
+    The only function in this file is meant to initialize the
+    preferences system early in the load process.
+
+    This is done in a way to hide the actual preferences backend from the
+    rest of the engine.
+
+    @{ */
+/** @file gnc-prefs-utils.h
+ *  @brief Preferences initialization function.
+ *  @author Copyright (C) 2013 Geert Janssens <geert at kobaltwit.be>
+ */
+
+#ifndef GNC_PREFS_UTILS_H_
+#define GNC_PREFS_UTILS_H_
+
+
+/** This function is called early in the load process
+ *  to preload a number of preferences from the settings backend
+ */
+void gnc_prefs_init (void);
+
+#endif /* GNC_PREFS_UTILS_H_ */
+/** @} */
+/** @} */
+

Deleted: gnucash/trunk/src/app-utils/gnc-prefs.c
===================================================================
--- gnucash/trunk/src/app-utils/gnc-prefs.c	2013-10-07 14:06:02 UTC (rev 23221)
+++ gnucash/trunk/src/app-utils/gnc-prefs.c	2013-10-07 14:06:23 UTC (rev 23222)
@@ -1,30 +0,0 @@
-/********************************************************************\
- * gnc-prefs.h -- utility functions for preferences management      *
- * Copyright (C) 2013 Geert Janssens <geert at kobaltwit.be>           *
- *                                                                  *
- * 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, contact:                        *
- *                                                                  *
- * Free Software Foundation           Voice:  +1-617-542-5942       *
- * 51 Franklin Street, Fifth Floor    Fax:    +1-617-542-2652       *
- * Boston, MA  02110-1301,  USA       gnu at gnu.org                   *
- *                                                                  *
-\********************************************************************/
-
-#include "gnc-gconf-utils.h"
-#include "gnc-prefs.h"
-
-void gnc_prefs_init (void)
-{
-    gnc_gconf_prefs_init ();
-}

Deleted: gnucash/trunk/src/app-utils/gnc-prefs.h
===================================================================
--- gnucash/trunk/src/app-utils/gnc-prefs.h	2013-10-07 14:06:02 UTC (rev 23221)
+++ gnucash/trunk/src/app-utils/gnc-prefs.h	2013-10-07 14:06:23 UTC (rev 23222)
@@ -1,29 +0,0 @@
-/********************************************************************\
- * gnc-prefs.h -- utility functions for preferences management      *
- * Copyright (C) 2013 Geert Janssens <geert at kobaltwit.be>           *
- *                                                                  *
- * 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, contact:                        *
- *                                                                  *
- * Free Software Foundation           Voice:  +1-617-542-5942       *
- * 51 Franklin Street, Fifth Floor    Fax:    +1-617-542-2652       *
- * Boston, MA  02110-1301,  USA       gnu at gnu.org                   *
- *                                                                  *
-\********************************************************************/
-
-#ifndef GNC_PREFS_H_
-#define GNC_PREFS_H_
-
-void gnc_prefs_init (void);
-
-#endif /* GNC_PREFS_H_ */

Modified: gnucash/trunk/src/app-utils/gncmod-app-utils.c
===================================================================
--- gnucash/trunk/src/app-utils/gncmod-app-utils.c	2013-10-07 14:06:02 UTC (rev 23221)
+++ gnucash/trunk/src/app-utils/gncmod-app-utils.c	2013-10-07 14:06:23 UTC (rev 23222)
@@ -14,7 +14,6 @@
 
 #include "gnc-component-manager.h"
 #include "gnc-hooks.h"
-#include "gnc-prefs.h"
 #include "gnc-exp-parser.h"
 
 GNC_MODULE_API_DECL(libgncmod_app_utils)
@@ -76,7 +75,6 @@
     if (refcount == 0)
     {
         gnc_component_manager_init ();
-        gnc_prefs_init ();
         gnc_hook_add_dangler(HOOK_STARTUP, (GFunc)gnc_exp_parser_init, NULL);
         gnc_hook_add_dangler(HOOK_SHUTDOWN, (GFunc)app_utils_shutdown, NULL);
     }

Modified: gnucash/trunk/src/backend/dbi/test/test-backend-dbi-basic.c
===================================================================
--- gnucash/trunk/src/backend/dbi/test/test-backend-dbi-basic.c	2013-10-07 14:06:02 UTC (rev 23221)
+++ gnucash/trunk/src/backend/dbi/test/test-backend-dbi-basic.c	2013-10-07 14:06:23 UTC (rev 23222)
@@ -29,7 +29,7 @@
 /* For test_conn_index_functions */
 #include "../gnc-backend-dbi-priv.h"
 /* For version_control */
-#include <gnc-core-prefs.h>
+#include <gnc-prefs.h>
 #include <qofsession-p.h>
 
 static const gchar* suitename = "/backend/dbi";
@@ -463,7 +463,7 @@
     QofBook *book;
     QofBackend *qbe;
     QofBackendError err;
-    gint ourversion = gnc_core_prefs_get_long_version();
+    gint ourversion = gnc_prefs_get_long_version();
 
     // Load the session data
     if (fixture->filename)

Modified: gnucash/trunk/src/backend/dbi/test/test-dbi-stuff.c
===================================================================
--- gnucash/trunk/src/backend/dbi/test/test-dbi-stuff.c	2013-10-07 14:06:02 UTC (rev 23221)
+++ gnucash/trunk/src/backend/dbi/test/test-dbi-stuff.c	2013-10-07 14:06:23 UTC (rev 23222)
@@ -25,7 +25,6 @@
 
 #include "config.h"
 #include "qof.h"
-#include "gnc-core-prefs.h"
 #include "qofsession-p.h"
 #include "cashobjects.h"
 #include "test-dbi-stuff.h"

Modified: gnucash/trunk/src/backend/sql/gnc-backend-sql.c
===================================================================
--- gnucash/trunk/src/backend/sql/gnc-backend-sql.c	2013-10-07 14:06:02 UTC (rev 23221)
+++ gnucash/trunk/src/backend/sql/gnc-backend-sql.c	2013-10-07 14:06:23 UTC (rev 23222)
@@ -72,7 +72,7 @@
 #include "gnc-tax-table-sql.h"
 #include "gnc-vendor-sql.h"
 
-#include "gnc-core-prefs.h"
+#include "gnc-prefs.h"
 
 #if defined( S_SPLINT_S )
 #include "splint-defs.h"
@@ -439,7 +439,7 @@
     ENTER( "book=%p, be->book=%p", book, be->book );
     update_progress( be );
     (void)reset_version_info( be );
-    gnc_sql_set_table_version( be, "Gnucash", gnc_core_prefs_get_long_version() );
+    gnc_sql_set_table_version( be, "Gnucash", gnc_prefs_get_long_version() );
     gnc_sql_set_table_version( be, "Gnucash-Resave", GNUCASH_RESAVE_VERSION );
 
     /* Create new tables */

Modified: gnucash/trunk/src/backend/xml/gnc-backend-xml.c
===================================================================
--- gnucash/trunk/src/backend/xml/gnc-backend-xml.c	2013-10-07 14:06:02 UTC (rev 23221)
+++ gnucash/trunk/src/backend/xml/gnc-backend-xml.c	2013-10-07 14:06:23 UTC (rev 23222)
@@ -75,7 +75,7 @@
 #include "io-gncxml.h"
 #include "io-gncxml-v2.h"
 #include "gnc-backend-xml.h"
-#include "gnc-core-prefs.h"
+#include "gnc-prefs.h"
 
 #include "gnc-address-xml-v2.h"
 #include "gnc-bill-term-xml-v2.h"
@@ -720,7 +720,7 @@
         }
     }
 
-    if (gnc_book_write_to_xml_file_v2(book, tmp_name, gnc_core_prefs_get_file_save_compressed()))
+    if (gnc_book_write_to_xml_file_v2(book, tmp_name, gnc_prefs_get_file_save_compressed()))
     {
         /* Record the file's permissions before g_unlinking it */
         rc = g_stat(datafile, &statbuf);
@@ -945,13 +945,13 @@
         /* The file is a backup or log file. Check the user's retention preference
          * to determine if we should keep it or not
          */
-        if (gnc_core_prefs_get_file_retention_policy() == XML_RETAIN_NONE)
+        if (gnc_prefs_get_file_retention_policy() == XML_RETAIN_NONE)
         {
             PINFO ("remove stale file: %s  - reason: preference XML_RETAIN_NONE", name);
             g_unlink(name);
         }
-        else if ((gnc_core_prefs_get_file_retention_policy() == XML_RETAIN_DAYS) &&
-                 (gnc_core_prefs_get_file_retention_days() > 0))
+        else if ((gnc_prefs_get_file_retention_policy() == XML_RETAIN_DAYS) &&
+                 (gnc_prefs_get_file_retention_days() > 0))
         {
             int days;
 
@@ -963,8 +963,8 @@
             }
             days = (int)(difftime(now, statbuf.st_mtime) / 86400);
 
-            PINFO ("file retention = %d days", gnc_core_prefs_get_file_retention_days());
-            if (days >= gnc_core_prefs_get_file_retention_days())
+            PINFO ("file retention = %d days", gnc_prefs_get_file_retention_days());
+            if (days >= gnc_prefs_get_file_retention_days())
             {
                 PINFO ("remove stale file: %s  - reason: more than %d days old", name, days);
                 g_unlink(name);

Modified: gnucash/trunk/src/bin/gnucash-bin.c
===================================================================
--- gnucash/trunk/src/bin/gnucash-bin.c	2013-10-07 14:06:02 UTC (rev 23221)
+++ gnucash/trunk/src/bin/gnucash-bin.c	2013-10-07 14:06:23 UTC (rev 23222)
@@ -42,7 +42,7 @@
 #include "top-level.h"
 #include "gfec.h"
 #include "gnc-commodity.h"
-#include "gnc-core-prefs.h"
+#include "gnc-prefs.h"
 #include "gnc-gsettings.h"
 #include "gnc-main-window.h"
 #include "gnc-splash.h"
@@ -571,8 +571,8 @@
         exit(0);
     }
 
-    gnc_core_prefs_set_debugging(debugging);
-    gnc_core_prefs_set_extra(extra);
+    gnc_prefs_set_debugging(debugging);
+    gnc_prefs_set_extra(extra);
 
     if (!gconf_path)
     {
@@ -595,7 +595,7 @@
     gnc_gsettings_set_prefix(g_strdup(gsettings_prefix));
 
     if (namespace_regexp)
-        gnc_core_prefs_set_namespace_regexp(namespace_regexp);
+        gnc_prefs_set_namespace_regexp(namespace_regexp);
 
     if (args_remaining)
         file_to_load = args_remaining[0];
@@ -810,7 +810,7 @@
 
     gnc_log_default();
 
-    if (gnc_core_prefs_is_debugging_enabled())
+    if (gnc_prefs_is_debugging_enabled())
     {
         qof_log_set_level("", QOF_LOG_INFO);
         qof_log_set_level("qof", QOF_LOG_INFO);

Modified: gnucash/trunk/src/business/business-gnome/gnc-plugin-business.c
===================================================================
--- gnucash/trunk/src/business/business-gnome/gnc-plugin-business.c	2013-10-07 14:06:02 UTC (rev 23221)
+++ gnucash/trunk/src/business/business-gnome/gnc-plugin-business.c	2013-10-07 14:06:23 UTC (rev 23222)
@@ -48,7 +48,7 @@
 #include "gnc-session.h"
 #include "gnome-utils/gnc-icons.h" /* for GNC_STOCK_INVOICE_NEW */
 
-#include "gnc-core-prefs.h" /* for GCONF_PATH */
+#include "gnc-prefs.h" /* for GCONF_PATH */
 #include "gnc-gconf-utils.h"
 #include "gnome-utils/gnc-main-window.h"
 

Modified: gnucash/trunk/src/core-utils/Makefile.am
===================================================================
--- gnucash/trunk/src/core-utils/Makefile.am	2013-10-07 14:06:02 UTC (rev 23221)
+++ gnucash/trunk/src/core-utils/Makefile.am	2013-10-07 14:06:23 UTC (rev 23222)
@@ -4,7 +4,7 @@
 
 libgnc_core_utils_la_SOURCES = \
   binreloc.c \
-  gnc-core-prefs.c \
+  gnc-prefs.c \
   gnc-features.c \
   gnc-filepath-utils.c \
   gnc-gdate-utils.c \
@@ -27,7 +27,8 @@
 
 noinst_HEADERS = \
   binreloc.h \
-  gnc-core-prefs.h \
+  gnc-prefs.h \
+  gnc-prefs-p.h \
   gnc-features.h \
   gnc-filepath-utils.h \
   gnc-gdate-utils.h \

Modified: gnucash/trunk/src/core-utils/core-utils.i
===================================================================
--- gnucash/trunk/src/core-utils/core-utils.i	2013-10-07 14:06:02 UTC (rev 23221)
+++ gnucash/trunk/src/core-utils/core-utils.i	2013-10-07 14:06:23 UTC (rev 23222)
@@ -1,7 +1,7 @@
 %module sw_core_utils
 %{
 #include <gnc-glib-utils.h>
-#include <gnc-core-prefs.h>
+#include <gnc-prefs.h>
 #include <gnc-path.h>
 #include <gnc-filepath-utils.h>
 #include <gnc-locale-utils.h>
@@ -25,7 +25,7 @@
 #endif
 %import "base-typemaps.i"
 
-%include <gnc-core-prefs.h>
+%include <gnc-prefs.h>
 
 %newobject gnc_path_get_bindir;
 gchar * gnc_path_get_bindir(void);

Modified: gnucash/trunk/src/core-utils/core-utils.scm
===================================================================
--- gnucash/trunk/src/core-utils/core-utils.scm	2013-10-07 14:06:02 UTC (rev 23221)
+++ gnucash/trunk/src/core-utils/core-utils.scm	2013-10-07 14:06:23 UTC (rev 23222)
@@ -18,7 +18,7 @@
 
 (use-modules (sw_core_utils))
 
-(re-export gnc-core-prefs-is-debugging-enabled)
+(re-export gnc-prefs-is-debugging-enabled)
 (re-export gnc-path-get-bindir)
 (re-export gnc-path-get-stdreportsdir)
 (re-export gnc-path-find-localized-html-file)

Deleted: gnucash/trunk/src/core-utils/gnc-core-prefs.c
===================================================================
--- gnucash/trunk/src/core-utils/gnc-core-prefs.c	2013-10-07 14:06:02 UTC (rev 23221)
+++ gnucash/trunk/src/core-utils/gnc-core-prefs.c	2013-10-07 14:06:23 UTC (rev 23222)
@@ -1,136 +0,0 @@
-/*
- * gnc-core-prefs.c:
- *
- * Copyright (C) 2006 Chris Shoemaker <c.shoemaker at cox.net>
- *
- * 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, contact:
- *
- * Free Software Foundation           Voice:  +1-617-542-5942
- * 51 Franklin Street, Fifth Floor    Fax:    +1-617-542-2652
- * Boston, MA  02110-1301,  USA       gnu at gnu.org
- */
-
-#include <stdlib.h>
-#include "config.h"
-#include "gnc-core-prefs.h"
-#include "gnc-version.h"
-#include "libqof/qof/qof.h"
-
-static gchar *namespace_regexp    = NULL;
-static gboolean is_debugging      = FALSE;
-static gboolean extras_enabled    = FALSE;
-static gboolean use_compression   = TRUE; // This is also the default in GConf
-static gint file_retention_policy = 1;    // 1 = "days", the default in GConf
-static gint file_retention_days   = 30;   // This is also the default in GConf
-static const gchar *gconf_path    = "/apps/gnucash";  // A sensible default
-
-/* This static indicates the debugging module that this .o belongs to.  */
-static QofLogModule log_module = G_LOG_DOMAIN;
-
-const gchar *
-gnc_core_prefs_get_namespace_regexp(void)
-{
-    return namespace_regexp;
-}
-
-void
-gnc_core_prefs_set_namespace_regexp(const gchar *str)
-{
-    if (namespace_regexp)
-        g_free(namespace_regexp);
-
-    if (str)
-        namespace_regexp = g_strdup(str);
-}
-
-gboolean
-gnc_core_prefs_is_debugging_enabled(void)
-{
-    return is_debugging;
-}
-
-void
-gnc_core_prefs_set_debugging(gboolean d)
-{
-    is_debugging = d;
-}
-
-gboolean
-gnc_core_prefs_is_extra_enabled(void)
-{
-    return extras_enabled;
-}
-
-void
-gnc_core_prefs_set_extra(gboolean enabled)
-{
-    extras_enabled = enabled;
-}
-
-gboolean
-gnc_core_prefs_get_file_save_compressed(void)
-{
-    return use_compression;
-}
-
-void
-gnc_core_prefs_set_file_save_compressed(gboolean compressed)
-{
-    use_compression = compressed;
-}
-
-gint
-gnc_core_prefs_get_file_retention_policy(void)
-{
-    return file_retention_policy;
-}
-
-void
-gnc_core_prefs_set_file_retention_policy(gint policy)
-{
-    file_retention_policy = policy;
-}
-
-gint
-gnc_core_prefs_get_file_retention_days(void)
-{
-    return file_retention_days;
-}
-
-void
-gnc_core_prefs_set_file_retention_days(gint days)
-{
-    file_retention_days = days;
-}
-
-const gchar *
-gnc_gconf_get_path_prefix (void)
-{
-    return gconf_path;
-}
-
-void
-gnc_gconf_set_path_prefix (const gchar *path)
-{
-    gconf_path = path;
-}
-
-guint
-gnc_core_prefs_get_long_version()
-{
-    return GNUCASH_MAJOR_VERSION * 1000000 +
-           GNUCASH_MINOR_VERSION * 10000 +
-           GNUCASH_MICRO_VERSION * 100 +
-           GNUCASH_NANO_VERSION;
-}

Deleted: gnucash/trunk/src/core-utils/gnc-core-prefs.h
===================================================================
--- gnucash/trunk/src/core-utils/gnc-core-prefs.h	2013-10-07 14:06:02 UTC (rev 23221)
+++ gnucash/trunk/src/core-utils/gnc-core-prefs.h	2013-10-07 14:06:23 UTC (rev 23222)
@@ -1,54 +0,0 @@
-/*
- * gnc-core-prefs.h:
- *
- * Copyright (C) 2006 Chris Shoemaker <c.shoemaker at cox.net>
- *
- * 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, contact:
- *
- * Free Software Foundation           Voice:  +1-617-542-5942
- * 51 Franklin Street, Fifth Floor    Fax:    +1-617-542-2652
- * Boston, MA  02110-1301,  USA       gnu at gnu.org
- */
-
-#ifndef GNC_MAIN_H
-#define GNC_MAIN_H
-
-#include <glib.h>
-
-#define GCONF_PATH "/apps/gnucash"
-
-const gchar *gnc_core_prefs_get_namespace_regexp(void);
-void gnc_core_prefs_set_namespace_regexp(const gchar *str);
-
-gboolean gnc_core_prefs_is_debugging_enabled(void);
-void gnc_core_prefs_set_debugging(gboolean d);
-
-gboolean gnc_core_prefs_is_extra_enabled(void);
-void gnc_core_prefs_set_extra(gboolean enabled);
-
-gboolean gnc_core_prefs_get_file_save_compressed(void);
-void gnc_core_prefs_set_file_save_compressed(gboolean compressed);
-
-gint gnc_core_prefs_get_file_retention_policy(void);
-void gnc_core_prefs_set_file_retention_policy(gint policy);
-
-gint gnc_core_prefs_get_file_retention_days(void);
-void gnc_core_prefs_set_file_retention_days(gint days);
-
-const gchar *gnc_gconf_get_path_prefix(void);
-void gnc_gconf_set_path_prefix(const gchar *prefix);
-
-guint gnc_core_prefs_get_long_version( void );
-
-#endif /* GNC_MAIN_H */

Added: gnucash/trunk/src/core-utils/gnc-prefs-p.h
===================================================================
--- gnucash/trunk/src/core-utils/gnc-prefs-p.h	                        (rev 0)
+++ gnucash/trunk/src/core-utils/gnc-prefs-p.h	2013-10-07 14:06:23 UTC (rev 23222)
@@ -0,0 +1,111 @@
+/********************************************************************\
+ * gnc-prefs.h Api to load and store preferences to a configurable  *
+ *             backend                                              *
+ *                                                                  *
+ * Copyright (C) 2013 Geert Janssens <geert at kobaltwit.be>           *
+ *                                                                  *
+ * 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, contact:                        *
+ *                                                                  *
+ * Free Software Foundation           Voice:  +1-617-542-5942       *
+ * 51 Franklin Street, Fifth Floor    Fax:    +1-617-542-2652       *
+ * Boston, MA  02110-1301,  USA       gnu at gnu.org                   *
+ *                                                                  *
+ ********************************************************************/
+
+#ifndef GNC_PREFS_P_H_
+#define GNC_PREFS_P_H_
+
+#include "gnc-prefs.h"
+
+
+typedef struct
+{
+        gulong (*register_cb) (const char *group,
+                               const gchar *pref_name,
+                               gpointer func,
+                               gpointer user_data);
+
+        void (*remove_cb_by_func) (const gchar *group,
+                                   const gchar *pref_name,
+                                   gpointer func,
+                                   gpointer user_data);
+
+        void (*remove_cb_by_id) (const gchar *group,
+                                 guint id);
+
+        guint (*register_group_cb) (const gchar *group,
+                                    gpointer func,
+                                    gpointer user_data);
+
+        void (*remove_group_cb_by_func) (const gchar *group,
+                                         gpointer func,
+                                         gpointer user_data);
+
+        void (*bind) (const gchar *group,
+                          /*@ null @*/ const gchar *pref_name,
+                          gpointer object,
+                          const gchar *property);
+
+        gboolean (*get_bool) (const gchar *group,
+                              /*@ null @*/ const gchar *pref_name);
+
+        gint (*get_int) (const gchar *group,
+                         const gchar *pref_name);
+
+        gdouble (*get_float) (const gchar *group,
+                              const gchar *pref_name);
+
+        gchar *(*get_string) (const gchar *group,
+                              const gchar *pref_name);
+
+        gint (*get_enum) (const gchar *group,
+                          const gchar *pref_name);
+
+        GVariant *(*get_value) (const gchar *group,
+                                const gchar *pref_name);
+
+        gboolean (*set_bool) (const gchar *group,
+                              const gchar *pref_name,
+                              gboolean value);
+
+        gboolean (*set_int) (const gchar *group,
+                             const gchar *pref_name,
+                             gint value);
+
+        gboolean (*set_float) (const gchar *group,
+                               const gchar *pref_name,
+                               gdouble value);
+
+        gboolean (*set_string) (const gchar *group,
+                                const gchar *pref_name,
+                                const gchar *value);
+
+        gboolean (*set_enum) (const gchar *group,
+                              const gchar *pref_name,
+                              gint value);
+
+        gboolean (*set_value) (const gchar *group,
+                               const gchar *pref_name,
+                               GVariant *value);
+
+        void (*reset) (const gchar *group,
+                       const gchar *pref_name);
+
+        void (*reset_group) (const gchar *group);
+
+} PrefsBackend;
+
+PrefsBackend prefsbackend;
+
+#endif /* GNC_PREFS_P_H_ */

Added: gnucash/trunk/src/core-utils/gnc-prefs.c
===================================================================
--- gnucash/trunk/src/core-utils/gnc-prefs.c	                        (rev 0)
+++ gnucash/trunk/src/core-utils/gnc-prefs.c	2013-10-07 14:06:23 UTC (rev 23222)
@@ -0,0 +1,337 @@
+/*
+ * gnc-prefs.c:
+ *
+ * Copyright (C) 2006 Chris Shoemaker <c.shoemaker at cox.net>
+ *
+ * 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, contact:
+ *
+ * Free Software Foundation           Voice:  +1-617-542-5942
+ * 51 Franklin Street, Fifth Floor    Fax:    +1-617-542-2652
+ * Boston, MA  02110-1301,  USA       gnu at gnu.org
+ */
+
+#include <stdlib.h>
+#include "config.h"
+#include "gnc-prefs.h"
+#include "gnc-prefs-p.h"
+#include "gnc-version.h"
+#include "libqof/qof/qof.h"
+
+static gchar *namespace_regexp    = NULL;
+static gboolean is_debugging      = FALSE;
+static gboolean extras_enabled    = FALSE;
+static gboolean use_compression   = TRUE; // This is also the default in the prefs backend
+static gint file_retention_policy = 1;    // 1 = "days", the default in the prefs backend
+static gint file_retention_days   = 30;   // This is also the default in the prefs backend
+static const gchar *gconf_path    = "/apps/gnucash";  // A sensible default
+
+/* This static indicates the debugging module that this .o belongs to.  */
+static QofLogModule log_module = G_LOG_DOMAIN;
+
+const gchar *
+gnc_prefs_get_namespace_regexp(void)
+{
+    return namespace_regexp;
+}
+
+void
+gnc_prefs_set_namespace_regexp(const gchar *str)
+{
+    if (namespace_regexp)
+        g_free(namespace_regexp);
+
+    if (str)
+        namespace_regexp = g_strdup(str);
+}
+
+gboolean
+gnc_prefs_is_debugging_enabled(void)
+{
+    return is_debugging;
+}
+
+void
+gnc_prefs_set_debugging(gboolean d)
+{
+    is_debugging = d;
+}
+
+gboolean
+gnc_prefs_is_extra_enabled(void)
+{
+    return extras_enabled;
+}
+
+void
+gnc_prefs_set_extra(gboolean enabled)
+{
+    extras_enabled = enabled;
+}
+
+gboolean
+gnc_prefs_get_file_save_compressed(void)
+{
+    return use_compression;
+}
+
+void
+gnc_prefs_set_file_save_compressed(gboolean compressed)
+{
+    use_compression = compressed;
+}
+
+gint
+gnc_prefs_get_file_retention_policy(void)
+{
+    return file_retention_policy;
+}
+
+void
+gnc_prefs_set_file_retention_policy(gint policy)
+{
+    file_retention_policy = policy;
+}
+
+gint
+gnc_prefs_get_file_retention_days(void)
+{
+    return file_retention_days;
+}
+
+void
+gnc_prefs_set_file_retention_days(gint days)
+{
+    file_retention_days = days;
+}
+
+const gchar *
+gnc_gconf_get_path_prefix (void)
+{
+    return gconf_path;
+}
+
+void
+gnc_gconf_set_path_prefix (const gchar *path)
+{
+    gconf_path = path;
+}
+
+guint
+gnc_prefs_get_long_version()
+{
+    return GNUCASH_MAJOR_VERSION * 1000000 +
+           GNUCASH_MINOR_VERSION * 10000 +
+           GNUCASH_MICRO_VERSION * 100 +
+           GNUCASH_NANO_VERSION;
+}
+
+gulong gnc_prefs_register_cb (const char *group,
+                              const gchar *pref_name,
+                              gpointer func,
+                              gpointer user_data)
+{
+    if (prefsbackend.register_cb)
+        return (prefsbackend.register_cb) (group, pref_name, func, user_data);
+    else
+        return 0;
+}
+
+
+void gnc_prefs_remove_cb_by_func (const gchar *group,
+                                  const gchar *pref_name,
+                                  gpointer func,
+                                  gpointer user_data)
+{
+    if (prefsbackend.remove_cb_by_func)
+        (prefsbackend.remove_cb_by_func) (group, pref_name, func, user_data);
+}
+
+
+void gnc_prefs_remove_cb_by_id (const gchar *group,
+                                guint id)
+{
+    if (prefsbackend.remove_cb_by_id)
+        (prefsbackend.remove_cb_by_id) (group, id);
+}
+
+
+guint gnc_prefs_register_group_cb (const gchar *group,
+                                   gpointer func,
+                                   gpointer user_data)
+{
+    if (prefsbackend.register_group_cb)
+        return (prefsbackend.register_group_cb) (group, func, user_data);
+    else
+        return 0;
+}
+
+
+void gnc_prefs_remove_group_cb_by_func (const gchar *group,
+                                        gpointer func,
+                                        gpointer user_data)
+{
+    if (prefsbackend.remove_group_cb_by_func)
+        (prefsbackend.remove_group_cb_by_func) (group, func, user_data);
+}
+
+
+void gnc_prefs_bind (const gchar *group,
+                         /*@ null @*/ const gchar *pref_name,
+                         gpointer object,
+                         const gchar *property)
+{
+    if (prefsbackend.bind)
+        (prefsbackend.bind) (group, pref_name, object, property);
+}
+
+
+gboolean gnc_prefs_get_bool (const gchar *group,
+                             /*@ null @*/ const gchar *pref_name)
+{
+    if (prefsbackend.get_bool)
+        return (prefsbackend.get_bool) (group, pref_name);
+    else
+        return FALSE;
+}
+
+
+gint gnc_prefs_get_int (const gchar *group,
+                        const gchar *pref_name)
+{
+    if (prefsbackend.get_int)
+        return (prefsbackend.get_int) (group, pref_name);
+    else
+        return 0;
+}
+
+
+gdouble gnc_prefs_get_float (const gchar *group,
+                             const gchar *pref_name)
+{
+    if (prefsbackend.get_float)
+        return (prefsbackend.get_float) (group, pref_name);
+    else
+        return 0.0;
+}
+
+
+gchar *gnc_prefs_get_string (const gchar *group,
+                             const gchar *pref_name)
+{
+    if (prefsbackend.get_string)
+        return (prefsbackend.get_string) (group, pref_name);
+    else
+        return NULL;
+}
+
+
+gint gnc_prefs_get_enum (const gchar *group,
+                         const gchar *pref_name)
+{
+    if (prefsbackend.get_enum)
+        return (prefsbackend.get_enum) (group, pref_name);
+    else
+        return 0;
+}
+
+
+GVariant *gnc_prefs_get_value (const gchar *group,
+                               const gchar *pref_name)
+{
+    if (prefsbackend.get_value)
+        return (prefsbackend.get_value) (group,pref_name);
+    else
+        return NULL;
+}
+
+
+gboolean gnc_prefs_set_bool (const gchar *group,
+                             const gchar *pref_name,
+                             gboolean value)
+{
+    if (prefsbackend.set_bool)
+        return (prefsbackend.set_bool) (group, pref_name, value);
+    else
+        return FALSE;
+}
+
+
+gboolean gnc_prefs_set_int (const gchar *group,
+                            const gchar *pref_name,
+                            gint value)
+{
+    if (prefsbackend.set_int)
+        return (prefsbackend.set_int) (group, pref_name, value);
+    else
+        return FALSE;
+}
+
+
+gboolean gnc_prefs_set_float (const gchar *group,
+                              const gchar *pref_name,
+                              gdouble value)
+{
+    if (prefsbackend.set_float)
+        return (prefsbackend.set_float) (group, pref_name, value);
+    else
+        return FALSE;
+}
+
+
+gboolean gnc_prefs_set_string (const gchar *group,
+                               const gchar *pref_name,
+                               const gchar *value)
+{
+    if (prefsbackend.set_string)
+        return (prefsbackend.set_string) (group, pref_name, value);
+    else
+        return FALSE;
+}
+
+
+gboolean gnc_prefs_set_enum (const gchar *group,
+                             const gchar *pref_name,
+                             gint value)
+{
+    if (prefsbackend.set_enum)
+        return (prefsbackend.set_enum) (group, pref_name, value);
+    else
+        return FALSE;
+}
+
+
+gboolean gnc_prefs_set_value (const gchar *group,
+                              const gchar *pref_name,
+                              GVariant *value)
+{
+    if (prefsbackend.set_value)
+        return (prefsbackend.set_value) (group, pref_name, value);
+    else
+        return FALSE;
+}
+
+
+void gnc_prefs_reset (const gchar *group,
+                      const gchar *pref_name)
+{
+    if (prefsbackend.reset)
+        (prefsbackend.reset) (group, pref_name);
+}
+
+void gnc_prefs_reset_group (const gchar *group)
+{
+    if (prefsbackend.reset_group)
+        (prefsbackend.reset_group) (group);
+}
+

Added: gnucash/trunk/src/core-utils/gnc-prefs.h
===================================================================
--- gnucash/trunk/src/core-utils/gnc-prefs.h	                        (rev 0)
+++ gnucash/trunk/src/core-utils/gnc-prefs.h	2013-10-07 14:06:23 UTC (rev 23222)
@@ -0,0 +1,469 @@
+/********************************************************************\
+ * gnc-prefs.h -- Api to load and store preferences to a            *
+ *                configurable backend                              *
+ *                                                                  *
+ * Copyright (C) 2013 Geert Janssens <geert at kobaltwit.be>           *
+ *                                                                  *
+ * 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, contact:                        *
+ *                                                                  *
+ * Free Software Foundation           Voice:  +1-617-542-5942       *
+ * 51 Franklin Street, Fifth Floor    Fax:    +1-617-542-2652       *
+ * Boston, MA  02110-1301,  USA       gnu at gnu.org                   *
+ *                                                                  *
+ ********************************************************************/
+
+/** @addtogroup Engine
+    @{ */
+/** @addtogroup Preferences Preferences
+
+    The API in this file is used to read and store preferences used
+    by gnucash. This api is a generic one. To actually store and
+    load preferences, a preferences backend should be configured.
+    Currently only one backend is defined: the preferences backend.
+
+    Note that preferences are organized in groups. Most functions
+    will require both a group and a preference name to find the
+    exact preference to work with.
+
+    @{ */
+/** @file gnc-prefs.h
+ *  @brief Generic api to store and retrieve preferences.
+ *  @author Copyright (C) 2013 Geert Janssens <geert at kobaltwit.be>
+ */
+
+#ifndef GNC_PREFS_H
+#define GNC_PREFS_H
+
+#include <glib.h>
+
+#define GCONF_PATH "/apps/gnucash"
+
+/* Preference groups used across multiple modules */
+#define GNC_PREFS_GROUP_GENERAL           "general"
+#define GNC_PREFS_GROUP_GENERAL_REGISTER  "general.register"
+#define GNC_PREFS_GROUP_GENERAL_REPORT    "general.report"
+#define GNC_PREFS_GROUP_WARNINGS          "general.warnings"
+#define GNC_PREFS_GROUP_WARNINGS_TEMP     "general.warnings.temporary"
+#define GNC_PREFS_GROUP_WARNINGS_PERM     "general.warnings.permanent"
+
+/* Preference names used across multiple modules */
+/* Currently the first one conflicts with same definition in gnc-gconf-utils.h
+ * Only load it if gnc-gconf-utils.h isn't loaded yet.
+ */
+#ifndef GNC_GCONF_UTILS_H
+#define DESKTOP_GNOME_INTERFACE "/desktop/gnome/interface"
+#endif /* GNC_GCONF_UTILS_H */
+#define GNC_PREF_TOOLBAR_STYLE       "toolbar_style"
+#define GNC_PREF_SAVE_GEOMETRY       "save_window_geometry"
+#define GNC_PREF_LAST_PATH           "last_path"
+#define GNC_PREF_USE_NEW             "use_new_window"
+#define GNC_PREF_ACCOUNTING_LABELS   "use_accounting_labels"
+#define GNC_PREF_ACCOUNT_SEPARATOR   "account_separator"
+#define GNC_PREF_NEGATIVE_IN_RED     "negative_in_red"
+#define GNC_PREF_NUM_SOURCE          "num_source"
+#define GNC_PREF_DATE_FORMAT         "date_format"
+#define GNC_PREF_DATE_COMPLETION     "date_completion"
+#define GNC_PREF_DATE_BACKMONTHS     "date_backmonths"
+#define GNC_PREF_SHOW_LEAF_ACCT_NAMES "show_leaf_account_names"
+
+/** @name Early bird functions, needed before any backend has been set up
+ @{
+*/
+
+const gchar *gnc_prefs_get_namespace_regexp(void);
+void gnc_prefs_set_namespace_regexp(const gchar *str);
+
+gboolean gnc_prefs_is_debugging_enabled(void);
+void gnc_prefs_set_debugging(gboolean d);
+
+gboolean gnc_prefs_is_extra_enabled(void);
+void gnc_prefs_set_extra(gboolean enabled);
+
+gboolean gnc_prefs_get_file_save_compressed(void);
+void gnc_prefs_set_file_save_compressed(gboolean compressed);
+
+gint gnc_prefs_get_file_retention_policy(void);
+void gnc_prefs_set_file_retention_policy(gint policy);
+
+gint gnc_prefs_get_file_retention_days(void);
+void gnc_prefs_set_file_retention_days(gint days);
+
+const gchar *gnc_gconf_get_path_prefix(void);
+void gnc_gconf_set_path_prefix(const gchar *prefix);
+
+guint gnc_prefs_get_long_version( void );
+
+/** @} */
+
+/** @name Listening for changes
+ @{
+*/
+
+
+/** Register a callback that gets triggered when the given preference changes.
+ *  Any time the preference's value changes, the routine
+ *  will be invoked and will be passed both the changed preference
+ *  and the user data passed to this function.
+ *
+ *  @param group This string contains the group name of the preference
+ *  to watch.
+ *
+ *  @param preference This string contains the name of the preference to watch.
+ *
+ *  @param func This is a pointer to the function to call when the preference
+ *  changes.
+ *
+ *  @param user_data This pointer will be passed to the callback
+ *  function.
+ *
+ *  @return This function returns the handler id for the registered
+ *  callback.
+ */
+gulong gnc_prefs_register_cb (const char *group,
+                              const gchar *pref_name,
+                              gpointer func,
+                              gpointer user_data);
+
+
+/** Remove a function that was registered for a callback when the
+ *  given preference changed.  Both the func and user_data
+ *  arguments are used to match up the callback to remove.
+ *  If no matching func and user_data are found to be registered
+ *  for the given preference, nothing will happen.
+ *
+ *  @param group This string contains the group name of the preference
+ *  that is being watched.
+ *
+ *  @param preference This string contains the name of the preference being watched.
+ *
+ *  @param func This is a pointer to the function that was registered
+ *  earlier.
+ *
+ *  @param user_data This pointer was passed to the callback
+ *  function when it was registered.
+ */
+void gnc_prefs_remove_cb_by_func (const gchar *group,
+                                  const gchar *pref_name,
+                                  gpointer func,
+                                  gpointer user_data);
+
+
+/** Remove a function that was registered for a callback when a
+ *  specific preference in the settings group changed.  The handler id
+ *  that was generated when the callback was registered is
+ *  use to find the callback to remove.
+ *  If no handler id is found nothing will happen.
+ *
+ *  @param group This string contains the group name of the preference
+ *  that is being watched.
+ *
+ *  @param id The handler id of the callback to be removed.
+ */
+void gnc_prefs_remove_cb_by_id (const gchar *group,
+                                guint id);
+
+
+/** Register a callback for when any preference in the settings group
+ *  is changed.  Any time the value of a preference in this group changes,
+ *  the routine will be invoked and will be passed the specified
+ *  user data.
+ *
+ *  @param group This string contains the name of the group
+ *  that is being watched.
+ *
+ *  @param func This is a pointer to the function to call when a preference
+ *  changes.
+ *
+ *  @param user_data This pointer will be passed to the callback
+ *  function.
+ */
+guint gnc_prefs_register_group_cb (const gchar *group,
+                                   gpointer func,
+                                   gpointer user_data);
+
+
+/** Remove a function that was registered for a callback when any preference
+ *  in the given settings group changed.  Both the func and user_data
+ *  arguments are used to match up the callback to remove.
+ *  If no matching func and user_data are found to be registered
+ *  for the given preference, nothing will happen.
+ *
+ *  @param group This string contains the name of the group
+ *  that is being watched.
+ *
+ *  @param func This is a pointer to the function that was registered
+ *  earlier.
+ *
+ *  @param user_data This pointer was passed to the callback
+ *  function when it was registered.
+ *
+ *  @note there is no gnc_settings_remove_any_cb_by_id. Use
+ *  gnc_settings_remove_cb_by_id instead if you want to
+ *  remove a callback set with gnc_settings_register_any_cb
+ *  by its handler id.
+ */
+void gnc_prefs_remove_group_cb_by_func (const gchar *group,
+                                        gpointer func,
+                                        gpointer user_data);
+
+
+/** Bind a setting to a g_object property. When this succeeds a change
+ *  of the setting will automatically update the bound object property
+ *  and vice versa.
+ *
+ *  @param group This string contains the group name of the preference to bind to.
+ *
+ *  @param preference This string is the name of the particular preference to
+ *  bind to.
+ *
+ *  @param object The object to be bound.
+ *
+ *  @param property The property of the object to bind to.
+ */
+void gnc_prefs_bind (const gchar *group,
+                         /*@ null @*/ const gchar *pref_name,
+                         gpointer object,
+                         const gchar *property);
+
+/** @} */
+
+/** @name Preference Getters
+ @{
+*/
+
+/** Get a boolean value from the preferences backend.
+ *
+ *  @param group This string specifies the group to which the preference belongs
+ *
+ *  @param preference This string is the name of the particular preference within
+ *  the named group of the preferences backend.
+ *
+ *  @return This function returns the TRUE or FALSE value stored at
+ *  the requested preference in the preferences backend.  If the preference has never
+ *  been set, this function passes on the default value returned by
+ *  the preferences backend.
+ */
+gboolean gnc_prefs_get_bool (const gchar *group,
+                             /*@ null @*/ const gchar *pref_name);
+
+/** Get an integer value from the preferences backend.
+ *
+ *  @param group This string specifies the group to which the preference belongs
+ *
+ *  @param preference This string is the name of the particular preference within
+ *  the named group of the preferences backend.
+ *
+ *  @return This function returns the integer value stored at the
+ *  requested preference in the preferences backend.  If the preference has never been
+ *  set, this function passes on the default value returned by the preferences backend.
+ *  If there is an error in processing, zero will be returned.
+ */
+gint gnc_prefs_get_int (const gchar *group,
+                        const gchar *pref_name);
+
+/** Get an float value from the preferences backend.
+ *
+ *  @param group This string specifies the group to which the preference belongs
+ *
+ *  @param preference This string is the name of the particular preference within
+ *  the named group of the preferences backend.
+ *
+ *  @return This function returns the float value stored at the
+ *  requested preference in the preferences backend.  If the preference has never been
+ *  set, this function passes on the default value returned by the preferences backend.
+ *  If there is an error in processing, zero will be returned.
+ */
+gdouble gnc_prefs_get_float (const gchar *group,
+                             const gchar *pref_name);
+
+/** Get a string value from the preferences backend.
+ *
+ *  @param group This string specifies the group to which the preference belongs
+ *
+ *  @param preference This string is the name of the particular preference within
+ *  the named group of the preferences backend.
+ *
+ *  @return This function returns the string value stored at the
+ *  requested preference in the preferences backend.  If the preference has never been
+ *  set, this function passes on the default value returned by the preferences backend
+ *  If there is an error in processing, NULL will be returned.
+ */
+gchar *gnc_prefs_get_string (const gchar *group,
+                             const gchar *pref_name);
+
+/** Get an enum value from the preferences backend.
+ *
+ *  @param group This string specifies the group to which the preference belongs
+ *
+ *  @param preference This string is the name of the particular preference within
+ *  the named group of the preferences backend.
+ *
+ *  @return This function returns the enum value stored at the
+ *  requested preference in the preferences backend.  If the preference has never been
+ *  set, this function passes on the default value returned by the preferences backend.
+ *  If there is an error in processing, zero will be returned.
+ */
+gint gnc_prefs_get_enum (const gchar *group,
+                         const gchar *pref_name);
+
+/** Get an arbitrary combination of values from the preferences backend.  This
+ *  combination of values can be anything that can be encapsulated
+ *  in a GVariant structure.
+ *
+ *  @param group This string specifies the group to which the preference belongs
+ *
+ *  @param preference This string is the name of the particular preference within
+ *  the named group of the preferences backend.
+ *
+ *  @return This function returns the a GVariant encapsulating the combination
+ *  of values stored at the requested preference in the preferences backend.
+ *  If the preference has never been set, this function passes on the default
+ *  value returned by the preferences backend.
+ *  If there is an error in processing, NULL will be returned.
+ *  It is the callers responsibility to free any GVariant data returned
+ *  by this function.
+ */
+GVariant *gnc_prefs_get_value (const gchar *group,
+                               const gchar *pref_name);
+
+/** @} */
+
+/** @name Preference Setters and Unset Functions
+ @{
+*/
+
+
+/** Store a boolean value into the preferences backend.
+ *
+ *  @param group This string specifies the group to which the preference belongs
+ *
+ *  @param preference This string is the name of the particular preference within
+ *  the named group of the preferences backend.
+ *
+ *  @param value The boolean value to be stored.
+ *
+ *  @return This function returns true if the value was set successfully
+ *  on the preference or false if not.
+ */
+gboolean gnc_prefs_set_bool (const gchar *group,
+                             const gchar *pref_name,
+                             gboolean value);
+
+/** Store an integer value into the preferences backend.
+ *
+ *  @param group This string specifies the group to which the preference belongs
+ *
+ *  @param preference This string is the name of the particular preference within
+ *  the named group of the preferences backend.
+ *
+ *  @param value The integer number to be stored.
+ *
+ *  @return This function returns true if the value was set successfully
+ *  on the preference or false if not.
+ */
+gboolean gnc_prefs_set_int (const gchar *group,
+                            const gchar *pref_name,
+                            gint value);
+
+/** Store a float value into the preferences backend.
+ *
+ *  @param group This string specifies the group to which the preference belongs
+ *
+ *  @param preference This string is the name of the particular preference within
+ *  the named group of the preferences backend.
+ *
+ *  @param value The floating point number to be stored.
+ *
+ *  @return This function returns true if the value was set successfully
+ *  on the preference or false if not.
+ */
+gboolean gnc_prefs_set_float (const gchar *group,
+                              const gchar *pref_name,
+                              gdouble value);
+
+
+/** Store a string into the preferences backend.
+ *
+ *  @param group This string specifies the group to which the preference belongs
+ *
+ *  @param preference This string is the name of the particular preference within
+ *  the named group of the preferences backend.
+ *
+ *  @param value The string to be stored.  the preferences backend will make a copy of this
+ *  string, so it is the callers responsibility to free the space used
+ *  by this string (if necessary).
+ *
+ *  @return This function returns true if the value was set successfully
+ *  on the preference or false if not.
+ */
+gboolean gnc_prefs_set_string (const gchar *group,
+                               const gchar *pref_name,
+                               const gchar *value);
+
+/** Store an enum value into the preferences backend.
+ *
+ *  @param group This string specifies the group to which the preference belongs
+ *
+ *  @param preference This string is the name of the particular preference within
+ *  the named group of the preferences backend.
+ *
+ *  @param value The enum number to be stored.
+ *
+ *  @return This function returns true if the value was set successfully
+ *  on the preference or false if not.
+ */
+gboolean gnc_prefs_set_enum (const gchar *group,
+                             const gchar *pref_name,
+                             gint value);
+
+/** Store an arbitrary combination of values into the preferences backend.
+ *
+ *  @param group This string specifies the group to which the preference belongs
+ *
+ *  @param preference This string is the name of the particular preference within
+ *  the named group of the preferences backend.
+ *
+ *  @param value The combination of values encapsulated in a GVariant
+ *  to be stored.
+ *
+ *  @return This function returns true if the value was set successfully
+ *  on the preference or false if not.
+ */
+gboolean gnc_prefs_set_value (const gchar *group,
+                              const gchar *pref_name,
+                              GVariant *value);
+
+/** Reset a preference to its default value in the preferences backend.
+ *
+ *  @param group This string specifies the group to which the preference belongs
+ *
+ *  @param preference This string is the name of the particular preference within
+ *  the named group of the preferences backend.
+ */
+void gnc_prefs_reset (const gchar *group,
+                      const gchar *pref_name);
+
+/** Reset all preferences in a group to their default values in the preferences backend.
+ *
+ *  @param group This string specifies the group to which the preference belongs
+ */
+void gnc_prefs_reset_group (const gchar *group);
+
+/** @} */
+
+
+#endif /* GNC_PREFS_H */
+
+/** @} */
+/** @} */

Modified: gnucash/trunk/src/engine/gnc-commodity.c
===================================================================
--- gnucash/trunk/src/engine/gnc-commodity.c	2013-10-07 14:06:02 UTC (rev 23221)
+++ gnucash/trunk/src/engine/gnc-commodity.c	2013-10-07 14:06:23 UTC (rev 23222)
@@ -35,7 +35,7 @@
 #include <regex.h>
 
 #include "gnc-commodity.h"
-#include "gnc-core-prefs.h"
+#include "gnc-prefs.h"
 
 static QofLogModule log_module = GNC_MOD_COMMODITY;
 
@@ -2028,7 +2028,7 @@
     GList * nslist, * tmp;
     GList * l = NULL;
     regex_t pattern;
-    const char *expression = gnc_core_prefs_get_namespace_regexp();
+    const char *expression = gnc_prefs_get_namespace_regexp();
 
     ENTER("table=%p, expression=%s", table, expression);
     if (!table)

Modified: gnucash/trunk/src/gnc/main.cpp
===================================================================
--- gnucash/trunk/src/gnc/main.cpp	2013-10-07 14:06:02 UTC (rev 23221)
+++ gnucash/trunk/src/gnc/main.cpp	2013-10-07 14:06:23 UTC (rev 23222)
@@ -39,7 +39,7 @@
 #include "core-utils/gnc-filepath-utils.h"
 #include "engine/gnc-hooks.h"
 #include "engine/gnc-commodity.h"
-#include "core-utils/gnc-core-prefs.h"
+#include "core-utils/gnc-prefs.h"
 #include "engine/gnc-session.h"
 #include "engine/engine-helpers.h"
 #include "engine/gnc-engine.h"
@@ -103,7 +103,7 @@
 
     gnc_log_default();
 
-    if (gnc_core_prefs_is_debugging_enabled())
+    if (gnc_prefs_is_debugging_enabled())
     {
         qof_log_set_level("", QOF_LOG_INFO);
         qof_log_set_level("qof", QOF_LOG_INFO);

Modified: gnucash/trunk/src/gnome-utils/gnc-gnome-utils.c
===================================================================
--- gnucash/trunk/src/gnome-utils/gnc-gnome-utils.c	2013-10-07 14:06:02 UTC (rev 23221)
+++ gnucash/trunk/src/gnome-utils/gnc-gnome-utils.c	2013-10-07 14:06:23 UTC (rev 23222)
@@ -32,6 +32,7 @@
 
 #include "assistant-gconf-setup.h"
 #include "gnc-gconf-utils.h"
+#include "gnc-prefs-utils.h"
 #include "gnc-gnome-utils.h"
 //#include "gnc-html.h"
 #include "gnc-engine.h"
@@ -633,6 +634,7 @@
 
     g_set_application_name(PACKAGE_NAME);
 
+    gnc_prefs_init();
     gnc_show_splash_screen();
     assistant_gconf_install_check_schemas();
 

Modified: gnucash/trunk/src/gnome-utils/gnc-main-window.c
===================================================================
--- gnucash/trunk/src/gnome-utils/gnc-main-window.c	2013-10-07 14:06:02 UTC (rev 23221)
+++ gnucash/trunk/src/gnome-utils/gnc-main-window.c	2013-10-07 14:06:23 UTC (rev 23222)
@@ -62,7 +62,7 @@
 #include "gnc-uri-utils.h"
 #include "core-utils/gnc-version.h"
 #include "gnc-window.h"
-#include "gnc-core-prefs.h"
+#include "gnc-prefs.h"
 #include "gnc-gconf-utils.h"
 #include "option-util.h"
 // +JSLED
@@ -3593,7 +3593,7 @@
 
     /* Testing */
     /* Now update the "eXtensions" menu */
-    if (!gnc_core_prefs_is_extra_enabled())
+    if (!gnc_prefs_is_extra_enabled())
     {
         GtkAction*  action;
 

Modified: gnucash/trunk/src/optional/python-bindings/Makefile.am
===================================================================
--- gnucash/trunk/src/optional/python-bindings/Makefile.am	2013-10-07 14:06:02 UTC (rev 23221)
+++ gnucash/trunk/src/optional/python-bindings/Makefile.am	2013-10-07 14:06:23 UTC (rev 23222)
@@ -68,7 +68,7 @@
 	${top_srcdir}/src/engine/gncTaxTable.h \
 	${top_srcdir}/src/engine/gncIDSearch.h \
 	${top_srcdir}/src/engine/gnc-pricedb.h \
-	${top_srcdir}/src/app-utils/gnc-prefs.h
+	${top_srcdir}/src/app-utils/gnc-prefs-utils.h
 
 
 gnucash_core.c: $(SWIG_FILES) ${top_srcdir}/src/base-typemaps.i ${top_srcdir}/src/engine/engine-common.i $(_gnucash_core_c_includes)

Modified: gnucash/trunk/src/optional/python-bindings/gnucash_core.i
===================================================================
--- gnucash/trunk/src/optional/python-bindings/gnucash_core.i	2013-10-07 14:06:02 UTC (rev 23221)
+++ gnucash/trunk/src/optional/python-bindings/gnucash_core.i	2013-10-07 14:06:23 UTC (rev 23222)
@@ -77,7 +77,7 @@
 #include "gncTaxTable.h"
 #include "gncIDSearch.h"
 #include "engine/gnc-pricedb.h"
-#include "app-utils/gnc-prefs.h"
+#include "app-utils/gnc-prefs-utils.h"
 %}
 
 %include <timespec.i>

Modified: gnucash/trunk/src/python/init.py
===================================================================
--- gnucash/trunk/src/python/init.py	2013-10-07 14:06:02 UTC (rev 23221)
+++ gnucash/trunk/src/python/init.py	2013-10-07 14:06:23 UTC (rev 23222)
@@ -1,11 +1,11 @@
 import sys
 import _sw_app_utils
 from gnucash import *
-from _sw_core_utils import gnc_core_prefs_is_extra_enabled
+from _sw_core_utils import gnc_prefs_is_extra_enabled
 import gtk
 import os
 sys.path.append(os.path.dirname(__file__))
-noisy = gnc_core_prefs_is_extra_enabled()
+noisy = gnc_prefs_is_extra_enabled()
 if noisy:
     print "woop", os.path.dirname(__file__)
 import pycons.console as cons



More information about the gnucash-changes mailing list