GnuCash  2.6.99
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
import-settings.c
1 /********************************************************************\
2  * This program is free software; you can redistribute it and/or *
3  * modify it under the terms of the GNU General Public License as *
4  * published by the Free Software Foundation; either version 2 of *
5  * the License, or (at your option) any later version. *
6  * *
7  * This program is distributed in the hope that it will be useful, *
8  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
9  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
10  * GNU General Public License for more details. *
11  * *
12  * You should have received a copy of the GNU General Public License*
13  * along with this program; if not, contact: *
14  * *
15  * Free Software Foundation Voice: +1-617-542-5942 *
16  * 51 Franklin Street, Fifth Floor Fax: +1-617-542-2652 *
17  * Boston, MA 02110-1301, USA [email protected] *
18 \********************************************************************/
27 #include "config.h"
28 
29 #include <glib.h>
30 
31 #include "import-settings.h"
32 #include "gnc-prefs.h"
33 
34 /********************************************************************\
35  * Default values for user prefs (or values for unimplemented prefs.*
36  * If you modify the value of any of these, you must do the same in *
37  * generic-import.scm *
38 \********************************************************************/
39 
40 static const int DEFAULT_ACTION_ADD_ENABLED = TRUE;
41 static const int DEFAULT_ACTION_CLEAR_ENABLED = TRUE;
42 
43 /********************************************************************\
44  * Structures passed between the functions *
45 \********************************************************************/
46 
48 {
49 
50  gboolean action_skip_enabled;
51  gboolean action_update_enabled;
52  gboolean action_add_enabled;
53  gboolean action_clear_enabled;
54 
68  double fuzzy_amount;
69  gint match_date_hardlimit;
70 };
71 
72 
73 /************************************************************************
74  * Getter/Setter Functions for the Data Types.
75  ************************************************************************/
76 /* Constructor */
79 {
80  GNCImportSettings * settings;
81 
82  settings = g_new0 ( GNCImportSettings, 1);
83 
84 
85  settings->action_skip_enabled =
86  gnc_prefs_get_bool (GNC_PREFS_GROUP_IMPORT, GNC_PREF_ENABLE_SKIP);
87  settings->action_update_enabled =
88  gnc_prefs_get_bool (GNC_PREFS_GROUP_IMPORT, GNC_PREF_ENABLE_UPDATE);
89  settings->action_add_enabled = DEFAULT_ACTION_ADD_ENABLED;
90  settings->action_clear_enabled = DEFAULT_ACTION_CLEAR_ENABLED;
91  settings->clear_threshold =
92  (int)gnc_prefs_get_float (GNC_PREFS_GROUP_IMPORT, GNC_PREF_AUTO_CLEAR_THRESHOLD);
93  settings->add_threshold =
94  (int)gnc_prefs_get_float (GNC_PREFS_GROUP_IMPORT, GNC_PREF_AUTO_ADD_THRESHOLD);
95  settings->display_threshold =
96  (int)gnc_prefs_get_float (GNC_PREFS_GROUP_IMPORT, GNC_PREF_MATCH_THRESHOLD);
97 
98  settings->fuzzy_amount =
99  gnc_prefs_get_float (GNC_PREFS_GROUP_IMPORT, GNC_PREF_ATM_FEE_THRESHOLD);
100 
101  settings->match_date_hardlimit = 42; /* 6 weeks */
102  return settings;
103 }
104 
105 /* Destructor */
107 {
108  if (settings)
109  {
110  g_free(settings);
111  }
112 }
113 
114 double
116 {
117  g_assert (settings);
118  return settings->fuzzy_amount;
119 };
120 
122 {
123  g_assert (settings);
124  return settings->action_skip_enabled;
125 };
126 
128 {
129  g_assert (settings);
130  return settings->action_add_enabled;
131 };
132 
134 {
135  g_assert (settings);
136  return settings->action_update_enabled;
137 };
138 
140 {
141  g_assert (settings);
142  return settings->action_clear_enabled;
143 };
144 
146 {
147  g_assert (settings);
148  return settings->clear_threshold;
149 };
150 
152 {
153  g_assert (settings);
154  return settings->add_threshold;
155 };
156 
158 {
159  g_assert (settings);
160  return settings->display_threshold;
161 };
162 
164 {
165  g_assert(s);
166  s->match_date_hardlimit = m;
167 }
169 {
170  g_assert(s);
171  return s->match_date_hardlimit;
172 }
173 
gint gnc_import_Settings_get_match_date_hardlimit(const GNCImportSettings *s)
gint gnc_import_Settings_get_clear_threshold(GNCImportSettings *settings)
GNCImportSettings * gnc_import_Settings_new(void)
gboolean gnc_import_Settings_get_action_add_enabled(GNCImportSettings *settings)
gint gnc_import_Settings_get_display_threshold(GNCImportSettings *settings)
void gnc_import_Settings_delete(GNCImportSettings *settings)
#define GNC_PREFS_GROUP_IMPORT
Import preference handling. User preference interface for transaction matching (for both the gui and ...
gboolean gnc_import_Settings_get_action_clear_enabled(GNCImportSettings *settings)
void gnc_import_Settings_set_match_date_hardlimit(GNCImportSettings *s, gint m)
double gnc_import_Settings_get_fuzzy_amount(GNCImportSettings *settings)
Generic api to store and retrieve preferences.
gboolean gnc_import_Settings_get_action_update_enabled(GNCImportSettings *settings)
gboolean gnc_prefs_get_bool(const gchar *group, const gchar *pref_name)
Definition: gnc-prefs.c:196
gboolean gnc_import_Settings_get_action_skip_enabled(GNCImportSettings *settings)
gint gnc_import_Settings_get_add_threshold(GNCImportSettings *settings)
gdouble gnc_prefs_get_float(const gchar *group, const gchar *pref_name)
Definition: gnc-prefs.c:227