1 /* HomeBank -- Free, easy, personal accounting for everyone.
2 * Copyright (C) 1995-2019 Maxime DOYEN
4 * This file is part of HomeBank.
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.
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.
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/>.
24 #include "dsp-mainwindow.h"
25 #include "gtk-chart-colors.h"
27 #include "ui-currency.h"
30 /****************************************************************************/
32 /****************************************************************************/
41 /* our global datas */
42 extern struct HomeBank
*GLOBALS
;
43 extern struct Preferences
*PREFS
;
58 PREF_LOCALE
, //old DISPLAY
59 PREF_TXN
, //old COLUMNS
69 static gchar
*pref_iconname
[PREF_MAX
] = {
79 "prf-euro", // to be renamed
83 static gchar
*pref_name
[PREF_MAX
] = {
96 static gchar
*CYA_TOOLBAR_STYLE
[] = {
97 N_("System defaults"),
100 N_("Text under icons"),
101 N_("Text beside icons"),
105 static gchar
*CYA_GRID_LINES
[] = {
114 gchar
*CYA_TANGO_COLORS
[] = {
122 gchar
*CYA_IMPORT_DATEORDER
[] = {
129 gchar
*CYA_IMPORT_OFXNAME
[] = {
137 gchar
*CYA_IMPORT_OFXMEMO
[] = {
139 N_("Append to Info"),
140 N_("Append to Memo"),
141 N_("Append to Payee"),
145 gchar
*CYA_IMPORT_CSVSEPARATOR
[] = {
155 extern gchar
*CYA_CHART_COLORSCHEME
[];
156 extern gchar
*CYA_MONTHS
[];
163 http://en.wikipedia.org/wiki/Currencies_of_the_European_Union
164 http://www.xe.com/euro.php
165 http://fr.wikipedia.org/wiki/Liste_des_unit%C3%A9s_mon%C3%A9taires_remplac%C3%A9es_par_l%27euro
166 http://www.inter-locale.com/LocalesDemo.jsp
168 static EuroParams euro_params
[] =
170 // , rate , symb , prfx , dec, grp, frac
171 // ---------------------------------------------------------------------
172 { 0, "" , "--------" , 1.0 , "" , FALSE
, ",", ".", 2 },
173 { 1, "ATS", "Austria" , 13.7603 , "S" , TRUE
, ",", ".", 2 }, // -S 1.234.567,89
174 { 2, "BEF", "Belgium" , 40.3399 , "BF" , TRUE
, ",", ".", 2 }, // BF 1.234.567,89 -
175 { 20, "BGN", "Bulgaria" , 1.95583 , "лв." , TRUE
, ",", " ", 2 }, // non-fixé - 2014 target for euro
176 { 24, "HRK", "Croatia" , 1.0000 , "kn" , FALSE
, "" , ".", 0 }, // non-fixé - 2015 target for euro earliest
177 { 14, "CYP", "Cyprus" , 0.585274 , "£" , TRUE
, ",", "" , 2 }, //
178 { 23, "CZK", "Czech Republic" , 28.36 , "Kč" , FALSE
, ",", " ", 2 }, // non-fixé - 2015 earliest
180 { 17, "EEK", "Estonia" , 15.6466 , "kr" , FALSE
, ",", " ", 2 }, //
181 { 3, "FIM", "Finland" , 5.94573 , "mk" , FALSE
, ",", " ", 2 }, // -1 234 567,89 mk
182 { 4, "FRF", "France" , 6.55957 , "F" , FALSE
, ",", " ", 2 }, // -1 234 567,89 F
183 { 5, "DEM", "Germany" , 1.95583 , "DM" , FALSE
, ",", ".", 2 }, // -1.234.567,89 DM
184 { 6, "GRD", "Greece" , 340.750 , "d" , TRUE
, ".", ",", 2 }, // ??
185 { 21, "HUF", "Hungary" , 261.51 , "Ft" , TRUE
, ",", " ", 2 }, // non-fixé - No current target for euro
186 { 7, "IEP", "Ireland" , 0.787564 , "£" , TRUE
, ".", ",", 2 }, // -£1,234,567.89
187 { 8, "ITL", "Italy" , 1936.27 , "L" , TRUE
, "" , ".", 0 }, // L -1.234.567
188 { 18, "LVL", "Latvia" , 0.702804 , "lat.", FALSE
, ",", "" , 2 }, // jan. 2014
189 { 19, "LTL", "Lithuania" , 3.45280 , "Lt" , FALSE
, ",", "" , 2 }, // jan. 2015
190 { 9, "LUF", "Luxembourg" , 40.3399 , "LU" , TRUE
, ",", ".", 2 }, // LU 1.234.567,89 -
191 { 15, "MTL", "Malta" , 0.429300 , "Lm" , TRUE
, ",", "" , 2 }, //
192 { 10, "NLG", "Netherlands" , 2.20371 , "F" , TRUE
, ",", ".", 2 }, // F 1.234.567,89-
193 { 25, "PLN", "Poland" , 0.25 , "zł" , FALSE
, ",", "" , 2 }, // non-fixé - No current target for euro
194 { 11, "PTE", "Portugal" , 200.482 , "Esc.", FALSE
, "$", ".", 2 }, // -1.234.567$89 Esc.
195 { 22, "RON", "Romania" , 3.5155 , "Leu" , FALSE
, ",", ".", 2 }, // non-fixé - 2015 target for euro earliest
196 { 16, "SKK", "Slovak Republic", 30.12600 , "Sk" , FALSE
, ",", " ", 2 }, //
197 { 13, "SIT", "Slovenia" , 239.640 , "tol" , TRUE
, ",", ".", 2 }, //
198 { 12, "ESP", "Spain" , 166.386 , "Pts" , TRUE
, "" , ".", 0 }, // -Pts 1.234.567
201 // { " ", "" , 1.00000 , "" , "" , FALSE, ",", "", 2 },
205 /* = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =*/
208 static LangName languagenames
[] =
210 // 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
211 //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
214 { "ab", "Abkhazian" },
216 { "af", "Afrikaans" },
219 { "an", "Aragonese" },
221 { "as", "Assamese" },
222 { "ast", "Asturian, Bable, Leonese, Asturleonese" },
225 { "az", "Azerbaijani" },
227 { "be", "Belarusian" },
228 { "bg", "Bulgarian" },
238 { "ch", "Chamorro" },
239 { "co", "Corsican" },
242 { "cu", "Old Church Slavonic" },
248 { "dz", "Dzongkha" },
252 { "eo", "Esperanto" },
254 { "et", "Estonian" },
262 { "fy", "Western Frisian" },
264 { "gd", "Scottish Gaelic" },
265 { "gl", "Galician" },
267 { "gu", "Gujarati" },
272 { "ho", "Hiri Motu" },
273 { "hr", "Croatian" },
275 { "hu", "Hungarian" },
276 { "hy", "Armenian" },
278 { "ia", "Interlingua" },
279 { "id", "Indonesian" },
280 { "ie", "Interlingue" },
282 { "ii", "Sichuan Yi" },
285 { "is", "Icelandic" },
287 { "iu", "Inuktitut" },
288 { "ja", "Japanese" },
289 { "jv", "Javanese" },
290 { "ka", "Georgian" },
293 { "kj", "Kwanyama" },
295 { "kl", "Kalaallisut" },
300 { "ks", "Kashmiri" },
306 { "lb", "Luxembourgish" },
308 { "li", "Limburgish" },
311 { "lt", "Lithuanian" },
312 { "lu", "Luba-Katanga" },
314 { "mg", "Malagasy" },
315 { "mh", "Marshallese" },
317 { "mk", "Macedonian" },
318 { "ml", "Malayalam" },
319 { "mn", "Mongolian" },
320 { "mo", "Moldavian" },
326 { "nb", "Norwegian Bokmål" },
327 { "nd", "North Ndebele" },
328 { "nds", "Low German, Low Saxon" },
332 { "nn", "Norwegian Nynorsk" },
333 { "no", "Norwegian" },
334 { "nr", "South Ndebele" },
336 { "ny", "Chichewa" },
341 { "os", "Ossetian" },
346 { "pt", "Portuguese" },
350 { "ro", "Romanian" },
352 { "rw", "Kinyarwanda" },
353 { "sa", "Sanskrit" },
354 { "sc", "Sardinian" },
356 { "se", "Northern Sami" },
358 { "si", "Sinhalese" },
364 { "sq", "Albanian" },
368 { "su", "Sundanese" },
375 { "ti", "Tigrinya" },
384 { "ty", "Tahitian" },
386 { "uk", "Ukrainian" },
390 { "vi", "Viêt Namese" },
404 static GtkWidget
*pref_list_create(void);
408 ui_language_combobox_compare_func (GtkTreeModel
*model
, GtkTreeIter
*a
, GtkTreeIter
*b
, gpointer userdata
)
411 gchar
*code1
, *code2
;
412 gchar
*name1
, *name2
;
414 gtk_tree_model_get(model
, a
, 0, &code1
, 1, &name1
, -1);
415 gtk_tree_model_get(model
, b
, 0, &code2
, 1, &name2
, -1);
417 //keep system laguage on top
418 if(code1
== NULL
) name1
= NULL
;
419 if(code2
== NULL
) name2
= NULL
;
421 retval
= hb_string_utf8_compare(name1
, name2
);
430 static gchar
*languagename_get(const gchar
*locale
)
434 for (i
= 0; i
< G_N_ELEMENTS (languagenames
); i
++)
436 if( g_ascii_strncasecmp(locale
, languagenames
[i
].locale
, -1) == 0 )
437 return languagenames
[i
].name
;
445 ui_language_combobox_get_name(const gchar
*locale
)
449 DB( g_print("[ui_language_combobox_get_name]\n") );
451 // A locale directory name is typically of the form language[_territory]
452 lang
= languagename_get (locale
);
455 const gchar
*delimiter
= strchr (locale
, '_'); // strip off the territory suffix
459 gchar
*copy
= g_strndup (locale
, delimiter
- locale
);
460 lang
= languagename_get (copy
);
466 g_warning(" locale name not found '%s'", locale
);
477 ui_language_combobox_populate(GtkWidget
*combobox
)
482 model
= gtk_combo_box_get_model(GTK_COMBO_BOX(combobox
));
483 gtk_list_store_append (GTK_LIST_STORE(model
), &iter
);
484 gtk_list_store_set (GTK_LIST_STORE(model
), &iter
,
486 1, _("System Language"),
489 GDir
*dir
= g_dir_open (homebank_app_get_locale_dir (), 0, NULL
);
490 const gchar
*dirname
;
495 while ((dirname
= g_dir_read_name (dir
)) != NULL
)
497 gchar
*filename
= g_build_filename (homebank_app_get_locale_dir (),
500 GETTEXT_PACKAGE
".mo",
502 //DB( g_print("- seek for '%s'\n", filename) );
503 if (g_file_test (filename
, G_FILE_TEST_EXISTS
))
508 gtk_list_store_append (GTK_LIST_STORE(model
), &iter
);
510 lang
= ui_language_combobox_get_name(dirname
);
511 label
= g_strdup_printf ("%s [%s]", lang
, dirname
);
513 gtk_list_store_set (GTK_LIST_STORE(model
), &iter
,
525 gtk_tree_sortable_set_sort_column_id(GTK_TREE_SORTABLE(model
), GTK_TREE_SORTABLE_DEFAULT_SORT_COLUMN_ID
, GTK_SORT_ASCENDING
);
532 ui_language_combobox_new(GtkWidget
*label
)
536 GtkCellRenderer
*renderer
;
538 store
= gtk_list_store_new (2,
542 gtk_tree_sortable_set_default_sort_func(GTK_TREE_SORTABLE(store
), ui_language_combobox_compare_func
, NULL
, NULL
);
544 combobox
= gtk_combo_box_new_with_model(GTK_TREE_MODEL(store
));
545 renderer
= gtk_cell_renderer_text_new ();
546 gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (combobox
), renderer
, TRUE
);
547 gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (combobox
), renderer
, "text", 1, NULL
);
549 gtk_combo_box_set_id_column( GTK_COMBO_BOX(combobox
), 0);
551 g_object_unref(store
);
554 gtk_label_set_mnemonic_widget (GTK_LABEL(label
), combobox
);
556 ui_language_combobox_populate(combobox
);
558 gtk_combo_box_set_active(GTK_COMBO_BOX(combobox
), 0);
564 /* = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =*/
565 /* = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =*/
566 /* = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =*/
568 static gint
ui_euro_combobox_id_to_active(gint id
)
572 DB( g_print("\n[ui-pref] ui_euro_combobox_id_to_active\n") );
575 for (i
= 0; i
< G_N_ELEMENTS (euro_params
); i
++)
577 if( euro_params
[i
].id
== id
)
580 DB( g_print("- id (country)=%d => %d - %s\n", id
, i
, euro_params
[i
].name
) );
590 static gint
ui_euro_combobox_active_to_id(gint active
)
594 DB( g_print("\n[ui-pref] ui_euro_combobox_active_to_id\n") );
596 DB( g_print("- to %d\n", active
) );
599 if( active
< (gint
)G_N_ELEMENTS (euro_params
) )
601 id
= euro_params
[active
].id
;
602 DB( g_print("- id (country)=%d '%s'\n", id
, euro_params
[active
].name
) );
608 static GtkWidget
*ui_euro_combobox_new(GtkWidget
*label
)
613 DB( g_print("\n[ui-pref] make euro preset\n") );
615 combobox
= gtk_combo_box_text_new();
616 for (i
= 0; i
< G_N_ELEMENTS (euro_params
); i
++)
618 gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(combobox
), euro_params
[i
].name
);
620 gtk_combo_box_set_active(GTK_COMBO_BOX(combobox
), 0);
623 gtk_label_set_mnemonic_widget (GTK_LABEL(label
), combobox
);
629 static void defpref_pathselect(GtkWidget
*widget
, gpointer user_data
)
631 struct defpref_data
*data
;
632 gint type
= GPOINTER_TO_INT(user_data
);
638 DB( g_print("\n[ui-pref] path select\n") );
640 data
= g_object_get_data(G_OBJECT(gtk_widget_get_ancestor(widget
, GTK_TYPE_WINDOW
)), "inst_data");
644 case PRF_PATH_WALLET
:
645 path
= &PREFS
->path_hbfile
;
646 entry
= data
->ST_path_hbfile
;
647 title
= _("Choose a default HomeBank files folder");
649 case PRF_PATH_IMPORT
:
650 path
= &PREFS
->path_import
;
651 entry
= data
->ST_path_import
;
652 title
= _("Choose a default import folder");
654 case PRF_PATH_EXPORT
:
655 path
= &PREFS
->path_export
;
656 entry
= data
->ST_path_export
;
657 title
= _("Choose a default export folder");
663 DB( g_print(" - hbfile %p %s at %p\n" , PREFS
->path_hbfile
, PREFS
->path_hbfile
, &PREFS
->path_hbfile
) );
664 DB( g_print(" - import %p %s at %p\n" , PREFS
->path_import
, PREFS
->path_import
, &PREFS
->path_import
) );
665 DB( g_print(" - export %p %s at %p\n" , PREFS
->path_export
, PREFS
->path_export
, &PREFS
->path_export
) );
668 DB( g_print(" - before: %s %p\n" , *path
, path
) );
670 r
= ui_file_chooser_folder(GTK_WINDOW(gtk_widget_get_ancestor(widget
, GTK_TYPE_WINDOW
)), title
, path
);
673 DB( g_print(" - after: %s\n", *path
) );
676 gtk_entry_set_text(GTK_ENTRY(entry
), *path
);
683 ** update the date sample label
685 static void defpref_date_sample(GtkWidget
*widget
, gpointer user_data
)
687 struct defpref_data
*data
;
692 DB( g_print("\n[ui-pref] date sample\n") );
694 data
= g_object_get_data(G_OBJECT(gtk_widget_get_ancestor(widget
, GTK_TYPE_WINDOW
)), "inst_data");
696 fmt
= gtk_entry_get_text(GTK_ENTRY(data
->ST_datefmt
));
697 date
= g_date_new_julian (GLOBALS
->today
);
698 g_date_strftime (buffer
, 256-1, fmt
, date
);
701 gtk_label_set_text(GTK_LABEL(data
->LB_date
), buffer
);
707 ** update the number sample label
709 static void defpref_numbereuro_sample(GtkWidget
*widget
, gpointer user_data
)
711 struct defpref_data
*data
;
713 gchar formatd_buf
[G_ASCII_DTOSTR_BUF_SIZE
];
716 DB( g_print("\n[ui-pref] number sample\n") );
718 data
= g_object_get_data(G_OBJECT(gtk_widget_get_ancestor(widget
, GTK_TYPE_WINDOW
)), "inst_data");
720 cur
.symbol
= (gchar
*)gtk_entry_get_text(GTK_ENTRY(data
->ST_euro_symbol
));
721 cur
.sym_prefix
= gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(data
->CM_euro_isprefix
));
722 cur
.decimal_char
= (gchar
*)gtk_entry_get_text(GTK_ENTRY(data
->ST_euro_decimalchar
));
723 cur
.grouping_char
= (gchar
*)gtk_entry_get_text(GTK_ENTRY(data
->ST_euro_groupingchar
));
724 cur
.frac_digits
= gtk_spin_button_get_value(GTK_SPIN_BUTTON(data
->NB_euro_fracdigits
));
726 da_cur_initformat (&cur
);
728 DB( g_print("fmt: %s\n", cur
.format
) );
730 g_ascii_formatd(formatd_buf
, sizeof (formatd_buf
), cur
.format
, HB_NUMBER_SAMPLE
);
731 hb_str_formatd(buf
, 127, formatd_buf
, &cur
, TRUE
);
733 gtk_label_set_text(GTK_LABEL(data
->LB_numbereuro
), buf
);
739 ** enable/disable euro
741 static void defpref_eurotoggle(GtkWidget
*widget
, gpointer user_data
)
743 struct defpref_data
*data
;
746 DB( g_print("\n[ui-pref] euro toggle\n") );
748 data
= g_object_get_data(G_OBJECT(gtk_widget_get_ancestor(widget
, GTK_TYPE_WINDOW
)), "inst_data");
750 sensitive
= gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(data
->CM_euro_enable
));
752 gtk_widget_set_sensitive(data
->GRP_currency
, sensitive
);
753 gtk_widget_set_sensitive(data
->GRP_rate
, sensitive
);
754 gtk_widget_set_sensitive(data
->GRP_format
, sensitive
);
759 ** set euro value widget from a country
761 static void defpref_eurosetcurrency(GtkWidget
*widget
, gint country
)
763 struct defpref_data
*data
;
768 DB( g_print("\n[ui-pref] eurosetcurrency\n") );
770 data
= g_object_get_data(G_OBJECT(gtk_widget_get_ancestor(widget
, GTK_TYPE_WINDOW
)), "inst_data");
772 active
= ui_euro_combobox_id_to_active(country
);
773 euro
= &euro_params
[active
];
774 buf
= g_strdup_printf("%s - %s", euro
->iso
, euro
->name
);
775 gtk_label_set_markup(GTK_LABEL(data
->ST_euro_country
), buf
);
781 ** set euro value widget from a country
783 static void defpref_europreset(GtkWidget
*widget
, gpointer user_data
)
785 struct defpref_data
*data
;
788 DB( g_print("\n[ui-pref] euro preset\n") );
790 data
= g_object_get_data(G_OBJECT(gtk_widget_get_ancestor(widget
, GTK_TYPE_WINDOW
)), "inst_data");
792 active
= gtk_combo_box_get_active (GTK_COMBO_BOX(data
->CY_euro_preset
));
793 data
->country
= ui_euro_combobox_active_to_id (active
);;
795 defpref_eurosetcurrency(widget
, data
->country
);
797 gtk_spin_button_set_value(GTK_SPIN_BUTTON(data
->NB_euro_value
), euro_params
[active
].value
);
799 gtk_spin_button_set_value(GTK_SPIN_BUTTON(data
->NB_euro_fracdigits
), euro_params
[active
].frac_digits
);
801 gtk_entry_set_text(GTK_ENTRY(data
->ST_euro_symbol
) , euro_params
[active
].symbol
);
802 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(data
->CM_euro_isprefix
), euro_params
[active
].sym_prefix
);
803 gtk_entry_set_text(GTK_ENTRY(data
->ST_euro_decimalchar
) , euro_params
[active
].decimal_char
);
804 gtk_entry_set_text(GTK_ENTRY(data
->ST_euro_groupingchar
), euro_params
[active
].grouping_char
);
809 static void defpref_colortoggle(GtkWidget
*widget
, gpointer user_data
)
811 struct defpref_data
*data
;
814 DB( g_print("\n[ui-pref] color toggle\n") );
816 data
= g_object_get_data(G_OBJECT(gtk_widget_get_ancestor(widget
, GTK_TYPE_WINDOW
)), "inst_data");
818 sensitive
= gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(data
->CM_custom_colors
));
820 gtk_widget_set_sensitive(data
->LB_colors
, sensitive
);
821 gtk_widget_set_sensitive(data
->CY_colors
, sensitive
);
822 gtk_widget_set_sensitive(data
->LB_exp_color
, sensitive
);
823 gtk_widget_set_sensitive(data
->GR_colors
, sensitive
);
827 static void defpref_backuptoggle(GtkWidget
*widget
, gpointer user_data
)
829 struct defpref_data
*data
;
832 DB( g_print("\n[ui-pref] backup toggle\n") );
834 data
= g_object_get_data(G_OBJECT(gtk_widget_get_ancestor(widget
, GTK_TYPE_WINDOW
)), "inst_data");
836 sensitive
= gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(data
->CM_bak_is_automatic
));
837 gtk_widget_set_sensitive(data
->LB_bak_max_num_copies
, sensitive
);
838 gtk_widget_set_sensitive(data
->NB_bak_max_num_copies
, sensitive
);
839 gtk_widget_set_sensitive(data
->GR_bak_freq
, sensitive
);
844 ** set preset colors for amount display
846 static void defpref_colorpreset(GtkWidget
*widget
, gpointer user_data
)
848 struct defpref_data
*data
;
851 gchar
*expcol
, *inccol
, *wrncol
;
853 DB( g_print("\n[ui-pref] color preset\n") );
855 data
= g_object_get_data(G_OBJECT(gtk_widget_get_ancestor(widget
, GTK_TYPE_WINDOW
)), "inst_data");
857 preset
= gtk_combo_box_get_active(GTK_COMBO_BOX(data
->CY_colors
));
862 expcol
= LIGHT_EXP_COLOR
;
863 inccol
= LIGHT_INC_COLOR
;
864 wrncol
= LIGHT_WARN_COLOR
;
868 expcol
= MEDIUM_EXP_COLOR
;
869 inccol
= MEDIUM_INC_COLOR
;
870 wrncol
= MEDIUM_WARN_COLOR
;
875 expcol
= DEFAULT_EXP_COLOR
;
876 inccol
= DEFAULT_INC_COLOR
;
877 wrncol
= DEFAULT_WARN_COLOR
;
882 gdk_rgba_parse(&rgba
, expcol
);
883 gtk_color_chooser_set_rgba(GTK_COLOR_CHOOSER(data
->CP_exp_color
), &rgba
);
885 gdk_rgba_parse(&rgba
, inccol
);
886 gtk_color_chooser_set_rgba(GTK_COLOR_CHOOSER(data
->CP_inc_color
), &rgba
);
888 gdk_rgba_parse(&rgba
, wrncol
);
889 gtk_color_chooser_set_rgba(GTK_COLOR_CHOOSER(data
->CP_warn_color
), &rgba
);
895 static void defpref_color_scheme_changed(GtkWidget
*widget
, gpointer user_data
)
897 struct defpref_data
*data
;
899 DB( g_print("\n[ui-pref] color scheme chnaged\n") );
901 data
= g_object_get_data(G_OBJECT(gtk_widget_get_ancestor(widget
, GTK_TYPE_WINDOW
)), "inst_data");
903 gtk_widget_queue_draw (data
->DA_colors
);
911 static void setGdkColor_from_RGB(GdkColor *color, guint32 value)
916 color->red = tmp | tmp<<8;
918 tmp = value >> 8 & 0xFF;
919 color->green = tmp | tmp<<8;
922 color->blue = tmp | tmp<<8;
928 ** set :: fill in widgets from PREFS structure
931 static void defpref_set(struct defpref_data
*data
)
935 DB( g_print("\n[ui-pref] set\n") );
938 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(data
->CM_show_splash
), PREFS
->showsplash
);
939 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(data
->CM_load_last
), PREFS
->loadlast
);
940 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(data
->CM_append_scheduled
), PREFS
->appendscheduled
);
941 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(data
->CM_do_update_currency
), PREFS
->do_update_currency
);
942 hbtk_combo_box_set_active_id(GTK_COMBO_BOX_TEXT(data
->CY_daterange_wal
), PREFS
->date_range_wal
);
943 gtk_spin_button_set_value(GTK_SPIN_BUTTON(data
->NB_fiscyearday
), PREFS
->fisc_year_day
);
944 gtk_combo_box_set_active(GTK_COMBO_BOX(data
->CY_fiscyearmonth
), PREFS
->fisc_year_month
- 1);
947 gtk_entry_set_text(GTK_ENTRY(data
->ST_path_hbfile
), PREFS
->path_hbfile
);
948 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(data
->CM_bak_is_automatic
), PREFS
->bak_is_automatic
);
949 gtk_spin_button_set_value(GTK_SPIN_BUTTON(data
->NB_bak_max_num_copies
), PREFS
->bak_max_num_copies
);
952 if(PREFS
->language
!= NULL
)
953 gtk_combo_box_set_active_id(GTK_COMBO_BOX(data
->CY_language
), PREFS
->language
);
955 gtk_combo_box_set_active (GTK_COMBO_BOX(data
->CY_language
), 0);
956 gtk_combo_box_set_active(GTK_COMBO_BOX(data
->CY_toolbar
), PREFS
->toolbar_style
);
957 //gtk_spin_button_set_value(GTK_SPIN_BUTTON(data->NB_image_size), PREFS->image_size);
959 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(data
->CM_custom_colors
), PREFS
->custom_colors
);
960 gdk_rgba_parse(&rgba
, PREFS
->color_exp
);
961 gtk_color_chooser_set_rgba(GTK_COLOR_CHOOSER(data
->CP_exp_color
), &rgba
);
962 gdk_rgba_parse(&rgba
, PREFS
->color_inc
);
963 gtk_color_chooser_set_rgba(GTK_COLOR_CHOOSER(data
->CP_inc_color
), &rgba
);
964 gdk_rgba_parse(&rgba
, PREFS
->color_warn
);
965 gtk_color_chooser_set_rgba(GTK_COLOR_CHOOSER(data
->CP_warn_color
), &rgba
);
966 //gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(data->CM_ruleshint), PREFS->rules_hint);
967 gtk_combo_box_set_active(GTK_COMBO_BOX(data
->CY_gridlines
), PREFS
->grid_lines
);
970 hbtk_combo_box_set_active_id(GTK_COMBO_BOX_TEXT(data
->CY_daterange_txn
), PREFS
->date_range_txn
);
971 gtk_spin_button_set_value(GTK_SPIN_BUTTON(data
->ST_datefuture_nbdays
), PREFS
->date_future_nbdays
);
972 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(data
->CM_hide_reconciled
), PREFS
->hidereconciled
);
973 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(data
->CM_show_remind
), PREFS
->showremind
);
974 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(data
->CM_herit_date
), PREFS
->heritdate
);
975 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(data
->CM_memoacp
), PREFS
->txn_memoacp
);
976 gtk_spin_button_set_value(GTK_SPIN_BUTTON(data
->ST_memoacp_days
), PREFS
->txn_memoacp_days
);
979 gtk_entry_set_text(GTK_ENTRY(data
->ST_datefmt
), PREFS
->date_format
);
980 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(data
->CM_unitismile
), PREFS
->vehicle_unit_ismile
);
981 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(data
->CM_unitisgal
), PREFS
->vehicle_unit_isgal
);
984 gtk_combo_box_set_active(GTK_COMBO_BOX(data
->CY_dtex_datefmt
), PREFS
->dtex_datefmt
);
985 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(data
->CM_dtex_ucfirst
), PREFS
->dtex_ucfirst
);
986 gtk_combo_box_set_active(GTK_COMBO_BOX(data
->CY_dtex_ofxname
), PREFS
->dtex_ofxname
);
987 gtk_combo_box_set_active(GTK_COMBO_BOX(data
->CY_dtex_ofxmemo
), PREFS
->dtex_ofxmemo
);
988 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(data
->CM_dtex_qifmemo
), PREFS
->dtex_qifmemo
);
989 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(data
->CM_dtex_qifswap
), PREFS
->dtex_qifswap
);
990 gtk_entry_set_text(GTK_ENTRY(data
->ST_path_import
), PREFS
->path_import
);
991 gtk_entry_set_text(GTK_ENTRY(data
->ST_path_export
), PREFS
->path_export
);
992 gtk_combo_box_set_active(GTK_COMBO_BOX(data
->CY_dtex_csvsep
), PREFS
->dtex_csvsep
);
995 hbtk_combo_box_set_active_id(GTK_COMBO_BOX_TEXT(data
->CY_daterange_rep
), PREFS
->date_range_rep
);
996 gtk_combo_box_set_active(GTK_COMBO_BOX(data
->CY_color_scheme
), PREFS
->report_color_scheme
);
997 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(data
->CM_stat_byamount
), PREFS
->stat_byamount
);
998 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(data
->CM_stat_showrate
), PREFS
->stat_showrate
);
999 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(data
->CM_stat_showdetail
), PREFS
->stat_showdetail
);
1000 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(data
->CM_budg_showdetail
), PREFS
->budg_showdetail
);
1003 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(data
->CM_euro_enable
), PREFS
->euro_active
);
1004 //gtk_combo_box_set_active(GTK_COMBO_BOX(data->CY_euro_preset), PREFS->euro_country);
1005 data
->country
= PREFS
->euro_country
;
1006 defpref_eurosetcurrency(data
->window
, data
->country
);
1007 gtk_spin_button_set_value(GTK_SPIN_BUTTON(data
->NB_euro_value
), PREFS
->euro_value
);
1008 ui_gtk_entry_set_text(data
->ST_euro_symbol
, PREFS
->minor_cur
.symbol
);
1009 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(data
->CM_euro_isprefix
), PREFS
->minor_cur
.sym_prefix
);
1010 ui_gtk_entry_set_text(data
->ST_euro_decimalchar
, PREFS
->minor_cur
.decimal_char
);
1011 ui_gtk_entry_set_text(data
->ST_euro_groupingchar
, PREFS
->minor_cur
.grouping_char
);
1012 gtk_spin_button_set_value(GTK_SPIN_BUTTON(data
->NB_euro_fracdigits
), PREFS
->minor_cur
.frac_digits
);
1014 //gtk_entry_set_text(GTK_ENTRY(data->ST_euro_symbol), PREFS->euro_symbol);
1015 //gtk_spin_button_set_value(GTK_SPIN_BUTTON(data->NB_euro_nbdec), PREFS->euro_nbdec);
1016 //gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(data->CM_euro_thsep), PREFS->euro_thsep);
1021 ** get :: fill PREFS structure from widgets
1023 #define RGBA_TO_INT(x) (int)(x*255)
1025 static gchar
*gdk_rgba_to_hex(GdkRGBA
*rgba
)
1027 return g_strdup_printf("#%02x%02x%02x", RGBA_TO_INT(rgba
->red
), RGBA_TO_INT(rgba
->green
), RGBA_TO_INT(rgba
->blue
));
1031 static void defpref_get(struct defpref_data
*data
)
1036 DB( g_print("\n[ui-pref] get\n") );
1039 PREFS
->showsplash
= gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(data
->CM_show_splash
));
1040 PREFS
->loadlast
= gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(data
->CM_load_last
));
1041 PREFS
->appendscheduled
= gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(data
->CM_append_scheduled
));
1042 PREFS
->do_update_currency
= gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(data
->CM_do_update_currency
));
1043 PREFS
->date_range_wal
= hbtk_combo_box_get_active_id(GTK_COMBO_BOX_TEXT(data
->CY_daterange_wal
));
1044 PREFS
->fisc_year_day
= gtk_spin_button_get_value(GTK_SPIN_BUTTON(data
->NB_fiscyearday
));
1045 PREFS
->fisc_year_month
= 1 + gtk_combo_box_get_active(GTK_COMBO_BOX(data
->CY_fiscyearmonth
));
1048 ui_gtk_entry_replace_text(data
->ST_path_hbfile
, &PREFS
->path_hbfile
);
1050 PREFS
->bak_is_automatic
= gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(data
->CM_bak_is_automatic
));
1051 PREFS
->bak_max_num_copies
= gtk_spin_button_get_value(GTK_SPIN_BUTTON(data
->NB_bak_max_num_copies
));
1053 g_free(PREFS
->language
);
1054 PREFS
->language
= NULL
;
1055 lang
= gtk_combo_box_get_active_id(GTK_COMBO_BOX(data
->CY_language
));
1058 PREFS
->language
= g_strdup(lang
);
1061 PREFS
->toolbar_style
= gtk_combo_box_get_active(GTK_COMBO_BOX(data
->CY_toolbar
));
1062 //PREFS->image_size = gtk_spin_button_get_value(GTK_SPIN_BUTTON(data->NB_image_size));
1064 PREFS
->custom_colors
= gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(data
->CM_custom_colors
));
1065 gtk_color_chooser_get_rgba(GTK_COLOR_CHOOSER(data
->CP_exp_color
), &rgba
);
1066 g_free(PREFS
->color_exp
);
1067 PREFS
->color_exp
= gdk_rgba_to_hex(&rgba
);
1068 gtk_color_chooser_get_rgba(GTK_COLOR_CHOOSER(data
->CP_inc_color
), &rgba
);
1069 g_free(PREFS
->color_inc
);
1070 PREFS
->color_inc
= gdk_rgba_to_hex(&rgba
);
1071 gtk_color_chooser_get_rgba(GTK_COLOR_CHOOSER(data
->CP_warn_color
), &rgba
);
1072 g_free(PREFS
->color_warn
);
1073 PREFS
->color_warn
= gdk_rgba_to_hex(&rgba
);
1074 //PREFS->rules_hint = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(data->CM_ruleshint));
1075 PREFS
->grid_lines
= gtk_combo_box_get_active(GTK_COMBO_BOX(data
->CY_gridlines
));
1076 //list_txn_colpref_get(GTK_TREE_VIEW(data->LV_opecolumns), PREFS->lst_ope_columns);
1079 PREFS
->date_range_txn
= hbtk_combo_box_get_active_id(GTK_COMBO_BOX_TEXT(data
->CY_daterange_txn
));
1080 PREFS
->date_future_nbdays
= gtk_spin_button_get_value(GTK_SPIN_BUTTON(data
->ST_datefuture_nbdays
));
1081 PREFS
->hidereconciled
= gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(data
->CM_hide_reconciled
));
1082 PREFS
->showremind
= gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(data
->CM_show_remind
));
1083 PREFS
->heritdate
= gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(data
->CM_herit_date
));
1084 PREFS
->txn_memoacp
= gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(data
->CM_memoacp
));
1085 PREFS
->txn_memoacp_days
= gtk_spin_button_get_value(GTK_SPIN_BUTTON(data
->ST_memoacp_days
));
1088 g_free(PREFS
->date_format
);
1089 PREFS
->date_format
= g_strdup(gtk_entry_get_text(GTK_ENTRY(data
->ST_datefmt
)));
1090 PREFS
->vehicle_unit_ismile
= gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(data
->CM_unitismile
));
1091 PREFS
->vehicle_unit_isgal
= gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(data
->CM_unitisgal
));
1094 PREFS
->dtex_datefmt
= gtk_combo_box_get_active(GTK_COMBO_BOX(data
->CY_dtex_datefmt
));
1095 PREFS
->dtex_ucfirst
= gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(data
->CM_dtex_ucfirst
));
1096 PREFS
->dtex_ofxname
= gtk_combo_box_get_active(GTK_COMBO_BOX(data
->CY_dtex_ofxname
));
1097 PREFS
->dtex_ofxmemo
= gtk_combo_box_get_active(GTK_COMBO_BOX(data
->CY_dtex_ofxmemo
));
1098 PREFS
->dtex_qifmemo
= gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(data
->CM_dtex_qifmemo
));
1099 PREFS
->dtex_qifswap
= gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(data
->CM_dtex_qifswap
));
1100 ui_gtk_entry_replace_text(data
->ST_path_import
, &PREFS
->path_import
);
1101 ui_gtk_entry_replace_text(data
->ST_path_export
, &PREFS
->path_export
);
1102 PREFS
->dtex_csvsep
= gtk_combo_box_get_active(GTK_COMBO_BOX(data
->CY_dtex_csvsep
));
1105 PREFS
->date_range_rep
= hbtk_combo_box_get_active_id(GTK_COMBO_BOX_TEXT(data
->CY_daterange_rep
));
1106 PREFS
->report_color_scheme
= gtk_combo_box_get_active(GTK_COMBO_BOX(data
->CY_color_scheme
));
1107 PREFS
->stat_byamount
= gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(data
->CM_stat_byamount
));
1108 PREFS
->stat_showrate
= gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(data
->CM_stat_showrate
));
1109 PREFS
->stat_showdetail
= gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(data
->CM_stat_showdetail
));
1110 PREFS
->budg_showdetail
= gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(data
->CM_budg_showdetail
));
1113 PREFS
->euro_active
= gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(data
->CM_euro_enable
));
1114 PREFS
->euro_country
= data
->country
;
1115 PREFS
->euro_value
= gtk_spin_button_get_value(GTK_SPIN_BUTTON(data
->NB_euro_value
));
1116 //strcpy(PREFS->euro_symbol, gtk_entry_get_text(GTK_ENTRY(data->ST_euro_symbol)));
1117 //PREFS->euro_nbdec = gtk_spin_button_get_value(GTK_SPIN_BUTTON(data->NB_euro_nbdec));
1118 //PREFS->euro_thsep = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(data->CM_euro_thsep));
1119 ui_gtk_entry_replace_text(data
->ST_euro_symbol
, &PREFS
->minor_cur
.symbol
);
1120 PREFS
->minor_cur
.sym_prefix
= gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(data
->CM_euro_isprefix
));
1121 ui_gtk_entry_replace_text(data
->ST_euro_decimalchar
, &PREFS
->minor_cur
.decimal_char
);
1122 ui_gtk_entry_replace_text(data
->ST_euro_groupingchar
, &PREFS
->minor_cur
.grouping_char
);
1123 PREFS
->minor_cur
.frac_digits
= gtk_spin_button_get_value(GTK_SPIN_BUTTON(data
->NB_euro_fracdigits
));
1124 //PREFS->chart_legend = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(data->CM_chartlegend));
1128 static GtkWidget
*defpref_page_import (struct defpref_data
*data
)
1130 GtkWidget
*content_grid
, *group_grid
, *label
, *widget
;
1133 content_grid
= gtk_grid_new();
1134 gtk_grid_set_row_spacing (GTK_GRID (content_grid
), SPACING_LARGE
);
1135 gtk_orientable_set_orientation(GTK_ORIENTABLE(content_grid
), GTK_ORIENTATION_VERTICAL
);
1138 // group :: Date options
1139 group_grid
= gtk_grid_new ();
1140 gtk_grid_set_row_spacing (GTK_GRID (group_grid
), SPACING_SMALL
);
1141 gtk_grid_set_column_spacing (GTK_GRID (group_grid
), SPACING_MEDIUM
);
1142 gtk_grid_attach (GTK_GRID (content_grid
), group_grid
, 0, crow
++, 1, 1);
1144 label
= make_label_group(_("General options"));
1145 gtk_grid_attach (GTK_GRID (group_grid
), label
, 0, 0, 3, 1);
1148 label
= make_label_widget(_("Date order:"));
1149 //----------------------------------------- l, r, t, b
1150 gtk_grid_attach (GTK_GRID (group_grid
), label
, 1, row
, 1, 1);
1151 widget
= make_cycle(label
, CYA_IMPORT_DATEORDER
);
1152 data
->CY_dtex_datefmt
= widget
;
1153 //gtk_grid_attach (GTK_GRID (group_grid), data->CY_option[FILTER_DATE], 1, 2, row, row+1);
1154 gtk_grid_attach (GTK_GRID (group_grid
), widget
, 2, row
, 1, 1);
1157 widget
= gtk_check_button_new_with_mnemonic (_("Sentence _case memo/payee"));
1158 data
->CM_dtex_ucfirst
= widget
;
1159 gtk_grid_attach (GTK_GRID (group_grid
), widget
, 1, row
, 2, 1);
1162 // group :: OFX/QFX options
1163 group_grid
= gtk_grid_new ();
1164 gtk_grid_set_row_spacing (GTK_GRID (group_grid
), SPACING_SMALL
);
1165 gtk_grid_set_column_spacing (GTK_GRID (group_grid
), SPACING_MEDIUM
);
1166 gtk_grid_attach (GTK_GRID (content_grid
), group_grid
, 0, crow
++, 1, 1);
1168 label
= make_label_group(_("OFX/QFX options"));
1169 gtk_grid_attach (GTK_GRID (group_grid
), label
, 0, 0, 3, 1);
1172 label
= make_label_widget(_("OFX _Name:"));
1173 //----------------------------------------- l, r, t, b
1174 gtk_grid_attach (GTK_GRID (group_grid
), label
, 1, row
, 1, 1);
1175 widget
= make_cycle(label
, CYA_IMPORT_OFXNAME
);
1176 data
->CY_dtex_ofxname
= widget
;
1177 //gtk_grid_attach (GTK_GRID (group_grid), data->CY_option[FILTER_DATE], 1, 2, row, row+1);
1178 gtk_grid_attach (GTK_GRID (group_grid
), widget
, 2, row
, 1, 1);
1181 label
= make_label_widget(_("OFX _Memo:"));
1182 //----------------------------------------- l, r, t, b
1183 gtk_grid_attach (GTK_GRID (group_grid
), label
, 1, row
, 1, 1);
1184 widget
= make_cycle(label
, CYA_IMPORT_OFXMEMO
);
1185 data
->CY_dtex_ofxmemo
= widget
;
1186 //gtk_grid_attach (GTK_GRID (group_grid), data->CY_option[FILTER_DATE], 1, 2, row, row+1);
1187 gtk_grid_attach (GTK_GRID (group_grid
), widget
, 2, row
, 1, 1);
1189 // group :: QIF options
1190 group_grid
= gtk_grid_new ();
1191 gtk_grid_set_row_spacing (GTK_GRID (group_grid
), SPACING_SMALL
);
1192 gtk_grid_set_column_spacing (GTK_GRID (group_grid
), SPACING_MEDIUM
);
1193 gtk_grid_attach (GTK_GRID (content_grid
), group_grid
, 0, crow
++, 1, 1);
1195 label
= make_label_group(_("QIF options"));
1196 gtk_grid_attach (GTK_GRID (group_grid
), label
, 0, 0, 3, 1);
1199 widget
= gtk_check_button_new_with_mnemonic (_("_Import memos"));
1200 data
->CM_dtex_qifmemo
= widget
;
1201 gtk_grid_attach (GTK_GRID (group_grid
), widget
, 1, row
, 1, 1);
1202 widget
= gtk_check_button_new_with_mnemonic (_("_Swap memos with payees"));
1203 data
->CM_dtex_qifswap
= widget
;
1204 gtk_grid_attach (GTK_GRID (group_grid
), widget
, 2, row
, 1, 1);
1206 // group :: other options
1207 group_grid
= gtk_grid_new ();
1208 gtk_grid_set_row_spacing (GTK_GRID (group_grid
), SPACING_SMALL
);
1209 gtk_grid_set_column_spacing (GTK_GRID (group_grid
), SPACING_MEDIUM
);
1210 gtk_grid_attach (GTK_GRID (content_grid
), group_grid
, 0, crow
++, 1, 1);
1212 label
= make_label_group(_("CSV options"));
1213 gtk_grid_attach (GTK_GRID (group_grid
), label
, 0, 0, 3, 1);
1216 label
= make_label(_("(transaction import only)"), 0.0, 0.5);
1217 gtk_grid_attach (GTK_GRID (group_grid
), label
, 1, row
, 2, 1);
1220 label
= make_label_widget(_("Separator:"));
1221 //----------------------------------------- l, r, t, b
1222 gtk_grid_attach (GTK_GRID (group_grid
), label
, 1, row
, 1, 1);
1223 widget
= make_cycle(label
, CYA_IMPORT_CSVSEPARATOR
);
1224 data
->CY_dtex_csvsep
= widget
;
1225 gtk_grid_attach (GTK_GRID (group_grid
), widget
, 2, row
, 1, 1);
1227 return content_grid
;
1233 draw_callback (GtkWidget
*widget
,
1237 struct defpref_data
*data
= user_data
;
1239 GtkColorScheme scheme
;
1243 index
= gtk_combo_box_get_active(GTK_COMBO_BOX(data
->CY_color_scheme
));
1245 colorscheme_init(&scheme
, index
);
1247 gtk_widget_get_size_request (widget
, &w
, &h
);
1249 for(i
=0;i
<scheme
.nb_cols
;i
++)
1251 cairo_user_set_rgbcol (cr
, &scheme
.colors
[i
]);
1252 cairo_rectangle(cr
, x
, y
, cube_dim
, cube_dim
);
1256 { x
= 0; y
= 1 + cube_dim
; }
1264 static GtkWidget
*defpref_page_reports (struct defpref_data
*data
)
1266 GtkWidget
*content_grid
, *group_grid
, *label
, *widget
;
1269 content_grid
= gtk_grid_new();
1270 gtk_grid_set_row_spacing (GTK_GRID (content_grid
), SPACING_LARGE
);
1271 gtk_orientable_set_orientation(GTK_ORIENTABLE(content_grid
), GTK_ORIENTATION_VERTICAL
);
1274 // group :: Initial filter
1275 group_grid
= gtk_grid_new ();
1276 gtk_grid_set_row_spacing (GTK_GRID (group_grid
), SPACING_SMALL
);
1277 gtk_grid_set_column_spacing (GTK_GRID (group_grid
), SPACING_MEDIUM
);
1278 gtk_grid_attach (GTK_GRID (content_grid
), group_grid
, 0, crow
++, 1, 1);
1280 label
= make_label_group(_("Initial filter"));
1281 gtk_grid_attach (GTK_GRID (group_grid
), label
, 0, 0, 3, 1);
1284 label
= make_label_widget(_("_Range:"));
1285 //----------------------------------------- l, r, t, b
1286 gtk_grid_attach (GTK_GRID (group_grid
), label
, 1, row
, 1, 1);
1287 widget
= make_daterange(label
, DATE_RANGE_CUSTOM_HIDE
);
1288 data
->CY_daterange_rep
= widget
;
1289 //gtk_grid_attach (GTK_GRID (group_grid), data->CY_option[FILTER_DATE], 1, 2, row, row+1);
1290 gtk_grid_attach (GTK_GRID (group_grid
), widget
, 2, row
, 1, 1);
1292 // group ::Charts options
1293 group_grid
= gtk_grid_new ();
1294 gtk_grid_set_row_spacing (GTK_GRID (group_grid
), SPACING_SMALL
);
1295 gtk_grid_set_column_spacing (GTK_GRID (group_grid
), SPACING_MEDIUM
);
1296 gtk_grid_attach (GTK_GRID (content_grid
), group_grid
, 0, crow
++, 1, 1);
1298 label
= make_label_group(_("Charts options"));
1299 gtk_grid_attach (GTK_GRID (group_grid
), label
, 0, 0, 3, 1);
1302 label
= make_label_widget(_("Color scheme:"));
1303 //----------------------------------------- l, r, t, b
1304 gtk_grid_attach (GTK_GRID (group_grid
), label
, 1, row
, 1, 1);
1305 widget
= make_cycle(label
, chart_colors
);
1306 data
->CY_color_scheme
= widget
;
1307 //gtk_grid_attach (GTK_GRID (group_grid), data->CY_option[FILTER_DATE], 1, 2, row, row+1);
1308 gtk_grid_attach (GTK_GRID (group_grid
), widget
, 2, row
, 1, 1);
1311 widget
= gtk_drawing_area_new ();
1312 data
->DA_colors
= widget
;
1313 gtk_widget_set_size_request (widget
, (1+cube_dim
)*16, (1+cube_dim
)*2);
1314 gtk_grid_attach (GTK_GRID (group_grid
), widget
, 2, row
, 1, 1);
1316 g_signal_connect (data
->DA_colors
, "draw", G_CALLBACK (draw_callback
), data
);
1318 // group :: Statistics options
1319 group_grid
= gtk_grid_new ();
1320 gtk_grid_set_row_spacing (GTK_GRID (group_grid
), SPACING_SMALL
);
1321 gtk_grid_set_column_spacing (GTK_GRID (group_grid
), SPACING_MEDIUM
);
1322 gtk_grid_attach (GTK_GRID (content_grid
), group_grid
, 0, crow
++, 1, 1);
1324 label
= make_label_group(_("Statistics options"));
1325 gtk_grid_attach (GTK_GRID (group_grid
), label
, 0, 0, 3, 1);
1328 widget
= gtk_check_button_new_with_mnemonic (_("Show by _amount"));
1329 data
->CM_stat_byamount
= widget
;
1330 gtk_grid_attach (GTK_GRID (group_grid
), widget
, 1, row
, 2, 1);
1333 widget
= gtk_check_button_new_with_mnemonic (_("Show _rate column"));
1334 data
->CM_stat_showrate
= widget
;
1335 gtk_grid_attach (GTK_GRID (group_grid
), widget
, 1, row
, 2, 1);
1338 widget
= gtk_check_button_new_with_mnemonic (_("Show _details"));
1339 data
->CM_stat_showdetail
= widget
;
1340 gtk_grid_attach (GTK_GRID (group_grid
), widget
, 1, row
, 2, 1);
1342 // group :: Budget options
1343 group_grid
= gtk_grid_new ();
1344 gtk_grid_set_row_spacing (GTK_GRID (group_grid
), SPACING_SMALL
);
1345 gtk_grid_set_column_spacing (GTK_GRID (group_grid
), SPACING_MEDIUM
);
1346 gtk_grid_attach (GTK_GRID (content_grid
), group_grid
, 0, crow
++, 1, 1);
1348 label
= make_label_group(_("Budget options"));
1349 gtk_grid_attach (GTK_GRID (group_grid
), label
, 0, 0, 3, 1);
1352 widget
= gtk_check_button_new_with_mnemonic (_("Show _details"));
1353 data
->CM_budg_showdetail
= widget
;
1354 gtk_grid_attach (GTK_GRID (group_grid
), widget
, 1, row
, 2, 1);
1356 return content_grid
;
1360 static GtkWidget
*defpref_page_euro (struct defpref_data
*data
)
1362 GtkWidget
*content_grid
, *group_grid
, *label
, *widget
, *expander
;
1365 content_grid
= gtk_grid_new();
1366 gtk_grid_set_row_spacing (GTK_GRID (content_grid
), SPACING_LARGE
);
1367 gtk_orientable_set_orientation(GTK_ORIENTABLE(content_grid
), GTK_ORIENTATION_VERTICAL
);
1371 group_grid
= gtk_grid_new ();
1372 gtk_grid_set_row_spacing (GTK_GRID (group_grid
), SPACING_SMALL
);
1373 gtk_grid_set_column_spacing (GTK_GRID (group_grid
), SPACING_MEDIUM
);
1374 gtk_grid_attach (GTK_GRID (content_grid
), group_grid
, 0, crow
++, 1, 1);
1376 label
= make_label_group(_("General"));
1377 gtk_grid_attach (GTK_GRID (group_grid
), label
, 0, 0, 3, 1);
1380 widget
= gtk_check_button_new_with_mnemonic (_("_Enable"));
1381 data
->CM_euro_enable
= widget
;
1382 gtk_grid_attach (GTK_GRID (group_grid
), widget
, 1, row
, 2, 1);
1384 // group :: Currency
1385 group_grid
= gtk_grid_new ();
1386 data
->GRP_currency
= group_grid
;
1387 gtk_grid_set_row_spacing (GTK_GRID (group_grid
), SPACING_SMALL
);
1388 gtk_grid_set_column_spacing (GTK_GRID (group_grid
), SPACING_MEDIUM
);
1389 gtk_grid_attach (GTK_GRID (content_grid
), group_grid
, 0, crow
++, 1, 1);
1391 label
= make_label_group(_("Currency"));
1392 gtk_grid_attach (GTK_GRID (group_grid
), label
, 0, 0, 4, 1);
1395 widget
= make_label(NULL
, 0.0, 0.5);
1396 data
->ST_euro_country
= widget
;
1397 //gtk_grid_attach (GTK_GRID (group_grid), data->CY_option[FILTER_DATE], 1, 2, row, row+1);
1398 gtk_grid_attach (GTK_GRID (group_grid
), widget
, 1, row
, 1, 1);
1401 label
= make_label_widget(_("_Preset:"));
1402 //----------------------------------------- l, r, t, b
1403 gtk_grid_attach (GTK_GRID (group_grid
), label
, 2, row
, 1, 1);
1404 widget
= ui_euro_combobox_new (label
);
1405 data
->CY_euro_preset
= widget
;
1406 gtk_widget_set_margin_left (label
, 2*SPACING_LARGE
);
1407 //gtk_grid_attach (GTK_GRID (group_grid), data->CY_option[FILTER_DATE], 1, 2, row, row+1);
1408 gtk_grid_attach (GTK_GRID (group_grid
), widget
, 3, row
, 1, 1);
1411 // group :: Exchange rate
1412 group_grid
= gtk_grid_new ();
1413 data
->GRP_rate
= group_grid
;
1414 gtk_grid_set_row_spacing (GTK_GRID (group_grid
), SPACING_SMALL
);
1415 gtk_grid_set_column_spacing (GTK_GRID (group_grid
), SPACING_MEDIUM
);
1416 gtk_grid_attach (GTK_GRID (content_grid
), group_grid
, 0, crow
++, 1, 1);
1418 label
= make_label_group(_("Exchange rate"));
1419 gtk_grid_attach (GTK_GRID (group_grid
), label
, 0, 0, 3, 1);
1422 label
= make_label_widget("1 EUR _=");
1423 gtk_grid_attach (GTK_GRID (group_grid
), label
, 1, row
, 1, 1);
1424 widget
= make_exchange_rate(label
);
1425 data
->NB_euro_value
= widget
;
1426 //gtk_grid_attach (GTK_GRID (group_grid), data->CY_option[FILTER_DATE], 1, 2, row, row+1);
1427 gtk_grid_attach (GTK_GRID (group_grid
), widget
, 2, row
, 1, 1);
1429 // group :: Numbers format
1430 group_grid
= gtk_grid_new ();
1431 data
->GRP_format
= group_grid
;
1432 gtk_grid_set_row_spacing (GTK_GRID (group_grid
), SPACING_SMALL
);
1433 gtk_grid_set_column_spacing (GTK_GRID (group_grid
), SPACING_MEDIUM
);
1434 gtk_grid_attach (GTK_GRID (content_grid
), group_grid
, 0, crow
++, 1, 1);
1436 label
= make_label_group(_("Format"));
1437 gtk_grid_attach (GTK_GRID (group_grid
), label
, 0, 0, 3, 1);
1440 widget
= make_label(NULL
, 0, 0.0);
1441 data
->LB_numbereuro
= widget
;
1442 gtk_grid_attach (GTK_GRID (group_grid
), widget
, 1, row
, 1, 1);
1445 expander
= gtk_expander_new_with_mnemonic(_("_Customize"));
1446 gtk_grid_attach (GTK_GRID (group_grid
), expander
, 1, row
, 1, 1);
1448 group_grid
= gtk_grid_new ();
1449 gtk_grid_set_row_spacing (GTK_GRID (group_grid
), SPACING_SMALL
);
1450 gtk_grid_set_column_spacing (GTK_GRID (group_grid
), SPACING_MEDIUM
);
1451 gtk_container_add (GTK_CONTAINER (expander
), group_grid
);
1454 label
= make_label_widget(_("_Symbol:"));
1455 gtk_grid_attach (GTK_GRID (group_grid
), label
, 1, row
, 1, 1);
1456 widget
= make_string_maxlength(label
, 3);
1457 data
->ST_euro_symbol
= widget
;
1458 gtk_grid_attach (GTK_GRID (group_grid
), widget
, 2, row
, 1, 1);
1461 widget
= gtk_check_button_new_with_mnemonic (_("Is pre_fix"));
1462 data
->CM_euro_isprefix
= widget
;
1463 gtk_grid_attach (GTK_GRID (group_grid
), widget
, 2, row
, 1, 1);
1466 label
= make_label_widget(_("_Decimal char:"));
1467 gtk_grid_attach (GTK_GRID (group_grid
), label
, 1, row
, 1, 1);
1468 widget
= make_string_maxlength(label
, 1);
1469 data
->ST_euro_decimalchar
= widget
;
1470 gtk_grid_attach (GTK_GRID (group_grid
), widget
, 2, row
, 1, 1);
1473 label
= make_label_widget(_("_Frac digits:"));
1474 gtk_grid_attach (GTK_GRID (group_grid
), label
, 1, row
, 1, 1);
1475 widget
= make_numeric(label
, 0.0, 6.0);
1476 data
->NB_euro_fracdigits
= widget
;
1477 gtk_grid_attach (GTK_GRID (group_grid
), widget
, 2, row
, 1, 1);
1480 label
= make_label_widget(_("_Grouping char:"));
1481 gtk_grid_attach (GTK_GRID (group_grid
), label
, 1, row
, 1, 1);
1482 widget
= make_string_maxlength(label
, 1);
1483 data
->ST_euro_groupingchar
= widget
;
1484 gtk_grid_attach (GTK_GRID (group_grid
), widget
, 2, row
, 1, 1);
1486 return content_grid
;
1490 static GtkWidget
*defpref_page_display (struct defpref_data
*data
)
1492 GtkWidget
*content_grid
, *group_grid
, *label
, *widget
, *expander
, *hbox
;
1495 content_grid
= gtk_grid_new();
1496 gtk_grid_set_row_spacing (GTK_GRID (content_grid
), SPACING_LARGE
);
1497 gtk_orientable_set_orientation(GTK_ORIENTABLE(content_grid
), GTK_ORIENTATION_VERTICAL
);
1501 group_grid
= gtk_grid_new ();
1502 gtk_grid_set_row_spacing (GTK_GRID (group_grid
), SPACING_SMALL
);
1503 gtk_grid_set_column_spacing (GTK_GRID (group_grid
), SPACING_MEDIUM
);
1504 gtk_grid_attach (GTK_GRID (content_grid
), group_grid
, 0, crow
++, 1, 1);
1506 label
= make_label_group(_("User interface"));
1507 gtk_grid_attach (GTK_GRID (group_grid
), label
, 0, 0, 3, 1);
1510 label
= make_label(_("_Language:"), 0, 0.5);
1511 gtk_grid_attach (GTK_GRID (group_grid
), label
, 1, row
, 1, 1);
1512 widget
= ui_language_combobox_new(label
);
1513 data
->CY_language
= widget
;
1514 gtk_grid_attach (GTK_GRID (group_grid
), widget
, 2, row
, 1, 1);
1518 label
= make_label(_("_Date display:"), 0, 0.5);
1519 gtk_grid_attach (GTK_GRID (group_grid
), label
, 1, row
, 1, 1);
1520 widget
= make_label(NULL
, 0, 0.5);
1521 data
->LB_date
= widget
;
1522 gtk_grid_attach (GTK_GRID (group_grid
), widget
, 2, row
, 1, 1);
1525 expander
= gtk_expander_new_with_mnemonic(_("_Customize"));
1526 gtk_grid_attach (GTK_GRID (group_grid
), expander
, 2, row
, 1, 1);
1528 group_grid
= gtk_grid_new ();
1529 gtk_grid_set_row_spacing (GTK_GRID (group_grid
), SPACING_SMALL
);
1530 gtk_grid_set_column_spacing (GTK_GRID (group_grid
), SPACING_MEDIUM
);
1531 gtk_container_add (GTK_CONTAINER (expander
), group_grid
);
1534 label
= make_label_widget(_("_Format:"));
1535 //----------------------------------------- l, r, t, b
1536 gtk_grid_attach (GTK_GRID (group_grid
), label
, 1, row
, 1, 1);
1537 widget
= make_string(label
);
1538 data
->ST_datefmt
= widget
;
1539 //gtk_grid_attach (GTK_GRID (group_grid), data->CY_option[FILTER_DATE], 1, 2, row, row+1);
1540 gtk_grid_attach (GTK_GRID (group_grid
), widget
, 2, row
, 1, 1);
1542 widget
= gtk_image_new_from_icon_name (ICONNAME_INFO
, GTK_ICON_SIZE_BUTTON
);
1543 gtk_grid_attach (GTK_GRID (group_grid
), widget
, 3, row
, 1, 1);
1546 gtk_widget_set_tooltip_text(widget
,
1547 _("%a locale's abbreviated weekday name.\n"
1548 "%A locale's full weekday name. \n"
1549 "%b locale's abbreviated month name. \n"
1550 "%B locale's full month name. \n"
1551 "%c locale's appropriate date and time representation. \n"
1552 "%C century number (the year divided by 100 and truncated to an integer) as a decimal number [00-99]. \n"
1553 "%d day of the month as a decimal number [01,31]. \n"
1554 "%D same as %m/%d/%y. \n"
1555 "%e day of the month as a decimal number [1,31]; a single digit is preceded by a space. \n"
1556 "%j day of the year as a decimal number [001,366]. \n"
1557 "%m month as a decimal number [01,12]. \n"
1558 "%p locale's appropriate date representation. \n"
1559 "%y year without century as a decimal number [00,99]. \n"
1560 "%Y year with century as a decimal number.")
1564 widget
= make_label(NULL
, 0.0, 0.5);
1565 gtk_label_set_markup (GTK_LABEL(widget
), "<small><a href=\"http://man7.org/linux/man-pages/man3/strftime.3.html\">online reference</a></small>");
1566 gtk_grid_attach (GTK_GRID (group_grid
), widget
, 2, row
, 1, 1);
1571 // group :: Fiscal year
1572 group_grid
= gtk_grid_new ();
1573 gtk_grid_set_row_spacing (GTK_GRID (group_grid
), SPACING_SMALL
);
1574 gtk_grid_set_column_spacing (GTK_GRID (group_grid
), SPACING_MEDIUM
);
1575 gtk_grid_attach (GTK_GRID (content_grid
), group_grid
, 0, crow
++, 1, 1);
1577 label
= make_label_group(_("Fiscal year"));
1578 gtk_grid_attach (GTK_GRID (group_grid
), label
, 0, 0, 3, 1);
1581 //TRANSLATORS: (fiscal year) starts on
1582 label
= make_label_widget(_("Starts _on:"));
1583 gtk_grid_attach (GTK_GRID (group_grid
), label
, 1, row
, 1, 1);
1585 hbox
= gtk_box_new(GTK_ORIENTATION_HORIZONTAL
, SPACING_SMALL
);
1586 gtk_grid_attach (GTK_GRID (group_grid
), hbox
, 2, row
, 1, 1);
1587 widget
= make_numeric (label
, 1, 28);
1588 data
->NB_fiscyearday
= widget
;
1589 gtk_box_pack_start (GTK_BOX (hbox
), widget
, FALSE
, FALSE
, 0);
1590 widget
= make_cycle (NULL
, CYA_MONTHS
);
1591 data
->CY_fiscyearmonth
= widget
;
1592 gtk_box_pack_start (GTK_BOX (hbox
), widget
, FALSE
, FALSE
, 0);
1596 // group :: Measurement units
1597 group_grid
= gtk_grid_new ();
1598 gtk_grid_set_row_spacing (GTK_GRID (group_grid
), SPACING_SMALL
);
1599 gtk_grid_set_column_spacing (GTK_GRID (group_grid
), SPACING_MEDIUM
);
1600 gtk_grid_attach (GTK_GRID (content_grid
), group_grid
, 0, crow
++, 1, 1);
1602 label
= make_label_group(_("Measurement units"));
1603 gtk_grid_attach (GTK_GRID (group_grid
), label
, 0, 0, 3, 1);
1606 widget
= gtk_check_button_new_with_mnemonic (_("Use _miles for meter"));
1607 data
->CM_unitismile
= widget
;
1608 gtk_grid_attach (GTK_GRID (group_grid
), widget
, 1, row
, 2, 1);
1611 widget
= gtk_check_button_new_with_mnemonic (_("Use _gallon for fuel"));
1612 data
->CM_unitisgal
= widget
;
1613 gtk_grid_attach (GTK_GRID (group_grid
), widget
, 1, row
, 2, 1);
1615 return content_grid
;
1619 static GtkWidget
*defpref_page_transactions (struct defpref_data
*data
)
1621 GtkWidget
*content_grid
, *group_grid
, *label
, *widget
;
1624 content_grid
= gtk_grid_new();
1625 gtk_grid_set_row_spacing (GTK_GRID (content_grid
), SPACING_LARGE
);
1626 gtk_orientable_set_orientation(GTK_ORIENTABLE(content_grid
), GTK_ORIENTATION_VERTICAL
);
1629 // group :: Transaction window
1630 group_grid
= gtk_grid_new ();
1631 gtk_grid_set_row_spacing (GTK_GRID (group_grid
), SPACING_SMALL
);
1632 gtk_grid_set_column_spacing (GTK_GRID (group_grid
), SPACING_MEDIUM
);
1633 gtk_grid_attach (GTK_GRID (content_grid
), group_grid
, 0, crow
++, 1, 1);
1635 label
= make_label_group(_("Transaction window"));
1636 gtk_grid_attach (GTK_GRID (group_grid
), label
, 0, 0, 3, 1);
1639 label
= make_label(_("_Range:"), 0, 0.5);
1640 //----------------------------------------- l, r, t, b
1641 gtk_grid_attach (GTK_GRID (group_grid
), label
, 1, row
, 1, 1);
1642 widget
= make_daterange(label
, DATE_RANGE_CUSTOM_HIDE
);
1643 data
->CY_daterange_txn
= widget
;
1644 gtk_grid_attach (GTK_GRID (group_grid
), widget
, 2, row
, 1, 1);
1647 label
= make_label(_("_Show future:"), 0, 0.5);
1648 //----------------------------------------- l, r, t, b
1649 gtk_grid_attach (GTK_GRID (group_grid
), label
, 1, row
, 1, 1);
1650 widget
= make_numeric(NULL
, 0, 366);
1652 data
->ST_datefuture_nbdays
= widget
;
1653 gtk_grid_attach (GTK_GRID (group_grid
), widget
, 2, row
, 1, 1);
1655 //TRANSLATORS: there is a spinner on the left of this label, and so you have 0....x days in advance the current date
1656 label
= make_label(_("days ahead"), 0, 0.5);
1657 gtk_grid_attach (GTK_GRID (group_grid
), label
, 3, row
, 1, 1);
1660 widget
= gtk_check_button_new_with_mnemonic (_("Hide reconciled transactions"));
1661 data
->CM_hide_reconciled
= widget
;
1662 gtk_grid_attach (GTK_GRID (group_grid
), widget
, 1, row
, 3, 1);
1665 widget
= gtk_check_button_new_with_mnemonic (_("Always show remind transactions"));
1666 data
->CM_show_remind
= widget
;
1667 gtk_grid_attach (GTK_GRID (group_grid
), widget
, 1, row
, 3, 1);
1669 // group :: Multiple add
1670 group_grid
= gtk_grid_new ();
1671 gtk_grid_set_row_spacing (GTK_GRID (group_grid
), SPACING_SMALL
);
1672 gtk_grid_set_column_spacing (GTK_GRID (group_grid
), SPACING_MEDIUM
);
1673 gtk_grid_attach (GTK_GRID (content_grid
), group_grid
, 0, crow
++, 1, 1);
1675 label
= make_label_group(_("Multiple add"));
1676 gtk_grid_attach (GTK_GRID (group_grid
), label
, 0, 0, 3, 1);
1679 widget
= gtk_check_button_new_with_mnemonic (_("Keep the last date"));
1680 data
->CM_herit_date
= widget
;
1681 gtk_grid_attach (GTK_GRID (group_grid
), widget
, 1, row
, 2, 1);
1683 // group :: Memo autocomplete
1684 group_grid
= gtk_grid_new ();
1685 gtk_grid_set_row_spacing (GTK_GRID (group_grid
), SPACING_SMALL
);
1686 gtk_grid_set_column_spacing (GTK_GRID (group_grid
), SPACING_MEDIUM
);
1687 gtk_grid_attach (GTK_GRID (content_grid
), group_grid
, 0, crow
++, 1, 1);
1689 label
= make_label_group(_("Memo autocomplete"));
1690 gtk_grid_attach (GTK_GRID (group_grid
), label
, 0, 0, 3, 1);
1693 widget
= gtk_check_button_new_with_mnemonic (_("Active"));
1694 data
->CM_memoacp
= widget
;
1695 gtk_grid_attach (GTK_GRID (group_grid
), widget
, 1, row
, 2, 1);
1698 widget
= make_numeric(NULL
, 0, 1460);
1699 data
->ST_memoacp_days
= widget
;
1700 gtk_grid_attach (GTK_GRID (group_grid
), widget
, 2, row
, 1, 1);
1701 label
= make_label(_("rolling days"), 0, 0.5);
1702 gtk_grid_attach (GTK_GRID (group_grid
), label
, 3, row
, 1, 1);
1704 // group :: Column list
1706 group_grid = gtk_grid_new ();
1707 gtk_grid_set_row_spacing (GTK_GRID (group_grid), SPACING_SMALL);
1708 gtk_grid_set_column_spacing (GTK_GRID (group_grid), SPACING_MEDIUM);
1709 gtk_grid_attach (GTK_GRID (content_grid), group_grid, 0, crow++, 1, 1);
1711 label = make_label_group(_("Column list"));
1712 gtk_grid_attach (GTK_GRID (group_grid), label, 0, 0, 3, 1);
1715 sw = gtk_scrolled_window_new (NULL, NULL);
1716 gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (sw), GTK_SHADOW_ETCHED_IN);
1717 gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (sw), GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC);
1718 widget = (GtkWidget *)list_txn_colprefcreate();
1719 data->LV_opecolumns = widget;
1720 gtk_widget_set_size_request(data->LV_opecolumns, HB_MINWIDTH_LIST, -1);
1721 gtk_container_add (GTK_CONTAINER (sw), widget);
1722 gtk_widget_set_vexpand (sw, TRUE);
1723 gtk_grid_attach (GTK_GRID (group_grid), sw, 1, row, 2, 1);
1724 gtk_widget_set_tooltip_text(widget, _("Drag & drop to change the order"));
1727 return content_grid
;
1732 static GtkWidget
*defpref_page_interface (struct defpref_data
*data
)
1734 GtkWidget
*content_grid
, *group_grid
, *hbox
, *label
, *widget
;
1737 content_grid
= gtk_grid_new();
1738 gtk_grid_set_row_spacing (GTK_GRID (content_grid
), SPACING_LARGE
);
1739 gtk_orientable_set_orientation(GTK_ORIENTABLE(content_grid
), GTK_ORIENTATION_VERTICAL
);
1743 group_grid
= gtk_grid_new ();
1744 gtk_grid_set_row_spacing (GTK_GRID (group_grid
), SPACING_SMALL
);
1745 gtk_grid_set_column_spacing (GTK_GRID (group_grid
), SPACING_MEDIUM
);
1746 gtk_grid_attach (GTK_GRID (content_grid
), group_grid
, 0, crow
++, 1, 1);
1748 label
= make_label_group(_("General"));
1749 gtk_grid_attach (GTK_GRID (group_grid
), label
, 0, 0, 3, 1);
1752 label
= make_label(_("_Toolbar:"), 0, 0.5);
1753 gtk_grid_attach (GTK_GRID (group_grid
), label
, 1, row
, 1, 1);
1754 widget
= make_cycle(label
, CYA_TOOLBAR_STYLE
);
1755 data
->CY_toolbar
= widget
;
1756 gtk_grid_attach (GTK_GRID (group_grid
), widget
, 2, row
, 1, 1);
1766 //widget = gtk_check_button_new_with_mnemonic (_("Enable rows in alternating colors"));
1767 //data->CM_ruleshint = widget;
1768 label
= make_label(_("_Grid line:"), 0, 0.5);
1769 gtk_grid_attach (GTK_GRID (group_grid
), label
, 1, row
, 1, 1);
1770 widget
= make_cycle(label
, CYA_GRID_LINES
);
1771 data
->CY_gridlines
= widget
;
1772 gtk_grid_attach (GTK_GRID (group_grid
), widget
, 2, row
, 1, 1);
1774 // group :: Amount colors
1775 group_grid
= gtk_grid_new ();
1776 gtk_grid_set_row_spacing (GTK_GRID (group_grid
), SPACING_SMALL
);
1777 gtk_grid_set_column_spacing (GTK_GRID (group_grid
), SPACING_MEDIUM
);
1778 gtk_grid_attach (GTK_GRID (content_grid
), group_grid
, 0, crow
++, 1, 1);
1780 label
= make_label_group(_("Amount colors"));
1781 gtk_grid_attach (GTK_GRID (group_grid
), label
, 0, 0, 3, 1);
1784 widget
= gtk_check_button_new_with_mnemonic (_("Uses custom colors"));
1785 data
->CM_custom_colors
= widget
;
1786 gtk_grid_attach (GTK_GRID (group_grid
), widget
, 1, row
, 2, 1);
1789 label
= make_label(_("_Preset:"), 0, 0.5);
1790 data
->LB_colors
= label
;
1791 //----------------------------------------- l, r, t, b
1792 gtk_grid_attach (GTK_GRID (group_grid
), label
, 1, row
, 1, 1);
1793 widget
= make_cycle(label
, CYA_TANGO_COLORS
);
1794 data
->CY_colors
= widget
;
1795 //gtk_grid_attach (GTK_GRID (group_grid), data->CY_option[FILTER_DATE], 1, 2, row, row+1);
1796 gtk_grid_attach (GTK_GRID (group_grid
), widget
, 2, row
, 1, 1);
1799 label
= make_label(_("_Expense:"), 0, 0.5);
1800 data
->LB_exp_color
= label
;
1801 //----------------------------------------- l, r, t, b
1802 gtk_grid_attach (GTK_GRID (group_grid
), label
, 1, row
, 1, 1);
1803 hbox
= gtk_box_new(GTK_ORIENTATION_HORIZONTAL
, SPACING_SMALL
);
1804 data
->GR_colors
= hbox
;
1805 gtk_grid_attach (GTK_GRID (group_grid
), hbox
, 2, row
, 1, 1);
1807 widget
= gtk_color_button_new ();
1808 data
->CP_exp_color
= widget
;
1809 gtk_box_pack_start (GTK_BOX (hbox
), widget
, FALSE
, FALSE
, 0);
1811 label
= make_label_widget(_("_Income:"));
1812 gtk_box_pack_start (GTK_BOX (hbox
), label
, FALSE
, FALSE
, 0);
1814 widget
= gtk_color_button_new ();
1815 data
->CP_inc_color
= widget
;
1816 gtk_box_pack_start (GTK_BOX (hbox
), widget
, FALSE
, FALSE
, 0);
1818 label
= make_label_widget(_("_Warning:"));
1819 gtk_box_pack_start (GTK_BOX (hbox
), label
, FALSE
, FALSE
, 0);
1821 widget
= gtk_color_button_new ();
1822 data
->CP_warn_color
= widget
;
1823 gtk_box_pack_start (GTK_BOX (hbox
), widget
, FALSE
, FALSE
, 0);
1825 return content_grid
;
1829 static GtkWidget
*defpref_page_filebackup (struct defpref_data
*data
)
1831 GtkWidget
*content_grid
, *group_grid
, *hbox
, *label
, *widget
;
1834 content_grid
= gtk_grid_new();
1835 gtk_grid_set_row_spacing (GTK_GRID (content_grid
), SPACING_LARGE
);
1836 gtk_orientable_set_orientation(GTK_ORIENTABLE(content_grid
), GTK_ORIENTATION_VERTICAL
);
1840 group_grid
= gtk_grid_new ();
1841 gtk_grid_set_row_spacing (GTK_GRID (group_grid
), SPACING_SMALL
);
1842 gtk_grid_set_column_spacing (GTK_GRID (group_grid
), SPACING_MEDIUM
);
1843 gtk_grid_attach (GTK_GRID (content_grid
), group_grid
, 0, crow
++, 1, 1);
1845 label
= make_label_group(_("Backup"));
1846 gtk_grid_attach (GTK_GRID (group_grid
), label
, 0, 0, 3, 1);
1849 widget
= gtk_check_button_new_with_mnemonic (_("_Enable automatic backups"));
1850 data
->CM_bak_is_automatic
= widget
;
1851 gtk_grid_attach (GTK_GRID (group_grid
), widget
, 1, row
, 2, 1);
1854 label
= make_label_widget(_("_Number of backups to keep:"));
1855 data
->LB_bak_max_num_copies
= label
;
1856 gtk_grid_attach (GTK_GRID (group_grid
), label
, 1, row
, 1, 1);
1857 widget
= make_numeric (label
, 1, 99);
1858 data
->NB_bak_max_num_copies
= widget
;
1859 gtk_grid_attach (GTK_GRID (group_grid
), widget
, 2, row
, 1, 1);
1862 hbox
= gtk_box_new(GTK_ORIENTATION_HORIZONTAL
, SPACING_SMALL
);
1863 data
->GR_bak_freq
= hbox
;
1864 //gtk_widget_set_hexpand (hbox, TRUE);
1865 gtk_grid_attach (GTK_GRID (group_grid
), hbox
, 1, row
, 2, 1);
1867 widget
= gtk_image_new_from_icon_name (ICONNAME_INFO
, GTK_ICON_SIZE_BUTTON
);
1868 gtk_box_pack_start (GTK_BOX (hbox
), widget
, FALSE
, FALSE
, 0);
1869 label
= make_label_widget(_("Backup frequency is once a day"));
1870 gtk_box_pack_start (GTK_BOX (hbox
), label
, FALSE
, FALSE
, 0);
1873 return content_grid
;
1877 static GtkWidget
*defpref_page_folders (struct defpref_data
*data
)
1879 GtkWidget
*content_grid
, *group_grid
, *hbox
, *label
, *widget
;
1882 content_grid
= gtk_grid_new();
1883 gtk_grid_set_row_spacing (GTK_GRID (content_grid
), SPACING_LARGE
);
1884 gtk_orientable_set_orientation(GTK_ORIENTABLE(content_grid
), GTK_ORIENTATION_VERTICAL
);
1887 // group :: Files folder
1888 group_grid
= gtk_grid_new ();
1889 gtk_grid_set_row_spacing (GTK_GRID (group_grid
), SPACING_SMALL
);
1890 gtk_grid_set_column_spacing (GTK_GRID (group_grid
), SPACING_MEDIUM
);
1891 gtk_grid_attach (GTK_GRID (content_grid
), group_grid
, 0, crow
++, 1, 1);
1893 label
= make_label_group(_("HomeBank files"));
1894 gtk_grid_attach (GTK_GRID (group_grid
), label
, 0, 0, 3, 1);
1897 label
= make_label_widget(_("_Wallets:"));
1898 gtk_grid_attach (GTK_GRID (group_grid
), label
, 1, row
, 1, 1);
1900 hbox
= gtk_box_new(GTK_ORIENTATION_HORIZONTAL
, 0);
1901 gtk_widget_set_hexpand (hbox
, TRUE
);
1902 gtk_grid_attach (GTK_GRID (group_grid
), hbox
, 2, row
, 1, 1);
1904 widget
= make_string(label
);
1905 data
->ST_path_hbfile
= widget
;
1906 gtk_style_context_add_class (gtk_widget_get_style_context (GTK_WIDGET(widget
)), GTK_STYLE_CLASS_LINKED
);
1907 gtk_box_pack_start (GTK_BOX (hbox
), widget
, TRUE
, TRUE
, 0);
1909 //widget = gtk_button_new_with_label("...");
1910 widget
= gtk_button_new_from_icon_name(ICONNAME_FOLDER
, GTK_ICON_SIZE_BUTTON
);
1911 data
->BT_path_hbfile
= widget
;
1912 gtk_box_pack_start (GTK_BOX (hbox
), widget
, FALSE
, FALSE
, 0);
1915 // group :: Files folder
1916 group_grid
= gtk_grid_new ();
1917 gtk_grid_set_row_spacing (GTK_GRID (group_grid
), SPACING_SMALL
);
1918 gtk_grid_set_column_spacing (GTK_GRID (group_grid
), SPACING_MEDIUM
);
1919 gtk_grid_attach (GTK_GRID (content_grid
), group_grid
, 0, crow
++, 1, 1);
1921 label
= make_label_group(_("Exchange files"));
1922 gtk_grid_attach (GTK_GRID (group_grid
), label
, 0, 0, 3, 1);
1925 label
= make_label_widget(_("_Import:"));
1926 //----------------------------------------- l, r, t, b
1927 gtk_grid_attach (GTK_GRID (group_grid
), label
, 1, row
, 1, 1);
1929 hbox
= gtk_box_new(GTK_ORIENTATION_HORIZONTAL
, 0);
1930 gtk_widget_set_hexpand (hbox
, TRUE
);
1931 gtk_grid_attach (GTK_GRID (group_grid
), hbox
, 2, row
, 1, 1);
1933 widget
= make_string(label
);
1934 data
->ST_path_import
= widget
;
1935 gtk_style_context_add_class (gtk_widget_get_style_context (GTK_WIDGET(widget
)), GTK_STYLE_CLASS_LINKED
);
1936 gtk_box_pack_start (GTK_BOX (hbox
), widget
, TRUE
, TRUE
, 0);
1938 //widget = gtk_button_new_with_label("...");
1939 widget
= gtk_button_new_from_icon_name(ICONNAME_FOLDER
, GTK_ICON_SIZE_BUTTON
);
1940 data
->BT_path_import
= widget
;
1941 gtk_box_pack_start (GTK_BOX (hbox
), widget
, FALSE
, FALSE
, 0);
1944 label
= make_label_widget(_("_Export:"));
1945 //----------------------------------------- l, r, t, b
1946 gtk_grid_attach (GTK_GRID (group_grid
), label
, 1, row
, 1, 1);
1948 hbox
= gtk_box_new(GTK_ORIENTATION_HORIZONTAL
, 0);
1949 gtk_widget_set_hexpand (hbox
, TRUE
);
1950 gtk_grid_attach (GTK_GRID (group_grid
), hbox
, 2, row
, 1, 1);
1952 widget
= make_string(label
);
1953 data
->ST_path_export
= widget
;
1954 gtk_style_context_add_class (gtk_widget_get_style_context (GTK_WIDGET(widget
)), GTK_STYLE_CLASS_LINKED
);
1955 gtk_box_pack_start (GTK_BOX (hbox
), widget
, TRUE
, TRUE
, 0);
1957 //widget = gtk_button_new_with_label("...");
1958 widget
= gtk_button_new_from_icon_name(ICONNAME_FOLDER
, GTK_ICON_SIZE_BUTTON
);
1959 data
->BT_path_export
= widget
;
1960 gtk_box_pack_start (GTK_BOX (hbox
), widget
, FALSE
, FALSE
, 0);
1964 return content_grid
;
1968 static GtkWidget
*defpref_page_general (struct defpref_data
*data
)
1970 GtkWidget
*content_grid
, *group_grid
, *label
, *widget
;
1973 content_grid
= gtk_grid_new();
1974 gtk_grid_set_row_spacing (GTK_GRID (content_grid
), SPACING_LARGE
);
1975 gtk_orientable_set_orientation(GTK_ORIENTABLE(content_grid
), GTK_ORIENTATION_VERTICAL
);
1978 // group :: Program start
1979 group_grid
= gtk_grid_new ();
1980 gtk_grid_set_row_spacing (GTK_GRID (group_grid
), SPACING_SMALL
);
1981 gtk_grid_set_column_spacing (GTK_GRID (group_grid
), SPACING_MEDIUM
);
1982 gtk_grid_attach (GTK_GRID (content_grid
), group_grid
, 0, crow
++, 1, 1);
1984 label
= make_label_group(_("Program start"));
1985 gtk_grid_attach (GTK_GRID (group_grid
), label
, 0, 0, 3, 1);
1988 widget
= gtk_check_button_new_with_mnemonic (_("Show splash screen"));
1989 data
->CM_show_splash
= widget
;
1990 gtk_grid_attach (GTK_GRID (group_grid
), widget
, 1, row
, 2, 1);
1993 widget
= gtk_check_button_new_with_mnemonic (_("Load last opened file"));
1994 data
->CM_load_last
= widget
;
1995 gtk_grid_attach (GTK_GRID (group_grid
), widget
, 1, row
, 2, 1);
1998 widget
= gtk_check_button_new_with_mnemonic (_("Post pending scheduled transactions"));
1999 data
->CM_append_scheduled
= widget
;
2000 gtk_grid_attach (GTK_GRID (group_grid
), widget
, 1, row
, 2, 1);
2003 widget
= gtk_check_button_new_with_mnemonic (_("Update currencies online"));
2004 data
->CM_do_update_currency
= widget
;
2005 gtk_grid_attach (GTK_GRID (group_grid
), widget
, 1, row
, 2, 1);
2008 // group :: Main window reports
2009 group_grid
= gtk_grid_new ();
2010 gtk_grid_set_row_spacing (GTK_GRID (group_grid
), SPACING_SMALL
);
2011 gtk_grid_set_column_spacing (GTK_GRID (group_grid
), SPACING_MEDIUM
);
2012 gtk_grid_attach (GTK_GRID (content_grid
), group_grid
, 0, crow
++, 1, 1);
2014 label
= make_label_group(_("Main window reports"));
2015 gtk_grid_attach (GTK_GRID (group_grid
), label
, 0, 0, 3, 1);
2018 label
= make_label(_("_Range:"), 0, 0.5);
2019 gtk_grid_attach (GTK_GRID (group_grid
), label
, 1, row
, 1, 1);
2020 widget
= make_daterange(label
, DATE_RANGE_CUSTOM_HIDE
);
2021 data
->CY_daterange_wal
= widget
;
2022 gtk_grid_attach (GTK_GRID (group_grid
), widget
, 2, row
, 1, 1);
2024 return content_grid
;
2028 static void defpref_selection(GtkTreeSelection
*treeselection
, gpointer user_data
)
2030 struct defpref_data
*data
;
2031 GtkWidget
*notebook
;
2032 GtkTreeView
*treeview
;
2033 GtkTreeModel
*model
;
2036 GValue val
= { 0, };
2039 DB( g_print("\n[ui-pref] selection\n") );
2041 if (gtk_tree_selection_get_selected(treeselection
, &model
, &iter
))
2043 notebook
= GTK_WIDGET(user_data
);
2044 treeview
= gtk_tree_selection_get_tree_view(treeselection
);
2045 data
= g_object_get_data(G_OBJECT(gtk_widget_get_ancestor(GTK_WIDGET(treeview
), GTK_TYPE_WINDOW
)), "inst_data");
2048 gtk_tree_model_get_value(model
, &iter
, LST_PREF_PAGE
, &val
);
2049 page
= g_value_get_int (&val
);
2050 DB( g_print(" - active is %d\n", page
) );
2051 g_value_unset (&val
);
2054 gtk_tree_model_get_value(model
, &iter
, LST_PREF_NAME
, &val
);
2055 gtk_label_set_text (GTK_LABEL (data
->label
), g_value_get_string (&val
));
2056 g_value_unset (&val
);
2058 gtk_tree_model_get_value(model
, &iter
, LST_PREF_ICONNAME
, &val
);
2059 //gtk_image_set_from_pixbuf (GTK_IMAGE (data->image), g_value_get_object (&val));
2060 gtk_image_set_from_icon_name(GTK_IMAGE (data
->image
), g_value_get_string (&val
), GTK_ICON_SIZE_DIALOG
);
2061 g_value_unset (&val
);
2065 gtk_notebook_set_current_page(GTK_NOTEBOOK(notebook
), page
);
2067 //defpref_change_page(GTK_WIDGET(gtk_tree_selection_get_tree_view(treeselection)), GINT_TO_POINTER(page));
2074 ** set the notebook active page from treeview
2076 /*void defpref_change_page(GtkWidget *widget, gpointer user_data)
2078 struct defpref_data *data;
2079 gint page = GPOINTER_TO_INT(user_data);
2080 GtkTreeModel *model;
2083 DB( g_print("\n[ui-pref] page\n") );
2085 data = g_object_get_data(G_OBJECT(gtk_widget_get_ancestor(widget, GTK_TYPE_WINDOW)), "inst_data");
2087 model = gtk_tree_view_get_model(GTK_TREE_VIEW(data->LV_page));
2095 gtk_notebook_set_current_page(GTK_NOTEBOOK(data->GR_page), page);
2101 ** add an empty new account to our temp GList and treeview
2103 static void defpref_reset(GtkWidget
*widget
, gpointer user_data
)
2105 struct defpref_data
*data
;
2108 data
= g_object_get_data(G_OBJECT(gtk_widget_get_ancestor(widget
, GTK_TYPE_WINDOW
)), "inst_data");
2109 DB( g_print("\n(defpref_reset) (data=%p)\n", data
) );
2111 result
= ui_dialog_msg_confirm_alert(
2112 GTK_WINDOW(data
->window
),
2113 _("Reset All Preferences"),
2114 _("Do you really want to reset\nall preferences to default\nvalues?"),
2117 if( result
== GTK_RESPONSE_OK
)
2119 homebank_pref_setdefault();
2126 // the window creation
2127 GtkWidget
*defpref_dialog_new (void)
2129 struct defpref_data data
;
2130 GtkWidget
*window
, *content
, *mainvbox
;
2131 GtkWidget
*hbox
, *vbox
, *sw
, *widget
, *notebook
, *page
, *ebox
, *image
, *label
;
2133 window
= gtk_dialog_new_with_buttons (_("Preferences"),
2134 GTK_WINDOW(GLOBALS
->mainwindow
),
2139 GTK_RESPONSE_REJECT
,
2141 GTK_RESPONSE_ACCEPT
,
2144 data
.window
= window
;
2146 //store our window private data
2147 g_object_set_data(G_OBJECT(window
), "inst_data", (gpointer
)&data
);
2149 gtk_window_set_icon_name(GTK_WINDOW (window
), ICONNAME_PREFERENCES
);
2151 content
= gtk_dialog_get_content_area(GTK_DIALOG (window
)); // return a vbox
2152 mainvbox
= gtk_box_new(GTK_ORIENTATION_VERTICAL
, SPACING_MEDIUM
);
2153 gtk_box_pack_start (GTK_BOX (content
), mainvbox
, TRUE
, TRUE
, 0);
2155 gtk_container_set_border_width(GTK_CONTAINER(mainvbox
), SPACING_MEDIUM
);
2157 hbox
= gtk_box_new(GTK_ORIENTATION_HORIZONTAL
, SPACING_MEDIUM
);
2158 gtk_box_pack_start (GTK_BOX (mainvbox
), hbox
, TRUE
, TRUE
, 0);
2161 vbox
= gtk_box_new(GTK_ORIENTATION_VERTICAL
, SPACING_SMALL
);
2162 gtk_box_pack_start (GTK_BOX (hbox
), vbox
, FALSE
, FALSE
, 0);
2165 sw
= gtk_scrolled_window_new (NULL
, NULL
);
2166 gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (sw
), GTK_SHADOW_ETCHED_IN
);
2167 gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (sw
), GTK_POLICY_NEVER
, GTK_POLICY_AUTOMATIC
);
2168 gtk_box_pack_start (GTK_BOX (vbox
), sw
, TRUE
, TRUE
, 0);
2169 widget
= pref_list_create();
2170 data
.LV_page
= widget
;
2171 gtk_container_add (GTK_CONTAINER (sw
), widget
);
2174 //right part : notebook
2175 vbox
= gtk_box_new (GTK_ORIENTATION_VERTICAL
, SPACING_MEDIUM
);
2176 gtk_box_pack_start (GTK_BOX (hbox
), vbox
, TRUE
, TRUE
, 0);
2177 gtk_widget_show (vbox
);
2179 ebox
= gtk_event_box_new();
2180 gtk_widget_set_name(ebox
, "hbebox");
2181 GtkStyleContext
*context
= gtk_widget_get_style_context (ebox
);
2182 #if GTK_MINOR_VERSION <= 18
2183 gtk_style_context_add_class (context
, GTK_STYLE_CLASS_LIST_ROW
);
2184 gtk_widget_set_state_flags(ebox
, GTK_STATE_FLAG_SELECTED
, TRUE
);
2186 GtkCssProvider
*provider
;
2187 provider
= gtk_css_provider_new ();
2188 gtk_css_provider_load_from_data (provider
,
2189 "#hbebox { color: @theme_selected_fg_color; background-color: @theme_selected_bg_color; }"
2191 gtk_style_context_add_provider (context
, GTK_STYLE_PROVIDER(provider
), G_MAXUINT
);
2193 // gtk_style_context_set_state(context, GTK_STATE_FLAG_SELECTED);
2196 gtk_box_pack_start (GTK_BOX (vbox
), ebox
, FALSE
, TRUE
, 0);
2197 gtk_widget_show (ebox
);
2199 hbox
= gtk_box_new (GTK_ORIENTATION_HORIZONTAL
, SPACING_SMALL
);
2200 gtk_container_set_border_width (GTK_CONTAINER (hbox
), SPACING_SMALL
);
2201 gtk_container_add (GTK_CONTAINER (ebox
), hbox
);
2202 gtk_widget_show (hbox
);
2204 label
= gtk_label_new (NULL
);
2205 gtk_widget_set_margin_left(label
, SPACING_MEDIUM
);
2206 gimp_label_set_attributes (GTK_LABEL (label
),
2207 PANGO_ATTR_SCALE
, PANGO_SCALE_XX_LARGE
,
2208 PANGO_ATTR_WEIGHT
, PANGO_WEIGHT_BOLD
,
2211 gtk_box_pack_start (GTK_BOX (hbox
), label
, FALSE
, FALSE
, 0);
2212 gtk_widget_show (label
);
2215 image
= gtk_image_new ();
2216 gtk_box_pack_end (GTK_BOX (hbox
), image
, FALSE
, FALSE
, 0);
2217 gtk_widget_show (image
);
2223 notebook
= gtk_notebook_new();
2224 data
.GR_page
= notebook
;
2225 gtk_widget_show(notebook
);
2226 gtk_notebook_set_show_tabs(GTK_NOTEBOOK(notebook
), FALSE
);
2227 gtk_notebook_set_show_border(GTK_NOTEBOOK(notebook
), FALSE
);
2228 gtk_box_pack_start (GTK_BOX (vbox
), notebook
, TRUE
, TRUE
, 0);
2233 PREF_LOCALE, //old DISPLAY
2234 PREF_TXN, //old COLUMNS
2244 page
= defpref_page_general(&data
);
2245 gtk_notebook_append_page (GTK_NOTEBOOK (notebook
), page
, NULL
);
2248 page
= defpref_page_interface(&data
);
2249 gtk_notebook_append_page (GTK_NOTEBOOK (notebook
), page
, NULL
);
2252 page
= defpref_page_display(&data
);
2253 gtk_notebook_append_page (GTK_NOTEBOOK (notebook
), page
, NULL
);
2256 page
= defpref_page_transactions(&data
);
2257 gtk_notebook_append_page (GTK_NOTEBOOK (notebook
), page
, NULL
);
2260 page
= defpref_page_import(&data
);
2261 gtk_notebook_append_page (GTK_NOTEBOOK (notebook
), page
, NULL
);
2264 page
= defpref_page_reports(&data
);
2265 gtk_notebook_append_page (GTK_NOTEBOOK (notebook
), page
, NULL
);
2268 page
= defpref_page_filebackup(&data
);
2269 gtk_notebook_append_page (GTK_NOTEBOOK (notebook
), page
, NULL
);
2272 page
= defpref_page_folders(&data
);
2273 gtk_notebook_append_page (GTK_NOTEBOOK (notebook
), page
, NULL
);
2276 page
= defpref_page_euro(&data
);
2277 gtk_notebook_append_page (GTK_NOTEBOOK (notebook
), page
, NULL
);
2280 //todo:should move this
2281 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(data
.CM_euro_enable
), PREFS
->euro_active
);
2283 //connect all our signals
2284 g_signal_connect (window
, "destroy", G_CALLBACK (gtk_widget_destroyed
), &window
);
2286 g_signal_connect (data
.CM_bak_is_automatic
, "toggled", G_CALLBACK (defpref_backuptoggle
), NULL
);
2290 g_signal_connect (data
.BT_path_hbfile
, "pressed", G_CALLBACK (defpref_pathselect
), GINT_TO_POINTER(PRF_PATH_WALLET
));
2291 g_signal_connect (data
.BT_path_import
, "pressed", G_CALLBACK (defpref_pathselect
), GINT_TO_POINTER(PRF_PATH_IMPORT
));
2292 g_signal_connect (data
.BT_path_export
, "pressed", G_CALLBACK (defpref_pathselect
), GINT_TO_POINTER(PRF_PATH_EXPORT
));
2294 g_signal_connect (data
.CM_custom_colors
, "toggled", G_CALLBACK (defpref_colortoggle
), NULL
);
2295 g_signal_connect (data
.CY_colors
, "changed", G_CALLBACK (defpref_colorpreset
), NULL
);
2299 g_signal_connect (gtk_tree_view_get_selection(GTK_TREE_VIEW(data
.LV_page
)), "changed", G_CALLBACK (defpref_selection
), notebook
);
2301 g_signal_connect (data
.CM_euro_enable
, "toggled", G_CALLBACK (defpref_eurotoggle
), NULL
);
2303 g_signal_connect (data
.CY_euro_preset
, "changed", G_CALLBACK (defpref_europreset
), NULL
);
2306 g_signal_connect (data
.ST_datefmt
, "changed", G_CALLBACK (defpref_date_sample
), NULL
);
2309 g_signal_connect (data
.CY_color_scheme
, "changed", G_CALLBACK (defpref_color_scheme_changed
), NULL
);
2313 g_signal_connect (data
.ST_euro_symbol
, "changed", G_CALLBACK (defpref_numbereuro_sample
), NULL
);
2314 g_signal_connect (data
.CM_euro_isprefix
, "toggled", G_CALLBACK (defpref_numbereuro_sample
), NULL
);
2315 g_signal_connect (data
.ST_euro_decimalchar
, "changed", G_CALLBACK (defpref_numbereuro_sample
), NULL
);
2316 g_signal_connect (data
.ST_euro_groupingchar
, "changed", G_CALLBACK (defpref_numbereuro_sample
), NULL
);
2317 g_signal_connect (data
.NB_euro_fracdigits
, "value-changed", G_CALLBACK (defpref_numbereuro_sample
), NULL
);
2319 //g_signal_connect (data.BT_default, "pressed", G_CALLBACK (defpref_currency_change), NULL);
2322 //setup, init and show window
2323 //defhbfile_setup(&data);
2324 //defhbfile_update(data.LV_arc, NULL);
2328 defpref_colortoggle(window
, NULL
);
2329 defpref_eurotoggle(window
, NULL
);
2331 gtk_window_resize(GTK_WINDOW(window
), 640, 256);
2335 GtkTreePath
*path
= gtk_tree_path_new_first ();
2337 gtk_tree_selection_select_path (gtk_tree_view_get_selection(GTK_TREE_VIEW(data
.LV_page
)), path
);
2341 gtk_tree_path_free(path
);
2343 gtk_widget_show_all (window
);
2350 result
= gtk_dialog_run (GTK_DIALOG (window
));
2354 case GTK_RESPONSE_ACCEPT
:
2355 old_lang
= g_strdup(PREFS
->language
);
2357 homebank_pref_save();
2358 ui_mainwindow_update(GLOBALS
->mainwindow
, GINT_TO_POINTER(UF_BALANCE
+UF_VISUAL
));
2360 DB( g_print("old='%s' new='%s'\n", old_lang
, PREFS
->language
) );
2362 if(g_ascii_strncasecmp(old_lang
== NULL
? "" : old_lang
, PREFS
->language
== NULL
? "" : PREFS
->language
, -1) != 0)
2364 ui_dialog_msg_infoerror(GTK_WINDOW(window
), GTK_MESSAGE_INFO
,
2366 _("You will have to restart HomeBank\nfor the language change to take effect.")
2375 defpref_reset (window
, NULL
);
2380 // cleanup and destroy
2381 //defhbfile_cleanup(&data, result);
2382 gtk_widget_destroy (window
);
2387 // -------------------------------
2390 static GtkWidget
*pref_list_create(void)
2392 GtkListStore
*store
;
2394 GtkCellRenderer
*renderer
;
2395 GtkTreeViewColumn
*column
;
2399 /* create list store */
2400 store
= gtk_list_store_new(
2408 view
= gtk_tree_view_new_with_model(GTK_TREE_MODEL(store
));
2409 g_object_unref(store
);
2411 gtk_tree_view_set_headers_visible(GTK_TREE_VIEW (view
), FALSE
);
2412 gtk_tree_selection_set_mode(gtk_tree_view_get_selection(GTK_TREE_VIEW(view
)), GTK_SELECTION_SINGLE
);
2414 /* column 1: icon */
2415 column
= gtk_tree_view_column_new();
2416 renderer
= gtk_cell_renderer_pixbuf_new ();
2417 g_object_set(renderer
, "stock-size", GTK_ICON_SIZE_DND
, NULL
);
2418 gtk_tree_view_column_pack_start(column
, renderer
, FALSE
);
2419 gtk_tree_view_column_set_attributes(column
, renderer
, "icon-name", LST_PREF_ICONNAME
, NULL
);
2421 renderer
= gtk_cell_renderer_text_new ();
2422 gtk_tree_view_column_pack_start(column
, renderer
, TRUE
);
2423 gtk_tree_view_column_set_attributes(column
, renderer
, "text", LST_PREF_NAME
, NULL
);
2425 gtk_tree_view_append_column (GTK_TREE_VIEW(view
), column
);
2427 //populate our combobox model
2428 for(i
=0;i
<PREF_MAX
;i
++)
2430 gtk_list_store_append(store
, &iter
);
2432 gtk_list_store_set(store
, &iter
,
2433 LST_PREF_ICONNAME
, pref_iconname
[i
],
2434 LST_PREF_NAME
, _(pref_name
[i
]),
2443 /* = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =*/
2446 extern gchar *list_txn_column_label[];
2450 list_txn_colpref_toggled_cell_data_function (GtkCellRendererToggle *cell,
2454 GtkTreeModel *model = (GtkTreeModel *)data;
2456 GtkTreePath *path = gtk_tree_path_new_from_string (path_str);
2460 gtk_tree_model_get_iter (model, &iter, path);
2461 gtk_tree_model_get (model, &iter, COLUMN_VISIBLE, &fixed, -1);
2463 // do something with the value
2467 gtk_list_store_set (GTK_LIST_STORE (model), &iter, COLUMN_VISIBLE, fixed, -1);
2470 gtk_tree_path_free (path);
2474 static void list_txn_colpref_get(GtkTreeView *treeview, gint *columns)
2476 GtkTreeModel *model;
2482 DB( g_print("[lst_txn-colpref] store column order \n") );
2484 model = gtk_tree_view_get_model(GTK_TREE_VIEW(treeview));
2485 valid = gtk_tree_model_get_iter_first(GTK_TREE_MODEL(model), &iter);
2489 gtk_tree_model_get(GTK_TREE_MODEL(model), &iter,
2490 COLUMN_VISIBLE, &visible,
2494 DB( g_print(" - column %d: %d\n",id, visible) );
2495 // start at index 2 (status, date always displayed
2496 columns[i+2] = visible == TRUE ? id : -id;
2498 // Make iter point to the next row in the list store
2499 valid = gtk_tree_model_iter_next(GTK_TREE_MODEL(model), &iter);
2505 GtkWidget *list_txn_colprefcreate(void)
2507 GtkListStore *store;
2509 GtkCellRenderer *renderer;
2510 GtkTreeViewColumn *column;
2514 DB( g_print("[lst_txn-colpref] create\n") );
2517 // create list store
2518 store = gtk_list_store_new(
2526 for(i=0 ; i < NUM_LST_DSPOPE-1; i++ ) //-1 cause account column avoid
2531 DB( g_print("eval %d, %s\n", i, list_txn_column_label[i]) );
2533 if(i <= LST_DSPOPE_DATE) // status, date always displayed
2536 //[i-1] here because lst_ope_columns[] do not store MODEL_TXN_POINTER
2537 id = ABS(PREFS->lst_ope_columns[i-1]);
2538 if(id == 0) id = i; //if we pass here, new column or weird into pref file
2539 visible = (PREFS->lst_ope_columns[i-1] > 0) ? TRUE : FALSE;
2542 DB( g_print(" - pos=%2d, id=%2d - %d '%s'\n", i, id, visible, list_txn_column_label[id]) );
2544 gtk_list_store_append (store, &iter);
2545 gtk_list_store_set (store, &iter,
2546 COLUMN_VISIBLE, visible,
2547 COLUMN_NAME, _(list_txn_column_label[id]),
2554 view = gtk_tree_view_new_with_model(GTK_TREE_MODEL(store));
2555 g_object_unref(store);
2559 renderer = gtk_cell_renderer_toggle_new ();
2560 column = gtk_tree_view_column_new_with_attributes (_("Visible"),
2562 "active", COLUMN_VISIBLE,
2564 gtk_tree_view_append_column (GTK_TREE_VIEW(view), column);
2566 g_signal_connect (renderer, "toggled",
2567 G_CALLBACK (list_txn_colpref_toggled_cell_data_function), store);
2570 renderer = gtk_cell_renderer_text_new ();
2571 column = gtk_tree_view_column_new_with_attributes (_("Column"),
2573 "text", COLUMN_NAME,
2575 gtk_tree_view_append_column (GTK_TREE_VIEW(view), column);
2577 gtk_tree_view_set_reorderable (GTK_TREE_VIEW(view), TRUE);