]> Dogcows Code - chaz/homebank/blob - src/hb-preferences.c
Merge branch 'master' into ext-perl
[chaz/homebank] / src / hb-preferences.c
1 /* HomeBank -- Free, easy, personal accounting for everyone.
2 * Copyright (C) 1995-2016 Maxime DOYEN
3 *
4 * This file is part of HomeBank.
5 *
6 * HomeBank is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * HomeBank is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program. If not, see <http://www.gnu.org/licenses/>.
18 */
19
20
21 #include "homebank.h"
22
23 #include "hb-preferences.h"
24 #include "hb-filter.h"
25 #include "gtk-chart-colors.h"
26
27 #ifdef G_OS_WIN32
28 #include <windows.h>
29 #endif
30
31 /****************************************************************************/
32 /* Debug macros */
33 /****************************************************************************/
34 #define MYDEBUG 0
35
36 #if MYDEBUG
37 #define DB(x) (x);
38 #else
39 #define DB(x);
40 #endif
41
42 /* our global datas */
43 extern struct HomeBank *GLOBALS;
44 extern struct Preferences *PREFS;
45
46 /* = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = */
47
48 static void homebank_pref_init_monetary(void)
49 {
50
51 DB( g_print("\n[system] get currency code\n") );
52
53 #ifdef G_OS_UNIX
54 struct lconv *lc = localeconv();
55
56 g_stpcpy (PREFS->IntCurrSymbol, lc->int_curr_symbol);
57 g_strstrip(PREFS->IntCurrSymbol);
58
59 DB( g_print("- stored '%s' from linux system\n", PREFS->IntCurrSymbol) );
60 #else
61
62 #ifdef G_OS_WIN32
63 #define BUFFER_SIZE 512
64 char buffer[BUFFER_SIZE];
65 //LPWSTR wcBuffer = buffer;
66 LPSTR wcBuffer = buffer;
67 int iResult;
68
69 //https://msdn.microsoft.com/en-us/library/windows/desktop/dd464799%28v=vs.85%29.aspx
70
71 //LOCALE_SINTLSYMBOL
72 iResult = GetLocaleInfoA(LOCALE_USER_DEFAULT, LOCALE_SINTLSYMBOL, wcBuffer, BUFFER_SIZE);
73 if(iResult > 0)
74 {
75 DB( g_print("LOCALE_SINTLSYMBOL='%s'\n", buffer) );
76 g_stpcpy (PREFS->IntCurrSymbol, buffer);
77 g_strstrip(PREFS->IntCurrSymbol);
78
79 DB( g_print("- stored '%s' from windows system\n", PREFS->IntCurrSymbol) );
80 }
81 #else
82
83 g_stpcpy (PREFS->IntCurrSymbol, "USD");
84
85 DB( g_print("- stored '%s' as default\n", PREFS->IntCurrSymbol) );
86
87 #endif
88
89 #endif
90
91
92 }
93
94
95 /*
96 static void homebank_pref_init_monetary(void)
97 {
98 DB( g_print("\n[preferences] monetary\n") );
99
100
101 #ifdef G_OS_UNIX
102
103 struct lconv *lc = localeconv();
104
105 DB( g_print("\n[preferences] monetary unix\n") );
106
107 DB( g_print("int_curr_symbol '%s'\n", lc->int_curr_symbol) );
108
109 DB( g_print("mon_decimal_point is utf8: %d\n", g_utf8_validate(lc->mon_decimal_point, -1, NULL)) );
110 DB( g_print("mon_decimal_point '%s'\n", lc->mon_decimal_point) );
111 DB( g_print("mon_decimal_point %x %x %x %x\n", lc->mon_decimal_point[0], lc->mon_decimal_point[1], lc->mon_decimal_point[2], lc->mon_decimal_point[3]) );
112
113 DB( g_print("mon_thousands_sep is utf8: %d\n", g_utf8_validate(lc->mon_thousands_sep, -1, NULL)) );
114 DB( g_print("mon_thousands_sep '%s'\n", lc->mon_thousands_sep) );
115 DB( g_print("mon_thousands_sep %x %x %x %x\n", lc->mon_thousands_sep[0], lc->mon_thousands_sep[1], lc->mon_thousands_sep[2], lc->mon_thousands_sep[3]) );
116
117
118 DB( g_print("frac_digits '%d'\n", (gint)lc->frac_digits) );
119
120 DB( g_print("currency_symbol '%s'\n", lc->currency_symbol) );
121
122 DB( g_print("p_cs_precedes '%d'\n", lc->p_cs_precedes) );
123
124 DB( g_print("n_cs_precedes '%d'\n", lc->n_cs_precedes) );
125
126 //PREFS->base_cur.iso_code = g_strdup(g_strstrip(lc->int_curr_symbol));
127
128 if( lc->p_cs_precedes || lc->n_cs_precedes )
129 {
130 PREFS->base_cur.symbol = g_strdup(lc->currency_symbol);
131 PREFS->base_cur.sym_prefix = TRUE;
132 DB( g_print("locale mon cs is a prefix\n") );
133 }
134 else
135 {
136 PREFS->base_cur.symbol = g_strdup(lc->currency_symbol);
137 PREFS->base_cur.sym_prefix = FALSE;
138 }
139
140 PREFS->base_cur.decimal_char = g_strdup(lc->mon_decimal_point);
141
142 PREFS->base_cur.grouping_char = g_strdup(lc->mon_thousands_sep);
143
144 //todo:fix
145 //PREFS->base_cur.grouping_char = g_locale_to_utf8(lc->mon_thousands_sep, -1, NULL, NULL, NULL);
146 //PREFS->base_cur.grouping_char = g_convert (lc->mon_thousands_sep, -1, "UTF-8", "ISO-8859-1", NULL, NULL, NULL);
147
148 DB( g_print(" -> grouping_char: '%s'\n", PREFS->base_cur.grouping_char) );
149
150 PREFS->base_cur.frac_digits = lc->frac_digits;
151
152 //fix 378992/421228
153 if( PREFS->base_cur.frac_digits > MAX_FRAC_DIGIT )
154 {
155 PREFS->base_cur.frac_digits = 2;
156 g_free(PREFS->base_cur.decimal_char);
157 PREFS->base_cur.decimal_char = g_strdup(".");
158 }
159
160 #else
161 #ifdef G_OS_WIN32
162
163 #define BUFFER_SIZE 512
164 char buffer[BUFFER_SIZE];
165 //LPWSTR wcBuffer = buffer;
166 LPSTR wcBuffer = buffer;
167 int iResult;
168 gsize toto;
169
170 //https://msdn.microsoft.com/en-us/library/windows/desktop/dd464799%28v=vs.85%29.aspx
171
172 //LOCALE_SINTLSYMBOL
173
174
175 //see g_locale_to_utf8 here
176 iResult = GetLocaleInfoA(LOCALE_USER_DEFAULT, LOCALE_SCURRENCY, wcBuffer, BUFFER_SIZE);
177 if(iResult > 0)
178 {
179 DB( g_print("LOCALE_SCURRENCY='%s'\n", buffer) );
180 PREFS->base_cur.symbol = g_locale_to_utf8(buffer, -1, NULL, &toto, NULL);
181 }
182
183 // LOCALE_ICURRENCY
184 //PREFS->base_cur.sym_prefix =
185
186 iResult = GetLocaleInfoA(LOCALE_USER_DEFAULT, LOCALE_SDECIMAL, wcBuffer, BUFFER_SIZE);
187 if(iResult > 0)
188 {
189 DB( g_print("LOCALE_SDECIMAL='%s'\n", buffer) );
190 PREFS->base_cur.decimal_char = g_locale_to_utf8(buffer, -1, NULL, &toto, NULL);
191 }
192
193 iResult = GetLocaleInfoA(LOCALE_USER_DEFAULT, LOCALE_STHOUSAND, wcBuffer, BUFFER_SIZE);
194 if(iResult > 0)
195 {
196 DB( g_print("LOCALE_STHOUSAND='%s'\n", buffer) );
197 PREFS->base_cur.grouping_char = g_locale_to_utf8(buffer, -1, NULL, &toto, NULL);
198 }
199
200 // LOCALE_ICURRDIGITS
201 PREFS->base_cur.frac_digits = 2;
202
203 #else
204
205 PREFS->base_cur.iso_code = g_strdup("USD");
206 PREFS->base_cur.symbol = NULL; //g_strdup("");
207 PREFS->base_cur.sym_prefix = FALSE;
208 PREFS->base_cur.decimal_char = g_strdup(".");
209 PREFS->base_cur.grouping_char = NULL; //g_strdup("");
210 PREFS->base_cur.frac_digits = 2;
211
212 #endif
213 #endif
214
215 }
216 */
217
218
219
220 static void homebank_pref_init_wingeometry(struct WinGeometry *wg, gint l, gint t, gint w, gint h)
221 {
222 wg->l = l;
223 wg->t = t;
224 wg->w = w;
225 wg->h = h;
226 wg->s = 0;
227 }
228
229
230 //vehicle_unit_100
231 //vehicle_unit_distbyvol
232 //=> used for column title
233
234 static void _homebank_pref_init_measurement_units(void)
235 {
236 // unit is kilometer
237 if(!PREFS->vehicle_unit_ismile)
238 {
239 PREFS->vehicle_unit_dist = "%d km";
240 PREFS->vehicle_unit_100 = "100 km";
241 }
242 // unit is miles
243 else
244 {
245 PREFS->vehicle_unit_dist = "%d mi.";
246 PREFS->vehicle_unit_100 = "100 mi.";
247 }
248
249 // unit is Liters
250 if(!PREFS->vehicle_unit_isgal)
251 {
252 //TRANSLATORS: format a liter number with l/L as abbreviation
253 PREFS->vehicle_unit_vol = _("%.2f l");
254 if(!PREFS->vehicle_unit_ismile)
255 //TRANSLATORS: kilometer per liter
256 PREFS->vehicle_unit_distbyvol = _("km/l");
257 else
258 //TRANSLATORS: miles per liter
259 PREFS->vehicle_unit_distbyvol = _("mi./l");
260 }
261 // unit is gallon
262 else
263 {
264 PREFS->vehicle_unit_vol = "%.2f gal.";
265 if(!PREFS->vehicle_unit_ismile)
266 PREFS->vehicle_unit_distbyvol = "km/gal.";
267 else
268 PREFS->vehicle_unit_distbyvol = "mi./gal.";
269 }
270
271 }
272
273
274 void homebank_pref_free(void)
275 {
276 DB( g_print("\n[preferences] free\n") );
277
278
279 g_free(PREFS->date_format);
280
281 g_free(PREFS->color_exp);
282 g_free(PREFS->color_inc);
283 g_free(PREFS->color_warn);
284
285 g_free(PREFS->path_hbfile);
286 g_free(PREFS->path_import);
287 g_free(PREFS->path_export);
288 //g_free(PREFS->path_navigator);
289
290 g_free(PREFS->language);
291
292
293 g_free(PREFS->minor_cur.symbol);
294 g_free(PREFS->minor_cur.decimal_char);
295 g_free(PREFS->minor_cur.grouping_char);
296
297 g_strfreev(PREFS->ext_path);
298 g_list_free_full(PREFS->ext_whitelist, g_free);
299
300 memset(PREFS, 0, sizeof(struct Preferences));
301 }
302
303
304 void homebank_pref_setdefault(void)
305 {
306 gint i;
307
308 DB( g_print("\n[preferences] pref init\n") );
309
310 homebank_pref_free();
311
312 PREFS->language = NULL;
313
314 PREFS->date_format = g_strdup(DEFAULT_FORMAT_DATE);
315
316 PREFS->path_hbfile = g_strdup_printf("%s", g_get_home_dir ());
317 PREFS->path_import = g_strdup_printf("%s", g_get_home_dir ());
318 PREFS->path_export = g_strdup_printf("%s", g_get_home_dir ());
319 //PREFS->path_navigator = g_strdup(DEFAULT_PATH_NAVIGATOR);
320
321 PREFS->showsplash = TRUE;
322 PREFS->loadlast = TRUE;
323 PREFS->appendscheduled = FALSE;
324 PREFS->do_update_currency = FALSE;
325
326 PREFS->heritdate = FALSE;
327 PREFS->hidereconciled = FALSE;
328 PREFS->showremind = TRUE;
329
330 PREFS->toolbar_style = 4; //text beside icons
331 PREFS->custom_colors = TRUE;
332 PREFS->color_exp = g_strdup(DEFAULT_EXP_COLOR);
333 PREFS->color_inc = g_strdup(DEFAULT_INC_COLOR);
334 PREFS->color_warn = g_strdup(DEFAULT_WARN_COLOR);
335 PREFS->grid_lines = GTK_TREE_VIEW_GRID_LINES_NONE;
336
337 /* fiscal year */
338 PREFS->fisc_year_day = 1;
339 PREFS->fisc_year_month = 1;
340
341 /* windows position/size */
342 homebank_pref_init_wingeometry(&PREFS->wal_wg, 0, 0, 1024, 600);
343 homebank_pref_init_wingeometry(&PREFS->acc_wg, 0, 0, 1024, 600);
344 homebank_pref_init_wingeometry(&PREFS->sta_wg, 0, 0, 800, 494);
345 homebank_pref_init_wingeometry(&PREFS->tme_wg, 0, 0, 800, 494);
346 homebank_pref_init_wingeometry(&PREFS->ove_wg, 0, 0, 800, 494);
347 homebank_pref_init_wingeometry(&PREFS->bud_wg, 0, 0, 800, 494);
348 homebank_pref_init_wingeometry(&PREFS->cst_wg, 0, 0, 800, 494);
349
350 homebank_pref_init_wingeometry(&PREFS->txn_wg, 0, 0, -1, -1);
351
352 homebank_pref_init_monetary();
353
354 PREFS->wal_toolbar = TRUE;
355 PREFS->wal_spending = TRUE;
356 PREFS->wal_upcoming = TRUE;
357 PREFS->wal_vpaned = 600/2;
358 PREFS->wal_hpaned = 1024/2;
359
360
361
362 i = 0;
363 /* prior v4.5
364 PREFS->lst_ope_columns[i++] = LST_DSPOPE_STATUS;
365 PREFS->lst_ope_columns[i++] = LST_DSPOPE_DATE;
366 PREFS->lst_ope_columns[i++] = LST_DSPOPE_INFO;
367 PREFS->lst_ope_columns[i++] = LST_DSPOPE_PAYEE;
368 PREFS->lst_ope_columns[i++] = LST_DSPOPE_WORDING;
369 PREFS->lst_ope_columns[i++] = -LST_DSPOPE_AMOUNT;
370 PREFS->lst_ope_columns[i++] = LST_DSPOPE_EXPENSE;
371 PREFS->lst_ope_columns[i++] = LST_DSPOPE_INCOME;
372 PREFS->lst_ope_columns[i++] = LST_DSPOPE_CATEGORY;
373 PREFS->lst_ope_columns[i++] = LST_DSPOPE_TAGS;
374 */
375 PREFS->lst_ope_columns[i++] = LST_DSPOPE_STATUS; //always displayed
376 PREFS->lst_ope_columns[i++] = LST_DSPOPE_DATE; //always displayed
377 PREFS->lst_ope_columns[i++] = LST_DSPOPE_INFO;
378 PREFS->lst_ope_columns[i++] = LST_DSPOPE_PAYEE;
379 PREFS->lst_ope_columns[i++] = LST_DSPOPE_CATEGORY;
380 PREFS->lst_ope_columns[i++] = LST_DSPOPE_TAGS;
381 PREFS->lst_ope_columns[i++] = LST_DSPOPE_CLR;
382 PREFS->lst_ope_columns[i++] = -LST_DSPOPE_AMOUNT;
383 PREFS->lst_ope_columns[i++] = LST_DSPOPE_EXPENSE;
384 PREFS->lst_ope_columns[i++] = LST_DSPOPE_INCOME;
385 PREFS->lst_ope_columns[i++] = LST_DSPOPE_BALANCE;
386 PREFS->lst_ope_columns[i++] = LST_DSPOPE_WORDING;
387
388 PREFS->lst_ope_sort_id = LST_DSPOPE_DATE;
389 PREFS->lst_ope_sort_order = GTK_SORT_ASCENDING;
390
391 for( i=0;i<NUM_LST_DSPOPE;i++)
392 PREFS->lst_ope_col_size[i] = -1;
393
394 //PREFS->base_cur.nbdecimal = 2;
395 //PREFS->base_cur.separator = TRUE;
396
397 PREFS->date_range_wal = FLT_RANGE_LASTMONTH;
398 PREFS->date_range_txn = FLT_RANGE_LAST12MONTHS;
399 PREFS->date_future_nbdays = 0;
400 PREFS->date_range_rep = FLT_RANGE_THISYEAR;
401
402 //import/export
403 PREFS->dtex_nointro = TRUE;
404 //PREFS->dtex_datefmt
405 PREFS->dtex_ofxname = 1;
406 PREFS->dtex_ofxmemo = 2;
407 PREFS->dtex_qifmemo = TRUE;
408 PREFS->dtex_qifswap = FALSE;
409
410 //todo: add intelligence here
411 PREFS->euro_active = FALSE;
412
413 PREFS->euro_country = 0;
414 PREFS->euro_value = 1.0;
415
416 da_cur_initformat(&PREFS->minor_cur);
417
418 //PREFS->euro_nbdec = 2;
419 //PREFS->euro_thsep = TRUE;
420 //PREFS->euro_symbol = g_strdup("??");
421
422 PREFS->stat_byamount = FALSE;
423 PREFS->stat_showdetail = FALSE;
424 PREFS->stat_showrate = FALSE;
425 PREFS->budg_showdetail = FALSE;
426 PREFS->report_color_scheme = CHART_COLMAP_HOMEBANK;
427
428 //PREFS->chart_legend = FALSE;
429
430 PREFS->vehicle_unit_ismile = FALSE;
431 PREFS->vehicle_unit_isgal = FALSE;
432
433 gchar** plugin_path = g_new0(gchar**, 4);
434 i = 0;
435 const gchar* env = g_getenv("HOMEBANK_PLUGINS");
436 if (env) {
437 if (g_path_is_absolute(env)) {
438 plugin_path[i++] = g_strdup(env);
439 } else {
440 gchar* cur = g_get_current_dir();
441 plugin_path[i++] = g_build_filename(cur, env, NULL);
442 g_free(cur);
443 }
444 }
445 plugin_path[i++] = g_build_filename(homebank_app_get_config_dir(), "plugins", NULL);
446 plugin_path[i++] = g_build_filename(homebank_app_get_pkglib_dir(), "plugins", NULL);
447 PREFS->ext_path = plugin_path;
448 PREFS->ext_whitelist = NULL;
449
450 _homebank_pref_init_measurement_units();
451
452 }
453
454
455 /*
456 ** load preference from homedir/.homebank (HB_DATA_PATH)
457 */
458 static void homebank_pref_get_wingeometry(
459 GKeyFile *key_file,
460 const gchar *group_name,
461 const gchar *key,
462 struct WinGeometry *storage)
463 {
464 if( g_key_file_has_key(key_file, group_name, key, NULL) )
465 {
466 gint *wg;
467 gsize length;
468
469 wg = g_key_file_get_integer_list(key_file, group_name, key, &length, NULL);
470 memcpy(storage, wg, 5*sizeof(gint));
471 g_free(wg);
472 // #606613 ensure left/top to be > 0
473 if(storage->l < 0)
474 storage->l = 0;
475
476 if(storage->t < 0)
477 storage->t = 0;
478 }
479 }
480
481
482
483
484 static void homebank_pref_get_boolean(
485 GKeyFile *key_file,
486 const gchar *group_name,
487 const gchar *key,
488 gboolean *storage)
489 {
490
491 if( g_key_file_has_key(key_file, group_name, key, NULL) )
492 {
493 *storage = g_key_file_get_boolean(key_file, group_name, key, NULL);
494 }
495 }
496
497 static void homebank_pref_get_integer(
498 GKeyFile *key_file,
499 const gchar *group_name,
500 const gchar *key,
501 gint *storage)
502 {
503
504 DB( g_print(" search %s in %s\n", key, group_name) );
505
506
507 if( g_key_file_has_key(key_file, group_name, key, NULL) )
508 {
509 *storage = g_key_file_get_integer(key_file, group_name, key, NULL);
510
511 DB( g_print(" store integer %d for %s at %x\n", *storage, key, *storage) );
512 }
513 }
514
515 static void homebank_pref_get_guint32(
516 GKeyFile *key_file,
517 const gchar *group_name,
518 const gchar *key,
519 guint32 *storage)
520 {
521
522 if( g_key_file_has_key(key_file, group_name, key, NULL) )
523 {
524 *storage = g_key_file_get_integer(key_file, group_name, key, NULL);
525 }
526 }
527
528 static void homebank_pref_get_short(
529 GKeyFile *key_file,
530 const gchar *group_name,
531 const gchar *key,
532 gshort *storage)
533 {
534
535 if( g_key_file_has_key(key_file, group_name, key, NULL) )
536 {
537 *storage = (gshort)g_key_file_get_integer(key_file, group_name, key, NULL);
538 }
539 }
540
541 static void homebank_pref_get_string(
542 GKeyFile *key_file,
543 const gchar *group_name,
544 const gchar *key,
545 gchar **storage)
546 {
547 gchar *string;
548
549 if( g_key_file_has_key(key_file, group_name, key, NULL) )
550 {
551 /* free any previous string */
552 if( *storage != NULL )
553 {
554 //DB( g_print(" storage was not null, freeing\n") );
555
556 g_free(*storage);
557 }
558
559 *storage = NULL;
560
561 string = g_key_file_get_string(key_file, group_name, key, NULL);
562 if( string != NULL )
563 {
564 *storage = g_strdup(string);
565
566 //DB( g_print(" store '%s' for %s at %x\n", string, key, *storage) );
567 }
568 }
569
570 /*
571 if (error)
572 {
573 g_warning ("error: %s\n", error->message);
574 g_error_free(error);
575 error = NULL;
576 }
577 */
578
579
580 }
581
582
583 static void homebank_pref_currfmt_convert(Currency *cur, gchar *prefix, gchar *suffix)
584 {
585
586 if( (prefix != NULL) && (strlen(prefix) > 0) )
587 {
588 cur->symbol = g_strdup(prefix);
589 cur->sym_prefix = TRUE;
590 }
591 else if( (suffix != NULL) )
592 {
593 cur->symbol = g_strdup(suffix);
594 cur->sym_prefix = FALSE;
595 }
596 }
597
598
599 gboolean homebank_pref_load(void)
600 {
601 GKeyFile *keyfile;
602 gboolean retval = FALSE;
603 gchar *group, *filename;
604 guint32 version;
605 GError *error = NULL;
606
607 DB( g_print("\n[preferences] pref load\n") );
608
609 keyfile = g_key_file_new();
610 if(keyfile)
611 {
612 filename = g_build_filename(homebank_app_get_config_dir(), "preferences", NULL );
613
614 DB( g_print(" - filename: %s\n", filename) );
615
616
617 if(g_key_file_load_from_file (keyfile, filename, G_KEY_FILE_NONE, NULL))
618 {
619
620 group = "General";
621
622 DB( g_print(" -> ** General\n") );
623
624 //since 4.51 version is integer
625 homebank_pref_get_guint32 (keyfile, group, "Version", &version);
626 if(version == 0) // old double number
627 {
628 gdouble v = g_key_file_get_double (keyfile, group, "Version", NULL);
629 version = (guint32)(v * 10);
630 }
631
632 DB( g_print(" - version: %d\n", version) );
633
634 homebank_pref_get_string(keyfile, group, "Language", &PREFS->language);
635
636 homebank_pref_get_short(keyfile, group, "BarStyle" , &PREFS->toolbar_style);
637
638 if(version <= 6 && PREFS->toolbar_style == 0) // force system to text beside
639 {
640 PREFS->toolbar_style = 4;
641 }
642
643 if(version <= 2) // retrieve old settings
644 {
645 guint32 color;
646
647 homebank_pref_get_guint32(keyfile, group, "ColorExp" , &color);
648 g_free(PREFS->color_exp);
649 PREFS->color_exp = g_strdup_printf("#%06x", color);
650
651 homebank_pref_get_guint32(keyfile, group, "ColorInc" , &color);
652 g_free(PREFS->color_inc);
653 PREFS->color_inc = g_strdup_printf("#%06x", color);
654
655 homebank_pref_get_guint32(keyfile, group, "ColorWarn", &color);
656 g_free(PREFS->color_warn);
657 PREFS->color_warn = g_strdup_printf("#%06x", color);
658 }
659 else
660 {
661 homebank_pref_get_boolean(keyfile, group, "CustomColors", &PREFS->custom_colors);
662
663 homebank_pref_get_string(keyfile, group, "ColorExp" , &PREFS->color_exp);
664 homebank_pref_get_string(keyfile, group, "ColorInc" , &PREFS->color_inc);
665 homebank_pref_get_string(keyfile, group, "ColorWarn", &PREFS->color_warn);
666
667 if( version <= 500 )
668 {
669 gboolean rules_hint;
670 homebank_pref_get_boolean(keyfile, group, "RulesHint", &rules_hint);
671 if( rules_hint == TRUE )
672 PREFS->grid_lines = GTK_TREE_VIEW_GRID_LINES_HORIZONTAL;
673
674 }
675 else
676 homebank_pref_get_short(keyfile, group, "GridLines", &PREFS->grid_lines);
677 }
678
679 DB( g_print(" - color exp: %s\n", PREFS->color_exp) );
680 DB( g_print(" - color inc: %s\n", PREFS->color_inc) );
681 DB( g_print(" - color wrn: %s\n", PREFS->color_warn) );
682
683
684 homebank_pref_get_string(keyfile, group, "WalletPath", &PREFS->path_hbfile);
685 homebank_pref_get_string(keyfile, group, "ImportPath", &PREFS->path_import);
686 homebank_pref_get_string(keyfile, group, "ExportPath", &PREFS->path_export);
687
688 homebank_pref_get_boolean(keyfile, group, "ShowSplash", &PREFS->showsplash);
689 homebank_pref_get_boolean(keyfile, group, "LoadLast", &PREFS->loadlast);
690 homebank_pref_get_boolean(keyfile, group, "AppendScheduled", &PREFS->appendscheduled);
691 homebank_pref_get_boolean(keyfile, group, "UpdateCurrency", &PREFS->do_update_currency);
692
693 homebank_pref_get_boolean(keyfile, group, "HeritDate", &PREFS->heritdate);
694 homebank_pref_get_boolean(keyfile, group, "HideReconciled", &PREFS->hidereconciled);
695 homebank_pref_get_boolean(keyfile, group, "ShowRemind", &PREFS->showremind);
696
697 if( g_key_file_has_key(keyfile, group, "ColumnsOpe", NULL) )
698 {
699 gboolean *bsrc;
700 gint *src, i, j;
701 gsize length;
702
703 if(version <= 2) //retrieve old 0.1 or 0.2 visibility boolean
704 {
705 bsrc = g_key_file_get_boolean_list(keyfile, group, "ColumnsOpe", &length, &error);
706 if( length == NUM_LST_DSPOPE-1 )
707 {
708 //and convert
709 for(i=0; i<NUM_LST_DSPOPE-1 ; i++)
710 {
711 PREFS->lst_ope_columns[i] = (bsrc[i] == TRUE) ? i+1 : -(i+1);
712 }
713 }
714 g_free(bsrc);
715 }
716 else
717 {
718 src = g_key_file_get_integer_list(keyfile, group, "ColumnsOpe", &length, &error);
719
720 DB( g_print(" - length %d (max=%d)\n", length, NUM_LST_DSPOPE) );
721
722 if( length == NUM_LST_DSPOPE-1 )
723 {
724 DB( g_print(" - copying column order from pref file\n") );
725 memcpy(PREFS->lst_ope_columns, src, length*sizeof(gint));
726 }
727 else
728 {
729 if(version <= 7)
730 {
731 if( length == NUM_LST_DSPOPE-2 ) //1 less column before v4.5.1
732 {
733 DB( g_print(" - upgrade from v7\n") );
734 DB( g_print(" - copying column order from pref file\n") );
735 memcpy(PREFS->lst_ope_columns, src, length*sizeof(gint));
736 //append balance column
737 PREFS->lst_ope_columns[10] = LST_DSPOPE_BALANCE;
738 }
739 }
740
741 if(version < 500)
742 {
743 if( length == NUM_LST_DSPOPE-2 ) //1 less column before v4.5.1
744 {
745 DB( g_print(" - upgrade prior v5.0\n") );
746 DB( g_print(" - copying column order from pref file\n") );
747 gboolean added = FALSE;
748 for(i=0,j=0; i<NUM_LST_DSPOPE-1 ; i++)
749 {
750 if( added == FALSE &&
751 (ABS(src[i]) == LST_DSPOPE_AMOUNT ||
752 ABS(src[i]) == LST_DSPOPE_EXPENSE ||
753 ABS(src[i]) == LST_DSPOPE_INCOME) )
754 {
755 PREFS->lst_ope_columns[j++] = LST_DSPOPE_CLR;
756 added = TRUE;
757 }
758 PREFS->lst_ope_columns[j++] = src[i];
759 }
760 }
761 }
762
763 }
764
765 g_free(src);
766 }
767
768 }
769
770 if( g_key_file_has_key(keyfile, group, "ColumnsOpeWidth", NULL) )
771 {
772 gint *src;
773 gsize length;
774
775 src = g_key_file_get_integer_list(keyfile, group, "ColumnsOpeWidth", &length, &error);
776
777 DB( g_print(" - length %d (max=%d)\n", length, NUM_LST_DSPOPE) );
778
779 if( length == NUM_LST_DSPOPE-1 )
780 {
781 DB( g_print(" - copying column width from pref file\n") );
782 memcpy(PREFS->lst_ope_col_size, src, length*sizeof(gint));
783 }
784 }
785
786 homebank_pref_get_integer(keyfile, group, "OpeSortId", &PREFS->lst_ope_sort_id);
787 homebank_pref_get_integer(keyfile, group, "OpeSortOrder", &PREFS->lst_ope_sort_order);
788
789 DB( g_print(" - set sort to %d %d\n", PREFS->lst_ope_sort_id, PREFS->lst_ope_sort_order) );
790
791 homebank_pref_get_short(keyfile, group, "FiscYearDay", &PREFS->fisc_year_day);
792 homebank_pref_get_short(keyfile, group, "FiscYearMonth", &PREFS->fisc_year_month);
793
794
795 group = "Windows";
796
797 DB( g_print(" -> ** Windows\n") );
798
799 homebank_pref_get_wingeometry(keyfile, group, "Wal", &PREFS->wal_wg);
800 homebank_pref_get_wingeometry(keyfile, group, "Acc", &PREFS->acc_wg);
801 homebank_pref_get_wingeometry(keyfile, group, "Sta", &PREFS->sta_wg);
802 homebank_pref_get_wingeometry(keyfile, group, "Tme", &PREFS->tme_wg);
803 homebank_pref_get_wingeometry(keyfile, group, "Ove", &PREFS->ove_wg);
804 homebank_pref_get_wingeometry(keyfile, group, "Bud", &PREFS->bud_wg);
805 homebank_pref_get_wingeometry(keyfile, group, "Car", &PREFS->cst_wg);
806
807 homebank_pref_get_wingeometry(keyfile, group, "Txn", &PREFS->txn_wg);
808
809 if(version <= 7) //set maximize to 0
810 {
811 PREFS->wal_wg.s = 0;
812 PREFS->acc_wg.s = 0;
813 PREFS->txn_wg.s = 0;
814 PREFS->sta_wg.s = 0;
815 PREFS->tme_wg.s = 0;
816 PREFS->ove_wg.s = 0;
817 PREFS->bud_wg.s = 0;
818 PREFS->cst_wg.s = 0;
819 }
820 homebank_pref_get_integer(keyfile, group, "WalVPaned", &PREFS->wal_vpaned);
821 homebank_pref_get_integer(keyfile, group, "WalHPaned", &PREFS->wal_hpaned);
822 homebank_pref_get_boolean(keyfile, group, "WalToolbar", &PREFS->wal_toolbar);
823 homebank_pref_get_boolean(keyfile, group, "WalSpending", &PREFS->wal_spending);
824 homebank_pref_get_boolean(keyfile, group, "WalUpcoming", &PREFS->wal_upcoming);
825
826
827 group = "Format";
828
829 DB( g_print(" -> ** Format\n") );
830
831 homebank_pref_get_string(keyfile, group, "DateFmt", &PREFS->date_format);
832
833 if(version < 460)
834 {
835 gboolean useimperial;
836
837 homebank_pref_get_boolean(keyfile, group, "UKUnits", &useimperial);
838 if(useimperial)
839 {
840 PREFS->vehicle_unit_ismile = TRUE;
841 PREFS->vehicle_unit_isgal = TRUE;
842 }
843 }
844
845 homebank_pref_get_boolean(keyfile, group, "UnitIsMile", &PREFS->vehicle_unit_ismile);
846 homebank_pref_get_boolean(keyfile, group, "UnitIsGal", &PREFS->vehicle_unit_isgal);
847
848
849 group = "Filter";
850
851 DB( g_print(" -> ** Filter\n") );
852
853 homebank_pref_get_integer(keyfile, group, "DateRangeWal", &PREFS->date_range_wal);
854 homebank_pref_get_integer(keyfile, group, "DateRangeTxn", &PREFS->date_range_txn);
855 homebank_pref_get_integer(keyfile, group, "DateFutureNbDays", &PREFS->date_future_nbdays);
856 homebank_pref_get_integer(keyfile, group, "DateRangeRep", &PREFS->date_range_rep);
857
858 if(version <= 7)
859 {
860 // shift date range >= 5, since we inserted a new one at position 5
861 if(PREFS->date_range_wal >= FLT_RANGE_LASTYEAR)
862 PREFS->date_range_wal++;
863 if(PREFS->date_range_txn >= FLT_RANGE_LASTYEAR)
864 PREFS->date_range_txn++;
865 if(PREFS->date_range_rep >= FLT_RANGE_LASTYEAR)
866 PREFS->date_range_rep++;
867 }
868
869
870 group = "Euro";
871
872 DB( g_print(" -> ** Euro\n") );
873
874 //homebank_pref_get_string(keyfile, group, "DefCurrency" , &PREFS->curr_default);
875
876 homebank_pref_get_boolean(keyfile, group, "Active", &PREFS->euro_active);
877 homebank_pref_get_integer(keyfile, group, "Country", &PREFS->euro_country);
878
879 gchar *ratestr = g_key_file_get_string (keyfile, group, "ChangeRate", NULL);
880 if(ratestr != NULL) PREFS->euro_value = g_ascii_strtod(ratestr, NULL);
881
882 if(version <= 1)
883 {
884 homebank_pref_get_string(keyfile, group, "Symbol", &PREFS->minor_cur.symbol);
885 PREFS->minor_cur.frac_digits = g_key_file_get_integer (keyfile, group, "NBDec", NULL);
886
887 //PREFS->euro_nbdec = g_key_file_get_integer (keyfile, group, "NBDec", NULL);
888 //PREFS->euro_thsep = g_key_file_get_boolean (keyfile, group, "Sep", NULL);
889 //gchar *tmpstr = g_key_file_get_string (keyfile, group, "Symbol", &error);
890 }
891 else
892 {
893 if(version < 460)
894 {
895 gchar *prefix = NULL;
896 gchar *suffix = NULL;
897
898 homebank_pref_get_string(keyfile, group, "PreSymbol", &prefix);
899 homebank_pref_get_string(keyfile, group, "SufSymbol", &suffix);
900 homebank_pref_currfmt_convert(&PREFS->minor_cur, prefix, suffix);
901 g_free(prefix);
902 g_free(suffix);
903 }
904 else
905 {
906 homebank_pref_get_string(keyfile, group, "Symbol", &PREFS->minor_cur.symbol);
907 homebank_pref_get_boolean(keyfile, group, "IsPrefix", &PREFS->minor_cur.sym_prefix);
908 }
909 homebank_pref_get_string(keyfile, group, "DecChar" , &PREFS->minor_cur.decimal_char);
910 homebank_pref_get_string(keyfile, group, "GroupChar", &PREFS->minor_cur.grouping_char);
911 homebank_pref_get_short(keyfile, group, "FracDigits", &PREFS->minor_cur.frac_digits);
912
913 //fix 378992/421228
914 if( PREFS->minor_cur.frac_digits > MAX_FRAC_DIGIT )
915 PREFS->minor_cur.frac_digits = MAX_FRAC_DIGIT;
916
917 da_cur_initformat(&PREFS->minor_cur);
918 }
919
920 //PREFS->euro_symbol = g_locale_to_utf8(tmpstr, -1, NULL, NULL, NULL);
921
922 group = "Report";
923
924 DB( g_print(" -> ** Report\n") );
925
926 homebank_pref_get_boolean(keyfile, group, "StatByAmount", &PREFS->stat_byamount);
927 homebank_pref_get_boolean(keyfile, group, "StatDetail", &PREFS->stat_showdetail);
928 homebank_pref_get_boolean(keyfile, group, "StatRate", &PREFS->stat_showrate);
929 homebank_pref_get_boolean(keyfile, group, "BudgDetail", &PREFS->budg_showdetail);
930 homebank_pref_get_integer(keyfile, group, "ColorScheme", &PREFS->report_color_scheme);
931
932 group = "Exchange";
933
934 DB( g_print(" -> ** Exchange\n") );
935
936 //homebank_pref_get_boolean(keyfile, group, "DoIntro", &PREFS->dtex_nointro);
937 homebank_pref_get_integer(keyfile, group, "DateFmt", &PREFS->dtex_datefmt);
938 homebank_pref_get_integer(keyfile, group, "OfxName", &PREFS->dtex_ofxname);
939 homebank_pref_get_integer(keyfile, group, "OfxMemo", &PREFS->dtex_ofxmemo);
940 homebank_pref_get_boolean(keyfile, group, "QifMemo", &PREFS->dtex_qifmemo);
941 homebank_pref_get_boolean(keyfile, group, "QifSwap", &PREFS->dtex_qifswap);
942
943
944 //group = "Chart";
945 //PREFS->chart_legend = g_key_file_get_boolean (keyfile, group, "Legend", NULL);
946
947
948 group = "Plugins";
949 {
950 DB( g_print(" -> ** Plugins\n") );
951
952 gchar** strv = g_key_file_get_string_list(keyfile, group, "Path", NULL, NULL);
953 if (strv) {
954 g_strfreev(PREFS->ext_path);
955 PREFS->ext_path = strv;
956 }
957
958 strv = g_key_file_get_string_list(keyfile, group, "Whitelist", NULL, NULL);
959 if (strv) {
960 gchar** it;
961 for (it = strv; it && *it; ++it) {
962 PREFS->ext_whitelist = g_list_append(PREFS->ext_whitelist, g_strdup(*it));
963 }
964 g_strfreev(strv);
965 }
966 }
967
968
969 /*
970 #if MYDEBUG == 1
971 gsize length;
972 gchar *contents = g_key_file_to_data (keyfile, &length, NULL);
973 //g_print(" keyfile:\n%s\n len=%d\n", contents, length);
974 g_free(contents);
975 #endif
976 */
977
978 }
979 g_free(filename);
980 g_key_file_free (keyfile);
981
982 _homebank_pref_init_measurement_units();
983 }
984
985 return retval;
986 }
987
988 static void homebank_pref_set_string(
989 GKeyFile *key_file,
990 const gchar *group_name,
991 const gchar *key,
992 gchar *string)
993 {
994
995 DB( g_print(" - homebank_pref_set_string :: group='%s' key='%s' value='%s'\n", group_name, key, string) );
996
997 if( string != NULL && *string != '\0')
998 g_key_file_set_string (key_file, group_name, key, string);
999 else
1000 g_key_file_set_string (key_file, group_name, key, "");
1001
1002 }
1003
1004
1005 /*
1006 ** save preference to homedir/.homebank (HB_DATA_PATH)
1007 */
1008 gboolean homebank_pref_save(void)
1009 {
1010 GKeyFile *keyfile;
1011 gboolean retval = FALSE;
1012 gchar *group, *filename;
1013 gsize length;
1014
1015 DB( g_print("\n[preferences] pref save\n") );
1016
1017 keyfile = g_key_file_new();
1018 if(keyfile )
1019 {
1020
1021 DB( g_print(" -> ** general\n") );
1022
1023
1024 group = "General";
1025 g_key_file_set_integer (keyfile, group, "Version", PREF_VERSION);
1026
1027 homebank_pref_set_string (keyfile, group, "Language", PREFS->language);
1028
1029 g_key_file_set_integer (keyfile, group, "BarStyle", PREFS->toolbar_style);
1030 //g_key_file_set_integer (keyfile, group, "BarImageSize", PREFS->image_size);
1031
1032 g_key_file_set_boolean (keyfile, group, "CustomColors", PREFS->custom_colors);
1033 g_key_file_set_string (keyfile, group, "ColorExp" , PREFS->color_exp);
1034 g_key_file_set_string (keyfile, group, "ColorInc" , PREFS->color_inc);
1035 g_key_file_set_string (keyfile, group, "ColorWarn", PREFS->color_warn);
1036
1037 g_key_file_set_integer (keyfile, group, "GridLines", PREFS->grid_lines);
1038
1039 homebank_pref_set_string (keyfile, group, "WalletPath" , PREFS->path_hbfile);
1040 homebank_pref_set_string (keyfile, group, "ImportPath" , PREFS->path_import);
1041 homebank_pref_set_string (keyfile, group, "ExportPath" , PREFS->path_export);
1042 //g_key_file_set_string (keyfile, group, "NavigatorPath", PREFS->path_navigator);
1043
1044 g_key_file_set_boolean (keyfile, group, "ShowSplash", PREFS->showsplash);
1045 g_key_file_set_boolean (keyfile, group, "LoadLast", PREFS->loadlast);
1046 g_key_file_set_boolean (keyfile, group, "AppendScheduled", PREFS->appendscheduled);
1047 g_key_file_set_boolean (keyfile, group, "UpdateCurrency", PREFS->do_update_currency);
1048
1049 g_key_file_set_boolean (keyfile, group, "HeritDate", PREFS->heritdate);
1050 g_key_file_set_boolean (keyfile, group, "HideReconciled", PREFS->hidereconciled);
1051 g_key_file_set_boolean (keyfile, group, "ShowRemind", PREFS->showremind);
1052
1053 g_key_file_set_integer_list(keyfile, group, "ColumnsOpe", PREFS->lst_ope_columns, NUM_LST_DSPOPE-1);
1054 g_key_file_set_integer_list(keyfile, group, "ColumnsOpeWidth", PREFS->lst_ope_col_size, NUM_LST_DSPOPE-1);
1055 g_key_file_set_integer (keyfile, group, "OpeSortId" , PREFS->lst_ope_sort_id);
1056 g_key_file_set_integer (keyfile, group, "OpeSortOrder" , PREFS->lst_ope_sort_order);
1057
1058 g_key_file_set_integer (keyfile, group, "FiscYearDay" , PREFS->fisc_year_day);
1059 g_key_file_set_integer (keyfile, group, "FiscYearMonth" , PREFS->fisc_year_month);
1060
1061 // added v3.4
1062 DB( g_print(" -> ** windows\n") );
1063
1064 group = "Windows";
1065 g_key_file_set_integer_list(keyfile, group, "Wal", (gint *)&PREFS->wal_wg, 5);
1066 g_key_file_set_integer_list(keyfile, group, "Acc", (gint *)&PREFS->acc_wg, 5);
1067 g_key_file_set_integer_list(keyfile, group, "Sta", (gint *)&PREFS->sta_wg, 5);
1068 g_key_file_set_integer_list(keyfile, group, "Tme", (gint *)&PREFS->tme_wg, 5);
1069 g_key_file_set_integer_list(keyfile, group, "Ove", (gint *)&PREFS->ove_wg, 5);
1070 g_key_file_set_integer_list(keyfile, group, "Bud", (gint *)&PREFS->bud_wg, 5);
1071 g_key_file_set_integer_list(keyfile, group, "Car", (gint *)&PREFS->cst_wg, 5);
1072
1073 g_key_file_set_integer_list(keyfile, group, "Txn", (gint *)&PREFS->txn_wg, 5);
1074
1075 g_key_file_set_integer (keyfile, group, "WalVPaned" , PREFS->wal_vpaned);
1076 g_key_file_set_integer (keyfile, group, "WalHPaned" , PREFS->wal_hpaned);
1077 g_key_file_set_boolean (keyfile, group, "WalToolbar", PREFS->wal_toolbar);
1078 g_key_file_set_boolean (keyfile, group, "WalSpending", PREFS->wal_spending);
1079 g_key_file_set_boolean (keyfile, group, "WalUpcoming", PREFS->wal_upcoming);
1080
1081
1082 DB( g_print(" -> ** format\n") );
1083
1084 group = "Format";
1085 homebank_pref_set_string (keyfile, group, "DateFmt" , PREFS->date_format);
1086
1087 //g_key_file_set_boolean (keyfile, group, "UKUnits" , PREFS->imperial_unit);
1088 g_key_file_set_boolean (keyfile, group, "UnitIsMile" , PREFS->vehicle_unit_ismile);
1089 g_key_file_set_boolean (keyfile, group, "UnitIsGal" , PREFS->vehicle_unit_isgal);
1090
1091
1092 DB( g_print(" -> ** filter\n") );
1093
1094 group = "Filter";
1095 g_key_file_set_integer (keyfile, group, "DateRangeWal", PREFS->date_range_wal);
1096 g_key_file_set_integer (keyfile, group, "DateRangeTxn", PREFS->date_range_txn);
1097 g_key_file_set_integer (keyfile, group, "DateFutureNbdays", PREFS->date_future_nbdays);
1098 g_key_file_set_integer (keyfile, group, "DateRangeRep", PREFS->date_range_rep);
1099
1100 DB( g_print(" -> ** euro\n") );
1101
1102 //euro options
1103 group = "Euro";
1104
1105 //homebank_pref_set_string(keyfile, group, "DefCurrency" , PREFS->curr_default);
1106
1107 g_key_file_set_boolean (keyfile, group, "Active" , PREFS->euro_active);
1108 if( PREFS->euro_active )
1109 {
1110 g_key_file_set_integer (keyfile, group, "Country", PREFS->euro_country);
1111 gchar ratestr[64];
1112 g_ascii_dtostr(ratestr, 63, PREFS->euro_value);
1113 homebank_pref_set_string (keyfile, group, "ChangeRate", ratestr);
1114 homebank_pref_set_string (keyfile, group, "Symbol" , PREFS->minor_cur.symbol);
1115 g_key_file_set_boolean (keyfile, group, "IsPrefix" , PREFS->minor_cur.sym_prefix);
1116 homebank_pref_set_string (keyfile, group, "DecChar" , PREFS->minor_cur.decimal_char);
1117 homebank_pref_set_string (keyfile, group, "GroupChar" , PREFS->minor_cur.grouping_char);
1118 g_key_file_set_integer (keyfile, group, "FracDigits", PREFS->minor_cur.frac_digits);
1119 }
1120
1121 //report options
1122 DB( g_print(" -> ** report\n") );
1123
1124 group = "Report";
1125 g_key_file_set_boolean (keyfile, group, "StatByAmount", PREFS->stat_byamount);
1126 g_key_file_set_boolean (keyfile, group, "StatDetail" , PREFS->stat_showdetail);
1127 g_key_file_set_boolean (keyfile, group, "StatRate" , PREFS->stat_showrate);
1128 g_key_file_set_boolean (keyfile, group, "BudgDetail" , PREFS->budg_showdetail);
1129 g_key_file_set_integer (keyfile, group, "ColorScheme" , PREFS->report_color_scheme);
1130
1131
1132 group = "Exchange";
1133 //g_key_file_set_boolean (keyfile, group, "DoIntro", PREFS->dtex_nointro);
1134 g_key_file_set_integer (keyfile, group, "DateFmt", PREFS->dtex_datefmt);
1135 g_key_file_set_integer (keyfile, group, "OfxName", PREFS->dtex_ofxname);
1136 g_key_file_set_integer (keyfile, group, "OfxMemo", PREFS->dtex_ofxmemo);
1137 g_key_file_set_boolean (keyfile, group, "QifMemo", PREFS->dtex_qifmemo);
1138 g_key_file_set_boolean (keyfile, group, "QifSwap", PREFS->dtex_qifswap);
1139
1140
1141 //group = "Chart";
1142 //g_key_file_set_boolean (keyfile, group, "Legend", PREFS->chart_legend);
1143
1144 group = "Plugins";
1145 {
1146 g_key_file_set_string_list(keyfile, group, "Path", (const gchar* const*)PREFS->ext_path, g_strv_length(PREFS->ext_path));
1147
1148 gsize len = g_list_length(PREFS->ext_whitelist);
1149 gchar** strv = g_new0(gchar*, len + 1);
1150 guint i;
1151
1152 for (i = 0; i < len; ++i) {
1153 strv[i] = g_list_nth_data(PREFS->ext_whitelist, i);
1154 }
1155 g_key_file_set_string_list(keyfile, group, "Whitelist", (const gchar* const*)strv, len);
1156 g_free(strv);
1157 }
1158
1159 //g_key_file_set_string (keyfile, group, "", PREFS->);
1160 //g_key_file_set_boolean (keyfile, group, "", PREFS->);
1161 //g_key_file_set_integer (keyfile, group, "", PREFS->);
1162
1163 DB( g_print(" -> ** g_key_file_to_data\n") );
1164
1165 gchar *contents = g_key_file_to_data (keyfile, &length, NULL);
1166
1167 //DB( g_print(" keyfile:\n%s\nlen=%d\n", contents, length) );
1168
1169 filename = g_build_filename(homebank_app_get_config_dir(), "preferences", NULL );
1170
1171 DB( g_print(" -> filename: %s\n", filename) );
1172
1173 g_file_set_contents(filename, contents, length, NULL);
1174
1175 DB( g_print(" -> contents: %s\n", contents) );
1176
1177 DB( g_print(" -> freeing filename\n") );
1178 g_free(filename);
1179
1180 DB( g_print(" -> freeing buffer\n") );
1181
1182 g_free(contents);
1183
1184 DB( g_print(" -> freeing keyfile\n") );
1185
1186 g_key_file_free (keyfile);
1187 }
1188
1189 _homebank_pref_init_measurement_units();
1190
1191 return retval;
1192 }
1193
This page took 0.091207 seconds and 4 git commands to generate.