1 /* HomeBank -- Free, easy, personal accounting for everyone.
2 * Copyright (C) 1995-2016 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
[];
153 //gchar *prefix_symbol; /* max symbol is 3 digits in unicode */
154 //gchar *suffix_symbol; /* but mostly is 1 digit */
158 gchar
*grouping_char
;
165 http://en.wikipedia.org/wiki/Currencies_of_the_European_Union
166 http://www.xe.com/euro.php
167 http://fr.wikipedia.org/wiki/Liste_des_unit%C3%A9s_mon%C3%A9taires_remplac%C3%A9es_par_l%27euro
168 http://www.inter-locale.com/LocalesDemo.jsp
170 static EuroParams euro_params
[] =
172 // , rate , symb , prfx , dec, grp, frac
173 // ---------------------------------------------------------------------
174 { "" , "--------" , 1.0 , "" , FALSE
, ",", ".", 2 },
175 { "ATS", "Austria" , 13.7603 , "S" , TRUE
, ",", ".", 2 }, // -S 1.234.567,89
176 { "BEF", "Belgium" , 40.3399 , "BF" , TRUE
, ",", ".", 2 }, // BF 1.234.567,89 -
177 { "FIM", "Finland" , 5.94573 , "mk" , FALSE
, ",", " ", 2 }, // -1 234 567,89 mk
178 { "FRF", "France" , 6.55957 , "F" , FALSE
, ",", " ", 2 }, // -1 234 567,89 F
179 { "DEM", "Germany" , 1.95583 , "DM" , FALSE
, ",", ".", 2 }, // -1.234.567,89 DM
180 { "GRD", "Greece" , 340.750 , "d" , TRUE
, ".", ",", 2 }, // ??
181 { "IEP", "Ireland" , 0.787564 , "£" , TRUE
, ".", ",", 2 }, // -£1,234,567.89
182 { "ITL", "Italy" , 1936.27 , "L" , TRUE
, "" , ".", 0 }, // L -1.234.567
183 { "LUF", "Luxembourg" , 40.3399 , "LU" , TRUE
, ",", ".", 2 }, // LU 1.234.567,89 -
184 { "NLG", "Netherlands" , 2.20371 , "F" , TRUE
, ",", ".", 2 }, // F 1.234.567,89-
185 { "PTE", "Portugal" , 200.482 , "Esc.", FALSE
, "$", ".", 2 }, // -1.234.567$89 Esc.
186 { "ESP", "Spain" , 166.386 , "Pts" , TRUE
, "" , ".", 0 }, // -Pts 1.234.567
188 { "SIT", "Slovenia" , 239.640 , "tol" , TRUE
, ",", ".", 2 }, //
190 { "CYP", "Cyprus" , 0.585274 , "£" , TRUE
, ",", "" , 2 }, //
191 { "MTL", "Malta" , 0.429300 , "Lm" , TRUE
, ",", "" , 2 }, //
193 { "SKK", "Slovaquia" , 30.12600 , "Sk" , FALSE
, ",", " ", 2 }, //
195 { "EEK", "Estonia" , 15.6466 , "kr" , FALSE
, ",", " ", 2 }, //
197 { "LVL", "Latvia" , 0.702804 , "lat.", FALSE
, ",", "" , 2 }, // jan. 2014
199 { "LTL", "Lithuania" , 3.45280 , "Lt." , TRUE
, ",", "" , 2 }, // jan. 2015
202 { "BGN", "Bulgaria" , 1.95583 , "лв." , TRUE
, ",", " ", 2 }, // non-fixé - 2014 target for euro
203 { "HUF", "Hungary" , 261.51 , "Ft" , TRUE
, ",", " ", 2 }, // non-fixé - No current target for euro
204 { "RON", "Romania" , 3.5155 , "Leu" , FALSE
, ",", ".", 2 }, // non-fixé - 2015 target for euro earliest
205 { "CZK", "Czech republic", 28.36 , "Kč" , FALSE
, ",", " ", 2 }, // non-fixé - 2015 earliest
206 { "HRK", "Croatia" , 1.0000 , "kn" , FALSE
, "" , ".", 0 }, // non-fixé - 2015 target for euro earliest
207 { "PLN", "Poland" , 0.25 , "zł" , FALSE
, ",", "" , 2 }, // non-fixé - No current target for euro
209 // { " ", "" , 1.00000 , "" , "" , FALSE, ",", "", 2 },
214 GtkWidget
*pref_list_create(void);
215 GtkWidget
*list_txn_colprefcreate(void);
217 static void list_txn_colpref_get(GtkTreeView
*treeview
, gboolean
*columns
);
223 /* = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =*/
231 static LangName languagenames
[] =
233 // 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
234 //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
237 { "ab", "Abkhazian" },
239 { "af", "Afrikaans" },
242 { "an", "Aragonese" },
244 { "as", "Assamese" },
245 { "ast", "Asturian, Bable, Leonese, Asturleonese" },
248 { "az", "Azerbaijani" },
250 { "be", "Belarusian" },
251 { "bg", "Bulgarian" },
261 { "ch", "Chamorro" },
262 { "co", "Corsican" },
265 { "cu", "Old Church Slavonic" },
271 { "dz", "Dzongkha" },
275 { "eo", "Esperanto" },
277 { "et", "Estonian" },
285 { "fy", "Western Frisian" },
287 { "gd", "Scottish Gaelic" },
288 { "gl", "Galician" },
290 { "gu", "Gujarati" },
295 { "ho", "Hiri Motu" },
296 { "hr", "Croatian" },
298 { "hu", "Hungarian" },
299 { "hy", "Armenian" },
301 { "ia", "Interlingua" },
302 { "id", "Indonesian" },
303 { "ie", "Interlingue" },
305 { "ii", "Sichuan Yi" },
308 { "is", "Icelandic" },
310 { "iu", "Inuktitut" },
311 { "ja", "Japanese" },
312 { "jv", "Javanese" },
313 { "ka", "Georgian" },
316 { "kj", "Kwanyama" },
318 { "kl", "Kalaallisut" },
323 { "ks", "Kashmiri" },
329 { "lb", "Luxembourgish" },
331 { "li", "Limburgish" },
334 { "lt", "Lithuanian" },
335 { "lu", "Luba-Katanga" },
337 { "mg", "Malagasy" },
338 { "mh", "Marshallese" },
340 { "mk", "Macedonian" },
341 { "ml", "Malayalam" },
342 { "mn", "Mongolian" },
343 { "mo", "Moldavian" },
349 { "nb", "Norwegian Bokmål" },
350 { "nd", "North Ndebele" },
351 { "nds", "Low German, Low Saxon" },
355 { "nn", "Norwegian Nynorsk" },
356 { "no", "Norwegian" },
357 { "nr", "South Ndebele" },
359 { "ny", "Chichewa" },
364 { "os", "Ossetian" },
369 { "pt", "Portuguese" },
373 { "ro", "Romanian" },
375 { "rw", "Kinyarwanda" },
376 { "sa", "Sanskrit" },
377 { "sc", "Sardinian" },
379 { "se", "Northern Sami" },
381 { "si", "Sinhalese" },
387 { "sq", "Albanian" },
391 { "su", "Sundanese" },
398 { "ti", "Tigrinya" },
407 { "ty", "Tahitian" },
409 { "uk", "Ukrainian" },
413 { "vi", "Viêt Namese" },
428 ui_language_combobox_compare_func (GtkTreeModel
*model
, GtkTreeIter
*a
, GtkTreeIter
*b
, gpointer userdata
)
431 gchar
*code1
, *code2
;
432 gchar
*name1
, *name2
;
434 gtk_tree_model_get(model
, a
, 0, &code1
, 1, &name1
, -1);
435 gtk_tree_model_get(model
, b
, 0, &code2
, 1, &name2
, -1);
437 //keep system laguage on top
438 if(code1
== NULL
) name1
= NULL
;
439 if(code2
== NULL
) name2
= NULL
;
441 retval
= hb_string_utf8_compare(name1
, name2
);
450 static gchar
*languagename_get(const gchar
*locale
)
454 for (i
= 0; i
< G_N_ELEMENTS (languagenames
); i
++)
456 if( g_ascii_strncasecmp(locale
, languagenames
[i
].locale
, -1) == 0 )
457 return languagenames
[i
].name
;
465 ui_language_combobox_get_name(const gchar
*locale
)
469 DB( g_print("[ui_language_combobox_get_name]\n") );
471 // A locale directory name is typically of the form language[_territory]
472 lang
= languagename_get (locale
);
475 const gchar
*delimiter
= strchr (locale
, '_'); // strip off the territory suffix
479 gchar
*copy
= g_strndup (locale
, delimiter
- locale
);
480 lang
= languagename_get (copy
);
486 g_warning(" locale name not found '%s'", locale
);
497 ui_language_combobox_populate(GtkWidget
*combobox
)
502 model
= gtk_combo_box_get_model(GTK_COMBO_BOX(combobox
));
503 gtk_list_store_append (GTK_LIST_STORE(model
), &iter
);
504 gtk_list_store_set (GTK_LIST_STORE(model
), &iter
,
506 1, _("System Language"),
509 GDir
*dir
= g_dir_open (homebank_app_get_locale_dir (), 0, NULL
);
510 const gchar
*dirname
;
515 while ((dirname
= g_dir_read_name (dir
)) != NULL
)
517 gchar
*filename
= g_build_filename (homebank_app_get_locale_dir (),
520 GETTEXT_PACKAGE
".mo",
522 //DB( g_print("- seek for '%s'\n", filename) );
523 if (g_file_test (filename
, G_FILE_TEST_EXISTS
))
528 gtk_list_store_append (GTK_LIST_STORE(model
), &iter
);
530 lang
= ui_language_combobox_get_name(dirname
);
531 label
= g_strdup_printf ("%s [%s]", lang
, dirname
);
533 gtk_list_store_set (GTK_LIST_STORE(model
), &iter
,
545 gtk_tree_sortable_set_sort_column_id(GTK_TREE_SORTABLE(model
), GTK_TREE_SORTABLE_DEFAULT_SORT_COLUMN_ID
, GTK_SORT_ASCENDING
);
552 ui_language_combobox_new(GtkWidget
*label
)
556 GtkCellRenderer
*renderer
;
558 store
= gtk_list_store_new (2,
562 gtk_tree_sortable_set_default_sort_func(GTK_TREE_SORTABLE(store
), ui_language_combobox_compare_func
, NULL
, NULL
);
564 combobox
= gtk_combo_box_new_with_model(GTK_TREE_MODEL(store
));
565 renderer
= gtk_cell_renderer_text_new ();
566 gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (combobox
), renderer
, TRUE
);
567 gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (combobox
), renderer
, "text", 1, NULL
);
569 gtk_combo_box_set_id_column( GTK_COMBO_BOX(combobox
), 0);
571 g_object_unref(store
);
574 gtk_label_set_mnemonic_widget (GTK_LABEL(label
), combobox
);
576 ui_language_combobox_populate(combobox
);
578 gtk_combo_box_set_active(GTK_COMBO_BOX(combobox
), 0);
584 /* = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =*/
585 /* = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =*/
586 /* = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =*/
592 static GtkWidget
*make_euro_presets(GtkWidget
*label
)
597 DB( g_print("\n[ui-pref] make euro preset\n") );
599 combobox
= gtk_combo_box_text_new();
600 for (i
= 0; i
< G_N_ELEMENTS (euro_params
); i
++)
602 gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(combobox
), euro_params
[i
].name
);
604 gtk_combo_box_set_active(GTK_COMBO_BOX(combobox
), 0);
607 gtk_label_set_mnemonic_widget (GTK_LABEL(label
), combobox
);
613 static void defpref_pathselect(GtkWidget
*widget
, gpointer user_data
)
615 struct defpref_data
*data
;
616 gint type
= GPOINTER_TO_INT(user_data
);
622 DB( g_print("\n[ui-pref] path select\n") );
624 data
= g_object_get_data(G_OBJECT(gtk_widget_get_ancestor(widget
, GTK_TYPE_WINDOW
)), "inst_data");
629 path
= &PREFS
->path_hbfile
;
630 entry
= data
->ST_path_hbfile
;
631 title
= _("Choose a default HomeBank files folder");
634 path
= &PREFS
->path_import
;
635 entry
= data
->ST_path_import
;
636 title
= _("Choose a default import folder");
639 path
= &PREFS
->path_export
;
640 entry
= data
->ST_path_export
;
641 title
= _("Choose a default export folder");
647 DB( g_print(" - hbfile %p %s at %p\n" , PREFS
->path_hbfile
, PREFS
->path_hbfile
, &PREFS
->path_hbfile
) );
648 DB( g_print(" - import %p %s at %p\n" , PREFS
->path_import
, PREFS
->path_import
, &PREFS
->path_import
) );
649 DB( g_print(" - export %p %s at %p\n" , PREFS
->path_export
, PREFS
->path_export
, &PREFS
->path_export
) );
652 DB( g_print(" - before: %s %p\n" , *path
, path
) );
654 r
= ui_file_chooser_folder(GTK_WINDOW(gtk_widget_get_ancestor(widget
, GTK_TYPE_WINDOW
)), title
, path
);
657 DB( g_print(" - after: %s\n", *path
) );
660 gtk_entry_set_text(GTK_ENTRY(entry
), *path
);
667 ** update the date sample label
669 static void defpref_date_sample(GtkWidget
*widget
, gpointer user_data
)
671 struct defpref_data
*data
;
676 DB( g_print("\n[ui-pref] date sample\n") );
678 data
= g_object_get_data(G_OBJECT(gtk_widget_get_ancestor(widget
, GTK_TYPE_WINDOW
)), "inst_data");
680 fmt
= gtk_entry_get_text(GTK_ENTRY(data
->ST_datefmt
));
681 date
= g_date_new_julian (GLOBALS
->today
);
682 g_date_strftime (buffer
, 256-1, fmt
, date
);
685 gtk_label_set_text(GTK_LABEL(data
->LB_date
), buffer
);
691 ** update the number sample label
693 static void defpref_numbereuro_sample(GtkWidget
*widget
, gpointer user_data
)
695 struct defpref_data
*data
;
697 gchar formatd_buf
[G_ASCII_DTOSTR_BUF_SIZE
];
700 DB( g_print("\n[ui-pref] number sample\n") );
702 data
= g_object_get_data(G_OBJECT(gtk_widget_get_ancestor(widget
, GTK_TYPE_WINDOW
)), "inst_data");
704 cur
.symbol
= (gchar
*)gtk_entry_get_text(GTK_ENTRY(data
->ST_euro_symbol
));
705 cur
.sym_prefix
= gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(data
->CM_euro_isprefix
));
706 cur
.decimal_char
= (gchar
*)gtk_entry_get_text(GTK_ENTRY(data
->ST_euro_decimalchar
));
707 cur
.grouping_char
= (gchar
*)gtk_entry_get_text(GTK_ENTRY(data
->ST_euro_groupingchar
));
708 cur
.frac_digits
= gtk_spin_button_get_value(GTK_SPIN_BUTTON(data
->NB_euro_fracdigits
));
710 da_cur_initformat (&cur
);
712 DB( g_print("fmt: %s\n", cur
.format
) );
714 g_ascii_formatd(formatd_buf
, sizeof (formatd_buf
), cur
.format
, HB_NUMBER_SAMPLE
);
715 hb_str_formatd(buf
, 127, formatd_buf
, &cur
, TRUE
);
717 gtk_label_set_text(GTK_LABEL(data
->LB_numbereuro
), buf
);
723 ** enable/disable euro
725 static void defpref_eurotoggle(GtkWidget
*widget
, gpointer user_data
)
727 struct defpref_data
*data
;
730 DB( g_print("\n[ui-pref] euro toggle\n") );
732 data
= g_object_get_data(G_OBJECT(gtk_widget_get_ancestor(widget
, GTK_TYPE_WINDOW
)), "inst_data");
734 sensitive
= gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(data
->CM_euro_enable
));
736 gtk_widget_set_sensitive(data
->GRP_currency
, sensitive
);
737 gtk_widget_set_sensitive(data
->GRP_rate
, sensitive
);
738 gtk_widget_set_sensitive(data
->GRP_format
, sensitive
);
743 ** set euro value widget from a country
745 static void defpref_eurosetcurrency(GtkWidget
*widget
, gpointer user_data
)
747 struct defpref_data
*data
;
748 EuroParams
*euro
= user_data
;
752 DB( g_print("\n[ui-pref] eurosetcurrency\n") );
754 data
= g_object_get_data(G_OBJECT(gtk_widget_get_ancestor(widget
, GTK_TYPE_WINDOW
)), "inst_data");
756 buf
= g_strdup_printf("%s - %s", euro
->iso
, euro
->name
);
758 gtk_label_set_markup(GTK_LABEL(data
->ST_euro_country
), buf
);
766 ** set euro value widget from a country
768 static void defpref_europreset(GtkWidget
*widget
, gpointer user_data
)
770 struct defpref_data
*data
;
773 DB( g_print("\n[ui-pref] euro preset\n") );
775 data
= g_object_get_data(G_OBJECT(gtk_widget_get_ancestor(widget
, GTK_TYPE_WINDOW
)), "inst_data");
777 country
= gtk_combo_box_get_active(GTK_COMBO_BOX(data
->CY_euro_preset
));
778 data
->country
= country
;
780 defpref_eurosetcurrency(widget
, &euro_params
[country
]);
782 gtk_spin_button_set_value(GTK_SPIN_BUTTON(data
->NB_euro_value
), euro_params
[country
].value
);
784 gtk_spin_button_set_value(GTK_SPIN_BUTTON(data
->NB_euro_fracdigits
), euro_params
[country
].frac_digits
);
786 gtk_entry_set_text(GTK_ENTRY(data
->ST_euro_symbol
) , euro_params
[country
].symbol
);
787 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(data
->CM_euro_isprefix
), euro_params
[country
].sym_prefix
);
788 gtk_entry_set_text(GTK_ENTRY(data
->ST_euro_decimalchar
) , euro_params
[country
].decimal_char
);
789 gtk_entry_set_text(GTK_ENTRY(data
->ST_euro_groupingchar
), euro_params
[country
].grouping_char
);
794 static void defpref_colortoggle(GtkWidget
*widget
, gpointer user_data
)
796 struct defpref_data
*data
;
799 DB( g_print("\n[ui-pref] color toggle\n") );
801 data
= g_object_get_data(G_OBJECT(gtk_widget_get_ancestor(widget
, GTK_TYPE_WINDOW
)), "inst_data");
803 sensitive
= gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(data
->CM_custom_colors
));
805 gtk_widget_set_sensitive(data
->GR_colors
, sensitive
);
811 ** set preset colors for amount display
813 static void defpref_colorpreset(GtkWidget
*widget
, gpointer user_data
)
815 struct defpref_data
*data
;
818 gchar
*expcol
, *inccol
, *wrncol
;
820 DB( g_print("\n[ui-pref] color preset\n") );
822 data
= g_object_get_data(G_OBJECT(gtk_widget_get_ancestor(widget
, GTK_TYPE_WINDOW
)), "inst_data");
824 preset
= gtk_combo_box_get_active(GTK_COMBO_BOX(data
->CY_colors
));
829 expcol
= LIGHT_EXP_COLOR
;
830 inccol
= LIGHT_INC_COLOR
;
831 wrncol
= LIGHT_WARN_COLOR
;
835 expcol
= MEDIUM_EXP_COLOR
;
836 inccol
= MEDIUM_INC_COLOR
;
837 wrncol
= MEDIUM_WARN_COLOR
;
842 expcol
= DEFAULT_EXP_COLOR
;
843 inccol
= DEFAULT_INC_COLOR
;
844 wrncol
= DEFAULT_WARN_COLOR
;
849 gdk_rgba_parse(&rgba
, expcol
);
850 gtk_color_chooser_set_rgba(GTK_COLOR_CHOOSER(data
->CP_exp_color
), &rgba
);
852 gdk_rgba_parse(&rgba
, inccol
);
853 gtk_color_chooser_set_rgba(GTK_COLOR_CHOOSER(data
->CP_inc_color
), &rgba
);
855 gdk_rgba_parse(&rgba
, wrncol
);
856 gtk_color_chooser_set_rgba(GTK_COLOR_CHOOSER(data
->CP_warn_color
), &rgba
);
862 static void defpref_color_scheme_changed(GtkWidget
*widget
, gpointer user_data
)
864 struct defpref_data
*data
;
866 DB( g_print("\n[ui-pref] color scheme chnaged\n") );
868 data
= g_object_get_data(G_OBJECT(gtk_widget_get_ancestor(widget
, GTK_TYPE_WINDOW
)), "inst_data");
870 gtk_widget_queue_draw (data
->DA_colors
);
878 static void setGdkColor_from_RGB(GdkColor *color, guint32 value)
883 color->red = tmp | tmp<<8;
885 tmp = value >> 8 & 0xFF;
886 color->green = tmp | tmp<<8;
889 color->blue = tmp | tmp<<8;
895 ** set :: fill in widgets from PREFS structure
898 static void defpref_set(struct defpref_data
*data
)
902 DB( g_print("\n[ui-pref] set\n") );
904 if(PREFS
->language
!= NULL
)
905 gtk_combo_box_set_active_id(GTK_COMBO_BOX(data
->CY_language
), PREFS
->language
);
907 gtk_combo_box_set_active (GTK_COMBO_BOX(data
->CY_language
), 0);
909 gtk_combo_box_set_active(GTK_COMBO_BOX(data
->CY_toolbar
), PREFS
->toolbar_style
);
910 //gtk_spin_button_set_value(GTK_SPIN_BUTTON(data->NB_image_size), PREFS->image_size);
912 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(data
->CM_custom_colors
), PREFS
->custom_colors
);
914 gdk_rgba_parse(&rgba
, PREFS
->color_exp
);
915 gtk_color_chooser_set_rgba(GTK_COLOR_CHOOSER(data
->CP_exp_color
), &rgba
);
917 gdk_rgba_parse(&rgba
, PREFS
->color_inc
);
918 gtk_color_chooser_set_rgba(GTK_COLOR_CHOOSER(data
->CP_inc_color
), &rgba
);
920 gdk_rgba_parse(&rgba
, PREFS
->color_warn
);
921 gtk_color_chooser_set_rgba(GTK_COLOR_CHOOSER(data
->CP_warn_color
), &rgba
);
923 //gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(data->CM_ruleshint), PREFS->rules_hint);
924 gtk_combo_box_set_active(GTK_COMBO_BOX(data
->CY_gridlines
), PREFS
->grid_lines
);
926 gtk_spin_button_set_value(GTK_SPIN_BUTTON(data
->NB_fiscyearday
), PREFS
->fisc_year_day
);
927 gtk_combo_box_set_active(GTK_COMBO_BOX(data
->CY_fiscyearmonth
), PREFS
->fisc_year_month
- 1);
929 gtk_entry_set_text(GTK_ENTRY(data
->ST_path_hbfile
), PREFS
->path_hbfile
);
930 gtk_entry_set_text(GTK_ENTRY(data
->ST_path_import
), PREFS
->path_import
);
931 gtk_entry_set_text(GTK_ENTRY(data
->ST_path_export
), PREFS
->path_export
);
932 //gtk_entry_set_text(GTK_ENTRY(data->ST_path_navigator), PREFS->path_navigator);
934 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(data
->CM_load_last
), PREFS
->loadlast
);
935 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(data
->CM_append_scheduled
), PREFS
->appendscheduled
);
936 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(data
->CM_do_update_currency
), PREFS
->do_update_currency
);
937 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(data
->CM_show_splash
), PREFS
->showsplash
);
938 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(data
->CM_herit_date
), PREFS
->heritdate
);
939 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(data
->CM_hide_reconciled
), PREFS
->hidereconciled
);
940 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(data
->CM_show_remind
), PREFS
->showremind
);
943 gtk_entry_set_text(GTK_ENTRY(data
->ST_datefmt
), PREFS
->date_format
);
945 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(data
->CM_unitismile
), PREFS
->vehicle_unit_ismile
);
946 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(data
->CM_unitisgal
), PREFS
->vehicle_unit_isgal
);
948 gtk_combo_box_set_active(GTK_COMBO_BOX(data
->CY_daterange_wal
), PREFS
->date_range_wal
);
949 gtk_combo_box_set_active(GTK_COMBO_BOX(data
->CY_daterange_txn
), PREFS
->date_range_txn
);
950 gtk_spin_button_set_value(GTK_SPIN_BUTTON(data
->ST_datefuture_nbdays
), PREFS
->date_future_nbdays
);
951 gtk_combo_box_set_active(GTK_COMBO_BOX(data
->CY_daterange_rep
), PREFS
->date_range_rep
);
954 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(data
->CM_euro_enable
), PREFS
->euro_active
);
955 //gtk_combo_box_set_active(GTK_COMBO_BOX(data->CY_euro_preset), PREFS->euro_country);
957 data
->country
= PREFS
->euro_country
;
958 defpref_eurosetcurrency(data
->window
, &euro_params
[PREFS
->euro_country
]);
960 gtk_spin_button_set_value(GTK_SPIN_BUTTON(data
->NB_euro_value
), PREFS
->euro_value
);
962 ui_gtk_entry_set_text(data
->ST_euro_symbol
, PREFS
->minor_cur
.symbol
);
963 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(data
->CM_euro_isprefix
), PREFS
->minor_cur
.sym_prefix
);
964 ui_gtk_entry_set_text(data
->ST_euro_decimalchar
, PREFS
->minor_cur
.decimal_char
);
965 ui_gtk_entry_set_text(data
->ST_euro_groupingchar
, PREFS
->minor_cur
.grouping_char
);
966 gtk_spin_button_set_value(GTK_SPIN_BUTTON(data
->NB_euro_fracdigits
), PREFS
->minor_cur
.frac_digits
);
969 //gtk_entry_set_text(GTK_ENTRY(data->ST_euro_symbol), PREFS->euro_symbol);
970 //gtk_spin_button_set_value(GTK_SPIN_BUTTON(data->NB_euro_nbdec), PREFS->euro_nbdec);
971 //gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(data->CM_euro_thsep), PREFS->euro_thsep);
973 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(data
->CM_stat_byamount
), PREFS
->stat_byamount
);
974 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(data
->CM_stat_showrate
), PREFS
->stat_showrate
);
975 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(data
->CM_stat_showdetail
), PREFS
->stat_showdetail
);
977 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(data
->CM_budg_showdetail
), PREFS
->budg_showdetail
);
979 gtk_combo_box_set_active(GTK_COMBO_BOX(data
->CY_color_scheme
), PREFS
->report_color_scheme
);
982 gtk_combo_box_set_active(GTK_COMBO_BOX(data
->CY_dtex_datefmt
), PREFS
->dtex_datefmt
);
983 gtk_combo_box_set_active(GTK_COMBO_BOX(data
->CY_dtex_ofxname
), PREFS
->dtex_ofxname
);
984 gtk_combo_box_set_active(GTK_COMBO_BOX(data
->CY_dtex_ofxmemo
), PREFS
->dtex_ofxmemo
);
985 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(data
->CM_dtex_qifmemo
), PREFS
->dtex_qifmemo
);
986 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(data
->CM_dtex_qifswap
), PREFS
->dtex_qifswap
);
993 ** get :: fill PREFS structure from widgets
996 #define RGBA_TO_INT(x) (int)(x*255)
998 static gchar
*gdk_rgba_to_hex(GdkRGBA
*rgba
)
1000 return g_strdup_printf("#%02x%02x%02x", RGBA_TO_INT(rgba
->red
), RGBA_TO_INT(rgba
->green
), RGBA_TO_INT(rgba
->blue
));
1004 static void defpref_get(struct defpref_data
*data
)
1009 DB( g_print("\n[ui-pref] get\n") );
1011 g_free(PREFS
->language
);
1012 PREFS
->language
= NULL
;
1013 lang
= gtk_combo_box_get_active_id(GTK_COMBO_BOX(data
->CY_language
));
1016 PREFS
->language
= g_strdup(lang
);
1019 PREFS
->toolbar_style
= gtk_combo_box_get_active(GTK_COMBO_BOX(data
->CY_toolbar
));
1020 //PREFS->image_size = gtk_spin_button_get_value(GTK_SPIN_BUTTON(data->NB_image_size));
1022 PREFS
->custom_colors
= gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(data
->CM_custom_colors
));
1024 gtk_color_chooser_get_rgba(GTK_COLOR_CHOOSER(data
->CP_exp_color
), &rgba
);
1025 g_free(PREFS
->color_exp
);
1026 PREFS
->color_exp
= gdk_rgba_to_hex(&rgba
);
1028 gtk_color_chooser_get_rgba(GTK_COLOR_CHOOSER(data
->CP_inc_color
), &rgba
);
1029 g_free(PREFS
->color_inc
);
1030 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
);
1036 //PREFS->rules_hint = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(data->CM_ruleshint));
1037 PREFS
->grid_lines
= gtk_combo_box_get_active(GTK_COMBO_BOX(data
->CY_gridlines
));
1039 PREFS
->fisc_year_day
= gtk_spin_button_get_value(GTK_SPIN_BUTTON(data
->NB_fiscyearday
));
1040 PREFS
->fisc_year_month
= 1 + gtk_combo_box_get_active(GTK_COMBO_BOX(data
->CY_fiscyearmonth
));
1042 list_txn_colpref_get(GTK_TREE_VIEW(data
->LV_opecolumns
), PREFS
->lst_ope_columns
);
1044 g_free(PREFS
->path_hbfile
);
1045 PREFS
->path_hbfile
= g_strdup(gtk_entry_get_text(GTK_ENTRY(data
->ST_path_hbfile
)));
1047 ui_gtk_entry_replace_text(data
->ST_path_import
, &PREFS
->path_import
);
1049 ui_gtk_entry_replace_text(data
->ST_path_export
, &PREFS
->path_export
);
1051 PREFS
->loadlast
= gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(data
->CM_load_last
));
1052 PREFS
->appendscheduled
= gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(data
->CM_append_scheduled
));
1053 PREFS
->do_update_currency
= gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(data
->CM_do_update_currency
));
1055 PREFS
->showsplash
= gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(data
->CM_show_splash
));
1056 PREFS
->heritdate
= gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(data
->CM_herit_date
));
1057 PREFS
->hidereconciled
= gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(data
->CM_hide_reconciled
));
1058 PREFS
->showremind
= gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(data
->CM_show_remind
));
1060 //g_free(PREFS->path_navigator);
1061 //PREFS->path_navigator = g_strdup(gtk_entry_get_text(GTK_ENTRY(data->ST_path_navigator)));
1063 g_free(PREFS
->date_format
);
1064 PREFS
->date_format
= g_strdup(gtk_entry_get_text(GTK_ENTRY(data
->ST_datefmt
)));
1066 PREFS
->vehicle_unit_ismile
= gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(data
->CM_unitismile
));
1067 PREFS
->vehicle_unit_isgal
= gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(data
->CM_unitisgal
));
1069 PREFS
->date_range_wal
= gtk_combo_box_get_active(GTK_COMBO_BOX(data
->CY_daterange_wal
));
1070 PREFS
->date_range_txn
= gtk_combo_box_get_active(GTK_COMBO_BOX(data
->CY_daterange_txn
));
1071 PREFS
->date_future_nbdays
= gtk_spin_button_get_value(GTK_SPIN_BUTTON(data
->ST_datefuture_nbdays
));
1072 PREFS
->date_range_rep
= gtk_combo_box_get_active(GTK_COMBO_BOX(data
->CY_daterange_rep
));
1074 PREFS
->euro_active
= gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(data
->CM_euro_enable
));
1076 PREFS
->euro_country
= data
->country
;
1077 PREFS
->euro_value
= gtk_spin_button_get_value(GTK_SPIN_BUTTON(data
->NB_euro_value
));
1078 //strcpy(PREFS->euro_symbol, gtk_entry_get_text(GTK_ENTRY(data->ST_euro_symbol)));
1079 //PREFS->euro_nbdec = gtk_spin_button_get_value(GTK_SPIN_BUTTON(data->NB_euro_nbdec));
1080 //PREFS->euro_thsep = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(data->CM_euro_thsep));
1082 ui_gtk_entry_replace_text(data
->ST_euro_symbol
, &PREFS
->minor_cur
.symbol
);
1083 PREFS
->minor_cur
.sym_prefix
= gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(data
->CM_euro_isprefix
));
1084 ui_gtk_entry_replace_text(data
->ST_euro_decimalchar
, &PREFS
->minor_cur
.decimal_char
);
1085 ui_gtk_entry_replace_text(data
->ST_euro_groupingchar
, &PREFS
->minor_cur
.grouping_char
);
1086 PREFS
->minor_cur
.frac_digits
= gtk_spin_button_get_value(GTK_SPIN_BUTTON(data
->NB_euro_fracdigits
));
1088 PREFS
->stat_byamount
= gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(data
->CM_stat_byamount
));
1089 PREFS
->stat_showrate
= gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(data
->CM_stat_showrate
));
1090 PREFS
->stat_showdetail
= gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(data
->CM_stat_showdetail
));
1092 PREFS
->budg_showdetail
= gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(data
->CM_budg_showdetail
));
1094 PREFS
->report_color_scheme
= gtk_combo_box_get_active(GTK_COMBO_BOX(data
->CY_color_scheme
));
1097 PREFS
->dtex_datefmt
= gtk_combo_box_get_active(GTK_COMBO_BOX(data
->CY_dtex_datefmt
));
1098 PREFS
->dtex_ofxname
= gtk_combo_box_get_active(GTK_COMBO_BOX(data
->CY_dtex_ofxname
));
1099 PREFS
->dtex_ofxmemo
= gtk_combo_box_get_active(GTK_COMBO_BOX(data
->CY_dtex_ofxmemo
));
1100 PREFS
->dtex_qifmemo
= gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(data
->CM_dtex_qifmemo
));
1101 PREFS
->dtex_qifswap
= gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(data
->CM_dtex_qifswap
));
1103 //PREFS->chart_legend = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(data->CM_chartlegend));
1108 static GtkWidget
*defpref_page_import (struct defpref_data
*data
)
1110 GtkWidget
*content_grid
, *group_grid
, *hbox
, *label
, *widget
;
1113 content_grid
= gtk_grid_new();
1114 gtk_grid_set_row_spacing (GTK_GRID (content_grid
), SPACING_LARGE
);
1115 gtk_orientable_set_orientation(GTK_ORIENTABLE(content_grid
), GTK_ORIENTATION_VERTICAL
);
1118 // group :: Date options
1119 group_grid
= gtk_grid_new ();
1120 gtk_grid_set_row_spacing (GTK_GRID (group_grid
), SPACING_SMALL
);
1121 gtk_grid_set_column_spacing (GTK_GRID (group_grid
), SPACING_MEDIUM
);
1122 gtk_grid_attach (GTK_GRID (content_grid
), group_grid
, 0, crow
++, 1, 1);
1124 label
= make_label_group(_("Date options"));
1125 gtk_grid_attach (GTK_GRID (group_grid
), label
, 0, 0, 3, 1);
1128 label
= make_label_widget(_("Date order:"));
1129 //----------------------------------------- l, r, t, b
1130 gtk_grid_attach (GTK_GRID (group_grid
), label
, 1, row
, 1, 1);
1131 widget
= make_cycle(label
, CYA_IMPORT_DATEORDER
);
1132 data
->CY_dtex_datefmt
= widget
;
1133 //gtk_grid_attach (GTK_GRID (group_grid), data->CY_option[FILTER_DATE], 1, 2, row, row+1);
1134 gtk_grid_attach (GTK_GRID (group_grid
), widget
, 2, row
, 1, 1);
1137 // group :: OFX/QFX options
1138 group_grid
= gtk_grid_new ();
1139 gtk_grid_set_row_spacing (GTK_GRID (group_grid
), SPACING_SMALL
);
1140 gtk_grid_set_column_spacing (GTK_GRID (group_grid
), SPACING_MEDIUM
);
1141 gtk_grid_attach (GTK_GRID (content_grid
), group_grid
, 0, crow
++, 1, 1);
1143 label
= make_label_group(_("OFX/QFX options"));
1144 gtk_grid_attach (GTK_GRID (group_grid
), label
, 0, 0, 3, 1);
1147 label
= make_label_widget(_("_Name field:"));
1148 //----------------------------------------- l, r, t, b
1149 gtk_grid_attach (GTK_GRID (group_grid
), label
, 1, row
, 1, 1);
1150 widget
= make_cycle(label
, CYA_IMPORT_OFXNAME
);
1151 data
->CY_dtex_ofxname
= widget
;
1152 //gtk_grid_attach (GTK_GRID (group_grid), data->CY_option[FILTER_DATE], 1, 2, row, row+1);
1153 gtk_grid_attach (GTK_GRID (group_grid
), widget
, 2, row
, 1, 1);
1156 label
= make_label_widget(_("_Memo field:"));
1157 //----------------------------------------- l, r, t, b
1158 gtk_grid_attach (GTK_GRID (group_grid
), label
, 1, row
, 1, 1);
1159 widget
= make_cycle(label
, CYA_IMPORT_OFXMEMO
);
1160 data
->CY_dtex_ofxmemo
= widget
;
1161 //gtk_grid_attach (GTK_GRID (group_grid), data->CY_option[FILTER_DATE], 1, 2, row, row+1);
1162 gtk_grid_attach (GTK_GRID (group_grid
), widget
, 2, row
, 1, 1);
1164 // group :: QIF options
1165 group_grid
= gtk_grid_new ();
1166 gtk_grid_set_row_spacing (GTK_GRID (group_grid
), SPACING_SMALL
);
1167 gtk_grid_set_column_spacing (GTK_GRID (group_grid
), SPACING_MEDIUM
);
1168 gtk_grid_attach (GTK_GRID (content_grid
), group_grid
, 0, crow
++, 1, 1);
1170 label
= make_label_group(_("QIF options"));
1171 gtk_grid_attach (GTK_GRID (group_grid
), label
, 0, 0, 3, 1);
1174 label
= make_label_widget(_("Memos:"));
1175 gtk_grid_attach (GTK_GRID (group_grid
), label
, 1, row
, 1, 1);
1176 widget
= gtk_check_button_new_with_mnemonic (_("_Import"));
1177 data
->CM_dtex_qifmemo
= widget
;
1178 gtk_grid_attach (GTK_GRID (group_grid
), widget
, 2, row
, 1, 1);
1179 widget
= gtk_check_button_new_with_mnemonic (_("_Swap with payees"));
1180 data
->CM_dtex_qifswap
= widget
;
1181 gtk_grid_attach (GTK_GRID (group_grid
), widget
, 3, row
, 1, 1);
1184 // group :: Files folder
1185 group_grid
= gtk_grid_new ();
1186 gtk_grid_set_row_spacing (GTK_GRID (group_grid
), SPACING_SMALL
);
1187 gtk_grid_set_column_spacing (GTK_GRID (group_grid
), SPACING_MEDIUM
);
1188 gtk_grid_attach (GTK_GRID (content_grid
), group_grid
, 0, crow
++, 1, 1);
1190 label
= make_label_group(_("Files folder"));
1191 gtk_grid_attach (GTK_GRID (group_grid
), label
, 0, 0, 3, 1);
1194 label
= make_label_widget(_("_Import:"));
1195 //----------------------------------------- l, r, t, b
1196 gtk_grid_attach (GTK_GRID (group_grid
), label
, 1, row
, 1, 1);
1198 hbox
= gtk_box_new(GTK_ORIENTATION_HORIZONTAL
, 0);
1199 gtk_widget_set_hexpand (hbox
, TRUE
);
1200 gtk_grid_attach (GTK_GRID (group_grid
), hbox
, 2, row
, 1, 1);
1202 widget
= make_string(label
);
1203 data
->ST_path_import
= widget
;
1204 gtk_style_context_add_class (gtk_widget_get_style_context (GTK_WIDGET(widget
)), GTK_STYLE_CLASS_LINKED
);
1205 gtk_box_pack_start (GTK_BOX (hbox
), widget
, TRUE
, TRUE
, 0);
1207 //widget = gtk_button_new_with_label("...");
1208 widget
= gtk_button_new_from_icon_name(ICONNAME_FOLDER
, GTK_ICON_SIZE_BUTTON
);
1209 data
->BT_path_import
= widget
;
1210 gtk_box_pack_start (GTK_BOX (hbox
), widget
, FALSE
, FALSE
, 0);
1213 label
= make_label_widget(_("_Export:"));
1214 //----------------------------------------- l, r, t, b
1215 gtk_grid_attach (GTK_GRID (group_grid
), label
, 1, row
, 1, 1);
1217 hbox
= gtk_box_new(GTK_ORIENTATION_HORIZONTAL
, 0);
1218 gtk_widget_set_hexpand (hbox
, TRUE
);
1219 gtk_grid_attach (GTK_GRID (group_grid
), hbox
, 2, row
, 1, 1);
1221 widget
= make_string(label
);
1222 data
->ST_path_export
= widget
;
1223 gtk_style_context_add_class (gtk_widget_get_style_context (GTK_WIDGET(widget
)), GTK_STYLE_CLASS_LINKED
);
1224 gtk_box_pack_start (GTK_BOX (hbox
), widget
, TRUE
, TRUE
, 0);
1226 //widget = gtk_button_new_with_label("...");
1227 widget
= gtk_button_new_from_icon_name(ICONNAME_FOLDER
, GTK_ICON_SIZE_BUTTON
);
1228 data
->BT_path_export
= widget
;
1229 gtk_box_pack_start (GTK_BOX (hbox
), widget
, FALSE
, FALSE
, 0);
1231 return content_grid
;
1237 draw_callback (GtkWidget
*widget
,
1241 struct defpref_data
*data
= user_data
;
1243 GtkColorScheme scheme
;
1247 index
= gtk_combo_box_get_active(GTK_COMBO_BOX(data
->CY_color_scheme
));
1249 colorscheme_init(&scheme
, index
);
1251 gtk_widget_get_size_request (widget
, &w
, &h
);
1253 for(i
=0;i
<scheme
.nb_cols
;i
++)
1255 cairo_user_set_rgbcol (cr
, &scheme
.colors
[i
]);
1256 cairo_rectangle(cr
, x
, y
, cube_dim
, cube_dim
);
1260 { x
= 0; y
= 1 + cube_dim
; }
1268 static GtkWidget
*defpref_page_reports (struct defpref_data
*data
)
1270 GtkWidget
*content_grid
, *group_grid
, *label
, *widget
;
1273 content_grid
= gtk_grid_new();
1274 gtk_grid_set_row_spacing (GTK_GRID (content_grid
), SPACING_LARGE
);
1275 gtk_orientable_set_orientation(GTK_ORIENTABLE(content_grid
), GTK_ORIENTATION_VERTICAL
);
1278 // group :: Initial filter
1279 group_grid
= gtk_grid_new ();
1280 gtk_grid_set_row_spacing (GTK_GRID (group_grid
), SPACING_SMALL
);
1281 gtk_grid_set_column_spacing (GTK_GRID (group_grid
), SPACING_MEDIUM
);
1282 gtk_grid_attach (GTK_GRID (content_grid
), group_grid
, 0, crow
++, 1, 1);
1284 label
= make_label_group(_("Initial filter"));
1285 gtk_grid_attach (GTK_GRID (group_grid
), label
, 0, 0, 3, 1);
1288 label
= make_label_widget(_("Date _range:"));
1289 //----------------------------------------- l, r, t, b
1290 gtk_grid_attach (GTK_GRID (group_grid
), label
, 1, row
, 1, 1);
1291 widget
= make_daterange(label
, FALSE
);
1292 data
->CY_daterange_rep
= widget
;
1293 //gtk_grid_attach (GTK_GRID (group_grid), data->CY_option[FILTER_DATE], 1, 2, row, row+1);
1294 gtk_grid_attach (GTK_GRID (group_grid
), widget
, 2, row
, 1, 1);
1296 // group ::Charts options
1297 group_grid
= gtk_grid_new ();
1298 gtk_grid_set_row_spacing (GTK_GRID (group_grid
), SPACING_SMALL
);
1299 gtk_grid_set_column_spacing (GTK_GRID (group_grid
), SPACING_MEDIUM
);
1300 gtk_grid_attach (GTK_GRID (content_grid
), group_grid
, 0, crow
++, 1, 1);
1302 label
= make_label_group(_("Charts options"));
1303 gtk_grid_attach (GTK_GRID (group_grid
), label
, 0, 0, 3, 1);
1306 label
= make_label_widget(_("Color scheme:"));
1307 //----------------------------------------- l, r, t, b
1308 gtk_grid_attach (GTK_GRID (group_grid
), label
, 1, row
, 1, 1);
1309 widget
= make_cycle(label
, chart_colors
);
1310 data
->CY_color_scheme
= widget
;
1311 //gtk_grid_attach (GTK_GRID (group_grid), data->CY_option[FILTER_DATE], 1, 2, row, row+1);
1312 gtk_grid_attach (GTK_GRID (group_grid
), widget
, 2, row
, 1, 1);
1315 widget
= gtk_drawing_area_new ();
1316 data
->DA_colors
= widget
;
1317 gtk_widget_set_size_request (widget
, (1+cube_dim
)*16, (1+cube_dim
)*2);
1318 gtk_grid_attach (GTK_GRID (group_grid
), widget
, 2, row
, 1, 1);
1320 g_signal_connect (data
->DA_colors
, "draw", G_CALLBACK (draw_callback
), data
);
1322 // group :: Statistics options
1323 group_grid
= gtk_grid_new ();
1324 gtk_grid_set_row_spacing (GTK_GRID (group_grid
), SPACING_SMALL
);
1325 gtk_grid_set_column_spacing (GTK_GRID (group_grid
), SPACING_MEDIUM
);
1326 gtk_grid_attach (GTK_GRID (content_grid
), group_grid
, 0, crow
++, 1, 1);
1328 label
= make_label_group(_("Statistics options"));
1329 gtk_grid_attach (GTK_GRID (group_grid
), label
, 0, 0, 3, 1);
1332 widget
= gtk_check_button_new_with_mnemonic (_("Show by _amount"));
1333 data
->CM_stat_byamount
= widget
;
1334 gtk_grid_attach (GTK_GRID (group_grid
), widget
, 1, row
, 2, 1);
1337 widget
= gtk_check_button_new_with_mnemonic (_("Show _rate column"));
1338 data
->CM_stat_showrate
= widget
;
1339 gtk_grid_attach (GTK_GRID (group_grid
), widget
, 1, row
, 2, 1);
1342 widget
= gtk_check_button_new_with_mnemonic (_("Show _details"));
1343 data
->CM_stat_showdetail
= widget
;
1344 gtk_grid_attach (GTK_GRID (group_grid
), widget
, 1, row
, 2, 1);
1346 // group :: Budget options
1347 group_grid
= gtk_grid_new ();
1348 gtk_grid_set_row_spacing (GTK_GRID (group_grid
), SPACING_SMALL
);
1349 gtk_grid_set_column_spacing (GTK_GRID (group_grid
), SPACING_MEDIUM
);
1350 gtk_grid_attach (GTK_GRID (content_grid
), group_grid
, 0, crow
++, 1, 1);
1352 label
= make_label_group(_("Budget options"));
1353 gtk_grid_attach (GTK_GRID (group_grid
), label
, 0, 0, 3, 1);
1356 widget
= gtk_check_button_new_with_mnemonic (_("Show _details"));
1357 data
->CM_budg_showdetail
= widget
;
1358 gtk_grid_attach (GTK_GRID (group_grid
), widget
, 1, row
, 2, 1);
1360 return content_grid
;
1364 static GtkWidget
*defpref_page_euro (struct defpref_data
*data
)
1366 GtkWidget
*content_grid
, *group_grid
, *label
, *widget
, *expander
;
1369 content_grid
= gtk_grid_new();
1370 gtk_grid_set_row_spacing (GTK_GRID (content_grid
), SPACING_LARGE
);
1371 gtk_orientable_set_orientation(GTK_ORIENTABLE(content_grid
), GTK_ORIENTATION_VERTICAL
);
1375 group_grid
= gtk_grid_new ();
1376 gtk_grid_set_row_spacing (GTK_GRID (group_grid
), SPACING_SMALL
);
1377 gtk_grid_set_column_spacing (GTK_GRID (group_grid
), SPACING_MEDIUM
);
1378 gtk_grid_attach (GTK_GRID (content_grid
), group_grid
, 0, crow
++, 1, 1);
1380 label
= make_label_group(_("General"));
1381 gtk_grid_attach (GTK_GRID (group_grid
), label
, 0, 0, 3, 1);
1384 widget
= gtk_check_button_new_with_mnemonic (_("_Enable"));
1385 data
->CM_euro_enable
= widget
;
1386 gtk_grid_attach (GTK_GRID (group_grid
), widget
, 1, row
, 2, 1);
1388 // group :: Currency
1389 group_grid
= gtk_grid_new ();
1390 data
->GRP_currency
= group_grid
;
1391 gtk_grid_set_row_spacing (GTK_GRID (group_grid
), SPACING_SMALL
);
1392 gtk_grid_set_column_spacing (GTK_GRID (group_grid
), SPACING_MEDIUM
);
1393 gtk_grid_attach (GTK_GRID (content_grid
), group_grid
, 0, crow
++, 1, 1);
1395 label
= make_label_group(_("Currency"));
1396 gtk_grid_attach (GTK_GRID (group_grid
), label
, 0, 0, 4, 1);
1399 widget
= make_label(NULL
, 0.0, 0.5);
1400 data
->ST_euro_country
= widget
;
1401 //gtk_grid_attach (GTK_GRID (group_grid), data->CY_option[FILTER_DATE], 1, 2, row, row+1);
1402 gtk_grid_attach (GTK_GRID (group_grid
), widget
, 1, row
, 1, 1);
1405 label
= make_label_widget(_("_Preset:"));
1406 //----------------------------------------- l, r, t, b
1407 gtk_grid_attach (GTK_GRID (group_grid
), label
, 2, row
, 1, 1);
1408 widget
= make_euro_presets(label
);
1409 data
->CY_euro_preset
= widget
;
1410 gtk_widget_set_margin_left (label
, 2*SPACING_LARGE
);
1411 //gtk_grid_attach (GTK_GRID (group_grid), data->CY_option[FILTER_DATE], 1, 2, row, row+1);
1412 gtk_grid_attach (GTK_GRID (group_grid
), widget
, 3, row
, 1, 1);
1415 // group :: Exchange rate
1416 group_grid
= gtk_grid_new ();
1417 data
->GRP_rate
= group_grid
;
1418 gtk_grid_set_row_spacing (GTK_GRID (group_grid
), SPACING_SMALL
);
1419 gtk_grid_set_column_spacing (GTK_GRID (group_grid
), SPACING_MEDIUM
);
1420 gtk_grid_attach (GTK_GRID (content_grid
), group_grid
, 0, crow
++, 1, 1);
1422 label
= make_label_group(_("Exchange rate"));
1423 gtk_grid_attach (GTK_GRID (group_grid
), label
, 0, 0, 3, 1);
1426 label
= make_label_widget("1 EUR _=");
1427 gtk_grid_attach (GTK_GRID (group_grid
), label
, 1, row
, 1, 1);
1428 widget
= make_exchange_rate(label
);
1429 data
->NB_euro_value
= widget
;
1430 //gtk_grid_attach (GTK_GRID (group_grid), data->CY_option[FILTER_DATE], 1, 2, row, row+1);
1431 gtk_grid_attach (GTK_GRID (group_grid
), widget
, 2, row
, 1, 1);
1433 // group :: Numbers format
1434 group_grid
= gtk_grid_new ();
1435 data
->GRP_format
= group_grid
;
1436 gtk_grid_set_row_spacing (GTK_GRID (group_grid
), SPACING_SMALL
);
1437 gtk_grid_set_column_spacing (GTK_GRID (group_grid
), SPACING_MEDIUM
);
1438 gtk_grid_attach (GTK_GRID (content_grid
), group_grid
, 0, crow
++, 1, 1);
1440 label
= make_label_group(_("Format"));
1441 gtk_grid_attach (GTK_GRID (group_grid
), label
, 0, 0, 3, 1);
1444 widget
= make_label(NULL
, 0, 0.0);
1445 data
->LB_numbereuro
= widget
;
1446 gtk_grid_attach (GTK_GRID (group_grid
), widget
, 1, row
, 1, 1);
1449 expander
= gtk_expander_new_with_mnemonic(_("_Customize"));
1450 gtk_grid_attach (GTK_GRID (group_grid
), expander
, 1, row
, 1, 1);
1452 group_grid
= gtk_grid_new ();
1453 gtk_grid_set_row_spacing (GTK_GRID (group_grid
), SPACING_SMALL
);
1454 gtk_grid_set_column_spacing (GTK_GRID (group_grid
), SPACING_MEDIUM
);
1455 gtk_container_add (GTK_CONTAINER (expander
), group_grid
);
1458 label
= make_label_widget(_("_Symbol:"));
1459 gtk_grid_attach (GTK_GRID (group_grid
), label
, 1, row
, 1, 1);
1460 widget
= make_string_maxlength(label
, 3);
1461 data
->ST_euro_symbol
= widget
;
1462 gtk_grid_attach (GTK_GRID (group_grid
), widget
, 2, row
, 1, 1);
1465 widget
= gtk_check_button_new_with_mnemonic (_("Is pre_fix"));
1466 data
->CM_euro_isprefix
= widget
;
1467 gtk_grid_attach (GTK_GRID (group_grid
), widget
, 2, row
, 1, 1);
1470 label
= make_label_widget(_("_Decimal char:"));
1471 gtk_grid_attach (GTK_GRID (group_grid
), label
, 1, row
, 1, 1);
1472 widget
= make_string_maxlength(label
, 1);
1473 data
->ST_euro_decimalchar
= widget
;
1474 gtk_grid_attach (GTK_GRID (group_grid
), widget
, 2, row
, 1, 1);
1477 label
= make_label_widget(_("_Frac digits:"));
1478 gtk_grid_attach (GTK_GRID (group_grid
), label
, 1, row
, 1, 1);
1479 widget
= make_numeric(label
, 0.0, 6.0);
1480 data
->NB_euro_fracdigits
= widget
;
1481 gtk_grid_attach (GTK_GRID (group_grid
), widget
, 2, row
, 1, 1);
1484 label
= make_label_widget(_("_Grouping char:"));
1485 gtk_grid_attach (GTK_GRID (group_grid
), label
, 1, row
, 1, 1);
1486 widget
= make_string_maxlength(label
, 1);
1487 data
->ST_euro_groupingchar
= widget
;
1488 gtk_grid_attach (GTK_GRID (group_grid
), widget
, 2, row
, 1, 1);
1490 return content_grid
;
1494 static GtkWidget
*defpref_page_display (struct defpref_data
*data
)
1496 GtkWidget
*content_grid
, *group_grid
, *label
, *widget
, *expander
;
1499 content_grid
= gtk_grid_new();
1500 gtk_grid_set_row_spacing (GTK_GRID (content_grid
), SPACING_LARGE
);
1501 gtk_orientable_set_orientation(GTK_ORIENTABLE(content_grid
), GTK_ORIENTATION_VERTICAL
);
1504 // group :: Date options
1505 group_grid
= gtk_grid_new ();
1506 gtk_grid_set_row_spacing (GTK_GRID (group_grid
), SPACING_SMALL
);
1507 gtk_grid_set_column_spacing (GTK_GRID (group_grid
), SPACING_MEDIUM
);
1508 gtk_grid_attach (GTK_GRID (content_grid
), group_grid
, 0, crow
++, 1, 1);
1510 label
= make_label_group(_("Date"));
1511 gtk_grid_attach (GTK_GRID (group_grid
), label
, 0, 0, 3, 1);
1514 widget
= make_label(NULL
, 0, 0.5);
1515 data
->LB_date
= widget
;
1516 gtk_grid_attach (GTK_GRID (group_grid
), widget
, 1, row
, 2, 1);
1519 expander
= gtk_expander_new_with_mnemonic(_("_Customize"));
1520 gtk_grid_attach (GTK_GRID (group_grid
), expander
, 1, row
, 1, 1);
1522 group_grid
= gtk_grid_new ();
1523 gtk_grid_set_row_spacing (GTK_GRID (group_grid
), SPACING_SMALL
);
1524 gtk_grid_set_column_spacing (GTK_GRID (group_grid
), SPACING_MEDIUM
);
1525 gtk_container_add (GTK_CONTAINER (expander
), group_grid
);
1528 label
= make_label_widget(_("_Format:"));
1529 //----------------------------------------- l, r, t, b
1530 gtk_grid_attach (GTK_GRID (group_grid
), label
, 1, row
, 1, 1);
1531 widget
= make_string(label
);
1532 data
->ST_datefmt
= widget
;
1533 //gtk_grid_attach (GTK_GRID (group_grid), data->CY_option[FILTER_DATE], 1, 2, row, row+1);
1534 gtk_grid_attach (GTK_GRID (group_grid
), widget
, 2, row
, 1, 1);
1536 widget
= gtk_image_new_from_icon_name (ICONNAME_INFO
, GTK_ICON_SIZE_BUTTON
);
1537 gtk_grid_attach (GTK_GRID (group_grid
), widget
, 3, row
, 1, 1);
1540 gtk_widget_set_tooltip_text(widget
,
1541 _("%a locale's abbreviated weekday name.\n"
1542 "%A locale's full weekday name. \n"
1543 "%b locale's abbreviated month name. \n"
1544 "%B locale's full month name. \n"
1545 "%c locale's appropriate date and time representation. \n"
1546 "%C century number (the year divided by 100 and truncated to an integer) as a decimal number [00-99]. \n"
1547 "%d day of the month as a decimal number [01,31]. \n"
1548 "%D same as %m/%d/%y. \n"
1549 "%e day of the month as a decimal number [1,31]; a single digit is preceded by a space. \n"
1550 "%j day of the year as a decimal number [001,366]. \n"
1551 "%m month as a decimal number [01,12]. \n"
1552 "%p locale's appropriate date representation. \n"
1553 "%y year without century as a decimal number [00,99]. \n"
1554 "%Y year with century as a decimal number. \n")
1558 widget
= make_label(NULL
, 0.0, 0.5);
1559 gtk_label_set_markup (GTK_LABEL(widget
), "<small><a href=\"http://man7.org/linux/man-pages/man3/strftime.3.html\">online reference</a></small>");
1560 gtk_grid_attach (GTK_GRID (group_grid
), widget
, 2, row
, 1, 1);
1562 // group :: Measurement units
1563 group_grid
= gtk_grid_new ();
1564 gtk_grid_set_row_spacing (GTK_GRID (group_grid
), SPACING_SMALL
);
1565 gtk_grid_set_column_spacing (GTK_GRID (group_grid
), SPACING_MEDIUM
);
1566 gtk_grid_attach (GTK_GRID (content_grid
), group_grid
, 0, crow
++, 1, 1);
1568 label
= make_label_group(_("Measurement units"));
1569 gtk_grid_attach (GTK_GRID (group_grid
), label
, 0, 0, 3, 1);
1572 widget
= gtk_check_button_new_with_mnemonic (_("Use _miles for meter"));
1573 data
->CM_unitismile
= widget
;
1574 gtk_grid_attach (GTK_GRID (group_grid
), widget
, 1, row
, 2, 1);
1577 widget
= gtk_check_button_new_with_mnemonic (_("Use _gallon for fuel"));
1578 data
->CM_unitisgal
= widget
;
1579 gtk_grid_attach (GTK_GRID (group_grid
), widget
, 1, row
, 2, 1);
1581 return content_grid
;
1585 static GtkWidget
*defpref_page_transactions (struct defpref_data
*data
)
1587 GtkWidget
*content_grid
, *group_grid
, *sw
, *label
, *widget
;
1590 content_grid
= gtk_grid_new();
1591 gtk_grid_set_row_spacing (GTK_GRID (content_grid
), SPACING_LARGE
);
1592 gtk_orientable_set_orientation(GTK_ORIENTABLE(content_grid
), GTK_ORIENTATION_VERTICAL
);
1595 // group :: Transaction window
1596 group_grid
= gtk_grid_new ();
1597 gtk_grid_set_row_spacing (GTK_GRID (group_grid
), SPACING_SMALL
);
1598 gtk_grid_set_column_spacing (GTK_GRID (group_grid
), SPACING_MEDIUM
);
1599 gtk_grid_attach (GTK_GRID (content_grid
), group_grid
, 0, crow
++, 1, 1);
1601 label
= make_label_group(_("Transaction window"));
1602 gtk_grid_attach (GTK_GRID (group_grid
), label
, 0, 0, 3, 1);
1605 label
= make_label_widget(_("Date _range:"));
1606 //----------------------------------------- l, r, t, b
1607 gtk_grid_attach (GTK_GRID (group_grid
), label
, 1, row
, 1, 1);
1608 widget
= make_daterange(label
, FALSE
);
1609 data
->CY_daterange_txn
= widget
;
1610 gtk_grid_attach (GTK_GRID (group_grid
), widget
, 2, row
, 1, 1);
1613 label
= make_label_widget(_("_Show:"));
1614 //----------------------------------------- l, r, t, b
1615 gtk_grid_attach (GTK_GRID (group_grid
), label
, 1, row
, 1, 1);
1616 widget
= make_numeric(NULL
, 0, 366);
1618 data
->ST_datefuture_nbdays
= widget
;
1619 gtk_grid_attach (GTK_GRID (group_grid
), widget
, 2, row
, 1, 1);
1621 //TRANSLATORS: there is a spinner on the left of this label, and so you have 0....x days in advance the current date
1622 label
= make_label(_("days in advance the current date"), 0, 0.5);
1623 gtk_grid_attach (GTK_GRID (group_grid
), label
, 3, row
, 1, 1);
1626 widget
= gtk_check_button_new_with_mnemonic (_("Hide reconciled transactions"));
1627 data
->CM_hide_reconciled
= widget
;
1628 gtk_grid_attach (GTK_GRID (group_grid
), widget
, 2, row
, 2, 1);
1631 widget
= gtk_check_button_new_with_mnemonic (_("Always show remind transactions"));
1632 data
->CM_show_remind
= widget
;
1633 gtk_grid_attach (GTK_GRID (group_grid
), widget
, 2, row
, 2, 1);
1635 // group :: Multiple add
1636 group_grid
= gtk_grid_new ();
1637 gtk_grid_set_row_spacing (GTK_GRID (group_grid
), SPACING_SMALL
);
1638 gtk_grid_set_column_spacing (GTK_GRID (group_grid
), SPACING_MEDIUM
);
1639 gtk_grid_attach (GTK_GRID (content_grid
), group_grid
, 0, crow
++, 1, 1);
1641 label
= make_label_group(_("Multiple add"));
1642 gtk_grid_attach (GTK_GRID (group_grid
), label
, 0, 0, 3, 1);
1645 widget
= gtk_check_button_new_with_mnemonic (_("Keep the last date"));
1646 data
->CM_herit_date
= widget
;
1647 gtk_grid_attach (GTK_GRID (group_grid
), widget
, 1, row
, 2, 1);
1649 // group :: Column list
1650 group_grid
= gtk_grid_new ();
1651 gtk_grid_set_row_spacing (GTK_GRID (group_grid
), SPACING_SMALL
);
1652 gtk_grid_set_column_spacing (GTK_GRID (group_grid
), SPACING_MEDIUM
);
1653 gtk_grid_attach (GTK_GRID (content_grid
), group_grid
, 0, crow
++, 1, 1);
1655 label
= make_label_group(_("Column list"));
1656 gtk_grid_attach (GTK_GRID (group_grid
), label
, 0, 0, 3, 1);
1659 sw
= gtk_scrolled_window_new (NULL
, NULL
);
1660 gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (sw
), GTK_SHADOW_ETCHED_IN
);
1661 gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (sw
), GTK_POLICY_NEVER
, GTK_POLICY_AUTOMATIC
);
1662 widget
= (GtkWidget
*)list_txn_colprefcreate();
1663 data
->LV_opecolumns
= widget
;
1664 gtk_widget_set_size_request(data
->LV_opecolumns
, HB_MINWIDTH_LIST
, -1);
1665 gtk_container_add (GTK_CONTAINER (sw
), widget
);
1666 gtk_widget_set_vexpand (sw
, TRUE
);
1667 gtk_grid_attach (GTK_GRID (group_grid
), sw
, 1, row
, 2, 1);
1668 gtk_widget_set_tooltip_text(widget
, _("Drag & drop to change the order"));
1670 return content_grid
;
1675 static GtkWidget
*defpref_page_interface (struct defpref_data
*data
)
1677 GtkWidget
*content_grid
, *group_grid
, *hbox
, *label
, *widget
;
1680 content_grid
= gtk_grid_new();
1681 gtk_grid_set_row_spacing (GTK_GRID (content_grid
), SPACING_LARGE
);
1682 gtk_orientable_set_orientation(GTK_ORIENTABLE(content_grid
), GTK_ORIENTATION_VERTICAL
);
1686 group_grid
= gtk_grid_new ();
1687 gtk_grid_set_row_spacing (GTK_GRID (group_grid
), SPACING_SMALL
);
1688 gtk_grid_set_column_spacing (GTK_GRID (group_grid
), SPACING_MEDIUM
);
1689 gtk_grid_attach (GTK_GRID (content_grid
), group_grid
, 0, crow
++, 1, 1);
1691 label
= make_label_group(_("General"));
1692 gtk_grid_attach (GTK_GRID (group_grid
), label
, 0, 0, 3, 1);
1695 label
= make_label_widget(_("_Language:"));
1696 gtk_grid_attach (GTK_GRID (group_grid
), label
, 1, row
, 1, 1);
1697 widget
= ui_language_combobox_new(label
);
1698 data
->CY_language
= widget
;
1699 gtk_grid_attach (GTK_GRID (group_grid
), widget
, 2, row
, 1, 1);
1702 label
= make_label_widget(_("_Toolbar:"));
1703 gtk_grid_attach (GTK_GRID (group_grid
), label
, 1, row
, 1, 1);
1704 widget
= make_cycle(label
, CYA_TOOLBAR_STYLE
);
1705 data
->CY_toolbar
= widget
;
1706 gtk_grid_attach (GTK_GRID (group_grid
), widget
, 2, row
, 1, 1);
1710 //widget = gtk_check_button_new_with_mnemonic (_("Enable rows in alternating colors"));
1711 //data->CM_ruleshint = widget;
1712 label
= make_label_widget(_("_Grid line:"));
1713 gtk_grid_attach (GTK_GRID (group_grid
), label
, 1, row
, 1, 1);
1714 widget
= make_cycle(label
, CYA_GRID_LINES
);
1715 data
->CY_gridlines
= widget
;
1716 gtk_grid_attach (GTK_GRID (group_grid
), widget
, 2, row
, 1, 1);
1718 // group :: Amount colors
1719 group_grid
= gtk_grid_new ();
1720 gtk_grid_set_row_spacing (GTK_GRID (group_grid
), SPACING_SMALL
);
1721 gtk_grid_set_column_spacing (GTK_GRID (group_grid
), SPACING_MEDIUM
);
1722 gtk_grid_attach (GTK_GRID (content_grid
), group_grid
, 0, crow
++, 1, 1);
1724 label
= make_label_group(_("Amount colors"));
1725 gtk_grid_attach (GTK_GRID (group_grid
), label
, 0, 0, 3, 1);
1728 widget
= gtk_check_button_new_with_mnemonic (_("Uses custom colors"));
1729 data
->CM_custom_colors
= widget
;
1730 gtk_grid_attach (GTK_GRID (group_grid
), widget
, 2, row
, 1, 1);
1732 group_grid
= gtk_grid_new ();
1733 data
->GR_colors
= group_grid
;
1734 gtk_grid_set_row_spacing (GTK_GRID (group_grid
), SPACING_SMALL
);
1735 gtk_grid_set_column_spacing (GTK_GRID (group_grid
), SPACING_MEDIUM
);
1736 gtk_grid_attach (GTK_GRID (content_grid
), group_grid
, 0, crow
++, 1, 1);
1739 label
= make_label_widget(_("_Preset:"));
1740 //----------------------------------------- l, r, t, b
1741 gtk_grid_attach (GTK_GRID (group_grid
), label
, 1, row
, 1, 1);
1742 widget
= make_cycle(label
, CYA_TANGO_COLORS
);
1743 data
->CY_colors
= widget
;
1744 //gtk_grid_attach (GTK_GRID (group_grid), data->CY_option[FILTER_DATE], 1, 2, row, row+1);
1745 gtk_grid_attach (GTK_GRID (group_grid
), widget
, 2, row
, 1, 1);
1748 label
= make_label_widget(_("_Expense:"));
1749 //----------------------------------------- l, r, t, b
1750 gtk_grid_attach (GTK_GRID (group_grid
), label
, 1, row
, 1, 1);
1751 hbox
= gtk_box_new(GTK_ORIENTATION_HORIZONTAL
, SPACING_SMALL
);
1752 gtk_grid_attach (GTK_GRID (group_grid
), hbox
, 2, row
, 1, 1);
1754 widget
= gtk_color_button_new ();
1755 data
->CP_exp_color
= widget
;
1756 gtk_box_pack_start (GTK_BOX (hbox
), widget
, FALSE
, FALSE
, 0);
1758 label
= make_label_widget(_("_Income:"));
1759 gtk_box_pack_start (GTK_BOX (hbox
), label
, FALSE
, FALSE
, 0);
1761 widget
= gtk_color_button_new ();
1762 data
->CP_inc_color
= widget
;
1763 gtk_box_pack_start (GTK_BOX (hbox
), widget
, FALSE
, FALSE
, 0);
1765 label
= make_label_widget(_("_Warning:"));
1766 gtk_box_pack_start (GTK_BOX (hbox
), label
, FALSE
, FALSE
, 0);
1768 widget
= gtk_color_button_new ();
1769 data
->CP_warn_color
= widget
;
1770 gtk_box_pack_start (GTK_BOX (hbox
), widget
, FALSE
, FALSE
, 0);
1772 return content_grid
;
1776 static GtkWidget
*defpref_page_general (struct defpref_data
*data
)
1778 GtkWidget
*content_grid
, *group_grid
, *hbox
, *label
, *widget
;
1781 content_grid
= gtk_grid_new();
1782 gtk_grid_set_row_spacing (GTK_GRID (content_grid
), SPACING_LARGE
);
1783 gtk_orientable_set_orientation(GTK_ORIENTABLE(content_grid
), GTK_ORIENTATION_VERTICAL
);
1786 // group :: Program start
1787 group_grid
= gtk_grid_new ();
1788 gtk_grid_set_row_spacing (GTK_GRID (group_grid
), SPACING_SMALL
);
1789 gtk_grid_set_column_spacing (GTK_GRID (group_grid
), SPACING_MEDIUM
);
1790 gtk_grid_attach (GTK_GRID (content_grid
), group_grid
, 0, crow
++, 1, 1);
1792 label
= make_label_group(_("Program start"));
1793 gtk_grid_attach (GTK_GRID (group_grid
), label
, 0, 0, 3, 1);
1796 widget
= gtk_check_button_new_with_mnemonic (_("Show splash screen"));
1797 data
->CM_show_splash
= widget
;
1798 gtk_grid_attach (GTK_GRID (group_grid
), widget
, 1, row
, 2, 1);
1801 widget
= gtk_check_button_new_with_mnemonic (_("Load last opened file"));
1802 data
->CM_load_last
= widget
;
1803 gtk_grid_attach (GTK_GRID (group_grid
), widget
, 1, row
, 2, 1);
1806 widget
= gtk_check_button_new_with_mnemonic (_("Post pending scheduled transactions"));
1807 data
->CM_append_scheduled
= widget
;
1808 gtk_grid_attach (GTK_GRID (group_grid
), widget
, 1, row
, 2, 1);
1811 widget
= gtk_check_button_new_with_mnemonic (_("Update currencies online"));
1812 data
->CM_do_update_currency
= widget
;
1813 gtk_grid_attach (GTK_GRID (group_grid
), widget
, 1, row
, 2, 1);
1815 // group :: Fiscal year
1816 group_grid
= gtk_grid_new ();
1817 gtk_grid_set_row_spacing (GTK_GRID (group_grid
), SPACING_SMALL
);
1818 gtk_grid_set_column_spacing (GTK_GRID (group_grid
), SPACING_MEDIUM
);
1819 gtk_grid_attach (GTK_GRID (content_grid
), group_grid
, 0, crow
++, 1, 1);
1821 label
= make_label_group(_("Fiscal year"));
1822 gtk_grid_attach (GTK_GRID (group_grid
), label
, 0, 0, 3, 1);
1825 //TRANSLATORS: (fiscal year) starts on
1826 label
= make_label_widget(_("Starts _on:"));
1827 gtk_grid_attach (GTK_GRID (group_grid
), label
, 1, row
, 1, 1);
1829 hbox
= gtk_box_new(GTK_ORIENTATION_HORIZONTAL
, SPACING_SMALL
);
1830 gtk_grid_attach (GTK_GRID (group_grid
), hbox
, 2, row
, 1, 1);
1831 widget
= make_numeric (label
, 1, 28);
1832 data
->NB_fiscyearday
= widget
;
1833 gtk_box_pack_start (GTK_BOX (hbox
), widget
, FALSE
, FALSE
, 0);
1834 widget
= make_cycle (NULL
, CYA_MONTHS
);
1835 data
->CY_fiscyearmonth
= widget
;
1836 gtk_box_pack_start (GTK_BOX (hbox
), widget
, FALSE
, FALSE
, 0);
1838 // group :: Main window reports
1839 group_grid
= gtk_grid_new ();
1840 gtk_grid_set_row_spacing (GTK_GRID (group_grid
), SPACING_SMALL
);
1841 gtk_grid_set_column_spacing (GTK_GRID (group_grid
), SPACING_MEDIUM
);
1842 gtk_grid_attach (GTK_GRID (content_grid
), group_grid
, 0, crow
++, 1, 1);
1844 label
= make_label_group(_("Main window reports"));
1845 gtk_grid_attach (GTK_GRID (group_grid
), label
, 0, 0, 3, 1);
1848 label
= make_label_widget(_("Date _range:"));
1849 gtk_grid_attach (GTK_GRID (group_grid
), label
, 1, row
, 1, 1);
1850 widget
= make_daterange(label
, FALSE
);
1851 data
->CY_daterange_wal
= widget
;
1852 gtk_grid_attach (GTK_GRID (group_grid
), widget
, 2, row
, 1, 1);
1854 // group :: Files folder
1855 group_grid
= gtk_grid_new ();
1856 gtk_grid_set_row_spacing (GTK_GRID (group_grid
), SPACING_SMALL
);
1857 gtk_grid_set_column_spacing (GTK_GRID (group_grid
), SPACING_MEDIUM
);
1858 gtk_grid_attach (GTK_GRID (content_grid
), group_grid
, 0, crow
++, 1, 1);
1860 label
= make_label_group(_("Files folder"));
1861 gtk_grid_attach (GTK_GRID (group_grid
), label
, 0, 0, 3, 1);
1864 label
= make_label_widget(_("_Default:"));
1865 gtk_grid_attach (GTK_GRID (group_grid
), label
, 1, row
, 1, 1);
1867 hbox
= gtk_box_new(GTK_ORIENTATION_HORIZONTAL
, 0);
1868 gtk_widget_set_hexpand (hbox
, TRUE
);
1869 gtk_grid_attach (GTK_GRID (group_grid
), hbox
, 2, row
, 1, 1);
1871 widget
= make_string(label
);
1872 data
->ST_path_hbfile
= widget
;
1873 gtk_style_context_add_class (gtk_widget_get_style_context (GTK_WIDGET(widget
)), GTK_STYLE_CLASS_LINKED
);
1874 gtk_box_pack_start (GTK_BOX (hbox
), widget
, TRUE
, TRUE
, 0);
1876 //widget = gtk_button_new_with_label("...");
1877 widget
= gtk_button_new_from_icon_name(ICONNAME_FOLDER
, GTK_ICON_SIZE_BUTTON
);
1878 data
->BT_path_hbfile
= widget
;
1879 gtk_box_pack_start (GTK_BOX (hbox
), widget
, FALSE
, FALSE
, 0);
1881 return content_grid
;
1884 static void defpref_selection(GtkTreeSelection
*treeselection
, gpointer user_data
)
1886 struct defpref_data
*data
;
1887 GtkWidget
*notebook
;
1888 GtkTreeView
*treeview
;
1889 GtkTreeModel
*model
;
1892 GValue val
= { 0, };
1895 DB( g_print("\n[ui-pref] selection\n") );
1897 if (gtk_tree_selection_get_selected(treeselection
, &model
, &iter
))
1899 notebook
= GTK_WIDGET(user_data
);
1900 treeview
= gtk_tree_selection_get_tree_view(treeselection
);
1901 data
= g_object_get_data(G_OBJECT(gtk_widget_get_ancestor(GTK_WIDGET(treeview
), GTK_TYPE_WINDOW
)), "inst_data");
1904 gtk_tree_model_get_value(model
, &iter
, LST_PREF_PAGE
, &val
);
1905 page
= g_value_get_int (&val
);
1906 DB( g_print(" - active is %d\n", page
) );
1907 g_value_unset (&val
);
1910 gtk_tree_model_get_value(model
, &iter
, LST_PREF_NAME
, &val
);
1911 gtk_label_set_text (GTK_LABEL (data
->label
), g_value_get_string (&val
));
1912 g_value_unset (&val
);
1914 gtk_tree_model_get_value(model
, &iter
, LST_PREF_ICONNAME
, &val
);
1915 //gtk_image_set_from_pixbuf (GTK_IMAGE (data->image), g_value_get_object (&val));
1916 gtk_image_set_from_icon_name(GTK_IMAGE (data
->image
), g_value_get_string (&val
), GTK_ICON_SIZE_DIALOG
);
1917 g_value_unset (&val
);
1921 gtk_notebook_set_current_page(GTK_NOTEBOOK(notebook
), page
);
1923 //defpref_change_page(GTK_WIDGET(gtk_tree_selection_get_tree_view(treeselection)), GINT_TO_POINTER(page));
1930 ** set the notebook active page from treeview
1932 /*void defpref_change_page(GtkWidget *widget, gpointer user_data)
1934 struct defpref_data *data;
1935 gint page = GPOINTER_TO_INT(user_data);
1936 GtkTreeModel *model;
1939 DB( g_print("\n[ui-pref] page\n") );
1941 data = g_object_get_data(G_OBJECT(gtk_widget_get_ancestor(widget, GTK_TYPE_WINDOW)), "inst_data");
1943 model = gtk_tree_view_get_model(GTK_TREE_VIEW(data->LV_page));
1951 gtk_notebook_set_current_page(GTK_NOTEBOOK(data->GR_page), page);
1957 ** add an empty new account to our temp GList and treeview
1959 static void defpref_clear(GtkWidget
*widget
, gpointer user_data
)
1961 struct defpref_data
*data
;
1964 data
= g_object_get_data(G_OBJECT(gtk_widget_get_ancestor(widget
, GTK_TYPE_WINDOW
)), "inst_data");
1965 DB( g_print("\n(defpref_clear) (data=%p)\n", data
) );
1967 result
= ui_dialog_msg_confirm_alert(
1968 GTK_WINDOW(data
->window
),
1969 _("Reset all preferences"),
1970 _("Do you really want to reset all\npreferences to default values?"),
1973 if( result
== GTK_RESPONSE_OK
)
1975 homebank_pref_setdefault();
1982 // the window creation
1983 GtkWidget
*defpref_dialog_new (void)
1985 struct defpref_data data
;
1986 GtkWidget
*window
, *content
, *mainvbox
;
1987 GtkWidget
*hbox
, *vbox
, *sw
, *widget
, *notebook
, *page
, *ebox
, *image
, *label
;
1989 window
= gtk_dialog_new_with_buttons (_("Preferences"),
1990 GTK_WINDOW(GLOBALS
->mainwindow
),
1993 GTK_RESPONSE_REJECT
,
1995 GTK_RESPONSE_ACCEPT
,
1998 data
.window
= window
;
2000 //store our window private data
2001 g_object_set_data(G_OBJECT(window
), "inst_data", (gpointer
)&data
);
2003 gtk_window_set_icon_name(GTK_WINDOW (window
), ICONNAME_PREFERENCES
);
2005 content
= gtk_dialog_get_content_area(GTK_DIALOG (window
)); // return a vbox
2006 mainvbox
= gtk_box_new(GTK_ORIENTATION_VERTICAL
, SPACING_MEDIUM
);
2007 gtk_box_pack_start (GTK_BOX (content
), mainvbox
, TRUE
, TRUE
, 0);
2009 gtk_container_set_border_width(GTK_CONTAINER(mainvbox
), SPACING_MEDIUM
);
2011 hbox
= gtk_box_new(GTK_ORIENTATION_HORIZONTAL
, SPACING_MEDIUM
);
2012 gtk_box_pack_start (GTK_BOX (mainvbox
), hbox
, TRUE
, TRUE
, 0);
2015 vbox
= gtk_box_new(GTK_ORIENTATION_VERTICAL
, SPACING_SMALL
);
2016 gtk_box_pack_start (GTK_BOX (hbox
), vbox
, FALSE
, FALSE
, 0);
2019 sw
= gtk_scrolled_window_new (NULL
, NULL
);
2020 gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (sw
), GTK_SHADOW_ETCHED_IN
);
2021 gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (sw
), GTK_POLICY_NEVER
, GTK_POLICY_AUTOMATIC
);
2022 gtk_box_pack_start (GTK_BOX (vbox
), sw
, TRUE
, TRUE
, 0);
2023 widget
= pref_list_create();
2024 data
.LV_page
= widget
;
2025 gtk_container_add (GTK_CONTAINER (sw
), widget
);
2028 data
.BT_clear
= gtk_button_new_with_mnemonic(_("_Reset"));
2029 gtk_box_pack_start (GTK_BOX (vbox
), data
.BT_clear
, FALSE
, TRUE
, 0);
2032 //right part : notebook
2033 vbox
= gtk_box_new (GTK_ORIENTATION_VERTICAL
, SPACING_MEDIUM
);
2034 gtk_box_pack_start (GTK_BOX (hbox
), vbox
, TRUE
, TRUE
, 0);
2035 gtk_widget_show (vbox
);
2037 ebox
= gtk_event_box_new();
2038 gtk_widget_set_name(ebox
, "hbebox");
2039 GtkStyleContext
*context
= gtk_widget_get_style_context (ebox
);
2040 #if GTK_MINOR_VERSION <= 18
2041 gtk_style_context_add_class (context
, GTK_STYLE_CLASS_LIST_ROW
);
2042 gtk_widget_set_state_flags(ebox
, GTK_STATE_FLAG_SELECTED
, TRUE
);
2044 GtkCssProvider
*provider
;
2045 provider
= gtk_css_provider_new ();
2046 gtk_css_provider_load_from_data (provider
,
2047 "#hbebox { color: @theme_selected_fg_color; background-color: @theme_selected_bg_color; }"
2049 gtk_style_context_add_provider (context
, GTK_STYLE_PROVIDER(provider
), G_MAXUINT
);
2051 // gtk_style_context_set_state(context, GTK_STATE_FLAG_SELECTED);
2054 gtk_box_pack_start (GTK_BOX (vbox
), ebox
, FALSE
, TRUE
, 0);
2055 gtk_widget_show (ebox
);
2057 hbox
= gtk_box_new (GTK_ORIENTATION_HORIZONTAL
, SPACING_SMALL
);
2058 gtk_container_set_border_width (GTK_CONTAINER (hbox
), SPACING_SMALL
);
2059 gtk_container_add (GTK_CONTAINER (ebox
), hbox
);
2060 gtk_widget_show (hbox
);
2062 label
= gtk_label_new (NULL
);
2063 gtk_widget_set_margin_left(label
, SPACING_MEDIUM
);
2064 gimp_label_set_attributes (GTK_LABEL (label
),
2065 PANGO_ATTR_SCALE
, PANGO_SCALE_XX_LARGE
,
2066 PANGO_ATTR_WEIGHT
, PANGO_WEIGHT_BOLD
,
2069 gtk_box_pack_start (GTK_BOX (hbox
), label
, FALSE
, FALSE
, 0);
2070 gtk_widget_show (label
);
2073 image
= gtk_image_new ();
2074 gtk_box_pack_end (GTK_BOX (hbox
), image
, FALSE
, FALSE
, 0);
2075 gtk_widget_show (image
);
2081 notebook
= gtk_notebook_new();
2082 data
.GR_page
= notebook
;
2083 gtk_widget_show(notebook
);
2084 gtk_notebook_set_show_tabs(GTK_NOTEBOOK(notebook
), FALSE
);
2085 gtk_notebook_set_show_border(GTK_NOTEBOOK(notebook
), FALSE
);
2086 gtk_box_pack_start (GTK_BOX (vbox
), notebook
, TRUE
, TRUE
, 0);
2098 page
= defpref_page_general(&data
);
2099 gtk_notebook_append_page (GTK_NOTEBOOK (notebook
), page
, NULL
);
2102 page
= defpref_page_interface(&data
);
2103 gtk_notebook_append_page (GTK_NOTEBOOK (notebook
), page
, NULL
);
2106 page
= defpref_page_transactions(&data
);
2107 gtk_notebook_append_page (GTK_NOTEBOOK (notebook
), page
, NULL
);
2110 page
= defpref_page_display(&data
);
2111 gtk_notebook_append_page (GTK_NOTEBOOK (notebook
), page
, NULL
);
2114 page
= defpref_page_import(&data
);
2115 gtk_notebook_append_page (GTK_NOTEBOOK (notebook
), page
, NULL
);
2118 page
= defpref_page_reports(&data
);
2119 gtk_notebook_append_page (GTK_NOTEBOOK (notebook
), page
, NULL
);
2122 page
= defpref_page_euro(&data
);
2123 gtk_notebook_append_page (GTK_NOTEBOOK (notebook
), page
, NULL
);
2126 //todo:should move this
2127 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(data
.CM_euro_enable
), PREFS
->euro_active
);
2129 //connect all our signals
2130 g_signal_connect (window
, "destroy", G_CALLBACK (gtk_widget_destroyed
), &window
);
2132 g_signal_connect (G_OBJECT (data
.BT_clear
), "clicked", G_CALLBACK (defpref_clear
), NULL
);
2135 g_signal_connect (data
.BT_path_hbfile
, "pressed", G_CALLBACK (defpref_pathselect
), GINT_TO_POINTER(1));
2136 g_signal_connect (data
.BT_path_import
, "pressed", G_CALLBACK (defpref_pathselect
), GINT_TO_POINTER(2));
2137 g_signal_connect (data
.BT_path_export
, "pressed", G_CALLBACK (defpref_pathselect
), GINT_TO_POINTER(3));
2139 g_signal_connect (data
.CM_custom_colors
, "toggled", G_CALLBACK (defpref_colortoggle
), NULL
);
2140 g_signal_connect (data
.CY_colors
, "changed", G_CALLBACK (defpref_colorpreset
), NULL
);
2144 g_signal_connect (gtk_tree_view_get_selection(GTK_TREE_VIEW(data
.LV_page
)), "changed", G_CALLBACK (defpref_selection
), notebook
);
2146 g_signal_connect (data
.CM_euro_enable
, "toggled", G_CALLBACK (defpref_eurotoggle
), NULL
);
2148 g_signal_connect (data
.CY_euro_preset
, "changed", G_CALLBACK (defpref_europreset
), NULL
);
2151 g_signal_connect (data
.ST_datefmt
, "changed", G_CALLBACK (defpref_date_sample
), NULL
);
2154 g_signal_connect (data
.CY_color_scheme
, "changed", G_CALLBACK (defpref_color_scheme_changed
), NULL
);
2158 g_signal_connect (data
.ST_euro_symbol
, "changed", G_CALLBACK (defpref_numbereuro_sample
), NULL
);
2159 g_signal_connect (data
.CM_euro_isprefix
, "toggled", G_CALLBACK (defpref_numbereuro_sample
), NULL
);
2160 g_signal_connect (data
.ST_euro_decimalchar
, "changed", G_CALLBACK (defpref_numbereuro_sample
), NULL
);
2161 g_signal_connect (data
.ST_euro_groupingchar
, "changed", G_CALLBACK (defpref_numbereuro_sample
), NULL
);
2162 g_signal_connect (data
.NB_euro_fracdigits
, "value-changed", G_CALLBACK (defpref_numbereuro_sample
), NULL
);
2164 //g_signal_connect (data.BT_default, "pressed", G_CALLBACK (defpref_currency_change), NULL);
2167 //setup, init and show window
2168 //defhbfile_setup(&data);
2169 //defhbfile_update(data.LV_arc, NULL);
2173 defpref_colortoggle(window
, NULL
);
2174 defpref_eurotoggle(window
, NULL
);
2176 gtk_window_resize(GTK_WINDOW(window
), 640, 256);
2180 GtkTreePath
*path
= gtk_tree_path_new_first ();
2182 gtk_tree_selection_select_path (gtk_tree_view_get_selection(GTK_TREE_VIEW(data
.LV_page
)), path
);
2186 gtk_tree_path_free(path
);
2188 gtk_widget_show_all (window
);
2195 result
= gtk_dialog_run (GTK_DIALOG (window
));
2199 case GTK_RESPONSE_ACCEPT
:
2200 old_lang
= g_strdup(PREFS
->language
);
2202 homebank_pref_save();
2203 ui_mainwindow_update(GLOBALS
->mainwindow
, GINT_TO_POINTER(UF_BALANCE
+UF_VISUAL
));
2205 DB( g_print("old='%s' new='%s'\n", old_lang
, PREFS
->language
) );
2207 if(g_ascii_strncasecmp(old_lang
== NULL
? "" : old_lang
, PREFS
->language
== NULL
? "" : PREFS
->language
, -1) != 0)
2209 ui_dialog_msg_infoerror(GTK_WINDOW(window
), GTK_MESSAGE_INFO
,
2211 _("You will have to restart HomeBank\nfor the language change to take effect.")
2221 // cleanup and destroy
2222 //defhbfile_cleanup(&data, result);
2223 gtk_widget_destroy (window
);
2228 // -------------------------------
2231 GtkWidget
*pref_list_create(void)
2233 GtkListStore
*store
;
2235 GtkCellRenderer
*renderer
;
2236 GtkTreeViewColumn
*column
;
2240 /* create list store */
2241 store
= gtk_list_store_new(
2249 view
= gtk_tree_view_new_with_model(GTK_TREE_MODEL(store
));
2250 g_object_unref(store
);
2252 gtk_tree_view_set_headers_visible(GTK_TREE_VIEW (view
), FALSE
);
2253 gtk_tree_selection_set_mode(gtk_tree_view_get_selection(GTK_TREE_VIEW(view
)), GTK_SELECTION_SINGLE
);
2255 /* column 1: icon */
2256 column
= gtk_tree_view_column_new();
2257 renderer
= gtk_cell_renderer_pixbuf_new ();
2258 g_object_set(renderer
, "stock-size", GTK_ICON_SIZE_DND
, NULL
);
2259 gtk_tree_view_column_pack_start(column
, renderer
, FALSE
);
2260 gtk_tree_view_column_set_attributes(column
, renderer
, "icon-name", LST_PREF_ICONNAME
, NULL
);
2262 renderer
= gtk_cell_renderer_text_new ();
2263 gtk_tree_view_column_pack_start(column
, renderer
, TRUE
);
2264 gtk_tree_view_column_set_attributes(column
, renderer
, "text", LST_PREF_NAME
, NULL
);
2266 gtk_tree_view_append_column (GTK_TREE_VIEW(view
), column
);
2268 //populate our combobox model
2269 for(i
=0;i
<PREF_MAX
;i
++)
2271 gtk_list_store_append(store
, &iter
);
2273 gtk_list_store_set(store
, &iter
,
2274 LST_PREF_ICONNAME
, pref_iconname
[i
],
2275 LST_PREF_NAME
, _(pref_name
[i
]),
2284 /* = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =*/
2287 extern gchar
*list_txn_column_label
[];
2291 list_txn_colpref_toggled_cell_data_function (GtkCellRendererToggle
*cell
,
2295 GtkTreeModel
*model
= (GtkTreeModel
*)data
;
2297 GtkTreePath
*path
= gtk_tree_path_new_from_string (path_str
);
2300 /* get toggled iter */
2301 gtk_tree_model_get_iter (model
, &iter
, path
);
2302 gtk_tree_model_get (model
, &iter
, COLUMN_VISIBLE
, &fixed
, -1);
2304 /* do something with the value */
2308 gtk_list_store_set (GTK_LIST_STORE (model
), &iter
, COLUMN_VISIBLE
, fixed
, -1);
2311 gtk_tree_path_free (path
);
2315 static void list_txn_colpref_get(GtkTreeView
*treeview
, gint
*columns
)
2317 GtkTreeModel
*model
;
2323 DB( g_print("[lst_txn-colpref] store column order \n") );
2326 model
= gtk_tree_view_get_model(GTK_TREE_VIEW(treeview
));
2327 valid
= gtk_tree_model_get_iter_first(GTK_TREE_MODEL(model
), &iter
);
2331 gtk_tree_model_get(GTK_TREE_MODEL(model
), &iter
,
2332 COLUMN_VISIBLE
, &visible
,
2336 DB( g_print(" - column %d: %d\n",id
, visible
) );
2337 // start at index 2 (status, date always displayed
2338 columns
[i
+2] = visible
== TRUE
? id
: -id
;
2340 /* Make iter point to the next row in the list store */
2341 valid
= gtk_tree_model_iter_next(GTK_TREE_MODEL(model
), &iter
);
2350 GtkWidget
*list_txn_colprefcreate(void)
2352 GtkListStore
*store
;
2354 GtkCellRenderer
*renderer
;
2355 GtkTreeViewColumn
*column
;
2359 DB( g_print("[lst_txn-colpref] create\n") );
2362 /* create list store */
2363 store
= gtk_list_store_new(
2371 for(i
=0 ; i
< NUM_LST_DSPOPE
-1; i
++ ) //-1 cause account column avoid
2376 DB( g_print("eval %d, %s\n", i
, list_txn_column_label
[i
]) );
2378 if(i
<= LST_DSPOPE_DATE
) // status, date always displayed
2381 //[i-1] here because lst_ope_columns[] do not store LST_DSPOPE_DATAS
2382 id
= ABS(PREFS
->lst_ope_columns
[i
-1]);
2383 if(id
== 0) id
= i
; //if we pass here, new column or weird into pref file
2384 visible
= (PREFS
->lst_ope_columns
[i
-1] > 0) ? TRUE
: FALSE
;
2387 DB( g_print(" - pos=%2d, id=%2d - %d '%s'\n", i
, id
, visible
, list_txn_column_label
[id
]) );
2389 gtk_list_store_append (store
, &iter
);
2390 gtk_list_store_set (store
, &iter
,
2391 COLUMN_VISIBLE
, visible
,
2392 COLUMN_NAME
, _(list_txn_column_label
[id
]),
2399 view
= gtk_tree_view_new_with_model(GTK_TREE_MODEL(store
));
2400 g_object_unref(store
);
2404 renderer
= gtk_cell_renderer_toggle_new ();
2405 column
= gtk_tree_view_column_new_with_attributes (_("Visible"),
2407 "active", COLUMN_VISIBLE
,
2409 gtk_tree_view_append_column (GTK_TREE_VIEW(view
), column
);
2411 g_signal_connect (renderer
, "toggled",
2412 G_CALLBACK (list_txn_colpref_toggled_cell_data_function
), store
);
2415 renderer
= gtk_cell_renderer_text_new ();
2416 column
= gtk_tree_view_column_new_with_attributes (_("Column"),
2418 "text", COLUMN_NAME
,
2420 gtk_tree_view_append_column (GTK_TREE_VIEW(view
), column
);
2422 gtk_tree_view_set_reorderable (GTK_TREE_VIEW(view
), TRUE
);