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