]> Dogcows Code - chaz/homebank/blob - src/hb-preferences.c
db7b3ed5a2adffbf11420f18a57f87a4d7e026d0
[chaz/homebank] / src / hb-preferences.c
1 /* HomeBank -- Free, easy, personal accounting for everyone.
2 * Copyright (C) 1995-2018 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 memset(PREFS, 0, sizeof(struct Preferences));
298 }
299
300
301 void homebank_pref_setdefault(void)
302 {
303 gint i;
304
305 DB( g_print("\n[preferences] pref init\n") );
306
307 homebank_pref_free();
308
309 PREFS->language = NULL;
310
311 PREFS->date_format = g_strdup(DEFAULT_FORMAT_DATE);
312
313 PREFS->path_hbfile = g_strdup_printf("%s", g_get_home_dir ());
314 PREFS->path_import = g_strdup_printf("%s", g_get_home_dir ());
315 PREFS->path_export = g_strdup_printf("%s", g_get_home_dir ());
316 //PREFS->path_navigator = g_strdup(DEFAULT_PATH_NAVIGATOR);
317
318 PREFS->showsplash = TRUE;
319 PREFS->loadlast = TRUE;
320 PREFS->appendscheduled = FALSE;
321 PREFS->do_update_currency = FALSE;
322
323 PREFS->heritdate = FALSE;
324 PREFS->hidereconciled = FALSE;
325 PREFS->showremind = TRUE;
326
327 PREFS->toolbar_style = 4; //text beside icons
328 PREFS->custom_colors = TRUE;
329 PREFS->color_exp = g_strdup(DEFAULT_EXP_COLOR);
330 PREFS->color_inc = g_strdup(DEFAULT_INC_COLOR);
331 PREFS->color_warn = g_strdup(DEFAULT_WARN_COLOR);
332 PREFS->grid_lines = GTK_TREE_VIEW_GRID_LINES_NONE;
333
334 /* fiscal year */
335 PREFS->fisc_year_day = 1;
336 PREFS->fisc_year_month = 1;
337
338 /* windows position/size */
339 homebank_pref_init_wingeometry(&PREFS->wal_wg, 0, 0, 1024, 600);
340 homebank_pref_init_wingeometry(&PREFS->acc_wg, 0, 0, 1024, 600);
341 homebank_pref_init_wingeometry(&PREFS->sta_wg, 0, 0, 800, 494);
342 homebank_pref_init_wingeometry(&PREFS->tme_wg, 0, 0, 800, 494);
343 homebank_pref_init_wingeometry(&PREFS->ove_wg, 0, 0, 800, 494);
344 homebank_pref_init_wingeometry(&PREFS->bud_wg, 0, 0, 800, 494);
345 homebank_pref_init_wingeometry(&PREFS->cst_wg, 0, 0, 800, 494);
346
347 homebank_pref_init_wingeometry(&PREFS->txn_wg, 0, 0, -1, -1);
348
349 homebank_pref_init_monetary();
350
351 PREFS->wal_toolbar = TRUE;
352 PREFS->wal_spending = TRUE;
353 PREFS->wal_upcoming = TRUE;
354 PREFS->wal_vpaned = 600/2;
355 PREFS->wal_hpaned = 1024/2;
356
357 PREFS->pnl_acc_col_acc_width = -1;
358 PREFS->pnl_acc_show_by = 0;
359 PREFS->pnl_upc_col_pay_width = -1;
360 PREFS->pnl_upc_col_mem_width = -1;
361
362
363 i = 0;
364 /* prior v4.5
365 PREFS->lst_ope_columns[i++] = LST_DSPOPE_STATUS;
366 PREFS->lst_ope_columns[i++] = LST_DSPOPE_DATE;
367 PREFS->lst_ope_columns[i++] = LST_DSPOPE_INFO;
368 PREFS->lst_ope_columns[i++] = LST_DSPOPE_PAYEE;
369 PREFS->lst_ope_columns[i++] = LST_DSPOPE_MEMO;
370 PREFS->lst_ope_columns[i++] = -LST_DSPOPE_AMOUNT;
371 PREFS->lst_ope_columns[i++] = LST_DSPOPE_EXPENSE;
372 PREFS->lst_ope_columns[i++] = LST_DSPOPE_INCOME;
373 PREFS->lst_ope_columns[i++] = LST_DSPOPE_CATEGORY;
374 PREFS->lst_ope_columns[i++] = LST_DSPOPE_TAGS;
375 */
376 PREFS->lst_ope_columns[i++] = LST_DSPOPE_STATUS; //always displayed
377 PREFS->lst_ope_columns[i++] = LST_DSPOPE_DATE; //always displayed
378 PREFS->lst_ope_columns[i++] = LST_DSPOPE_INFO;
379 PREFS->lst_ope_columns[i++] = LST_DSPOPE_PAYEE;
380 PREFS->lst_ope_columns[i++] = LST_DSPOPE_CATEGORY;
381 PREFS->lst_ope_columns[i++] = LST_DSPOPE_TAGS;
382 PREFS->lst_ope_columns[i++] = LST_DSPOPE_CLR;
383 PREFS->lst_ope_columns[i++] = -LST_DSPOPE_AMOUNT;
384 PREFS->lst_ope_columns[i++] = LST_DSPOPE_EXPENSE;
385 PREFS->lst_ope_columns[i++] = LST_DSPOPE_INCOME;
386 PREFS->lst_ope_columns[i++] = LST_DSPOPE_BALANCE;
387 PREFS->lst_ope_columns[i++] = LST_DSPOPE_MEMO;
388
389 PREFS->lst_ope_sort_id = LST_DSPOPE_DATE;
390 PREFS->lst_ope_sort_order = GTK_SORT_ASCENDING;
391
392 for( i=0;i<NUM_LST_DSPOPE;i++)
393 PREFS->lst_ope_col_size[i] = -1;
394
395 //PREFS->base_cur.nbdecimal = 2;
396 //PREFS->base_cur.separator = TRUE;
397
398 PREFS->date_range_wal = FLT_RANGE_LASTMONTH;
399 PREFS->date_range_txn = FLT_RANGE_LAST12MONTHS;
400 PREFS->date_future_nbdays = 0;
401 PREFS->date_range_rep = FLT_RANGE_THISYEAR;
402
403 //import/export
404 PREFS->dtex_nointro = TRUE;
405 //PREFS->dtex_datefmt
406 PREFS->dtex_ofxname = 1;
407 PREFS->dtex_ofxmemo = 2;
408 PREFS->dtex_qifmemo = TRUE;
409 PREFS->dtex_qifswap = FALSE;
410
411 //todo: add intelligence here
412 PREFS->euro_active = FALSE;
413
414 PREFS->euro_country = 0;
415 PREFS->euro_value = 1.0;
416
417 da_cur_initformat(&PREFS->minor_cur);
418
419 //PREFS->euro_nbdec = 2;
420 //PREFS->euro_thsep = TRUE;
421 //PREFS->euro_symbol = g_strdup("??");
422
423 PREFS->stat_byamount = FALSE;
424 PREFS->stat_showdetail = FALSE;
425 PREFS->stat_showrate = FALSE;
426 PREFS->budg_showdetail = FALSE;
427 PREFS->report_color_scheme = CHART_COLMAP_HOMEBANK;
428
429 //PREFS->chart_legend = FALSE;
430
431 PREFS->vehicle_unit_ismile = FALSE;
432 PREFS->vehicle_unit_isgal = FALSE;
433
434 _homebank_pref_init_measurement_units();
435
436 }
437
438
439 /*
440 ** load preference from homedir/.homebank (HB_DATA_PATH)
441 */
442 static void homebank_pref_get_wingeometry(
443 GKeyFile *key_file,
444 const gchar *group_name,
445 const gchar *key,
446 struct WinGeometry *storage)
447 {
448 if( g_key_file_has_key(key_file, group_name, key, NULL) )
449 {
450 gint *wg;
451 gsize length;
452
453 wg = g_key_file_get_integer_list(key_file, group_name, key, &length, NULL);
454 memcpy(storage, wg, 5*sizeof(gint));
455 g_free(wg);
456 // #606613 ensure left/top to be > 0
457 if(storage->l < 0)
458 storage->l = 0;
459
460 if(storage->t < 0)
461 storage->t = 0;
462 }
463 }
464
465
466
467
468 static void homebank_pref_get_boolean(
469 GKeyFile *key_file,
470 const gchar *group_name,
471 const gchar *key,
472 gboolean *storage)
473 {
474
475 if( g_key_file_has_key(key_file, group_name, key, NULL) )
476 {
477 *storage = g_key_file_get_boolean(key_file, group_name, key, NULL);
478 }
479 }
480
481 static void homebank_pref_get_integer(
482 GKeyFile *key_file,
483 const gchar *group_name,
484 const gchar *key,
485 gint *storage)
486 {
487
488 DB( g_print(" search %s in %s\n", key, group_name) );
489
490
491 if( g_key_file_has_key(key_file, group_name, key, NULL) )
492 {
493 *storage = g_key_file_get_integer(key_file, group_name, key, NULL);
494
495 DB( g_print(" store integer %d for %s at %x\n", *storage, key, *storage) );
496 }
497 }
498
499 static void homebank_pref_get_guint32(
500 GKeyFile *key_file,
501 const gchar *group_name,
502 const gchar *key,
503 guint32 *storage)
504 {
505
506 if( g_key_file_has_key(key_file, group_name, key, NULL) )
507 {
508 *storage = g_key_file_get_integer(key_file, group_name, key, NULL);
509 }
510 }
511
512 static void homebank_pref_get_short(
513 GKeyFile *key_file,
514 const gchar *group_name,
515 const gchar *key,
516 gshort *storage)
517 {
518
519 if( g_key_file_has_key(key_file, group_name, key, NULL) )
520 {
521 *storage = (gshort)g_key_file_get_integer(key_file, group_name, key, NULL);
522 }
523 }
524
525 static void homebank_pref_get_string(
526 GKeyFile *key_file,
527 const gchar *group_name,
528 const gchar *key,
529 gchar **storage)
530 {
531 gchar *string;
532
533 if( g_key_file_has_key(key_file, group_name, key, NULL) )
534 {
535 /* free any previous string */
536 if( *storage != NULL )
537 {
538 //DB( g_print(" storage was not null, freeing\n") );
539
540 g_free(*storage);
541 }
542
543 *storage = NULL;
544
545 string = g_key_file_get_string(key_file, group_name, key, NULL);
546 if( string != NULL )
547 {
548 //*storage = g_strdup(string);
549 //leak
550 *storage = string; //already a new allocated string
551
552 //DB( g_print(" store '%s' for %s at %x\n", string, key, *storage) );
553 }
554 }
555
556 /*
557 if (error)
558 {
559 g_warning ("error: %s\n", error->message);
560 g_error_free(error);
561 error = NULL;
562 }
563 */
564
565
566 }
567
568
569 static void homebank_pref_currfmt_convert(Currency *cur, gchar *prefix, gchar *suffix)
570 {
571
572 if( (prefix != NULL) && (strlen(prefix) > 0) )
573 {
574 cur->symbol = g_strdup(prefix);
575 cur->sym_prefix = TRUE;
576 }
577 else if( (suffix != NULL) )
578 {
579 cur->symbol = g_strdup(suffix);
580 cur->sym_prefix = FALSE;
581 }
582 }
583
584
585 gboolean homebank_pref_load(void)
586 {
587 GKeyFile *keyfile;
588 gboolean retval = FALSE;
589 gchar *group, *filename;
590 guint32 version;
591 GError *error = NULL;
592
593 DB( g_print("\n[preferences] pref load\n") );
594
595 keyfile = g_key_file_new();
596 if(keyfile)
597 {
598 filename = g_build_filename(homebank_app_get_config_dir(), "preferences", NULL );
599
600 DB( g_print(" - filename: %s\n", filename) );
601
602
603 if(g_key_file_load_from_file (keyfile, filename, G_KEY_FILE_NONE, NULL))
604 {
605
606 group = "General";
607
608 DB( g_print(" -> ** General\n") );
609
610 //since 4.51 version is integer
611 homebank_pref_get_guint32 (keyfile, group, "Version", &version);
612 if(version == 0) // old double number
613 {
614 gdouble v = g_key_file_get_double (keyfile, group, "Version", NULL);
615 version = (guint32)(v * 10);
616 }
617
618 DB( g_print(" - version: %d\n", version) );
619
620 homebank_pref_get_string(keyfile, group, "Language", &PREFS->language);
621
622 homebank_pref_get_short(keyfile, group, "BarStyle" , &PREFS->toolbar_style);
623
624 if(version <= 6 && PREFS->toolbar_style == 0) // force system to text beside
625 {
626 PREFS->toolbar_style = 4;
627 }
628
629 if(version <= 2) // retrieve old settings
630 {
631 guint32 color;
632
633 homebank_pref_get_guint32(keyfile, group, "ColorExp" , &color);
634 g_free(PREFS->color_exp);
635 PREFS->color_exp = g_strdup_printf("#%06x", color);
636
637 homebank_pref_get_guint32(keyfile, group, "ColorInc" , &color);
638 g_free(PREFS->color_inc);
639 PREFS->color_inc = g_strdup_printf("#%06x", color);
640
641 homebank_pref_get_guint32(keyfile, group, "ColorWarn", &color);
642 g_free(PREFS->color_warn);
643 PREFS->color_warn = g_strdup_printf("#%06x", color);
644 }
645 else
646 {
647 homebank_pref_get_boolean(keyfile, group, "CustomColors", &PREFS->custom_colors);
648
649 homebank_pref_get_string(keyfile, group, "ColorExp" , &PREFS->color_exp);
650 homebank_pref_get_string(keyfile, group, "ColorInc" , &PREFS->color_inc);
651 homebank_pref_get_string(keyfile, group, "ColorWarn", &PREFS->color_warn);
652
653 if( version <= 500 )
654 {
655 gboolean rules_hint;
656 homebank_pref_get_boolean(keyfile, group, "RulesHint", &rules_hint);
657 if( rules_hint == TRUE )
658 PREFS->grid_lines = GTK_TREE_VIEW_GRID_LINES_HORIZONTAL;
659
660 }
661 else
662 homebank_pref_get_short(keyfile, group, "GridLines", &PREFS->grid_lines);
663 }
664
665 DB( g_print(" - color exp: %s\n", PREFS->color_exp) );
666 DB( g_print(" - color inc: %s\n", PREFS->color_inc) );
667 DB( g_print(" - color wrn: %s\n", PREFS->color_warn) );
668
669
670 homebank_pref_get_string(keyfile, group, "WalletPath", &PREFS->path_hbfile);
671 homebank_pref_get_string(keyfile, group, "ImportPath", &PREFS->path_import);
672 homebank_pref_get_string(keyfile, group, "ExportPath", &PREFS->path_export);
673
674 homebank_pref_get_boolean(keyfile, group, "ShowSplash", &PREFS->showsplash);
675 homebank_pref_get_boolean(keyfile, group, "LoadLast", &PREFS->loadlast);
676 homebank_pref_get_boolean(keyfile, group, "AppendScheduled", &PREFS->appendscheduled);
677 homebank_pref_get_boolean(keyfile, group, "UpdateCurrency", &PREFS->do_update_currency);
678
679 homebank_pref_get_boolean(keyfile, group, "HeritDate", &PREFS->heritdate);
680 homebank_pref_get_boolean(keyfile, group, "HideReconciled", &PREFS->hidereconciled);
681 homebank_pref_get_boolean(keyfile, group, "ShowRemind", &PREFS->showremind);
682
683 if( g_key_file_has_key(keyfile, group, "ColumnsOpe", NULL) )
684 {
685 gboolean *bsrc;
686 gint *src, i, j;
687 gsize length;
688
689 if(version <= 2) //retrieve old 0.1 or 0.2 visibility boolean
690 {
691 bsrc = g_key_file_get_boolean_list(keyfile, group, "ColumnsOpe", &length, &error);
692 if( length == NUM_LST_DSPOPE-1 )
693 {
694 //and convert
695 for(i=0; i<NUM_LST_DSPOPE-1 ; i++)
696 {
697 PREFS->lst_ope_columns[i] = (bsrc[i] == TRUE) ? i+1 : -(i+1);
698 }
699 }
700 g_free(bsrc);
701 }
702 else
703 {
704 src = g_key_file_get_integer_list(keyfile, group, "ColumnsOpe", &length, &error);
705
706 DB( g_print(" - length %d (max=%d)\n", length, NUM_LST_DSPOPE) );
707
708 if( length == NUM_LST_DSPOPE-1 )
709 {
710 DB( g_print(" - copying column order from pref file\n") );
711 memcpy(PREFS->lst_ope_columns, src, length*sizeof(gint));
712 }
713 else
714 {
715 if(version <= 7)
716 {
717 if( length == NUM_LST_DSPOPE-2 ) //1 less column before v4.5.1
718 {
719 DB( g_print(" - upgrade from v7\n") );
720 DB( g_print(" - copying column order from pref file\n") );
721 memcpy(PREFS->lst_ope_columns, src, length*sizeof(gint));
722 //append balance column
723 PREFS->lst_ope_columns[10] = LST_DSPOPE_BALANCE;
724 }
725 }
726
727 if(version < 500)
728 {
729 if( length == NUM_LST_DSPOPE-2 ) //1 less column before v4.5.1
730 {
731 DB( g_print(" - upgrade prior v5.0\n") );
732 DB( g_print(" - copying column order from pref file\n") );
733 gboolean added = FALSE;
734 for(i=0,j=0; i<NUM_LST_DSPOPE-1 ; i++)
735 {
736 if( added == FALSE &&
737 (ABS(src[i]) == LST_DSPOPE_AMOUNT ||
738 ABS(src[i]) == LST_DSPOPE_EXPENSE ||
739 ABS(src[i]) == LST_DSPOPE_INCOME) )
740 {
741 PREFS->lst_ope_columns[j++] = LST_DSPOPE_CLR;
742 added = TRUE;
743 }
744 PREFS->lst_ope_columns[j++] = src[i];
745 }
746 }
747 }
748
749 }
750
751 g_free(src);
752 }
753
754 }
755
756 if( g_key_file_has_key(keyfile, group, "ColumnsOpeWidth", NULL) )
757 {
758 gint *src;
759 gsize length;
760
761 src = g_key_file_get_integer_list(keyfile, group, "ColumnsOpeWidth", &length, &error);
762
763 DB( g_print(" - length %d (max=%d)\n", length, NUM_LST_DSPOPE) );
764
765 if( length == NUM_LST_DSPOPE-1 )
766 {
767 DB( g_print(" - copying column width from pref file\n") );
768 memcpy(PREFS->lst_ope_col_size, src, length*sizeof(gint));
769 }
770
771 //leak
772 g_free(src);
773
774 }
775
776 homebank_pref_get_integer(keyfile, group, "OpeSortId", &PREFS->lst_ope_sort_id);
777 homebank_pref_get_integer(keyfile, group, "OpeSortOrder", &PREFS->lst_ope_sort_order);
778
779 DB( g_print(" - set sort to %d %d\n", PREFS->lst_ope_sort_id, PREFS->lst_ope_sort_order) );
780
781 homebank_pref_get_short(keyfile, group, "FiscYearDay", &PREFS->fisc_year_day);
782 homebank_pref_get_short(keyfile, group, "FiscYearMonth", &PREFS->fisc_year_month);
783
784
785 group = "Windows";
786
787 DB( g_print(" -> ** Windows\n") );
788
789 homebank_pref_get_wingeometry(keyfile, group, "Wal", &PREFS->wal_wg);
790 homebank_pref_get_wingeometry(keyfile, group, "Acc", &PREFS->acc_wg);
791 homebank_pref_get_wingeometry(keyfile, group, "Sta", &PREFS->sta_wg);
792 homebank_pref_get_wingeometry(keyfile, group, "Tme", &PREFS->tme_wg);
793 homebank_pref_get_wingeometry(keyfile, group, "Ove", &PREFS->ove_wg);
794 homebank_pref_get_wingeometry(keyfile, group, "Bud", &PREFS->bud_wg);
795 homebank_pref_get_wingeometry(keyfile, group, "Car", &PREFS->cst_wg);
796
797 homebank_pref_get_wingeometry(keyfile, group, "Txn", &PREFS->txn_wg);
798
799 if(version <= 7) //set maximize to 0
800 {
801 PREFS->wal_wg.s = 0;
802 PREFS->acc_wg.s = 0;
803 PREFS->txn_wg.s = 0;
804 PREFS->sta_wg.s = 0;
805 PREFS->tme_wg.s = 0;
806 PREFS->ove_wg.s = 0;
807 PREFS->bud_wg.s = 0;
808 PREFS->cst_wg.s = 0;
809 }
810 homebank_pref_get_integer(keyfile, group, "WalVPaned", &PREFS->wal_vpaned);
811 homebank_pref_get_integer(keyfile, group, "WalHPaned", &PREFS->wal_hpaned);
812 homebank_pref_get_boolean(keyfile, group, "WalToolbar", &PREFS->wal_toolbar);
813 homebank_pref_get_boolean(keyfile, group, "WalSpending", &PREFS->wal_spending);
814 homebank_pref_get_boolean(keyfile, group, "WalUpcoming", &PREFS->wal_upcoming);
815
816 //since 5.1.3
817 group = "Panels";
818
819 DB( g_print(" -> ** Panels\n") );
820
821 homebank_pref_get_short(keyfile, group, "AccColAccW", &PREFS->pnl_acc_col_acc_width);
822 homebank_pref_get_short(keyfile, group, "AccShowBy" , &PREFS->pnl_acc_show_by);
823
824 homebank_pref_get_short(keyfile, group, "UpcColPayW", &PREFS->pnl_upc_col_pay_width);
825 homebank_pref_get_short(keyfile, group, "UpcColMemW", &PREFS->pnl_upc_col_mem_width);
826
827
828 group = "Format";
829
830 DB( g_print(" -> ** Format\n") );
831
832 homebank_pref_get_string(keyfile, group, "DateFmt", &PREFS->date_format);
833
834 if(version < 460)
835 {
836 gboolean useimperial;
837
838 homebank_pref_get_boolean(keyfile, group, "UKUnits", &useimperial);
839 if(useimperial)
840 {
841 PREFS->vehicle_unit_ismile = TRUE;
842 PREFS->vehicle_unit_isgal = TRUE;
843 }
844 }
845
846 homebank_pref_get_boolean(keyfile, group, "UnitIsMile", &PREFS->vehicle_unit_ismile);
847 homebank_pref_get_boolean(keyfile, group, "UnitIsGal", &PREFS->vehicle_unit_isgal);
848
849
850 group = "Filter";
851
852 DB( g_print(" -> ** Filter\n") );
853
854 homebank_pref_get_integer(keyfile, group, "DateRangeWal", &PREFS->date_range_wal);
855 homebank_pref_get_integer(keyfile, group, "DateRangeTxn", &PREFS->date_range_txn);
856 homebank_pref_get_integer(keyfile, group, "DateFutureNbDays", &PREFS->date_future_nbdays);
857 homebank_pref_get_integer(keyfile, group, "DateRangeRep", &PREFS->date_range_rep);
858
859 if(version <= 7)
860 {
861 // shift date range >= 5, since we inserted a new one at position 5
862 if(PREFS->date_range_wal >= FLT_RANGE_LASTYEAR)
863 PREFS->date_range_wal++;
864 if(PREFS->date_range_txn >= FLT_RANGE_LASTYEAR)
865 PREFS->date_range_txn++;
866 if(PREFS->date_range_rep >= FLT_RANGE_LASTYEAR)
867 PREFS->date_range_rep++;
868 }
869
870
871 group = "Euro";
872
873 DB( g_print(" -> ** Euro\n") );
874
875 //homebank_pref_get_string(keyfile, group, "DefCurrency" , &PREFS->curr_default);
876
877 homebank_pref_get_boolean(keyfile, group, "Active", &PREFS->euro_active);
878 homebank_pref_get_integer(keyfile, group, "Country", &PREFS->euro_country);
879
880 gchar *ratestr = g_key_file_get_string (keyfile, group, "ChangeRate", NULL);
881 if(ratestr != NULL) PREFS->euro_value = g_ascii_strtod(ratestr, NULL);
882
883 if(version <= 1)
884 {
885 homebank_pref_get_string(keyfile, group, "Symbol", &PREFS->minor_cur.symbol);
886 PREFS->minor_cur.frac_digits = g_key_file_get_integer (keyfile, group, "NBDec", NULL);
887
888 //PREFS->euro_nbdec = g_key_file_get_integer (keyfile, group, "NBDec", NULL);
889 //PREFS->euro_thsep = g_key_file_get_boolean (keyfile, group, "Sep", NULL);
890 //gchar *tmpstr = g_key_file_get_string (keyfile, group, "Symbol", &error);
891 }
892 else
893 {
894 if(version < 460)
895 {
896 gchar *prefix = NULL;
897 gchar *suffix = NULL;
898
899 homebank_pref_get_string(keyfile, group, "PreSymbol", &prefix);
900 homebank_pref_get_string(keyfile, group, "SufSymbol", &suffix);
901 homebank_pref_currfmt_convert(&PREFS->minor_cur, prefix, suffix);
902 g_free(prefix);
903 g_free(suffix);
904 }
905 else
906 {
907 homebank_pref_get_string(keyfile, group, "Symbol", &PREFS->minor_cur.symbol);
908 homebank_pref_get_boolean(keyfile, group, "IsPrefix", &PREFS->minor_cur.sym_prefix);
909 }
910 homebank_pref_get_string(keyfile, group, "DecChar" , &PREFS->minor_cur.decimal_char);
911 homebank_pref_get_string(keyfile, group, "GroupChar", &PREFS->minor_cur.grouping_char);
912 homebank_pref_get_short(keyfile, group, "FracDigits", &PREFS->minor_cur.frac_digits);
913
914 //fix 378992/421228
915 if( PREFS->minor_cur.frac_digits > MAX_FRAC_DIGIT )
916 PREFS->minor_cur.frac_digits = MAX_FRAC_DIGIT;
917
918 da_cur_initformat(&PREFS->minor_cur);
919 }
920
921 //PREFS->euro_symbol = g_locale_to_utf8(tmpstr, -1, NULL, NULL, NULL);
922
923 group = "Report";
924
925 DB( g_print(" -> ** Report\n") );
926
927 homebank_pref_get_boolean(keyfile, group, "StatByAmount", &PREFS->stat_byamount);
928 homebank_pref_get_boolean(keyfile, group, "StatDetail", &PREFS->stat_showdetail);
929 homebank_pref_get_boolean(keyfile, group, "StatRate", &PREFS->stat_showrate);
930 homebank_pref_get_boolean(keyfile, group, "BudgDetail", &PREFS->budg_showdetail);
931 homebank_pref_get_integer(keyfile, group, "ColorScheme", &PREFS->report_color_scheme);
932
933 group = "Exchange";
934
935 DB( g_print(" -> ** Exchange\n") );
936
937 //homebank_pref_get_boolean(keyfile, group, "DoIntro", &PREFS->dtex_nointro);
938
939 homebank_pref_get_integer(keyfile, group, "DateFmt", &PREFS->dtex_datefmt);
940 homebank_pref_get_integer(keyfile, group, "OfxName", &PREFS->dtex_ofxname);
941 homebank_pref_get_integer(keyfile, group, "OfxMemo", &PREFS->dtex_ofxmemo);
942 homebank_pref_get_boolean(keyfile, group, "QifMemo", &PREFS->dtex_qifmemo);
943 homebank_pref_get_boolean(keyfile, group, "QifSwap", &PREFS->dtex_qifswap);
944
945
946 //group = "Chart";
947 //PREFS->chart_legend = g_key_file_get_boolean (keyfile, group, "Legend", NULL);
948
949
950 /*
951 #if MYDEBUG == 1
952 gsize length;
953 gchar *contents = g_key_file_to_data (keyfile, &length, NULL);
954 //g_print(" keyfile:\n%s\n len=%d\n", contents, length);
955 g_free(contents);
956 #endif
957 */
958
959 }
960 g_free(filename);
961 g_key_file_free (keyfile);
962
963 _homebank_pref_init_measurement_units();
964 }
965
966 return retval;
967 }
968
969 static void homebank_pref_set_string(
970 GKeyFile *key_file,
971 const gchar *group_name,
972 const gchar *key,
973 gchar *string)
974 {
975
976 DB( g_print(" - homebank_pref_set_string :: group='%s' key='%s' value='%s'\n", group_name, key, string) );
977
978 if( string != NULL && *string != '\0')
979 g_key_file_set_string (key_file, group_name, key, string);
980 else
981 g_key_file_set_string (key_file, group_name, key, "");
982
983 }
984
985
986 /*
987 ** save preference to homedir/.homebank (HB_DATA_PATH)
988 */
989 gboolean homebank_pref_save(void)
990 {
991 GKeyFile *keyfile;
992 gboolean retval = FALSE;
993 gchar *group, *filename;
994 gsize length;
995
996 DB( g_print("\n[preferences] pref save\n") );
997
998 keyfile = g_key_file_new();
999 if(keyfile )
1000 {
1001
1002 DB( g_print(" -> ** general\n") );
1003
1004
1005 group = "General";
1006 g_key_file_set_integer (keyfile, group, "Version", PREF_VERSION);
1007
1008 homebank_pref_set_string (keyfile, group, "Language", PREFS->language);
1009
1010 g_key_file_set_integer (keyfile, group, "BarStyle", PREFS->toolbar_style);
1011 //g_key_file_set_integer (keyfile, group, "BarImageSize", PREFS->image_size);
1012
1013
1014
1015 g_key_file_set_boolean (keyfile, group, "CustomColors", PREFS->custom_colors);
1016 g_key_file_set_string (keyfile, group, "ColorExp" , PREFS->color_exp);
1017 g_key_file_set_string (keyfile, group, "ColorInc" , PREFS->color_inc);
1018 g_key_file_set_string (keyfile, group, "ColorWarn", PREFS->color_warn);
1019
1020 g_key_file_set_integer (keyfile, group, "GridLines", PREFS->grid_lines);
1021
1022 homebank_pref_set_string (keyfile, group, "WalletPath" , PREFS->path_hbfile);
1023 homebank_pref_set_string (keyfile, group, "ImportPath" , PREFS->path_import);
1024 homebank_pref_set_string (keyfile, group, "ExportPath" , PREFS->path_export);
1025 //g_key_file_set_string (keyfile, group, "NavigatorPath", PREFS->path_navigator);
1026
1027
1028
1029
1030 g_key_file_set_boolean (keyfile, group, "ShowSplash", PREFS->showsplash);
1031 g_key_file_set_boolean (keyfile, group, "LoadLast", PREFS->loadlast);
1032 g_key_file_set_boolean (keyfile, group, "AppendScheduled", PREFS->appendscheduled);
1033 g_key_file_set_boolean (keyfile, group, "UpdateCurrency", PREFS->do_update_currency);
1034
1035 g_key_file_set_boolean (keyfile, group, "HeritDate", PREFS->heritdate);
1036 g_key_file_set_boolean (keyfile, group, "HideReconciled", PREFS->hidereconciled);
1037 g_key_file_set_boolean (keyfile, group, "ShowRemind", PREFS->showremind);
1038
1039 g_key_file_set_integer_list(keyfile, group, "ColumnsOpe", PREFS->lst_ope_columns, NUM_LST_DSPOPE-1);
1040 g_key_file_set_integer_list(keyfile, group, "ColumnsOpeWidth", PREFS->lst_ope_col_size, NUM_LST_DSPOPE-1);
1041 g_key_file_set_integer (keyfile, group, "OpeSortId" , PREFS->lst_ope_sort_id);
1042 g_key_file_set_integer (keyfile, group, "OpeSortOrder" , PREFS->lst_ope_sort_order);
1043
1044 g_key_file_set_integer (keyfile, group, "FiscYearDay" , PREFS->fisc_year_day);
1045 g_key_file_set_integer (keyfile, group, "FiscYearMonth" , PREFS->fisc_year_month);
1046
1047 // added v3.4
1048 DB( g_print(" -> ** windows\n") );
1049
1050 group = "Windows";
1051 g_key_file_set_integer_list(keyfile, group, "Wal", (gint *)&PREFS->wal_wg, 5);
1052 g_key_file_set_integer_list(keyfile, group, "Acc", (gint *)&PREFS->acc_wg, 5);
1053 g_key_file_set_integer_list(keyfile, group, "Sta", (gint *)&PREFS->sta_wg, 5);
1054 g_key_file_set_integer_list(keyfile, group, "Tme", (gint *)&PREFS->tme_wg, 5);
1055 g_key_file_set_integer_list(keyfile, group, "Ove", (gint *)&PREFS->ove_wg, 5);
1056 g_key_file_set_integer_list(keyfile, group, "Bud", (gint *)&PREFS->bud_wg, 5);
1057 g_key_file_set_integer_list(keyfile, group, "Car", (gint *)&PREFS->cst_wg, 5);
1058
1059 g_key_file_set_integer_list(keyfile, group, "Txn", (gint *)&PREFS->txn_wg, 5);
1060
1061 g_key_file_set_integer (keyfile, group, "WalVPaned" , PREFS->wal_vpaned);
1062 g_key_file_set_integer (keyfile, group, "WalHPaned" , PREFS->wal_hpaned);
1063 g_key_file_set_boolean (keyfile, group, "WalToolbar", PREFS->wal_toolbar);
1064 g_key_file_set_boolean (keyfile, group, "WalSpending", PREFS->wal_spending);
1065 g_key_file_set_boolean (keyfile, group, "WalUpcoming", PREFS->wal_upcoming);
1066
1067 //since 5.1.3
1068 DB( g_print(" -> ** Panels\n") );
1069
1070 group = "Panels";
1071 g_key_file_set_integer(keyfile, group, "AccColAccW", PREFS->pnl_acc_col_acc_width);
1072 g_key_file_set_integer(keyfile, group, "AccShowBy" , PREFS->pnl_acc_show_by);
1073
1074 g_key_file_set_integer(keyfile, group, "UpcColPayW", PREFS->pnl_upc_col_pay_width);
1075 g_key_file_set_integer(keyfile, group, "UpcColMemW", PREFS->pnl_upc_col_mem_width);
1076
1077
1078 DB( g_print(" -> ** format\n") );
1079
1080 group = "Format";
1081 homebank_pref_set_string (keyfile, group, "DateFmt" , PREFS->date_format);
1082
1083 //g_key_file_set_boolean (keyfile, group, "UKUnits" , PREFS->imperial_unit);
1084 g_key_file_set_boolean (keyfile, group, "UnitIsMile" , PREFS->vehicle_unit_ismile);
1085 g_key_file_set_boolean (keyfile, group, "UnitIsGal" , PREFS->vehicle_unit_isgal);
1086
1087
1088 DB( g_print(" -> ** filter\n") );
1089
1090 group = "Filter";
1091 g_key_file_set_integer (keyfile, group, "DateRangeWal", PREFS->date_range_wal);
1092 g_key_file_set_integer (keyfile, group, "DateRangeTxn", PREFS->date_range_txn);
1093 g_key_file_set_integer (keyfile, group, "DateFutureNbDays", PREFS->date_future_nbdays);
1094 g_key_file_set_integer (keyfile, group, "DateRangeRep", PREFS->date_range_rep);
1095
1096 DB( g_print(" -> ** euro\n") );
1097
1098 //euro options
1099 group = "Euro";
1100
1101 //homebank_pref_set_string(keyfile, group, "DefCurrency" , PREFS->curr_default);
1102
1103 g_key_file_set_boolean (keyfile, group, "Active" , PREFS->euro_active);
1104 if( PREFS->euro_active )
1105 {
1106 g_key_file_set_integer (keyfile, group, "Country", PREFS->euro_country);
1107 gchar ratestr[64];
1108 g_ascii_dtostr(ratestr, 63, PREFS->euro_value);
1109 homebank_pref_set_string (keyfile, group, "ChangeRate", ratestr);
1110 homebank_pref_set_string (keyfile, group, "Symbol" , PREFS->minor_cur.symbol);
1111 g_key_file_set_boolean (keyfile, group, "IsPrefix" , PREFS->minor_cur.sym_prefix);
1112 homebank_pref_set_string (keyfile, group, "DecChar" , PREFS->minor_cur.decimal_char);
1113 homebank_pref_set_string (keyfile, group, "GroupChar" , PREFS->minor_cur.grouping_char);
1114 g_key_file_set_integer (keyfile, group, "FracDigits", PREFS->minor_cur.frac_digits);
1115 }
1116
1117 //report options
1118 DB( g_print(" -> ** report\n") );
1119
1120 group = "Report";
1121 g_key_file_set_boolean (keyfile, group, "StatByAmount", PREFS->stat_byamount);
1122 g_key_file_set_boolean (keyfile, group, "StatDetail" , PREFS->stat_showdetail);
1123 g_key_file_set_boolean (keyfile, group, "StatRate" , PREFS->stat_showrate);
1124 g_key_file_set_boolean (keyfile, group, "BudgDetail" , PREFS->budg_showdetail);
1125 g_key_file_set_integer (keyfile, group, "ColorScheme" , PREFS->report_color_scheme);
1126
1127
1128 group = "Exchange";
1129 //g_key_file_set_boolean (keyfile, group, "DoIntro", PREFS->dtex_nointro);
1130
1131 g_key_file_set_integer (keyfile, group, "DateFmt", PREFS->dtex_datefmt);
1132 g_key_file_set_integer (keyfile, group, "OfxName", PREFS->dtex_ofxname);
1133 g_key_file_set_integer (keyfile, group, "OfxMemo", PREFS->dtex_ofxmemo);
1134 g_key_file_set_boolean (keyfile, group, "QifMemo", PREFS->dtex_qifmemo);
1135 g_key_file_set_boolean (keyfile, group, "QifSwap", PREFS->dtex_qifswap);
1136
1137
1138 //group = "Chart";
1139 //g_key_file_set_boolean (keyfile, group, "Legend", PREFS->chart_legend);
1140
1141 //g_key_file_set_string (keyfile, group, "", PREFS->);
1142 //g_key_file_set_boolean (keyfile, group, "", PREFS->);
1143 //g_key_file_set_integer (keyfile, group, "", PREFS->);
1144
1145 DB( g_print(" -> ** g_key_file_to_data\n") );
1146
1147 gchar *contents = g_key_file_to_data (keyfile, &length, NULL);
1148
1149 //DB( g_print(" keyfile:\n%s\nlen=%d\n", contents, length) );
1150
1151 filename = g_build_filename(homebank_app_get_config_dir(), "preferences", NULL );
1152
1153 DB( g_print(" -> filename: %s\n", filename) );
1154
1155 g_file_set_contents(filename, contents, length, NULL);
1156
1157 DB( g_print(" -> contents: %s\n", contents) );
1158
1159 DB( g_print(" -> freeing filename\n") );
1160 g_free(filename);
1161
1162 DB( g_print(" -> freeing buffer\n") );
1163
1164 g_free(contents);
1165
1166 DB( g_print(" -> freeing keyfile\n") );
1167
1168 g_key_file_free (keyfile);
1169 }
1170
1171 _homebank_pref_init_measurement_units();
1172
1173 return retval;
1174 }
1175
This page took 0.086531 seconds and 4 git commands to generate.