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