27 #include "gnc-prefs-p.h"
28 #include "gnc-version.h"
29 #include "libqof/qof/qof.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;
44 gnc_prefs_get_namespace_regexp(
void)
46 return namespace_regexp;
50 gnc_prefs_set_namespace_regexp(
const gchar *str)
53 g_free(namespace_regexp);
56 namespace_regexp = g_strdup(str);
60 gnc_prefs_is_debugging_enabled(
void)
66 gnc_prefs_set_debugging(gboolean d)
72 gnc_prefs_is_extra_enabled(
void)
74 return extras_enabled;
78 gnc_prefs_set_extra(gboolean enabled)
80 extras_enabled = enabled;
84 gnc_prefs_get_file_save_compressed(
void)
86 return use_compression;
90 gnc_prefs_set_file_save_compressed(gboolean compressed)
92 use_compression = compressed;
96 gnc_prefs_get_file_retention_policy(
void)
98 return file_retention_policy;
102 gnc_prefs_set_file_retention_policy(gint policy)
104 file_retention_policy = policy;
108 gnc_prefs_get_file_retention_days(
void)
110 return file_retention_days;
114 gnc_prefs_set_file_retention_days(gint days)
116 file_retention_days = days;
120 gnc_prefs_get_long_version()
122 return GNUCASH_MAJOR_VERSION * 1000000 +
123 GNUCASH_MINOR_VERSION * 10000 +
124 GNUCASH_MICRO_VERSION * 100 +
125 GNUCASH_NANO_VERSION;
129 const gchar *pref_name,
133 ENTER(
"group %s; pref_name %s, prefsbackend->register_cb %p", group, pref_name,
134 prefsbackend ? prefsbackend->register_cb : NULL);
135 if (prefsbackend && prefsbackend->register_cb)
138 return (prefsbackend->register_cb) (group, pref_name, func, user_data);
142 LEAVE(
"no backend loaded, or the backend doesn't define register_cb, returning 0");
149 const gchar *pref_name,
153 if (prefsbackend && prefsbackend->remove_cb_by_func)
154 (prefsbackend->remove_cb_by_func) (group, pref_name, func, user_data);
161 if (prefsbackend && prefsbackend->remove_cb_by_id)
162 (prefsbackend->remove_cb_by_id) (group,
id);
170 if (prefsbackend && prefsbackend->register_group_cb)
171 return (prefsbackend->register_group_cb) (group, func, user_data);
181 if (prefsbackend && prefsbackend->remove_group_cb_by_func)
182 (prefsbackend->remove_group_cb_by_func) (group, func, user_data);
187 const gchar *pref_name,
189 const gchar *property)
191 if (prefsbackend && prefsbackend->bind)
192 (prefsbackend->bind) (group, pref_name,
object, property);
197 const gchar *pref_name)
199 if (prefsbackend && prefsbackend->get_bool)
200 return (prefsbackend->get_bool) (group, pref_name);
207 const gchar *pref_name)
209 if (prefsbackend && prefsbackend->get_int)
210 return (prefsbackend->get_int) (group, pref_name);
217 const gchar *pref_name)
221 result = g_variant_get_int64 (var);
222 g_variant_unref (var);
228 const gchar *pref_name)
230 if (prefsbackend && prefsbackend->get_float)
231 return (prefsbackend->get_float) (group, pref_name);
238 const gchar *pref_name)
240 if (prefsbackend && prefsbackend->get_string)
241 return (prefsbackend->get_string) (group, pref_name);
248 const gchar *pref_name)
250 if (prefsbackend && prefsbackend->get_enum)
251 return (prefsbackend->get_enum) (group, pref_name);
258 const gchar *pref_name,
259 gdouble *x, gdouble *y)
266 if (g_variant_is_of_type (coords, (
const GVariantType *)
"(dd)") )
267 g_variant_get (coords,
"(dd)", x, y);
268 g_variant_unref (coords);
273 const gchar *pref_name)
275 if (prefsbackend && prefsbackend->get_value)
276 return (prefsbackend->get_value) (group,pref_name);
283 const gchar *pref_name,
286 if (prefsbackend && prefsbackend->set_bool)
287 return (prefsbackend->set_bool) (group, pref_name, value);
294 const gchar *pref_name,
297 if (prefsbackend && prefsbackend->set_int)
298 return (prefsbackend->set_int) (group, pref_name, value);
305 const gchar *pref_name,
308 GVariant *var = g_variant_new (
"x",value);
314 const gchar *pref_name,
317 if (prefsbackend && prefsbackend->set_float)
318 return (prefsbackend->set_float) (group, pref_name, value);
325 const gchar *pref_name,
328 if (prefsbackend && prefsbackend->set_string)
329 return (prefsbackend->set_string) (group, pref_name, value);
336 const gchar *pref_name,
339 if (prefsbackend && prefsbackend->set_enum)
340 return (prefsbackend->set_enum) (group, pref_name, value);
347 const gchar *pref_name,
348 gdouble x, gdouble y)
350 GVariant *var = g_variant_new (
"(dd)",x, y);
356 const gchar *pref_name,
359 if (prefsbackend && prefsbackend->set_value)
360 return (prefsbackend->set_value) (group, pref_name, value);
367 const gchar *pref_name)
369 if (prefsbackend && prefsbackend->reset)
370 (prefsbackend->reset) (group, pref_name);
375 if (prefsbackend && prefsbackend->reset_group)
376 (prefsbackend->reset_group) (group);
381 return (prefsbackend !=NULL);
void gnc_prefs_reset_group(const gchar *group)
gboolean gnc_prefs_set_value(const gchar *group, const gchar *pref_name, GVariant *value)
gchar * gnc_prefs_get_string(const gchar *group, const gchar *pref_name)
gulong gnc_prefs_register_cb(const char *group, const gchar *pref_name, gpointer func, gpointer user_data)
#define G_LOG_DOMAIN
Functions providing the SX List as a plugin page.
gboolean gnc_prefs_set_int(const gchar *group, const gchar *pref_name, gint value)
void gnc_prefs_reset(const gchar *group, const gchar *pref_name)
gboolean gnc_prefs_set_string(const gchar *group, const gchar *pref_name, const gchar *value)
#define ENTER(format, args...)
gint64 gnc_prefs_get_int64(const gchar *group, const gchar *pref_name)
gint gnc_prefs_get_int(const gchar *group, const gchar *pref_name)
void gnc_prefs_remove_cb_by_id(const gchar *group, guint id)
void gnc_prefs_bind(const gchar *group, const gchar *pref_name, gpointer object, const gchar *property)
gboolean gnc_prefs_set_bool(const gchar *group, const gchar *pref_name, gboolean value)
gboolean gnc_prefs_set_enum(const gchar *group, const gchar *pref_name, gint value)
gint gnc_prefs_get_enum(const gchar *group, const gchar *pref_name)
gboolean gnc_prefs_set_float(const gchar *group, const gchar *pref_name, gdouble value)
gboolean gnc_prefs_set_coords(const gchar *group, const gchar *pref_name, gdouble x, gdouble y)
void gnc_prefs_get_coords(const gchar *group, const gchar *pref_name, gdouble *x, gdouble *y)
void gnc_prefs_remove_group_cb_by_func(const gchar *group, gpointer func, gpointer user_data)
GVariant * gnc_prefs_get_value(const gchar *group, const gchar *pref_name)
Generic api to store and retrieve preferences.
guint gnc_prefs_register_group_cb(const gchar *group, gpointer func, gpointer user_data)
gboolean gnc_prefs_get_bool(const gchar *group, const gchar *pref_name)
#define LEAVE(format, args...)
gboolean gnc_prefs_is_set_up(void)
const gchar * QofLogModule
void gnc_prefs_remove_cb_by_func(const gchar *group, const gchar *pref_name, gpointer func, gpointer user_data)
gdouble gnc_prefs_get_float(const gchar *group, const gchar *pref_name)
gboolean gnc_prefs_set_int64(const gchar *group, const gchar *pref_name, gint64 value)