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"
29 #include "ui-currency.h"
32 /****************************************************************************/
34 /****************************************************************************/
43 /* our global datas */
44 extern struct HomeBank
*GLOBALS
;
45 extern struct Preferences
*PREFS
;
58 EXT_COLUMN_ENABLED
= 0,
61 EXT_COLUMN_PLUGIN_NAME
,
66 static gchar
*pref_iconname
[PREF_MAX
] = {
76 "prf-euro", // to be renamed
81 static gchar
*pref_name
[PREF_MAX
] = {
95 static gchar
*CYA_TOOLBAR_STYLE
[] = {
96 N_("System defaults"),
99 N_("Text under icons"),
100 N_("Text beside icons"),
104 static gchar
*CYA_GRID_LINES
[] = {
113 gchar
*CYA_TANGO_COLORS
[] = {
121 gchar
*CYA_IMPORT_DATEORDER
[] = {
128 gchar
*CYA_IMPORT_OFXNAME
[] = {
136 gchar
*CYA_IMPORT_OFXMEMO
[] = {
138 N_("Append to Info"),
139 N_("Append to Memo"),
140 N_("Append to Payee"),
144 gchar
*CYA_IMPORT_CSVSEPARATOR
[] = {
154 extern gchar
*CYA_CHART_COLORSCHEME
[];
155 extern gchar
*CYA_MONTHS
[];
162 http://en.wikipedia.org/wiki/Currencies_of_the_European_Union
163 http://www.xe.com/euro.php
164 http://fr.wikipedia.org/wiki/Liste_des_unit%C3%A9s_mon%C3%A9taires_remplac%C3%A9es_par_l%27euro
165 http://www.inter-locale.com/LocalesDemo.jsp
167 static EuroParams euro_params
[] =
169 // , rate , symb , prfx , dec, grp, frac
170 // ---------------------------------------------------------------------
171 { 0, "" , "--------" , 1.0 , "" , FALSE
, ",", ".", 2 },
172 { 1, "ATS", "Austria" , 13.7603 , "S" , TRUE
, ",", ".", 2 }, // -S 1.234.567,89
173 { 2, "BEF", "Belgium" , 40.3399 , "BF" , TRUE
, ",", ".", 2 }, // BF 1.234.567,89 -
174 { 20, "BGN", "Bulgaria" , 1.95583 , "лв." , TRUE
, ",", " ", 2 }, // non-fixé - 2014 target for euro
175 { 24, "HRK", "Croatia" , 1.0000 , "kn" , FALSE
, "" , ".", 0 }, // non-fixé - 2015 target for euro earliest
176 { 14, "CYP", "Cyprus" , 0.585274 , "£" , TRUE
, ",", "" , 2 }, //
177 { 23, "CZK", "Czech Republic" , 28.36 , "Kč" , FALSE
, ",", " ", 2 }, // non-fixé - 2015 earliest
179 { 17, "EEK", "Estonia" , 15.6466 , "kr" , FALSE
, ",", " ", 2 }, //
180 { 3, "FIM", "Finland" , 5.94573 , "mk" , FALSE
, ",", " ", 2 }, // -1 234 567,89 mk
181 { 4, "FRF", "France" , 6.55957 , "F" , FALSE
, ",", " ", 2 }, // -1 234 567,89 F
182 { 5, "DEM", "Germany" , 1.95583 , "DM" , FALSE
, ",", ".", 2 }, // -1.234.567,89 DM
183 { 6, "GRD", "Greece" , 340.750 , "d" , TRUE
, ".", ",", 2 }, // ??
184 { 21, "HUF", "Hungary" , 261.51 , "Ft" , TRUE
, ",", " ", 2 }, // non-fixé - No current target for euro
185 { 7, "IEP", "Ireland" , 0.787564 , "£" , TRUE
, ".", ",", 2 }, // -£1,234,567.89
186 { 8, "ITL", "Italy" , 1936.27 , "L" , TRUE
, "" , ".", 0 }, // L -1.234.567
187 { 18, "LVL", "Latvia" , 0.702804 , "lat.", FALSE
, ",", "" , 2 }, // jan. 2014
188 { 19, "LTL", "Lithuania" , 3.45280 , "Lt" , FALSE
, ",", "" , 2 }, // jan. 2015
189 { 9, "LUF", "Luxembourg" , 40.3399 , "LU" , TRUE
, ",", ".", 2 }, // LU 1.234.567,89 -
190 { 15, "MTL", "Malta" , 0.429300 , "Lm" , TRUE
, ",", "" , 2 }, //
191 { 10, "NLG", "Netherlands" , 2.20371 , "F" , TRUE
, ",", ".", 2 }, // F 1.234.567,89-
192 { 25, "PLN", "Poland" , 0.25 , "zł" , FALSE
, ",", "" , 2 }, // non-fixé - No current target for euro
193 { 11, "PTE", "Portugal" , 200.482 , "Esc.", FALSE
, "$", ".", 2 }, // -1.234.567$89 Esc.
194 { 22, "RON", "Romania" , 3.5155 , "Leu" , FALSE
, ",", ".", 2 }, // non-fixé - 2015 target for euro earliest
195 { 16, "SKK", "Slovak Republic", 30.12600 , "Sk" , FALSE
, ",", " ", 2 }, //
196 { 13, "SIT", "Slovenia" , 239.640 , "tol" , TRUE
, ",", ".", 2 }, //
197 { 12, "ESP", "Spain" , 166.386 , "Pts" , TRUE
, "" , ".", 0 }, // -Pts 1.234.567
200 // { " ", "" , 1.00000 , "" , "" , FALSE, ",", "", 2 },
204 static void list_ext_colpref_get(GtkTreeView
*treeview
, GList
**columns
);
207 /* = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =*/
210 static LangName languagenames
[] =
212 // 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
213 //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
216 { "ab", "Abkhazian" },
218 { "af", "Afrikaans" },
221 { "an", "Aragonese" },
223 { "as", "Assamese" },
224 { "ast", "Asturian, Bable, Leonese, Asturleonese" },
227 { "az", "Azerbaijani" },
229 { "be", "Belarusian" },
230 { "bg", "Bulgarian" },
240 { "ch", "Chamorro" },
241 { "co", "Corsican" },
244 { "cu", "Old Church Slavonic" },
250 { "dz", "Dzongkha" },
254 { "eo", "Esperanto" },
256 { "et", "Estonian" },
264 { "fy", "Western Frisian" },
266 { "gd", "Scottish Gaelic" },
267 { "gl", "Galician" },
269 { "gu", "Gujarati" },
274 { "ho", "Hiri Motu" },
275 { "hr", "Croatian" },
277 { "hu", "Hungarian" },
278 { "hy", "Armenian" },
280 { "ia", "Interlingua" },
281 { "id", "Indonesian" },
282 { "ie", "Interlingue" },
284 { "ii", "Sichuan Yi" },
287 { "is", "Icelandic" },
289 { "iu", "Inuktitut" },
290 { "ja", "Japanese" },
291 { "jv", "Javanese" },
292 { "ka", "Georgian" },
295 { "kj", "Kwanyama" },
297 { "kl", "Kalaallisut" },
302 { "ks", "Kashmiri" },
308 { "lb", "Luxembourgish" },
310 { "li", "Limburgish" },
313 { "lt", "Lithuanian" },
314 { "lu", "Luba-Katanga" },
316 { "mg", "Malagasy" },
317 { "mh", "Marshallese" },
319 { "mk", "Macedonian" },
320 { "ml", "Malayalam" },
321 { "mn", "Mongolian" },
322 { "mo", "Moldavian" },
328 { "nb", "Norwegian Bokmål" },
329 { "nd", "North Ndebele" },
330 { "nds", "Low German, Low Saxon" },
334 { "nn", "Norwegian Nynorsk" },
335 { "no", "Norwegian" },
336 { "nr", "South Ndebele" },
338 { "ny", "Chichewa" },
343 { "os", "Ossetian" },
348 { "pt", "Portuguese" },
352 { "ro", "Romanian" },
354 { "rw", "Kinyarwanda" },
355 { "sa", "Sanskrit" },
356 { "sc", "Sardinian" },
358 { "se", "Northern Sami" },
360 { "si", "Sinhalese" },
366 { "sq", "Albanian" },
370 { "su", "Sundanese" },
377 { "ti", "Tigrinya" },
386 { "ty", "Tahitian" },
388 { "uk", "Ukrainian" },
392 { "vi", "Viêt Namese" },
406 static GtkWidget
*pref_list_create(void);
410 ui_language_combobox_compare_func (GtkTreeModel
*model
, GtkTreeIter
*a
, GtkTreeIter
*b
, gpointer userdata
)
413 gchar
*code1
, *code2
;
414 gchar
*name1
, *name2
;
416 gtk_tree_model_get(model
, a
, 0, &code1
, 1, &name1
, -1);
417 gtk_tree_model_get(model
, b
, 0, &code2
, 1, &name2
, -1);
419 //keep system laguage on top
420 if(code1
== NULL
) name1
= NULL
;
421 if(code2
== NULL
) name2
= NULL
;
423 retval
= hb_string_utf8_compare(name1
, name2
);
432 static gchar
*languagename_get(const gchar
*locale
)
436 for (i
= 0; i
< G_N_ELEMENTS (languagenames
); i
++)
438 if( g_ascii_strncasecmp(locale
, languagenames
[i
].locale
, -1) == 0 )
439 return languagenames
[i
].name
;
447 ui_language_combobox_get_name(const gchar
*locale
)
451 DB( g_print("[ui_language_combobox_get_name]\n") );
453 // A locale directory name is typically of the form language[_territory]
454 lang
= languagename_get (locale
);
457 const gchar
*delimiter
= strchr (locale
, '_'); // strip off the territory suffix
461 gchar
*copy
= g_strndup (locale
, delimiter
- locale
);
462 lang
= languagename_get (copy
);
468 g_warning(" locale name not found '%s'", locale
);
479 ui_language_combobox_populate(GtkWidget
*combobox
)
484 model
= gtk_combo_box_get_model(GTK_COMBO_BOX(combobox
));
485 gtk_list_store_append (GTK_LIST_STORE(model
), &iter
);
486 gtk_list_store_set (GTK_LIST_STORE(model
), &iter
,
488 1, _("System Language"),
491 GDir
*dir
= g_dir_open (homebank_app_get_locale_dir (), 0, NULL
);
492 const gchar
*dirname
;
497 while ((dirname
= g_dir_read_name (dir
)) != NULL
)
499 gchar
*filename
= g_build_filename (homebank_app_get_locale_dir (),
502 GETTEXT_PACKAGE
".mo",
504 //DB( g_print("- seek for '%s'\n", filename) );
505 if (g_file_test (filename
, G_FILE_TEST_EXISTS
))
510 gtk_list_store_append (GTK_LIST_STORE(model
), &iter
);
512 lang
= ui_language_combobox_get_name(dirname
);
513 label
= g_strdup_printf ("%s [%s]", lang
, dirname
);
515 gtk_list_store_set (GTK_LIST_STORE(model
), &iter
,
527 gtk_tree_sortable_set_sort_column_id(GTK_TREE_SORTABLE(model
), GTK_TREE_SORTABLE_DEFAULT_SORT_COLUMN_ID
, GTK_SORT_ASCENDING
);
534 ui_language_combobox_new(GtkWidget
*label
)
538 GtkCellRenderer
*renderer
;
540 store
= gtk_list_store_new (2,
544 gtk_tree_sortable_set_default_sort_func(GTK_TREE_SORTABLE(store
), ui_language_combobox_compare_func
, NULL
, NULL
);
546 combobox
= gtk_combo_box_new_with_model(GTK_TREE_MODEL(store
));
547 renderer
= gtk_cell_renderer_text_new ();
548 gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (combobox
), renderer
, TRUE
);
549 gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (combobox
), renderer
, "text", 1, NULL
);
551 gtk_combo_box_set_id_column( GTK_COMBO_BOX(combobox
), 0);
553 g_object_unref(store
);
556 gtk_label_set_mnemonic_widget (GTK_LABEL(label
), combobox
);
558 ui_language_combobox_populate(combobox
);
560 gtk_combo_box_set_active(GTK_COMBO_BOX(combobox
), 0);
566 /* = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =*/
567 /* = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =*/
568 /* = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =*/
570 static gint
ui_euro_combobox_id_to_active(gint id
)
574 DB( g_print("\n[ui-pref] ui_euro_combobox_id_to_active\n") );
577 for (i
= 0; i
< G_N_ELEMENTS (euro_params
); i
++)
579 if( euro_params
[i
].id
== id
)
582 DB( g_print("- id (country)=%d => %d - %s\n", id
, i
, euro_params
[i
].name
) );
592 static gint
ui_euro_combobox_active_to_id(gint active
)
596 DB( g_print("\n[ui-pref] ui_euro_combobox_active_to_id\n") );
598 DB( g_print("- to %d\n", active
) );
601 if( active
< (gint
)G_N_ELEMENTS (euro_params
) )
603 id
= euro_params
[active
].id
;
604 DB( g_print("- id (country)=%d '%s'\n", id
, euro_params
[active
].name
) );
610 static GtkWidget
*ui_euro_combobox_new(GtkWidget
*label
)
615 DB( g_print("\n[ui-pref] make euro preset\n") );
617 combobox
= gtk_combo_box_text_new();
618 for (i
= 0; i
< G_N_ELEMENTS (euro_params
); i
++)
620 gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(combobox
), euro_params
[i
].name
);
622 gtk_combo_box_set_active(GTK_COMBO_BOX(combobox
), 0);
625 gtk_label_set_mnemonic_widget (GTK_LABEL(label
), combobox
);
631 static void defpref_pathselect(GtkWidget
*widget
, gpointer user_data
)
633 struct defpref_data
*data
;
634 gint type
= GPOINTER_TO_INT(user_data
);
640 DB( g_print("\n[ui-pref] path select\n") );
642 data
= g_object_get_data(G_OBJECT(gtk_widget_get_ancestor(widget
, GTK_TYPE_WINDOW
)), "inst_data");
646 case PRF_PATH_WALLET
:
647 path
= &PREFS
->path_hbfile
;
648 entry
= data
->ST_path_hbfile
;
649 title
= _("Choose a default HomeBank files folder");
651 case PRF_PATH_IMPORT
:
652 path
= &PREFS
->path_import
;
653 entry
= data
->ST_path_import
;
654 title
= _("Choose a default import folder");
656 case PRF_PATH_EXPORT
:
657 path
= &PREFS
->path_export
;
658 entry
= data
->ST_path_export
;
659 title
= _("Choose a default export folder");
665 DB( g_print(" - hbfile %p %s at %p\n" , PREFS
->path_hbfile
, PREFS
->path_hbfile
, &PREFS
->path_hbfile
) );
666 DB( g_print(" - import %p %s at %p\n" , PREFS
->path_import
, PREFS
->path_import
, &PREFS
->path_import
) );
667 DB( g_print(" - export %p %s at %p\n" , PREFS
->path_export
, PREFS
->path_export
, &PREFS
->path_export
) );
670 DB( g_print(" - before: %s %p\n" , *path
, path
) );
672 r
= ui_file_chooser_folder(GTK_WINDOW(gtk_widget_get_ancestor(widget
, GTK_TYPE_WINDOW
)), title
, path
);
675 DB( g_print(" - after: %s\n", *path
) );
678 gtk_entry_set_text(GTK_ENTRY(entry
), *path
);
685 ** update the date sample label
687 static void defpref_date_sample(GtkWidget
*widget
, gpointer user_data
)
689 struct defpref_data
*data
;
694 DB( g_print("\n[ui-pref] date sample\n") );
696 data
= g_object_get_data(G_OBJECT(gtk_widget_get_ancestor(widget
, GTK_TYPE_WINDOW
)), "inst_data");
698 fmt
= gtk_entry_get_text(GTK_ENTRY(data
->ST_datefmt
));
699 date
= g_date_new_julian (GLOBALS
->today
);
700 g_date_strftime (buffer
, 256-1, fmt
, date
);
703 gtk_label_set_text(GTK_LABEL(data
->LB_date
), buffer
);
709 ** update the number sample label
711 static void defpref_numbereuro_sample(GtkWidget
*widget
, gpointer user_data
)
713 struct defpref_data
*data
;
715 gchar formatd_buf
[G_ASCII_DTOSTR_BUF_SIZE
];
718 DB( g_print("\n[ui-pref] number sample\n") );
720 data
= g_object_get_data(G_OBJECT(gtk_widget_get_ancestor(widget
, GTK_TYPE_WINDOW
)), "inst_data");
722 cur
.symbol
= (gchar
*)gtk_entry_get_text(GTK_ENTRY(data
->ST_euro_symbol
));
723 cur
.sym_prefix
= gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(data
->CM_euro_isprefix
));
724 cur
.decimal_char
= (gchar
*)gtk_entry_get_text(GTK_ENTRY(data
->ST_euro_decimalchar
));
725 cur
.grouping_char
= (gchar
*)gtk_entry_get_text(GTK_ENTRY(data
->ST_euro_groupingchar
));
726 cur
.frac_digits
= gtk_spin_button_get_value(GTK_SPIN_BUTTON(data
->NB_euro_fracdigits
));
728 da_cur_initformat (&cur
);
730 DB( g_print("fmt: %s\n", cur
.format
) );
732 g_ascii_formatd(formatd_buf
, sizeof (formatd_buf
), cur
.format
, HB_NUMBER_SAMPLE
);
733 hb_str_formatd(buf
, 127, formatd_buf
, &cur
, TRUE
);
735 gtk_label_set_text(GTK_LABEL(data
->LB_numbereuro
), buf
);
741 ** enable/disable euro
743 static void defpref_eurotoggle(GtkWidget
*widget
, gpointer user_data
)
745 struct defpref_data
*data
;
748 DB( g_print("\n[ui-pref] euro toggle\n") );
750 data
= g_object_get_data(G_OBJECT(gtk_widget_get_ancestor(widget
, GTK_TYPE_WINDOW
)), "inst_data");
752 sensitive
= gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(data
->CM_euro_enable
));
754 gtk_widget_set_sensitive(data
->GRP_currency
, sensitive
);
755 gtk_widget_set_sensitive(data
->GRP_rate
, sensitive
);
756 gtk_widget_set_sensitive(data
->GRP_format
, sensitive
);
761 ** set euro value widget from a country
763 static void defpref_eurosetcurrency(GtkWidget
*widget
, gint country
)
765 struct defpref_data
*data
;
770 DB( g_print("\n[ui-pref] eurosetcurrency\n") );
772 data
= g_object_get_data(G_OBJECT(gtk_widget_get_ancestor(widget
, GTK_TYPE_WINDOW
)), "inst_data");
774 active
= ui_euro_combobox_id_to_active(country
);
775 euro
= &euro_params
[active
];
776 buf
= g_strdup_printf("%s - %s", euro
->iso
, euro
->name
);
777 gtk_label_set_markup(GTK_LABEL(data
->ST_euro_country
), buf
);
783 ** set euro value widget from a country
785 static void defpref_europreset(GtkWidget
*widget
, gpointer user_data
)
787 struct defpref_data
*data
;
790 DB( g_print("\n[ui-pref] euro preset\n") );
792 data
= g_object_get_data(G_OBJECT(gtk_widget_get_ancestor(widget
, GTK_TYPE_WINDOW
)), "inst_data");
794 active
= gtk_combo_box_get_active (GTK_COMBO_BOX(data
->CY_euro_preset
));
795 data
->country
= ui_euro_combobox_active_to_id (active
);;
797 defpref_eurosetcurrency(widget
, data
->country
);
799 gtk_spin_button_set_value(GTK_SPIN_BUTTON(data
->NB_euro_value
), euro_params
[active
].value
);
801 gtk_spin_button_set_value(GTK_SPIN_BUTTON(data
->NB_euro_fracdigits
), euro_params
[active
].frac_digits
);
803 gtk_entry_set_text(GTK_ENTRY(data
->ST_euro_symbol
) , euro_params
[active
].symbol
);
804 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(data
->CM_euro_isprefix
), euro_params
[active
].sym_prefix
);
805 gtk_entry_set_text(GTK_ENTRY(data
->ST_euro_decimalchar
) , euro_params
[active
].decimal_char
);
806 gtk_entry_set_text(GTK_ENTRY(data
->ST_euro_groupingchar
), euro_params
[active
].grouping_char
);
811 static void defpref_colortoggle(GtkWidget
*widget
, gpointer user_data
)
813 struct defpref_data
*data
;
816 DB( g_print("\n[ui-pref] color toggle\n") );
818 data
= g_object_get_data(G_OBJECT(gtk_widget_get_ancestor(widget
, GTK_TYPE_WINDOW
)), "inst_data");
820 sensitive
= gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(data
->CM_custom_colors
));
822 gtk_widget_set_sensitive(data
->LB_colors
, sensitive
);
823 gtk_widget_set_sensitive(data
->CY_colors
, sensitive
);
824 gtk_widget_set_sensitive(data
->LB_exp_color
, sensitive
);
825 gtk_widget_set_sensitive(data
->GR_colors
, sensitive
);
829 static void defpref_backuptoggle(GtkWidget
*widget
, gpointer user_data
)
831 struct defpref_data
*data
;
834 DB( g_print("\n[ui-pref] backup toggle\n") );
836 data
= g_object_get_data(G_OBJECT(gtk_widget_get_ancestor(widget
, GTK_TYPE_WINDOW
)), "inst_data");
838 sensitive
= gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(data
->CM_bak_is_automatic
));
839 gtk_widget_set_sensitive(data
->LB_bak_max_num_copies
, sensitive
);
840 gtk_widget_set_sensitive(data
->NB_bak_max_num_copies
, sensitive
);
841 gtk_widget_set_sensitive(data
->GR_bak_freq
, sensitive
);
846 ** set preset colors for amount display
848 static void defpref_colorpreset(GtkWidget
*widget
, gpointer user_data
)
850 struct defpref_data
*data
;
853 gchar
*expcol
, *inccol
, *wrncol
;
855 DB( g_print("\n[ui-pref] color preset\n") );
857 data
= g_object_get_data(G_OBJECT(gtk_widget_get_ancestor(widget
, GTK_TYPE_WINDOW
)), "inst_data");
859 preset
= gtk_combo_box_get_active(GTK_COMBO_BOX(data
->CY_colors
));
864 expcol
= LIGHT_EXP_COLOR
;
865 inccol
= LIGHT_INC_COLOR
;
866 wrncol
= LIGHT_WARN_COLOR
;
870 expcol
= MEDIUM_EXP_COLOR
;
871 inccol
= MEDIUM_INC_COLOR
;
872 wrncol
= MEDIUM_WARN_COLOR
;
877 expcol
= DEFAULT_EXP_COLOR
;
878 inccol
= DEFAULT_INC_COLOR
;
879 wrncol
= DEFAULT_WARN_COLOR
;
884 gdk_rgba_parse(&rgba
, expcol
);
885 gtk_color_chooser_set_rgba(GTK_COLOR_CHOOSER(data
->CP_exp_color
), &rgba
);
887 gdk_rgba_parse(&rgba
, inccol
);
888 gtk_color_chooser_set_rgba(GTK_COLOR_CHOOSER(data
->CP_inc_color
), &rgba
);
890 gdk_rgba_parse(&rgba
, wrncol
);
891 gtk_color_chooser_set_rgba(GTK_COLOR_CHOOSER(data
->CP_warn_color
), &rgba
);
897 static void defpref_color_scheme_changed(GtkWidget
*widget
, gpointer user_data
)
899 struct defpref_data
*data
;
901 DB( g_print("\n[ui-pref] color scheme chnaged\n") );
903 data
= g_object_get_data(G_OBJECT(gtk_widget_get_ancestor(widget
, GTK_TYPE_WINDOW
)), "inst_data");
905 gtk_widget_queue_draw (data
->DA_colors
);
913 static void setGdkColor_from_RGB(GdkColor *color, guint32 value)
918 color->red = tmp | tmp<<8;
920 tmp = value >> 8 & 0xFF;
921 color->green = tmp | tmp<<8;
924 color->blue = tmp | tmp<<8;
930 ** set :: fill in widgets from PREFS structure
933 static void defpref_set(struct defpref_data
*data
)
937 DB( g_print("\n[ui-pref] set\n") );
940 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(data
->CM_show_splash
), PREFS
->showsplash
);
941 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(data
->CM_load_last
), PREFS
->loadlast
);
942 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(data
->CM_append_scheduled
), PREFS
->appendscheduled
);
943 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(data
->CM_do_update_currency
), PREFS
->do_update_currency
);
944 hbtk_combo_box_set_active_id(GTK_COMBO_BOX_TEXT(data
->CY_daterange_wal
), PREFS
->date_range_wal
);
945 gtk_spin_button_set_value(GTK_SPIN_BUTTON(data
->NB_fiscyearday
), PREFS
->fisc_year_day
);
946 gtk_combo_box_set_active(GTK_COMBO_BOX(data
->CY_fiscyearmonth
), PREFS
->fisc_year_month
- 1);
949 gtk_entry_set_text(GTK_ENTRY(data
->ST_path_hbfile
), PREFS
->path_hbfile
);
950 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(data
->CM_bak_is_automatic
), PREFS
->bak_is_automatic
);
951 gtk_spin_button_set_value(GTK_SPIN_BUTTON(data
->NB_bak_max_num_copies
), PREFS
->bak_max_num_copies
);
954 if(PREFS
->language
!= NULL
)
955 gtk_combo_box_set_active_id(GTK_COMBO_BOX(data
->CY_language
), PREFS
->language
);
957 gtk_combo_box_set_active (GTK_COMBO_BOX(data
->CY_language
), 0);
958 gtk_combo_box_set_active(GTK_COMBO_BOX(data
->CY_toolbar
), PREFS
->toolbar_style
);
959 //gtk_spin_button_set_value(GTK_SPIN_BUTTON(data->NB_image_size), PREFS->image_size);
961 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(data
->CM_custom_colors
), PREFS
->custom_colors
);
962 gdk_rgba_parse(&rgba
, PREFS
->color_exp
);
963 gtk_color_chooser_set_rgba(GTK_COLOR_CHOOSER(data
->CP_exp_color
), &rgba
);
964 gdk_rgba_parse(&rgba
, PREFS
->color_inc
);
965 gtk_color_chooser_set_rgba(GTK_COLOR_CHOOSER(data
->CP_inc_color
), &rgba
);
966 gdk_rgba_parse(&rgba
, PREFS
->color_warn
);
967 gtk_color_chooser_set_rgba(GTK_COLOR_CHOOSER(data
->CP_warn_color
), &rgba
);
968 //gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(data->CM_ruleshint), PREFS->rules_hint);
969 gtk_combo_box_set_active(GTK_COMBO_BOX(data
->CY_gridlines
), PREFS
->grid_lines
);
972 hbtk_combo_box_set_active_id(GTK_COMBO_BOX_TEXT(data
->CY_daterange_txn
), PREFS
->date_range_txn
);
973 gtk_spin_button_set_value(GTK_SPIN_BUTTON(data
->ST_datefuture_nbdays
), PREFS
->date_future_nbdays
);
974 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(data
->CM_hide_reconciled
), PREFS
->hidereconciled
);
975 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(data
->CM_show_remind
), PREFS
->showremind
);
976 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(data
->CM_herit_date
), PREFS
->heritdate
);
977 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(data
->CM_memoacp
), PREFS
->txn_memoacp
);
978 gtk_spin_button_set_value(GTK_SPIN_BUTTON(data
->ST_memoacp_days
), PREFS
->txn_memoacp_days
);
981 gtk_entry_set_text(GTK_ENTRY(data
->ST_datefmt
), PREFS
->date_format
);
982 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(data
->CM_unitismile
), PREFS
->vehicle_unit_ismile
);
983 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(data
->CM_unitisgal
), PREFS
->vehicle_unit_isgal
);
986 gtk_combo_box_set_active(GTK_COMBO_BOX(data
->CY_dtex_datefmt
), PREFS
->dtex_datefmt
);
987 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(data
->CM_dtex_ucfirst
), PREFS
->dtex_ucfirst
);
988 gtk_combo_box_set_active(GTK_COMBO_BOX(data
->CY_dtex_ofxname
), PREFS
->dtex_ofxname
);
989 gtk_combo_box_set_active(GTK_COMBO_BOX(data
->CY_dtex_ofxmemo
), PREFS
->dtex_ofxmemo
);
990 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(data
->CM_dtex_qifmemo
), PREFS
->dtex_qifmemo
);
991 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(data
->CM_dtex_qifswap
), PREFS
->dtex_qifswap
);
992 gtk_entry_set_text(GTK_ENTRY(data
->ST_path_import
), PREFS
->path_import
);
993 gtk_entry_set_text(GTK_ENTRY(data
->ST_path_export
), PREFS
->path_export
);
994 gtk_combo_box_set_active(GTK_COMBO_BOX(data
->CY_dtex_csvsep
), PREFS
->dtex_csvsep
);
997 hbtk_combo_box_set_active_id(GTK_COMBO_BOX_TEXT(data
->CY_daterange_rep
), PREFS
->date_range_rep
);
998 gtk_combo_box_set_active(GTK_COMBO_BOX(data
->CY_color_scheme
), PREFS
->report_color_scheme
);
999 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(data
->CM_stat_byamount
), PREFS
->stat_byamount
);
1000 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(data
->CM_stat_showrate
), PREFS
->stat_showrate
);
1001 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(data
->CM_stat_showdetail
), PREFS
->stat_showdetail
);
1002 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(data
->CM_budg_showdetail
), PREFS
->budg_showdetail
);
1005 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(data
->CM_euro_enable
), PREFS
->euro_active
);
1006 //gtk_combo_box_set_active(GTK_COMBO_BOX(data->CY_euro_preset), PREFS->euro_country);
1007 data
->country
= PREFS
->euro_country
;
1008 defpref_eurosetcurrency(data
->window
, data
->country
);
1009 gtk_spin_button_set_value(GTK_SPIN_BUTTON(data
->NB_euro_value
), PREFS
->euro_value
);
1010 ui_gtk_entry_set_text(data
->ST_euro_symbol
, PREFS
->minor_cur
.symbol
);
1011 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(data
->CM_euro_isprefix
), PREFS
->minor_cur
.sym_prefix
);
1012 ui_gtk_entry_set_text(data
->ST_euro_decimalchar
, PREFS
->minor_cur
.decimal_char
);
1013 ui_gtk_entry_set_text(data
->ST_euro_groupingchar
, PREFS
->minor_cur
.grouping_char
);
1014 gtk_spin_button_set_value(GTK_SPIN_BUTTON(data
->NB_euro_fracdigits
), PREFS
->minor_cur
.frac_digits
);
1016 //gtk_entry_set_text(GTK_ENTRY(data->ST_euro_symbol), PREFS->euro_symbol);
1017 //gtk_spin_button_set_value(GTK_SPIN_BUTTON(data->NB_euro_nbdec), PREFS->euro_nbdec);
1018 //gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(data->CM_euro_thsep), PREFS->euro_thsep);
1023 ** get :: fill PREFS structure from widgets
1025 #define RGBA_TO_INT(x) (int)(x*255)
1027 static gchar
*gdk_rgba_to_hex(GdkRGBA
*rgba
)
1029 return g_strdup_printf("#%02x%02x%02x", RGBA_TO_INT(rgba
->red
), RGBA_TO_INT(rgba
->green
), RGBA_TO_INT(rgba
->blue
));
1033 static void defpref_get(struct defpref_data
*data
)
1038 DB( g_print("\n[ui-pref] get\n") );
1041 PREFS
->showsplash
= gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(data
->CM_show_splash
));
1042 PREFS
->loadlast
= gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(data
->CM_load_last
));
1043 PREFS
->appendscheduled
= gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(data
->CM_append_scheduled
));
1044 PREFS
->do_update_currency
= gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(data
->CM_do_update_currency
));
1045 PREFS
->date_range_wal
= hbtk_combo_box_get_active_id(GTK_COMBO_BOX_TEXT(data
->CY_daterange_wal
));
1046 PREFS
->fisc_year_day
= gtk_spin_button_get_value(GTK_SPIN_BUTTON(data
->NB_fiscyearday
));
1047 PREFS
->fisc_year_month
= 1 + gtk_combo_box_get_active(GTK_COMBO_BOX(data
->CY_fiscyearmonth
));
1050 ui_gtk_entry_replace_text(data
->ST_path_hbfile
, &PREFS
->path_hbfile
);
1052 PREFS
->bak_is_automatic
= gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(data
->CM_bak_is_automatic
));
1053 PREFS
->bak_max_num_copies
= gtk_spin_button_get_value(GTK_SPIN_BUTTON(data
->NB_bak_max_num_copies
));
1055 g_free(PREFS
->language
);
1056 PREFS
->language
= NULL
;
1057 lang
= gtk_combo_box_get_active_id(GTK_COMBO_BOX(data
->CY_language
));
1060 PREFS
->language
= g_strdup(lang
);
1063 PREFS
->toolbar_style
= gtk_combo_box_get_active(GTK_COMBO_BOX(data
->CY_toolbar
));
1064 //PREFS->image_size = gtk_spin_button_get_value(GTK_SPIN_BUTTON(data->NB_image_size));
1066 PREFS
->custom_colors
= gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(data
->CM_custom_colors
));
1067 gtk_color_chooser_get_rgba(GTK_COLOR_CHOOSER(data
->CP_exp_color
), &rgba
);
1068 g_free(PREFS
->color_exp
);
1069 PREFS
->color_exp
= gdk_rgba_to_hex(&rgba
);
1070 gtk_color_chooser_get_rgba(GTK_COLOR_CHOOSER(data
->CP_inc_color
), &rgba
);
1071 g_free(PREFS
->color_inc
);
1072 PREFS
->color_inc
= gdk_rgba_to_hex(&rgba
);
1073 gtk_color_chooser_get_rgba(GTK_COLOR_CHOOSER(data
->CP_warn_color
), &rgba
);
1074 g_free(PREFS
->color_warn
);
1075 PREFS
->color_warn
= gdk_rgba_to_hex(&rgba
);
1076 //PREFS->rules_hint = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(data->CM_ruleshint));
1077 PREFS
->grid_lines
= gtk_combo_box_get_active(GTK_COMBO_BOX(data
->CY_gridlines
));
1078 //list_txn_colpref_get(GTK_TREE_VIEW(data->LV_opecolumns), PREFS->lst_ope_columns);
1081 PREFS
->date_range_txn
= hbtk_combo_box_get_active_id(GTK_COMBO_BOX_TEXT(data
->CY_daterange_txn
));
1082 PREFS
->date_future_nbdays
= gtk_spin_button_get_value(GTK_SPIN_BUTTON(data
->ST_datefuture_nbdays
));
1083 PREFS
->hidereconciled
= gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(data
->CM_hide_reconciled
));
1084 PREFS
->showremind
= gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(data
->CM_show_remind
));
1085 PREFS
->heritdate
= gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(data
->CM_herit_date
));
1086 PREFS
->txn_memoacp
= gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(data
->CM_memoacp
));
1087 PREFS
->txn_memoacp_days
= gtk_spin_button_get_value(GTK_SPIN_BUTTON(data
->ST_memoacp_days
));
1090 g_free(PREFS
->date_format
);
1091 PREFS
->date_format
= g_strdup(gtk_entry_get_text(GTK_ENTRY(data
->ST_datefmt
)));
1092 PREFS
->vehicle_unit_ismile
= gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(data
->CM_unitismile
));
1093 PREFS
->vehicle_unit_isgal
= gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(data
->CM_unitisgal
));
1096 PREFS
->dtex_datefmt
= gtk_combo_box_get_active(GTK_COMBO_BOX(data
->CY_dtex_datefmt
));
1097 PREFS
->dtex_ucfirst
= gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(data
->CM_dtex_ucfirst
));
1098 PREFS
->dtex_ofxname
= gtk_combo_box_get_active(GTK_COMBO_BOX(data
->CY_dtex_ofxname
));
1099 PREFS
->dtex_ofxmemo
= gtk_combo_box_get_active(GTK_COMBO_BOX(data
->CY_dtex_ofxmemo
));
1100 PREFS
->dtex_qifmemo
= gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(data
->CM_dtex_qifmemo
));
1101 PREFS
->dtex_qifswap
= gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(data
->CM_dtex_qifswap
));
1102 ui_gtk_entry_replace_text(data
->ST_path_import
, &PREFS
->path_import
);
1103 ui_gtk_entry_replace_text(data
->ST_path_export
, &PREFS
->path_export
);
1104 PREFS
->dtex_csvsep
= gtk_combo_box_get_active(GTK_COMBO_BOX(data
->CY_dtex_csvsep
));
1107 PREFS
->date_range_rep
= hbtk_combo_box_get_active_id(GTK_COMBO_BOX_TEXT(data
->CY_daterange_rep
));
1108 PREFS
->report_color_scheme
= gtk_combo_box_get_active(GTK_COMBO_BOX(data
->CY_color_scheme
));
1109 PREFS
->stat_byamount
= gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(data
->CM_stat_byamount
));
1110 PREFS
->stat_showrate
= gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(data
->CM_stat_showrate
));
1111 PREFS
->stat_showdetail
= gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(data
->CM_stat_showdetail
));
1112 PREFS
->budg_showdetail
= gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(data
->CM_budg_showdetail
));
1115 PREFS
->euro_active
= gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(data
->CM_euro_enable
));
1116 PREFS
->euro_country
= data
->country
;
1117 PREFS
->euro_value
= gtk_spin_button_get_value(GTK_SPIN_BUTTON(data
->NB_euro_value
));
1118 //strcpy(PREFS->euro_symbol, gtk_entry_get_text(GTK_ENTRY(data->ST_euro_symbol)));
1119 //PREFS->euro_nbdec = gtk_spin_button_get_value(GTK_SPIN_BUTTON(data->NB_euro_nbdec));
1120 //PREFS->euro_thsep = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(data->CM_euro_thsep));
1121 ui_gtk_entry_replace_text(data
->ST_euro_symbol
, &PREFS
->minor_cur
.symbol
);
1122 PREFS
->minor_cur
.sym_prefix
= gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(data
->CM_euro_isprefix
));
1123 ui_gtk_entry_replace_text(data
->ST_euro_decimalchar
, &PREFS
->minor_cur
.decimal_char
);
1124 ui_gtk_entry_replace_text(data
->ST_euro_groupingchar
, &PREFS
->minor_cur
.grouping_char
);
1125 PREFS
->minor_cur
.frac_digits
= gtk_spin_button_get_value(GTK_SPIN_BUTTON(data
->NB_euro_fracdigits
));
1126 //PREFS->chart_legend = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(data->CM_chartlegend));
1128 list_ext_colpref_get(GTK_TREE_VIEW(data
->PI_plugin_columns
), &(PREFS
->ext_whitelist
));
1132 static GtkWidget
*defpref_page_import (struct defpref_data
*data
)
1134 GtkWidget
*content_grid
, *group_grid
, *label
, *widget
;
1137 content_grid
= gtk_grid_new();
1138 gtk_grid_set_row_spacing (GTK_GRID (content_grid
), SPACING_LARGE
);
1139 gtk_orientable_set_orientation(GTK_ORIENTABLE(content_grid
), GTK_ORIENTATION_VERTICAL
);
1142 // group :: Date options
1143 group_grid
= gtk_grid_new ();
1144 gtk_grid_set_row_spacing (GTK_GRID (group_grid
), SPACING_SMALL
);
1145 gtk_grid_set_column_spacing (GTK_GRID (group_grid
), SPACING_MEDIUM
);
1146 gtk_grid_attach (GTK_GRID (content_grid
), group_grid
, 0, crow
++, 1, 1);
1148 label
= make_label_group(_("General options"));
1149 gtk_grid_attach (GTK_GRID (group_grid
), label
, 0, 0, 3, 1);
1152 label
= make_label_widget(_("Date order:"));
1153 //----------------------------------------- l, r, t, b
1154 gtk_grid_attach (GTK_GRID (group_grid
), label
, 1, row
, 1, 1);
1155 widget
= make_cycle(label
, CYA_IMPORT_DATEORDER
);
1156 data
->CY_dtex_datefmt
= widget
;
1157 //gtk_grid_attach (GTK_GRID (group_grid), data->CY_option[FILTER_DATE], 1, 2, row, row+1);
1158 gtk_grid_attach (GTK_GRID (group_grid
), widget
, 2, row
, 1, 1);
1161 widget
= gtk_check_button_new_with_mnemonic (_("Sentence _case memo/payee"));
1162 data
->CM_dtex_ucfirst
= widget
;
1163 gtk_grid_attach (GTK_GRID (group_grid
), widget
, 1, row
, 2, 1);
1166 // group :: OFX/QFX options
1167 group_grid
= gtk_grid_new ();
1168 gtk_grid_set_row_spacing (GTK_GRID (group_grid
), SPACING_SMALL
);
1169 gtk_grid_set_column_spacing (GTK_GRID (group_grid
), SPACING_MEDIUM
);
1170 gtk_grid_attach (GTK_GRID (content_grid
), group_grid
, 0, crow
++, 1, 1);
1172 label
= make_label_group(_("OFX/QFX options"));
1173 gtk_grid_attach (GTK_GRID (group_grid
), label
, 0, 0, 3, 1);
1176 label
= make_label_widget(_("OFX _Name:"));
1177 //----------------------------------------- l, r, t, b
1178 gtk_grid_attach (GTK_GRID (group_grid
), label
, 1, row
, 1, 1);
1179 widget
= make_cycle(label
, CYA_IMPORT_OFXNAME
);
1180 data
->CY_dtex_ofxname
= widget
;
1181 //gtk_grid_attach (GTK_GRID (group_grid), data->CY_option[FILTER_DATE], 1, 2, row, row+1);
1182 gtk_grid_attach (GTK_GRID (group_grid
), widget
, 2, row
, 1, 1);
1185 label
= make_label_widget(_("OFX _Memo:"));
1186 //----------------------------------------- l, r, t, b
1187 gtk_grid_attach (GTK_GRID (group_grid
), label
, 1, row
, 1, 1);
1188 widget
= make_cycle(label
, CYA_IMPORT_OFXMEMO
);
1189 data
->CY_dtex_ofxmemo
= widget
;
1190 //gtk_grid_attach (GTK_GRID (group_grid), data->CY_option[FILTER_DATE], 1, 2, row, row+1);
1191 gtk_grid_attach (GTK_GRID (group_grid
), widget
, 2, row
, 1, 1);
1193 // group :: QIF options
1194 group_grid
= gtk_grid_new ();
1195 gtk_grid_set_row_spacing (GTK_GRID (group_grid
), SPACING_SMALL
);
1196 gtk_grid_set_column_spacing (GTK_GRID (group_grid
), SPACING_MEDIUM
);
1197 gtk_grid_attach (GTK_GRID (content_grid
), group_grid
, 0, crow
++, 1, 1);
1199 label
= make_label_group(_("QIF options"));
1200 gtk_grid_attach (GTK_GRID (group_grid
), label
, 0, 0, 3, 1);
1203 widget
= gtk_check_button_new_with_mnemonic (_("_Import memos"));
1204 data
->CM_dtex_qifmemo
= widget
;
1205 gtk_grid_attach (GTK_GRID (group_grid
), widget
, 1, row
, 1, 1);
1206 widget
= gtk_check_button_new_with_mnemonic (_("_Swap memos with payees"));
1207 data
->CM_dtex_qifswap
= widget
;
1208 gtk_grid_attach (GTK_GRID (group_grid
), widget
, 2, row
, 1, 1);
1210 // group :: other options
1211 group_grid
= gtk_grid_new ();
1212 gtk_grid_set_row_spacing (GTK_GRID (group_grid
), SPACING_SMALL
);
1213 gtk_grid_set_column_spacing (GTK_GRID (group_grid
), SPACING_MEDIUM
);
1214 gtk_grid_attach (GTK_GRID (content_grid
), group_grid
, 0, crow
++, 1, 1);
1216 label
= make_label_group(_("CSV options"));
1217 gtk_grid_attach (GTK_GRID (group_grid
), label
, 0, 0, 3, 1);
1220 label
= make_label(_("(transaction import only)"), 0.0, 0.5);
1221 gtk_grid_attach (GTK_GRID (group_grid
), label
, 1, row
, 2, 1);
1224 label
= make_label_widget(_("Separator:"));
1225 //----------------------------------------- l, r, t, b
1226 gtk_grid_attach (GTK_GRID (group_grid
), label
, 1, row
, 1, 1);
1227 widget
= make_cycle(label
, CYA_IMPORT_CSVSEPARATOR
);
1228 data
->CY_dtex_csvsep
= widget
;
1229 gtk_grid_attach (GTK_GRID (group_grid
), widget
, 2, row
, 1, 1);
1231 return content_grid
;
1237 draw_callback (GtkWidget
*widget
,
1241 struct defpref_data
*data
= user_data
;
1243 GtkColorScheme scheme
;
1247 index
= gtk_combo_box_get_active(GTK_COMBO_BOX(data
->CY_color_scheme
));
1249 colorscheme_init(&scheme
, index
);
1251 gtk_widget_get_size_request (widget
, &w
, &h
);
1253 for(i
=0;i
<scheme
.nb_cols
;i
++)
1255 cairo_user_set_rgbcol (cr
, &scheme
.colors
[i
]);
1256 cairo_rectangle(cr
, x
, y
, cube_dim
, cube_dim
);
1260 { x
= 0; y
= 1 + cube_dim
; }
1268 static GtkWidget
*defpref_page_reports (struct defpref_data
*data
)
1270 GtkWidget
*content_grid
, *group_grid
, *label
, *widget
;
1273 content_grid
= gtk_grid_new();
1274 gtk_grid_set_row_spacing (GTK_GRID (content_grid
), SPACING_LARGE
);
1275 gtk_orientable_set_orientation(GTK_ORIENTABLE(content_grid
), GTK_ORIENTATION_VERTICAL
);
1278 // group :: Initial filter
1279 group_grid
= gtk_grid_new ();
1280 gtk_grid_set_row_spacing (GTK_GRID (group_grid
), SPACING_SMALL
);
1281 gtk_grid_set_column_spacing (GTK_GRID (group_grid
), SPACING_MEDIUM
);
1282 gtk_grid_attach (GTK_GRID (content_grid
), group_grid
, 0, crow
++, 1, 1);
1284 label
= make_label_group(_("Initial filter"));
1285 gtk_grid_attach (GTK_GRID (group_grid
), label
, 0, 0, 3, 1);
1288 label
= make_label_widget(_("_Range:"));
1289 //----------------------------------------- l, r, t, b
1290 gtk_grid_attach (GTK_GRID (group_grid
), label
, 1, row
, 1, 1);
1291 widget
= make_daterange(label
, DATE_RANGE_CUSTOM_HIDE
);
1292 data
->CY_daterange_rep
= widget
;
1293 //gtk_grid_attach (GTK_GRID (group_grid), data->CY_option[FILTER_DATE], 1, 2, row, row+1);
1294 gtk_grid_attach (GTK_GRID (group_grid
), widget
, 2, row
, 1, 1);
1296 // group ::Charts options
1297 group_grid
= gtk_grid_new ();
1298 gtk_grid_set_row_spacing (GTK_GRID (group_grid
), SPACING_SMALL
);
1299 gtk_grid_set_column_spacing (GTK_GRID (group_grid
), SPACING_MEDIUM
);
1300 gtk_grid_attach (GTK_GRID (content_grid
), group_grid
, 0, crow
++, 1, 1);
1302 label
= make_label_group(_("Charts options"));
1303 gtk_grid_attach (GTK_GRID (group_grid
), label
, 0, 0, 3, 1);
1306 label
= make_label_widget(_("Color scheme:"));
1307 //----------------------------------------- l, r, t, b
1308 gtk_grid_attach (GTK_GRID (group_grid
), label
, 1, row
, 1, 1);
1309 widget
= make_cycle(label
, chart_colors
);
1310 data
->CY_color_scheme
= widget
;
1311 //gtk_grid_attach (GTK_GRID (group_grid), data->CY_option[FILTER_DATE], 1, 2, row, row+1);
1312 gtk_grid_attach (GTK_GRID (group_grid
), widget
, 2, row
, 1, 1);
1315 widget
= gtk_drawing_area_new ();
1316 data
->DA_colors
= widget
;
1317 gtk_widget_set_size_request (widget
, (1+cube_dim
)*16, (1+cube_dim
)*2);
1318 gtk_grid_attach (GTK_GRID (group_grid
), widget
, 2, row
, 1, 1);
1320 g_signal_connect (data
->DA_colors
, "draw", G_CALLBACK (draw_callback
), data
);
1322 // group :: Statistics options
1323 group_grid
= gtk_grid_new ();
1324 gtk_grid_set_row_spacing (GTK_GRID (group_grid
), SPACING_SMALL
);
1325 gtk_grid_set_column_spacing (GTK_GRID (group_grid
), SPACING_MEDIUM
);
1326 gtk_grid_attach (GTK_GRID (content_grid
), group_grid
, 0, crow
++, 1, 1);
1328 label
= make_label_group(_("Statistics options"));
1329 gtk_grid_attach (GTK_GRID (group_grid
), label
, 0, 0, 3, 1);
1332 widget
= gtk_check_button_new_with_mnemonic (_("Show by _amount"));
1333 data
->CM_stat_byamount
= widget
;
1334 gtk_grid_attach (GTK_GRID (group_grid
), widget
, 1, row
, 2, 1);
1337 widget
= gtk_check_button_new_with_mnemonic (_("Show _rate column"));
1338 data
->CM_stat_showrate
= widget
;
1339 gtk_grid_attach (GTK_GRID (group_grid
), widget
, 1, row
, 2, 1);
1342 widget
= gtk_check_button_new_with_mnemonic (_("Show _details"));
1343 data
->CM_stat_showdetail
= widget
;
1344 gtk_grid_attach (GTK_GRID (group_grid
), widget
, 1, row
, 2, 1);
1346 // group :: Budget options
1347 group_grid
= gtk_grid_new ();
1348 gtk_grid_set_row_spacing (GTK_GRID (group_grid
), SPACING_SMALL
);
1349 gtk_grid_set_column_spacing (GTK_GRID (group_grid
), SPACING_MEDIUM
);
1350 gtk_grid_attach (GTK_GRID (content_grid
), group_grid
, 0, crow
++, 1, 1);
1352 label
= make_label_group(_("Budget options"));
1353 gtk_grid_attach (GTK_GRID (group_grid
), label
, 0, 0, 3, 1);
1356 widget
= gtk_check_button_new_with_mnemonic (_("Show _details"));
1357 data
->CM_budg_showdetail
= widget
;
1358 gtk_grid_attach (GTK_GRID (group_grid
), widget
, 1, row
, 2, 1);
1360 return content_grid
;
1364 static GtkWidget
*defpref_page_euro (struct defpref_data
*data
)
1366 GtkWidget
*content_grid
, *group_grid
, *label
, *widget
, *expander
;
1369 content_grid
= gtk_grid_new();
1370 gtk_grid_set_row_spacing (GTK_GRID (content_grid
), SPACING_LARGE
);
1371 gtk_orientable_set_orientation(GTK_ORIENTABLE(content_grid
), GTK_ORIENTATION_VERTICAL
);
1375 group_grid
= gtk_grid_new ();
1376 gtk_grid_set_row_spacing (GTK_GRID (group_grid
), SPACING_SMALL
);
1377 gtk_grid_set_column_spacing (GTK_GRID (group_grid
), SPACING_MEDIUM
);
1378 gtk_grid_attach (GTK_GRID (content_grid
), group_grid
, 0, crow
++, 1, 1);
1380 label
= make_label_group(_("General"));
1381 gtk_grid_attach (GTK_GRID (group_grid
), label
, 0, 0, 3, 1);
1384 widget
= gtk_check_button_new_with_mnemonic (_("_Enable"));
1385 data
->CM_euro_enable
= widget
;
1386 gtk_grid_attach (GTK_GRID (group_grid
), widget
, 1, row
, 2, 1);
1388 // group :: Currency
1389 group_grid
= gtk_grid_new ();
1390 data
->GRP_currency
= group_grid
;
1391 gtk_grid_set_row_spacing (GTK_GRID (group_grid
), SPACING_SMALL
);
1392 gtk_grid_set_column_spacing (GTK_GRID (group_grid
), SPACING_MEDIUM
);
1393 gtk_grid_attach (GTK_GRID (content_grid
), group_grid
, 0, crow
++, 1, 1);
1395 label
= make_label_group(_("Currency"));
1396 gtk_grid_attach (GTK_GRID (group_grid
), label
, 0, 0, 4, 1);
1399 widget
= make_label(NULL
, 0.0, 0.5);
1400 data
->ST_euro_country
= widget
;
1401 //gtk_grid_attach (GTK_GRID (group_grid), data->CY_option[FILTER_DATE], 1, 2, row, row+1);
1402 gtk_grid_attach (GTK_GRID (group_grid
), widget
, 1, row
, 1, 1);
1405 label
= make_label_widget(_("_Preset:"));
1406 //----------------------------------------- l, r, t, b
1407 gtk_grid_attach (GTK_GRID (group_grid
), label
, 2, row
, 1, 1);
1408 widget
= ui_euro_combobox_new (label
);
1409 data
->CY_euro_preset
= widget
;
1410 gtk_widget_set_margin_left (label
, 2*SPACING_LARGE
);
1411 //gtk_grid_attach (GTK_GRID (group_grid), data->CY_option[FILTER_DATE], 1, 2, row, row+1);
1412 gtk_grid_attach (GTK_GRID (group_grid
), widget
, 3, row
, 1, 1);
1415 // group :: Exchange rate
1416 group_grid
= gtk_grid_new ();
1417 data
->GRP_rate
= group_grid
;
1418 gtk_grid_set_row_spacing (GTK_GRID (group_grid
), SPACING_SMALL
);
1419 gtk_grid_set_column_spacing (GTK_GRID (group_grid
), SPACING_MEDIUM
);
1420 gtk_grid_attach (GTK_GRID (content_grid
), group_grid
, 0, crow
++, 1, 1);
1422 label
= make_label_group(_("Exchange rate"));
1423 gtk_grid_attach (GTK_GRID (group_grid
), label
, 0, 0, 3, 1);
1426 label
= make_label_widget("1 EUR _=");
1427 gtk_grid_attach (GTK_GRID (group_grid
), label
, 1, row
, 1, 1);
1428 widget
= make_exchange_rate(label
);
1429 data
->NB_euro_value
= widget
;
1430 //gtk_grid_attach (GTK_GRID (group_grid), data->CY_option[FILTER_DATE], 1, 2, row, row+1);
1431 gtk_grid_attach (GTK_GRID (group_grid
), widget
, 2, row
, 1, 1);
1433 // group :: Numbers format
1434 group_grid
= gtk_grid_new ();
1435 data
->GRP_format
= group_grid
;
1436 gtk_grid_set_row_spacing (GTK_GRID (group_grid
), SPACING_SMALL
);
1437 gtk_grid_set_column_spacing (GTK_GRID (group_grid
), SPACING_MEDIUM
);
1438 gtk_grid_attach (GTK_GRID (content_grid
), group_grid
, 0, crow
++, 1, 1);
1440 label
= make_label_group(_("Format"));
1441 gtk_grid_attach (GTK_GRID (group_grid
), label
, 0, 0, 3, 1);
1444 widget
= make_label(NULL
, 0, 0.0);
1445 data
->LB_numbereuro
= widget
;
1446 gtk_grid_attach (GTK_GRID (group_grid
), widget
, 1, row
, 1, 1);
1449 expander
= gtk_expander_new_with_mnemonic(_("_Customize"));
1450 gtk_grid_attach (GTK_GRID (group_grid
), expander
, 1, row
, 1, 1);
1452 group_grid
= gtk_grid_new ();
1453 gtk_grid_set_row_spacing (GTK_GRID (group_grid
), SPACING_SMALL
);
1454 gtk_grid_set_column_spacing (GTK_GRID (group_grid
), SPACING_MEDIUM
);
1455 gtk_container_add (GTK_CONTAINER (expander
), group_grid
);
1458 label
= make_label_widget(_("_Symbol:"));
1459 gtk_grid_attach (GTK_GRID (group_grid
), label
, 1, row
, 1, 1);
1460 widget
= make_string_maxlength(label
, 3);
1461 data
->ST_euro_symbol
= widget
;
1462 gtk_grid_attach (GTK_GRID (group_grid
), widget
, 2, row
, 1, 1);
1465 widget
= gtk_check_button_new_with_mnemonic (_("Is pre_fix"));
1466 data
->CM_euro_isprefix
= widget
;
1467 gtk_grid_attach (GTK_GRID (group_grid
), widget
, 2, row
, 1, 1);
1470 label
= make_label_widget(_("_Decimal char:"));
1471 gtk_grid_attach (GTK_GRID (group_grid
), label
, 1, row
, 1, 1);
1472 widget
= make_string_maxlength(label
, 1);
1473 data
->ST_euro_decimalchar
= widget
;
1474 gtk_grid_attach (GTK_GRID (group_grid
), widget
, 2, row
, 1, 1);
1477 label
= make_label_widget(_("_Frac digits:"));
1478 gtk_grid_attach (GTK_GRID (group_grid
), label
, 1, row
, 1, 1);
1479 widget
= make_numeric(label
, 0.0, 6.0);
1480 data
->NB_euro_fracdigits
= widget
;
1481 gtk_grid_attach (GTK_GRID (group_grid
), widget
, 2, row
, 1, 1);
1484 label
= make_label_widget(_("_Grouping char:"));
1485 gtk_grid_attach (GTK_GRID (group_grid
), label
, 1, row
, 1, 1);
1486 widget
= make_string_maxlength(label
, 1);
1487 data
->ST_euro_groupingchar
= widget
;
1488 gtk_grid_attach (GTK_GRID (group_grid
), widget
, 2, row
, 1, 1);
1490 return content_grid
;
1494 static GtkWidget
*defpref_page_display (struct defpref_data
*data
)
1496 GtkWidget
*content_grid
, *group_grid
, *label
, *widget
, *expander
, *hbox
;
1499 content_grid
= gtk_grid_new();
1500 gtk_grid_set_row_spacing (GTK_GRID (content_grid
), SPACING_LARGE
);
1501 gtk_orientable_set_orientation(GTK_ORIENTABLE(content_grid
), GTK_ORIENTATION_VERTICAL
);
1505 group_grid
= gtk_grid_new ();
1506 gtk_grid_set_row_spacing (GTK_GRID (group_grid
), SPACING_SMALL
);
1507 gtk_grid_set_column_spacing (GTK_GRID (group_grid
), SPACING_MEDIUM
);
1508 gtk_grid_attach (GTK_GRID (content_grid
), group_grid
, 0, crow
++, 1, 1);
1510 label
= make_label_group(_("User interface"));
1511 gtk_grid_attach (GTK_GRID (group_grid
), label
, 0, 0, 3, 1);
1514 label
= make_label(_("_Language:"), 0, 0.5);
1515 gtk_grid_attach (GTK_GRID (group_grid
), label
, 1, row
, 1, 1);
1516 widget
= ui_language_combobox_new(label
);
1517 data
->CY_language
= widget
;
1518 gtk_grid_attach (GTK_GRID (group_grid
), widget
, 2, row
, 1, 1);
1522 label
= make_label(_("_Date display:"), 0, 0.5);
1523 gtk_grid_attach (GTK_GRID (group_grid
), label
, 1, row
, 1, 1);
1524 widget
= make_label(NULL
, 0, 0.5);
1525 data
->LB_date
= widget
;
1526 gtk_grid_attach (GTK_GRID (group_grid
), widget
, 2, row
, 1, 1);
1529 expander
= gtk_expander_new_with_mnemonic(_("_Customize"));
1530 gtk_grid_attach (GTK_GRID (group_grid
), expander
, 2, row
, 1, 1);
1532 group_grid
= gtk_grid_new ();
1533 gtk_grid_set_row_spacing (GTK_GRID (group_grid
), SPACING_SMALL
);
1534 gtk_grid_set_column_spacing (GTK_GRID (group_grid
), SPACING_MEDIUM
);
1535 gtk_container_add (GTK_CONTAINER (expander
), group_grid
);
1538 label
= make_label_widget(_("_Format:"));
1539 //----------------------------------------- l, r, t, b
1540 gtk_grid_attach (GTK_GRID (group_grid
), label
, 1, row
, 1, 1);
1541 widget
= make_string(label
);
1542 data
->ST_datefmt
= widget
;
1543 //gtk_grid_attach (GTK_GRID (group_grid), data->CY_option[FILTER_DATE], 1, 2, row, row+1);
1544 gtk_grid_attach (GTK_GRID (group_grid
), widget
, 2, row
, 1, 1);
1546 widget
= gtk_image_new_from_icon_name (ICONNAME_INFO
, GTK_ICON_SIZE_BUTTON
);
1547 gtk_grid_attach (GTK_GRID (group_grid
), widget
, 3, row
, 1, 1);
1550 gtk_widget_set_tooltip_text(widget
,
1551 _("%a locale's abbreviated weekday name.\n"
1552 "%A locale's full weekday name. \n"
1553 "%b locale's abbreviated month name. \n"
1554 "%B locale's full month name. \n"
1555 "%c locale's appropriate date and time representation. \n"
1556 "%C century number (the year divided by 100 and truncated to an integer) as a decimal number [00-99]. \n"
1557 "%d day of the month as a decimal number [01,31]. \n"
1558 "%D same as %m/%d/%y. \n"
1559 "%e day of the month as a decimal number [1,31]; a single digit is preceded by a space. \n"
1560 "%j day of the year as a decimal number [001,366]. \n"
1561 "%m month as a decimal number [01,12]. \n"
1562 "%p locale's appropriate date representation. \n"
1563 "%y year without century as a decimal number [00,99]. \n"
1564 "%Y year with century as a decimal number.")
1568 widget
= make_label(NULL
, 0.0, 0.5);
1569 gtk_label_set_markup (GTK_LABEL(widget
), "<small><a href=\"http://man7.org/linux/man-pages/man3/strftime.3.html\">online reference</a></small>");
1570 gtk_grid_attach (GTK_GRID (group_grid
), widget
, 2, row
, 1, 1);
1575 // group :: Fiscal year
1576 group_grid
= gtk_grid_new ();
1577 gtk_grid_set_row_spacing (GTK_GRID (group_grid
), SPACING_SMALL
);
1578 gtk_grid_set_column_spacing (GTK_GRID (group_grid
), SPACING_MEDIUM
);
1579 gtk_grid_attach (GTK_GRID (content_grid
), group_grid
, 0, crow
++, 1, 1);
1581 label
= make_label_group(_("Fiscal year"));
1582 gtk_grid_attach (GTK_GRID (group_grid
), label
, 0, 0, 3, 1);
1585 //TRANSLATORS: (fiscal year) starts on
1586 label
= make_label_widget(_("Starts _on:"));
1587 gtk_grid_attach (GTK_GRID (group_grid
), label
, 1, row
, 1, 1);
1589 hbox
= gtk_box_new(GTK_ORIENTATION_HORIZONTAL
, SPACING_SMALL
);
1590 gtk_grid_attach (GTK_GRID (group_grid
), hbox
, 2, row
, 1, 1);
1591 widget
= make_numeric (label
, 1, 28);
1592 data
->NB_fiscyearday
= widget
;
1593 gtk_box_pack_start (GTK_BOX (hbox
), widget
, FALSE
, FALSE
, 0);
1594 widget
= make_cycle (NULL
, CYA_MONTHS
);
1595 data
->CY_fiscyearmonth
= widget
;
1596 gtk_box_pack_start (GTK_BOX (hbox
), widget
, FALSE
, FALSE
, 0);
1600 // group :: Measurement units
1601 group_grid
= gtk_grid_new ();
1602 gtk_grid_set_row_spacing (GTK_GRID (group_grid
), SPACING_SMALL
);
1603 gtk_grid_set_column_spacing (GTK_GRID (group_grid
), SPACING_MEDIUM
);
1604 gtk_grid_attach (GTK_GRID (content_grid
), group_grid
, 0, crow
++, 1, 1);
1606 label
= make_label_group(_("Measurement units"));
1607 gtk_grid_attach (GTK_GRID (group_grid
), label
, 0, 0, 3, 1);
1610 widget
= gtk_check_button_new_with_mnemonic (_("Use _miles for meter"));
1611 data
->CM_unitismile
= widget
;
1612 gtk_grid_attach (GTK_GRID (group_grid
), widget
, 1, row
, 2, 1);
1615 widget
= gtk_check_button_new_with_mnemonic (_("Use _gallon for fuel"));
1616 data
->CM_unitisgal
= widget
;
1617 gtk_grid_attach (GTK_GRID (group_grid
), widget
, 1, row
, 2, 1);
1619 return content_grid
;
1623 static GtkWidget
*defpref_page_transactions (struct defpref_data
*data
)
1625 GtkWidget
*content_grid
, *group_grid
, *label
, *widget
;
1628 content_grid
= gtk_grid_new();
1629 gtk_grid_set_row_spacing (GTK_GRID (content_grid
), SPACING_LARGE
);
1630 gtk_orientable_set_orientation(GTK_ORIENTABLE(content_grid
), GTK_ORIENTATION_VERTICAL
);
1633 // group :: Transaction window
1634 group_grid
= gtk_grid_new ();
1635 gtk_grid_set_row_spacing (GTK_GRID (group_grid
), SPACING_SMALL
);
1636 gtk_grid_set_column_spacing (GTK_GRID (group_grid
), SPACING_MEDIUM
);
1637 gtk_grid_attach (GTK_GRID (content_grid
), group_grid
, 0, crow
++, 1, 1);
1639 label
= make_label_group(_("Transaction window"));
1640 gtk_grid_attach (GTK_GRID (group_grid
), label
, 0, 0, 3, 1);
1643 label
= make_label(_("_Range:"), 0, 0.5);
1644 //----------------------------------------- l, r, t, b
1645 gtk_grid_attach (GTK_GRID (group_grid
), label
, 1, row
, 1, 1);
1646 widget
= make_daterange(label
, DATE_RANGE_CUSTOM_HIDE
);
1647 data
->CY_daterange_txn
= widget
;
1648 gtk_grid_attach (GTK_GRID (group_grid
), widget
, 2, row
, 1, 1);
1651 label
= make_label(_("_Show future:"), 0, 0.5);
1652 //----------------------------------------- l, r, t, b
1653 gtk_grid_attach (GTK_GRID (group_grid
), label
, 1, row
, 1, 1);
1654 widget
= make_numeric(NULL
, 0, 366);
1656 data
->ST_datefuture_nbdays
= widget
;
1657 gtk_grid_attach (GTK_GRID (group_grid
), widget
, 2, row
, 1, 1);
1659 //TRANSLATORS: there is a spinner on the left of this label, and so you have 0....x days in advance the current date
1660 label
= make_label(_("days ahead"), 0, 0.5);
1661 gtk_grid_attach (GTK_GRID (group_grid
), label
, 3, row
, 1, 1);
1664 widget
= gtk_check_button_new_with_mnemonic (_("Hide reconciled transactions"));
1665 data
->CM_hide_reconciled
= widget
;
1666 gtk_grid_attach (GTK_GRID (group_grid
), widget
, 1, row
, 3, 1);
1669 widget
= gtk_check_button_new_with_mnemonic (_("Always show remind transactions"));
1670 data
->CM_show_remind
= widget
;
1671 gtk_grid_attach (GTK_GRID (group_grid
), widget
, 1, row
, 3, 1);
1673 // group :: Multiple add
1674 group_grid
= gtk_grid_new ();
1675 gtk_grid_set_row_spacing (GTK_GRID (group_grid
), SPACING_SMALL
);
1676 gtk_grid_set_column_spacing (GTK_GRID (group_grid
), SPACING_MEDIUM
);
1677 gtk_grid_attach (GTK_GRID (content_grid
), group_grid
, 0, crow
++, 1, 1);
1679 label
= make_label_group(_("Multiple add"));
1680 gtk_grid_attach (GTK_GRID (group_grid
), label
, 0, 0, 3, 1);
1683 widget
= gtk_check_button_new_with_mnemonic (_("Keep the last date"));
1684 data
->CM_herit_date
= widget
;
1685 gtk_grid_attach (GTK_GRID (group_grid
), widget
, 1, row
, 2, 1);
1687 // group :: Memo autocomplete
1688 group_grid
= gtk_grid_new ();
1689 gtk_grid_set_row_spacing (GTK_GRID (group_grid
), SPACING_SMALL
);
1690 gtk_grid_set_column_spacing (GTK_GRID (group_grid
), SPACING_MEDIUM
);
1691 gtk_grid_attach (GTK_GRID (content_grid
), group_grid
, 0, crow
++, 1, 1);
1693 label
= make_label_group(_("Memo autocomplete"));
1694 gtk_grid_attach (GTK_GRID (group_grid
), label
, 0, 0, 3, 1);
1697 widget
= gtk_check_button_new_with_mnemonic (_("Active"));
1698 data
->CM_memoacp
= widget
;
1699 gtk_grid_attach (GTK_GRID (group_grid
), widget
, 1, row
, 2, 1);
1702 widget
= make_numeric(NULL
, 0, 1460);
1703 data
->ST_memoacp_days
= widget
;
1704 gtk_grid_attach (GTK_GRID (group_grid
), widget
, 2, row
, 1, 1);
1705 label
= make_label(_("rolling days"), 0, 0.5);
1706 gtk_grid_attach (GTK_GRID (group_grid
), label
, 3, row
, 1, 1);
1708 // group :: Column list
1710 group_grid = gtk_grid_new ();
1711 gtk_grid_set_row_spacing (GTK_GRID (group_grid), SPACING_SMALL);
1712 gtk_grid_set_column_spacing (GTK_GRID (group_grid), SPACING_MEDIUM);
1713 gtk_grid_attach (GTK_GRID (content_grid), group_grid, 0, crow++, 1, 1);
1715 label = make_label_group(_("Column list"));
1716 gtk_grid_attach (GTK_GRID (group_grid), label, 0, 0, 3, 1);
1719 sw = gtk_scrolled_window_new (NULL, NULL);
1720 gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (sw), GTK_SHADOW_ETCHED_IN);
1721 gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (sw), GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC);
1722 widget = (GtkWidget *)list_txn_colprefcreate();
1723 data->LV_opecolumns = widget;
1724 gtk_widget_set_size_request(data->LV_opecolumns, HB_MINWIDTH_LIST, -1);
1725 gtk_container_add (GTK_CONTAINER (sw), widget);
1726 gtk_widget_set_vexpand (sw, TRUE);
1727 gtk_grid_attach (GTK_GRID (group_grid), sw, 1, row, 2, 1);
1728 gtk_widget_set_tooltip_text(widget, _("Drag & drop to change the order"));
1731 return content_grid
;
1736 static GtkWidget
*defpref_page_interface (struct defpref_data
*data
)
1738 GtkWidget
*content_grid
, *group_grid
, *hbox
, *label
, *widget
;
1741 content_grid
= gtk_grid_new();
1742 gtk_grid_set_row_spacing (GTK_GRID (content_grid
), SPACING_LARGE
);
1743 gtk_orientable_set_orientation(GTK_ORIENTABLE(content_grid
), GTK_ORIENTATION_VERTICAL
);
1747 group_grid
= gtk_grid_new ();
1748 gtk_grid_set_row_spacing (GTK_GRID (group_grid
), SPACING_SMALL
);
1749 gtk_grid_set_column_spacing (GTK_GRID (group_grid
), SPACING_MEDIUM
);
1750 gtk_grid_attach (GTK_GRID (content_grid
), group_grid
, 0, crow
++, 1, 1);
1752 label
= make_label_group(_("General"));
1753 gtk_grid_attach (GTK_GRID (group_grid
), label
, 0, 0, 3, 1);
1756 label
= make_label(_("_Toolbar:"), 0, 0.5);
1757 gtk_grid_attach (GTK_GRID (group_grid
), label
, 1, row
, 1, 1);
1758 widget
= make_cycle(label
, CYA_TOOLBAR_STYLE
);
1759 data
->CY_toolbar
= widget
;
1760 gtk_grid_attach (GTK_GRID (group_grid
), widget
, 2, row
, 1, 1);
1770 //widget = gtk_check_button_new_with_mnemonic (_("Enable rows in alternating colors"));
1771 //data->CM_ruleshint = widget;
1772 label
= make_label(_("_Grid line:"), 0, 0.5);
1773 gtk_grid_attach (GTK_GRID (group_grid
), label
, 1, row
, 1, 1);
1774 widget
= make_cycle(label
, CYA_GRID_LINES
);
1775 data
->CY_gridlines
= widget
;
1776 gtk_grid_attach (GTK_GRID (group_grid
), widget
, 2, row
, 1, 1);
1778 // group :: Amount colors
1779 group_grid
= gtk_grid_new ();
1780 gtk_grid_set_row_spacing (GTK_GRID (group_grid
), SPACING_SMALL
);
1781 gtk_grid_set_column_spacing (GTK_GRID (group_grid
), SPACING_MEDIUM
);
1782 gtk_grid_attach (GTK_GRID (content_grid
), group_grid
, 0, crow
++, 1, 1);
1784 label
= make_label_group(_("Amount colors"));
1785 gtk_grid_attach (GTK_GRID (group_grid
), label
, 0, 0, 3, 1);
1788 widget
= gtk_check_button_new_with_mnemonic (_("Uses custom colors"));
1789 data
->CM_custom_colors
= widget
;
1790 gtk_grid_attach (GTK_GRID (group_grid
), widget
, 1, row
, 2, 1);
1793 label
= make_label(_("_Preset:"), 0, 0.5);
1794 data
->LB_colors
= label
;
1795 //----------------------------------------- l, r, t, b
1796 gtk_grid_attach (GTK_GRID (group_grid
), label
, 1, row
, 1, 1);
1797 widget
= make_cycle(label
, CYA_TANGO_COLORS
);
1798 data
->CY_colors
= widget
;
1799 //gtk_grid_attach (GTK_GRID (group_grid), data->CY_option[FILTER_DATE], 1, 2, row, row+1);
1800 gtk_grid_attach (GTK_GRID (group_grid
), widget
, 2, row
, 1, 1);
1803 label
= make_label(_("_Expense:"), 0, 0.5);
1804 data
->LB_exp_color
= label
;
1805 //----------------------------------------- l, r, t, b
1806 gtk_grid_attach (GTK_GRID (group_grid
), label
, 1, row
, 1, 1);
1807 hbox
= gtk_box_new(GTK_ORIENTATION_HORIZONTAL
, SPACING_SMALL
);
1808 data
->GR_colors
= hbox
;
1809 gtk_grid_attach (GTK_GRID (group_grid
), hbox
, 2, row
, 1, 1);
1811 widget
= gtk_color_button_new ();
1812 data
->CP_exp_color
= widget
;
1813 gtk_box_pack_start (GTK_BOX (hbox
), widget
, FALSE
, FALSE
, 0);
1815 label
= make_label_widget(_("_Income:"));
1816 gtk_box_pack_start (GTK_BOX (hbox
), label
, FALSE
, FALSE
, 0);
1818 widget
= gtk_color_button_new ();
1819 data
->CP_inc_color
= widget
;
1820 gtk_box_pack_start (GTK_BOX (hbox
), widget
, FALSE
, FALSE
, 0);
1822 label
= make_label_widget(_("_Warning:"));
1823 gtk_box_pack_start (GTK_BOX (hbox
), label
, FALSE
, FALSE
, 0);
1825 widget
= gtk_color_button_new ();
1826 data
->CP_warn_color
= widget
;
1827 gtk_box_pack_start (GTK_BOX (hbox
), widget
, FALSE
, FALSE
, 0);
1829 return content_grid
;
1833 static GtkWidget
*defpref_page_filebackup (struct defpref_data
*data
)
1835 GtkWidget
*content_grid
, *group_grid
, *hbox
, *label
, *widget
;
1838 content_grid
= gtk_grid_new();
1839 gtk_grid_set_row_spacing (GTK_GRID (content_grid
), SPACING_LARGE
);
1840 gtk_orientable_set_orientation(GTK_ORIENTABLE(content_grid
), GTK_ORIENTATION_VERTICAL
);
1844 group_grid
= gtk_grid_new ();
1845 gtk_grid_set_row_spacing (GTK_GRID (group_grid
), SPACING_SMALL
);
1846 gtk_grid_set_column_spacing (GTK_GRID (group_grid
), SPACING_MEDIUM
);
1847 gtk_grid_attach (GTK_GRID (content_grid
), group_grid
, 0, crow
++, 1, 1);
1849 label
= make_label_group(_("Backup"));
1850 gtk_grid_attach (GTK_GRID (group_grid
), label
, 0, 0, 3, 1);
1853 widget
= gtk_check_button_new_with_mnemonic (_("_Enable automatic backups"));
1854 data
->CM_bak_is_automatic
= widget
;
1855 gtk_grid_attach (GTK_GRID (group_grid
), widget
, 1, row
, 2, 1);
1858 label
= make_label_widget(_("_Number of backups to keep:"));
1859 data
->LB_bak_max_num_copies
= label
;
1860 gtk_grid_attach (GTK_GRID (group_grid
), label
, 1, row
, 1, 1);
1861 widget
= make_numeric (label
, 1, 99);
1862 data
->NB_bak_max_num_copies
= widget
;
1863 gtk_grid_attach (GTK_GRID (group_grid
), widget
, 2, row
, 1, 1);
1866 hbox
= gtk_box_new(GTK_ORIENTATION_HORIZONTAL
, SPACING_SMALL
);
1867 data
->GR_bak_freq
= hbox
;
1868 //gtk_widget_set_hexpand (hbox, TRUE);
1869 gtk_grid_attach (GTK_GRID (group_grid
), hbox
, 1, row
, 2, 1);
1871 widget
= gtk_image_new_from_icon_name (ICONNAME_INFO
, GTK_ICON_SIZE_BUTTON
);
1872 gtk_box_pack_start (GTK_BOX (hbox
), widget
, FALSE
, FALSE
, 0);
1873 label
= make_label_widget(_("Backup frequency is once a day"));
1874 gtk_box_pack_start (GTK_BOX (hbox
), label
, FALSE
, FALSE
, 0);
1877 return content_grid
;
1881 static GtkWidget
*defpref_page_folders (struct defpref_data
*data
)
1883 GtkWidget
*content_grid
, *group_grid
, *hbox
, *label
, *widget
;
1886 content_grid
= gtk_grid_new();
1887 gtk_grid_set_row_spacing (GTK_GRID (content_grid
), SPACING_LARGE
);
1888 gtk_orientable_set_orientation(GTK_ORIENTABLE(content_grid
), GTK_ORIENTATION_VERTICAL
);
1891 // group :: Files folder
1892 group_grid
= gtk_grid_new ();
1893 gtk_grid_set_row_spacing (GTK_GRID (group_grid
), SPACING_SMALL
);
1894 gtk_grid_set_column_spacing (GTK_GRID (group_grid
), SPACING_MEDIUM
);
1895 gtk_grid_attach (GTK_GRID (content_grid
), group_grid
, 0, crow
++, 1, 1);
1897 label
= make_label_group(_("HomeBank files"));
1898 gtk_grid_attach (GTK_GRID (group_grid
), label
, 0, 0, 3, 1);
1901 label
= make_label_widget(_("_Wallets:"));
1902 gtk_grid_attach (GTK_GRID (group_grid
), label
, 1, row
, 1, 1);
1904 hbox
= gtk_box_new(GTK_ORIENTATION_HORIZONTAL
, 0);
1905 gtk_widget_set_hexpand (hbox
, TRUE
);
1906 gtk_grid_attach (GTK_GRID (group_grid
), hbox
, 2, row
, 1, 1);
1908 widget
= make_string(label
);
1909 data
->ST_path_hbfile
= widget
;
1910 gtk_style_context_add_class (gtk_widget_get_style_context (GTK_WIDGET(widget
)), GTK_STYLE_CLASS_LINKED
);
1911 gtk_box_pack_start (GTK_BOX (hbox
), widget
, TRUE
, TRUE
, 0);
1913 //widget = gtk_button_new_with_label("...");
1914 widget
= gtk_button_new_from_icon_name(ICONNAME_FOLDER
, GTK_ICON_SIZE_BUTTON
);
1915 data
->BT_path_hbfile
= widget
;
1916 gtk_box_pack_start (GTK_BOX (hbox
), widget
, FALSE
, FALSE
, 0);
1919 // group :: Files folder
1920 group_grid
= gtk_grid_new ();
1921 gtk_grid_set_row_spacing (GTK_GRID (group_grid
), SPACING_SMALL
);
1922 gtk_grid_set_column_spacing (GTK_GRID (group_grid
), SPACING_MEDIUM
);
1923 gtk_grid_attach (GTK_GRID (content_grid
), group_grid
, 0, crow
++, 1, 1);
1925 label
= make_label_group(_("Exchange files"));
1926 gtk_grid_attach (GTK_GRID (group_grid
), label
, 0, 0, 3, 1);
1929 label
= make_label_widget(_("_Import:"));
1930 //----------------------------------------- l, r, t, b
1931 gtk_grid_attach (GTK_GRID (group_grid
), label
, 1, row
, 1, 1);
1933 hbox
= gtk_box_new(GTK_ORIENTATION_HORIZONTAL
, 0);
1934 gtk_widget_set_hexpand (hbox
, TRUE
);
1935 gtk_grid_attach (GTK_GRID (group_grid
), hbox
, 2, row
, 1, 1);
1937 widget
= make_string(label
);
1938 data
->ST_path_import
= widget
;
1939 gtk_style_context_add_class (gtk_widget_get_style_context (GTK_WIDGET(widget
)), GTK_STYLE_CLASS_LINKED
);
1940 gtk_box_pack_start (GTK_BOX (hbox
), widget
, TRUE
, TRUE
, 0);
1942 //widget = gtk_button_new_with_label("...");
1943 widget
= gtk_button_new_from_icon_name(ICONNAME_FOLDER
, GTK_ICON_SIZE_BUTTON
);
1944 data
->BT_path_import
= widget
;
1945 gtk_box_pack_start (GTK_BOX (hbox
), widget
, FALSE
, FALSE
, 0);
1948 label
= make_label_widget(_("_Export:"));
1949 //----------------------------------------- l, r, t, b
1950 gtk_grid_attach (GTK_GRID (group_grid
), label
, 1, row
, 1, 1);
1952 hbox
= gtk_box_new(GTK_ORIENTATION_HORIZONTAL
, 0);
1953 gtk_widget_set_hexpand (hbox
, TRUE
);
1954 gtk_grid_attach (GTK_GRID (group_grid
), hbox
, 2, row
, 1, 1);
1956 widget
= make_string(label
);
1957 data
->ST_path_export
= widget
;
1958 gtk_style_context_add_class (gtk_widget_get_style_context (GTK_WIDGET(widget
)), GTK_STYLE_CLASS_LINKED
);
1959 gtk_box_pack_start (GTK_BOX (hbox
), widget
, TRUE
, TRUE
, 0);
1961 //widget = gtk_button_new_with_label("...");
1962 widget
= gtk_button_new_from_icon_name(ICONNAME_FOLDER
, GTK_ICON_SIZE_BUTTON
);
1963 data
->BT_path_export
= widget
;
1964 gtk_box_pack_start (GTK_BOX (hbox
), widget
, FALSE
, FALSE
, 0);
1968 return content_grid
;
1972 static GtkWidget
*defpref_page_general (struct defpref_data
*data
)
1974 GtkWidget
*content_grid
, *group_grid
, *label
, *widget
;
1977 content_grid
= gtk_grid_new();
1978 gtk_grid_set_row_spacing (GTK_GRID (content_grid
), SPACING_LARGE
);
1979 gtk_orientable_set_orientation(GTK_ORIENTABLE(content_grid
), GTK_ORIENTATION_VERTICAL
);
1982 // group :: Program start
1983 group_grid
= gtk_grid_new ();
1984 gtk_grid_set_row_spacing (GTK_GRID (group_grid
), SPACING_SMALL
);
1985 gtk_grid_set_column_spacing (GTK_GRID (group_grid
), SPACING_MEDIUM
);
1986 gtk_grid_attach (GTK_GRID (content_grid
), group_grid
, 0, crow
++, 1, 1);
1988 label
= make_label_group(_("Program start"));
1989 gtk_grid_attach (GTK_GRID (group_grid
), label
, 0, 0, 3, 1);
1992 widget
= gtk_check_button_new_with_mnemonic (_("Show splash screen"));
1993 data
->CM_show_splash
= widget
;
1994 gtk_grid_attach (GTK_GRID (group_grid
), widget
, 1, row
, 2, 1);
1997 widget
= gtk_check_button_new_with_mnemonic (_("Load last opened file"));
1998 data
->CM_load_last
= widget
;
1999 gtk_grid_attach (GTK_GRID (group_grid
), widget
, 1, row
, 2, 1);
2002 widget
= gtk_check_button_new_with_mnemonic (_("Post pending scheduled transactions"));
2003 data
->CM_append_scheduled
= widget
;
2004 gtk_grid_attach (GTK_GRID (group_grid
), widget
, 1, row
, 2, 1);
2007 widget
= gtk_check_button_new_with_mnemonic (_("Update currencies online"));
2008 data
->CM_do_update_currency
= widget
;
2009 gtk_grid_attach (GTK_GRID (group_grid
), widget
, 1, row
, 2, 1);
2012 // group :: Main window reports
2013 group_grid
= gtk_grid_new ();
2014 gtk_grid_set_row_spacing (GTK_GRID (group_grid
), SPACING_SMALL
);
2015 gtk_grid_set_column_spacing (GTK_GRID (group_grid
), SPACING_MEDIUM
);
2016 gtk_grid_attach (GTK_GRID (content_grid
), group_grid
, 0, crow
++, 1, 1);
2018 label
= make_label_group(_("Main window reports"));
2019 gtk_grid_attach (GTK_GRID (group_grid
), label
, 0, 0, 3, 1);
2022 label
= make_label(_("_Range:"), 0, 0.5);
2023 gtk_grid_attach (GTK_GRID (group_grid
), label
, 1, row
, 1, 1);
2024 widget
= make_daterange(label
, DATE_RANGE_CUSTOM_HIDE
);
2025 data
->CY_daterange_wal
= widget
;
2026 gtk_grid_attach (GTK_GRID (group_grid
), widget
, 2, row
, 1, 1);
2028 return content_grid
;
2032 void plugin_execute_action(GtkTreeView
* treeview
, GtkTreePath
* path
, GtkTreeViewColumn
* col
, gpointer userdata
);
2035 toggle_plugin(GtkCellRendererToggle
*cell
, gchar
* path_str
, gpointer data
)
2037 GtkTreeModel
*model
= (GtkTreeModel
*)data
;
2039 GtkTreePath
*path
= gtk_tree_path_new_from_string(path_str
);
2041 const gchar
* plugin
;
2043 gtk_tree_model_get_iter(model
, &iter
, path
);
2044 gtk_tree_model_get(model
, &iter
, EXT_COLUMN_PLUGIN_NAME
, &plugin
, -1);
2046 gboolean enabled
= ext_is_plugin_loaded(plugin
);
2048 ext_unload_plugin(plugin
);
2051 enabled
= (ext_load_plugin(plugin
) == 0);
2053 ext_run_modal(_("Plugin Error"), _("The plugin failed to load properly."), "error");
2058 gtk_list_store_set(GTK_LIST_STORE (model
), &iter
, EXT_COLUMN_ENABLED
, enabled
, -1);
2061 gtk_tree_path_free(path
);
2065 void plugin_execute_action(GtkTreeView
* treeview
, GtkTreePath
* path
, GtkTreeViewColumn
* col
, gpointer userdata
)
2067 GtkTreeModel
* model
= gtk_tree_view_get_model(treeview
);
2070 if (gtk_tree_model_get_iter(model
, &iter
, path
)) {
2071 gchar
* plugin_filename
;
2072 gtk_tree_model_get(model
, &iter
, EXT_COLUMN_PLUGIN_NAME
, &plugin_filename
, -1);
2073 ext_execute_action(plugin_filename
);
2074 g_free(plugin_filename
);
2078 static GtkWidget
*defpref_page_plugins (struct defpref_data
*data
)
2080 GtkWidget
*container
;
2081 GtkListStore
*store
;
2085 container
= gtk_vbox_new(FALSE
, 0);
2087 store
= gtk_list_store_new(EXT_NUM_COLUMNS
, G_TYPE_BOOLEAN
, G_TYPE_STRING
, G_TYPE_STRING
, G_TYPE_STRING
);
2089 gchar
** plugins
= ext_list_plugins();
2091 for (plugins_it
= plugins
; *plugins_it
; ++plugins_it
) {
2093 gboolean enabled
= ext_is_plugin_loaded(*plugins_it
);
2094 GHashTable
* metadata
= ext_read_plugin_metadata(*plugins_it
);
2096 metadata
= g_hash_table_new(g_str_hash
, g_str_equal
);
2102 gchar
* name
= g_hash_table_lookup(metadata
, "name");
2103 if (!name
|| *name
== '\0') {
2106 name
= g_markup_escape_text(name
, -1);
2107 gchar
* label
= g_strdup_printf("<b>%s</b>", name
);
2108 gchar
* tooltip
= g_strdup_printf("<span size='x-large' weight='bold'>%s</span>", name
);
2112 gchar
* version
= g_hash_table_lookup(metadata
, "version");
2114 version
= g_markup_escape_text(version
, -1);
2116 label
= g_strdup_printf("%s %s", tmp
, version
);
2119 tooltip
= g_strdup_printf("%s %s", tmp
, version
);
2125 gchar
* abstract
= g_hash_table_lookup(metadata
, "abstract");
2127 abstract
= g_markup_escape_text(abstract
, -1);
2129 label
= g_strdup_printf("%s\n%s", tmp
, abstract
);
2135 gchar
* author
= g_hash_table_lookup(metadata
, "author");
2137 author
= g_markup_escape_text(author
, -1);
2139 tooltip
= g_strdup_printf("%s\n%s", tmp
, author
);
2145 gchar
* website
= g_hash_table_lookup(metadata
, "website");
2147 website
= g_markup_escape_text(website
, -1);
2149 tooltip
= g_strdup_printf("%s\n<b>%s:</b> %s", tmp
, _("Website"), website
);
2155 tmp
= ext_find_plugin(*plugins_it
);
2156 gchar
* full
= g_markup_escape_text(tmp
, -1);
2159 tooltip
= g_strdup_printf("%s\n<b>%s:</b> %s", tmp
, _("File"), full
);
2163 g_hash_table_unref(metadata
);
2165 gtk_list_store_append(store
, &it
);
2166 gtk_list_store_set(store
, &it
,
2167 EXT_COLUMN_ENABLED
, enabled
,
2168 EXT_COLUMN_LABEL
, label
,
2169 EXT_COLUMN_TOOLTIP
, tooltip
,
2170 EXT_COLUMN_PLUGIN_NAME
, *plugins_it
,
2176 g_strfreev(plugins
);
2178 view
= gtk_tree_view_new_with_model(GTK_TREE_MODEL(store
));
2179 g_object_unref(store
);
2181 g_signal_connect(view
, "row-activated", (GCallback
)plugin_execute_action
, NULL
);
2183 gtk_tree_view_set_rules_hint(GTK_TREE_VIEW(view
), TRUE
);
2184 gtk_tree_view_set_headers_visible(GTK_TREE_VIEW(view
), TRUE
);
2185 gtk_tree_view_set_tooltip_column(GTK_TREE_VIEW(view
), EXT_COLUMN_TOOLTIP
);
2188 GtkTreeViewColumn
*col
;
2189 GtkCellRenderer
*renderer
;
2192 col
= gtk_tree_view_column_new();
2193 gtk_tree_view_column_set_title(col
, _("Enabled"));
2194 gtk_tree_view_column_set_sort_column_id(col
, EXT_COLUMN_ENABLED
);
2195 gtk_tree_view_append_column(GTK_TREE_VIEW(view
), col
);
2197 renderer
= gtk_cell_renderer_toggle_new();
2198 gtk_tree_view_column_pack_start(col
, renderer
, TRUE
);
2199 gtk_tree_view_column_add_attribute(col
, renderer
, "active", 0);
2200 g_signal_connect(renderer
, "toggled", G_CALLBACK(toggle_plugin
), store
);
2202 col
= gtk_tree_view_column_new();
2203 gtk_tree_view_column_set_title(col
, _("Plugin"));
2204 gtk_tree_view_column_set_sort_column_id(col
, EXT_COLUMN_LABEL
);
2205 gtk_tree_view_column_set_expand(col
, TRUE
);
2206 /*gtk_tree_view_column_set_sort_order(col, GTK_SORT_ASCENDING);*/
2207 gtk_tree_view_append_column(GTK_TREE_VIEW(view
), col
);
2209 renderer
= gtk_cell_renderer_text_new();
2210 g_object_set(renderer
, "ellipsize", PANGO_ELLIPSIZE_END
, NULL
);
2211 gtk_tree_view_column_pack_start(col
, renderer
, TRUE
);
2212 gtk_tree_view_column_add_attribute(col
, renderer
, "markup", EXT_COLUMN_LABEL
);
2214 data
->PI_plugin_columns
= view
;
2216 GtkWidget
* sw
= gtk_scrolled_window_new(NULL
, NULL
);
2217 gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(sw
), GTK_SHADOW_ETCHED_IN
);
2218 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(sw
), GTK_POLICY_NEVER
, GTK_POLICY_AUTOMATIC
);
2219 gtk_container_add(GTK_CONTAINER(sw
), view
);
2221 gtk_box_pack_start(GTK_BOX(container
), sw
, TRUE
, TRUE
, 0);
2227 static void defpref_selection(GtkTreeSelection
*treeselection
, gpointer user_data
)
2229 struct defpref_data
*data
;
2230 GtkWidget
*notebook
;
2231 GtkTreeView
*treeview
;
2232 GtkTreeModel
*model
;
2235 GValue val
= { 0, };
2238 DB( g_print("\n[ui-pref] selection\n") );
2240 if (gtk_tree_selection_get_selected(treeselection
, &model
, &iter
))
2242 notebook
= GTK_WIDGET(user_data
);
2243 treeview
= gtk_tree_selection_get_tree_view(treeselection
);
2244 data
= g_object_get_data(G_OBJECT(gtk_widget_get_ancestor(GTK_WIDGET(treeview
), GTK_TYPE_WINDOW
)), "inst_data");
2247 gtk_tree_model_get_value(model
, &iter
, LST_PREF_PAGE
, &val
);
2248 page
= g_value_get_int (&val
);
2249 DB( g_print(" - active is %d\n", page
) );
2250 g_value_unset (&val
);
2253 gtk_tree_model_get_value(model
, &iter
, LST_PREF_NAME
, &val
);
2254 gtk_label_set_text (GTK_LABEL (data
->label
), g_value_get_string (&val
));
2255 g_value_unset (&val
);
2257 gtk_tree_model_get_value(model
, &iter
, LST_PREF_ICONNAME
, &val
);
2258 //gtk_image_set_from_pixbuf (GTK_IMAGE (data->image), g_value_get_object (&val));
2259 gtk_image_set_from_icon_name(GTK_IMAGE (data
->image
), g_value_get_string (&val
), GTK_ICON_SIZE_DIALOG
);
2260 g_value_unset (&val
);
2264 gtk_notebook_set_current_page(GTK_NOTEBOOK(notebook
), page
);
2266 //defpref_change_page(GTK_WIDGET(gtk_tree_selection_get_tree_view(treeselection)), GINT_TO_POINTER(page));
2273 ** set the notebook active page from treeview
2275 /*void defpref_change_page(GtkWidget *widget, gpointer user_data)
2277 struct defpref_data *data;
2278 gint page = GPOINTER_TO_INT(user_data);
2279 GtkTreeModel *model;
2282 DB( g_print("\n[ui-pref] page\n") );
2284 data = g_object_get_data(G_OBJECT(gtk_widget_get_ancestor(widget, GTK_TYPE_WINDOW)), "inst_data");
2286 model = gtk_tree_view_get_model(GTK_TREE_VIEW(data->LV_page));
2294 gtk_notebook_set_current_page(GTK_NOTEBOOK(data->GR_page), page);
2300 ** add an empty new account to our temp GList and treeview
2302 static void defpref_reset(GtkWidget
*widget
, gpointer user_data
)
2304 struct defpref_data
*data
;
2307 data
= g_object_get_data(G_OBJECT(gtk_widget_get_ancestor(widget
, GTK_TYPE_WINDOW
)), "inst_data");
2308 DB( g_print("\n(defpref_reset) (data=%p)\n", data
) );
2310 result
= ui_dialog_msg_confirm_alert(
2311 GTK_WINDOW(data
->window
),
2312 _("Reset All Preferences"),
2313 _("Do you really want to reset\nall preferences to default\nvalues?"),
2316 if( result
== GTK_RESPONSE_OK
)
2318 homebank_pref_setdefault();
2325 // the window creation
2326 GtkWidget
*defpref_dialog_new (gint initial_selection
)
2328 struct defpref_data data
;
2329 GtkWidget
*window
, *content
, *mainvbox
;
2330 GtkWidget
*hbox
, *vbox
, *sw
, *widget
, *notebook
, *page
, *ebox
, *image
, *label
;
2332 window
= gtk_dialog_new_with_buttons (_("Preferences"),
2333 GTK_WINDOW(GLOBALS
->mainwindow
),
2338 GTK_RESPONSE_REJECT
,
2340 GTK_RESPONSE_ACCEPT
,
2343 data
.window
= window
;
2345 //store our window private data
2346 g_object_set_data(G_OBJECT(window
), "inst_data", (gpointer
)&data
);
2348 gtk_window_set_icon_name(GTK_WINDOW (window
), ICONNAME_PREFERENCES
);
2350 content
= gtk_dialog_get_content_area(GTK_DIALOG (window
)); // return a vbox
2351 mainvbox
= gtk_box_new(GTK_ORIENTATION_VERTICAL
, SPACING_MEDIUM
);
2352 gtk_box_pack_start (GTK_BOX (content
), mainvbox
, TRUE
, TRUE
, 0);
2354 gtk_container_set_border_width(GTK_CONTAINER(mainvbox
), SPACING_MEDIUM
);
2356 hbox
= gtk_box_new(GTK_ORIENTATION_HORIZONTAL
, SPACING_MEDIUM
);
2357 gtk_box_pack_start (GTK_BOX (mainvbox
), hbox
, TRUE
, TRUE
, 0);
2360 vbox
= gtk_box_new(GTK_ORIENTATION_VERTICAL
, SPACING_SMALL
);
2361 gtk_box_pack_start (GTK_BOX (hbox
), vbox
, FALSE
, FALSE
, 0);
2364 sw
= gtk_scrolled_window_new (NULL
, NULL
);
2365 gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (sw
), GTK_SHADOW_ETCHED_IN
);
2366 gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (sw
), GTK_POLICY_NEVER
, GTK_POLICY_AUTOMATIC
);
2367 gtk_box_pack_start (GTK_BOX (vbox
), sw
, TRUE
, TRUE
, 0);
2368 widget
= pref_list_create();
2369 data
.LV_page
= widget
;
2370 gtk_container_add (GTK_CONTAINER (sw
), widget
);
2373 //right part : notebook
2374 vbox
= gtk_box_new (GTK_ORIENTATION_VERTICAL
, SPACING_MEDIUM
);
2375 gtk_box_pack_start (GTK_BOX (hbox
), vbox
, TRUE
, TRUE
, 0);
2376 gtk_widget_show (vbox
);
2378 ebox
= gtk_event_box_new();
2379 gtk_widget_set_name(ebox
, "hbebox");
2380 GtkStyleContext
*context
= gtk_widget_get_style_context (ebox
);
2381 #if GTK_MINOR_VERSION <= 18
2382 gtk_style_context_add_class (context
, GTK_STYLE_CLASS_LIST_ROW
);
2383 gtk_widget_set_state_flags(ebox
, GTK_STATE_FLAG_SELECTED
, TRUE
);
2385 GtkCssProvider
*provider
;
2386 provider
= gtk_css_provider_new ();
2387 gtk_css_provider_load_from_data (provider
,
2388 "#hbebox { color: @theme_selected_fg_color; background-color: @theme_selected_bg_color; }"
2390 gtk_style_context_add_provider (context
, GTK_STYLE_PROVIDER(provider
), G_MAXUINT
);
2392 // gtk_style_context_set_state(context, GTK_STATE_FLAG_SELECTED);
2395 gtk_box_pack_start (GTK_BOX (vbox
), ebox
, FALSE
, TRUE
, 0);
2396 gtk_widget_show (ebox
);
2398 hbox
= gtk_box_new (GTK_ORIENTATION_HORIZONTAL
, SPACING_SMALL
);
2399 gtk_container_set_border_width (GTK_CONTAINER (hbox
), SPACING_SMALL
);
2400 gtk_container_add (GTK_CONTAINER (ebox
), hbox
);
2401 gtk_widget_show (hbox
);
2403 label
= gtk_label_new (NULL
);
2404 gtk_widget_set_margin_left(label
, SPACING_MEDIUM
);
2405 gimp_label_set_attributes (GTK_LABEL (label
),
2406 PANGO_ATTR_SCALE
, PANGO_SCALE_XX_LARGE
,
2407 PANGO_ATTR_WEIGHT
, PANGO_WEIGHT_BOLD
,
2410 gtk_box_pack_start (GTK_BOX (hbox
), label
, FALSE
, FALSE
, 0);
2411 gtk_widget_show (label
);
2414 image
= gtk_image_new ();
2415 gtk_box_pack_end (GTK_BOX (hbox
), image
, FALSE
, FALSE
, 0);
2416 gtk_widget_show (image
);
2422 notebook
= gtk_notebook_new();
2423 data
.GR_page
= notebook
;
2424 gtk_widget_show(notebook
);
2425 gtk_notebook_set_show_tabs(GTK_NOTEBOOK(notebook
), FALSE
);
2426 gtk_notebook_set_show_border(GTK_NOTEBOOK(notebook
), FALSE
);
2427 gtk_box_pack_start (GTK_BOX (vbox
), notebook
, TRUE
, TRUE
, 0);
2432 PREF_LOCALE, //old DISPLAY
2433 PREF_TXN, //old COLUMNS
2443 page
= defpref_page_general(&data
);
2444 gtk_notebook_append_page (GTK_NOTEBOOK (notebook
), page
, NULL
);
2447 page
= defpref_page_interface(&data
);
2448 gtk_notebook_append_page (GTK_NOTEBOOK (notebook
), page
, NULL
);
2451 page
= defpref_page_display(&data
);
2452 gtk_notebook_append_page (GTK_NOTEBOOK (notebook
), page
, NULL
);
2455 page
= defpref_page_transactions(&data
);
2456 gtk_notebook_append_page (GTK_NOTEBOOK (notebook
), page
, NULL
);
2459 page
= defpref_page_import(&data
);
2460 gtk_notebook_append_page (GTK_NOTEBOOK (notebook
), page
, NULL
);
2463 page
= defpref_page_reports(&data
);
2464 gtk_notebook_append_page (GTK_NOTEBOOK (notebook
), page
, NULL
);
2467 page
= defpref_page_filebackup(&data
);
2468 gtk_notebook_append_page (GTK_NOTEBOOK (notebook
), page
, NULL
);
2471 page
= defpref_page_folders(&data
);
2472 gtk_notebook_append_page (GTK_NOTEBOOK (notebook
), page
, NULL
);
2475 page
= defpref_page_euro(&data
);
2476 gtk_notebook_append_page (GTK_NOTEBOOK (notebook
), page
, NULL
);
2479 page
= defpref_page_plugins(&data
);
2480 gtk_notebook_append_page (GTK_NOTEBOOK (notebook
), page
, NULL
);
2483 //todo:should move this
2484 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(data
.CM_euro_enable
), PREFS
->euro_active
);
2486 //connect all our signals
2487 g_signal_connect (window
, "destroy", G_CALLBACK (gtk_widget_destroyed
), &window
);
2489 g_signal_connect (data
.CM_bak_is_automatic
, "toggled", G_CALLBACK (defpref_backuptoggle
), NULL
);
2493 g_signal_connect (data
.BT_path_hbfile
, "pressed", G_CALLBACK (defpref_pathselect
), GINT_TO_POINTER(PRF_PATH_WALLET
));
2494 g_signal_connect (data
.BT_path_import
, "pressed", G_CALLBACK (defpref_pathselect
), GINT_TO_POINTER(PRF_PATH_IMPORT
));
2495 g_signal_connect (data
.BT_path_export
, "pressed", G_CALLBACK (defpref_pathselect
), GINT_TO_POINTER(PRF_PATH_EXPORT
));
2497 g_signal_connect (data
.CM_custom_colors
, "toggled", G_CALLBACK (defpref_colortoggle
), NULL
);
2498 g_signal_connect (data
.CY_colors
, "changed", G_CALLBACK (defpref_colorpreset
), NULL
);
2502 g_signal_connect (gtk_tree_view_get_selection(GTK_TREE_VIEW(data
.LV_page
)), "changed", G_CALLBACK (defpref_selection
), notebook
);
2504 g_signal_connect (data
.CM_euro_enable
, "toggled", G_CALLBACK (defpref_eurotoggle
), NULL
);
2506 g_signal_connect (data
.CY_euro_preset
, "changed", G_CALLBACK (defpref_europreset
), NULL
);
2509 g_signal_connect (data
.ST_datefmt
, "changed", G_CALLBACK (defpref_date_sample
), NULL
);
2512 g_signal_connect (data
.CY_color_scheme
, "changed", G_CALLBACK (defpref_color_scheme_changed
), NULL
);
2516 g_signal_connect (data
.ST_euro_symbol
, "changed", G_CALLBACK (defpref_numbereuro_sample
), NULL
);
2517 g_signal_connect (data
.CM_euro_isprefix
, "toggled", G_CALLBACK (defpref_numbereuro_sample
), NULL
);
2518 g_signal_connect (data
.ST_euro_decimalchar
, "changed", G_CALLBACK (defpref_numbereuro_sample
), NULL
);
2519 g_signal_connect (data
.ST_euro_groupingchar
, "changed", G_CALLBACK (defpref_numbereuro_sample
), NULL
);
2520 g_signal_connect (data
.NB_euro_fracdigits
, "value-changed", G_CALLBACK (defpref_numbereuro_sample
), NULL
);
2522 //g_signal_connect (data.BT_default, "pressed", G_CALLBACK (defpref_currency_change), NULL);
2525 //setup, init and show window
2526 //defhbfile_setup(&data);
2527 //defhbfile_update(data.LV_arc, NULL);
2531 defpref_colortoggle(window
, NULL
);
2532 defpref_eurotoggle(window
, NULL
);
2534 gtk_window_resize(GTK_WINDOW(window
), 640, 256);
2538 GtkTreePath
*path
= gtk_tree_path_new_from_indices(initial_selection
, -1);
2541 gtk_tree_selection_select_path (gtk_tree_view_get_selection(GTK_TREE_VIEW(data
.LV_page
)), path
);
2545 gtk_tree_path_free(path
);
2547 gtk_widget_show_all (window
);
2548 gtk_notebook_set_current_page(GTK_NOTEBOOK(notebook
), initial_selection
);
2555 result
= gtk_dialog_run (GTK_DIALOG (window
));
2559 case GTK_RESPONSE_ACCEPT
:
2560 old_lang
= g_strdup(PREFS
->language
);
2562 homebank_pref_save();
2563 ui_mainwindow_update(GLOBALS
->mainwindow
, GINT_TO_POINTER(UF_BALANCE
+UF_VISUAL
));
2565 DB( g_print("old='%s' new='%s'\n", old_lang
, PREFS
->language
) );
2567 if(g_ascii_strncasecmp(old_lang
== NULL
? "" : old_lang
, PREFS
->language
== NULL
? "" : PREFS
->language
, -1) != 0)
2569 ui_dialog_msg_infoerror(GTK_WINDOW(window
), GTK_MESSAGE_INFO
,
2571 _("You will have to restart HomeBank\nfor the language change to take effect.")
2580 defpref_reset (window
, NULL
);
2585 // cleanup and destroy
2586 //defhbfile_cleanup(&data, result);
2587 gtk_widget_destroy (window
);
2592 // -------------------------------
2595 static GtkWidget
*pref_list_create(void)
2597 GtkListStore
*store
;
2599 GtkCellRenderer
*renderer
;
2600 GtkTreeViewColumn
*column
;
2604 /* create list store */
2605 store
= gtk_list_store_new(
2613 view
= gtk_tree_view_new_with_model(GTK_TREE_MODEL(store
));
2614 g_object_unref(store
);
2616 gtk_tree_view_set_headers_visible(GTK_TREE_VIEW (view
), FALSE
);
2617 gtk_tree_selection_set_mode(gtk_tree_view_get_selection(GTK_TREE_VIEW(view
)), GTK_SELECTION_SINGLE
);
2619 /* column 1: icon */
2620 column
= gtk_tree_view_column_new();
2621 renderer
= gtk_cell_renderer_pixbuf_new ();
2622 g_object_set(renderer
, "stock-size", GTK_ICON_SIZE_DND
, NULL
);
2623 gtk_tree_view_column_pack_start(column
, renderer
, FALSE
);
2624 gtk_tree_view_column_set_attributes(column
, renderer
, "icon-name", LST_PREF_ICONNAME
, NULL
);
2626 renderer
= gtk_cell_renderer_text_new ();
2627 gtk_tree_view_column_pack_start(column
, renderer
, TRUE
);
2628 gtk_tree_view_column_set_attributes(column
, renderer
, "text", LST_PREF_NAME
, NULL
);
2630 gtk_tree_view_append_column (GTK_TREE_VIEW(view
), column
);
2632 //populate our combobox model
2633 for(i
=0;i
<PREF_MAX
;i
++)
2635 gtk_list_store_append(store
, &iter
);
2637 gtk_list_store_set(store
, &iter
,
2638 LST_PREF_ICONNAME
, pref_iconname
[i
],
2639 LST_PREF_NAME
, _(pref_name
[i
]),
2648 /* = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =*/
2651 extern gchar *list_txn_column_label[];
2655 list_txn_colpref_toggled_cell_data_function (GtkCellRendererToggle *cell,
2659 GtkTreeModel *model = (GtkTreeModel *)data;
2661 GtkTreePath *path = gtk_tree_path_new_from_string (path_str);
2665 gtk_tree_model_get_iter (model, &iter, path);
2666 gtk_tree_model_get (model, &iter, COLUMN_VISIBLE, &fixed, -1);
2668 // do something with the value
2672 gtk_list_store_set (GTK_LIST_STORE (model), &iter, COLUMN_VISIBLE, fixed, -1);
2675 gtk_tree_path_free (path);
2679 static void list_txn_colpref_get(GtkTreeView *treeview, gint *columns)
2681 GtkTreeModel *model;
2687 DB( g_print("[lst_txn-colpref] store column order \n") );
2689 model = gtk_tree_view_get_model(GTK_TREE_VIEW(treeview));
2690 valid = gtk_tree_model_get_iter_first(GTK_TREE_MODEL(model), &iter);
2694 gtk_tree_model_get(GTK_TREE_MODEL(model), &iter,
2695 COLUMN_VISIBLE, &visible,
2699 DB( g_print(" - column %d: %d\n",id, visible) );
2700 // start at index 2 (status, date always displayed
2701 columns[i+2] = visible == TRUE ? id : -id;
2703 // Make iter point to the next row in the list store
2704 valid = gtk_tree_model_iter_next(GTK_TREE_MODEL(model), &iter);
2710 GtkWidget *list_txn_colprefcreate(void)
2712 GtkListStore *store;
2714 GtkCellRenderer *renderer;
2715 GtkTreeViewColumn *column;
2719 DB( g_print("[lst_txn-colpref] create\n") );
2722 // create list store
2723 store = gtk_list_store_new(
2731 for(i=0 ; i < NUM_LST_DSPOPE-1; i++ ) //-1 cause account column avoid
2736 DB( g_print("eval %d, %s\n", i, list_txn_column_label[i]) );
2738 if(i <= LST_DSPOPE_DATE) // status, date always displayed
2741 //[i-1] here because lst_ope_columns[] do not store MODEL_TXN_POINTER
2742 id = ABS(PREFS->lst_ope_columns[i-1]);
2743 if(id == 0) id = i; //if we pass here, new column or weird into pref file
2744 visible = (PREFS->lst_ope_columns[i-1] > 0) ? TRUE : FALSE;
2747 DB( g_print(" - pos=%2d, id=%2d - %d '%s'\n", i, id, visible, list_txn_column_label[id]) );
2749 gtk_list_store_append (store, &iter);
2750 gtk_list_store_set (store, &iter,
2751 COLUMN_VISIBLE, visible,
2752 COLUMN_NAME, _(list_txn_column_label[id]),
2759 view = gtk_tree_view_new_with_model(GTK_TREE_MODEL(store));
2760 g_object_unref(store);
2764 renderer = gtk_cell_renderer_toggle_new ();
2765 column = gtk_tree_view_column_new_with_attributes (_("Visible"),
2767 "active", COLUMN_VISIBLE,
2769 gtk_tree_view_append_column (GTK_TREE_VIEW(view), column);
2771 g_signal_connect (renderer, "toggled",
2772 G_CALLBACK (list_txn_colpref_toggled_cell_data_function), store);
2775 renderer = gtk_cell_renderer_text_new ();
2776 column = gtk_tree_view_column_new_with_attributes (_("Column"),
2778 "text", COLUMN_NAME,
2780 gtk_tree_view_append_column (GTK_TREE_VIEW(view), column);
2782 gtk_tree_view_set_reorderable (GTK_TREE_VIEW(view), TRUE);
2790 static void list_ext_colpref_get(GtkTreeView
*treeview
, GList
**columns
)
2792 GtkTreeModel
*model
;
2795 g_list_free_full(*columns
, g_free
);
2798 model
= gtk_tree_view_get_model(GTK_TREE_VIEW(treeview
));
2800 gboolean valid
= gtk_tree_model_get_iter_first(GTK_TREE_MODEL(model
), &iter
);
2802 gboolean enabled
= FALSE
;
2805 gtk_tree_model_get(GTK_TREE_MODEL(model
), &iter
,
2806 EXT_COLUMN_ENABLED
, &enabled
,
2807 EXT_COLUMN_PLUGIN_NAME
, &name
,
2811 *columns
= g_list_append(*columns
, g_strdup(name
));
2814 valid
= gtk_tree_model_iter_next(GTK_TREE_MODEL(model
), &iter
);