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