GnuCash
5.6-150-g038405b370+
|
The API in this file is designed to make it easy to use the GSettings system from within Gnucash. More...
Files | |
file | gnc-gsettings.h |
GSettings helper routines. | |
Functions | |
const gchar * | gnc_gsettings_get_prefix (void) |
Get the default gsettings schema prefix. More... | |
void | gnc_gsettings_block_all (void) |
Block all prefs callbacks, used while preference dialog is loaded. | |
void | gnc_gsettings_unblock_all (void) |
UnBlock all prefs callbacks, used while preference dialog is loaded. | |
void | gnc_gsettings_load_backend (void) |
Configure gsettings as the backend for the gnucash preferences api. | |
void | gnc_gsettings_shutdown (void) |
Free the GSettings resources. | |
void | gnc_gsettings_version_upgrade (void) |
Check whether we need to adjust the user settings to a newer version. More... | |
Listening for changes | |
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. More... | |
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. More... | |
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. More... | |
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. More... | |
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. More... | |
void | gnc_gsettings_bind (const gchar *schema, const gchar *key, gpointer object, const gchar *property) |
Bind a setting to a g_object property. More... | |
GSettings Get Functions | |
gboolean | gnc_gsettings_get_bool (const gchar *schema, const gchar *key) |
Get a boolean value from GSettings. More... | |
gint | gnc_gsettings_get_int (const gchar *schema, const gchar *key) |
Get an integer value from GSettings. More... | |
gdouble | gnc_gsettings_get_float (const gchar *schema, const gchar *key) |
Get an float value from GSettings. More... | |
gchar * | gnc_gsettings_get_string (const gchar *schema, const gchar *key) |
Get a string value from GSettings. More... | |
gint | gnc_gsettings_get_enum (const gchar *schema, const gchar *key) |
Get an enum value from GSettings. More... | |
GVariant * | gnc_gsettings_get_value (const gchar *schema, const gchar *key) |
Get an arbitrary combination of values from GSettings. More... | |
GSettings Set/Unset Functions | |
gboolean | gnc_gsettings_set_bool (const gchar *schema, const gchar *key, gboolean value) |
Store a boolean value into GSettings. More... | |
gboolean | gnc_gsettings_set_int (const gchar *schema, const gchar *key, gint value) |
Store an integer value into GSettings. More... | |
gboolean | gnc_gsettings_set_float (const gchar *schema, const gchar *key, gdouble value) |
Store a float value into GSettings. More... | |
gboolean | gnc_gsettings_set_string (const gchar *schema, const gchar *key, const gchar *value) |
Store a string into GSettings. More... | |
gboolean | gnc_gsettings_set_enum (const gchar *schema, const gchar *key, gint value) |
Store an enum value into GSettings. More... | |
gboolean | gnc_gsettings_set_value (const gchar *schema, const gchar *key, GVariant *value) |
Store an arbitrary combination of values into GSettings. More... | |
void | gnc_gsettings_reset (const gchar *schema, const gchar *key) |
Reset a key to its default value in GSettings. More... | |
void | gnc_gsettings_reset_schema (const gchar *schema) |
Reset all keys in a schema to their default values in GSettings. More... | |
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
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.
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.
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. |
key | This string is the name of the particular key within the named schema of gsettings. |
object | The object to be bound. |
property | The property of the object to bind to. |
Definition at line 282 of file gnc-gsettings.cpp.
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.
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. |
key | This string is the name of the particular key within the named schema of gsettings. |
Definition at line 352 of file gnc-gsettings.cpp.
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.
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. |
key | This string is the name of the particular key within the named schema of gsettings. |
Definition at line 378 of file gnc-gsettings.cpp.
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.
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. |
key | This string is the name of the particular key within the named schema of gsettings. |
Definition at line 365 of file gnc-gsettings.cpp.
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.
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. |
key | This string is the name of the particular key within the named schema of gsettings. |
Definition at line 359 of file gnc-gsettings.cpp.
const gchar* gnc_gsettings_get_prefix | ( | void | ) |
Get the default gsettings schema prefix.
If none was set explicitly, this defaults to "org.gnucash.GnuCash"
Definition at line 147 of file gnc-gsettings.cpp.
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.
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. |
key | This string is the name of the particular key within the named schema of gsettings. |
Definition at line 371 of file gnc-gsettings.cpp.
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.
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. |
key | This string is the name of the particular key within the named schema of gsettings. |
Definition at line 384 of file gnc-gsettings.cpp.
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.
schema | This value contains the name of the schema that is being watched. |
func | This is a pointer to the function to call when a key changes. |
user_data | This pointer will be passed to the callback function. |
Definition at line 265 of file gnc-gsettings.cpp.
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.
schema | This value contains the schema name of the key to watch. |
key | This value contains the name of the key to watch. |
func | This is a pointer to the function to call when the key changes. |
user_data | This pointer will be passed to the callback function. |
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.
schema | This value contains the name of the schema that is being watched. |
func | This is a pointer to the function that was registered earlier. |
user_data | This pointer was passed to the callback function when it was registered. |
Definition at line 274 of file gnc-gsettings.cpp.
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.
schema | This value contains the schema name of the key that is being watched. |
key | This value contains the name of the key being watched. |
func | This is a pointer to the function that was registered earlier. |
user_data | This pointer was passed to the callback function when it was registered. |
Definition at line 203 of file gnc-gsettings.cpp.
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.
schema | This value contains the schema name of the key that is being watched. |
id | The handler id of the callback to be removed. |
Definition at line 245 of file gnc-gsettings.cpp.
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.
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. |
key | This string is the name of the particular key within the named schema of gsettings. |
Definition at line 456 of file gnc-gsettings.cpp.
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.
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. |
Definition at line 471 of file gnc-gsettings.cpp.
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.
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. |
key | This string is the name of the particular key within the named schema of gsettings. |
value | The boolean value to be stored. |
Definition at line 420 of file gnc-gsettings.cpp.
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.
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. |
key | This string is the name of the particular key within the named schema of gsettings. |
value | The enum number to be stored. |
Definition at line 444 of file gnc-gsettings.cpp.
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.
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. |
key | This string is the name of the particular key within the named schema of gsettings. |
value | The floating point number to be stored. |
Definition at line 432 of file gnc-gsettings.cpp.
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.
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. |
key | This string is the name of the particular key within the named schema of gsettings. |
value | The integer number to be stored. |
Definition at line 426 of file gnc-gsettings.cpp.
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.
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. |
key | This string is the name of the particular key within the named schema of gsettings. |
value | The 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). |
Definition at line 438 of file gnc-gsettings.cpp.
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.
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. |
key | This string is the name of the particular key within the named schema of gsettings. |
value | The combination of values encapsulated in a GVariant to be stored. |
Definition at line 450 of file gnc-gsettings.cpp.
void gnc_gsettings_version_upgrade | ( | void | ) |
Check whether we need to adjust the user settings to a newer version.
New version of GnuCash may come with changes in the settings schema. This function will take the necessary steps to convert old settings to new (when possible).
Definition at line 723 of file gnc-gsettings.cpp.