28 #include "gnc-prefs-p.h" 31 static gchar *namespace_regexp = NULL;
32 static gboolean is_debugging = FALSE;
33 static gboolean extras_enabled = FALSE;
34 static gboolean use_compression = TRUE;
35 static gint file_retention_policy = 1;
36 static gint file_retention_days = 30;
41 static gulong reg_auto_raise_lists_id;
42 static gulong reg_negative_color_pref_id;
47 gnc_prefs_get_namespace_regexp(
void)
49 return namespace_regexp;
53 gnc_prefs_set_namespace_regexp(
const gchar *str)
56 g_free(namespace_regexp);
59 namespace_regexp = g_strdup(str);
63 gnc_prefs_is_debugging_enabled(
void)
69 gnc_prefs_set_debugging(gboolean d)
75 gnc_prefs_is_extra_enabled(
void)
77 return extras_enabled;
81 gnc_prefs_set_extra(gboolean enabled)
83 extras_enabled = enabled;
87 gnc_prefs_get_file_save_compressed(
void)
89 return use_compression;
93 gnc_prefs_set_file_save_compressed(gboolean compressed)
95 use_compression = compressed;
99 gnc_prefs_get_file_retention_policy(
void)
101 return file_retention_policy;
105 gnc_prefs_set_file_retention_policy(gint policy)
107 file_retention_policy = policy;
111 gnc_prefs_get_file_retention_days(
void)
113 return file_retention_days;
117 gnc_prefs_set_file_retention_days(gint days)
119 file_retention_days = days;
123 gnc_prefs_get_long_version()
125 return PROJECT_VERSION_MAJOR * 1000000 + PROJECT_VERSION_MINOR;
129 const gchar *pref_name,
133 if (prefsbackend && prefsbackend->register_cb)
134 return (prefsbackend->register_cb) (group, pref_name, func, user_data);
137 g_warning (
"no preferences backend loaded, or the backend doesn't define register_cb, returning 0");
144 const gchar *pref_name,
148 if (prefsbackend && prefsbackend->remove_cb_by_func)
149 (prefsbackend->remove_cb_by_func) (group, pref_name, func, user_data);
156 if (prefsbackend && prefsbackend->remove_cb_by_id)
157 (prefsbackend->remove_cb_by_id) (group,
id);
165 if (prefsbackend && prefsbackend->register_group_cb)
166 return (prefsbackend->register_group_cb) (group, func, user_data);
176 if (prefsbackend && prefsbackend->remove_group_cb_by_func)
177 (prefsbackend->remove_group_cb_by_func) (group, func, user_data);
182 const gchar *pref_name,
184 const gchar *property)
186 if (prefsbackend && prefsbackend->bind)
187 (prefsbackend->bind) (group, pref_name,
object, property);
192 const gchar *pref_name)
194 if (prefsbackend && prefsbackend->get_bool)
195 return (prefsbackend->get_bool) (group, pref_name);
202 const gchar *pref_name)
204 if (prefsbackend && prefsbackend->get_int)
205 return (prefsbackend->get_int) (group, pref_name);
212 const gchar *pref_name)
216 result = g_variant_get_int64 (var);
217 g_variant_unref (var);
223 const gchar *pref_name)
225 if (prefsbackend && prefsbackend->get_float)
226 return (prefsbackend->get_float) (group, pref_name);
233 const gchar *pref_name)
235 if (prefsbackend && prefsbackend->get_string)
236 return (prefsbackend->get_string) (group, pref_name);
243 const gchar *pref_name)
245 if (prefsbackend && prefsbackend->get_enum)
246 return (prefsbackend->get_enum) (group, pref_name);
253 const gchar *pref_name,
254 gdouble *x, gdouble *y)
261 if (g_variant_is_of_type (coords, (
const GVariantType *)
"(dd)") )
262 g_variant_get (coords,
"(dd)", x, y);
263 g_variant_unref (coords);
268 const gchar *pref_name)
270 if (prefsbackend && prefsbackend->get_value)
271 return (prefsbackend->get_value) (group,pref_name);
278 const gchar *pref_name,
281 if (prefsbackend && prefsbackend->set_bool)
282 return (prefsbackend->set_bool) (group, pref_name, value);
289 const gchar *pref_name,
292 if (prefsbackend && prefsbackend->set_int)
293 return (prefsbackend->set_int) (group, pref_name, value);
300 const gchar *pref_name,
303 GVariant *var = g_variant_new (
"x",value);
309 const gchar *pref_name,
312 if (prefsbackend && prefsbackend->set_float)
313 return (prefsbackend->set_float) (group, pref_name, value);
320 const gchar *pref_name,
323 if (prefsbackend && prefsbackend->set_string)
324 return (prefsbackend->set_string) (group, pref_name, value);
331 const gchar *pref_name,
334 if (prefsbackend && prefsbackend->set_enum)
335 return (prefsbackend->set_enum) (group, pref_name, value);
342 const gchar *pref_name,
343 gdouble x, gdouble y)
345 GVariant *var = g_variant_new (
"(dd)",x, y);
351 const gchar *pref_name,
354 if (prefsbackend && prefsbackend->set_value)
355 return (prefsbackend->set_value) (group, pref_name, value);
362 const gchar *pref_name)
364 if (prefsbackend && prefsbackend->reset)
365 (prefsbackend->reset) (group, pref_name);
370 if (prefsbackend && prefsbackend->reset_group)
371 (prefsbackend->reset_group) (group);
376 return (prefsbackend !=NULL);
381 if (prefsbackend && prefsbackend->block_all)
382 (prefsbackend->block_all) ();
387 if (prefsbackend && prefsbackend->unblock_all)
388 (prefsbackend->unblock_all) ();
393 return reg_auto_raise_lists_id;
396 void gnc_prefs_set_reg_auto_raise_lists_id (gulong
id)
398 reg_auto_raise_lists_id = id;
403 return reg_negative_color_pref_id;
406 void gnc_prefs_set_reg_negative_color_pref_id (gulong
id)
408 reg_negative_color_pref_id = id;
void gnc_prefs_reset_group(const gchar *group)
Reset all preferences in a group to their default values in the preferences backend.
gboolean gnc_prefs_set_value(const gchar *group, const gchar *pref_name, GVariant *value)
Store an arbitrary combination of values into the preferences backend.
gchar * gnc_prefs_get_string(const gchar *group, const gchar *pref_name)
Get a string value from the preferences backend.
gulong gnc_prefs_register_cb(const char *group, const gchar *pref_name, gpointer func, gpointer user_data)
Register a callback that gets triggered when the given preference changes.
functions to query various version related strings that were set at build time.
gulong gnc_prefs_get_reg_negative_color_pref_id(void)
Get and Set registered preference id for register negative_color_pref.
gboolean gnc_prefs_set_int(const gchar *group, const gchar *pref_name, gint value)
Store an integer value into the preferences backend.
void gnc_prefs_reset(const gchar *group, const gchar *pref_name)
Reset a preference to its default value in the preferences backend.
gboolean gnc_prefs_set_string(const gchar *group, const gchar *pref_name, const gchar *value)
Store a string into the preferences backend.
gint64 gnc_prefs_get_int64(const gchar *group, const gchar *pref_name)
Get an 64 bit integer value from the preferences backend.
gint gnc_prefs_get_int(const gchar *group, const gchar *pref_name)
Get an integer value from the preferences backend.
void gnc_prefs_remove_cb_by_id(const gchar *group, guint id)
Remove a function that was registered for a callback when a specific preference in the settings group...
void gnc_prefs_bind(const gchar *group, const gchar *pref_name, gpointer object, const gchar *property)
Bind a setting to a g_object property.
gboolean gnc_prefs_set_bool(const gchar *group, const gchar *pref_name, gboolean value)
Store a boolean value into the preferences backend.
gboolean gnc_prefs_set_enum(const gchar *group, const gchar *pref_name, gint value)
Store an enum value into the preferences backend.
gint gnc_prefs_get_enum(const gchar *group, const gchar *pref_name)
Get an enum value from the preferences backend.
gboolean gnc_prefs_set_float(const gchar *group, const gchar *pref_name, gdouble value)
Store a float value into the preferences backend.
gboolean gnc_prefs_set_coords(const gchar *group, const gchar *pref_name, gdouble x, gdouble y)
Store coordinates into the preferences backend.
void gnc_prefs_get_coords(const gchar *group, const gchar *pref_name, gdouble *x, gdouble *y)
Get a pair of coordinates from the preferences backend.
void gnc_prefs_remove_group_cb_by_func(const gchar *group, gpointer func, gpointer user_data)
Remove a function that was registered for a callback when any preference in the given settings group ...
GVariant * gnc_prefs_get_value(const gchar *group, const gchar *pref_name)
Get an arbitrary combination of values from the preferences backend.
Generic api to store and retrieve preferences.
guint gnc_prefs_register_group_cb(const gchar *group, gpointer func, gpointer user_data)
Register a callback for when any preference in the settings group is changed.
gboolean gnc_prefs_get_bool(const gchar *group, const gchar *pref_name)
Get a boolean value from the preferences backend.
gulong gnc_prefs_get_reg_auto_raise_lists_id(void)
Get and Set registered preference id for register auto_raise_lists.
void gnc_prefs_block_all(void)
Block all preference callbacks.
void gnc_prefs_unblock_all(void)
Unblock all preferences callbacks.
gboolean gnc_prefs_is_set_up(void)
Test if preferences backend is set up.
void gnc_prefs_remove_cb_by_func(const gchar *group, const gchar *pref_name, gpointer func, gpointer user_data)
Remove a function that was registered for a callback when the given preference changed.
gdouble gnc_prefs_get_float(const gchar *group, const gchar *pref_name)
Get an float value from the preferences backend.
gboolean gnc_prefs_set_int64(const gchar *group, const gchar *pref_name, gint64 value)
Store a 64 bit integer value into the preferences backend.