r23220 - gnucash/trunk/src/app-utils - GSettings: add functions to unset a key or complete schema
Geert Janssens
gjanssens at code.gnucash.org
Mon Oct 7 10:05:15 EDT 2013
Author: gjanssens
Date: 2013-10-07 10:05:14 -0400 (Mon, 07 Oct 2013)
New Revision: 23220
Trac: http://svn.gnucash.org/trac/changeset/23220
Modified:
gnucash/trunk/src/app-utils/gnc-gsettings.c
gnucash/trunk/src/app-utils/gnc-gsettings.h
Log:
GSettings: add functions to unset a key or complete schema
Modified: gnucash/trunk/src/app-utils/gnc-gsettings.c
===================================================================
--- gnucash/trunk/src/app-utils/gnc-gsettings.c 2013-10-07 14:05:02 UTC (rev 23219)
+++ gnucash/trunk/src/app-utils/gnc-gsettings.c 2013-10-07 14:05:14 UTC (rev 23220)
@@ -447,3 +447,36 @@
return result;
}
+
+void
+gnc_gsettings_reset (const gchar *schema,
+ const gchar *key)
+{
+ GSettings *schema_ptr = gnc_gsettings_get_schema_ptr (schema);
+ g_return_if_fail (G_IS_SETTINGS (schema_ptr));
+
+ if (gnc_gsettings_is_valid_key (schema_ptr, key))
+ g_settings_reset (schema_ptr, key);
+ else
+ PERR ("Invalid key %s for schema %s", key, schema);
+}
+
+void
+gnc_gsettings_reset_schema (const gchar *schema)
+{
+ gchar **keys;
+ gint counter = 0;
+
+ keys = g_settings_list_keys (gnc_gsettings_get_schema_ptr (schema));
+
+ if (!keys)
+ return;
+
+ while (keys[counter])
+ {
+ gnc_gsettings_reset (schema, keys[counter]);
+ counter++;
+ }
+
+ g_strfreev (keys);
+}
Modified: gnucash/trunk/src/app-utils/gnc-gsettings.h
===================================================================
--- gnucash/trunk/src/app-utils/gnc-gsettings.h 2013-10-07 14:05:02 UTC (rev 23219)
+++ gnucash/trunk/src/app-utils/gnc-gsettings.h 2013-10-07 14:05:14 UTC (rev 23220)
@@ -547,6 +547,46 @@
const gchar *key,
GVariant *value);
+/** Reset a key to its default value in GSettings.
+ *
+ * Reset a key to its default value in GSettings. Internally this
+ * is done by removing the value from the database. The next attempt
+ * to read this value will return the default as specified in the
+ * GSettings schema for this key. The schema name
+ * provided as argument is combined with the default gnucash schema
+ * prefix to produce a fully qualified schema name.
+ *
+ * @param schema This string provides a grouping of keys within the
+ * GnuCash schema of the gsettings 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 key This string is the name of the particular key within
+ * the named schema of gsettings.
+ */
+void gnc_gsettings_reset (const gchar *schema,
+ const gchar *key);
+
+/** Reset all keys in a schema to their default values in GSettings.
+ *
+ * Reset a keys in schema to their default values in GSettings. Internally
+ * this is done by removing the values from the database. The next attempt
+ * to read a keys will return its default as specified in the
+ * GSettings schema for this key. The schema name
+ * provided as argument is combined with the default gnucash schema
+ * prefix to produce a fully qualified schema name.
+ *
+ * @param schema This string provides a grouping of keys within the
+ * GnuCash schema of the gsettings 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.
+ */
+void gnc_gsettings_reset_schema (const gchar *schema);
+
/** @} */
More information about the gnucash-changes
mailing list