GnuCash  2.6.99
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Files | Macros | Functions
GSettings Utilities

Files

file  gnc-gsettings.h
 GSettings helper routines.
 

Macros

#define GSET_SCHEMA_PREFIX   "org.gnucash"
 

Functions

gchar * gnc_gsettings_normalize_schema_name (const gchar *name)
 
void gnc_gsettings_set_prefix (const gchar *prefix)
 
const gchar * gnc_gsettings_get_prefix (void)
 
void gnc_gsettings_load_backend (void)
 
void gnc_gsettings_migrate_from_gconf (void)
 

Listening for changes

gulong gnc_gsettings_register_cb (const char *schema, const gchar *key, gpointer func, gpointer user_data)
 
void gnc_gsettings_remove_cb_by_func (const gchar *schema, const gchar *key, gpointer func, gpointer user_data)
 
void gnc_gsettings_remove_cb_by_id (const gchar *schema, guint id)
 
guint gnc_gsettings_register_any_cb (const gchar *schema, gpointer func, gpointer user_data)
 
void gnc_gsettings_remove_any_cb_by_func (const gchar *schema, gpointer func, gpointer user_data)
 
void gnc_gsettings_bind (const gchar *schema, const gchar *key, gpointer object, const gchar *property)
 

GSettings Get Functions

gboolean gnc_gsettings_get_bool (const gchar *schema, const gchar *key)
 
gint gnc_gsettings_get_int (const gchar *schema, const gchar *key)
 
gdouble gnc_gsettings_get_float (const gchar *schema, const gchar *key)
 
gchar * gnc_gsettings_get_string (const gchar *schema, const gchar *key)
 
gint gnc_gsettings_get_enum (const gchar *schema, const gchar *key)
 
GVariant * gnc_gsettings_get_value (const gchar *schema, const gchar *key)
 

GSettings Set/Unset Functions

gboolean gnc_gsettings_set_bool (const gchar *schema, const gchar *key, gboolean value)
 
gboolean gnc_gsettings_set_int (const gchar *schema, const gchar *key, gint value)
 
gboolean gnc_gsettings_set_float (const gchar *schema, const gchar *key, gdouble value)
 
gboolean gnc_gsettings_set_string (const gchar *schema, const gchar *key, const gchar *value)
 
gboolean gnc_gsettings_set_enum (const gchar *schema, const gchar *key, gint value)
 
gboolean gnc_gsettings_set_value (const gchar *schema, const gchar *key, GVariant *value)
 
void gnc_gsettings_reset (const gchar *schema, const gchar *key)
 
void gnc_gsettings_reset_schema (const gchar *schema)
 

Detailed Description

The API in this file is designed to make it easy to use the GSettings system from within Gnucash. GSettings is a shared key/value storage system.

The main benefits of these routines are that they

  1. maintain a list of GSettings objects (one per schema),
  2. convert gnucash internal schema names into full gsettings schema id's, and
  3. 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.

Function Documentation

void gnc_gsettings_bind ( const gchar *  schema,
const gchar *  key,
gpointer  object,
const gchar *  property 
)

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.

Parameters
schemaThis 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.
keyThis string is the name of the particular key within the named schema of gsettings.
objectThe object to be bound.
propertyThe property of the object to bind to.

Definition at line 254 of file gnc-gsettings.c.

258 {
259  GSettings *schema_ptr = gnc_gsettings_get_schema_ptr (schema);
260  g_return_if_fail (G_IS_SETTINGS (schema_ptr));
261 
262  if (gnc_gsettings_is_valid_key (schema_ptr, key))
263  g_settings_bind (schema_ptr, key, object, property, 0);
264  else
265  {
266  PERR ("Invalid key %s for schema %s", key, schema);
267  }
268 }
#define PERR(format, args...)
Definition: qoflog.h:237
gboolean gnc_gsettings_get_bool ( const gchar *  schema,
const gchar *  key 
)

Get a boolean value from GSettings.

Retrieve a TRUE/FALSE value from GSettings. The schema name provided as argument is combined with the default gnucash schema prefix to produce a fully qualified schema name.

Parameters
schemaThis 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.
keyThis string is the name of the particular key within the named schema of gsettings.
Returns
This function returns the TRUE or FALSE value stored at the requested key in the gsettings database. If the key has never been set, this function passes on the default value returned by GSettings as specified in the schema for this key.

Definition at line 275 of file gnc-gsettings.c.

277 {
278  GSettings *schema_ptr = gnc_gsettings_get_schema_ptr (schema);
279  g_return_val_if_fail (G_IS_SETTINGS (schema_ptr), FALSE);
280 
281  if (gnc_gsettings_is_valid_key (schema_ptr, key))
282  return g_settings_get_boolean (schema_ptr, key);
283  else
284  {
285  PERR ("Invalid key %s for schema %s", key, schema);
286  return FALSE;
287  }
288 }
#define PERR(format, args...)
Definition: qoflog.h:237
gint gnc_gsettings_get_enum ( const gchar *  schema,
const gchar *  key 
)

Get an enum value from GSettings.

Retrieve an enum value from GSettings. The schema name provided as argument is combined with the default gnucash schema prefix to produce a fully qualified schema name.

Parameters
schemaThis 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.
keyThis string is the name of the particular key within the named schema of gsettings.
Returns
This function returns the enum value stored at the requested key in the gsettings database. If the key has never been set, this function passes on the default value returned by GSettings 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 GSettings.

Definition at line 427 of file gnc-gsettings.c.

429 {
430  GSettings *schema_ptr = gnc_gsettings_get_schema_ptr (schema);
431  g_return_val_if_fail (G_IS_SETTINGS (schema_ptr), 0);
432 
433  if (gnc_gsettings_is_valid_key (schema_ptr, key))
434  return g_settings_get_enum (schema_ptr, key);
435  else
436  {
437  PERR ("Invalid key %s for schema %s", key, schema);
438  return 0;
439  }
440 }
#define PERR(format, args...)
Definition: qoflog.h:237
gdouble gnc_gsettings_get_float ( const gchar *  schema,
const gchar *  key 
)

Get an float value from GSettings.

Retrieve an float value from GSettings. The schema name provided as argument is combined with the default gnucash schema prefix to produce a fully qualified schema name.

Parameters
schemaThis 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.
keyThis string is the name of the particular key within the named schema of gsettings.
Returns
This function returns the float value stored at the requested key in the gsettings database. If the key has never been set, this function passes on the default value returned by GSettings 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 GSettings.

Definition at line 351 of file gnc-gsettings.c.

353 {
354  GSettings *schema_ptr = gnc_gsettings_get_schema_ptr (schema);
355  g_return_val_if_fail (G_IS_SETTINGS (schema_ptr), 0);
356 
357  if (gnc_gsettings_is_valid_key (schema_ptr, key))
358  return g_settings_get_double (schema_ptr, key);
359  else
360  {
361  PERR ("Invalid key %s for schema %s", key, schema);
362  return 0;
363  }
364 }
#define PERR(format, args...)
Definition: qoflog.h:237
gint gnc_gsettings_get_int ( const gchar *  schema,
const gchar *  key 
)

Get an integer value from GSettings.

Retrieve an integer value from GSettings. The schema name provided as argument is combined with the default gnucash schema prefix to produce a fully qualified schema name.

Parameters
schemaThis 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.
keyThis string is the name of the particular key within the named schema of gsettings.
Returns
This function returns the integer value stored at the requested key in the gsettings database. If the key has never been set, this function passes on the default value returned by GSettings 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 GSettings.

Definition at line 314 of file gnc-gsettings.c.

316 {
317  GSettings *schema_ptr = gnc_gsettings_get_schema_ptr (schema);
318  g_return_val_if_fail (G_IS_SETTINGS (schema_ptr), 0);
319 
320  if (gnc_gsettings_is_valid_key (schema_ptr, key))
321  return g_settings_get_int (schema_ptr, key);
322  else
323  {
324  PERR ("Invalid key %s for schema %s", key, schema);
325  return 0;
326  }
327 }
#define PERR(format, args...)
Definition: qoflog.h:237
const gchar* gnc_gsettings_get_prefix ( void  )

Get the default gsettings schema prefix. If none was set explicitly, this defaults to "org.gnucash"

Definition at line 128 of file gnc-gsettings.c.

129 {
130  if (!gsettings_prefix)
131  {
132  const char *prefix = g_getenv("GNC_GSETTINGS_PREFIX");
133  if (prefix)
134  gsettings_prefix = prefix;
135  else
136  gsettings_prefix = GSET_SCHEMA_PREFIX;
137  }
138  return gsettings_prefix;
139 }
gchar* gnc_gsettings_get_string ( const gchar *  schema,
const gchar *  key 
)

Get a string value from GSettings.

Retrieve an string value from GSettings. The schema name provided as argument is combined with the default gnucash schema prefix to produce a fully qualified schema name.

Parameters
schemaThis 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.
keyThis string is the name of the particular key within the named schema of gsettings.
Returns
This function returns the string value stored at the requested key in the gsettings database. If the key has never been set, this function passes on the default value returned by GSettings 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 GSettings. It is the callers responsibility to free any string returned by this function.

Definition at line 388 of file gnc-gsettings.c.

390 {
391  GSettings *schema_ptr = gnc_gsettings_get_schema_ptr (schema);
392  g_return_val_if_fail (G_IS_SETTINGS (schema_ptr), NULL);
393 
394  if (gnc_gsettings_is_valid_key (schema_ptr, key))
395  return g_settings_get_string (schema_ptr, key);
396  else
397  {
398  PERR ("Invalid key %s for schema %s", key, schema);
399  return NULL;
400  }
401 }
#define PERR(format, args...)
Definition: qoflog.h:237
GVariant* gnc_gsettings_get_value ( const gchar *  schema,
const gchar *  key 
)

Get an arbitrary combination of values from GSettings.

Retrieve an arbitrary combination of values from GSettings. This combination of values can be anything that can be encapsulated in a GVariant structure. The schema name provided as argument is combined with the default gnucash schema prefix to produce a fully qualified schema name.

Parameters
schemaThis 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.
keyThis string is the name of the particular key within the named schema of gsettings.
Returns
This function returns the a GVariant encapsulating the combination of values stored at the requested key in the gsettings database. If the key has never been set, this function passes on the default value returned by GSettings 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 GSettings. It is the callers responsibility to free any GVariant data returned by this function.

Definition at line 464 of file gnc-gsettings.c.

466 {
467  GSettings *schema_ptr = gnc_gsettings_get_schema_ptr (schema);
468  g_return_val_if_fail (G_IS_SETTINGS (schema_ptr), NULL);
469 
470  if (gnc_gsettings_is_valid_key (schema_ptr, key))
471  return g_settings_get_value (schema_ptr, key);
472  else
473  {
474  PERR ("Invalid key %s for schema %s", key, schema);
475  return NULL;
476  }
477 }
#define PERR(format, args...)
Definition: qoflog.h:237
void gnc_gsettings_load_backend ( void  )

Configure gsettings as the backend for the gnucash preferences api.

Definition at line 533 of file gnc-gsettings.c.

534 {
535  ENTER("");
536 
537  /* The gsettings backend only works in an installed environment.
538  * When called from the source environment (for testing purposes)
539  * simply return.
540  */
541  if (g_strcmp0 (g_getenv ("GNC_UNINSTALLED"), "1") == 0)
542  return;
543 
544  if (!prefsbackend)
545  prefsbackend = g_new0 (PrefsBackend, 1);
546 
547  prefsbackend->register_cb = gnc_gsettings_register_cb;
548  prefsbackend->remove_cb_by_func = gnc_gsettings_remove_cb_by_func;
549  prefsbackend->remove_cb_by_id = gnc_gsettings_remove_cb_by_id;
550  prefsbackend->register_group_cb = gnc_gsettings_register_any_cb;
551  prefsbackend->remove_group_cb_by_func = gnc_gsettings_remove_any_cb_by_func;
552  prefsbackend->bind = gnc_gsettings_bind;
553  prefsbackend->get_bool = gnc_gsettings_get_bool;
554  prefsbackend->get_int = gnc_gsettings_get_int;
555  prefsbackend->get_float = gnc_gsettings_get_float;
556  prefsbackend->get_string = gnc_gsettings_get_string;
557  prefsbackend->get_enum = gnc_gsettings_get_enum;
558  prefsbackend->get_value = gnc_gsettings_get_value;
559  prefsbackend->set_bool = gnc_gsettings_set_bool;
560  prefsbackend->set_int = gnc_gsettings_set_int;
561  prefsbackend->set_float = gnc_gsettings_set_float;
562  prefsbackend->set_string = gnc_gsettings_set_string;
563  prefsbackend->set_enum = gnc_gsettings_set_enum;
564  prefsbackend->set_value = gnc_gsettings_set_value;
565  prefsbackend->reset = gnc_gsettings_reset;
566  prefsbackend->reset_group = gnc_gsettings_reset_schema;
567 
568  LEAVE("Prefsbackend bind = %p", prefsbackend->bind);
569 }
gboolean gnc_gsettings_set_int(const gchar *schema, const gchar *key, gint value)
gboolean gnc_gsettings_set_float(const gchar *schema, const gchar *key, gdouble value)
gint gnc_gsettings_get_int(const gchar *schema, const gchar *key)
void gnc_gsettings_bind(const gchar *schema, const gchar *key, gpointer object, const gchar *property)
#define ENTER(format, args...)
Definition: qoflog.h:261
void gnc_gsettings_remove_any_cb_by_func(const gchar *schema, gpointer func, gpointer user_data)
gboolean gnc_gsettings_set_enum(const gchar *schema, const gchar *key, gint value)
GVariant * gnc_gsettings_get_value(const gchar *schema, const gchar *key)
guint gnc_gsettings_register_any_cb(const gchar *schema, gpointer func, gpointer user_data)
void gnc_gsettings_reset_schema(const gchar *schema)
gdouble gnc_gsettings_get_float(const gchar *schema, const gchar *key)
void gnc_gsettings_reset(const gchar *schema, const gchar *key)
gchar * gnc_gsettings_get_string(const gchar *schema, const gchar *key)
gint gnc_gsettings_get_enum(const gchar *schema, const gchar *key)
gboolean gnc_gsettings_set_bool(const gchar *schema, const gchar *key, gboolean value)
#define LEAVE(format, args...)
Definition: qoflog.h:271
gboolean gnc_gsettings_get_bool(const gchar *schema, const gchar *key)
void gnc_gsettings_remove_cb_by_id(const gchar *schema, guint handlerid)
gboolean gnc_gsettings_set_value(const gchar *schema, const gchar *key, GVariant *value)
gulong gnc_gsettings_register_cb(const char *schema, const gchar *key, gpointer func, gpointer user_data)
gboolean gnc_gsettings_set_string(const gchar *schema, const gchar *key, const gchar *value)
void gnc_gsettings_remove_cb_by_func(const gchar *schema, const gchar *key, gpointer func, gpointer user_data)
gchar* gnc_gsettings_normalize_schema_name ( const gchar *  name)

Convert a partial schema name into a complete gsettings schema name.

This function takes a partial gsettings schema name and converts it into a fully qualified gsettings schema name. It does this by prepending the standard prefix for all gnucash schemas. If the schema is already fully qualified (i.e. begins with the default schema prefix, this routine will not change it.

Parameters
nameA partial schema name. The default prefix is prepended to this name to produce a fully qualified schema name.
Returns
This function returns a string pointer to the fully qualified schema name. It is the caller's responsibility to free this string.

Definition at line 142 of file gnc-gsettings.c.

143 {
144  if (name == NULL)
145  {
146  /* Need to return a newly allocated string */
147  return g_strdup(gnc_gsettings_get_prefix());
148  }
149  if (g_str_has_prefix (name, gnc_gsettings_get_prefix ()))
150  {
151  /* Need to return a newly allocated string */
152  return g_strdup(name);
153  }
154 
155  return g_strjoin(".", gnc_gsettings_get_prefix(), name, NULL);
156 }
const gchar * gnc_gsettings_get_prefix(void)
guint gnc_gsettings_register_any_cb ( const gchar *  schema,
gpointer  func,
gpointer  user_data 
)

Register a callback for when any key in the settings schema is changed. Any time the value of a key in this schema changes, the routine will be invoked and will be passed the specified user data.

Parameters
schemaThis value contains the name of the schema that is being watched.
funcThis is a pointer to the function to call when a key changes.
user_dataThis pointer will be passed to the callback function.

Definition at line 237 of file gnc-gsettings.c.

240 {
241  return gnc_gsettings_register_cb (schema, NULL, func, user_data);
242 }
gulong gnc_gsettings_register_cb(const char *schema, const gchar *key, gpointer func, gpointer user_data)
gulong gnc_gsettings_register_cb ( const char *  schema,
const gchar *  key,
gpointer  func,
gpointer  user_data 
)

Register a callback for when a specific key in the settings schema is changed. Any time the key's value changes, the routine will be invoked and will be passed both the changed gsettings entry and the user data passed to this function.

Parameters
schemaThis value contains the schema name of the key to watch.
keyThis value contains the name of the key to watch.
funcThis is a pointer to the function to call when the key changes.
user_dataThis pointer will be passed to the callback function.
Returns
This function returns the handler id for the registered callback.
void gnc_gsettings_remove_any_cb_by_func ( const gchar *  schema,
gpointer  func,
gpointer  user_data 
)

Remove a function that was registered for a callback when any key in the given settings schema 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 key, nothing will happen.

Parameters
schemaThis value contains the name of the schema that is being watched.
funcThis is a pointer to the function that was registered earlier.
user_dataThis 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.

Definition at line 246 of file gnc-gsettings.c.

249 {
250  gnc_gsettings_remove_cb_by_func (schema, NULL, func, user_data);
251 }
void gnc_gsettings_remove_cb_by_func(const gchar *schema, const gchar *key, gpointer func, gpointer user_data)
void gnc_gsettings_remove_cb_by_func ( const gchar *  schema,
const gchar *  key,
gpointer  func,
gpointer  user_data 
)

Remove a function that was registered for a callback when a specific key in the settings schema 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 key, nothing will happen.

Parameters
schemaThis value contains the schema name of the key that is being watched.
keyThis value contains the name of the key being watched.
funcThis is a pointer to the function that was registered earlier.
user_dataThis pointer was passed to the callback function when it was registered.

Definition at line 196 of file gnc-gsettings.c.

200 {
201  gint matched = 0;
202  GQuark quark = 0;
203 
204  GSettings *schema_ptr = gnc_gsettings_get_schema_ptr (schema);
205  g_return_if_fail (G_IS_SETTINGS (schema_ptr));
206  g_return_if_fail (func);
207 
208  ENTER ();
209 
210  if ((key) && (gnc_gsettings_is_valid_key(schema_ptr, key)))
211  quark = g_quark_from_string (key);
212 
213  matched = g_signal_handlers_disconnect_matched (
214  schema_ptr,
215  G_SIGNAL_MATCH_DETAIL | G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA,
216  g_signal_lookup ("changed", G_TYPE_SETTINGS), /* signal_id */
217  quark, /* signal_detail */
218  NULL, /* closure */
219  G_CALLBACK (func), /* callback function */
220  user_data);
221  LEAVE ("Schema: %s, key: %s - removed %d handlers for 'changed' signal", schema, key, matched);
222 }
#define ENTER(format, args...)
Definition: qoflog.h:261
#define LEAVE(format, args...)
Definition: qoflog.h:271
void gnc_gsettings_remove_cb_by_id ( const gchar *  schema,
guint  id 
)

Remove a function that was registered for a callback when a specific key in the settings schema 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.

Parameters
schemaThis value contains the schema name of the key that is being watched.
idThe handler id of the callback to be removed.

Definition at line 226 of file gnc-gsettings.c.

228 {
229  GSettings *schema_ptr = gnc_gsettings_get_schema_ptr (schema);
230  g_return_if_fail (G_IS_SETTINGS (schema_ptr));
231 
232  g_signal_handler_disconnect (schema_ptr, handlerid);
233 }
void gnc_gsettings_reset ( const gchar *  schema,
const gchar *  key 
)

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.

Parameters
schemaThis 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.
keyThis string is the name of the particular key within the named schema of gsettings.

Definition at line 501 of file gnc-gsettings.c.

503 {
504  GSettings *schema_ptr = gnc_gsettings_get_schema_ptr (schema);
505  g_return_if_fail (G_IS_SETTINGS (schema_ptr));
506 
507  if (gnc_gsettings_is_valid_key (schema_ptr, key))
508  g_settings_reset (schema_ptr, key);
509  else
510  PERR ("Invalid key %s for schema %s", key, schema);
511 }
#define PERR(format, args...)
Definition: qoflog.h:237
void gnc_gsettings_reset_schema ( const gchar *  schema)

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.

Parameters
schemaThis 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.

Definition at line 514 of file gnc-gsettings.c.

515 {
516  gchar **keys;
517  gint counter = 0;
518 
519  keys = g_settings_list_keys (gnc_gsettings_get_schema_ptr (schema));
520 
521  if (!keys)
522  return;
523 
524  while (keys[counter])
525  {
526  gnc_gsettings_reset (schema, keys[counter]);
527  counter++;
528  }
529 
530  g_strfreev (keys);
531 }
void gnc_gsettings_reset(const gchar *schema, const gchar *key)
gboolean gnc_gsettings_set_bool ( const gchar *  schema,
const gchar *  key,
gboolean  value 
)

Store a boolean value into GSettings.

Store a boolean value into GSettings. The schema name provided as argument is combined with the default gnucash schema prefix to produce a fully qualified schema name.

Parameters
schemaThis 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.
keyThis string is the name of the particular key within the named schema of gsettings.
valueThe boolean value to be stored.
Returns
This function returns true if the value was set successfully on the key or false if not.

Definition at line 291 of file gnc-gsettings.c.

294 {
295  gboolean result = FALSE;
296  GSettings *schema_ptr = gnc_gsettings_get_schema_ptr (schema);
297  g_return_val_if_fail (G_IS_SETTINGS (schema_ptr), FALSE);
298 
299  ENTER("schema: %s, key: %s", schema, key);
300  if (gnc_gsettings_is_valid_key (schema_ptr, key))
301  {
302  result = g_settings_set_boolean (schema_ptr, key, value);
303  if (!result)
304  PERR ("Unable to set value for key %s in schema %s", key, schema);
305  }
306  else
307  PERR ("Invalid key %s for schema %s", key, schema);
308 
309  LEAVE("result %i", result);
310  return result;
311 }
#define PERR(format, args...)
Definition: qoflog.h:237
#define ENTER(format, args...)
Definition: qoflog.h:261
#define LEAVE(format, args...)
Definition: qoflog.h:271
gboolean gnc_gsettings_set_enum ( const gchar *  schema,
const gchar *  key,
gint  value 
)

Store an enum value into GSettings.

Store an enum into GSettings. The schema name provided as argument is combined with the default gnucash schema prefix to produce a fully qualified schema name.

Parameters
schemaThis 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.
keyThis string is the name of the particular key within the named schema of gsettings.
valueThe enum number to be stored.
Returns
This function returns true if the value was set successfully on the key or false if not.

Definition at line 443 of file gnc-gsettings.c.

446 {
447  gboolean result = FALSE;
448  GSettings *schema_ptr = gnc_gsettings_get_schema_ptr (schema);
449  g_return_val_if_fail (G_IS_SETTINGS (schema_ptr), FALSE);
450 
451  if (gnc_gsettings_is_valid_key (schema_ptr, key))
452  {
453  result = g_settings_set_enum (schema_ptr, key, value);
454  if (!result)
455  PERR ("Unable to set value for key %s in schema %s", key, schema);
456  }
457  else
458  PERR ("Invalid key %s for schema %s", key, schema);
459 
460  return result;
461 }
#define PERR(format, args...)
Definition: qoflog.h:237
gboolean gnc_gsettings_set_float ( const gchar *  schema,
const gchar *  key,
gdouble  value 
)

Store a float value into GSettings.

Store a float into GSettings. The schema name provided as argument is combined with the default gnucash schema prefix to produce a fully qualified schema name.

Parameters
schemaThis 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.
keyThis string is the name of the particular key within the named schema of gsettings.
valueThe floating point number to be stored.
Returns
This function returns true if the value was set successfully on the key or false if not.

Definition at line 367 of file gnc-gsettings.c.

370 {
371  gboolean result = FALSE;
372  GSettings *schema_ptr = gnc_gsettings_get_schema_ptr (schema);
373  g_return_val_if_fail (G_IS_SETTINGS (schema_ptr), FALSE);
374 
375  if (gnc_gsettings_is_valid_key (schema_ptr, key))
376  {
377  result = g_settings_set_double (schema_ptr, key, value);
378  if (!result)
379  PERR ("Unable to set value for key %s in schema %s", key, schema);
380  }
381  else
382  PERR ("Invalid key %s for schema %s", key, schema);
383 
384  return result;
385 }
#define PERR(format, args...)
Definition: qoflog.h:237
gboolean gnc_gsettings_set_int ( const gchar *  schema,
const gchar *  key,
gint  value 
)

Store an integer value into GSettings.

Store an integer into GSettings. The schema name provided as argument is combined with the default gnucash schema prefix to produce a fully qualified schema name.

Parameters
schemaThis 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.
keyThis string is the name of the particular key within the named schema of gsettings.
valueThe integer number to be stored.
Returns
This function returns true if the value was set successfully on the key or false if not.

Definition at line 330 of file gnc-gsettings.c.

333 {
334  gboolean result = FALSE;
335  GSettings *schema_ptr = gnc_gsettings_get_schema_ptr (schema);
336  g_return_val_if_fail (G_IS_SETTINGS (schema_ptr), FALSE);
337 
338  if (gnc_gsettings_is_valid_key (schema_ptr, key))
339  {
340  result = g_settings_set_int (schema_ptr, key, value);
341  if (!result)
342  PERR ("Unable to set value for key %s in schema %s", key, schema);
343  }
344  else
345  PERR ("Invalid key %s for schema %s", key, schema);
346 
347  return result;
348 }
#define PERR(format, args...)
Definition: qoflog.h:237
void gnc_gsettings_set_prefix ( const gchar *  prefix)

Set the default gsettings schema prefix. This is used to generate complete schema id's if only partial id's are passed.

Definition at line 122 of file gnc-gsettings.c.

123 {
124  gsettings_prefix = prefix;
125 }
gboolean gnc_gsettings_set_string ( const gchar *  schema,
const gchar *  key,
const gchar *  value 
)

Store a string into GSettings.

Store a single string into GSettings. The schema name provided as argument is combined with the default gnucash schema prefix to produce a fully qualified schema name.

Parameters
schemaThis 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.
keyThis string is the name of the particular key within the named schema of gsettings.
valueThe string to be stored. GSettings will make a copy of this string, so it is the callers responsibility to free the space used by this string (if necessary).
Returns
This function returns true if the value was set successfully on the key or false if not.

Definition at line 404 of file gnc-gsettings.c.

407 {
408  gboolean result = FALSE;
409  GSettings *schema_ptr = gnc_gsettings_get_schema_ptr (schema);
410  g_return_val_if_fail (G_IS_SETTINGS (schema_ptr), FALSE);
411 
412  ENTER("schema: %s, key: %s", schema, key);
413  if (gnc_gsettings_is_valid_key (schema_ptr, key))
414  {
415  result = g_settings_set_string (schema_ptr, key, value);
416  if (!result)
417  PERR ("Unable to set value for key %s in schema %s", key, schema);
418  }
419  else
420  PERR ("Invalid key %s for schema %s", key, schema);
421 
422  LEAVE("result %i", result);
423  return result;
424 }
#define PERR(format, args...)
Definition: qoflog.h:237
#define ENTER(format, args...)
Definition: qoflog.h:261
#define LEAVE(format, args...)
Definition: qoflog.h:271
gboolean gnc_gsettings_set_value ( const gchar *  schema,
const gchar *  key,
GVariant *  value 
)

Store an arbitrary combination of values into GSettings.

Store an arbitrary combination of values into GSettings. This combination of values can be anything that can be encapsulated in a GVariant structure. The schema name provided as argument is combined with the default gnucash schema prefix to produce a fully qualified schema name.

Parameters
schemaThis 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.
keyThis string is the name of the particular key within the named schema of gsettings.
valueThe combination of values encapsulated in a GVariant to be stored.
Returns
This function returns true if the value was set successfully on the key or false if not.

Definition at line 480 of file gnc-gsettings.c.

483 {
484  gboolean result = FALSE;
485  GSettings *schema_ptr = gnc_gsettings_get_schema_ptr (schema);
486  g_return_val_if_fail (G_IS_SETTINGS (schema_ptr), FALSE);
487 
488  if (gnc_gsettings_is_valid_key (schema_ptr, key))
489  {
490  result = g_settings_set_value (schema_ptr, key, value);
491  if (!result)
492  PERR ("Unable to set value for key %s in schema %s", key, schema);
493  }
494  else
495  PERR ("Invalid key %s for schema %s", key, schema);
496 
497  return result;
498 }
#define PERR(format, args...)
Definition: qoflog.h:237