[Gnucash-changes] Move the gconf helper routines to the code-utils
directory.
David Hampton
hampton at cvs.gnucash.org
Sun Apr 24 16:55:55 EDT 2005
Log Message:
-----------
Move the gconf helper routines to the code-utils directory. Clean
up the usage of these functions. Document the functions with doxygen.
Tags:
----
gnucash-gnome2-dev
Modified Files:
--------------
gnucash:
configure.in
gnucash/src/business/business-gnome:
Makefile.am
gnucash/src/business/dialog-tax-table:
Makefile.am
gnucash/src/core-utils:
Makefile.am
gnucash/src/gnome:
dialog-commodities.c
gnucash/src/gnome-search:
Makefile.am
gnucash/src/gnome-utils:
Makefile.am
gnc-tree-view-common.c
gw-gnome-utils-spec.scm
gnucash/src/import-export/hbci:
Makefile.am
gnucash/src/import-export/ofx:
Makefile.am
gnucash/src/import-export/qif-import:
Makefile.am
gnucash/src/report/report-gnome:
Makefile.am
Added Files:
-----------
gnucash/src/core-utils:
gnc-gconf-utils.c
gnc-gconf-utils.h
Removed Files:
-------------
gnucash/src/gnome-utils:
gnc-gconf-utils.c
gnc-gconf-utils.h
Revision Data
-------------
Index: configure.in
===================================================================
RCS file: /home/cvs/cvsroot/gnucash/configure.in,v
retrieving revision 1.359.2.45
retrieving revision 1.359.2.46
diff -Lconfigure.in -Lconfigure.in -u -r1.359.2.45 -r1.359.2.46
--- configure.in
+++ configure.in
@@ -332,6 +332,9 @@
fi
fi
+PKG_CHECK_MODULES(GCONF, gconf-2.0 >= "2.0")
+AC_SUBST(GCONF_CFLAGS)
+AC_SUBST(GCONF_LIBS)
AM_CONDITIONAL(GNC_HAVE_GUILE_WWW, test "${gnc_have_guile_www}" = yes)
Index: Makefile.am
===================================================================
RCS file: /home/cvs/cvsroot/gnucash/src/business/business-gnome/Makefile.am,v
retrieving revision 1.31.4.8
retrieving revision 1.31.4.9
diff -Lsrc/business/business-gnome/Makefile.am -Lsrc/business/business-gnome/Makefile.am -u -r1.31.4.8 -r1.31.4.9
--- src/business/business-gnome/Makefile.am
+++ src/business/business-gnome/Makefile.am
@@ -5,6 +5,7 @@
AM_CFLAGS = \
-I${top_srcdir}/src \
+ -I${top_srcdir}/src/core-utils \
-I${top_srcdir}/src/engine \
-I${top_srcdir}/src/gnc-module \
-I${top_srcdir}/src/gnome-utils \
@@ -67,6 +68,7 @@
libgncmod_business_gnome_la_LIBADD = \
${top_builddir}/src/business/business-core/libgncmod-business-core.la \
${top_builddir}/src/business/business-ledger/libgnc-business-ledger.la \
+ ${top_builddir}/src/core-utils/libcore-utils.la \
${top_builddir}/src/gnc-module/libgncmodule.la \
${GUILE_LIBS} \
${GNOME_LIBS} \
Index: Makefile.am
===================================================================
RCS file: /home/cvs/cvsroot/gnucash/src/business/dialog-tax-table/Makefile.am,v
retrieving revision 1.5.4.4
retrieving revision 1.5.4.5
diff -Lsrc/business/dialog-tax-table/Makefile.am -Lsrc/business/dialog-tax-table/Makefile.am -u -r1.5.4.4 -r1.5.4.5
--- src/business/dialog-tax-table/Makefile.am
+++ src/business/dialog-tax-table/Makefile.am
@@ -4,6 +4,7 @@
AM_CFLAGS = \
-I${top_srcdir}/src \
+ -I${top_srcdir}/src/core-utils \
-I${top_srcdir}/src/engine \
-I${top_srcdir}/src/gnc-module \
-I${top_srcdir}/src/gnome-utils \
@@ -30,6 +31,7 @@
libgncmod_dialog_tax_table_la_LIBADD = \
../../gnc-module/libgncmodule.la \
+ ../../core-utils/libcore-utils.la \
${GUILE_LIBS} \
${GNOME_LIBS} \
${G_WRAP_LINK_ARGS} \
Index: Makefile.am
===================================================================
RCS file: /home/cvs/cvsroot/gnucash/src/core-utils/Makefile.am,v
retrieving revision 1.7
retrieving revision 1.7.4.1
diff -Lsrc/core-utils/Makefile.am -Lsrc/core-utils/Makefile.am -u -r1.7 -r1.7.4.1
--- src/core-utils/Makefile.am
+++ src/core-utils/Makefile.am
@@ -1,16 +1,23 @@
lib_LTLIBRARIES = libcore-utils.la libgw-core-utils.la
-gwmoddir = ${GNC_GWRAP_LIBDIR}
-gwmod_DATA = gw-core-utils-spec.scm gw-core-utils.scm
-
-libcore_utils_la_SOURCES = core-utils.c
-libcore_utils_la_LDFLAGS = -module ${GLIB_LIBS}
-libcore_utils_la_LIBADD =
-
-libgw_core_utils_la_SOURCES = gw-core-utils.c
-libgw_core_utils_la_LDFLAGS = -module ${G_WRAP_LINK_ARGS} ${GUILE_LIBS}
-libgw_core_utils_la_LIBADD = libcore-utils.la
+libcore_utils_la_SOURCES = \
+ core-utils.c \
+ gnc-gconf-utils.c
+
+libcore_utils_la_LDFLAGS = -module
+
+libcore_utils_la_LIBADD = \
+ ${GLIB_LIBS} \
+ ${GCONF_LIBS}
+
+libgw_core_utils_la_SOURCES = \
+ gw-core-utils.c
+
+libgw_core_utils_la_LDFLAGS = -module ${G_WRAP_LINK_ARGS}
+libgw_core_utils_la_LIBADD = \
+ libcore-utils.la \
+ ${GUILE_LIBS}
noinst_HEADERS = \
core-utils.h \
@@ -18,7 +25,14 @@
EXTRA_DIST = .cvsignore ${gwmod_DATA}
-AM_CFLAGS = ${G_WRAP_COMPILE_ARGS} ${GLIB_CFLAGS} ${GUILE_INCS}
+AM_CFLAGS = \
+ ${G_WRAP_COMPILE_ARGS} \
+ ${GUILE_INCS} \
+ ${GLIB_CFLAGS} \
+ ${GCONF_CFLAGS}
+
+gwmoddir = ${GNC_GWRAP_LIBDIR}
+gwmod_DATA = gw-core-utils-spec.scm gw-core-utils.scm
if GNUCASH_SEPARATE_BUILDDIR
#Only needed when srcdir and builddir are different
--- /dev/null
+++ src/core-utils/gnc-gconf-utils.h
@@ -0,0 +1,497 @@
+/********************************************************************\
+ * gnc-gconf-utils.h -- utility functions for storing/retrieving *
+ * data in the GConf database for GnuCash *
+ * Copyright (C) 2005 David Hampton <hampton at employees.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, contact: *
+ * *
+ * Free Software Foundation Voice: +1-617-542-5942 *
+ * 59 Temple Place - Suite 330 Fax: +1-617-542-2652 *
+ * Boston, MA 02111-1307, USA gnu at gnu.org *
+ * *
+\********************************************************************/
+
+/** @addtogroup Object
+ @{ */
+/** @addtogroup GConf
+
+ The API in this file is designed to make it easy to use the GConf
+ system from within Gnucash. GConf is a shared key/value storage
+ system.
+
+ The main benefits of these routines are that they 1) maintain a
+ GConfClient object, 2) convert gnucash internal section names into
+ full gconf pathnames, and 3) optionally take care of error
+ checking on return values.
+
+ @{ */
+/** @file gnc-gconf-utils.h
+ * @brief GConf helper routines.
+ * @author Copyright (C) 2005 David Hampton <hampton at employees.org>
+ */
+
+
+#ifndef GNC_GCONF_UTILS_H
+#define GNC_GCONF_UTILS_H
+
+#include <gconf/gconf-client.h>
+
+/** @name GConf Miscellaneous Functions */
+/** @{ */
+
+/** Convert a local key name to a full gconf path name.
+ *
+ * This function takes a gconf key name and converts it into a fully
+ * qualified gconf path name. It does this by prepending the
+ * standard path for all gnucash keys. It the key is already fully
+ * qualified (i.e. begins with a '/' character), this routine does
+ * not change the key.
+ *
+ * @param A partial gconf key or section name. This name is added to
+ * the standard prefix to produce a fully qualified key name.
+ *
+ * @return This function returns a string pointer to the fully
+ * qualified path name of the gconf key. It is the caller's
+ * responsibility to free this string.
+ */
+char *gnc_gconf_section_name (const char *name);
+
+/** Tell GConf to propagate changes.
+ *
+ * This function tells gconf that changes have been made and that is
+ * should propagate its internal state to permanent storage and any
+ * other clients. This function is a suggestion to gconf, not a
+ * directive, and is therefore should be considered optional. Doesn't
+ * hurt to call it though if you've made numerous changes to gconf in
+ * a short period of time.
+ */
+void gnc_gconf_suggest_sync (void);
+
+/** @} */
+
+
+
+/** @name GConf Get Functions */
+/** @{ */
+
+/** Get a boolean value from GConf.
+ *
+ * Retrieve a TRUE/FALSE value from GConf. The section and key names
+ * provided as arguments are combined with the standard gnucash key
+ * prefix to produce a fully qualified key name. Either name (but
+ * not both) may be a fully qualified key path name, in which case it
+ * is used as is, without the standard gnucash prefix. This allows
+ * the program to access keys like standard desktop settings. Either
+ * name (but not both) may be NULL.
+ *
+ * @param section This string provides a grouping of keys within the
+ * GnuCash section of the gconf database. It can be a simple string
+ * as in "history" for settings that are common to many areas of
+ * gnucash, or it can be a partial path name as in
+ * "dialogs/business/invoice" for setting that only apply to one
+ * specific area of the program.
+ *
+ * @param name This string is the name of the particular key within
+ * the named section of gconf.
+ *
+ * @param error An optional pointer to a GError structure. If NULL,
+ * this function will check for any errors returned by GConf and will
+ * display an error message via stdout. If present, this function
+ * will pass any error back to the calling function for it to handle.
+ *
+ * @return This function returns the TRUE or FALSE value stored at
+ * the requested key in the gconf database. If the key has never
+ * been set, this function passes on the default value returned by
+ * GConf as specified in the schema for this key. If there is an
+ * error in processing, this function passed on the value of FALSE as
+ * returned by GConf.
+ */
+gboolean gnc_gconf_get_bool (const gchar *section,
+ const gchar *name,
+ GError **error);
+
+/** Get a boolean value from GConf with no error argument.
+ *
+ * Retrieve a TRUE/FALSE value from GConf. The section and key names
+ * provided as arguments are combined with the standard gnucash key
+ * prefix to produce a fully qualified key name. Either name (but
+ * not both) may be a fully qualified key path name, in which case it
+ * is used as is, without the standard gnucash prefix. This allows
+ * the program to access keys like standard desktop settings. Either
+ * name (but not both) may be NULL.
+ *
+ * @param section This string provides a grouping of keys within the
+ * GnuCash section of the gconf database. It can be a simple string
+ * as in "history" for settings that are common to many areas of
+ * gnucash, or it can be a partial path name as in
+ * "dialogs/business/invoice" for setting that only apply to one
+ * specific area of the program.
+ *
+ * @param name This string is the name of the particular key within
+ * the named section of gconf.
+ *
+ * @return This function returns the TRUE or FALSE value stored at
+ * the requested key in the gconf database. If the key has never
+ * been set, this function passes on the default value returned by
+ * GConf as specified in the schema for this key. If there is an
+ * error in processing, this function passed on the value of FALSE as
+ * returned by GConf.
+ *
+ * @note This function was intended for use only by the guile wrapper
+ * functions. It should not be called from C code.
+ */
+gboolean gnc_gconf_get_bool_no_error (const gchar *section,
+ const gchar *name);
+
+/** Get an integer value from GConf.
+ *
+ * Retrieve an integer value from GConf. The section and key names
+ * provided as arguments are combined with the standard gnucash key
+ * prefix to produce a fully qualified key name. Either name (but
+ * not both) may be a fully qualified key path name, in which case it
+ * is used as is, without the standard gnucash prefix. This allows
+ * the program to access keys like standard desktop settings. Either
+ * name (but not both) may be NULL.
+ *
+ * @param section This string provides a grouping of keys within the
+ * GnuCash section of the gconf database. It can be a simple string
+ * as in "history" for settings that are common to many areas of
+ * gnucash, or it can be a partial path name as in
+ * "dialogs/business/invoice" for setting that only apply to one
+ * specific area of the program.
+ *
+ * @param name This string is the name of the particular key within
+ * the named section of gconf.
+ *
+ * @param error An optional pointer to a GError structure. If NULL,
+ * this function will check for any errors returned by GConf and will
+ * display an error message via stdout. If present, this function
+ * will pass any error back to the calling function for it to handle.
+ *
+ * @return This function returns the integer value stored at the
+ * requested key in the gconf database. If the key has never been
+ * set, this function passes on the default value returned by GConf
+ * as specified in the schema for this key. If there is an error in
+ * processing, this function passed on the value of zero as returned
+ * by GConf.
+ */
+gint gnc_gconf_get_int (const gchar *section,
+ const gchar *name,
+ GError **error);
+
+/** Get a string value from GConf.
+ *
+ * Retrieve an string value from GConf. The section and key names
+ * provided as arguments are combined with the standard gnucash key
+ * prefix to produce a fully qualified key name. Either name (but
+ * not both) may be a fully qualified key path name, in which case it
+ * is used as is, without the standard gnucash prefix. This allows
+ * the program to access keys like standard desktop settings. Either
+ * name (but not both) may be NULL.
+ *
+ * @param section This string provides a grouping of keys within the
+ * GnuCash section of the gconf database. It can be a simple string
+ * as in "history" for settings that are common to many areas of
+ * gnucash, or it can be a partial path name as in
+ * "dialogs/business/invoice" for setting that only apply to one
+ * specific area of the program.
+ *
+ * @param name This string is the name of the particular key within
+ * the named section of gconf.
+ *
+ * @param error An optional pointer to a GError structure. If NULL,
+ * this function will check for any errors returned by GConf and will
+ * display an error message via stdout. If present, this function
+ * will pass any error back to the calling function for it to handle.
+ *
+ * @return This function returns the string value stored at the
+ * requested key in the gconf database. If the key has never been
+ * set, this function passes on the default value returned by GConf
+ * as specified in the schema for this key. If there is an error in
+ * processing, this function passed on the NULL value as returned by
+ * GConf. It is the callers responsibility to free any string
+ * returned by this function.
+ */
+char *gnc_gconf_get_string (const gchar *section,
+ const gchar *name,
+ GError **error);
+
+/** Get a list of values from GConf.
+ *
+ * Retrieve a list of values from GConf. This list may be of any
+ * kind of value understoof by GConf, but all values in the list will
+ * be of the same type. The section and key names provided as
+ * arguments are combined with the standard gnucash key prefix to
+ * produce a fully qualified key name. Either name (but not both)
+ * may be a fully qualified key path name, in which case it is used
+ * as is, without the standard gnucash prefix. This allows the
+ * program to access keys like standard desktop settings. Either
+ * name (but not both) may be NULL.
+ *
+ * @param section This string provides a grouping of keys within the
+ * GnuCash section of the gconf database. It can be a simple string
+ * as in "history" for settings that are common to many areas of
+ * gnucash, or it can be a partial path name as in
+ * "dialogs/business/invoice" for setting that only apply to one
+ * specific area of the program.
+ *
+ * @param name This string is the name of the particular key within
+ * the named section of gconf.
+ *
+ * @param list_type This enum indicates the type of each item in the
+ * returned list. This type must match the type off the stored
+ * items.
+ *
+ * @param error An optional pointer to a GError structure. If NULL,
+ * this function will check for any errors returned by GConf and will
+ * display an error message via stdout. If present, this function
+ * will pass any error back to the calling function for it to handle.
+ *
+ * @return This function returns a list of value stored at the
+ * requested key in the gconf database. If the key has never been
+ * set, this function passes on the default value returned by GConf
+ * as specified in the schema for this key. If there is an error in
+ * processing, this function passed on the NULL value as returned by
+ * GConf. It is the callers responsibility to free any memory
+ * returned by this function. This include the list itself, and any
+ * list data that are string values.
+ */
+GSList *gnc_gconf_get_list (const gchar *section,
+ const gchar *name,
+ GConfValueType list_type,
+ GError **error);
+/** @} */
+
+/** @name GConf Set/Unset Functions */
+/** @{ */
+
+
+/** Store a boolean value into GConf.
+ *
+ * Store a boolean value into GConf. The section and key names
+ * provided as arguments are combined with the standard gnucash key
+ * prefix to produce a fully qualified key name. Either name (but
+ * not both) may be a fully qualified key path name, in which case it
+ * is used as is, without the standard gnucash prefix. This allows
+ * the program to access keys like standard desktop settings. Either
+ * name (but not both) may be NULL.
+ *
+ * @param section This string provides a grouping of keys within the
+ * GnuCash section of the gconf database. It can be a simple string
+ * as in "history" for settings that are common to many areas of
+ * gnucash, or it can be a partial path name as in
+ * "dialogs/business/invoice" for setting that only apply to one
+ * specific area of the program.
+ *
+ * @param name This string is the name of the particular key within
+ * the named section of gconf.
+ *
+ * @value The TRUE/FALSE value to be stored.
+ *
+ * @param error An optional pointer to a GError structure. If NULL,
+ * this function will check for any errors returned by GConf and will
+ * display an error message via stdout. If present, this function
+ * will pass any error back to the calling function for it to handle.
+ */
+void gnc_gconf_set_bool (const gchar *section,
+ const gchar *name,
+ const gboolean value,
+ GError **error);
+
+/** Store an integer value into GConf.
+ *
+ * Store an integer into GConf. The section and key names provided
+ * as arguments are combined with the standard gnucash key prefix to
+ * produce a fully qualified key name. Either name (but not both)
+ * may be a fully qualified key path name, in which case it is used
+ * as is, without the standard gnucash prefix. This allows the
+ * program to access keys like standard desktop settings. Either
+ * name (but not both) may be NULL.
+ *
+ * @param section This string provides a grouping of keys within the
+ * GnuCash section of the gconf database. It can be a simple string
+ * as in "history" for settings that are common to many areas of
+ * gnucash, or it can be a partial path name as in
+ * "dialogs/business/invoice" for setting that only apply to one
+ * specific area of the program.
+ *
+ * @param name This string is the name of the particular key within
+ * the named section of gconf.
+ *
+ * @value The number to be stored.
+ *
+ * @param error An optional pointer to a GError structure. If NULL,
+ * this function will check for any errors returned by GConf and will
+ * display an error message via stdout. If present, this function
+ * will pass any error back to the calling function for it to handle.
+ */
+void gnc_gconf_set_int (const gchar *section,
+ const gchar *name,
+ const gint value,
+ GError **error);
+
+/** Store a string into GConf.
+ *
+ * Store a single string into GConf. The section and key names
+ * provided as arguments are combined with the standard gnucash key
+ * prefix to produce a fully qualified key name. Either name (but
+ * not both) may be a fully qualified key path name, in which case it
+ * is used as is, without the standard gnucash prefix. This allows
+ * the program to access keys like standard desktop settings. Either
+ * name (but not both) may be NULL.
+ *
+ * @param section This string provides a grouping of keys within the
+ * GnuCash section of the gconf database. It can be a simple string
+ * as in "history" for settings that are common to many areas of
+ * gnucash, or it can be a partial path name as in
+ * "dialogs/business/invoice" for setting that only apply to one
+ * specific area of the program.
+ *
+ * @param name This string is the name of the particular key within
+ * the named section of gconf.
+ *
+ * @value The string to be stored. GConf will make a copy of this
+ * string, so it is the callers responsibility to free the space used
+ * by this string (if necessary).
+ *
+ * @param error An optional pointer to a GError structure. If NULL,
+ * this function will check for any errors returned by GConf and will
+ * display an error message via stdout. If present, this function
+ * will pass any error back to the calling function for it to handle.
+ */
+void gnc_gconf_set_string (const gchar *section,
+ const gchar *name,
+ const gchar *value,
+ GError **error);
+
+/** Store a list of values into GConf.
+ *
+ * Store a list of values into GConf. This list may be of any kind
+ * of value understoof by GConf, but all values in the list must be
+ * of the same type. The section and key names provided as arguments
+ * are combined with the standard gnucash key prefix to produce a
+ * fully qualified key name. Either name (but not both) may be a
+ * fully qualified key path name, in which case it is used as is,
+ * without the standard gnucash prefix. This allows the program to
+ * access keys like standard desktop settings. Either name (but not
+ * both) may be NULL.
+ *
+ * @param section This string provides a grouping of keys within the
+ * GnuCash section of the gconf database. It can be a simple string
+ * as in "history" for settings that are common to many areas of
+ * gnucash, or it can be a partial path name as in
+ * "dialogs/business/invoice" for setting that only apply to one
+ * specific area of the program.
+ *
+ * @param name This string is the name of the particular key within
+ * the named section of gconf.
+ *
+ * @param list_type This enum indicates the type of each item in the
+ * list to be stored.
+ *
+ * @value The list of items to be stored. Each item in the list must
+ * be of the type specified. E.G. If the list_type is
+ * GCONF_VALUE_STRING, then the data field of each element in the
+ * list must be a string pointer.
+ *
+ * @param error An optional pointer to a GError structure. If NULL,
+ * this function will check for any errors returned by GConf and will
+ * display an error message via stdout. If present, this function
+ * will pass any error back to the calling function for it to handle.
+ */
+void gnc_gconf_set_list (const gchar *section,
+ const gchar *name,
+ GConfValueType list_type,
+ GSList *value,
+ GError **error);
+
+/** Delete a value from GConf.
+ *
+ * Complete remove a value from GConf. The next attempt to read this
+ * value will return the default as specified in the GConf schema for
+ * this key. The section and key names provided as arguments are
+ * combined with the standard gnucash key prefix to produce a fully
+ * qualified key name. Either name (but not both) may be a fully
+ * qualified key path name, in which case it is used as is, without
+ * the standard gnucash prefix. This allows the program to access
+ * keys like standard desktop settings. Either name (but not both)
+ * may be NULL.
+ *
+ * @param section This string provides a grouping of keys within the
+ * GnuCash section of the gconf database. It can be a simple string
+ * as in "history" for settings that are common to many areas of
+ * gnucash, or it can be a partial path name as in
+ * "dialogs/business/invoice" for setting that only apply to one
+ * specific area of the program.
+ *
+ * @param name This string is the name of the particular key within
+ * the named section of gconf.
+ *
+ * @param error An optional pointer to a GError structure. If NULL,
+ * this function will check for any errors returned by GConf and will
+ * display an error message via stdout. If present, this function
+ * will pass any error back to the calling function for it to handle.
+ */
+void gnc_gconf_unset (const gchar *section,
+ const gchar *name,
+ GError **error);
+
+/** @} */
+
+/** @name GConf Notification Functions */
+/** @{ */
+
+/** Add a notification callback to GConf.
+ *
+ * Add a function that will be called whenever a value within the
+ * specified section of the GConf tree changes. The section name
+ * provided as an argument is combined with the standard gnucash key
+ * prefix to produce a fully qualified key name. This name may be a
+ * fully qualified key path name, in which case it is used as is,
+ * without the standard gnucash prefix. This allows the object to
+ * respond to keys like standard desktop settings.
+ *
+ * @param section This string provides a grouping of keys within the
+ * GnuCash section of the gconf database. It can be a simple string
+ * as in "history" for settings that are common to many areas of
+ * gnucash, or it can be a partial path name as in
+ * "dialogs/business/invoice" for setting that only apply to one
+ * specific area of the program. Any key changes within this section
+ * will invoke the notification function.
+ *
+ * @param callback The function to call when a value changes. This
+ * function will receive the key/value pair as one argument, and the
+ * 'object' argument to this function as another of its arguments.
+ */
+void gnc_gconf_add_notification (GObject *object,
+ const gchar *section,
+ GConfClientNotifyFunc callback);
+
+/** Remove a callback from GConf.
+ *
+ * Remove a GConf callback function previously added with the
+ * gnc_gconf_add_notification function. The section name must be the
+ * same string provided when the callback function was added. This
+ * name is used to find/remove the callback.
+ *
+ * @param section This string is used to find the correct
+ * notification function to remove from GConf.
+ */
+void gnc_gconf_remove_notification (GObject *object,
+ const gchar *section);
+/** @} */
+
+#endif /* GNC_GCONF_UTILS_H */
+/** @} */
+/** @} */
--- /dev/null
+++ src/core-utils/gnc-gconf-utils.c
@@ -0,0 +1,415 @@
+/********************************************************************\
+ * gnc-gconf-utils.c -- utility functions for storing/retrieving *
+ * data in the GConf database for GnuCash *
+ * Copyright (C) 2005 David Hampton <hampton at employees.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, contact: *
+ * *
+ * Free Software Foundation Voice: +1-617-542-5942 *
+ * 59 Temple Place - Suite 330 Fax: +1-617-542-2652 *
+ * Boston, MA 02111-1307, USA gnu at gnu.org *
+ * *
+\********************************************************************/
+
+#include "config.h"
+
+#include <stdio.h>
+#include "gnc-gconf-utils.h"
+
+#define APP_GNUCASH "/apps/gnucash/%s"
+#define CLIENT_TAG "%s-client"
+#define NOTIFY_TAG "%s-notify_id"
+
+static GConfClient *our_client = NULL;
+
+
+char *
+gnc_gconf_section_name (const char *name)
+{
+ if (*name == '/') {
+ /* Need to return a newly allocated string */
+ return g_strdup(name);
+ }
+
+ /* This could (should?) be accomplished with a call to
+ * gnome_gconf_get_app_settings_relative(), but that would introduce
+ * a new library dependancy, even though its not a gui library. In
+ * order to keep this file completely "gnome-free" this approach was
+ * used.
+ */
+ return g_strdup_printf(APP_GNUCASH, name);
+}
+
+static gchar *
+gnc_gconf_make_key (const gchar *section, const gchar *name)
+{
+ gchar *section_path, *key;
+
+ g_assert ((section != NULL) && (name != NULL));
+
+ if (section == NULL) {
+ if (*name == '/')
+ return g_strdup(name);
+ return gnc_gconf_section_name(name);
+ }
+
+ if (name == NULL) {
+ if (*section == '/')
+ return g_strdup(section);
+ return gnc_gconf_section_name(section);
+ }
+
+ g_assert ((*section != '/') && (*name != '/'));
+
+ section_path = gnc_gconf_section_name(section);
+ key = g_strdup_printf("%s/%s", section_path, name);
+ g_free(section_path);
+ return key;
+}
+
+
+gboolean
+gnc_gconf_get_bool (const gchar *section,
+ const gchar *name,
+ GError **caller_error)
+{
+ GError *error = NULL;
+ gboolean value;
+ gchar *key;
+
+ if (our_client == NULL)
+ our_client = gconf_client_get_default();
+
+ key = gnc_gconf_make_key(section, name);
+ value = gconf_client_get_bool(our_client, key, &error);
+ if (error) {
+ if (caller_error) {
+ g_propagate_error(caller_error, error);
+ } else {
+ printf("Failed to load key %s: %s", key, error->message);
+ g_error_free(error);
+ }
+ }
+ g_free(key);
+ return value;
+}
+
+gboolean
+gnc_gconf_get_bool_no_error (const gchar *section,
+ const gchar *name)
+{
+ return gnc_gconf_get_bool(section, name, NULL);
+}
+
+void
+gnc_gconf_set_bool (const gchar *section,
+ const gchar *name,
+ const gboolean value,
+ GError **caller_error)
+{
+ GError *error = NULL;
+ gchar *key;
+
+ if (our_client == NULL)
+ our_client = gconf_client_get_default();
+
+ /* Remember whether the column width */
+ key = gnc_gconf_make_key(section, name);
+ if (!gconf_client_set_bool(our_client, key, value, &error)) {
+ if (caller_error) {
+ g_propagate_error(caller_error, error);
+ } else {
+ printf("Failed to save key %s: %s", key, error->message);
+ g_error_free(error);
+ }
+ }
+ g_free(key);
+}
+
+gint
+gnc_gconf_get_int (const gchar *section,
+ const gchar *name,
+ GError **caller_error)
+{
+ GError *error = NULL;
+ gint value;
+ gchar *key;
+
+ if (our_client == NULL)
+ our_client = gconf_client_get_default();
+
+ key = gnc_gconf_make_key(section, name);
+ value = gconf_client_get_int(our_client, key, &error);
+ if (error) {
+ if (caller_error) {
+ g_propagate_error(caller_error, error);
+ } else {
+ printf("Failed to load key %s: %s", key, error->message);
+ g_error_free(error);
+ }
+ }
+ g_free(key);
+ return value;
+}
+
+void
+gnc_gconf_set_int (const gchar *section,
+ const gchar *name,
+ const gint value,
+ GError **caller_error)
+{
+ GError *error = NULL;
+ gchar *key;
+
+ if (our_client == NULL)
+ our_client = gconf_client_get_default();
+
+ /* Remember whether the column width */
+ key = gnc_gconf_make_key(section, name);
+ if (!gconf_client_set_int(our_client, key, value, &error)) {
+ if (caller_error) {
+ g_propagate_error(caller_error, error);
+ } else {
+ printf("Failed to save key %s: %s", key, error->message);
+ g_error_free(error);
+ }
+ }
+ g_free(key);
+}
+
+gchar *
+gnc_gconf_get_string (const gchar *section,
+ const gchar *name,
+ GError **caller_error)
+{
+ GError *error = NULL;
+ gchar *value;
+ gchar *key;
+
+ if (our_client == NULL)
+ our_client = gconf_client_get_default();
+
+ key = gnc_gconf_make_key(section, name);
+ value = gconf_client_get_string(our_client, key, &error);
+ if (error) {
+ if (caller_error) {
+ g_propagate_error(caller_error, error);
+ } else {
+ printf("Failed to load key %s: %s", key, error->message);
+ g_error_free(error);
+ }
+ }
+ g_free(key);
+ return value;
+}
+
+void
+gnc_gconf_set_string (const gchar *section,
+ const gchar *name,
+ const gchar *value,
+ GError **caller_error)
+{
+ GError *error = NULL;
+ gchar *key;
+
+ if (our_client == NULL)
+ our_client = gconf_client_get_default();
+
+ key = gnc_gconf_make_key(section, name);
+ if (!gconf_client_set_string(our_client, key, value, &error)) {
+ if (caller_error) {
+ g_propagate_error(caller_error, error);
+ } else {
+ printf("Failed to save key %s: %s", key, error->message);
+ g_error_free(error);
+ }
+ }
+ g_free(key);
+}
+
+GSList *
+gnc_gconf_get_list (const gchar *section,
+ const gchar *name,
+ GConfValueType list_type,
+ GError **caller_error)
+{
+ GError *error = NULL;
+ GSList *value;
+ gchar *key;
+
+ if (our_client == NULL)
+ our_client = gconf_client_get_default();
+
+ key = gnc_gconf_make_key(section, name);
+ value = gconf_client_get_list(our_client, key, list_type, &error);
+ if (error) {
+ if (caller_error) {
+ g_propagate_error(caller_error, error);
+ } else {
+ printf("Failed to load key %s: %s", key, error->message);
+ g_error_free(error);
+ }
+ }
+ g_free(key);
+ return value;
+}
+
+void
+gnc_gconf_set_list (const gchar *section,
+ const gchar *name,
+ GConfValueType list_type,
+ GSList *value,
+ GError **caller_error)
+{
+ GError *error = NULL;
+ gchar *key;
+
+ if (our_client == NULL)
+ our_client = gconf_client_get_default();
+
+ key = gnc_gconf_make_key(section, name);
+ if (!gconf_client_set_list(our_client, key, list_type, value, &error)) {
+ if (caller_error) {
+ g_propagate_error(caller_error, error);
+ } else {
+ printf("Failed to save key %s: %s", key, error->message);
+ g_error_free(error);
+ }
+ }
+ g_free(key);
+}
+
+void
+gnc_gconf_unset (const gchar *section,
+ const gchar *name,
+ GError **caller_error)
+{
+ GError *error = NULL;
+ gchar *key;
+
+ if (our_client == NULL)
+ our_client = gconf_client_get_default();
+
+ key = gnc_gconf_make_key(section, name);
+ if (!gconf_client_unset(our_client, key, &error)) {
+ if (caller_error) {
+ g_propagate_error(caller_error, error);
+ } else {
+ printf("Failed to save key %s: %s", key, error->message);
+ g_error_free(error);
+ }
+ }
+ g_free(key);
+}
+
+
+void
+gnc_gconf_suggest_sync (void)
+{
+ GError *error = NULL;
+
+ if (our_client == NULL)
+ our_client = gconf_client_get_default();
+
+ gconf_client_suggest_sync(our_client, &error);
+ if (error != NULL) {
+ printf("Failed to sync gconf: %s", error->message);
+ g_error_free(error);
+ }
+}
+
+
+void
+gnc_gconf_add_notification (GObject *object,
+ const gchar *section,
+ GConfClientNotifyFunc callback)
+{
+
+ GConfClient *client;
+ GError *error = NULL;
+ gchar *path, *client_tag, *notify_tag;
+ guint id;
+
+ g_return_if_fail(!G_IS_OBJECT(object));
+ g_return_if_fail(section != NULL);
+ g_return_if_fail(callback != NULL);
+
+ client = gconf_client_get_default();
+ path = gnc_gconf_section_name(section);
+
+
+ /*
+ * First we have to add the directory...
+ */
+ gconf_client_add_dir(client, path, GCONF_CLIENT_PRELOAD_ONELEVEL, &error);
+ if (error != NULL) {
+ printf("Failed to add history section to watched directories in gconf: %s", error->message);
+ g_error_free(error);
+ g_object_unref(client);
+ return;
+ }
+
+ /*
+ * Then we can add the notification callback.
+ */
+ id = gconf_client_notify_add(client, path, callback,
+ object, NULL, &error);
+ if (error != NULL) {
+ printf("Failed to set gconf notify for history section: %s", error->message);
+ gconf_client_remove_dir(client, path, NULL);
+ g_error_free(error);
+ g_object_unref(client);
+ return;
+ }
+
+ /*
+ * Save the values needed to undo this later.
+ */
+ client_tag = g_strdup_printf(CLIENT_TAG, section);
+ notify_tag = g_strdup_printf(NOTIFY_TAG, section);
+ g_object_set_data(object, client_tag, client);
+ g_object_set_data(object, notify_tag, GUINT_TO_POINTER(id));
+ g_free(notify_tag);
+ g_free(client_tag);
+}
+
+
+void
+gnc_gconf_remove_notification (GObject *object,
+ const gchar *section)
+{
+ GConfClient *client;
+ gchar *path, *client_tag, *notify_tag;
+ guint id;
+
+ g_return_if_fail(!G_IS_OBJECT(object));
+ g_return_if_fail(section != NULL);
+
+ /*
+ * Remove any gconf notifications
+ */
+ client_tag = g_strdup_printf(CLIENT_TAG, section);
+ client = g_object_get_data(object, client_tag);
+ path = gnc_gconf_section_name(section);
+ if (client) {
+ notify_tag = g_strdup_printf(NOTIFY_TAG, section);
+ id = GPOINTER_TO_UINT(g_object_get_data(object, notify_tag));
+ gconf_client_notify_remove(client, id);
+ gconf_client_remove_dir(client, path, NULL);
+ g_object_unref(client);
+ g_free(notify_tag);
+ }
+ g_free(path);
+ g_free(client_tag);
+}
Index: dialog-commodities.c
===================================================================
RCS file: /home/cvs/cvsroot/gnucash/src/gnome/dialog-commodities.c,v
retrieving revision 1.14.4.9
retrieving revision 1.14.4.10
diff -Lsrc/gnome/dialog-commodities.c -Lsrc/gnome/dialog-commodities.c -u -r1.14.4.9 -r1.14.4.10
--- src/gnome/dialog-commodities.c
+++ src/gnome/dialog-commodities.c
@@ -40,6 +40,7 @@
#define DIALOG_COMMODITIES_CM_CLASS "dialog-commodities"
+#define GCONF_SECTION "dialogs/edit_commodities"
/* This static indicates the debugging module that this .o belongs to. */
/* static short module = MOD_GUI; */
@@ -54,7 +55,6 @@
gboolean show_currencies;
gboolean new;
- gchar *gconf_section;
} CommoditiesDialog;
@@ -72,7 +72,6 @@
{
gnc_unregister_gui_component_by_data (DIALOG_COMMODITIES_CM_CLASS, cd);
- g_free (cd->gconf_section);
g_free (cd);
}
@@ -279,9 +278,7 @@
dialog = glade_xml_get_widget (xml, "Commodities Dialog");
cd->dialog = dialog;
- cd->gconf_section = gnc_gconf_section_name ("dialogs/commodities_dialog");
- gnc_gconf_client_get_bool (NULL, NULL, cd->gconf_section,
- "include_iso", &cd->show_currencies);
+ cd->show_currencies = gnc_gconf_get_bool(GCONF_SECTION, "include_iso", NULL);
glade_xml_signal_autoconnect_full(xml, gnc_glade_autoconnect_full_func, cd);
@@ -320,7 +317,7 @@
gtk_window_resize (GTK_WINDOW(cd->dialog), last_width, last_height);
gnc_tree_view_commodity_restore_settings (cd->commodity_tree,
- cd->gconf_section);
+ GCONF_SECTION);
}
static void
@@ -331,9 +328,8 @@
gtk_window_get_size(GTK_WINDOW(cd->dialog), &last_width, &last_height);
gnc_save_window_size("commodities_win", last_width, last_height);
- gnc_gconf_client_set_bool (NULL, NULL, cd->gconf_section,
- "include_iso", cd->show_currencies);
- gnc_tree_view_commodity_save_settings (cd->commodity_tree, cd->gconf_section);
+ gnc_gconf_set_bool(GCONF_SECTION, "include_iso", cd->show_currencies, NULL);
+ gnc_tree_view_commodity_save_settings (cd->commodity_tree, GCONF_SECTION);
gtk_widget_destroy(cd->dialog);
}
Index: Makefile.am
===================================================================
RCS file: /home/cvs/cvsroot/gnucash/src/gnome-search/Makefile.am,v
retrieving revision 1.12.2.5
retrieving revision 1.12.2.6
diff -Lsrc/gnome-search/Makefile.am -Lsrc/gnome-search/Makefile.am -u -r1.12.2.5 -r1.12.2.6
--- src/gnome-search/Makefile.am
+++ src/gnome-search/Makefile.am
@@ -4,6 +4,7 @@
AM_CFLAGS = \
-I${top_srcdir}/src \
+ -I${top_srcdir}/src/core-utils \
-I${top_srcdir}/src/engine \
-I${top_srcdir}/src/app-utils \
-I${top_srcdir}/src/gnome-utils \
@@ -53,6 +54,7 @@
libgncmod_gnome_search_la_LIBADD = \
${top_builddir}/src/gnc-module/libgncmodule.la \
+ ${top_builddir}/src/core-utils/libcore-utils.la \
${GUILE_LIBS} \
${GNOME_LIBS} \
${GTKHTML_LIBS} \
Index: gnc-tree-view-common.c
===================================================================
RCS file: /home/cvs/cvsroot/gnucash/src/gnome-utils/Attic/gnc-tree-view-common.c,v
retrieving revision 1.1.2.1
retrieving revision 1.1.2.2
diff -Lsrc/gnome-utils/gnc-tree-view-common.c -Lsrc/gnome-utils/gnc-tree-view-common.c -u -r1.1.2.1 -r1.1.2.2
--- src/gnome-utils/gnc-tree-view-common.c
+++ src/gnome-utils/gnc-tree-view-common.c
@@ -2,7 +2,7 @@
* gnc-tree-view-common.c -- common utilities for manipulating a
* GtkTreeView within gnucash
*
- * Copyright (C) 2003 David Hampton <hampton at employees.org>
+ * Copyright (C) 2003,2005 David Hampton <hampton at employees.org>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
@@ -210,7 +210,6 @@
static void
gnc_tree_view_common_save_sort_info (GtkTreeView *view,
const gchar *section,
- GConfClient *client,
gnc_view_column *defaults)
{
GtkTreeViewColumn *column;
@@ -239,8 +238,8 @@
enum_value = g_enum_get_value (enum_class, order);
enum_name = enum_value->value_nick;
- gnc_gconf_client_set_string (client, NULL, section, "sort_column", col_name);
- gnc_gconf_client_set_string (client, NULL, section, "sort_order", enum_name);
+ gnc_gconf_set_string(section, "sort_column", col_name, NULL);
+ gnc_gconf_set_string(section, "sort_order", enum_name, NULL);
}
void
@@ -254,8 +253,6 @@
const gchar *tree_name;
const gchar *name;
gint i, num;
- GConfClient * client;
- GError * error;
g_return_if_fail (GTK_IS_TREE_VIEW(view));
g_return_if_fail (section != NULL);
@@ -265,8 +262,6 @@
ENTER("view %p, name %s, section %s, defaults %p",
view, tree_name, section, defaults);
- client = gconf_client_get_default ();
-
for (i = 0; defaults[i].pref_name != NULL; i++) {
column = gtk_tree_view_get_column (view, i);
num = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(column), COLUMN_NUM));
@@ -276,37 +271,29 @@
column_names = g_slist_append(column_names, (gpointer)name);
/* Remember whether the column is visible */
- key = g_strdup_printf("%s/%s_visible", section, name);
- gnc_gconf_client_set_bool (client, key, NULL, NULL,
- gtk_tree_view_column_get_visible (column));
+ key = g_strdup_printf("%s_visible", name);
+ gnc_gconf_set_bool(section, key,
+ gtk_tree_view_column_get_visible(column), NULL);
+ g_free(key);
/* Remember whether the column width */
- key = g_strdup_printf("%s/%s_width", section, name);
- gnc_gconf_client_set_int (client, key, NULL, NULL,
- gtk_tree_view_column_get_width (column));
+ key = g_strdup_printf("%s_width", name);
+ gnc_gconf_set_int(section, key,
+ gtk_tree_view_column_get_width(column), NULL);
+ g_free(key);
}
- gnc_tree_view_common_save_sort_info (view, section, client, defaults);
-
- /* Remember whether the rules hint is active */
- key = g_strdup_printf("%s/rules_hint", section);
- gnc_gconf_client_set_bool (client, key, NULL, NULL,
- gtk_tree_view_get_rules_hint (view));
+ gnc_tree_view_common_save_sort_info (view, section, defaults);
- key = g_strdup_printf("%s/column_order", section);
- if (!gconf_client_set_list (client, key, GCONF_VALUE_STRING,
- column_names, &error)) {
- DEBUG("Failed to save order: %s", error->message);
- g_error_free (error);
- }
- g_free(key);
+ gnc_gconf_set_list(section, "column_order", GCONF_VALUE_STRING,
+ column_names, NULL);
+ gnc_gconf_suggest_sync();
LEAVE(" ");
}
static void
gnc_tree_view_common_restore_sort_info (GtkTreeView *view,
const gchar *section,
- GConfClient *client,
gnc_view_column *defaults)
{
GtkTreeModel *s_model;
@@ -316,15 +303,13 @@
GEnumClass *enum_class;
GEnumValue *enum_value;
- if (!gnc_gconf_client_get_string (client, NULL, section, "sort_column", &value))
- return;
+ value = gnc_gconf_get_string(section, "sort_column", NULL);
if (value) {
sort_column_id = view_column_find_by_name(defaults, value);
g_free(value);
}
- if (!gnc_gconf_client_get_string (client, NULL, section, "sort_order", &value))
- return;
+ value = gnc_gconf_get_string(section, "sort_order", NULL);
if (value) {
enum_class = g_type_class_ref (GTK_TYPE_SORT_TYPE);
enum_value = g_enum_get_value_by_nick (enum_class, value);
@@ -351,8 +336,6 @@
GSList *column_names, *tmp, *next;
gboolean visible;
gint i, width;
- GConfClient *client;
- GError *error = NULL;
g_return_if_fail (GTK_IS_TREE_VIEW(view));
g_return_if_fail (section != NULL);
@@ -362,30 +345,19 @@
ENTER("view %p, name %s, section %s, defaults %p",
view, tree_name, section, defaults);
- client = gconf_client_get_default ();
-
/* Get the column order information first. This can be used as a
* key to see if 1) there is any information present in the users
* gconf files, and 2) the gconf schema have been installed. If the
* result is a null list, neither of the two is present and this
* routine should bail now. We'll actually swap the columns around
* after setting up all the other information. */
- key = g_strdup_printf("%s/column_order", section);
- column_names =
- gconf_client_get_list (client, key, GCONF_VALUE_STRING, &error);
- g_free(key);
+ column_names = gnc_gconf_get_list(section, "column_order",
+ GCONF_VALUE_STRING, NULL);
if (column_names == NULL)
return;
- /* Restore whether the rules hint is visible */
- key = g_strdup_printf("%s/rules_hint", section);
- if (gnc_gconf_client_get_bool (client, key, NULL, NULL, &visible)) {
- DEBUG("Setting rules hint to %d", visible);
- gtk_tree_view_set_rules_hint (view, visible);
- }
-
/* Restore the sort information, if any */
- gnc_tree_view_common_restore_sort_info (view, section, client, defaults);
+ gnc_tree_view_common_restore_sort_info (view, section, defaults);
/* Restore any per-column information */
for (i = 0; defaults[i].pref_name != NULL; i++) {
@@ -394,18 +366,20 @@
DEBUG("Processing column %s", col_name);
/* visible */
- key = g_strdup_printf("%s/%s_visible", section, col_name);
- if (gnc_gconf_client_get_bool (client, key, NULL, NULL, &visible)) {
- DEBUG(" Setting %s column visibility to %d", col_name, visible);
- gtk_tree_view_column_set_visible (column, visible);
- }
+ key = g_strdup_printf("%s_visible", col_name);
+ visible = gnc_gconf_get_bool(section, key, NULL);
+ DEBUG(" Setting %s column visibility to %d", col_name, visible);
+ gtk_tree_view_column_set_visible (column, visible);
+ g_free(key);
/* column width */
- key = g_strdup_printf("%s/%s_width", section, col_name);
- if (gnc_gconf_client_get_int (client, key, NULL, NULL, &width)) {
+ key = g_strdup_printf("%s_width", col_name);
+ width = gnc_gconf_get_int(section, key, NULL);
+ if (width != 0) {
DEBUG(" Would set %s column width to %d", col_name, width);
// gtk_tree_view_column_set_width (column, width);
}
+ g_free(key);
}
/* Now swap the columns around the way the user had them. */
@@ -434,6 +408,5 @@
}
g_slist_free(column_names);
-
LEAVE(" ");
}
Index: gw-gnome-utils-spec.scm
===================================================================
RCS file: /home/cvs/cvsroot/gnucash/src/gnome-utils/gw-gnome-utils-spec.scm,v
retrieving revision 1.19.4.5
retrieving revision 1.19.4.6
diff -Lsrc/gnome-utils/gw-gnome-utils-spec.scm -Lsrc/gnome-utils/gw-gnome-utils-spec.scm -u -r1.19.4.5 -r1.19.4.6
--- src/gnome-utils/gw-gnome-utils-spec.scm
+++ src/gnome-utils/gw-gnome-utils-spec.scm
@@ -47,6 +47,7 @@
"#include <gnc-menu-extensions.h>\n"
"#include <gnc-ui.h>\n"
"#include <print-session.h>\n"
+ "#include <gnc-gconf-utils.h>\n"
)))
@@ -496,6 +497,13 @@
"gnc_unset_busy_cursor"
'((<gtk:Widget*> window))
"Remove a busy cursor for a specific window. If null, the busy cursor will be removed on all windows.")
-)
-
+ (gw:wrap-function
+ ws
+ 'gnc:gconf-get-bool
+ '<gw:bool>
+ "gnc_gconf_get_bool_no_error"
+ '(((<gw:mchars> caller-owned) section)
+ ((<gw:mchars> caller-owned) name))
+ "Get a boolean value from gconf.")
+)
--- src/gnome-utils/gnc-gconf-utils.h
+++ /dev/null
@@ -1,40 +0,0 @@
-#include <gconf/gconf-client.h>
-
-char * gnc_gconf_section_name (const char *name);
-
-gboolean
-gnc_gconf_client_get_bool (GConfClient *client,
- gchar *key,
- const gchar *section,
- const gchar *name,
- gboolean *value);
-
-void gnc_gconf_client_set_bool (GConfClient *client,
- gchar *key,
- const gchar *section,
- const gchar *name,
- const gboolean value);
-
-gboolean
-gnc_gconf_client_get_int (GConfClient *client,
- gchar *key,
- const gchar *section,
- const gchar *name,
- gint *value);
-
-void gnc_gconf_client_set_int (GConfClient *client,
- gchar *key,
- const gchar *section,
- const gchar *name,
- const gint value);
-
-gboolean gnc_gconf_client_get_string (GConfClient *client,
- gchar *key,
- const gchar *section,
- const gchar *name,
- gchar **value);
-void gnc_gconf_client_set_string (GConfClient *client,
- gchar *key,
- const gchar *section,
- const gchar *name,
- const gchar *value);
--- src/gnome-utils/gnc-gconf-utils.c
+++ /dev/null
@@ -1,180 +0,0 @@
-/********************************************************************\
- * gnc-gconf-utils.c -- utility functions for gnome for GnuCash *
- * Copyright (C) 2001 Linux Developers Group *
- * *
- * 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 *
- * 59 Temple Place - Suite 330 Fax: +1-617-542-2652 *
- * Boston, MA 02111-1307, USA gnu at gnu.org *
- * *
-\********************************************************************/
-
-#include "config.h"
-
-#include <gnome.h>
-#include <gconf/gconf-client.h>
-
-#include "gnc-gconf-utils.h"
-
-
-char *
-gnc_gconf_section_name (const char *name)
-{
- return gnome_gconf_get_app_settings_relative(NULL, name);
-}
-
-static gchar *
-gnc_gconf_make_key (gchar *key, const gchar *section, const gchar *name)
-{
- if (key)
- return key;
- return g_strdup_printf("%s/%s", section, name);
-}
-
-
-gboolean
-gnc_gconf_client_get_bool (GConfClient *client,
- gchar *key,
- const gchar *section,
- const gchar *name,
- gboolean *value)
-{
- GError *error = NULL;
-
- if (client == NULL)
- client = gconf_client_get_default ();
-
- key = gnc_gconf_make_key (key, section, name);
- *value = gconf_client_get_bool (client, key, &error);
- if (error == NULL) {
- g_free(key);
- return TRUE;
- }
-
- printf("Failed to load key %s: %s", key, error->message);
- g_error_free (error);
- g_free(key);
- return FALSE;
-}
-
-void
-gnc_gconf_client_set_bool (GConfClient *client,
- gchar *key,
- const gchar *section,
- const gchar *name,
- const gboolean value)
-{
- GError *error = NULL;
-
- if (client == NULL)
- client = gconf_client_get_default ();
-
- /* Remember whether the column width */
- key = gnc_gconf_make_key (key, section, name);
- if (!gconf_client_set_bool (client, key, value, &error)) {
- printf("Failed to save key %s: %s", key, error->message);
- g_error_free (error);
- }
- g_free(key);
-}
-
-gboolean
-gnc_gconf_client_get_int (GConfClient *client,
- gchar *key,
- const gchar *section,
- const gchar *name,
- gint *value)
-{
- GError *error = NULL;
-
- if (client == NULL)
- client = gconf_client_get_default ();
-
- key = gnc_gconf_make_key (key, section, name);
- *value = gconf_client_get_int (client, key, &error);
- if (error == NULL) {
- g_free(key);
- return TRUE;
- }
-
- printf("Failed to load key %s: %s", key, error->message);
- g_error_free (error);
- g_free(key);
- return FALSE;
-}
-
-void
-gnc_gconf_client_set_int (GConfClient *client,
- gchar *key,
- const gchar *section,
- const gchar *name,
- const gint value)
-{
- GError *error = NULL;
-
- if (client == NULL)
- client = gconf_client_get_default ();
-
- /* Remember whether the column width */
- key = gnc_gconf_make_key (key, section, name);
- if (!gconf_client_set_int (client, key, value, &error)) {
- printf("Failed to save key %s: %s", key, error->message);
- g_error_free (error);
- }
- g_free(key);
-}
-
-gboolean
-gnc_gconf_client_get_string (GConfClient *client,
- gchar *key,
- const gchar *section,
- const gchar *name,
- gchar **value)
-{
- GError *error = NULL;
-
- if (client == NULL)
- client = gconf_client_get_default ();
-
- key = gnc_gconf_make_key (key, section, name);
- *value = gconf_client_get_string (client, key, &error);
- if (error == NULL) {
- g_free(key);
- return TRUE;
- }
-
- printf("Failed to load key %s: %s", key, error->message);
- g_error_free (error);
- g_free(key);
- return FALSE;
-
-}
-
-void
-gnc_gconf_client_set_string (GConfClient *client,
- gchar *key,
- const gchar *section,
- const gchar *name,
- const gchar *value)
-{
- GError *error = NULL;
-
- key = gnc_gconf_make_key (key, section, name);
- if (!gconf_client_set_string (client, key, value, &error)) {
- printf("Failed to save key %s: %s", key, error->message);
- g_error_free (error);
- }
- g_free(key);
-}
Index: Makefile.am
===================================================================
RCS file: /home/cvs/cvsroot/gnucash/src/gnome-utils/Makefile.am,v
retrieving revision 1.48.2.26
retrieving revision 1.48.2.27
diff -Lsrc/gnome-utils/Makefile.am -Lsrc/gnome-utils/Makefile.am -u -r1.48.2.26 -r1.48.2.27
--- src/gnome-utils/Makefile.am
+++ src/gnome-utils/Makefile.am
@@ -9,6 +9,7 @@
-DSYSCONFDIR=\"${GNC_CONFIGDIR}\" \
-DDATADIR=\"${GNC_SHAREDIR}\" \
-DLIBDIR=\"${GNC_LIBDIR}\" \
+ -I${top_srcdir}/src/core-utils \
-I${top_srcdir}/src/gnc-module \
-I${top_srcdir}/src/engine \
-I${top_srcdir}/src/backend/file \
@@ -56,7 +57,6 @@
gnc-druid-provider-multifile-gnome.c \
gnc-frequency.c \
gnc-general-select.c \
- gnc-gconf-utils.c \
gnc-gnome-utils.c \
gnc-gui-query.c \
gnc-html-history.c \
@@ -108,7 +108,6 @@
gnc-druid-gnome-ui.h \
gnc-frequency.h \
gnc-general-select.h \
- gnc-gconf-utils.h \
gnc-gnome-utils.h \
gnc-gui-query.h \
gnc-html-history.h \
@@ -148,6 +147,7 @@
libgncmod_gnome_utils_la_LDFLAGS = -module
libgncmod_gnome_utils_la_LIBADD = \
+ ${top_builddir}/src/core-utils/libcore-utils.la \
${top_builddir}/src/gnc-module/libgncmodule.la \
${top_builddir}/src/engine/libgncmod-engine.la \
${top_builddir}/src/calculation/libgncmod-calculation.la \
Index: Makefile.am
===================================================================
RCS file: /home/cvs/cvsroot/gnucash/src/import-export/hbci/Makefile.am,v
retrieving revision 1.22.4.9
retrieving revision 1.22.4.10
diff -Lsrc/import-export/hbci/Makefile.am -Lsrc/import-export/hbci/Makefile.am -u -r1.22.4.9 -r1.22.4.10
--- src/import-export/hbci/Makefile.am
+++ src/import-export/hbci/Makefile.am
@@ -45,6 +45,7 @@
libgncmod_hbci_la_LIBADD = \
${top_builddir}/src/gnc-module/libgncmodule.la \
+ ${top_builddir}/src/core-utils/libcore-utils.la \
${top_builddir}/src/engine/libgncmod-engine.la \
${top_builddir}/src/import-export/libgncmod-generic-import.la \
${top_builddir}/src/gnome/libgncgnome.la \
@@ -63,6 +64,7 @@
AM_CFLAGS = \
-I${top_srcdir}/src \
+ -I${top_srcdir}/src/core-utils \
-I${top_srcdir}/src/engine \
-I${top_srcdir}/src/gnc-module \
-I${top_srcdir}/src/app-utils \
Index: Makefile.am
===================================================================
RCS file: /home/cvs/cvsroot/gnucash/src/import-export/ofx/Makefile.am,v
retrieving revision 1.10.4.4
retrieving revision 1.10.4.5
diff -Lsrc/import-export/ofx/Makefile.am -Lsrc/import-export/ofx/Makefile.am -u -r1.10.4.4 -r1.10.4.5
--- src/import-export/ofx/Makefile.am
+++ src/import-export/ofx/Makefile.am
@@ -14,6 +14,7 @@
libgncmod_ofx_la_LDFLAGS = -module
libgncmod_ofx_la_LIBADD = \
+ ${top_builddir}/src/core-utils/libcore-utils.la \
${top_builddir}/src/gnc-module/libgncmodule.la \
${top_builddir}/src/engine/libgncmod-engine.la \
${top_builddir}/src/import-export/libgncmod-generic-import.la \
@@ -23,6 +24,7 @@
AM_CFLAGS = \
-I${top_srcdir}/src \
+ -I${top_srcdir}/src/core-utils \
-I${top_srcdir}/src/engine \
-I${top_srcdir}/src/gnc-module \
-I${top_srcdir}/src/app-utils \
Index: Makefile.am
===================================================================
RCS file: /home/cvs/cvsroot/gnucash/src/import-export/qif-import/Makefile.am,v
retrieving revision 1.21.4.7
retrieving revision 1.21.4.8
diff -Lsrc/import-export/qif-import/Makefile.am -Lsrc/import-export/qif-import/Makefile.am -u -r1.21.4.7 -r1.21.4.8
--- src/import-export/qif-import/Makefile.am
+++ src/import-export/qif-import/Makefile.am
@@ -19,6 +19,7 @@
libgncmod_qif_import_la_LIBADD = \
${top_builddir}/src/import-export/libgncmod-generic-import.la \
+ ${top_builddir}/src/core-utils/libcore-utils.la \
${top_builddir}/src/gnome-utils/libgncmod-gnome-utils.la \
${top_builddir}/src/app-file/libgncmod-app-file.la \
${top_builddir}/src/gnc-module/libgncmodule.la \
@@ -50,6 +51,7 @@
AM_CFLAGS = \
-I${top_srcdir}/src \
+ -I${top_srcdir}/src/core-utils \
-I${top_srcdir}/src/engine \
-I${top_srcdir}/src/gnc-module \
-I${top_srcdir}/src/app-utils \
Index: Makefile.am
===================================================================
RCS file: /home/cvs/cvsroot/gnucash/src/report/report-gnome/Makefile.am,v
retrieving revision 1.14.4.6
retrieving revision 1.14.4.7
diff -Lsrc/report/report-gnome/Makefile.am -Lsrc/report/report-gnome/Makefile.am -u -r1.14.4.6 -r1.14.4.7
--- src/report/report-gnome/Makefile.am
+++ src/report/report-gnome/Makefile.am
@@ -7,6 +7,7 @@
AM_CFLAGS = \
-I${top_srcdir}/src \
+ -I${top_srcdir}/src/core-utils \
-I${top_srcdir}/src/gnc-module \
-I${top_srcdir}/src/engine \
-I${top_srcdir}/src/app-utils \
@@ -39,6 +40,7 @@
libgncmod_report_gnome_la_LDFLAGS = -module
libgncmod_report_gnome_la_LIBADD = \
+ ${top_builddir}/src/core-utils/libcore-utils.la \
${top_builddir}/src/gnc-module/libgncmodule.la \
${top_builddir}/src/gnome-utils/libgncmod-gnome-utils.la \
${top_builddir}/src/app-file/libgncmod-app-file.la \
More information about the gnucash-changes
mailing list