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"),
145 extern gchar
*CYA_CHART_COLORSCHEME
[];
146 extern gchar
*CYA_MONTHS
[];
153 http://en.wikipedia.org/wiki/Currencies_of_the_European_Union
154 http://www.xe.com/euro.php
155 http://fr.wikipedia.org/wiki/Liste_des_unit%C3%A9s_mon%C3%A9taires_remplac%C3%A9es_par_l%27euro
156 http://www.inter-locale.com/LocalesDemo.jsp
158 static EuroParams euro_params
[] =
160 // , rate , symb , prfx , dec, grp, frac
161 // ---------------------------------------------------------------------
162 { 0, "" , "--------" , 1.0 , "" , FALSE
, ",", ".", 2 },
163 { 1, "ATS", "Austria" , 13.7603 , "S" , TRUE
, ",", ".", 2 }, // -S 1.234.567,89
164 { 2, "BEF", "Belgium" , 40.3399 , "BF" , TRUE
, ",", ".", 2 }, // BF 1.234.567,89 -
165 { 20, "BGN", "Bulgaria" , 1.95583 , "лв." , TRUE
, ",", " ", 2 }, // non-fixé - 2014 target for euro
166 { 24, "HRK", "Croatia" , 1.0000 , "kn" , FALSE
, "" , ".", 0 }, // non-fixé - 2015 target for euro earliest
167 { 14, "CYP", "Cyprus" , 0.585274 , "£" , TRUE
, ",", "" , 2 }, //
168 { 23, "CZK", "Czech Republic" , 28.36 , "Kč" , FALSE
, ",", " ", 2 }, // non-fixé - 2015 earliest
170 { 17, "EEK", "Estonia" , 15.6466 , "kr" , FALSE
, ",", " ", 2 }, //
171 { 3, "FIM", "Finland" , 5.94573 , "mk" , FALSE
, ",", " ", 2 }, // -1 234 567,89 mk
172 { 4, "FRF", "France" , 6.55957 , "F" , FALSE
, ",", " ", 2 }, // -1 234 567,89 F
173 { 5, "DEM", "Germany" , 1.95583 , "DM" , FALSE
, ",", ".", 2 }, // -1.234.567,89 DM
174 { 6, "GRD", "Greece" , 340.750 , "d" , TRUE
, ".", ",", 2 }, // ??
175 { 21, "HUF", "Hungary" , 261.51 , "Ft" , TRUE
, ",", " ", 2 }, // non-fixé - No current target for euro
176 { 7, "IEP", "Ireland" , 0.787564 , "£" , TRUE
, ".", ",", 2 }, // -£1,234,567.89
177 { 8, "ITL", "Italy" , 1936.27 , "L" , TRUE
, "" , ".", 0 }, // L -1.234.567
178 { 18, "LVL", "Latvia" , 0.702804 , "lat.", FALSE
, ",", "" , 2 }, // jan. 2014
179 { 19, "LTL", "Lithuania" , 3.45280 , "Lt" , FALSE
, ",", "" , 2 }, // jan. 2015
180 { 9, "LUF", "Luxembourg" , 40.3399 , "LU" , TRUE
, ",", ".", 2 }, // LU 1.234.567,89 -
181 { 15, "MTL", "Malta" , 0.429300 , "Lm" , TRUE
, ",", "" , 2 }, //
182 { 10, "NLG", "Netherlands" , 2.20371 , "F" , TRUE
, ",", ".", 2 }, // F 1.234.567,89-
183 { 25, "PLN", "Poland" , 0.25 , "zł" , FALSE
, ",", "" , 2 }, // non-fixé - No current target for euro
184 { 11, "PTE", "Portugal" , 200.482 , "Esc.", FALSE
, "$", ".", 2 }, // -1.234.567$89 Esc.
185 { 22, "RON", "Romania" , 3.5155 , "Leu" , FALSE
, ",", ".", 2 }, // non-fixé - 2015 target for euro earliest
186 { 16, "SKK", "Slovak Republic", 30.12600 , "Sk" , FALSE
, ",", " ", 2 }, //
187 { 13, "SIT", "Slovenia" , 239.640 , "tol" , TRUE
, ",", ".", 2 }, //
188 { 12, "ESP", "Spain" , 166.386 , "Pts" , TRUE
, "" , ".", 0 }, // -Pts 1.234.567
191 // { " ", "" , 1.00000 , "" , "" , FALSE, ",", "", 2 },
195 static void list_ext_colpref_get(GtkTreeView
*treeview
, GList
**columns
);
198 /* = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =*/
201 static LangName languagenames
[] =
203 // 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
204 //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
207 { "ab", "Abkhazian" },
209 { "af", "Afrikaans" },
212 { "an", "Aragonese" },
214 { "as", "Assamese" },
215 { "ast", "Asturian, Bable, Leonese, Asturleonese" },
218 { "az", "Azerbaijani" },
220 { "be", "Belarusian" },
221 { "bg", "Bulgarian" },
231 { "ch", "Chamorro" },
232 { "co", "Corsican" },
235 { "cu", "Old Church Slavonic" },
241 { "dz", "Dzongkha" },
245 { "eo", "Esperanto" },
247 { "et", "Estonian" },
255 { "fy", "Western Frisian" },
257 { "gd", "Scottish Gaelic" },
258 { "gl", "Galician" },
260 { "gu", "Gujarati" },
265 { "ho", "Hiri Motu" },
266 { "hr", "Croatian" },
268 { "hu", "Hungarian" },
269 { "hy", "Armenian" },
271 { "ia", "Interlingua" },
272 { "id", "Indonesian" },
273 { "ie", "Interlingue" },
275 { "ii", "Sichuan Yi" },
278 { "is", "Icelandic" },
280 { "iu", "Inuktitut" },
281 { "ja", "Japanese" },
282 { "jv", "Javanese" },
283 { "ka", "Georgian" },
286 { "kj", "Kwanyama" },
288 { "kl", "Kalaallisut" },
293 { "ks", "Kashmiri" },
299 { "lb", "Luxembourgish" },
301 { "li", "Limburgish" },
304 { "lt", "Lithuanian" },
305 { "lu", "Luba-Katanga" },
307 { "mg", "Malagasy" },
308 { "mh", "Marshallese" },
310 { "mk", "Macedonian" },
311 { "ml", "Malayalam" },
312 { "mn", "Mongolian" },
313 { "mo", "Moldavian" },
319 { "nb", "Norwegian Bokmål" },
320 { "nd", "North Ndebele" },
321 { "nds", "Low German, Low Saxon" },
325 { "nn", "Norwegian Nynorsk" },
326 { "no", "Norwegian" },
327 { "nr", "South Ndebele" },
329 { "ny", "Chichewa" },
334 { "os", "Ossetian" },
339 { "pt", "Portuguese" },
343 { "ro", "Romanian" },
345 { "rw", "Kinyarwanda" },
346 { "sa", "Sanskrit" },
347 { "sc", "Sardinian" },
349 { "se", "Northern Sami" },
351 { "si", "Sinhalese" },
357 { "sq", "Albanian" },
361 { "su", "Sundanese" },
368 { "ti", "Tigrinya" },
377 { "ty", "Tahitian" },
379 { "uk", "Ukrainian" },
383 { "vi", "Viêt Namese" },
397 static GtkWidget
*pref_list_create(void);
401 ui_language_combobox_compare_func (GtkTreeModel
*model
, GtkTreeIter
*a
, GtkTreeIter
*b
, gpointer userdata
)
404 gchar
*code1
, *code2
;
405 gchar
*name1
, *name2
;
407 gtk_tree_model_get(model
, a
, 0, &code1
, 1, &name1
, -1);
408 gtk_tree_model_get(model
, b
, 0, &code2
, 1, &name2
, -1);
410 //keep system laguage on top
411 if(code1
== NULL
) name1
= NULL
;
412 if(code2
== NULL
) name2
= NULL
;
414 retval
= hb_string_utf8_compare(name1
, name2
);
423 static gchar
*languagename_get(const gchar
*locale
)
427 for (i
= 0; i
< G_N_ELEMENTS (languagenames
); i
++)
429 if( g_ascii_strncasecmp(locale
, languagenames
[i
].locale
, -1) == 0 )
430 return languagenames
[i
].name
;
438 ui_language_combobox_get_name(const gchar
*locale
)
442 DB( g_print("[ui_language_combobox_get_name]\n") );
444 // A locale directory name is typically of the form language[_territory]
445 lang
= languagename_get (locale
);
448 const gchar
*delimiter
= strchr (locale
, '_'); // strip off the territory suffix
452 gchar
*copy
= g_strndup (locale
, delimiter
- locale
);
453 lang
= languagename_get (copy
);
459 g_warning(" locale name not found '%s'", locale
);
470 ui_language_combobox_populate(GtkWidget
*combobox
)
475 model
= gtk_combo_box_get_model(GTK_COMBO_BOX(combobox
));
476 gtk_list_store_append (GTK_LIST_STORE(model
), &iter
);
477 gtk_list_store_set (GTK_LIST_STORE(model
), &iter
,
479 1, _("System Language"),
482 GDir
*dir
= g_dir_open (homebank_app_get_locale_dir (), 0, NULL
);
483 const gchar
*dirname
;
488 while ((dirname
= g_dir_read_name (dir
)) != NULL
)
490 gchar
*filename
= g_build_filename (homebank_app_get_locale_dir (),
493 GETTEXT_PACKAGE
".mo",
495 //DB( g_print("- seek for '%s'\n", filename) );
496 if (g_file_test (filename
, G_FILE_TEST_EXISTS
))
501 gtk_list_store_append (GTK_LIST_STORE(model
), &iter
);
503 lang
= ui_language_combobox_get_name(dirname
);
504 label
= g_strdup_printf ("%s [%s]", lang
, dirname
);
506 gtk_list_store_set (GTK_LIST_STORE(model
), &iter
,
518 gtk_tree_sortable_set_sort_column_id(GTK_TREE_SORTABLE(model
), GTK_TREE_SORTABLE_DEFAULT_SORT_COLUMN_ID
, GTK_SORT_ASCENDING
);
525 ui_language_combobox_new(GtkWidget
*label
)
529 GtkCellRenderer
*renderer
;
531 store
= gtk_list_store_new (2,
535 gtk_tree_sortable_set_default_sort_func(GTK_TREE_SORTABLE(store
), ui_language_combobox_compare_func
, NULL
, NULL
);
537 combobox
= gtk_combo_box_new_with_model(GTK_TREE_MODEL(store
));
538 renderer
= gtk_cell_renderer_text_new ();
539 gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (combobox
), renderer
, TRUE
);
540 gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (combobox
), renderer
, "text", 1, NULL
);
542 gtk_combo_box_set_id_column( GTK_COMBO_BOX(combobox
), 0);
544 g_object_unref(store
);
547 gtk_label_set_mnemonic_widget (GTK_LABEL(label
), combobox
);
549 ui_language_combobox_populate(combobox
);
551 gtk_combo_box_set_active(GTK_COMBO_BOX(combobox
), 0);
557 /* = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =*/
558 /* = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =*/
559 /* = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =*/
561 static gint
ui_euro_combobox_id_to_active(gint id
)
565 DB( g_print("\n[ui-pref] ui_euro_combobox_id_to_active\n") );
568 for (i
= 0; i
< G_N_ELEMENTS (euro_params
); i
++)
570 if( euro_params
[i
].id
== id
)
573 DB( g_print("- id (country)=%d => %d - %s\n", id
, i
, euro_params
[i
].name
) );
583 static gint
ui_euro_combobox_active_to_id(gint active
)
587 DB( g_print("\n[ui-pref] ui_euro_combobox_active_to_id\n") );
589 DB( g_print("- to %d\n", active
) );
592 if( active
< (gint
)G_N_ELEMENTS (euro_params
) )
594 id
= euro_params
[active
].id
;
595 DB( g_print("- id (country)=%d '%s'\n", id
, euro_params
[active
].name
) );
601 static GtkWidget
*ui_euro_combobox_new(GtkWidget
*label
)
606 DB( g_print("\n[ui-pref] make euro preset\n") );
608 combobox
= gtk_combo_box_text_new();
609 for (i
= 0; i
< G_N_ELEMENTS (euro_params
); i
++)
611 gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(combobox
), euro_params
[i
].name
);
613 gtk_combo_box_set_active(GTK_COMBO_BOX(combobox
), 0);
616 gtk_label_set_mnemonic_widget (GTK_LABEL(label
), combobox
);
622 static void defpref_pathselect(GtkWidget
*widget
, gpointer user_data
)
624 struct defpref_data
*data
;
625 gint type
= GPOINTER_TO_INT(user_data
);
631 DB( g_print("\n[ui-pref] path select\n") );
633 data
= g_object_get_data(G_OBJECT(gtk_widget_get_ancestor(widget
, GTK_TYPE_WINDOW
)), "inst_data");
637 case PRF_PATH_WALLET
:
638 path
= &PREFS
->path_hbfile
;
639 entry
= data
->ST_path_hbfile
;
640 title
= _("Choose a default HomeBank files folder");
642 case PRF_PATH_IMPORT
:
643 path
= &PREFS
->path_import
;
644 entry
= data
->ST_path_import
;
645 title
= _("Choose a default import folder");
647 case PRF_PATH_EXPORT
:
648 path
= &PREFS
->path_export
;
649 entry
= data
->ST_path_export
;
650 title
= _("Choose a default export folder");
656 DB( g_print(" - hbfile %p %s at %p\n" , PREFS
->path_hbfile
, PREFS
->path_hbfile
, &PREFS
->path_hbfile
) );
657 DB( g_print(" - import %p %s at %p\n" , PREFS
->path_import
, PREFS
->path_import
, &PREFS
->path_import
) );
658 DB( g_print(" - export %p %s at %p\n" , PREFS
->path_export
, PREFS
->path_export
, &PREFS
->path_export
) );
661 DB( g_print(" - before: %s %p\n" , *path
, path
) );
663 r
= ui_file_chooser_folder(GTK_WINDOW(gtk_widget_get_ancestor(widget
, GTK_TYPE_WINDOW
)), title
, path
);
666 DB( g_print(" - after: %s\n", *path
) );
669 gtk_entry_set_text(GTK_ENTRY(entry
), *path
);
676 ** update the date sample label
678 static void defpref_date_sample(GtkWidget
*widget
, gpointer user_data
)
680 struct defpref_data
*data
;
685 DB( g_print("\n[ui-pref] date sample\n") );
687 data
= g_object_get_data(G_OBJECT(gtk_widget_get_ancestor(widget
, GTK_TYPE_WINDOW
)), "inst_data");
689 fmt
= gtk_entry_get_text(GTK_ENTRY(data
->ST_datefmt
));
690 date
= g_date_new_julian (GLOBALS
->today
);
691 g_date_strftime (buffer
, 256-1, fmt
, date
);
694 gtk_label_set_text(GTK_LABEL(data
->LB_date
), buffer
);
700 ** update the number sample label
702 static void defpref_numbereuro_sample(GtkWidget
*widget
, gpointer user_data
)
704 struct defpref_data
*data
;
706 gchar formatd_buf
[G_ASCII_DTOSTR_BUF_SIZE
];
709 DB( g_print("\n[ui-pref] number sample\n") );
711 data
= g_object_get_data(G_OBJECT(gtk_widget_get_ancestor(widget
, GTK_TYPE_WINDOW
)), "inst_data");
713 cur
.symbol
= (gchar
*)gtk_entry_get_text(GTK_ENTRY(data
->ST_euro_symbol
));
714 cur
.sym_prefix
= gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(data
->CM_euro_isprefix
));
715 cur
.decimal_char
= (gchar
*)gtk_entry_get_text(GTK_ENTRY(data
->ST_euro_decimalchar
));
716 cur
.grouping_char
= (gchar
*)gtk_entry_get_text(GTK_ENTRY(data
->ST_euro_groupingchar
));
717 cur
.frac_digits
= gtk_spin_button_get_value(GTK_SPIN_BUTTON(data
->NB_euro_fracdigits
));
719 da_cur_initformat (&cur
);
721 DB( g_print("fmt: %s\n", cur
.format
) );
723 g_ascii_formatd(formatd_buf
, sizeof (formatd_buf
), cur
.format
, HB_NUMBER_SAMPLE
);
724 hb_str_formatd(buf
, 127, formatd_buf
, &cur
, TRUE
);
726 gtk_label_set_text(GTK_LABEL(data
->LB_numbereuro
), buf
);
732 ** enable/disable euro
734 static void defpref_eurotoggle(GtkWidget
*widget
, gpointer user_data
)
736 struct defpref_data
*data
;
739 DB( g_print("\n[ui-pref] euro toggle\n") );
741 data
= g_object_get_data(G_OBJECT(gtk_widget_get_ancestor(widget
, GTK_TYPE_WINDOW
)), "inst_data");
743 sensitive
= gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(data
->CM_euro_enable
));
745 gtk_widget_set_sensitive(data
->GRP_currency
, sensitive
);
746 gtk_widget_set_sensitive(data
->GRP_rate
, sensitive
);
747 gtk_widget_set_sensitive(data
->GRP_format
, sensitive
);
752 ** set euro value widget from a country
754 static void defpref_eurosetcurrency(GtkWidget
*widget
, gint country
)
756 struct defpref_data
*data
;
761 DB( g_print("\n[ui-pref] eurosetcurrency\n") );
763 data
= g_object_get_data(G_OBJECT(gtk_widget_get_ancestor(widget
, GTK_TYPE_WINDOW
)), "inst_data");
765 active
= ui_euro_combobox_id_to_active(country
);
766 euro
= &euro_params
[active
];
767 buf
= g_strdup_printf("%s - %s", euro
->iso
, euro
->name
);
768 gtk_label_set_markup(GTK_LABEL(data
->ST_euro_country
), buf
);
774 ** set euro value widget from a country
776 static void defpref_europreset(GtkWidget
*widget
, gpointer user_data
)
778 struct defpref_data
*data
;
781 DB( g_print("\n[ui-pref] euro preset\n") );
783 data
= g_object_get_data(G_OBJECT(gtk_widget_get_ancestor(widget
, GTK_TYPE_WINDOW
)), "inst_data");
785 active
= gtk_combo_box_get_active (GTK_COMBO_BOX(data
->CY_euro_preset
));
786 data
->country
= ui_euro_combobox_active_to_id (active
);;
788 defpref_eurosetcurrency(widget
, data
->country
);
790 gtk_spin_button_set_value(GTK_SPIN_BUTTON(data
->NB_euro_value
), euro_params
[active
].value
);
792 gtk_spin_button_set_value(GTK_SPIN_BUTTON(data
->NB_euro_fracdigits
), euro_params
[active
].frac_digits
);
794 gtk_entry_set_text(GTK_ENTRY(data
->ST_euro_symbol
) , euro_params
[active
].symbol
);
795 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(data
->CM_euro_isprefix
), euro_params
[active
].sym_prefix
);
796 gtk_entry_set_text(GTK_ENTRY(data
->ST_euro_decimalchar
) , euro_params
[active
].decimal_char
);
797 gtk_entry_set_text(GTK_ENTRY(data
->ST_euro_groupingchar
), euro_params
[active
].grouping_char
);
802 static void defpref_colortoggle(GtkWidget
*widget
, gpointer user_data
)
804 struct defpref_data
*data
;
807 DB( g_print("\n[ui-pref] color toggle\n") );
809 data
= g_object_get_data(G_OBJECT(gtk_widget_get_ancestor(widget
, GTK_TYPE_WINDOW
)), "inst_data");
811 sensitive
= gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(data
->CM_custom_colors
));
813 gtk_widget_set_sensitive(data
->LB_colors
, sensitive
);
814 gtk_widget_set_sensitive(data
->CY_colors
, sensitive
);
815 gtk_widget_set_sensitive(data
->LB_exp_color
, sensitive
);
816 gtk_widget_set_sensitive(data
->GR_colors
, sensitive
);
820 static void defpref_backuptoggle(GtkWidget
*widget
, gpointer user_data
)
822 struct defpref_data
*data
;
825 DB( g_print("\n[ui-pref] backup toggle\n") );
827 data
= g_object_get_data(G_OBJECT(gtk_widget_get_ancestor(widget
, GTK_TYPE_WINDOW
)), "inst_data");
829 sensitive
= gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(data
->CM_bak_is_automatic
));
830 gtk_widget_set_sensitive(data
->LB_bak_max_num_copies
, sensitive
);
831 gtk_widget_set_sensitive(data
->NB_bak_max_num_copies
, sensitive
);
832 gtk_widget_set_sensitive(data
->GR_bak_freq
, sensitive
);
837 ** set preset colors for amount display
839 static void defpref_colorpreset(GtkWidget
*widget
, gpointer user_data
)
841 struct defpref_data
*data
;
844 gchar
*expcol
, *inccol
, *wrncol
;
846 DB( g_print("\n[ui-pref] color preset\n") );
848 data
= g_object_get_data(G_OBJECT(gtk_widget_get_ancestor(widget
, GTK_TYPE_WINDOW
)), "inst_data");
850 preset
= gtk_combo_box_get_active(GTK_COMBO_BOX(data
->CY_colors
));
855 expcol
= LIGHT_EXP_COLOR
;
856 inccol
= LIGHT_INC_COLOR
;
857 wrncol
= LIGHT_WARN_COLOR
;
861 expcol
= MEDIUM_EXP_COLOR
;
862 inccol
= MEDIUM_INC_COLOR
;
863 wrncol
= MEDIUM_WARN_COLOR
;
868 expcol
= DEFAULT_EXP_COLOR
;
869 inccol
= DEFAULT_INC_COLOR
;
870 wrncol
= DEFAULT_WARN_COLOR
;
875 gdk_rgba_parse(&rgba
, expcol
);
876 gtk_color_chooser_set_rgba(GTK_COLOR_CHOOSER(data
->CP_exp_color
), &rgba
);
878 gdk_rgba_parse(&rgba
, inccol
);
879 gtk_color_chooser_set_rgba(GTK_COLOR_CHOOSER(data
->CP_inc_color
), &rgba
);
881 gdk_rgba_parse(&rgba
, wrncol
);
882 gtk_color_chooser_set_rgba(GTK_COLOR_CHOOSER(data
->CP_warn_color
), &rgba
);
888 static void defpref_color_scheme_changed(GtkWidget
*widget
, gpointer user_data
)
890 struct defpref_data
*data
;
892 DB( g_print("\n[ui-pref] color scheme chnaged\n") );
894 data
= g_object_get_data(G_OBJECT(gtk_widget_get_ancestor(widget
, GTK_TYPE_WINDOW
)), "inst_data");
896 gtk_widget_queue_draw (data
->DA_colors
);
904 static void setGdkColor_from_RGB(GdkColor *color, guint32 value)
909 color->red = tmp | tmp<<8;
911 tmp = value >> 8 & 0xFF;
912 color->green = tmp | tmp<<8;
915 color->blue = tmp | tmp<<8;
921 ** set :: fill in widgets from PREFS structure
924 static void defpref_set(struct defpref_data
*data
)
928 DB( g_print("\n[ui-pref] set\n") );
931 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(data
->CM_show_splash
), PREFS
->showsplash
);
932 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(data
->CM_load_last
), PREFS
->loadlast
);
933 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(data
->CM_append_scheduled
), PREFS
->appendscheduled
);
934 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(data
->CM_do_update_currency
), PREFS
->do_update_currency
);
935 gtk_combo_box_set_active(GTK_COMBO_BOX(data
->CY_daterange_wal
), PREFS
->date_range_wal
);
936 gtk_spin_button_set_value(GTK_SPIN_BUTTON(data
->NB_fiscyearday
), PREFS
->fisc_year_day
);
937 gtk_combo_box_set_active(GTK_COMBO_BOX(data
->CY_fiscyearmonth
), PREFS
->fisc_year_month
- 1);
940 gtk_entry_set_text(GTK_ENTRY(data
->ST_path_hbfile
), PREFS
->path_hbfile
);
941 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(data
->CM_bak_is_automatic
), PREFS
->bak_is_automatic
);
942 gtk_spin_button_set_value(GTK_SPIN_BUTTON(data
->NB_bak_max_num_copies
), PREFS
->bak_max_num_copies
);
945 if(PREFS
->language
!= NULL
)
946 gtk_combo_box_set_active_id(GTK_COMBO_BOX(data
->CY_language
), PREFS
->language
);
948 gtk_combo_box_set_active (GTK_COMBO_BOX(data
->CY_language
), 0);
949 gtk_combo_box_set_active(GTK_COMBO_BOX(data
->CY_toolbar
), PREFS
->toolbar_style
);
950 //gtk_spin_button_set_value(GTK_SPIN_BUTTON(data->NB_image_size), PREFS->image_size);
952 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(data
->CM_custom_colors
), PREFS
->custom_colors
);
953 gdk_rgba_parse(&rgba
, PREFS
->color_exp
);
954 gtk_color_chooser_set_rgba(GTK_COLOR_CHOOSER(data
->CP_exp_color
), &rgba
);
955 gdk_rgba_parse(&rgba
, PREFS
->color_inc
);
956 gtk_color_chooser_set_rgba(GTK_COLOR_CHOOSER(data
->CP_inc_color
), &rgba
);
957 gdk_rgba_parse(&rgba
, PREFS
->color_warn
);
958 gtk_color_chooser_set_rgba(GTK_COLOR_CHOOSER(data
->CP_warn_color
), &rgba
);
959 //gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(data->CM_ruleshint), PREFS->rules_hint);
960 gtk_combo_box_set_active(GTK_COMBO_BOX(data
->CY_gridlines
), PREFS
->grid_lines
);
963 gtk_combo_box_set_active(GTK_COMBO_BOX(data
->CY_daterange_txn
), PREFS
->date_range_txn
);
964 gtk_spin_button_set_value(GTK_SPIN_BUTTON(data
->ST_datefuture_nbdays
), PREFS
->date_future_nbdays
);
965 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(data
->CM_hide_reconciled
), PREFS
->hidereconciled
);
966 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(data
->CM_show_remind
), PREFS
->showremind
);
967 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(data
->CM_herit_date
), PREFS
->heritdate
);
968 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(data
->CM_memoacp
), PREFS
->txn_memoacp
);
969 gtk_spin_button_set_value(GTK_SPIN_BUTTON(data
->ST_memoacp_days
), PREFS
->txn_memoacp_days
);
972 gtk_entry_set_text(GTK_ENTRY(data
->ST_datefmt
), PREFS
->date_format
);
973 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(data
->CM_unitismile
), PREFS
->vehicle_unit_ismile
);
974 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(data
->CM_unitisgal
), PREFS
->vehicle_unit_isgal
);
977 gtk_combo_box_set_active(GTK_COMBO_BOX(data
->CY_dtex_datefmt
), PREFS
->dtex_datefmt
);
978 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(data
->CM_dtex_ucfirst
), PREFS
->dtex_ucfirst
);
979 gtk_combo_box_set_active(GTK_COMBO_BOX(data
->CY_dtex_ofxname
), PREFS
->dtex_ofxname
);
980 gtk_combo_box_set_active(GTK_COMBO_BOX(data
->CY_dtex_ofxmemo
), PREFS
->dtex_ofxmemo
);
981 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(data
->CM_dtex_qifmemo
), PREFS
->dtex_qifmemo
);
982 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(data
->CM_dtex_qifswap
), PREFS
->dtex_qifswap
);
983 gtk_entry_set_text(GTK_ENTRY(data
->ST_path_import
), PREFS
->path_import
);
984 gtk_entry_set_text(GTK_ENTRY(data
->ST_path_export
), PREFS
->path_export
);
987 gtk_combo_box_set_active(GTK_COMBO_BOX(data
->CY_daterange_rep
), PREFS
->date_range_rep
);
988 gtk_combo_box_set_active(GTK_COMBO_BOX(data
->CY_color_scheme
), PREFS
->report_color_scheme
);
989 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(data
->CM_stat_byamount
), PREFS
->stat_byamount
);
990 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(data
->CM_stat_showrate
), PREFS
->stat_showrate
);
991 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(data
->CM_stat_showdetail
), PREFS
->stat_showdetail
);
992 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(data
->CM_budg_showdetail
), PREFS
->budg_showdetail
);
995 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(data
->CM_euro_enable
), PREFS
->euro_active
);
996 //gtk_combo_box_set_active(GTK_COMBO_BOX(data->CY_euro_preset), PREFS->euro_country);
997 data
->country
= PREFS
->euro_country
;
998 defpref_eurosetcurrency(data
->window
, data
->country
);
999 gtk_spin_button_set_value(GTK_SPIN_BUTTON(data
->NB_euro_value
), PREFS
->euro_value
);
1000 ui_gtk_entry_set_text(data
->ST_euro_symbol
, PREFS
->minor_cur
.symbol
);
1001 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(data
->CM_euro_isprefix
), PREFS
->minor_cur
.sym_prefix
);
1002 ui_gtk_entry_set_text(data
->ST_euro_decimalchar
, PREFS
->minor_cur
.decimal_char
);
1003 ui_gtk_entry_set_text(data
->ST_euro_groupingchar
, PREFS
->minor_cur
.grouping_char
);
1004 gtk_spin_button_set_value(GTK_SPIN_BUTTON(data
->NB_euro_fracdigits
), PREFS
->minor_cur
.frac_digits
);
1006 //gtk_entry_set_text(GTK_ENTRY(data->ST_euro_symbol), PREFS->euro_symbol);
1007 //gtk_spin_button_set_value(GTK_SPIN_BUTTON(data->NB_euro_nbdec), PREFS->euro_nbdec);
1008 //gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(data->CM_euro_thsep), PREFS->euro_thsep);
1013 ** get :: fill PREFS structure from widgets
1015 #define RGBA_TO_INT(x) (int)(x*255)
1017 static gchar
*gdk_rgba_to_hex(GdkRGBA
*rgba
)
1019 return g_strdup_printf("#%02x%02x%02x", RGBA_TO_INT(rgba
->red
), RGBA_TO_INT(rgba
->green
), RGBA_TO_INT(rgba
->blue
));
1023 static void defpref_get(struct defpref_data
*data
)
1028 DB( g_print("\n[ui-pref] get\n") );
1031 PREFS
->showsplash
= gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(data
->CM_show_splash
));
1032 PREFS
->loadlast
= gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(data
->CM_load_last
));
1033 PREFS
->appendscheduled
= gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(data
->CM_append_scheduled
));
1034 PREFS
->do_update_currency
= gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(data
->CM_do_update_currency
));
1035 PREFS
->date_range_wal
= gtk_combo_box_get_active(GTK_COMBO_BOX(data
->CY_daterange_wal
));
1036 PREFS
->fisc_year_day
= gtk_spin_button_get_value(GTK_SPIN_BUTTON(data
->NB_fiscyearday
));
1037 PREFS
->fisc_year_month
= 1 + gtk_combo_box_get_active(GTK_COMBO_BOX(data
->CY_fiscyearmonth
));
1040 ui_gtk_entry_replace_text(data
->ST_path_hbfile
, &PREFS
->path_hbfile
);
1042 PREFS
->bak_is_automatic
= gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(data
->CM_bak_is_automatic
));
1043 PREFS
->bak_max_num_copies
= gtk_spin_button_get_value(GTK_SPIN_BUTTON(data
->NB_bak_max_num_copies
));
1045 g_free(PREFS
->language
);
1046 PREFS
->language
= NULL
;
1047 lang
= gtk_combo_box_get_active_id(GTK_COMBO_BOX(data
->CY_language
));
1050 PREFS
->language
= g_strdup(lang
);
1053 PREFS
->toolbar_style
= gtk_combo_box_get_active(GTK_COMBO_BOX(data
->CY_toolbar
));
1054 //PREFS->image_size = gtk_spin_button_get_value(GTK_SPIN_BUTTON(data->NB_image_size));
1056 PREFS
->custom_colors
= gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(data
->CM_custom_colors
));
1057 gtk_color_chooser_get_rgba(GTK_COLOR_CHOOSER(data
->CP_exp_color
), &rgba
);
1058 g_free(PREFS
->color_exp
);
1059 PREFS
->color_exp
= gdk_rgba_to_hex(&rgba
);
1060 gtk_color_chooser_get_rgba(GTK_COLOR_CHOOSER(data
->CP_inc_color
), &rgba
);
1061 g_free(PREFS
->color_inc
);
1062 PREFS
->color_inc
= gdk_rgba_to_hex(&rgba
);
1063 gtk_color_chooser_get_rgba(GTK_COLOR_CHOOSER(data
->CP_warn_color
), &rgba
);
1064 g_free(PREFS
->color_warn
);
1065 PREFS
->color_warn
= gdk_rgba_to_hex(&rgba
);
1066 //PREFS->rules_hint = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(data->CM_ruleshint));
1067 PREFS
->grid_lines
= gtk_combo_box_get_active(GTK_COMBO_BOX(data
->CY_gridlines
));
1068 //list_txn_colpref_get(GTK_TREE_VIEW(data->LV_opecolumns), PREFS->lst_ope_columns);
1071 PREFS
->date_range_txn
= gtk_combo_box_get_active(GTK_COMBO_BOX(data
->CY_daterange_txn
));
1072 PREFS
->date_future_nbdays
= gtk_spin_button_get_value(GTK_SPIN_BUTTON(data
->ST_datefuture_nbdays
));
1073 PREFS
->hidereconciled
= gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(data
->CM_hide_reconciled
));
1074 PREFS
->showremind
= gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(data
->CM_show_remind
));
1075 PREFS
->heritdate
= gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(data
->CM_herit_date
));
1076 PREFS
->txn_memoacp
= gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(data
->CM_memoacp
));
1077 PREFS
->txn_memoacp_days
= gtk_spin_button_get_value(GTK_SPIN_BUTTON(data
->ST_memoacp_days
));
1080 g_free(PREFS
->date_format
);
1081 PREFS
->date_format
= g_strdup(gtk_entry_get_text(GTK_ENTRY(data
->ST_datefmt
)));
1082 PREFS
->vehicle_unit_ismile
= gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(data
->CM_unitismile
));
1083 PREFS
->vehicle_unit_isgal
= gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(data
->CM_unitisgal
));
1086 PREFS
->dtex_datefmt
= gtk_combo_box_get_active(GTK_COMBO_BOX(data
->CY_dtex_datefmt
));
1087 PREFS
->dtex_ucfirst
= gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(data
->CM_dtex_ucfirst
));
1088 PREFS
->dtex_ofxname
= gtk_combo_box_get_active(GTK_COMBO_BOX(data
->CY_dtex_ofxname
));
1089 PREFS
->dtex_ofxmemo
= gtk_combo_box_get_active(GTK_COMBO_BOX(data
->CY_dtex_ofxmemo
));
1090 PREFS
->dtex_qifmemo
= gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(data
->CM_dtex_qifmemo
));
1091 PREFS
->dtex_qifswap
= gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(data
->CM_dtex_qifswap
));
1092 ui_gtk_entry_replace_text(data
->ST_path_import
, &PREFS
->path_import
);
1093 ui_gtk_entry_replace_text(data
->ST_path_export
, &PREFS
->path_export
);
1096 PREFS
->date_range_rep
= gtk_combo_box_get_active(GTK_COMBO_BOX(data
->CY_daterange_rep
));
1097 PREFS
->report_color_scheme
= gtk_combo_box_get_active(GTK_COMBO_BOX(data
->CY_color_scheme
));
1098 PREFS
->stat_byamount
= gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(data
->CM_stat_byamount
));
1099 PREFS
->stat_showrate
= gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(data
->CM_stat_showrate
));
1100 PREFS
->stat_showdetail
= gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(data
->CM_stat_showdetail
));
1101 PREFS
->budg_showdetail
= gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(data
->CM_budg_showdetail
));
1104 PREFS
->euro_active
= gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(data
->CM_euro_enable
));
1105 PREFS
->euro_country
= data
->country
;
1106 PREFS
->euro_value
= gtk_spin_button_get_value(GTK_SPIN_BUTTON(data
->NB_euro_value
));
1107 //strcpy(PREFS->euro_symbol, gtk_entry_get_text(GTK_ENTRY(data->ST_euro_symbol)));
1108 //PREFS->euro_nbdec = gtk_spin_button_get_value(GTK_SPIN_BUTTON(data->NB_euro_nbdec));
1109 //PREFS->euro_thsep = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(data->CM_euro_thsep));
1110 ui_gtk_entry_replace_text(data
->ST_euro_symbol
, &PREFS
->minor_cur
.symbol
);
1111 PREFS
->minor_cur
.sym_prefix
= gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(data
->CM_euro_isprefix
));
1112 ui_gtk_entry_replace_text(data
->ST_euro_decimalchar
, &PREFS
->minor_cur
.decimal_char
);
1113 ui_gtk_entry_replace_text(data
->ST_euro_groupingchar
, &PREFS
->minor_cur
.grouping_char
);
1114 PREFS
->minor_cur
.frac_digits
= gtk_spin_button_get_value(GTK_SPIN_BUTTON(data
->NB_euro_fracdigits
));
1115 //PREFS->chart_legend = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(data->CM_chartlegend));
1117 list_ext_colpref_get(GTK_TREE_VIEW(data
->PI_plugin_columns
), &(PREFS
->ext_whitelist
));
1121 static GtkWidget
*defpref_page_import (struct defpref_data
*data
)
1123 GtkWidget
*content_grid
, *group_grid
, *label
, *widget
;
1126 content_grid
= gtk_grid_new();
1127 gtk_grid_set_row_spacing (GTK_GRID (content_grid
), SPACING_LARGE
);
1128 gtk_orientable_set_orientation(GTK_ORIENTABLE(content_grid
), GTK_ORIENTATION_VERTICAL
);
1131 // group :: Date options
1132 group_grid
= gtk_grid_new ();
1133 gtk_grid_set_row_spacing (GTK_GRID (group_grid
), SPACING_SMALL
);
1134 gtk_grid_set_column_spacing (GTK_GRID (group_grid
), SPACING_MEDIUM
);
1135 gtk_grid_attach (GTK_GRID (content_grid
), group_grid
, 0, crow
++, 1, 1);
1137 label
= make_label_group(_("Date options"));
1138 gtk_grid_attach (GTK_GRID (group_grid
), label
, 0, 0, 3, 1);
1141 label
= make_label_widget(_("Date order:"));
1142 //----------------------------------------- l, r, t, b
1143 gtk_grid_attach (GTK_GRID (group_grid
), label
, 1, row
, 1, 1);
1144 widget
= make_cycle(label
, CYA_IMPORT_DATEORDER
);
1145 data
->CY_dtex_datefmt
= widget
;
1146 //gtk_grid_attach (GTK_GRID (group_grid), data->CY_option[FILTER_DATE], 1, 2, row, row+1);
1147 gtk_grid_attach (GTK_GRID (group_grid
), widget
, 2, row
, 1, 1);
1150 // group :: OFX/QFX options
1151 group_grid
= gtk_grid_new ();
1152 gtk_grid_set_row_spacing (GTK_GRID (group_grid
), SPACING_SMALL
);
1153 gtk_grid_set_column_spacing (GTK_GRID (group_grid
), SPACING_MEDIUM
);
1154 gtk_grid_attach (GTK_GRID (content_grid
), group_grid
, 0, crow
++, 1, 1);
1156 label
= make_label_group(_("OFX/QFX options"));
1157 gtk_grid_attach (GTK_GRID (group_grid
), label
, 0, 0, 3, 1);
1160 label
= make_label_widget(_("OFX _Name:"));
1161 //----------------------------------------- l, r, t, b
1162 gtk_grid_attach (GTK_GRID (group_grid
), label
, 1, row
, 1, 1);
1163 widget
= make_cycle(label
, CYA_IMPORT_OFXNAME
);
1164 data
->CY_dtex_ofxname
= widget
;
1165 //gtk_grid_attach (GTK_GRID (group_grid), data->CY_option[FILTER_DATE], 1, 2, row, row+1);
1166 gtk_grid_attach (GTK_GRID (group_grid
), widget
, 2, row
, 1, 1);
1169 label
= make_label_widget(_("OFX _Memo:"));
1170 //----------------------------------------- l, r, t, b
1171 gtk_grid_attach (GTK_GRID (group_grid
), label
, 1, row
, 1, 1);
1172 widget
= make_cycle(label
, CYA_IMPORT_OFXMEMO
);
1173 data
->CY_dtex_ofxmemo
= widget
;
1174 //gtk_grid_attach (GTK_GRID (group_grid), data->CY_option[FILTER_DATE], 1, 2, row, row+1);
1175 gtk_grid_attach (GTK_GRID (group_grid
), widget
, 2, row
, 1, 1);
1177 // group :: QIF options
1178 group_grid
= gtk_grid_new ();
1179 gtk_grid_set_row_spacing (GTK_GRID (group_grid
), SPACING_SMALL
);
1180 gtk_grid_set_column_spacing (GTK_GRID (group_grid
), SPACING_MEDIUM
);
1181 gtk_grid_attach (GTK_GRID (content_grid
), group_grid
, 0, crow
++, 1, 1);
1183 label
= make_label_group(_("QIF options"));
1184 gtk_grid_attach (GTK_GRID (group_grid
), label
, 0, 0, 3, 1);
1187 widget
= gtk_check_button_new_with_mnemonic (_("_Import memos"));
1188 data
->CM_dtex_qifmemo
= widget
;
1189 gtk_grid_attach (GTK_GRID (group_grid
), widget
, 1, row
, 1, 1);
1190 widget
= gtk_check_button_new_with_mnemonic (_("_Swap memos with payees"));
1191 data
->CM_dtex_qifswap
= widget
;
1192 gtk_grid_attach (GTK_GRID (group_grid
), widget
, 2, row
, 1, 1);
1194 // group :: other options
1195 group_grid
= gtk_grid_new ();
1196 gtk_grid_set_row_spacing (GTK_GRID (group_grid
), SPACING_SMALL
);
1197 gtk_grid_set_column_spacing (GTK_GRID (group_grid
), SPACING_MEDIUM
);
1198 gtk_grid_attach (GTK_GRID (content_grid
), group_grid
, 0, crow
++, 1, 1);
1200 label
= make_label_group(_("Other options"));
1201 gtk_grid_attach (GTK_GRID (group_grid
), label
, 0, 0, 3, 1);
1204 widget
= gtk_check_button_new_with_mnemonic (_("Sentence _case memo/payee"));
1205 data
->CM_dtex_ucfirst
= widget
;
1206 gtk_grid_attach (GTK_GRID (group_grid
), widget
, 1, row
, 1, 1);
1209 return content_grid
;
1215 draw_callback (GtkWidget
*widget
,
1219 struct defpref_data
*data
= user_data
;
1221 GtkColorScheme scheme
;
1225 index
= gtk_combo_box_get_active(GTK_COMBO_BOX(data
->CY_color_scheme
));
1227 colorscheme_init(&scheme
, index
);
1229 gtk_widget_get_size_request (widget
, &w
, &h
);
1231 for(i
=0;i
<scheme
.nb_cols
;i
++)
1233 cairo_user_set_rgbcol (cr
, &scheme
.colors
[i
]);
1234 cairo_rectangle(cr
, x
, y
, cube_dim
, cube_dim
);
1238 { x
= 0; y
= 1 + cube_dim
; }
1246 static GtkWidget
*defpref_page_reports (struct defpref_data
*data
)
1248 GtkWidget
*content_grid
, *group_grid
, *label
, *widget
;
1251 content_grid
= gtk_grid_new();
1252 gtk_grid_set_row_spacing (GTK_GRID (content_grid
), SPACING_LARGE
);
1253 gtk_orientable_set_orientation(GTK_ORIENTABLE(content_grid
), GTK_ORIENTATION_VERTICAL
);
1256 // group :: Initial filter
1257 group_grid
= gtk_grid_new ();
1258 gtk_grid_set_row_spacing (GTK_GRID (group_grid
), SPACING_SMALL
);
1259 gtk_grid_set_column_spacing (GTK_GRID (group_grid
), SPACING_MEDIUM
);
1260 gtk_grid_attach (GTK_GRID (content_grid
), group_grid
, 0, crow
++, 1, 1);
1262 label
= make_label_group(_("Initial filter"));
1263 gtk_grid_attach (GTK_GRID (group_grid
), label
, 0, 0, 3, 1);
1266 label
= make_label_widget(_("_Range:"));
1267 //----------------------------------------- l, r, t, b
1268 gtk_grid_attach (GTK_GRID (group_grid
), label
, 1, row
, 1, 1);
1269 widget
= make_daterange(label
, FALSE
);
1270 data
->CY_daterange_rep
= widget
;
1271 //gtk_grid_attach (GTK_GRID (group_grid), data->CY_option[FILTER_DATE], 1, 2, row, row+1);
1272 gtk_grid_attach (GTK_GRID (group_grid
), widget
, 2, row
, 1, 1);
1274 // group ::Charts options
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(_("Charts options"));
1281 gtk_grid_attach (GTK_GRID (group_grid
), label
, 0, 0, 3, 1);
1284 label
= make_label_widget(_("Color scheme:"));
1285 //----------------------------------------- l, r, t, b
1286 gtk_grid_attach (GTK_GRID (group_grid
), label
, 1, row
, 1, 1);
1287 widget
= make_cycle(label
, chart_colors
);
1288 data
->CY_color_scheme
= 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);
1293 widget
= gtk_drawing_area_new ();
1294 data
->DA_colors
= widget
;
1295 gtk_widget_set_size_request (widget
, (1+cube_dim
)*16, (1+cube_dim
)*2);
1296 gtk_grid_attach (GTK_GRID (group_grid
), widget
, 2, row
, 1, 1);
1298 g_signal_connect (data
->DA_colors
, "draw", G_CALLBACK (draw_callback
), data
);
1300 // group :: Statistics options
1301 group_grid
= gtk_grid_new ();
1302 gtk_grid_set_row_spacing (GTK_GRID (group_grid
), SPACING_SMALL
);
1303 gtk_grid_set_column_spacing (GTK_GRID (group_grid
), SPACING_MEDIUM
);
1304 gtk_grid_attach (GTK_GRID (content_grid
), group_grid
, 0, crow
++, 1, 1);
1306 label
= make_label_group(_("Statistics options"));
1307 gtk_grid_attach (GTK_GRID (group_grid
), label
, 0, 0, 3, 1);
1310 widget
= gtk_check_button_new_with_mnemonic (_("Show by _amount"));
1311 data
->CM_stat_byamount
= widget
;
1312 gtk_grid_attach (GTK_GRID (group_grid
), widget
, 1, row
, 2, 1);
1315 widget
= gtk_check_button_new_with_mnemonic (_("Show _rate column"));
1316 data
->CM_stat_showrate
= widget
;
1317 gtk_grid_attach (GTK_GRID (group_grid
), widget
, 1, row
, 2, 1);
1320 widget
= gtk_check_button_new_with_mnemonic (_("Show _details"));
1321 data
->CM_stat_showdetail
= widget
;
1322 gtk_grid_attach (GTK_GRID (group_grid
), widget
, 1, row
, 2, 1);
1324 // group :: Budget options
1325 group_grid
= gtk_grid_new ();
1326 gtk_grid_set_row_spacing (GTK_GRID (group_grid
), SPACING_SMALL
);
1327 gtk_grid_set_column_spacing (GTK_GRID (group_grid
), SPACING_MEDIUM
);
1328 gtk_grid_attach (GTK_GRID (content_grid
), group_grid
, 0, crow
++, 1, 1);
1330 label
= make_label_group(_("Budget options"));
1331 gtk_grid_attach (GTK_GRID (group_grid
), label
, 0, 0, 3, 1);
1334 widget
= gtk_check_button_new_with_mnemonic (_("Show _details"));
1335 data
->CM_budg_showdetail
= widget
;
1336 gtk_grid_attach (GTK_GRID (group_grid
), widget
, 1, row
, 2, 1);
1338 return content_grid
;
1342 static GtkWidget
*defpref_page_euro (struct defpref_data
*data
)
1344 GtkWidget
*content_grid
, *group_grid
, *label
, *widget
, *expander
;
1347 content_grid
= gtk_grid_new();
1348 gtk_grid_set_row_spacing (GTK_GRID (content_grid
), SPACING_LARGE
);
1349 gtk_orientable_set_orientation(GTK_ORIENTABLE(content_grid
), GTK_ORIENTATION_VERTICAL
);
1353 group_grid
= gtk_grid_new ();
1354 gtk_grid_set_row_spacing (GTK_GRID (group_grid
), SPACING_SMALL
);
1355 gtk_grid_set_column_spacing (GTK_GRID (group_grid
), SPACING_MEDIUM
);
1356 gtk_grid_attach (GTK_GRID (content_grid
), group_grid
, 0, crow
++, 1, 1);
1358 label
= make_label_group(_("General"));
1359 gtk_grid_attach (GTK_GRID (group_grid
), label
, 0, 0, 3, 1);
1362 widget
= gtk_check_button_new_with_mnemonic (_("_Enable"));
1363 data
->CM_euro_enable
= widget
;
1364 gtk_grid_attach (GTK_GRID (group_grid
), widget
, 1, row
, 2, 1);
1366 // group :: Currency
1367 group_grid
= gtk_grid_new ();
1368 data
->GRP_currency
= group_grid
;
1369 gtk_grid_set_row_spacing (GTK_GRID (group_grid
), SPACING_SMALL
);
1370 gtk_grid_set_column_spacing (GTK_GRID (group_grid
), SPACING_MEDIUM
);
1371 gtk_grid_attach (GTK_GRID (content_grid
), group_grid
, 0, crow
++, 1, 1);
1373 label
= make_label_group(_("Currency"));
1374 gtk_grid_attach (GTK_GRID (group_grid
), label
, 0, 0, 4, 1);
1377 widget
= make_label(NULL
, 0.0, 0.5);
1378 data
->ST_euro_country
= widget
;
1379 //gtk_grid_attach (GTK_GRID (group_grid), data->CY_option[FILTER_DATE], 1, 2, row, row+1);
1380 gtk_grid_attach (GTK_GRID (group_grid
), widget
, 1, row
, 1, 1);
1383 label
= make_label_widget(_("_Preset:"));
1384 //----------------------------------------- l, r, t, b
1385 gtk_grid_attach (GTK_GRID (group_grid
), label
, 2, row
, 1, 1);
1386 widget
= ui_euro_combobox_new (label
);
1387 data
->CY_euro_preset
= widget
;
1388 gtk_widget_set_margin_left (label
, 2*SPACING_LARGE
);
1389 //gtk_grid_attach (GTK_GRID (group_grid), data->CY_option[FILTER_DATE], 1, 2, row, row+1);
1390 gtk_grid_attach (GTK_GRID (group_grid
), widget
, 3, row
, 1, 1);
1393 // group :: Exchange rate
1394 group_grid
= gtk_grid_new ();
1395 data
->GRP_rate
= group_grid
;
1396 gtk_grid_set_row_spacing (GTK_GRID (group_grid
), SPACING_SMALL
);
1397 gtk_grid_set_column_spacing (GTK_GRID (group_grid
), SPACING_MEDIUM
);
1398 gtk_grid_attach (GTK_GRID (content_grid
), group_grid
, 0, crow
++, 1, 1);
1400 label
= make_label_group(_("Exchange rate"));
1401 gtk_grid_attach (GTK_GRID (group_grid
), label
, 0, 0, 3, 1);
1404 label
= make_label_widget("1 EUR _=");
1405 gtk_grid_attach (GTK_GRID (group_grid
), label
, 1, row
, 1, 1);
1406 widget
= make_exchange_rate(label
);
1407 data
->NB_euro_value
= widget
;
1408 //gtk_grid_attach (GTK_GRID (group_grid), data->CY_option[FILTER_DATE], 1, 2, row, row+1);
1409 gtk_grid_attach (GTK_GRID (group_grid
), widget
, 2, row
, 1, 1);
1411 // group :: Numbers format
1412 group_grid
= gtk_grid_new ();
1413 data
->GRP_format
= 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(_("Format"));
1419 gtk_grid_attach (GTK_GRID (group_grid
), label
, 0, 0, 3, 1);
1422 widget
= make_label(NULL
, 0, 0.0);
1423 data
->LB_numbereuro
= widget
;
1424 gtk_grid_attach (GTK_GRID (group_grid
), widget
, 1, row
, 1, 1);
1427 expander
= gtk_expander_new_with_mnemonic(_("_Customize"));
1428 gtk_grid_attach (GTK_GRID (group_grid
), expander
, 1, row
, 1, 1);
1430 group_grid
= gtk_grid_new ();
1431 gtk_grid_set_row_spacing (GTK_GRID (group_grid
), SPACING_SMALL
);
1432 gtk_grid_set_column_spacing (GTK_GRID (group_grid
), SPACING_MEDIUM
);
1433 gtk_container_add (GTK_CONTAINER (expander
), group_grid
);
1436 label
= make_label_widget(_("_Symbol:"));
1437 gtk_grid_attach (GTK_GRID (group_grid
), label
, 1, row
, 1, 1);
1438 widget
= make_string_maxlength(label
, 3);
1439 data
->ST_euro_symbol
= widget
;
1440 gtk_grid_attach (GTK_GRID (group_grid
), widget
, 2, row
, 1, 1);
1443 widget
= gtk_check_button_new_with_mnemonic (_("Is pre_fix"));
1444 data
->CM_euro_isprefix
= widget
;
1445 gtk_grid_attach (GTK_GRID (group_grid
), widget
, 2, row
, 1, 1);
1448 label
= make_label_widget(_("_Decimal char:"));
1449 gtk_grid_attach (GTK_GRID (group_grid
), label
, 1, row
, 1, 1);
1450 widget
= make_string_maxlength(label
, 1);
1451 data
->ST_euro_decimalchar
= widget
;
1452 gtk_grid_attach (GTK_GRID (group_grid
), widget
, 2, row
, 1, 1);
1455 label
= make_label_widget(_("_Frac digits:"));
1456 gtk_grid_attach (GTK_GRID (group_grid
), label
, 1, row
, 1, 1);
1457 widget
= make_numeric(label
, 0.0, 6.0);
1458 data
->NB_euro_fracdigits
= widget
;
1459 gtk_grid_attach (GTK_GRID (group_grid
), widget
, 2, row
, 1, 1);
1462 label
= make_label_widget(_("_Grouping char:"));
1463 gtk_grid_attach (GTK_GRID (group_grid
), label
, 1, row
, 1, 1);
1464 widget
= make_string_maxlength(label
, 1);
1465 data
->ST_euro_groupingchar
= widget
;
1466 gtk_grid_attach (GTK_GRID (group_grid
), widget
, 2, row
, 1, 1);
1468 return content_grid
;
1472 static GtkWidget
*defpref_page_display (struct defpref_data
*data
)
1474 GtkWidget
*content_grid
, *group_grid
, *label
, *widget
, *expander
, *hbox
;
1477 content_grid
= gtk_grid_new();
1478 gtk_grid_set_row_spacing (GTK_GRID (content_grid
), SPACING_LARGE
);
1479 gtk_orientable_set_orientation(GTK_ORIENTABLE(content_grid
), GTK_ORIENTATION_VERTICAL
);
1483 group_grid
= gtk_grid_new ();
1484 gtk_grid_set_row_spacing (GTK_GRID (group_grid
), SPACING_SMALL
);
1485 gtk_grid_set_column_spacing (GTK_GRID (group_grid
), SPACING_MEDIUM
);
1486 gtk_grid_attach (GTK_GRID (content_grid
), group_grid
, 0, crow
++, 1, 1);
1488 label
= make_label_group(_("User interface"));
1489 gtk_grid_attach (GTK_GRID (group_grid
), label
, 0, 0, 3, 1);
1492 label
= make_label(_("_Language:"), 0, 0.5);
1493 gtk_grid_attach (GTK_GRID (group_grid
), label
, 1, row
, 1, 1);
1494 widget
= ui_language_combobox_new(label
);
1495 data
->CY_language
= widget
;
1496 gtk_grid_attach (GTK_GRID (group_grid
), widget
, 2, row
, 1, 1);
1500 label
= make_label(_("_Date display:"), 0, 0.5);
1501 gtk_grid_attach (GTK_GRID (group_grid
), label
, 1, row
, 1, 1);
1502 widget
= make_label(NULL
, 0, 0.5);
1503 data
->LB_date
= widget
;
1504 gtk_grid_attach (GTK_GRID (group_grid
), widget
, 2, row
, 1, 1);
1507 expander
= gtk_expander_new_with_mnemonic(_("_Customize"));
1508 gtk_grid_attach (GTK_GRID (group_grid
), expander
, 2, row
, 1, 1);
1510 group_grid
= gtk_grid_new ();
1511 gtk_grid_set_row_spacing (GTK_GRID (group_grid
), SPACING_SMALL
);
1512 gtk_grid_set_column_spacing (GTK_GRID (group_grid
), SPACING_MEDIUM
);
1513 gtk_container_add (GTK_CONTAINER (expander
), group_grid
);
1516 label
= make_label_widget(_("_Format:"));
1517 //----------------------------------------- l, r, t, b
1518 gtk_grid_attach (GTK_GRID (group_grid
), label
, 1, row
, 1, 1);
1519 widget
= make_string(label
);
1520 data
->ST_datefmt
= widget
;
1521 //gtk_grid_attach (GTK_GRID (group_grid), data->CY_option[FILTER_DATE], 1, 2, row, row+1);
1522 gtk_grid_attach (GTK_GRID (group_grid
), widget
, 2, row
, 1, 1);
1524 widget
= gtk_image_new_from_icon_name (ICONNAME_INFO
, GTK_ICON_SIZE_BUTTON
);
1525 gtk_grid_attach (GTK_GRID (group_grid
), widget
, 3, row
, 1, 1);
1528 gtk_widget_set_tooltip_text(widget
,
1529 _("%a locale's abbreviated weekday name.\n"
1530 "%A locale's full weekday name. \n"
1531 "%b locale's abbreviated month name. \n"
1532 "%B locale's full month name. \n"
1533 "%c locale's appropriate date and time representation. \n"
1534 "%C century number (the year divided by 100 and truncated to an integer) as a decimal number [00-99]. \n"
1535 "%d day of the month as a decimal number [01,31]. \n"
1536 "%D same as %m/%d/%y. \n"
1537 "%e day of the month as a decimal number [1,31]; a single digit is preceded by a space. \n"
1538 "%j day of the year as a decimal number [001,366]. \n"
1539 "%m month as a decimal number [01,12]. \n"
1540 "%p locale's appropriate date representation. \n"
1541 "%y year without century as a decimal number [00,99]. \n"
1542 "%Y year with century as a decimal number.")
1546 widget
= make_label(NULL
, 0.0, 0.5);
1547 gtk_label_set_markup (GTK_LABEL(widget
), "<small><a href=\"http://man7.org/linux/man-pages/man3/strftime.3.html\">online reference</a></small>");
1548 gtk_grid_attach (GTK_GRID (group_grid
), widget
, 2, row
, 1, 1);
1553 // group :: Fiscal year
1554 group_grid
= gtk_grid_new ();
1555 gtk_grid_set_row_spacing (GTK_GRID (group_grid
), SPACING_SMALL
);
1556 gtk_grid_set_column_spacing (GTK_GRID (group_grid
), SPACING_MEDIUM
);
1557 gtk_grid_attach (GTK_GRID (content_grid
), group_grid
, 0, crow
++, 1, 1);
1559 label
= make_label_group(_("Fiscal year"));
1560 gtk_grid_attach (GTK_GRID (group_grid
), label
, 0, 0, 3, 1);
1563 //TRANSLATORS: (fiscal year) starts on
1564 label
= make_label_widget(_("Starts _on:"));
1565 gtk_grid_attach (GTK_GRID (group_grid
), label
, 1, row
, 1, 1);
1567 hbox
= gtk_box_new(GTK_ORIENTATION_HORIZONTAL
, SPACING_SMALL
);
1568 gtk_grid_attach (GTK_GRID (group_grid
), hbox
, 2, row
, 1, 1);
1569 widget
= make_numeric (label
, 1, 28);
1570 data
->NB_fiscyearday
= widget
;
1571 gtk_box_pack_start (GTK_BOX (hbox
), widget
, FALSE
, FALSE
, 0);
1572 widget
= make_cycle (NULL
, CYA_MONTHS
);
1573 data
->CY_fiscyearmonth
= widget
;
1574 gtk_box_pack_start (GTK_BOX (hbox
), widget
, FALSE
, FALSE
, 0);
1578 // group :: Measurement units
1579 group_grid
= gtk_grid_new ();
1580 gtk_grid_set_row_spacing (GTK_GRID (group_grid
), SPACING_SMALL
);
1581 gtk_grid_set_column_spacing (GTK_GRID (group_grid
), SPACING_MEDIUM
);
1582 gtk_grid_attach (GTK_GRID (content_grid
), group_grid
, 0, crow
++, 1, 1);
1584 label
= make_label_group(_("Measurement units"));
1585 gtk_grid_attach (GTK_GRID (group_grid
), label
, 0, 0, 3, 1);
1588 widget
= gtk_check_button_new_with_mnemonic (_("Use _miles for meter"));
1589 data
->CM_unitismile
= widget
;
1590 gtk_grid_attach (GTK_GRID (group_grid
), widget
, 1, row
, 2, 1);
1593 widget
= gtk_check_button_new_with_mnemonic (_("Use _gallon for fuel"));
1594 data
->CM_unitisgal
= widget
;
1595 gtk_grid_attach (GTK_GRID (group_grid
), widget
, 1, row
, 2, 1);
1597 return content_grid
;
1601 static GtkWidget
*defpref_page_transactions (struct defpref_data
*data
)
1603 GtkWidget
*content_grid
, *group_grid
, *label
, *widget
;
1606 content_grid
= gtk_grid_new();
1607 gtk_grid_set_row_spacing (GTK_GRID (content_grid
), SPACING_LARGE
);
1608 gtk_orientable_set_orientation(GTK_ORIENTABLE(content_grid
), GTK_ORIENTATION_VERTICAL
);
1611 // group :: Transaction window
1612 group_grid
= gtk_grid_new ();
1613 gtk_grid_set_row_spacing (GTK_GRID (group_grid
), SPACING_SMALL
);
1614 gtk_grid_set_column_spacing (GTK_GRID (group_grid
), SPACING_MEDIUM
);
1615 gtk_grid_attach (GTK_GRID (content_grid
), group_grid
, 0, crow
++, 1, 1);
1617 label
= make_label_group(_("Transaction window"));
1618 gtk_grid_attach (GTK_GRID (group_grid
), label
, 0, 0, 3, 1);
1621 label
= make_label(_("_Range:"), 0, 0.5);
1622 //----------------------------------------- l, r, t, b
1623 gtk_grid_attach (GTK_GRID (group_grid
), label
, 1, row
, 1, 1);
1624 widget
= make_daterange(label
, FALSE
);
1625 data
->CY_daterange_txn
= widget
;
1626 gtk_grid_attach (GTK_GRID (group_grid
), widget
, 2, row
, 1, 1);
1629 label
= make_label(_("_Show future:"), 0, 0.5);
1630 //----------------------------------------- l, r, t, b
1631 gtk_grid_attach (GTK_GRID (group_grid
), label
, 1, row
, 1, 1);
1632 widget
= make_numeric(NULL
, 0, 366);
1634 data
->ST_datefuture_nbdays
= widget
;
1635 gtk_grid_attach (GTK_GRID (group_grid
), widget
, 2, row
, 1, 1);
1637 //TRANSLATORS: there is a spinner on the left of this label, and so you have 0....x days in advance the current date
1638 label
= make_label(_("days ahead"), 0, 0.5);
1639 gtk_grid_attach (GTK_GRID (group_grid
), label
, 3, row
, 1, 1);
1642 widget
= gtk_check_button_new_with_mnemonic (_("Hide reconciled transactions"));
1643 data
->CM_hide_reconciled
= widget
;
1644 gtk_grid_attach (GTK_GRID (group_grid
), widget
, 1, row
, 3, 1);
1647 widget
= gtk_check_button_new_with_mnemonic (_("Always show remind transactions"));
1648 data
->CM_show_remind
= widget
;
1649 gtk_grid_attach (GTK_GRID (group_grid
), widget
, 1, row
, 3, 1);
1651 // group :: Multiple add
1652 group_grid
= gtk_grid_new ();
1653 gtk_grid_set_row_spacing (GTK_GRID (group_grid
), SPACING_SMALL
);
1654 gtk_grid_set_column_spacing (GTK_GRID (group_grid
), SPACING_MEDIUM
);
1655 gtk_grid_attach (GTK_GRID (content_grid
), group_grid
, 0, crow
++, 1, 1);
1657 label
= make_label_group(_("Multiple add"));
1658 gtk_grid_attach (GTK_GRID (group_grid
), label
, 0, 0, 3, 1);
1661 widget
= gtk_check_button_new_with_mnemonic (_("Keep the last date"));
1662 data
->CM_herit_date
= widget
;
1663 gtk_grid_attach (GTK_GRID (group_grid
), widget
, 1, row
, 2, 1);
1665 // group :: Memo autocomplete
1666 group_grid
= gtk_grid_new ();
1667 gtk_grid_set_row_spacing (GTK_GRID (group_grid
), SPACING_SMALL
);
1668 gtk_grid_set_column_spacing (GTK_GRID (group_grid
), SPACING_MEDIUM
);
1669 gtk_grid_attach (GTK_GRID (content_grid
), group_grid
, 0, crow
++, 1, 1);
1671 label
= make_label_group(_("Memo autocomplete"));
1672 gtk_grid_attach (GTK_GRID (group_grid
), label
, 0, 0, 3, 1);
1675 widget
= gtk_check_button_new_with_mnemonic (_("Active"));
1676 data
->CM_memoacp
= widget
;
1677 gtk_grid_attach (GTK_GRID (group_grid
), widget
, 1, row
, 2, 1);
1680 widget
= make_numeric(NULL
, 0, 1460);
1681 data
->ST_memoacp_days
= widget
;
1682 gtk_grid_attach (GTK_GRID (group_grid
), widget
, 2, row
, 1, 1);
1683 label
= make_label(_("rolling days"), 0, 0.5);
1684 gtk_grid_attach (GTK_GRID (group_grid
), label
, 3, row
, 1, 1);
1686 // group :: Column list
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(_("Column list"));
1694 gtk_grid_attach (GTK_GRID (group_grid), label, 0, 0, 3, 1);
1697 sw = gtk_scrolled_window_new (NULL, NULL);
1698 gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (sw), GTK_SHADOW_ETCHED_IN);
1699 gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (sw), GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC);
1700 widget = (GtkWidget *)list_txn_colprefcreate();
1701 data->LV_opecolumns = widget;
1702 gtk_widget_set_size_request(data->LV_opecolumns, HB_MINWIDTH_LIST, -1);
1703 gtk_container_add (GTK_CONTAINER (sw), widget);
1704 gtk_widget_set_vexpand (sw, TRUE);
1705 gtk_grid_attach (GTK_GRID (group_grid), sw, 1, row, 2, 1);
1706 gtk_widget_set_tooltip_text(widget, _("Drag & drop to change the order"));
1709 return content_grid
;
1714 static GtkWidget
*defpref_page_interface (struct defpref_data
*data
)
1716 GtkWidget
*content_grid
, *group_grid
, *hbox
, *label
, *widget
;
1719 content_grid
= gtk_grid_new();
1720 gtk_grid_set_row_spacing (GTK_GRID (content_grid
), SPACING_LARGE
);
1721 gtk_orientable_set_orientation(GTK_ORIENTABLE(content_grid
), GTK_ORIENTATION_VERTICAL
);
1725 group_grid
= gtk_grid_new ();
1726 gtk_grid_set_row_spacing (GTK_GRID (group_grid
), SPACING_SMALL
);
1727 gtk_grid_set_column_spacing (GTK_GRID (group_grid
), SPACING_MEDIUM
);
1728 gtk_grid_attach (GTK_GRID (content_grid
), group_grid
, 0, crow
++, 1, 1);
1730 label
= make_label_group(_("General"));
1731 gtk_grid_attach (GTK_GRID (group_grid
), label
, 0, 0, 3, 1);
1734 label
= make_label(_("_Toolbar:"), 0, 0.5);
1735 gtk_grid_attach (GTK_GRID (group_grid
), label
, 1, row
, 1, 1);
1736 widget
= make_cycle(label
, CYA_TOOLBAR_STYLE
);
1737 data
->CY_toolbar
= widget
;
1738 gtk_grid_attach (GTK_GRID (group_grid
), widget
, 2, row
, 1, 1);
1754 //widget = gtk_check_button_new_with_mnemonic (_("Enable rows in alternating colors"));
1755 //data->CM_ruleshint = widget;
1756 label
= make_label(_("_Grid line:"), 0, 0.5);
1757 gtk_grid_attach (GTK_GRID (group_grid
), label
, 1, row
, 1, 1);
1758 widget
= make_cycle(label
, CYA_GRID_LINES
);
1759 data
->CY_gridlines
= widget
;
1760 gtk_grid_attach (GTK_GRID (group_grid
), widget
, 2, row
, 1, 1);
1762 // group :: Amount colors
1763 group_grid
= gtk_grid_new ();
1764 gtk_grid_set_row_spacing (GTK_GRID (group_grid
), SPACING_SMALL
);
1765 gtk_grid_set_column_spacing (GTK_GRID (group_grid
), SPACING_MEDIUM
);
1766 gtk_grid_attach (GTK_GRID (content_grid
), group_grid
, 0, crow
++, 1, 1);
1768 label
= make_label_group(_("Amount colors"));
1769 gtk_grid_attach (GTK_GRID (group_grid
), label
, 0, 0, 3, 1);
1772 widget
= gtk_check_button_new_with_mnemonic (_("Uses custom colors"));
1773 data
->CM_custom_colors
= widget
;
1774 gtk_grid_attach (GTK_GRID (group_grid
), widget
, 1, row
, 2, 1);
1777 label
= make_label(_("_Preset:"), 0, 0.5);
1778 data
->LB_colors
= label
;
1779 //----------------------------------------- l, r, t, b
1780 gtk_grid_attach (GTK_GRID (group_grid
), label
, 1, row
, 1, 1);
1781 widget
= make_cycle(label
, CYA_TANGO_COLORS
);
1782 data
->CY_colors
= widget
;
1783 //gtk_grid_attach (GTK_GRID (group_grid), data->CY_option[FILTER_DATE], 1, 2, row, row+1);
1784 gtk_grid_attach (GTK_GRID (group_grid
), widget
, 2, row
, 1, 1);
1787 label
= make_label(_("_Expense:"), 0, 0.5);
1788 data
->LB_exp_color
= label
;
1789 //----------------------------------------- l, r, t, b
1790 gtk_grid_attach (GTK_GRID (group_grid
), label
, 1, row
, 1, 1);
1791 hbox
= gtk_box_new(GTK_ORIENTATION_HORIZONTAL
, SPACING_SMALL
);
1792 data
->GR_colors
= hbox
;
1793 gtk_grid_attach (GTK_GRID (group_grid
), hbox
, 2, row
, 1, 1);
1795 widget
= gtk_color_button_new ();
1796 data
->CP_exp_color
= widget
;
1797 gtk_box_pack_start (GTK_BOX (hbox
), widget
, FALSE
, FALSE
, 0);
1799 label
= make_label_widget(_("_Income:"));
1800 gtk_box_pack_start (GTK_BOX (hbox
), label
, FALSE
, FALSE
, 0);
1802 widget
= gtk_color_button_new ();
1803 data
->CP_inc_color
= widget
;
1804 gtk_box_pack_start (GTK_BOX (hbox
), widget
, FALSE
, FALSE
, 0);
1806 label
= make_label_widget(_("_Warning:"));
1807 gtk_box_pack_start (GTK_BOX (hbox
), label
, FALSE
, FALSE
, 0);
1809 widget
= gtk_color_button_new ();
1810 data
->CP_warn_color
= widget
;
1811 gtk_box_pack_start (GTK_BOX (hbox
), widget
, FALSE
, FALSE
, 0);
1813 return content_grid
;
1817 static GtkWidget
*defpref_page_filebackup (struct defpref_data
*data
)
1819 GtkWidget
*content_grid
, *group_grid
, *hbox
, *label
, *widget
;
1822 content_grid
= gtk_grid_new();
1823 gtk_grid_set_row_spacing (GTK_GRID (content_grid
), SPACING_LARGE
);
1824 gtk_orientable_set_orientation(GTK_ORIENTABLE(content_grid
), GTK_ORIENTATION_VERTICAL
);
1828 group_grid
= gtk_grid_new ();
1829 gtk_grid_set_row_spacing (GTK_GRID (group_grid
), SPACING_SMALL
);
1830 gtk_grid_set_column_spacing (GTK_GRID (group_grid
), SPACING_MEDIUM
);
1831 gtk_grid_attach (GTK_GRID (content_grid
), group_grid
, 0, crow
++, 1, 1);
1833 label
= make_label_group(_("Backup"));
1834 gtk_grid_attach (GTK_GRID (group_grid
), label
, 0, 0, 3, 1);
1837 widget
= gtk_check_button_new_with_mnemonic (_("_Enable automatic backups"));
1838 data
->CM_bak_is_automatic
= widget
;
1839 gtk_grid_attach (GTK_GRID (group_grid
), widget
, 1, row
, 2, 1);
1842 label
= make_label_widget(_("_Number of backups to keep:"));
1843 data
->LB_bak_max_num_copies
= label
;
1844 gtk_grid_attach (GTK_GRID (group_grid
), label
, 1, row
, 1, 1);
1845 widget
= make_numeric (label
, 1, 99);
1846 data
->NB_bak_max_num_copies
= widget
;
1847 gtk_grid_attach (GTK_GRID (group_grid
), widget
, 2, row
, 1, 1);
1850 hbox
= gtk_box_new(GTK_ORIENTATION_HORIZONTAL
, SPACING_SMALL
);
1851 data
->GR_bak_freq
= hbox
;
1852 //gtk_widget_set_hexpand (hbox, TRUE);
1853 gtk_grid_attach (GTK_GRID (group_grid
), hbox
, 1, row
, 2, 1);
1855 widget
= gtk_image_new_from_icon_name (ICONNAME_INFO
, GTK_ICON_SIZE_BUTTON
);
1856 gtk_box_pack_start (GTK_BOX (hbox
), widget
, FALSE
, FALSE
, 0);
1857 label
= make_label_widget(_("Backup frequency is once a day"));
1858 gtk_box_pack_start (GTK_BOX (hbox
), label
, FALSE
, FALSE
, 0);
1861 return content_grid
;
1865 static GtkWidget
*defpref_page_folders (struct defpref_data
*data
)
1867 GtkWidget
*content_grid
, *group_grid
, *hbox
, *label
, *widget
;
1870 content_grid
= gtk_grid_new();
1871 gtk_grid_set_row_spacing (GTK_GRID (content_grid
), SPACING_LARGE
);
1872 gtk_orientable_set_orientation(GTK_ORIENTABLE(content_grid
), GTK_ORIENTATION_VERTICAL
);
1875 // group :: Files folder
1876 group_grid
= gtk_grid_new ();
1877 gtk_grid_set_row_spacing (GTK_GRID (group_grid
), SPACING_SMALL
);
1878 gtk_grid_set_column_spacing (GTK_GRID (group_grid
), SPACING_MEDIUM
);
1879 gtk_grid_attach (GTK_GRID (content_grid
), group_grid
, 0, crow
++, 1, 1);
1881 label
= make_label_group(_("HomeBank files"));
1882 gtk_grid_attach (GTK_GRID (group_grid
), label
, 0, 0, 3, 1);
1885 label
= make_label_widget(_("_Wallets:"));
1886 gtk_grid_attach (GTK_GRID (group_grid
), label
, 1, row
, 1, 1);
1888 hbox
= gtk_box_new(GTK_ORIENTATION_HORIZONTAL
, 0);
1889 gtk_widget_set_hexpand (hbox
, TRUE
);
1890 gtk_grid_attach (GTK_GRID (group_grid
), hbox
, 2, row
, 1, 1);
1892 widget
= make_string(label
);
1893 data
->ST_path_hbfile
= widget
;
1894 gtk_style_context_add_class (gtk_widget_get_style_context (GTK_WIDGET(widget
)), GTK_STYLE_CLASS_LINKED
);
1895 gtk_box_pack_start (GTK_BOX (hbox
), widget
, TRUE
, TRUE
, 0);
1897 //widget = gtk_button_new_with_label("...");
1898 widget
= gtk_button_new_from_icon_name(ICONNAME_FOLDER
, GTK_ICON_SIZE_BUTTON
);
1899 data
->BT_path_hbfile
= widget
;
1900 gtk_box_pack_start (GTK_BOX (hbox
), widget
, FALSE
, FALSE
, 0);
1903 // group :: Files folder
1904 group_grid
= gtk_grid_new ();
1905 gtk_grid_set_row_spacing (GTK_GRID (group_grid
), SPACING_SMALL
);
1906 gtk_grid_set_column_spacing (GTK_GRID (group_grid
), SPACING_MEDIUM
);
1907 gtk_grid_attach (GTK_GRID (content_grid
), group_grid
, 0, crow
++, 1, 1);
1909 label
= make_label_group(_("Exchange files"));
1910 gtk_grid_attach (GTK_GRID (group_grid
), label
, 0, 0, 3, 1);
1913 label
= make_label_widget(_("_Import:"));
1914 //----------------------------------------- l, r, t, b
1915 gtk_grid_attach (GTK_GRID (group_grid
), label
, 1, row
, 1, 1);
1917 hbox
= gtk_box_new(GTK_ORIENTATION_HORIZONTAL
, 0);
1918 gtk_widget_set_hexpand (hbox
, TRUE
);
1919 gtk_grid_attach (GTK_GRID (group_grid
), hbox
, 2, row
, 1, 1);
1921 widget
= make_string(label
);
1922 data
->ST_path_import
= widget
;
1923 gtk_style_context_add_class (gtk_widget_get_style_context (GTK_WIDGET(widget
)), GTK_STYLE_CLASS_LINKED
);
1924 gtk_box_pack_start (GTK_BOX (hbox
), widget
, TRUE
, TRUE
, 0);
1926 //widget = gtk_button_new_with_label("...");
1927 widget
= gtk_button_new_from_icon_name(ICONNAME_FOLDER
, GTK_ICON_SIZE_BUTTON
);
1928 data
->BT_path_import
= widget
;
1929 gtk_box_pack_start (GTK_BOX (hbox
), widget
, FALSE
, FALSE
, 0);
1932 label
= make_label_widget(_("_Export:"));
1933 //----------------------------------------- l, r, t, b
1934 gtk_grid_attach (GTK_GRID (group_grid
), label
, 1, row
, 1, 1);
1936 hbox
= gtk_box_new(GTK_ORIENTATION_HORIZONTAL
, 0);
1937 gtk_widget_set_hexpand (hbox
, TRUE
);
1938 gtk_grid_attach (GTK_GRID (group_grid
), hbox
, 2, row
, 1, 1);
1940 widget
= make_string(label
);
1941 data
->ST_path_export
= widget
;
1942 gtk_style_context_add_class (gtk_widget_get_style_context (GTK_WIDGET(widget
)), GTK_STYLE_CLASS_LINKED
);
1943 gtk_box_pack_start (GTK_BOX (hbox
), widget
, TRUE
, TRUE
, 0);
1945 //widget = gtk_button_new_with_label("...");
1946 widget
= gtk_button_new_from_icon_name(ICONNAME_FOLDER
, GTK_ICON_SIZE_BUTTON
);
1947 data
->BT_path_export
= widget
;
1948 gtk_box_pack_start (GTK_BOX (hbox
), widget
, FALSE
, FALSE
, 0);
1952 return content_grid
;
1956 static GtkWidget
*defpref_page_general (struct defpref_data
*data
)
1958 GtkWidget
*content_grid
, *group_grid
, *label
, *widget
;
1961 content_grid
= gtk_grid_new();
1962 gtk_grid_set_row_spacing (GTK_GRID (content_grid
), SPACING_LARGE
);
1963 gtk_orientable_set_orientation(GTK_ORIENTABLE(content_grid
), GTK_ORIENTATION_VERTICAL
);
1966 // group :: Program start
1967 group_grid
= gtk_grid_new ();
1968 gtk_grid_set_row_spacing (GTK_GRID (group_grid
), SPACING_SMALL
);
1969 gtk_grid_set_column_spacing (GTK_GRID (group_grid
), SPACING_MEDIUM
);
1970 gtk_grid_attach (GTK_GRID (content_grid
), group_grid
, 0, crow
++, 1, 1);
1972 label
= make_label_group(_("Program start"));
1973 gtk_grid_attach (GTK_GRID (group_grid
), label
, 0, 0, 3, 1);
1976 widget
= gtk_check_button_new_with_mnemonic (_("Show splash screen"));
1977 data
->CM_show_splash
= widget
;
1978 gtk_grid_attach (GTK_GRID (group_grid
), widget
, 1, row
, 2, 1);
1981 widget
= gtk_check_button_new_with_mnemonic (_("Load last opened file"));
1982 data
->CM_load_last
= widget
;
1983 gtk_grid_attach (GTK_GRID (group_grid
), widget
, 1, row
, 2, 1);
1986 widget
= gtk_check_button_new_with_mnemonic (_("Post pending scheduled transactions"));
1987 data
->CM_append_scheduled
= widget
;
1988 gtk_grid_attach (GTK_GRID (group_grid
), widget
, 1, row
, 2, 1);
1991 widget
= gtk_check_button_new_with_mnemonic (_("Update currencies online"));
1992 data
->CM_do_update_currency
= widget
;
1993 gtk_grid_attach (GTK_GRID (group_grid
), widget
, 1, row
, 2, 1);
1996 // group :: Main window reports
1997 group_grid
= gtk_grid_new ();
1998 gtk_grid_set_row_spacing (GTK_GRID (group_grid
), SPACING_SMALL
);
1999 gtk_grid_set_column_spacing (GTK_GRID (group_grid
), SPACING_MEDIUM
);
2000 gtk_grid_attach (GTK_GRID (content_grid
), group_grid
, 0, crow
++, 1, 1);
2002 label
= make_label_group(_("Main window reports"));
2003 gtk_grid_attach (GTK_GRID (group_grid
), label
, 0, 0, 3, 1);
2006 label
= make_label(_("_Range:"), 0, 0.5);
2007 gtk_grid_attach (GTK_GRID (group_grid
), label
, 1, row
, 1, 1);
2008 widget
= make_daterange(label
, FALSE
);
2009 data
->CY_daterange_wal
= widget
;
2010 gtk_grid_attach (GTK_GRID (group_grid
), widget
, 2, row
, 1, 1);
2012 return content_grid
;
2016 void plugin_execute_action(GtkTreeView
* treeview
, GtkTreePath
* path
, GtkTreeViewColumn
* col
, gpointer userdata
);
2019 toggle_plugin(GtkCellRendererToggle
*cell
, gchar
* path_str
, gpointer data
)
2021 GtkTreeModel
*model
= (GtkTreeModel
*)data
;
2023 GtkTreePath
*path
= gtk_tree_path_new_from_string(path_str
);
2025 const gchar
* plugin
;
2027 gtk_tree_model_get_iter(model
, &iter
, path
);
2028 gtk_tree_model_get(model
, &iter
, EXT_COLUMN_PLUGIN_NAME
, &plugin
, -1);
2030 gboolean enabled
= ext_is_plugin_loaded(plugin
);
2032 ext_unload_plugin(plugin
);
2035 enabled
= (ext_load_plugin(plugin
) == 0);
2037 ext_run_modal(_("Plugin Error"), _("The plugin failed to load properly."), "error");
2042 gtk_list_store_set(GTK_LIST_STORE (model
), &iter
, EXT_COLUMN_ENABLED
, enabled
, -1);
2045 gtk_tree_path_free(path
);
2049 void plugin_execute_action(GtkTreeView
* treeview
, GtkTreePath
* path
, GtkTreeViewColumn
* col
, gpointer userdata
)
2051 GtkTreeModel
* model
= gtk_tree_view_get_model(treeview
);
2054 if (gtk_tree_model_get_iter(model
, &iter
, path
)) {
2055 gchar
* plugin_filename
;
2056 gtk_tree_model_get(model
, &iter
, EXT_COLUMN_PLUGIN_NAME
, &plugin_filename
, -1);
2057 ext_execute_action(plugin_filename
);
2058 g_free(plugin_filename
);
2062 static GtkWidget
*defpref_page_plugins (struct defpref_data
*data
)
2064 GtkWidget
*container
;
2065 GtkListStore
*store
;
2069 container
= gtk_vbox_new(FALSE
, 0);
2071 store
= gtk_list_store_new(EXT_NUM_COLUMNS
, G_TYPE_BOOLEAN
, G_TYPE_STRING
, G_TYPE_STRING
, G_TYPE_STRING
);
2073 gchar
** plugins
= ext_list_plugins();
2075 for (plugins_it
= plugins
; *plugins_it
; ++plugins_it
) {
2077 gboolean enabled
= ext_is_plugin_loaded(*plugins_it
);
2078 GHashTable
* metadata
= ext_read_plugin_metadata(*plugins_it
);
2080 metadata
= g_hash_table_new(g_str_hash
, g_str_equal
);
2086 gchar
* name
= g_hash_table_lookup(metadata
, "name");
2087 if (!name
|| *name
== '\0') {
2090 name
= g_markup_escape_text(name
, -1);
2091 gchar
* label
= g_strdup_printf("<b>%s</b>", name
);
2092 gchar
* tooltip
= g_strdup_printf("<span size='x-large' weight='bold'>%s</span>", name
);
2096 gchar
* version
= g_hash_table_lookup(metadata
, "version");
2098 version
= g_markup_escape_text(version
, -1);
2100 label
= g_strdup_printf("%s %s", tmp
, version
);
2103 tooltip
= g_strdup_printf("%s %s", tmp
, version
);
2109 gchar
* abstract
= g_hash_table_lookup(metadata
, "abstract");
2111 abstract
= g_markup_escape_text(abstract
, -1);
2113 label
= g_strdup_printf("%s\n%s", tmp
, abstract
);
2119 gchar
* author
= g_hash_table_lookup(metadata
, "author");
2121 author
= g_markup_escape_text(author
, -1);
2123 tooltip
= g_strdup_printf("%s\n%s", tmp
, author
);
2129 gchar
* website
= g_hash_table_lookup(metadata
, "website");
2131 website
= g_markup_escape_text(website
, -1);
2133 tooltip
= g_strdup_printf("%s\n<b>%s:</b> %s", tmp
, _("Website"), website
);
2139 tmp
= ext_find_plugin(*plugins_it
);
2140 gchar
* full
= g_markup_escape_text(tmp
, -1);
2143 tooltip
= g_strdup_printf("%s\n<b>%s:</b> %s", tmp
, _("File"), full
);
2147 g_hash_table_unref(metadata
);
2149 gtk_list_store_append(store
, &it
);
2150 gtk_list_store_set(store
, &it
,
2151 EXT_COLUMN_ENABLED
, enabled
,
2152 EXT_COLUMN_LABEL
, label
,
2153 EXT_COLUMN_TOOLTIP
, tooltip
,
2154 EXT_COLUMN_PLUGIN_NAME
, *plugins_it
,
2160 g_strfreev(plugins
);
2162 view
= gtk_tree_view_new_with_model(GTK_TREE_MODEL(store
));
2163 g_object_unref(store
);
2165 g_signal_connect(view
, "row-activated", (GCallback
)plugin_execute_action
, NULL
);
2167 gtk_tree_view_set_rules_hint(GTK_TREE_VIEW(view
), TRUE
);
2168 gtk_tree_view_set_headers_visible(GTK_TREE_VIEW(view
), TRUE
);
2169 gtk_tree_view_set_tooltip_column(GTK_TREE_VIEW(view
), EXT_COLUMN_TOOLTIP
);
2172 GtkTreeViewColumn
*col
;
2173 GtkCellRenderer
*renderer
;
2176 col
= gtk_tree_view_column_new();
2177 gtk_tree_view_column_set_title(col
, _("Enabled"));
2178 gtk_tree_view_column_set_sort_column_id(col
, EXT_COLUMN_ENABLED
);
2179 gtk_tree_view_append_column(GTK_TREE_VIEW(view
), col
);
2181 renderer
= gtk_cell_renderer_toggle_new();
2182 gtk_tree_view_column_pack_start(col
, renderer
, TRUE
);
2183 gtk_tree_view_column_add_attribute(col
, renderer
, "active", 0);
2184 g_signal_connect(renderer
, "toggled", G_CALLBACK(toggle_plugin
), store
);
2186 col
= gtk_tree_view_column_new();
2187 gtk_tree_view_column_set_title(col
, _("Plugin"));
2188 gtk_tree_view_column_set_sort_column_id(col
, EXT_COLUMN_LABEL
);
2189 gtk_tree_view_column_set_expand(col
, TRUE
);
2190 /*gtk_tree_view_column_set_sort_order(col, GTK_SORT_ASCENDING);*/
2191 gtk_tree_view_append_column(GTK_TREE_VIEW(view
), col
);
2193 renderer
= gtk_cell_renderer_text_new();
2194 g_object_set(renderer
, "ellipsize", PANGO_ELLIPSIZE_END
, NULL
);
2195 gtk_tree_view_column_pack_start(col
, renderer
, TRUE
);
2196 gtk_tree_view_column_add_attribute(col
, renderer
, "markup", EXT_COLUMN_LABEL
);
2198 data
->PI_plugin_columns
= view
;
2200 GtkWidget
* sw
= gtk_scrolled_window_new(NULL
, NULL
);
2201 gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(sw
), GTK_SHADOW_ETCHED_IN
);
2202 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(sw
), GTK_POLICY_NEVER
, GTK_POLICY_AUTOMATIC
);
2203 gtk_container_add(GTK_CONTAINER(sw
), view
);
2205 gtk_box_pack_start(GTK_BOX(container
), sw
, TRUE
, TRUE
, 0);
2211 static void defpref_selection(GtkTreeSelection
*treeselection
, gpointer user_data
)
2213 struct defpref_data
*data
;
2214 GtkWidget
*notebook
;
2215 GtkTreeView
*treeview
;
2216 GtkTreeModel
*model
;
2219 GValue val
= { 0, };
2222 DB( g_print("\n[ui-pref] selection\n") );
2224 if (gtk_tree_selection_get_selected(treeselection
, &model
, &iter
))
2226 notebook
= GTK_WIDGET(user_data
);
2227 treeview
= gtk_tree_selection_get_tree_view(treeselection
);
2228 data
= g_object_get_data(G_OBJECT(gtk_widget_get_ancestor(GTK_WIDGET(treeview
), GTK_TYPE_WINDOW
)), "inst_data");
2231 gtk_tree_model_get_value(model
, &iter
, LST_PREF_PAGE
, &val
);
2232 page
= g_value_get_int (&val
);
2233 DB( g_print(" - active is %d\n", page
) );
2234 g_value_unset (&val
);
2237 gtk_tree_model_get_value(model
, &iter
, LST_PREF_NAME
, &val
);
2238 gtk_label_set_text (GTK_LABEL (data
->label
), g_value_get_string (&val
));
2239 g_value_unset (&val
);
2241 gtk_tree_model_get_value(model
, &iter
, LST_PREF_ICONNAME
, &val
);
2242 //gtk_image_set_from_pixbuf (GTK_IMAGE (data->image), g_value_get_object (&val));
2243 gtk_image_set_from_icon_name(GTK_IMAGE (data
->image
), g_value_get_string (&val
), GTK_ICON_SIZE_DIALOG
);
2244 g_value_unset (&val
);
2248 gtk_notebook_set_current_page(GTK_NOTEBOOK(notebook
), page
);
2250 //defpref_change_page(GTK_WIDGET(gtk_tree_selection_get_tree_view(treeselection)), GINT_TO_POINTER(page));
2257 ** set the notebook active page from treeview
2259 /*void defpref_change_page(GtkWidget *widget, gpointer user_data)
2261 struct defpref_data *data;
2262 gint page = GPOINTER_TO_INT(user_data);
2263 GtkTreeModel *model;
2266 DB( g_print("\n[ui-pref] page\n") );
2268 data = g_object_get_data(G_OBJECT(gtk_widget_get_ancestor(widget, GTK_TYPE_WINDOW)), "inst_data");
2270 model = gtk_tree_view_get_model(GTK_TREE_VIEW(data->LV_page));
2278 gtk_notebook_set_current_page(GTK_NOTEBOOK(data->GR_page), page);
2284 ** add an empty new account to our temp GList and treeview
2286 static void defpref_reset(GtkWidget
*widget
, gpointer user_data
)
2288 struct defpref_data
*data
;
2291 data
= g_object_get_data(G_OBJECT(gtk_widget_get_ancestor(widget
, GTK_TYPE_WINDOW
)), "inst_data");
2292 DB( g_print("\n(defpref_reset) (data=%p)\n", data
) );
2294 result
= ui_dialog_msg_confirm_alert(
2295 GTK_WINDOW(data
->window
),
2296 _("Reset All Preferences"),
2297 _("Do you really want to reset\nall preferences to default\nvalues?"),
2300 if( result
== GTK_RESPONSE_OK
)
2302 homebank_pref_setdefault();
2309 // the window creation
2310 GtkWidget
*defpref_dialog_new (gint initial_selection
)
2312 struct defpref_data data
;
2313 GtkWidget
*window
, *content
, *mainvbox
;
2314 GtkWidget
*hbox
, *vbox
, *sw
, *widget
, *notebook
, *page
, *ebox
, *image
, *label
;
2316 window
= gtk_dialog_new_with_buttons (_("Preferences"),
2317 GTK_WINDOW(GLOBALS
->mainwindow
),
2322 GTK_RESPONSE_REJECT
,
2324 GTK_RESPONSE_ACCEPT
,
2327 data
.window
= window
;
2329 //store our window private data
2330 g_object_set_data(G_OBJECT(window
), "inst_data", (gpointer
)&data
);
2332 gtk_window_set_icon_name(GTK_WINDOW (window
), ICONNAME_PREFERENCES
);
2334 content
= gtk_dialog_get_content_area(GTK_DIALOG (window
)); // return a vbox
2335 mainvbox
= gtk_box_new(GTK_ORIENTATION_VERTICAL
, SPACING_MEDIUM
);
2336 gtk_box_pack_start (GTK_BOX (content
), mainvbox
, TRUE
, TRUE
, 0);
2338 gtk_container_set_border_width(GTK_CONTAINER(mainvbox
), SPACING_MEDIUM
);
2340 hbox
= gtk_box_new(GTK_ORIENTATION_HORIZONTAL
, SPACING_MEDIUM
);
2341 gtk_box_pack_start (GTK_BOX (mainvbox
), hbox
, TRUE
, TRUE
, 0);
2344 vbox
= gtk_box_new(GTK_ORIENTATION_VERTICAL
, SPACING_SMALL
);
2345 gtk_box_pack_start (GTK_BOX (hbox
), vbox
, FALSE
, FALSE
, 0);
2348 sw
= gtk_scrolled_window_new (NULL
, NULL
);
2349 gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (sw
), GTK_SHADOW_ETCHED_IN
);
2350 gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (sw
), GTK_POLICY_NEVER
, GTK_POLICY_AUTOMATIC
);
2351 gtk_box_pack_start (GTK_BOX (vbox
), sw
, TRUE
, TRUE
, 0);
2352 widget
= pref_list_create();
2353 data
.LV_page
= widget
;
2354 gtk_container_add (GTK_CONTAINER (sw
), widget
);
2357 //right part : notebook
2358 vbox
= gtk_box_new (GTK_ORIENTATION_VERTICAL
, SPACING_MEDIUM
);
2359 gtk_box_pack_start (GTK_BOX (hbox
), vbox
, TRUE
, TRUE
, 0);
2360 gtk_widget_show (vbox
);
2362 ebox
= gtk_event_box_new();
2363 gtk_widget_set_name(ebox
, "hbebox");
2364 GtkStyleContext
*context
= gtk_widget_get_style_context (ebox
);
2365 #if GTK_MINOR_VERSION <= 18
2366 gtk_style_context_add_class (context
, GTK_STYLE_CLASS_LIST_ROW
);
2367 gtk_widget_set_state_flags(ebox
, GTK_STATE_FLAG_SELECTED
, TRUE
);
2369 GtkCssProvider
*provider
;
2370 provider
= gtk_css_provider_new ();
2371 gtk_css_provider_load_from_data (provider
,
2372 "#hbebox { color: @theme_selected_fg_color; background-color: @theme_selected_bg_color; }"
2374 gtk_style_context_add_provider (context
, GTK_STYLE_PROVIDER(provider
), G_MAXUINT
);
2376 // gtk_style_context_set_state(context, GTK_STATE_FLAG_SELECTED);
2379 gtk_box_pack_start (GTK_BOX (vbox
), ebox
, FALSE
, TRUE
, 0);
2380 gtk_widget_show (ebox
);
2382 hbox
= gtk_box_new (GTK_ORIENTATION_HORIZONTAL
, SPACING_SMALL
);
2383 gtk_container_set_border_width (GTK_CONTAINER (hbox
), SPACING_SMALL
);
2384 gtk_container_add (GTK_CONTAINER (ebox
), hbox
);
2385 gtk_widget_show (hbox
);
2387 label
= gtk_label_new (NULL
);
2388 gtk_widget_set_margin_left(label
, SPACING_MEDIUM
);
2389 gimp_label_set_attributes (GTK_LABEL (label
),
2390 PANGO_ATTR_SCALE
, PANGO_SCALE_XX_LARGE
,
2391 PANGO_ATTR_WEIGHT
, PANGO_WEIGHT_BOLD
,
2394 gtk_box_pack_start (GTK_BOX (hbox
), label
, FALSE
, FALSE
, 0);
2395 gtk_widget_show (label
);
2398 image
= gtk_image_new ();
2399 gtk_box_pack_end (GTK_BOX (hbox
), image
, FALSE
, FALSE
, 0);
2400 gtk_widget_show (image
);
2406 notebook
= gtk_notebook_new();
2407 data
.GR_page
= notebook
;
2408 gtk_widget_show(notebook
);
2409 gtk_notebook_set_show_tabs(GTK_NOTEBOOK(notebook
), FALSE
);
2410 gtk_notebook_set_show_border(GTK_NOTEBOOK(notebook
), FALSE
);
2411 gtk_box_pack_start (GTK_BOX (vbox
), notebook
, TRUE
, TRUE
, 0);
2416 PREF_LOCALE, //old DISPLAY
2417 PREF_TXN, //old COLUMNS
2427 page
= defpref_page_general(&data
);
2428 gtk_notebook_append_page (GTK_NOTEBOOK (notebook
), page
, NULL
);
2431 page
= defpref_page_interface(&data
);
2432 gtk_notebook_append_page (GTK_NOTEBOOK (notebook
), page
, NULL
);
2435 page
= defpref_page_display(&data
);
2436 gtk_notebook_append_page (GTK_NOTEBOOK (notebook
), page
, NULL
);
2439 page
= defpref_page_transactions(&data
);
2440 gtk_notebook_append_page (GTK_NOTEBOOK (notebook
), page
, NULL
);
2443 page
= defpref_page_import(&data
);
2444 gtk_notebook_append_page (GTK_NOTEBOOK (notebook
), page
, NULL
);
2447 page
= defpref_page_reports(&data
);
2448 gtk_notebook_append_page (GTK_NOTEBOOK (notebook
), page
, NULL
);
2451 page
= defpref_page_filebackup(&data
);
2452 gtk_notebook_append_page (GTK_NOTEBOOK (notebook
), page
, NULL
);
2455 page
= defpref_page_folders(&data
);
2456 gtk_notebook_append_page (GTK_NOTEBOOK (notebook
), page
, NULL
);
2459 page
= defpref_page_euro(&data
);
2460 gtk_notebook_append_page (GTK_NOTEBOOK (notebook
), page
, NULL
);
2463 page
= defpref_page_plugins(&data
);
2464 gtk_notebook_append_page (GTK_NOTEBOOK (notebook
), page
, NULL
);
2467 //todo:should move this
2468 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(data
.CM_euro_enable
), PREFS
->euro_active
);
2470 //connect all our signals
2471 g_signal_connect (window
, "destroy", G_CALLBACK (gtk_widget_destroyed
), &window
);
2473 g_signal_connect (data
.CM_bak_is_automatic
, "toggled", G_CALLBACK (defpref_backuptoggle
), NULL
);
2477 g_signal_connect (data
.BT_path_hbfile
, "pressed", G_CALLBACK (defpref_pathselect
), GINT_TO_POINTER(PRF_PATH_WALLET
));
2478 g_signal_connect (data
.BT_path_import
, "pressed", G_CALLBACK (defpref_pathselect
), GINT_TO_POINTER(PRF_PATH_IMPORT
));
2479 g_signal_connect (data
.BT_path_export
, "pressed", G_CALLBACK (defpref_pathselect
), GINT_TO_POINTER(PRF_PATH_EXPORT
));
2481 g_signal_connect (data
.CM_custom_colors
, "toggled", G_CALLBACK (defpref_colortoggle
), NULL
);
2482 g_signal_connect (data
.CY_colors
, "changed", G_CALLBACK (defpref_colorpreset
), NULL
);
2486 g_signal_connect (gtk_tree_view_get_selection(GTK_TREE_VIEW(data
.LV_page
)), "changed", G_CALLBACK (defpref_selection
), notebook
);
2488 g_signal_connect (data
.CM_euro_enable
, "toggled", G_CALLBACK (defpref_eurotoggle
), NULL
);
2490 g_signal_connect (data
.CY_euro_preset
, "changed", G_CALLBACK (defpref_europreset
), NULL
);
2493 g_signal_connect (data
.ST_datefmt
, "changed", G_CALLBACK (defpref_date_sample
), NULL
);
2496 g_signal_connect (data
.CY_color_scheme
, "changed", G_CALLBACK (defpref_color_scheme_changed
), NULL
);
2500 g_signal_connect (data
.ST_euro_symbol
, "changed", G_CALLBACK (defpref_numbereuro_sample
), NULL
);
2501 g_signal_connect (data
.CM_euro_isprefix
, "toggled", G_CALLBACK (defpref_numbereuro_sample
), NULL
);
2502 g_signal_connect (data
.ST_euro_decimalchar
, "changed", G_CALLBACK (defpref_numbereuro_sample
), NULL
);
2503 g_signal_connect (data
.ST_euro_groupingchar
, "changed", G_CALLBACK (defpref_numbereuro_sample
), NULL
);
2504 g_signal_connect (data
.NB_euro_fracdigits
, "value-changed", G_CALLBACK (defpref_numbereuro_sample
), NULL
);
2506 //g_signal_connect (data.BT_default, "pressed", G_CALLBACK (defpref_currency_change), NULL);
2509 //setup, init and show window
2510 //defhbfile_setup(&data);
2511 //defhbfile_update(data.LV_arc, NULL);
2515 defpref_colortoggle(window
, NULL
);
2516 defpref_eurotoggle(window
, NULL
);
2518 gtk_window_resize(GTK_WINDOW(window
), 640, 256);
2522 GtkTreePath
*path
= gtk_tree_path_new_from_indices(initial_selection
, -1);
2525 gtk_tree_selection_select_path (gtk_tree_view_get_selection(GTK_TREE_VIEW(data
.LV_page
)), path
);
2529 gtk_tree_path_free(path
);
2531 gtk_widget_show_all (window
);
2532 gtk_notebook_set_current_page(GTK_NOTEBOOK(notebook
), initial_selection
);
2539 result
= gtk_dialog_run (GTK_DIALOG (window
));
2543 case GTK_RESPONSE_ACCEPT
:
2544 old_lang
= g_strdup(PREFS
->language
);
2546 homebank_pref_save();
2547 ui_mainwindow_update(GLOBALS
->mainwindow
, GINT_TO_POINTER(UF_BALANCE
+UF_VISUAL
));
2549 DB( g_print("old='%s' new='%s'\n", old_lang
, PREFS
->language
) );
2551 if(g_ascii_strncasecmp(old_lang
== NULL
? "" : old_lang
, PREFS
->language
== NULL
? "" : PREFS
->language
, -1) != 0)
2553 ui_dialog_msg_infoerror(GTK_WINDOW(window
), GTK_MESSAGE_INFO
,
2555 _("You will have to restart HomeBank\nfor the language change to take effect.")
2564 defpref_reset (window
, NULL
);
2569 // cleanup and destroy
2570 //defhbfile_cleanup(&data, result);
2571 gtk_widget_destroy (window
);
2576 // -------------------------------
2579 static GtkWidget
*pref_list_create(void)
2581 GtkListStore
*store
;
2583 GtkCellRenderer
*renderer
;
2584 GtkTreeViewColumn
*column
;
2588 /* create list store */
2589 store
= gtk_list_store_new(
2597 view
= gtk_tree_view_new_with_model(GTK_TREE_MODEL(store
));
2598 g_object_unref(store
);
2600 gtk_tree_view_set_headers_visible(GTK_TREE_VIEW (view
), FALSE
);
2601 gtk_tree_selection_set_mode(gtk_tree_view_get_selection(GTK_TREE_VIEW(view
)), GTK_SELECTION_SINGLE
);
2603 /* column 1: icon */
2604 column
= gtk_tree_view_column_new();
2605 renderer
= gtk_cell_renderer_pixbuf_new ();
2606 g_object_set(renderer
, "stock-size", GTK_ICON_SIZE_DND
, NULL
);
2607 gtk_tree_view_column_pack_start(column
, renderer
, FALSE
);
2608 gtk_tree_view_column_set_attributes(column
, renderer
, "icon-name", LST_PREF_ICONNAME
, NULL
);
2610 renderer
= gtk_cell_renderer_text_new ();
2611 gtk_tree_view_column_pack_start(column
, renderer
, TRUE
);
2612 gtk_tree_view_column_set_attributes(column
, renderer
, "text", LST_PREF_NAME
, NULL
);
2614 gtk_tree_view_append_column (GTK_TREE_VIEW(view
), column
);
2616 //populate our combobox model
2617 for(i
=0;i
<PREF_MAX
;i
++)
2619 gtk_list_store_append(store
, &iter
);
2621 gtk_list_store_set(store
, &iter
,
2622 LST_PREF_ICONNAME
, pref_iconname
[i
],
2623 LST_PREF_NAME
, _(pref_name
[i
]),
2632 /* = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =*/
2635 extern gchar *list_txn_column_label[];
2639 list_txn_colpref_toggled_cell_data_function (GtkCellRendererToggle *cell,
2643 GtkTreeModel *model = (GtkTreeModel *)data;
2645 GtkTreePath *path = gtk_tree_path_new_from_string (path_str);
2649 gtk_tree_model_get_iter (model, &iter, path);
2650 gtk_tree_model_get (model, &iter, COLUMN_VISIBLE, &fixed, -1);
2652 // do something with the value
2656 gtk_list_store_set (GTK_LIST_STORE (model), &iter, COLUMN_VISIBLE, fixed, -1);
2659 gtk_tree_path_free (path);
2663 static void list_txn_colpref_get(GtkTreeView *treeview, gint *columns)
2665 GtkTreeModel *model;
2671 DB( g_print("[lst_txn-colpref] store column order \n") );
2673 model = gtk_tree_view_get_model(GTK_TREE_VIEW(treeview));
2674 valid = gtk_tree_model_get_iter_first(GTK_TREE_MODEL(model), &iter);
2678 gtk_tree_model_get(GTK_TREE_MODEL(model), &iter,
2679 COLUMN_VISIBLE, &visible,
2683 DB( g_print(" - column %d: %d\n",id, visible) );
2684 // start at index 2 (status, date always displayed
2685 columns[i+2] = visible == TRUE ? id : -id;
2687 // Make iter point to the next row in the list store
2688 valid = gtk_tree_model_iter_next(GTK_TREE_MODEL(model), &iter);
2694 GtkWidget *list_txn_colprefcreate(void)
2696 GtkListStore *store;
2698 GtkCellRenderer *renderer;
2699 GtkTreeViewColumn *column;
2703 DB( g_print("[lst_txn-colpref] create\n") );
2706 // create list store
2707 store = gtk_list_store_new(
2715 for(i=0 ; i < NUM_LST_DSPOPE-1; i++ ) //-1 cause account column avoid
2720 DB( g_print("eval %d, %s\n", i, list_txn_column_label[i]) );
2722 if(i <= LST_DSPOPE_DATE) // status, date always displayed
2725 //[i-1] here because lst_ope_columns[] do not store LST_DSPOPE_DATAS
2726 id = ABS(PREFS->lst_ope_columns[i-1]);
2727 if(id == 0) id = i; //if we pass here, new column or weird into pref file
2728 visible = (PREFS->lst_ope_columns[i-1] > 0) ? TRUE : FALSE;
2731 DB( g_print(" - pos=%2d, id=%2d - %d '%s'\n", i, id, visible, list_txn_column_label[id]) );
2733 gtk_list_store_append (store, &iter);
2734 gtk_list_store_set (store, &iter,
2735 COLUMN_VISIBLE, visible,
2736 COLUMN_NAME, _(list_txn_column_label[id]),
2743 view = gtk_tree_view_new_with_model(GTK_TREE_MODEL(store));
2744 g_object_unref(store);
2748 renderer = gtk_cell_renderer_toggle_new ();
2749 column = gtk_tree_view_column_new_with_attributes (_("Visible"),
2751 "active", COLUMN_VISIBLE,
2753 gtk_tree_view_append_column (GTK_TREE_VIEW(view), column);
2755 g_signal_connect (renderer, "toggled",
2756 G_CALLBACK (list_txn_colpref_toggled_cell_data_function), store);
2759 renderer = gtk_cell_renderer_text_new ();
2760 column = gtk_tree_view_column_new_with_attributes (_("Column"),
2762 "text", COLUMN_NAME,
2764 gtk_tree_view_append_column (GTK_TREE_VIEW(view), column);
2766 gtk_tree_view_set_reorderable (GTK_TREE_VIEW(view), TRUE);
2774 static void list_ext_colpref_get(GtkTreeView
*treeview
, GList
**columns
)
2776 GtkTreeModel
*model
;
2779 g_list_free_full(*columns
, g_free
);
2782 model
= gtk_tree_view_get_model(GTK_TREE_VIEW(treeview
));
2784 gboolean valid
= gtk_tree_model_get_iter_first(GTK_TREE_MODEL(model
), &iter
);
2786 gboolean enabled
= FALSE
;
2789 gtk_tree_model_get(GTK_TREE_MODEL(model
), &iter
,
2790 EXT_COLUMN_ENABLED
, &enabled
,
2791 EXT_COLUMN_PLUGIN_NAME
, &name
,
2795 *columns
= g_list_append(*columns
, g_strdup(name
));
2798 valid
= gtk_tree_model_iter_next(GTK_TREE_MODEL(model
), &iter
);