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