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"
29 #include "ui-currency.h"
32 /****************************************************************************/
34 /****************************************************************************/
43 /* our global datas */
44 extern struct HomeBank
*GLOBALS
;
45 extern struct Preferences
*PREFS
;
58 EXT_COLUMN_ENABLED
= 0,
61 EXT_COLUMN_PLUGIN_NAME
,
66 static gchar
*pref_iconname
[PREF_MAX
] = {
73 "prf-euro", // to be renamed
78 static gchar
*pref_name
[PREF_MAX
] = {
90 static gchar
*CYA_TOOLBAR_STYLE
[] = {
91 N_("System defaults"),
94 N_("Text under icons"),
95 N_("Text beside icons"),
99 static gchar
*CYA_GRID_LINES
[] = {
108 gchar
*CYA_TANGO_COLORS
[] = {
116 gchar
*CYA_IMPORT_DATEORDER
[] = {
123 gchar
*CYA_IMPORT_OFXNAME
[] = {
130 gchar
*CYA_IMPORT_OFXMEMO
[] = {
132 N_("Append to Info"),
133 N_("Append to Memo"),
134 N_("Append to Payee"),
139 extern gchar
*CYA_CHART_COLORSCHEME
[];
140 extern gchar
*CYA_MONTHS
[];
147 http://en.wikipedia.org/wiki/Currencies_of_the_European_Union
148 http://www.xe.com/euro.php
149 http://fr.wikipedia.org/wiki/Liste_des_unit%C3%A9s_mon%C3%A9taires_remplac%C3%A9es_par_l%27euro
150 http://www.inter-locale.com/LocalesDemo.jsp
152 static EuroParams euro_params
[] =
154 // , rate , symb , prfx , dec, grp, frac
155 // ---------------------------------------------------------------------
156 { 0, "" , "--------" , 1.0 , "" , FALSE
, ",", ".", 2 },
157 { 1, "ATS", "Austria" , 13.7603 , "S" , TRUE
, ",", ".", 2 }, // -S 1.234.567,89
158 { 2, "BEF", "Belgium" , 40.3399 , "BF" , TRUE
, ",", ".", 2 }, // BF 1.234.567,89 -
159 { 20, "BGN", "Bulgaria" , 1.95583 , "лв." , TRUE
, ",", " ", 2 }, // non-fixé - 2014 target for euro
160 { 24, "HRK", "Croatia" , 1.0000 , "kn" , FALSE
, "" , ".", 0 }, // non-fixé - 2015 target for euro earliest
161 { 14, "CYP", "Cyprus" , 0.585274 , "£" , TRUE
, ",", "" , 2 }, //
162 { 23, "CZK", "Czech Republic" , 28.36 , "Kč" , FALSE
, ",", " ", 2 }, // non-fixé - 2015 earliest
164 { 17, "EEK", "Estonia" , 15.6466 , "kr" , FALSE
, ",", " ", 2 }, //
165 { 3, "FIM", "Finland" , 5.94573 , "mk" , FALSE
, ",", " ", 2 }, // -1 234 567,89 mk
166 { 4, "FRF", "France" , 6.55957 , "F" , FALSE
, ",", " ", 2 }, // -1 234 567,89 F
167 { 5, "DEM", "Germany" , 1.95583 , "DM" , FALSE
, ",", ".", 2 }, // -1.234.567,89 DM
168 { 6, "GRD", "Greece" , 340.750 , "d" , TRUE
, ".", ",", 2 }, // ??
169 { 21, "HUF", "Hungary" , 261.51 , "Ft" , TRUE
, ",", " ", 2 }, // non-fixé - No current target for euro
170 { 7, "IEP", "Ireland" , 0.787564 , "£" , TRUE
, ".", ",", 2 }, // -£1,234,567.89
171 { 8, "ITL", "Italy" , 1936.27 , "L" , TRUE
, "" , ".", 0 }, // L -1.234.567
172 { 18, "LVL", "Latvia" , 0.702804 , "lat.", FALSE
, ",", "" , 2 }, // jan. 2014
173 { 19, "LTL", "Lithuania" , 3.45280 , "Lt" , FALSE
, ",", "" , 2 }, // jan. 2015
174 { 9, "LUF", "Luxembourg" , 40.3399 , "LU" , TRUE
, ",", ".", 2 }, // LU 1.234.567,89 -
175 { 15, "MTL", "Malta" , 0.429300 , "Lm" , TRUE
, ",", "" , 2 }, //
176 { 10, "NLG", "Netherlands" , 2.20371 , "F" , TRUE
, ",", ".", 2 }, // F 1.234.567,89-
177 { 25, "PLN", "Poland" , 0.25 , "zł" , FALSE
, ",", "" , 2 }, // non-fixé - No current target for euro
178 { 11, "PTE", "Portugal" , 200.482 , "Esc.", FALSE
, "$", ".", 2 }, // -1.234.567$89 Esc.
179 { 22, "RON", "Romania" , 3.5155 , "Leu" , FALSE
, ",", ".", 2 }, // non-fixé - 2015 target for euro earliest
180 { 16, "SKK", "Slovak Republic", 30.12600 , "Sk" , FALSE
, ",", " ", 2 }, //
181 { 13, "SIT", "Slovenia" , 239.640 , "tol" , TRUE
, ",", ".", 2 }, //
182 { 12, "ESP", "Spain" , 166.386 , "Pts" , TRUE
, "" , ".", 0 }, // -Pts 1.234.567
185 // { " ", "" , 1.00000 , "" , "" , FALSE, ",", "", 2 },
189 static void list_ext_colpref_get(GtkTreeView
*treeview
, GList
**columns
);
192 /* = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =*/
195 static LangName languagenames
[] =
197 // 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
198 //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
201 { "ab", "Abkhazian" },
203 { "af", "Afrikaans" },
206 { "an", "Aragonese" },
208 { "as", "Assamese" },
209 { "ast", "Asturian, Bable, Leonese, Asturleonese" },
212 { "az", "Azerbaijani" },
214 { "be", "Belarusian" },
215 { "bg", "Bulgarian" },
225 { "ch", "Chamorro" },
226 { "co", "Corsican" },
229 { "cu", "Old Church Slavonic" },
235 { "dz", "Dzongkha" },
239 { "eo", "Esperanto" },
241 { "et", "Estonian" },
249 { "fy", "Western Frisian" },
251 { "gd", "Scottish Gaelic" },
252 { "gl", "Galician" },
254 { "gu", "Gujarati" },
259 { "ho", "Hiri Motu" },
260 { "hr", "Croatian" },
262 { "hu", "Hungarian" },
263 { "hy", "Armenian" },
265 { "ia", "Interlingua" },
266 { "id", "Indonesian" },
267 { "ie", "Interlingue" },
269 { "ii", "Sichuan Yi" },
272 { "is", "Icelandic" },
274 { "iu", "Inuktitut" },
275 { "ja", "Japanese" },
276 { "jv", "Javanese" },
277 { "ka", "Georgian" },
280 { "kj", "Kwanyama" },
282 { "kl", "Kalaallisut" },
287 { "ks", "Kashmiri" },
293 { "lb", "Luxembourgish" },
295 { "li", "Limburgish" },
298 { "lt", "Lithuanian" },
299 { "lu", "Luba-Katanga" },
301 { "mg", "Malagasy" },
302 { "mh", "Marshallese" },
304 { "mk", "Macedonian" },
305 { "ml", "Malayalam" },
306 { "mn", "Mongolian" },
307 { "mo", "Moldavian" },
313 { "nb", "Norwegian Bokmål" },
314 { "nd", "North Ndebele" },
315 { "nds", "Low German, Low Saxon" },
319 { "nn", "Norwegian Nynorsk" },
320 { "no", "Norwegian" },
321 { "nr", "South Ndebele" },
323 { "ny", "Chichewa" },
328 { "os", "Ossetian" },
333 { "pt", "Portuguese" },
337 { "ro", "Romanian" },
339 { "rw", "Kinyarwanda" },
340 { "sa", "Sanskrit" },
341 { "sc", "Sardinian" },
343 { "se", "Northern Sami" },
345 { "si", "Sinhalese" },
351 { "sq", "Albanian" },
355 { "su", "Sundanese" },
362 { "ti", "Tigrinya" },
371 { "ty", "Tahitian" },
373 { "uk", "Ukrainian" },
377 { "vi", "Viêt Namese" },
391 static GtkWidget
*pref_list_create(void);
395 ui_language_combobox_compare_func (GtkTreeModel
*model
, GtkTreeIter
*a
, GtkTreeIter
*b
, gpointer userdata
)
398 gchar
*code1
, *code2
;
399 gchar
*name1
, *name2
;
401 gtk_tree_model_get(model
, a
, 0, &code1
, 1, &name1
, -1);
402 gtk_tree_model_get(model
, b
, 0, &code2
, 1, &name2
, -1);
404 //keep system laguage on top
405 if(code1
== NULL
) name1
= NULL
;
406 if(code2
== NULL
) name2
= NULL
;
408 retval
= hb_string_utf8_compare(name1
, name2
);
417 static gchar
*languagename_get(const gchar
*locale
)
421 for (i
= 0; i
< G_N_ELEMENTS (languagenames
); i
++)
423 if( g_ascii_strncasecmp(locale
, languagenames
[i
].locale
, -1) == 0 )
424 return languagenames
[i
].name
;
432 ui_language_combobox_get_name(const gchar
*locale
)
436 DB( g_print("[ui_language_combobox_get_name]\n") );
438 // A locale directory name is typically of the form language[_territory]
439 lang
= languagename_get (locale
);
442 const gchar
*delimiter
= strchr (locale
, '_'); // strip off the territory suffix
446 gchar
*copy
= g_strndup (locale
, delimiter
- locale
);
447 lang
= languagename_get (copy
);
453 g_warning(" locale name not found '%s'", locale
);
464 ui_language_combobox_populate(GtkWidget
*combobox
)
469 model
= gtk_combo_box_get_model(GTK_COMBO_BOX(combobox
));
470 gtk_list_store_append (GTK_LIST_STORE(model
), &iter
);
471 gtk_list_store_set (GTK_LIST_STORE(model
), &iter
,
473 1, _("System Language"),
476 GDir
*dir
= g_dir_open (homebank_app_get_locale_dir (), 0, NULL
);
477 const gchar
*dirname
;
482 while ((dirname
= g_dir_read_name (dir
)) != NULL
)
484 gchar
*filename
= g_build_filename (homebank_app_get_locale_dir (),
487 GETTEXT_PACKAGE
".mo",
489 //DB( g_print("- seek for '%s'\n", filename) );
490 if (g_file_test (filename
, G_FILE_TEST_EXISTS
))
495 gtk_list_store_append (GTK_LIST_STORE(model
), &iter
);
497 lang
= ui_language_combobox_get_name(dirname
);
498 label
= g_strdup_printf ("%s [%s]", lang
, dirname
);
500 gtk_list_store_set (GTK_LIST_STORE(model
), &iter
,
512 gtk_tree_sortable_set_sort_column_id(GTK_TREE_SORTABLE(model
), GTK_TREE_SORTABLE_DEFAULT_SORT_COLUMN_ID
, GTK_SORT_ASCENDING
);
519 ui_language_combobox_new(GtkWidget
*label
)
523 GtkCellRenderer
*renderer
;
525 store
= gtk_list_store_new (2,
529 gtk_tree_sortable_set_default_sort_func(GTK_TREE_SORTABLE(store
), ui_language_combobox_compare_func
, NULL
, NULL
);
531 combobox
= gtk_combo_box_new_with_model(GTK_TREE_MODEL(store
));
532 renderer
= gtk_cell_renderer_text_new ();
533 gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (combobox
), renderer
, TRUE
);
534 gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (combobox
), renderer
, "text", 1, NULL
);
536 gtk_combo_box_set_id_column( GTK_COMBO_BOX(combobox
), 0);
538 g_object_unref(store
);
541 gtk_label_set_mnemonic_widget (GTK_LABEL(label
), combobox
);
543 ui_language_combobox_populate(combobox
);
545 gtk_combo_box_set_active(GTK_COMBO_BOX(combobox
), 0);
551 /* = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =*/
552 /* = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =*/
553 /* = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =*/
555 static gint
ui_euro_combobox_id_to_active(gint id
)
559 DB( g_print("\n[ui-pref] ui_euro_combobox_id_to_active\n") );
562 for (i
= 0; i
< G_N_ELEMENTS (euro_params
); i
++)
564 if( euro_params
[i
].id
== id
)
567 DB( g_print("- id (country)=%d => %d - %s\n", id
, i
, euro_params
[i
].name
) );
577 static gint
ui_euro_combobox_active_to_id(gint active
)
581 DB( g_print("\n[ui-pref] ui_euro_combobox_active_to_id\n") );
583 DB( g_print("- to %d\n", active
) );
586 if( active
< (gint
)G_N_ELEMENTS (euro_params
) )
588 id
= euro_params
[active
].id
;
589 DB( g_print("- id (country)=%d '%s'\n", id
, euro_params
[active
].name
) );
595 static GtkWidget
*ui_euro_combobox_new(GtkWidget
*label
)
600 DB( g_print("\n[ui-pref] make euro preset\n") );
602 combobox
= gtk_combo_box_text_new();
603 for (i
= 0; i
< G_N_ELEMENTS (euro_params
); i
++)
605 gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(combobox
), euro_params
[i
].name
);
607 gtk_combo_box_set_active(GTK_COMBO_BOX(combobox
), 0);
610 gtk_label_set_mnemonic_widget (GTK_LABEL(label
), combobox
);
616 static void defpref_pathselect(GtkWidget
*widget
, gpointer user_data
)
618 struct defpref_data
*data
;
619 gint type
= GPOINTER_TO_INT(user_data
);
625 DB( g_print("\n[ui-pref] path select\n") );
627 data
= g_object_get_data(G_OBJECT(gtk_widget_get_ancestor(widget
, GTK_TYPE_WINDOW
)), "inst_data");
632 path
= &PREFS
->path_hbfile
;
633 entry
= data
->ST_path_hbfile
;
634 title
= _("Choose a default HomeBank files folder");
637 path
= &PREFS
->path_import
;
638 entry
= data
->ST_path_import
;
639 title
= _("Choose a default import folder");
642 path
= &PREFS
->path_export
;
643 entry
= data
->ST_path_export
;
644 title
= _("Choose a default export folder");
650 DB( g_print(" - hbfile %p %s at %p\n" , PREFS
->path_hbfile
, PREFS
->path_hbfile
, &PREFS
->path_hbfile
) );
651 DB( g_print(" - import %p %s at %p\n" , PREFS
->path_import
, PREFS
->path_import
, &PREFS
->path_import
) );
652 DB( g_print(" - export %p %s at %p\n" , PREFS
->path_export
, PREFS
->path_export
, &PREFS
->path_export
) );
655 DB( g_print(" - before: %s %p\n" , *path
, path
) );
657 r
= ui_file_chooser_folder(GTK_WINDOW(gtk_widget_get_ancestor(widget
, GTK_TYPE_WINDOW
)), title
, path
);
660 DB( g_print(" - after: %s\n", *path
) );
663 gtk_entry_set_text(GTK_ENTRY(entry
), *path
);
670 ** update the date sample label
672 static void defpref_date_sample(GtkWidget
*widget
, gpointer user_data
)
674 struct defpref_data
*data
;
679 DB( g_print("\n[ui-pref] date sample\n") );
681 data
= g_object_get_data(G_OBJECT(gtk_widget_get_ancestor(widget
, GTK_TYPE_WINDOW
)), "inst_data");
683 fmt
= gtk_entry_get_text(GTK_ENTRY(data
->ST_datefmt
));
684 date
= g_date_new_julian (GLOBALS
->today
);
685 g_date_strftime (buffer
, 256-1, fmt
, date
);
688 gtk_label_set_text(GTK_LABEL(data
->LB_date
), buffer
);
694 ** update the number sample label
696 static void defpref_numbereuro_sample(GtkWidget
*widget
, gpointer user_data
)
698 struct defpref_data
*data
;
700 gchar formatd_buf
[G_ASCII_DTOSTR_BUF_SIZE
];
703 DB( g_print("\n[ui-pref] number sample\n") );
705 data
= g_object_get_data(G_OBJECT(gtk_widget_get_ancestor(widget
, GTK_TYPE_WINDOW
)), "inst_data");
707 cur
.symbol
= (gchar
*)gtk_entry_get_text(GTK_ENTRY(data
->ST_euro_symbol
));
708 cur
.sym_prefix
= gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(data
->CM_euro_isprefix
));
709 cur
.decimal_char
= (gchar
*)gtk_entry_get_text(GTK_ENTRY(data
->ST_euro_decimalchar
));
710 cur
.grouping_char
= (gchar
*)gtk_entry_get_text(GTK_ENTRY(data
->ST_euro_groupingchar
));
711 cur
.frac_digits
= gtk_spin_button_get_value(GTK_SPIN_BUTTON(data
->NB_euro_fracdigits
));
713 da_cur_initformat (&cur
);
715 DB( g_print("fmt: %s\n", cur
.format
) );
717 g_ascii_formatd(formatd_buf
, sizeof (formatd_buf
), cur
.format
, HB_NUMBER_SAMPLE
);
718 hb_str_formatd(buf
, 127, formatd_buf
, &cur
, TRUE
);
720 gtk_label_set_text(GTK_LABEL(data
->LB_numbereuro
), buf
);
726 ** enable/disable euro
728 static void defpref_eurotoggle(GtkWidget
*widget
, gpointer user_data
)
730 struct defpref_data
*data
;
733 DB( g_print("\n[ui-pref] euro toggle\n") );
735 data
= g_object_get_data(G_OBJECT(gtk_widget_get_ancestor(widget
, GTK_TYPE_WINDOW
)), "inst_data");
737 sensitive
= gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(data
->CM_euro_enable
));
739 gtk_widget_set_sensitive(data
->GRP_currency
, sensitive
);
740 gtk_widget_set_sensitive(data
->GRP_rate
, sensitive
);
741 gtk_widget_set_sensitive(data
->GRP_format
, sensitive
);
746 ** set euro value widget from a country
748 static void defpref_eurosetcurrency(GtkWidget
*widget
, gint country
)
750 struct defpref_data
*data
;
755 DB( g_print("\n[ui-pref] eurosetcurrency\n") );
757 data
= g_object_get_data(G_OBJECT(gtk_widget_get_ancestor(widget
, GTK_TYPE_WINDOW
)), "inst_data");
759 active
= ui_euro_combobox_id_to_active(country
);
760 euro
= &euro_params
[active
];
761 buf
= g_strdup_printf("%s - %s", euro
->iso
, euro
->name
);
762 gtk_label_set_markup(GTK_LABEL(data
->ST_euro_country
), buf
);
768 ** set euro value widget from a country
770 static void defpref_europreset(GtkWidget
*widget
, gpointer user_data
)
772 struct defpref_data
*data
;
775 DB( g_print("\n[ui-pref] euro preset\n") );
777 data
= g_object_get_data(G_OBJECT(gtk_widget_get_ancestor(widget
, GTK_TYPE_WINDOW
)), "inst_data");
779 active
= gtk_combo_box_get_active (GTK_COMBO_BOX(data
->CY_euro_preset
));
780 data
->country
= ui_euro_combobox_active_to_id (active
);;
782 defpref_eurosetcurrency(widget
, data
->country
);
784 gtk_spin_button_set_value(GTK_SPIN_BUTTON(data
->NB_euro_value
), euro_params
[active
].value
);
786 gtk_spin_button_set_value(GTK_SPIN_BUTTON(data
->NB_euro_fracdigits
), euro_params
[active
].frac_digits
);
788 gtk_entry_set_text(GTK_ENTRY(data
->ST_euro_symbol
) , euro_params
[active
].symbol
);
789 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(data
->CM_euro_isprefix
), euro_params
[active
].sym_prefix
);
790 gtk_entry_set_text(GTK_ENTRY(data
->ST_euro_decimalchar
) , euro_params
[active
].decimal_char
);
791 gtk_entry_set_text(GTK_ENTRY(data
->ST_euro_groupingchar
), euro_params
[active
].grouping_char
);
796 static void defpref_colortoggle(GtkWidget
*widget
, gpointer user_data
)
798 struct defpref_data
*data
;
801 DB( g_print("\n[ui-pref] color toggle\n") );
803 data
= g_object_get_data(G_OBJECT(gtk_widget_get_ancestor(widget
, GTK_TYPE_WINDOW
)), "inst_data");
805 sensitive
= gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(data
->CM_custom_colors
));
807 gtk_widget_set_sensitive(data
->GR_colors
, sensitive
);
813 ** set preset colors for amount display
815 static void defpref_colorpreset(GtkWidget
*widget
, gpointer user_data
)
817 struct defpref_data
*data
;
820 gchar
*expcol
, *inccol
, *wrncol
;
822 DB( g_print("\n[ui-pref] color preset\n") );
824 data
= g_object_get_data(G_OBJECT(gtk_widget_get_ancestor(widget
, GTK_TYPE_WINDOW
)), "inst_data");
826 preset
= gtk_combo_box_get_active(GTK_COMBO_BOX(data
->CY_colors
));
831 expcol
= LIGHT_EXP_COLOR
;
832 inccol
= LIGHT_INC_COLOR
;
833 wrncol
= LIGHT_WARN_COLOR
;
837 expcol
= MEDIUM_EXP_COLOR
;
838 inccol
= MEDIUM_INC_COLOR
;
839 wrncol
= MEDIUM_WARN_COLOR
;
844 expcol
= DEFAULT_EXP_COLOR
;
845 inccol
= DEFAULT_INC_COLOR
;
846 wrncol
= DEFAULT_WARN_COLOR
;
851 gdk_rgba_parse(&rgba
, expcol
);
852 gtk_color_chooser_set_rgba(GTK_COLOR_CHOOSER(data
->CP_exp_color
), &rgba
);
854 gdk_rgba_parse(&rgba
, inccol
);
855 gtk_color_chooser_set_rgba(GTK_COLOR_CHOOSER(data
->CP_inc_color
), &rgba
);
857 gdk_rgba_parse(&rgba
, wrncol
);
858 gtk_color_chooser_set_rgba(GTK_COLOR_CHOOSER(data
->CP_warn_color
), &rgba
);
864 static void defpref_color_scheme_changed(GtkWidget
*widget
, gpointer user_data
)
866 struct defpref_data
*data
;
868 DB( g_print("\n[ui-pref] color scheme chnaged\n") );
870 data
= g_object_get_data(G_OBJECT(gtk_widget_get_ancestor(widget
, GTK_TYPE_WINDOW
)), "inst_data");
872 gtk_widget_queue_draw (data
->DA_colors
);
880 static void setGdkColor_from_RGB(GdkColor *color, guint32 value)
885 color->red = tmp | tmp<<8;
887 tmp = value >> 8 & 0xFF;
888 color->green = tmp | tmp<<8;
891 color->blue = tmp | tmp<<8;
897 ** set :: fill in widgets from PREFS structure
900 static void defpref_set(struct defpref_data
*data
)
904 DB( g_print("\n[ui-pref] set\n") );
907 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(data
->CM_show_splash
), PREFS
->showsplash
);
908 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(data
->CM_load_last
), PREFS
->loadlast
);
909 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(data
->CM_append_scheduled
), PREFS
->appendscheduled
);
910 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(data
->CM_do_update_currency
), PREFS
->do_update_currency
);
911 gtk_combo_box_set_active(GTK_COMBO_BOX(data
->CY_daterange_wal
), PREFS
->date_range_wal
);
912 gtk_spin_button_set_value(GTK_SPIN_BUTTON(data
->NB_fiscyearday
), PREFS
->fisc_year_day
);
913 gtk_combo_box_set_active(GTK_COMBO_BOX(data
->CY_fiscyearmonth
), PREFS
->fisc_year_month
- 1);
916 gtk_entry_set_text(GTK_ENTRY(data
->ST_path_hbfile
), PREFS
->path_hbfile
);
921 if(PREFS
->language
!= NULL
)
922 gtk_combo_box_set_active_id(GTK_COMBO_BOX(data
->CY_language
), PREFS
->language
);
924 gtk_combo_box_set_active (GTK_COMBO_BOX(data
->CY_language
), 0);
925 gtk_combo_box_set_active(GTK_COMBO_BOX(data
->CY_toolbar
), PREFS
->toolbar_style
);
926 //gtk_spin_button_set_value(GTK_SPIN_BUTTON(data->NB_image_size), PREFS->image_size);
928 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(data
->CM_custom_colors
), PREFS
->custom_colors
);
929 gdk_rgba_parse(&rgba
, PREFS
->color_exp
);
930 gtk_color_chooser_set_rgba(GTK_COLOR_CHOOSER(data
->CP_exp_color
), &rgba
);
931 gdk_rgba_parse(&rgba
, PREFS
->color_inc
);
932 gtk_color_chooser_set_rgba(GTK_COLOR_CHOOSER(data
->CP_inc_color
), &rgba
);
933 gdk_rgba_parse(&rgba
, PREFS
->color_warn
);
934 gtk_color_chooser_set_rgba(GTK_COLOR_CHOOSER(data
->CP_warn_color
), &rgba
);
935 //gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(data->CM_ruleshint), PREFS->rules_hint);
936 gtk_combo_box_set_active(GTK_COMBO_BOX(data
->CY_gridlines
), PREFS
->grid_lines
);
939 gtk_combo_box_set_active(GTK_COMBO_BOX(data
->CY_daterange_txn
), PREFS
->date_range_txn
);
940 gtk_spin_button_set_value(GTK_SPIN_BUTTON(data
->ST_datefuture_nbdays
), PREFS
->date_future_nbdays
);
941 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(data
->CM_hide_reconciled
), PREFS
->hidereconciled
);
942 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(data
->CM_show_remind
), PREFS
->showremind
);
943 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(data
->CM_herit_date
), PREFS
->heritdate
);
946 gtk_entry_set_text(GTK_ENTRY(data
->ST_datefmt
), PREFS
->date_format
);
947 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(data
->CM_unitismile
), PREFS
->vehicle_unit_ismile
);
948 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(data
->CM_unitisgal
), PREFS
->vehicle_unit_isgal
);
951 gtk_combo_box_set_active(GTK_COMBO_BOX(data
->CY_dtex_datefmt
), PREFS
->dtex_datefmt
);
952 gtk_combo_box_set_active(GTK_COMBO_BOX(data
->CY_dtex_ofxname
), PREFS
->dtex_ofxname
);
953 gtk_combo_box_set_active(GTK_COMBO_BOX(data
->CY_dtex_ofxmemo
), PREFS
->dtex_ofxmemo
);
954 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(data
->CM_dtex_qifmemo
), PREFS
->dtex_qifmemo
);
955 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(data
->CM_dtex_qifswap
), PREFS
->dtex_qifswap
);
956 gtk_entry_set_text(GTK_ENTRY(data
->ST_path_import
), PREFS
->path_import
);
957 gtk_entry_set_text(GTK_ENTRY(data
->ST_path_export
), PREFS
->path_export
);
960 gtk_combo_box_set_active(GTK_COMBO_BOX(data
->CY_daterange_rep
), PREFS
->date_range_rep
);
961 gtk_combo_box_set_active(GTK_COMBO_BOX(data
->CY_color_scheme
), PREFS
->report_color_scheme
);
962 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(data
->CM_stat_byamount
), PREFS
->stat_byamount
);
963 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(data
->CM_stat_showrate
), PREFS
->stat_showrate
);
964 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(data
->CM_stat_showdetail
), PREFS
->stat_showdetail
);
965 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(data
->CM_budg_showdetail
), PREFS
->budg_showdetail
);
968 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(data
->CM_euro_enable
), PREFS
->euro_active
);
969 //gtk_combo_box_set_active(GTK_COMBO_BOX(data->CY_euro_preset), PREFS->euro_country);
970 data
->country
= PREFS
->euro_country
;
971 defpref_eurosetcurrency(data
->window
, data
->country
);
972 gtk_spin_button_set_value(GTK_SPIN_BUTTON(data
->NB_euro_value
), PREFS
->euro_value
);
973 ui_gtk_entry_set_text(data
->ST_euro_symbol
, PREFS
->minor_cur
.symbol
);
974 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(data
->CM_euro_isprefix
), PREFS
->minor_cur
.sym_prefix
);
975 ui_gtk_entry_set_text(data
->ST_euro_decimalchar
, PREFS
->minor_cur
.decimal_char
);
976 ui_gtk_entry_set_text(data
->ST_euro_groupingchar
, PREFS
->minor_cur
.grouping_char
);
977 gtk_spin_button_set_value(GTK_SPIN_BUTTON(data
->NB_euro_fracdigits
), PREFS
->minor_cur
.frac_digits
);
979 //gtk_entry_set_text(GTK_ENTRY(data->ST_euro_symbol), PREFS->euro_symbol);
980 //gtk_spin_button_set_value(GTK_SPIN_BUTTON(data->NB_euro_nbdec), PREFS->euro_nbdec);
981 //gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(data->CM_euro_thsep), PREFS->euro_thsep);
986 ** get :: fill PREFS structure from widgets
988 #define RGBA_TO_INT(x) (int)(x*255)
990 static gchar
*gdk_rgba_to_hex(GdkRGBA
*rgba
)
992 return g_strdup_printf("#%02x%02x%02x", RGBA_TO_INT(rgba
->red
), RGBA_TO_INT(rgba
->green
), RGBA_TO_INT(rgba
->blue
));
996 static void defpref_get(struct defpref_data
*data
)
1001 DB( g_print("\n[ui-pref] get\n") );
1004 PREFS
->showsplash
= gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(data
->CM_show_splash
));
1005 PREFS
->loadlast
= gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(data
->CM_load_last
));
1006 PREFS
->appendscheduled
= gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(data
->CM_append_scheduled
));
1007 PREFS
->do_update_currency
= gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(data
->CM_do_update_currency
));
1008 PREFS
->date_range_wal
= gtk_combo_box_get_active(GTK_COMBO_BOX(data
->CY_daterange_wal
));
1009 PREFS
->fisc_year_day
= gtk_spin_button_get_value(GTK_SPIN_BUTTON(data
->NB_fiscyearday
));
1010 PREFS
->fisc_year_month
= 1 + gtk_combo_box_get_active(GTK_COMBO_BOX(data
->CY_fiscyearmonth
));
1013 g_free(PREFS
->path_hbfile
);
1014 PREFS
->path_hbfile
= g_strdup(gtk_entry_get_text(GTK_ENTRY(data
->ST_path_hbfile
)));
1018 g_free(PREFS
->language
);
1019 PREFS
->language
= NULL
;
1020 lang
= gtk_combo_box_get_active_id(GTK_COMBO_BOX(data
->CY_language
));
1023 PREFS
->language
= g_strdup(lang
);
1026 PREFS
->toolbar_style
= gtk_combo_box_get_active(GTK_COMBO_BOX(data
->CY_toolbar
));
1027 //PREFS->image_size = gtk_spin_button_get_value(GTK_SPIN_BUTTON(data->NB_image_size));
1029 PREFS
->custom_colors
= gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(data
->CM_custom_colors
));
1030 gtk_color_chooser_get_rgba(GTK_COLOR_CHOOSER(data
->CP_exp_color
), &rgba
);
1031 g_free(PREFS
->color_exp
);
1032 PREFS
->color_exp
= gdk_rgba_to_hex(&rgba
);
1033 gtk_color_chooser_get_rgba(GTK_COLOR_CHOOSER(data
->CP_inc_color
), &rgba
);
1034 g_free(PREFS
->color_inc
);
1035 PREFS
->color_inc
= gdk_rgba_to_hex(&rgba
);
1036 gtk_color_chooser_get_rgba(GTK_COLOR_CHOOSER(data
->CP_warn_color
), &rgba
);
1037 g_free(PREFS
->color_warn
);
1038 PREFS
->color_warn
= gdk_rgba_to_hex(&rgba
);
1039 //PREFS->rules_hint = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(data->CM_ruleshint));
1040 PREFS
->grid_lines
= gtk_combo_box_get_active(GTK_COMBO_BOX(data
->CY_gridlines
));
1041 //list_txn_colpref_get(GTK_TREE_VIEW(data->LV_opecolumns), PREFS->lst_ope_columns);
1044 PREFS
->date_range_txn
= gtk_combo_box_get_active(GTK_COMBO_BOX(data
->CY_daterange_txn
));
1045 PREFS
->date_future_nbdays
= gtk_spin_button_get_value(GTK_SPIN_BUTTON(data
->ST_datefuture_nbdays
));
1046 PREFS
->hidereconciled
= gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(data
->CM_hide_reconciled
));
1047 PREFS
->showremind
= gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(data
->CM_show_remind
));
1048 PREFS
->heritdate
= gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(data
->CM_herit_date
));
1051 g_free(PREFS
->date_format
);
1052 PREFS
->date_format
= g_strdup(gtk_entry_get_text(GTK_ENTRY(data
->ST_datefmt
)));
1053 PREFS
->vehicle_unit_ismile
= gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(data
->CM_unitismile
));
1054 PREFS
->vehicle_unit_isgal
= gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(data
->CM_unitisgal
));
1057 PREFS
->dtex_datefmt
= gtk_combo_box_get_active(GTK_COMBO_BOX(data
->CY_dtex_datefmt
));
1058 PREFS
->dtex_ofxname
= gtk_combo_box_get_active(GTK_COMBO_BOX(data
->CY_dtex_ofxname
));
1059 PREFS
->dtex_ofxmemo
= gtk_combo_box_get_active(GTK_COMBO_BOX(data
->CY_dtex_ofxmemo
));
1060 PREFS
->dtex_qifmemo
= gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(data
->CM_dtex_qifmemo
));
1061 PREFS
->dtex_qifswap
= gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(data
->CM_dtex_qifswap
));
1062 ui_gtk_entry_replace_text(data
->ST_path_import
, &PREFS
->path_import
);
1063 ui_gtk_entry_replace_text(data
->ST_path_export
, &PREFS
->path_export
);
1066 PREFS
->date_range_rep
= gtk_combo_box_get_active(GTK_COMBO_BOX(data
->CY_daterange_rep
));
1067 PREFS
->report_color_scheme
= gtk_combo_box_get_active(GTK_COMBO_BOX(data
->CY_color_scheme
));
1068 PREFS
->stat_byamount
= gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(data
->CM_stat_byamount
));
1069 PREFS
->stat_showrate
= gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(data
->CM_stat_showrate
));
1070 PREFS
->stat_showdetail
= gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(data
->CM_stat_showdetail
));
1071 PREFS
->budg_showdetail
= gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(data
->CM_budg_showdetail
));
1074 PREFS
->euro_active
= gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(data
->CM_euro_enable
));
1075 PREFS
->euro_country
= data
->country
;
1076 PREFS
->euro_value
= gtk_spin_button_get_value(GTK_SPIN_BUTTON(data
->NB_euro_value
));
1077 //strcpy(PREFS->euro_symbol, gtk_entry_get_text(GTK_ENTRY(data->ST_euro_symbol)));
1078 //PREFS->euro_nbdec = gtk_spin_button_get_value(GTK_SPIN_BUTTON(data->NB_euro_nbdec));
1079 //PREFS->euro_thsep = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(data->CM_euro_thsep));
1080 ui_gtk_entry_replace_text(data
->ST_euro_symbol
, &PREFS
->minor_cur
.symbol
);
1081 PREFS
->minor_cur
.sym_prefix
= gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(data
->CM_euro_isprefix
));
1082 ui_gtk_entry_replace_text(data
->ST_euro_decimalchar
, &PREFS
->minor_cur
.decimal_char
);
1083 ui_gtk_entry_replace_text(data
->ST_euro_groupingchar
, &PREFS
->minor_cur
.grouping_char
);
1084 PREFS
->minor_cur
.frac_digits
= gtk_spin_button_get_value(GTK_SPIN_BUTTON(data
->NB_euro_fracdigits
));
1085 //PREFS->chart_legend = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(data->CM_chartlegend));
1087 list_ext_colpref_get(GTK_TREE_VIEW(data
->PI_plugin_columns
), &(PREFS
->ext_whitelist
));
1091 static GtkWidget
*defpref_page_import (struct defpref_data
*data
)
1093 GtkWidget
*content_grid
, *group_grid
, *hbox
, *label
, *widget
;
1096 content_grid
= gtk_grid_new();
1097 gtk_grid_set_row_spacing (GTK_GRID (content_grid
), SPACING_LARGE
);
1098 gtk_orientable_set_orientation(GTK_ORIENTABLE(content_grid
), GTK_ORIENTATION_VERTICAL
);
1101 // group :: Date options
1102 group_grid
= gtk_grid_new ();
1103 gtk_grid_set_row_spacing (GTK_GRID (group_grid
), SPACING_SMALL
);
1104 gtk_grid_set_column_spacing (GTK_GRID (group_grid
), SPACING_MEDIUM
);
1105 gtk_grid_attach (GTK_GRID (content_grid
), group_grid
, 0, crow
++, 1, 1);
1107 label
= make_label_group(_("Date options"));
1108 gtk_grid_attach (GTK_GRID (group_grid
), label
, 0, 0, 3, 1);
1111 label
= make_label_widget(_("Date order:"));
1112 //----------------------------------------- l, r, t, b
1113 gtk_grid_attach (GTK_GRID (group_grid
), label
, 1, row
, 1, 1);
1114 widget
= make_cycle(label
, CYA_IMPORT_DATEORDER
);
1115 data
->CY_dtex_datefmt
= widget
;
1116 //gtk_grid_attach (GTK_GRID (group_grid), data->CY_option[FILTER_DATE], 1, 2, row, row+1);
1117 gtk_grid_attach (GTK_GRID (group_grid
), widget
, 2, row
, 1, 1);
1120 // group :: OFX/QFX options
1121 group_grid
= gtk_grid_new ();
1122 gtk_grid_set_row_spacing (GTK_GRID (group_grid
), SPACING_SMALL
);
1123 gtk_grid_set_column_spacing (GTK_GRID (group_grid
), SPACING_MEDIUM
);
1124 gtk_grid_attach (GTK_GRID (content_grid
), group_grid
, 0, crow
++, 1, 1);
1126 label
= make_label_group(_("OFX/QFX options"));
1127 gtk_grid_attach (GTK_GRID (group_grid
), label
, 0, 0, 3, 1);
1130 label
= make_label_widget(_("_Name field:"));
1131 //----------------------------------------- l, r, t, b
1132 gtk_grid_attach (GTK_GRID (group_grid
), label
, 1, row
, 1, 1);
1133 widget
= make_cycle(label
, CYA_IMPORT_OFXNAME
);
1134 data
->CY_dtex_ofxname
= widget
;
1135 //gtk_grid_attach (GTK_GRID (group_grid), data->CY_option[FILTER_DATE], 1, 2, row, row+1);
1136 gtk_grid_attach (GTK_GRID (group_grid
), widget
, 2, row
, 1, 1);
1139 label
= make_label_widget(_("_Memo field:"));
1140 //----------------------------------------- l, r, t, b
1141 gtk_grid_attach (GTK_GRID (group_grid
), label
, 1, row
, 1, 1);
1142 widget
= make_cycle(label
, CYA_IMPORT_OFXMEMO
);
1143 data
->CY_dtex_ofxmemo
= widget
;
1144 //gtk_grid_attach (GTK_GRID (group_grid), data->CY_option[FILTER_DATE], 1, 2, row, row+1);
1145 gtk_grid_attach (GTK_GRID (group_grid
), widget
, 2, row
, 1, 1);
1147 // group :: QIF options
1148 group_grid
= gtk_grid_new ();
1149 gtk_grid_set_row_spacing (GTK_GRID (group_grid
), SPACING_SMALL
);
1150 gtk_grid_set_column_spacing (GTK_GRID (group_grid
), SPACING_MEDIUM
);
1151 gtk_grid_attach (GTK_GRID (content_grid
), group_grid
, 0, crow
++, 1, 1);
1153 label
= make_label_group(_("QIF options"));
1154 gtk_grid_attach (GTK_GRID (group_grid
), label
, 0, 0, 3, 1);
1157 label
= make_label_widget(_("Memos:"));
1158 gtk_grid_attach (GTK_GRID (group_grid
), label
, 1, row
, 1, 1);
1159 widget
= gtk_check_button_new_with_mnemonic (_("_Import"));
1160 data
->CM_dtex_qifmemo
= widget
;
1161 gtk_grid_attach (GTK_GRID (group_grid
), widget
, 2, row
, 1, 1);
1162 widget
= gtk_check_button_new_with_mnemonic (_("_Swap with payees"));
1163 data
->CM_dtex_qifswap
= widget
;
1164 gtk_grid_attach (GTK_GRID (group_grid
), widget
, 3, row
, 1, 1);
1167 // group :: Files folder
1168 group_grid
= gtk_grid_new ();
1169 gtk_grid_set_row_spacing (GTK_GRID (group_grid
), SPACING_SMALL
);
1170 gtk_grid_set_column_spacing (GTK_GRID (group_grid
), SPACING_MEDIUM
);
1171 gtk_grid_attach (GTK_GRID (content_grid
), group_grid
, 0, crow
++, 1, 1);
1173 label
= make_label_group(_("Files folder"));
1174 gtk_grid_attach (GTK_GRID (group_grid
), label
, 0, 0, 3, 1);
1177 label
= make_label_widget(_("_Import:"));
1178 //----------------------------------------- l, r, t, b
1179 gtk_grid_attach (GTK_GRID (group_grid
), label
, 1, row
, 1, 1);
1181 hbox
= gtk_box_new(GTK_ORIENTATION_HORIZONTAL
, 0);
1182 gtk_widget_set_hexpand (hbox
, TRUE
);
1183 gtk_grid_attach (GTK_GRID (group_grid
), hbox
, 2, row
, 1, 1);
1185 widget
= make_string(label
);
1186 data
->ST_path_import
= widget
;
1187 gtk_style_context_add_class (gtk_widget_get_style_context (GTK_WIDGET(widget
)), GTK_STYLE_CLASS_LINKED
);
1188 gtk_box_pack_start (GTK_BOX (hbox
), widget
, TRUE
, TRUE
, 0);
1190 //widget = gtk_button_new_with_label("...");
1191 widget
= gtk_button_new_from_icon_name(ICONNAME_FOLDER
, GTK_ICON_SIZE_BUTTON
);
1192 data
->BT_path_import
= widget
;
1193 gtk_box_pack_start (GTK_BOX (hbox
), widget
, FALSE
, FALSE
, 0);
1196 label
= make_label_widget(_("_Export:"));
1197 //----------------------------------------- l, r, t, b
1198 gtk_grid_attach (GTK_GRID (group_grid
), label
, 1, row
, 1, 1);
1200 hbox
= gtk_box_new(GTK_ORIENTATION_HORIZONTAL
, 0);
1201 gtk_widget_set_hexpand (hbox
, TRUE
);
1202 gtk_grid_attach (GTK_GRID (group_grid
), hbox
, 2, row
, 1, 1);
1204 widget
= make_string(label
);
1205 data
->ST_path_export
= widget
;
1206 gtk_style_context_add_class (gtk_widget_get_style_context (GTK_WIDGET(widget
)), GTK_STYLE_CLASS_LINKED
);
1207 gtk_box_pack_start (GTK_BOX (hbox
), widget
, TRUE
, TRUE
, 0);
1209 //widget = gtk_button_new_with_label("...");
1210 widget
= gtk_button_new_from_icon_name(ICONNAME_FOLDER
, GTK_ICON_SIZE_BUTTON
);
1211 data
->BT_path_export
= widget
;
1212 gtk_box_pack_start (GTK_BOX (hbox
), widget
, FALSE
, FALSE
, 0);
1214 return content_grid
;
1220 draw_callback (GtkWidget
*widget
,
1224 struct defpref_data
*data
= user_data
;
1226 GtkColorScheme scheme
;
1230 index
= gtk_combo_box_get_active(GTK_COMBO_BOX(data
->CY_color_scheme
));
1232 colorscheme_init(&scheme
, index
);
1234 gtk_widget_get_size_request (widget
, &w
, &h
);
1236 for(i
=0;i
<scheme
.nb_cols
;i
++)
1238 cairo_user_set_rgbcol (cr
, &scheme
.colors
[i
]);
1239 cairo_rectangle(cr
, x
, y
, cube_dim
, cube_dim
);
1243 { x
= 0; y
= 1 + cube_dim
; }
1251 static GtkWidget
*defpref_page_reports (struct defpref_data
*data
)
1253 GtkWidget
*content_grid
, *group_grid
, *label
, *widget
;
1256 content_grid
= gtk_grid_new();
1257 gtk_grid_set_row_spacing (GTK_GRID (content_grid
), SPACING_LARGE
);
1258 gtk_orientable_set_orientation(GTK_ORIENTABLE(content_grid
), GTK_ORIENTATION_VERTICAL
);
1261 // group :: Initial filter
1262 group_grid
= gtk_grid_new ();
1263 gtk_grid_set_row_spacing (GTK_GRID (group_grid
), SPACING_SMALL
);
1264 gtk_grid_set_column_spacing (GTK_GRID (group_grid
), SPACING_MEDIUM
);
1265 gtk_grid_attach (GTK_GRID (content_grid
), group_grid
, 0, crow
++, 1, 1);
1267 label
= make_label_group(_("Initial filter"));
1268 gtk_grid_attach (GTK_GRID (group_grid
), label
, 0, 0, 3, 1);
1271 label
= make_label_widget(_("Date _range:"));
1272 //----------------------------------------- l, r, t, b
1273 gtk_grid_attach (GTK_GRID (group_grid
), label
, 1, row
, 1, 1);
1274 widget
= make_daterange(label
, FALSE
);
1275 data
->CY_daterange_rep
= widget
;
1276 //gtk_grid_attach (GTK_GRID (group_grid), data->CY_option[FILTER_DATE], 1, 2, row, row+1);
1277 gtk_grid_attach (GTK_GRID (group_grid
), widget
, 2, row
, 1, 1);
1279 // group ::Charts options
1280 group_grid
= gtk_grid_new ();
1281 gtk_grid_set_row_spacing (GTK_GRID (group_grid
), SPACING_SMALL
);
1282 gtk_grid_set_column_spacing (GTK_GRID (group_grid
), SPACING_MEDIUM
);
1283 gtk_grid_attach (GTK_GRID (content_grid
), group_grid
, 0, crow
++, 1, 1);
1285 label
= make_label_group(_("Charts options"));
1286 gtk_grid_attach (GTK_GRID (group_grid
), label
, 0, 0, 3, 1);
1289 label
= make_label_widget(_("Color scheme:"));
1290 //----------------------------------------- l, r, t, b
1291 gtk_grid_attach (GTK_GRID (group_grid
), label
, 1, row
, 1, 1);
1292 widget
= make_cycle(label
, chart_colors
);
1293 data
->CY_color_scheme
= widget
;
1294 //gtk_grid_attach (GTK_GRID (group_grid), data->CY_option[FILTER_DATE], 1, 2, row, row+1);
1295 gtk_grid_attach (GTK_GRID (group_grid
), widget
, 2, row
, 1, 1);
1298 widget
= gtk_drawing_area_new ();
1299 data
->DA_colors
= widget
;
1300 gtk_widget_set_size_request (widget
, (1+cube_dim
)*16, (1+cube_dim
)*2);
1301 gtk_grid_attach (GTK_GRID (group_grid
), widget
, 2, row
, 1, 1);
1303 g_signal_connect (data
->DA_colors
, "draw", G_CALLBACK (draw_callback
), data
);
1305 // group :: Statistics options
1306 group_grid
= gtk_grid_new ();
1307 gtk_grid_set_row_spacing (GTK_GRID (group_grid
), SPACING_SMALL
);
1308 gtk_grid_set_column_spacing (GTK_GRID (group_grid
), SPACING_MEDIUM
);
1309 gtk_grid_attach (GTK_GRID (content_grid
), group_grid
, 0, crow
++, 1, 1);
1311 label
= make_label_group(_("Statistics options"));
1312 gtk_grid_attach (GTK_GRID (group_grid
), label
, 0, 0, 3, 1);
1315 widget
= gtk_check_button_new_with_mnemonic (_("Show by _amount"));
1316 data
->CM_stat_byamount
= widget
;
1317 gtk_grid_attach (GTK_GRID (group_grid
), widget
, 1, row
, 2, 1);
1320 widget
= gtk_check_button_new_with_mnemonic (_("Show _rate column"));
1321 data
->CM_stat_showrate
= widget
;
1322 gtk_grid_attach (GTK_GRID (group_grid
), widget
, 1, row
, 2, 1);
1325 widget
= gtk_check_button_new_with_mnemonic (_("Show _details"));
1326 data
->CM_stat_showdetail
= widget
;
1327 gtk_grid_attach (GTK_GRID (group_grid
), widget
, 1, row
, 2, 1);
1329 // group :: Budget options
1330 group_grid
= gtk_grid_new ();
1331 gtk_grid_set_row_spacing (GTK_GRID (group_grid
), SPACING_SMALL
);
1332 gtk_grid_set_column_spacing (GTK_GRID (group_grid
), SPACING_MEDIUM
);
1333 gtk_grid_attach (GTK_GRID (content_grid
), group_grid
, 0, crow
++, 1, 1);
1335 label
= make_label_group(_("Budget options"));
1336 gtk_grid_attach (GTK_GRID (group_grid
), label
, 0, 0, 3, 1);
1339 widget
= gtk_check_button_new_with_mnemonic (_("Show _details"));
1340 data
->CM_budg_showdetail
= widget
;
1341 gtk_grid_attach (GTK_GRID (group_grid
), widget
, 1, row
, 2, 1);
1343 return content_grid
;
1347 static GtkWidget
*defpref_page_euro (struct defpref_data
*data
)
1349 GtkWidget
*content_grid
, *group_grid
, *label
, *widget
, *expander
;
1352 content_grid
= gtk_grid_new();
1353 gtk_grid_set_row_spacing (GTK_GRID (content_grid
), SPACING_LARGE
);
1354 gtk_orientable_set_orientation(GTK_ORIENTABLE(content_grid
), GTK_ORIENTATION_VERTICAL
);
1358 group_grid
= gtk_grid_new ();
1359 gtk_grid_set_row_spacing (GTK_GRID (group_grid
), SPACING_SMALL
);
1360 gtk_grid_set_column_spacing (GTK_GRID (group_grid
), SPACING_MEDIUM
);
1361 gtk_grid_attach (GTK_GRID (content_grid
), group_grid
, 0, crow
++, 1, 1);
1363 label
= make_label_group(_("General"));
1364 gtk_grid_attach (GTK_GRID (group_grid
), label
, 0, 0, 3, 1);
1367 widget
= gtk_check_button_new_with_mnemonic (_("_Enable"));
1368 data
->CM_euro_enable
= widget
;
1369 gtk_grid_attach (GTK_GRID (group_grid
), widget
, 1, row
, 2, 1);
1371 // group :: Currency
1372 group_grid
= gtk_grid_new ();
1373 data
->GRP_currency
= group_grid
;
1374 gtk_grid_set_row_spacing (GTK_GRID (group_grid
), SPACING_SMALL
);
1375 gtk_grid_set_column_spacing (GTK_GRID (group_grid
), SPACING_MEDIUM
);
1376 gtk_grid_attach (GTK_GRID (content_grid
), group_grid
, 0, crow
++, 1, 1);
1378 label
= make_label_group(_("Currency"));
1379 gtk_grid_attach (GTK_GRID (group_grid
), label
, 0, 0, 4, 1);
1382 widget
= make_label(NULL
, 0.0, 0.5);
1383 data
->ST_euro_country
= widget
;
1384 //gtk_grid_attach (GTK_GRID (group_grid), data->CY_option[FILTER_DATE], 1, 2, row, row+1);
1385 gtk_grid_attach (GTK_GRID (group_grid
), widget
, 1, row
, 1, 1);
1388 label
= make_label_widget(_("_Preset:"));
1389 //----------------------------------------- l, r, t, b
1390 gtk_grid_attach (GTK_GRID (group_grid
), label
, 2, row
, 1, 1);
1391 widget
= ui_euro_combobox_new (label
);
1392 data
->CY_euro_preset
= widget
;
1393 gtk_widget_set_margin_left (label
, 2*SPACING_LARGE
);
1394 //gtk_grid_attach (GTK_GRID (group_grid), data->CY_option[FILTER_DATE], 1, 2, row, row+1);
1395 gtk_grid_attach (GTK_GRID (group_grid
), widget
, 3, row
, 1, 1);
1398 // group :: Exchange rate
1399 group_grid
= gtk_grid_new ();
1400 data
->GRP_rate
= group_grid
;
1401 gtk_grid_set_row_spacing (GTK_GRID (group_grid
), SPACING_SMALL
);
1402 gtk_grid_set_column_spacing (GTK_GRID (group_grid
), SPACING_MEDIUM
);
1403 gtk_grid_attach (GTK_GRID (content_grid
), group_grid
, 0, crow
++, 1, 1);
1405 label
= make_label_group(_("Exchange rate"));
1406 gtk_grid_attach (GTK_GRID (group_grid
), label
, 0, 0, 3, 1);
1409 label
= make_label_widget("1 EUR _=");
1410 gtk_grid_attach (GTK_GRID (group_grid
), label
, 1, row
, 1, 1);
1411 widget
= make_exchange_rate(label
);
1412 data
->NB_euro_value
= widget
;
1413 //gtk_grid_attach (GTK_GRID (group_grid), data->CY_option[FILTER_DATE], 1, 2, row, row+1);
1414 gtk_grid_attach (GTK_GRID (group_grid
), widget
, 2, row
, 1, 1);
1416 // group :: Numbers format
1417 group_grid
= gtk_grid_new ();
1418 data
->GRP_format
= group_grid
;
1419 gtk_grid_set_row_spacing (GTK_GRID (group_grid
), SPACING_SMALL
);
1420 gtk_grid_set_column_spacing (GTK_GRID (group_grid
), SPACING_MEDIUM
);
1421 gtk_grid_attach (GTK_GRID (content_grid
), group_grid
, 0, crow
++, 1, 1);
1423 label
= make_label_group(_("Format"));
1424 gtk_grid_attach (GTK_GRID (group_grid
), label
, 0, 0, 3, 1);
1427 widget
= make_label(NULL
, 0, 0.0);
1428 data
->LB_numbereuro
= widget
;
1429 gtk_grid_attach (GTK_GRID (group_grid
), widget
, 1, row
, 1, 1);
1432 expander
= gtk_expander_new_with_mnemonic(_("_Customize"));
1433 gtk_grid_attach (GTK_GRID (group_grid
), expander
, 1, row
, 1, 1);
1435 group_grid
= gtk_grid_new ();
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_container_add (GTK_CONTAINER (expander
), group_grid
);
1441 label
= make_label_widget(_("_Symbol:"));
1442 gtk_grid_attach (GTK_GRID (group_grid
), label
, 1, row
, 1, 1);
1443 widget
= make_string_maxlength(label
, 3);
1444 data
->ST_euro_symbol
= widget
;
1445 gtk_grid_attach (GTK_GRID (group_grid
), widget
, 2, row
, 1, 1);
1448 widget
= gtk_check_button_new_with_mnemonic (_("Is pre_fix"));
1449 data
->CM_euro_isprefix
= widget
;
1450 gtk_grid_attach (GTK_GRID (group_grid
), widget
, 2, row
, 1, 1);
1453 label
= make_label_widget(_("_Decimal char:"));
1454 gtk_grid_attach (GTK_GRID (group_grid
), label
, 1, row
, 1, 1);
1455 widget
= make_string_maxlength(label
, 1);
1456 data
->ST_euro_decimalchar
= widget
;
1457 gtk_grid_attach (GTK_GRID (group_grid
), widget
, 2, row
, 1, 1);
1460 label
= make_label_widget(_("_Frac digits:"));
1461 gtk_grid_attach (GTK_GRID (group_grid
), label
, 1, row
, 1, 1);
1462 widget
= make_numeric(label
, 0.0, 6.0);
1463 data
->NB_euro_fracdigits
= widget
;
1464 gtk_grid_attach (GTK_GRID (group_grid
), widget
, 2, row
, 1, 1);
1467 label
= make_label_widget(_("_Grouping char:"));
1468 gtk_grid_attach (GTK_GRID (group_grid
), label
, 1, row
, 1, 1);
1469 widget
= make_string_maxlength(label
, 1);
1470 data
->ST_euro_groupingchar
= widget
;
1471 gtk_grid_attach (GTK_GRID (group_grid
), widget
, 2, row
, 1, 1);
1473 return content_grid
;
1477 static GtkWidget
*defpref_page_display (struct defpref_data
*data
)
1479 GtkWidget
*content_grid
, *group_grid
, *label
, *widget
, *expander
;
1482 content_grid
= gtk_grid_new();
1483 gtk_grid_set_row_spacing (GTK_GRID (content_grid
), SPACING_LARGE
);
1484 gtk_orientable_set_orientation(GTK_ORIENTABLE(content_grid
), GTK_ORIENTATION_VERTICAL
);
1487 // group :: Date options
1488 group_grid
= gtk_grid_new ();
1489 gtk_grid_set_row_spacing (GTK_GRID (group_grid
), SPACING_SMALL
);
1490 gtk_grid_set_column_spacing (GTK_GRID (group_grid
), SPACING_MEDIUM
);
1491 gtk_grid_attach (GTK_GRID (content_grid
), group_grid
, 0, crow
++, 1, 1);
1493 label
= make_label_group(_("Date"));
1494 gtk_grid_attach (GTK_GRID (group_grid
), label
, 0, 0, 3, 1);
1497 widget
= make_label(NULL
, 0, 0.5);
1498 data
->LB_date
= widget
;
1499 gtk_grid_attach (GTK_GRID (group_grid
), widget
, 1, row
, 2, 1);
1502 expander
= gtk_expander_new_with_mnemonic(_("_Customize"));
1503 gtk_grid_attach (GTK_GRID (group_grid
), expander
, 1, row
, 1, 1);
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_container_add (GTK_CONTAINER (expander
), group_grid
);
1511 label
= make_label_widget(_("_Format:"));
1512 //----------------------------------------- l, r, t, b
1513 gtk_grid_attach (GTK_GRID (group_grid
), label
, 1, row
, 1, 1);
1514 widget
= make_string(label
);
1515 data
->ST_datefmt
= widget
;
1516 //gtk_grid_attach (GTK_GRID (group_grid), data->CY_option[FILTER_DATE], 1, 2, row, row+1);
1517 gtk_grid_attach (GTK_GRID (group_grid
), widget
, 2, row
, 1, 1);
1519 widget
= gtk_image_new_from_icon_name (ICONNAME_INFO
, GTK_ICON_SIZE_BUTTON
);
1520 gtk_grid_attach (GTK_GRID (group_grid
), widget
, 3, row
, 1, 1);
1523 gtk_widget_set_tooltip_text(widget
,
1524 _("%a locale's abbreviated weekday name.\n"
1525 "%A locale's full weekday name. \n"
1526 "%b locale's abbreviated month name. \n"
1527 "%B locale's full month name. \n"
1528 "%c locale's appropriate date and time representation. \n"
1529 "%C century number (the year divided by 100 and truncated to an integer) as a decimal number [00-99]. \n"
1530 "%d day of the month as a decimal number [01,31]. \n"
1531 "%D same as %m/%d/%y. \n"
1532 "%e day of the month as a decimal number [1,31]; a single digit is preceded by a space. \n"
1533 "%j day of the year as a decimal number [001,366]. \n"
1534 "%m month as a decimal number [01,12]. \n"
1535 "%p locale's appropriate date representation. \n"
1536 "%y year without century as a decimal number [00,99]. \n"
1537 "%Y year with century as a decimal number. \n")
1541 widget
= make_label(NULL
, 0.0, 0.5);
1542 gtk_label_set_markup (GTK_LABEL(widget
), "<small><a href=\"http://man7.org/linux/man-pages/man3/strftime.3.html\">online reference</a></small>");
1543 gtk_grid_attach (GTK_GRID (group_grid
), widget
, 2, row
, 1, 1);
1545 // group :: Measurement units
1546 group_grid
= gtk_grid_new ();
1547 gtk_grid_set_row_spacing (GTK_GRID (group_grid
), SPACING_SMALL
);
1548 gtk_grid_set_column_spacing (GTK_GRID (group_grid
), SPACING_MEDIUM
);
1549 gtk_grid_attach (GTK_GRID (content_grid
), group_grid
, 0, crow
++, 1, 1);
1551 label
= make_label_group(_("Measurement units"));
1552 gtk_grid_attach (GTK_GRID (group_grid
), label
, 0, 0, 3, 1);
1555 widget
= gtk_check_button_new_with_mnemonic (_("Use _miles for meter"));
1556 data
->CM_unitismile
= widget
;
1557 gtk_grid_attach (GTK_GRID (group_grid
), widget
, 1, row
, 2, 1);
1560 widget
= gtk_check_button_new_with_mnemonic (_("Use _gallon for fuel"));
1561 data
->CM_unitisgal
= widget
;
1562 gtk_grid_attach (GTK_GRID (group_grid
), widget
, 1, row
, 2, 1);
1564 return content_grid
;
1568 static GtkWidget
*defpref_page_transactions (struct defpref_data
*data
)
1570 GtkWidget
*content_grid
, *group_grid
, *label
, *widget
;
1573 content_grid
= gtk_grid_new();
1574 gtk_grid_set_row_spacing (GTK_GRID (content_grid
), SPACING_LARGE
);
1575 gtk_orientable_set_orientation(GTK_ORIENTABLE(content_grid
), GTK_ORIENTATION_VERTICAL
);
1578 // group :: Transaction window
1579 group_grid
= gtk_grid_new ();
1580 gtk_grid_set_row_spacing (GTK_GRID (group_grid
), SPACING_SMALL
);
1581 gtk_grid_set_column_spacing (GTK_GRID (group_grid
), SPACING_MEDIUM
);
1582 gtk_grid_attach (GTK_GRID (content_grid
), group_grid
, 0, crow
++, 1, 1);
1584 label
= make_label_group(_("Transaction window"));
1585 gtk_grid_attach (GTK_GRID (group_grid
), label
, 0, 0, 3, 1);
1588 label
= make_label_widget(_("Date _range:"));
1589 //----------------------------------------- l, r, t, b
1590 gtk_grid_attach (GTK_GRID (group_grid
), label
, 1, row
, 1, 1);
1591 widget
= make_daterange(label
, FALSE
);
1592 data
->CY_daterange_txn
= widget
;
1593 gtk_grid_attach (GTK_GRID (group_grid
), widget
, 2, row
, 1, 1);
1596 label
= make_label_widget(_("_Show:"));
1597 //----------------------------------------- l, r, t, b
1598 gtk_grid_attach (GTK_GRID (group_grid
), label
, 1, row
, 1, 1);
1599 widget
= make_numeric(NULL
, 0, 366);
1601 data
->ST_datefuture_nbdays
= widget
;
1602 gtk_grid_attach (GTK_GRID (group_grid
), widget
, 2, row
, 1, 1);
1604 //TRANSLATORS: there is a spinner on the left of this label, and so you have 0....x days in advance the current date
1605 label
= make_label(_("days in advance the current date"), 0, 0.5);
1606 gtk_grid_attach (GTK_GRID (group_grid
), label
, 3, row
, 1, 1);
1609 widget
= gtk_check_button_new_with_mnemonic (_("Hide reconciled transactions"));
1610 data
->CM_hide_reconciled
= widget
;
1611 gtk_grid_attach (GTK_GRID (group_grid
), widget
, 2, row
, 2, 1);
1614 widget
= gtk_check_button_new_with_mnemonic (_("Always show remind transactions"));
1615 data
->CM_show_remind
= widget
;
1616 gtk_grid_attach (GTK_GRID (group_grid
), widget
, 2, row
, 2, 1);
1618 // group :: Multiple add
1619 group_grid
= gtk_grid_new ();
1620 gtk_grid_set_row_spacing (GTK_GRID (group_grid
), SPACING_SMALL
);
1621 gtk_grid_set_column_spacing (GTK_GRID (group_grid
), SPACING_MEDIUM
);
1622 gtk_grid_attach (GTK_GRID (content_grid
), group_grid
, 0, crow
++, 1, 1);
1624 label
= make_label_group(_("Multiple add"));
1625 gtk_grid_attach (GTK_GRID (group_grid
), label
, 0, 0, 3, 1);
1628 widget
= gtk_check_button_new_with_mnemonic (_("Keep the last date"));
1629 data
->CM_herit_date
= widget
;
1630 gtk_grid_attach (GTK_GRID (group_grid
), widget
, 1, row
, 2, 1);
1632 // group :: Column list
1634 group_grid = gtk_grid_new ();
1635 gtk_grid_set_row_spacing (GTK_GRID (group_grid), SPACING_SMALL);
1636 gtk_grid_set_column_spacing (GTK_GRID (group_grid), SPACING_MEDIUM);
1637 gtk_grid_attach (GTK_GRID (content_grid), group_grid, 0, crow++, 1, 1);
1639 label = make_label_group(_("Column list"));
1640 gtk_grid_attach (GTK_GRID (group_grid), label, 0, 0, 3, 1);
1643 sw = gtk_scrolled_window_new (NULL, NULL);
1644 gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (sw), GTK_SHADOW_ETCHED_IN);
1645 gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (sw), GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC);
1646 widget = (GtkWidget *)list_txn_colprefcreate();
1647 data->LV_opecolumns = widget;
1648 gtk_widget_set_size_request(data->LV_opecolumns, HB_MINWIDTH_LIST, -1);
1649 gtk_container_add (GTK_CONTAINER (sw), widget);
1650 gtk_widget_set_vexpand (sw, TRUE);
1651 gtk_grid_attach (GTK_GRID (group_grid), sw, 1, row, 2, 1);
1652 gtk_widget_set_tooltip_text(widget, _("Drag & drop to change the order"));
1655 return content_grid
;
1660 static GtkWidget
*defpref_page_interface (struct defpref_data
*data
)
1662 GtkWidget
*content_grid
, *group_grid
, *hbox
, *label
, *widget
;
1665 content_grid
= gtk_grid_new();
1666 gtk_grid_set_row_spacing (GTK_GRID (content_grid
), SPACING_LARGE
);
1667 gtk_orientable_set_orientation(GTK_ORIENTABLE(content_grid
), GTK_ORIENTATION_VERTICAL
);
1671 group_grid
= gtk_grid_new ();
1672 gtk_grid_set_row_spacing (GTK_GRID (group_grid
), SPACING_SMALL
);
1673 gtk_grid_set_column_spacing (GTK_GRID (group_grid
), SPACING_MEDIUM
);
1674 gtk_grid_attach (GTK_GRID (content_grid
), group_grid
, 0, crow
++, 1, 1);
1676 label
= make_label_group(_("General"));
1677 gtk_grid_attach (GTK_GRID (group_grid
), label
, 0, 0, 3, 1);
1680 label
= make_label_widget(_("_Language:"));
1681 gtk_grid_attach (GTK_GRID (group_grid
), label
, 1, row
, 1, 1);
1682 widget
= ui_language_combobox_new(label
);
1683 data
->CY_language
= widget
;
1684 gtk_grid_attach (GTK_GRID (group_grid
), widget
, 2, row
, 1, 1);
1687 label
= make_label_widget(_("_Toolbar:"));
1688 gtk_grid_attach (GTK_GRID (group_grid
), label
, 1, row
, 1, 1);
1689 widget
= make_cycle(label
, CYA_TOOLBAR_STYLE
);
1690 data
->CY_toolbar
= widget
;
1691 gtk_grid_attach (GTK_GRID (group_grid
), widget
, 2, row
, 1, 1);
1695 //widget = gtk_check_button_new_with_mnemonic (_("Enable rows in alternating colors"));
1696 //data->CM_ruleshint = widget;
1697 label
= make_label_widget(_("_Grid line:"));
1698 gtk_grid_attach (GTK_GRID (group_grid
), label
, 1, row
, 1, 1);
1699 widget
= make_cycle(label
, CYA_GRID_LINES
);
1700 data
->CY_gridlines
= widget
;
1701 gtk_grid_attach (GTK_GRID (group_grid
), widget
, 2, row
, 1, 1);
1703 // group :: Amount colors
1704 group_grid
= gtk_grid_new ();
1705 gtk_grid_set_row_spacing (GTK_GRID (group_grid
), SPACING_SMALL
);
1706 gtk_grid_set_column_spacing (GTK_GRID (group_grid
), SPACING_MEDIUM
);
1707 gtk_grid_attach (GTK_GRID (content_grid
), group_grid
, 0, crow
++, 1, 1);
1709 label
= make_label_group(_("Amount colors"));
1710 gtk_grid_attach (GTK_GRID (group_grid
), label
, 0, 0, 3, 1);
1713 widget
= gtk_check_button_new_with_mnemonic (_("Uses custom colors"));
1714 data
->CM_custom_colors
= widget
;
1715 gtk_grid_attach (GTK_GRID (group_grid
), widget
, 2, row
, 1, 1);
1717 group_grid
= gtk_grid_new ();
1718 data
->GR_colors
= group_grid
;
1719 gtk_grid_set_row_spacing (GTK_GRID (group_grid
), SPACING_SMALL
);
1720 gtk_grid_set_column_spacing (GTK_GRID (group_grid
), SPACING_MEDIUM
);
1721 gtk_grid_attach (GTK_GRID (content_grid
), group_grid
, 0, crow
++, 1, 1);
1724 label
= make_label_widget(_("_Preset:"));
1725 //----------------------------------------- l, r, t, b
1726 gtk_grid_attach (GTK_GRID (group_grid
), label
, 1, row
, 1, 1);
1727 widget
= make_cycle(label
, CYA_TANGO_COLORS
);
1728 data
->CY_colors
= widget
;
1729 //gtk_grid_attach (GTK_GRID (group_grid), data->CY_option[FILTER_DATE], 1, 2, row, row+1);
1730 gtk_grid_attach (GTK_GRID (group_grid
), widget
, 2, row
, 1, 1);
1733 label
= make_label_widget(_("_Expense:"));
1734 //----------------------------------------- l, r, t, b
1735 gtk_grid_attach (GTK_GRID (group_grid
), label
, 1, row
, 1, 1);
1736 hbox
= gtk_box_new(GTK_ORIENTATION_HORIZONTAL
, SPACING_SMALL
);
1737 gtk_grid_attach (GTK_GRID (group_grid
), hbox
, 2, row
, 1, 1);
1739 widget
= gtk_color_button_new ();
1740 data
->CP_exp_color
= widget
;
1741 gtk_box_pack_start (GTK_BOX (hbox
), widget
, FALSE
, FALSE
, 0);
1743 label
= make_label_widget(_("_Income:"));
1744 gtk_box_pack_start (GTK_BOX (hbox
), label
, FALSE
, FALSE
, 0);
1746 widget
= gtk_color_button_new ();
1747 data
->CP_inc_color
= widget
;
1748 gtk_box_pack_start (GTK_BOX (hbox
), widget
, FALSE
, FALSE
, 0);
1750 label
= make_label_widget(_("_Warning:"));
1751 gtk_box_pack_start (GTK_BOX (hbox
), label
, FALSE
, FALSE
, 0);
1753 widget
= gtk_color_button_new ();
1754 data
->CP_warn_color
= widget
;
1755 gtk_box_pack_start (GTK_BOX (hbox
), widget
, FALSE
, FALSE
, 0);
1757 return content_grid
;
1761 static GtkWidget
*defpref_page_general (struct defpref_data
*data
)
1763 GtkWidget
*content_grid
, *group_grid
, *hbox
, *label
, *widget
;
1766 content_grid
= gtk_grid_new();
1767 gtk_grid_set_row_spacing (GTK_GRID (content_grid
), SPACING_LARGE
);
1768 gtk_orientable_set_orientation(GTK_ORIENTABLE(content_grid
), GTK_ORIENTATION_VERTICAL
);
1771 // group :: Program start
1772 group_grid
= gtk_grid_new ();
1773 gtk_grid_set_row_spacing (GTK_GRID (group_grid
), SPACING_SMALL
);
1774 gtk_grid_set_column_spacing (GTK_GRID (group_grid
), SPACING_MEDIUM
);
1775 gtk_grid_attach (GTK_GRID (content_grid
), group_grid
, 0, crow
++, 1, 1);
1777 label
= make_label_group(_("Program start"));
1778 gtk_grid_attach (GTK_GRID (group_grid
), label
, 0, 0, 3, 1);
1781 widget
= gtk_check_button_new_with_mnemonic (_("Show splash screen"));
1782 data
->CM_show_splash
= widget
;
1783 gtk_grid_attach (GTK_GRID (group_grid
), widget
, 1, row
, 2, 1);
1786 widget
= gtk_check_button_new_with_mnemonic (_("Load last opened file"));
1787 data
->CM_load_last
= widget
;
1788 gtk_grid_attach (GTK_GRID (group_grid
), widget
, 1, row
, 2, 1);
1791 widget
= gtk_check_button_new_with_mnemonic (_("Post pending scheduled transactions"));
1792 data
->CM_append_scheduled
= widget
;
1793 gtk_grid_attach (GTK_GRID (group_grid
), widget
, 1, row
, 2, 1);
1796 widget
= gtk_check_button_new_with_mnemonic (_("Update currencies online"));
1797 data
->CM_do_update_currency
= widget
;
1798 gtk_grid_attach (GTK_GRID (group_grid
), widget
, 1, row
, 2, 1);
1800 // group :: Fiscal year
1801 group_grid
= gtk_grid_new ();
1802 gtk_grid_set_row_spacing (GTK_GRID (group_grid
), SPACING_SMALL
);
1803 gtk_grid_set_column_spacing (GTK_GRID (group_grid
), SPACING_MEDIUM
);
1804 gtk_grid_attach (GTK_GRID (content_grid
), group_grid
, 0, crow
++, 1, 1);
1806 label
= make_label_group(_("Fiscal year"));
1807 gtk_grid_attach (GTK_GRID (group_grid
), label
, 0, 0, 3, 1);
1810 //TRANSLATORS: (fiscal year) starts on
1811 label
= make_label_widget(_("Starts _on:"));
1812 gtk_grid_attach (GTK_GRID (group_grid
), label
, 1, row
, 1, 1);
1814 hbox
= gtk_box_new(GTK_ORIENTATION_HORIZONTAL
, SPACING_SMALL
);
1815 gtk_grid_attach (GTK_GRID (group_grid
), hbox
, 2, row
, 1, 1);
1816 widget
= make_numeric (label
, 1, 28);
1817 data
->NB_fiscyearday
= widget
;
1818 gtk_box_pack_start (GTK_BOX (hbox
), widget
, FALSE
, FALSE
, 0);
1819 widget
= make_cycle (NULL
, CYA_MONTHS
);
1820 data
->CY_fiscyearmonth
= widget
;
1821 gtk_box_pack_start (GTK_BOX (hbox
), widget
, FALSE
, FALSE
, 0);
1823 // group :: Main window reports
1824 group_grid
= gtk_grid_new ();
1825 gtk_grid_set_row_spacing (GTK_GRID (group_grid
), SPACING_SMALL
);
1826 gtk_grid_set_column_spacing (GTK_GRID (group_grid
), SPACING_MEDIUM
);
1827 gtk_grid_attach (GTK_GRID (content_grid
), group_grid
, 0, crow
++, 1, 1);
1829 label
= make_label_group(_("Main window reports"));
1830 gtk_grid_attach (GTK_GRID (group_grid
), label
, 0, 0, 3, 1);
1833 label
= make_label_widget(_("Date _range:"));
1834 gtk_grid_attach (GTK_GRID (group_grid
), label
, 1, row
, 1, 1);
1835 widget
= make_daterange(label
, FALSE
);
1836 data
->CY_daterange_wal
= widget
;
1837 gtk_grid_attach (GTK_GRID (group_grid
), widget
, 2, row
, 1, 1);
1839 // group :: Files folder
1840 group_grid
= gtk_grid_new ();
1841 gtk_grid_set_row_spacing (GTK_GRID (group_grid
), SPACING_SMALL
);
1842 gtk_grid_set_column_spacing (GTK_GRID (group_grid
), SPACING_MEDIUM
);
1843 gtk_grid_attach (GTK_GRID (content_grid
), group_grid
, 0, crow
++, 1, 1);
1845 label
= make_label_group(_("Files folder"));
1846 gtk_grid_attach (GTK_GRID (group_grid
), label
, 0, 0, 3, 1);
1849 label
= make_label_widget(_("_Default:"));
1850 gtk_grid_attach (GTK_GRID (group_grid
), label
, 1, row
, 1, 1);
1852 hbox
= gtk_box_new(GTK_ORIENTATION_HORIZONTAL
, 0);
1853 gtk_widget_set_hexpand (hbox
, TRUE
);
1854 gtk_grid_attach (GTK_GRID (group_grid
), hbox
, 2, row
, 1, 1);
1856 widget
= make_string(label
);
1857 data
->ST_path_hbfile
= widget
;
1858 gtk_style_context_add_class (gtk_widget_get_style_context (GTK_WIDGET(widget
)), GTK_STYLE_CLASS_LINKED
);
1859 gtk_box_pack_start (GTK_BOX (hbox
), widget
, TRUE
, TRUE
, 0);
1861 //widget = gtk_button_new_with_label("...");
1862 widget
= gtk_button_new_from_icon_name(ICONNAME_FOLDER
, GTK_ICON_SIZE_BUTTON
);
1863 data
->BT_path_hbfile
= widget
;
1864 gtk_box_pack_start (GTK_BOX (hbox
), widget
, FALSE
, FALSE
, 0);
1866 return content_grid
;
1870 void plugin_execute_action(GtkTreeView
* treeview
, GtkTreePath
* path
, GtkTreeViewColumn
* col
, gpointer userdata
);
1873 toggle_plugin(GtkCellRendererToggle
*cell
, gchar
* path_str
, gpointer data
)
1875 GtkTreeModel
*model
= (GtkTreeModel
*)data
;
1877 GtkTreePath
*path
= gtk_tree_path_new_from_string(path_str
);
1879 const gchar
* plugin
;
1881 gtk_tree_model_get_iter(model
, &iter
, path
);
1882 gtk_tree_model_get(model
, &iter
, EXT_COLUMN_PLUGIN_NAME
, &plugin
, -1);
1884 gboolean enabled
= ext_is_plugin_loaded(plugin
);
1886 ext_unload_plugin(plugin
);
1889 enabled
= (ext_load_plugin(plugin
) == 0);
1891 ext_run_modal(_("Plugin Error"), _("The plugin failed to load properly."), "error");
1896 gtk_list_store_set(GTK_LIST_STORE (model
), &iter
, EXT_COLUMN_ENABLED
, enabled
, -1);
1899 gtk_tree_path_free(path
);
1903 void plugin_execute_action(GtkTreeView
* treeview
, GtkTreePath
* path
, GtkTreeViewColumn
* col
, gpointer userdata
)
1905 GtkTreeModel
* model
= gtk_tree_view_get_model(treeview
);
1908 if (gtk_tree_model_get_iter(model
, &iter
, path
)) {
1909 gchar
* plugin_filename
;
1910 gtk_tree_model_get(model
, &iter
, EXT_COLUMN_PLUGIN_NAME
, &plugin_filename
, -1);
1911 ext_execute_action(plugin_filename
);
1912 g_free(plugin_filename
);
1916 static GtkWidget
*defpref_page_plugins (struct defpref_data
*data
)
1918 GtkWidget
*container
;
1919 GtkListStore
*store
;
1923 container
= gtk_vbox_new(FALSE
, 0);
1925 store
= gtk_list_store_new(EXT_NUM_COLUMNS
, G_TYPE_BOOLEAN
, G_TYPE_STRING
, G_TYPE_STRING
, G_TYPE_STRING
);
1927 gchar
** plugins
= ext_list_plugins();
1929 for (plugins_it
= plugins
; *plugins_it
; ++plugins_it
) {
1931 gboolean enabled
= ext_is_plugin_loaded(*plugins_it
);
1932 GHashTable
* metadata
= ext_read_plugin_metadata(*plugins_it
);
1934 metadata
= g_hash_table_new(g_str_hash
, g_str_equal
);
1940 gchar
* name
= g_hash_table_lookup(metadata
, "name");
1941 if (!name
|| *name
== '\0') {
1944 name
= g_markup_escape_text(name
, -1);
1945 gchar
* label
= g_strdup_printf("<b>%s</b>", name
);
1946 gchar
* tooltip
= g_strdup_printf("<span size='x-large' weight='bold'>%s</span>", name
);
1950 gchar
* version
= g_hash_table_lookup(metadata
, "version");
1952 version
= g_markup_escape_text(version
, -1);
1954 label
= g_strdup_printf("%s %s", tmp
, version
);
1957 tooltip
= g_strdup_printf("%s %s", tmp
, version
);
1963 gchar
* abstract
= g_hash_table_lookup(metadata
, "abstract");
1965 abstract
= g_markup_escape_text(abstract
, -1);
1967 label
= g_strdup_printf("%s\n%s", tmp
, abstract
);
1973 gchar
* author
= g_hash_table_lookup(metadata
, "author");
1975 author
= g_markup_escape_text(author
, -1);
1977 tooltip
= g_strdup_printf("%s\n%s", tmp
, author
);
1983 gchar
* website
= g_hash_table_lookup(metadata
, "website");
1985 website
= g_markup_escape_text(website
, -1);
1987 tooltip
= g_strdup_printf("%s\n<b>%s:</b> %s", tmp
, _("Website"), website
);
1993 tmp
= ext_find_plugin(*plugins_it
);
1994 gchar
* full
= g_markup_escape_text(tmp
, -1);
1997 tooltip
= g_strdup_printf("%s\n<b>%s:</b> %s", tmp
, _("File"), full
);
2001 g_hash_table_unref(metadata
);
2003 gtk_list_store_append(store
, &it
);
2004 gtk_list_store_set(store
, &it
,
2005 EXT_COLUMN_ENABLED
, enabled
,
2006 EXT_COLUMN_LABEL
, label
,
2007 EXT_COLUMN_TOOLTIP
, tooltip
,
2008 EXT_COLUMN_PLUGIN_NAME
, *plugins_it
,
2014 g_strfreev(plugins
);
2016 view
= gtk_tree_view_new_with_model(GTK_TREE_MODEL(store
));
2017 g_object_unref(store
);
2019 g_signal_connect(view
, "row-activated", (GCallback
)plugin_execute_action
, NULL
);
2021 gtk_tree_view_set_rules_hint(GTK_TREE_VIEW(view
), TRUE
);
2022 gtk_tree_view_set_headers_visible(GTK_TREE_VIEW(view
), TRUE
);
2023 gtk_tree_view_set_tooltip_column(GTK_TREE_VIEW(view
), EXT_COLUMN_TOOLTIP
);
2026 GtkTreeViewColumn
*col
;
2027 GtkCellRenderer
*renderer
;
2030 col
= gtk_tree_view_column_new();
2031 gtk_tree_view_column_set_title(col
, _("Enabled"));
2032 gtk_tree_view_column_set_sort_column_id(col
, EXT_COLUMN_ENABLED
);
2033 gtk_tree_view_append_column(GTK_TREE_VIEW(view
), col
);
2035 renderer
= gtk_cell_renderer_toggle_new();
2036 gtk_tree_view_column_pack_start(col
, renderer
, TRUE
);
2037 gtk_tree_view_column_add_attribute(col
, renderer
, "active", 0);
2038 g_signal_connect(renderer
, "toggled", G_CALLBACK(toggle_plugin
), store
);
2040 col
= gtk_tree_view_column_new();
2041 gtk_tree_view_column_set_title(col
, _("Plugin"));
2042 gtk_tree_view_column_set_sort_column_id(col
, EXT_COLUMN_LABEL
);
2043 gtk_tree_view_column_set_expand(col
, TRUE
);
2044 /*gtk_tree_view_column_set_sort_order(col, GTK_SORT_ASCENDING);*/
2045 gtk_tree_view_append_column(GTK_TREE_VIEW(view
), col
);
2047 renderer
= gtk_cell_renderer_text_new();
2048 g_object_set(renderer
, "ellipsize", PANGO_ELLIPSIZE_END
, NULL
);
2049 gtk_tree_view_column_pack_start(col
, renderer
, TRUE
);
2050 gtk_tree_view_column_add_attribute(col
, renderer
, "markup", EXT_COLUMN_LABEL
);
2052 data
->PI_plugin_columns
= view
;
2054 GtkWidget
* sw
= gtk_scrolled_window_new(NULL
, NULL
);
2055 gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(sw
), GTK_SHADOW_ETCHED_IN
);
2056 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(sw
), GTK_POLICY_NEVER
, GTK_POLICY_AUTOMATIC
);
2057 gtk_container_add(GTK_CONTAINER(sw
), view
);
2059 gtk_box_pack_start(GTK_BOX(container
), sw
, TRUE
, TRUE
, 0);
2065 static void defpref_selection(GtkTreeSelection
*treeselection
, gpointer user_data
)
2067 struct defpref_data
*data
;
2068 GtkWidget
*notebook
;
2069 GtkTreeView
*treeview
;
2070 GtkTreeModel
*model
;
2073 GValue val
= { 0, };
2076 DB( g_print("\n[ui-pref] selection\n") );
2078 if (gtk_tree_selection_get_selected(treeselection
, &model
, &iter
))
2080 notebook
= GTK_WIDGET(user_data
);
2081 treeview
= gtk_tree_selection_get_tree_view(treeselection
);
2082 data
= g_object_get_data(G_OBJECT(gtk_widget_get_ancestor(GTK_WIDGET(treeview
), GTK_TYPE_WINDOW
)), "inst_data");
2085 gtk_tree_model_get_value(model
, &iter
, LST_PREF_PAGE
, &val
);
2086 page
= g_value_get_int (&val
);
2087 DB( g_print(" - active is %d\n", page
) );
2088 g_value_unset (&val
);
2091 gtk_tree_model_get_value(model
, &iter
, LST_PREF_NAME
, &val
);
2092 gtk_label_set_text (GTK_LABEL (data
->label
), g_value_get_string (&val
));
2093 g_value_unset (&val
);
2095 gtk_tree_model_get_value(model
, &iter
, LST_PREF_ICONNAME
, &val
);
2096 //gtk_image_set_from_pixbuf (GTK_IMAGE (data->image), g_value_get_object (&val));
2097 gtk_image_set_from_icon_name(GTK_IMAGE (data
->image
), g_value_get_string (&val
), GTK_ICON_SIZE_DIALOG
);
2098 g_value_unset (&val
);
2102 gtk_notebook_set_current_page(GTK_NOTEBOOK(notebook
), page
);
2104 //defpref_change_page(GTK_WIDGET(gtk_tree_selection_get_tree_view(treeselection)), GINT_TO_POINTER(page));
2111 ** set the notebook active page from treeview
2113 /*void defpref_change_page(GtkWidget *widget, gpointer user_data)
2115 struct defpref_data *data;
2116 gint page = GPOINTER_TO_INT(user_data);
2117 GtkTreeModel *model;
2120 DB( g_print("\n[ui-pref] page\n") );
2122 data = g_object_get_data(G_OBJECT(gtk_widget_get_ancestor(widget, GTK_TYPE_WINDOW)), "inst_data");
2124 model = gtk_tree_view_get_model(GTK_TREE_VIEW(data->LV_page));
2132 gtk_notebook_set_current_page(GTK_NOTEBOOK(data->GR_page), page);
2138 ** add an empty new account to our temp GList and treeview
2140 static void defpref_clear(GtkWidget
*widget
, gpointer user_data
)
2142 struct defpref_data
*data
;
2145 data
= g_object_get_data(G_OBJECT(gtk_widget_get_ancestor(widget
, GTK_TYPE_WINDOW
)), "inst_data");
2146 DB( g_print("\n(defpref_clear) (data=%p)\n", data
) );
2148 result
= ui_dialog_msg_confirm_alert(
2149 GTK_WINDOW(data
->window
),
2150 _("Reset all preferences"),
2151 _("Do you really want to reset all\npreferences to default values?"),
2154 if( result
== GTK_RESPONSE_OK
)
2156 homebank_pref_setdefault();
2163 // the window creation
2164 GtkWidget
*defpref_dialog_new (gint initial_selection
)
2166 struct defpref_data data
;
2167 GtkWidget
*window
, *content
, *mainvbox
;
2168 GtkWidget
*hbox
, *vbox
, *sw
, *widget
, *notebook
, *page
, *ebox
, *image
, *label
;
2170 window
= gtk_dialog_new_with_buttons (_("Preferences"),
2171 GTK_WINDOW(GLOBALS
->mainwindow
),
2174 GTK_RESPONSE_REJECT
,
2176 GTK_RESPONSE_ACCEPT
,
2179 data
.window
= window
;
2181 //store our window private data
2182 g_object_set_data(G_OBJECT(window
), "inst_data", (gpointer
)&data
);
2184 gtk_window_set_icon_name(GTK_WINDOW (window
), ICONNAME_PREFERENCES
);
2186 content
= gtk_dialog_get_content_area(GTK_DIALOG (window
)); // return a vbox
2187 mainvbox
= gtk_box_new(GTK_ORIENTATION_VERTICAL
, SPACING_MEDIUM
);
2188 gtk_box_pack_start (GTK_BOX (content
), mainvbox
, TRUE
, TRUE
, 0);
2190 gtk_container_set_border_width(GTK_CONTAINER(mainvbox
), SPACING_MEDIUM
);
2192 hbox
= gtk_box_new(GTK_ORIENTATION_HORIZONTAL
, SPACING_MEDIUM
);
2193 gtk_box_pack_start (GTK_BOX (mainvbox
), hbox
, TRUE
, TRUE
, 0);
2196 vbox
= gtk_box_new(GTK_ORIENTATION_VERTICAL
, SPACING_SMALL
);
2197 gtk_box_pack_start (GTK_BOX (hbox
), vbox
, FALSE
, FALSE
, 0);
2200 sw
= gtk_scrolled_window_new (NULL
, NULL
);
2201 gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (sw
), GTK_SHADOW_ETCHED_IN
);
2202 gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (sw
), GTK_POLICY_NEVER
, GTK_POLICY_AUTOMATIC
);
2203 gtk_box_pack_start (GTK_BOX (vbox
), sw
, TRUE
, TRUE
, 0);
2204 widget
= pref_list_create();
2205 data
.LV_page
= widget
;
2206 gtk_container_add (GTK_CONTAINER (sw
), widget
);
2209 data
.BT_clear
= gtk_button_new_with_mnemonic(_("_Reset"));
2210 gtk_box_pack_start (GTK_BOX (vbox
), data
.BT_clear
, FALSE
, TRUE
, 0);
2213 //right part : notebook
2214 vbox
= gtk_box_new (GTK_ORIENTATION_VERTICAL
, SPACING_MEDIUM
);
2215 gtk_box_pack_start (GTK_BOX (hbox
), vbox
, TRUE
, TRUE
, 0);
2216 gtk_widget_show (vbox
);
2218 ebox
= gtk_event_box_new();
2219 gtk_widget_set_name(ebox
, "hbebox");
2220 GtkStyleContext
*context
= gtk_widget_get_style_context (ebox
);
2221 #if GTK_MINOR_VERSION <= 18
2222 gtk_style_context_add_class (context
, GTK_STYLE_CLASS_LIST_ROW
);
2223 gtk_widget_set_state_flags(ebox
, GTK_STATE_FLAG_SELECTED
, TRUE
);
2225 GtkCssProvider
*provider
;
2226 provider
= gtk_css_provider_new ();
2227 gtk_css_provider_load_from_data (provider
,
2228 "#hbebox { color: @theme_selected_fg_color; background-color: @theme_selected_bg_color; }"
2230 gtk_style_context_add_provider (context
, GTK_STYLE_PROVIDER(provider
), G_MAXUINT
);
2232 // gtk_style_context_set_state(context, GTK_STATE_FLAG_SELECTED);
2235 gtk_box_pack_start (GTK_BOX (vbox
), ebox
, FALSE
, TRUE
, 0);
2236 gtk_widget_show (ebox
);
2238 hbox
= gtk_box_new (GTK_ORIENTATION_HORIZONTAL
, SPACING_SMALL
);
2239 gtk_container_set_border_width (GTK_CONTAINER (hbox
), SPACING_SMALL
);
2240 gtk_container_add (GTK_CONTAINER (ebox
), hbox
);
2241 gtk_widget_show (hbox
);
2243 label
= gtk_label_new (NULL
);
2244 gtk_widget_set_margin_left(label
, SPACING_MEDIUM
);
2245 gimp_label_set_attributes (GTK_LABEL (label
),
2246 PANGO_ATTR_SCALE
, PANGO_SCALE_XX_LARGE
,
2247 PANGO_ATTR_WEIGHT
, PANGO_WEIGHT_BOLD
,
2250 gtk_box_pack_start (GTK_BOX (hbox
), label
, FALSE
, FALSE
, 0);
2251 gtk_widget_show (label
);
2254 image
= gtk_image_new ();
2255 gtk_box_pack_end (GTK_BOX (hbox
), image
, FALSE
, FALSE
, 0);
2256 gtk_widget_show (image
);
2262 notebook
= gtk_notebook_new();
2263 data
.GR_page
= notebook
;
2264 gtk_widget_show(notebook
);
2265 gtk_notebook_set_show_tabs(GTK_NOTEBOOK(notebook
), FALSE
);
2266 gtk_notebook_set_show_border(GTK_NOTEBOOK(notebook
), FALSE
);
2267 gtk_box_pack_start (GTK_BOX (vbox
), notebook
, TRUE
, TRUE
, 0);
2279 page
= defpref_page_general(&data
);
2280 gtk_notebook_append_page (GTK_NOTEBOOK (notebook
), page
, NULL
);
2283 page
= defpref_page_interface(&data
);
2284 gtk_notebook_append_page (GTK_NOTEBOOK (notebook
), page
, NULL
);
2287 page
= defpref_page_transactions(&data
);
2288 gtk_notebook_append_page (GTK_NOTEBOOK (notebook
), page
, NULL
);
2291 page
= defpref_page_display(&data
);
2292 gtk_notebook_append_page (GTK_NOTEBOOK (notebook
), page
, NULL
);
2295 page
= defpref_page_import(&data
);
2296 gtk_notebook_append_page (GTK_NOTEBOOK (notebook
), page
, NULL
);
2299 page
= defpref_page_reports(&data
);
2300 gtk_notebook_append_page (GTK_NOTEBOOK (notebook
), page
, NULL
);
2303 page
= defpref_page_euro(&data
);
2304 gtk_notebook_append_page (GTK_NOTEBOOK (notebook
), page
, NULL
);
2307 page
= defpref_page_plugins(&data
);
2308 gtk_notebook_append_page (GTK_NOTEBOOK (notebook
), page
, NULL
);
2311 //todo:should move this
2312 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(data
.CM_euro_enable
), PREFS
->euro_active
);
2314 //connect all our signals
2315 g_signal_connect (window
, "destroy", G_CALLBACK (gtk_widget_destroyed
), &window
);
2317 g_signal_connect (G_OBJECT (data
.BT_clear
), "clicked", G_CALLBACK (defpref_clear
), NULL
);
2320 g_signal_connect (data
.BT_path_hbfile
, "pressed", G_CALLBACK (defpref_pathselect
), GINT_TO_POINTER(1));
2321 g_signal_connect (data
.BT_path_import
, "pressed", G_CALLBACK (defpref_pathselect
), GINT_TO_POINTER(2));
2322 g_signal_connect (data
.BT_path_export
, "pressed", G_CALLBACK (defpref_pathselect
), GINT_TO_POINTER(3));
2324 g_signal_connect (data
.CM_custom_colors
, "toggled", G_CALLBACK (defpref_colortoggle
), NULL
);
2325 g_signal_connect (data
.CY_colors
, "changed", G_CALLBACK (defpref_colorpreset
), NULL
);
2329 g_signal_connect (gtk_tree_view_get_selection(GTK_TREE_VIEW(data
.LV_page
)), "changed", G_CALLBACK (defpref_selection
), notebook
);
2331 g_signal_connect (data
.CM_euro_enable
, "toggled", G_CALLBACK (defpref_eurotoggle
), NULL
);
2333 g_signal_connect (data
.CY_euro_preset
, "changed", G_CALLBACK (defpref_europreset
), NULL
);
2336 g_signal_connect (data
.ST_datefmt
, "changed", G_CALLBACK (defpref_date_sample
), NULL
);
2339 g_signal_connect (data
.CY_color_scheme
, "changed", G_CALLBACK (defpref_color_scheme_changed
), NULL
);
2343 g_signal_connect (data
.ST_euro_symbol
, "changed", G_CALLBACK (defpref_numbereuro_sample
), NULL
);
2344 g_signal_connect (data
.CM_euro_isprefix
, "toggled", G_CALLBACK (defpref_numbereuro_sample
), NULL
);
2345 g_signal_connect (data
.ST_euro_decimalchar
, "changed", G_CALLBACK (defpref_numbereuro_sample
), NULL
);
2346 g_signal_connect (data
.ST_euro_groupingchar
, "changed", G_CALLBACK (defpref_numbereuro_sample
), NULL
);
2347 g_signal_connect (data
.NB_euro_fracdigits
, "value-changed", G_CALLBACK (defpref_numbereuro_sample
), NULL
);
2349 //g_signal_connect (data.BT_default, "pressed", G_CALLBACK (defpref_currency_change), NULL);
2352 //setup, init and show window
2353 //defhbfile_setup(&data);
2354 //defhbfile_update(data.LV_arc, NULL);
2358 defpref_colortoggle(window
, NULL
);
2359 defpref_eurotoggle(window
, NULL
);
2361 gtk_window_resize(GTK_WINDOW(window
), 640, 256);
2365 GtkTreePath
*path
= gtk_tree_path_new_from_indices(initial_selection
, -1);
2368 gtk_tree_selection_select_path (gtk_tree_view_get_selection(GTK_TREE_VIEW(data
.LV_page
)), path
);
2372 gtk_tree_path_free(path
);
2374 gtk_widget_show_all (window
);
2375 gtk_notebook_set_current_page(GTK_NOTEBOOK(notebook
), initial_selection
);
2382 result
= gtk_dialog_run (GTK_DIALOG (window
));
2386 case GTK_RESPONSE_ACCEPT
:
2387 old_lang
= g_strdup(PREFS
->language
);
2389 homebank_pref_save();
2390 ui_mainwindow_update(GLOBALS
->mainwindow
, GINT_TO_POINTER(UF_BALANCE
+UF_VISUAL
));
2392 DB( g_print("old='%s' new='%s'\n", old_lang
, PREFS
->language
) );
2394 if(g_ascii_strncasecmp(old_lang
== NULL
? "" : old_lang
, PREFS
->language
== NULL
? "" : PREFS
->language
, -1) != 0)
2396 ui_dialog_msg_infoerror(GTK_WINDOW(window
), GTK_MESSAGE_INFO
,
2398 _("You will have to restart HomeBank\nfor the language change to take effect.")
2408 // cleanup and destroy
2409 //defhbfile_cleanup(&data, result);
2410 gtk_widget_destroy (window
);
2415 // -------------------------------
2418 static GtkWidget
*pref_list_create(void)
2420 GtkListStore
*store
;
2422 GtkCellRenderer
*renderer
;
2423 GtkTreeViewColumn
*column
;
2427 /* create list store */
2428 store
= gtk_list_store_new(
2436 view
= gtk_tree_view_new_with_model(GTK_TREE_MODEL(store
));
2437 g_object_unref(store
);
2439 gtk_tree_view_set_headers_visible(GTK_TREE_VIEW (view
), FALSE
);
2440 gtk_tree_selection_set_mode(gtk_tree_view_get_selection(GTK_TREE_VIEW(view
)), GTK_SELECTION_SINGLE
);
2442 /* column 1: icon */
2443 column
= gtk_tree_view_column_new();
2444 renderer
= gtk_cell_renderer_pixbuf_new ();
2445 g_object_set(renderer
, "stock-size", GTK_ICON_SIZE_DND
, NULL
);
2446 gtk_tree_view_column_pack_start(column
, renderer
, FALSE
);
2447 gtk_tree_view_column_set_attributes(column
, renderer
, "icon-name", LST_PREF_ICONNAME
, NULL
);
2449 renderer
= gtk_cell_renderer_text_new ();
2450 gtk_tree_view_column_pack_start(column
, renderer
, TRUE
);
2451 gtk_tree_view_column_set_attributes(column
, renderer
, "text", LST_PREF_NAME
, NULL
);
2453 gtk_tree_view_append_column (GTK_TREE_VIEW(view
), column
);
2455 //populate our combobox model
2456 for(i
=0;i
<PREF_MAX
;i
++)
2458 gtk_list_store_append(store
, &iter
);
2460 gtk_list_store_set(store
, &iter
,
2461 LST_PREF_ICONNAME
, pref_iconname
[i
],
2462 LST_PREF_NAME
, _(pref_name
[i
]),
2471 /* = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =*/
2474 extern gchar *list_txn_column_label[];
2478 list_txn_colpref_toggled_cell_data_function (GtkCellRendererToggle *cell,
2482 GtkTreeModel *model = (GtkTreeModel *)data;
2484 GtkTreePath *path = gtk_tree_path_new_from_string (path_str);
2488 gtk_tree_model_get_iter (model, &iter, path);
2489 gtk_tree_model_get (model, &iter, COLUMN_VISIBLE, &fixed, -1);
2491 // do something with the value
2495 gtk_list_store_set (GTK_LIST_STORE (model), &iter, COLUMN_VISIBLE, fixed, -1);
2498 gtk_tree_path_free (path);
2502 static void list_txn_colpref_get(GtkTreeView *treeview, gint *columns)
2504 GtkTreeModel *model;
2510 DB( g_print("[lst_txn-colpref] store column order \n") );
2512 model = gtk_tree_view_get_model(GTK_TREE_VIEW(treeview));
2513 valid = gtk_tree_model_get_iter_first(GTK_TREE_MODEL(model), &iter);
2517 gtk_tree_model_get(GTK_TREE_MODEL(model), &iter,
2518 COLUMN_VISIBLE, &visible,
2522 DB( g_print(" - column %d: %d\n",id, visible) );
2523 // start at index 2 (status, date always displayed
2524 columns[i+2] = visible == TRUE ? id : -id;
2526 // Make iter point to the next row in the list store
2527 valid = gtk_tree_model_iter_next(GTK_TREE_MODEL(model), &iter);
2533 GtkWidget *list_txn_colprefcreate(void)
2535 GtkListStore *store;
2537 GtkCellRenderer *renderer;
2538 GtkTreeViewColumn *column;
2542 DB( g_print("[lst_txn-colpref] create\n") );
2545 // create list store
2546 store = gtk_list_store_new(
2554 for(i=0 ; i < NUM_LST_DSPOPE-1; i++ ) //-1 cause account column avoid
2559 DB( g_print("eval %d, %s\n", i, list_txn_column_label[i]) );
2561 if(i <= LST_DSPOPE_DATE) // status, date always displayed
2564 //[i-1] here because lst_ope_columns[] do not store LST_DSPOPE_DATAS
2565 id = ABS(PREFS->lst_ope_columns[i-1]);
2566 if(id == 0) id = i; //if we pass here, new column or weird into pref file
2567 visible = (PREFS->lst_ope_columns[i-1] > 0) ? TRUE : FALSE;
2570 DB( g_print(" - pos=%2d, id=%2d - %d '%s'\n", i, id, visible, list_txn_column_label[id]) );
2572 gtk_list_store_append (store, &iter);
2573 gtk_list_store_set (store, &iter,
2574 COLUMN_VISIBLE, visible,
2575 COLUMN_NAME, _(list_txn_column_label[id]),
2582 view = gtk_tree_view_new_with_model(GTK_TREE_MODEL(store));
2583 g_object_unref(store);
2587 renderer = gtk_cell_renderer_toggle_new ();
2588 column = gtk_tree_view_column_new_with_attributes (_("Visible"),
2590 "active", COLUMN_VISIBLE,
2592 gtk_tree_view_append_column (GTK_TREE_VIEW(view), column);
2594 g_signal_connect (renderer, "toggled",
2595 G_CALLBACK (list_txn_colpref_toggled_cell_data_function), store);
2598 renderer = gtk_cell_renderer_text_new ();
2599 column = gtk_tree_view_column_new_with_attributes (_("Column"),
2601 "text", COLUMN_NAME,
2603 gtk_tree_view_append_column (GTK_TREE_VIEW(view), column);
2605 gtk_tree_view_set_reorderable (GTK_TREE_VIEW(view), TRUE);
2613 static void list_ext_colpref_get(GtkTreeView
*treeview
, GList
**columns
)
2615 GtkTreeModel
*model
;
2618 g_list_free_full(*columns
, g_free
);
2621 model
= gtk_tree_view_get_model(GTK_TREE_VIEW(treeview
));
2623 gboolean valid
= gtk_tree_model_get_iter_first(GTK_TREE_MODEL(model
), &iter
);
2625 gboolean enabled
= FALSE
;
2628 gtk_tree_model_get(GTK_TREE_MODEL(model
), &iter
,
2629 EXT_COLUMN_ENABLED
, &enabled
,
2630 EXT_COLUMN_PLUGIN_NAME
, &name
,
2634 *columns
= g_list_append(*columns
, g_strdup(name
));
2637 valid
= gtk_tree_model_iter_next(GTK_TREE_MODEL(model
), &iter
);