1 /* HomeBank -- Free, easy, personal accounting for everyone.
2 * Copyright (C) 1995-2017 Maxime DOYEN
4 * This file is part of HomeBank.
6 * HomeBank is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * HomeBank is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program. If not, see <http://www.gnu.org/licenses/>.
24 #include "dsp_mainwindow.h"
25 #include "gtk-chart-colors.h"
27 #include "ui-currency.h"
30 /****************************************************************************/
32 /****************************************************************************/
41 /* our global datas */
42 extern struct HomeBank
*GLOBALS
;
43 extern struct Preferences
*PREFS
;
74 static gchar
*pref_iconname
[PREF_MAX
] = {
81 "prf-euro", // to be renamed
85 static gchar
*pref_name
[PREF_MAX
] = {
96 static gchar
*CYA_TOOLBAR_STYLE
[] = {
97 N_("System defaults"),
100 N_("Text under icons"),
101 N_("Text beside icons"),
105 static gchar
*CYA_GRID_LINES
[] = {
114 gchar
*CYA_TANGO_COLORS
[] = {
122 gchar
*CYA_IMPORT_DATEORDER
[] = {
129 gchar
*CYA_IMPORT_OFXNAME
[] = {
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
[];
154 //gchar *prefix_symbol; /* max symbol is 3 digits in unicode */
155 //gchar *suffix_symbol; /* but mostly is 1 digit */
159 gchar
*grouping_char
;
166 http://en.wikipedia.org/wiki/Currencies_of_the_European_Union
167 http://www.xe.com/euro.php
168 http://fr.wikipedia.org/wiki/Liste_des_unit%C3%A9s_mon%C3%A9taires_remplac%C3%A9es_par_l%27euro
169 http://www.inter-locale.com/LocalesDemo.jsp
171 static EuroParams euro_params
[] =
173 // , rate , symb , prfx , dec, grp, frac
174 // ---------------------------------------------------------------------
175 { 0, "" , "--------" , 1.0 , "" , FALSE
, ",", ".", 2 },
176 { 1, "ATS", "Austria" , 13.7603 , "S" , TRUE
, ",", ".", 2 }, // -S 1.234.567,89
177 { 2, "BEF", "Belgium" , 40.3399 , "BF" , TRUE
, ",", ".", 2 }, // BF 1.234.567,89 -
178 { 20, "BGN", "Bulgaria" , 1.95583 , "лв." , TRUE
, ",", " ", 2 }, // non-fixé - 2014 target for euro
179 { 24, "HRK", "Croatia" , 1.0000 , "kn" , FALSE
, "" , ".", 0 }, // non-fixé - 2015 target for euro earliest
180 { 14, "CYP", "Cyprus" , 0.585274 , "£" , TRUE
, ",", "" , 2 }, //
181 { 23, "CZK", "Czech Republic" , 28.36 , "Kč" , FALSE
, ",", " ", 2 }, // non-fixé - 2015 earliest
183 { 17, "EEK", "Estonia" , 15.6466 , "kr" , FALSE
, ",", " ", 2 }, //
184 { 3, "FIM", "Finland" , 5.94573 , "mk" , FALSE
, ",", " ", 2 }, // -1 234 567,89 mk
185 { 4, "FRF", "France" , 6.55957 , "F" , FALSE
, ",", " ", 2 }, // -1 234 567,89 F
186 { 5, "DEM", "Germany" , 1.95583 , "DM" , FALSE
, ",", ".", 2 }, // -1.234.567,89 DM
187 { 6, "GRD", "Greece" , 340.750 , "d" , TRUE
, ".", ",", 2 }, // ??
188 { 21, "HUF", "Hungary" , 261.51 , "Ft" , TRUE
, ",", " ", 2 }, // non-fixé - No current target for euro
189 { 7, "IEP", "Ireland" , 0.787564 , "£" , TRUE
, ".", ",", 2 }, // -£1,234,567.89
190 { 8, "ITL", "Italy" , 1936.27 , "L" , TRUE
, "" , ".", 0 }, // L -1.234.567
191 { 18, "LVL", "Latvia" , 0.702804 , "lat.", FALSE
, ",", "" , 2 }, // jan. 2014
192 { 19, "LTL", "Lithuania" , 3.45280 , "Lt" , FALSE
, ",", "" , 2 }, // jan. 2015
193 { 9, "LUF", "Luxembourg" , 40.3399 , "LU" , TRUE
, ",", ".", 2 }, // LU 1.234.567,89 -
194 { 15, "MTL", "Malta" , 0.429300 , "Lm" , TRUE
, ",", "" , 2 }, //
195 { 10, "NLG", "Netherlands" , 2.20371 , "F" , TRUE
, ",", ".", 2 }, // F 1.234.567,89-
196 { 25, "PLN", "Poland" , 0.25 , "zł" , FALSE
, ",", "" , 2 }, // non-fixé - No current target for euro
197 { 11, "PTE", "Portugal" , 200.482 , "Esc.", FALSE
, "$", ".", 2 }, // -1.234.567$89 Esc.
198 { 22, "RON", "Romania" , 3.5155 , "Leu" , FALSE
, ",", ".", 2 }, // non-fixé - 2015 target for euro earliest
199 { 16, "SKK", "Slovak Republic", 30.12600 , "Sk" , FALSE
, ",", " ", 2 }, //
200 { 13, "SIT", "Slovenia" , 239.640 , "tol" , TRUE
, ",", ".", 2 }, //
201 { 12, "ESP", "Spain" , 166.386 , "Pts" , TRUE
, "" , ".", 0 }, // -Pts 1.234.567
204 // { " ", "" , 1.00000 , "" , "" , FALSE, ",", "", 2 },
208 GtkWidget
*pref_list_create(void);
209 GtkWidget
*list_txn_colprefcreate(void);
211 static void list_txn_colpref_get(GtkTreeView
*treeview
, gboolean
*columns
);
217 /* = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =*/
225 static LangName languagenames
[] =
227 // 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
228 //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
231 { "ab", "Abkhazian" },
233 { "af", "Afrikaans" },
236 { "an", "Aragonese" },
238 { "as", "Assamese" },
239 { "ast", "Asturian, Bable, Leonese, Asturleonese" },
242 { "az", "Azerbaijani" },
244 { "be", "Belarusian" },
245 { "bg", "Bulgarian" },
255 { "ch", "Chamorro" },
256 { "co", "Corsican" },
259 { "cu", "Old Church Slavonic" },
265 { "dz", "Dzongkha" },
269 { "eo", "Esperanto" },
271 { "et", "Estonian" },
279 { "fy", "Western Frisian" },
281 { "gd", "Scottish Gaelic" },
282 { "gl", "Galician" },
284 { "gu", "Gujarati" },
289 { "ho", "Hiri Motu" },
290 { "hr", "Croatian" },
292 { "hu", "Hungarian" },
293 { "hy", "Armenian" },
295 { "ia", "Interlingua" },
296 { "id", "Indonesian" },
297 { "ie", "Interlingue" },
299 { "ii", "Sichuan Yi" },
302 { "is", "Icelandic" },
304 { "iu", "Inuktitut" },
305 { "ja", "Japanese" },
306 { "jv", "Javanese" },
307 { "ka", "Georgian" },
310 { "kj", "Kwanyama" },
312 { "kl", "Kalaallisut" },
317 { "ks", "Kashmiri" },
323 { "lb", "Luxembourgish" },
325 { "li", "Limburgish" },
328 { "lt", "Lithuanian" },
329 { "lu", "Luba-Katanga" },
331 { "mg", "Malagasy" },
332 { "mh", "Marshallese" },
334 { "mk", "Macedonian" },
335 { "ml", "Malayalam" },
336 { "mn", "Mongolian" },
337 { "mo", "Moldavian" },
343 { "nb", "Norwegian Bokmål" },
344 { "nd", "North Ndebele" },
345 { "nds", "Low German, Low Saxon" },
349 { "nn", "Norwegian Nynorsk" },
350 { "no", "Norwegian" },
351 { "nr", "South Ndebele" },
353 { "ny", "Chichewa" },
358 { "os", "Ossetian" },
363 { "pt", "Portuguese" },
367 { "ro", "Romanian" },
369 { "rw", "Kinyarwanda" },
370 { "sa", "Sanskrit" },
371 { "sc", "Sardinian" },
373 { "se", "Northern Sami" },
375 { "si", "Sinhalese" },
381 { "sq", "Albanian" },
385 { "su", "Sundanese" },
392 { "ti", "Tigrinya" },
401 { "ty", "Tahitian" },
403 { "uk", "Ukrainian" },
407 { "vi", "Viêt Namese" },
422 ui_language_combobox_compare_func (GtkTreeModel
*model
, GtkTreeIter
*a
, GtkTreeIter
*b
, gpointer userdata
)
425 gchar
*code1
, *code2
;
426 gchar
*name1
, *name2
;
428 gtk_tree_model_get(model
, a
, 0, &code1
, 1, &name1
, -1);
429 gtk_tree_model_get(model
, b
, 0, &code2
, 1, &name2
, -1);
431 //keep system laguage on top
432 if(code1
== NULL
) name1
= NULL
;
433 if(code2
== NULL
) name2
= NULL
;
435 retval
= hb_string_utf8_compare(name1
, name2
);
444 static gchar
*languagename_get(const gchar
*locale
)
448 for (i
= 0; i
< G_N_ELEMENTS (languagenames
); i
++)
450 if( g_ascii_strncasecmp(locale
, languagenames
[i
].locale
, -1) == 0 )
451 return languagenames
[i
].name
;
459 ui_language_combobox_get_name(const gchar
*locale
)
463 DB( g_print("[ui_language_combobox_get_name]\n") );
465 // A locale directory name is typically of the form language[_territory]
466 lang
= languagename_get (locale
);
469 const gchar
*delimiter
= strchr (locale
, '_'); // strip off the territory suffix
473 gchar
*copy
= g_strndup (locale
, delimiter
- locale
);
474 lang
= languagename_get (copy
);
480 g_warning(" locale name not found '%s'", locale
);
491 ui_language_combobox_populate(GtkWidget
*combobox
)
496 model
= gtk_combo_box_get_model(GTK_COMBO_BOX(combobox
));
497 gtk_list_store_append (GTK_LIST_STORE(model
), &iter
);
498 gtk_list_store_set (GTK_LIST_STORE(model
), &iter
,
500 1, _("System Language"),
503 GDir
*dir
= g_dir_open (homebank_app_get_locale_dir (), 0, NULL
);
504 const gchar
*dirname
;
509 while ((dirname
= g_dir_read_name (dir
)) != NULL
)
511 gchar
*filename
= g_build_filename (homebank_app_get_locale_dir (),
514 GETTEXT_PACKAGE
".mo",
516 //DB( g_print("- seek for '%s'\n", filename) );
517 if (g_file_test (filename
, G_FILE_TEST_EXISTS
))
522 gtk_list_store_append (GTK_LIST_STORE(model
), &iter
);
524 lang
= ui_language_combobox_get_name(dirname
);
525 label
= g_strdup_printf ("%s [%s]", lang
, dirname
);
527 gtk_list_store_set (GTK_LIST_STORE(model
), &iter
,
539 gtk_tree_sortable_set_sort_column_id(GTK_TREE_SORTABLE(model
), GTK_TREE_SORTABLE_DEFAULT_SORT_COLUMN_ID
, GTK_SORT_ASCENDING
);
546 ui_language_combobox_new(GtkWidget
*label
)
550 GtkCellRenderer
*renderer
;
552 store
= gtk_list_store_new (2,
556 gtk_tree_sortable_set_default_sort_func(GTK_TREE_SORTABLE(store
), ui_language_combobox_compare_func
, NULL
, NULL
);
558 combobox
= gtk_combo_box_new_with_model(GTK_TREE_MODEL(store
));
559 renderer
= gtk_cell_renderer_text_new ();
560 gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (combobox
), renderer
, TRUE
);
561 gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (combobox
), renderer
, "text", 1, NULL
);
563 gtk_combo_box_set_id_column( GTK_COMBO_BOX(combobox
), 0);
565 g_object_unref(store
);
568 gtk_label_set_mnemonic_widget (GTK_LABEL(label
), combobox
);
570 ui_language_combobox_populate(combobox
);
572 gtk_combo_box_set_active(GTK_COMBO_BOX(combobox
), 0);
578 /* = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =*/
579 /* = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =*/
580 /* = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =*/
582 static gint
ui_euro_combobox_id_to_active(gint id
)
586 DB( g_print("\n[ui-pref] ui_euro_combobox_id_to_active\n") );
589 for (i
= 0; i
< G_N_ELEMENTS (euro_params
); i
++)
591 if( euro_params
[i
].id
== id
)
594 DB( g_print("- id (country)=%d => %d - %s\n", id
, i
, euro_params
[i
].name
) );
604 static gint
ui_euro_combobox_active_to_id(gint active
)
608 DB( g_print("\n[ui-pref] ui_euro_combobox_active_to_id\n") );
610 DB( g_print("- to %d\n", active
) );
613 if( active
< (gint
)G_N_ELEMENTS (euro_params
) )
615 id
= euro_params
[active
].id
;
616 DB( g_print("- id (country)=%d '%s'\n", id
, euro_params
[active
].name
) );
622 static GtkWidget
*ui_euro_combobox_new(GtkWidget
*label
)
627 DB( g_print("\n[ui-pref] make euro preset\n") );
629 combobox
= gtk_combo_box_text_new();
630 for (i
= 0; i
< G_N_ELEMENTS (euro_params
); i
++)
632 gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(combobox
), euro_params
[i
].name
);
634 gtk_combo_box_set_active(GTK_COMBO_BOX(combobox
), 0);
637 gtk_label_set_mnemonic_widget (GTK_LABEL(label
), combobox
);
643 static void defpref_pathselect(GtkWidget
*widget
, gpointer user_data
)
645 struct defpref_data
*data
;
646 gint type
= GPOINTER_TO_INT(user_data
);
652 DB( g_print("\n[ui-pref] path select\n") );
654 data
= g_object_get_data(G_OBJECT(gtk_widget_get_ancestor(widget
, GTK_TYPE_WINDOW
)), "inst_data");
659 path
= &PREFS
->path_hbfile
;
660 entry
= data
->ST_path_hbfile
;
661 title
= _("Choose a default HomeBank files folder");
664 path
= &PREFS
->path_import
;
665 entry
= data
->ST_path_import
;
666 title
= _("Choose a default import folder");
669 path
= &PREFS
->path_export
;
670 entry
= data
->ST_path_export
;
671 title
= _("Choose a default export folder");
677 DB( g_print(" - hbfile %p %s at %p\n" , PREFS
->path_hbfile
, PREFS
->path_hbfile
, &PREFS
->path_hbfile
) );
678 DB( g_print(" - import %p %s at %p\n" , PREFS
->path_import
, PREFS
->path_import
, &PREFS
->path_import
) );
679 DB( g_print(" - export %p %s at %p\n" , PREFS
->path_export
, PREFS
->path_export
, &PREFS
->path_export
) );
682 DB( g_print(" - before: %s %p\n" , *path
, path
) );
684 r
= ui_file_chooser_folder(GTK_WINDOW(gtk_widget_get_ancestor(widget
, GTK_TYPE_WINDOW
)), title
, path
);
687 DB( g_print(" - after: %s\n", *path
) );
690 gtk_entry_set_text(GTK_ENTRY(entry
), *path
);
697 ** update the date sample label
699 static void defpref_date_sample(GtkWidget
*widget
, gpointer user_data
)
701 struct defpref_data
*data
;
706 DB( g_print("\n[ui-pref] date sample\n") );
708 data
= g_object_get_data(G_OBJECT(gtk_widget_get_ancestor(widget
, GTK_TYPE_WINDOW
)), "inst_data");
710 fmt
= gtk_entry_get_text(GTK_ENTRY(data
->ST_datefmt
));
711 date
= g_date_new_julian (GLOBALS
->today
);
712 g_date_strftime (buffer
, 256-1, fmt
, date
);
715 gtk_label_set_text(GTK_LABEL(data
->LB_date
), buffer
);
721 ** update the number sample label
723 static void defpref_numbereuro_sample(GtkWidget
*widget
, gpointer user_data
)
725 struct defpref_data
*data
;
727 gchar formatd_buf
[G_ASCII_DTOSTR_BUF_SIZE
];
730 DB( g_print("\n[ui-pref] number sample\n") );
732 data
= g_object_get_data(G_OBJECT(gtk_widget_get_ancestor(widget
, GTK_TYPE_WINDOW
)), "inst_data");
734 cur
.symbol
= (gchar
*)gtk_entry_get_text(GTK_ENTRY(data
->ST_euro_symbol
));
735 cur
.sym_prefix
= gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(data
->CM_euro_isprefix
));
736 cur
.decimal_char
= (gchar
*)gtk_entry_get_text(GTK_ENTRY(data
->ST_euro_decimalchar
));
737 cur
.grouping_char
= (gchar
*)gtk_entry_get_text(GTK_ENTRY(data
->ST_euro_groupingchar
));
738 cur
.frac_digits
= gtk_spin_button_get_value(GTK_SPIN_BUTTON(data
->NB_euro_fracdigits
));
740 da_cur_initformat (&cur
);
742 DB( g_print("fmt: %s\n", cur
.format
) );
744 g_ascii_formatd(formatd_buf
, sizeof (formatd_buf
), cur
.format
, HB_NUMBER_SAMPLE
);
745 hb_str_formatd(buf
, 127, formatd_buf
, &cur
, TRUE
);
747 gtk_label_set_text(GTK_LABEL(data
->LB_numbereuro
), buf
);
753 ** enable/disable euro
755 static void defpref_eurotoggle(GtkWidget
*widget
, gpointer user_data
)
757 struct defpref_data
*data
;
760 DB( g_print("\n[ui-pref] euro toggle\n") );
762 data
= g_object_get_data(G_OBJECT(gtk_widget_get_ancestor(widget
, GTK_TYPE_WINDOW
)), "inst_data");
764 sensitive
= gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(data
->CM_euro_enable
));
766 gtk_widget_set_sensitive(data
->GRP_currency
, sensitive
);
767 gtk_widget_set_sensitive(data
->GRP_rate
, sensitive
);
768 gtk_widget_set_sensitive(data
->GRP_format
, sensitive
);
773 ** set euro value widget from a country
775 static void defpref_eurosetcurrency(GtkWidget
*widget
, gint country
)
777 struct defpref_data
*data
;
782 DB( g_print("\n[ui-pref] eurosetcurrency\n") );
784 data
= g_object_get_data(G_OBJECT(gtk_widget_get_ancestor(widget
, GTK_TYPE_WINDOW
)), "inst_data");
786 active
= ui_euro_combobox_id_to_active(country
);
787 euro
= &euro_params
[active
];
788 buf
= g_strdup_printf("%s - %s", euro
->iso
, euro
->name
);
789 gtk_label_set_markup(GTK_LABEL(data
->ST_euro_country
), buf
);
795 ** set euro value widget from a country
797 static void defpref_europreset(GtkWidget
*widget
, gpointer user_data
)
799 struct defpref_data
*data
;
802 DB( g_print("\n[ui-pref] euro preset\n") );
804 data
= g_object_get_data(G_OBJECT(gtk_widget_get_ancestor(widget
, GTK_TYPE_WINDOW
)), "inst_data");
806 active
= gtk_combo_box_get_active (GTK_COMBO_BOX(data
->CY_euro_preset
));
807 data
->country
= ui_euro_combobox_active_to_id (active
);;
809 defpref_eurosetcurrency(widget
, data
->country
);
811 gtk_spin_button_set_value(GTK_SPIN_BUTTON(data
->NB_euro_value
), euro_params
[active
].value
);
813 gtk_spin_button_set_value(GTK_SPIN_BUTTON(data
->NB_euro_fracdigits
), euro_params
[active
].frac_digits
);
815 gtk_entry_set_text(GTK_ENTRY(data
->ST_euro_symbol
) , euro_params
[active
].symbol
);
816 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(data
->CM_euro_isprefix
), euro_params
[active
].sym_prefix
);
817 gtk_entry_set_text(GTK_ENTRY(data
->ST_euro_decimalchar
) , euro_params
[active
].decimal_char
);
818 gtk_entry_set_text(GTK_ENTRY(data
->ST_euro_groupingchar
), euro_params
[active
].grouping_char
);
823 static void defpref_colortoggle(GtkWidget
*widget
, gpointer user_data
)
825 struct defpref_data
*data
;
828 DB( g_print("\n[ui-pref] color toggle\n") );
830 data
= g_object_get_data(G_OBJECT(gtk_widget_get_ancestor(widget
, GTK_TYPE_WINDOW
)), "inst_data");
832 sensitive
= gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(data
->CM_custom_colors
));
834 gtk_widget_set_sensitive(data
->GR_colors
, sensitive
);
840 ** set preset colors for amount display
842 static void defpref_colorpreset(GtkWidget
*widget
, gpointer user_data
)
844 struct defpref_data
*data
;
847 gchar
*expcol
, *inccol
, *wrncol
;
849 DB( g_print("\n[ui-pref] color preset\n") );
851 data
= g_object_get_data(G_OBJECT(gtk_widget_get_ancestor(widget
, GTK_TYPE_WINDOW
)), "inst_data");
853 preset
= gtk_combo_box_get_active(GTK_COMBO_BOX(data
->CY_colors
));
858 expcol
= LIGHT_EXP_COLOR
;
859 inccol
= LIGHT_INC_COLOR
;
860 wrncol
= LIGHT_WARN_COLOR
;
864 expcol
= MEDIUM_EXP_COLOR
;
865 inccol
= MEDIUM_INC_COLOR
;
866 wrncol
= MEDIUM_WARN_COLOR
;
871 expcol
= DEFAULT_EXP_COLOR
;
872 inccol
= DEFAULT_INC_COLOR
;
873 wrncol
= DEFAULT_WARN_COLOR
;
878 gdk_rgba_parse(&rgba
, expcol
);
879 gtk_color_chooser_set_rgba(GTK_COLOR_CHOOSER(data
->CP_exp_color
), &rgba
);
881 gdk_rgba_parse(&rgba
, inccol
);
882 gtk_color_chooser_set_rgba(GTK_COLOR_CHOOSER(data
->CP_inc_color
), &rgba
);
884 gdk_rgba_parse(&rgba
, wrncol
);
885 gtk_color_chooser_set_rgba(GTK_COLOR_CHOOSER(data
->CP_warn_color
), &rgba
);
891 static void defpref_color_scheme_changed(GtkWidget
*widget
, gpointer user_data
)
893 struct defpref_data
*data
;
895 DB( g_print("\n[ui-pref] color scheme chnaged\n") );
897 data
= g_object_get_data(G_OBJECT(gtk_widget_get_ancestor(widget
, GTK_TYPE_WINDOW
)), "inst_data");
899 gtk_widget_queue_draw (data
->DA_colors
);
907 static void setGdkColor_from_RGB(GdkColor *color, guint32 value)
912 color->red = tmp | tmp<<8;
914 tmp = value >> 8 & 0xFF;
915 color->green = tmp | tmp<<8;
918 color->blue = tmp | tmp<<8;
924 ** set :: fill in widgets from PREFS structure
927 static void defpref_set(struct defpref_data
*data
)
931 DB( g_print("\n[ui-pref] set\n") );
933 if(PREFS
->language
!= NULL
)
934 gtk_combo_box_set_active_id(GTK_COMBO_BOX(data
->CY_language
), PREFS
->language
);
936 gtk_combo_box_set_active (GTK_COMBO_BOX(data
->CY_language
), 0);
938 gtk_combo_box_set_active(GTK_COMBO_BOX(data
->CY_toolbar
), PREFS
->toolbar_style
);
939 //gtk_spin_button_set_value(GTK_SPIN_BUTTON(data->NB_image_size), PREFS->image_size);
943 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(data
->CM_custom_colors
), PREFS
->custom_colors
);
945 gdk_rgba_parse(&rgba
, PREFS
->color_exp
);
946 gtk_color_chooser_set_rgba(GTK_COLOR_CHOOSER(data
->CP_exp_color
), &rgba
);
948 gdk_rgba_parse(&rgba
, PREFS
->color_inc
);
949 gtk_color_chooser_set_rgba(GTK_COLOR_CHOOSER(data
->CP_inc_color
), &rgba
);
951 gdk_rgba_parse(&rgba
, PREFS
->color_warn
);
952 gtk_color_chooser_set_rgba(GTK_COLOR_CHOOSER(data
->CP_warn_color
), &rgba
);
954 //gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(data->CM_ruleshint), PREFS->rules_hint);
955 gtk_combo_box_set_active(GTK_COMBO_BOX(data
->CY_gridlines
), PREFS
->grid_lines
);
957 gtk_spin_button_set_value(GTK_SPIN_BUTTON(data
->NB_fiscyearday
), PREFS
->fisc_year_day
);
958 gtk_combo_box_set_active(GTK_COMBO_BOX(data
->CY_fiscyearmonth
), PREFS
->fisc_year_month
- 1);
960 gtk_entry_set_text(GTK_ENTRY(data
->ST_path_hbfile
), PREFS
->path_hbfile
);
961 gtk_entry_set_text(GTK_ENTRY(data
->ST_path_import
), PREFS
->path_import
);
962 gtk_entry_set_text(GTK_ENTRY(data
->ST_path_export
), PREFS
->path_export
);
963 //gtk_entry_set_text(GTK_ENTRY(data->ST_path_navigator), PREFS->path_navigator);
965 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(data
->CM_load_last
), PREFS
->loadlast
);
966 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(data
->CM_append_scheduled
), PREFS
->appendscheduled
);
967 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(data
->CM_do_update_currency
), PREFS
->do_update_currency
);
968 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(data
->CM_show_splash
), PREFS
->showsplash
);
969 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(data
->CM_herit_date
), PREFS
->heritdate
);
970 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(data
->CM_hide_reconciled
), PREFS
->hidereconciled
);
971 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(data
->CM_show_remind
), PREFS
->showremind
);
974 gtk_entry_set_text(GTK_ENTRY(data
->ST_datefmt
), PREFS
->date_format
);
976 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(data
->CM_unitismile
), PREFS
->vehicle_unit_ismile
);
977 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(data
->CM_unitisgal
), PREFS
->vehicle_unit_isgal
);
979 gtk_combo_box_set_active(GTK_COMBO_BOX(data
->CY_daterange_wal
), PREFS
->date_range_wal
);
980 gtk_combo_box_set_active(GTK_COMBO_BOX(data
->CY_daterange_txn
), PREFS
->date_range_txn
);
981 gtk_spin_button_set_value(GTK_SPIN_BUTTON(data
->ST_datefuture_nbdays
), PREFS
->date_future_nbdays
);
982 gtk_combo_box_set_active(GTK_COMBO_BOX(data
->CY_daterange_rep
), PREFS
->date_range_rep
);
985 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(data
->CM_euro_enable
), PREFS
->euro_active
);
986 //gtk_combo_box_set_active(GTK_COMBO_BOX(data->CY_euro_preset), PREFS->euro_country);
987 data
->country
= PREFS
->euro_country
;
988 defpref_eurosetcurrency(data
->window
, data
->country
);
990 gtk_spin_button_set_value(GTK_SPIN_BUTTON(data
->NB_euro_value
), PREFS
->euro_value
);
992 ui_gtk_entry_set_text(data
->ST_euro_symbol
, PREFS
->minor_cur
.symbol
);
993 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(data
->CM_euro_isprefix
), PREFS
->minor_cur
.sym_prefix
);
994 ui_gtk_entry_set_text(data
->ST_euro_decimalchar
, PREFS
->minor_cur
.decimal_char
);
995 ui_gtk_entry_set_text(data
->ST_euro_groupingchar
, PREFS
->minor_cur
.grouping_char
);
996 gtk_spin_button_set_value(GTK_SPIN_BUTTON(data
->NB_euro_fracdigits
), PREFS
->minor_cur
.frac_digits
);
999 //gtk_entry_set_text(GTK_ENTRY(data->ST_euro_symbol), PREFS->euro_symbol);
1000 //gtk_spin_button_set_value(GTK_SPIN_BUTTON(data->NB_euro_nbdec), PREFS->euro_nbdec);
1001 //gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(data->CM_euro_thsep), PREFS->euro_thsep);
1003 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(data
->CM_stat_byamount
), PREFS
->stat_byamount
);
1004 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(data
->CM_stat_showrate
), PREFS
->stat_showrate
);
1005 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(data
->CM_stat_showdetail
), PREFS
->stat_showdetail
);
1007 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(data
->CM_budg_showdetail
), PREFS
->budg_showdetail
);
1009 gtk_combo_box_set_active(GTK_COMBO_BOX(data
->CY_color_scheme
), PREFS
->report_color_scheme
);
1012 gtk_combo_box_set_active(GTK_COMBO_BOX(data
->CY_dtex_datefmt
), PREFS
->dtex_datefmt
);
1013 gtk_combo_box_set_active(GTK_COMBO_BOX(data
->CY_dtex_ofxname
), PREFS
->dtex_ofxname
);
1014 gtk_combo_box_set_active(GTK_COMBO_BOX(data
->CY_dtex_ofxmemo
), PREFS
->dtex_ofxmemo
);
1015 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(data
->CM_dtex_qifmemo
), PREFS
->dtex_qifmemo
);
1016 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(data
->CM_dtex_qifswap
), PREFS
->dtex_qifswap
);
1023 ** get :: fill PREFS structure from widgets
1026 #define RGBA_TO_INT(x) (int)(x*255)
1028 static gchar
*gdk_rgba_to_hex(GdkRGBA
*rgba
)
1030 return g_strdup_printf("#%02x%02x%02x", RGBA_TO_INT(rgba
->red
), RGBA_TO_INT(rgba
->green
), RGBA_TO_INT(rgba
->blue
));
1034 static void defpref_get(struct defpref_data
*data
)
1039 DB( g_print("\n[ui-pref] get\n") );
1041 g_free(PREFS
->language
);
1042 PREFS
->language
= NULL
;
1043 lang
= gtk_combo_box_get_active_id(GTK_COMBO_BOX(data
->CY_language
));
1046 PREFS
->language
= g_strdup(lang
);
1049 PREFS
->toolbar_style
= gtk_combo_box_get_active(GTK_COMBO_BOX(data
->CY_toolbar
));
1050 //PREFS->image_size = gtk_spin_button_get_value(GTK_SPIN_BUTTON(data->NB_image_size));
1052 PREFS
->custom_colors
= gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(data
->CM_custom_colors
));
1054 gtk_color_chooser_get_rgba(GTK_COLOR_CHOOSER(data
->CP_exp_color
), &rgba
);
1055 g_free(PREFS
->color_exp
);
1056 PREFS
->color_exp
= gdk_rgba_to_hex(&rgba
);
1058 gtk_color_chooser_get_rgba(GTK_COLOR_CHOOSER(data
->CP_inc_color
), &rgba
);
1059 g_free(PREFS
->color_inc
);
1060 PREFS
->color_inc
= gdk_rgba_to_hex(&rgba
);
1062 gtk_color_chooser_get_rgba(GTK_COLOR_CHOOSER(data
->CP_warn_color
), &rgba
);
1063 g_free(PREFS
->color_warn
);
1064 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
));
1069 PREFS
->fisc_year_day
= gtk_spin_button_get_value(GTK_SPIN_BUTTON(data
->NB_fiscyearday
));
1070 PREFS
->fisc_year_month
= 1 + gtk_combo_box_get_active(GTK_COMBO_BOX(data
->CY_fiscyearmonth
));
1072 list_txn_colpref_get(GTK_TREE_VIEW(data
->LV_opecolumns
), PREFS
->lst_ope_columns
);
1074 g_free(PREFS
->path_hbfile
);
1075 PREFS
->path_hbfile
= g_strdup(gtk_entry_get_text(GTK_ENTRY(data
->ST_path_hbfile
)));
1077 ui_gtk_entry_replace_text(data
->ST_path_import
, &PREFS
->path_import
);
1079 ui_gtk_entry_replace_text(data
->ST_path_export
, &PREFS
->path_export
);
1081 PREFS
->loadlast
= gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(data
->CM_load_last
));
1082 PREFS
->appendscheduled
= gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(data
->CM_append_scheduled
));
1083 PREFS
->do_update_currency
= gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(data
->CM_do_update_currency
));
1085 PREFS
->showsplash
= gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(data
->CM_show_splash
));
1086 PREFS
->heritdate
= gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(data
->CM_herit_date
));
1087 PREFS
->hidereconciled
= gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(data
->CM_hide_reconciled
));
1088 PREFS
->showremind
= gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(data
->CM_show_remind
));
1090 //g_free(PREFS->path_navigator);
1091 //PREFS->path_navigator = g_strdup(gtk_entry_get_text(GTK_ENTRY(data->ST_path_navigator)));
1093 g_free(PREFS
->date_format
);
1094 PREFS
->date_format
= g_strdup(gtk_entry_get_text(GTK_ENTRY(data
->ST_datefmt
)));
1096 PREFS
->vehicle_unit_ismile
= gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(data
->CM_unitismile
));
1097 PREFS
->vehicle_unit_isgal
= gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(data
->CM_unitisgal
));
1099 PREFS
->date_range_wal
= gtk_combo_box_get_active(GTK_COMBO_BOX(data
->CY_daterange_wal
));
1100 PREFS
->date_range_txn
= gtk_combo_box_get_active(GTK_COMBO_BOX(data
->CY_daterange_txn
));
1101 PREFS
->date_future_nbdays
= gtk_spin_button_get_value(GTK_SPIN_BUTTON(data
->ST_datefuture_nbdays
));
1102 PREFS
->date_range_rep
= gtk_combo_box_get_active(GTK_COMBO_BOX(data
->CY_daterange_rep
));
1104 PREFS
->euro_active
= gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(data
->CM_euro_enable
));
1106 PREFS
->euro_country
= data
->country
;
1107 PREFS
->euro_value
= gtk_spin_button_get_value(GTK_SPIN_BUTTON(data
->NB_euro_value
));
1108 //strcpy(PREFS->euro_symbol, gtk_entry_get_text(GTK_ENTRY(data->ST_euro_symbol)));
1109 //PREFS->euro_nbdec = gtk_spin_button_get_value(GTK_SPIN_BUTTON(data->NB_euro_nbdec));
1110 //PREFS->euro_thsep = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(data->CM_euro_thsep));
1112 ui_gtk_entry_replace_text(data
->ST_euro_symbol
, &PREFS
->minor_cur
.symbol
);
1113 PREFS
->minor_cur
.sym_prefix
= gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(data
->CM_euro_isprefix
));
1114 ui_gtk_entry_replace_text(data
->ST_euro_decimalchar
, &PREFS
->minor_cur
.decimal_char
);
1115 ui_gtk_entry_replace_text(data
->ST_euro_groupingchar
, &PREFS
->minor_cur
.grouping_char
);
1116 PREFS
->minor_cur
.frac_digits
= gtk_spin_button_get_value(GTK_SPIN_BUTTON(data
->NB_euro_fracdigits
));
1118 PREFS
->stat_byamount
= gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(data
->CM_stat_byamount
));
1119 PREFS
->stat_showrate
= gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(data
->CM_stat_showrate
));
1120 PREFS
->stat_showdetail
= gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(data
->CM_stat_showdetail
));
1122 PREFS
->budg_showdetail
= gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(data
->CM_budg_showdetail
));
1124 PREFS
->report_color_scheme
= gtk_combo_box_get_active(GTK_COMBO_BOX(data
->CY_color_scheme
));
1127 PREFS
->dtex_datefmt
= gtk_combo_box_get_active(GTK_COMBO_BOX(data
->CY_dtex_datefmt
));
1128 PREFS
->dtex_ofxname
= gtk_combo_box_get_active(GTK_COMBO_BOX(data
->CY_dtex_ofxname
));
1129 PREFS
->dtex_ofxmemo
= gtk_combo_box_get_active(GTK_COMBO_BOX(data
->CY_dtex_ofxmemo
));
1130 PREFS
->dtex_qifmemo
= gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(data
->CM_dtex_qifmemo
));
1131 PREFS
->dtex_qifswap
= gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(data
->CM_dtex_qifswap
));
1133 //PREFS->chart_legend = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(data->CM_chartlegend));
1138 static GtkWidget
*defpref_page_import (struct defpref_data
*data
)
1140 GtkWidget
*content_grid
, *group_grid
, *hbox
, *label
, *widget
;
1143 content_grid
= gtk_grid_new();
1144 gtk_grid_set_row_spacing (GTK_GRID (content_grid
), SPACING_LARGE
);
1145 gtk_orientable_set_orientation(GTK_ORIENTABLE(content_grid
), GTK_ORIENTATION_VERTICAL
);
1148 // group :: Date options
1149 group_grid
= gtk_grid_new ();
1150 gtk_grid_set_row_spacing (GTK_GRID (group_grid
), SPACING_SMALL
);
1151 gtk_grid_set_column_spacing (GTK_GRID (group_grid
), SPACING_MEDIUM
);
1152 gtk_grid_attach (GTK_GRID (content_grid
), group_grid
, 0, crow
++, 1, 1);
1154 label
= make_label_group(_("Date options"));
1155 gtk_grid_attach (GTK_GRID (group_grid
), label
, 0, 0, 3, 1);
1158 label
= make_label_widget(_("Date order:"));
1159 //----------------------------------------- l, r, t, b
1160 gtk_grid_attach (GTK_GRID (group_grid
), label
, 1, row
, 1, 1);
1161 widget
= make_cycle(label
, CYA_IMPORT_DATEORDER
);
1162 data
->CY_dtex_datefmt
= widget
;
1163 //gtk_grid_attach (GTK_GRID (group_grid), data->CY_option[FILTER_DATE], 1, 2, row, row+1);
1164 gtk_grid_attach (GTK_GRID (group_grid
), widget
, 2, row
, 1, 1);
1167 // group :: OFX/QFX options
1168 group_grid
= gtk_grid_new ();
1169 gtk_grid_set_row_spacing (GTK_GRID (group_grid
), SPACING_SMALL
);
1170 gtk_grid_set_column_spacing (GTK_GRID (group_grid
), SPACING_MEDIUM
);
1171 gtk_grid_attach (GTK_GRID (content_grid
), group_grid
, 0, crow
++, 1, 1);
1173 label
= make_label_group(_("OFX/QFX options"));
1174 gtk_grid_attach (GTK_GRID (group_grid
), label
, 0, 0, 3, 1);
1177 label
= make_label_widget(_("_Name field:"));
1178 //----------------------------------------- l, r, t, b
1179 gtk_grid_attach (GTK_GRID (group_grid
), label
, 1, row
, 1, 1);
1180 widget
= make_cycle(label
, CYA_IMPORT_OFXNAME
);
1181 data
->CY_dtex_ofxname
= widget
;
1182 //gtk_grid_attach (GTK_GRID (group_grid), data->CY_option[FILTER_DATE], 1, 2, row, row+1);
1183 gtk_grid_attach (GTK_GRID (group_grid
), widget
, 2, row
, 1, 1);
1186 label
= make_label_widget(_("_Memo field:"));
1187 //----------------------------------------- l, r, t, b
1188 gtk_grid_attach (GTK_GRID (group_grid
), label
, 1, row
, 1, 1);
1189 widget
= make_cycle(label
, CYA_IMPORT_OFXMEMO
);
1190 data
->CY_dtex_ofxmemo
= widget
;
1191 //gtk_grid_attach (GTK_GRID (group_grid), data->CY_option[FILTER_DATE], 1, 2, row, row+1);
1192 gtk_grid_attach (GTK_GRID (group_grid
), widget
, 2, row
, 1, 1);
1194 // group :: QIF 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(_("QIF options"));
1201 gtk_grid_attach (GTK_GRID (group_grid
), label
, 0, 0, 3, 1);
1204 label
= make_label_widget(_("Memos:"));
1205 gtk_grid_attach (GTK_GRID (group_grid
), label
, 1, row
, 1, 1);
1206 widget
= gtk_check_button_new_with_mnemonic (_("_Import"));
1207 data
->CM_dtex_qifmemo
= widget
;
1208 gtk_grid_attach (GTK_GRID (group_grid
), widget
, 2, row
, 1, 1);
1209 widget
= gtk_check_button_new_with_mnemonic (_("_Swap with payees"));
1210 data
->CM_dtex_qifswap
= widget
;
1211 gtk_grid_attach (GTK_GRID (group_grid
), widget
, 3, row
, 1, 1);
1214 // group :: Files folder
1215 group_grid
= gtk_grid_new ();
1216 gtk_grid_set_row_spacing (GTK_GRID (group_grid
), SPACING_SMALL
);
1217 gtk_grid_set_column_spacing (GTK_GRID (group_grid
), SPACING_MEDIUM
);
1218 gtk_grid_attach (GTK_GRID (content_grid
), group_grid
, 0, crow
++, 1, 1);
1220 label
= make_label_group(_("Files folder"));
1221 gtk_grid_attach (GTK_GRID (group_grid
), label
, 0, 0, 3, 1);
1224 label
= make_label_widget(_("_Import:"));
1225 //----------------------------------------- l, r, t, b
1226 gtk_grid_attach (GTK_GRID (group_grid
), label
, 1, row
, 1, 1);
1228 hbox
= gtk_box_new(GTK_ORIENTATION_HORIZONTAL
, 0);
1229 gtk_widget_set_hexpand (hbox
, TRUE
);
1230 gtk_grid_attach (GTK_GRID (group_grid
), hbox
, 2, row
, 1, 1);
1232 widget
= make_string(label
);
1233 data
->ST_path_import
= widget
;
1234 gtk_style_context_add_class (gtk_widget_get_style_context (GTK_WIDGET(widget
)), GTK_STYLE_CLASS_LINKED
);
1235 gtk_box_pack_start (GTK_BOX (hbox
), widget
, TRUE
, TRUE
, 0);
1237 //widget = gtk_button_new_with_label("...");
1238 widget
= gtk_button_new_from_icon_name(ICONNAME_FOLDER
, GTK_ICON_SIZE_BUTTON
);
1239 data
->BT_path_import
= widget
;
1240 gtk_box_pack_start (GTK_BOX (hbox
), widget
, FALSE
, FALSE
, 0);
1243 label
= make_label_widget(_("_Export:"));
1244 //----------------------------------------- l, r, t, b
1245 gtk_grid_attach (GTK_GRID (group_grid
), label
, 1, row
, 1, 1);
1247 hbox
= gtk_box_new(GTK_ORIENTATION_HORIZONTAL
, 0);
1248 gtk_widget_set_hexpand (hbox
, TRUE
);
1249 gtk_grid_attach (GTK_GRID (group_grid
), hbox
, 2, row
, 1, 1);
1251 widget
= make_string(label
);
1252 data
->ST_path_export
= widget
;
1253 gtk_style_context_add_class (gtk_widget_get_style_context (GTK_WIDGET(widget
)), GTK_STYLE_CLASS_LINKED
);
1254 gtk_box_pack_start (GTK_BOX (hbox
), widget
, TRUE
, TRUE
, 0);
1256 //widget = gtk_button_new_with_label("...");
1257 widget
= gtk_button_new_from_icon_name(ICONNAME_FOLDER
, GTK_ICON_SIZE_BUTTON
);
1258 data
->BT_path_export
= widget
;
1259 gtk_box_pack_start (GTK_BOX (hbox
), widget
, FALSE
, FALSE
, 0);
1261 return content_grid
;
1267 draw_callback (GtkWidget
*widget
,
1271 struct defpref_data
*data
= user_data
;
1273 GtkColorScheme scheme
;
1277 index
= gtk_combo_box_get_active(GTK_COMBO_BOX(data
->CY_color_scheme
));
1279 colorscheme_init(&scheme
, index
);
1281 gtk_widget_get_size_request (widget
, &w
, &h
);
1283 for(i
=0;i
<scheme
.nb_cols
;i
++)
1285 cairo_user_set_rgbcol (cr
, &scheme
.colors
[i
]);
1286 cairo_rectangle(cr
, x
, y
, cube_dim
, cube_dim
);
1290 { x
= 0; y
= 1 + cube_dim
; }
1298 static GtkWidget
*defpref_page_reports (struct defpref_data
*data
)
1300 GtkWidget
*content_grid
, *group_grid
, *label
, *widget
;
1303 content_grid
= gtk_grid_new();
1304 gtk_grid_set_row_spacing (GTK_GRID (content_grid
), SPACING_LARGE
);
1305 gtk_orientable_set_orientation(GTK_ORIENTABLE(content_grid
), GTK_ORIENTATION_VERTICAL
);
1308 // group :: Initial filter
1309 group_grid
= gtk_grid_new ();
1310 gtk_grid_set_row_spacing (GTK_GRID (group_grid
), SPACING_SMALL
);
1311 gtk_grid_set_column_spacing (GTK_GRID (group_grid
), SPACING_MEDIUM
);
1312 gtk_grid_attach (GTK_GRID (content_grid
), group_grid
, 0, crow
++, 1, 1);
1314 label
= make_label_group(_("Initial filter"));
1315 gtk_grid_attach (GTK_GRID (group_grid
), label
, 0, 0, 3, 1);
1318 label
= make_label_widget(_("Date _range:"));
1319 //----------------------------------------- l, r, t, b
1320 gtk_grid_attach (GTK_GRID (group_grid
), label
, 1, row
, 1, 1);
1321 widget
= make_daterange(label
, FALSE
);
1322 data
->CY_daterange_rep
= widget
;
1323 //gtk_grid_attach (GTK_GRID (group_grid), data->CY_option[FILTER_DATE], 1, 2, row, row+1);
1324 gtk_grid_attach (GTK_GRID (group_grid
), widget
, 2, row
, 1, 1);
1326 // group ::Charts options
1327 group_grid
= gtk_grid_new ();
1328 gtk_grid_set_row_spacing (GTK_GRID (group_grid
), SPACING_SMALL
);
1329 gtk_grid_set_column_spacing (GTK_GRID (group_grid
), SPACING_MEDIUM
);
1330 gtk_grid_attach (GTK_GRID (content_grid
), group_grid
, 0, crow
++, 1, 1);
1332 label
= make_label_group(_("Charts options"));
1333 gtk_grid_attach (GTK_GRID (group_grid
), label
, 0, 0, 3, 1);
1336 label
= make_label_widget(_("Color scheme:"));
1337 //----------------------------------------- l, r, t, b
1338 gtk_grid_attach (GTK_GRID (group_grid
), label
, 1, row
, 1, 1);
1339 widget
= make_cycle(label
, chart_colors
);
1340 data
->CY_color_scheme
= widget
;
1341 //gtk_grid_attach (GTK_GRID (group_grid), data->CY_option[FILTER_DATE], 1, 2, row, row+1);
1342 gtk_grid_attach (GTK_GRID (group_grid
), widget
, 2, row
, 1, 1);
1345 widget
= gtk_drawing_area_new ();
1346 data
->DA_colors
= widget
;
1347 gtk_widget_set_size_request (widget
, (1+cube_dim
)*16, (1+cube_dim
)*2);
1348 gtk_grid_attach (GTK_GRID (group_grid
), widget
, 2, row
, 1, 1);
1350 g_signal_connect (data
->DA_colors
, "draw", G_CALLBACK (draw_callback
), data
);
1352 // group :: Statistics options
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(_("Statistics options"));
1359 gtk_grid_attach (GTK_GRID (group_grid
), label
, 0, 0, 3, 1);
1362 widget
= gtk_check_button_new_with_mnemonic (_("Show by _amount"));
1363 data
->CM_stat_byamount
= widget
;
1364 gtk_grid_attach (GTK_GRID (group_grid
), widget
, 1, row
, 2, 1);
1367 widget
= gtk_check_button_new_with_mnemonic (_("Show _rate column"));
1368 data
->CM_stat_showrate
= widget
;
1369 gtk_grid_attach (GTK_GRID (group_grid
), widget
, 1, row
, 2, 1);
1372 widget
= gtk_check_button_new_with_mnemonic (_("Show _details"));
1373 data
->CM_stat_showdetail
= widget
;
1374 gtk_grid_attach (GTK_GRID (group_grid
), widget
, 1, row
, 2, 1);
1376 // group :: Budget options
1377 group_grid
= gtk_grid_new ();
1378 gtk_grid_set_row_spacing (GTK_GRID (group_grid
), SPACING_SMALL
);
1379 gtk_grid_set_column_spacing (GTK_GRID (group_grid
), SPACING_MEDIUM
);
1380 gtk_grid_attach (GTK_GRID (content_grid
), group_grid
, 0, crow
++, 1, 1);
1382 label
= make_label_group(_("Budget options"));
1383 gtk_grid_attach (GTK_GRID (group_grid
), label
, 0, 0, 3, 1);
1386 widget
= gtk_check_button_new_with_mnemonic (_("Show _details"));
1387 data
->CM_budg_showdetail
= widget
;
1388 gtk_grid_attach (GTK_GRID (group_grid
), widget
, 1, row
, 2, 1);
1390 return content_grid
;
1394 static GtkWidget
*defpref_page_euro (struct defpref_data
*data
)
1396 GtkWidget
*content_grid
, *group_grid
, *label
, *widget
, *expander
;
1399 content_grid
= gtk_grid_new();
1400 gtk_grid_set_row_spacing (GTK_GRID (content_grid
), SPACING_LARGE
);
1401 gtk_orientable_set_orientation(GTK_ORIENTABLE(content_grid
), GTK_ORIENTATION_VERTICAL
);
1405 group_grid
= gtk_grid_new ();
1406 gtk_grid_set_row_spacing (GTK_GRID (group_grid
), SPACING_SMALL
);
1407 gtk_grid_set_column_spacing (GTK_GRID (group_grid
), SPACING_MEDIUM
);
1408 gtk_grid_attach (GTK_GRID (content_grid
), group_grid
, 0, crow
++, 1, 1);
1410 label
= make_label_group(_("General"));
1411 gtk_grid_attach (GTK_GRID (group_grid
), label
, 0, 0, 3, 1);
1414 widget
= gtk_check_button_new_with_mnemonic (_("_Enable"));
1415 data
->CM_euro_enable
= widget
;
1416 gtk_grid_attach (GTK_GRID (group_grid
), widget
, 1, row
, 2, 1);
1418 // group :: Currency
1419 group_grid
= gtk_grid_new ();
1420 data
->GRP_currency
= group_grid
;
1421 gtk_grid_set_row_spacing (GTK_GRID (group_grid
), SPACING_SMALL
);
1422 gtk_grid_set_column_spacing (GTK_GRID (group_grid
), SPACING_MEDIUM
);
1423 gtk_grid_attach (GTK_GRID (content_grid
), group_grid
, 0, crow
++, 1, 1);
1425 label
= make_label_group(_("Currency"));
1426 gtk_grid_attach (GTK_GRID (group_grid
), label
, 0, 0, 4, 1);
1429 widget
= make_label(NULL
, 0.0, 0.5);
1430 data
->ST_euro_country
= widget
;
1431 //gtk_grid_attach (GTK_GRID (group_grid), data->CY_option[FILTER_DATE], 1, 2, row, row+1);
1432 gtk_grid_attach (GTK_GRID (group_grid
), widget
, 1, row
, 1, 1);
1435 label
= make_label_widget(_("_Preset:"));
1436 //----------------------------------------- l, r, t, b
1437 gtk_grid_attach (GTK_GRID (group_grid
), label
, 2, row
, 1, 1);
1438 widget
= ui_euro_combobox_new (label
);
1439 data
->CY_euro_preset
= widget
;
1440 gtk_widget_set_margin_left (label
, 2*SPACING_LARGE
);
1441 //gtk_grid_attach (GTK_GRID (group_grid), data->CY_option[FILTER_DATE], 1, 2, row, row+1);
1442 gtk_grid_attach (GTK_GRID (group_grid
), widget
, 3, row
, 1, 1);
1445 // group :: Exchange rate
1446 group_grid
= gtk_grid_new ();
1447 data
->GRP_rate
= group_grid
;
1448 gtk_grid_set_row_spacing (GTK_GRID (group_grid
), SPACING_SMALL
);
1449 gtk_grid_set_column_spacing (GTK_GRID (group_grid
), SPACING_MEDIUM
);
1450 gtk_grid_attach (GTK_GRID (content_grid
), group_grid
, 0, crow
++, 1, 1);
1452 label
= make_label_group(_("Exchange rate"));
1453 gtk_grid_attach (GTK_GRID (group_grid
), label
, 0, 0, 3, 1);
1456 label
= make_label_widget("1 EUR _=");
1457 gtk_grid_attach (GTK_GRID (group_grid
), label
, 1, row
, 1, 1);
1458 widget
= make_exchange_rate(label
);
1459 data
->NB_euro_value
= widget
;
1460 //gtk_grid_attach (GTK_GRID (group_grid), data->CY_option[FILTER_DATE], 1, 2, row, row+1);
1461 gtk_grid_attach (GTK_GRID (group_grid
), widget
, 2, row
, 1, 1);
1463 // group :: Numbers format
1464 group_grid
= gtk_grid_new ();
1465 data
->GRP_format
= group_grid
;
1466 gtk_grid_set_row_spacing (GTK_GRID (group_grid
), SPACING_SMALL
);
1467 gtk_grid_set_column_spacing (GTK_GRID (group_grid
), SPACING_MEDIUM
);
1468 gtk_grid_attach (GTK_GRID (content_grid
), group_grid
, 0, crow
++, 1, 1);
1470 label
= make_label_group(_("Format"));
1471 gtk_grid_attach (GTK_GRID (group_grid
), label
, 0, 0, 3, 1);
1474 widget
= make_label(NULL
, 0, 0.0);
1475 data
->LB_numbereuro
= widget
;
1476 gtk_grid_attach (GTK_GRID (group_grid
), widget
, 1, row
, 1, 1);
1479 expander
= gtk_expander_new_with_mnemonic(_("_Customize"));
1480 gtk_grid_attach (GTK_GRID (group_grid
), expander
, 1, row
, 1, 1);
1482 group_grid
= gtk_grid_new ();
1483 gtk_grid_set_row_spacing (GTK_GRID (group_grid
), SPACING_SMALL
);
1484 gtk_grid_set_column_spacing (GTK_GRID (group_grid
), SPACING_MEDIUM
);
1485 gtk_container_add (GTK_CONTAINER (expander
), group_grid
);
1488 label
= make_label_widget(_("_Symbol:"));
1489 gtk_grid_attach (GTK_GRID (group_grid
), label
, 1, row
, 1, 1);
1490 widget
= make_string_maxlength(label
, 3);
1491 data
->ST_euro_symbol
= widget
;
1492 gtk_grid_attach (GTK_GRID (group_grid
), widget
, 2, row
, 1, 1);
1495 widget
= gtk_check_button_new_with_mnemonic (_("Is pre_fix"));
1496 data
->CM_euro_isprefix
= widget
;
1497 gtk_grid_attach (GTK_GRID (group_grid
), widget
, 2, row
, 1, 1);
1500 label
= make_label_widget(_("_Decimal char:"));
1501 gtk_grid_attach (GTK_GRID (group_grid
), label
, 1, row
, 1, 1);
1502 widget
= make_string_maxlength(label
, 1);
1503 data
->ST_euro_decimalchar
= widget
;
1504 gtk_grid_attach (GTK_GRID (group_grid
), widget
, 2, row
, 1, 1);
1507 label
= make_label_widget(_("_Frac digits:"));
1508 gtk_grid_attach (GTK_GRID (group_grid
), label
, 1, row
, 1, 1);
1509 widget
= make_numeric(label
, 0.0, 6.0);
1510 data
->NB_euro_fracdigits
= widget
;
1511 gtk_grid_attach (GTK_GRID (group_grid
), widget
, 2, row
, 1, 1);
1514 label
= make_label_widget(_("_Grouping char:"));
1515 gtk_grid_attach (GTK_GRID (group_grid
), label
, 1, row
, 1, 1);
1516 widget
= make_string_maxlength(label
, 1);
1517 data
->ST_euro_groupingchar
= widget
;
1518 gtk_grid_attach (GTK_GRID (group_grid
), widget
, 2, row
, 1, 1);
1520 return content_grid
;
1524 static GtkWidget
*defpref_page_display (struct defpref_data
*data
)
1526 GtkWidget
*content_grid
, *group_grid
, *label
, *widget
, *expander
;
1529 content_grid
= gtk_grid_new();
1530 gtk_grid_set_row_spacing (GTK_GRID (content_grid
), SPACING_LARGE
);
1531 gtk_orientable_set_orientation(GTK_ORIENTABLE(content_grid
), GTK_ORIENTATION_VERTICAL
);
1534 // group :: Date options
1535 group_grid
= gtk_grid_new ();
1536 gtk_grid_set_row_spacing (GTK_GRID (group_grid
), SPACING_SMALL
);
1537 gtk_grid_set_column_spacing (GTK_GRID (group_grid
), SPACING_MEDIUM
);
1538 gtk_grid_attach (GTK_GRID (content_grid
), group_grid
, 0, crow
++, 1, 1);
1540 label
= make_label_group(_("Date"));
1541 gtk_grid_attach (GTK_GRID (group_grid
), label
, 0, 0, 3, 1);
1544 widget
= make_label(NULL
, 0, 0.5);
1545 data
->LB_date
= widget
;
1546 gtk_grid_attach (GTK_GRID (group_grid
), widget
, 1, row
, 2, 1);
1549 expander
= gtk_expander_new_with_mnemonic(_("_Customize"));
1550 gtk_grid_attach (GTK_GRID (group_grid
), expander
, 1, row
, 1, 1);
1552 group_grid
= gtk_grid_new ();
1553 gtk_grid_set_row_spacing (GTK_GRID (group_grid
), SPACING_SMALL
);
1554 gtk_grid_set_column_spacing (GTK_GRID (group_grid
), SPACING_MEDIUM
);
1555 gtk_container_add (GTK_CONTAINER (expander
), group_grid
);
1558 label
= make_label_widget(_("_Format:"));
1559 //----------------------------------------- l, r, t, b
1560 gtk_grid_attach (GTK_GRID (group_grid
), label
, 1, row
, 1, 1);
1561 widget
= make_string(label
);
1562 data
->ST_datefmt
= widget
;
1563 //gtk_grid_attach (GTK_GRID (group_grid), data->CY_option[FILTER_DATE], 1, 2, row, row+1);
1564 gtk_grid_attach (GTK_GRID (group_grid
), widget
, 2, row
, 1, 1);
1566 widget
= gtk_image_new_from_icon_name (ICONNAME_INFO
, GTK_ICON_SIZE_BUTTON
);
1567 gtk_grid_attach (GTK_GRID (group_grid
), widget
, 3, row
, 1, 1);
1570 gtk_widget_set_tooltip_text(widget
,
1571 _("%a locale's abbreviated weekday name.\n"
1572 "%A locale's full weekday name. \n"
1573 "%b locale's abbreviated month name. \n"
1574 "%B locale's full month name. \n"
1575 "%c locale's appropriate date and time representation. \n"
1576 "%C century number (the year divided by 100 and truncated to an integer) as a decimal number [00-99]. \n"
1577 "%d day of the month as a decimal number [01,31]. \n"
1578 "%D same as %m/%d/%y. \n"
1579 "%e day of the month as a decimal number [1,31]; a single digit is preceded by a space. \n"
1580 "%j day of the year as a decimal number [001,366]. \n"
1581 "%m month as a decimal number [01,12]. \n"
1582 "%p locale's appropriate date representation. \n"
1583 "%y year without century as a decimal number [00,99]. \n"
1584 "%Y year with century as a decimal number. \n")
1588 widget
= make_label(NULL
, 0.0, 0.5);
1589 gtk_label_set_markup (GTK_LABEL(widget
), "<small><a href=\"http://man7.org/linux/man-pages/man3/strftime.3.html\">online reference</a></small>");
1590 gtk_grid_attach (GTK_GRID (group_grid
), widget
, 2, row
, 1, 1);
1592 // group :: Measurement units
1593 group_grid
= gtk_grid_new ();
1594 gtk_grid_set_row_spacing (GTK_GRID (group_grid
), SPACING_SMALL
);
1595 gtk_grid_set_column_spacing (GTK_GRID (group_grid
), SPACING_MEDIUM
);
1596 gtk_grid_attach (GTK_GRID (content_grid
), group_grid
, 0, crow
++, 1, 1);
1598 label
= make_label_group(_("Measurement units"));
1599 gtk_grid_attach (GTK_GRID (group_grid
), label
, 0, 0, 3, 1);
1602 widget
= gtk_check_button_new_with_mnemonic (_("Use _miles for meter"));
1603 data
->CM_unitismile
= widget
;
1604 gtk_grid_attach (GTK_GRID (group_grid
), widget
, 1, row
, 2, 1);
1607 widget
= gtk_check_button_new_with_mnemonic (_("Use _gallon for fuel"));
1608 data
->CM_unitisgal
= widget
;
1609 gtk_grid_attach (GTK_GRID (group_grid
), widget
, 1, row
, 2, 1);
1611 return content_grid
;
1615 static GtkWidget
*defpref_page_transactions (struct defpref_data
*data
)
1617 GtkWidget
*content_grid
, *group_grid
, *sw
, *label
, *widget
;
1620 content_grid
= gtk_grid_new();
1621 gtk_grid_set_row_spacing (GTK_GRID (content_grid
), SPACING_LARGE
);
1622 gtk_orientable_set_orientation(GTK_ORIENTABLE(content_grid
), GTK_ORIENTATION_VERTICAL
);
1625 // group :: Transaction window
1626 group_grid
= gtk_grid_new ();
1627 gtk_grid_set_row_spacing (GTK_GRID (group_grid
), SPACING_SMALL
);
1628 gtk_grid_set_column_spacing (GTK_GRID (group_grid
), SPACING_MEDIUM
);
1629 gtk_grid_attach (GTK_GRID (content_grid
), group_grid
, 0, crow
++, 1, 1);
1631 label
= make_label_group(_("Transaction window"));
1632 gtk_grid_attach (GTK_GRID (group_grid
), label
, 0, 0, 3, 1);
1635 label
= make_label_widget(_("Date _range:"));
1636 //----------------------------------------- l, r, t, b
1637 gtk_grid_attach (GTK_GRID (group_grid
), label
, 1, row
, 1, 1);
1638 widget
= make_daterange(label
, FALSE
);
1639 data
->CY_daterange_txn
= widget
;
1640 gtk_grid_attach (GTK_GRID (group_grid
), widget
, 2, row
, 1, 1);
1643 label
= make_label_widget(_("_Show:"));
1644 //----------------------------------------- l, r, t, b
1645 gtk_grid_attach (GTK_GRID (group_grid
), label
, 1, row
, 1, 1);
1646 widget
= make_numeric(NULL
, 0, 366);
1648 data
->ST_datefuture_nbdays
= widget
;
1649 gtk_grid_attach (GTK_GRID (group_grid
), widget
, 2, row
, 1, 1);
1651 //TRANSLATORS: there is a spinner on the left of this label, and so you have 0....x days in advance the current date
1652 label
= make_label(_("days in advance the current date"), 0, 0.5);
1653 gtk_grid_attach (GTK_GRID (group_grid
), label
, 3, row
, 1, 1);
1656 widget
= gtk_check_button_new_with_mnemonic (_("Hide reconciled transactions"));
1657 data
->CM_hide_reconciled
= widget
;
1658 gtk_grid_attach (GTK_GRID (group_grid
), widget
, 2, row
, 2, 1);
1661 widget
= gtk_check_button_new_with_mnemonic (_("Always show remind transactions"));
1662 data
->CM_show_remind
= widget
;
1663 gtk_grid_attach (GTK_GRID (group_grid
), widget
, 2, row
, 2, 1);
1665 // group :: Multiple add
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(_("Multiple add"));
1672 gtk_grid_attach (GTK_GRID (group_grid
), label
, 0, 0, 3, 1);
1675 widget
= gtk_check_button_new_with_mnemonic (_("Keep the last date"));
1676 data
->CM_herit_date
= widget
;
1677 gtk_grid_attach (GTK_GRID (group_grid
), widget
, 1, row
, 2, 1);
1679 // group :: Column list
1680 group_grid
= gtk_grid_new ();
1681 gtk_grid_set_row_spacing (GTK_GRID (group_grid
), SPACING_SMALL
);
1682 gtk_grid_set_column_spacing (GTK_GRID (group_grid
), SPACING_MEDIUM
);
1683 gtk_grid_attach (GTK_GRID (content_grid
), group_grid
, 0, crow
++, 1, 1);
1685 label
= make_label_group(_("Column list"));
1686 gtk_grid_attach (GTK_GRID (group_grid
), label
, 0, 0, 3, 1);
1689 sw
= gtk_scrolled_window_new (NULL
, NULL
);
1690 gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (sw
), GTK_SHADOW_ETCHED_IN
);
1691 gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (sw
), GTK_POLICY_NEVER
, GTK_POLICY_AUTOMATIC
);
1692 widget
= (GtkWidget
*)list_txn_colprefcreate();
1693 data
->LV_opecolumns
= widget
;
1694 gtk_widget_set_size_request(data
->LV_opecolumns
, HB_MINWIDTH_LIST
, -1);
1695 gtk_container_add (GTK_CONTAINER (sw
), widget
);
1696 gtk_widget_set_vexpand (sw
, TRUE
);
1697 gtk_grid_attach (GTK_GRID (group_grid
), sw
, 1, row
, 2, 1);
1698 gtk_widget_set_tooltip_text(widget
, _("Drag & drop to change the order"));
1700 return content_grid
;
1705 static GtkWidget
*defpref_page_interface (struct defpref_data
*data
)
1707 GtkWidget
*content_grid
, *group_grid
, *hbox
, *label
, *widget
;
1710 content_grid
= gtk_grid_new();
1711 gtk_grid_set_row_spacing (GTK_GRID (content_grid
), SPACING_LARGE
);
1712 gtk_orientable_set_orientation(GTK_ORIENTABLE(content_grid
), GTK_ORIENTATION_VERTICAL
);
1716 group_grid
= gtk_grid_new ();
1717 gtk_grid_set_row_spacing (GTK_GRID (group_grid
), SPACING_SMALL
);
1718 gtk_grid_set_column_spacing (GTK_GRID (group_grid
), SPACING_MEDIUM
);
1719 gtk_grid_attach (GTK_GRID (content_grid
), group_grid
, 0, crow
++, 1, 1);
1721 label
= make_label_group(_("General"));
1722 gtk_grid_attach (GTK_GRID (group_grid
), label
, 0, 0, 3, 1);
1725 label
= make_label_widget(_("_Language:"));
1726 gtk_grid_attach (GTK_GRID (group_grid
), label
, 1, row
, 1, 1);
1727 widget
= ui_language_combobox_new(label
);
1728 data
->CY_language
= widget
;
1729 gtk_grid_attach (GTK_GRID (group_grid
), widget
, 2, row
, 1, 1);
1732 label
= make_label_widget(_("_Toolbar:"));
1733 gtk_grid_attach (GTK_GRID (group_grid
), label
, 1, row
, 1, 1);
1734 widget
= make_cycle(label
, CYA_TOOLBAR_STYLE
);
1735 data
->CY_toolbar
= widget
;
1736 gtk_grid_attach (GTK_GRID (group_grid
), widget
, 2, row
, 1, 1);
1740 //widget = gtk_check_button_new_with_mnemonic (_("Enable rows in alternating colors"));
1741 //data->CM_ruleshint = widget;
1742 label
= make_label_widget(_("_Grid line:"));
1743 gtk_grid_attach (GTK_GRID (group_grid
), label
, 1, row
, 1, 1);
1744 widget
= make_cycle(label
, CYA_GRID_LINES
);
1745 data
->CY_gridlines
= widget
;
1746 gtk_grid_attach (GTK_GRID (group_grid
), widget
, 2, row
, 1, 1);
1748 // group :: Amount colors
1749 group_grid
= gtk_grid_new ();
1750 gtk_grid_set_row_spacing (GTK_GRID (group_grid
), SPACING_SMALL
);
1751 gtk_grid_set_column_spacing (GTK_GRID (group_grid
), SPACING_MEDIUM
);
1752 gtk_grid_attach (GTK_GRID (content_grid
), group_grid
, 0, crow
++, 1, 1);
1754 label
= make_label_group(_("Amount colors"));
1755 gtk_grid_attach (GTK_GRID (group_grid
), label
, 0, 0, 3, 1);
1758 widget
= gtk_check_button_new_with_mnemonic (_("Uses custom colors"));
1759 data
->CM_custom_colors
= widget
;
1760 gtk_grid_attach (GTK_GRID (group_grid
), widget
, 2, row
, 1, 1);
1762 group_grid
= gtk_grid_new ();
1763 data
->GR_colors
= group_grid
;
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);
1769 label
= make_label_widget(_("_Preset:"));
1770 //----------------------------------------- l, r, t, b
1771 gtk_grid_attach (GTK_GRID (group_grid
), label
, 1, row
, 1, 1);
1772 widget
= make_cycle(label
, CYA_TANGO_COLORS
);
1773 data
->CY_colors
= widget
;
1774 //gtk_grid_attach (GTK_GRID (group_grid), data->CY_option[FILTER_DATE], 1, 2, row, row+1);
1775 gtk_grid_attach (GTK_GRID (group_grid
), widget
, 2, row
, 1, 1);
1778 label
= make_label_widget(_("_Expense:"));
1779 //----------------------------------------- l, r, t, b
1780 gtk_grid_attach (GTK_GRID (group_grid
), label
, 1, row
, 1, 1);
1781 hbox
= gtk_box_new(GTK_ORIENTATION_HORIZONTAL
, SPACING_SMALL
);
1782 gtk_grid_attach (GTK_GRID (group_grid
), hbox
, 2, row
, 1, 1);
1784 widget
= gtk_color_button_new ();
1785 data
->CP_exp_color
= widget
;
1786 gtk_box_pack_start (GTK_BOX (hbox
), widget
, FALSE
, FALSE
, 0);
1788 label
= make_label_widget(_("_Income:"));
1789 gtk_box_pack_start (GTK_BOX (hbox
), label
, FALSE
, FALSE
, 0);
1791 widget
= gtk_color_button_new ();
1792 data
->CP_inc_color
= widget
;
1793 gtk_box_pack_start (GTK_BOX (hbox
), widget
, FALSE
, FALSE
, 0);
1795 label
= make_label_widget(_("_Warning:"));
1796 gtk_box_pack_start (GTK_BOX (hbox
), label
, FALSE
, FALSE
, 0);
1798 widget
= gtk_color_button_new ();
1799 data
->CP_warn_color
= widget
;
1800 gtk_box_pack_start (GTK_BOX (hbox
), widget
, FALSE
, FALSE
, 0);
1802 return content_grid
;
1806 static GtkWidget
*defpref_page_general (struct defpref_data
*data
)
1808 GtkWidget
*content_grid
, *group_grid
, *hbox
, *label
, *widget
;
1811 content_grid
= gtk_grid_new();
1812 gtk_grid_set_row_spacing (GTK_GRID (content_grid
), SPACING_LARGE
);
1813 gtk_orientable_set_orientation(GTK_ORIENTABLE(content_grid
), GTK_ORIENTATION_VERTICAL
);
1816 // group :: Program start
1817 group_grid
= gtk_grid_new ();
1818 gtk_grid_set_row_spacing (GTK_GRID (group_grid
), SPACING_SMALL
);
1819 gtk_grid_set_column_spacing (GTK_GRID (group_grid
), SPACING_MEDIUM
);
1820 gtk_grid_attach (GTK_GRID (content_grid
), group_grid
, 0, crow
++, 1, 1);
1822 label
= make_label_group(_("Program start"));
1823 gtk_grid_attach (GTK_GRID (group_grid
), label
, 0, 0, 3, 1);
1826 widget
= gtk_check_button_new_with_mnemonic (_("Show splash screen"));
1827 data
->CM_show_splash
= widget
;
1828 gtk_grid_attach (GTK_GRID (group_grid
), widget
, 1, row
, 2, 1);
1831 widget
= gtk_check_button_new_with_mnemonic (_("Load last opened file"));
1832 data
->CM_load_last
= widget
;
1833 gtk_grid_attach (GTK_GRID (group_grid
), widget
, 1, row
, 2, 1);
1836 widget
= gtk_check_button_new_with_mnemonic (_("Post pending scheduled transactions"));
1837 data
->CM_append_scheduled
= widget
;
1838 gtk_grid_attach (GTK_GRID (group_grid
), widget
, 1, row
, 2, 1);
1841 widget
= gtk_check_button_new_with_mnemonic (_("Update currencies online"));
1842 data
->CM_do_update_currency
= widget
;
1843 gtk_grid_attach (GTK_GRID (group_grid
), widget
, 1, row
, 2, 1);
1845 // group :: Fiscal year
1846 group_grid
= gtk_grid_new ();
1847 gtk_grid_set_row_spacing (GTK_GRID (group_grid
), SPACING_SMALL
);
1848 gtk_grid_set_column_spacing (GTK_GRID (group_grid
), SPACING_MEDIUM
);
1849 gtk_grid_attach (GTK_GRID (content_grid
), group_grid
, 0, crow
++, 1, 1);
1851 label
= make_label_group(_("Fiscal year"));
1852 gtk_grid_attach (GTK_GRID (group_grid
), label
, 0, 0, 3, 1);
1855 //TRANSLATORS: (fiscal year) starts on
1856 label
= make_label_widget(_("Starts _on:"));
1857 gtk_grid_attach (GTK_GRID (group_grid
), label
, 1, row
, 1, 1);
1859 hbox
= gtk_box_new(GTK_ORIENTATION_HORIZONTAL
, SPACING_SMALL
);
1860 gtk_grid_attach (GTK_GRID (group_grid
), hbox
, 2, row
, 1, 1);
1861 widget
= make_numeric (label
, 1, 28);
1862 data
->NB_fiscyearday
= widget
;
1863 gtk_box_pack_start (GTK_BOX (hbox
), widget
, FALSE
, FALSE
, 0);
1864 widget
= make_cycle (NULL
, CYA_MONTHS
);
1865 data
->CY_fiscyearmonth
= widget
;
1866 gtk_box_pack_start (GTK_BOX (hbox
), widget
, FALSE
, FALSE
, 0);
1868 // group :: Main window reports
1869 group_grid
= gtk_grid_new ();
1870 gtk_grid_set_row_spacing (GTK_GRID (group_grid
), SPACING_SMALL
);
1871 gtk_grid_set_column_spacing (GTK_GRID (group_grid
), SPACING_MEDIUM
);
1872 gtk_grid_attach (GTK_GRID (content_grid
), group_grid
, 0, crow
++, 1, 1);
1874 label
= make_label_group(_("Main window reports"));
1875 gtk_grid_attach (GTK_GRID (group_grid
), label
, 0, 0, 3, 1);
1878 label
= make_label_widget(_("Date _range:"));
1879 gtk_grid_attach (GTK_GRID (group_grid
), label
, 1, row
, 1, 1);
1880 widget
= make_daterange(label
, FALSE
);
1881 data
->CY_daterange_wal
= widget
;
1882 gtk_grid_attach (GTK_GRID (group_grid
), widget
, 2, row
, 1, 1);
1884 // group :: Files folder
1885 group_grid
= gtk_grid_new ();
1886 gtk_grid_set_row_spacing (GTK_GRID (group_grid
), SPACING_SMALL
);
1887 gtk_grid_set_column_spacing (GTK_GRID (group_grid
), SPACING_MEDIUM
);
1888 gtk_grid_attach (GTK_GRID (content_grid
), group_grid
, 0, crow
++, 1, 1);
1890 label
= make_label_group(_("Files folder"));
1891 gtk_grid_attach (GTK_GRID (group_grid
), label
, 0, 0, 3, 1);
1894 label
= make_label_widget(_("_Default:"));
1895 gtk_grid_attach (GTK_GRID (group_grid
), label
, 1, row
, 1, 1);
1897 hbox
= gtk_box_new(GTK_ORIENTATION_HORIZONTAL
, 0);
1898 gtk_widget_set_hexpand (hbox
, TRUE
);
1899 gtk_grid_attach (GTK_GRID (group_grid
), hbox
, 2, row
, 1, 1);
1901 widget
= make_string(label
);
1902 data
->ST_path_hbfile
= widget
;
1903 gtk_style_context_add_class (gtk_widget_get_style_context (GTK_WIDGET(widget
)), GTK_STYLE_CLASS_LINKED
);
1904 gtk_box_pack_start (GTK_BOX (hbox
), widget
, TRUE
, TRUE
, 0);
1906 //widget = gtk_button_new_with_label("...");
1907 widget
= gtk_button_new_from_icon_name(ICONNAME_FOLDER
, GTK_ICON_SIZE_BUTTON
);
1908 data
->BT_path_hbfile
= widget
;
1909 gtk_box_pack_start (GTK_BOX (hbox
), widget
, FALSE
, FALSE
, 0);
1911 return content_grid
;
1914 static void defpref_selection(GtkTreeSelection
*treeselection
, gpointer user_data
)
1916 struct defpref_data
*data
;
1917 GtkWidget
*notebook
;
1918 GtkTreeView
*treeview
;
1919 GtkTreeModel
*model
;
1922 GValue val
= { 0, };
1925 DB( g_print("\n[ui-pref] selection\n") );
1927 if (gtk_tree_selection_get_selected(treeselection
, &model
, &iter
))
1929 notebook
= GTK_WIDGET(user_data
);
1930 treeview
= gtk_tree_selection_get_tree_view(treeselection
);
1931 data
= g_object_get_data(G_OBJECT(gtk_widget_get_ancestor(GTK_WIDGET(treeview
), GTK_TYPE_WINDOW
)), "inst_data");
1934 gtk_tree_model_get_value(model
, &iter
, LST_PREF_PAGE
, &val
);
1935 page
= g_value_get_int (&val
);
1936 DB( g_print(" - active is %d\n", page
) );
1937 g_value_unset (&val
);
1940 gtk_tree_model_get_value(model
, &iter
, LST_PREF_NAME
, &val
);
1941 gtk_label_set_text (GTK_LABEL (data
->label
), g_value_get_string (&val
));
1942 g_value_unset (&val
);
1944 gtk_tree_model_get_value(model
, &iter
, LST_PREF_ICONNAME
, &val
);
1945 //gtk_image_set_from_pixbuf (GTK_IMAGE (data->image), g_value_get_object (&val));
1946 gtk_image_set_from_icon_name(GTK_IMAGE (data
->image
), g_value_get_string (&val
), GTK_ICON_SIZE_DIALOG
);
1947 g_value_unset (&val
);
1951 gtk_notebook_set_current_page(GTK_NOTEBOOK(notebook
), page
);
1953 //defpref_change_page(GTK_WIDGET(gtk_tree_selection_get_tree_view(treeselection)), GINT_TO_POINTER(page));
1960 ** set the notebook active page from treeview
1962 /*void defpref_change_page(GtkWidget *widget, gpointer user_data)
1964 struct defpref_data *data;
1965 gint page = GPOINTER_TO_INT(user_data);
1966 GtkTreeModel *model;
1969 DB( g_print("\n[ui-pref] page\n") );
1971 data = g_object_get_data(G_OBJECT(gtk_widget_get_ancestor(widget, GTK_TYPE_WINDOW)), "inst_data");
1973 model = gtk_tree_view_get_model(GTK_TREE_VIEW(data->LV_page));
1981 gtk_notebook_set_current_page(GTK_NOTEBOOK(data->GR_page), page);
1987 ** add an empty new account to our temp GList and treeview
1989 static void defpref_clear(GtkWidget
*widget
, gpointer user_data
)
1991 struct defpref_data
*data
;
1994 data
= g_object_get_data(G_OBJECT(gtk_widget_get_ancestor(widget
, GTK_TYPE_WINDOW
)), "inst_data");
1995 DB( g_print("\n(defpref_clear) (data=%p)\n", data
) );
1997 result
= ui_dialog_msg_confirm_alert(
1998 GTK_WINDOW(data
->window
),
1999 _("Reset all preferences"),
2000 _("Do you really want to reset all\npreferences to default values?"),
2003 if( result
== GTK_RESPONSE_OK
)
2005 homebank_pref_setdefault();
2012 // the window creation
2013 GtkWidget
*defpref_dialog_new (void)
2015 struct defpref_data data
;
2016 GtkWidget
*window
, *content
, *mainvbox
;
2017 GtkWidget
*hbox
, *vbox
, *sw
, *widget
, *notebook
, *page
, *ebox
, *image
, *label
;
2019 window
= gtk_dialog_new_with_buttons (_("Preferences"),
2020 GTK_WINDOW(GLOBALS
->mainwindow
),
2023 GTK_RESPONSE_REJECT
,
2025 GTK_RESPONSE_ACCEPT
,
2028 data
.window
= window
;
2030 //store our window private data
2031 g_object_set_data(G_OBJECT(window
), "inst_data", (gpointer
)&data
);
2033 gtk_window_set_icon_name(GTK_WINDOW (window
), ICONNAME_PREFERENCES
);
2035 content
= gtk_dialog_get_content_area(GTK_DIALOG (window
)); // return a vbox
2036 mainvbox
= gtk_box_new(GTK_ORIENTATION_VERTICAL
, SPACING_MEDIUM
);
2037 gtk_box_pack_start (GTK_BOX (content
), mainvbox
, TRUE
, TRUE
, 0);
2039 gtk_container_set_border_width(GTK_CONTAINER(mainvbox
), SPACING_MEDIUM
);
2041 hbox
= gtk_box_new(GTK_ORIENTATION_HORIZONTAL
, SPACING_MEDIUM
);
2042 gtk_box_pack_start (GTK_BOX (mainvbox
), hbox
, TRUE
, TRUE
, 0);
2045 vbox
= gtk_box_new(GTK_ORIENTATION_VERTICAL
, SPACING_SMALL
);
2046 gtk_box_pack_start (GTK_BOX (hbox
), vbox
, FALSE
, FALSE
, 0);
2049 sw
= gtk_scrolled_window_new (NULL
, NULL
);
2050 gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (sw
), GTK_SHADOW_ETCHED_IN
);
2051 gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (sw
), GTK_POLICY_NEVER
, GTK_POLICY_AUTOMATIC
);
2052 gtk_box_pack_start (GTK_BOX (vbox
), sw
, TRUE
, TRUE
, 0);
2053 widget
= pref_list_create();
2054 data
.LV_page
= widget
;
2055 gtk_container_add (GTK_CONTAINER (sw
), widget
);
2058 data
.BT_clear
= gtk_button_new_with_mnemonic(_("_Reset"));
2059 gtk_box_pack_start (GTK_BOX (vbox
), data
.BT_clear
, FALSE
, TRUE
, 0);
2062 //right part : notebook
2063 vbox
= gtk_box_new (GTK_ORIENTATION_VERTICAL
, SPACING_MEDIUM
);
2064 gtk_box_pack_start (GTK_BOX (hbox
), vbox
, TRUE
, TRUE
, 0);
2065 gtk_widget_show (vbox
);
2067 ebox
= gtk_event_box_new();
2068 gtk_widget_set_name(ebox
, "hbebox");
2069 GtkStyleContext
*context
= gtk_widget_get_style_context (ebox
);
2070 #if GTK_MINOR_VERSION <= 18
2071 gtk_style_context_add_class (context
, GTK_STYLE_CLASS_LIST_ROW
);
2072 gtk_widget_set_state_flags(ebox
, GTK_STATE_FLAG_SELECTED
, TRUE
);
2074 GtkCssProvider
*provider
;
2075 provider
= gtk_css_provider_new ();
2076 gtk_css_provider_load_from_data (provider
,
2077 "#hbebox { color: @theme_selected_fg_color; background-color: @theme_selected_bg_color; }"
2079 gtk_style_context_add_provider (context
, GTK_STYLE_PROVIDER(provider
), G_MAXUINT
);
2081 // gtk_style_context_set_state(context, GTK_STATE_FLAG_SELECTED);
2084 gtk_box_pack_start (GTK_BOX (vbox
), ebox
, FALSE
, TRUE
, 0);
2085 gtk_widget_show (ebox
);
2087 hbox
= gtk_box_new (GTK_ORIENTATION_HORIZONTAL
, SPACING_SMALL
);
2088 gtk_container_set_border_width (GTK_CONTAINER (hbox
), SPACING_SMALL
);
2089 gtk_container_add (GTK_CONTAINER (ebox
), hbox
);
2090 gtk_widget_show (hbox
);
2092 label
= gtk_label_new (NULL
);
2093 gtk_widget_set_margin_left(label
, SPACING_MEDIUM
);
2094 gimp_label_set_attributes (GTK_LABEL (label
),
2095 PANGO_ATTR_SCALE
, PANGO_SCALE_XX_LARGE
,
2096 PANGO_ATTR_WEIGHT
, PANGO_WEIGHT_BOLD
,
2099 gtk_box_pack_start (GTK_BOX (hbox
), label
, FALSE
, FALSE
, 0);
2100 gtk_widget_show (label
);
2103 image
= gtk_image_new ();
2104 gtk_box_pack_end (GTK_BOX (hbox
), image
, FALSE
, FALSE
, 0);
2105 gtk_widget_show (image
);
2111 notebook
= gtk_notebook_new();
2112 data
.GR_page
= notebook
;
2113 gtk_widget_show(notebook
);
2114 gtk_notebook_set_show_tabs(GTK_NOTEBOOK(notebook
), FALSE
);
2115 gtk_notebook_set_show_border(GTK_NOTEBOOK(notebook
), FALSE
);
2116 gtk_box_pack_start (GTK_BOX (vbox
), notebook
, TRUE
, TRUE
, 0);
2128 page
= defpref_page_general(&data
);
2129 gtk_notebook_append_page (GTK_NOTEBOOK (notebook
), page
, NULL
);
2132 page
= defpref_page_interface(&data
);
2133 gtk_notebook_append_page (GTK_NOTEBOOK (notebook
), page
, NULL
);
2136 page
= defpref_page_transactions(&data
);
2137 gtk_notebook_append_page (GTK_NOTEBOOK (notebook
), page
, NULL
);
2140 page
= defpref_page_display(&data
);
2141 gtk_notebook_append_page (GTK_NOTEBOOK (notebook
), page
, NULL
);
2144 page
= defpref_page_import(&data
);
2145 gtk_notebook_append_page (GTK_NOTEBOOK (notebook
), page
, NULL
);
2148 page
= defpref_page_reports(&data
);
2149 gtk_notebook_append_page (GTK_NOTEBOOK (notebook
), page
, NULL
);
2152 page
= defpref_page_euro(&data
);
2153 gtk_notebook_append_page (GTK_NOTEBOOK (notebook
), page
, NULL
);
2156 //todo:should move this
2157 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(data
.CM_euro_enable
), PREFS
->euro_active
);
2159 //connect all our signals
2160 g_signal_connect (window
, "destroy", G_CALLBACK (gtk_widget_destroyed
), &window
);
2162 g_signal_connect (G_OBJECT (data
.BT_clear
), "clicked", G_CALLBACK (defpref_clear
), NULL
);
2165 g_signal_connect (data
.BT_path_hbfile
, "pressed", G_CALLBACK (defpref_pathselect
), GINT_TO_POINTER(1));
2166 g_signal_connect (data
.BT_path_import
, "pressed", G_CALLBACK (defpref_pathselect
), GINT_TO_POINTER(2));
2167 g_signal_connect (data
.BT_path_export
, "pressed", G_CALLBACK (defpref_pathselect
), GINT_TO_POINTER(3));
2169 g_signal_connect (data
.CM_custom_colors
, "toggled", G_CALLBACK (defpref_colortoggle
), NULL
);
2170 g_signal_connect (data
.CY_colors
, "changed", G_CALLBACK (defpref_colorpreset
), NULL
);
2174 g_signal_connect (gtk_tree_view_get_selection(GTK_TREE_VIEW(data
.LV_page
)), "changed", G_CALLBACK (defpref_selection
), notebook
);
2176 g_signal_connect (data
.CM_euro_enable
, "toggled", G_CALLBACK (defpref_eurotoggle
), NULL
);
2178 g_signal_connect (data
.CY_euro_preset
, "changed", G_CALLBACK (defpref_europreset
), NULL
);
2181 g_signal_connect (data
.ST_datefmt
, "changed", G_CALLBACK (defpref_date_sample
), NULL
);
2184 g_signal_connect (data
.CY_color_scheme
, "changed", G_CALLBACK (defpref_color_scheme_changed
), NULL
);
2188 g_signal_connect (data
.ST_euro_symbol
, "changed", G_CALLBACK (defpref_numbereuro_sample
), NULL
);
2189 g_signal_connect (data
.CM_euro_isprefix
, "toggled", G_CALLBACK (defpref_numbereuro_sample
), NULL
);
2190 g_signal_connect (data
.ST_euro_decimalchar
, "changed", G_CALLBACK (defpref_numbereuro_sample
), NULL
);
2191 g_signal_connect (data
.ST_euro_groupingchar
, "changed", G_CALLBACK (defpref_numbereuro_sample
), NULL
);
2192 g_signal_connect (data
.NB_euro_fracdigits
, "value-changed", G_CALLBACK (defpref_numbereuro_sample
), NULL
);
2194 //g_signal_connect (data.BT_default, "pressed", G_CALLBACK (defpref_currency_change), NULL);
2197 //setup, init and show window
2198 //defhbfile_setup(&data);
2199 //defhbfile_update(data.LV_arc, NULL);
2203 defpref_colortoggle(window
, NULL
);
2204 defpref_eurotoggle(window
, NULL
);
2206 gtk_window_resize(GTK_WINDOW(window
), 640, 256);
2210 GtkTreePath
*path
= gtk_tree_path_new_first ();
2212 gtk_tree_selection_select_path (gtk_tree_view_get_selection(GTK_TREE_VIEW(data
.LV_page
)), path
);
2216 gtk_tree_path_free(path
);
2218 gtk_widget_show_all (window
);
2225 result
= gtk_dialog_run (GTK_DIALOG (window
));
2229 case GTK_RESPONSE_ACCEPT
:
2230 old_lang
= g_strdup(PREFS
->language
);
2232 homebank_pref_save();
2233 ui_mainwindow_update(GLOBALS
->mainwindow
, GINT_TO_POINTER(UF_BALANCE
+UF_VISUAL
));
2235 DB( g_print("old='%s' new='%s'\n", old_lang
, PREFS
->language
) );
2237 if(g_ascii_strncasecmp(old_lang
== NULL
? "" : old_lang
, PREFS
->language
== NULL
? "" : PREFS
->language
, -1) != 0)
2239 ui_dialog_msg_infoerror(GTK_WINDOW(window
), GTK_MESSAGE_INFO
,
2241 _("You will have to restart HomeBank\nfor the language change to take effect.")
2251 // cleanup and destroy
2252 //defhbfile_cleanup(&data, result);
2253 gtk_widget_destroy (window
);
2258 // -------------------------------
2261 GtkWidget
*pref_list_create(void)
2263 GtkListStore
*store
;
2265 GtkCellRenderer
*renderer
;
2266 GtkTreeViewColumn
*column
;
2270 /* create list store */
2271 store
= gtk_list_store_new(
2279 view
= gtk_tree_view_new_with_model(GTK_TREE_MODEL(store
));
2280 g_object_unref(store
);
2282 gtk_tree_view_set_headers_visible(GTK_TREE_VIEW (view
), FALSE
);
2283 gtk_tree_selection_set_mode(gtk_tree_view_get_selection(GTK_TREE_VIEW(view
)), GTK_SELECTION_SINGLE
);
2285 /* column 1: icon */
2286 column
= gtk_tree_view_column_new();
2287 renderer
= gtk_cell_renderer_pixbuf_new ();
2288 g_object_set(renderer
, "stock-size", GTK_ICON_SIZE_DND
, NULL
);
2289 gtk_tree_view_column_pack_start(column
, renderer
, FALSE
);
2290 gtk_tree_view_column_set_attributes(column
, renderer
, "icon-name", LST_PREF_ICONNAME
, NULL
);
2292 renderer
= gtk_cell_renderer_text_new ();
2293 gtk_tree_view_column_pack_start(column
, renderer
, TRUE
);
2294 gtk_tree_view_column_set_attributes(column
, renderer
, "text", LST_PREF_NAME
, NULL
);
2296 gtk_tree_view_append_column (GTK_TREE_VIEW(view
), column
);
2298 //populate our combobox model
2299 for(i
=0;i
<PREF_MAX
;i
++)
2301 gtk_list_store_append(store
, &iter
);
2303 gtk_list_store_set(store
, &iter
,
2304 LST_PREF_ICONNAME
, pref_iconname
[i
],
2305 LST_PREF_NAME
, _(pref_name
[i
]),
2314 /* = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =*/
2317 extern gchar
*list_txn_column_label
[];
2321 list_txn_colpref_toggled_cell_data_function (GtkCellRendererToggle
*cell
,
2325 GtkTreeModel
*model
= (GtkTreeModel
*)data
;
2327 GtkTreePath
*path
= gtk_tree_path_new_from_string (path_str
);
2330 /* get toggled iter */
2331 gtk_tree_model_get_iter (model
, &iter
, path
);
2332 gtk_tree_model_get (model
, &iter
, COLUMN_VISIBLE
, &fixed
, -1);
2334 /* do something with the value */
2338 gtk_list_store_set (GTK_LIST_STORE (model
), &iter
, COLUMN_VISIBLE
, fixed
, -1);
2341 gtk_tree_path_free (path
);
2345 static void list_txn_colpref_get(GtkTreeView
*treeview
, gint
*columns
)
2347 GtkTreeModel
*model
;
2353 DB( g_print("[lst_txn-colpref] store column order \n") );
2356 model
= gtk_tree_view_get_model(GTK_TREE_VIEW(treeview
));
2357 valid
= gtk_tree_model_get_iter_first(GTK_TREE_MODEL(model
), &iter
);
2361 gtk_tree_model_get(GTK_TREE_MODEL(model
), &iter
,
2362 COLUMN_VISIBLE
, &visible
,
2366 DB( g_print(" - column %d: %d\n",id
, visible
) );
2367 // start at index 2 (status, date always displayed
2368 columns
[i
+2] = visible
== TRUE
? id
: -id
;
2370 /* Make iter point to the next row in the list store */
2371 valid
= gtk_tree_model_iter_next(GTK_TREE_MODEL(model
), &iter
);
2380 GtkWidget
*list_txn_colprefcreate(void)
2382 GtkListStore
*store
;
2384 GtkCellRenderer
*renderer
;
2385 GtkTreeViewColumn
*column
;
2389 DB( g_print("[lst_txn-colpref] create\n") );
2392 /* create list store */
2393 store
= gtk_list_store_new(
2401 for(i
=0 ; i
< NUM_LST_DSPOPE
-1; i
++ ) //-1 cause account column avoid
2406 DB( g_print("eval %d, %s\n", i
, list_txn_column_label
[i
]) );
2408 if(i
<= LST_DSPOPE_DATE
) // status, date always displayed
2411 //[i-1] here because lst_ope_columns[] do not store LST_DSPOPE_DATAS
2412 id
= ABS(PREFS
->lst_ope_columns
[i
-1]);
2413 if(id
== 0) id
= i
; //if we pass here, new column or weird into pref file
2414 visible
= (PREFS
->lst_ope_columns
[i
-1] > 0) ? TRUE
: FALSE
;
2417 DB( g_print(" - pos=%2d, id=%2d - %d '%s'\n", i
, id
, visible
, list_txn_column_label
[id
]) );
2419 gtk_list_store_append (store
, &iter
);
2420 gtk_list_store_set (store
, &iter
,
2421 COLUMN_VISIBLE
, visible
,
2422 COLUMN_NAME
, _(list_txn_column_label
[id
]),
2429 view
= gtk_tree_view_new_with_model(GTK_TREE_MODEL(store
));
2430 g_object_unref(store
);
2434 renderer
= gtk_cell_renderer_toggle_new ();
2435 column
= gtk_tree_view_column_new_with_attributes (_("Visible"),
2437 "active", COLUMN_VISIBLE
,
2439 gtk_tree_view_append_column (GTK_TREE_VIEW(view
), column
);
2441 g_signal_connect (renderer
, "toggled",
2442 G_CALLBACK (list_txn_colpref_toggled_cell_data_function
), store
);
2445 renderer
= gtk_cell_renderer_text_new ();
2446 column
= gtk_tree_view_column_new_with_attributes (_("Column"),
2448 "text", COLUMN_NAME
,
2450 gtk_tree_view_append_column (GTK_TREE_VIEW(view
), column
);
2452 gtk_tree_view_set_reorderable (GTK_TREE_VIEW(view
), TRUE
);