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"
29 #include "ui-currency.h"
32 /****************************************************************************/
34 /****************************************************************************/
43 /* our global datas */
44 extern struct HomeBank
*GLOBALS
;
45 extern struct Preferences
*PREFS
;
65 EXT_COLUMN_ENABLED
= 0,
68 EXT_COLUMN_PLUGIN_NAME
,
73 static gchar
*pref_iconname
[PREF_MAX
] = {
80 "prf-euro", // to be renamed
85 static gchar
*pref_name
[PREF_MAX
] = {
97 static gchar
*CYA_TOOLBAR_STYLE
[] = {
98 N_("System defaults"),
101 N_("Text under icons"),
102 N_("Text beside icons"),
106 static gchar
*CYA_GRID_LINES
[] = {
115 gchar
*CYA_TANGO_COLORS
[] = {
123 gchar
*CYA_IMPORT_DATEORDER
[] = {
130 gchar
*CYA_IMPORT_OFXNAME
[] = {
137 gchar
*CYA_IMPORT_OFXMEMO
[] = {
139 N_("Append to Info"),
140 N_("Append to Memo"),
141 N_("Append to Payee"),
146 extern gchar
*CYA_CHART_COLORSCHEME
[];
147 extern gchar
*CYA_MONTHS
[];
154 //gchar *prefix_symbol; /* max symbol is 3 digits in unicode */
155 //gchar *suffix_symbol; /* but mostly is 1 digit */
159 gchar
*grouping_char
;
166 http://en.wikipedia.org/wiki/Currencies_of_the_European_Union
167 http://www.xe.com/euro.php
168 http://fr.wikipedia.org/wiki/Liste_des_unit%C3%A9s_mon%C3%A9taires_remplac%C3%A9es_par_l%27euro
169 http://www.inter-locale.com/LocalesDemo.jsp
171 static EuroParams euro_params
[] =
173 // , rate , symb , prfx , dec, grp, frac
174 // ---------------------------------------------------------------------
175 { "" , "--------" , 1.0 , "" , FALSE
, ",", ".", 2 },
176 { "ATS", "Austria" , 13.7603 , "S" , TRUE
, ",", ".", 2 }, // -S 1.234.567,89
177 { "BEF", "Belgium" , 40.3399 , "BF" , TRUE
, ",", ".", 2 }, // BF 1.234.567,89 -
178 { "FIM", "Finland" , 5.94573 , "mk" , FALSE
, ",", " ", 2 }, // -1 234 567,89 mk
179 { "FRF", "France" , 6.55957 , "F" , FALSE
, ",", " ", 2 }, // -1 234 567,89 F
180 { "DEM", "Germany" , 1.95583 , "DM" , FALSE
, ",", ".", 2 }, // -1.234.567,89 DM
181 { "GRD", "Greece" , 340.750 , "d" , TRUE
, ".", ",", 2 }, // ??
182 { "IEP", "Ireland" , 0.787564 , "£" , TRUE
, ".", ",", 2 }, // -£1,234,567.89
183 { "ITL", "Italy" , 1936.27 , "L" , TRUE
, "" , ".", 0 }, // L -1.234.567
184 { "LUF", "Luxembourg" , 40.3399 , "LU" , TRUE
, ",", ".", 2 }, // LU 1.234.567,89 -
185 { "NLG", "Netherlands" , 2.20371 , "F" , TRUE
, ",", ".", 2 }, // F 1.234.567,89-
186 { "PTE", "Portugal" , 200.482 , "Esc.", FALSE
, "$", ".", 2 }, // -1.234.567$89 Esc.
187 { "ESP", "Spain" , 166.386 , "Pts" , TRUE
, "" , ".", 0 }, // -Pts 1.234.567
189 { "SIT", "Slovenia" , 239.640 , "tol" , TRUE
, ",", ".", 2 }, //
191 { "CYP", "Cyprus" , 0.585274 , "£" , TRUE
, ",", "" , 2 }, //
192 { "MTL", "Malta" , 0.429300 , "Lm" , TRUE
, ",", "" , 2 }, //
194 { "SKK", "Slovaquia" , 30.12600 , "Sk" , FALSE
, ",", " ", 2 }, //
196 { "EEK", "Estonia" , 15.6466 , "kr" , FALSE
, ",", " ", 2 }, //
198 { "LVL", "Latvia" , 0.702804 , "lat.", FALSE
, ",", "" , 2 }, // jan. 2014
200 { "LTL", "Lithuania" , 3.45280 , "Lt." , TRUE
, ",", "" , 2 }, // jan. 2015
203 { "BGN", "Bulgaria" , 1.95583 , "лв." , TRUE
, ",", " ", 2 }, // non-fixé - 2014 target for euro
204 { "HUF", "Hungary" , 261.51 , "Ft" , TRUE
, ",", " ", 2 }, // non-fixé - No current target for euro
205 { "RON", "Romania" , 3.5155 , "Leu" , FALSE
, ",", ".", 2 }, // non-fixé - 2015 target for euro earliest
206 { "CZK", "Czech republic", 28.36 , "Kč" , FALSE
, ",", " ", 2 }, // non-fixé - 2015 earliest
207 { "HRK", "Croatia" , 1.0000 , "kn" , FALSE
, "" , ".", 0 }, // non-fixé - 2015 target for euro earliest
208 { "PLN", "Poland" , 0.25 , "zł" , FALSE
, ",", "" , 2 }, // non-fixé - No current target for euro
210 // { " ", "" , 1.00000 , "" , "" , FALSE, ",", "", 2 },
215 GtkWidget
*pref_list_create(void);
216 GtkWidget
*list_txn_colprefcreate(void);
218 static void list_txn_colpref_get(GtkTreeView
*treeview
, gboolean
*columns
);
220 static void list_ext_colpref_get(GtkTreeView
*treeview
, GList
**columns
);
225 /* = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =*/
233 static LangName languagenames
[] =
235 // 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
236 //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
239 { "ab", "Abkhazian" },
241 { "af", "Afrikaans" },
244 { "an", "Aragonese" },
246 { "as", "Assamese" },
247 { "ast", "Asturian, Bable, Leonese, Asturleonese" },
250 { "az", "Azerbaijani" },
252 { "be", "Belarusian" },
253 { "bg", "Bulgarian" },
263 { "ch", "Chamorro" },
264 { "co", "Corsican" },
267 { "cu", "Old Church Slavonic" },
273 { "dz", "Dzongkha" },
277 { "eo", "Esperanto" },
279 { "et", "Estonian" },
287 { "fy", "Western Frisian" },
289 { "gd", "Scottish Gaelic" },
290 { "gl", "Galician" },
292 { "gu", "Gujarati" },
297 { "ho", "Hiri Motu" },
298 { "hr", "Croatian" },
300 { "hu", "Hungarian" },
301 { "hy", "Armenian" },
303 { "ia", "Interlingua" },
304 { "id", "Indonesian" },
305 { "ie", "Interlingue" },
307 { "ii", "Sichuan Yi" },
310 { "is", "Icelandic" },
312 { "iu", "Inuktitut" },
313 { "ja", "Japanese" },
314 { "jv", "Javanese" },
315 { "ka", "Georgian" },
318 { "kj", "Kwanyama" },
320 { "kl", "Kalaallisut" },
325 { "ks", "Kashmiri" },
331 { "lb", "Luxembourgish" },
333 { "li", "Limburgish" },
336 { "lt", "Lithuanian" },
337 { "lu", "Luba-Katanga" },
339 { "mg", "Malagasy" },
340 { "mh", "Marshallese" },
342 { "mk", "Macedonian" },
343 { "ml", "Malayalam" },
344 { "mn", "Mongolian" },
345 { "mo", "Moldavian" },
351 { "nb", "Norwegian Bokmål" },
352 { "nd", "North Ndebele" },
353 { "nds", "Low German, Low Saxon" },
357 { "nn", "Norwegian Nynorsk" },
358 { "no", "Norwegian" },
359 { "nr", "South Ndebele" },
361 { "ny", "Chichewa" },
366 { "os", "Ossetian" },
371 { "pt", "Portuguese" },
375 { "ro", "Romanian" },
377 { "rw", "Kinyarwanda" },
378 { "sa", "Sanskrit" },
379 { "sc", "Sardinian" },
381 { "se", "Northern Sami" },
383 { "si", "Sinhalese" },
389 { "sq", "Albanian" },
393 { "su", "Sundanese" },
400 { "ti", "Tigrinya" },
409 { "ty", "Tahitian" },
411 { "uk", "Ukrainian" },
415 { "vi", "Viêt Namese" },
430 ui_language_combobox_compare_func (GtkTreeModel
*model
, GtkTreeIter
*a
, GtkTreeIter
*b
, gpointer userdata
)
433 gchar
*code1
, *code2
;
434 gchar
*name1
, *name2
;
436 gtk_tree_model_get(model
, a
, 0, &code1
, 1, &name1
, -1);
437 gtk_tree_model_get(model
, b
, 0, &code2
, 1, &name2
, -1);
439 //keep system laguage on top
440 if(code1
== NULL
) name1
= NULL
;
441 if(code2
== NULL
) name2
= NULL
;
443 retval
= hb_string_utf8_compare(name1
, name2
);
452 static gchar
*languagename_get(const gchar
*locale
)
456 for (i
= 0; i
< G_N_ELEMENTS (languagenames
); i
++)
458 if( g_ascii_strncasecmp(locale
, languagenames
[i
].locale
, -1) == 0 )
459 return languagenames
[i
].name
;
467 ui_language_combobox_get_name(const gchar
*locale
)
471 DB( g_print("[ui_language_combobox_get_name]\n") );
473 // A locale directory name is typically of the form language[_territory]
474 lang
= languagename_get (locale
);
477 const gchar
*delimiter
= strchr (locale
, '_'); // strip off the territory suffix
481 gchar
*copy
= g_strndup (locale
, delimiter
- locale
);
482 lang
= languagename_get (copy
);
488 g_warning(" locale name not found '%s'", locale
);
499 ui_language_combobox_populate(GtkWidget
*combobox
)
504 model
= gtk_combo_box_get_model(GTK_COMBO_BOX(combobox
));
505 gtk_list_store_append (GTK_LIST_STORE(model
), &iter
);
506 gtk_list_store_set (GTK_LIST_STORE(model
), &iter
,
508 1, _("System Language"),
511 GDir
*dir
= g_dir_open (homebank_app_get_locale_dir (), 0, NULL
);
512 const gchar
*dirname
;
517 while ((dirname
= g_dir_read_name (dir
)) != NULL
)
519 gchar
*filename
= g_build_filename (homebank_app_get_locale_dir (),
522 GETTEXT_PACKAGE
".mo",
524 //DB( g_print("- seek for '%s'\n", filename) );
525 if (g_file_test (filename
, G_FILE_TEST_EXISTS
))
530 gtk_list_store_append (GTK_LIST_STORE(model
), &iter
);
532 lang
= ui_language_combobox_get_name(dirname
);
533 label
= g_strdup_printf ("%s [%s]", lang
, dirname
);
535 gtk_list_store_set (GTK_LIST_STORE(model
), &iter
,
547 gtk_tree_sortable_set_sort_column_id(GTK_TREE_SORTABLE(model
), GTK_TREE_SORTABLE_DEFAULT_SORT_COLUMN_ID
, GTK_SORT_ASCENDING
);
554 ui_language_combobox_new(GtkWidget
*label
)
558 GtkCellRenderer
*renderer
;
560 store
= gtk_list_store_new (2,
564 gtk_tree_sortable_set_default_sort_func(GTK_TREE_SORTABLE(store
), ui_language_combobox_compare_func
, NULL
, NULL
);
566 combobox
= gtk_combo_box_new_with_model(GTK_TREE_MODEL(store
));
567 renderer
= gtk_cell_renderer_text_new ();
568 gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (combobox
), renderer
, TRUE
);
569 gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (combobox
), renderer
, "text", 1, NULL
);
571 gtk_combo_box_set_id_column( GTK_COMBO_BOX(combobox
), 0);
573 g_object_unref(store
);
576 gtk_label_set_mnemonic_widget (GTK_LABEL(label
), combobox
);
578 ui_language_combobox_populate(combobox
);
580 gtk_combo_box_set_active(GTK_COMBO_BOX(combobox
), 0);
586 /* = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =*/
587 /* = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =*/
588 /* = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =*/
594 static GtkWidget
*make_euro_presets(GtkWidget
*label
)
599 DB( g_print("\n[ui-pref] make euro preset\n") );
601 combobox
= gtk_combo_box_text_new();
602 for (i
= 0; i
< G_N_ELEMENTS (euro_params
); i
++)
604 gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(combobox
), euro_params
[i
].name
);
606 gtk_combo_box_set_active(GTK_COMBO_BOX(combobox
), 0);
609 gtk_label_set_mnemonic_widget (GTK_LABEL(label
), combobox
);
615 static void defpref_pathselect(GtkWidget
*widget
, gpointer user_data
)
617 struct defpref_data
*data
;
618 gint type
= GPOINTER_TO_INT(user_data
);
624 DB( g_print("\n[ui-pref] path select\n") );
626 data
= g_object_get_data(G_OBJECT(gtk_widget_get_ancestor(widget
, GTK_TYPE_WINDOW
)), "inst_data");
631 path
= &PREFS
->path_hbfile
;
632 entry
= data
->ST_path_hbfile
;
633 title
= _("Choose a default HomeBank files folder");
636 path
= &PREFS
->path_import
;
637 entry
= data
->ST_path_import
;
638 title
= _("Choose a default import folder");
641 path
= &PREFS
->path_export
;
642 entry
= data
->ST_path_export
;
643 title
= _("Choose a default export folder");
649 DB( g_print(" - hbfile %p %s at %p\n" , PREFS
->path_hbfile
, PREFS
->path_hbfile
, &PREFS
->path_hbfile
) );
650 DB( g_print(" - import %p %s at %p\n" , PREFS
->path_import
, PREFS
->path_import
, &PREFS
->path_import
) );
651 DB( g_print(" - export %p %s at %p\n" , PREFS
->path_export
, PREFS
->path_export
, &PREFS
->path_export
) );
654 DB( g_print(" - before: %s %p\n" , *path
, path
) );
656 r
= ui_file_chooser_folder(GTK_WINDOW(gtk_widget_get_ancestor(widget
, GTK_TYPE_WINDOW
)), title
, path
);
659 DB( g_print(" - after: %s\n", *path
) );
662 gtk_entry_set_text(GTK_ENTRY(entry
), *path
);
669 ** update the date sample label
671 static void defpref_date_sample(GtkWidget
*widget
, gpointer user_data
)
673 struct defpref_data
*data
;
678 DB( g_print("\n[ui-pref] date sample\n") );
680 data
= g_object_get_data(G_OBJECT(gtk_widget_get_ancestor(widget
, GTK_TYPE_WINDOW
)), "inst_data");
682 fmt
= gtk_entry_get_text(GTK_ENTRY(data
->ST_datefmt
));
683 date
= g_date_new_julian (GLOBALS
->today
);
684 g_date_strftime (buffer
, 256-1, fmt
, date
);
687 gtk_label_set_text(GTK_LABEL(data
->LB_date
), buffer
);
693 ** update the number sample label
695 static void defpref_numbereuro_sample(GtkWidget
*widget
, gpointer user_data
)
697 struct defpref_data
*data
;
699 gchar formatd_buf
[G_ASCII_DTOSTR_BUF_SIZE
];
702 DB( g_print("\n[ui-pref] number sample\n") );
704 data
= g_object_get_data(G_OBJECT(gtk_widget_get_ancestor(widget
, GTK_TYPE_WINDOW
)), "inst_data");
706 cur
.symbol
= (gchar
*)gtk_entry_get_text(GTK_ENTRY(data
->ST_euro_symbol
));
707 cur
.sym_prefix
= gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(data
->CM_euro_isprefix
));
708 cur
.decimal_char
= (gchar
*)gtk_entry_get_text(GTK_ENTRY(data
->ST_euro_decimalchar
));
709 cur
.grouping_char
= (gchar
*)gtk_entry_get_text(GTK_ENTRY(data
->ST_euro_groupingchar
));
710 cur
.frac_digits
= gtk_spin_button_get_value(GTK_SPIN_BUTTON(data
->NB_euro_fracdigits
));
712 da_cur_initformat (&cur
);
714 DB( g_print("fmt: %s\n", cur
.format
) );
716 g_ascii_formatd(formatd_buf
, sizeof (formatd_buf
), cur
.format
, HB_NUMBER_SAMPLE
);
717 hb_str_formatd(buf
, 127, formatd_buf
, &cur
, TRUE
);
719 gtk_label_set_text(GTK_LABEL(data
->LB_numbereuro
), buf
);
725 ** enable/disable euro
727 static void defpref_eurotoggle(GtkWidget
*widget
, gpointer user_data
)
729 struct defpref_data
*data
;
732 DB( g_print("\n[ui-pref] euro toggle\n") );
734 data
= g_object_get_data(G_OBJECT(gtk_widget_get_ancestor(widget
, GTK_TYPE_WINDOW
)), "inst_data");
736 sensitive
= gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(data
->CM_euro_enable
));
738 gtk_widget_set_sensitive(data
->GRP_currency
, sensitive
);
739 gtk_widget_set_sensitive(data
->GRP_rate
, sensitive
);
740 gtk_widget_set_sensitive(data
->GRP_format
, sensitive
);
745 ** set euro value widget from a country
747 static void defpref_eurosetcurrency(GtkWidget
*widget
, gpointer user_data
)
749 struct defpref_data
*data
;
750 EuroParams
*euro
= user_data
;
754 DB( g_print("\n[ui-pref] eurosetcurrency\n") );
756 data
= g_object_get_data(G_OBJECT(gtk_widget_get_ancestor(widget
, GTK_TYPE_WINDOW
)), "inst_data");
758 buf
= g_strdup_printf("%s - %s", euro
->iso
, euro
->name
);
760 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 country
= gtk_combo_box_get_active(GTK_COMBO_BOX(data
->CY_euro_preset
));
780 data
->country
= country
;
782 defpref_eurosetcurrency(widget
, &euro_params
[country
]);
784 gtk_spin_button_set_value(GTK_SPIN_BUTTON(data
->NB_euro_value
), euro_params
[country
].value
);
786 gtk_spin_button_set_value(GTK_SPIN_BUTTON(data
->NB_euro_fracdigits
), euro_params
[country
].frac_digits
);
788 gtk_entry_set_text(GTK_ENTRY(data
->ST_euro_symbol
) , euro_params
[country
].symbol
);
789 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(data
->CM_euro_isprefix
), euro_params
[country
].sym_prefix
);
790 gtk_entry_set_text(GTK_ENTRY(data
->ST_euro_decimalchar
) , euro_params
[country
].decimal_char
);
791 gtk_entry_set_text(GTK_ENTRY(data
->ST_euro_groupingchar
), euro_params
[country
].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") );
906 if(PREFS
->language
!= NULL
)
907 gtk_combo_box_set_active_id(GTK_COMBO_BOX(data
->CY_language
), PREFS
->language
);
909 gtk_combo_box_set_active (GTK_COMBO_BOX(data
->CY_language
), 0);
911 gtk_combo_box_set_active(GTK_COMBO_BOX(data
->CY_toolbar
), PREFS
->toolbar_style
);
912 //gtk_spin_button_set_value(GTK_SPIN_BUTTON(data->NB_image_size), PREFS->image_size);
914 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(data
->CM_custom_colors
), PREFS
->custom_colors
);
916 gdk_rgba_parse(&rgba
, PREFS
->color_exp
);
917 gtk_color_chooser_set_rgba(GTK_COLOR_CHOOSER(data
->CP_exp_color
), &rgba
);
919 gdk_rgba_parse(&rgba
, PREFS
->color_inc
);
920 gtk_color_chooser_set_rgba(GTK_COLOR_CHOOSER(data
->CP_inc_color
), &rgba
);
922 gdk_rgba_parse(&rgba
, PREFS
->color_warn
);
923 gtk_color_chooser_set_rgba(GTK_COLOR_CHOOSER(data
->CP_warn_color
), &rgba
);
925 //gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(data->CM_ruleshint), PREFS->rules_hint);
926 gtk_combo_box_set_active(GTK_COMBO_BOX(data
->CY_gridlines
), PREFS
->grid_lines
);
928 gtk_spin_button_set_value(GTK_SPIN_BUTTON(data
->NB_fiscyearday
), PREFS
->fisc_year_day
);
929 gtk_combo_box_set_active(GTK_COMBO_BOX(data
->CY_fiscyearmonth
), PREFS
->fisc_year_month
- 1);
931 gtk_entry_set_text(GTK_ENTRY(data
->ST_path_hbfile
), PREFS
->path_hbfile
);
932 gtk_entry_set_text(GTK_ENTRY(data
->ST_path_import
), PREFS
->path_import
);
933 gtk_entry_set_text(GTK_ENTRY(data
->ST_path_export
), PREFS
->path_export
);
934 //gtk_entry_set_text(GTK_ENTRY(data->ST_path_navigator), PREFS->path_navigator);
936 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(data
->CM_load_last
), PREFS
->loadlast
);
937 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(data
->CM_append_scheduled
), PREFS
->appendscheduled
);
938 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(data
->CM_do_update_currency
), PREFS
->do_update_currency
);
939 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(data
->CM_show_splash
), PREFS
->showsplash
);
940 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(data
->CM_herit_date
), PREFS
->heritdate
);
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
);
945 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
);
950 gtk_combo_box_set_active(GTK_COMBO_BOX(data
->CY_daterange_wal
), PREFS
->date_range_wal
);
951 gtk_combo_box_set_active(GTK_COMBO_BOX(data
->CY_daterange_txn
), PREFS
->date_range_txn
);
952 gtk_spin_button_set_value(GTK_SPIN_BUTTON(data
->ST_datefuture_nbdays
), PREFS
->date_future_nbdays
);
953 gtk_combo_box_set_active(GTK_COMBO_BOX(data
->CY_daterange_rep
), PREFS
->date_range_rep
);
956 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(data
->CM_euro_enable
), PREFS
->euro_active
);
957 //gtk_combo_box_set_active(GTK_COMBO_BOX(data->CY_euro_preset), PREFS->euro_country);
959 data
->country
= PREFS
->euro_country
;
960 defpref_eurosetcurrency(data
->window
, &euro_params
[PREFS
->euro_country
]);
962 gtk_spin_button_set_value(GTK_SPIN_BUTTON(data
->NB_euro_value
), PREFS
->euro_value
);
964 ui_gtk_entry_set_text(data
->ST_euro_symbol
, PREFS
->minor_cur
.symbol
);
965 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(data
->CM_euro_isprefix
), PREFS
->minor_cur
.sym_prefix
);
966 ui_gtk_entry_set_text(data
->ST_euro_decimalchar
, PREFS
->minor_cur
.decimal_char
);
967 ui_gtk_entry_set_text(data
->ST_euro_groupingchar
, PREFS
->minor_cur
.grouping_char
);
968 gtk_spin_button_set_value(GTK_SPIN_BUTTON(data
->NB_euro_fracdigits
), PREFS
->minor_cur
.frac_digits
);
971 //gtk_entry_set_text(GTK_ENTRY(data->ST_euro_symbol), PREFS->euro_symbol);
972 //gtk_spin_button_set_value(GTK_SPIN_BUTTON(data->NB_euro_nbdec), PREFS->euro_nbdec);
973 //gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(data->CM_euro_thsep), PREFS->euro_thsep);
975 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(data
->CM_stat_byamount
), PREFS
->stat_byamount
);
976 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(data
->CM_stat_showrate
), PREFS
->stat_showrate
);
977 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(data
->CM_stat_showdetail
), PREFS
->stat_showdetail
);
979 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(data
->CM_budg_showdetail
), PREFS
->budg_showdetail
);
981 gtk_combo_box_set_active(GTK_COMBO_BOX(data
->CY_color_scheme
), PREFS
->report_color_scheme
);
984 gtk_combo_box_set_active(GTK_COMBO_BOX(data
->CY_dtex_datefmt
), PREFS
->dtex_datefmt
);
985 gtk_combo_box_set_active(GTK_COMBO_BOX(data
->CY_dtex_ofxname
), PREFS
->dtex_ofxname
);
986 gtk_combo_box_set_active(GTK_COMBO_BOX(data
->CY_dtex_ofxmemo
), PREFS
->dtex_ofxmemo
);
987 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(data
->CM_dtex_qifmemo
), PREFS
->dtex_qifmemo
);
988 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(data
->CM_dtex_qifswap
), PREFS
->dtex_qifswap
);
995 ** get :: fill PREFS structure from widgets
998 #define RGBA_TO_INT(x) (int)(x*255)
1000 static gchar
*gdk_rgba_to_hex(GdkRGBA
*rgba
)
1002 return g_strdup_printf("#%02x%02x%02x", RGBA_TO_INT(rgba
->red
), RGBA_TO_INT(rgba
->green
), RGBA_TO_INT(rgba
->blue
));
1006 static void defpref_get(struct defpref_data
*data
)
1011 DB( g_print("\n[ui-pref] get\n") );
1013 g_free(PREFS
->language
);
1014 PREFS
->language
= NULL
;
1015 lang
= gtk_combo_box_get_active_id(GTK_COMBO_BOX(data
->CY_language
));
1018 PREFS
->language
= g_strdup(lang
);
1021 PREFS
->toolbar_style
= gtk_combo_box_get_active(GTK_COMBO_BOX(data
->CY_toolbar
));
1022 //PREFS->image_size = gtk_spin_button_get_value(GTK_SPIN_BUTTON(data->NB_image_size));
1024 PREFS
->custom_colors
= gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(data
->CM_custom_colors
));
1026 gtk_color_chooser_get_rgba(GTK_COLOR_CHOOSER(data
->CP_exp_color
), &rgba
);
1027 g_free(PREFS
->color_exp
);
1028 PREFS
->color_exp
= gdk_rgba_to_hex(&rgba
);
1030 gtk_color_chooser_get_rgba(GTK_COLOR_CHOOSER(data
->CP_inc_color
), &rgba
);
1031 g_free(PREFS
->color_inc
);
1032 PREFS
->color_inc
= gdk_rgba_to_hex(&rgba
);
1034 gtk_color_chooser_get_rgba(GTK_COLOR_CHOOSER(data
->CP_warn_color
), &rgba
);
1035 g_free(PREFS
->color_warn
);
1036 PREFS
->color_warn
= gdk_rgba_to_hex(&rgba
);
1038 //PREFS->rules_hint = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(data->CM_ruleshint));
1039 PREFS
->grid_lines
= gtk_combo_box_get_active(GTK_COMBO_BOX(data
->CY_gridlines
));
1041 PREFS
->fisc_year_day
= gtk_spin_button_get_value(GTK_SPIN_BUTTON(data
->NB_fiscyearday
));
1042 PREFS
->fisc_year_month
= 1 + gtk_combo_box_get_active(GTK_COMBO_BOX(data
->CY_fiscyearmonth
));
1044 list_txn_colpref_get(GTK_TREE_VIEW(data
->LV_opecolumns
), PREFS
->lst_ope_columns
);
1046 g_free(PREFS
->path_hbfile
);
1047 PREFS
->path_hbfile
= g_strdup(gtk_entry_get_text(GTK_ENTRY(data
->ST_path_hbfile
)));
1049 ui_gtk_entry_replace_text(data
->ST_path_import
, &PREFS
->path_import
);
1051 ui_gtk_entry_replace_text(data
->ST_path_export
, &PREFS
->path_export
);
1053 PREFS
->loadlast
= gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(data
->CM_load_last
));
1054 PREFS
->appendscheduled
= gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(data
->CM_append_scheduled
));
1055 PREFS
->do_update_currency
= gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(data
->CM_do_update_currency
));
1057 PREFS
->showsplash
= gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(data
->CM_show_splash
));
1058 PREFS
->heritdate
= gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(data
->CM_herit_date
));
1059 PREFS
->hidereconciled
= gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(data
->CM_hide_reconciled
));
1060 PREFS
->showremind
= gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(data
->CM_show_remind
));
1062 //g_free(PREFS->path_navigator);
1063 //PREFS->path_navigator = g_strdup(gtk_entry_get_text(GTK_ENTRY(data->ST_path_navigator)));
1065 g_free(PREFS
->date_format
);
1066 PREFS
->date_format
= g_strdup(gtk_entry_get_text(GTK_ENTRY(data
->ST_datefmt
)));
1068 PREFS
->vehicle_unit_ismile
= gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(data
->CM_unitismile
));
1069 PREFS
->vehicle_unit_isgal
= gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(data
->CM_unitisgal
));
1071 PREFS
->date_range_wal
= gtk_combo_box_get_active(GTK_COMBO_BOX(data
->CY_daterange_wal
));
1072 PREFS
->date_range_txn
= gtk_combo_box_get_active(GTK_COMBO_BOX(data
->CY_daterange_txn
));
1073 PREFS
->date_future_nbdays
= gtk_spin_button_get_value(GTK_SPIN_BUTTON(data
->ST_datefuture_nbdays
));
1074 PREFS
->date_range_rep
= gtk_combo_box_get_active(GTK_COMBO_BOX(data
->CY_daterange_rep
));
1076 PREFS
->euro_active
= gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(data
->CM_euro_enable
));
1078 PREFS
->euro_country
= data
->country
;
1079 PREFS
->euro_value
= gtk_spin_button_get_value(GTK_SPIN_BUTTON(data
->NB_euro_value
));
1080 //strcpy(PREFS->euro_symbol, gtk_entry_get_text(GTK_ENTRY(data->ST_euro_symbol)));
1081 //PREFS->euro_nbdec = gtk_spin_button_get_value(GTK_SPIN_BUTTON(data->NB_euro_nbdec));
1082 //PREFS->euro_thsep = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(data->CM_euro_thsep));
1084 ui_gtk_entry_replace_text(data
->ST_euro_symbol
, &PREFS
->minor_cur
.symbol
);
1085 PREFS
->minor_cur
.sym_prefix
= gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(data
->CM_euro_isprefix
));
1086 ui_gtk_entry_replace_text(data
->ST_euro_decimalchar
, &PREFS
->minor_cur
.decimal_char
);
1087 ui_gtk_entry_replace_text(data
->ST_euro_groupingchar
, &PREFS
->minor_cur
.grouping_char
);
1088 PREFS
->minor_cur
.frac_digits
= gtk_spin_button_get_value(GTK_SPIN_BUTTON(data
->NB_euro_fracdigits
));
1090 PREFS
->stat_byamount
= gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(data
->CM_stat_byamount
));
1091 PREFS
->stat_showrate
= gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(data
->CM_stat_showrate
));
1092 PREFS
->stat_showdetail
= gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(data
->CM_stat_showdetail
));
1094 PREFS
->budg_showdetail
= gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(data
->CM_budg_showdetail
));
1096 PREFS
->report_color_scheme
= gtk_combo_box_get_active(GTK_COMBO_BOX(data
->CY_color_scheme
));
1099 PREFS
->dtex_datefmt
= gtk_combo_box_get_active(GTK_COMBO_BOX(data
->CY_dtex_datefmt
));
1100 PREFS
->dtex_ofxname
= gtk_combo_box_get_active(GTK_COMBO_BOX(data
->CY_dtex_ofxname
));
1101 PREFS
->dtex_ofxmemo
= gtk_combo_box_get_active(GTK_COMBO_BOX(data
->CY_dtex_ofxmemo
));
1102 PREFS
->dtex_qifmemo
= gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(data
->CM_dtex_qifmemo
));
1103 PREFS
->dtex_qifswap
= gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(data
->CM_dtex_qifswap
));
1105 //PREFS->chart_legend = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(data->CM_chartlegend));
1107 list_ext_colpref_get(GTK_TREE_VIEW(data
->PI_plugin_columns
), &(PREFS
->ext_whitelist
));
1111 static GtkWidget
*defpref_page_import (struct defpref_data
*data
)
1113 GtkWidget
*content_grid
, *group_grid
, *hbox
, *label
, *widget
;
1116 content_grid
= gtk_grid_new();
1117 gtk_grid_set_row_spacing (GTK_GRID (content_grid
), SPACING_LARGE
);
1118 gtk_orientable_set_orientation(GTK_ORIENTABLE(content_grid
), GTK_ORIENTATION_VERTICAL
);
1121 // group :: Date options
1122 group_grid
= gtk_grid_new ();
1123 gtk_grid_set_row_spacing (GTK_GRID (group_grid
), SPACING_SMALL
);
1124 gtk_grid_set_column_spacing (GTK_GRID (group_grid
), SPACING_MEDIUM
);
1125 gtk_grid_attach (GTK_GRID (content_grid
), group_grid
, 0, crow
++, 1, 1);
1127 label
= make_label_group(_("Date options"));
1128 gtk_grid_attach (GTK_GRID (group_grid
), label
, 0, 0, 3, 1);
1131 label
= make_label_widget(_("Date order:"));
1132 //----------------------------------------- l, r, t, b
1133 gtk_grid_attach (GTK_GRID (group_grid
), label
, 1, row
, 1, 1);
1134 widget
= make_cycle(label
, CYA_IMPORT_DATEORDER
);
1135 data
->CY_dtex_datefmt
= widget
;
1136 //gtk_grid_attach (GTK_GRID (group_grid), data->CY_option[FILTER_DATE], 1, 2, row, row+1);
1137 gtk_grid_attach (GTK_GRID (group_grid
), widget
, 2, row
, 1, 1);
1140 // group :: OFX/QFX options
1141 group_grid
= gtk_grid_new ();
1142 gtk_grid_set_row_spacing (GTK_GRID (group_grid
), SPACING_SMALL
);
1143 gtk_grid_set_column_spacing (GTK_GRID (group_grid
), SPACING_MEDIUM
);
1144 gtk_grid_attach (GTK_GRID (content_grid
), group_grid
, 0, crow
++, 1, 1);
1146 label
= make_label_group(_("OFX/QFX options"));
1147 gtk_grid_attach (GTK_GRID (group_grid
), label
, 0, 0, 3, 1);
1150 label
= make_label_widget(_("_Name field:"));
1151 //----------------------------------------- l, r, t, b
1152 gtk_grid_attach (GTK_GRID (group_grid
), label
, 1, row
, 1, 1);
1153 widget
= make_cycle(label
, CYA_IMPORT_OFXNAME
);
1154 data
->CY_dtex_ofxname
= widget
;
1155 //gtk_grid_attach (GTK_GRID (group_grid), data->CY_option[FILTER_DATE], 1, 2, row, row+1);
1156 gtk_grid_attach (GTK_GRID (group_grid
), widget
, 2, row
, 1, 1);
1159 label
= make_label_widget(_("_Memo field:"));
1160 //----------------------------------------- l, r, t, b
1161 gtk_grid_attach (GTK_GRID (group_grid
), label
, 1, row
, 1, 1);
1162 widget
= make_cycle(label
, CYA_IMPORT_OFXMEMO
);
1163 data
->CY_dtex_ofxmemo
= widget
;
1164 //gtk_grid_attach (GTK_GRID (group_grid), data->CY_option[FILTER_DATE], 1, 2, row, row+1);
1165 gtk_grid_attach (GTK_GRID (group_grid
), widget
, 2, row
, 1, 1);
1167 // group :: QIF options
1168 group_grid
= gtk_grid_new ();
1169 gtk_grid_set_row_spacing (GTK_GRID (group_grid
), SPACING_SMALL
);
1170 gtk_grid_set_column_spacing (GTK_GRID (group_grid
), SPACING_MEDIUM
);
1171 gtk_grid_attach (GTK_GRID (content_grid
), group_grid
, 0, crow
++, 1, 1);
1173 label
= make_label_group(_("QIF options"));
1174 gtk_grid_attach (GTK_GRID (group_grid
), label
, 0, 0, 3, 1);
1177 label
= make_label_widget(_("Memos:"));
1178 gtk_grid_attach (GTK_GRID (group_grid
), label
, 1, row
, 1, 1);
1179 widget
= gtk_check_button_new_with_mnemonic (_("_Import"));
1180 data
->CM_dtex_qifmemo
= widget
;
1181 gtk_grid_attach (GTK_GRID (group_grid
), widget
, 2, row
, 1, 1);
1182 widget
= gtk_check_button_new_with_mnemonic (_("_Swap with payees"));
1183 data
->CM_dtex_qifswap
= widget
;
1184 gtk_grid_attach (GTK_GRID (group_grid
), widget
, 3, row
, 1, 1);
1187 // group :: Files folder
1188 group_grid
= gtk_grid_new ();
1189 gtk_grid_set_row_spacing (GTK_GRID (group_grid
), SPACING_SMALL
);
1190 gtk_grid_set_column_spacing (GTK_GRID (group_grid
), SPACING_MEDIUM
);
1191 gtk_grid_attach (GTK_GRID (content_grid
), group_grid
, 0, crow
++, 1, 1);
1193 label
= make_label_group(_("Files folder"));
1194 gtk_grid_attach (GTK_GRID (group_grid
), label
, 0, 0, 3, 1);
1197 label
= make_label_widget(_("_Import:"));
1198 //----------------------------------------- l, r, t, b
1199 gtk_grid_attach (GTK_GRID (group_grid
), label
, 1, row
, 1, 1);
1201 hbox
= gtk_box_new(GTK_ORIENTATION_HORIZONTAL
, 0);
1202 gtk_widget_set_hexpand (hbox
, TRUE
);
1203 gtk_grid_attach (GTK_GRID (group_grid
), hbox
, 2, row
, 1, 1);
1205 widget
= make_string(label
);
1206 data
->ST_path_import
= widget
;
1207 gtk_style_context_add_class (gtk_widget_get_style_context (GTK_WIDGET(widget
)), GTK_STYLE_CLASS_LINKED
);
1208 gtk_box_pack_start (GTK_BOX (hbox
), widget
, TRUE
, TRUE
, 0);
1210 //widget = gtk_button_new_with_label("...");
1211 widget
= gtk_button_new_from_icon_name(ICONNAME_FOLDER
, GTK_ICON_SIZE_BUTTON
);
1212 data
->BT_path_import
= widget
;
1213 gtk_box_pack_start (GTK_BOX (hbox
), widget
, FALSE
, FALSE
, 0);
1216 label
= make_label_widget(_("_Export:"));
1217 //----------------------------------------- l, r, t, b
1218 gtk_grid_attach (GTK_GRID (group_grid
), label
, 1, row
, 1, 1);
1220 hbox
= gtk_box_new(GTK_ORIENTATION_HORIZONTAL
, 0);
1221 gtk_widget_set_hexpand (hbox
, TRUE
);
1222 gtk_grid_attach (GTK_GRID (group_grid
), hbox
, 2, row
, 1, 1);
1224 widget
= make_string(label
);
1225 data
->ST_path_export
= widget
;
1226 gtk_style_context_add_class (gtk_widget_get_style_context (GTK_WIDGET(widget
)), GTK_STYLE_CLASS_LINKED
);
1227 gtk_box_pack_start (GTK_BOX (hbox
), widget
, TRUE
, TRUE
, 0);
1229 //widget = gtk_button_new_with_label("...");
1230 widget
= gtk_button_new_from_icon_name(ICONNAME_FOLDER
, GTK_ICON_SIZE_BUTTON
);
1231 data
->BT_path_export
= widget
;
1232 gtk_box_pack_start (GTK_BOX (hbox
), widget
, FALSE
, FALSE
, 0);
1234 return content_grid
;
1240 draw_callback (GtkWidget
*widget
,
1244 struct defpref_data
*data
= user_data
;
1246 GtkColorScheme scheme
;
1250 index
= gtk_combo_box_get_active(GTK_COMBO_BOX(data
->CY_color_scheme
));
1252 colorscheme_init(&scheme
, index
);
1254 gtk_widget_get_size_request (widget
, &w
, &h
);
1256 for(i
=0;i
<scheme
.nb_cols
;i
++)
1258 cairo_user_set_rgbcol (cr
, &scheme
.colors
[i
]);
1259 cairo_rectangle(cr
, x
, y
, cube_dim
, cube_dim
);
1263 { x
= 0; y
= 1 + cube_dim
; }
1271 static GtkWidget
*defpref_page_reports (struct defpref_data
*data
)
1273 GtkWidget
*content_grid
, *group_grid
, *label
, *widget
;
1276 content_grid
= gtk_grid_new();
1277 gtk_grid_set_row_spacing (GTK_GRID (content_grid
), SPACING_LARGE
);
1278 gtk_orientable_set_orientation(GTK_ORIENTABLE(content_grid
), GTK_ORIENTATION_VERTICAL
);
1281 // group :: Initial filter
1282 group_grid
= gtk_grid_new ();
1283 gtk_grid_set_row_spacing (GTK_GRID (group_grid
), SPACING_SMALL
);
1284 gtk_grid_set_column_spacing (GTK_GRID (group_grid
), SPACING_MEDIUM
);
1285 gtk_grid_attach (GTK_GRID (content_grid
), group_grid
, 0, crow
++, 1, 1);
1287 label
= make_label_group(_("Initial filter"));
1288 gtk_grid_attach (GTK_GRID (group_grid
), label
, 0, 0, 3, 1);
1291 label
= make_label_widget(_("Date _range:"));
1292 //----------------------------------------- l, r, t, b
1293 gtk_grid_attach (GTK_GRID (group_grid
), label
, 1, row
, 1, 1);
1294 widget
= make_daterange(label
, FALSE
);
1295 data
->CY_daterange_rep
= widget
;
1296 //gtk_grid_attach (GTK_GRID (group_grid), data->CY_option[FILTER_DATE], 1, 2, row, row+1);
1297 gtk_grid_attach (GTK_GRID (group_grid
), widget
, 2, row
, 1, 1);
1299 // group ::Charts options
1300 group_grid
= gtk_grid_new ();
1301 gtk_grid_set_row_spacing (GTK_GRID (group_grid
), SPACING_SMALL
);
1302 gtk_grid_set_column_spacing (GTK_GRID (group_grid
), SPACING_MEDIUM
);
1303 gtk_grid_attach (GTK_GRID (content_grid
), group_grid
, 0, crow
++, 1, 1);
1305 label
= make_label_group(_("Charts options"));
1306 gtk_grid_attach (GTK_GRID (group_grid
), label
, 0, 0, 3, 1);
1309 label
= make_label_widget(_("Color scheme:"));
1310 //----------------------------------------- l, r, t, b
1311 gtk_grid_attach (GTK_GRID (group_grid
), label
, 1, row
, 1, 1);
1312 widget
= make_cycle(label
, chart_colors
);
1313 data
->CY_color_scheme
= widget
;
1314 //gtk_grid_attach (GTK_GRID (group_grid), data->CY_option[FILTER_DATE], 1, 2, row, row+1);
1315 gtk_grid_attach (GTK_GRID (group_grid
), widget
, 2, row
, 1, 1);
1318 widget
= gtk_drawing_area_new ();
1319 data
->DA_colors
= widget
;
1320 gtk_widget_set_size_request (widget
, (1+cube_dim
)*16, (1+cube_dim
)*2);
1321 gtk_grid_attach (GTK_GRID (group_grid
), widget
, 2, row
, 1, 1);
1323 g_signal_connect (data
->DA_colors
, "draw", G_CALLBACK (draw_callback
), data
);
1325 // group :: Statistics options
1326 group_grid
= gtk_grid_new ();
1327 gtk_grid_set_row_spacing (GTK_GRID (group_grid
), SPACING_SMALL
);
1328 gtk_grid_set_column_spacing (GTK_GRID (group_grid
), SPACING_MEDIUM
);
1329 gtk_grid_attach (GTK_GRID (content_grid
), group_grid
, 0, crow
++, 1, 1);
1331 label
= make_label_group(_("Statistics options"));
1332 gtk_grid_attach (GTK_GRID (group_grid
), label
, 0, 0, 3, 1);
1335 widget
= gtk_check_button_new_with_mnemonic (_("Show by _amount"));
1336 data
->CM_stat_byamount
= widget
;
1337 gtk_grid_attach (GTK_GRID (group_grid
), widget
, 1, row
, 2, 1);
1340 widget
= gtk_check_button_new_with_mnemonic (_("Show _rate column"));
1341 data
->CM_stat_showrate
= widget
;
1342 gtk_grid_attach (GTK_GRID (group_grid
), widget
, 1, row
, 2, 1);
1345 widget
= gtk_check_button_new_with_mnemonic (_("Show _details"));
1346 data
->CM_stat_showdetail
= widget
;
1347 gtk_grid_attach (GTK_GRID (group_grid
), widget
, 1, row
, 2, 1);
1349 // group :: Budget options
1350 group_grid
= gtk_grid_new ();
1351 gtk_grid_set_row_spacing (GTK_GRID (group_grid
), SPACING_SMALL
);
1352 gtk_grid_set_column_spacing (GTK_GRID (group_grid
), SPACING_MEDIUM
);
1353 gtk_grid_attach (GTK_GRID (content_grid
), group_grid
, 0, crow
++, 1, 1);
1355 label
= make_label_group(_("Budget options"));
1356 gtk_grid_attach (GTK_GRID (group_grid
), label
, 0, 0, 3, 1);
1359 widget
= gtk_check_button_new_with_mnemonic (_("Show _details"));
1360 data
->CM_budg_showdetail
= widget
;
1361 gtk_grid_attach (GTK_GRID (group_grid
), widget
, 1, row
, 2, 1);
1363 return content_grid
;
1367 static GtkWidget
*defpref_page_euro (struct defpref_data
*data
)
1369 GtkWidget
*content_grid
, *group_grid
, *label
, *widget
, *expander
;
1372 content_grid
= gtk_grid_new();
1373 gtk_grid_set_row_spacing (GTK_GRID (content_grid
), SPACING_LARGE
);
1374 gtk_orientable_set_orientation(GTK_ORIENTABLE(content_grid
), GTK_ORIENTATION_VERTICAL
);
1378 group_grid
= gtk_grid_new ();
1379 gtk_grid_set_row_spacing (GTK_GRID (group_grid
), SPACING_SMALL
);
1380 gtk_grid_set_column_spacing (GTK_GRID (group_grid
), SPACING_MEDIUM
);
1381 gtk_grid_attach (GTK_GRID (content_grid
), group_grid
, 0, crow
++, 1, 1);
1383 label
= make_label_group(_("General"));
1384 gtk_grid_attach (GTK_GRID (group_grid
), label
, 0, 0, 3, 1);
1387 widget
= gtk_check_button_new_with_mnemonic (_("_Enable"));
1388 data
->CM_euro_enable
= widget
;
1389 gtk_grid_attach (GTK_GRID (group_grid
), widget
, 1, row
, 2, 1);
1391 // group :: Currency
1392 group_grid
= gtk_grid_new ();
1393 data
->GRP_currency
= group_grid
;
1394 gtk_grid_set_row_spacing (GTK_GRID (group_grid
), SPACING_SMALL
);
1395 gtk_grid_set_column_spacing (GTK_GRID (group_grid
), SPACING_MEDIUM
);
1396 gtk_grid_attach (GTK_GRID (content_grid
), group_grid
, 0, crow
++, 1, 1);
1398 label
= make_label_group(_("Currency"));
1399 gtk_grid_attach (GTK_GRID (group_grid
), label
, 0, 0, 4, 1);
1402 widget
= make_label(NULL
, 0.0, 0.5);
1403 data
->ST_euro_country
= widget
;
1404 //gtk_grid_attach (GTK_GRID (group_grid), data->CY_option[FILTER_DATE], 1, 2, row, row+1);
1405 gtk_grid_attach (GTK_GRID (group_grid
), widget
, 1, row
, 1, 1);
1408 label
= make_label_widget(_("_Preset:"));
1409 //----------------------------------------- l, r, t, b
1410 gtk_grid_attach (GTK_GRID (group_grid
), label
, 2, row
, 1, 1);
1411 widget
= make_euro_presets(label
);
1412 data
->CY_euro_preset
= widget
;
1413 gtk_widget_set_margin_left (label
, 2*SPACING_LARGE
);
1414 //gtk_grid_attach (GTK_GRID (group_grid), data->CY_option[FILTER_DATE], 1, 2, row, row+1);
1415 gtk_grid_attach (GTK_GRID (group_grid
), widget
, 3, row
, 1, 1);
1418 // group :: Exchange rate
1419 group_grid
= gtk_grid_new ();
1420 data
->GRP_rate
= group_grid
;
1421 gtk_grid_set_row_spacing (GTK_GRID (group_grid
), SPACING_SMALL
);
1422 gtk_grid_set_column_spacing (GTK_GRID (group_grid
), SPACING_MEDIUM
);
1423 gtk_grid_attach (GTK_GRID (content_grid
), group_grid
, 0, crow
++, 1, 1);
1425 label
= make_label_group(_("Exchange rate"));
1426 gtk_grid_attach (GTK_GRID (group_grid
), label
, 0, 0, 3, 1);
1429 label
= make_label_widget("1 EUR _=");
1430 gtk_grid_attach (GTK_GRID (group_grid
), label
, 1, row
, 1, 1);
1431 widget
= make_exchange_rate(label
);
1432 data
->NB_euro_value
= widget
;
1433 //gtk_grid_attach (GTK_GRID (group_grid), data->CY_option[FILTER_DATE], 1, 2, row, row+1);
1434 gtk_grid_attach (GTK_GRID (group_grid
), widget
, 2, row
, 1, 1);
1436 // group :: Numbers format
1437 group_grid
= gtk_grid_new ();
1438 data
->GRP_format
= group_grid
;
1439 gtk_grid_set_row_spacing (GTK_GRID (group_grid
), SPACING_SMALL
);
1440 gtk_grid_set_column_spacing (GTK_GRID (group_grid
), SPACING_MEDIUM
);
1441 gtk_grid_attach (GTK_GRID (content_grid
), group_grid
, 0, crow
++, 1, 1);
1443 label
= make_label_group(_("Format"));
1444 gtk_grid_attach (GTK_GRID (group_grid
), label
, 0, 0, 3, 1);
1447 widget
= make_label(NULL
, 0, 0.0);
1448 data
->LB_numbereuro
= widget
;
1449 gtk_grid_attach (GTK_GRID (group_grid
), widget
, 1, row
, 1, 1);
1452 expander
= gtk_expander_new_with_mnemonic(_("_Customize"));
1453 gtk_grid_attach (GTK_GRID (group_grid
), expander
, 1, row
, 1, 1);
1455 group_grid
= gtk_grid_new ();
1456 gtk_grid_set_row_spacing (GTK_GRID (group_grid
), SPACING_SMALL
);
1457 gtk_grid_set_column_spacing (GTK_GRID (group_grid
), SPACING_MEDIUM
);
1458 gtk_container_add (GTK_CONTAINER (expander
), group_grid
);
1461 label
= make_label_widget(_("_Symbol:"));
1462 gtk_grid_attach (GTK_GRID (group_grid
), label
, 1, row
, 1, 1);
1463 widget
= make_string_maxlength(label
, 3);
1464 data
->ST_euro_symbol
= widget
;
1465 gtk_grid_attach (GTK_GRID (group_grid
), widget
, 2, row
, 1, 1);
1468 widget
= gtk_check_button_new_with_mnemonic (_("Is pre_fix"));
1469 data
->CM_euro_isprefix
= widget
;
1470 gtk_grid_attach (GTK_GRID (group_grid
), widget
, 2, row
, 1, 1);
1473 label
= make_label_widget(_("_Decimal char:"));
1474 gtk_grid_attach (GTK_GRID (group_grid
), label
, 1, row
, 1, 1);
1475 widget
= make_string_maxlength(label
, 1);
1476 data
->ST_euro_decimalchar
= widget
;
1477 gtk_grid_attach (GTK_GRID (group_grid
), widget
, 2, row
, 1, 1);
1480 label
= make_label_widget(_("_Frac digits:"));
1481 gtk_grid_attach (GTK_GRID (group_grid
), label
, 1, row
, 1, 1);
1482 widget
= make_numeric(label
, 0.0, 6.0);
1483 data
->NB_euro_fracdigits
= widget
;
1484 gtk_grid_attach (GTK_GRID (group_grid
), widget
, 2, row
, 1, 1);
1487 label
= make_label_widget(_("_Grouping char:"));
1488 gtk_grid_attach (GTK_GRID (group_grid
), label
, 1, row
, 1, 1);
1489 widget
= make_string_maxlength(label
, 1);
1490 data
->ST_euro_groupingchar
= widget
;
1491 gtk_grid_attach (GTK_GRID (group_grid
), widget
, 2, row
, 1, 1);
1493 return content_grid
;
1497 static GtkWidget
*defpref_page_display (struct defpref_data
*data
)
1499 GtkWidget
*content_grid
, *group_grid
, *label
, *widget
, *expander
;
1502 content_grid
= gtk_grid_new();
1503 gtk_grid_set_row_spacing (GTK_GRID (content_grid
), SPACING_LARGE
);
1504 gtk_orientable_set_orientation(GTK_ORIENTABLE(content_grid
), GTK_ORIENTATION_VERTICAL
);
1507 // group :: Date options
1508 group_grid
= gtk_grid_new ();
1509 gtk_grid_set_row_spacing (GTK_GRID (group_grid
), SPACING_SMALL
);
1510 gtk_grid_set_column_spacing (GTK_GRID (group_grid
), SPACING_MEDIUM
);
1511 gtk_grid_attach (GTK_GRID (content_grid
), group_grid
, 0, crow
++, 1, 1);
1513 label
= make_label_group(_("Date"));
1514 gtk_grid_attach (GTK_GRID (group_grid
), label
, 0, 0, 3, 1);
1517 widget
= make_label(NULL
, 0, 0.5);
1518 data
->LB_date
= widget
;
1519 gtk_grid_attach (GTK_GRID (group_grid
), widget
, 1, row
, 2, 1);
1522 expander
= gtk_expander_new_with_mnemonic(_("_Customize"));
1523 gtk_grid_attach (GTK_GRID (group_grid
), expander
, 1, row
, 1, 1);
1525 group_grid
= gtk_grid_new ();
1526 gtk_grid_set_row_spacing (GTK_GRID (group_grid
), SPACING_SMALL
);
1527 gtk_grid_set_column_spacing (GTK_GRID (group_grid
), SPACING_MEDIUM
);
1528 gtk_container_add (GTK_CONTAINER (expander
), group_grid
);
1531 label
= make_label_widget(_("_Format:"));
1532 //----------------------------------------- l, r, t, b
1533 gtk_grid_attach (GTK_GRID (group_grid
), label
, 1, row
, 1, 1);
1534 widget
= make_string(label
);
1535 data
->ST_datefmt
= widget
;
1536 //gtk_grid_attach (GTK_GRID (group_grid), data->CY_option[FILTER_DATE], 1, 2, row, row+1);
1537 gtk_grid_attach (GTK_GRID (group_grid
), widget
, 2, row
, 1, 1);
1539 widget
= gtk_image_new_from_icon_name (ICONNAME_INFO
, GTK_ICON_SIZE_BUTTON
);
1540 gtk_grid_attach (GTK_GRID (group_grid
), widget
, 3, row
, 1, 1);
1543 gtk_widget_set_tooltip_text(widget
,
1544 _("%a locale's abbreviated weekday name.\n"
1545 "%A locale's full weekday name. \n"
1546 "%b locale's abbreviated month name. \n"
1547 "%B locale's full month name. \n"
1548 "%c locale's appropriate date and time representation. \n"
1549 "%C century number (the year divided by 100 and truncated to an integer) as a decimal number [00-99]. \n"
1550 "%d day of the month as a decimal number [01,31]. \n"
1551 "%D same as %m/%d/%y. \n"
1552 "%e day of the month as a decimal number [1,31]; a single digit is preceded by a space. \n"
1553 "%j day of the year as a decimal number [001,366]. \n"
1554 "%m month as a decimal number [01,12]. \n"
1555 "%p locale's appropriate date representation. \n"
1556 "%y year without century as a decimal number [00,99]. \n"
1557 "%Y year with century as a decimal number. \n")
1561 widget
= make_label(NULL
, 0.0, 0.5);
1562 gtk_label_set_markup (GTK_LABEL(widget
), "<small><a href=\"http://man7.org/linux/man-pages/man3/strftime.3.html\">online reference</a></small>");
1563 gtk_grid_attach (GTK_GRID (group_grid
), widget
, 2, row
, 1, 1);
1565 // group :: Measurement units
1566 group_grid
= gtk_grid_new ();
1567 gtk_grid_set_row_spacing (GTK_GRID (group_grid
), SPACING_SMALL
);
1568 gtk_grid_set_column_spacing (GTK_GRID (group_grid
), SPACING_MEDIUM
);
1569 gtk_grid_attach (GTK_GRID (content_grid
), group_grid
, 0, crow
++, 1, 1);
1571 label
= make_label_group(_("Measurement units"));
1572 gtk_grid_attach (GTK_GRID (group_grid
), label
, 0, 0, 3, 1);
1575 widget
= gtk_check_button_new_with_mnemonic (_("Use _miles for meter"));
1576 data
->CM_unitismile
= widget
;
1577 gtk_grid_attach (GTK_GRID (group_grid
), widget
, 1, row
, 2, 1);
1580 widget
= gtk_check_button_new_with_mnemonic (_("Use _gallon for fuel"));
1581 data
->CM_unitisgal
= widget
;
1582 gtk_grid_attach (GTK_GRID (group_grid
), widget
, 1, row
, 2, 1);
1584 return content_grid
;
1588 static GtkWidget
*defpref_page_transactions (struct defpref_data
*data
)
1590 GtkWidget
*content_grid
, *group_grid
, *sw
, *label
, *widget
;
1593 content_grid
= gtk_grid_new();
1594 gtk_grid_set_row_spacing (GTK_GRID (content_grid
), SPACING_LARGE
);
1595 gtk_orientable_set_orientation(GTK_ORIENTABLE(content_grid
), GTK_ORIENTATION_VERTICAL
);
1598 // group :: Transaction window
1599 group_grid
= gtk_grid_new ();
1600 gtk_grid_set_row_spacing (GTK_GRID (group_grid
), SPACING_SMALL
);
1601 gtk_grid_set_column_spacing (GTK_GRID (group_grid
), SPACING_MEDIUM
);
1602 gtk_grid_attach (GTK_GRID (content_grid
), group_grid
, 0, crow
++, 1, 1);
1604 label
= make_label_group(_("Transaction window"));
1605 gtk_grid_attach (GTK_GRID (group_grid
), label
, 0, 0, 3, 1);
1608 label
= make_label_widget(_("Date _range:"));
1609 //----------------------------------------- l, r, t, b
1610 gtk_grid_attach (GTK_GRID (group_grid
), label
, 1, row
, 1, 1);
1611 widget
= make_daterange(label
, FALSE
);
1612 data
->CY_daterange_txn
= widget
;
1613 gtk_grid_attach (GTK_GRID (group_grid
), widget
, 2, row
, 1, 1);
1616 label
= make_label_widget(_("_Show:"));
1617 //----------------------------------------- l, r, t, b
1618 gtk_grid_attach (GTK_GRID (group_grid
), label
, 1, row
, 1, 1);
1619 widget
= make_numeric(NULL
, 0, 366);
1621 data
->ST_datefuture_nbdays
= widget
;
1622 gtk_grid_attach (GTK_GRID (group_grid
), widget
, 2, row
, 1, 1);
1624 //TRANSLATORS: there is a spinner on the left of this label, and so you have 0....x days in advance the current date
1625 label
= make_label(_("days in advance the current date"), 0, 0.5);
1626 gtk_grid_attach (GTK_GRID (group_grid
), label
, 3, row
, 1, 1);
1629 widget
= gtk_check_button_new_with_mnemonic (_("Hide reconciled transactions"));
1630 data
->CM_hide_reconciled
= widget
;
1631 gtk_grid_attach (GTK_GRID (group_grid
), widget
, 2, row
, 2, 1);
1634 widget
= gtk_check_button_new_with_mnemonic (_("Always show remind transactions"));
1635 data
->CM_show_remind
= widget
;
1636 gtk_grid_attach (GTK_GRID (group_grid
), widget
, 2, row
, 2, 1);
1638 // group :: Multiple add
1639 group_grid
= gtk_grid_new ();
1640 gtk_grid_set_row_spacing (GTK_GRID (group_grid
), SPACING_SMALL
);
1641 gtk_grid_set_column_spacing (GTK_GRID (group_grid
), SPACING_MEDIUM
);
1642 gtk_grid_attach (GTK_GRID (content_grid
), group_grid
, 0, crow
++, 1, 1);
1644 label
= make_label_group(_("Multiple add"));
1645 gtk_grid_attach (GTK_GRID (group_grid
), label
, 0, 0, 3, 1);
1648 widget
= gtk_check_button_new_with_mnemonic (_("Keep the last date"));
1649 data
->CM_herit_date
= widget
;
1650 gtk_grid_attach (GTK_GRID (group_grid
), widget
, 1, row
, 2, 1);
1652 // group :: Column list
1653 group_grid
= gtk_grid_new ();
1654 gtk_grid_set_row_spacing (GTK_GRID (group_grid
), SPACING_SMALL
);
1655 gtk_grid_set_column_spacing (GTK_GRID (group_grid
), SPACING_MEDIUM
);
1656 gtk_grid_attach (GTK_GRID (content_grid
), group_grid
, 0, crow
++, 1, 1);
1658 label
= make_label_group(_("Column list"));
1659 gtk_grid_attach (GTK_GRID (group_grid
), label
, 0, 0, 3, 1);
1662 sw
= gtk_scrolled_window_new (NULL
, NULL
);
1663 gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (sw
), GTK_SHADOW_ETCHED_IN
);
1664 gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (sw
), GTK_POLICY_NEVER
, GTK_POLICY_AUTOMATIC
);
1665 widget
= (GtkWidget
*)list_txn_colprefcreate();
1666 data
->LV_opecolumns
= widget
;
1667 gtk_widget_set_size_request(data
->LV_opecolumns
, HB_MINWIDTH_LIST
, -1);
1668 gtk_container_add (GTK_CONTAINER (sw
), widget
);
1669 gtk_widget_set_vexpand (sw
, TRUE
);
1670 gtk_grid_attach (GTK_GRID (group_grid
), sw
, 1, row
, 2, 1);
1671 gtk_widget_set_tooltip_text(widget
, _("Drag & drop to change the order"));
1673 return content_grid
;
1678 static GtkWidget
*defpref_page_interface (struct defpref_data
*data
)
1680 GtkWidget
*content_grid
, *group_grid
, *hbox
, *label
, *widget
;
1683 content_grid
= gtk_grid_new();
1684 gtk_grid_set_row_spacing (GTK_GRID (content_grid
), SPACING_LARGE
);
1685 gtk_orientable_set_orientation(GTK_ORIENTABLE(content_grid
), GTK_ORIENTATION_VERTICAL
);
1689 group_grid
= gtk_grid_new ();
1690 gtk_grid_set_row_spacing (GTK_GRID (group_grid
), SPACING_SMALL
);
1691 gtk_grid_set_column_spacing (GTK_GRID (group_grid
), SPACING_MEDIUM
);
1692 gtk_grid_attach (GTK_GRID (content_grid
), group_grid
, 0, crow
++, 1, 1);
1694 label
= make_label_group(_("General"));
1695 gtk_grid_attach (GTK_GRID (group_grid
), label
, 0, 0, 3, 1);
1698 label
= make_label_widget(_("_Language:"));
1699 gtk_grid_attach (GTK_GRID (group_grid
), label
, 1, row
, 1, 1);
1700 widget
= ui_language_combobox_new(label
);
1701 data
->CY_language
= widget
;
1702 gtk_grid_attach (GTK_GRID (group_grid
), widget
, 2, row
, 1, 1);
1705 label
= make_label_widget(_("_Toolbar:"));
1706 gtk_grid_attach (GTK_GRID (group_grid
), label
, 1, row
, 1, 1);
1707 widget
= make_cycle(label
, CYA_TOOLBAR_STYLE
);
1708 data
->CY_toolbar
= widget
;
1709 gtk_grid_attach (GTK_GRID (group_grid
), widget
, 2, row
, 1, 1);
1713 //widget = gtk_check_button_new_with_mnemonic (_("Enable rows in alternating colors"));
1714 //data->CM_ruleshint = widget;
1715 label
= make_label_widget(_("_Grid line:"));
1716 gtk_grid_attach (GTK_GRID (group_grid
), label
, 1, row
, 1, 1);
1717 widget
= make_cycle(label
, CYA_GRID_LINES
);
1718 data
->CY_gridlines
= widget
;
1719 gtk_grid_attach (GTK_GRID (group_grid
), widget
, 2, row
, 1, 1);
1721 // group :: Amount colors
1722 group_grid
= gtk_grid_new ();
1723 gtk_grid_set_row_spacing (GTK_GRID (group_grid
), SPACING_SMALL
);
1724 gtk_grid_set_column_spacing (GTK_GRID (group_grid
), SPACING_MEDIUM
);
1725 gtk_grid_attach (GTK_GRID (content_grid
), group_grid
, 0, crow
++, 1, 1);
1727 label
= make_label_group(_("Amount colors"));
1728 gtk_grid_attach (GTK_GRID (group_grid
), label
, 0, 0, 3, 1);
1731 widget
= gtk_check_button_new_with_mnemonic (_("Uses custom colors"));
1732 data
->CM_custom_colors
= widget
;
1733 gtk_grid_attach (GTK_GRID (group_grid
), widget
, 2, row
, 1, 1);
1735 group_grid
= gtk_grid_new ();
1736 data
->GR_colors
= group_grid
;
1737 gtk_grid_set_row_spacing (GTK_GRID (group_grid
), SPACING_SMALL
);
1738 gtk_grid_set_column_spacing (GTK_GRID (group_grid
), SPACING_MEDIUM
);
1739 gtk_grid_attach (GTK_GRID (content_grid
), group_grid
, 0, crow
++, 1, 1);
1742 label
= make_label_widget(_("_Preset:"));
1743 //----------------------------------------- l, r, t, b
1744 gtk_grid_attach (GTK_GRID (group_grid
), label
, 1, row
, 1, 1);
1745 widget
= make_cycle(label
, CYA_TANGO_COLORS
);
1746 data
->CY_colors
= widget
;
1747 //gtk_grid_attach (GTK_GRID (group_grid), data->CY_option[FILTER_DATE], 1, 2, row, row+1);
1748 gtk_grid_attach (GTK_GRID (group_grid
), widget
, 2, row
, 1, 1);
1751 label
= make_label_widget(_("_Expense:"));
1752 //----------------------------------------- l, r, t, b
1753 gtk_grid_attach (GTK_GRID (group_grid
), label
, 1, row
, 1, 1);
1754 hbox
= gtk_box_new(GTK_ORIENTATION_HORIZONTAL
, SPACING_SMALL
);
1755 gtk_grid_attach (GTK_GRID (group_grid
), hbox
, 2, row
, 1, 1);
1757 widget
= gtk_color_button_new ();
1758 data
->CP_exp_color
= widget
;
1759 gtk_box_pack_start (GTK_BOX (hbox
), widget
, FALSE
, FALSE
, 0);
1761 label
= make_label_widget(_("_Income:"));
1762 gtk_box_pack_start (GTK_BOX (hbox
), label
, FALSE
, FALSE
, 0);
1764 widget
= gtk_color_button_new ();
1765 data
->CP_inc_color
= widget
;
1766 gtk_box_pack_start (GTK_BOX (hbox
), widget
, FALSE
, FALSE
, 0);
1768 label
= make_label_widget(_("_Warning:"));
1769 gtk_box_pack_start (GTK_BOX (hbox
), label
, FALSE
, FALSE
, 0);
1771 widget
= gtk_color_button_new ();
1772 data
->CP_warn_color
= widget
;
1773 gtk_box_pack_start (GTK_BOX (hbox
), widget
, FALSE
, FALSE
, 0);
1775 return content_grid
;
1779 static GtkWidget
*defpref_page_general (struct defpref_data
*data
)
1781 GtkWidget
*content_grid
, *group_grid
, *hbox
, *label
, *widget
;
1784 content_grid
= gtk_grid_new();
1785 gtk_grid_set_row_spacing (GTK_GRID (content_grid
), SPACING_LARGE
);
1786 gtk_orientable_set_orientation(GTK_ORIENTABLE(content_grid
), GTK_ORIENTATION_VERTICAL
);
1789 // group :: Program start
1790 group_grid
= gtk_grid_new ();
1791 gtk_grid_set_row_spacing (GTK_GRID (group_grid
), SPACING_SMALL
);
1792 gtk_grid_set_column_spacing (GTK_GRID (group_grid
), SPACING_MEDIUM
);
1793 gtk_grid_attach (GTK_GRID (content_grid
), group_grid
, 0, crow
++, 1, 1);
1795 label
= make_label_group(_("Program start"));
1796 gtk_grid_attach (GTK_GRID (group_grid
), label
, 0, 0, 3, 1);
1799 widget
= gtk_check_button_new_with_mnemonic (_("Show splash screen"));
1800 data
->CM_show_splash
= widget
;
1801 gtk_grid_attach (GTK_GRID (group_grid
), widget
, 1, row
, 2, 1);
1804 widget
= gtk_check_button_new_with_mnemonic (_("Load last opened file"));
1805 data
->CM_load_last
= widget
;
1806 gtk_grid_attach (GTK_GRID (group_grid
), widget
, 1, row
, 2, 1);
1809 widget
= gtk_check_button_new_with_mnemonic (_("Post pending scheduled transactions"));
1810 data
->CM_append_scheduled
= widget
;
1811 gtk_grid_attach (GTK_GRID (group_grid
), widget
, 1, row
, 2, 1);
1814 widget
= gtk_check_button_new_with_mnemonic (_("Update currencies online"));
1815 data
->CM_do_update_currency
= widget
;
1816 gtk_grid_attach (GTK_GRID (group_grid
), widget
, 1, row
, 2, 1);
1818 // group :: Fiscal year
1819 group_grid
= gtk_grid_new ();
1820 gtk_grid_set_row_spacing (GTK_GRID (group_grid
), SPACING_SMALL
);
1821 gtk_grid_set_column_spacing (GTK_GRID (group_grid
), SPACING_MEDIUM
);
1822 gtk_grid_attach (GTK_GRID (content_grid
), group_grid
, 0, crow
++, 1, 1);
1824 label
= make_label_group(_("Fiscal year"));
1825 gtk_grid_attach (GTK_GRID (group_grid
), label
, 0, 0, 3, 1);
1828 //TRANSLATORS: (fiscal year) starts on
1829 label
= make_label_widget(_("Starts _on:"));
1830 gtk_grid_attach (GTK_GRID (group_grid
), label
, 1, row
, 1, 1);
1832 hbox
= gtk_box_new(GTK_ORIENTATION_HORIZONTAL
, SPACING_SMALL
);
1833 gtk_grid_attach (GTK_GRID (group_grid
), hbox
, 2, row
, 1, 1);
1834 widget
= make_numeric (label
, 1, 28);
1835 data
->NB_fiscyearday
= widget
;
1836 gtk_box_pack_start (GTK_BOX (hbox
), widget
, FALSE
, FALSE
, 0);
1837 widget
= make_cycle (NULL
, CYA_MONTHS
);
1838 data
->CY_fiscyearmonth
= widget
;
1839 gtk_box_pack_start (GTK_BOX (hbox
), widget
, FALSE
, FALSE
, 0);
1841 // group :: Main window reports
1842 group_grid
= gtk_grid_new ();
1843 gtk_grid_set_row_spacing (GTK_GRID (group_grid
), SPACING_SMALL
);
1844 gtk_grid_set_column_spacing (GTK_GRID (group_grid
), SPACING_MEDIUM
);
1845 gtk_grid_attach (GTK_GRID (content_grid
), group_grid
, 0, crow
++, 1, 1);
1847 label
= make_label_group(_("Main window reports"));
1848 gtk_grid_attach (GTK_GRID (group_grid
), label
, 0, 0, 3, 1);
1851 label
= make_label_widget(_("Date _range:"));
1852 gtk_grid_attach (GTK_GRID (group_grid
), label
, 1, row
, 1, 1);
1853 widget
= make_daterange(label
, FALSE
);
1854 data
->CY_daterange_wal
= widget
;
1855 gtk_grid_attach (GTK_GRID (group_grid
), widget
, 2, row
, 1, 1);
1857 // group :: Files folder
1858 group_grid
= gtk_grid_new ();
1859 gtk_grid_set_row_spacing (GTK_GRID (group_grid
), SPACING_SMALL
);
1860 gtk_grid_set_column_spacing (GTK_GRID (group_grid
), SPACING_MEDIUM
);
1861 gtk_grid_attach (GTK_GRID (content_grid
), group_grid
, 0, crow
++, 1, 1);
1863 label
= make_label_group(_("Files folder"));
1864 gtk_grid_attach (GTK_GRID (group_grid
), label
, 0, 0, 3, 1);
1867 label
= make_label_widget(_("_Default:"));
1868 gtk_grid_attach (GTK_GRID (group_grid
), label
, 1, row
, 1, 1);
1870 hbox
= gtk_box_new(GTK_ORIENTATION_HORIZONTAL
, 0);
1871 gtk_widget_set_hexpand (hbox
, TRUE
);
1872 gtk_grid_attach (GTK_GRID (group_grid
), hbox
, 2, row
, 1, 1);
1874 widget
= make_string(label
);
1875 data
->ST_path_hbfile
= widget
;
1876 gtk_style_context_add_class (gtk_widget_get_style_context (GTK_WIDGET(widget
)), GTK_STYLE_CLASS_LINKED
);
1877 gtk_box_pack_start (GTK_BOX (hbox
), widget
, TRUE
, TRUE
, 0);
1879 //widget = gtk_button_new_with_label("...");
1880 widget
= gtk_button_new_from_icon_name(ICONNAME_FOLDER
, GTK_ICON_SIZE_BUTTON
);
1881 data
->BT_path_hbfile
= widget
;
1882 gtk_box_pack_start (GTK_BOX (hbox
), widget
, FALSE
, FALSE
, 0);
1884 return content_grid
;
1888 void plugin_execute_action(GtkTreeView
* treeview
, GtkTreePath
* path
, GtkTreeViewColumn
* col
, gpointer userdata
);
1891 toggle_plugin(GtkCellRendererToggle
*cell
, gchar
* path_str
, gpointer data
)
1893 GtkTreeModel
*model
= (GtkTreeModel
*)data
;
1895 GtkTreePath
*path
= gtk_tree_path_new_from_string(path_str
);
1897 const gchar
* plugin
;
1899 gtk_tree_model_get_iter(model
, &iter
, path
);
1900 gtk_tree_model_get(model
, &iter
, EXT_COLUMN_PLUGIN_NAME
, &plugin
, -1);
1902 gboolean enabled
= ext_is_plugin_loaded(plugin
);
1904 ext_unload_plugin(plugin
);
1907 enabled
= (ext_load_plugin(plugin
) == 0);
1909 ext_run_modal(_("Plugin Error"), _("The plugin failed to load properly."), "error");
1914 gtk_list_store_set(GTK_LIST_STORE (model
), &iter
, EXT_COLUMN_ENABLED
, enabled
, -1);
1917 gtk_tree_path_free(path
);
1921 void plugin_execute_action(GtkTreeView
* treeview
, GtkTreePath
* path
, GtkTreeViewColumn
* col
, gpointer userdata
)
1923 GtkTreeModel
* model
= gtk_tree_view_get_model(treeview
);
1926 if (gtk_tree_model_get_iter(model
, &iter
, path
)) {
1927 gchar
* plugin_filename
;
1928 gtk_tree_model_get(model
, &iter
, EXT_COLUMN_PLUGIN_NAME
, &plugin_filename
, -1);
1929 ext_execute_action(plugin_filename
);
1930 g_free(plugin_filename
);
1934 static GtkWidget
*defpref_page_plugins (struct defpref_data
*data
)
1936 GtkWidget
*container
;
1937 GtkListStore
*store
;
1941 container
= gtk_vbox_new(FALSE
, 0);
1943 store
= gtk_list_store_new(EXT_NUM_COLUMNS
, G_TYPE_BOOLEAN
, G_TYPE_STRING
, G_TYPE_STRING
, G_TYPE_STRING
);
1945 gchar
** plugins
= ext_list_plugins();
1947 for (plugins_it
= plugins
; *plugins_it
; ++plugins_it
) {
1949 gboolean enabled
= ext_is_plugin_loaded(*plugins_it
);
1950 GHashTable
* metadata
= ext_read_plugin_metadata(*plugins_it
);
1952 metadata
= g_hash_table_new(g_str_hash
, g_str_equal
);
1958 gchar
* name
= g_hash_table_lookup(metadata
, "name");
1959 if (!name
|| *name
== '\0') {
1962 name
= g_markup_escape_text(name
, -1);
1963 gchar
* label
= g_strdup_printf("<b>%s</b>", name
);
1964 gchar
* tooltip
= g_strdup_printf("<span size='x-large' weight='bold'>%s</span>", name
);
1968 gchar
* version
= g_hash_table_lookup(metadata
, "version");
1970 version
= g_markup_escape_text(version
, -1);
1972 label
= g_strdup_printf("%s %s", tmp
, version
);
1975 tooltip
= g_strdup_printf("%s %s", tmp
, version
);
1981 gchar
* abstract
= g_hash_table_lookup(metadata
, "abstract");
1983 abstract
= g_markup_escape_text(abstract
, -1);
1985 label
= g_strdup_printf("%s\n%s", tmp
, abstract
);
1991 gchar
* author
= g_hash_table_lookup(metadata
, "author");
1993 author
= g_markup_escape_text(author
, -1);
1995 tooltip
= g_strdup_printf("%s\n%s", tmp
, author
);
2001 gchar
* website
= g_hash_table_lookup(metadata
, "website");
2003 website
= g_markup_escape_text(website
, -1);
2005 tooltip
= g_strdup_printf("%s\n<b>%s:</b> %s", tmp
, _("Website"), website
);
2011 tmp
= ext_find_plugin(*plugins_it
);
2012 gchar
* full
= g_markup_escape_text(tmp
, -1);
2015 tooltip
= g_strdup_printf("%s\n<b>%s:</b> %s", tmp
, _("File"), full
);
2019 g_hash_table_unref(metadata
);
2021 gtk_list_store_append(store
, &it
);
2022 gtk_list_store_set(store
, &it
,
2023 EXT_COLUMN_ENABLED
, enabled
,
2024 EXT_COLUMN_LABEL
, label
,
2025 EXT_COLUMN_TOOLTIP
, tooltip
,
2026 EXT_COLUMN_PLUGIN_NAME
, *plugins_it
,
2032 g_strfreev(plugins
);
2034 view
= gtk_tree_view_new_with_model(GTK_TREE_MODEL(store
));
2035 g_object_unref(store
);
2037 g_signal_connect(view
, "row-activated", (GCallback
)plugin_execute_action
, NULL
);
2039 gtk_tree_view_set_rules_hint(GTK_TREE_VIEW(view
), TRUE
);
2040 gtk_tree_view_set_headers_visible(GTK_TREE_VIEW(view
), TRUE
);
2041 gtk_tree_view_set_tooltip_column(GTK_TREE_VIEW(view
), EXT_COLUMN_TOOLTIP
);
2044 GtkTreeViewColumn
*col
;
2045 GtkCellRenderer
*renderer
;
2048 col
= gtk_tree_view_column_new();
2049 gtk_tree_view_column_set_title(col
, _("Enabled"));
2050 gtk_tree_view_column_set_sort_column_id(col
, EXT_COLUMN_ENABLED
);
2051 gtk_tree_view_append_column(GTK_TREE_VIEW(view
), col
);
2053 renderer
= gtk_cell_renderer_toggle_new();
2054 gtk_tree_view_column_pack_start(col
, renderer
, TRUE
);
2055 gtk_tree_view_column_add_attribute(col
, renderer
, "active", 0);
2056 g_signal_connect(renderer
, "toggled", G_CALLBACK(toggle_plugin
), store
);
2058 col
= gtk_tree_view_column_new();
2059 gtk_tree_view_column_set_title(col
, _("Plugin"));
2060 gtk_tree_view_column_set_sort_column_id(col
, EXT_COLUMN_LABEL
);
2061 gtk_tree_view_column_set_expand(col
, TRUE
);
2062 /*gtk_tree_view_column_set_sort_order(col, GTK_SORT_ASCENDING);*/
2063 gtk_tree_view_append_column(GTK_TREE_VIEW(view
), col
);
2065 renderer
= gtk_cell_renderer_text_new();
2066 g_object_set(renderer
, "ellipsize", PANGO_ELLIPSIZE_END
, NULL
);
2067 gtk_tree_view_column_pack_start(col
, renderer
, TRUE
);
2068 gtk_tree_view_column_add_attribute(col
, renderer
, "markup", EXT_COLUMN_LABEL
);
2070 data
->PI_plugin_columns
= view
;
2072 GtkWidget
* sw
= gtk_scrolled_window_new(NULL
, NULL
);
2073 gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(sw
), GTK_SHADOW_ETCHED_IN
);
2074 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(sw
), GTK_POLICY_NEVER
, GTK_POLICY_AUTOMATIC
);
2075 gtk_container_add(GTK_CONTAINER(sw
), view
);
2077 gtk_box_pack_start(GTK_BOX(container
), sw
, TRUE
, TRUE
, 0);
2083 static void defpref_selection(GtkTreeSelection
*treeselection
, gpointer user_data
)
2085 struct defpref_data
*data
;
2086 GtkWidget
*notebook
;
2087 GtkTreeView
*treeview
;
2088 GtkTreeModel
*model
;
2091 GValue val
= { 0, };
2094 DB( g_print("\n[ui-pref] selection\n") );
2096 if (gtk_tree_selection_get_selected(treeselection
, &model
, &iter
))
2098 notebook
= GTK_WIDGET(user_data
);
2099 treeview
= gtk_tree_selection_get_tree_view(treeselection
);
2100 data
= g_object_get_data(G_OBJECT(gtk_widget_get_ancestor(GTK_WIDGET(treeview
), GTK_TYPE_WINDOW
)), "inst_data");
2103 gtk_tree_model_get_value(model
, &iter
, LST_PREF_PAGE
, &val
);
2104 page
= g_value_get_int (&val
);
2105 DB( g_print(" - active is %d\n", page
) );
2106 g_value_unset (&val
);
2109 gtk_tree_model_get_value(model
, &iter
, LST_PREF_NAME
, &val
);
2110 gtk_label_set_text (GTK_LABEL (data
->label
), g_value_get_string (&val
));
2111 g_value_unset (&val
);
2113 gtk_tree_model_get_value(model
, &iter
, LST_PREF_ICONNAME
, &val
);
2114 //gtk_image_set_from_pixbuf (GTK_IMAGE (data->image), g_value_get_object (&val));
2115 gtk_image_set_from_icon_name(GTK_IMAGE (data
->image
), g_value_get_string (&val
), GTK_ICON_SIZE_DIALOG
);
2116 g_value_unset (&val
);
2120 gtk_notebook_set_current_page(GTK_NOTEBOOK(notebook
), page
);
2122 //defpref_change_page(GTK_WIDGET(gtk_tree_selection_get_tree_view(treeselection)), GINT_TO_POINTER(page));
2129 ** set the notebook active page from treeview
2131 /*void defpref_change_page(GtkWidget *widget, gpointer user_data)
2133 struct defpref_data *data;
2134 gint page = GPOINTER_TO_INT(user_data);
2135 GtkTreeModel *model;
2138 DB( g_print("\n[ui-pref] page\n") );
2140 data = g_object_get_data(G_OBJECT(gtk_widget_get_ancestor(widget, GTK_TYPE_WINDOW)), "inst_data");
2142 model = gtk_tree_view_get_model(GTK_TREE_VIEW(data->LV_page));
2150 gtk_notebook_set_current_page(GTK_NOTEBOOK(data->GR_page), page);
2156 ** add an empty new account to our temp GList and treeview
2158 static void defpref_clear(GtkWidget
*widget
, gpointer user_data
)
2160 struct defpref_data
*data
;
2163 data
= g_object_get_data(G_OBJECT(gtk_widget_get_ancestor(widget
, GTK_TYPE_WINDOW
)), "inst_data");
2164 DB( g_print("\n(defpref_clear) (data=%p)\n", data
) );
2166 result
= ui_dialog_msg_confirm_alert(
2167 GTK_WINDOW(data
->window
),
2168 _("Reset all preferences"),
2169 _("Do you really want to reset all\npreferences to default values?"),
2172 if( result
== GTK_RESPONSE_OK
)
2174 homebank_pref_setdefault();
2181 // the window creation
2182 GtkWidget
*defpref_dialog_new (gint initial_selection
)
2184 struct defpref_data data
;
2185 GtkWidget
*window
, *content
, *mainvbox
;
2186 GtkWidget
*hbox
, *vbox
, *sw
, *widget
, *notebook
, *page
, *ebox
, *image
, *label
;
2188 window
= gtk_dialog_new_with_buttons (_("Preferences"),
2189 GTK_WINDOW(GLOBALS
->mainwindow
),
2192 GTK_RESPONSE_REJECT
,
2194 GTK_RESPONSE_ACCEPT
,
2197 data
.window
= window
;
2199 //store our window private data
2200 g_object_set_data(G_OBJECT(window
), "inst_data", (gpointer
)&data
);
2202 gtk_window_set_icon_name(GTK_WINDOW (window
), ICONNAME_PREFERENCES
);
2204 content
= gtk_dialog_get_content_area(GTK_DIALOG (window
)); // return a vbox
2205 mainvbox
= gtk_box_new(GTK_ORIENTATION_VERTICAL
, SPACING_MEDIUM
);
2206 gtk_box_pack_start (GTK_BOX (content
), mainvbox
, TRUE
, TRUE
, 0);
2208 gtk_container_set_border_width(GTK_CONTAINER(mainvbox
), SPACING_MEDIUM
);
2210 hbox
= gtk_box_new(GTK_ORIENTATION_HORIZONTAL
, SPACING_MEDIUM
);
2211 gtk_box_pack_start (GTK_BOX (mainvbox
), hbox
, TRUE
, TRUE
, 0);
2214 vbox
= gtk_box_new(GTK_ORIENTATION_VERTICAL
, SPACING_SMALL
);
2215 gtk_box_pack_start (GTK_BOX (hbox
), vbox
, FALSE
, FALSE
, 0);
2218 sw
= gtk_scrolled_window_new (NULL
, NULL
);
2219 gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (sw
), GTK_SHADOW_ETCHED_IN
);
2220 gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (sw
), GTK_POLICY_NEVER
, GTK_POLICY_AUTOMATIC
);
2221 gtk_box_pack_start (GTK_BOX (vbox
), sw
, TRUE
, TRUE
, 0);
2222 widget
= pref_list_create();
2223 data
.LV_page
= widget
;
2224 gtk_container_add (GTK_CONTAINER (sw
), widget
);
2227 data
.BT_clear
= gtk_button_new_with_mnemonic(_("_Reset"));
2228 gtk_box_pack_start (GTK_BOX (vbox
), data
.BT_clear
, FALSE
, TRUE
, 0);
2231 //right part : notebook
2232 vbox
= gtk_box_new (GTK_ORIENTATION_VERTICAL
, SPACING_MEDIUM
);
2233 gtk_box_pack_start (GTK_BOX (hbox
), vbox
, TRUE
, TRUE
, 0);
2234 gtk_widget_show (vbox
);
2236 ebox
= gtk_event_box_new();
2237 gtk_widget_set_name(ebox
, "hbebox");
2238 GtkStyleContext
*context
= gtk_widget_get_style_context (ebox
);
2239 #if GTK_MINOR_VERSION <= 18
2240 gtk_style_context_add_class (context
, GTK_STYLE_CLASS_LIST_ROW
);
2241 gtk_widget_set_state_flags(ebox
, GTK_STATE_FLAG_SELECTED
, TRUE
);
2243 GtkCssProvider
*provider
;
2244 provider
= gtk_css_provider_new ();
2245 gtk_css_provider_load_from_data (provider
,
2246 "#hbebox { color: @theme_selected_fg_color; background-color: @theme_selected_bg_color; }"
2248 gtk_style_context_add_provider (context
, GTK_STYLE_PROVIDER(provider
), G_MAXUINT
);
2250 // gtk_style_context_set_state(context, GTK_STATE_FLAG_SELECTED);
2253 gtk_box_pack_start (GTK_BOX (vbox
), ebox
, FALSE
, TRUE
, 0);
2254 gtk_widget_show (ebox
);
2256 hbox
= gtk_box_new (GTK_ORIENTATION_HORIZONTAL
, SPACING_SMALL
);
2257 gtk_container_set_border_width (GTK_CONTAINER (hbox
), SPACING_SMALL
);
2258 gtk_container_add (GTK_CONTAINER (ebox
), hbox
);
2259 gtk_widget_show (hbox
);
2261 label
= gtk_label_new (NULL
);
2262 gtk_widget_set_margin_left(label
, SPACING_MEDIUM
);
2263 gimp_label_set_attributes (GTK_LABEL (label
),
2264 PANGO_ATTR_SCALE
, PANGO_SCALE_XX_LARGE
,
2265 PANGO_ATTR_WEIGHT
, PANGO_WEIGHT_BOLD
,
2268 gtk_box_pack_start (GTK_BOX (hbox
), label
, FALSE
, FALSE
, 0);
2269 gtk_widget_show (label
);
2272 image
= gtk_image_new ();
2273 gtk_box_pack_end (GTK_BOX (hbox
), image
, FALSE
, FALSE
, 0);
2274 gtk_widget_show (image
);
2280 notebook
= gtk_notebook_new();
2281 data
.GR_page
= notebook
;
2282 gtk_widget_show(notebook
);
2283 gtk_notebook_set_show_tabs(GTK_NOTEBOOK(notebook
), FALSE
);
2284 gtk_notebook_set_show_border(GTK_NOTEBOOK(notebook
), FALSE
);
2285 gtk_box_pack_start (GTK_BOX (vbox
), notebook
, TRUE
, TRUE
, 0);
2297 page
= defpref_page_general(&data
);
2298 gtk_notebook_append_page (GTK_NOTEBOOK (notebook
), page
, NULL
);
2301 page
= defpref_page_interface(&data
);
2302 gtk_notebook_append_page (GTK_NOTEBOOK (notebook
), page
, NULL
);
2305 page
= defpref_page_transactions(&data
);
2306 gtk_notebook_append_page (GTK_NOTEBOOK (notebook
), page
, NULL
);
2309 page
= defpref_page_display(&data
);
2310 gtk_notebook_append_page (GTK_NOTEBOOK (notebook
), page
, NULL
);
2313 page
= defpref_page_import(&data
);
2314 gtk_notebook_append_page (GTK_NOTEBOOK (notebook
), page
, NULL
);
2317 page
= defpref_page_reports(&data
);
2318 gtk_notebook_append_page (GTK_NOTEBOOK (notebook
), page
, NULL
);
2321 page
= defpref_page_euro(&data
);
2322 gtk_notebook_append_page (GTK_NOTEBOOK (notebook
), page
, NULL
);
2325 page
= defpref_page_plugins(&data
);
2326 gtk_notebook_append_page (GTK_NOTEBOOK (notebook
), page
, NULL
);
2329 //todo:should move this
2330 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(data
.CM_euro_enable
), PREFS
->euro_active
);
2332 //connect all our signals
2333 g_signal_connect (window
, "destroy", G_CALLBACK (gtk_widget_destroyed
), &window
);
2335 g_signal_connect (G_OBJECT (data
.BT_clear
), "clicked", G_CALLBACK (defpref_clear
), NULL
);
2338 g_signal_connect (data
.BT_path_hbfile
, "pressed", G_CALLBACK (defpref_pathselect
), GINT_TO_POINTER(1));
2339 g_signal_connect (data
.BT_path_import
, "pressed", G_CALLBACK (defpref_pathselect
), GINT_TO_POINTER(2));
2340 g_signal_connect (data
.BT_path_export
, "pressed", G_CALLBACK (defpref_pathselect
), GINT_TO_POINTER(3));
2342 g_signal_connect (data
.CM_custom_colors
, "toggled", G_CALLBACK (defpref_colortoggle
), NULL
);
2343 g_signal_connect (data
.CY_colors
, "changed", G_CALLBACK (defpref_colorpreset
), NULL
);
2347 g_signal_connect (gtk_tree_view_get_selection(GTK_TREE_VIEW(data
.LV_page
)), "changed", G_CALLBACK (defpref_selection
), notebook
);
2349 g_signal_connect (data
.CM_euro_enable
, "toggled", G_CALLBACK (defpref_eurotoggle
), NULL
);
2351 g_signal_connect (data
.CY_euro_preset
, "changed", G_CALLBACK (defpref_europreset
), NULL
);
2354 g_signal_connect (data
.ST_datefmt
, "changed", G_CALLBACK (defpref_date_sample
), NULL
);
2357 g_signal_connect (data
.CY_color_scheme
, "changed", G_CALLBACK (defpref_color_scheme_changed
), NULL
);
2361 g_signal_connect (data
.ST_euro_symbol
, "changed", G_CALLBACK (defpref_numbereuro_sample
), NULL
);
2362 g_signal_connect (data
.CM_euro_isprefix
, "toggled", G_CALLBACK (defpref_numbereuro_sample
), NULL
);
2363 g_signal_connect (data
.ST_euro_decimalchar
, "changed", G_CALLBACK (defpref_numbereuro_sample
), NULL
);
2364 g_signal_connect (data
.ST_euro_groupingchar
, "changed", G_CALLBACK (defpref_numbereuro_sample
), NULL
);
2365 g_signal_connect (data
.NB_euro_fracdigits
, "value-changed", G_CALLBACK (defpref_numbereuro_sample
), NULL
);
2367 //g_signal_connect (data.BT_default, "pressed", G_CALLBACK (defpref_currency_change), NULL);
2370 //setup, init and show window
2371 //defhbfile_setup(&data);
2372 //defhbfile_update(data.LV_arc, NULL);
2376 defpref_colortoggle(window
, NULL
);
2377 defpref_eurotoggle(window
, NULL
);
2379 gtk_window_resize(GTK_WINDOW(window
), 640, 256);
2383 GtkTreePath
*path
= gtk_tree_path_new_from_indices(initial_selection
, -1);
2386 gtk_tree_selection_select_path (gtk_tree_view_get_selection(GTK_TREE_VIEW(data
.LV_page
)), path
);
2390 gtk_tree_path_free(path
);
2392 gtk_widget_show_all (window
);
2393 gtk_notebook_set_current_page(GTK_NOTEBOOK(notebook
), initial_selection
);
2400 result
= gtk_dialog_run (GTK_DIALOG (window
));
2404 case GTK_RESPONSE_ACCEPT
:
2405 old_lang
= g_strdup(PREFS
->language
);
2407 homebank_pref_save();
2408 ui_mainwindow_update(GLOBALS
->mainwindow
, GINT_TO_POINTER(UF_BALANCE
+UF_VISUAL
));
2410 DB( g_print("old='%s' new='%s'\n", old_lang
, PREFS
->language
) );
2412 if(g_ascii_strncasecmp(old_lang
== NULL
? "" : old_lang
, PREFS
->language
== NULL
? "" : PREFS
->language
, -1) != 0)
2414 ui_dialog_msg_infoerror(GTK_WINDOW(window
), GTK_MESSAGE_INFO
,
2416 _("You will have to restart HomeBank\nfor the language change to take effect.")
2426 // cleanup and destroy
2427 //defhbfile_cleanup(&data, result);
2428 gtk_widget_destroy (window
);
2433 // -------------------------------
2436 GtkWidget
*pref_list_create(void)
2438 GtkListStore
*store
;
2440 GtkCellRenderer
*renderer
;
2441 GtkTreeViewColumn
*column
;
2445 /* create list store */
2446 store
= gtk_list_store_new(
2454 view
= gtk_tree_view_new_with_model(GTK_TREE_MODEL(store
));
2455 g_object_unref(store
);
2457 gtk_tree_view_set_headers_visible(GTK_TREE_VIEW (view
), FALSE
);
2458 gtk_tree_selection_set_mode(gtk_tree_view_get_selection(GTK_TREE_VIEW(view
)), GTK_SELECTION_SINGLE
);
2460 /* column 1: icon */
2461 column
= gtk_tree_view_column_new();
2462 renderer
= gtk_cell_renderer_pixbuf_new ();
2463 g_object_set(renderer
, "stock-size", GTK_ICON_SIZE_DND
, NULL
);
2464 gtk_tree_view_column_pack_start(column
, renderer
, FALSE
);
2465 gtk_tree_view_column_set_attributes(column
, renderer
, "icon-name", LST_PREF_ICONNAME
, NULL
);
2467 renderer
= gtk_cell_renderer_text_new ();
2468 gtk_tree_view_column_pack_start(column
, renderer
, TRUE
);
2469 gtk_tree_view_column_set_attributes(column
, renderer
, "text", LST_PREF_NAME
, NULL
);
2471 gtk_tree_view_append_column (GTK_TREE_VIEW(view
), column
);
2473 //populate our combobox model
2474 for(i
=0;i
<PREF_MAX
;i
++)
2476 gtk_list_store_append(store
, &iter
);
2478 gtk_list_store_set(store
, &iter
,
2479 LST_PREF_ICONNAME
, pref_iconname
[i
],
2480 LST_PREF_NAME
, _(pref_name
[i
]),
2489 /* = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =*/
2492 extern gchar
*list_txn_column_label
[];
2496 list_txn_colpref_toggled_cell_data_function (GtkCellRendererToggle
*cell
,
2500 GtkTreeModel
*model
= (GtkTreeModel
*)data
;
2502 GtkTreePath
*path
= gtk_tree_path_new_from_string (path_str
);
2505 /* get toggled iter */
2506 gtk_tree_model_get_iter (model
, &iter
, path
);
2507 gtk_tree_model_get (model
, &iter
, COLUMN_VISIBLE
, &fixed
, -1);
2509 /* do something with the value */
2513 gtk_list_store_set (GTK_LIST_STORE (model
), &iter
, COLUMN_VISIBLE
, fixed
, -1);
2516 gtk_tree_path_free (path
);
2520 static void list_txn_colpref_get(GtkTreeView
*treeview
, gint
*columns
)
2522 GtkTreeModel
*model
;
2528 DB( g_print("[lst_txn-colpref] store column order \n") );
2531 model
= gtk_tree_view_get_model(GTK_TREE_VIEW(treeview
));
2532 valid
= gtk_tree_model_get_iter_first(GTK_TREE_MODEL(model
), &iter
);
2536 gtk_tree_model_get(GTK_TREE_MODEL(model
), &iter
,
2537 COLUMN_VISIBLE
, &visible
,
2541 DB( g_print(" - column %d: %d\n",id
, visible
) );
2542 // start at index 2 (status, date always displayed
2543 columns
[i
+2] = visible
== TRUE
? id
: -id
;
2545 /* Make iter point to the next row in the list store */
2546 valid
= gtk_tree_model_iter_next(GTK_TREE_MODEL(model
), &iter
);
2555 GtkWidget
*list_txn_colprefcreate(void)
2557 GtkListStore
*store
;
2559 GtkCellRenderer
*renderer
;
2560 GtkTreeViewColumn
*column
;
2564 DB( g_print("[lst_txn-colpref] create\n") );
2567 /* create list store */
2568 store
= gtk_list_store_new(
2576 for(i
=0 ; i
< NUM_LST_DSPOPE
-1; i
++ ) //-1 cause account column avoid
2581 DB( g_print("eval %d, %s\n", i
, list_txn_column_label
[i
]) );
2583 if(i
<= LST_DSPOPE_DATE
) // status, date always displayed
2586 //[i-1] here because lst_ope_columns[] do not store LST_DSPOPE_DATAS
2587 id
= ABS(PREFS
->lst_ope_columns
[i
-1]);
2588 if(id
== 0) id
= i
; //if we pass here, new column or weird into pref file
2589 visible
= (PREFS
->lst_ope_columns
[i
-1] > 0) ? TRUE
: FALSE
;
2592 DB( g_print(" - pos=%2d, id=%2d - %d '%s'\n", i
, id
, visible
, list_txn_column_label
[id
]) );
2594 gtk_list_store_append (store
, &iter
);
2595 gtk_list_store_set (store
, &iter
,
2596 COLUMN_VISIBLE
, visible
,
2597 COLUMN_NAME
, _(list_txn_column_label
[id
]),
2604 view
= gtk_tree_view_new_with_model(GTK_TREE_MODEL(store
));
2605 g_object_unref(store
);
2609 renderer
= gtk_cell_renderer_toggle_new ();
2610 column
= gtk_tree_view_column_new_with_attributes (_("Visible"),
2612 "active", COLUMN_VISIBLE
,
2614 gtk_tree_view_append_column (GTK_TREE_VIEW(view
), column
);
2616 g_signal_connect (renderer
, "toggled",
2617 G_CALLBACK (list_txn_colpref_toggled_cell_data_function
), store
);
2620 renderer
= gtk_cell_renderer_text_new ();
2621 column
= gtk_tree_view_column_new_with_attributes (_("Column"),
2623 "text", COLUMN_NAME
,
2625 gtk_tree_view_append_column (GTK_TREE_VIEW(view
), column
);
2627 gtk_tree_view_set_reorderable (GTK_TREE_VIEW(view
), TRUE
);
2634 static void list_ext_colpref_get(GtkTreeView
*treeview
, GList
**columns
)
2636 GtkTreeModel
*model
;
2639 g_list_free_full(*columns
, g_free
);
2642 model
= gtk_tree_view_get_model(GTK_TREE_VIEW(treeview
));
2644 gboolean valid
= gtk_tree_model_get_iter_first(GTK_TREE_MODEL(model
), &iter
);
2646 gboolean enabled
= FALSE
;
2649 gtk_tree_model_get(GTK_TREE_MODEL(model
), &iter
,
2650 EXT_COLUMN_ENABLED
, &enabled
,
2651 EXT_COLUMN_PLUGIN_NAME
, &name
,
2655 *columns
= g_list_append(*columns
, g_strdup(name
));
2658 valid
= gtk_tree_model_iter_next(GTK_TREE_MODEL(model
), &iter
);