1 /* HomeBank -- Free, easy, personal accounting for everyone.
2 * Copyright (C) 1995-2018 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
;
67 static gchar
*pref_iconname
[PREF_MAX
] = {
74 "prf-euro", // to be renamed
78 static gchar
*pref_name
[PREF_MAX
] = {
89 static gchar
*CYA_TOOLBAR_STYLE
[] = {
90 N_("System defaults"),
93 N_("Text under icons"),
94 N_("Text beside icons"),
98 static gchar
*CYA_GRID_LINES
[] = {
107 gchar
*CYA_TANGO_COLORS
[] = {
115 gchar
*CYA_IMPORT_DATEORDER
[] = {
122 gchar
*CYA_IMPORT_OFXNAME
[] = {
129 gchar
*CYA_IMPORT_OFXMEMO
[] = {
131 N_("Append to Info"),
132 N_("Append to Memo"),
133 N_("Append to Payee"),
138 extern gchar
*CYA_CHART_COLORSCHEME
[];
139 extern gchar
*CYA_MONTHS
[];
146 http://en.wikipedia.org/wiki/Currencies_of_the_European_Union
147 http://www.xe.com/euro.php
148 http://fr.wikipedia.org/wiki/Liste_des_unit%C3%A9s_mon%C3%A9taires_remplac%C3%A9es_par_l%27euro
149 http://www.inter-locale.com/LocalesDemo.jsp
151 static EuroParams euro_params
[] =
153 // , rate , symb , prfx , dec, grp, frac
154 // ---------------------------------------------------------------------
155 { 0, "" , "--------" , 1.0 , "" , FALSE
, ",", ".", 2 },
156 { 1, "ATS", "Austria" , 13.7603 , "S" , TRUE
, ",", ".", 2 }, // -S 1.234.567,89
157 { 2, "BEF", "Belgium" , 40.3399 , "BF" , TRUE
, ",", ".", 2 }, // BF 1.234.567,89 -
158 { 20, "BGN", "Bulgaria" , 1.95583 , "лв." , TRUE
, ",", " ", 2 }, // non-fixé - 2014 target for euro
159 { 24, "HRK", "Croatia" , 1.0000 , "kn" , FALSE
, "" , ".", 0 }, // non-fixé - 2015 target for euro earliest
160 { 14, "CYP", "Cyprus" , 0.585274 , "£" , TRUE
, ",", "" , 2 }, //
161 { 23, "CZK", "Czech Republic" , 28.36 , "Kč" , FALSE
, ",", " ", 2 }, // non-fixé - 2015 earliest
163 { 17, "EEK", "Estonia" , 15.6466 , "kr" , FALSE
, ",", " ", 2 }, //
164 { 3, "FIM", "Finland" , 5.94573 , "mk" , FALSE
, ",", " ", 2 }, // -1 234 567,89 mk
165 { 4, "FRF", "France" , 6.55957 , "F" , FALSE
, ",", " ", 2 }, // -1 234 567,89 F
166 { 5, "DEM", "Germany" , 1.95583 , "DM" , FALSE
, ",", ".", 2 }, // -1.234.567,89 DM
167 { 6, "GRD", "Greece" , 340.750 , "d" , TRUE
, ".", ",", 2 }, // ??
168 { 21, "HUF", "Hungary" , 261.51 , "Ft" , TRUE
, ",", " ", 2 }, // non-fixé - No current target for euro
169 { 7, "IEP", "Ireland" , 0.787564 , "£" , TRUE
, ".", ",", 2 }, // -£1,234,567.89
170 { 8, "ITL", "Italy" , 1936.27 , "L" , TRUE
, "" , ".", 0 }, // L -1.234.567
171 { 18, "LVL", "Latvia" , 0.702804 , "lat.", FALSE
, ",", "" , 2 }, // jan. 2014
172 { 19, "LTL", "Lithuania" , 3.45280 , "Lt" , FALSE
, ",", "" , 2 }, // jan. 2015
173 { 9, "LUF", "Luxembourg" , 40.3399 , "LU" , TRUE
, ",", ".", 2 }, // LU 1.234.567,89 -
174 { 15, "MTL", "Malta" , 0.429300 , "Lm" , TRUE
, ",", "" , 2 }, //
175 { 10, "NLG", "Netherlands" , 2.20371 , "F" , TRUE
, ",", ".", 2 }, // F 1.234.567,89-
176 { 25, "PLN", "Poland" , 0.25 , "zł" , FALSE
, ",", "" , 2 }, // non-fixé - No current target for euro
177 { 11, "PTE", "Portugal" , 200.482 , "Esc.", FALSE
, "$", ".", 2 }, // -1.234.567$89 Esc.
178 { 22, "RON", "Romania" , 3.5155 , "Leu" , FALSE
, ",", ".", 2 }, // non-fixé - 2015 target for euro earliest
179 { 16, "SKK", "Slovak Republic", 30.12600 , "Sk" , FALSE
, ",", " ", 2 }, //
180 { 13, "SIT", "Slovenia" , 239.640 , "tol" , TRUE
, ",", ".", 2 }, //
181 { 12, "ESP", "Spain" , 166.386 , "Pts" , TRUE
, "" , ".", 0 }, // -Pts 1.234.567
184 // { " ", "" , 1.00000 , "" , "" , FALSE, ",", "", 2 },
188 /* = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =*/
191 static LangName languagenames
[] =
193 // 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
194 //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
197 { "ab", "Abkhazian" },
199 { "af", "Afrikaans" },
202 { "an", "Aragonese" },
204 { "as", "Assamese" },
205 { "ast", "Asturian, Bable, Leonese, Asturleonese" },
208 { "az", "Azerbaijani" },
210 { "be", "Belarusian" },
211 { "bg", "Bulgarian" },
221 { "ch", "Chamorro" },
222 { "co", "Corsican" },
225 { "cu", "Old Church Slavonic" },
231 { "dz", "Dzongkha" },
235 { "eo", "Esperanto" },
237 { "et", "Estonian" },
245 { "fy", "Western Frisian" },
247 { "gd", "Scottish Gaelic" },
248 { "gl", "Galician" },
250 { "gu", "Gujarati" },
255 { "ho", "Hiri Motu" },
256 { "hr", "Croatian" },
258 { "hu", "Hungarian" },
259 { "hy", "Armenian" },
261 { "ia", "Interlingua" },
262 { "id", "Indonesian" },
263 { "ie", "Interlingue" },
265 { "ii", "Sichuan Yi" },
268 { "is", "Icelandic" },
270 { "iu", "Inuktitut" },
271 { "ja", "Japanese" },
272 { "jv", "Javanese" },
273 { "ka", "Georgian" },
276 { "kj", "Kwanyama" },
278 { "kl", "Kalaallisut" },
283 { "ks", "Kashmiri" },
289 { "lb", "Luxembourgish" },
291 { "li", "Limburgish" },
294 { "lt", "Lithuanian" },
295 { "lu", "Luba-Katanga" },
297 { "mg", "Malagasy" },
298 { "mh", "Marshallese" },
300 { "mk", "Macedonian" },
301 { "ml", "Malayalam" },
302 { "mn", "Mongolian" },
303 { "mo", "Moldavian" },
309 { "nb", "Norwegian Bokmål" },
310 { "nd", "North Ndebele" },
311 { "nds", "Low German, Low Saxon" },
315 { "nn", "Norwegian Nynorsk" },
316 { "no", "Norwegian" },
317 { "nr", "South Ndebele" },
319 { "ny", "Chichewa" },
324 { "os", "Ossetian" },
329 { "pt", "Portuguese" },
333 { "ro", "Romanian" },
335 { "rw", "Kinyarwanda" },
336 { "sa", "Sanskrit" },
337 { "sc", "Sardinian" },
339 { "se", "Northern Sami" },
341 { "si", "Sinhalese" },
347 { "sq", "Albanian" },
351 { "su", "Sundanese" },
358 { "ti", "Tigrinya" },
367 { "ty", "Tahitian" },
369 { "uk", "Ukrainian" },
373 { "vi", "Viêt Namese" },
387 static GtkWidget
*pref_list_create(void);
391 ui_language_combobox_compare_func (GtkTreeModel
*model
, GtkTreeIter
*a
, GtkTreeIter
*b
, gpointer userdata
)
394 gchar
*code1
, *code2
;
395 gchar
*name1
, *name2
;
397 gtk_tree_model_get(model
, a
, 0, &code1
, 1, &name1
, -1);
398 gtk_tree_model_get(model
, b
, 0, &code2
, 1, &name2
, -1);
400 //keep system laguage on top
401 if(code1
== NULL
) name1
= NULL
;
402 if(code2
== NULL
) name2
= NULL
;
404 retval
= hb_string_utf8_compare(name1
, name2
);
413 static gchar
*languagename_get(const gchar
*locale
)
417 for (i
= 0; i
< G_N_ELEMENTS (languagenames
); i
++)
419 if( g_ascii_strncasecmp(locale
, languagenames
[i
].locale
, -1) == 0 )
420 return languagenames
[i
].name
;
428 ui_language_combobox_get_name(const gchar
*locale
)
432 DB( g_print("[ui_language_combobox_get_name]\n") );
434 // A locale directory name is typically of the form language[_territory]
435 lang
= languagename_get (locale
);
438 const gchar
*delimiter
= strchr (locale
, '_'); // strip off the territory suffix
442 gchar
*copy
= g_strndup (locale
, delimiter
- locale
);
443 lang
= languagename_get (copy
);
449 g_warning(" locale name not found '%s'", locale
);
460 ui_language_combobox_populate(GtkWidget
*combobox
)
465 model
= gtk_combo_box_get_model(GTK_COMBO_BOX(combobox
));
466 gtk_list_store_append (GTK_LIST_STORE(model
), &iter
);
467 gtk_list_store_set (GTK_LIST_STORE(model
), &iter
,
469 1, _("System Language"),
472 GDir
*dir
= g_dir_open (homebank_app_get_locale_dir (), 0, NULL
);
473 const gchar
*dirname
;
478 while ((dirname
= g_dir_read_name (dir
)) != NULL
)
480 gchar
*filename
= g_build_filename (homebank_app_get_locale_dir (),
483 GETTEXT_PACKAGE
".mo",
485 //DB( g_print("- seek for '%s'\n", filename) );
486 if (g_file_test (filename
, G_FILE_TEST_EXISTS
))
491 gtk_list_store_append (GTK_LIST_STORE(model
), &iter
);
493 lang
= ui_language_combobox_get_name(dirname
);
494 label
= g_strdup_printf ("%s [%s]", lang
, dirname
);
496 gtk_list_store_set (GTK_LIST_STORE(model
), &iter
,
508 gtk_tree_sortable_set_sort_column_id(GTK_TREE_SORTABLE(model
), GTK_TREE_SORTABLE_DEFAULT_SORT_COLUMN_ID
, GTK_SORT_ASCENDING
);
515 ui_language_combobox_new(GtkWidget
*label
)
519 GtkCellRenderer
*renderer
;
521 store
= gtk_list_store_new (2,
525 gtk_tree_sortable_set_default_sort_func(GTK_TREE_SORTABLE(store
), ui_language_combobox_compare_func
, NULL
, NULL
);
527 combobox
= gtk_combo_box_new_with_model(GTK_TREE_MODEL(store
));
528 renderer
= gtk_cell_renderer_text_new ();
529 gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (combobox
), renderer
, TRUE
);
530 gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (combobox
), renderer
, "text", 1, NULL
);
532 gtk_combo_box_set_id_column( GTK_COMBO_BOX(combobox
), 0);
534 g_object_unref(store
);
537 gtk_label_set_mnemonic_widget (GTK_LABEL(label
), combobox
);
539 ui_language_combobox_populate(combobox
);
541 gtk_combo_box_set_active(GTK_COMBO_BOX(combobox
), 0);
547 /* = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =*/
548 /* = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =*/
549 /* = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =*/
551 static gint
ui_euro_combobox_id_to_active(gint id
)
555 DB( g_print("\n[ui-pref] ui_euro_combobox_id_to_active\n") );
558 for (i
= 0; i
< G_N_ELEMENTS (euro_params
); i
++)
560 if( euro_params
[i
].id
== id
)
563 DB( g_print("- id (country)=%d => %d - %s\n", id
, i
, euro_params
[i
].name
) );
573 static gint
ui_euro_combobox_active_to_id(gint active
)
577 DB( g_print("\n[ui-pref] ui_euro_combobox_active_to_id\n") );
579 DB( g_print("- to %d\n", active
) );
582 if( active
< (gint
)G_N_ELEMENTS (euro_params
) )
584 id
= euro_params
[active
].id
;
585 DB( g_print("- id (country)=%d '%s'\n", id
, euro_params
[active
].name
) );
591 static GtkWidget
*ui_euro_combobox_new(GtkWidget
*label
)
596 DB( g_print("\n[ui-pref] make euro preset\n") );
598 combobox
= gtk_combo_box_text_new();
599 for (i
= 0; i
< G_N_ELEMENTS (euro_params
); i
++)
601 gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(combobox
), euro_params
[i
].name
);
603 gtk_combo_box_set_active(GTK_COMBO_BOX(combobox
), 0);
606 gtk_label_set_mnemonic_widget (GTK_LABEL(label
), combobox
);
612 static void defpref_pathselect(GtkWidget
*widget
, gpointer user_data
)
614 struct defpref_data
*data
;
615 gint type
= GPOINTER_TO_INT(user_data
);
621 DB( g_print("\n[ui-pref] path select\n") );
623 data
= g_object_get_data(G_OBJECT(gtk_widget_get_ancestor(widget
, GTK_TYPE_WINDOW
)), "inst_data");
628 path
= &PREFS
->path_hbfile
;
629 entry
= data
->ST_path_hbfile
;
630 title
= _("Choose a default HomeBank files folder");
633 path
= &PREFS
->path_import
;
634 entry
= data
->ST_path_import
;
635 title
= _("Choose a default import folder");
638 path
= &PREFS
->path_export
;
639 entry
= data
->ST_path_export
;
640 title
= _("Choose a default export folder");
646 DB( g_print(" - hbfile %p %s at %p\n" , PREFS
->path_hbfile
, PREFS
->path_hbfile
, &PREFS
->path_hbfile
) );
647 DB( g_print(" - import %p %s at %p\n" , PREFS
->path_import
, PREFS
->path_import
, &PREFS
->path_import
) );
648 DB( g_print(" - export %p %s at %p\n" , PREFS
->path_export
, PREFS
->path_export
, &PREFS
->path_export
) );
651 DB( g_print(" - before: %s %p\n" , *path
, path
) );
653 r
= ui_file_chooser_folder(GTK_WINDOW(gtk_widget_get_ancestor(widget
, GTK_TYPE_WINDOW
)), title
, path
);
656 DB( g_print(" - after: %s\n", *path
) );
659 gtk_entry_set_text(GTK_ENTRY(entry
), *path
);
666 ** update the date sample label
668 static void defpref_date_sample(GtkWidget
*widget
, gpointer user_data
)
670 struct defpref_data
*data
;
675 DB( g_print("\n[ui-pref] date sample\n") );
677 data
= g_object_get_data(G_OBJECT(gtk_widget_get_ancestor(widget
, GTK_TYPE_WINDOW
)), "inst_data");
679 fmt
= gtk_entry_get_text(GTK_ENTRY(data
->ST_datefmt
));
680 date
= g_date_new_julian (GLOBALS
->today
);
681 g_date_strftime (buffer
, 256-1, fmt
, date
);
684 gtk_label_set_text(GTK_LABEL(data
->LB_date
), buffer
);
690 ** update the number sample label
692 static void defpref_numbereuro_sample(GtkWidget
*widget
, gpointer user_data
)
694 struct defpref_data
*data
;
696 gchar formatd_buf
[G_ASCII_DTOSTR_BUF_SIZE
];
699 DB( g_print("\n[ui-pref] number sample\n") );
701 data
= g_object_get_data(G_OBJECT(gtk_widget_get_ancestor(widget
, GTK_TYPE_WINDOW
)), "inst_data");
703 cur
.symbol
= (gchar
*)gtk_entry_get_text(GTK_ENTRY(data
->ST_euro_symbol
));
704 cur
.sym_prefix
= gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(data
->CM_euro_isprefix
));
705 cur
.decimal_char
= (gchar
*)gtk_entry_get_text(GTK_ENTRY(data
->ST_euro_decimalchar
));
706 cur
.grouping_char
= (gchar
*)gtk_entry_get_text(GTK_ENTRY(data
->ST_euro_groupingchar
));
707 cur
.frac_digits
= gtk_spin_button_get_value(GTK_SPIN_BUTTON(data
->NB_euro_fracdigits
));
709 da_cur_initformat (&cur
);
711 DB( g_print("fmt: %s\n", cur
.format
) );
713 g_ascii_formatd(formatd_buf
, sizeof (formatd_buf
), cur
.format
, HB_NUMBER_SAMPLE
);
714 hb_str_formatd(buf
, 127, formatd_buf
, &cur
, TRUE
);
716 gtk_label_set_text(GTK_LABEL(data
->LB_numbereuro
), buf
);
722 ** enable/disable euro
724 static void defpref_eurotoggle(GtkWidget
*widget
, gpointer user_data
)
726 struct defpref_data
*data
;
729 DB( g_print("\n[ui-pref] euro toggle\n") );
731 data
= g_object_get_data(G_OBJECT(gtk_widget_get_ancestor(widget
, GTK_TYPE_WINDOW
)), "inst_data");
733 sensitive
= gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(data
->CM_euro_enable
));
735 gtk_widget_set_sensitive(data
->GRP_currency
, sensitive
);
736 gtk_widget_set_sensitive(data
->GRP_rate
, sensitive
);
737 gtk_widget_set_sensitive(data
->GRP_format
, sensitive
);
742 ** set euro value widget from a country
744 static void defpref_eurosetcurrency(GtkWidget
*widget
, gint country
)
746 struct defpref_data
*data
;
751 DB( g_print("\n[ui-pref] eurosetcurrency\n") );
753 data
= g_object_get_data(G_OBJECT(gtk_widget_get_ancestor(widget
, GTK_TYPE_WINDOW
)), "inst_data");
755 active
= ui_euro_combobox_id_to_active(country
);
756 euro
= &euro_params
[active
];
757 buf
= g_strdup_printf("%s - %s", euro
->iso
, euro
->name
);
758 gtk_label_set_markup(GTK_LABEL(data
->ST_euro_country
), buf
);
764 ** set euro value widget from a country
766 static void defpref_europreset(GtkWidget
*widget
, gpointer user_data
)
768 struct defpref_data
*data
;
771 DB( g_print("\n[ui-pref] euro preset\n") );
773 data
= g_object_get_data(G_OBJECT(gtk_widget_get_ancestor(widget
, GTK_TYPE_WINDOW
)), "inst_data");
775 active
= gtk_combo_box_get_active (GTK_COMBO_BOX(data
->CY_euro_preset
));
776 data
->country
= ui_euro_combobox_active_to_id (active
);;
778 defpref_eurosetcurrency(widget
, data
->country
);
780 gtk_spin_button_set_value(GTK_SPIN_BUTTON(data
->NB_euro_value
), euro_params
[active
].value
);
782 gtk_spin_button_set_value(GTK_SPIN_BUTTON(data
->NB_euro_fracdigits
), euro_params
[active
].frac_digits
);
784 gtk_entry_set_text(GTK_ENTRY(data
->ST_euro_symbol
) , euro_params
[active
].symbol
);
785 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(data
->CM_euro_isprefix
), euro_params
[active
].sym_prefix
);
786 gtk_entry_set_text(GTK_ENTRY(data
->ST_euro_decimalchar
) , euro_params
[active
].decimal_char
);
787 gtk_entry_set_text(GTK_ENTRY(data
->ST_euro_groupingchar
), euro_params
[active
].grouping_char
);
792 static void defpref_colortoggle(GtkWidget
*widget
, gpointer user_data
)
794 struct defpref_data
*data
;
797 DB( g_print("\n[ui-pref] color toggle\n") );
799 data
= g_object_get_data(G_OBJECT(gtk_widget_get_ancestor(widget
, GTK_TYPE_WINDOW
)), "inst_data");
801 sensitive
= gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(data
->CM_custom_colors
));
803 gtk_widget_set_sensitive(data
->GR_colors
, sensitive
);
809 ** set preset colors for amount display
811 static void defpref_colorpreset(GtkWidget
*widget
, gpointer user_data
)
813 struct defpref_data
*data
;
816 gchar
*expcol
, *inccol
, *wrncol
;
818 DB( g_print("\n[ui-pref] color preset\n") );
820 data
= g_object_get_data(G_OBJECT(gtk_widget_get_ancestor(widget
, GTK_TYPE_WINDOW
)), "inst_data");
822 preset
= gtk_combo_box_get_active(GTK_COMBO_BOX(data
->CY_colors
));
827 expcol
= LIGHT_EXP_COLOR
;
828 inccol
= LIGHT_INC_COLOR
;
829 wrncol
= LIGHT_WARN_COLOR
;
833 expcol
= MEDIUM_EXP_COLOR
;
834 inccol
= MEDIUM_INC_COLOR
;
835 wrncol
= MEDIUM_WARN_COLOR
;
840 expcol
= DEFAULT_EXP_COLOR
;
841 inccol
= DEFAULT_INC_COLOR
;
842 wrncol
= DEFAULT_WARN_COLOR
;
847 gdk_rgba_parse(&rgba
, expcol
);
848 gtk_color_chooser_set_rgba(GTK_COLOR_CHOOSER(data
->CP_exp_color
), &rgba
);
850 gdk_rgba_parse(&rgba
, inccol
);
851 gtk_color_chooser_set_rgba(GTK_COLOR_CHOOSER(data
->CP_inc_color
), &rgba
);
853 gdk_rgba_parse(&rgba
, wrncol
);
854 gtk_color_chooser_set_rgba(GTK_COLOR_CHOOSER(data
->CP_warn_color
), &rgba
);
860 static void defpref_color_scheme_changed(GtkWidget
*widget
, gpointer user_data
)
862 struct defpref_data
*data
;
864 DB( g_print("\n[ui-pref] color scheme chnaged\n") );
866 data
= g_object_get_data(G_OBJECT(gtk_widget_get_ancestor(widget
, GTK_TYPE_WINDOW
)), "inst_data");
868 gtk_widget_queue_draw (data
->DA_colors
);
876 static void setGdkColor_from_RGB(GdkColor *color, guint32 value)
881 color->red = tmp | tmp<<8;
883 tmp = value >> 8 & 0xFF;
884 color->green = tmp | tmp<<8;
887 color->blue = tmp | tmp<<8;
893 ** set :: fill in widgets from PREFS structure
896 static void defpref_set(struct defpref_data
*data
)
900 DB( g_print("\n[ui-pref] set\n") );
903 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(data
->CM_show_splash
), PREFS
->showsplash
);
904 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(data
->CM_load_last
), PREFS
->loadlast
);
905 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(data
->CM_append_scheduled
), PREFS
->appendscheduled
);
906 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(data
->CM_do_update_currency
), PREFS
->do_update_currency
);
907 gtk_combo_box_set_active(GTK_COMBO_BOX(data
->CY_daterange_wal
), PREFS
->date_range_wal
);
908 gtk_spin_button_set_value(GTK_SPIN_BUTTON(data
->NB_fiscyearday
), PREFS
->fisc_year_day
);
909 gtk_combo_box_set_active(GTK_COMBO_BOX(data
->CY_fiscyearmonth
), PREFS
->fisc_year_month
- 1);
912 gtk_entry_set_text(GTK_ENTRY(data
->ST_path_hbfile
), PREFS
->path_hbfile
);
917 if(PREFS
->language
!= NULL
)
918 gtk_combo_box_set_active_id(GTK_COMBO_BOX(data
->CY_language
), PREFS
->language
);
920 gtk_combo_box_set_active (GTK_COMBO_BOX(data
->CY_language
), 0);
921 gtk_combo_box_set_active(GTK_COMBO_BOX(data
->CY_toolbar
), PREFS
->toolbar_style
);
922 //gtk_spin_button_set_value(GTK_SPIN_BUTTON(data->NB_image_size), PREFS->image_size);
924 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(data
->CM_custom_colors
), PREFS
->custom_colors
);
925 gdk_rgba_parse(&rgba
, PREFS
->color_exp
);
926 gtk_color_chooser_set_rgba(GTK_COLOR_CHOOSER(data
->CP_exp_color
), &rgba
);
927 gdk_rgba_parse(&rgba
, PREFS
->color_inc
);
928 gtk_color_chooser_set_rgba(GTK_COLOR_CHOOSER(data
->CP_inc_color
), &rgba
);
929 gdk_rgba_parse(&rgba
, PREFS
->color_warn
);
930 gtk_color_chooser_set_rgba(GTK_COLOR_CHOOSER(data
->CP_warn_color
), &rgba
);
931 //gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(data->CM_ruleshint), PREFS->rules_hint);
932 gtk_combo_box_set_active(GTK_COMBO_BOX(data
->CY_gridlines
), PREFS
->grid_lines
);
935 gtk_combo_box_set_active(GTK_COMBO_BOX(data
->CY_daterange_txn
), PREFS
->date_range_txn
);
936 gtk_spin_button_set_value(GTK_SPIN_BUTTON(data
->ST_datefuture_nbdays
), PREFS
->date_future_nbdays
);
937 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(data
->CM_hide_reconciled
), PREFS
->hidereconciled
);
938 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(data
->CM_show_remind
), PREFS
->showremind
);
939 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(data
->CM_herit_date
), PREFS
->heritdate
);
942 gtk_entry_set_text(GTK_ENTRY(data
->ST_datefmt
), PREFS
->date_format
);
943 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(data
->CM_unitismile
), PREFS
->vehicle_unit_ismile
);
944 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(data
->CM_unitisgal
), PREFS
->vehicle_unit_isgal
);
947 gtk_combo_box_set_active(GTK_COMBO_BOX(data
->CY_dtex_datefmt
), PREFS
->dtex_datefmt
);
948 gtk_combo_box_set_active(GTK_COMBO_BOX(data
->CY_dtex_ofxname
), PREFS
->dtex_ofxname
);
949 gtk_combo_box_set_active(GTK_COMBO_BOX(data
->CY_dtex_ofxmemo
), PREFS
->dtex_ofxmemo
);
950 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(data
->CM_dtex_qifmemo
), PREFS
->dtex_qifmemo
);
951 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(data
->CM_dtex_qifswap
), PREFS
->dtex_qifswap
);
952 gtk_entry_set_text(GTK_ENTRY(data
->ST_path_import
), PREFS
->path_import
);
953 gtk_entry_set_text(GTK_ENTRY(data
->ST_path_export
), PREFS
->path_export
);
956 gtk_combo_box_set_active(GTK_COMBO_BOX(data
->CY_daterange_rep
), PREFS
->date_range_rep
);
957 gtk_combo_box_set_active(GTK_COMBO_BOX(data
->CY_color_scheme
), PREFS
->report_color_scheme
);
958 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(data
->CM_stat_byamount
), PREFS
->stat_byamount
);
959 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(data
->CM_stat_showrate
), PREFS
->stat_showrate
);
960 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(data
->CM_stat_showdetail
), PREFS
->stat_showdetail
);
961 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(data
->CM_budg_showdetail
), PREFS
->budg_showdetail
);
964 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(data
->CM_euro_enable
), PREFS
->euro_active
);
965 //gtk_combo_box_set_active(GTK_COMBO_BOX(data->CY_euro_preset), PREFS->euro_country);
966 data
->country
= PREFS
->euro_country
;
967 defpref_eurosetcurrency(data
->window
, data
->country
);
968 gtk_spin_button_set_value(GTK_SPIN_BUTTON(data
->NB_euro_value
), PREFS
->euro_value
);
969 ui_gtk_entry_set_text(data
->ST_euro_symbol
, PREFS
->minor_cur
.symbol
);
970 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(data
->CM_euro_isprefix
), PREFS
->minor_cur
.sym_prefix
);
971 ui_gtk_entry_set_text(data
->ST_euro_decimalchar
, PREFS
->minor_cur
.decimal_char
);
972 ui_gtk_entry_set_text(data
->ST_euro_groupingchar
, PREFS
->minor_cur
.grouping_char
);
973 gtk_spin_button_set_value(GTK_SPIN_BUTTON(data
->NB_euro_fracdigits
), PREFS
->minor_cur
.frac_digits
);
975 //gtk_entry_set_text(GTK_ENTRY(data->ST_euro_symbol), PREFS->euro_symbol);
976 //gtk_spin_button_set_value(GTK_SPIN_BUTTON(data->NB_euro_nbdec), PREFS->euro_nbdec);
977 //gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(data->CM_euro_thsep), PREFS->euro_thsep);
982 ** get :: fill PREFS structure from widgets
984 #define RGBA_TO_INT(x) (int)(x*255)
986 static gchar
*gdk_rgba_to_hex(GdkRGBA
*rgba
)
988 return g_strdup_printf("#%02x%02x%02x", RGBA_TO_INT(rgba
->red
), RGBA_TO_INT(rgba
->green
), RGBA_TO_INT(rgba
->blue
));
992 static void defpref_get(struct defpref_data
*data
)
997 DB( g_print("\n[ui-pref] get\n") );
1000 PREFS
->showsplash
= gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(data
->CM_show_splash
));
1001 PREFS
->loadlast
= gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(data
->CM_load_last
));
1002 PREFS
->appendscheduled
= gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(data
->CM_append_scheduled
));
1003 PREFS
->do_update_currency
= gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(data
->CM_do_update_currency
));
1004 PREFS
->date_range_wal
= gtk_combo_box_get_active(GTK_COMBO_BOX(data
->CY_daterange_wal
));
1005 PREFS
->fisc_year_day
= gtk_spin_button_get_value(GTK_SPIN_BUTTON(data
->NB_fiscyearday
));
1006 PREFS
->fisc_year_month
= 1 + gtk_combo_box_get_active(GTK_COMBO_BOX(data
->CY_fiscyearmonth
));
1009 g_free(PREFS
->path_hbfile
);
1010 PREFS
->path_hbfile
= g_strdup(gtk_entry_get_text(GTK_ENTRY(data
->ST_path_hbfile
)));
1014 g_free(PREFS
->language
);
1015 PREFS
->language
= NULL
;
1016 lang
= gtk_combo_box_get_active_id(GTK_COMBO_BOX(data
->CY_language
));
1019 PREFS
->language
= g_strdup(lang
);
1022 PREFS
->toolbar_style
= gtk_combo_box_get_active(GTK_COMBO_BOX(data
->CY_toolbar
));
1023 //PREFS->image_size = gtk_spin_button_get_value(GTK_SPIN_BUTTON(data->NB_image_size));
1025 PREFS
->custom_colors
= gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(data
->CM_custom_colors
));
1026 gtk_color_chooser_get_rgba(GTK_COLOR_CHOOSER(data
->CP_exp_color
), &rgba
);
1027 g_free(PREFS
->color_exp
);
1028 PREFS
->color_exp
= gdk_rgba_to_hex(&rgba
);
1029 gtk_color_chooser_get_rgba(GTK_COLOR_CHOOSER(data
->CP_inc_color
), &rgba
);
1030 g_free(PREFS
->color_inc
);
1031 PREFS
->color_inc
= gdk_rgba_to_hex(&rgba
);
1032 gtk_color_chooser_get_rgba(GTK_COLOR_CHOOSER(data
->CP_warn_color
), &rgba
);
1033 g_free(PREFS
->color_warn
);
1034 PREFS
->color_warn
= gdk_rgba_to_hex(&rgba
);
1035 //PREFS->rules_hint = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(data->CM_ruleshint));
1036 PREFS
->grid_lines
= gtk_combo_box_get_active(GTK_COMBO_BOX(data
->CY_gridlines
));
1037 //list_txn_colpref_get(GTK_TREE_VIEW(data->LV_opecolumns), PREFS->lst_ope_columns);
1040 PREFS
->date_range_txn
= gtk_combo_box_get_active(GTK_COMBO_BOX(data
->CY_daterange_txn
));
1041 PREFS
->date_future_nbdays
= gtk_spin_button_get_value(GTK_SPIN_BUTTON(data
->ST_datefuture_nbdays
));
1042 PREFS
->hidereconciled
= gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(data
->CM_hide_reconciled
));
1043 PREFS
->showremind
= gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(data
->CM_show_remind
));
1044 PREFS
->heritdate
= gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(data
->CM_herit_date
));
1047 g_free(PREFS
->date_format
);
1048 PREFS
->date_format
= g_strdup(gtk_entry_get_text(GTK_ENTRY(data
->ST_datefmt
)));
1049 PREFS
->vehicle_unit_ismile
= gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(data
->CM_unitismile
));
1050 PREFS
->vehicle_unit_isgal
= gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(data
->CM_unitisgal
));
1053 PREFS
->dtex_datefmt
= gtk_combo_box_get_active(GTK_COMBO_BOX(data
->CY_dtex_datefmt
));
1054 PREFS
->dtex_ofxname
= gtk_combo_box_get_active(GTK_COMBO_BOX(data
->CY_dtex_ofxname
));
1055 PREFS
->dtex_ofxmemo
= gtk_combo_box_get_active(GTK_COMBO_BOX(data
->CY_dtex_ofxmemo
));
1056 PREFS
->dtex_qifmemo
= gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(data
->CM_dtex_qifmemo
));
1057 PREFS
->dtex_qifswap
= gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(data
->CM_dtex_qifswap
));
1058 ui_gtk_entry_replace_text(data
->ST_path_import
, &PREFS
->path_import
);
1059 ui_gtk_entry_replace_text(data
->ST_path_export
, &PREFS
->path_export
);
1062 PREFS
->date_range_rep
= gtk_combo_box_get_active(GTK_COMBO_BOX(data
->CY_daterange_rep
));
1063 PREFS
->report_color_scheme
= gtk_combo_box_get_active(GTK_COMBO_BOX(data
->CY_color_scheme
));
1064 PREFS
->stat_byamount
= gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(data
->CM_stat_byamount
));
1065 PREFS
->stat_showrate
= gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(data
->CM_stat_showrate
));
1066 PREFS
->stat_showdetail
= gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(data
->CM_stat_showdetail
));
1067 PREFS
->budg_showdetail
= gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(data
->CM_budg_showdetail
));
1070 PREFS
->euro_active
= gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(data
->CM_euro_enable
));
1071 PREFS
->euro_country
= data
->country
;
1072 PREFS
->euro_value
= gtk_spin_button_get_value(GTK_SPIN_BUTTON(data
->NB_euro_value
));
1073 //strcpy(PREFS->euro_symbol, gtk_entry_get_text(GTK_ENTRY(data->ST_euro_symbol)));
1074 //PREFS->euro_nbdec = gtk_spin_button_get_value(GTK_SPIN_BUTTON(data->NB_euro_nbdec));
1075 //PREFS->euro_thsep = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(data->CM_euro_thsep));
1076 ui_gtk_entry_replace_text(data
->ST_euro_symbol
, &PREFS
->minor_cur
.symbol
);
1077 PREFS
->minor_cur
.sym_prefix
= gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(data
->CM_euro_isprefix
));
1078 ui_gtk_entry_replace_text(data
->ST_euro_decimalchar
, &PREFS
->minor_cur
.decimal_char
);
1079 ui_gtk_entry_replace_text(data
->ST_euro_groupingchar
, &PREFS
->minor_cur
.grouping_char
);
1080 PREFS
->minor_cur
.frac_digits
= gtk_spin_button_get_value(GTK_SPIN_BUTTON(data
->NB_euro_fracdigits
));
1081 //PREFS->chart_legend = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(data->CM_chartlegend));
1085 static GtkWidget
*defpref_page_import (struct defpref_data
*data
)
1087 GtkWidget
*content_grid
, *group_grid
, *hbox
, *label
, *widget
;
1090 content_grid
= gtk_grid_new();
1091 gtk_grid_set_row_spacing (GTK_GRID (content_grid
), SPACING_LARGE
);
1092 gtk_orientable_set_orientation(GTK_ORIENTABLE(content_grid
), GTK_ORIENTATION_VERTICAL
);
1095 // group :: Date options
1096 group_grid
= gtk_grid_new ();
1097 gtk_grid_set_row_spacing (GTK_GRID (group_grid
), SPACING_SMALL
);
1098 gtk_grid_set_column_spacing (GTK_GRID (group_grid
), SPACING_MEDIUM
);
1099 gtk_grid_attach (GTK_GRID (content_grid
), group_grid
, 0, crow
++, 1, 1);
1101 label
= make_label_group(_("Date options"));
1102 gtk_grid_attach (GTK_GRID (group_grid
), label
, 0, 0, 3, 1);
1105 label
= make_label_widget(_("Date order:"));
1106 //----------------------------------------- l, r, t, b
1107 gtk_grid_attach (GTK_GRID (group_grid
), label
, 1, row
, 1, 1);
1108 widget
= make_cycle(label
, CYA_IMPORT_DATEORDER
);
1109 data
->CY_dtex_datefmt
= widget
;
1110 //gtk_grid_attach (GTK_GRID (group_grid), data->CY_option[FILTER_DATE], 1, 2, row, row+1);
1111 gtk_grid_attach (GTK_GRID (group_grid
), widget
, 2, row
, 1, 1);
1114 // group :: OFX/QFX options
1115 group_grid
= gtk_grid_new ();
1116 gtk_grid_set_row_spacing (GTK_GRID (group_grid
), SPACING_SMALL
);
1117 gtk_grid_set_column_spacing (GTK_GRID (group_grid
), SPACING_MEDIUM
);
1118 gtk_grid_attach (GTK_GRID (content_grid
), group_grid
, 0, crow
++, 1, 1);
1120 label
= make_label_group(_("OFX/QFX options"));
1121 gtk_grid_attach (GTK_GRID (group_grid
), label
, 0, 0, 3, 1);
1124 label
= make_label_widget(_("_Name field:"));
1125 //----------------------------------------- l, r, t, b
1126 gtk_grid_attach (GTK_GRID (group_grid
), label
, 1, row
, 1, 1);
1127 widget
= make_cycle(label
, CYA_IMPORT_OFXNAME
);
1128 data
->CY_dtex_ofxname
= widget
;
1129 //gtk_grid_attach (GTK_GRID (group_grid), data->CY_option[FILTER_DATE], 1, 2, row, row+1);
1130 gtk_grid_attach (GTK_GRID (group_grid
), widget
, 2, row
, 1, 1);
1133 label
= make_label_widget(_("_Memo field:"));
1134 //----------------------------------------- l, r, t, b
1135 gtk_grid_attach (GTK_GRID (group_grid
), label
, 1, row
, 1, 1);
1136 widget
= make_cycle(label
, CYA_IMPORT_OFXMEMO
);
1137 data
->CY_dtex_ofxmemo
= widget
;
1138 //gtk_grid_attach (GTK_GRID (group_grid), data->CY_option[FILTER_DATE], 1, 2, row, row+1);
1139 gtk_grid_attach (GTK_GRID (group_grid
), widget
, 2, row
, 1, 1);
1141 // group :: QIF options
1142 group_grid
= gtk_grid_new ();
1143 gtk_grid_set_row_spacing (GTK_GRID (group_grid
), SPACING_SMALL
);
1144 gtk_grid_set_column_spacing (GTK_GRID (group_grid
), SPACING_MEDIUM
);
1145 gtk_grid_attach (GTK_GRID (content_grid
), group_grid
, 0, crow
++, 1, 1);
1147 label
= make_label_group(_("QIF options"));
1148 gtk_grid_attach (GTK_GRID (group_grid
), label
, 0, 0, 3, 1);
1151 label
= make_label_widget(_("Memos:"));
1152 gtk_grid_attach (GTK_GRID (group_grid
), label
, 1, row
, 1, 1);
1153 widget
= gtk_check_button_new_with_mnemonic (_("_Import"));
1154 data
->CM_dtex_qifmemo
= widget
;
1155 gtk_grid_attach (GTK_GRID (group_grid
), widget
, 2, row
, 1, 1);
1156 widget
= gtk_check_button_new_with_mnemonic (_("_Swap with payees"));
1157 data
->CM_dtex_qifswap
= widget
;
1158 gtk_grid_attach (GTK_GRID (group_grid
), widget
, 3, row
, 1, 1);
1161 // group :: Files folder
1162 group_grid
= gtk_grid_new ();
1163 gtk_grid_set_row_spacing (GTK_GRID (group_grid
), SPACING_SMALL
);
1164 gtk_grid_set_column_spacing (GTK_GRID (group_grid
), SPACING_MEDIUM
);
1165 gtk_grid_attach (GTK_GRID (content_grid
), group_grid
, 0, crow
++, 1, 1);
1167 label
= make_label_group(_("Files folder"));
1168 gtk_grid_attach (GTK_GRID (group_grid
), label
, 0, 0, 3, 1);
1171 label
= make_label_widget(_("_Import:"));
1172 //----------------------------------------- l, r, t, b
1173 gtk_grid_attach (GTK_GRID (group_grid
), label
, 1, row
, 1, 1);
1175 hbox
= gtk_box_new(GTK_ORIENTATION_HORIZONTAL
, 0);
1176 gtk_widget_set_hexpand (hbox
, TRUE
);
1177 gtk_grid_attach (GTK_GRID (group_grid
), hbox
, 2, row
, 1, 1);
1179 widget
= make_string(label
);
1180 data
->ST_path_import
= widget
;
1181 gtk_style_context_add_class (gtk_widget_get_style_context (GTK_WIDGET(widget
)), GTK_STYLE_CLASS_LINKED
);
1182 gtk_box_pack_start (GTK_BOX (hbox
), widget
, TRUE
, TRUE
, 0);
1184 //widget = gtk_button_new_with_label("...");
1185 widget
= gtk_button_new_from_icon_name(ICONNAME_FOLDER
, GTK_ICON_SIZE_BUTTON
);
1186 data
->BT_path_import
= widget
;
1187 gtk_box_pack_start (GTK_BOX (hbox
), widget
, FALSE
, FALSE
, 0);
1190 label
= make_label_widget(_("_Export:"));
1191 //----------------------------------------- l, r, t, b
1192 gtk_grid_attach (GTK_GRID (group_grid
), label
, 1, row
, 1, 1);
1194 hbox
= gtk_box_new(GTK_ORIENTATION_HORIZONTAL
, 0);
1195 gtk_widget_set_hexpand (hbox
, TRUE
);
1196 gtk_grid_attach (GTK_GRID (group_grid
), hbox
, 2, row
, 1, 1);
1198 widget
= make_string(label
);
1199 data
->ST_path_export
= widget
;
1200 gtk_style_context_add_class (gtk_widget_get_style_context (GTK_WIDGET(widget
)), GTK_STYLE_CLASS_LINKED
);
1201 gtk_box_pack_start (GTK_BOX (hbox
), widget
, TRUE
, TRUE
, 0);
1203 //widget = gtk_button_new_with_label("...");
1204 widget
= gtk_button_new_from_icon_name(ICONNAME_FOLDER
, GTK_ICON_SIZE_BUTTON
);
1205 data
->BT_path_export
= widget
;
1206 gtk_box_pack_start (GTK_BOX (hbox
), widget
, FALSE
, FALSE
, 0);
1208 return content_grid
;
1214 draw_callback (GtkWidget
*widget
,
1218 struct defpref_data
*data
= user_data
;
1220 GtkColorScheme scheme
;
1224 index
= gtk_combo_box_get_active(GTK_COMBO_BOX(data
->CY_color_scheme
));
1226 colorscheme_init(&scheme
, index
);
1228 gtk_widget_get_size_request (widget
, &w
, &h
);
1230 for(i
=0;i
<scheme
.nb_cols
;i
++)
1232 cairo_user_set_rgbcol (cr
, &scheme
.colors
[i
]);
1233 cairo_rectangle(cr
, x
, y
, cube_dim
, cube_dim
);
1237 { x
= 0; y
= 1 + cube_dim
; }
1245 static GtkWidget
*defpref_page_reports (struct defpref_data
*data
)
1247 GtkWidget
*content_grid
, *group_grid
, *label
, *widget
;
1250 content_grid
= gtk_grid_new();
1251 gtk_grid_set_row_spacing (GTK_GRID (content_grid
), SPACING_LARGE
);
1252 gtk_orientable_set_orientation(GTK_ORIENTABLE(content_grid
), GTK_ORIENTATION_VERTICAL
);
1255 // group :: Initial filter
1256 group_grid
= gtk_grid_new ();
1257 gtk_grid_set_row_spacing (GTK_GRID (group_grid
), SPACING_SMALL
);
1258 gtk_grid_set_column_spacing (GTK_GRID (group_grid
), SPACING_MEDIUM
);
1259 gtk_grid_attach (GTK_GRID (content_grid
), group_grid
, 0, crow
++, 1, 1);
1261 label
= make_label_group(_("Initial filter"));
1262 gtk_grid_attach (GTK_GRID (group_grid
), label
, 0, 0, 3, 1);
1265 label
= make_label_widget(_("Date _range:"));
1266 //----------------------------------------- l, r, t, b
1267 gtk_grid_attach (GTK_GRID (group_grid
), label
, 1, row
, 1, 1);
1268 widget
= make_daterange(label
, FALSE
);
1269 data
->CY_daterange_rep
= widget
;
1270 //gtk_grid_attach (GTK_GRID (group_grid), data->CY_option[FILTER_DATE], 1, 2, row, row+1);
1271 gtk_grid_attach (GTK_GRID (group_grid
), widget
, 2, row
, 1, 1);
1273 // group ::Charts options
1274 group_grid
= gtk_grid_new ();
1275 gtk_grid_set_row_spacing (GTK_GRID (group_grid
), SPACING_SMALL
);
1276 gtk_grid_set_column_spacing (GTK_GRID (group_grid
), SPACING_MEDIUM
);
1277 gtk_grid_attach (GTK_GRID (content_grid
), group_grid
, 0, crow
++, 1, 1);
1279 label
= make_label_group(_("Charts options"));
1280 gtk_grid_attach (GTK_GRID (group_grid
), label
, 0, 0, 3, 1);
1283 label
= make_label_widget(_("Color scheme:"));
1284 //----------------------------------------- l, r, t, b
1285 gtk_grid_attach (GTK_GRID (group_grid
), label
, 1, row
, 1, 1);
1286 widget
= make_cycle(label
, chart_colors
);
1287 data
->CY_color_scheme
= widget
;
1288 //gtk_grid_attach (GTK_GRID (group_grid), data->CY_option[FILTER_DATE], 1, 2, row, row+1);
1289 gtk_grid_attach (GTK_GRID (group_grid
), widget
, 2, row
, 1, 1);
1292 widget
= gtk_drawing_area_new ();
1293 data
->DA_colors
= widget
;
1294 gtk_widget_set_size_request (widget
, (1+cube_dim
)*16, (1+cube_dim
)*2);
1295 gtk_grid_attach (GTK_GRID (group_grid
), widget
, 2, row
, 1, 1);
1297 g_signal_connect (data
->DA_colors
, "draw", G_CALLBACK (draw_callback
), data
);
1299 // group :: Statistics options
1300 group_grid
= gtk_grid_new ();
1301 gtk_grid_set_row_spacing (GTK_GRID (group_grid
), SPACING_SMALL
);
1302 gtk_grid_set_column_spacing (GTK_GRID (group_grid
), SPACING_MEDIUM
);
1303 gtk_grid_attach (GTK_GRID (content_grid
), group_grid
, 0, crow
++, 1, 1);
1305 label
= make_label_group(_("Statistics options"));
1306 gtk_grid_attach (GTK_GRID (group_grid
), label
, 0, 0, 3, 1);
1309 widget
= gtk_check_button_new_with_mnemonic (_("Show by _amount"));
1310 data
->CM_stat_byamount
= widget
;
1311 gtk_grid_attach (GTK_GRID (group_grid
), widget
, 1, row
, 2, 1);
1314 widget
= gtk_check_button_new_with_mnemonic (_("Show _rate column"));
1315 data
->CM_stat_showrate
= widget
;
1316 gtk_grid_attach (GTK_GRID (group_grid
), widget
, 1, row
, 2, 1);
1319 widget
= gtk_check_button_new_with_mnemonic (_("Show _details"));
1320 data
->CM_stat_showdetail
= widget
;
1321 gtk_grid_attach (GTK_GRID (group_grid
), widget
, 1, row
, 2, 1);
1323 // group :: Budget options
1324 group_grid
= gtk_grid_new ();
1325 gtk_grid_set_row_spacing (GTK_GRID (group_grid
), SPACING_SMALL
);
1326 gtk_grid_set_column_spacing (GTK_GRID (group_grid
), SPACING_MEDIUM
);
1327 gtk_grid_attach (GTK_GRID (content_grid
), group_grid
, 0, crow
++, 1, 1);
1329 label
= make_label_group(_("Budget options"));
1330 gtk_grid_attach (GTK_GRID (group_grid
), label
, 0, 0, 3, 1);
1333 widget
= gtk_check_button_new_with_mnemonic (_("Show _details"));
1334 data
->CM_budg_showdetail
= widget
;
1335 gtk_grid_attach (GTK_GRID (group_grid
), widget
, 1, row
, 2, 1);
1337 return content_grid
;
1341 static GtkWidget
*defpref_page_euro (struct defpref_data
*data
)
1343 GtkWidget
*content_grid
, *group_grid
, *label
, *widget
, *expander
;
1346 content_grid
= gtk_grid_new();
1347 gtk_grid_set_row_spacing (GTK_GRID (content_grid
), SPACING_LARGE
);
1348 gtk_orientable_set_orientation(GTK_ORIENTABLE(content_grid
), GTK_ORIENTATION_VERTICAL
);
1352 group_grid
= gtk_grid_new ();
1353 gtk_grid_set_row_spacing (GTK_GRID (group_grid
), SPACING_SMALL
);
1354 gtk_grid_set_column_spacing (GTK_GRID (group_grid
), SPACING_MEDIUM
);
1355 gtk_grid_attach (GTK_GRID (content_grid
), group_grid
, 0, crow
++, 1, 1);
1357 label
= make_label_group(_("General"));
1358 gtk_grid_attach (GTK_GRID (group_grid
), label
, 0, 0, 3, 1);
1361 widget
= gtk_check_button_new_with_mnemonic (_("_Enable"));
1362 data
->CM_euro_enable
= widget
;
1363 gtk_grid_attach (GTK_GRID (group_grid
), widget
, 1, row
, 2, 1);
1365 // group :: Currency
1366 group_grid
= gtk_grid_new ();
1367 data
->GRP_currency
= group_grid
;
1368 gtk_grid_set_row_spacing (GTK_GRID (group_grid
), SPACING_SMALL
);
1369 gtk_grid_set_column_spacing (GTK_GRID (group_grid
), SPACING_MEDIUM
);
1370 gtk_grid_attach (GTK_GRID (content_grid
), group_grid
, 0, crow
++, 1, 1);
1372 label
= make_label_group(_("Currency"));
1373 gtk_grid_attach (GTK_GRID (group_grid
), label
, 0, 0, 4, 1);
1376 widget
= make_label(NULL
, 0.0, 0.5);
1377 data
->ST_euro_country
= widget
;
1378 //gtk_grid_attach (GTK_GRID (group_grid), data->CY_option[FILTER_DATE], 1, 2, row, row+1);
1379 gtk_grid_attach (GTK_GRID (group_grid
), widget
, 1, row
, 1, 1);
1382 label
= make_label_widget(_("_Preset:"));
1383 //----------------------------------------- l, r, t, b
1384 gtk_grid_attach (GTK_GRID (group_grid
), label
, 2, row
, 1, 1);
1385 widget
= ui_euro_combobox_new (label
);
1386 data
->CY_euro_preset
= widget
;
1387 gtk_widget_set_margin_left (label
, 2*SPACING_LARGE
);
1388 //gtk_grid_attach (GTK_GRID (group_grid), data->CY_option[FILTER_DATE], 1, 2, row, row+1);
1389 gtk_grid_attach (GTK_GRID (group_grid
), widget
, 3, row
, 1, 1);
1392 // group :: Exchange rate
1393 group_grid
= gtk_grid_new ();
1394 data
->GRP_rate
= group_grid
;
1395 gtk_grid_set_row_spacing (GTK_GRID (group_grid
), SPACING_SMALL
);
1396 gtk_grid_set_column_spacing (GTK_GRID (group_grid
), SPACING_MEDIUM
);
1397 gtk_grid_attach (GTK_GRID (content_grid
), group_grid
, 0, crow
++, 1, 1);
1399 label
= make_label_group(_("Exchange rate"));
1400 gtk_grid_attach (GTK_GRID (group_grid
), label
, 0, 0, 3, 1);
1403 label
= make_label_widget("1 EUR _=");
1404 gtk_grid_attach (GTK_GRID (group_grid
), label
, 1, row
, 1, 1);
1405 widget
= make_exchange_rate(label
);
1406 data
->NB_euro_value
= widget
;
1407 //gtk_grid_attach (GTK_GRID (group_grid), data->CY_option[FILTER_DATE], 1, 2, row, row+1);
1408 gtk_grid_attach (GTK_GRID (group_grid
), widget
, 2, row
, 1, 1);
1410 // group :: Numbers format
1411 group_grid
= gtk_grid_new ();
1412 data
->GRP_format
= group_grid
;
1413 gtk_grid_set_row_spacing (GTK_GRID (group_grid
), SPACING_SMALL
);
1414 gtk_grid_set_column_spacing (GTK_GRID (group_grid
), SPACING_MEDIUM
);
1415 gtk_grid_attach (GTK_GRID (content_grid
), group_grid
, 0, crow
++, 1, 1);
1417 label
= make_label_group(_("Format"));
1418 gtk_grid_attach (GTK_GRID (group_grid
), label
, 0, 0, 3, 1);
1421 widget
= make_label(NULL
, 0, 0.0);
1422 data
->LB_numbereuro
= widget
;
1423 gtk_grid_attach (GTK_GRID (group_grid
), widget
, 1, row
, 1, 1);
1426 expander
= gtk_expander_new_with_mnemonic(_("_Customize"));
1427 gtk_grid_attach (GTK_GRID (group_grid
), expander
, 1, row
, 1, 1);
1429 group_grid
= gtk_grid_new ();
1430 gtk_grid_set_row_spacing (GTK_GRID (group_grid
), SPACING_SMALL
);
1431 gtk_grid_set_column_spacing (GTK_GRID (group_grid
), SPACING_MEDIUM
);
1432 gtk_container_add (GTK_CONTAINER (expander
), group_grid
);
1435 label
= make_label_widget(_("_Symbol:"));
1436 gtk_grid_attach (GTK_GRID (group_grid
), label
, 1, row
, 1, 1);
1437 widget
= make_string_maxlength(label
, 3);
1438 data
->ST_euro_symbol
= widget
;
1439 gtk_grid_attach (GTK_GRID (group_grid
), widget
, 2, row
, 1, 1);
1442 widget
= gtk_check_button_new_with_mnemonic (_("Is pre_fix"));
1443 data
->CM_euro_isprefix
= widget
;
1444 gtk_grid_attach (GTK_GRID (group_grid
), widget
, 2, row
, 1, 1);
1447 label
= make_label_widget(_("_Decimal char:"));
1448 gtk_grid_attach (GTK_GRID (group_grid
), label
, 1, row
, 1, 1);
1449 widget
= make_string_maxlength(label
, 1);
1450 data
->ST_euro_decimalchar
= widget
;
1451 gtk_grid_attach (GTK_GRID (group_grid
), widget
, 2, row
, 1, 1);
1454 label
= make_label_widget(_("_Frac digits:"));
1455 gtk_grid_attach (GTK_GRID (group_grid
), label
, 1, row
, 1, 1);
1456 widget
= make_numeric(label
, 0.0, 6.0);
1457 data
->NB_euro_fracdigits
= widget
;
1458 gtk_grid_attach (GTK_GRID (group_grid
), widget
, 2, row
, 1, 1);
1461 label
= make_label_widget(_("_Grouping char:"));
1462 gtk_grid_attach (GTK_GRID (group_grid
), label
, 1, row
, 1, 1);
1463 widget
= make_string_maxlength(label
, 1);
1464 data
->ST_euro_groupingchar
= widget
;
1465 gtk_grid_attach (GTK_GRID (group_grid
), widget
, 2, row
, 1, 1);
1467 return content_grid
;
1471 static GtkWidget
*defpref_page_display (struct defpref_data
*data
)
1473 GtkWidget
*content_grid
, *group_grid
, *label
, *widget
, *expander
;
1476 content_grid
= gtk_grid_new();
1477 gtk_grid_set_row_spacing (GTK_GRID (content_grid
), SPACING_LARGE
);
1478 gtk_orientable_set_orientation(GTK_ORIENTABLE(content_grid
), GTK_ORIENTATION_VERTICAL
);
1481 // group :: Date options
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_grid_attach (GTK_GRID (content_grid
), group_grid
, 0, crow
++, 1, 1);
1487 label
= make_label_group(_("Date"));
1488 gtk_grid_attach (GTK_GRID (group_grid
), label
, 0, 0, 3, 1);
1491 widget
= make_label(NULL
, 0, 0.5);
1492 data
->LB_date
= widget
;
1493 gtk_grid_attach (GTK_GRID (group_grid
), widget
, 1, row
, 2, 1);
1496 expander
= gtk_expander_new_with_mnemonic(_("_Customize"));
1497 gtk_grid_attach (GTK_GRID (group_grid
), expander
, 1, row
, 1, 1);
1499 group_grid
= gtk_grid_new ();
1500 gtk_grid_set_row_spacing (GTK_GRID (group_grid
), SPACING_SMALL
);
1501 gtk_grid_set_column_spacing (GTK_GRID (group_grid
), SPACING_MEDIUM
);
1502 gtk_container_add (GTK_CONTAINER (expander
), group_grid
);
1505 label
= make_label_widget(_("_Format:"));
1506 //----------------------------------------- l, r, t, b
1507 gtk_grid_attach (GTK_GRID (group_grid
), label
, 1, row
, 1, 1);
1508 widget
= make_string(label
);
1509 data
->ST_datefmt
= widget
;
1510 //gtk_grid_attach (GTK_GRID (group_grid), data->CY_option[FILTER_DATE], 1, 2, row, row+1);
1511 gtk_grid_attach (GTK_GRID (group_grid
), widget
, 2, row
, 1, 1);
1513 widget
= gtk_image_new_from_icon_name (ICONNAME_INFO
, GTK_ICON_SIZE_BUTTON
);
1514 gtk_grid_attach (GTK_GRID (group_grid
), widget
, 3, row
, 1, 1);
1517 gtk_widget_set_tooltip_text(widget
,
1518 _("%a locale's abbreviated weekday name.\n"
1519 "%A locale's full weekday name. \n"
1520 "%b locale's abbreviated month name. \n"
1521 "%B locale's full month name. \n"
1522 "%c locale's appropriate date and time representation. \n"
1523 "%C century number (the year divided by 100 and truncated to an integer) as a decimal number [00-99]. \n"
1524 "%d day of the month as a decimal number [01,31]. \n"
1525 "%D same as %m/%d/%y. \n"
1526 "%e day of the month as a decimal number [1,31]; a single digit is preceded by a space. \n"
1527 "%j day of the year as a decimal number [001,366]. \n"
1528 "%m month as a decimal number [01,12]. \n"
1529 "%p locale's appropriate date representation. \n"
1530 "%y year without century as a decimal number [00,99]. \n"
1531 "%Y year with century as a decimal number. \n")
1535 widget
= make_label(NULL
, 0.0, 0.5);
1536 gtk_label_set_markup (GTK_LABEL(widget
), "<small><a href=\"http://man7.org/linux/man-pages/man3/strftime.3.html\">online reference</a></small>");
1537 gtk_grid_attach (GTK_GRID (group_grid
), widget
, 2, row
, 1, 1);
1539 // group :: Measurement units
1540 group_grid
= gtk_grid_new ();
1541 gtk_grid_set_row_spacing (GTK_GRID (group_grid
), SPACING_SMALL
);
1542 gtk_grid_set_column_spacing (GTK_GRID (group_grid
), SPACING_MEDIUM
);
1543 gtk_grid_attach (GTK_GRID (content_grid
), group_grid
, 0, crow
++, 1, 1);
1545 label
= make_label_group(_("Measurement units"));
1546 gtk_grid_attach (GTK_GRID (group_grid
), label
, 0, 0, 3, 1);
1549 widget
= gtk_check_button_new_with_mnemonic (_("Use _miles for meter"));
1550 data
->CM_unitismile
= widget
;
1551 gtk_grid_attach (GTK_GRID (group_grid
), widget
, 1, row
, 2, 1);
1554 widget
= gtk_check_button_new_with_mnemonic (_("Use _gallon for fuel"));
1555 data
->CM_unitisgal
= widget
;
1556 gtk_grid_attach (GTK_GRID (group_grid
), widget
, 1, row
, 2, 1);
1558 return content_grid
;
1562 static GtkWidget
*defpref_page_transactions (struct defpref_data
*data
)
1564 GtkWidget
*content_grid
, *group_grid
, *label
, *widget
;
1567 content_grid
= gtk_grid_new();
1568 gtk_grid_set_row_spacing (GTK_GRID (content_grid
), SPACING_LARGE
);
1569 gtk_orientable_set_orientation(GTK_ORIENTABLE(content_grid
), GTK_ORIENTATION_VERTICAL
);
1572 // group :: Transaction window
1573 group_grid
= gtk_grid_new ();
1574 gtk_grid_set_row_spacing (GTK_GRID (group_grid
), SPACING_SMALL
);
1575 gtk_grid_set_column_spacing (GTK_GRID (group_grid
), SPACING_MEDIUM
);
1576 gtk_grid_attach (GTK_GRID (content_grid
), group_grid
, 0, crow
++, 1, 1);
1578 label
= make_label_group(_("Transaction window"));
1579 gtk_grid_attach (GTK_GRID (group_grid
), label
, 0, 0, 3, 1);
1582 label
= make_label_widget(_("Date _range:"));
1583 //----------------------------------------- l, r, t, b
1584 gtk_grid_attach (GTK_GRID (group_grid
), label
, 1, row
, 1, 1);
1585 widget
= make_daterange(label
, FALSE
);
1586 data
->CY_daterange_txn
= widget
;
1587 gtk_grid_attach (GTK_GRID (group_grid
), widget
, 2, row
, 1, 1);
1590 label
= make_label_widget(_("_Show:"));
1591 //----------------------------------------- l, r, t, b
1592 gtk_grid_attach (GTK_GRID (group_grid
), label
, 1, row
, 1, 1);
1593 widget
= make_numeric(NULL
, 0, 366);
1595 data
->ST_datefuture_nbdays
= widget
;
1596 gtk_grid_attach (GTK_GRID (group_grid
), widget
, 2, row
, 1, 1);
1598 //TRANSLATORS: there is a spinner on the left of this label, and so you have 0....x days in advance the current date
1599 label
= make_label(_("days in advance the current date"), 0, 0.5);
1600 gtk_grid_attach (GTK_GRID (group_grid
), label
, 3, row
, 1, 1);
1603 widget
= gtk_check_button_new_with_mnemonic (_("Hide reconciled transactions"));
1604 data
->CM_hide_reconciled
= widget
;
1605 gtk_grid_attach (GTK_GRID (group_grid
), widget
, 2, row
, 2, 1);
1608 widget
= gtk_check_button_new_with_mnemonic (_("Always show remind transactions"));
1609 data
->CM_show_remind
= widget
;
1610 gtk_grid_attach (GTK_GRID (group_grid
), widget
, 2, row
, 2, 1);
1612 // group :: Multiple add
1613 group_grid
= gtk_grid_new ();
1614 gtk_grid_set_row_spacing (GTK_GRID (group_grid
), SPACING_SMALL
);
1615 gtk_grid_set_column_spacing (GTK_GRID (group_grid
), SPACING_MEDIUM
);
1616 gtk_grid_attach (GTK_GRID (content_grid
), group_grid
, 0, crow
++, 1, 1);
1618 label
= make_label_group(_("Multiple add"));
1619 gtk_grid_attach (GTK_GRID (group_grid
), label
, 0, 0, 3, 1);
1622 widget
= gtk_check_button_new_with_mnemonic (_("Keep the last date"));
1623 data
->CM_herit_date
= widget
;
1624 gtk_grid_attach (GTK_GRID (group_grid
), widget
, 1, row
, 2, 1);
1626 // group :: Column list
1628 group_grid = gtk_grid_new ();
1629 gtk_grid_set_row_spacing (GTK_GRID (group_grid), SPACING_SMALL);
1630 gtk_grid_set_column_spacing (GTK_GRID (group_grid), SPACING_MEDIUM);
1631 gtk_grid_attach (GTK_GRID (content_grid), group_grid, 0, crow++, 1, 1);
1633 label = make_label_group(_("Column list"));
1634 gtk_grid_attach (GTK_GRID (group_grid), label, 0, 0, 3, 1);
1637 sw = gtk_scrolled_window_new (NULL, NULL);
1638 gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (sw), GTK_SHADOW_ETCHED_IN);
1639 gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (sw), GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC);
1640 widget = (GtkWidget *)list_txn_colprefcreate();
1641 data->LV_opecolumns = widget;
1642 gtk_widget_set_size_request(data->LV_opecolumns, HB_MINWIDTH_LIST, -1);
1643 gtk_container_add (GTK_CONTAINER (sw), widget);
1644 gtk_widget_set_vexpand (sw, TRUE);
1645 gtk_grid_attach (GTK_GRID (group_grid), sw, 1, row, 2, 1);
1646 gtk_widget_set_tooltip_text(widget, _("Drag & drop to change the order"));
1649 return content_grid
;
1654 static GtkWidget
*defpref_page_interface (struct defpref_data
*data
)
1656 GtkWidget
*content_grid
, *group_grid
, *hbox
, *label
, *widget
;
1659 content_grid
= gtk_grid_new();
1660 gtk_grid_set_row_spacing (GTK_GRID (content_grid
), SPACING_LARGE
);
1661 gtk_orientable_set_orientation(GTK_ORIENTABLE(content_grid
), GTK_ORIENTATION_VERTICAL
);
1665 group_grid
= gtk_grid_new ();
1666 gtk_grid_set_row_spacing (GTK_GRID (group_grid
), SPACING_SMALL
);
1667 gtk_grid_set_column_spacing (GTK_GRID (group_grid
), SPACING_MEDIUM
);
1668 gtk_grid_attach (GTK_GRID (content_grid
), group_grid
, 0, crow
++, 1, 1);
1670 label
= make_label_group(_("General"));
1671 gtk_grid_attach (GTK_GRID (group_grid
), label
, 0, 0, 3, 1);
1674 label
= make_label_widget(_("_Language:"));
1675 gtk_grid_attach (GTK_GRID (group_grid
), label
, 1, row
, 1, 1);
1676 widget
= ui_language_combobox_new(label
);
1677 data
->CY_language
= widget
;
1678 gtk_grid_attach (GTK_GRID (group_grid
), widget
, 2, row
, 1, 1);
1681 label
= make_label_widget(_("_Toolbar:"));
1682 gtk_grid_attach (GTK_GRID (group_grid
), label
, 1, row
, 1, 1);
1683 widget
= make_cycle(label
, CYA_TOOLBAR_STYLE
);
1684 data
->CY_toolbar
= widget
;
1685 gtk_grid_attach (GTK_GRID (group_grid
), widget
, 2, row
, 1, 1);
1689 //widget = gtk_check_button_new_with_mnemonic (_("Enable rows in alternating colors"));
1690 //data->CM_ruleshint = widget;
1691 label
= make_label_widget(_("_Grid line:"));
1692 gtk_grid_attach (GTK_GRID (group_grid
), label
, 1, row
, 1, 1);
1693 widget
= make_cycle(label
, CYA_GRID_LINES
);
1694 data
->CY_gridlines
= widget
;
1695 gtk_grid_attach (GTK_GRID (group_grid
), widget
, 2, row
, 1, 1);
1697 // group :: Amount colors
1698 group_grid
= gtk_grid_new ();
1699 gtk_grid_set_row_spacing (GTK_GRID (group_grid
), SPACING_SMALL
);
1700 gtk_grid_set_column_spacing (GTK_GRID (group_grid
), SPACING_MEDIUM
);
1701 gtk_grid_attach (GTK_GRID (content_grid
), group_grid
, 0, crow
++, 1, 1);
1703 label
= make_label_group(_("Amount colors"));
1704 gtk_grid_attach (GTK_GRID (group_grid
), label
, 0, 0, 3, 1);
1707 widget
= gtk_check_button_new_with_mnemonic (_("Uses custom colors"));
1708 data
->CM_custom_colors
= widget
;
1709 gtk_grid_attach (GTK_GRID (group_grid
), widget
, 2, row
, 1, 1);
1711 group_grid
= gtk_grid_new ();
1712 data
->GR_colors
= group_grid
;
1713 gtk_grid_set_row_spacing (GTK_GRID (group_grid
), SPACING_SMALL
);
1714 gtk_grid_set_column_spacing (GTK_GRID (group_grid
), SPACING_MEDIUM
);
1715 gtk_grid_attach (GTK_GRID (content_grid
), group_grid
, 0, crow
++, 1, 1);
1718 label
= make_label_widget(_("_Preset:"));
1719 //----------------------------------------- l, r, t, b
1720 gtk_grid_attach (GTK_GRID (group_grid
), label
, 1, row
, 1, 1);
1721 widget
= make_cycle(label
, CYA_TANGO_COLORS
);
1722 data
->CY_colors
= widget
;
1723 //gtk_grid_attach (GTK_GRID (group_grid), data->CY_option[FILTER_DATE], 1, 2, row, row+1);
1724 gtk_grid_attach (GTK_GRID (group_grid
), widget
, 2, row
, 1, 1);
1727 label
= make_label_widget(_("_Expense:"));
1728 //----------------------------------------- l, r, t, b
1729 gtk_grid_attach (GTK_GRID (group_grid
), label
, 1, row
, 1, 1);
1730 hbox
= gtk_box_new(GTK_ORIENTATION_HORIZONTAL
, SPACING_SMALL
);
1731 gtk_grid_attach (GTK_GRID (group_grid
), hbox
, 2, row
, 1, 1);
1733 widget
= gtk_color_button_new ();
1734 data
->CP_exp_color
= widget
;
1735 gtk_box_pack_start (GTK_BOX (hbox
), widget
, FALSE
, FALSE
, 0);
1737 label
= make_label_widget(_("_Income:"));
1738 gtk_box_pack_start (GTK_BOX (hbox
), label
, FALSE
, FALSE
, 0);
1740 widget
= gtk_color_button_new ();
1741 data
->CP_inc_color
= widget
;
1742 gtk_box_pack_start (GTK_BOX (hbox
), widget
, FALSE
, FALSE
, 0);
1744 label
= make_label_widget(_("_Warning:"));
1745 gtk_box_pack_start (GTK_BOX (hbox
), label
, FALSE
, FALSE
, 0);
1747 widget
= gtk_color_button_new ();
1748 data
->CP_warn_color
= widget
;
1749 gtk_box_pack_start (GTK_BOX (hbox
), widget
, FALSE
, FALSE
, 0);
1751 return content_grid
;
1755 static GtkWidget
*defpref_page_general (struct defpref_data
*data
)
1757 GtkWidget
*content_grid
, *group_grid
, *hbox
, *label
, *widget
;
1760 content_grid
= gtk_grid_new();
1761 gtk_grid_set_row_spacing (GTK_GRID (content_grid
), SPACING_LARGE
);
1762 gtk_orientable_set_orientation(GTK_ORIENTABLE(content_grid
), GTK_ORIENTATION_VERTICAL
);
1765 // group :: Program start
1766 group_grid
= gtk_grid_new ();
1767 gtk_grid_set_row_spacing (GTK_GRID (group_grid
), SPACING_SMALL
);
1768 gtk_grid_set_column_spacing (GTK_GRID (group_grid
), SPACING_MEDIUM
);
1769 gtk_grid_attach (GTK_GRID (content_grid
), group_grid
, 0, crow
++, 1, 1);
1771 label
= make_label_group(_("Program start"));
1772 gtk_grid_attach (GTK_GRID (group_grid
), label
, 0, 0, 3, 1);
1775 widget
= gtk_check_button_new_with_mnemonic (_("Show splash screen"));
1776 data
->CM_show_splash
= widget
;
1777 gtk_grid_attach (GTK_GRID (group_grid
), widget
, 1, row
, 2, 1);
1780 widget
= gtk_check_button_new_with_mnemonic (_("Load last opened file"));
1781 data
->CM_load_last
= widget
;
1782 gtk_grid_attach (GTK_GRID (group_grid
), widget
, 1, row
, 2, 1);
1785 widget
= gtk_check_button_new_with_mnemonic (_("Post pending scheduled transactions"));
1786 data
->CM_append_scheduled
= widget
;
1787 gtk_grid_attach (GTK_GRID (group_grid
), widget
, 1, row
, 2, 1);
1790 widget
= gtk_check_button_new_with_mnemonic (_("Update currencies online"));
1791 data
->CM_do_update_currency
= widget
;
1792 gtk_grid_attach (GTK_GRID (group_grid
), widget
, 1, row
, 2, 1);
1794 // group :: Fiscal year
1795 group_grid
= gtk_grid_new ();
1796 gtk_grid_set_row_spacing (GTK_GRID (group_grid
), SPACING_SMALL
);
1797 gtk_grid_set_column_spacing (GTK_GRID (group_grid
), SPACING_MEDIUM
);
1798 gtk_grid_attach (GTK_GRID (content_grid
), group_grid
, 0, crow
++, 1, 1);
1800 label
= make_label_group(_("Fiscal year"));
1801 gtk_grid_attach (GTK_GRID (group_grid
), label
, 0, 0, 3, 1);
1804 //TRANSLATORS: (fiscal year) starts on
1805 label
= make_label_widget(_("Starts _on:"));
1806 gtk_grid_attach (GTK_GRID (group_grid
), label
, 1, row
, 1, 1);
1808 hbox
= gtk_box_new(GTK_ORIENTATION_HORIZONTAL
, SPACING_SMALL
);
1809 gtk_grid_attach (GTK_GRID (group_grid
), hbox
, 2, row
, 1, 1);
1810 widget
= make_numeric (label
, 1, 28);
1811 data
->NB_fiscyearday
= widget
;
1812 gtk_box_pack_start (GTK_BOX (hbox
), widget
, FALSE
, FALSE
, 0);
1813 widget
= make_cycle (NULL
, CYA_MONTHS
);
1814 data
->CY_fiscyearmonth
= widget
;
1815 gtk_box_pack_start (GTK_BOX (hbox
), widget
, FALSE
, FALSE
, 0);
1817 // group :: Main window reports
1818 group_grid
= gtk_grid_new ();
1819 gtk_grid_set_row_spacing (GTK_GRID (group_grid
), SPACING_SMALL
);
1820 gtk_grid_set_column_spacing (GTK_GRID (group_grid
), SPACING_MEDIUM
);
1821 gtk_grid_attach (GTK_GRID (content_grid
), group_grid
, 0, crow
++, 1, 1);
1823 label
= make_label_group(_("Main window reports"));
1824 gtk_grid_attach (GTK_GRID (group_grid
), label
, 0, 0, 3, 1);
1827 label
= make_label_widget(_("Date _range:"));
1828 gtk_grid_attach (GTK_GRID (group_grid
), label
, 1, row
, 1, 1);
1829 widget
= make_daterange(label
, FALSE
);
1830 data
->CY_daterange_wal
= widget
;
1831 gtk_grid_attach (GTK_GRID (group_grid
), widget
, 2, row
, 1, 1);
1833 // group :: Files folder
1834 group_grid
= gtk_grid_new ();
1835 gtk_grid_set_row_spacing (GTK_GRID (group_grid
), SPACING_SMALL
);
1836 gtk_grid_set_column_spacing (GTK_GRID (group_grid
), SPACING_MEDIUM
);
1837 gtk_grid_attach (GTK_GRID (content_grid
), group_grid
, 0, crow
++, 1, 1);
1839 label
= make_label_group(_("Files folder"));
1840 gtk_grid_attach (GTK_GRID (group_grid
), label
, 0, 0, 3, 1);
1843 label
= make_label_widget(_("_Default:"));
1844 gtk_grid_attach (GTK_GRID (group_grid
), label
, 1, row
, 1, 1);
1846 hbox
= gtk_box_new(GTK_ORIENTATION_HORIZONTAL
, 0);
1847 gtk_widget_set_hexpand (hbox
, TRUE
);
1848 gtk_grid_attach (GTK_GRID (group_grid
), hbox
, 2, row
, 1, 1);
1850 widget
= make_string(label
);
1851 data
->ST_path_hbfile
= widget
;
1852 gtk_style_context_add_class (gtk_widget_get_style_context (GTK_WIDGET(widget
)), GTK_STYLE_CLASS_LINKED
);
1853 gtk_box_pack_start (GTK_BOX (hbox
), widget
, TRUE
, TRUE
, 0);
1855 //widget = gtk_button_new_with_label("...");
1856 widget
= gtk_button_new_from_icon_name(ICONNAME_FOLDER
, GTK_ICON_SIZE_BUTTON
);
1857 data
->BT_path_hbfile
= widget
;
1858 gtk_box_pack_start (GTK_BOX (hbox
), widget
, FALSE
, FALSE
, 0);
1860 return content_grid
;
1863 static void defpref_selection(GtkTreeSelection
*treeselection
, gpointer user_data
)
1865 struct defpref_data
*data
;
1866 GtkWidget
*notebook
;
1867 GtkTreeView
*treeview
;
1868 GtkTreeModel
*model
;
1871 GValue val
= { 0, };
1874 DB( g_print("\n[ui-pref] selection\n") );
1876 if (gtk_tree_selection_get_selected(treeselection
, &model
, &iter
))
1878 notebook
= GTK_WIDGET(user_data
);
1879 treeview
= gtk_tree_selection_get_tree_view(treeselection
);
1880 data
= g_object_get_data(G_OBJECT(gtk_widget_get_ancestor(GTK_WIDGET(treeview
), GTK_TYPE_WINDOW
)), "inst_data");
1883 gtk_tree_model_get_value(model
, &iter
, LST_PREF_PAGE
, &val
);
1884 page
= g_value_get_int (&val
);
1885 DB( g_print(" - active is %d\n", page
) );
1886 g_value_unset (&val
);
1889 gtk_tree_model_get_value(model
, &iter
, LST_PREF_NAME
, &val
);
1890 gtk_label_set_text (GTK_LABEL (data
->label
), g_value_get_string (&val
));
1891 g_value_unset (&val
);
1893 gtk_tree_model_get_value(model
, &iter
, LST_PREF_ICONNAME
, &val
);
1894 //gtk_image_set_from_pixbuf (GTK_IMAGE (data->image), g_value_get_object (&val));
1895 gtk_image_set_from_icon_name(GTK_IMAGE (data
->image
), g_value_get_string (&val
), GTK_ICON_SIZE_DIALOG
);
1896 g_value_unset (&val
);
1900 gtk_notebook_set_current_page(GTK_NOTEBOOK(notebook
), page
);
1902 //defpref_change_page(GTK_WIDGET(gtk_tree_selection_get_tree_view(treeselection)), GINT_TO_POINTER(page));
1909 ** set the notebook active page from treeview
1911 /*void defpref_change_page(GtkWidget *widget, gpointer user_data)
1913 struct defpref_data *data;
1914 gint page = GPOINTER_TO_INT(user_data);
1915 GtkTreeModel *model;
1918 DB( g_print("\n[ui-pref] page\n") );
1920 data = g_object_get_data(G_OBJECT(gtk_widget_get_ancestor(widget, GTK_TYPE_WINDOW)), "inst_data");
1922 model = gtk_tree_view_get_model(GTK_TREE_VIEW(data->LV_page));
1930 gtk_notebook_set_current_page(GTK_NOTEBOOK(data->GR_page), page);
1936 ** add an empty new account to our temp GList and treeview
1938 static void defpref_clear(GtkWidget
*widget
, gpointer user_data
)
1940 struct defpref_data
*data
;
1943 data
= g_object_get_data(G_OBJECT(gtk_widget_get_ancestor(widget
, GTK_TYPE_WINDOW
)), "inst_data");
1944 DB( g_print("\n(defpref_clear) (data=%p)\n", data
) );
1946 result
= ui_dialog_msg_confirm_alert(
1947 GTK_WINDOW(data
->window
),
1948 _("Reset all preferences"),
1949 _("Do you really want to reset all\npreferences to default values?"),
1952 if( result
== GTK_RESPONSE_OK
)
1954 homebank_pref_setdefault();
1961 // the window creation
1962 GtkWidget
*defpref_dialog_new (void)
1964 struct defpref_data data
;
1965 GtkWidget
*window
, *content
, *mainvbox
;
1966 GtkWidget
*hbox
, *vbox
, *sw
, *widget
, *notebook
, *page
, *ebox
, *image
, *label
;
1968 window
= gtk_dialog_new_with_buttons (_("Preferences"),
1969 GTK_WINDOW(GLOBALS
->mainwindow
),
1972 GTK_RESPONSE_REJECT
,
1974 GTK_RESPONSE_ACCEPT
,
1977 data
.window
= window
;
1979 //store our window private data
1980 g_object_set_data(G_OBJECT(window
), "inst_data", (gpointer
)&data
);
1982 gtk_window_set_icon_name(GTK_WINDOW (window
), ICONNAME_PREFERENCES
);
1984 content
= gtk_dialog_get_content_area(GTK_DIALOG (window
)); // return a vbox
1985 mainvbox
= gtk_box_new(GTK_ORIENTATION_VERTICAL
, SPACING_MEDIUM
);
1986 gtk_box_pack_start (GTK_BOX (content
), mainvbox
, TRUE
, TRUE
, 0);
1988 gtk_container_set_border_width(GTK_CONTAINER(mainvbox
), SPACING_MEDIUM
);
1990 hbox
= gtk_box_new(GTK_ORIENTATION_HORIZONTAL
, SPACING_MEDIUM
);
1991 gtk_box_pack_start (GTK_BOX (mainvbox
), hbox
, TRUE
, TRUE
, 0);
1994 vbox
= gtk_box_new(GTK_ORIENTATION_VERTICAL
, SPACING_SMALL
);
1995 gtk_box_pack_start (GTK_BOX (hbox
), vbox
, FALSE
, FALSE
, 0);
1998 sw
= gtk_scrolled_window_new (NULL
, NULL
);
1999 gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (sw
), GTK_SHADOW_ETCHED_IN
);
2000 gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (sw
), GTK_POLICY_NEVER
, GTK_POLICY_AUTOMATIC
);
2001 gtk_box_pack_start (GTK_BOX (vbox
), sw
, TRUE
, TRUE
, 0);
2002 widget
= pref_list_create();
2003 data
.LV_page
= widget
;
2004 gtk_container_add (GTK_CONTAINER (sw
), widget
);
2007 data
.BT_clear
= gtk_button_new_with_mnemonic(_("_Reset"));
2008 gtk_box_pack_start (GTK_BOX (vbox
), data
.BT_clear
, FALSE
, TRUE
, 0);
2011 //right part : notebook
2012 vbox
= gtk_box_new (GTK_ORIENTATION_VERTICAL
, SPACING_MEDIUM
);
2013 gtk_box_pack_start (GTK_BOX (hbox
), vbox
, TRUE
, TRUE
, 0);
2014 gtk_widget_show (vbox
);
2016 ebox
= gtk_event_box_new();
2017 gtk_widget_set_name(ebox
, "hbebox");
2018 GtkStyleContext
*context
= gtk_widget_get_style_context (ebox
);
2019 #if GTK_MINOR_VERSION <= 18
2020 gtk_style_context_add_class (context
, GTK_STYLE_CLASS_LIST_ROW
);
2021 gtk_widget_set_state_flags(ebox
, GTK_STATE_FLAG_SELECTED
, TRUE
);
2023 GtkCssProvider
*provider
;
2024 provider
= gtk_css_provider_new ();
2025 gtk_css_provider_load_from_data (provider
,
2026 "#hbebox { color: @theme_selected_fg_color; background-color: @theme_selected_bg_color; }"
2028 gtk_style_context_add_provider (context
, GTK_STYLE_PROVIDER(provider
), G_MAXUINT
);
2030 // gtk_style_context_set_state(context, GTK_STATE_FLAG_SELECTED);
2033 gtk_box_pack_start (GTK_BOX (vbox
), ebox
, FALSE
, TRUE
, 0);
2034 gtk_widget_show (ebox
);
2036 hbox
= gtk_box_new (GTK_ORIENTATION_HORIZONTAL
, SPACING_SMALL
);
2037 gtk_container_set_border_width (GTK_CONTAINER (hbox
), SPACING_SMALL
);
2038 gtk_container_add (GTK_CONTAINER (ebox
), hbox
);
2039 gtk_widget_show (hbox
);
2041 label
= gtk_label_new (NULL
);
2042 gtk_widget_set_margin_left(label
, SPACING_MEDIUM
);
2043 gimp_label_set_attributes (GTK_LABEL (label
),
2044 PANGO_ATTR_SCALE
, PANGO_SCALE_XX_LARGE
,
2045 PANGO_ATTR_WEIGHT
, PANGO_WEIGHT_BOLD
,
2048 gtk_box_pack_start (GTK_BOX (hbox
), label
, FALSE
, FALSE
, 0);
2049 gtk_widget_show (label
);
2052 image
= gtk_image_new ();
2053 gtk_box_pack_end (GTK_BOX (hbox
), image
, FALSE
, FALSE
, 0);
2054 gtk_widget_show (image
);
2060 notebook
= gtk_notebook_new();
2061 data
.GR_page
= notebook
;
2062 gtk_widget_show(notebook
);
2063 gtk_notebook_set_show_tabs(GTK_NOTEBOOK(notebook
), FALSE
);
2064 gtk_notebook_set_show_border(GTK_NOTEBOOK(notebook
), FALSE
);
2065 gtk_box_pack_start (GTK_BOX (vbox
), notebook
, TRUE
, TRUE
, 0);
2077 page
= defpref_page_general(&data
);
2078 gtk_notebook_append_page (GTK_NOTEBOOK (notebook
), page
, NULL
);
2081 page
= defpref_page_interface(&data
);
2082 gtk_notebook_append_page (GTK_NOTEBOOK (notebook
), page
, NULL
);
2085 page
= defpref_page_transactions(&data
);
2086 gtk_notebook_append_page (GTK_NOTEBOOK (notebook
), page
, NULL
);
2089 page
= defpref_page_display(&data
);
2090 gtk_notebook_append_page (GTK_NOTEBOOK (notebook
), page
, NULL
);
2093 page
= defpref_page_import(&data
);
2094 gtk_notebook_append_page (GTK_NOTEBOOK (notebook
), page
, NULL
);
2097 page
= defpref_page_reports(&data
);
2098 gtk_notebook_append_page (GTK_NOTEBOOK (notebook
), page
, NULL
);
2101 page
= defpref_page_euro(&data
);
2102 gtk_notebook_append_page (GTK_NOTEBOOK (notebook
), page
, NULL
);
2105 //todo:should move this
2106 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(data
.CM_euro_enable
), PREFS
->euro_active
);
2108 //connect all our signals
2109 g_signal_connect (window
, "destroy", G_CALLBACK (gtk_widget_destroyed
), &window
);
2111 g_signal_connect (G_OBJECT (data
.BT_clear
), "clicked", G_CALLBACK (defpref_clear
), NULL
);
2114 g_signal_connect (data
.BT_path_hbfile
, "pressed", G_CALLBACK (defpref_pathselect
), GINT_TO_POINTER(1));
2115 g_signal_connect (data
.BT_path_import
, "pressed", G_CALLBACK (defpref_pathselect
), GINT_TO_POINTER(2));
2116 g_signal_connect (data
.BT_path_export
, "pressed", G_CALLBACK (defpref_pathselect
), GINT_TO_POINTER(3));
2118 g_signal_connect (data
.CM_custom_colors
, "toggled", G_CALLBACK (defpref_colortoggle
), NULL
);
2119 g_signal_connect (data
.CY_colors
, "changed", G_CALLBACK (defpref_colorpreset
), NULL
);
2123 g_signal_connect (gtk_tree_view_get_selection(GTK_TREE_VIEW(data
.LV_page
)), "changed", G_CALLBACK (defpref_selection
), notebook
);
2125 g_signal_connect (data
.CM_euro_enable
, "toggled", G_CALLBACK (defpref_eurotoggle
), NULL
);
2127 g_signal_connect (data
.CY_euro_preset
, "changed", G_CALLBACK (defpref_europreset
), NULL
);
2130 g_signal_connect (data
.ST_datefmt
, "changed", G_CALLBACK (defpref_date_sample
), NULL
);
2133 g_signal_connect (data
.CY_color_scheme
, "changed", G_CALLBACK (defpref_color_scheme_changed
), NULL
);
2137 g_signal_connect (data
.ST_euro_symbol
, "changed", G_CALLBACK (defpref_numbereuro_sample
), NULL
);
2138 g_signal_connect (data
.CM_euro_isprefix
, "toggled", G_CALLBACK (defpref_numbereuro_sample
), NULL
);
2139 g_signal_connect (data
.ST_euro_decimalchar
, "changed", G_CALLBACK (defpref_numbereuro_sample
), NULL
);
2140 g_signal_connect (data
.ST_euro_groupingchar
, "changed", G_CALLBACK (defpref_numbereuro_sample
), NULL
);
2141 g_signal_connect (data
.NB_euro_fracdigits
, "value-changed", G_CALLBACK (defpref_numbereuro_sample
), NULL
);
2143 //g_signal_connect (data.BT_default, "pressed", G_CALLBACK (defpref_currency_change), NULL);
2146 //setup, init and show window
2147 //defhbfile_setup(&data);
2148 //defhbfile_update(data.LV_arc, NULL);
2152 defpref_colortoggle(window
, NULL
);
2153 defpref_eurotoggle(window
, NULL
);
2155 gtk_window_resize(GTK_WINDOW(window
), 640, 256);
2159 GtkTreePath
*path
= gtk_tree_path_new_first ();
2161 gtk_tree_selection_select_path (gtk_tree_view_get_selection(GTK_TREE_VIEW(data
.LV_page
)), path
);
2165 gtk_tree_path_free(path
);
2167 gtk_widget_show_all (window
);
2174 result
= gtk_dialog_run (GTK_DIALOG (window
));
2178 case GTK_RESPONSE_ACCEPT
:
2179 old_lang
= g_strdup(PREFS
->language
);
2181 homebank_pref_save();
2182 ui_mainwindow_update(GLOBALS
->mainwindow
, GINT_TO_POINTER(UF_BALANCE
+UF_VISUAL
));
2184 DB( g_print("old='%s' new='%s'\n", old_lang
, PREFS
->language
) );
2186 if(g_ascii_strncasecmp(old_lang
== NULL
? "" : old_lang
, PREFS
->language
== NULL
? "" : PREFS
->language
, -1) != 0)
2188 ui_dialog_msg_infoerror(GTK_WINDOW(window
), GTK_MESSAGE_INFO
,
2190 _("You will have to restart HomeBank\nfor the language change to take effect.")
2200 // cleanup and destroy
2201 //defhbfile_cleanup(&data, result);
2202 gtk_widget_destroy (window
);
2207 // -------------------------------
2210 static GtkWidget
*pref_list_create(void)
2212 GtkListStore
*store
;
2214 GtkCellRenderer
*renderer
;
2215 GtkTreeViewColumn
*column
;
2219 /* create list store */
2220 store
= gtk_list_store_new(
2228 view
= gtk_tree_view_new_with_model(GTK_TREE_MODEL(store
));
2229 g_object_unref(store
);
2231 gtk_tree_view_set_headers_visible(GTK_TREE_VIEW (view
), FALSE
);
2232 gtk_tree_selection_set_mode(gtk_tree_view_get_selection(GTK_TREE_VIEW(view
)), GTK_SELECTION_SINGLE
);
2234 /* column 1: icon */
2235 column
= gtk_tree_view_column_new();
2236 renderer
= gtk_cell_renderer_pixbuf_new ();
2237 g_object_set(renderer
, "stock-size", GTK_ICON_SIZE_DND
, NULL
);
2238 gtk_tree_view_column_pack_start(column
, renderer
, FALSE
);
2239 gtk_tree_view_column_set_attributes(column
, renderer
, "icon-name", LST_PREF_ICONNAME
, NULL
);
2241 renderer
= gtk_cell_renderer_text_new ();
2242 gtk_tree_view_column_pack_start(column
, renderer
, TRUE
);
2243 gtk_tree_view_column_set_attributes(column
, renderer
, "text", LST_PREF_NAME
, NULL
);
2245 gtk_tree_view_append_column (GTK_TREE_VIEW(view
), column
);
2247 //populate our combobox model
2248 for(i
=0;i
<PREF_MAX
;i
++)
2250 gtk_list_store_append(store
, &iter
);
2252 gtk_list_store_set(store
, &iter
,
2253 LST_PREF_ICONNAME
, pref_iconname
[i
],
2254 LST_PREF_NAME
, _(pref_name
[i
]),
2263 /* = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =*/
2266 extern gchar *list_txn_column_label[];
2270 list_txn_colpref_toggled_cell_data_function (GtkCellRendererToggle *cell,
2274 GtkTreeModel *model = (GtkTreeModel *)data;
2276 GtkTreePath *path = gtk_tree_path_new_from_string (path_str);
2280 gtk_tree_model_get_iter (model, &iter, path);
2281 gtk_tree_model_get (model, &iter, COLUMN_VISIBLE, &fixed, -1);
2283 // do something with the value
2287 gtk_list_store_set (GTK_LIST_STORE (model), &iter, COLUMN_VISIBLE, fixed, -1);
2290 gtk_tree_path_free (path);
2294 static void list_txn_colpref_get(GtkTreeView *treeview, gint *columns)
2296 GtkTreeModel *model;
2302 DB( g_print("[lst_txn-colpref] store column order \n") );
2304 model = gtk_tree_view_get_model(GTK_TREE_VIEW(treeview));
2305 valid = gtk_tree_model_get_iter_first(GTK_TREE_MODEL(model), &iter);
2309 gtk_tree_model_get(GTK_TREE_MODEL(model), &iter,
2310 COLUMN_VISIBLE, &visible,
2314 DB( g_print(" - column %d: %d\n",id, visible) );
2315 // start at index 2 (status, date always displayed
2316 columns[i+2] = visible == TRUE ? id : -id;
2318 // Make iter point to the next row in the list store
2319 valid = gtk_tree_model_iter_next(GTK_TREE_MODEL(model), &iter);
2325 GtkWidget *list_txn_colprefcreate(void)
2327 GtkListStore *store;
2329 GtkCellRenderer *renderer;
2330 GtkTreeViewColumn *column;
2334 DB( g_print("[lst_txn-colpref] create\n") );
2337 // create list store
2338 store = gtk_list_store_new(
2346 for(i=0 ; i < NUM_LST_DSPOPE-1; i++ ) //-1 cause account column avoid
2351 DB( g_print("eval %d, %s\n", i, list_txn_column_label[i]) );
2353 if(i <= LST_DSPOPE_DATE) // status, date always displayed
2356 //[i-1] here because lst_ope_columns[] do not store LST_DSPOPE_DATAS
2357 id = ABS(PREFS->lst_ope_columns[i-1]);
2358 if(id == 0) id = i; //if we pass here, new column or weird into pref file
2359 visible = (PREFS->lst_ope_columns[i-1] > 0) ? TRUE : FALSE;
2362 DB( g_print(" - pos=%2d, id=%2d - %d '%s'\n", i, id, visible, list_txn_column_label[id]) );
2364 gtk_list_store_append (store, &iter);
2365 gtk_list_store_set (store, &iter,
2366 COLUMN_VISIBLE, visible,
2367 COLUMN_NAME, _(list_txn_column_label[id]),
2374 view = gtk_tree_view_new_with_model(GTK_TREE_MODEL(store));
2375 g_object_unref(store);
2379 renderer = gtk_cell_renderer_toggle_new ();
2380 column = gtk_tree_view_column_new_with_attributes (_("Visible"),
2382 "active", COLUMN_VISIBLE,
2384 gtk_tree_view_append_column (GTK_TREE_VIEW(view), column);
2386 g_signal_connect (renderer, "toggled",
2387 G_CALLBACK (list_txn_colpref_toggled_cell_data_function), store);
2390 renderer = gtk_cell_renderer_text_new ();
2391 column = gtk_tree_view_column_new_with_attributes (_("Column"),
2393 "text", COLUMN_NAME,
2395 gtk_tree_view_append_column (GTK_TREE_VIEW(view), column);
2397 gtk_tree_view_set_reorderable (GTK_TREE_VIEW(view), TRUE);