]> Dogcows Code - chaz/homebank/blob - src/ui-pref.c
Merge branch 'upstream'
[chaz/homebank] / src / ui-pref.c
1 /* HomeBank -- Free, easy, personal accounting for everyone.
2 * Copyright (C) 1995-2017 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 "ui-pref.h"
24 #include "dsp_mainwindow.h"
25 #include "gtk-chart-colors.h"
26
27 #include "ui-currency.h"
28
29
30 /****************************************************************************/
31 /* Debug macros */
32 /****************************************************************************/
33 #define MYDEBUG 0
34
35 #if MYDEBUG
36 #define DB(x) (x);
37 #else
38 #define DB(x);
39 #endif
40
41 /* our global datas */
42 extern struct HomeBank *GLOBALS;
43 extern struct Preferences *PREFS;
44
45
46 enum {
47 LST_PREF_ICONNAME,
48 LST_PREF_NAME,
49 LST_PREF_PAGE,
50 LST_PREF_MAX
51 };
52
53 enum
54 {
55 COLUMN_VISIBLE,
56 COLUMN_NAME,
57 COLUMN_ID,
58 NUM_COLUMNS
59 };
60
61 enum
62 {
63 PREF_GENERAL,
64 PREF_INTERFACE,
65 PREF_COLUMNS,
66 PREF_DISPLAY,
67 PREF_IMPORT,
68 PREF_REPORT,
69 PREF_EURO,
70 PREF_MAX
71 };
72
73
74 static gchar *pref_iconname[PREF_MAX] = {
75 "prf-general",
76 "prf-interface",
77 "prf-columns",
78 "prf-display",
79 "prf-import",
80 "prf-report",
81 "prf-euro", // to be renamed
82 //"prf_charts.svg"
83 };
84
85 static gchar *pref_name[PREF_MAX] = {
86 N_("General"),
87 N_("Interface"),
88 N_("Transactions"),
89 N_("Display format"),
90 N_("Import/Export"),
91 N_("Report"),
92 N_("Euro minor")
93 //
94 };
95
96 static gchar *CYA_TOOLBAR_STYLE[] = {
97 N_("System defaults"),
98 N_("Icons only"),
99 N_("Text only"),
100 N_("Text under icons"),
101 N_("Text beside icons"),
102 NULL
103 };
104
105 static gchar *CYA_GRID_LINES[] = {
106 N_("None"),
107 N_("Horizontal"),
108 N_("Vertical"),
109 N_("Both"),
110 NULL
111 };
112
113
114 gchar *CYA_TANGO_COLORS[] = {
115 "----",
116 N_("Tango light"),
117 N_("Tango medium"),
118 N_("Tango dark"),
119 NULL
120 };
121
122 gchar *CYA_IMPORT_DATEORDER[] = {
123 N_("m-d-y"),
124 N_("d-m-y"),
125 N_("y-m-d"),
126 NULL
127 };
128
129 gchar *CYA_IMPORT_OFXNAME[] = {
130 N_("Ignore"),
131 N_("Memo"),
132 N_("Payee"),
133 NULL
134 };
135
136 gchar *CYA_IMPORT_OFXMEMO[] = {
137 N_("Ignore"),
138 N_("Append to Info"),
139 N_("Append to Memo"),
140 N_("Append to Payee"),
141 NULL
142 };
143
144
145 extern gchar *CYA_CHART_COLORSCHEME[];
146 extern gchar *CYA_MONTHS[];
147
148 typedef struct
149 {
150 gshort id;
151 gchar *iso;
152 gchar *name;
153 gdouble value;
154 //gchar *prefix_symbol; /* max symbol is 3 digits in unicode */
155 //gchar *suffix_symbol; /* but mostly is 1 digit */
156 gchar *symbol;
157 gboolean sym_prefix;
158 gchar *decimal_char;
159 gchar *grouping_char;
160 gshort frac_digits;
161 } EuroParams;
162
163
164 /*
165 source:
166 http://en.wikipedia.org/wiki/Currencies_of_the_European_Union
167 http://www.xe.com/euro.php
168 http://fr.wikipedia.org/wiki/Liste_des_unit%C3%A9s_mon%C3%A9taires_remplac%C3%A9es_par_l%27euro
169 http://www.inter-locale.com/LocalesDemo.jsp
170 */
171 static EuroParams euro_params[] =
172 {
173 // , rate , symb , prfx , dec, grp, frac
174 // ---------------------------------------------------------------------
175 { 0, "" , "--------" , 1.0 , "" , FALSE, ",", ".", 2 },
176 { 1, "ATS", "Austria" , 13.7603 , "S" , TRUE , ",", ".", 2 }, // -S 1.234.567,89
177 { 2, "BEF", "Belgium" , 40.3399 , "BF" , TRUE , ",", ".", 2 }, // BF 1.234.567,89 -
178 { 20, "BGN", "Bulgaria" , 1.95583 , "лв." , TRUE , ",", " ", 2 }, // non-fixé - 2014 target for euro
179 { 24, "HRK", "Croatia" , 1.0000 , "kn" , FALSE, "" , ".", 0 }, // non-fixé - 2015 target for euro earliest
180 { 14, "CYP", "Cyprus" , 0.585274 , "£" , TRUE , ",", "" , 2 }, //
181 { 23, "CZK", "Czech Republic" , 28.36 , "Kč" , FALSE, ",", " ", 2 }, // non-fixé - 2015 earliest
182 // Denmark
183 { 17, "EEK", "Estonia" , 15.6466 , "kr" , FALSE, ",", " ", 2 }, //
184 { 3, "FIM", "Finland" , 5.94573 , "mk" , FALSE, ",", " ", 2 }, // -1 234 567,89 mk
185 { 4, "FRF", "France" , 6.55957 , "F" , FALSE, ",", " ", 2 }, // -1 234 567,89 F
186 { 5, "DEM", "Germany" , 1.95583 , "DM" , FALSE, ",", ".", 2 }, // -1.234.567,89 DM
187 { 6, "GRD", "Greece" , 340.750 , "d" , TRUE , ".", ",", 2 }, // ??
188 { 21, "HUF", "Hungary" , 261.51 , "Ft" , TRUE , ",", " ", 2 }, // non-fixé - No current target for euro
189 { 7, "IEP", "Ireland" , 0.787564 , "£" , TRUE , ".", ",", 2 }, // -£1,234,567.89
190 { 8, "ITL", "Italy" , 1936.27 , "L" , TRUE , "" , ".", 0 }, // L -1.234.567
191 { 18, "LVL", "Latvia" , 0.702804 , "lat.", FALSE, ",", "" , 2 }, // jan. 2014
192 { 19, "LTL", "Lithuania" , 3.45280 , "Lt" , FALSE, ",", "" , 2 }, // jan. 2015
193 { 9, "LUF", "Luxembourg" , 40.3399 , "LU" , TRUE , ",", ".", 2 }, // LU 1.234.567,89 -
194 { 15, "MTL", "Malta" , 0.429300 , "Lm" , TRUE , ",", "" , 2 }, //
195 { 10, "NLG", "Netherlands" , 2.20371 , "F" , TRUE , ",", ".", 2 }, // F 1.234.567,89-
196 { 25, "PLN", "Poland" , 0.25 , "zł" , FALSE, ",", "" , 2 }, // non-fixé - No current target for euro
197 { 11, "PTE", "Portugal" , 200.482 , "Esc.", FALSE, "$", ".", 2 }, // -1.234.567$89 Esc.
198 { 22, "RON", "Romania" , 3.5155 , "Leu" , FALSE, ",", ".", 2 }, // non-fixé - 2015 target for euro earliest
199 { 16, "SKK", "Slovak Republic", 30.12600 , "Sk" , FALSE, ",", " ", 2 }, //
200 { 13, "SIT", "Slovenia" , 239.640 , "tol" , TRUE , ",", ".", 2 }, //
201 { 12, "ESP", "Spain" , 166.386 , "Pts" , TRUE , "" , ".", 0 }, // -Pts 1.234.567
202 //Sweden
203 //United Kingdom
204 // { " ", "" , 1.00000 , "" , "" , FALSE, ",", "", 2 },
205 };
206
207
208 GtkWidget *pref_list_create(void);
209 GtkWidget *list_txn_colprefcreate(void);
210
211 static void list_txn_colpref_get(GtkTreeView *treeview, gboolean *columns);
212
213
214
215
216
217 /* = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =*/
218 typedef struct
219 {
220 gchar *locale;
221 gchar *name;
222
223 } LangName;
224
225 static LangName languagenames[] =
226 {
227 // af ar ast be bg ca cs cy da de el en_AU en_CA en_GB es et eu fa fi fr ga gl he hr hu id is it
228 //ja ka ko lt lv ms nb nds nl oc pl pt_BR pt pt_PT ro ru si sk sl sr sv tr uk vi zh_CN zh_TW
229
230 { "aa", "Afar" },
231 { "ab", "Abkhazian" },
232 { "ae", "Avestan" },
233 { "af", "Afrikaans" },
234 { "ak", "Akan" },
235 { "am", "Amharic" },
236 { "an", "Aragonese" },
237 { "ar", "Arabic" },
238 { "as", "Assamese" },
239 { "ast", "Asturian, Bable, Leonese, Asturleonese" },
240 { "av", "Avaric" },
241 { "ay", "Aymara" },
242 { "az", "Azerbaijani" },
243 { "ba", "Bashkir" },
244 { "be", "Belarusian" },
245 { "bg", "Bulgarian" },
246 { "bh", "Bihari" },
247 { "bi", "Bislama" },
248 { "bm", "Bambara" },
249 { "bn", "Bengali" },
250 { "bo", "Tibetan" },
251 { "br", "Breton" },
252 { "bs", "Bosnian" },
253 { "ca", "Catalan" },
254 { "ce", "Chechen" },
255 { "ch", "Chamorro" },
256 { "co", "Corsican" },
257 { "cr", "Cree" },
258 { "cs", "Czech" },
259 { "cu", "Old Church Slavonic" },
260 { "cv", "Chuvash" },
261 { "cy", "Welsh" },
262 { "da", "Danish" },
263 { "de", "German" },
264 { "dv", "Divehi" },
265 { "dz", "Dzongkha" },
266 { "ee", "Ewe" },
267 { "el", "Greek" },
268 { "en", "English" },
269 { "eo", "Esperanto" },
270 { "es", "Spanish" },
271 { "et", "Estonian" },
272 { "eu", "Basque" },
273 { "fa", "Persian" },
274 { "ff", "Fulah" },
275 { "fi", "Finnish" },
276 { "fj", "Fijian" },
277 { "fo", "Faroese" },
278 { "fr", "French" },
279 { "fy", "Western Frisian" },
280 { "ga", "Irish" },
281 { "gd", "Scottish Gaelic" },
282 { "gl", "Galician" },
283 { "gn", "Guarani" },
284 { "gu", "Gujarati" },
285 { "gv", "Manx" },
286 { "ha", "Hausa" },
287 { "he", "Hebrew" },
288 { "hi", "Hindi" },
289 { "ho", "Hiri Motu" },
290 { "hr", "Croatian" },
291 { "ht", "Haitian" },
292 { "hu", "Hungarian" },
293 { "hy", "Armenian" },
294 { "hz", "Herero" },
295 { "ia", "Interlingua" },
296 { "id", "Indonesian" },
297 { "ie", "Interlingue" },
298 { "ig", "Igbo" },
299 { "ii", "Sichuan Yi" },
300 { "ik", "Inupiaq" },
301 { "io", "Ido" },
302 { "is", "Icelandic" },
303 { "it", "Italian" },
304 { "iu", "Inuktitut" },
305 { "ja", "Japanese" },
306 { "jv", "Javanese" },
307 { "ka", "Georgian" },
308 { "kg", "Kongo" },
309 { "ki", "Kikuyu" },
310 { "kj", "Kwanyama" },
311 { "kk", "Kazakh" },
312 { "kl", "Kalaallisut" },
313 { "km", "Khmer" },
314 { "kn", "Kannada" },
315 { "ko", "Korean" },
316 { "kr", "Kanuri" },
317 { "ks", "Kashmiri" },
318 { "ku", "Kurdish" },
319 { "kv", "Komi" },
320 { "kw", "Cornish" },
321 { "ky", "Kirghiz" },
322 { "la", "Latin" },
323 { "lb", "Luxembourgish" },
324 { "lg", "Ganda" },
325 { "li", "Limburgish" },
326 { "ln", "Lingala" },
327 { "lo", "Lao" },
328 { "lt", "Lithuanian" },
329 { "lu", "Luba-Katanga" },
330 { "lv", "Latvian" },
331 { "mg", "Malagasy" },
332 { "mh", "Marshallese" },
333 { "mi", "Māori" },
334 { "mk", "Macedonian" },
335 { "ml", "Malayalam" },
336 { "mn", "Mongolian" },
337 { "mo", "Moldavian" },
338 { "mr", "Marathi" },
339 { "ms", "Malay" },
340 { "mt", "Maltese" },
341 { "my", "Burmese" },
342 { "na", "Nauru" },
343 { "nb", "Norwegian Bokmål" },
344 { "nd", "North Ndebele" },
345 { "nds", "Low German, Low Saxon" },
346 { "ne", "Nepali" },
347 { "ng", "Ndonga" },
348 { "nl", "Dutch" },
349 { "nn", "Norwegian Nynorsk" },
350 { "no", "Norwegian" },
351 { "nr", "South Ndebele" },
352 { "nv", "Navajo" },
353 { "ny", "Chichewa" },
354 { "oc", "Occitan" },
355 { "oj", "Ojibwa" },
356 { "om", "Oromo" },
357 { "or", "Oriya" },
358 { "os", "Ossetian" },
359 { "pa", "Panjabi" },
360 { "pi", "Pāli" },
361 { "pl", "Polish" },
362 { "ps", "Pashto" },
363 { "pt", "Portuguese" },
364 { "qu", "Quechua" },
365 { "rm", "Romansh" },
366 { "rn", "Kirundi" },
367 { "ro", "Romanian" },
368 { "ru", "Russian" },
369 { "rw", "Kinyarwanda" },
370 { "sa", "Sanskrit" },
371 { "sc", "Sardinian" },
372 { "sd", "Sindhi" },
373 { "se", "Northern Sami" },
374 { "sg", "Sango" },
375 { "si", "Sinhalese" },
376 { "sk", "Slovak" },
377 { "sl", "Slovene" },
378 { "sm", "Samoan" },
379 { "sn", "Shona" },
380 { "so", "Somali" },
381 { "sq", "Albanian" },
382 { "sr", "Serbian" },
383 { "ss", "Swati" },
384 { "st", "Sotho" },
385 { "su", "Sundanese" },
386 { "sv", "Swedish" },
387 { "sw", "Swahili" },
388 { "ta", "Tamil" },
389 { "te", "Telugu" },
390 { "tg", "Tajik" },
391 { "th", "Thai" },
392 { "ti", "Tigrinya" },
393 { "tk", "Turkmen" },
394 { "tl", "Tagalog" },
395 { "tn", "Tswana" },
396 { "to", "Tonga" },
397 { "tr", "Turkish" },
398 { "ts", "Tsonga" },
399 { "tt", "Tatar" },
400 { "tw", "Twi" },
401 { "ty", "Tahitian" },
402 { "ug", "Uighur" },
403 { "uk", "Ukrainian" },
404 { "ur", "Urdu" },
405 { "uz", "Uzbek" },
406 { "ve", "Venda" },
407 { "vi", "Viêt Namese" },
408 { "vo", "Volapük" },
409 { "wa", "Walloon" },
410 { "wo", "Wolof" },
411 { "xh", "Xhosa" },
412 { "yi", "Yiddish" },
413 { "yo", "Yoruba" },
414 { "za", "Zhuang" },
415 { "zh", "Chinese" },
416 { "zu", "Zulu" }
417
418 };
419
420
421 static gint
422 ui_language_combobox_compare_func (GtkTreeModel *model, GtkTreeIter *a, GtkTreeIter *b, gpointer userdata)
423 {
424 gint retval = 0;
425 gchar *code1, *code2;
426 gchar *name1, *name2;
427
428 gtk_tree_model_get(model, a, 0, &code1, 1, &name1, -1);
429 gtk_tree_model_get(model, b, 0, &code2, 1, &name2, -1);
430
431 //keep system laguage on top
432 if(code1 == NULL) name1 = NULL;
433 if(code2 == NULL) name2 = NULL;
434
435 retval = hb_string_utf8_compare(name1, name2);
436
437 g_free(name2);
438 g_free(name1);
439
440 return retval;
441 }
442
443
444 static gchar *languagename_get(const gchar *locale)
445 {
446 guint i;
447
448 for (i = 0; i < G_N_ELEMENTS (languagenames); i++)
449 {
450 if( g_ascii_strncasecmp(locale, languagenames[i].locale, -1) == 0 )
451 return languagenames[i].name;
452 }
453
454 return NULL;
455 }
456
457
458 static const gchar *
459 ui_language_combobox_get_name(const gchar *locale)
460 {
461 const gchar *lang;
462
463 DB( g_print("[ui_language_combobox_get_name]\n") );
464
465 // A locale directory name is typically of the form language[_territory]
466 lang = languagename_get (locale);
467 if (! lang)
468 {
469 const gchar *delimiter = strchr (locale, '_'); // strip off the territory suffix
470
471 if (delimiter)
472 {
473 gchar *copy = g_strndup (locale, delimiter - locale);
474 lang = languagename_get (copy);
475 g_free (copy);
476 }
477
478 if(! lang)
479 {
480 g_warning(" locale name not found '%s'", locale);
481 lang = locale;
482 }
483
484 }
485
486 return lang;
487 }
488
489
490 static void
491 ui_language_combobox_populate(GtkWidget *combobox)
492 {
493 GtkTreeModel *model;
494 GtkTreeIter iter;
495
496 model = gtk_combo_box_get_model(GTK_COMBO_BOX(combobox));
497 gtk_list_store_append (GTK_LIST_STORE(model), &iter);
498 gtk_list_store_set (GTK_LIST_STORE(model), &iter,
499 0, NULL,
500 1, _("System Language"),
501 -1);
502
503 GDir *dir = g_dir_open (homebank_app_get_locale_dir (), 0, NULL);
504 const gchar *dirname;
505
506 if (! dir)
507 return;
508
509 while ((dirname = g_dir_read_name (dir)) != NULL)
510 {
511 gchar *filename = g_build_filename (homebank_app_get_locale_dir (),
512 dirname,
513 "LC_MESSAGES",
514 GETTEXT_PACKAGE ".mo",
515 NULL);
516 //DB( g_print("- seek for '%s'\n", filename) );
517 if (g_file_test (filename, G_FILE_TEST_EXISTS))
518 {
519 const gchar *lang;
520 gchar *label;
521
522 gtk_list_store_append (GTK_LIST_STORE(model), &iter);
523
524 lang = ui_language_combobox_get_name(dirname);
525 label = g_strdup_printf ("%s [%s]", lang, dirname);
526
527 gtk_list_store_set (GTK_LIST_STORE(model), &iter,
528 0, dirname,
529 1, label,
530 -1);
531 g_free(label);
532
533 }
534 g_free (filename);
535
536 }
537 g_dir_close (dir);
538
539 gtk_tree_sortable_set_sort_column_id(GTK_TREE_SORTABLE(model), GTK_TREE_SORTABLE_DEFAULT_SORT_COLUMN_ID, GTK_SORT_ASCENDING);
540
541
542 }
543
544
545 static GtkWidget *
546 ui_language_combobox_new(GtkWidget *label)
547 {
548 GtkListStore *store;
549 GtkWidget *combobox;
550 GtkCellRenderer *renderer;
551
552 store = gtk_list_store_new (2,
553 G_TYPE_STRING,
554 G_TYPE_STRING
555 );
556 gtk_tree_sortable_set_default_sort_func(GTK_TREE_SORTABLE(store), ui_language_combobox_compare_func, NULL, NULL);
557
558 combobox = gtk_combo_box_new_with_model(GTK_TREE_MODEL(store));
559 renderer = gtk_cell_renderer_text_new ();
560 gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (combobox), renderer, TRUE);
561 gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (combobox), renderer, "text", 1, NULL);
562
563 gtk_combo_box_set_id_column( GTK_COMBO_BOX(combobox), 0);
564
565 g_object_unref(store);
566
567 if(label)
568 gtk_label_set_mnemonic_widget (GTK_LABEL(label), combobox);
569
570 ui_language_combobox_populate(combobox);
571
572 gtk_combo_box_set_active(GTK_COMBO_BOX(combobox), 0);
573
574 return combobox;
575 }
576
577
578 /* = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =*/
579 /* = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =*/
580 /* = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =*/
581
582 static gint ui_euro_combobox_id_to_active(gint id)
583 {
584 guint i, retval;
585
586 DB( g_print("\n[ui-pref] ui_euro_combobox_id_to_active\n") );
587
588 retval = 0;
589 for (i = 0; i < G_N_ELEMENTS (euro_params); i++)
590 {
591 if( euro_params[i].id == id )
592 {
593 retval = i;
594 DB( g_print("- id (country)=%d => %d - %s\n", id, i, euro_params[i].name) );
595 break;
596 }
597 }
598
599 return retval;
600 }
601
602
603
604 static gint ui_euro_combobox_active_to_id(gint active)
605 {
606 gint id;
607
608 DB( g_print("\n[ui-pref] ui_euro_combobox_active_to_id\n") );
609
610 DB( g_print("- to %d\n", active) );
611
612 id = 0;
613 if( active < (gint)G_N_ELEMENTS (euro_params) )
614 {
615 id = euro_params[active].id;
616 DB( g_print("- id (country)=%d '%s'\n", id, euro_params[active].name) );
617 }
618 return id;
619 }
620
621
622 static GtkWidget *ui_euro_combobox_new(GtkWidget *label)
623 {
624 GtkWidget *combobox;
625 guint i;
626
627 DB( g_print("\n[ui-pref] make euro preset\n") );
628
629 combobox = gtk_combo_box_text_new();
630 for (i = 0; i < G_N_ELEMENTS (euro_params); i++)
631 {
632 gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(combobox), euro_params[i].name);
633 }
634 gtk_combo_box_set_active(GTK_COMBO_BOX(combobox), 0);
635
636 if(label)
637 gtk_label_set_mnemonic_widget (GTK_LABEL(label), combobox);
638
639 return combobox;
640 }
641
642
643 static void defpref_pathselect(GtkWidget *widget, gpointer user_data)
644 {
645 struct defpref_data *data;
646 gint type = GPOINTER_TO_INT(user_data);
647 gchar **path;
648 gchar *title;
649 GtkWidget *entry;
650 gboolean r;
651
652 DB( g_print("\n[ui-pref] path select\n") );
653
654 data = g_object_get_data(G_OBJECT(gtk_widget_get_ancestor(widget, GTK_TYPE_WINDOW)), "inst_data");
655
656 switch( type )
657 {
658 case 1:
659 path = &PREFS->path_hbfile;
660 entry = data->ST_path_hbfile;
661 title = _("Choose a default HomeBank files folder");
662 break;
663 case 2:
664 path = &PREFS->path_import;
665 entry = data->ST_path_import;
666 title = _("Choose a default import folder");
667 break;
668 case 3:
669 path = &PREFS->path_export;
670 entry = data->ST_path_export;
671 title = _("Choose a default export folder");
672 break;
673 default:
674 return;
675 }
676
677 DB( g_print(" - hbfile %p %s at %p\n" , PREFS->path_hbfile, PREFS->path_hbfile, &PREFS->path_hbfile) );
678 DB( g_print(" - import %p %s at %p\n" , PREFS->path_import, PREFS->path_import, &PREFS->path_import) );
679 DB( g_print(" - export %p %s at %p\n" , PREFS->path_export, PREFS->path_export, &PREFS->path_export) );
680
681
682 DB( g_print(" - before: %s %p\n" , *path, path) );
683
684 r = ui_file_chooser_folder(GTK_WINDOW(gtk_widget_get_ancestor(widget, GTK_TYPE_WINDOW)), title, path);
685
686
687 DB( g_print(" - after: %s\n", *path) );
688
689 if( r == TRUE )
690 gtk_entry_set_text(GTK_ENTRY(entry), *path);
691
692
693 }
694
695
696 /*
697 ** update the date sample label
698 */
699 static void defpref_date_sample(GtkWidget *widget, gpointer user_data)
700 {
701 struct defpref_data *data;
702 gchar buffer[256];
703 const gchar *fmt;
704 GDate *date;
705
706 DB( g_print("\n[ui-pref] date sample\n") );
707
708 data = g_object_get_data(G_OBJECT(gtk_widget_get_ancestor(widget, GTK_TYPE_WINDOW)), "inst_data");
709
710 fmt = gtk_entry_get_text(GTK_ENTRY(data->ST_datefmt));
711 date = g_date_new_julian (GLOBALS->today);
712 g_date_strftime (buffer, 256-1, fmt, date);
713 g_date_free(date);
714
715 gtk_label_set_text(GTK_LABEL(data->LB_date), buffer);
716
717 }
718
719
720 /*
721 ** update the number sample label
722 */
723 static void defpref_numbereuro_sample(GtkWidget *widget, gpointer user_data)
724 {
725 struct defpref_data *data;
726 Currency cur;
727 gchar formatd_buf[G_ASCII_DTOSTR_BUF_SIZE];
728 gchar buf[128];
729
730 DB( g_print("\n[ui-pref] number sample\n") );
731
732 data = g_object_get_data(G_OBJECT(gtk_widget_get_ancestor(widget, GTK_TYPE_WINDOW)), "inst_data");
733
734 cur.symbol = (gchar *)gtk_entry_get_text(GTK_ENTRY(data->ST_euro_symbol));
735 cur.sym_prefix = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(data->CM_euro_isprefix));
736 cur.decimal_char = (gchar *)gtk_entry_get_text(GTK_ENTRY(data->ST_euro_decimalchar));
737 cur.grouping_char = (gchar *)gtk_entry_get_text(GTK_ENTRY(data->ST_euro_groupingchar));
738 cur.frac_digits = gtk_spin_button_get_value(GTK_SPIN_BUTTON(data->NB_euro_fracdigits));
739
740 da_cur_initformat (&cur);
741
742 DB( g_print("fmt: %s\n", cur.format) );
743
744 g_ascii_formatd(formatd_buf, sizeof (formatd_buf), cur.format, HB_NUMBER_SAMPLE);
745 hb_str_formatd(buf, 127, formatd_buf, &cur, TRUE);
746
747 gtk_label_set_text(GTK_LABEL(data->LB_numbereuro), buf);
748
749 }
750
751
752 /*
753 ** enable/disable euro
754 */
755 static void defpref_eurotoggle(GtkWidget *widget, gpointer user_data)
756 {
757 struct defpref_data *data;
758 gboolean sensitive;
759
760 DB( g_print("\n[ui-pref] euro toggle\n") );
761
762 data = g_object_get_data(G_OBJECT(gtk_widget_get_ancestor(widget, GTK_TYPE_WINDOW)), "inst_data");
763
764 sensitive = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(data->CM_euro_enable));
765
766 gtk_widget_set_sensitive(data->GRP_currency , sensitive);
767 gtk_widget_set_sensitive(data->GRP_rate , sensitive);
768 gtk_widget_set_sensitive(data->GRP_format , sensitive);
769 }
770
771
772 /*
773 ** set euro value widget from a country
774 */
775 static void defpref_eurosetcurrency(GtkWidget *widget, gint country)
776 {
777 struct defpref_data *data;
778 EuroParams *euro;
779 gchar *buf;
780 gint active;
781
782 DB( g_print("\n[ui-pref] eurosetcurrency\n") );
783
784 data = g_object_get_data(G_OBJECT(gtk_widget_get_ancestor(widget, GTK_TYPE_WINDOW)), "inst_data");
785
786 active = ui_euro_combobox_id_to_active(country);
787 euro = &euro_params[active];
788 buf = g_strdup_printf("%s - %s", euro->iso, euro->name);
789 gtk_label_set_markup(GTK_LABEL(data->ST_euro_country), buf);
790 g_free(buf);
791 }
792
793
794 /*
795 ** set euro value widget from a country
796 */
797 static void defpref_europreset(GtkWidget *widget, gpointer user_data)
798 {
799 struct defpref_data *data;
800 gint active;
801
802 DB( g_print("\n[ui-pref] euro preset\n") );
803
804 data = g_object_get_data(G_OBJECT(gtk_widget_get_ancestor(widget, GTK_TYPE_WINDOW)), "inst_data");
805
806 active = gtk_combo_box_get_active (GTK_COMBO_BOX(data->CY_euro_preset));
807 data->country = ui_euro_combobox_active_to_id (active);;
808
809 defpref_eurosetcurrency(widget, data->country);
810
811 gtk_spin_button_set_value(GTK_SPIN_BUTTON(data->NB_euro_value), euro_params[active].value);
812
813 gtk_spin_button_set_value(GTK_SPIN_BUTTON(data->NB_euro_fracdigits), euro_params[active].frac_digits);
814
815 gtk_entry_set_text(GTK_ENTRY(data->ST_euro_symbol) , euro_params[active].symbol);
816 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(data->CM_euro_isprefix), euro_params[active].sym_prefix);
817 gtk_entry_set_text(GTK_ENTRY(data->ST_euro_decimalchar) , euro_params[active].decimal_char);
818 gtk_entry_set_text(GTK_ENTRY(data->ST_euro_groupingchar), euro_params[active].grouping_char);
819
820 }
821
822
823 static void defpref_colortoggle(GtkWidget *widget, gpointer user_data)
824 {
825 struct defpref_data *data;
826 gboolean sensitive;
827
828 DB( g_print("\n[ui-pref] color toggle\n") );
829
830 data = g_object_get_data(G_OBJECT(gtk_widget_get_ancestor(widget, GTK_TYPE_WINDOW)), "inst_data");
831
832 sensitive = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(data->CM_custom_colors));
833
834 gtk_widget_set_sensitive(data->GR_colors , sensitive);
835
836 }
837
838
839 /*
840 ** set preset colors for amount display
841 */
842 static void defpref_colorpreset(GtkWidget *widget, gpointer user_data)
843 {
844 struct defpref_data *data;
845 GdkRGBA rgba;
846 gint preset;
847 gchar *expcol, *inccol, *wrncol;
848
849 DB( g_print("\n[ui-pref] color preset\n") );
850
851 data = g_object_get_data(G_OBJECT(gtk_widget_get_ancestor(widget, GTK_TYPE_WINDOW)), "inst_data");
852
853 preset = gtk_combo_box_get_active(GTK_COMBO_BOX(data->CY_colors));
854
855 switch( preset)
856 {
857 case 1: //light
858 expcol = LIGHT_EXP_COLOR;
859 inccol = LIGHT_INC_COLOR;
860 wrncol = LIGHT_WARN_COLOR;
861 break;
862
863 case 2: //medium
864 expcol = MEDIUM_EXP_COLOR;
865 inccol = MEDIUM_INC_COLOR;
866 wrncol = MEDIUM_WARN_COLOR;
867 break;
868
869 case 3: //dark
870 default:
871 expcol = DEFAULT_EXP_COLOR;
872 inccol = DEFAULT_INC_COLOR;
873 wrncol = DEFAULT_WARN_COLOR;
874 break;
875 }
876
877
878 gdk_rgba_parse(&rgba, expcol);
879 gtk_color_chooser_set_rgba(GTK_COLOR_CHOOSER(data->CP_exp_color), &rgba);
880
881 gdk_rgba_parse(&rgba, inccol);
882 gtk_color_chooser_set_rgba(GTK_COLOR_CHOOSER(data->CP_inc_color), &rgba);
883
884 gdk_rgba_parse(&rgba, wrncol);
885 gtk_color_chooser_set_rgba(GTK_COLOR_CHOOSER(data->CP_warn_color), &rgba);
886
887
888 }
889
890
891 static void defpref_color_scheme_changed(GtkWidget *widget, gpointer user_data)
892 {
893 struct defpref_data *data;
894
895 DB( g_print("\n[ui-pref] color scheme chnaged\n") );
896
897 data = g_object_get_data(G_OBJECT(gtk_widget_get_ancestor(widget, GTK_TYPE_WINDOW)), "inst_data");
898
899 gtk_widget_queue_draw (data->DA_colors);
900
901 }
902
903
904
905
906 /*
907 static void setGdkColor_from_RGB(GdkColor *color, guint32 value)
908 {
909 guint tmp;
910
911 tmp = value >> 16;
912 color->red = tmp | tmp<<8;
913
914 tmp = value >> 8 & 0xFF;
915 color->green = tmp | tmp<<8;
916
917 tmp = value & 0xFF;
918 color->blue = tmp | tmp<<8;
919 }
920 */
921
922
923 /*
924 ** set :: fill in widgets from PREFS structure
925 */
926
927 static void defpref_set(struct defpref_data *data)
928 {
929 GdkRGBA rgba;
930
931 DB( g_print("\n[ui-pref] set\n") );
932
933 if(PREFS->language != NULL)
934 gtk_combo_box_set_active_id(GTK_COMBO_BOX(data->CY_language), PREFS->language);
935 else
936 gtk_combo_box_set_active (GTK_COMBO_BOX(data->CY_language), 0);
937
938 gtk_combo_box_set_active(GTK_COMBO_BOX(data->CY_toolbar), PREFS->toolbar_style);
939 //gtk_spin_button_set_value(GTK_SPIN_BUTTON(data->NB_image_size), PREFS->image_size);
940
941
942
943 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(data->CM_custom_colors), PREFS->custom_colors);
944
945 gdk_rgba_parse(&rgba, PREFS->color_exp);
946 gtk_color_chooser_set_rgba(GTK_COLOR_CHOOSER(data->CP_exp_color), &rgba);
947
948 gdk_rgba_parse(&rgba, PREFS->color_inc);
949 gtk_color_chooser_set_rgba(GTK_COLOR_CHOOSER(data->CP_inc_color), &rgba);
950
951 gdk_rgba_parse(&rgba, PREFS->color_warn);
952 gtk_color_chooser_set_rgba(GTK_COLOR_CHOOSER(data->CP_warn_color), &rgba);
953
954 //gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(data->CM_ruleshint), PREFS->rules_hint);
955 gtk_combo_box_set_active(GTK_COMBO_BOX(data->CY_gridlines), PREFS->grid_lines);
956
957 gtk_spin_button_set_value(GTK_SPIN_BUTTON(data->NB_fiscyearday), PREFS->fisc_year_day );
958 gtk_combo_box_set_active(GTK_COMBO_BOX(data->CY_fiscyearmonth), PREFS->fisc_year_month - 1);
959
960 gtk_entry_set_text(GTK_ENTRY(data->ST_path_hbfile), PREFS->path_hbfile);
961 gtk_entry_set_text(GTK_ENTRY(data->ST_path_import), PREFS->path_import);
962 gtk_entry_set_text(GTK_ENTRY(data->ST_path_export), PREFS->path_export);
963 //gtk_entry_set_text(GTK_ENTRY(data->ST_path_navigator), PREFS->path_navigator);
964
965 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(data->CM_load_last), PREFS->loadlast);
966 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(data->CM_append_scheduled), PREFS->appendscheduled);
967 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(data->CM_do_update_currency), PREFS->do_update_currency);
968 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(data->CM_show_splash), PREFS->showsplash);
969 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(data->CM_herit_date), PREFS->heritdate);
970 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(data->CM_hide_reconciled), PREFS->hidereconciled);
971 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(data->CM_show_remind), PREFS->showremind);
972
973 /* display */
974 gtk_entry_set_text(GTK_ENTRY(data->ST_datefmt), PREFS->date_format);
975
976 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(data->CM_unitismile), PREFS->vehicle_unit_ismile);
977 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(data->CM_unitisgal), PREFS->vehicle_unit_isgal);
978
979 gtk_combo_box_set_active(GTK_COMBO_BOX(data->CY_daterange_wal), PREFS->date_range_wal);
980 gtk_combo_box_set_active(GTK_COMBO_BOX(data->CY_daterange_txn), PREFS->date_range_txn);
981 gtk_spin_button_set_value(GTK_SPIN_BUTTON(data->ST_datefuture_nbdays), PREFS->date_future_nbdays);
982 gtk_combo_box_set_active(GTK_COMBO_BOX(data->CY_daterange_rep), PREFS->date_range_rep);
983
984 /* euro */
985 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(data->CM_euro_enable), PREFS->euro_active);
986 //gtk_combo_box_set_active(GTK_COMBO_BOX(data->CY_euro_preset), PREFS->euro_country);
987 data->country = PREFS->euro_country;
988 defpref_eurosetcurrency(data->window, data->country);
989
990 gtk_spin_button_set_value(GTK_SPIN_BUTTON(data->NB_euro_value), PREFS->euro_value);
991
992 ui_gtk_entry_set_text(data->ST_euro_symbol, PREFS->minor_cur.symbol);
993 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(data->CM_euro_isprefix), PREFS->minor_cur.sym_prefix);
994 ui_gtk_entry_set_text(data->ST_euro_decimalchar, PREFS->minor_cur.decimal_char);
995 ui_gtk_entry_set_text(data->ST_euro_groupingchar, PREFS->minor_cur.grouping_char);
996 gtk_spin_button_set_value(GTK_SPIN_BUTTON(data->NB_euro_fracdigits), PREFS->minor_cur.frac_digits);
997
998
999 //gtk_entry_set_text(GTK_ENTRY(data->ST_euro_symbol), PREFS->euro_symbol);
1000 //gtk_spin_button_set_value(GTK_SPIN_BUTTON(data->NB_euro_nbdec), PREFS->euro_nbdec);
1001 //gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(data->CM_euro_thsep), PREFS->euro_thsep);
1002
1003 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(data->CM_stat_byamount), PREFS->stat_byamount);
1004 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(data->CM_stat_showrate), PREFS->stat_showrate);
1005 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(data->CM_stat_showdetail), PREFS->stat_showdetail);
1006
1007 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(data->CM_budg_showdetail), PREFS->budg_showdetail);
1008
1009 gtk_combo_box_set_active(GTK_COMBO_BOX(data->CY_color_scheme), PREFS->report_color_scheme);
1010
1011 /* import */
1012 gtk_combo_box_set_active(GTK_COMBO_BOX(data->CY_dtex_datefmt), PREFS->dtex_datefmt);
1013 gtk_combo_box_set_active(GTK_COMBO_BOX(data->CY_dtex_ofxname), PREFS->dtex_ofxname);
1014 gtk_combo_box_set_active(GTK_COMBO_BOX(data->CY_dtex_ofxmemo), PREFS->dtex_ofxmemo);
1015 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(data->CM_dtex_qifmemo), PREFS->dtex_qifmemo);
1016 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(data->CM_dtex_qifswap), PREFS->dtex_qifswap);
1017
1018
1019 }
1020
1021
1022 /*
1023 ** get :: fill PREFS structure from widgets
1024 */
1025
1026 #define RGBA_TO_INT(x) (int)(x*255)
1027
1028 static gchar *gdk_rgba_to_hex(GdkRGBA *rgba)
1029 {
1030 return g_strdup_printf("#%02x%02x%02x", RGBA_TO_INT(rgba->red), RGBA_TO_INT(rgba->green), RGBA_TO_INT(rgba->blue));
1031 }
1032
1033
1034 static void defpref_get(struct defpref_data *data)
1035 {
1036 GdkRGBA rgba;
1037 const gchar *lang;
1038
1039 DB( g_print("\n[ui-pref] get\n") );
1040
1041 g_free(PREFS->language);
1042 PREFS->language = NULL;
1043 lang = gtk_combo_box_get_active_id(GTK_COMBO_BOX(data->CY_language));
1044 if(lang != NULL)
1045 {
1046 PREFS->language = g_strdup(lang);
1047 }
1048
1049 PREFS->toolbar_style = gtk_combo_box_get_active(GTK_COMBO_BOX(data->CY_toolbar));
1050 //PREFS->image_size = gtk_spin_button_get_value(GTK_SPIN_BUTTON(data->NB_image_size));
1051
1052 PREFS->custom_colors = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(data->CM_custom_colors));
1053
1054 gtk_color_chooser_get_rgba(GTK_COLOR_CHOOSER(data->CP_exp_color), &rgba);
1055 g_free(PREFS->color_exp);
1056 PREFS->color_exp = gdk_rgba_to_hex(&rgba);
1057
1058 gtk_color_chooser_get_rgba(GTK_COLOR_CHOOSER(data->CP_inc_color), &rgba);
1059 g_free(PREFS->color_inc);
1060 PREFS->color_inc = gdk_rgba_to_hex(&rgba);
1061
1062 gtk_color_chooser_get_rgba(GTK_COLOR_CHOOSER(data->CP_warn_color), &rgba);
1063 g_free(PREFS->color_warn);
1064 PREFS->color_warn = gdk_rgba_to_hex(&rgba);
1065
1066 //PREFS->rules_hint = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(data->CM_ruleshint));
1067 PREFS->grid_lines = gtk_combo_box_get_active(GTK_COMBO_BOX(data->CY_gridlines));
1068
1069 PREFS->fisc_year_day = gtk_spin_button_get_value(GTK_SPIN_BUTTON(data->NB_fiscyearday));
1070 PREFS->fisc_year_month = 1 + gtk_combo_box_get_active(GTK_COMBO_BOX(data->CY_fiscyearmonth));
1071
1072 list_txn_colpref_get(GTK_TREE_VIEW(data->LV_opecolumns), PREFS->lst_ope_columns);
1073
1074 g_free(PREFS->path_hbfile);
1075 PREFS->path_hbfile = g_strdup(gtk_entry_get_text(GTK_ENTRY(data->ST_path_hbfile)));
1076
1077 ui_gtk_entry_replace_text(data->ST_path_import, &PREFS->path_import);
1078
1079 ui_gtk_entry_replace_text(data->ST_path_export, &PREFS->path_export);
1080
1081 PREFS->loadlast = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(data->CM_load_last));
1082 PREFS->appendscheduled = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(data->CM_append_scheduled));
1083 PREFS->do_update_currency = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(data->CM_do_update_currency));
1084
1085 PREFS->showsplash = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(data->CM_show_splash));
1086 PREFS->heritdate = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(data->CM_herit_date));
1087 PREFS->hidereconciled = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(data->CM_hide_reconciled));
1088 PREFS->showremind = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(data->CM_show_remind));
1089
1090 //g_free(PREFS->path_navigator);
1091 //PREFS->path_navigator = g_strdup(gtk_entry_get_text(GTK_ENTRY(data->ST_path_navigator)));
1092
1093 g_free(PREFS->date_format);
1094 PREFS->date_format = g_strdup(gtk_entry_get_text(GTK_ENTRY(data->ST_datefmt)));
1095
1096 PREFS->vehicle_unit_ismile = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(data->CM_unitismile));
1097 PREFS->vehicle_unit_isgal = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(data->CM_unitisgal));
1098
1099 PREFS->date_range_wal = gtk_combo_box_get_active(GTK_COMBO_BOX(data->CY_daterange_wal));
1100 PREFS->date_range_txn = gtk_combo_box_get_active(GTK_COMBO_BOX(data->CY_daterange_txn));
1101 PREFS->date_future_nbdays = gtk_spin_button_get_value(GTK_SPIN_BUTTON(data->ST_datefuture_nbdays));
1102 PREFS->date_range_rep = gtk_combo_box_get_active(GTK_COMBO_BOX(data->CY_daterange_rep));
1103
1104 PREFS->euro_active = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(data->CM_euro_enable));
1105
1106 PREFS->euro_country = data->country;
1107 PREFS->euro_value = gtk_spin_button_get_value(GTK_SPIN_BUTTON(data->NB_euro_value));
1108 //strcpy(PREFS->euro_symbol, gtk_entry_get_text(GTK_ENTRY(data->ST_euro_symbol)));
1109 //PREFS->euro_nbdec = gtk_spin_button_get_value(GTK_SPIN_BUTTON(data->NB_euro_nbdec));
1110 //PREFS->euro_thsep = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(data->CM_euro_thsep));
1111
1112 ui_gtk_entry_replace_text(data->ST_euro_symbol, &PREFS->minor_cur.symbol);
1113 PREFS->minor_cur.sym_prefix = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(data->CM_euro_isprefix));
1114 ui_gtk_entry_replace_text(data->ST_euro_decimalchar, &PREFS->minor_cur.decimal_char);
1115 ui_gtk_entry_replace_text(data->ST_euro_groupingchar, &PREFS->minor_cur.grouping_char);
1116 PREFS->minor_cur.frac_digits = gtk_spin_button_get_value(GTK_SPIN_BUTTON(data->NB_euro_fracdigits));
1117
1118 PREFS->stat_byamount = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(data->CM_stat_byamount));
1119 PREFS->stat_showrate = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(data->CM_stat_showrate));
1120 PREFS->stat_showdetail = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(data->CM_stat_showdetail));
1121
1122 PREFS->budg_showdetail = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(data->CM_budg_showdetail));
1123
1124 PREFS->report_color_scheme = gtk_combo_box_get_active(GTK_COMBO_BOX(data->CY_color_scheme));
1125
1126 /* import */
1127 PREFS->dtex_datefmt = gtk_combo_box_get_active(GTK_COMBO_BOX(data->CY_dtex_datefmt));
1128 PREFS->dtex_ofxname = gtk_combo_box_get_active(GTK_COMBO_BOX(data->CY_dtex_ofxname));
1129 PREFS->dtex_ofxmemo = gtk_combo_box_get_active(GTK_COMBO_BOX(data->CY_dtex_ofxmemo));
1130 PREFS->dtex_qifmemo = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(data->CM_dtex_qifmemo));
1131 PREFS->dtex_qifswap = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(data->CM_dtex_qifswap));
1132
1133 //PREFS->chart_legend = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(data->CM_chartlegend));
1134
1135 }
1136
1137
1138 static GtkWidget *defpref_page_import (struct defpref_data *data)
1139 {
1140 GtkWidget *content_grid, *group_grid, *hbox, *label, *widget;
1141 gint crow, row;
1142
1143 content_grid = gtk_grid_new();
1144 gtk_grid_set_row_spacing (GTK_GRID (content_grid), SPACING_LARGE);
1145 gtk_orientable_set_orientation(GTK_ORIENTABLE(content_grid), GTK_ORIENTATION_VERTICAL);
1146
1147 crow = 0;
1148 // group :: Date options
1149 group_grid = gtk_grid_new ();
1150 gtk_grid_set_row_spacing (GTK_GRID (group_grid), SPACING_SMALL);
1151 gtk_grid_set_column_spacing (GTK_GRID (group_grid), SPACING_MEDIUM);
1152 gtk_grid_attach (GTK_GRID (content_grid), group_grid, 0, crow++, 1, 1);
1153
1154 label = make_label_group(_("Date options"));
1155 gtk_grid_attach (GTK_GRID (group_grid), label, 0, 0, 3, 1);
1156
1157 row = 1;
1158 label = make_label_widget(_("Date order:"));
1159 //----------------------------------------- l, r, t, b
1160 gtk_grid_attach (GTK_GRID (group_grid), label, 1, row, 1, 1);
1161 widget = make_cycle(label, CYA_IMPORT_DATEORDER);
1162 data->CY_dtex_datefmt = widget;
1163 //gtk_grid_attach (GTK_GRID (group_grid), data->CY_option[FILTER_DATE], 1, 2, row, row+1);
1164 gtk_grid_attach (GTK_GRID (group_grid), widget, 2, row, 1, 1);
1165
1166
1167 // group :: OFX/QFX options
1168 group_grid = gtk_grid_new ();
1169 gtk_grid_set_row_spacing (GTK_GRID (group_grid), SPACING_SMALL);
1170 gtk_grid_set_column_spacing (GTK_GRID (group_grid), SPACING_MEDIUM);
1171 gtk_grid_attach (GTK_GRID (content_grid), group_grid, 0, crow++, 1, 1);
1172
1173 label = make_label_group(_("OFX/QFX options"));
1174 gtk_grid_attach (GTK_GRID (group_grid), label, 0, 0, 3, 1);
1175
1176 row = 1;
1177 label = make_label_widget(_("_Name field:"));
1178 //----------------------------------------- l, r, t, b
1179 gtk_grid_attach (GTK_GRID (group_grid), label, 1, row, 1, 1);
1180 widget = make_cycle(label, CYA_IMPORT_OFXNAME);
1181 data->CY_dtex_ofxname = widget;
1182 //gtk_grid_attach (GTK_GRID (group_grid), data->CY_option[FILTER_DATE], 1, 2, row, row+1);
1183 gtk_grid_attach (GTK_GRID (group_grid), widget, 2, row, 1, 1);
1184
1185 row++;
1186 label = make_label_widget(_("_Memo field:"));
1187 //----------------------------------------- l, r, t, b
1188 gtk_grid_attach (GTK_GRID (group_grid), label, 1, row, 1, 1);
1189 widget = make_cycle(label, CYA_IMPORT_OFXMEMO);
1190 data->CY_dtex_ofxmemo = widget;
1191 //gtk_grid_attach (GTK_GRID (group_grid), data->CY_option[FILTER_DATE], 1, 2, row, row+1);
1192 gtk_grid_attach (GTK_GRID (group_grid), widget, 2, row, 1, 1);
1193
1194 // group :: QIF options
1195 group_grid = gtk_grid_new ();
1196 gtk_grid_set_row_spacing (GTK_GRID (group_grid), SPACING_SMALL);
1197 gtk_grid_set_column_spacing (GTK_GRID (group_grid), SPACING_MEDIUM);
1198 gtk_grid_attach (GTK_GRID (content_grid), group_grid, 0, crow++, 1, 1);
1199
1200 label = make_label_group(_("QIF options"));
1201 gtk_grid_attach (GTK_GRID (group_grid), label, 0, 0, 3, 1);
1202
1203 row = 1;
1204 label = make_label_widget(_("Memos:"));
1205 gtk_grid_attach (GTK_GRID (group_grid), label, 1, row, 1, 1);
1206 widget = gtk_check_button_new_with_mnemonic (_("_Import"));
1207 data->CM_dtex_qifmemo = widget;
1208 gtk_grid_attach (GTK_GRID (group_grid), widget, 2, row, 1, 1);
1209 widget = gtk_check_button_new_with_mnemonic (_("_Swap with payees"));
1210 data->CM_dtex_qifswap = widget;
1211 gtk_grid_attach (GTK_GRID (group_grid), widget, 3, row, 1, 1);
1212
1213
1214 // group :: Files folder
1215 group_grid = gtk_grid_new ();
1216 gtk_grid_set_row_spacing (GTK_GRID (group_grid), SPACING_SMALL);
1217 gtk_grid_set_column_spacing (GTK_GRID (group_grid), SPACING_MEDIUM);
1218 gtk_grid_attach (GTK_GRID (content_grid), group_grid, 0, crow++, 1, 1);
1219
1220 label = make_label_group(_("Files folder"));
1221 gtk_grid_attach (GTK_GRID (group_grid), label, 0, 0, 3, 1);
1222
1223 row = 1;
1224 label = make_label_widget(_("_Import:"));
1225 //----------------------------------------- l, r, t, b
1226 gtk_grid_attach (GTK_GRID (group_grid), label, 1, row, 1, 1);
1227
1228 hbox = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0);
1229 gtk_widget_set_hexpand (hbox, TRUE);
1230 gtk_grid_attach (GTK_GRID (group_grid), hbox, 2, row, 1, 1);
1231
1232 widget = make_string(label);
1233 data->ST_path_import = widget;
1234 gtk_style_context_add_class (gtk_widget_get_style_context (GTK_WIDGET(widget)), GTK_STYLE_CLASS_LINKED);
1235 gtk_box_pack_start (GTK_BOX (hbox), widget, TRUE, TRUE, 0);
1236
1237 //widget = gtk_button_new_with_label("...");
1238 widget = gtk_button_new_from_icon_name(ICONNAME_FOLDER, GTK_ICON_SIZE_BUTTON);
1239 data->BT_path_import = widget;
1240 gtk_box_pack_start (GTK_BOX (hbox), widget, FALSE, FALSE, 0);
1241
1242 row++;
1243 label = make_label_widget(_("_Export:"));
1244 //----------------------------------------- l, r, t, b
1245 gtk_grid_attach (GTK_GRID (group_grid), label, 1, row, 1, 1);
1246
1247 hbox = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0);
1248 gtk_widget_set_hexpand (hbox, TRUE);
1249 gtk_grid_attach (GTK_GRID (group_grid), hbox, 2, row, 1, 1);
1250
1251 widget = make_string(label);
1252 data->ST_path_export = widget;
1253 gtk_style_context_add_class (gtk_widget_get_style_context (GTK_WIDGET(widget)), GTK_STYLE_CLASS_LINKED);
1254 gtk_box_pack_start (GTK_BOX (hbox), widget, TRUE, TRUE, 0);
1255
1256 //widget = gtk_button_new_with_label("...");
1257 widget = gtk_button_new_from_icon_name(ICONNAME_FOLDER, GTK_ICON_SIZE_BUTTON);
1258 data->BT_path_export = widget;
1259 gtk_box_pack_start (GTK_BOX (hbox), widget, FALSE, FALSE, 0);
1260
1261 return content_grid;
1262 }
1263
1264 #define cube_dim 16
1265
1266 static gboolean
1267 draw_callback (GtkWidget *widget,
1268 cairo_t *cr,
1269 gpointer user_data)
1270 {
1271 struct defpref_data *data = user_data;
1272 gint index;
1273 GtkColorScheme scheme;
1274 gint w, h;
1275 gint i, x, y;
1276
1277 index = gtk_combo_box_get_active(GTK_COMBO_BOX(data->CY_color_scheme));
1278
1279 colorscheme_init(&scheme, index);
1280
1281 gtk_widget_get_size_request (widget, &w, &h);
1282 x = y = 0;
1283 for(i=0;i<scheme.nb_cols;i++)
1284 {
1285 cairo_user_set_rgbcol (cr, &scheme.colors[i]);
1286 cairo_rectangle(cr, x, y, cube_dim, cube_dim);
1287 cairo_fill(cr);
1288 x += 1 + cube_dim;
1289 if( i == 15 )
1290 { x = 0; y = 1 + cube_dim; }
1291 }
1292
1293 return TRUE;
1294 }
1295
1296
1297
1298 static GtkWidget *defpref_page_reports (struct defpref_data *data)
1299 {
1300 GtkWidget *content_grid, *group_grid, *label, *widget;
1301 gint crow, row;
1302
1303 content_grid = gtk_grid_new();
1304 gtk_grid_set_row_spacing (GTK_GRID (content_grid), SPACING_LARGE);
1305 gtk_orientable_set_orientation(GTK_ORIENTABLE(content_grid), GTK_ORIENTATION_VERTICAL);
1306
1307 crow = 0;
1308 // group :: Initial filter
1309 group_grid = gtk_grid_new ();
1310 gtk_grid_set_row_spacing (GTK_GRID (group_grid), SPACING_SMALL);
1311 gtk_grid_set_column_spacing (GTK_GRID (group_grid), SPACING_MEDIUM);
1312 gtk_grid_attach (GTK_GRID (content_grid), group_grid, 0, crow++, 1, 1);
1313
1314 label = make_label_group(_("Initial filter"));
1315 gtk_grid_attach (GTK_GRID (group_grid), label, 0, 0, 3, 1);
1316
1317 row = 1;
1318 label = make_label_widget(_("Date _range:"));
1319 //----------------------------------------- l, r, t, b
1320 gtk_grid_attach (GTK_GRID (group_grid), label, 1, row, 1, 1);
1321 widget = make_daterange(label, FALSE);
1322 data->CY_daterange_rep = widget;
1323 //gtk_grid_attach (GTK_GRID (group_grid), data->CY_option[FILTER_DATE], 1, 2, row, row+1);
1324 gtk_grid_attach (GTK_GRID (group_grid), widget, 2, row, 1, 1);
1325
1326 // group ::Charts options
1327 group_grid = gtk_grid_new ();
1328 gtk_grid_set_row_spacing (GTK_GRID (group_grid), SPACING_SMALL);
1329 gtk_grid_set_column_spacing (GTK_GRID (group_grid), SPACING_MEDIUM);
1330 gtk_grid_attach (GTK_GRID (content_grid), group_grid, 0, crow++, 1, 1);
1331
1332 label = make_label_group(_("Charts options"));
1333 gtk_grid_attach (GTK_GRID (group_grid), label, 0, 0, 3, 1);
1334
1335 row = 1;
1336 label = make_label_widget(_("Color scheme:"));
1337 //----------------------------------------- l, r, t, b
1338 gtk_grid_attach (GTK_GRID (group_grid), label, 1, row, 1, 1);
1339 widget = make_cycle(label, chart_colors);
1340 data->CY_color_scheme = widget;
1341 //gtk_grid_attach (GTK_GRID (group_grid), data->CY_option[FILTER_DATE], 1, 2, row, row+1);
1342 gtk_grid_attach (GTK_GRID (group_grid), widget, 2, row, 1, 1);
1343
1344 row++;
1345 widget = gtk_drawing_area_new ();
1346 data->DA_colors = widget;
1347 gtk_widget_set_size_request (widget, (1+cube_dim)*16, (1+cube_dim)*2);
1348 gtk_grid_attach (GTK_GRID (group_grid), widget, 2, row, 1, 1);
1349
1350 g_signal_connect (data->DA_colors, "draw", G_CALLBACK (draw_callback), data);
1351
1352 // group :: Statistics options
1353 group_grid = gtk_grid_new ();
1354 gtk_grid_set_row_spacing (GTK_GRID (group_grid), SPACING_SMALL);
1355 gtk_grid_set_column_spacing (GTK_GRID (group_grid), SPACING_MEDIUM);
1356 gtk_grid_attach (GTK_GRID (content_grid), group_grid, 0, crow++, 1, 1);
1357
1358 label = make_label_group(_("Statistics options"));
1359 gtk_grid_attach (GTK_GRID (group_grid), label, 0, 0, 3, 1);
1360
1361 row = 1;
1362 widget = gtk_check_button_new_with_mnemonic (_("Show by _amount"));
1363 data->CM_stat_byamount = widget;
1364 gtk_grid_attach (GTK_GRID (group_grid), widget, 1, row, 2, 1);
1365
1366 row++;
1367 widget = gtk_check_button_new_with_mnemonic (_("Show _rate column"));
1368 data->CM_stat_showrate = widget;
1369 gtk_grid_attach (GTK_GRID (group_grid), widget, 1, row, 2, 1);
1370
1371 row++;
1372 widget = gtk_check_button_new_with_mnemonic (_("Show _details"));
1373 data->CM_stat_showdetail = widget;
1374 gtk_grid_attach (GTK_GRID (group_grid), widget, 1, row, 2, 1);
1375
1376 // group :: Budget options
1377 group_grid = gtk_grid_new ();
1378 gtk_grid_set_row_spacing (GTK_GRID (group_grid), SPACING_SMALL);
1379 gtk_grid_set_column_spacing (GTK_GRID (group_grid), SPACING_MEDIUM);
1380 gtk_grid_attach (GTK_GRID (content_grid), group_grid, 0, crow++, 1, 1);
1381
1382 label = make_label_group(_("Budget options"));
1383 gtk_grid_attach (GTK_GRID (group_grid), label, 0, 0, 3, 1);
1384
1385 row = 1;
1386 widget = gtk_check_button_new_with_mnemonic (_("Show _details"));
1387 data->CM_budg_showdetail = widget;
1388 gtk_grid_attach (GTK_GRID (group_grid), widget, 1, row, 2, 1);
1389
1390 return content_grid;
1391 }
1392
1393
1394 static GtkWidget *defpref_page_euro (struct defpref_data *data)
1395 {
1396 GtkWidget *content_grid, *group_grid, *label, *widget, *expander;
1397 gint crow, row;
1398
1399 content_grid = gtk_grid_new();
1400 gtk_grid_set_row_spacing (GTK_GRID (content_grid), SPACING_LARGE);
1401 gtk_orientable_set_orientation(GTK_ORIENTABLE(content_grid), GTK_ORIENTATION_VERTICAL);
1402
1403 crow = 0;
1404 // group :: General
1405 group_grid = gtk_grid_new ();
1406 gtk_grid_set_row_spacing (GTK_GRID (group_grid), SPACING_SMALL);
1407 gtk_grid_set_column_spacing (GTK_GRID (group_grid), SPACING_MEDIUM);
1408 gtk_grid_attach (GTK_GRID (content_grid), group_grid, 0, crow++, 1, 1);
1409
1410 label = make_label_group(_("General"));
1411 gtk_grid_attach (GTK_GRID (group_grid), label, 0, 0, 3, 1);
1412
1413 row=1;
1414 widget = gtk_check_button_new_with_mnemonic (_("_Enable"));
1415 data->CM_euro_enable = widget;
1416 gtk_grid_attach (GTK_GRID (group_grid), widget, 1, row, 2, 1);
1417
1418 // group :: Currency
1419 group_grid = gtk_grid_new ();
1420 data->GRP_currency = group_grid;
1421 gtk_grid_set_row_spacing (GTK_GRID (group_grid), SPACING_SMALL);
1422 gtk_grid_set_column_spacing (GTK_GRID (group_grid), SPACING_MEDIUM);
1423 gtk_grid_attach (GTK_GRID (content_grid), group_grid, 0, crow++, 1, 1);
1424
1425 label = make_label_group(_("Currency"));
1426 gtk_grid_attach (GTK_GRID (group_grid), label, 0, 0, 4, 1);
1427
1428 row=1;
1429 widget = make_label(NULL, 0.0, 0.5);
1430 data->ST_euro_country = widget;
1431 //gtk_grid_attach (GTK_GRID (group_grid), data->CY_option[FILTER_DATE], 1, 2, row, row+1);
1432 gtk_grid_attach (GTK_GRID (group_grid), widget, 1, row, 1, 1);
1433
1434 //row++;
1435 label = make_label_widget(_("_Preset:"));
1436 //----------------------------------------- l, r, t, b
1437 gtk_grid_attach (GTK_GRID (group_grid), label, 2, row, 1, 1);
1438 widget = ui_euro_combobox_new (label);
1439 data->CY_euro_preset = widget;
1440 gtk_widget_set_margin_left (label, 2*SPACING_LARGE);
1441 //gtk_grid_attach (GTK_GRID (group_grid), data->CY_option[FILTER_DATE], 1, 2, row, row+1);
1442 gtk_grid_attach (GTK_GRID (group_grid), widget, 3, row, 1, 1);
1443
1444
1445 // group :: Exchange rate
1446 group_grid = gtk_grid_new ();
1447 data->GRP_rate = group_grid;
1448 gtk_grid_set_row_spacing (GTK_GRID (group_grid), SPACING_SMALL);
1449 gtk_grid_set_column_spacing (GTK_GRID (group_grid), SPACING_MEDIUM);
1450 gtk_grid_attach (GTK_GRID (content_grid), group_grid, 0, crow++, 1, 1);
1451
1452 label = make_label_group(_("Exchange rate"));
1453 gtk_grid_attach (GTK_GRID (group_grid), label, 0, 0, 3, 1);
1454
1455 row=1;
1456 label = make_label_widget("1 EUR _=");
1457 gtk_grid_attach (GTK_GRID (group_grid), label, 1, row, 1, 1);
1458 widget = make_exchange_rate(label);
1459 data->NB_euro_value = widget;
1460 //gtk_grid_attach (GTK_GRID (group_grid), data->CY_option[FILTER_DATE], 1, 2, row, row+1);
1461 gtk_grid_attach (GTK_GRID (group_grid), widget, 2, row, 1, 1);
1462
1463 // group :: Numbers format
1464 group_grid = gtk_grid_new ();
1465 data->GRP_format = group_grid;
1466 gtk_grid_set_row_spacing (GTK_GRID (group_grid), SPACING_SMALL);
1467 gtk_grid_set_column_spacing (GTK_GRID (group_grid), SPACING_MEDIUM);
1468 gtk_grid_attach (GTK_GRID (content_grid), group_grid, 0, crow++, 1, 1);
1469
1470 label = make_label_group(_("Format"));
1471 gtk_grid_attach (GTK_GRID (group_grid), label, 0, 0, 3, 1);
1472
1473 row = 1;
1474 widget = make_label(NULL, 0, 0.0);
1475 data->LB_numbereuro = widget;
1476 gtk_grid_attach (GTK_GRID (group_grid), widget, 1, row, 1, 1);
1477
1478 row++;
1479 expander = gtk_expander_new_with_mnemonic(_("_Customize"));
1480 gtk_grid_attach (GTK_GRID (group_grid), expander, 1, row, 1, 1);
1481
1482 group_grid = gtk_grid_new ();
1483 gtk_grid_set_row_spacing (GTK_GRID (group_grid), SPACING_SMALL);
1484 gtk_grid_set_column_spacing (GTK_GRID (group_grid), SPACING_MEDIUM);
1485 gtk_container_add (GTK_CONTAINER (expander), group_grid);
1486
1487 row = 0;
1488 label = make_label_widget(_("_Symbol:"));
1489 gtk_grid_attach (GTK_GRID (group_grid), label, 1, row, 1, 1);
1490 widget = make_string_maxlength(label, 3);
1491 data->ST_euro_symbol = widget;
1492 gtk_grid_attach (GTK_GRID (group_grid), widget, 2, row, 1, 1);
1493
1494 row++;
1495 widget = gtk_check_button_new_with_mnemonic (_("Is pre_fix"));
1496 data->CM_euro_isprefix = widget;
1497 gtk_grid_attach (GTK_GRID (group_grid), widget, 2, row, 1, 1);
1498
1499 row++;
1500 label = make_label_widget(_("_Decimal char:"));
1501 gtk_grid_attach (GTK_GRID (group_grid), label, 1, row, 1, 1);
1502 widget = make_string_maxlength(label, 1);
1503 data->ST_euro_decimalchar = widget;
1504 gtk_grid_attach (GTK_GRID (group_grid), widget, 2, row, 1, 1);
1505
1506 row++;
1507 label = make_label_widget(_("_Frac digits:"));
1508 gtk_grid_attach (GTK_GRID (group_grid), label, 1, row, 1, 1);
1509 widget = make_numeric(label, 0.0, 6.0);
1510 data->NB_euro_fracdigits = widget;
1511 gtk_grid_attach (GTK_GRID (group_grid), widget, 2, row, 1, 1);
1512
1513 row++;
1514 label = make_label_widget(_("_Grouping char:"));
1515 gtk_grid_attach (GTK_GRID (group_grid), label, 1, row, 1, 1);
1516 widget = make_string_maxlength(label, 1);
1517 data->ST_euro_groupingchar = widget;
1518 gtk_grid_attach (GTK_GRID (group_grid), widget, 2, row, 1, 1);
1519
1520 return content_grid;
1521 }
1522
1523
1524 static GtkWidget *defpref_page_display (struct defpref_data *data)
1525 {
1526 GtkWidget *content_grid, *group_grid, *label, *widget, *expander;
1527 gint crow, row;
1528
1529 content_grid = gtk_grid_new();
1530 gtk_grid_set_row_spacing (GTK_GRID (content_grid), SPACING_LARGE);
1531 gtk_orientable_set_orientation(GTK_ORIENTABLE(content_grid), GTK_ORIENTATION_VERTICAL);
1532
1533 crow = 0;
1534 // group :: Date options
1535 group_grid = gtk_grid_new ();
1536 gtk_grid_set_row_spacing (GTK_GRID (group_grid), SPACING_SMALL);
1537 gtk_grid_set_column_spacing (GTK_GRID (group_grid), SPACING_MEDIUM);
1538 gtk_grid_attach (GTK_GRID (content_grid), group_grid, 0, crow++, 1, 1);
1539
1540 label = make_label_group(_("Date"));
1541 gtk_grid_attach (GTK_GRID (group_grid), label, 0, 0, 3, 1);
1542
1543 row = 1;
1544 widget = make_label(NULL, 0, 0.5);
1545 data->LB_date = widget;
1546 gtk_grid_attach (GTK_GRID (group_grid), widget, 1, row, 2, 1);
1547
1548 row++;
1549 expander = gtk_expander_new_with_mnemonic(_("_Customize"));
1550 gtk_grid_attach (GTK_GRID (group_grid), expander, 1, row, 1, 1);
1551
1552 group_grid = gtk_grid_new ();
1553 gtk_grid_set_row_spacing (GTK_GRID (group_grid), SPACING_SMALL);
1554 gtk_grid_set_column_spacing (GTK_GRID (group_grid), SPACING_MEDIUM);
1555 gtk_container_add (GTK_CONTAINER (expander), group_grid);
1556
1557 row = 1;
1558 label = make_label_widget(_("_Format:"));
1559 //----------------------------------------- l, r, t, b
1560 gtk_grid_attach (GTK_GRID (group_grid), label, 1, row, 1, 1);
1561 widget = make_string(label);
1562 data->ST_datefmt = widget;
1563 //gtk_grid_attach (GTK_GRID (group_grid), data->CY_option[FILTER_DATE], 1, 2, row, row+1);
1564 gtk_grid_attach (GTK_GRID (group_grid), widget, 2, row, 1, 1);
1565
1566 widget = gtk_image_new_from_icon_name (ICONNAME_INFO, GTK_ICON_SIZE_BUTTON);
1567 gtk_grid_attach (GTK_GRID (group_grid), widget, 3, row, 1, 1);
1568
1569
1570 gtk_widget_set_tooltip_text(widget,
1571 _("%a locale's abbreviated weekday name.\n"
1572 "%A locale's full weekday name. \n"
1573 "%b locale's abbreviated month name. \n"
1574 "%B locale's full month name. \n"
1575 "%c locale's appropriate date and time representation. \n"
1576 "%C century number (the year divided by 100 and truncated to an integer) as a decimal number [00-99]. \n"
1577 "%d day of the month as a decimal number [01,31]. \n"
1578 "%D same as %m/%d/%y. \n"
1579 "%e day of the month as a decimal number [1,31]; a single digit is preceded by a space. \n"
1580 "%j day of the year as a decimal number [001,366]. \n"
1581 "%m month as a decimal number [01,12]. \n"
1582 "%p locale's appropriate date representation. \n"
1583 "%y year without century as a decimal number [00,99]. \n"
1584 "%Y year with century as a decimal number. \n")
1585 );
1586
1587 row++;
1588 widget = make_label(NULL, 0.0, 0.5);
1589 gtk_label_set_markup (GTK_LABEL(widget), "<small><a href=\"http://man7.org/linux/man-pages/man3/strftime.3.html\">online reference</a></small>");
1590 gtk_grid_attach (GTK_GRID (group_grid), widget, 2, row, 1, 1);
1591
1592 // group :: Measurement units
1593 group_grid = gtk_grid_new ();
1594 gtk_grid_set_row_spacing (GTK_GRID (group_grid), SPACING_SMALL);
1595 gtk_grid_set_column_spacing (GTK_GRID (group_grid), SPACING_MEDIUM);
1596 gtk_grid_attach (GTK_GRID (content_grid), group_grid, 0, crow++, 1, 1);
1597
1598 label = make_label_group(_("Measurement units"));
1599 gtk_grid_attach (GTK_GRID (group_grid), label, 0, 0, 3, 1);
1600
1601 row = 1;
1602 widget = gtk_check_button_new_with_mnemonic (_("Use _miles for meter"));
1603 data->CM_unitismile = widget;
1604 gtk_grid_attach (GTK_GRID (group_grid), widget, 1, row, 2, 1);
1605
1606 row++;
1607 widget = gtk_check_button_new_with_mnemonic (_("Use _gallon for fuel"));
1608 data->CM_unitisgal = widget;
1609 gtk_grid_attach (GTK_GRID (group_grid), widget, 1, row, 2, 1);
1610
1611 return content_grid;
1612 }
1613
1614
1615 static GtkWidget *defpref_page_transactions (struct defpref_data *data)
1616 {
1617 GtkWidget *content_grid, *group_grid, *sw, *label, *widget;
1618 gint crow, row;
1619
1620 content_grid = gtk_grid_new();
1621 gtk_grid_set_row_spacing (GTK_GRID (content_grid), SPACING_LARGE);
1622 gtk_orientable_set_orientation(GTK_ORIENTABLE(content_grid), GTK_ORIENTATION_VERTICAL);
1623
1624 crow = 0;
1625 // group :: Transaction window
1626 group_grid = gtk_grid_new ();
1627 gtk_grid_set_row_spacing (GTK_GRID (group_grid), SPACING_SMALL);
1628 gtk_grid_set_column_spacing (GTK_GRID (group_grid), SPACING_MEDIUM);
1629 gtk_grid_attach (GTK_GRID (content_grid), group_grid, 0, crow++, 1, 1);
1630
1631 label = make_label_group(_("Transaction window"));
1632 gtk_grid_attach (GTK_GRID (group_grid), label, 0, 0, 3, 1);
1633
1634 row = 1;
1635 label = make_label_widget(_("Date _range:"));
1636 //----------------------------------------- l, r, t, b
1637 gtk_grid_attach (GTK_GRID (group_grid), label, 1, row, 1, 1);
1638 widget = make_daterange(label, FALSE);
1639 data->CY_daterange_txn = widget;
1640 gtk_grid_attach (GTK_GRID (group_grid), widget, 2, row, 1, 1);
1641
1642 row++;
1643 label = make_label_widget(_("_Show:"));
1644 //----------------------------------------- l, r, t, b
1645 gtk_grid_attach (GTK_GRID (group_grid), label, 1, row, 1, 1);
1646 widget = make_numeric(NULL, 0, 366);
1647
1648 data->ST_datefuture_nbdays = widget;
1649 gtk_grid_attach (GTK_GRID (group_grid), widget, 2, row, 1, 1);
1650
1651 //TRANSLATORS: there is a spinner on the left of this label, and so you have 0....x days in advance the current date
1652 label = make_label(_("days in advance the current date"), 0, 0.5);
1653 gtk_grid_attach (GTK_GRID (group_grid), label, 3, row, 1, 1);
1654
1655 row++;
1656 widget = gtk_check_button_new_with_mnemonic (_("Hide reconciled transactions"));
1657 data->CM_hide_reconciled = widget;
1658 gtk_grid_attach (GTK_GRID (group_grid), widget, 2, row, 2, 1);
1659
1660 row++;
1661 widget = gtk_check_button_new_with_mnemonic (_("Always show remind transactions"));
1662 data->CM_show_remind = widget;
1663 gtk_grid_attach (GTK_GRID (group_grid), widget, 2, row, 2, 1);
1664
1665 // group :: Multiple add
1666 group_grid = gtk_grid_new ();
1667 gtk_grid_set_row_spacing (GTK_GRID (group_grid), SPACING_SMALL);
1668 gtk_grid_set_column_spacing (GTK_GRID (group_grid), SPACING_MEDIUM);
1669 gtk_grid_attach (GTK_GRID (content_grid), group_grid, 0, crow++, 1, 1);
1670
1671 label = make_label_group(_("Multiple add"));
1672 gtk_grid_attach (GTK_GRID (group_grid), label, 0, 0, 3, 1);
1673
1674 row = 1;
1675 widget = gtk_check_button_new_with_mnemonic (_("Keep the last date"));
1676 data->CM_herit_date = widget;
1677 gtk_grid_attach (GTK_GRID (group_grid), widget, 1, row, 2, 1);
1678
1679 // group :: Column list
1680 group_grid = gtk_grid_new ();
1681 gtk_grid_set_row_spacing (GTK_GRID (group_grid), SPACING_SMALL);
1682 gtk_grid_set_column_spacing (GTK_GRID (group_grid), SPACING_MEDIUM);
1683 gtk_grid_attach (GTK_GRID (content_grid), group_grid, 0, crow++, 1, 1);
1684
1685 label = make_label_group(_("Column list"));
1686 gtk_grid_attach (GTK_GRID (group_grid), label, 0, 0, 3, 1);
1687
1688 row = 1;
1689 sw = gtk_scrolled_window_new (NULL, NULL);
1690 gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (sw), GTK_SHADOW_ETCHED_IN);
1691 gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (sw), GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC);
1692 widget = (GtkWidget *)list_txn_colprefcreate();
1693 data->LV_opecolumns = widget;
1694 gtk_widget_set_size_request(data->LV_opecolumns, HB_MINWIDTH_LIST, -1);
1695 gtk_container_add (GTK_CONTAINER (sw), widget);
1696 gtk_widget_set_vexpand (sw, TRUE);
1697 gtk_grid_attach (GTK_GRID (group_grid), sw, 1, row, 2, 1);
1698 gtk_widget_set_tooltip_text(widget, _("Drag & drop to change the order"));
1699
1700 return content_grid;
1701 }
1702
1703
1704
1705 static GtkWidget *defpref_page_interface (struct defpref_data *data)
1706 {
1707 GtkWidget *content_grid, *group_grid, *hbox, *label, *widget;
1708 gint crow, row;
1709
1710 content_grid = gtk_grid_new();
1711 gtk_grid_set_row_spacing (GTK_GRID (content_grid), SPACING_LARGE);
1712 gtk_orientable_set_orientation(GTK_ORIENTABLE(content_grid), GTK_ORIENTATION_VERTICAL);
1713
1714 crow = 0;
1715 // group :: General
1716 group_grid = gtk_grid_new ();
1717 gtk_grid_set_row_spacing (GTK_GRID (group_grid), SPACING_SMALL);
1718 gtk_grid_set_column_spacing (GTK_GRID (group_grid), SPACING_MEDIUM);
1719 gtk_grid_attach (GTK_GRID (content_grid), group_grid, 0, crow++, 1, 1);
1720
1721 label = make_label_group(_("General"));
1722 gtk_grid_attach (GTK_GRID (group_grid), label, 0, 0, 3, 1);
1723
1724 row = 1;
1725 label = make_label_widget(_("_Language:"));
1726 gtk_grid_attach (GTK_GRID (group_grid), label, 1, row, 1, 1);
1727 widget = ui_language_combobox_new(label);
1728 data->CY_language = widget;
1729 gtk_grid_attach (GTK_GRID (group_grid), widget, 2, row, 1, 1);
1730
1731 row++;
1732 label = make_label_widget(_("_Toolbar:"));
1733 gtk_grid_attach (GTK_GRID (group_grid), label, 1, row, 1, 1);
1734 widget = make_cycle(label, CYA_TOOLBAR_STYLE);
1735 data->CY_toolbar = widget;
1736 gtk_grid_attach (GTK_GRID (group_grid), widget, 2, row, 1, 1);
1737
1738
1739 row++;
1740 //widget = gtk_check_button_new_with_mnemonic (_("Enable rows in alternating colors"));
1741 //data->CM_ruleshint = widget;
1742 label = make_label_widget(_("_Grid line:"));
1743 gtk_grid_attach (GTK_GRID (group_grid), label, 1, row, 1, 1);
1744 widget = make_cycle(label, CYA_GRID_LINES);
1745 data->CY_gridlines = widget;
1746 gtk_grid_attach (GTK_GRID (group_grid), widget, 2, row, 1, 1);
1747
1748 // group :: Amount colors
1749 group_grid = gtk_grid_new ();
1750 gtk_grid_set_row_spacing (GTK_GRID (group_grid), SPACING_SMALL);
1751 gtk_grid_set_column_spacing (GTK_GRID (group_grid), SPACING_MEDIUM);
1752 gtk_grid_attach (GTK_GRID (content_grid), group_grid, 0, crow++, 1, 1);
1753
1754 label = make_label_group(_("Amount colors"));
1755 gtk_grid_attach (GTK_GRID (group_grid), label, 0, 0, 3, 1);
1756
1757 row = 1;
1758 widget = gtk_check_button_new_with_mnemonic (_("Uses custom colors"));
1759 data->CM_custom_colors = widget;
1760 gtk_grid_attach (GTK_GRID (group_grid), widget, 2, row, 1, 1);
1761
1762 group_grid = gtk_grid_new ();
1763 data->GR_colors = group_grid;
1764 gtk_grid_set_row_spacing (GTK_GRID (group_grid), SPACING_SMALL);
1765 gtk_grid_set_column_spacing (GTK_GRID (group_grid), SPACING_MEDIUM);
1766 gtk_grid_attach (GTK_GRID (content_grid), group_grid, 0, crow++, 1, 1);
1767
1768 row++;
1769 label = make_label_widget(_("_Preset:"));
1770 //----------------------------------------- l, r, t, b
1771 gtk_grid_attach (GTK_GRID (group_grid), label, 1, row, 1, 1);
1772 widget = make_cycle(label, CYA_TANGO_COLORS);
1773 data->CY_colors = widget;
1774 //gtk_grid_attach (GTK_GRID (group_grid), data->CY_option[FILTER_DATE], 1, 2, row, row+1);
1775 gtk_grid_attach (GTK_GRID (group_grid), widget, 2, row, 1, 1);
1776
1777 row++;
1778 label = make_label_widget(_("_Expense:"));
1779 //----------------------------------------- l, r, t, b
1780 gtk_grid_attach (GTK_GRID (group_grid), label, 1, row, 1, 1);
1781 hbox = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, SPACING_SMALL);
1782 gtk_grid_attach (GTK_GRID (group_grid), hbox, 2, row, 1, 1);
1783
1784 widget = gtk_color_button_new ();
1785 data->CP_exp_color = widget;
1786 gtk_box_pack_start (GTK_BOX (hbox), widget, FALSE, FALSE, 0);
1787
1788 label = make_label_widget(_("_Income:"));
1789 gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0);
1790
1791 widget = gtk_color_button_new ();
1792 data->CP_inc_color = widget;
1793 gtk_box_pack_start (GTK_BOX (hbox), widget, FALSE, FALSE, 0);
1794
1795 label = make_label_widget(_("_Warning:"));
1796 gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0);
1797
1798 widget = gtk_color_button_new ();
1799 data->CP_warn_color = widget;
1800 gtk_box_pack_start (GTK_BOX (hbox), widget, FALSE, FALSE, 0);
1801
1802 return content_grid;
1803 }
1804
1805
1806 static GtkWidget *defpref_page_general (struct defpref_data *data)
1807 {
1808 GtkWidget *content_grid, *group_grid, *hbox, *label, *widget;
1809 gint crow, row;
1810
1811 content_grid = gtk_grid_new();
1812 gtk_grid_set_row_spacing (GTK_GRID (content_grid), SPACING_LARGE);
1813 gtk_orientable_set_orientation(GTK_ORIENTABLE(content_grid), GTK_ORIENTATION_VERTICAL);
1814
1815 crow = 0;
1816 // group :: Program start
1817 group_grid = gtk_grid_new ();
1818 gtk_grid_set_row_spacing (GTK_GRID (group_grid), SPACING_SMALL);
1819 gtk_grid_set_column_spacing (GTK_GRID (group_grid), SPACING_MEDIUM);
1820 gtk_grid_attach (GTK_GRID (content_grid), group_grid, 0, crow++, 1, 1);
1821
1822 label = make_label_group(_("Program start"));
1823 gtk_grid_attach (GTK_GRID (group_grid), label, 0, 0, 3, 1);
1824
1825 row = 1;
1826 widget = gtk_check_button_new_with_mnemonic (_("Show splash screen"));
1827 data->CM_show_splash = widget;
1828 gtk_grid_attach (GTK_GRID (group_grid), widget, 1, row, 2, 1);
1829
1830 row++;
1831 widget = gtk_check_button_new_with_mnemonic (_("Load last opened file"));
1832 data->CM_load_last = widget;
1833 gtk_grid_attach (GTK_GRID (group_grid), widget, 1, row, 2, 1);
1834
1835 row++;
1836 widget = gtk_check_button_new_with_mnemonic (_("Post pending scheduled transactions"));
1837 data->CM_append_scheduled = widget;
1838 gtk_grid_attach (GTK_GRID (group_grid), widget, 1, row, 2, 1);
1839
1840 row++;
1841 widget = gtk_check_button_new_with_mnemonic (_("Update currencies online"));
1842 data->CM_do_update_currency = widget;
1843 gtk_grid_attach (GTK_GRID (group_grid), widget, 1, row, 2, 1);
1844
1845 // group :: Fiscal year
1846 group_grid = gtk_grid_new ();
1847 gtk_grid_set_row_spacing (GTK_GRID (group_grid), SPACING_SMALL);
1848 gtk_grid_set_column_spacing (GTK_GRID (group_grid), SPACING_MEDIUM);
1849 gtk_grid_attach (GTK_GRID (content_grid), group_grid, 0, crow++, 1, 1);
1850
1851 label = make_label_group(_("Fiscal year"));
1852 gtk_grid_attach (GTK_GRID (group_grid), label, 0, 0, 3, 1);
1853
1854 row = 1;
1855 //TRANSLATORS: (fiscal year) starts on
1856 label = make_label_widget(_("Starts _on:"));
1857 gtk_grid_attach (GTK_GRID (group_grid), label, 1, row, 1, 1);
1858
1859 hbox = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, SPACING_SMALL);
1860 gtk_grid_attach (GTK_GRID (group_grid), hbox, 2, row, 1, 1);
1861 widget = make_numeric (label, 1, 28);
1862 data->NB_fiscyearday = widget;
1863 gtk_box_pack_start (GTK_BOX (hbox), widget, FALSE, FALSE, 0);
1864 widget = make_cycle (NULL, CYA_MONTHS);
1865 data->CY_fiscyearmonth = widget;
1866 gtk_box_pack_start (GTK_BOX (hbox), widget, FALSE, FALSE, 0);
1867
1868 // group :: Main window reports
1869 group_grid = gtk_grid_new ();
1870 gtk_grid_set_row_spacing (GTK_GRID (group_grid), SPACING_SMALL);
1871 gtk_grid_set_column_spacing (GTK_GRID (group_grid), SPACING_MEDIUM);
1872 gtk_grid_attach (GTK_GRID (content_grid), group_grid, 0, crow++, 1, 1);
1873
1874 label = make_label_group(_("Main window reports"));
1875 gtk_grid_attach (GTK_GRID (group_grid), label, 0, 0, 3, 1);
1876
1877 row = 1;
1878 label = make_label_widget(_("Date _range:"));
1879 gtk_grid_attach (GTK_GRID (group_grid), label, 1, row, 1, 1);
1880 widget = make_daterange(label, FALSE);
1881 data->CY_daterange_wal = widget;
1882 gtk_grid_attach (GTK_GRID (group_grid), widget, 2, row, 1, 1);
1883
1884 // group :: Files folder
1885 group_grid = gtk_grid_new ();
1886 gtk_grid_set_row_spacing (GTK_GRID (group_grid), SPACING_SMALL);
1887 gtk_grid_set_column_spacing (GTK_GRID (group_grid), SPACING_MEDIUM);
1888 gtk_grid_attach (GTK_GRID (content_grid), group_grid, 0, crow++, 1, 1);
1889
1890 label = make_label_group(_("Files folder"));
1891 gtk_grid_attach (GTK_GRID (group_grid), label, 0, 0, 3, 1);
1892
1893 row = 1;
1894 label = make_label_widget(_("_Default:"));
1895 gtk_grid_attach (GTK_GRID (group_grid), label, 1, row, 1, 1);
1896
1897 hbox = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0);
1898 gtk_widget_set_hexpand (hbox, TRUE);
1899 gtk_grid_attach (GTK_GRID (group_grid), hbox, 2, row, 1, 1);
1900
1901 widget = make_string(label);
1902 data->ST_path_hbfile = widget;
1903 gtk_style_context_add_class (gtk_widget_get_style_context (GTK_WIDGET(widget)), GTK_STYLE_CLASS_LINKED);
1904 gtk_box_pack_start (GTK_BOX (hbox), widget, TRUE, TRUE, 0);
1905
1906 //widget = gtk_button_new_with_label("...");
1907 widget = gtk_button_new_from_icon_name(ICONNAME_FOLDER, GTK_ICON_SIZE_BUTTON);
1908 data->BT_path_hbfile = widget;
1909 gtk_box_pack_start (GTK_BOX (hbox), widget, FALSE, FALSE, 0);
1910
1911 return content_grid;
1912 }
1913
1914 static void defpref_selection(GtkTreeSelection *treeselection, gpointer user_data)
1915 {
1916 struct defpref_data *data;
1917 GtkWidget *notebook;
1918 GtkTreeView *treeview;
1919 GtkTreeModel *model;
1920 GtkTreeIter iter;
1921
1922 GValue val = { 0, };
1923 gint page;
1924
1925 DB( g_print("\n[ui-pref] selection\n") );
1926
1927 if (gtk_tree_selection_get_selected(treeselection, &model, &iter))
1928 {
1929 notebook = GTK_WIDGET(user_data);
1930 treeview = gtk_tree_selection_get_tree_view(treeselection);
1931 data = g_object_get_data(G_OBJECT(gtk_widget_get_ancestor(GTK_WIDGET(treeview), GTK_TYPE_WINDOW)), "inst_data");
1932
1933
1934 gtk_tree_model_get_value(model, &iter, LST_PREF_PAGE, &val);
1935 page = g_value_get_int (&val);
1936 DB( g_print(" - active is %d\n", page) );
1937 g_value_unset (&val);
1938
1939
1940 gtk_tree_model_get_value(model, &iter, LST_PREF_NAME, &val);
1941 gtk_label_set_text (GTK_LABEL (data->label), g_value_get_string (&val));
1942 g_value_unset (&val);
1943
1944 gtk_tree_model_get_value(model, &iter, LST_PREF_ICONNAME, &val);
1945 //gtk_image_set_from_pixbuf (GTK_IMAGE (data->image), g_value_get_object (&val));
1946 gtk_image_set_from_icon_name(GTK_IMAGE (data->image), g_value_get_string (&val), GTK_ICON_SIZE_DIALOG);
1947 g_value_unset (&val);
1948
1949
1950
1951 gtk_notebook_set_current_page(GTK_NOTEBOOK(notebook), page);
1952
1953 //defpref_change_page(GTK_WIDGET(gtk_tree_selection_get_tree_view(treeselection)), GINT_TO_POINTER(page));
1954 }
1955
1956 }
1957
1958
1959 /*
1960 ** set the notebook active page from treeview
1961 */
1962 /*void defpref_change_page(GtkWidget *widget, gpointer user_data)
1963 {
1964 struct defpref_data *data;
1965 gint page = GPOINTER_TO_INT(user_data);
1966 GtkTreeModel *model;
1967
1968
1969 DB( g_print("\n[ui-pref] page\n") );
1970
1971 data = g_object_get_data(G_OBJECT(gtk_widget_get_ancestor(widget, GTK_TYPE_WINDOW)), "inst_data");
1972
1973 model = gtk_tree_view_get_model(GTK_TREE_VIEW(data->LV_page));
1974
1975
1976
1977
1978
1979
1980
1981 gtk_notebook_set_current_page(GTK_NOTEBOOK(data->GR_page), page);
1982 }
1983 */
1984
1985
1986 /*
1987 ** add an empty new account to our temp GList and treeview
1988 */
1989 static void defpref_clear(GtkWidget *widget, gpointer user_data)
1990 {
1991 struct defpref_data *data;
1992 gint result;
1993
1994 data = g_object_get_data(G_OBJECT(gtk_widget_get_ancestor(widget, GTK_TYPE_WINDOW)), "inst_data");
1995 DB( g_print("\n(defpref_clear) (data=%p)\n", data) );
1996
1997 result = ui_dialog_msg_confirm_alert(
1998 GTK_WINDOW(data->window),
1999 _("Reset all preferences"),
2000 _("Do you really want to reset all\npreferences to default values?"),
2001 _("Reset")
2002 );
2003 if( result == GTK_RESPONSE_OK )
2004 {
2005 homebank_pref_setdefault();
2006 defpref_set(data);
2007 }
2008
2009 }
2010
2011
2012 // the window creation
2013 GtkWidget *defpref_dialog_new (void)
2014 {
2015 struct defpref_data data;
2016 GtkWidget *window, *content, *mainvbox;
2017 GtkWidget *hbox, *vbox, *sw, *widget, *notebook, *page, *ebox, *image, *label;
2018
2019 window = gtk_dialog_new_with_buttons (_("Preferences"),
2020 GTK_WINDOW(GLOBALS->mainwindow),
2021 0,
2022 _("_Cancel"),
2023 GTK_RESPONSE_REJECT,
2024 _("_OK"),
2025 GTK_RESPONSE_ACCEPT,
2026 NULL);
2027
2028 data.window = window;
2029
2030 //store our window private data
2031 g_object_set_data(G_OBJECT(window), "inst_data", (gpointer)&data);
2032
2033 gtk_window_set_icon_name(GTK_WINDOW (window), ICONNAME_PREFERENCES);
2034
2035 content = gtk_dialog_get_content_area(GTK_DIALOG (window)); // return a vbox
2036 mainvbox = gtk_box_new(GTK_ORIENTATION_VERTICAL, SPACING_MEDIUM);
2037 gtk_box_pack_start (GTK_BOX (content), mainvbox, TRUE, TRUE, 0);
2038
2039 gtk_container_set_border_width(GTK_CONTAINER(mainvbox), SPACING_MEDIUM);
2040
2041 hbox = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, SPACING_MEDIUM);
2042 gtk_box_pack_start (GTK_BOX (mainvbox), hbox, TRUE, TRUE, 0);
2043
2044 //left part
2045 vbox = gtk_box_new(GTK_ORIENTATION_VERTICAL, SPACING_SMALL);
2046 gtk_box_pack_start (GTK_BOX (hbox), vbox, FALSE, FALSE, 0);
2047
2048 //list
2049 sw = gtk_scrolled_window_new (NULL, NULL);
2050 gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (sw), GTK_SHADOW_ETCHED_IN);
2051 gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (sw), GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC);
2052 gtk_box_pack_start (GTK_BOX (vbox), sw, TRUE, TRUE, 0);
2053 widget = pref_list_create();
2054 data.LV_page = widget;
2055 gtk_container_add (GTK_CONTAINER (sw), widget);
2056
2057 // clear button
2058 data.BT_clear = gtk_button_new_with_mnemonic(_("_Reset"));
2059 gtk_box_pack_start (GTK_BOX (vbox), data.BT_clear, FALSE, TRUE, 0);
2060
2061
2062 //right part : notebook
2063 vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, SPACING_MEDIUM);
2064 gtk_box_pack_start (GTK_BOX (hbox), vbox, TRUE, TRUE, 0);
2065 gtk_widget_show (vbox);
2066
2067 ebox = gtk_event_box_new();
2068 gtk_widget_set_name(ebox, "hbebox");
2069 GtkStyleContext *context = gtk_widget_get_style_context (ebox);
2070 #if GTK_MINOR_VERSION <= 18
2071 gtk_style_context_add_class (context, GTK_STYLE_CLASS_LIST_ROW);
2072 gtk_widget_set_state_flags(ebox, GTK_STATE_FLAG_SELECTED, TRUE);
2073 #else
2074 GtkCssProvider *provider;
2075 provider = gtk_css_provider_new ();
2076 gtk_css_provider_load_from_data (provider,
2077 "#hbebox { color: @theme_selected_fg_color; background-color: @theme_selected_bg_color; }"
2078 , -1, NULL);
2079 gtk_style_context_add_provider (context, GTK_STYLE_PROVIDER(provider), G_MAXUINT);
2080
2081 // gtk_style_context_set_state(context, GTK_STATE_FLAG_SELECTED);
2082 #endif
2083
2084 gtk_box_pack_start (GTK_BOX (vbox), ebox, FALSE, TRUE, 0);
2085 gtk_widget_show (ebox);
2086
2087 hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, SPACING_SMALL);
2088 gtk_container_set_border_width (GTK_CONTAINER (hbox), SPACING_SMALL);
2089 gtk_container_add (GTK_CONTAINER (ebox), hbox);
2090 gtk_widget_show (hbox);
2091
2092 label = gtk_label_new (NULL);
2093 gtk_widget_set_margin_left(label, SPACING_MEDIUM);
2094 gimp_label_set_attributes (GTK_LABEL (label),
2095 PANGO_ATTR_SCALE, PANGO_SCALE_XX_LARGE,
2096 PANGO_ATTR_WEIGHT, PANGO_WEIGHT_BOLD,
2097 -1);
2098
2099 gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0);
2100 gtk_widget_show (label);
2101 data.label = label;
2102
2103 image = gtk_image_new ();
2104 gtk_box_pack_end (GTK_BOX (hbox), image, FALSE, FALSE, 0);
2105 gtk_widget_show (image);
2106 data.image = image;
2107
2108
2109
2110 //notebook
2111 notebook = gtk_notebook_new();
2112 data.GR_page = notebook;
2113 gtk_widget_show(notebook);
2114 gtk_notebook_set_show_tabs(GTK_NOTEBOOK(notebook), FALSE);
2115 gtk_notebook_set_show_border(GTK_NOTEBOOK(notebook), FALSE);
2116 gtk_box_pack_start (GTK_BOX (vbox), notebook, TRUE, TRUE, 0);
2117
2118 /*
2119 "general",
2120 "interface",
2121 "display",
2122 "help",
2123 "euro",
2124 "report"
2125 */
2126
2127 //general
2128 page = defpref_page_general(&data);
2129 gtk_notebook_append_page (GTK_NOTEBOOK (notebook), page, NULL);
2130
2131 //interface
2132 page = defpref_page_interface(&data);
2133 gtk_notebook_append_page (GTK_NOTEBOOK (notebook), page, NULL);
2134
2135 //columns
2136 page = defpref_page_transactions(&data);
2137 gtk_notebook_append_page (GTK_NOTEBOOK (notebook), page, NULL);
2138
2139 //display
2140 page = defpref_page_display(&data);
2141 gtk_notebook_append_page (GTK_NOTEBOOK (notebook), page, NULL);
2142
2143 //import
2144 page = defpref_page_import(&data);
2145 gtk_notebook_append_page (GTK_NOTEBOOK (notebook), page, NULL);
2146
2147 //report
2148 page = defpref_page_reports(&data);
2149 gtk_notebook_append_page (GTK_NOTEBOOK (notebook), page, NULL);
2150
2151 //euro
2152 page = defpref_page_euro(&data);
2153 gtk_notebook_append_page (GTK_NOTEBOOK (notebook), page, NULL);
2154
2155
2156 //todo:should move this
2157 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(data.CM_euro_enable), PREFS->euro_active);
2158
2159 //connect all our signals
2160 g_signal_connect (window, "destroy", G_CALLBACK (gtk_widget_destroyed), &window);
2161
2162 g_signal_connect (G_OBJECT (data.BT_clear), "clicked", G_CALLBACK (defpref_clear), NULL);
2163
2164 //path selector
2165 g_signal_connect (data.BT_path_hbfile, "pressed", G_CALLBACK (defpref_pathselect), GINT_TO_POINTER(1));
2166 g_signal_connect (data.BT_path_import, "pressed", G_CALLBACK (defpref_pathselect), GINT_TO_POINTER(2));
2167 g_signal_connect (data.BT_path_export, "pressed", G_CALLBACK (defpref_pathselect), GINT_TO_POINTER(3));
2168
2169 g_signal_connect (data.CM_custom_colors, "toggled", G_CALLBACK (defpref_colortoggle), NULL);
2170 g_signal_connect (data.CY_colors, "changed", G_CALLBACK (defpref_colorpreset), NULL);
2171
2172
2173
2174 g_signal_connect (gtk_tree_view_get_selection(GTK_TREE_VIEW(data.LV_page)), "changed", G_CALLBACK (defpref_selection), notebook);
2175
2176 g_signal_connect (data.CM_euro_enable, "toggled", G_CALLBACK (defpref_eurotoggle), NULL);
2177
2178 g_signal_connect (data.CY_euro_preset, "changed", G_CALLBACK (defpref_europreset), NULL);
2179
2180 //date
2181 g_signal_connect (data.ST_datefmt, "changed", G_CALLBACK (defpref_date_sample), NULL);
2182
2183 //report
2184 g_signal_connect (data.CY_color_scheme, "changed", G_CALLBACK (defpref_color_scheme_changed), NULL);
2185
2186
2187 //euro number
2188 g_signal_connect (data.ST_euro_symbol , "changed", G_CALLBACK (defpref_numbereuro_sample), NULL);
2189 g_signal_connect (data.CM_euro_isprefix, "toggled", G_CALLBACK (defpref_numbereuro_sample), NULL);
2190 g_signal_connect (data.ST_euro_decimalchar , "changed", G_CALLBACK (defpref_numbereuro_sample), NULL);
2191 g_signal_connect (data.ST_euro_groupingchar, "changed", G_CALLBACK (defpref_numbereuro_sample), NULL);
2192 g_signal_connect (data.NB_euro_fracdigits, "value-changed", G_CALLBACK (defpref_numbereuro_sample), NULL);
2193
2194 //g_signal_connect (data.BT_default, "pressed", G_CALLBACK (defpref_currency_change), NULL);
2195
2196
2197 //setup, init and show window
2198 //defhbfile_setup(&data);
2199 //defhbfile_update(data.LV_arc, NULL);
2200
2201 defpref_set(&data);
2202
2203 defpref_colortoggle(window, NULL);
2204 defpref_eurotoggle(window, NULL);
2205
2206 gtk_window_resize(GTK_WINDOW(window), 640, 256);
2207
2208
2209 //select first row
2210 GtkTreePath *path = gtk_tree_path_new_first ();
2211
2212 gtk_tree_selection_select_path (gtk_tree_view_get_selection(GTK_TREE_VIEW(data.LV_page)), path);
2213
2214
2215
2216 gtk_tree_path_free(path);
2217
2218 gtk_widget_show_all (window);
2219
2220 gint result;
2221 gchar *old_lang;
2222
2223
2224 //wait for the user
2225 result = gtk_dialog_run (GTK_DIALOG (window));
2226
2227 switch( result )
2228 {
2229 case GTK_RESPONSE_ACCEPT:
2230 old_lang = g_strdup(PREFS->language);
2231 defpref_get(&data);
2232 homebank_pref_save();
2233 ui_mainwindow_update(GLOBALS->mainwindow, GINT_TO_POINTER(UF_BALANCE+UF_VISUAL));
2234
2235 DB( g_print("old='%s' new='%s'\n", old_lang, PREFS->language) );
2236
2237 if(g_ascii_strncasecmp(old_lang == NULL ? "" : old_lang, PREFS->language == NULL ? "" : PREFS->language, -1) != 0)
2238 {
2239 ui_dialog_msg_infoerror(GTK_WINDOW(window), GTK_MESSAGE_INFO,
2240 _("Info"),
2241 _("You will have to restart HomeBank\nfor the language change to take effect.")
2242 );
2243
2244 }
2245
2246 g_free(old_lang);
2247 break;
2248 }
2249
2250
2251 // cleanup and destroy
2252 //defhbfile_cleanup(&data, result);
2253 gtk_widget_destroy (window);
2254
2255 return window;
2256 }
2257
2258 // -------------------------------
2259
2260
2261 GtkWidget *pref_list_create(void)
2262 {
2263 GtkListStore *store;
2264 GtkWidget *view;
2265 GtkCellRenderer *renderer;
2266 GtkTreeViewColumn *column;
2267 GtkTreeIter iter;
2268 gint i;
2269
2270 /* create list store */
2271 store = gtk_list_store_new(
2272 LST_PREF_MAX,
2273 G_TYPE_STRING,
2274 G_TYPE_STRING,
2275 G_TYPE_INT
2276 );
2277
2278 //treeview
2279 view = gtk_tree_view_new_with_model(GTK_TREE_MODEL(store));
2280 g_object_unref(store);
2281
2282 gtk_tree_view_set_headers_visible(GTK_TREE_VIEW (view), FALSE);
2283 gtk_tree_selection_set_mode(gtk_tree_view_get_selection(GTK_TREE_VIEW(view)), GTK_SELECTION_SINGLE);
2284
2285 /* column 1: icon */
2286 column = gtk_tree_view_column_new();
2287 renderer = gtk_cell_renderer_pixbuf_new ();
2288 g_object_set(renderer, "stock-size", GTK_ICON_SIZE_DND, NULL);
2289 gtk_tree_view_column_pack_start(column, renderer, FALSE);
2290 gtk_tree_view_column_set_attributes(column, renderer, "icon-name", LST_PREF_ICONNAME, NULL);
2291
2292 renderer = gtk_cell_renderer_text_new ();
2293 gtk_tree_view_column_pack_start(column, renderer, TRUE);
2294 gtk_tree_view_column_set_attributes(column, renderer, "text", LST_PREF_NAME, NULL);
2295
2296 gtk_tree_view_append_column (GTK_TREE_VIEW(view), column);
2297
2298 //populate our combobox model
2299 for(i=0;i<PREF_MAX;i++)
2300 {
2301 gtk_list_store_append(store, &iter);
2302
2303 gtk_list_store_set(store, &iter,
2304 LST_PREF_ICONNAME, pref_iconname[i],
2305 LST_PREF_NAME, _(pref_name[i]),
2306 LST_PREF_PAGE, i,
2307 -1);
2308 }
2309
2310 return(view);
2311 }
2312
2313
2314 /* = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =*/
2315
2316
2317 extern gchar *list_txn_column_label[];
2318
2319
2320 static void
2321 list_txn_colpref_toggled_cell_data_function (GtkCellRendererToggle *cell,
2322 gchar *path_str,
2323 gpointer data)
2324 {
2325 GtkTreeModel *model = (GtkTreeModel *)data;
2326 GtkTreeIter iter;
2327 GtkTreePath *path = gtk_tree_path_new_from_string (path_str);
2328 gboolean fixed;
2329
2330 /* get toggled iter */
2331 gtk_tree_model_get_iter (model, &iter, path);
2332 gtk_tree_model_get (model, &iter, COLUMN_VISIBLE, &fixed, -1);
2333
2334 /* do something with the value */
2335 fixed ^= 1;
2336
2337 /* set new value */
2338 gtk_list_store_set (GTK_LIST_STORE (model), &iter, COLUMN_VISIBLE, fixed, -1);
2339
2340 /* clean up */
2341 gtk_tree_path_free (path);
2342 }
2343
2344
2345 static void list_txn_colpref_get(GtkTreeView *treeview, gint *columns)
2346 {
2347 GtkTreeModel *model;
2348 GtkTreeIter iter;
2349 gboolean valid;
2350 gboolean visible;
2351 gint i, id;
2352
2353 DB( g_print("[lst_txn-colpref] store column order \n") );
2354
2355
2356 model = gtk_tree_view_get_model(GTK_TREE_VIEW(treeview));
2357 valid = gtk_tree_model_get_iter_first(GTK_TREE_MODEL(model), &iter);
2358 i = 0;
2359 while (valid)
2360 {
2361 gtk_tree_model_get(GTK_TREE_MODEL(model), &iter,
2362 COLUMN_VISIBLE, &visible,
2363 COLUMN_ID, &id,
2364 -1);
2365
2366 DB( g_print(" - column %d: %d\n",id, visible) );
2367 // start at index 2 (status, date always displayed
2368 columns[i+2] = visible == TRUE ? id : -id;
2369
2370 /* Make iter point to the next row in the list store */
2371 valid = gtk_tree_model_iter_next(GTK_TREE_MODEL(model), &iter);
2372 i++;
2373 }
2374
2375
2376
2377 }
2378
2379
2380 GtkWidget *list_txn_colprefcreate(void)
2381 {
2382 GtkListStore *store;
2383 GtkWidget *view;
2384 GtkCellRenderer *renderer;
2385 GtkTreeViewColumn *column;
2386 GtkTreeIter iter;
2387 gint i;
2388
2389 DB( g_print("[lst_txn-colpref] create\n") );
2390
2391
2392 /* create list store */
2393 store = gtk_list_store_new(
2394 3,
2395 G_TYPE_BOOLEAN,
2396 G_TYPE_STRING,
2397 G_TYPE_UINT
2398 );
2399
2400 /* populate */
2401 for(i=0 ; i < NUM_LST_DSPOPE-1; i++ ) //-1 cause account column avoid
2402 {
2403 gint id;
2404 gboolean visible;
2405
2406 DB( g_print("eval %d, %s\n", i, list_txn_column_label[i]) );
2407
2408 if(i <= LST_DSPOPE_DATE) // status, date always displayed
2409 continue;
2410
2411 //[i-1] here because lst_ope_columns[] do not store LST_DSPOPE_DATAS
2412 id = ABS(PREFS->lst_ope_columns[i-1]);
2413 if(id == 0) id = i; //if we pass here, new column or weird into pref file
2414 visible = (PREFS->lst_ope_columns[i-1] > 0) ? TRUE : FALSE;
2415
2416
2417 DB( g_print(" - pos=%2d, id=%2d - %d '%s'\n", i, id, visible, list_txn_column_label[id]) );
2418
2419 gtk_list_store_append (store, &iter);
2420 gtk_list_store_set (store, &iter,
2421 COLUMN_VISIBLE, visible,
2422 COLUMN_NAME, _(list_txn_column_label[id]),
2423 COLUMN_ID , id,
2424 -1);
2425
2426 }
2427
2428 //treeview
2429 view = gtk_tree_view_new_with_model(GTK_TREE_MODEL(store));
2430 g_object_unref(store);
2431
2432
2433
2434 renderer = gtk_cell_renderer_toggle_new ();
2435 column = gtk_tree_view_column_new_with_attributes (_("Visible"),
2436 renderer,
2437 "active", COLUMN_VISIBLE,
2438 NULL);
2439 gtk_tree_view_append_column (GTK_TREE_VIEW(view), column);
2440
2441 g_signal_connect (renderer, "toggled",
2442 G_CALLBACK (list_txn_colpref_toggled_cell_data_function), store);
2443
2444
2445 renderer = gtk_cell_renderer_text_new ();
2446 column = gtk_tree_view_column_new_with_attributes (_("Column"),
2447 renderer,
2448 "text", COLUMN_NAME,
2449 NULL);
2450 gtk_tree_view_append_column (GTK_TREE_VIEW(view), column);
2451
2452 gtk_tree_view_set_reorderable (GTK_TREE_VIEW(view), TRUE);
2453
2454
2455 return(view);
2456 }
2457
This page took 0.146303 seconds and 4 git commands to generate.