1 /* HomeBank -- Free, easy, personal accounting for everyone.
2 * Copyright (C) 1995-2017 Maxime DOYEN
4 * This file is part of HomeBank.
6 * HomeBank is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * HomeBank is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program. If not, see <http://www.gnu.org/licenses/>.
24 #include "dsp_mainwindow.h"
25 #include "gtk-chart-colors.h"
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
[];
155 //gchar *prefix_symbol; /* max symbol is 3 digits in unicode */
156 //gchar *suffix_symbol; /* but mostly is 1 digit */
160 gchar
*grouping_char
;
167 http://en.wikipedia.org/wiki/Currencies_of_the_European_Union
168 http://www.xe.com/euro.php
169 http://fr.wikipedia.org/wiki/Liste_des_unit%C3%A9s_mon%C3%A9taires_remplac%C3%A9es_par_l%27euro
170 http://www.inter-locale.com/LocalesDemo.jsp
172 static EuroParams euro_params
[] =
174 // , rate , symb , prfx , dec, grp, frac
175 // ---------------------------------------------------------------------
176 { 0, "" , "--------" , 1.0 , "" , FALSE
, ",", ".", 2 },
177 { 1, "ATS", "Austria" , 13.7603 , "S" , TRUE
, ",", ".", 2 }, // -S 1.234.567,89
178 { 2, "BEF", "Belgium" , 40.3399 , "BF" , TRUE
, ",", ".", 2 }, // BF 1.234.567,89 -
179 { 20, "BGN", "Bulgaria" , 1.95583 , "лв." , TRUE
, ",", " ", 2 }, // non-fixé - 2014 target for euro
180 { 24, "HRK", "Croatia" , 1.0000 , "kn" , FALSE
, "" , ".", 0 }, // non-fixé - 2015 target for euro earliest
181 { 14, "CYP", "Cyprus" , 0.585274 , "£" , TRUE
, ",", "" , 2 }, //
182 { 23, "CZK", "Czech Republic" , 28.36 , "Kč" , FALSE
, ",", " ", 2 }, // non-fixé - 2015 earliest
184 { 17, "EEK", "Estonia" , 15.6466 , "kr" , FALSE
, ",", " ", 2 }, //
185 { 3, "FIM", "Finland" , 5.94573 , "mk" , FALSE
, ",", " ", 2 }, // -1 234 567,89 mk
186 { 4, "FRF", "France" , 6.55957 , "F" , FALSE
, ",", " ", 2 }, // -1 234 567,89 F
187 { 5, "DEM", "Germany" , 1.95583 , "DM" , FALSE
, ",", ".", 2 }, // -1.234.567,89 DM
188 { 6, "GRD", "Greece" , 340.750 , "d" , TRUE
, ".", ",", 2 }, // ??
189 { 21, "HUF", "Hungary" , 261.51 , "Ft" , TRUE
, ",", " ", 2 }, // non-fixé - No current target for euro
190 { 7, "IEP", "Ireland" , 0.787564 , "£" , TRUE
, ".", ",", 2 }, // -£1,234,567.89
191 { 8, "ITL", "Italy" , 1936.27 , "L" , TRUE
, "" , ".", 0 }, // L -1.234.567
192 { 18, "LVL", "Latvia" , 0.702804 , "lat.", FALSE
, ",", "" , 2 }, // jan. 2014
193 { 19, "LTL", "Lithuania" , 3.45280 , "Lt" , FALSE
, ",", "" , 2 }, // jan. 2015
194 { 9, "LUF", "Luxembourg" , 40.3399 , "LU" , TRUE
, ",", ".", 2 }, // LU 1.234.567,89 -
195 { 15, "MTL", "Malta" , 0.429300 , "Lm" , TRUE
, ",", "" , 2 }, //
196 { 10, "NLG", "Netherlands" , 2.20371 , "F" , TRUE
, ",", ".", 2 }, // F 1.234.567,89-
197 { 25, "PLN", "Poland" , 0.25 , "zł" , FALSE
, ",", "" , 2 }, // non-fixé - No current target for euro
198 { 11, "PTE", "Portugal" , 200.482 , "Esc.", FALSE
, "$", ".", 2 }, // -1.234.567$89 Esc.
199 { 22, "RON", "Romania" , 3.5155 , "Leu" , FALSE
, ",", ".", 2 }, // non-fixé - 2015 target for euro earliest
200 { 16, "SKK", "Slovak Republic", 30.12600 , "Sk" , FALSE
, ",", " ", 2 }, //
201 { 13, "SIT", "Slovenia" , 239.640 , "tol" , TRUE
, ",", ".", 2 }, //
202 { 12, "ESP", "Spain" , 166.386 , "Pts" , TRUE
, "" , ".", 0 }, // -Pts 1.234.567
205 // { " ", "" , 1.00000 , "" , "" , FALSE, ",", "", 2 },
209 GtkWidget
*pref_list_create(void);
210 GtkWidget
*list_txn_colprefcreate(void);
212 static void list_txn_colpref_get(GtkTreeView
*treeview
, gboolean
*columns
);
214 static void list_ext_colpref_get(GtkTreeView
*treeview
, GList
**columns
);
219 /* = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =*/
227 static LangName languagenames
[] =
229 // 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
230 //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
233 { "ab", "Abkhazian" },
235 { "af", "Afrikaans" },
238 { "an", "Aragonese" },
240 { "as", "Assamese" },
241 { "ast", "Asturian, Bable, Leonese, Asturleonese" },
244 { "az", "Azerbaijani" },
246 { "be", "Belarusian" },
247 { "bg", "Bulgarian" },
257 { "ch", "Chamorro" },
258 { "co", "Corsican" },
261 { "cu", "Old Church Slavonic" },
267 { "dz", "Dzongkha" },
271 { "eo", "Esperanto" },
273 { "et", "Estonian" },
281 { "fy", "Western Frisian" },
283 { "gd", "Scottish Gaelic" },
284 { "gl", "Galician" },
286 { "gu", "Gujarati" },
291 { "ho", "Hiri Motu" },
292 { "hr", "Croatian" },
294 { "hu", "Hungarian" },
295 { "hy", "Armenian" },
297 { "ia", "Interlingua" },
298 { "id", "Indonesian" },
299 { "ie", "Interlingue" },
301 { "ii", "Sichuan Yi" },
304 { "is", "Icelandic" },
306 { "iu", "Inuktitut" },
307 { "ja", "Japanese" },
308 { "jv", "Javanese" },
309 { "ka", "Georgian" },
312 { "kj", "Kwanyama" },
314 { "kl", "Kalaallisut" },
319 { "ks", "Kashmiri" },
325 { "lb", "Luxembourgish" },
327 { "li", "Limburgish" },
330 { "lt", "Lithuanian" },
331 { "lu", "Luba-Katanga" },
333 { "mg", "Malagasy" },
334 { "mh", "Marshallese" },
336 { "mk", "Macedonian" },
337 { "ml", "Malayalam" },
338 { "mn", "Mongolian" },
339 { "mo", "Moldavian" },
345 { "nb", "Norwegian Bokmål" },
346 { "nd", "North Ndebele" },
347 { "nds", "Low German, Low Saxon" },
351 { "nn", "Norwegian Nynorsk" },
352 { "no", "Norwegian" },
353 { "nr", "South Ndebele" },
355 { "ny", "Chichewa" },
360 { "os", "Ossetian" },
365 { "pt", "Portuguese" },
369 { "ro", "Romanian" },
371 { "rw", "Kinyarwanda" },
372 { "sa", "Sanskrit" },
373 { "sc", "Sardinian" },
375 { "se", "Northern Sami" },
377 { "si", "Sinhalese" },
383 { "sq", "Albanian" },
387 { "su", "Sundanese" },
394 { "ti", "Tigrinya" },
403 { "ty", "Tahitian" },
405 { "uk", "Ukrainian" },
409 { "vi", "Viêt Namese" },
424 ui_language_combobox_compare_func (GtkTreeModel
*model
, GtkTreeIter
*a
, GtkTreeIter
*b
, gpointer userdata
)
427 gchar
*code1
, *code2
;
428 gchar
*name1
, *name2
;
430 gtk_tree_model_get(model
, a
, 0, &code1
, 1, &name1
, -1);
431 gtk_tree_model_get(model
, b
, 0, &code2
, 1, &name2
, -1);
433 //keep system laguage on top
434 if(code1
== NULL
) name1
= NULL
;
435 if(code2
== NULL
) name2
= NULL
;
437 retval
= hb_string_utf8_compare(name1
, name2
);
446 static gchar
*languagename_get(const gchar
*locale
)
450 for (i
= 0; i
< G_N_ELEMENTS (languagenames
); i
++)
452 if( g_ascii_strncasecmp(locale
, languagenames
[i
].locale
, -1) == 0 )
453 return languagenames
[i
].name
;
461 ui_language_combobox_get_name(const gchar
*locale
)
465 DB( g_print("[ui_language_combobox_get_name]\n") );
467 // A locale directory name is typically of the form language[_territory]
468 lang
= languagename_get (locale
);
471 const gchar
*delimiter
= strchr (locale
, '_'); // strip off the territory suffix
475 gchar
*copy
= g_strndup (locale
, delimiter
- locale
);
476 lang
= languagename_get (copy
);
482 g_warning(" locale name not found '%s'", locale
);
493 ui_language_combobox_populate(GtkWidget
*combobox
)
498 model
= gtk_combo_box_get_model(GTK_COMBO_BOX(combobox
));
499 gtk_list_store_append (GTK_LIST_STORE(model
), &iter
);
500 gtk_list_store_set (GTK_LIST_STORE(model
), &iter
,
502 1, _("System Language"),
505 GDir
*dir
= g_dir_open (homebank_app_get_locale_dir (), 0, NULL
);
506 const gchar
*dirname
;
511 while ((dirname
= g_dir_read_name (dir
)) != NULL
)
513 gchar
*filename
= g_build_filename (homebank_app_get_locale_dir (),
516 GETTEXT_PACKAGE
".mo",
518 //DB( g_print("- seek for '%s'\n", filename) );
519 if (g_file_test (filename
, G_FILE_TEST_EXISTS
))
524 gtk_list_store_append (GTK_LIST_STORE(model
), &iter
);
526 lang
= ui_language_combobox_get_name(dirname
);
527 label
= g_strdup_printf ("%s [%s]", lang
, dirname
);
529 gtk_list_store_set (GTK_LIST_STORE(model
), &iter
,
541 gtk_tree_sortable_set_sort_column_id(GTK_TREE_SORTABLE(model
), GTK_TREE_SORTABLE_DEFAULT_SORT_COLUMN_ID
, GTK_SORT_ASCENDING
);
548 ui_language_combobox_new(GtkWidget
*label
)
552 GtkCellRenderer
*renderer
;
554 store
= gtk_list_store_new (2,
558 gtk_tree_sortable_set_default_sort_func(GTK_TREE_SORTABLE(store
), ui_language_combobox_compare_func
, NULL
, NULL
);
560 combobox
= gtk_combo_box_new_with_model(GTK_TREE_MODEL(store
));
561 renderer
= gtk_cell_renderer_text_new ();
562 gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (combobox
), renderer
, TRUE
);
563 gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (combobox
), renderer
, "text", 1, NULL
);
565 gtk_combo_box_set_id_column( GTK_COMBO_BOX(combobox
), 0);
567 g_object_unref(store
);
570 gtk_label_set_mnemonic_widget (GTK_LABEL(label
), combobox
);
572 ui_language_combobox_populate(combobox
);
574 gtk_combo_box_set_active(GTK_COMBO_BOX(combobox
), 0);
580 /* = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =*/
581 /* = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =*/
582 /* = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =*/
584 static gint
ui_euro_combobox_id_to_active(gint id
)
588 DB( g_print("\n[ui-pref] ui_euro_combobox_id_to_active\n") );
591 for (i
= 0; i
< G_N_ELEMENTS (euro_params
); i
++)
593 if( euro_params
[i
].id
== id
)
596 DB( g_print("- id (country)=%d => %d - %s\n", id
, i
, euro_params
[i
].name
) );
606 static gint
ui_euro_combobox_active_to_id(gint active
)
610 DB( g_print("\n[ui-pref] ui_euro_combobox_active_to_id\n") );
612 DB( g_print("- to %d\n", active
) );
615 if( active
< (gint
)G_N_ELEMENTS (euro_params
) )
617 id
= euro_params
[active
].id
;
618 DB( g_print("- id (country)=%d '%s'\n", id
, euro_params
[active
].name
) );
624 static GtkWidget
*ui_euro_combobox_new(GtkWidget
*label
)
629 DB( g_print("\n[ui-pref] make euro preset\n") );
631 combobox
= gtk_combo_box_text_new();
632 for (i
= 0; i
< G_N_ELEMENTS (euro_params
); i
++)
634 gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(combobox
), euro_params
[i
].name
);
636 gtk_combo_box_set_active(GTK_COMBO_BOX(combobox
), 0);
639 gtk_label_set_mnemonic_widget (GTK_LABEL(label
), combobox
);
645 static void defpref_pathselect(GtkWidget
*widget
, gpointer user_data
)
647 struct defpref_data
*data
;
648 gint type
= GPOINTER_TO_INT(user_data
);
654 DB( g_print("\n[ui-pref] path select\n") );
656 data
= g_object_get_data(G_OBJECT(gtk_widget_get_ancestor(widget
, GTK_TYPE_WINDOW
)), "inst_data");
661 path
= &PREFS
->path_hbfile
;
662 entry
= data
->ST_path_hbfile
;
663 title
= _("Choose a default HomeBank files folder");
666 path
= &PREFS
->path_import
;
667 entry
= data
->ST_path_import
;
668 title
= _("Choose a default import folder");
671 path
= &PREFS
->path_export
;
672 entry
= data
->ST_path_export
;
673 title
= _("Choose a default export folder");
679 DB( g_print(" - hbfile %p %s at %p\n" , PREFS
->path_hbfile
, PREFS
->path_hbfile
, &PREFS
->path_hbfile
) );
680 DB( g_print(" - import %p %s at %p\n" , PREFS
->path_import
, PREFS
->path_import
, &PREFS
->path_import
) );
681 DB( g_print(" - export %p %s at %p\n" , PREFS
->path_export
, PREFS
->path_export
, &PREFS
->path_export
) );
684 DB( g_print(" - before: %s %p\n" , *path
, path
) );
686 r
= ui_file_chooser_folder(GTK_WINDOW(gtk_widget_get_ancestor(widget
, GTK_TYPE_WINDOW
)), title
, path
);
689 DB( g_print(" - after: %s\n", *path
) );
692 gtk_entry_set_text(GTK_ENTRY(entry
), *path
);
699 ** update the date sample label
701 static void defpref_date_sample(GtkWidget
*widget
, gpointer user_data
)
703 struct defpref_data
*data
;
708 DB( g_print("\n[ui-pref] date sample\n") );
710 data
= g_object_get_data(G_OBJECT(gtk_widget_get_ancestor(widget
, GTK_TYPE_WINDOW
)), "inst_data");
712 fmt
= gtk_entry_get_text(GTK_ENTRY(data
->ST_datefmt
));
713 date
= g_date_new_julian (GLOBALS
->today
);
714 g_date_strftime (buffer
, 256-1, fmt
, date
);
717 gtk_label_set_text(GTK_LABEL(data
->LB_date
), buffer
);
723 ** update the number sample label
725 static void defpref_numbereuro_sample(GtkWidget
*widget
, gpointer user_data
)
727 struct defpref_data
*data
;
729 gchar formatd_buf
[G_ASCII_DTOSTR_BUF_SIZE
];
732 DB( g_print("\n[ui-pref] number sample\n") );
734 data
= g_object_get_data(G_OBJECT(gtk_widget_get_ancestor(widget
, GTK_TYPE_WINDOW
)), "inst_data");
736 cur
.symbol
= (gchar
*)gtk_entry_get_text(GTK_ENTRY(data
->ST_euro_symbol
));
737 cur
.sym_prefix
= gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(data
->CM_euro_isprefix
));
738 cur
.decimal_char
= (gchar
*)gtk_entry_get_text(GTK_ENTRY(data
->ST_euro_decimalchar
));
739 cur
.grouping_char
= (gchar
*)gtk_entry_get_text(GTK_ENTRY(data
->ST_euro_groupingchar
));
740 cur
.frac_digits
= gtk_spin_button_get_value(GTK_SPIN_BUTTON(data
->NB_euro_fracdigits
));
742 da_cur_initformat (&cur
);
744 DB( g_print("fmt: %s\n", cur
.format
) );
746 g_ascii_formatd(formatd_buf
, sizeof (formatd_buf
), cur
.format
, HB_NUMBER_SAMPLE
);
747 hb_str_formatd(buf
, 127, formatd_buf
, &cur
, TRUE
);
749 gtk_label_set_text(GTK_LABEL(data
->LB_numbereuro
), buf
);
755 ** enable/disable euro
757 static void defpref_eurotoggle(GtkWidget
*widget
, gpointer user_data
)
759 struct defpref_data
*data
;
762 DB( g_print("\n[ui-pref] euro toggle\n") );
764 data
= g_object_get_data(G_OBJECT(gtk_widget_get_ancestor(widget
, GTK_TYPE_WINDOW
)), "inst_data");
766 sensitive
= gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(data
->CM_euro_enable
));
768 gtk_widget_set_sensitive(data
->GRP_currency
, sensitive
);
769 gtk_widget_set_sensitive(data
->GRP_rate
, sensitive
);
770 gtk_widget_set_sensitive(data
->GRP_format
, sensitive
);
775 ** set euro value widget from a country
777 static void defpref_eurosetcurrency(GtkWidget
*widget
, gint country
)
779 struct defpref_data
*data
;
784 DB( g_print("\n[ui-pref] eurosetcurrency\n") );
786 data
= g_object_get_data(G_OBJECT(gtk_widget_get_ancestor(widget
, GTK_TYPE_WINDOW
)), "inst_data");
788 active
= ui_euro_combobox_id_to_active(country
);
789 euro
= &euro_params
[active
];
790 buf
= g_strdup_printf("%s - %s", euro
->iso
, euro
->name
);
791 gtk_label_set_markup(GTK_LABEL(data
->ST_euro_country
), buf
);
797 ** set euro value widget from a country
799 static void defpref_europreset(GtkWidget
*widget
, gpointer user_data
)
801 struct defpref_data
*data
;
804 DB( g_print("\n[ui-pref] euro preset\n") );
806 data
= g_object_get_data(G_OBJECT(gtk_widget_get_ancestor(widget
, GTK_TYPE_WINDOW
)), "inst_data");
808 active
= gtk_combo_box_get_active (GTK_COMBO_BOX(data
->CY_euro_preset
));
809 data
->country
= ui_euro_combobox_active_to_id (active
);;
811 defpref_eurosetcurrency(widget
, data
->country
);
813 gtk_spin_button_set_value(GTK_SPIN_BUTTON(data
->NB_euro_value
), euro_params
[active
].value
);
815 gtk_spin_button_set_value(GTK_SPIN_BUTTON(data
->NB_euro_fracdigits
), euro_params
[active
].frac_digits
);
817 gtk_entry_set_text(GTK_ENTRY(data
->ST_euro_symbol
) , euro_params
[active
].symbol
);
818 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(data
->CM_euro_isprefix
), euro_params
[active
].sym_prefix
);
819 gtk_entry_set_text(GTK_ENTRY(data
->ST_euro_decimalchar
) , euro_params
[active
].decimal_char
);
820 gtk_entry_set_text(GTK_ENTRY(data
->ST_euro_groupingchar
), euro_params
[active
].grouping_char
);
825 static void defpref_colortoggle(GtkWidget
*widget
, gpointer user_data
)
827 struct defpref_data
*data
;
830 DB( g_print("\n[ui-pref] color toggle\n") );
832 data
= g_object_get_data(G_OBJECT(gtk_widget_get_ancestor(widget
, GTK_TYPE_WINDOW
)), "inst_data");
834 sensitive
= gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(data
->CM_custom_colors
));
836 gtk_widget_set_sensitive(data
->GR_colors
, sensitive
);
842 ** set preset colors for amount display
844 static void defpref_colorpreset(GtkWidget
*widget
, gpointer user_data
)
846 struct defpref_data
*data
;
849 gchar
*expcol
, *inccol
, *wrncol
;
851 DB( g_print("\n[ui-pref] color preset\n") );
853 data
= g_object_get_data(G_OBJECT(gtk_widget_get_ancestor(widget
, GTK_TYPE_WINDOW
)), "inst_data");
855 preset
= gtk_combo_box_get_active(GTK_COMBO_BOX(data
->CY_colors
));
860 expcol
= LIGHT_EXP_COLOR
;
861 inccol
= LIGHT_INC_COLOR
;
862 wrncol
= LIGHT_WARN_COLOR
;
866 expcol
= MEDIUM_EXP_COLOR
;
867 inccol
= MEDIUM_INC_COLOR
;
868 wrncol
= MEDIUM_WARN_COLOR
;
873 expcol
= DEFAULT_EXP_COLOR
;
874 inccol
= DEFAULT_INC_COLOR
;
875 wrncol
= DEFAULT_WARN_COLOR
;
880 gdk_rgba_parse(&rgba
, expcol
);
881 gtk_color_chooser_set_rgba(GTK_COLOR_CHOOSER(data
->CP_exp_color
), &rgba
);
883 gdk_rgba_parse(&rgba
, inccol
);
884 gtk_color_chooser_set_rgba(GTK_COLOR_CHOOSER(data
->CP_inc_color
), &rgba
);
886 gdk_rgba_parse(&rgba
, wrncol
);
887 gtk_color_chooser_set_rgba(GTK_COLOR_CHOOSER(data
->CP_warn_color
), &rgba
);
893 static void defpref_color_scheme_changed(GtkWidget
*widget
, gpointer user_data
)
895 struct defpref_data
*data
;
897 DB( g_print("\n[ui-pref] color scheme chnaged\n") );
899 data
= g_object_get_data(G_OBJECT(gtk_widget_get_ancestor(widget
, GTK_TYPE_WINDOW
)), "inst_data");
901 gtk_widget_queue_draw (data
->DA_colors
);
909 static void setGdkColor_from_RGB(GdkColor *color, guint32 value)
914 color->red = tmp | tmp<<8;
916 tmp = value >> 8 & 0xFF;
917 color->green = tmp | tmp<<8;
920 color->blue = tmp | tmp<<8;
926 ** set :: fill in widgets from PREFS structure
929 static void defpref_set(struct defpref_data
*data
)
933 DB( g_print("\n[ui-pref] set\n") );
935 if(PREFS
->language
!= NULL
)
936 gtk_combo_box_set_active_id(GTK_COMBO_BOX(data
->CY_language
), PREFS
->language
);
938 gtk_combo_box_set_active (GTK_COMBO_BOX(data
->CY_language
), 0);
940 gtk_combo_box_set_active(GTK_COMBO_BOX(data
->CY_toolbar
), PREFS
->toolbar_style
);
941 //gtk_spin_button_set_value(GTK_SPIN_BUTTON(data->NB_image_size), PREFS->image_size);
945 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(data
->CM_custom_colors
), PREFS
->custom_colors
);
947 gdk_rgba_parse(&rgba
, PREFS
->color_exp
);
948 gtk_color_chooser_set_rgba(GTK_COLOR_CHOOSER(data
->CP_exp_color
), &rgba
);
950 gdk_rgba_parse(&rgba
, PREFS
->color_inc
);
951 gtk_color_chooser_set_rgba(GTK_COLOR_CHOOSER(data
->CP_inc_color
), &rgba
);
953 gdk_rgba_parse(&rgba
, PREFS
->color_warn
);
954 gtk_color_chooser_set_rgba(GTK_COLOR_CHOOSER(data
->CP_warn_color
), &rgba
);
956 //gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(data->CM_ruleshint), PREFS->rules_hint);
957 gtk_combo_box_set_active(GTK_COMBO_BOX(data
->CY_gridlines
), PREFS
->grid_lines
);
959 gtk_spin_button_set_value(GTK_SPIN_BUTTON(data
->NB_fiscyearday
), PREFS
->fisc_year_day
);
960 gtk_combo_box_set_active(GTK_COMBO_BOX(data
->CY_fiscyearmonth
), PREFS
->fisc_year_month
- 1);
962 gtk_entry_set_text(GTK_ENTRY(data
->ST_path_hbfile
), PREFS
->path_hbfile
);
963 gtk_entry_set_text(GTK_ENTRY(data
->ST_path_import
), PREFS
->path_import
);
964 gtk_entry_set_text(GTK_ENTRY(data
->ST_path_export
), PREFS
->path_export
);
965 //gtk_entry_set_text(GTK_ENTRY(data->ST_path_navigator), PREFS->path_navigator);
967 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(data
->CM_load_last
), PREFS
->loadlast
);
968 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(data
->CM_append_scheduled
), PREFS
->appendscheduled
);
969 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(data
->CM_do_update_currency
), PREFS
->do_update_currency
);
970 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(data
->CM_show_splash
), PREFS
->showsplash
);
971 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(data
->CM_herit_date
), PREFS
->heritdate
);
972 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(data
->CM_hide_reconciled
), PREFS
->hidereconciled
);
973 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(data
->CM_show_remind
), PREFS
->showremind
);
976 gtk_entry_set_text(GTK_ENTRY(data
->ST_datefmt
), PREFS
->date_format
);
978 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(data
->CM_unitismile
), PREFS
->vehicle_unit_ismile
);
979 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(data
->CM_unitisgal
), PREFS
->vehicle_unit_isgal
);
981 gtk_combo_box_set_active(GTK_COMBO_BOX(data
->CY_daterange_wal
), PREFS
->date_range_wal
);
982 gtk_combo_box_set_active(GTK_COMBO_BOX(data
->CY_daterange_txn
), PREFS
->date_range_txn
);
983 gtk_spin_button_set_value(GTK_SPIN_BUTTON(data
->ST_datefuture_nbdays
), PREFS
->date_future_nbdays
);
984 gtk_combo_box_set_active(GTK_COMBO_BOX(data
->CY_daterange_rep
), PREFS
->date_range_rep
);
987 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(data
->CM_euro_enable
), PREFS
->euro_active
);
988 //gtk_combo_box_set_active(GTK_COMBO_BOX(data->CY_euro_preset), PREFS->euro_country);
989 data
->country
= PREFS
->euro_country
;
990 defpref_eurosetcurrency(data
->window
, data
->country
);
992 gtk_spin_button_set_value(GTK_SPIN_BUTTON(data
->NB_euro_value
), PREFS
->euro_value
);
994 ui_gtk_entry_set_text(data
->ST_euro_symbol
, PREFS
->minor_cur
.symbol
);
995 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(data
->CM_euro_isprefix
), PREFS
->minor_cur
.sym_prefix
);
996 ui_gtk_entry_set_text(data
->ST_euro_decimalchar
, PREFS
->minor_cur
.decimal_char
);
997 ui_gtk_entry_set_text(data
->ST_euro_groupingchar
, PREFS
->minor_cur
.grouping_char
);
998 gtk_spin_button_set_value(GTK_SPIN_BUTTON(data
->NB_euro_fracdigits
), PREFS
->minor_cur
.frac_digits
);
1001 //gtk_entry_set_text(GTK_ENTRY(data->ST_euro_symbol), PREFS->euro_symbol);
1002 //gtk_spin_button_set_value(GTK_SPIN_BUTTON(data->NB_euro_nbdec), PREFS->euro_nbdec);
1003 //gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(data->CM_euro_thsep), PREFS->euro_thsep);
1005 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(data
->CM_stat_byamount
), PREFS
->stat_byamount
);
1006 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(data
->CM_stat_showrate
), PREFS
->stat_showrate
);
1007 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(data
->CM_stat_showdetail
), PREFS
->stat_showdetail
);
1009 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(data
->CM_budg_showdetail
), PREFS
->budg_showdetail
);
1011 gtk_combo_box_set_active(GTK_COMBO_BOX(data
->CY_color_scheme
), PREFS
->report_color_scheme
);
1014 gtk_combo_box_set_active(GTK_COMBO_BOX(data
->CY_dtex_datefmt
), PREFS
->dtex_datefmt
);
1015 gtk_combo_box_set_active(GTK_COMBO_BOX(data
->CY_dtex_ofxname
), PREFS
->dtex_ofxname
);
1016 gtk_combo_box_set_active(GTK_COMBO_BOX(data
->CY_dtex_ofxmemo
), PREFS
->dtex_ofxmemo
);
1017 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(data
->CM_dtex_qifmemo
), PREFS
->dtex_qifmemo
);
1018 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(data
->CM_dtex_qifswap
), PREFS
->dtex_qifswap
);
1025 ** get :: fill PREFS structure from widgets
1028 #define RGBA_TO_INT(x) (int)(x*255)
1030 static gchar
*gdk_rgba_to_hex(GdkRGBA
*rgba
)
1032 return g_strdup_printf("#%02x%02x%02x", RGBA_TO_INT(rgba
->red
), RGBA_TO_INT(rgba
->green
), RGBA_TO_INT(rgba
->blue
));
1036 static void defpref_get(struct defpref_data
*data
)
1041 DB( g_print("\n[ui-pref] get\n") );
1043 g_free(PREFS
->language
);
1044 PREFS
->language
= NULL
;
1045 lang
= gtk_combo_box_get_active_id(GTK_COMBO_BOX(data
->CY_language
));
1048 PREFS
->language
= g_strdup(lang
);
1051 PREFS
->toolbar_style
= gtk_combo_box_get_active(GTK_COMBO_BOX(data
->CY_toolbar
));
1052 //PREFS->image_size = gtk_spin_button_get_value(GTK_SPIN_BUTTON(data->NB_image_size));
1054 PREFS
->custom_colors
= gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(data
->CM_custom_colors
));
1056 gtk_color_chooser_get_rgba(GTK_COLOR_CHOOSER(data
->CP_exp_color
), &rgba
);
1057 g_free(PREFS
->color_exp
);
1058 PREFS
->color_exp
= gdk_rgba_to_hex(&rgba
);
1060 gtk_color_chooser_get_rgba(GTK_COLOR_CHOOSER(data
->CP_inc_color
), &rgba
);
1061 g_free(PREFS
->color_inc
);
1062 PREFS
->color_inc
= gdk_rgba_to_hex(&rgba
);
1064 gtk_color_chooser_get_rgba(GTK_COLOR_CHOOSER(data
->CP_warn_color
), &rgba
);
1065 g_free(PREFS
->color_warn
);
1066 PREFS
->color_warn
= gdk_rgba_to_hex(&rgba
);
1068 //PREFS->rules_hint = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(data->CM_ruleshint));
1069 PREFS
->grid_lines
= gtk_combo_box_get_active(GTK_COMBO_BOX(data
->CY_gridlines
));
1071 PREFS
->fisc_year_day
= gtk_spin_button_get_value(GTK_SPIN_BUTTON(data
->NB_fiscyearday
));
1072 PREFS
->fisc_year_month
= 1 + gtk_combo_box_get_active(GTK_COMBO_BOX(data
->CY_fiscyearmonth
));
1074 list_txn_colpref_get(GTK_TREE_VIEW(data
->LV_opecolumns
), PREFS
->lst_ope_columns
);
1076 g_free(PREFS
->path_hbfile
);
1077 PREFS
->path_hbfile
= g_strdup(gtk_entry_get_text(GTK_ENTRY(data
->ST_path_hbfile
)));
1079 ui_gtk_entry_replace_text(data
->ST_path_import
, &PREFS
->path_import
);
1081 ui_gtk_entry_replace_text(data
->ST_path_export
, &PREFS
->path_export
);
1083 PREFS
->loadlast
= gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(data
->CM_load_last
));
1084 PREFS
->appendscheduled
= gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(data
->CM_append_scheduled
));
1085 PREFS
->do_update_currency
= gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(data
->CM_do_update_currency
));
1087 PREFS
->showsplash
= gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(data
->CM_show_splash
));
1088 PREFS
->heritdate
= gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(data
->CM_herit_date
));
1089 PREFS
->hidereconciled
= gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(data
->CM_hide_reconciled
));
1090 PREFS
->showremind
= gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(data
->CM_show_remind
));
1092 //g_free(PREFS->path_navigator);
1093 //PREFS->path_navigator = g_strdup(gtk_entry_get_text(GTK_ENTRY(data->ST_path_navigator)));
1095 g_free(PREFS
->date_format
);
1096 PREFS
->date_format
= g_strdup(gtk_entry_get_text(GTK_ENTRY(data
->ST_datefmt
)));
1098 PREFS
->vehicle_unit_ismile
= gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(data
->CM_unitismile
));
1099 PREFS
->vehicle_unit_isgal
= gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(data
->CM_unitisgal
));
1101 PREFS
->date_range_wal
= gtk_combo_box_get_active(GTK_COMBO_BOX(data
->CY_daterange_wal
));
1102 PREFS
->date_range_txn
= gtk_combo_box_get_active(GTK_COMBO_BOX(data
->CY_daterange_txn
));
1103 PREFS
->date_future_nbdays
= gtk_spin_button_get_value(GTK_SPIN_BUTTON(data
->ST_datefuture_nbdays
));
1104 PREFS
->date_range_rep
= gtk_combo_box_get_active(GTK_COMBO_BOX(data
->CY_daterange_rep
));
1106 PREFS
->euro_active
= gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(data
->CM_euro_enable
));
1108 PREFS
->euro_country
= data
->country
;
1109 PREFS
->euro_value
= gtk_spin_button_get_value(GTK_SPIN_BUTTON(data
->NB_euro_value
));
1110 //strcpy(PREFS->euro_symbol, gtk_entry_get_text(GTK_ENTRY(data->ST_euro_symbol)));
1111 //PREFS->euro_nbdec = gtk_spin_button_get_value(GTK_SPIN_BUTTON(data->NB_euro_nbdec));
1112 //PREFS->euro_thsep = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(data->CM_euro_thsep));
1114 ui_gtk_entry_replace_text(data
->ST_euro_symbol
, &PREFS
->minor_cur
.symbol
);
1115 PREFS
->minor_cur
.sym_prefix
= gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(data
->CM_euro_isprefix
));
1116 ui_gtk_entry_replace_text(data
->ST_euro_decimalchar
, &PREFS
->minor_cur
.decimal_char
);
1117 ui_gtk_entry_replace_text(data
->ST_euro_groupingchar
, &PREFS
->minor_cur
.grouping_char
);
1118 PREFS
->minor_cur
.frac_digits
= gtk_spin_button_get_value(GTK_SPIN_BUTTON(data
->NB_euro_fracdigits
));
1120 PREFS
->stat_byamount
= gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(data
->CM_stat_byamount
));
1121 PREFS
->stat_showrate
= gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(data
->CM_stat_showrate
));
1122 PREFS
->stat_showdetail
= gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(data
->CM_stat_showdetail
));
1124 PREFS
->budg_showdetail
= gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(data
->CM_budg_showdetail
));
1126 PREFS
->report_color_scheme
= gtk_combo_box_get_active(GTK_COMBO_BOX(data
->CY_color_scheme
));
1129 PREFS
->dtex_datefmt
= gtk_combo_box_get_active(GTK_COMBO_BOX(data
->CY_dtex_datefmt
));
1130 PREFS
->dtex_ofxname
= gtk_combo_box_get_active(GTK_COMBO_BOX(data
->CY_dtex_ofxname
));
1131 PREFS
->dtex_ofxmemo
= gtk_combo_box_get_active(GTK_COMBO_BOX(data
->CY_dtex_ofxmemo
));
1132 PREFS
->dtex_qifmemo
= gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(data
->CM_dtex_qifmemo
));
1133 PREFS
->dtex_qifswap
= gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(data
->CM_dtex_qifswap
));
1135 //PREFS->chart_legend = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(data->CM_chartlegend));
1137 list_ext_colpref_get(GTK_TREE_VIEW(data
->PI_plugin_columns
), &(PREFS
->ext_whitelist
));
1141 static GtkWidget
*defpref_page_import (struct defpref_data
*data
)
1143 GtkWidget
*content_grid
, *group_grid
, *hbox
, *label
, *widget
;
1146 content_grid
= gtk_grid_new();
1147 gtk_grid_set_row_spacing (GTK_GRID (content_grid
), SPACING_LARGE
);
1148 gtk_orientable_set_orientation(GTK_ORIENTABLE(content_grid
), GTK_ORIENTATION_VERTICAL
);
1151 // group :: Date options
1152 group_grid
= gtk_grid_new ();
1153 gtk_grid_set_row_spacing (GTK_GRID (group_grid
), SPACING_SMALL
);
1154 gtk_grid_set_column_spacing (GTK_GRID (group_grid
), SPACING_MEDIUM
);
1155 gtk_grid_attach (GTK_GRID (content_grid
), group_grid
, 0, crow
++, 1, 1);
1157 label
= make_label_group(_("Date options"));
1158 gtk_grid_attach (GTK_GRID (group_grid
), label
, 0, 0, 3, 1);
1161 label
= make_label_widget(_("Date order:"));
1162 //----------------------------------------- l, r, t, b
1163 gtk_grid_attach (GTK_GRID (group_grid
), label
, 1, row
, 1, 1);
1164 widget
= make_cycle(label
, CYA_IMPORT_DATEORDER
);
1165 data
->CY_dtex_datefmt
= widget
;
1166 //gtk_grid_attach (GTK_GRID (group_grid), data->CY_option[FILTER_DATE], 1, 2, row, row+1);
1167 gtk_grid_attach (GTK_GRID (group_grid
), widget
, 2, row
, 1, 1);
1170 // group :: OFX/QFX options
1171 group_grid
= gtk_grid_new ();
1172 gtk_grid_set_row_spacing (GTK_GRID (group_grid
), SPACING_SMALL
);
1173 gtk_grid_set_column_spacing (GTK_GRID (group_grid
), SPACING_MEDIUM
);
1174 gtk_grid_attach (GTK_GRID (content_grid
), group_grid
, 0, crow
++, 1, 1);
1176 label
= make_label_group(_("OFX/QFX options"));
1177 gtk_grid_attach (GTK_GRID (group_grid
), label
, 0, 0, 3, 1);
1180 label
= make_label_widget(_("_Name field:"));
1181 //----------------------------------------- l, r, t, b
1182 gtk_grid_attach (GTK_GRID (group_grid
), label
, 1, row
, 1, 1);
1183 widget
= make_cycle(label
, CYA_IMPORT_OFXNAME
);
1184 data
->CY_dtex_ofxname
= widget
;
1185 //gtk_grid_attach (GTK_GRID (group_grid), data->CY_option[FILTER_DATE], 1, 2, row, row+1);
1186 gtk_grid_attach (GTK_GRID (group_grid
), widget
, 2, row
, 1, 1);
1189 label
= make_label_widget(_("_Memo field:"));
1190 //----------------------------------------- l, r, t, b
1191 gtk_grid_attach (GTK_GRID (group_grid
), label
, 1, row
, 1, 1);
1192 widget
= make_cycle(label
, CYA_IMPORT_OFXMEMO
);
1193 data
->CY_dtex_ofxmemo
= widget
;
1194 //gtk_grid_attach (GTK_GRID (group_grid), data->CY_option[FILTER_DATE], 1, 2, row, row+1);
1195 gtk_grid_attach (GTK_GRID (group_grid
), widget
, 2, row
, 1, 1);
1197 // group :: QIF options
1198 group_grid
= gtk_grid_new ();
1199 gtk_grid_set_row_spacing (GTK_GRID (group_grid
), SPACING_SMALL
);
1200 gtk_grid_set_column_spacing (GTK_GRID (group_grid
), SPACING_MEDIUM
);
1201 gtk_grid_attach (GTK_GRID (content_grid
), group_grid
, 0, crow
++, 1, 1);
1203 label
= make_label_group(_("QIF options"));
1204 gtk_grid_attach (GTK_GRID (group_grid
), label
, 0, 0, 3, 1);
1207 label
= make_label_widget(_("Memos:"));
1208 gtk_grid_attach (GTK_GRID (group_grid
), label
, 1, row
, 1, 1);
1209 widget
= gtk_check_button_new_with_mnemonic (_("_Import"));
1210 data
->CM_dtex_qifmemo
= widget
;
1211 gtk_grid_attach (GTK_GRID (group_grid
), widget
, 2, row
, 1, 1);
1212 widget
= gtk_check_button_new_with_mnemonic (_("_Swap with payees"));
1213 data
->CM_dtex_qifswap
= widget
;
1214 gtk_grid_attach (GTK_GRID (group_grid
), widget
, 3, row
, 1, 1);
1217 // group :: Files folder
1218 group_grid
= gtk_grid_new ();
1219 gtk_grid_set_row_spacing (GTK_GRID (group_grid
), SPACING_SMALL
);
1220 gtk_grid_set_column_spacing (GTK_GRID (group_grid
), SPACING_MEDIUM
);
1221 gtk_grid_attach (GTK_GRID (content_grid
), group_grid
, 0, crow
++, 1, 1);
1223 label
= make_label_group(_("Files folder"));
1224 gtk_grid_attach (GTK_GRID (group_grid
), label
, 0, 0, 3, 1);
1227 label
= make_label_widget(_("_Import:"));
1228 //----------------------------------------- l, r, t, b
1229 gtk_grid_attach (GTK_GRID (group_grid
), label
, 1, row
, 1, 1);
1231 hbox
= gtk_box_new(GTK_ORIENTATION_HORIZONTAL
, 0);
1232 gtk_widget_set_hexpand (hbox
, TRUE
);
1233 gtk_grid_attach (GTK_GRID (group_grid
), hbox
, 2, row
, 1, 1);
1235 widget
= make_string(label
);
1236 data
->ST_path_import
= widget
;
1237 gtk_style_context_add_class (gtk_widget_get_style_context (GTK_WIDGET(widget
)), GTK_STYLE_CLASS_LINKED
);
1238 gtk_box_pack_start (GTK_BOX (hbox
), widget
, TRUE
, TRUE
, 0);
1240 //widget = gtk_button_new_with_label("...");
1241 widget
= gtk_button_new_from_icon_name(ICONNAME_FOLDER
, GTK_ICON_SIZE_BUTTON
);
1242 data
->BT_path_import
= widget
;
1243 gtk_box_pack_start (GTK_BOX (hbox
), widget
, FALSE
, FALSE
, 0);
1246 label
= make_label_widget(_("_Export:"));
1247 //----------------------------------------- l, r, t, b
1248 gtk_grid_attach (GTK_GRID (group_grid
), label
, 1, row
, 1, 1);
1250 hbox
= gtk_box_new(GTK_ORIENTATION_HORIZONTAL
, 0);
1251 gtk_widget_set_hexpand (hbox
, TRUE
);
1252 gtk_grid_attach (GTK_GRID (group_grid
), hbox
, 2, row
, 1, 1);
1254 widget
= make_string(label
);
1255 data
->ST_path_export
= widget
;
1256 gtk_style_context_add_class (gtk_widget_get_style_context (GTK_WIDGET(widget
)), GTK_STYLE_CLASS_LINKED
);
1257 gtk_box_pack_start (GTK_BOX (hbox
), widget
, TRUE
, TRUE
, 0);
1259 //widget = gtk_button_new_with_label("...");
1260 widget
= gtk_button_new_from_icon_name(ICONNAME_FOLDER
, GTK_ICON_SIZE_BUTTON
);
1261 data
->BT_path_export
= widget
;
1262 gtk_box_pack_start (GTK_BOX (hbox
), widget
, FALSE
, FALSE
, 0);
1264 return content_grid
;
1270 draw_callback (GtkWidget
*widget
,
1274 struct defpref_data
*data
= user_data
;
1276 GtkColorScheme scheme
;
1280 index
= gtk_combo_box_get_active(GTK_COMBO_BOX(data
->CY_color_scheme
));
1282 colorscheme_init(&scheme
, index
);
1284 gtk_widget_get_size_request (widget
, &w
, &h
);
1286 for(i
=0;i
<scheme
.nb_cols
;i
++)
1288 cairo_user_set_rgbcol (cr
, &scheme
.colors
[i
]);
1289 cairo_rectangle(cr
, x
, y
, cube_dim
, cube_dim
);
1293 { x
= 0; y
= 1 + cube_dim
; }
1301 static GtkWidget
*defpref_page_reports (struct defpref_data
*data
)
1303 GtkWidget
*content_grid
, *group_grid
, *label
, *widget
;
1306 content_grid
= gtk_grid_new();
1307 gtk_grid_set_row_spacing (GTK_GRID (content_grid
), SPACING_LARGE
);
1308 gtk_orientable_set_orientation(GTK_ORIENTABLE(content_grid
), GTK_ORIENTATION_VERTICAL
);
1311 // group :: Initial filter
1312 group_grid
= gtk_grid_new ();
1313 gtk_grid_set_row_spacing (GTK_GRID (group_grid
), SPACING_SMALL
);
1314 gtk_grid_set_column_spacing (GTK_GRID (group_grid
), SPACING_MEDIUM
);
1315 gtk_grid_attach (GTK_GRID (content_grid
), group_grid
, 0, crow
++, 1, 1);
1317 label
= make_label_group(_("Initial filter"));
1318 gtk_grid_attach (GTK_GRID (group_grid
), label
, 0, 0, 3, 1);
1321 label
= make_label_widget(_("Date _range:"));
1322 //----------------------------------------- l, r, t, b
1323 gtk_grid_attach (GTK_GRID (group_grid
), label
, 1, row
, 1, 1);
1324 widget
= make_daterange(label
, FALSE
);
1325 data
->CY_daterange_rep
= widget
;
1326 //gtk_grid_attach (GTK_GRID (group_grid), data->CY_option[FILTER_DATE], 1, 2, row, row+1);
1327 gtk_grid_attach (GTK_GRID (group_grid
), widget
, 2, row
, 1, 1);
1329 // group ::Charts 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(_("Charts options"));
1336 gtk_grid_attach (GTK_GRID (group_grid
), label
, 0, 0, 3, 1);
1339 label
= make_label_widget(_("Color scheme:"));
1340 //----------------------------------------- l, r, t, b
1341 gtk_grid_attach (GTK_GRID (group_grid
), label
, 1, row
, 1, 1);
1342 widget
= make_cycle(label
, chart_colors
);
1343 data
->CY_color_scheme
= widget
;
1344 //gtk_grid_attach (GTK_GRID (group_grid), data->CY_option[FILTER_DATE], 1, 2, row, row+1);
1345 gtk_grid_attach (GTK_GRID (group_grid
), widget
, 2, row
, 1, 1);
1348 widget
= gtk_drawing_area_new ();
1349 data
->DA_colors
= widget
;
1350 gtk_widget_set_size_request (widget
, (1+cube_dim
)*16, (1+cube_dim
)*2);
1351 gtk_grid_attach (GTK_GRID (group_grid
), widget
, 2, row
, 1, 1);
1353 g_signal_connect (data
->DA_colors
, "draw", G_CALLBACK (draw_callback
), data
);
1355 // group :: Statistics options
1356 group_grid
= gtk_grid_new ();
1357 gtk_grid_set_row_spacing (GTK_GRID (group_grid
), SPACING_SMALL
);
1358 gtk_grid_set_column_spacing (GTK_GRID (group_grid
), SPACING_MEDIUM
);
1359 gtk_grid_attach (GTK_GRID (content_grid
), group_grid
, 0, crow
++, 1, 1);
1361 label
= make_label_group(_("Statistics options"));
1362 gtk_grid_attach (GTK_GRID (group_grid
), label
, 0, 0, 3, 1);
1365 widget
= gtk_check_button_new_with_mnemonic (_("Show by _amount"));
1366 data
->CM_stat_byamount
= widget
;
1367 gtk_grid_attach (GTK_GRID (group_grid
), widget
, 1, row
, 2, 1);
1370 widget
= gtk_check_button_new_with_mnemonic (_("Show _rate column"));
1371 data
->CM_stat_showrate
= widget
;
1372 gtk_grid_attach (GTK_GRID (group_grid
), widget
, 1, row
, 2, 1);
1375 widget
= gtk_check_button_new_with_mnemonic (_("Show _details"));
1376 data
->CM_stat_showdetail
= widget
;
1377 gtk_grid_attach (GTK_GRID (group_grid
), widget
, 1, row
, 2, 1);
1379 // group :: Budget options
1380 group_grid
= gtk_grid_new ();
1381 gtk_grid_set_row_spacing (GTK_GRID (group_grid
), SPACING_SMALL
);
1382 gtk_grid_set_column_spacing (GTK_GRID (group_grid
), SPACING_MEDIUM
);
1383 gtk_grid_attach (GTK_GRID (content_grid
), group_grid
, 0, crow
++, 1, 1);
1385 label
= make_label_group(_("Budget options"));
1386 gtk_grid_attach (GTK_GRID (group_grid
), label
, 0, 0, 3, 1);
1389 widget
= gtk_check_button_new_with_mnemonic (_("Show _details"));
1390 data
->CM_budg_showdetail
= widget
;
1391 gtk_grid_attach (GTK_GRID (group_grid
), widget
, 1, row
, 2, 1);
1393 return content_grid
;
1397 static GtkWidget
*defpref_page_euro (struct defpref_data
*data
)
1399 GtkWidget
*content_grid
, *group_grid
, *label
, *widget
, *expander
;
1402 content_grid
= gtk_grid_new();
1403 gtk_grid_set_row_spacing (GTK_GRID (content_grid
), SPACING_LARGE
);
1404 gtk_orientable_set_orientation(GTK_ORIENTABLE(content_grid
), GTK_ORIENTATION_VERTICAL
);
1408 group_grid
= gtk_grid_new ();
1409 gtk_grid_set_row_spacing (GTK_GRID (group_grid
), SPACING_SMALL
);
1410 gtk_grid_set_column_spacing (GTK_GRID (group_grid
), SPACING_MEDIUM
);
1411 gtk_grid_attach (GTK_GRID (content_grid
), group_grid
, 0, crow
++, 1, 1);
1413 label
= make_label_group(_("General"));
1414 gtk_grid_attach (GTK_GRID (group_grid
), label
, 0, 0, 3, 1);
1417 widget
= gtk_check_button_new_with_mnemonic (_("_Enable"));
1418 data
->CM_euro_enable
= widget
;
1419 gtk_grid_attach (GTK_GRID (group_grid
), widget
, 1, row
, 2, 1);
1421 // group :: Currency
1422 group_grid
= gtk_grid_new ();
1423 data
->GRP_currency
= group_grid
;
1424 gtk_grid_set_row_spacing (GTK_GRID (group_grid
), SPACING_SMALL
);
1425 gtk_grid_set_column_spacing (GTK_GRID (group_grid
), SPACING_MEDIUM
);
1426 gtk_grid_attach (GTK_GRID (content_grid
), group_grid
, 0, crow
++, 1, 1);
1428 label
= make_label_group(_("Currency"));
1429 gtk_grid_attach (GTK_GRID (group_grid
), label
, 0, 0, 4, 1);
1432 widget
= make_label(NULL
, 0.0, 0.5);
1433 data
->ST_euro_country
= widget
;
1434 //gtk_grid_attach (GTK_GRID (group_grid), data->CY_option[FILTER_DATE], 1, 2, row, row+1);
1435 gtk_grid_attach (GTK_GRID (group_grid
), widget
, 1, row
, 1, 1);
1438 label
= make_label_widget(_("_Preset:"));
1439 //----------------------------------------- l, r, t, b
1440 gtk_grid_attach (GTK_GRID (group_grid
), label
, 2, row
, 1, 1);
1441 widget
= ui_euro_combobox_new (label
);
1442 data
->CY_euro_preset
= widget
;
1443 gtk_widget_set_margin_left (label
, 2*SPACING_LARGE
);
1444 //gtk_grid_attach (GTK_GRID (group_grid), data->CY_option[FILTER_DATE], 1, 2, row, row+1);
1445 gtk_grid_attach (GTK_GRID (group_grid
), widget
, 3, row
, 1, 1);
1448 // group :: Exchange rate
1449 group_grid
= gtk_grid_new ();
1450 data
->GRP_rate
= group_grid
;
1451 gtk_grid_set_row_spacing (GTK_GRID (group_grid
), SPACING_SMALL
);
1452 gtk_grid_set_column_spacing (GTK_GRID (group_grid
), SPACING_MEDIUM
);
1453 gtk_grid_attach (GTK_GRID (content_grid
), group_grid
, 0, crow
++, 1, 1);
1455 label
= make_label_group(_("Exchange rate"));
1456 gtk_grid_attach (GTK_GRID (group_grid
), label
, 0, 0, 3, 1);
1459 label
= make_label_widget("1 EUR _=");
1460 gtk_grid_attach (GTK_GRID (group_grid
), label
, 1, row
, 1, 1);
1461 widget
= make_exchange_rate(label
);
1462 data
->NB_euro_value
= widget
;
1463 //gtk_grid_attach (GTK_GRID (group_grid), data->CY_option[FILTER_DATE], 1, 2, row, row+1);
1464 gtk_grid_attach (GTK_GRID (group_grid
), widget
, 2, row
, 1, 1);
1466 // group :: Numbers format
1467 group_grid
= gtk_grid_new ();
1468 data
->GRP_format
= group_grid
;
1469 gtk_grid_set_row_spacing (GTK_GRID (group_grid
), SPACING_SMALL
);
1470 gtk_grid_set_column_spacing (GTK_GRID (group_grid
), SPACING_MEDIUM
);
1471 gtk_grid_attach (GTK_GRID (content_grid
), group_grid
, 0, crow
++, 1, 1);
1473 label
= make_label_group(_("Format"));
1474 gtk_grid_attach (GTK_GRID (group_grid
), label
, 0, 0, 3, 1);
1477 widget
= make_label(NULL
, 0, 0.0);
1478 data
->LB_numbereuro
= widget
;
1479 gtk_grid_attach (GTK_GRID (group_grid
), widget
, 1, row
, 1, 1);
1482 expander
= gtk_expander_new_with_mnemonic(_("_Customize"));
1483 gtk_grid_attach (GTK_GRID (group_grid
), expander
, 1, row
, 1, 1);
1485 group_grid
= gtk_grid_new ();
1486 gtk_grid_set_row_spacing (GTK_GRID (group_grid
), SPACING_SMALL
);
1487 gtk_grid_set_column_spacing (GTK_GRID (group_grid
), SPACING_MEDIUM
);
1488 gtk_container_add (GTK_CONTAINER (expander
), group_grid
);
1491 label
= make_label_widget(_("_Symbol:"));
1492 gtk_grid_attach (GTK_GRID (group_grid
), label
, 1, row
, 1, 1);
1493 widget
= make_string_maxlength(label
, 3);
1494 data
->ST_euro_symbol
= widget
;
1495 gtk_grid_attach (GTK_GRID (group_grid
), widget
, 2, row
, 1, 1);
1498 widget
= gtk_check_button_new_with_mnemonic (_("Is pre_fix"));
1499 data
->CM_euro_isprefix
= widget
;
1500 gtk_grid_attach (GTK_GRID (group_grid
), widget
, 2, row
, 1, 1);
1503 label
= make_label_widget(_("_Decimal char:"));
1504 gtk_grid_attach (GTK_GRID (group_grid
), label
, 1, row
, 1, 1);
1505 widget
= make_string_maxlength(label
, 1);
1506 data
->ST_euro_decimalchar
= widget
;
1507 gtk_grid_attach (GTK_GRID (group_grid
), widget
, 2, row
, 1, 1);
1510 label
= make_label_widget(_("_Frac digits:"));
1511 gtk_grid_attach (GTK_GRID (group_grid
), label
, 1, row
, 1, 1);
1512 widget
= make_numeric(label
, 0.0, 6.0);
1513 data
->NB_euro_fracdigits
= widget
;
1514 gtk_grid_attach (GTK_GRID (group_grid
), widget
, 2, row
, 1, 1);
1517 label
= make_label_widget(_("_Grouping char:"));
1518 gtk_grid_attach (GTK_GRID (group_grid
), label
, 1, row
, 1, 1);
1519 widget
= make_string_maxlength(label
, 1);
1520 data
->ST_euro_groupingchar
= widget
;
1521 gtk_grid_attach (GTK_GRID (group_grid
), widget
, 2, row
, 1, 1);
1523 return content_grid
;
1527 static GtkWidget
*defpref_page_display (struct defpref_data
*data
)
1529 GtkWidget
*content_grid
, *group_grid
, *label
, *widget
, *expander
;
1532 content_grid
= gtk_grid_new();
1533 gtk_grid_set_row_spacing (GTK_GRID (content_grid
), SPACING_LARGE
);
1534 gtk_orientable_set_orientation(GTK_ORIENTABLE(content_grid
), GTK_ORIENTATION_VERTICAL
);
1537 // group :: Date options
1538 group_grid
= gtk_grid_new ();
1539 gtk_grid_set_row_spacing (GTK_GRID (group_grid
), SPACING_SMALL
);
1540 gtk_grid_set_column_spacing (GTK_GRID (group_grid
), SPACING_MEDIUM
);
1541 gtk_grid_attach (GTK_GRID (content_grid
), group_grid
, 0, crow
++, 1, 1);
1543 label
= make_label_group(_("Date"));
1544 gtk_grid_attach (GTK_GRID (group_grid
), label
, 0, 0, 3, 1);
1547 widget
= make_label(NULL
, 0, 0.5);
1548 data
->LB_date
= widget
;
1549 gtk_grid_attach (GTK_GRID (group_grid
), widget
, 1, row
, 2, 1);
1552 expander
= gtk_expander_new_with_mnemonic(_("_Customize"));
1553 gtk_grid_attach (GTK_GRID (group_grid
), expander
, 1, row
, 1, 1);
1555 group_grid
= gtk_grid_new ();
1556 gtk_grid_set_row_spacing (GTK_GRID (group_grid
), SPACING_SMALL
);
1557 gtk_grid_set_column_spacing (GTK_GRID (group_grid
), SPACING_MEDIUM
);
1558 gtk_container_add (GTK_CONTAINER (expander
), group_grid
);
1561 label
= make_label_widget(_("_Format:"));
1562 //----------------------------------------- l, r, t, b
1563 gtk_grid_attach (GTK_GRID (group_grid
), label
, 1, row
, 1, 1);
1564 widget
= make_string(label
);
1565 data
->ST_datefmt
= widget
;
1566 //gtk_grid_attach (GTK_GRID (group_grid), data->CY_option[FILTER_DATE], 1, 2, row, row+1);
1567 gtk_grid_attach (GTK_GRID (group_grid
), widget
, 2, row
, 1, 1);
1569 widget
= gtk_image_new_from_icon_name (ICONNAME_INFO
, GTK_ICON_SIZE_BUTTON
);
1570 gtk_grid_attach (GTK_GRID (group_grid
), widget
, 3, row
, 1, 1);
1573 gtk_widget_set_tooltip_text(widget
,
1574 _("%a locale's abbreviated weekday name.\n"
1575 "%A locale's full weekday name. \n"
1576 "%b locale's abbreviated month name. \n"
1577 "%B locale's full month name. \n"
1578 "%c locale's appropriate date and time representation. \n"
1579 "%C century number (the year divided by 100 and truncated to an integer) as a decimal number [00-99]. \n"
1580 "%d day of the month as a decimal number [01,31]. \n"
1581 "%D same as %m/%d/%y. \n"
1582 "%e day of the month as a decimal number [1,31]; a single digit is preceded by a space. \n"
1583 "%j day of the year as a decimal number [001,366]. \n"
1584 "%m month as a decimal number [01,12]. \n"
1585 "%p locale's appropriate date representation. \n"
1586 "%y year without century as a decimal number [00,99]. \n"
1587 "%Y year with century as a decimal number. \n")
1591 widget
= make_label(NULL
, 0.0, 0.5);
1592 gtk_label_set_markup (GTK_LABEL(widget
), "<small><a href=\"http://man7.org/linux/man-pages/man3/strftime.3.html\">online reference</a></small>");
1593 gtk_grid_attach (GTK_GRID (group_grid
), widget
, 2, row
, 1, 1);
1595 // group :: Measurement units
1596 group_grid
= gtk_grid_new ();
1597 gtk_grid_set_row_spacing (GTK_GRID (group_grid
), SPACING_SMALL
);
1598 gtk_grid_set_column_spacing (GTK_GRID (group_grid
), SPACING_MEDIUM
);
1599 gtk_grid_attach (GTK_GRID (content_grid
), group_grid
, 0, crow
++, 1, 1);
1601 label
= make_label_group(_("Measurement units"));
1602 gtk_grid_attach (GTK_GRID (group_grid
), label
, 0, 0, 3, 1);
1605 widget
= gtk_check_button_new_with_mnemonic (_("Use _miles for meter"));
1606 data
->CM_unitismile
= widget
;
1607 gtk_grid_attach (GTK_GRID (group_grid
), widget
, 1, row
, 2, 1);
1610 widget
= gtk_check_button_new_with_mnemonic (_("Use _gallon for fuel"));
1611 data
->CM_unitisgal
= widget
;
1612 gtk_grid_attach (GTK_GRID (group_grid
), widget
, 1, row
, 2, 1);
1614 return content_grid
;
1618 static GtkWidget
*defpref_page_transactions (struct defpref_data
*data
)
1620 GtkWidget
*content_grid
, *group_grid
, *sw
, *label
, *widget
;
1623 content_grid
= gtk_grid_new();
1624 gtk_grid_set_row_spacing (GTK_GRID (content_grid
), SPACING_LARGE
);
1625 gtk_orientable_set_orientation(GTK_ORIENTABLE(content_grid
), GTK_ORIENTATION_VERTICAL
);
1628 // group :: Transaction window
1629 group_grid
= gtk_grid_new ();
1630 gtk_grid_set_row_spacing (GTK_GRID (group_grid
), SPACING_SMALL
);
1631 gtk_grid_set_column_spacing (GTK_GRID (group_grid
), SPACING_MEDIUM
);
1632 gtk_grid_attach (GTK_GRID (content_grid
), group_grid
, 0, crow
++, 1, 1);
1634 label
= make_label_group(_("Transaction window"));
1635 gtk_grid_attach (GTK_GRID (group_grid
), label
, 0, 0, 3, 1);
1638 label
= make_label_widget(_("Date _range:"));
1639 //----------------------------------------- l, r, t, b
1640 gtk_grid_attach (GTK_GRID (group_grid
), label
, 1, row
, 1, 1);
1641 widget
= make_daterange(label
, FALSE
);
1642 data
->CY_daterange_txn
= widget
;
1643 gtk_grid_attach (GTK_GRID (group_grid
), widget
, 2, row
, 1, 1);
1646 label
= make_label_widget(_("_Show:"));
1647 //----------------------------------------- l, r, t, b
1648 gtk_grid_attach (GTK_GRID (group_grid
), label
, 1, row
, 1, 1);
1649 widget
= make_numeric(NULL
, 0, 366);
1651 data
->ST_datefuture_nbdays
= widget
;
1652 gtk_grid_attach (GTK_GRID (group_grid
), widget
, 2, row
, 1, 1);
1654 //TRANSLATORS: there is a spinner on the left of this label, and so you have 0....x days in advance the current date
1655 label
= make_label(_("days in advance the current date"), 0, 0.5);
1656 gtk_grid_attach (GTK_GRID (group_grid
), label
, 3, row
, 1, 1);
1659 widget
= gtk_check_button_new_with_mnemonic (_("Hide reconciled transactions"));
1660 data
->CM_hide_reconciled
= widget
;
1661 gtk_grid_attach (GTK_GRID (group_grid
), widget
, 2, row
, 2, 1);
1664 widget
= gtk_check_button_new_with_mnemonic (_("Always show remind transactions"));
1665 data
->CM_show_remind
= widget
;
1666 gtk_grid_attach (GTK_GRID (group_grid
), widget
, 2, row
, 2, 1);
1668 // group :: Multiple add
1669 group_grid
= gtk_grid_new ();
1670 gtk_grid_set_row_spacing (GTK_GRID (group_grid
), SPACING_SMALL
);
1671 gtk_grid_set_column_spacing (GTK_GRID (group_grid
), SPACING_MEDIUM
);
1672 gtk_grid_attach (GTK_GRID (content_grid
), group_grid
, 0, crow
++, 1, 1);
1674 label
= make_label_group(_("Multiple add"));
1675 gtk_grid_attach (GTK_GRID (group_grid
), label
, 0, 0, 3, 1);
1678 widget
= gtk_check_button_new_with_mnemonic (_("Keep the last date"));
1679 data
->CM_herit_date
= widget
;
1680 gtk_grid_attach (GTK_GRID (group_grid
), widget
, 1, row
, 2, 1);
1682 // group :: Column list
1683 group_grid
= gtk_grid_new ();
1684 gtk_grid_set_row_spacing (GTK_GRID (group_grid
), SPACING_SMALL
);
1685 gtk_grid_set_column_spacing (GTK_GRID (group_grid
), SPACING_MEDIUM
);
1686 gtk_grid_attach (GTK_GRID (content_grid
), group_grid
, 0, crow
++, 1, 1);
1688 label
= make_label_group(_("Column list"));
1689 gtk_grid_attach (GTK_GRID (group_grid
), label
, 0, 0, 3, 1);
1692 sw
= gtk_scrolled_window_new (NULL
, NULL
);
1693 gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (sw
), GTK_SHADOW_ETCHED_IN
);
1694 gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (sw
), GTK_POLICY_NEVER
, GTK_POLICY_AUTOMATIC
);
1695 widget
= (GtkWidget
*)list_txn_colprefcreate();
1696 data
->LV_opecolumns
= widget
;
1697 gtk_widget_set_size_request(data
->LV_opecolumns
, HB_MINWIDTH_LIST
, -1);
1698 gtk_container_add (GTK_CONTAINER (sw
), widget
);
1699 gtk_widget_set_vexpand (sw
, TRUE
);
1700 gtk_grid_attach (GTK_GRID (group_grid
), sw
, 1, row
, 2, 1);
1701 gtk_widget_set_tooltip_text(widget
, _("Drag & drop to change the order"));
1703 return content_grid
;
1708 static GtkWidget
*defpref_page_interface (struct defpref_data
*data
)
1710 GtkWidget
*content_grid
, *group_grid
, *hbox
, *label
, *widget
;
1713 content_grid
= gtk_grid_new();
1714 gtk_grid_set_row_spacing (GTK_GRID (content_grid
), SPACING_LARGE
);
1715 gtk_orientable_set_orientation(GTK_ORIENTABLE(content_grid
), GTK_ORIENTATION_VERTICAL
);
1719 group_grid
= gtk_grid_new ();
1720 gtk_grid_set_row_spacing (GTK_GRID (group_grid
), SPACING_SMALL
);
1721 gtk_grid_set_column_spacing (GTK_GRID (group_grid
), SPACING_MEDIUM
);
1722 gtk_grid_attach (GTK_GRID (content_grid
), group_grid
, 0, crow
++, 1, 1);
1724 label
= make_label_group(_("General"));
1725 gtk_grid_attach (GTK_GRID (group_grid
), label
, 0, 0, 3, 1);
1728 label
= make_label_widget(_("_Language:"));
1729 gtk_grid_attach (GTK_GRID (group_grid
), label
, 1, row
, 1, 1);
1730 widget
= ui_language_combobox_new(label
);
1731 data
->CY_language
= widget
;
1732 gtk_grid_attach (GTK_GRID (group_grid
), widget
, 2, row
, 1, 1);
1735 label
= make_label_widget(_("_Toolbar:"));
1736 gtk_grid_attach (GTK_GRID (group_grid
), label
, 1, row
, 1, 1);
1737 widget
= make_cycle(label
, CYA_TOOLBAR_STYLE
);
1738 data
->CY_toolbar
= widget
;
1739 gtk_grid_attach (GTK_GRID (group_grid
), widget
, 2, row
, 1, 1);
1743 //widget = gtk_check_button_new_with_mnemonic (_("Enable rows in alternating colors"));
1744 //data->CM_ruleshint = widget;
1745 label
= make_label_widget(_("_Grid line:"));
1746 gtk_grid_attach (GTK_GRID (group_grid
), label
, 1, row
, 1, 1);
1747 widget
= make_cycle(label
, CYA_GRID_LINES
);
1748 data
->CY_gridlines
= widget
;
1749 gtk_grid_attach (GTK_GRID (group_grid
), widget
, 2, row
, 1, 1);
1751 // group :: Amount colors
1752 group_grid
= gtk_grid_new ();
1753 gtk_grid_set_row_spacing (GTK_GRID (group_grid
), SPACING_SMALL
);
1754 gtk_grid_set_column_spacing (GTK_GRID (group_grid
), SPACING_MEDIUM
);
1755 gtk_grid_attach (GTK_GRID (content_grid
), group_grid
, 0, crow
++, 1, 1);
1757 label
= make_label_group(_("Amount colors"));
1758 gtk_grid_attach (GTK_GRID (group_grid
), label
, 0, 0, 3, 1);
1761 widget
= gtk_check_button_new_with_mnemonic (_("Uses custom colors"));
1762 data
->CM_custom_colors
= widget
;
1763 gtk_grid_attach (GTK_GRID (group_grid
), widget
, 2, row
, 1, 1);
1765 group_grid
= gtk_grid_new ();
1766 data
->GR_colors
= group_grid
;
1767 gtk_grid_set_row_spacing (GTK_GRID (group_grid
), SPACING_SMALL
);
1768 gtk_grid_set_column_spacing (GTK_GRID (group_grid
), SPACING_MEDIUM
);
1769 gtk_grid_attach (GTK_GRID (content_grid
), group_grid
, 0, crow
++, 1, 1);
1772 label
= make_label_widget(_("_Preset:"));
1773 //----------------------------------------- l, r, t, b
1774 gtk_grid_attach (GTK_GRID (group_grid
), label
, 1, row
, 1, 1);
1775 widget
= make_cycle(label
, CYA_TANGO_COLORS
);
1776 data
->CY_colors
= widget
;
1777 //gtk_grid_attach (GTK_GRID (group_grid), data->CY_option[FILTER_DATE], 1, 2, row, row+1);
1778 gtk_grid_attach (GTK_GRID (group_grid
), widget
, 2, row
, 1, 1);
1781 label
= make_label_widget(_("_Expense:"));
1782 //----------------------------------------- l, r, t, b
1783 gtk_grid_attach (GTK_GRID (group_grid
), label
, 1, row
, 1, 1);
1784 hbox
= gtk_box_new(GTK_ORIENTATION_HORIZONTAL
, SPACING_SMALL
);
1785 gtk_grid_attach (GTK_GRID (group_grid
), hbox
, 2, row
, 1, 1);
1787 widget
= gtk_color_button_new ();
1788 data
->CP_exp_color
= widget
;
1789 gtk_box_pack_start (GTK_BOX (hbox
), widget
, FALSE
, FALSE
, 0);
1791 label
= make_label_widget(_("_Income:"));
1792 gtk_box_pack_start (GTK_BOX (hbox
), label
, FALSE
, FALSE
, 0);
1794 widget
= gtk_color_button_new ();
1795 data
->CP_inc_color
= widget
;
1796 gtk_box_pack_start (GTK_BOX (hbox
), widget
, FALSE
, FALSE
, 0);
1798 label
= make_label_widget(_("_Warning:"));
1799 gtk_box_pack_start (GTK_BOX (hbox
), label
, FALSE
, FALSE
, 0);
1801 widget
= gtk_color_button_new ();
1802 data
->CP_warn_color
= widget
;
1803 gtk_box_pack_start (GTK_BOX (hbox
), widget
, FALSE
, FALSE
, 0);
1805 return content_grid
;
1809 static GtkWidget
*defpref_page_general (struct defpref_data
*data
)
1811 GtkWidget
*content_grid
, *group_grid
, *hbox
, *label
, *widget
;
1814 content_grid
= gtk_grid_new();
1815 gtk_grid_set_row_spacing (GTK_GRID (content_grid
), SPACING_LARGE
);
1816 gtk_orientable_set_orientation(GTK_ORIENTABLE(content_grid
), GTK_ORIENTATION_VERTICAL
);
1819 // group :: Program start
1820 group_grid
= gtk_grid_new ();
1821 gtk_grid_set_row_spacing (GTK_GRID (group_grid
), SPACING_SMALL
);
1822 gtk_grid_set_column_spacing (GTK_GRID (group_grid
), SPACING_MEDIUM
);
1823 gtk_grid_attach (GTK_GRID (content_grid
), group_grid
, 0, crow
++, 1, 1);
1825 label
= make_label_group(_("Program start"));
1826 gtk_grid_attach (GTK_GRID (group_grid
), label
, 0, 0, 3, 1);
1829 widget
= gtk_check_button_new_with_mnemonic (_("Show splash screen"));
1830 data
->CM_show_splash
= widget
;
1831 gtk_grid_attach (GTK_GRID (group_grid
), widget
, 1, row
, 2, 1);
1834 widget
= gtk_check_button_new_with_mnemonic (_("Load last opened file"));
1835 data
->CM_load_last
= widget
;
1836 gtk_grid_attach (GTK_GRID (group_grid
), widget
, 1, row
, 2, 1);
1839 widget
= gtk_check_button_new_with_mnemonic (_("Post pending scheduled transactions"));
1840 data
->CM_append_scheduled
= widget
;
1841 gtk_grid_attach (GTK_GRID (group_grid
), widget
, 1, row
, 2, 1);
1844 widget
= gtk_check_button_new_with_mnemonic (_("Update currencies online"));
1845 data
->CM_do_update_currency
= widget
;
1846 gtk_grid_attach (GTK_GRID (group_grid
), widget
, 1, row
, 2, 1);
1848 // group :: Fiscal year
1849 group_grid
= gtk_grid_new ();
1850 gtk_grid_set_row_spacing (GTK_GRID (group_grid
), SPACING_SMALL
);
1851 gtk_grid_set_column_spacing (GTK_GRID (group_grid
), SPACING_MEDIUM
);
1852 gtk_grid_attach (GTK_GRID (content_grid
), group_grid
, 0, crow
++, 1, 1);
1854 label
= make_label_group(_("Fiscal year"));
1855 gtk_grid_attach (GTK_GRID (group_grid
), label
, 0, 0, 3, 1);
1858 //TRANSLATORS: (fiscal year) starts on
1859 label
= make_label_widget(_("Starts _on:"));
1860 gtk_grid_attach (GTK_GRID (group_grid
), label
, 1, row
, 1, 1);
1862 hbox
= gtk_box_new(GTK_ORIENTATION_HORIZONTAL
, SPACING_SMALL
);
1863 gtk_grid_attach (GTK_GRID (group_grid
), hbox
, 2, row
, 1, 1);
1864 widget
= make_numeric (label
, 1, 28);
1865 data
->NB_fiscyearday
= widget
;
1866 gtk_box_pack_start (GTK_BOX (hbox
), widget
, FALSE
, FALSE
, 0);
1867 widget
= make_cycle (NULL
, CYA_MONTHS
);
1868 data
->CY_fiscyearmonth
= widget
;
1869 gtk_box_pack_start (GTK_BOX (hbox
), widget
, FALSE
, FALSE
, 0);
1871 // group :: Main window reports
1872 group_grid
= gtk_grid_new ();
1873 gtk_grid_set_row_spacing (GTK_GRID (group_grid
), SPACING_SMALL
);
1874 gtk_grid_set_column_spacing (GTK_GRID (group_grid
), SPACING_MEDIUM
);
1875 gtk_grid_attach (GTK_GRID (content_grid
), group_grid
, 0, crow
++, 1, 1);
1877 label
= make_label_group(_("Main window reports"));
1878 gtk_grid_attach (GTK_GRID (group_grid
), label
, 0, 0, 3, 1);
1881 label
= make_label_widget(_("Date _range:"));
1882 gtk_grid_attach (GTK_GRID (group_grid
), label
, 1, row
, 1, 1);
1883 widget
= make_daterange(label
, FALSE
);
1884 data
->CY_daterange_wal
= widget
;
1885 gtk_grid_attach (GTK_GRID (group_grid
), widget
, 2, row
, 1, 1);
1887 // group :: Files folder
1888 group_grid
= gtk_grid_new ();
1889 gtk_grid_set_row_spacing (GTK_GRID (group_grid
), SPACING_SMALL
);
1890 gtk_grid_set_column_spacing (GTK_GRID (group_grid
), SPACING_MEDIUM
);
1891 gtk_grid_attach (GTK_GRID (content_grid
), group_grid
, 0, crow
++, 1, 1);
1893 label
= make_label_group(_("Files folder"));
1894 gtk_grid_attach (GTK_GRID (group_grid
), label
, 0, 0, 3, 1);
1897 label
= make_label_widget(_("_Default:"));
1898 gtk_grid_attach (GTK_GRID (group_grid
), label
, 1, row
, 1, 1);
1900 hbox
= gtk_box_new(GTK_ORIENTATION_HORIZONTAL
, 0);
1901 gtk_widget_set_hexpand (hbox
, TRUE
);
1902 gtk_grid_attach (GTK_GRID (group_grid
), hbox
, 2, row
, 1, 1);
1904 widget
= make_string(label
);
1905 data
->ST_path_hbfile
= widget
;
1906 gtk_style_context_add_class (gtk_widget_get_style_context (GTK_WIDGET(widget
)), GTK_STYLE_CLASS_LINKED
);
1907 gtk_box_pack_start (GTK_BOX (hbox
), widget
, TRUE
, TRUE
, 0);
1909 //widget = gtk_button_new_with_label("...");
1910 widget
= gtk_button_new_from_icon_name(ICONNAME_FOLDER
, GTK_ICON_SIZE_BUTTON
);
1911 data
->BT_path_hbfile
= widget
;
1912 gtk_box_pack_start (GTK_BOX (hbox
), widget
, FALSE
, FALSE
, 0);
1914 return content_grid
;
1918 void plugin_execute_action(GtkTreeView
* treeview
, GtkTreePath
* path
, GtkTreeViewColumn
* col
, gpointer userdata
);
1921 toggle_plugin(GtkCellRendererToggle
*cell
, gchar
* path_str
, gpointer data
)
1923 GtkTreeModel
*model
= (GtkTreeModel
*)data
;
1925 GtkTreePath
*path
= gtk_tree_path_new_from_string(path_str
);
1927 const gchar
* plugin
;
1929 gtk_tree_model_get_iter(model
, &iter
, path
);
1930 gtk_tree_model_get(model
, &iter
, EXT_COLUMN_PLUGIN_NAME
, &plugin
, -1);
1932 gboolean enabled
= ext_is_plugin_loaded(plugin
);
1934 ext_unload_plugin(plugin
);
1937 enabled
= (ext_load_plugin(plugin
) == 0);
1939 ext_run_modal(_("Plugin Error"), _("The plugin failed to load properly."), "error");
1944 gtk_list_store_set(GTK_LIST_STORE (model
), &iter
, EXT_COLUMN_ENABLED
, enabled
, -1);
1947 gtk_tree_path_free(path
);
1951 void plugin_execute_action(GtkTreeView
* treeview
, GtkTreePath
* path
, GtkTreeViewColumn
* col
, gpointer userdata
)
1953 GtkTreeModel
* model
= gtk_tree_view_get_model(treeview
);
1956 if (gtk_tree_model_get_iter(model
, &iter
, path
)) {
1957 gchar
* plugin_filename
;
1958 gtk_tree_model_get(model
, &iter
, EXT_COLUMN_PLUGIN_NAME
, &plugin_filename
, -1);
1959 ext_execute_action(plugin_filename
);
1960 g_free(plugin_filename
);
1964 static GtkWidget
*defpref_page_plugins (struct defpref_data
*data
)
1966 GtkWidget
*container
;
1967 GtkListStore
*store
;
1971 container
= gtk_vbox_new(FALSE
, 0);
1973 store
= gtk_list_store_new(EXT_NUM_COLUMNS
, G_TYPE_BOOLEAN
, G_TYPE_STRING
, G_TYPE_STRING
, G_TYPE_STRING
);
1975 gchar
** plugins
= ext_list_plugins();
1977 for (plugins_it
= plugins
; *plugins_it
; ++plugins_it
) {
1979 gboolean enabled
= ext_is_plugin_loaded(*plugins_it
);
1980 GHashTable
* metadata
= ext_read_plugin_metadata(*plugins_it
);
1982 metadata
= g_hash_table_new(g_str_hash
, g_str_equal
);
1988 gchar
* name
= g_hash_table_lookup(metadata
, "name");
1989 if (!name
|| *name
== '\0') {
1992 name
= g_markup_escape_text(name
, -1);
1993 gchar
* label
= g_strdup_printf("<b>%s</b>", name
);
1994 gchar
* tooltip
= g_strdup_printf("<span size='x-large' weight='bold'>%s</span>", name
);
1998 gchar
* version
= g_hash_table_lookup(metadata
, "version");
2000 version
= g_markup_escape_text(version
, -1);
2002 label
= g_strdup_printf("%s %s", tmp
, version
);
2005 tooltip
= g_strdup_printf("%s %s", tmp
, version
);
2011 gchar
* abstract
= g_hash_table_lookup(metadata
, "abstract");
2013 abstract
= g_markup_escape_text(abstract
, -1);
2015 label
= g_strdup_printf("%s\n%s", tmp
, abstract
);
2021 gchar
* author
= g_hash_table_lookup(metadata
, "author");
2023 author
= g_markup_escape_text(author
, -1);
2025 tooltip
= g_strdup_printf("%s\n%s", tmp
, author
);
2031 gchar
* website
= g_hash_table_lookup(metadata
, "website");
2033 website
= g_markup_escape_text(website
, -1);
2035 tooltip
= g_strdup_printf("%s\n<b>%s:</b> %s", tmp
, _("Website"), website
);
2041 tmp
= ext_find_plugin(*plugins_it
);
2042 gchar
* full
= g_markup_escape_text(tmp
, -1);
2045 tooltip
= g_strdup_printf("%s\n<b>%s:</b> %s", tmp
, _("File"), full
);
2049 g_hash_table_unref(metadata
);
2051 gtk_list_store_append(store
, &it
);
2052 gtk_list_store_set(store
, &it
,
2053 EXT_COLUMN_ENABLED
, enabled
,
2054 EXT_COLUMN_LABEL
, label
,
2055 EXT_COLUMN_TOOLTIP
, tooltip
,
2056 EXT_COLUMN_PLUGIN_NAME
, *plugins_it
,
2062 g_strfreev(plugins
);
2064 view
= gtk_tree_view_new_with_model(GTK_TREE_MODEL(store
));
2065 g_object_unref(store
);
2067 g_signal_connect(view
, "row-activated", (GCallback
)plugin_execute_action
, NULL
);
2069 gtk_tree_view_set_rules_hint(GTK_TREE_VIEW(view
), TRUE
);
2070 gtk_tree_view_set_headers_visible(GTK_TREE_VIEW(view
), TRUE
);
2071 gtk_tree_view_set_tooltip_column(GTK_TREE_VIEW(view
), EXT_COLUMN_TOOLTIP
);
2074 GtkTreeViewColumn
*col
;
2075 GtkCellRenderer
*renderer
;
2078 col
= gtk_tree_view_column_new();
2079 gtk_tree_view_column_set_title(col
, _("Enabled"));
2080 gtk_tree_view_column_set_sort_column_id(col
, EXT_COLUMN_ENABLED
);
2081 gtk_tree_view_append_column(GTK_TREE_VIEW(view
), col
);
2083 renderer
= gtk_cell_renderer_toggle_new();
2084 gtk_tree_view_column_pack_start(col
, renderer
, TRUE
);
2085 gtk_tree_view_column_add_attribute(col
, renderer
, "active", 0);
2086 g_signal_connect(renderer
, "toggled", G_CALLBACK(toggle_plugin
), store
);
2088 col
= gtk_tree_view_column_new();
2089 gtk_tree_view_column_set_title(col
, _("Plugin"));
2090 gtk_tree_view_column_set_sort_column_id(col
, EXT_COLUMN_LABEL
);
2091 gtk_tree_view_column_set_expand(col
, TRUE
);
2092 /*gtk_tree_view_column_set_sort_order(col, GTK_SORT_ASCENDING);*/
2093 gtk_tree_view_append_column(GTK_TREE_VIEW(view
), col
);
2095 renderer
= gtk_cell_renderer_text_new();
2096 g_object_set(renderer
, "ellipsize", PANGO_ELLIPSIZE_END
, NULL
);
2097 gtk_tree_view_column_pack_start(col
, renderer
, TRUE
);
2098 gtk_tree_view_column_add_attribute(col
, renderer
, "markup", EXT_COLUMN_LABEL
);
2100 data
->PI_plugin_columns
= view
;
2102 GtkWidget
* sw
= gtk_scrolled_window_new(NULL
, NULL
);
2103 gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(sw
), GTK_SHADOW_ETCHED_IN
);
2104 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(sw
), GTK_POLICY_NEVER
, GTK_POLICY_AUTOMATIC
);
2105 gtk_container_add(GTK_CONTAINER(sw
), view
);
2107 gtk_box_pack_start(GTK_BOX(container
), sw
, TRUE
, TRUE
, 0);
2113 static void defpref_selection(GtkTreeSelection
*treeselection
, gpointer user_data
)
2115 struct defpref_data
*data
;
2116 GtkWidget
*notebook
;
2117 GtkTreeView
*treeview
;
2118 GtkTreeModel
*model
;
2121 GValue val
= { 0, };
2124 DB( g_print("\n[ui-pref] selection\n") );
2126 if (gtk_tree_selection_get_selected(treeselection
, &model
, &iter
))
2128 notebook
= GTK_WIDGET(user_data
);
2129 treeview
= gtk_tree_selection_get_tree_view(treeselection
);
2130 data
= g_object_get_data(G_OBJECT(gtk_widget_get_ancestor(GTK_WIDGET(treeview
), GTK_TYPE_WINDOW
)), "inst_data");
2133 gtk_tree_model_get_value(model
, &iter
, LST_PREF_PAGE
, &val
);
2134 page
= g_value_get_int (&val
);
2135 DB( g_print(" - active is %d\n", page
) );
2136 g_value_unset (&val
);
2139 gtk_tree_model_get_value(model
, &iter
, LST_PREF_NAME
, &val
);
2140 gtk_label_set_text (GTK_LABEL (data
->label
), g_value_get_string (&val
));
2141 g_value_unset (&val
);
2143 gtk_tree_model_get_value(model
, &iter
, LST_PREF_ICONNAME
, &val
);
2144 //gtk_image_set_from_pixbuf (GTK_IMAGE (data->image), g_value_get_object (&val));
2145 gtk_image_set_from_icon_name(GTK_IMAGE (data
->image
), g_value_get_string (&val
), GTK_ICON_SIZE_DIALOG
);
2146 g_value_unset (&val
);
2150 gtk_notebook_set_current_page(GTK_NOTEBOOK(notebook
), page
);
2152 //defpref_change_page(GTK_WIDGET(gtk_tree_selection_get_tree_view(treeselection)), GINT_TO_POINTER(page));
2159 ** set the notebook active page from treeview
2161 /*void defpref_change_page(GtkWidget *widget, gpointer user_data)
2163 struct defpref_data *data;
2164 gint page = GPOINTER_TO_INT(user_data);
2165 GtkTreeModel *model;
2168 DB( g_print("\n[ui-pref] page\n") );
2170 data = g_object_get_data(G_OBJECT(gtk_widget_get_ancestor(widget, GTK_TYPE_WINDOW)), "inst_data");
2172 model = gtk_tree_view_get_model(GTK_TREE_VIEW(data->LV_page));
2180 gtk_notebook_set_current_page(GTK_NOTEBOOK(data->GR_page), page);
2186 ** add an empty new account to our temp GList and treeview
2188 static void defpref_clear(GtkWidget
*widget
, gpointer user_data
)
2190 struct defpref_data
*data
;
2193 data
= g_object_get_data(G_OBJECT(gtk_widget_get_ancestor(widget
, GTK_TYPE_WINDOW
)), "inst_data");
2194 DB( g_print("\n(defpref_clear) (data=%p)\n", data
) );
2196 result
= ui_dialog_msg_confirm_alert(
2197 GTK_WINDOW(data
->window
),
2198 _("Reset all preferences"),
2199 _("Do you really want to reset all\npreferences to default values?"),
2202 if( result
== GTK_RESPONSE_OK
)
2204 homebank_pref_setdefault();
2211 // the window creation
2212 GtkWidget
*defpref_dialog_new (gint initial_selection
)
2214 struct defpref_data data
;
2215 GtkWidget
*window
, *content
, *mainvbox
;
2216 GtkWidget
*hbox
, *vbox
, *sw
, *widget
, *notebook
, *page
, *ebox
, *image
, *label
;
2218 window
= gtk_dialog_new_with_buttons (_("Preferences"),
2219 GTK_WINDOW(GLOBALS
->mainwindow
),
2222 GTK_RESPONSE_REJECT
,
2224 GTK_RESPONSE_ACCEPT
,
2227 data
.window
= window
;
2229 //store our window private data
2230 g_object_set_data(G_OBJECT(window
), "inst_data", (gpointer
)&data
);
2232 gtk_window_set_icon_name(GTK_WINDOW (window
), ICONNAME_PREFERENCES
);
2234 content
= gtk_dialog_get_content_area(GTK_DIALOG (window
)); // return a vbox
2235 mainvbox
= gtk_box_new(GTK_ORIENTATION_VERTICAL
, SPACING_MEDIUM
);
2236 gtk_box_pack_start (GTK_BOX (content
), mainvbox
, TRUE
, TRUE
, 0);
2238 gtk_container_set_border_width(GTK_CONTAINER(mainvbox
), SPACING_MEDIUM
);
2240 hbox
= gtk_box_new(GTK_ORIENTATION_HORIZONTAL
, SPACING_MEDIUM
);
2241 gtk_box_pack_start (GTK_BOX (mainvbox
), hbox
, TRUE
, TRUE
, 0);
2244 vbox
= gtk_box_new(GTK_ORIENTATION_VERTICAL
, SPACING_SMALL
);
2245 gtk_box_pack_start (GTK_BOX (hbox
), vbox
, FALSE
, FALSE
, 0);
2248 sw
= gtk_scrolled_window_new (NULL
, NULL
);
2249 gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (sw
), GTK_SHADOW_ETCHED_IN
);
2250 gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (sw
), GTK_POLICY_NEVER
, GTK_POLICY_AUTOMATIC
);
2251 gtk_box_pack_start (GTK_BOX (vbox
), sw
, TRUE
, TRUE
, 0);
2252 widget
= pref_list_create();
2253 data
.LV_page
= widget
;
2254 gtk_container_add (GTK_CONTAINER (sw
), widget
);
2257 data
.BT_clear
= gtk_button_new_with_mnemonic(_("_Reset"));
2258 gtk_box_pack_start (GTK_BOX (vbox
), data
.BT_clear
, FALSE
, TRUE
, 0);
2261 //right part : notebook
2262 vbox
= gtk_box_new (GTK_ORIENTATION_VERTICAL
, SPACING_MEDIUM
);
2263 gtk_box_pack_start (GTK_BOX (hbox
), vbox
, TRUE
, TRUE
, 0);
2264 gtk_widget_show (vbox
);
2266 ebox
= gtk_event_box_new();
2267 gtk_widget_set_name(ebox
, "hbebox");
2268 GtkStyleContext
*context
= gtk_widget_get_style_context (ebox
);
2269 #if GTK_MINOR_VERSION <= 18
2270 gtk_style_context_add_class (context
, GTK_STYLE_CLASS_LIST_ROW
);
2271 gtk_widget_set_state_flags(ebox
, GTK_STATE_FLAG_SELECTED
, TRUE
);
2273 GtkCssProvider
*provider
;
2274 provider
= gtk_css_provider_new ();
2275 gtk_css_provider_load_from_data (provider
,
2276 "#hbebox { color: @theme_selected_fg_color; background-color: @theme_selected_bg_color; }"
2278 gtk_style_context_add_provider (context
, GTK_STYLE_PROVIDER(provider
), G_MAXUINT
);
2280 // gtk_style_context_set_state(context, GTK_STATE_FLAG_SELECTED);
2283 gtk_box_pack_start (GTK_BOX (vbox
), ebox
, FALSE
, TRUE
, 0);
2284 gtk_widget_show (ebox
);
2286 hbox
= gtk_box_new (GTK_ORIENTATION_HORIZONTAL
, SPACING_SMALL
);
2287 gtk_container_set_border_width (GTK_CONTAINER (hbox
), SPACING_SMALL
);
2288 gtk_container_add (GTK_CONTAINER (ebox
), hbox
);
2289 gtk_widget_show (hbox
);
2291 label
= gtk_label_new (NULL
);
2292 gtk_widget_set_margin_left(label
, SPACING_MEDIUM
);
2293 gimp_label_set_attributes (GTK_LABEL (label
),
2294 PANGO_ATTR_SCALE
, PANGO_SCALE_XX_LARGE
,
2295 PANGO_ATTR_WEIGHT
, PANGO_WEIGHT_BOLD
,
2298 gtk_box_pack_start (GTK_BOX (hbox
), label
, FALSE
, FALSE
, 0);
2299 gtk_widget_show (label
);
2302 image
= gtk_image_new ();
2303 gtk_box_pack_end (GTK_BOX (hbox
), image
, FALSE
, FALSE
, 0);
2304 gtk_widget_show (image
);
2310 notebook
= gtk_notebook_new();
2311 data
.GR_page
= notebook
;
2312 gtk_widget_show(notebook
);
2313 gtk_notebook_set_show_tabs(GTK_NOTEBOOK(notebook
), FALSE
);
2314 gtk_notebook_set_show_border(GTK_NOTEBOOK(notebook
), FALSE
);
2315 gtk_box_pack_start (GTK_BOX (vbox
), notebook
, TRUE
, TRUE
, 0);
2327 page
= defpref_page_general(&data
);
2328 gtk_notebook_append_page (GTK_NOTEBOOK (notebook
), page
, NULL
);
2331 page
= defpref_page_interface(&data
);
2332 gtk_notebook_append_page (GTK_NOTEBOOK (notebook
), page
, NULL
);
2335 page
= defpref_page_transactions(&data
);
2336 gtk_notebook_append_page (GTK_NOTEBOOK (notebook
), page
, NULL
);
2339 page
= defpref_page_display(&data
);
2340 gtk_notebook_append_page (GTK_NOTEBOOK (notebook
), page
, NULL
);
2343 page
= defpref_page_import(&data
);
2344 gtk_notebook_append_page (GTK_NOTEBOOK (notebook
), page
, NULL
);
2347 page
= defpref_page_reports(&data
);
2348 gtk_notebook_append_page (GTK_NOTEBOOK (notebook
), page
, NULL
);
2351 page
= defpref_page_euro(&data
);
2352 gtk_notebook_append_page (GTK_NOTEBOOK (notebook
), page
, NULL
);
2355 page
= defpref_page_plugins(&data
);
2356 gtk_notebook_append_page (GTK_NOTEBOOK (notebook
), page
, NULL
);
2359 //todo:should move this
2360 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(data
.CM_euro_enable
), PREFS
->euro_active
);
2362 //connect all our signals
2363 g_signal_connect (window
, "destroy", G_CALLBACK (gtk_widget_destroyed
), &window
);
2365 g_signal_connect (G_OBJECT (data
.BT_clear
), "clicked", G_CALLBACK (defpref_clear
), NULL
);
2368 g_signal_connect (data
.BT_path_hbfile
, "pressed", G_CALLBACK (defpref_pathselect
), GINT_TO_POINTER(1));
2369 g_signal_connect (data
.BT_path_import
, "pressed", G_CALLBACK (defpref_pathselect
), GINT_TO_POINTER(2));
2370 g_signal_connect (data
.BT_path_export
, "pressed", G_CALLBACK (defpref_pathselect
), GINT_TO_POINTER(3));
2372 g_signal_connect (data
.CM_custom_colors
, "toggled", G_CALLBACK (defpref_colortoggle
), NULL
);
2373 g_signal_connect (data
.CY_colors
, "changed", G_CALLBACK (defpref_colorpreset
), NULL
);
2377 g_signal_connect (gtk_tree_view_get_selection(GTK_TREE_VIEW(data
.LV_page
)), "changed", G_CALLBACK (defpref_selection
), notebook
);
2379 g_signal_connect (data
.CM_euro_enable
, "toggled", G_CALLBACK (defpref_eurotoggle
), NULL
);
2381 g_signal_connect (data
.CY_euro_preset
, "changed", G_CALLBACK (defpref_europreset
), NULL
);
2384 g_signal_connect (data
.ST_datefmt
, "changed", G_CALLBACK (defpref_date_sample
), NULL
);
2387 g_signal_connect (data
.CY_color_scheme
, "changed", G_CALLBACK (defpref_color_scheme_changed
), NULL
);
2391 g_signal_connect (data
.ST_euro_symbol
, "changed", G_CALLBACK (defpref_numbereuro_sample
), NULL
);
2392 g_signal_connect (data
.CM_euro_isprefix
, "toggled", G_CALLBACK (defpref_numbereuro_sample
), NULL
);
2393 g_signal_connect (data
.ST_euro_decimalchar
, "changed", G_CALLBACK (defpref_numbereuro_sample
), NULL
);
2394 g_signal_connect (data
.ST_euro_groupingchar
, "changed", G_CALLBACK (defpref_numbereuro_sample
), NULL
);
2395 g_signal_connect (data
.NB_euro_fracdigits
, "value-changed", G_CALLBACK (defpref_numbereuro_sample
), NULL
);
2397 //g_signal_connect (data.BT_default, "pressed", G_CALLBACK (defpref_currency_change), NULL);
2400 //setup, init and show window
2401 //defhbfile_setup(&data);
2402 //defhbfile_update(data.LV_arc, NULL);
2406 defpref_colortoggle(window
, NULL
);
2407 defpref_eurotoggle(window
, NULL
);
2409 gtk_window_resize(GTK_WINDOW(window
), 640, 256);
2413 GtkTreePath
*path
= gtk_tree_path_new_from_indices(initial_selection
, -1);
2416 gtk_tree_selection_select_path (gtk_tree_view_get_selection(GTK_TREE_VIEW(data
.LV_page
)), path
);
2420 gtk_tree_path_free(path
);
2422 gtk_widget_show_all (window
);
2423 gtk_notebook_set_current_page(GTK_NOTEBOOK(notebook
), initial_selection
);
2430 result
= gtk_dialog_run (GTK_DIALOG (window
));
2434 case GTK_RESPONSE_ACCEPT
:
2435 old_lang
= g_strdup(PREFS
->language
);
2437 homebank_pref_save();
2438 ui_mainwindow_update(GLOBALS
->mainwindow
, GINT_TO_POINTER(UF_BALANCE
+UF_VISUAL
));
2440 DB( g_print("old='%s' new='%s'\n", old_lang
, PREFS
->language
) );
2442 if(g_ascii_strncasecmp(old_lang
== NULL
? "" : old_lang
, PREFS
->language
== NULL
? "" : PREFS
->language
, -1) != 0)
2444 ui_dialog_msg_infoerror(GTK_WINDOW(window
), GTK_MESSAGE_INFO
,
2446 _("You will have to restart HomeBank\nfor the language change to take effect.")
2456 // cleanup and destroy
2457 //defhbfile_cleanup(&data, result);
2458 gtk_widget_destroy (window
);
2463 // -------------------------------
2466 GtkWidget
*pref_list_create(void)
2468 GtkListStore
*store
;
2470 GtkCellRenderer
*renderer
;
2471 GtkTreeViewColumn
*column
;
2475 /* create list store */
2476 store
= gtk_list_store_new(
2484 view
= gtk_tree_view_new_with_model(GTK_TREE_MODEL(store
));
2485 g_object_unref(store
);
2487 gtk_tree_view_set_headers_visible(GTK_TREE_VIEW (view
), FALSE
);
2488 gtk_tree_selection_set_mode(gtk_tree_view_get_selection(GTK_TREE_VIEW(view
)), GTK_SELECTION_SINGLE
);
2490 /* column 1: icon */
2491 column
= gtk_tree_view_column_new();
2492 renderer
= gtk_cell_renderer_pixbuf_new ();
2493 g_object_set(renderer
, "stock-size", GTK_ICON_SIZE_DND
, NULL
);
2494 gtk_tree_view_column_pack_start(column
, renderer
, FALSE
);
2495 gtk_tree_view_column_set_attributes(column
, renderer
, "icon-name", LST_PREF_ICONNAME
, NULL
);
2497 renderer
= gtk_cell_renderer_text_new ();
2498 gtk_tree_view_column_pack_start(column
, renderer
, TRUE
);
2499 gtk_tree_view_column_set_attributes(column
, renderer
, "text", LST_PREF_NAME
, NULL
);
2501 gtk_tree_view_append_column (GTK_TREE_VIEW(view
), column
);
2503 //populate our combobox model
2504 for(i
=0;i
<PREF_MAX
;i
++)
2506 gtk_list_store_append(store
, &iter
);
2508 gtk_list_store_set(store
, &iter
,
2509 LST_PREF_ICONNAME
, pref_iconname
[i
],
2510 LST_PREF_NAME
, _(pref_name
[i
]),
2519 /* = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =*/
2522 extern gchar
*list_txn_column_label
[];
2526 list_txn_colpref_toggled_cell_data_function (GtkCellRendererToggle
*cell
,
2530 GtkTreeModel
*model
= (GtkTreeModel
*)data
;
2532 GtkTreePath
*path
= gtk_tree_path_new_from_string (path_str
);
2535 /* get toggled iter */
2536 gtk_tree_model_get_iter (model
, &iter
, path
);
2537 gtk_tree_model_get (model
, &iter
, COLUMN_VISIBLE
, &fixed
, -1);
2539 /* do something with the value */
2543 gtk_list_store_set (GTK_LIST_STORE (model
), &iter
, COLUMN_VISIBLE
, fixed
, -1);
2546 gtk_tree_path_free (path
);
2550 static void list_txn_colpref_get(GtkTreeView
*treeview
, gint
*columns
)
2552 GtkTreeModel
*model
;
2558 DB( g_print("[lst_txn-colpref] store column order \n") );
2561 model
= gtk_tree_view_get_model(GTK_TREE_VIEW(treeview
));
2562 valid
= gtk_tree_model_get_iter_first(GTK_TREE_MODEL(model
), &iter
);
2566 gtk_tree_model_get(GTK_TREE_MODEL(model
), &iter
,
2567 COLUMN_VISIBLE
, &visible
,
2571 DB( g_print(" - column %d: %d\n",id
, visible
) );
2572 // start at index 2 (status, date always displayed
2573 columns
[i
+2] = visible
== TRUE
? id
: -id
;
2575 /* Make iter point to the next row in the list store */
2576 valid
= gtk_tree_model_iter_next(GTK_TREE_MODEL(model
), &iter
);
2585 GtkWidget
*list_txn_colprefcreate(void)
2587 GtkListStore
*store
;
2589 GtkCellRenderer
*renderer
;
2590 GtkTreeViewColumn
*column
;
2594 DB( g_print("[lst_txn-colpref] create\n") );
2597 /* create list store */
2598 store
= gtk_list_store_new(
2606 for(i
=0 ; i
< NUM_LST_DSPOPE
-1; i
++ ) //-1 cause account column avoid
2611 DB( g_print("eval %d, %s\n", i
, list_txn_column_label
[i
]) );
2613 if(i
<= LST_DSPOPE_DATE
) // status, date always displayed
2616 //[i-1] here because lst_ope_columns[] do not store LST_DSPOPE_DATAS
2617 id
= ABS(PREFS
->lst_ope_columns
[i
-1]);
2618 if(id
== 0) id
= i
; //if we pass here, new column or weird into pref file
2619 visible
= (PREFS
->lst_ope_columns
[i
-1] > 0) ? TRUE
: FALSE
;
2622 DB( g_print(" - pos=%2d, id=%2d - %d '%s'\n", i
, id
, visible
, list_txn_column_label
[id
]) );
2624 gtk_list_store_append (store
, &iter
);
2625 gtk_list_store_set (store
, &iter
,
2626 COLUMN_VISIBLE
, visible
,
2627 COLUMN_NAME
, _(list_txn_column_label
[id
]),
2634 view
= gtk_tree_view_new_with_model(GTK_TREE_MODEL(store
));
2635 g_object_unref(store
);
2639 renderer
= gtk_cell_renderer_toggle_new ();
2640 column
= gtk_tree_view_column_new_with_attributes (_("Visible"),
2642 "active", COLUMN_VISIBLE
,
2644 gtk_tree_view_append_column (GTK_TREE_VIEW(view
), column
);
2646 g_signal_connect (renderer
, "toggled",
2647 G_CALLBACK (list_txn_colpref_toggled_cell_data_function
), store
);
2650 renderer
= gtk_cell_renderer_text_new ();
2651 column
= gtk_tree_view_column_new_with_attributes (_("Column"),
2653 "text", COLUMN_NAME
,
2655 gtk_tree_view_append_column (GTK_TREE_VIEW(view
), column
);
2657 gtk_tree_view_set_reorderable (GTK_TREE_VIEW(view
), TRUE
);
2664 static void list_ext_colpref_get(GtkTreeView
*treeview
, GList
**columns
)
2666 GtkTreeModel
*model
;
2669 g_list_free_full(*columns
, g_free
);
2672 model
= gtk_tree_view_get_model(GTK_TREE_VIEW(treeview
));
2674 gboolean valid
= gtk_tree_model_get_iter_first(GTK_TREE_MODEL(model
), &iter
);
2676 gboolean enabled
= FALSE
;
2679 gtk_tree_model_get(GTK_TREE_MODEL(model
), &iter
,
2680 EXT_COLUMN_ENABLED
, &enabled
,
2681 EXT_COLUMN_PLUGIN_NAME
, &name
,
2685 *columns
= g_list_append(*columns
, g_strdup(name
));
2688 valid
= gtk_tree_model_iter_next(GTK_TREE_MODEL(model
), &iter
);