GnuCash  5.6-150-g038405b370+
gnc-prefs.h
Go to the documentation of this file.
1 /********************************************************************\
2  * gnc-prefs.h -- Api to load and store preferences to a *
3  * configurable backend *
4  * *
5  * Copyright (C) 2013 Geert Janssens <geert@kobaltwit.be> *
6  * *
7  * This program is free software; you can redistribute it and/or *
8  * modify it under the terms of the GNU General Public License as *
9  * published by the Free Software Foundation; either version 2 of *
10  * the License, or (at your option) any later version. *
11  * *
12  * This program is distributed in the hope that it will be useful, *
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
15  * GNU General Public License for more details. *
16  * *
17  * You should have received a copy of the GNU General Public License*
18  * along with this program; if not, contact: *
19  * *
20  * Free Software Foundation Voice: +1-617-542-5942 *
21  * 51 Franklin Street, Fifth Floor Fax: +1-617-542-2652 *
22  * Boston, MA 02110-1301, USA gnu@gnu.org *
23  * *
24  ********************************************************************/
25 
45 #ifndef GNC_PREFS_H
46 #define GNC_PREFS_H
47 
48 #include <glib.h>
49 
50 /* Preference groups used across multiple modules */
51 #define GNC_PREFS_GROUP_GENERAL "general"
52 #define GNC_PREFS_GROUP_GENERAL_REGISTER "general.register"
53 #define GNC_PREFS_GROUP_GENERAL_REPORT "general.report"
54 #define GNC_PREFS_GROUP_WARNINGS "general.warnings"
55 #define GNC_PREFS_GROUP_WARNINGS_TEMP "warnings.temporary"
56 #define GNC_PREFS_GROUP_WARNINGS_PERM "warnings.permanent"
57 #define GNC_PREFS_GROUP_ACCT_SUMMARY "window.pages.account-tree.summary"
58 
59 /* Preference names used across multiple modules */
60 #define GNC_PREF_VERSION "prefs-version"
61 #define GNC_PREF_SAVE_GEOMETRY "save-window-geometry"
62 #define GNC_PREF_LAST_PATH "last-path"
63 #define GNC_PREF_USE_NEW "use-new-window"
64 #define GNC_PREF_ACCOUNTING_LABELS "use-accounting-labels"
65 #define GNC_PREF_ACCOUNT_SEPARATOR "account-separator"
66 #define GNC_PREF_NEGATIVE_IN_RED "negative-in-red"
67 #define GNC_PREF_NUM_SOURCE "num-source"
68 #define GNC_PREF_DATE_FORMAT "date-format"
69 #define GNC_PREF_DATE_COMPL_THISYEAR "date-completion-thisyear"
70 #define GNC_PREF_DATE_COMPL_SLIDING "date-completion-sliding"
71 #define GNC_PREF_DATE_BACKMONTHS "date-backmonths"
72 #define GNC_PREF_SHOW_LEAF_ACCT_NAMES "show-leaf-account-names"
73 #define GNC_PREF_ENTER_MOVES_TO_END "enter-moves-to-end"
74 /* Register preferences */
75 #define GNC_PREF_DRAW_HOR_LINES "draw-horizontal-lines"
76 #define GNC_PREF_DRAW_VERT_LINES "draw-vertical-lines"
77 #define GNC_PREF_ALT_COLOR_BY_TRANS "alternate-color-by-transaction"
78 #define GNC_PREF_USE_THEME_COLORS "use-theme-colors" // Obsolete, to remove in a future major version (> 2.8)
79 #define GNC_PREF_USE_GNUCASH_COLOR_THEME "use-gnucash-color-theme"
80 #define GNC_PREF_TAB_TRANS_MEMORISED "tab-to-transfer-on-memorised"
81 #define GNC_PREF_FUTURE_AFTER_BLANK "future-after-blank-transaction"
82 /* Date preferences */
83 #define GNC_PREF_START_CHOICE_ABS "start-choice-absolute"
84 #define GNC_PREF_START_CHOICE_REL "start-choice-relative"
85 #define GNC_PREF_START_DATE "start-date"
86 #define GNC_PREF_START_PERIOD "start-period"
87 #define GNC_PREF_END_CHOICE_ABS "end-choice-absolute"
88 #define GNC_PREF_END_CHOICE_REL "end-choice-relative"
89 #define GNC_PREF_END_DATE "end-date"
90 #define GNC_PREF_END_PERIOD "end-period"
91 /* Currency preferences */
92 #define GNC_PREF_CURRENCY_OTHER "currency-other"
93 #define GNC_PREF_CURRENCY_CHOICE_LOCALE "currency-choice-locale"
94 #define GNC_PREF_CURRENCY_CHOICE_OTHER "currency-choice-other"
95 
96 #ifdef __cplusplus
97 extern "C" {
98 #endif
99 
104 const gchar *gnc_prefs_get_namespace_regexp(void);
105 void gnc_prefs_set_namespace_regexp(const gchar *str);
106 
107 gboolean gnc_prefs_is_debugging_enabled(void);
108 void gnc_prefs_set_debugging(gboolean d);
109 
110 gboolean gnc_prefs_is_extra_enabled(void);
111 void gnc_prefs_set_extra(gboolean enabled);
112 
113 gboolean gnc_prefs_get_file_save_compressed(void);
114 void gnc_prefs_set_file_save_compressed(gboolean compressed);
115 
116 gint gnc_prefs_get_file_retention_policy(void);
117 void gnc_prefs_set_file_retention_policy(gint policy);
118 
119 gint gnc_prefs_get_file_retention_days(void);
120 void gnc_prefs_set_file_retention_days(gint days);
121 
122 guint gnc_prefs_get_long_version( void );
123 
129 gboolean gnc_prefs_is_set_up (void);
130 
133 void gnc_prefs_block_all (void);
134 
137 void gnc_prefs_unblock_all (void);
138 
163 gulong gnc_prefs_register_cb (const char *group,
164  const gchar *pref_name,
165  gpointer func,
166  gpointer user_data);
167 
168 
186 void gnc_prefs_remove_cb_by_func (const gchar *group,
187  const gchar *pref_name,
188  gpointer func,
189  gpointer user_data);
190 
191 
203 void gnc_prefs_remove_cb_by_id (const gchar *group,
204  guint id);
205 
206 
221 guint gnc_prefs_register_group_cb (const gchar *group,
222  gpointer func,
223  gpointer user_data);
224 
225 
246 void gnc_prefs_remove_group_cb_by_func (const gchar *group,
247  gpointer func,
248  gpointer user_data);
249 
250 
264 void gnc_prefs_bind (const gchar *group,
265  /*@ null @*/ const gchar *pref_name,
266  gpointer object,
267  const gchar *property);
268 
287 gboolean gnc_prefs_get_bool (const gchar *group,
288  /*@ null @*/ const gchar *pref_name);
289 
302 gint gnc_prefs_get_int (const gchar *group,
303  const gchar *pref_name);
304 
317 gint64 gnc_prefs_get_int64 (const gchar *group,
318  const gchar *pref_name);
319 
332 gdouble gnc_prefs_get_float (const gchar *group,
333  const gchar *pref_name);
334 
347 gchar *gnc_prefs_get_string (const gchar *group,
348  const gchar *pref_name);
349 
362 gint gnc_prefs_get_enum (const gchar *group,
363  const gchar *pref_name);
364 
378 void gnc_prefs_get_coords (const gchar *group,
379  const gchar *pref_name,
380  gdouble *x, gdouble *y);
381 
399 GVariant *gnc_prefs_get_value (const gchar *group,
400  const gchar *pref_name);
401 
421 gboolean gnc_prefs_set_bool (const gchar *group,
422  const gchar *pref_name,
423  gboolean value);
424 
437 gboolean gnc_prefs_set_int (const gchar *group,
438  const gchar *pref_name,
439  gint value);
440 
453 gboolean gnc_prefs_set_int64 (const gchar *group,
454  const gchar *pref_name,
455  gint64 value);
456 
469 gboolean gnc_prefs_set_float (const gchar *group,
470  const gchar *pref_name,
471  gdouble value);
472 
473 
488 gboolean gnc_prefs_set_string (const gchar *group,
489  const gchar *pref_name,
490  const gchar *value);
491 
504 gboolean gnc_prefs_set_enum (const gchar *group,
505  const gchar *pref_name,
506  gint value);
507 
523 gboolean gnc_prefs_set_coords (const gchar *group,
524  const gchar *pref_name,
525  gdouble x, gdouble y);
526 
540 gboolean gnc_prefs_set_value (const gchar *group,
541  const gchar *pref_name,
542  GVariant *value);
543 
551 void gnc_prefs_reset (const gchar *group,
552  const gchar *pref_name);
553 
558 void gnc_prefs_reset_group (const gchar *group);
559 
563 void gnc_prefs_set_reg_auto_raise_lists_id (gulong id);
564 
568 void gnc_prefs_set_reg_negative_color_pref_id (gulong id);
569 
572 #ifdef __cplusplus
573 }
574 #endif
575 
576 
577 #endif /* GNC_PREFS_H */
578 
void gnc_prefs_reset_group(const gchar *group)
Reset all preferences in a group to their default values in the preferences backend.
Definition: gnc-prefs.c:368
gboolean gnc_prefs_set_value(const gchar *group, const gchar *pref_name, GVariant *value)
Store an arbitrary combination of values into the preferences backend.
Definition: gnc-prefs.c:350
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.
Definition: gnc-prefs.c:128
gulong gnc_prefs_get_reg_negative_color_pref_id(void)
Get and Set registered preference id for register negative_color_pref.
Definition: gnc-prefs.c:401
gboolean gnc_prefs_set_int(const gchar *group, const gchar *pref_name, gint value)
Store an integer value into the preferences backend.
Definition: gnc-prefs.c:288
void gnc_prefs_reset(const gchar *group, const gchar *pref_name)
Reset a preference to its default value in the preferences backend.
Definition: gnc-prefs.c:361
gboolean gnc_prefs_set_string(const gchar *group, const gchar *pref_name, const gchar *value)
Store a string into the preferences backend.
Definition: gnc-prefs.c:319
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...
Definition: gnc-prefs.c:153
void gnc_prefs_bind(const gchar *group, const gchar *pref_name, gpointer object, const gchar *property)
Bind a setting to a g_object property.
Definition: gnc-prefs.c:181
gboolean gnc_prefs_set_bool(const gchar *group, const gchar *pref_name, gboolean value)
Store a boolean value into the preferences backend.
Definition: gnc-prefs.c:277
gboolean gnc_prefs_set_enum(const gchar *group, const gchar *pref_name, gint value)
Store an enum value into the preferences backend.
Definition: gnc-prefs.c:330
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.
Definition: gnc-prefs.c:308
gboolean gnc_prefs_set_coords(const gchar *group, const gchar *pref_name, gdouble x, gdouble y)
Store coordinates into the preferences backend.
Definition: gnc-prefs.c:341
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 ...
Definition: gnc-prefs.c:172
GVariant * gnc_prefs_get_value(const gchar *group, const gchar *pref_name)
Get an arbitrary combination of values from the preferences backend.
Definition: gnc-prefs.c:267
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.
Definition: gnc-prefs.c:161
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.
Definition: gnc-prefs.c:391
void gnc_prefs_block_all(void)
Block all preference callbacks.
Definition: gnc-prefs.c:379
void gnc_prefs_unblock_all(void)
Unblock all preferences callbacks.
Definition: gnc-prefs.c:385
gboolean gnc_prefs_is_set_up(void)
Test if preferences backend is set up.
Definition: gnc-prefs.c:374
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.
Definition: gnc-prefs.c:143
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.
Definition: gnc-prefs.c:299