]> Dogcows Code - chaz/homebank/blob - src/ui-pref.c
Merge branch 'master' into ext-perl
[chaz/homebank] / src / ui-pref.c
1 /* HomeBank -- Free, easy, personal accounting for everyone.
2 * Copyright (C) 1995-2018 Maxime DOYEN
3 *
4 * This file is part of HomeBank.
5 *
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.
10 *
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.
15 *
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/>.
18 */
19
20
21 #include "homebank.h"
22
23 #include "ui-pref.h"
24 #include "dsp_mainwindow.h"
25 #include "gtk-chart-colors.h"
26
27 #include "ext.h"
28
29 #include "ui-currency.h"
30
31
32 /****************************************************************************/
33 /* Debug macros */
34 /****************************************************************************/
35 #define MYDEBUG 0
36
37 #if MYDEBUG
38 #define DB(x) (x);
39 #else
40 #define DB(x);
41 #endif
42
43 /* our global datas */
44 extern struct HomeBank *GLOBALS;
45 extern struct Preferences *PREFS;
46
47
48 enum {
49 LST_PREF_ICONNAME,
50 LST_PREF_NAME,
51 LST_PREF_PAGE,
52 LST_PREF_MAX
53 };
54
55
56 enum
57 {
58 EXT_COLUMN_ENABLED = 0,
59 EXT_COLUMN_LABEL,
60 EXT_COLUMN_TOOLTIP,
61 EXT_COLUMN_PLUGIN_NAME,
62 EXT_NUM_COLUMNS
63 };
64
65
66 static gchar *pref_iconname[PREF_MAX] = {
67 "prf-general",
68 "prf-interface",
69 "prf-columns",
70 "prf-display",
71 "prf-import",
72 "prf-report",
73 "prf-euro", // to be renamed
74 "prf-plugins",
75 //"prf_charts.svg"
76 };
77
78 static gchar *pref_name[PREF_MAX] = {
79 N_("General"),
80 N_("Interface"),
81 N_("Transactions"),
82 N_("Display format"),
83 N_("Import/Export"),
84 N_("Report"),
85 N_("Euro minor"),
86 N_("Plugins")
87 //
88 };
89
90 static gchar *CYA_TOOLBAR_STYLE[] = {
91 N_("System defaults"),
92 N_("Icons only"),
93 N_("Text only"),
94 N_("Text under icons"),
95 N_("Text beside icons"),
96 NULL
97 };
98
99 static gchar *CYA_GRID_LINES[] = {
100 N_("None"),
101 N_("Horizontal"),
102 N_("Vertical"),
103 N_("Both"),
104 NULL
105 };
106
107
108 gchar *CYA_TANGO_COLORS[] = {
109 "----",
110 N_("Tango light"),
111 N_("Tango medium"),
112 N_("Tango dark"),
113 NULL
114 };
115
116 gchar *CYA_IMPORT_DATEORDER[] = {
117 N_("m-d-y"),
118 N_("d-m-y"),
119 N_("y-m-d"),
120 NULL
121 };
122
123 gchar *CYA_IMPORT_OFXNAME[] = {
124 N_("Ignore"),
125 N_("Memo"),
126 N_("Payee"),
127 NULL
128 };
129
130 gchar *CYA_IMPORT_OFXMEMO[] = {
131 N_("Ignore"),
132 N_("Append to Info"),
133 N_("Append to Memo"),
134 N_("Append to Payee"),
135 NULL
136 };
137
138
139 extern gchar *CYA_CHART_COLORSCHEME[];
140 extern gchar *CYA_MONTHS[];
141
142
143
144
145 /*
146 source:
147 http://en.wikipedia.org/wiki/Currencies_of_the_European_Union
148 http://www.xe.com/euro.php
149 http://fr.wikipedia.org/wiki/Liste_des_unit%C3%A9s_mon%C3%A9taires_remplac%C3%A9es_par_l%27euro
150 http://www.inter-locale.com/LocalesDemo.jsp
151 */
152 static EuroParams euro_params[] =
153 {
154 // , rate , symb , prfx , dec, grp, frac
155 // ---------------------------------------------------------------------
156 { 0, "" , "--------" , 1.0 , "" , FALSE, ",", ".", 2 },
157 { 1, "ATS", "Austria" , 13.7603 , "S" , TRUE , ",", ".", 2 }, // -S 1.234.567,89
158 { 2, "BEF", "Belgium" , 40.3399 , "BF" , TRUE , ",", ".", 2 }, // BF 1.234.567,89 -
159 { 20, "BGN", "Bulgaria" , 1.95583 , "лв." , TRUE , ",", " ", 2 }, // non-fixé - 2014 target for euro
160 { 24, "HRK", "Croatia" , 1.0000 , "kn" , FALSE, "" , ".", 0 }, // non-fixé - 2015 target for euro earliest
161 { 14, "CYP", "Cyprus" , 0.585274 , "£" , TRUE , ",", "" , 2 }, //
162 { 23, "CZK", "Czech Republic" , 28.36 , "Kč" , FALSE, ",", " ", 2 }, // non-fixé - 2015 earliest
163 // Denmark
164 { 17, "EEK", "Estonia" , 15.6466 , "kr" , FALSE, ",", " ", 2 }, //
165 { 3, "FIM", "Finland" , 5.94573 , "mk" , FALSE, ",", " ", 2 }, // -1 234 567,89 mk
166 { 4, "FRF", "France" , 6.55957 , "F" , FALSE, ",", " ", 2 }, // -1 234 567,89 F
167 { 5, "DEM", "Germany" , 1.95583 , "DM" , FALSE, ",", ".", 2 }, // -1.234.567,89 DM
168 { 6, "GRD", "Greece" , 340.750 , "d" , TRUE , ".", ",", 2 }, // ??
169 { 21, "HUF", "Hungary" , 261.51 , "Ft" , TRUE , ",", " ", 2 }, // non-fixé - No current target for euro
170 { 7, "IEP", "Ireland" , 0.787564 , "£" , TRUE , ".", ",", 2 }, // -£1,234,567.89
171 { 8, "ITL", "Italy" , 1936.27 , "L" , TRUE , "" , ".", 0 }, // L -1.234.567
172 { 18, "LVL", "Latvia" , 0.702804 , "lat.", FALSE, ",", "" , 2 }, // jan. 2014
173 { 19, "LTL", "Lithuania" , 3.45280 , "Lt" , FALSE, ",", "" , 2 }, // jan. 2015
174 { 9, "LUF", "Luxembourg" , 40.3399 , "LU" , TRUE , ",", ".", 2 }, // LU 1.234.567,89 -
175 { 15, "MTL", "Malta" , 0.429300 , "Lm" , TRUE , ",", "" , 2 }, //
176 { 10, "NLG", "Netherlands" , 2.20371 , "F" , TRUE , ",", ".", 2 }, // F 1.234.567,89-
177 { 25, "PLN", "Poland" , 0.25 , "zł" , FALSE, ",", "" , 2 }, // non-fixé - No current target for euro
178 { 11, "PTE", "Portugal" , 200.482 , "Esc.", FALSE, "$", ".", 2 }, // -1.234.567$89 Esc.
179 { 22, "RON", "Romania" , 3.5155 , "Leu" , FALSE, ",", ".", 2 }, // non-fixé - 2015 target for euro earliest
180 { 16, "SKK", "Slovak Republic", 30.12600 , "Sk" , FALSE, ",", " ", 2 }, //
181 { 13, "SIT", "Slovenia" , 239.640 , "tol" , TRUE , ",", ".", 2 }, //
182 { 12, "ESP", "Spain" , 166.386 , "Pts" , TRUE , "" , ".", 0 }, // -Pts 1.234.567
183 //Sweden
184 //United Kingdom
185 // { " ", "" , 1.00000 , "" , "" , FALSE, ",", "", 2 },
186 };
187
188
189 static void list_ext_colpref_get(GtkTreeView *treeview, GList **columns);
190
191
192 /* = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =*/
193
194
195 static LangName languagenames[] =
196 {
197 // af ar ast be bg ca cs cy da de el en_AU en_CA en_GB es et eu fa fi fr ga gl he hr hu id is it
198 //ja ka ko lt lv ms nb nds nl oc pl pt_BR pt pt_PT ro ru si sk sl sr sv tr uk vi zh_CN zh_TW
199
200 { "aa", "Afar" },
201 { "ab", "Abkhazian" },
202 { "ae", "Avestan" },
203 { "af", "Afrikaans" },
204 { "ak", "Akan" },
205 { "am", "Amharic" },
206 { "an", "Aragonese" },
207 { "ar", "Arabic" },
208 { "as", "Assamese" },
209 { "ast", "Asturian, Bable, Leonese, Asturleonese" },
210 { "av", "Avaric" },
211 { "ay", "Aymara" },
212 { "az", "Azerbaijani" },
213 { "ba", "Bashkir" },
214 { "be", "Belarusian" },
215 { "bg", "Bulgarian" },
216 { "bh", "Bihari" },
217 { "bi", "Bislama" },
218 { "bm", "Bambara" },
219 { "bn", "Bengali" },
220 { "bo", "Tibetan" },
221 { "br", "Breton" },
222 { "bs", "Bosnian" },
223 { "ca", "Catalan" },
224 { "ce", "Chechen" },
225 { "ch", "Chamorro" },
226 { "co", "Corsican" },
227 { "cr", "Cree" },
228 { "cs", "Czech" },
229 { "cu", "Old Church Slavonic" },
230 { "cv", "Chuvash" },
231 { "cy", "Welsh" },
232 { "da", "Danish" },
233 { "de", "German" },
234 { "dv", "Divehi" },
235 { "dz", "Dzongkha" },
236 { "ee", "Ewe" },
237 { "el", "Greek" },
238 { "en", "English" },
239 { "eo", "Esperanto" },
240 { "es", "Spanish" },
241 { "et", "Estonian" },
242 { "eu", "Basque" },
243 { "fa", "Persian" },
244 { "ff", "Fulah" },
245 { "fi", "Finnish" },
246 { "fj", "Fijian" },
247 { "fo", "Faroese" },
248 { "fr", "French" },
249 { "fy", "Western Frisian" },
250 { "ga", "Irish" },
251 { "gd", "Scottish Gaelic" },
252 { "gl", "Galician" },
253 { "gn", "Guarani" },
254 { "gu", "Gujarati" },
255 { "gv", "Manx" },
256 { "ha", "Hausa" },
257 { "he", "Hebrew" },
258 { "hi", "Hindi" },
259 { "ho", "Hiri Motu" },
260 { "hr", "Croatian" },
261 { "ht", "Haitian" },
262 { "hu", "Hungarian" },
263 { "hy", "Armenian" },
264 { "hz", "Herero" },
265 { "ia", "Interlingua" },
266 { "id", "Indonesian" },
267 { "ie", "Interlingue" },
268 { "ig", "Igbo" },
269 { "ii", "Sichuan Yi" },
270 { "ik", "Inupiaq" },
271 { "io", "Ido" },
272 { "is", "Icelandic" },
273 { "it", "Italian" },
274 { "iu", "Inuktitut" },
275 { "ja", "Japanese" },
276 { "jv", "Javanese" },
277 { "ka", "Georgian" },
278 { "kg", "Kongo" },
279 { "ki", "Kikuyu" },
280 { "kj", "Kwanyama" },
281 { "kk", "Kazakh" },
282 { "kl", "Kalaallisut" },
283 { "km", "Khmer" },
284 { "kn", "Kannada" },
285 { "ko", "Korean" },
286 { "kr", "Kanuri" },
287 { "ks", "Kashmiri" },
288 { "ku", "Kurdish" },
289 { "kv", "Komi" },
290 { "kw", "Cornish" },
291 { "ky", "Kirghiz" },
292 { "la", "Latin" },
293 { "lb", "Luxembourgish" },
294 { "lg", "Ganda" },
295 { "li", "Limburgish" },
296 { "ln", "Lingala" },
297 { "lo", "Lao" },
298 { "lt", "Lithuanian" },
299 { "lu", "Luba-Katanga" },
300 { "lv", "Latvian" },
301 { "mg", "Malagasy" },
302 { "mh", "Marshallese" },
303 { "mi", "Māori" },
304 { "mk", "Macedonian" },
305 { "ml", "Malayalam" },
306 { "mn", "Mongolian" },
307 { "mo", "Moldavian" },
308 { "mr", "Marathi" },
309 { "ms", "Malay" },
310 { "mt", "Maltese" },
311 { "my", "Burmese" },
312 { "na", "Nauru" },
313 { "nb", "Norwegian Bokmål" },
314 { "nd", "North Ndebele" },
315 { "nds", "Low German, Low Saxon" },
316 { "ne", "Nepali" },
317 { "ng", "Ndonga" },
318 { "nl", "Dutch" },
319 { "nn", "Norwegian Nynorsk" },
320 { "no", "Norwegian" },
321 { "nr", "South Ndebele" },
322 { "nv", "Navajo" },
323 { "ny", "Chichewa" },
324 { "oc", "Occitan" },
325 { "oj", "Ojibwa" },
326 { "om", "Oromo" },
327 { "or", "Oriya" },
328 { "os", "Ossetian" },
329 { "pa", "Panjabi" },
330 { "pi", "Pāli" },
331 { "pl", "Polish" },
332 { "ps", "Pashto" },
333 { "pt", "Portuguese" },
334 { "qu", "Quechua" },
335 { "rm", "Romansh" },
336 { "rn", "Kirundi" },
337 { "ro", "Romanian" },
338 { "ru", "Russian" },
339 { "rw", "Kinyarwanda" },
340 { "sa", "Sanskrit" },
341 { "sc", "Sardinian" },
342 { "sd", "Sindhi" },
343 { "se", "Northern Sami" },
344 { "sg", "Sango" },
345 { "si", "Sinhalese" },
346 { "sk", "Slovak" },
347 { "sl", "Slovene" },
348 { "sm", "Samoan" },
349 { "sn", "Shona" },
350 { "so", "Somali" },
351 { "sq", "Albanian" },
352 { "sr", "Serbian" },
353 { "ss", "Swati" },
354 { "st", "Sotho" },
355 { "su", "Sundanese" },
356 { "sv", "Swedish" },
357 { "sw", "Swahili" },
358 { "ta", "Tamil" },
359 { "te", "Telugu" },
360 { "tg", "Tajik" },
361 { "th", "Thai" },
362 { "ti", "Tigrinya" },
363 { "tk", "Turkmen" },
364 { "tl", "Tagalog" },
365 { "tn", "Tswana" },
366 { "to", "Tonga" },
367 { "tr", "Turkish" },
368 { "ts", "Tsonga" },
369 { "tt", "Tatar" },
370 { "tw", "Twi" },
371 { "ty", "Tahitian" },
372 { "ug", "Uighur" },
373 { "uk", "Ukrainian" },
374 { "ur", "Urdu" },
375 { "uz", "Uzbek" },
376 { "ve", "Venda" },
377 { "vi", "Viêt Namese" },
378 { "vo", "Volapük" },
379 { "wa", "Walloon" },
380 { "wo", "Wolof" },
381 { "xh", "Xhosa" },
382 { "yi", "Yiddish" },
383 { "yo", "Yoruba" },
384 { "za", "Zhuang" },
385 { "zh", "Chinese" },
386 { "zu", "Zulu" }
387
388 };
389
390
391 static GtkWidget *pref_list_create(void);
392
393
394 static gint
395 ui_language_combobox_compare_func (GtkTreeModel *model, GtkTreeIter *a, GtkTreeIter *b, gpointer userdata)
396 {
397 gint retval = 0;
398 gchar *code1, *code2;
399 gchar *name1, *name2;
400
401 gtk_tree_model_get(model, a, 0, &code1, 1, &name1, -1);
402 gtk_tree_model_get(model, b, 0, &code2, 1, &name2, -1);
403
404 //keep system laguage on top
405 if(code1 == NULL) name1 = NULL;
406 if(code2 == NULL) name2 = NULL;
407
408 retval = hb_string_utf8_compare(name1, name2);
409
410 g_free(name2);
411 g_free(name1);
412
413 return retval;
414 }
415
416
417 static gchar *languagename_get(const gchar *locale)
418 {
419 guint i;
420
421 for (i = 0; i < G_N_ELEMENTS (languagenames); i++)
422 {
423 if( g_ascii_strncasecmp(locale, languagenames[i].locale, -1) == 0 )
424 return languagenames[i].name;
425 }
426
427 return NULL;
428 }
429
430
431 static const gchar *
432 ui_language_combobox_get_name(const gchar *locale)
433 {
434 const gchar *lang;
435
436 DB( g_print("[ui_language_combobox_get_name]\n") );
437
438 // A locale directory name is typically of the form language[_territory]
439 lang = languagename_get (locale);
440 if (! lang)
441 {
442 const gchar *delimiter = strchr (locale, '_'); // strip off the territory suffix
443
444 if (delimiter)
445 {
446 gchar *copy = g_strndup (locale, delimiter - locale);
447 lang = languagename_get (copy);
448 g_free (copy);
449 }
450
451 if(! lang)
452 {
453 g_warning(" locale name not found '%s'", locale);
454 lang = locale;
455 }
456
457 }
458
459 return lang;
460 }
461
462
463 static void
464 ui_language_combobox_populate(GtkWidget *combobox)
465 {
466 GtkTreeModel *model;
467 GtkTreeIter iter;
468
469 model = gtk_combo_box_get_model(GTK_COMBO_BOX(combobox));
470 gtk_list_store_append (GTK_LIST_STORE(model), &iter);
471 gtk_list_store_set (GTK_LIST_STORE(model), &iter,
472 0, NULL,
473 1, _("System Language"),
474 -1);
475
476 GDir *dir = g_dir_open (homebank_app_get_locale_dir (), 0, NULL);
477 const gchar *dirname;
478
479 if (! dir)
480 return;
481
482 while ((dirname = g_dir_read_name (dir)) != NULL)
483 {
484 gchar *filename = g_build_filename (homebank_app_get_locale_dir (),
485 dirname,
486 "LC_MESSAGES",
487 GETTEXT_PACKAGE ".mo",
488 NULL);
489 //DB( g_print("- seek for '%s'\n", filename) );
490 if (g_file_test (filename, G_FILE_TEST_EXISTS))
491 {
492 const gchar *lang;
493 gchar *label;
494
495 gtk_list_store_append (GTK_LIST_STORE(model), &iter);
496
497 lang = ui_language_combobox_get_name(dirname);
498 label = g_strdup_printf ("%s [%s]", lang, dirname);
499
500 gtk_list_store_set (GTK_LIST_STORE(model), &iter,
501 0, dirname,
502 1, label,
503 -1);
504 g_free(label);
505
506 }
507 g_free (filename);
508
509 }
510 g_dir_close (dir);
511
512 gtk_tree_sortable_set_sort_column_id(GTK_TREE_SORTABLE(model), GTK_TREE_SORTABLE_DEFAULT_SORT_COLUMN_ID, GTK_SORT_ASCENDING);
513
514
515 }
516
517
518 static GtkWidget *
519 ui_language_combobox_new(GtkWidget *label)
520 {
521 GtkListStore *store;
522 GtkWidget *combobox;
523 GtkCellRenderer *renderer;
524
525 store = gtk_list_store_new (2,
526 G_TYPE_STRING,
527 G_TYPE_STRING
528 );
529 gtk_tree_sortable_set_default_sort_func(GTK_TREE_SORTABLE(store), ui_language_combobox_compare_func, NULL, NULL);
530
531 combobox = gtk_combo_box_new_with_model(GTK_TREE_MODEL(store));
532 renderer = gtk_cell_renderer_text_new ();
533 gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (combobox), renderer, TRUE);
534 gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (combobox), renderer, "text", 1, NULL);
535
536 gtk_combo_box_set_id_column( GTK_COMBO_BOX(combobox), 0);
537
538 g_object_unref(store);
539
540 if(label)
541 gtk_label_set_mnemonic_widget (GTK_LABEL(label), combobox);
542
543 ui_language_combobox_populate(combobox);
544
545 gtk_combo_box_set_active(GTK_COMBO_BOX(combobox), 0);
546
547 return combobox;
548 }
549
550
551 /* = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =*/
552 /* = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =*/
553 /* = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =*/
554
555 static gint ui_euro_combobox_id_to_active(gint id)
556 {
557 guint i, retval;
558
559 DB( g_print("\n[ui-pref] ui_euro_combobox_id_to_active\n") );
560
561 retval = 0;
562 for (i = 0; i < G_N_ELEMENTS (euro_params); i++)
563 {
564 if( euro_params[i].id == id )
565 {
566 retval = i;
567 DB( g_print("- id (country)=%d => %d - %s\n", id, i, euro_params[i].name) );
568 break;
569 }
570 }
571
572 return retval;
573 }
574
575
576
577 static gint ui_euro_combobox_active_to_id(gint active)
578 {
579 gint id;
580
581 DB( g_print("\n[ui-pref] ui_euro_combobox_active_to_id\n") );
582
583 DB( g_print("- to %d\n", active) );
584
585 id = 0;
586 if( active < (gint)G_N_ELEMENTS (euro_params) )
587 {
588 id = euro_params[active].id;
589 DB( g_print("- id (country)=%d '%s'\n", id, euro_params[active].name) );
590 }
591 return id;
592 }
593
594
595 static GtkWidget *ui_euro_combobox_new(GtkWidget *label)
596 {
597 GtkWidget *combobox;
598 guint i;
599
600 DB( g_print("\n[ui-pref] make euro preset\n") );
601
602 combobox = gtk_combo_box_text_new();
603 for (i = 0; i < G_N_ELEMENTS (euro_params); i++)
604 {
605 gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(combobox), euro_params[i].name);
606 }
607 gtk_combo_box_set_active(GTK_COMBO_BOX(combobox), 0);
608
609 if(label)
610 gtk_label_set_mnemonic_widget (GTK_LABEL(label), combobox);
611
612 return combobox;
613 }
614
615
616 static void defpref_pathselect(GtkWidget *widget, gpointer user_data)
617 {
618 struct defpref_data *data;
619 gint type = GPOINTER_TO_INT(user_data);
620 gchar **path;
621 gchar *title;
622 GtkWidget *entry;
623 gboolean r;
624
625 DB( g_print("\n[ui-pref] path select\n") );
626
627 data = g_object_get_data(G_OBJECT(gtk_widget_get_ancestor(widget, GTK_TYPE_WINDOW)), "inst_data");
628
629 switch( type )
630 {
631 case 1:
632 path = &PREFS->path_hbfile;
633 entry = data->ST_path_hbfile;
634 title = _("Choose a default HomeBank files folder");
635 break;
636 case 2:
637 path = &PREFS->path_import;
638 entry = data->ST_path_import;
639 title = _("Choose a default import folder");
640 break;
641 case 3:
642 path = &PREFS->path_export;
643 entry = data->ST_path_export;
644 title = _("Choose a default export folder");
645 break;
646 default:
647 return;
648 }
649
650 DB( g_print(" - hbfile %p %s at %p\n" , PREFS->path_hbfile, PREFS->path_hbfile, &PREFS->path_hbfile) );
651 DB( g_print(" - import %p %s at %p\n" , PREFS->path_import, PREFS->path_import, &PREFS->path_import) );
652 DB( g_print(" - export %p %s at %p\n" , PREFS->path_export, PREFS->path_export, &PREFS->path_export) );
653
654
655 DB( g_print(" - before: %s %p\n" , *path, path) );
656
657 r = ui_file_chooser_folder(GTK_WINDOW(gtk_widget_get_ancestor(widget, GTK_TYPE_WINDOW)), title, path);
658
659
660 DB( g_print(" - after: %s\n", *path) );
661
662 if( r == TRUE )
663 gtk_entry_set_text(GTK_ENTRY(entry), *path);
664
665
666 }
667
668
669 /*
670 ** update the date sample label
671 */
672 static void defpref_date_sample(GtkWidget *widget, gpointer user_data)
673 {
674 struct defpref_data *data;
675 gchar buffer[256];
676 const gchar *fmt;
677 GDate *date;
678
679 DB( g_print("\n[ui-pref] date sample\n") );
680
681 data = g_object_get_data(G_OBJECT(gtk_widget_get_ancestor(widget, GTK_TYPE_WINDOW)), "inst_data");
682
683 fmt = gtk_entry_get_text(GTK_ENTRY(data->ST_datefmt));
684 date = g_date_new_julian (GLOBALS->today);
685 g_date_strftime (buffer, 256-1, fmt, date);
686 g_date_free(date);
687
688 gtk_label_set_text(GTK_LABEL(data->LB_date), buffer);
689
690 }
691
692
693 /*
694 ** update the number sample label
695 */
696 static void defpref_numbereuro_sample(GtkWidget *widget, gpointer user_data)
697 {
698 struct defpref_data *data;
699 Currency cur;
700 gchar formatd_buf[G_ASCII_DTOSTR_BUF_SIZE];
701 gchar buf[128];
702
703 DB( g_print("\n[ui-pref] number sample\n") );
704
705 data = g_object_get_data(G_OBJECT(gtk_widget_get_ancestor(widget, GTK_TYPE_WINDOW)), "inst_data");
706
707 cur.symbol = (gchar *)gtk_entry_get_text(GTK_ENTRY(data->ST_euro_symbol));
708 cur.sym_prefix = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(data->CM_euro_isprefix));
709 cur.decimal_char = (gchar *)gtk_entry_get_text(GTK_ENTRY(data->ST_euro_decimalchar));
710 cur.grouping_char = (gchar *)gtk_entry_get_text(GTK_ENTRY(data->ST_euro_groupingchar));
711 cur.frac_digits = gtk_spin_button_get_value(GTK_SPIN_BUTTON(data->NB_euro_fracdigits));
712
713 da_cur_initformat (&cur);
714
715 DB( g_print("fmt: %s\n", cur.format) );
716
717 g_ascii_formatd(formatd_buf, sizeof (formatd_buf), cur.format, HB_NUMBER_SAMPLE);
718 hb_str_formatd(buf, 127, formatd_buf, &cur, TRUE);
719
720 gtk_label_set_text(GTK_LABEL(data->LB_numbereuro), buf);
721
722 }
723
724
725 /*
726 ** enable/disable euro
727 */
728 static void defpref_eurotoggle(GtkWidget *widget, gpointer user_data)
729 {
730 struct defpref_data *data;
731 gboolean sensitive;
732
733 DB( g_print("\n[ui-pref] euro toggle\n") );
734
735 data = g_object_get_data(G_OBJECT(gtk_widget_get_ancestor(widget, GTK_TYPE_WINDOW)), "inst_data");
736
737 sensitive = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(data->CM_euro_enable));
738
739 gtk_widget_set_sensitive(data->GRP_currency , sensitive);
740 gtk_widget_set_sensitive(data->GRP_rate , sensitive);
741 gtk_widget_set_sensitive(data->GRP_format , sensitive);
742 }
743
744
745 /*
746 ** set euro value widget from a country
747 */
748 static void defpref_eurosetcurrency(GtkWidget *widget, gint country)
749 {
750 struct defpref_data *data;
751 EuroParams *euro;
752 gchar *buf;
753 gint active;
754
755 DB( g_print("\n[ui-pref] eurosetcurrency\n") );
756
757 data = g_object_get_data(G_OBJECT(gtk_widget_get_ancestor(widget, GTK_TYPE_WINDOW)), "inst_data");
758
759 active = ui_euro_combobox_id_to_active(country);
760 euro = &euro_params[active];
761 buf = g_strdup_printf("%s - %s", euro->iso, euro->name);
762 gtk_label_set_markup(GTK_LABEL(data->ST_euro_country), buf);
763 g_free(buf);
764 }
765
766
767 /*
768 ** set euro value widget from a country
769 */
770 static void defpref_europreset(GtkWidget *widget, gpointer user_data)
771 {
772 struct defpref_data *data;
773 gint active;
774
775 DB( g_print("\n[ui-pref] euro preset\n") );
776
777 data = g_object_get_data(G_OBJECT(gtk_widget_get_ancestor(widget, GTK_TYPE_WINDOW)), "inst_data");
778
779 active = gtk_combo_box_get_active (GTK_COMBO_BOX(data->CY_euro_preset));
780 data->country = ui_euro_combobox_active_to_id (active);;
781
782 defpref_eurosetcurrency(widget, data->country);
783
784 gtk_spin_button_set_value(GTK_SPIN_BUTTON(data->NB_euro_value), euro_params[active].value);
785
786 gtk_spin_button_set_value(GTK_SPIN_BUTTON(data->NB_euro_fracdigits), euro_params[active].frac_digits);
787
788 gtk_entry_set_text(GTK_ENTRY(data->ST_euro_symbol) , euro_params[active].symbol);
789 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(data->CM_euro_isprefix), euro_params[active].sym_prefix);
790 gtk_entry_set_text(GTK_ENTRY(data->ST_euro_decimalchar) , euro_params[active].decimal_char);
791 gtk_entry_set_text(GTK_ENTRY(data->ST_euro_groupingchar), euro_params[active].grouping_char);
792
793 }
794
795
796 static void defpref_colortoggle(GtkWidget *widget, gpointer user_data)
797 {
798 struct defpref_data *data;
799 gboolean sensitive;
800
801 DB( g_print("\n[ui-pref] color toggle\n") );
802
803 data = g_object_get_data(G_OBJECT(gtk_widget_get_ancestor(widget, GTK_TYPE_WINDOW)), "inst_data");
804
805 sensitive = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(data->CM_custom_colors));
806
807 gtk_widget_set_sensitive(data->GR_colors , sensitive);
808
809 }
810
811
812 /*
813 ** set preset colors for amount display
814 */
815 static void defpref_colorpreset(GtkWidget *widget, gpointer user_data)
816 {
817 struct defpref_data *data;
818 GdkRGBA rgba;
819 gint preset;
820 gchar *expcol, *inccol, *wrncol;
821
822 DB( g_print("\n[ui-pref] color preset\n") );
823
824 data = g_object_get_data(G_OBJECT(gtk_widget_get_ancestor(widget, GTK_TYPE_WINDOW)), "inst_data");
825
826 preset = gtk_combo_box_get_active(GTK_COMBO_BOX(data->CY_colors));
827
828 switch( preset)
829 {
830 case 1: //light
831 expcol = LIGHT_EXP_COLOR;
832 inccol = LIGHT_INC_COLOR;
833 wrncol = LIGHT_WARN_COLOR;
834 break;
835
836 case 2: //medium
837 expcol = MEDIUM_EXP_COLOR;
838 inccol = MEDIUM_INC_COLOR;
839 wrncol = MEDIUM_WARN_COLOR;
840 break;
841
842 case 3: //dark
843 default:
844 expcol = DEFAULT_EXP_COLOR;
845 inccol = DEFAULT_INC_COLOR;
846 wrncol = DEFAULT_WARN_COLOR;
847 break;
848 }
849
850
851 gdk_rgba_parse(&rgba, expcol);
852 gtk_color_chooser_set_rgba(GTK_COLOR_CHOOSER(data->CP_exp_color), &rgba);
853
854 gdk_rgba_parse(&rgba, inccol);
855 gtk_color_chooser_set_rgba(GTK_COLOR_CHOOSER(data->CP_inc_color), &rgba);
856
857 gdk_rgba_parse(&rgba, wrncol);
858 gtk_color_chooser_set_rgba(GTK_COLOR_CHOOSER(data->CP_warn_color), &rgba);
859
860
861 }
862
863
864 static void defpref_color_scheme_changed(GtkWidget *widget, gpointer user_data)
865 {
866 struct defpref_data *data;
867
868 DB( g_print("\n[ui-pref] color scheme chnaged\n") );
869
870 data = g_object_get_data(G_OBJECT(gtk_widget_get_ancestor(widget, GTK_TYPE_WINDOW)), "inst_data");
871
872 gtk_widget_queue_draw (data->DA_colors);
873
874 }
875
876
877
878
879 /*
880 static void setGdkColor_from_RGB(GdkColor *color, guint32 value)
881 {
882 guint tmp;
883
884 tmp = value >> 16;
885 color->red = tmp | tmp<<8;
886
887 tmp = value >> 8 & 0xFF;
888 color->green = tmp | tmp<<8;
889
890 tmp = value & 0xFF;
891 color->blue = tmp | tmp<<8;
892 }
893 */
894
895
896 /*
897 ** set :: fill in widgets from PREFS structure
898 */
899
900 static void defpref_set(struct defpref_data *data)
901 {
902 GdkRGBA rgba;
903
904 DB( g_print("\n[ui-pref] set\n") );
905
906 // general
907 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(data->CM_show_splash), PREFS->showsplash);
908 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(data->CM_load_last), PREFS->loadlast);
909 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(data->CM_append_scheduled), PREFS->appendscheduled);
910 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(data->CM_do_update_currency), PREFS->do_update_currency);
911 gtk_combo_box_set_active(GTK_COMBO_BOX(data->CY_daterange_wal), PREFS->date_range_wal);
912 gtk_spin_button_set_value(GTK_SPIN_BUTTON(data->NB_fiscyearday), PREFS->fisc_year_day );
913 gtk_combo_box_set_active(GTK_COMBO_BOX(data->CY_fiscyearmonth), PREFS->fisc_year_month - 1);
914
915 // files/backup
916 gtk_entry_set_text(GTK_ENTRY(data->ST_path_hbfile), PREFS->path_hbfile);
917
918
919
920 // interface
921 if(PREFS->language != NULL)
922 gtk_combo_box_set_active_id(GTK_COMBO_BOX(data->CY_language), PREFS->language);
923 else
924 gtk_combo_box_set_active (GTK_COMBO_BOX(data->CY_language), 0);
925 gtk_combo_box_set_active(GTK_COMBO_BOX(data->CY_toolbar), PREFS->toolbar_style);
926 //gtk_spin_button_set_value(GTK_SPIN_BUTTON(data->NB_image_size), PREFS->image_size);
927
928 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(data->CM_custom_colors), PREFS->custom_colors);
929 gdk_rgba_parse(&rgba, PREFS->color_exp);
930 gtk_color_chooser_set_rgba(GTK_COLOR_CHOOSER(data->CP_exp_color), &rgba);
931 gdk_rgba_parse(&rgba, PREFS->color_inc);
932 gtk_color_chooser_set_rgba(GTK_COLOR_CHOOSER(data->CP_inc_color), &rgba);
933 gdk_rgba_parse(&rgba, PREFS->color_warn);
934 gtk_color_chooser_set_rgba(GTK_COLOR_CHOOSER(data->CP_warn_color), &rgba);
935 //gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(data->CM_ruleshint), PREFS->rules_hint);
936 gtk_combo_box_set_active(GTK_COMBO_BOX(data->CY_gridlines), PREFS->grid_lines);
937
938 // transactions
939 gtk_combo_box_set_active(GTK_COMBO_BOX(data->CY_daterange_txn), PREFS->date_range_txn);
940 gtk_spin_button_set_value(GTK_SPIN_BUTTON(data->ST_datefuture_nbdays), PREFS->date_future_nbdays);
941 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(data->CM_hide_reconciled), PREFS->hidereconciled);
942 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(data->CM_show_remind), PREFS->showremind);
943 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(data->CM_herit_date), PREFS->heritdate);
944
945 // display format
946 gtk_entry_set_text(GTK_ENTRY(data->ST_datefmt), PREFS->date_format);
947 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(data->CM_unitismile), PREFS->vehicle_unit_ismile);
948 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(data->CM_unitisgal), PREFS->vehicle_unit_isgal);
949
950 // import/export
951 gtk_combo_box_set_active(GTK_COMBO_BOX(data->CY_dtex_datefmt), PREFS->dtex_datefmt);
952 gtk_combo_box_set_active(GTK_COMBO_BOX(data->CY_dtex_ofxname), PREFS->dtex_ofxname);
953 gtk_combo_box_set_active(GTK_COMBO_BOX(data->CY_dtex_ofxmemo), PREFS->dtex_ofxmemo);
954 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(data->CM_dtex_qifmemo), PREFS->dtex_qifmemo);
955 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(data->CM_dtex_qifswap), PREFS->dtex_qifswap);
956 gtk_entry_set_text(GTK_ENTRY(data->ST_path_import), PREFS->path_import);
957 gtk_entry_set_text(GTK_ENTRY(data->ST_path_export), PREFS->path_export);
958
959 // report
960 gtk_combo_box_set_active(GTK_COMBO_BOX(data->CY_daterange_rep), PREFS->date_range_rep);
961 gtk_combo_box_set_active(GTK_COMBO_BOX(data->CY_color_scheme), PREFS->report_color_scheme);
962 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(data->CM_stat_byamount), PREFS->stat_byamount);
963 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(data->CM_stat_showrate), PREFS->stat_showrate);
964 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(data->CM_stat_showdetail), PREFS->stat_showdetail);
965 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(data->CM_budg_showdetail), PREFS->budg_showdetail);
966
967 /* euro */
968 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(data->CM_euro_enable), PREFS->euro_active);
969 //gtk_combo_box_set_active(GTK_COMBO_BOX(data->CY_euro_preset), PREFS->euro_country);
970 data->country = PREFS->euro_country;
971 defpref_eurosetcurrency(data->window, data->country);
972 gtk_spin_button_set_value(GTK_SPIN_BUTTON(data->NB_euro_value), PREFS->euro_value);
973 ui_gtk_entry_set_text(data->ST_euro_symbol, PREFS->minor_cur.symbol);
974 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(data->CM_euro_isprefix), PREFS->minor_cur.sym_prefix);
975 ui_gtk_entry_set_text(data->ST_euro_decimalchar, PREFS->minor_cur.decimal_char);
976 ui_gtk_entry_set_text(data->ST_euro_groupingchar, PREFS->minor_cur.grouping_char);
977 gtk_spin_button_set_value(GTK_SPIN_BUTTON(data->NB_euro_fracdigits), PREFS->minor_cur.frac_digits);
978
979 //gtk_entry_set_text(GTK_ENTRY(data->ST_euro_symbol), PREFS->euro_symbol);
980 //gtk_spin_button_set_value(GTK_SPIN_BUTTON(data->NB_euro_nbdec), PREFS->euro_nbdec);
981 //gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(data->CM_euro_thsep), PREFS->euro_thsep);
982 }
983
984
985 /*
986 ** get :: fill PREFS structure from widgets
987 */
988 #define RGBA_TO_INT(x) (int)(x*255)
989
990 static gchar *gdk_rgba_to_hex(GdkRGBA *rgba)
991 {
992 return g_strdup_printf("#%02x%02x%02x", RGBA_TO_INT(rgba->red), RGBA_TO_INT(rgba->green), RGBA_TO_INT(rgba->blue));
993 }
994
995
996 static void defpref_get(struct defpref_data *data)
997 {
998 GdkRGBA rgba;
999 const gchar *lang;
1000
1001 DB( g_print("\n[ui-pref] get\n") );
1002
1003 // general
1004 PREFS->showsplash = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(data->CM_show_splash));
1005 PREFS->loadlast = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(data->CM_load_last));
1006 PREFS->appendscheduled = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(data->CM_append_scheduled));
1007 PREFS->do_update_currency = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(data->CM_do_update_currency));
1008 PREFS->date_range_wal = gtk_combo_box_get_active(GTK_COMBO_BOX(data->CY_daterange_wal));
1009 PREFS->fisc_year_day = gtk_spin_button_get_value(GTK_SPIN_BUTTON(data->NB_fiscyearday));
1010 PREFS->fisc_year_month = 1 + gtk_combo_box_get_active(GTK_COMBO_BOX(data->CY_fiscyearmonth));
1011
1012 // files/backup
1013 g_free(PREFS->path_hbfile);
1014 PREFS->path_hbfile = g_strdup(gtk_entry_get_text(GTK_ENTRY(data->ST_path_hbfile)));
1015
1016
1017
1018 g_free(PREFS->language);
1019 PREFS->language = NULL;
1020 lang = gtk_combo_box_get_active_id(GTK_COMBO_BOX(data->CY_language));
1021 if(lang != NULL)
1022 {
1023 PREFS->language = g_strdup(lang);
1024 }
1025
1026 PREFS->toolbar_style = gtk_combo_box_get_active(GTK_COMBO_BOX(data->CY_toolbar));
1027 //PREFS->image_size = gtk_spin_button_get_value(GTK_SPIN_BUTTON(data->NB_image_size));
1028
1029 PREFS->custom_colors = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(data->CM_custom_colors));
1030 gtk_color_chooser_get_rgba(GTK_COLOR_CHOOSER(data->CP_exp_color), &rgba);
1031 g_free(PREFS->color_exp);
1032 PREFS->color_exp = gdk_rgba_to_hex(&rgba);
1033 gtk_color_chooser_get_rgba(GTK_COLOR_CHOOSER(data->CP_inc_color), &rgba);
1034 g_free(PREFS->color_inc);
1035 PREFS->color_inc = gdk_rgba_to_hex(&rgba);
1036 gtk_color_chooser_get_rgba(GTK_COLOR_CHOOSER(data->CP_warn_color), &rgba);
1037 g_free(PREFS->color_warn);
1038 PREFS->color_warn = gdk_rgba_to_hex(&rgba);
1039 //PREFS->rules_hint = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(data->CM_ruleshint));
1040 PREFS->grid_lines = gtk_combo_box_get_active(GTK_COMBO_BOX(data->CY_gridlines));
1041 //list_txn_colpref_get(GTK_TREE_VIEW(data->LV_opecolumns), PREFS->lst_ope_columns);
1042
1043 // transaction
1044 PREFS->date_range_txn = gtk_combo_box_get_active(GTK_COMBO_BOX(data->CY_daterange_txn));
1045 PREFS->date_future_nbdays = gtk_spin_button_get_value(GTK_SPIN_BUTTON(data->ST_datefuture_nbdays));
1046 PREFS->hidereconciled = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(data->CM_hide_reconciled));
1047 PREFS->showremind = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(data->CM_show_remind));
1048 PREFS->heritdate = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(data->CM_herit_date));
1049
1050 // display format
1051 g_free(PREFS->date_format);
1052 PREFS->date_format = g_strdup(gtk_entry_get_text(GTK_ENTRY(data->ST_datefmt)));
1053 PREFS->vehicle_unit_ismile = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(data->CM_unitismile));
1054 PREFS->vehicle_unit_isgal = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(data->CM_unitisgal));
1055
1056 // import/export
1057 PREFS->dtex_datefmt = gtk_combo_box_get_active(GTK_COMBO_BOX(data->CY_dtex_datefmt));
1058 PREFS->dtex_ofxname = gtk_combo_box_get_active(GTK_COMBO_BOX(data->CY_dtex_ofxname));
1059 PREFS->dtex_ofxmemo = gtk_combo_box_get_active(GTK_COMBO_BOX(data->CY_dtex_ofxmemo));
1060 PREFS->dtex_qifmemo = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(data->CM_dtex_qifmemo));
1061 PREFS->dtex_qifswap = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(data->CM_dtex_qifswap));
1062 ui_gtk_entry_replace_text(data->ST_path_import, &PREFS->path_import);
1063 ui_gtk_entry_replace_text(data->ST_path_export, &PREFS->path_export);
1064
1065 // report
1066 PREFS->date_range_rep = gtk_combo_box_get_active(GTK_COMBO_BOX(data->CY_daterange_rep));
1067 PREFS->report_color_scheme = gtk_combo_box_get_active(GTK_COMBO_BOX(data->CY_color_scheme));
1068 PREFS->stat_byamount = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(data->CM_stat_byamount));
1069 PREFS->stat_showrate = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(data->CM_stat_showrate));
1070 PREFS->stat_showdetail = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(data->CM_stat_showdetail));
1071 PREFS->budg_showdetail = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(data->CM_budg_showdetail));
1072
1073 // euro minor
1074 PREFS->euro_active = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(data->CM_euro_enable));
1075 PREFS->euro_country = data->country;
1076 PREFS->euro_value = gtk_spin_button_get_value(GTK_SPIN_BUTTON(data->NB_euro_value));
1077 //strcpy(PREFS->euro_symbol, gtk_entry_get_text(GTK_ENTRY(data->ST_euro_symbol)));
1078 //PREFS->euro_nbdec = gtk_spin_button_get_value(GTK_SPIN_BUTTON(data->NB_euro_nbdec));
1079 //PREFS->euro_thsep = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(data->CM_euro_thsep));
1080 ui_gtk_entry_replace_text(data->ST_euro_symbol, &PREFS->minor_cur.symbol);
1081 PREFS->minor_cur.sym_prefix = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(data->CM_euro_isprefix));
1082 ui_gtk_entry_replace_text(data->ST_euro_decimalchar, &PREFS->minor_cur.decimal_char);
1083 ui_gtk_entry_replace_text(data->ST_euro_groupingchar, &PREFS->minor_cur.grouping_char);
1084 PREFS->minor_cur.frac_digits = gtk_spin_button_get_value(GTK_SPIN_BUTTON(data->NB_euro_fracdigits));
1085 //PREFS->chart_legend = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(data->CM_chartlegend));
1086
1087 list_ext_colpref_get(GTK_TREE_VIEW(data->PI_plugin_columns), &(PREFS->ext_whitelist));
1088 }
1089
1090
1091 static GtkWidget *defpref_page_import (struct defpref_data *data)
1092 {
1093 GtkWidget *content_grid, *group_grid, *hbox, *label, *widget;
1094 gint crow, row;
1095
1096 content_grid = gtk_grid_new();
1097 gtk_grid_set_row_spacing (GTK_GRID (content_grid), SPACING_LARGE);
1098 gtk_orientable_set_orientation(GTK_ORIENTABLE(content_grid), GTK_ORIENTATION_VERTICAL);
1099
1100 crow = 0;
1101 // group :: Date options
1102 group_grid = gtk_grid_new ();
1103 gtk_grid_set_row_spacing (GTK_GRID (group_grid), SPACING_SMALL);
1104 gtk_grid_set_column_spacing (GTK_GRID (group_grid), SPACING_MEDIUM);
1105 gtk_grid_attach (GTK_GRID (content_grid), group_grid, 0, crow++, 1, 1);
1106
1107 label = make_label_group(_("Date options"));
1108 gtk_grid_attach (GTK_GRID (group_grid), label, 0, 0, 3, 1);
1109
1110 row = 1;
1111 label = make_label_widget(_("Date order:"));
1112 //----------------------------------------- l, r, t, b
1113 gtk_grid_attach (GTK_GRID (group_grid), label, 1, row, 1, 1);
1114 widget = make_cycle(label, CYA_IMPORT_DATEORDER);
1115 data->CY_dtex_datefmt = widget;
1116 //gtk_grid_attach (GTK_GRID (group_grid), data->CY_option[FILTER_DATE], 1, 2, row, row+1);
1117 gtk_grid_attach (GTK_GRID (group_grid), widget, 2, row, 1, 1);
1118
1119
1120 // group :: OFX/QFX options
1121 group_grid = gtk_grid_new ();
1122 gtk_grid_set_row_spacing (GTK_GRID (group_grid), SPACING_SMALL);
1123 gtk_grid_set_column_spacing (GTK_GRID (group_grid), SPACING_MEDIUM);
1124 gtk_grid_attach (GTK_GRID (content_grid), group_grid, 0, crow++, 1, 1);
1125
1126 label = make_label_group(_("OFX/QFX options"));
1127 gtk_grid_attach (GTK_GRID (group_grid), label, 0, 0, 3, 1);
1128
1129 row = 1;
1130 label = make_label_widget(_("_Name field:"));
1131 //----------------------------------------- l, r, t, b
1132 gtk_grid_attach (GTK_GRID (group_grid), label, 1, row, 1, 1);
1133 widget = make_cycle(label, CYA_IMPORT_OFXNAME);
1134 data->CY_dtex_ofxname = widget;
1135 //gtk_grid_attach (GTK_GRID (group_grid), data->CY_option[FILTER_DATE], 1, 2, row, row+1);
1136 gtk_grid_attach (GTK_GRID (group_grid), widget, 2, row, 1, 1);
1137
1138 row++;
1139 label = make_label_widget(_("_Memo field:"));
1140 //----------------------------------------- l, r, t, b
1141 gtk_grid_attach (GTK_GRID (group_grid), label, 1, row, 1, 1);
1142 widget = make_cycle(label, CYA_IMPORT_OFXMEMO);
1143 data->CY_dtex_ofxmemo = widget;
1144 //gtk_grid_attach (GTK_GRID (group_grid), data->CY_option[FILTER_DATE], 1, 2, row, row+1);
1145 gtk_grid_attach (GTK_GRID (group_grid), widget, 2, row, 1, 1);
1146
1147 // group :: QIF options
1148 group_grid = gtk_grid_new ();
1149 gtk_grid_set_row_spacing (GTK_GRID (group_grid), SPACING_SMALL);
1150 gtk_grid_set_column_spacing (GTK_GRID (group_grid), SPACING_MEDIUM);
1151 gtk_grid_attach (GTK_GRID (content_grid), group_grid, 0, crow++, 1, 1);
1152
1153 label = make_label_group(_("QIF options"));
1154 gtk_grid_attach (GTK_GRID (group_grid), label, 0, 0, 3, 1);
1155
1156 row = 1;
1157 label = make_label_widget(_("Memos:"));
1158 gtk_grid_attach (GTK_GRID (group_grid), label, 1, row, 1, 1);
1159 widget = gtk_check_button_new_with_mnemonic (_("_Import"));
1160 data->CM_dtex_qifmemo = widget;
1161 gtk_grid_attach (GTK_GRID (group_grid), widget, 2, row, 1, 1);
1162 widget = gtk_check_button_new_with_mnemonic (_("_Swap with payees"));
1163 data->CM_dtex_qifswap = widget;
1164 gtk_grid_attach (GTK_GRID (group_grid), widget, 3, row, 1, 1);
1165
1166
1167 // group :: Files folder
1168 group_grid = gtk_grid_new ();
1169 gtk_grid_set_row_spacing (GTK_GRID (group_grid), SPACING_SMALL);
1170 gtk_grid_set_column_spacing (GTK_GRID (group_grid), SPACING_MEDIUM);
1171 gtk_grid_attach (GTK_GRID (content_grid), group_grid, 0, crow++, 1, 1);
1172
1173 label = make_label_group(_("Files folder"));
1174 gtk_grid_attach (GTK_GRID (group_grid), label, 0, 0, 3, 1);
1175
1176 row = 1;
1177 label = make_label_widget(_("_Import:"));
1178 //----------------------------------------- l, r, t, b
1179 gtk_grid_attach (GTK_GRID (group_grid), label, 1, row, 1, 1);
1180
1181 hbox = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0);
1182 gtk_widget_set_hexpand (hbox, TRUE);
1183 gtk_grid_attach (GTK_GRID (group_grid), hbox, 2, row, 1, 1);
1184
1185 widget = make_string(label);
1186 data->ST_path_import = widget;
1187 gtk_style_context_add_class (gtk_widget_get_style_context (GTK_WIDGET(widget)), GTK_STYLE_CLASS_LINKED);
1188 gtk_box_pack_start (GTK_BOX (hbox), widget, TRUE, TRUE, 0);
1189
1190 //widget = gtk_button_new_with_label("...");
1191 widget = gtk_button_new_from_icon_name(ICONNAME_FOLDER, GTK_ICON_SIZE_BUTTON);
1192 data->BT_path_import = widget;
1193 gtk_box_pack_start (GTK_BOX (hbox), widget, FALSE, FALSE, 0);
1194
1195 row++;
1196 label = make_label_widget(_("_Export:"));
1197 //----------------------------------------- l, r, t, b
1198 gtk_grid_attach (GTK_GRID (group_grid), label, 1, row, 1, 1);
1199
1200 hbox = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0);
1201 gtk_widget_set_hexpand (hbox, TRUE);
1202 gtk_grid_attach (GTK_GRID (group_grid), hbox, 2, row, 1, 1);
1203
1204 widget = make_string(label);
1205 data->ST_path_export = widget;
1206 gtk_style_context_add_class (gtk_widget_get_style_context (GTK_WIDGET(widget)), GTK_STYLE_CLASS_LINKED);
1207 gtk_box_pack_start (GTK_BOX (hbox), widget, TRUE, TRUE, 0);
1208
1209 //widget = gtk_button_new_with_label("...");
1210 widget = gtk_button_new_from_icon_name(ICONNAME_FOLDER, GTK_ICON_SIZE_BUTTON);
1211 data->BT_path_export = widget;
1212 gtk_box_pack_start (GTK_BOX (hbox), widget, FALSE, FALSE, 0);
1213
1214 return content_grid;
1215 }
1216
1217 #define cube_dim 16
1218
1219 static gboolean
1220 draw_callback (GtkWidget *widget,
1221 cairo_t *cr,
1222 gpointer user_data)
1223 {
1224 struct defpref_data *data = user_data;
1225 gint index;
1226 GtkColorScheme scheme;
1227 gint w, h;
1228 gint i, x, y;
1229
1230 index = gtk_combo_box_get_active(GTK_COMBO_BOX(data->CY_color_scheme));
1231
1232 colorscheme_init(&scheme, index);
1233
1234 gtk_widget_get_size_request (widget, &w, &h);
1235 x = y = 0;
1236 for(i=0;i<scheme.nb_cols;i++)
1237 {
1238 cairo_user_set_rgbcol (cr, &scheme.colors[i]);
1239 cairo_rectangle(cr, x, y, cube_dim, cube_dim);
1240 cairo_fill(cr);
1241 x += 1 + cube_dim;
1242 if( i == 15 )
1243 { x = 0; y = 1 + cube_dim; }
1244 }
1245
1246 return TRUE;
1247 }
1248
1249
1250
1251 static GtkWidget *defpref_page_reports (struct defpref_data *data)
1252 {
1253 GtkWidget *content_grid, *group_grid, *label, *widget;
1254 gint crow, row;
1255
1256 content_grid = gtk_grid_new();
1257 gtk_grid_set_row_spacing (GTK_GRID (content_grid), SPACING_LARGE);
1258 gtk_orientable_set_orientation(GTK_ORIENTABLE(content_grid), GTK_ORIENTATION_VERTICAL);
1259
1260 crow = 0;
1261 // group :: Initial filter
1262 group_grid = gtk_grid_new ();
1263 gtk_grid_set_row_spacing (GTK_GRID (group_grid), SPACING_SMALL);
1264 gtk_grid_set_column_spacing (GTK_GRID (group_grid), SPACING_MEDIUM);
1265 gtk_grid_attach (GTK_GRID (content_grid), group_grid, 0, crow++, 1, 1);
1266
1267 label = make_label_group(_("Initial filter"));
1268 gtk_grid_attach (GTK_GRID (group_grid), label, 0, 0, 3, 1);
1269
1270 row = 1;
1271 label = make_label_widget(_("Date _range:"));
1272 //----------------------------------------- l, r, t, b
1273 gtk_grid_attach (GTK_GRID (group_grid), label, 1, row, 1, 1);
1274 widget = make_daterange(label, FALSE);
1275 data->CY_daterange_rep = widget;
1276 //gtk_grid_attach (GTK_GRID (group_grid), data->CY_option[FILTER_DATE], 1, 2, row, row+1);
1277 gtk_grid_attach (GTK_GRID (group_grid), widget, 2, row, 1, 1);
1278
1279 // group ::Charts options
1280 group_grid = gtk_grid_new ();
1281 gtk_grid_set_row_spacing (GTK_GRID (group_grid), SPACING_SMALL);
1282 gtk_grid_set_column_spacing (GTK_GRID (group_grid), SPACING_MEDIUM);
1283 gtk_grid_attach (GTK_GRID (content_grid), group_grid, 0, crow++, 1, 1);
1284
1285 label = make_label_group(_("Charts options"));
1286 gtk_grid_attach (GTK_GRID (group_grid), label, 0, 0, 3, 1);
1287
1288 row = 1;
1289 label = make_label_widget(_("Color scheme:"));
1290 //----------------------------------------- l, r, t, b
1291 gtk_grid_attach (GTK_GRID (group_grid), label, 1, row, 1, 1);
1292 widget = make_cycle(label, chart_colors);
1293 data->CY_color_scheme = widget;
1294 //gtk_grid_attach (GTK_GRID (group_grid), data->CY_option[FILTER_DATE], 1, 2, row, row+1);
1295 gtk_grid_attach (GTK_GRID (group_grid), widget, 2, row, 1, 1);
1296
1297 row++;
1298 widget = gtk_drawing_area_new ();
1299 data->DA_colors = widget;
1300 gtk_widget_set_size_request (widget, (1+cube_dim)*16, (1+cube_dim)*2);
1301 gtk_grid_attach (GTK_GRID (group_grid), widget, 2, row, 1, 1);
1302
1303 g_signal_connect (data->DA_colors, "draw", G_CALLBACK (draw_callback), data);
1304
1305 // group :: Statistics options
1306 group_grid = gtk_grid_new ();
1307 gtk_grid_set_row_spacing (GTK_GRID (group_grid), SPACING_SMALL);
1308 gtk_grid_set_column_spacing (GTK_GRID (group_grid), SPACING_MEDIUM);
1309 gtk_grid_attach (GTK_GRID (content_grid), group_grid, 0, crow++, 1, 1);
1310
1311 label = make_label_group(_("Statistics options"));
1312 gtk_grid_attach (GTK_GRID (group_grid), label, 0, 0, 3, 1);
1313
1314 row = 1;
1315 widget = gtk_check_button_new_with_mnemonic (_("Show by _amount"));
1316 data->CM_stat_byamount = widget;
1317 gtk_grid_attach (GTK_GRID (group_grid), widget, 1, row, 2, 1);
1318
1319 row++;
1320 widget = gtk_check_button_new_with_mnemonic (_("Show _rate column"));
1321 data->CM_stat_showrate = widget;
1322 gtk_grid_attach (GTK_GRID (group_grid), widget, 1, row, 2, 1);
1323
1324 row++;
1325 widget = gtk_check_button_new_with_mnemonic (_("Show _details"));
1326 data->CM_stat_showdetail = widget;
1327 gtk_grid_attach (GTK_GRID (group_grid), widget, 1, row, 2, 1);
1328
1329 // group :: Budget options
1330 group_grid = gtk_grid_new ();
1331 gtk_grid_set_row_spacing (GTK_GRID (group_grid), SPACING_SMALL);
1332 gtk_grid_set_column_spacing (GTK_GRID (group_grid), SPACING_MEDIUM);
1333 gtk_grid_attach (GTK_GRID (content_grid), group_grid, 0, crow++, 1, 1);
1334
1335 label = make_label_group(_("Budget options"));
1336 gtk_grid_attach (GTK_GRID (group_grid), label, 0, 0, 3, 1);
1337
1338 row = 1;
1339 widget = gtk_check_button_new_with_mnemonic (_("Show _details"));
1340 data->CM_budg_showdetail = widget;
1341 gtk_grid_attach (GTK_GRID (group_grid), widget, 1, row, 2, 1);
1342
1343 return content_grid;
1344 }
1345
1346
1347 static GtkWidget *defpref_page_euro (struct defpref_data *data)
1348 {
1349 GtkWidget *content_grid, *group_grid, *label, *widget, *expander;
1350 gint crow, row;
1351
1352 content_grid = gtk_grid_new();
1353 gtk_grid_set_row_spacing (GTK_GRID (content_grid), SPACING_LARGE);
1354 gtk_orientable_set_orientation(GTK_ORIENTABLE(content_grid), GTK_ORIENTATION_VERTICAL);
1355
1356 crow = 0;
1357 // group :: General
1358 group_grid = gtk_grid_new ();
1359 gtk_grid_set_row_spacing (GTK_GRID (group_grid), SPACING_SMALL);
1360 gtk_grid_set_column_spacing (GTK_GRID (group_grid), SPACING_MEDIUM);
1361 gtk_grid_attach (GTK_GRID (content_grid), group_grid, 0, crow++, 1, 1);
1362
1363 label = make_label_group(_("General"));
1364 gtk_grid_attach (GTK_GRID (group_grid), label, 0, 0, 3, 1);
1365
1366 row=1;
1367 widget = gtk_check_button_new_with_mnemonic (_("_Enable"));
1368 data->CM_euro_enable = widget;
1369 gtk_grid_attach (GTK_GRID (group_grid), widget, 1, row, 2, 1);
1370
1371 // group :: Currency
1372 group_grid = gtk_grid_new ();
1373 data->GRP_currency = group_grid;
1374 gtk_grid_set_row_spacing (GTK_GRID (group_grid), SPACING_SMALL);
1375 gtk_grid_set_column_spacing (GTK_GRID (group_grid), SPACING_MEDIUM);
1376 gtk_grid_attach (GTK_GRID (content_grid), group_grid, 0, crow++, 1, 1);
1377
1378 label = make_label_group(_("Currency"));
1379 gtk_grid_attach (GTK_GRID (group_grid), label, 0, 0, 4, 1);
1380
1381 row=1;
1382 widget = make_label(NULL, 0.0, 0.5);
1383 data->ST_euro_country = widget;
1384 //gtk_grid_attach (GTK_GRID (group_grid), data->CY_option[FILTER_DATE], 1, 2, row, row+1);
1385 gtk_grid_attach (GTK_GRID (group_grid), widget, 1, row, 1, 1);
1386
1387 //row++;
1388 label = make_label_widget(_("_Preset:"));
1389 //----------------------------------------- l, r, t, b
1390 gtk_grid_attach (GTK_GRID (group_grid), label, 2, row, 1, 1);
1391 widget = ui_euro_combobox_new (label);
1392 data->CY_euro_preset = widget;
1393 gtk_widget_set_margin_left (label, 2*SPACING_LARGE);
1394 //gtk_grid_attach (GTK_GRID (group_grid), data->CY_option[FILTER_DATE], 1, 2, row, row+1);
1395 gtk_grid_attach (GTK_GRID (group_grid), widget, 3, row, 1, 1);
1396
1397
1398 // group :: Exchange rate
1399 group_grid = gtk_grid_new ();
1400 data->GRP_rate = group_grid;
1401 gtk_grid_set_row_spacing (GTK_GRID (group_grid), SPACING_SMALL);
1402 gtk_grid_set_column_spacing (GTK_GRID (group_grid), SPACING_MEDIUM);
1403 gtk_grid_attach (GTK_GRID (content_grid), group_grid, 0, crow++, 1, 1);
1404
1405 label = make_label_group(_("Exchange rate"));
1406 gtk_grid_attach (GTK_GRID (group_grid), label, 0, 0, 3, 1);
1407
1408 row=1;
1409 label = make_label_widget("1 EUR _=");
1410 gtk_grid_attach (GTK_GRID (group_grid), label, 1, row, 1, 1);
1411 widget = make_exchange_rate(label);
1412 data->NB_euro_value = widget;
1413 //gtk_grid_attach (GTK_GRID (group_grid), data->CY_option[FILTER_DATE], 1, 2, row, row+1);
1414 gtk_grid_attach (GTK_GRID (group_grid), widget, 2, row, 1, 1);
1415
1416 // group :: Numbers format
1417 group_grid = gtk_grid_new ();
1418 data->GRP_format = group_grid;
1419 gtk_grid_set_row_spacing (GTK_GRID (group_grid), SPACING_SMALL);
1420 gtk_grid_set_column_spacing (GTK_GRID (group_grid), SPACING_MEDIUM);
1421 gtk_grid_attach (GTK_GRID (content_grid), group_grid, 0, crow++, 1, 1);
1422
1423 label = make_label_group(_("Format"));
1424 gtk_grid_attach (GTK_GRID (group_grid), label, 0, 0, 3, 1);
1425
1426 row = 1;
1427 widget = make_label(NULL, 0, 0.0);
1428 data->LB_numbereuro = widget;
1429 gtk_grid_attach (GTK_GRID (group_grid), widget, 1, row, 1, 1);
1430
1431 row++;
1432 expander = gtk_expander_new_with_mnemonic(_("_Customize"));
1433 gtk_grid_attach (GTK_GRID (group_grid), expander, 1, row, 1, 1);
1434
1435 group_grid = gtk_grid_new ();
1436 gtk_grid_set_row_spacing (GTK_GRID (group_grid), SPACING_SMALL);
1437 gtk_grid_set_column_spacing (GTK_GRID (group_grid), SPACING_MEDIUM);
1438 gtk_container_add (GTK_CONTAINER (expander), group_grid);
1439
1440 row = 0;
1441 label = make_label_widget(_("_Symbol:"));
1442 gtk_grid_attach (GTK_GRID (group_grid), label, 1, row, 1, 1);
1443 widget = make_string_maxlength(label, 3);
1444 data->ST_euro_symbol = widget;
1445 gtk_grid_attach (GTK_GRID (group_grid), widget, 2, row, 1, 1);
1446
1447 row++;
1448 widget = gtk_check_button_new_with_mnemonic (_("Is pre_fix"));
1449 data->CM_euro_isprefix = widget;
1450 gtk_grid_attach (GTK_GRID (group_grid), widget, 2, row, 1, 1);
1451
1452 row++;
1453 label = make_label_widget(_("_Decimal char:"));
1454 gtk_grid_attach (GTK_GRID (group_grid), label, 1, row, 1, 1);
1455 widget = make_string_maxlength(label, 1);
1456 data->ST_euro_decimalchar = widget;
1457 gtk_grid_attach (GTK_GRID (group_grid), widget, 2, row, 1, 1);
1458
1459 row++;
1460 label = make_label_widget(_("_Frac digits:"));
1461 gtk_grid_attach (GTK_GRID (group_grid), label, 1, row, 1, 1);
1462 widget = make_numeric(label, 0.0, 6.0);
1463 data->NB_euro_fracdigits = widget;
1464 gtk_grid_attach (GTK_GRID (group_grid), widget, 2, row, 1, 1);
1465
1466 row++;
1467 label = make_label_widget(_("_Grouping char:"));
1468 gtk_grid_attach (GTK_GRID (group_grid), label, 1, row, 1, 1);
1469 widget = make_string_maxlength(label, 1);
1470 data->ST_euro_groupingchar = widget;
1471 gtk_grid_attach (GTK_GRID (group_grid), widget, 2, row, 1, 1);
1472
1473 return content_grid;
1474 }
1475
1476
1477 static GtkWidget *defpref_page_display (struct defpref_data *data)
1478 {
1479 GtkWidget *content_grid, *group_grid, *label, *widget, *expander;
1480 gint crow, row;
1481
1482 content_grid = gtk_grid_new();
1483 gtk_grid_set_row_spacing (GTK_GRID (content_grid), SPACING_LARGE);
1484 gtk_orientable_set_orientation(GTK_ORIENTABLE(content_grid), GTK_ORIENTATION_VERTICAL);
1485
1486 crow = 0;
1487 // group :: Date options
1488 group_grid = gtk_grid_new ();
1489 gtk_grid_set_row_spacing (GTK_GRID (group_grid), SPACING_SMALL);
1490 gtk_grid_set_column_spacing (GTK_GRID (group_grid), SPACING_MEDIUM);
1491 gtk_grid_attach (GTK_GRID (content_grid), group_grid, 0, crow++, 1, 1);
1492
1493 label = make_label_group(_("Date"));
1494 gtk_grid_attach (GTK_GRID (group_grid), label, 0, 0, 3, 1);
1495
1496 row = 1;
1497 widget = make_label(NULL, 0, 0.5);
1498 data->LB_date = widget;
1499 gtk_grid_attach (GTK_GRID (group_grid), widget, 1, row, 2, 1);
1500
1501 row++;
1502 expander = gtk_expander_new_with_mnemonic(_("_Customize"));
1503 gtk_grid_attach (GTK_GRID (group_grid), expander, 1, row, 1, 1);
1504
1505 group_grid = gtk_grid_new ();
1506 gtk_grid_set_row_spacing (GTK_GRID (group_grid), SPACING_SMALL);
1507 gtk_grid_set_column_spacing (GTK_GRID (group_grid), SPACING_MEDIUM);
1508 gtk_container_add (GTK_CONTAINER (expander), group_grid);
1509
1510 row = 1;
1511 label = make_label_widget(_("_Format:"));
1512 //----------------------------------------- l, r, t, b
1513 gtk_grid_attach (GTK_GRID (group_grid), label, 1, row, 1, 1);
1514 widget = make_string(label);
1515 data->ST_datefmt = widget;
1516 //gtk_grid_attach (GTK_GRID (group_grid), data->CY_option[FILTER_DATE], 1, 2, row, row+1);
1517 gtk_grid_attach (GTK_GRID (group_grid), widget, 2, row, 1, 1);
1518
1519 widget = gtk_image_new_from_icon_name (ICONNAME_INFO, GTK_ICON_SIZE_BUTTON);
1520 gtk_grid_attach (GTK_GRID (group_grid), widget, 3, row, 1, 1);
1521
1522
1523 gtk_widget_set_tooltip_text(widget,
1524 _("%a locale's abbreviated weekday name.\n"
1525 "%A locale's full weekday name. \n"
1526 "%b locale's abbreviated month name. \n"
1527 "%B locale's full month name. \n"
1528 "%c locale's appropriate date and time representation. \n"
1529 "%C century number (the year divided by 100 and truncated to an integer) as a decimal number [00-99]. \n"
1530 "%d day of the month as a decimal number [01,31]. \n"
1531 "%D same as %m/%d/%y. \n"
1532 "%e day of the month as a decimal number [1,31]; a single digit is preceded by a space. \n"
1533 "%j day of the year as a decimal number [001,366]. \n"
1534 "%m month as a decimal number [01,12]. \n"
1535 "%p locale's appropriate date representation. \n"
1536 "%y year without century as a decimal number [00,99]. \n"
1537 "%Y year with century as a decimal number. \n")
1538 );
1539
1540 row++;
1541 widget = make_label(NULL, 0.0, 0.5);
1542 gtk_label_set_markup (GTK_LABEL(widget), "<small><a href=\"http://man7.org/linux/man-pages/man3/strftime.3.html\">online reference</a></small>");
1543 gtk_grid_attach (GTK_GRID (group_grid), widget, 2, row, 1, 1);
1544
1545 // group :: Measurement units
1546 group_grid = gtk_grid_new ();
1547 gtk_grid_set_row_spacing (GTK_GRID (group_grid), SPACING_SMALL);
1548 gtk_grid_set_column_spacing (GTK_GRID (group_grid), SPACING_MEDIUM);
1549 gtk_grid_attach (GTK_GRID (content_grid), group_grid, 0, crow++, 1, 1);
1550
1551 label = make_label_group(_("Measurement units"));
1552 gtk_grid_attach (GTK_GRID (group_grid), label, 0, 0, 3, 1);
1553
1554 row = 1;
1555 widget = gtk_check_button_new_with_mnemonic (_("Use _miles for meter"));
1556 data->CM_unitismile = widget;
1557 gtk_grid_attach (GTK_GRID (group_grid), widget, 1, row, 2, 1);
1558
1559 row++;
1560 widget = gtk_check_button_new_with_mnemonic (_("Use _gallon for fuel"));
1561 data->CM_unitisgal = widget;
1562 gtk_grid_attach (GTK_GRID (group_grid), widget, 1, row, 2, 1);
1563
1564 return content_grid;
1565 }
1566
1567
1568 static GtkWidget *defpref_page_transactions (struct defpref_data *data)
1569 {
1570 GtkWidget *content_grid, *group_grid, *label, *widget;
1571 gint crow, row;
1572
1573 content_grid = gtk_grid_new();
1574 gtk_grid_set_row_spacing (GTK_GRID (content_grid), SPACING_LARGE);
1575 gtk_orientable_set_orientation(GTK_ORIENTABLE(content_grid), GTK_ORIENTATION_VERTICAL);
1576
1577 crow = 0;
1578 // group :: Transaction window
1579 group_grid = gtk_grid_new ();
1580 gtk_grid_set_row_spacing (GTK_GRID (group_grid), SPACING_SMALL);
1581 gtk_grid_set_column_spacing (GTK_GRID (group_grid), SPACING_MEDIUM);
1582 gtk_grid_attach (GTK_GRID (content_grid), group_grid, 0, crow++, 1, 1);
1583
1584 label = make_label_group(_("Transaction window"));
1585 gtk_grid_attach (GTK_GRID (group_grid), label, 0, 0, 3, 1);
1586
1587 row = 1;
1588 label = make_label_widget(_("Date _range:"));
1589 //----------------------------------------- l, r, t, b
1590 gtk_grid_attach (GTK_GRID (group_grid), label, 1, row, 1, 1);
1591 widget = make_daterange(label, FALSE);
1592 data->CY_daterange_txn = widget;
1593 gtk_grid_attach (GTK_GRID (group_grid), widget, 2, row, 1, 1);
1594
1595 row++;
1596 label = make_label_widget(_("_Show:"));
1597 //----------------------------------------- l, r, t, b
1598 gtk_grid_attach (GTK_GRID (group_grid), label, 1, row, 1, 1);
1599 widget = make_numeric(NULL, 0, 366);
1600
1601 data->ST_datefuture_nbdays = widget;
1602 gtk_grid_attach (GTK_GRID (group_grid), widget, 2, row, 1, 1);
1603
1604 //TRANSLATORS: there is a spinner on the left of this label, and so you have 0....x days in advance the current date
1605 label = make_label(_("days in advance the current date"), 0, 0.5);
1606 gtk_grid_attach (GTK_GRID (group_grid), label, 3, row, 1, 1);
1607
1608 row++;
1609 widget = gtk_check_button_new_with_mnemonic (_("Hide reconciled transactions"));
1610 data->CM_hide_reconciled = widget;
1611 gtk_grid_attach (GTK_GRID (group_grid), widget, 2, row, 2, 1);
1612
1613 row++;
1614 widget = gtk_check_button_new_with_mnemonic (_("Always show remind transactions"));
1615 data->CM_show_remind = widget;
1616 gtk_grid_attach (GTK_GRID (group_grid), widget, 2, row, 2, 1);
1617
1618 // group :: Multiple add
1619 group_grid = gtk_grid_new ();
1620 gtk_grid_set_row_spacing (GTK_GRID (group_grid), SPACING_SMALL);
1621 gtk_grid_set_column_spacing (GTK_GRID (group_grid), SPACING_MEDIUM);
1622 gtk_grid_attach (GTK_GRID (content_grid), group_grid, 0, crow++, 1, 1);
1623
1624 label = make_label_group(_("Multiple add"));
1625 gtk_grid_attach (GTK_GRID (group_grid), label, 0, 0, 3, 1);
1626
1627 row = 1;
1628 widget = gtk_check_button_new_with_mnemonic (_("Keep the last date"));
1629 data->CM_herit_date = widget;
1630 gtk_grid_attach (GTK_GRID (group_grid), widget, 1, row, 2, 1);
1631
1632 // group :: Column list
1633 /*
1634 group_grid = gtk_grid_new ();
1635 gtk_grid_set_row_spacing (GTK_GRID (group_grid), SPACING_SMALL);
1636 gtk_grid_set_column_spacing (GTK_GRID (group_grid), SPACING_MEDIUM);
1637 gtk_grid_attach (GTK_GRID (content_grid), group_grid, 0, crow++, 1, 1);
1638
1639 label = make_label_group(_("Column list"));
1640 gtk_grid_attach (GTK_GRID (group_grid), label, 0, 0, 3, 1);
1641
1642 row = 1;
1643 sw = gtk_scrolled_window_new (NULL, NULL);
1644 gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (sw), GTK_SHADOW_ETCHED_IN);
1645 gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (sw), GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC);
1646 widget = (GtkWidget *)list_txn_colprefcreate();
1647 data->LV_opecolumns = widget;
1648 gtk_widget_set_size_request(data->LV_opecolumns, HB_MINWIDTH_LIST, -1);
1649 gtk_container_add (GTK_CONTAINER (sw), widget);
1650 gtk_widget_set_vexpand (sw, TRUE);
1651 gtk_grid_attach (GTK_GRID (group_grid), sw, 1, row, 2, 1);
1652 gtk_widget_set_tooltip_text(widget, _("Drag & drop to change the order"));
1653 */
1654
1655 return content_grid;
1656 }
1657
1658
1659
1660 static GtkWidget *defpref_page_interface (struct defpref_data *data)
1661 {
1662 GtkWidget *content_grid, *group_grid, *hbox, *label, *widget;
1663 gint crow, row;
1664
1665 content_grid = gtk_grid_new();
1666 gtk_grid_set_row_spacing (GTK_GRID (content_grid), SPACING_LARGE);
1667 gtk_orientable_set_orientation(GTK_ORIENTABLE(content_grid), GTK_ORIENTATION_VERTICAL);
1668
1669 crow = 0;
1670 // group :: General
1671 group_grid = gtk_grid_new ();
1672 gtk_grid_set_row_spacing (GTK_GRID (group_grid), SPACING_SMALL);
1673 gtk_grid_set_column_spacing (GTK_GRID (group_grid), SPACING_MEDIUM);
1674 gtk_grid_attach (GTK_GRID (content_grid), group_grid, 0, crow++, 1, 1);
1675
1676 label = make_label_group(_("General"));
1677 gtk_grid_attach (GTK_GRID (group_grid), label, 0, 0, 3, 1);
1678
1679 row = 1;
1680 label = make_label_widget(_("_Language:"));
1681 gtk_grid_attach (GTK_GRID (group_grid), label, 1, row, 1, 1);
1682 widget = ui_language_combobox_new(label);
1683 data->CY_language = widget;
1684 gtk_grid_attach (GTK_GRID (group_grid), widget, 2, row, 1, 1);
1685
1686 row++;
1687 label = make_label_widget(_("_Toolbar:"));
1688 gtk_grid_attach (GTK_GRID (group_grid), label, 1, row, 1, 1);
1689 widget = make_cycle(label, CYA_TOOLBAR_STYLE);
1690 data->CY_toolbar = widget;
1691 gtk_grid_attach (GTK_GRID (group_grid), widget, 2, row, 1, 1);
1692
1693
1694 row++;
1695 //widget = gtk_check_button_new_with_mnemonic (_("Enable rows in alternating colors"));
1696 //data->CM_ruleshint = widget;
1697 label = make_label_widget(_("_Grid line:"));
1698 gtk_grid_attach (GTK_GRID (group_grid), label, 1, row, 1, 1);
1699 widget = make_cycle(label, CYA_GRID_LINES);
1700 data->CY_gridlines = widget;
1701 gtk_grid_attach (GTK_GRID (group_grid), widget, 2, row, 1, 1);
1702
1703 // group :: Amount colors
1704 group_grid = gtk_grid_new ();
1705 gtk_grid_set_row_spacing (GTK_GRID (group_grid), SPACING_SMALL);
1706 gtk_grid_set_column_spacing (GTK_GRID (group_grid), SPACING_MEDIUM);
1707 gtk_grid_attach (GTK_GRID (content_grid), group_grid, 0, crow++, 1, 1);
1708
1709 label = make_label_group(_("Amount colors"));
1710 gtk_grid_attach (GTK_GRID (group_grid), label, 0, 0, 3, 1);
1711
1712 row = 1;
1713 widget = gtk_check_button_new_with_mnemonic (_("Uses custom colors"));
1714 data->CM_custom_colors = widget;
1715 gtk_grid_attach (GTK_GRID (group_grid), widget, 2, row, 1, 1);
1716
1717 group_grid = gtk_grid_new ();
1718 data->GR_colors = group_grid;
1719 gtk_grid_set_row_spacing (GTK_GRID (group_grid), SPACING_SMALL);
1720 gtk_grid_set_column_spacing (GTK_GRID (group_grid), SPACING_MEDIUM);
1721 gtk_grid_attach (GTK_GRID (content_grid), group_grid, 0, crow++, 1, 1);
1722
1723 row++;
1724 label = make_label_widget(_("_Preset:"));
1725 //----------------------------------------- l, r, t, b
1726 gtk_grid_attach (GTK_GRID (group_grid), label, 1, row, 1, 1);
1727 widget = make_cycle(label, CYA_TANGO_COLORS);
1728 data->CY_colors = widget;
1729 //gtk_grid_attach (GTK_GRID (group_grid), data->CY_option[FILTER_DATE], 1, 2, row, row+1);
1730 gtk_grid_attach (GTK_GRID (group_grid), widget, 2, row, 1, 1);
1731
1732 row++;
1733 label = make_label_widget(_("_Expense:"));
1734 //----------------------------------------- l, r, t, b
1735 gtk_grid_attach (GTK_GRID (group_grid), label, 1, row, 1, 1);
1736 hbox = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, SPACING_SMALL);
1737 gtk_grid_attach (GTK_GRID (group_grid), hbox, 2, row, 1, 1);
1738
1739 widget = gtk_color_button_new ();
1740 data->CP_exp_color = widget;
1741 gtk_box_pack_start (GTK_BOX (hbox), widget, FALSE, FALSE, 0);
1742
1743 label = make_label_widget(_("_Income:"));
1744 gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0);
1745
1746 widget = gtk_color_button_new ();
1747 data->CP_inc_color = widget;
1748 gtk_box_pack_start (GTK_BOX (hbox), widget, FALSE, FALSE, 0);
1749
1750 label = make_label_widget(_("_Warning:"));
1751 gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0);
1752
1753 widget = gtk_color_button_new ();
1754 data->CP_warn_color = widget;
1755 gtk_box_pack_start (GTK_BOX (hbox), widget, FALSE, FALSE, 0);
1756
1757 return content_grid;
1758 }
1759
1760
1761 static GtkWidget *defpref_page_general (struct defpref_data *data)
1762 {
1763 GtkWidget *content_grid, *group_grid, *hbox, *label, *widget;
1764 gint crow, row;
1765
1766 content_grid = gtk_grid_new();
1767 gtk_grid_set_row_spacing (GTK_GRID (content_grid), SPACING_LARGE);
1768 gtk_orientable_set_orientation(GTK_ORIENTABLE(content_grid), GTK_ORIENTATION_VERTICAL);
1769
1770 crow = 0;
1771 // group :: Program start
1772 group_grid = gtk_grid_new ();
1773 gtk_grid_set_row_spacing (GTK_GRID (group_grid), SPACING_SMALL);
1774 gtk_grid_set_column_spacing (GTK_GRID (group_grid), SPACING_MEDIUM);
1775 gtk_grid_attach (GTK_GRID (content_grid), group_grid, 0, crow++, 1, 1);
1776
1777 label = make_label_group(_("Program start"));
1778 gtk_grid_attach (GTK_GRID (group_grid), label, 0, 0, 3, 1);
1779
1780 row = 1;
1781 widget = gtk_check_button_new_with_mnemonic (_("Show splash screen"));
1782 data->CM_show_splash = widget;
1783 gtk_grid_attach (GTK_GRID (group_grid), widget, 1, row, 2, 1);
1784
1785 row++;
1786 widget = gtk_check_button_new_with_mnemonic (_("Load last opened file"));
1787 data->CM_load_last = widget;
1788 gtk_grid_attach (GTK_GRID (group_grid), widget, 1, row, 2, 1);
1789
1790 row++;
1791 widget = gtk_check_button_new_with_mnemonic (_("Post pending scheduled transactions"));
1792 data->CM_append_scheduled = widget;
1793 gtk_grid_attach (GTK_GRID (group_grid), widget, 1, row, 2, 1);
1794
1795 row++;
1796 widget = gtk_check_button_new_with_mnemonic (_("Update currencies online"));
1797 data->CM_do_update_currency = widget;
1798 gtk_grid_attach (GTK_GRID (group_grid), widget, 1, row, 2, 1);
1799
1800 // group :: Fiscal year
1801 group_grid = gtk_grid_new ();
1802 gtk_grid_set_row_spacing (GTK_GRID (group_grid), SPACING_SMALL);
1803 gtk_grid_set_column_spacing (GTK_GRID (group_grid), SPACING_MEDIUM);
1804 gtk_grid_attach (GTK_GRID (content_grid), group_grid, 0, crow++, 1, 1);
1805
1806 label = make_label_group(_("Fiscal year"));
1807 gtk_grid_attach (GTK_GRID (group_grid), label, 0, 0, 3, 1);
1808
1809 row = 1;
1810 //TRANSLATORS: (fiscal year) starts on
1811 label = make_label_widget(_("Starts _on:"));
1812 gtk_grid_attach (GTK_GRID (group_grid), label, 1, row, 1, 1);
1813
1814 hbox = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, SPACING_SMALL);
1815 gtk_grid_attach (GTK_GRID (group_grid), hbox, 2, row, 1, 1);
1816 widget = make_numeric (label, 1, 28);
1817 data->NB_fiscyearday = widget;
1818 gtk_box_pack_start (GTK_BOX (hbox), widget, FALSE, FALSE, 0);
1819 widget = make_cycle (NULL, CYA_MONTHS);
1820 data->CY_fiscyearmonth = widget;
1821 gtk_box_pack_start (GTK_BOX (hbox), widget, FALSE, FALSE, 0);
1822
1823 // group :: Main window reports
1824 group_grid = gtk_grid_new ();
1825 gtk_grid_set_row_spacing (GTK_GRID (group_grid), SPACING_SMALL);
1826 gtk_grid_set_column_spacing (GTK_GRID (group_grid), SPACING_MEDIUM);
1827 gtk_grid_attach (GTK_GRID (content_grid), group_grid, 0, crow++, 1, 1);
1828
1829 label = make_label_group(_("Main window reports"));
1830 gtk_grid_attach (GTK_GRID (group_grid), label, 0, 0, 3, 1);
1831
1832 row = 1;
1833 label = make_label_widget(_("Date _range:"));
1834 gtk_grid_attach (GTK_GRID (group_grid), label, 1, row, 1, 1);
1835 widget = make_daterange(label, FALSE);
1836 data->CY_daterange_wal = widget;
1837 gtk_grid_attach (GTK_GRID (group_grid), widget, 2, row, 1, 1);
1838
1839 // group :: Files folder
1840 group_grid = gtk_grid_new ();
1841 gtk_grid_set_row_spacing (GTK_GRID (group_grid), SPACING_SMALL);
1842 gtk_grid_set_column_spacing (GTK_GRID (group_grid), SPACING_MEDIUM);
1843 gtk_grid_attach (GTK_GRID (content_grid), group_grid, 0, crow++, 1, 1);
1844
1845 label = make_label_group(_("Files folder"));
1846 gtk_grid_attach (GTK_GRID (group_grid), label, 0, 0, 3, 1);
1847
1848 row = 1;
1849 label = make_label_widget(_("_Default:"));
1850 gtk_grid_attach (GTK_GRID (group_grid), label, 1, row, 1, 1);
1851
1852 hbox = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0);
1853 gtk_widget_set_hexpand (hbox, TRUE);
1854 gtk_grid_attach (GTK_GRID (group_grid), hbox, 2, row, 1, 1);
1855
1856 widget = make_string(label);
1857 data->ST_path_hbfile = widget;
1858 gtk_style_context_add_class (gtk_widget_get_style_context (GTK_WIDGET(widget)), GTK_STYLE_CLASS_LINKED);
1859 gtk_box_pack_start (GTK_BOX (hbox), widget, TRUE, TRUE, 0);
1860
1861 //widget = gtk_button_new_with_label("...");
1862 widget = gtk_button_new_from_icon_name(ICONNAME_FOLDER, GTK_ICON_SIZE_BUTTON);
1863 data->BT_path_hbfile = widget;
1864 gtk_box_pack_start (GTK_BOX (hbox), widget, FALSE, FALSE, 0);
1865
1866 return content_grid;
1867 }
1868
1869
1870 void plugin_execute_action(GtkTreeView* treeview, GtkTreePath* path, GtkTreeViewColumn* col, gpointer userdata);
1871
1872 static void
1873 toggle_plugin(GtkCellRendererToggle *cell, gchar* path_str, gpointer data)
1874 {
1875 GtkTreeModel *model = (GtkTreeModel*)data;
1876 GtkTreeIter iter;
1877 GtkTreePath *path = gtk_tree_path_new_from_string(path_str);
1878
1879 const gchar* plugin;
1880
1881 gtk_tree_model_get_iter(model, &iter, path);
1882 gtk_tree_model_get(model, &iter, EXT_COLUMN_PLUGIN_NAME, &plugin, -1);
1883
1884 gboolean enabled = ext_is_plugin_loaded(plugin);
1885 if (enabled) {
1886 ext_unload_plugin(plugin);
1887 enabled = FALSE;
1888 } else {
1889 enabled = (ext_load_plugin(plugin) == 0);
1890 if (!enabled) {
1891 ext_run_modal(_("Plugin Error"), _("The plugin failed to load properly."), "error");
1892 }
1893 }
1894
1895 /* set new value */
1896 gtk_list_store_set(GTK_LIST_STORE (model), &iter, EXT_COLUMN_ENABLED, enabled, -1);
1897
1898 /* clean up */
1899 gtk_tree_path_free(path);
1900 }
1901
1902
1903 void plugin_execute_action(GtkTreeView* treeview, GtkTreePath* path, GtkTreeViewColumn* col, gpointer userdata)
1904 {
1905 GtkTreeModel* model = gtk_tree_view_get_model(treeview);
1906 GtkTreeIter iter;
1907
1908 if (gtk_tree_model_get_iter(model, &iter, path)) {
1909 gchar* plugin_filename;
1910 gtk_tree_model_get(model, &iter, EXT_COLUMN_PLUGIN_NAME, &plugin_filename, -1);
1911 ext_execute_action(plugin_filename);
1912 g_free(plugin_filename);
1913 }
1914 }
1915
1916 static GtkWidget *defpref_page_plugins (struct defpref_data *data)
1917 {
1918 GtkWidget *container;
1919 GtkListStore *store;
1920 GtkTreeIter it;
1921 GtkWidget* view;
1922
1923 container = gtk_vbox_new(FALSE, 0);
1924
1925 store = gtk_list_store_new(EXT_NUM_COLUMNS, G_TYPE_BOOLEAN, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING);
1926
1927 gchar** plugins = ext_list_plugins();
1928 gchar** plugins_it;
1929 for (plugins_it = plugins; *plugins_it; ++plugins_it) {
1930
1931 gboolean enabled = ext_is_plugin_loaded(*plugins_it);
1932 GHashTable* metadata = ext_read_plugin_metadata(*plugins_it);
1933 if (!metadata) {
1934 metadata = g_hash_table_new(g_str_hash, g_str_equal);
1935 }
1936
1937 gchar* tmp = NULL;
1938
1939 // NAME
1940 gchar* name = g_hash_table_lookup(metadata, "name");
1941 if (!name || *name == '\0') {
1942 name = *plugins_it;
1943 }
1944 name = g_markup_escape_text(name, -1);
1945 gchar* label = g_strdup_printf("<b>%s</b>", name);
1946 gchar* tooltip = g_strdup_printf("<span size='x-large' weight='bold'>%s</span>", name);
1947 g_free(name);
1948
1949 // VERSION
1950 gchar* version = g_hash_table_lookup(metadata, "version");
1951 if (version) {
1952 version = g_markup_escape_text(version, -1);
1953 tmp = label;
1954 label = g_strdup_printf("%s %s", tmp, version);
1955 g_free(tmp);
1956 tmp = tooltip;
1957 tooltip = g_strdup_printf("%s %s", tmp, version);
1958 g_free(tmp);
1959 g_free(version);
1960 }
1961
1962 // ABSTRACT
1963 gchar* abstract = g_hash_table_lookup(metadata, "abstract");
1964 if (abstract) {
1965 abstract = g_markup_escape_text(abstract, -1);
1966 tmp = label;
1967 label = g_strdup_printf("%s\n%s", tmp, abstract);
1968 g_free(tmp);
1969 g_free(abstract);
1970 }
1971
1972 // AUTHOR
1973 gchar* author = g_hash_table_lookup(metadata, "author");
1974 if (author) {
1975 author = g_markup_escape_text(author, -1);
1976 tmp = tooltip;
1977 tooltip = g_strdup_printf("%s\n%s", tmp, author);
1978 g_free(tmp);
1979 g_free(author);
1980 }
1981
1982 // WEBSITE
1983 gchar* website = g_hash_table_lookup(metadata, "website");
1984 if (website) {
1985 website = g_markup_escape_text(website, -1);
1986 tmp = tooltip;
1987 tooltip = g_strdup_printf("%s\n<b>%s:</b> %s", tmp, _("Website"), website);
1988 g_free(tmp);
1989 g_free(website);
1990 }
1991
1992 // FILEPATH
1993 tmp = ext_find_plugin(*plugins_it);
1994 gchar* full = g_markup_escape_text(tmp, -1);
1995 g_free(tmp);
1996 tmp = tooltip;
1997 tooltip = g_strdup_printf("%s\n<b>%s:</b> %s", tmp, _("File"), full);
1998 g_free(tmp);
1999 g_free(full);
2000
2001 g_hash_table_unref(metadata);
2002
2003 gtk_list_store_append(store, &it);
2004 gtk_list_store_set(store, &it,
2005 EXT_COLUMN_ENABLED, enabled,
2006 EXT_COLUMN_LABEL, label,
2007 EXT_COLUMN_TOOLTIP, tooltip,
2008 EXT_COLUMN_PLUGIN_NAME, *plugins_it,
2009 -1);
2010
2011 g_free(label);
2012 g_free(tooltip);
2013 }
2014 g_strfreev(plugins);
2015
2016 view = gtk_tree_view_new_with_model(GTK_TREE_MODEL(store));
2017 g_object_unref(store);
2018
2019 g_signal_connect(view, "row-activated", (GCallback)plugin_execute_action, NULL);
2020
2021 gtk_tree_view_set_rules_hint(GTK_TREE_VIEW(view), TRUE);
2022 gtk_tree_view_set_headers_visible(GTK_TREE_VIEW(view), TRUE);
2023 gtk_tree_view_set_tooltip_column(GTK_TREE_VIEW(view), EXT_COLUMN_TOOLTIP);
2024
2025
2026 GtkTreeViewColumn *col;
2027 GtkCellRenderer *renderer;
2028
2029
2030 col = gtk_tree_view_column_new();
2031 gtk_tree_view_column_set_title(col, _("Enabled"));
2032 gtk_tree_view_column_set_sort_column_id(col, EXT_COLUMN_ENABLED);
2033 gtk_tree_view_append_column(GTK_TREE_VIEW(view), col);
2034
2035 renderer = gtk_cell_renderer_toggle_new();
2036 gtk_tree_view_column_pack_start(col, renderer, TRUE);
2037 gtk_tree_view_column_add_attribute(col, renderer, "active", 0);
2038 g_signal_connect(renderer, "toggled", G_CALLBACK(toggle_plugin), store);
2039
2040 col = gtk_tree_view_column_new();
2041 gtk_tree_view_column_set_title(col, _("Plugin"));
2042 gtk_tree_view_column_set_sort_column_id(col, EXT_COLUMN_LABEL);
2043 gtk_tree_view_column_set_expand(col, TRUE);
2044 /*gtk_tree_view_column_set_sort_order(col, GTK_SORT_ASCENDING);*/
2045 gtk_tree_view_append_column(GTK_TREE_VIEW(view), col);
2046
2047 renderer = gtk_cell_renderer_text_new();
2048 g_object_set(renderer, "ellipsize", PANGO_ELLIPSIZE_END, NULL);
2049 gtk_tree_view_column_pack_start(col, renderer, TRUE);
2050 gtk_tree_view_column_add_attribute(col, renderer, "markup", EXT_COLUMN_LABEL);
2051
2052 data->PI_plugin_columns = view;
2053
2054 GtkWidget* sw = gtk_scrolled_window_new(NULL, NULL);
2055 gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(sw), GTK_SHADOW_ETCHED_IN);
2056 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(sw), GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC);
2057 gtk_container_add(GTK_CONTAINER(sw), view);
2058
2059 gtk_box_pack_start(GTK_BOX(container), sw, TRUE, TRUE, 0);
2060
2061 return(container);
2062 }
2063
2064
2065 static void defpref_selection(GtkTreeSelection *treeselection, gpointer user_data)
2066 {
2067 struct defpref_data *data;
2068 GtkWidget *notebook;
2069 GtkTreeView *treeview;
2070 GtkTreeModel *model;
2071 GtkTreeIter iter;
2072
2073 GValue val = { 0, };
2074 gint page;
2075
2076 DB( g_print("\n[ui-pref] selection\n") );
2077
2078 if (gtk_tree_selection_get_selected(treeselection, &model, &iter))
2079 {
2080 notebook = GTK_WIDGET(user_data);
2081 treeview = gtk_tree_selection_get_tree_view(treeselection);
2082 data = g_object_get_data(G_OBJECT(gtk_widget_get_ancestor(GTK_WIDGET(treeview), GTK_TYPE_WINDOW)), "inst_data");
2083
2084
2085 gtk_tree_model_get_value(model, &iter, LST_PREF_PAGE, &val);
2086 page = g_value_get_int (&val);
2087 DB( g_print(" - active is %d\n", page) );
2088 g_value_unset (&val);
2089
2090
2091 gtk_tree_model_get_value(model, &iter, LST_PREF_NAME, &val);
2092 gtk_label_set_text (GTK_LABEL (data->label), g_value_get_string (&val));
2093 g_value_unset (&val);
2094
2095 gtk_tree_model_get_value(model, &iter, LST_PREF_ICONNAME, &val);
2096 //gtk_image_set_from_pixbuf (GTK_IMAGE (data->image), g_value_get_object (&val));
2097 gtk_image_set_from_icon_name(GTK_IMAGE (data->image), g_value_get_string (&val), GTK_ICON_SIZE_DIALOG);
2098 g_value_unset (&val);
2099
2100
2101
2102 gtk_notebook_set_current_page(GTK_NOTEBOOK(notebook), page);
2103
2104 //defpref_change_page(GTK_WIDGET(gtk_tree_selection_get_tree_view(treeselection)), GINT_TO_POINTER(page));
2105 }
2106
2107 }
2108
2109
2110 /*
2111 ** set the notebook active page from treeview
2112 */
2113 /*void defpref_change_page(GtkWidget *widget, gpointer user_data)
2114 {
2115 struct defpref_data *data;
2116 gint page = GPOINTER_TO_INT(user_data);
2117 GtkTreeModel *model;
2118
2119
2120 DB( g_print("\n[ui-pref] page\n") );
2121
2122 data = g_object_get_data(G_OBJECT(gtk_widget_get_ancestor(widget, GTK_TYPE_WINDOW)), "inst_data");
2123
2124 model = gtk_tree_view_get_model(GTK_TREE_VIEW(data->LV_page));
2125
2126
2127
2128
2129
2130
2131
2132 gtk_notebook_set_current_page(GTK_NOTEBOOK(data->GR_page), page);
2133 }
2134 */
2135
2136
2137 /*
2138 ** add an empty new account to our temp GList and treeview
2139 */
2140 static void defpref_clear(GtkWidget *widget, gpointer user_data)
2141 {
2142 struct defpref_data *data;
2143 gint result;
2144
2145 data = g_object_get_data(G_OBJECT(gtk_widget_get_ancestor(widget, GTK_TYPE_WINDOW)), "inst_data");
2146 DB( g_print("\n(defpref_clear) (data=%p)\n", data) );
2147
2148 result = ui_dialog_msg_confirm_alert(
2149 GTK_WINDOW(data->window),
2150 _("Reset all preferences"),
2151 _("Do you really want to reset all\npreferences to default values?"),
2152 _("Reset")
2153 );
2154 if( result == GTK_RESPONSE_OK )
2155 {
2156 homebank_pref_setdefault();
2157 defpref_set(data);
2158 }
2159
2160 }
2161
2162
2163 // the window creation
2164 GtkWidget *defpref_dialog_new (gint initial_selection)
2165 {
2166 struct defpref_data data;
2167 GtkWidget *window, *content, *mainvbox;
2168 GtkWidget *hbox, *vbox, *sw, *widget, *notebook, *page, *ebox, *image, *label;
2169
2170 window = gtk_dialog_new_with_buttons (_("Preferences"),
2171 GTK_WINDOW(GLOBALS->mainwindow),
2172 0,
2173 _("_Cancel"),
2174 GTK_RESPONSE_REJECT,
2175 _("_OK"),
2176 GTK_RESPONSE_ACCEPT,
2177 NULL);
2178
2179 data.window = window;
2180
2181 //store our window private data
2182 g_object_set_data(G_OBJECT(window), "inst_data", (gpointer)&data);
2183
2184 gtk_window_set_icon_name(GTK_WINDOW (window), ICONNAME_PREFERENCES);
2185
2186 content = gtk_dialog_get_content_area(GTK_DIALOG (window)); // return a vbox
2187 mainvbox = gtk_box_new(GTK_ORIENTATION_VERTICAL, SPACING_MEDIUM);
2188 gtk_box_pack_start (GTK_BOX (content), mainvbox, TRUE, TRUE, 0);
2189
2190 gtk_container_set_border_width(GTK_CONTAINER(mainvbox), SPACING_MEDIUM);
2191
2192 hbox = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, SPACING_MEDIUM);
2193 gtk_box_pack_start (GTK_BOX (mainvbox), hbox, TRUE, TRUE, 0);
2194
2195 //left part
2196 vbox = gtk_box_new(GTK_ORIENTATION_VERTICAL, SPACING_SMALL);
2197 gtk_box_pack_start (GTK_BOX (hbox), vbox, FALSE, FALSE, 0);
2198
2199 //list
2200 sw = gtk_scrolled_window_new (NULL, NULL);
2201 gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (sw), GTK_SHADOW_ETCHED_IN);
2202 gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (sw), GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC);
2203 gtk_box_pack_start (GTK_BOX (vbox), sw, TRUE, TRUE, 0);
2204 widget = pref_list_create();
2205 data.LV_page = widget;
2206 gtk_container_add (GTK_CONTAINER (sw), widget);
2207
2208 // clear button
2209 data.BT_clear = gtk_button_new_with_mnemonic(_("_Reset"));
2210 gtk_box_pack_start (GTK_BOX (vbox), data.BT_clear, FALSE, TRUE, 0);
2211
2212
2213 //right part : notebook
2214 vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, SPACING_MEDIUM);
2215 gtk_box_pack_start (GTK_BOX (hbox), vbox, TRUE, TRUE, 0);
2216 gtk_widget_show (vbox);
2217
2218 ebox = gtk_event_box_new();
2219 gtk_widget_set_name(ebox, "hbebox");
2220 GtkStyleContext *context = gtk_widget_get_style_context (ebox);
2221 #if GTK_MINOR_VERSION <= 18
2222 gtk_style_context_add_class (context, GTK_STYLE_CLASS_LIST_ROW);
2223 gtk_widget_set_state_flags(ebox, GTK_STATE_FLAG_SELECTED, TRUE);
2224 #else
2225 GtkCssProvider *provider;
2226 provider = gtk_css_provider_new ();
2227 gtk_css_provider_load_from_data (provider,
2228 "#hbebox { color: @theme_selected_fg_color; background-color: @theme_selected_bg_color; }"
2229 , -1, NULL);
2230 gtk_style_context_add_provider (context, GTK_STYLE_PROVIDER(provider), G_MAXUINT);
2231
2232 // gtk_style_context_set_state(context, GTK_STATE_FLAG_SELECTED);
2233 #endif
2234
2235 gtk_box_pack_start (GTK_BOX (vbox), ebox, FALSE, TRUE, 0);
2236 gtk_widget_show (ebox);
2237
2238 hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, SPACING_SMALL);
2239 gtk_container_set_border_width (GTK_CONTAINER (hbox), SPACING_SMALL);
2240 gtk_container_add (GTK_CONTAINER (ebox), hbox);
2241 gtk_widget_show (hbox);
2242
2243 label = gtk_label_new (NULL);
2244 gtk_widget_set_margin_left(label, SPACING_MEDIUM);
2245 gimp_label_set_attributes (GTK_LABEL (label),
2246 PANGO_ATTR_SCALE, PANGO_SCALE_XX_LARGE,
2247 PANGO_ATTR_WEIGHT, PANGO_WEIGHT_BOLD,
2248 -1);
2249
2250 gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0);
2251 gtk_widget_show (label);
2252 data.label = label;
2253
2254 image = gtk_image_new ();
2255 gtk_box_pack_end (GTK_BOX (hbox), image, FALSE, FALSE, 0);
2256 gtk_widget_show (image);
2257 data.image = image;
2258
2259
2260
2261 //notebook
2262 notebook = gtk_notebook_new();
2263 data.GR_page = notebook;
2264 gtk_widget_show(notebook);
2265 gtk_notebook_set_show_tabs(GTK_NOTEBOOK(notebook), FALSE);
2266 gtk_notebook_set_show_border(GTK_NOTEBOOK(notebook), FALSE);
2267 gtk_box_pack_start (GTK_BOX (vbox), notebook, TRUE, TRUE, 0);
2268
2269 /*
2270 "general",
2271 "interface",
2272 "display",
2273 "help",
2274 "euro",
2275 "report"
2276 */
2277
2278 //general
2279 page = defpref_page_general(&data);
2280 gtk_notebook_append_page (GTK_NOTEBOOK (notebook), page, NULL);
2281
2282 //interface
2283 page = defpref_page_interface(&data);
2284 gtk_notebook_append_page (GTK_NOTEBOOK (notebook), page, NULL);
2285
2286 //columns
2287 page = defpref_page_transactions(&data);
2288 gtk_notebook_append_page (GTK_NOTEBOOK (notebook), page, NULL);
2289
2290 //display
2291 page = defpref_page_display(&data);
2292 gtk_notebook_append_page (GTK_NOTEBOOK (notebook), page, NULL);
2293
2294 //import
2295 page = defpref_page_import(&data);
2296 gtk_notebook_append_page (GTK_NOTEBOOK (notebook), page, NULL);
2297
2298 //report
2299 page = defpref_page_reports(&data);
2300 gtk_notebook_append_page (GTK_NOTEBOOK (notebook), page, NULL);
2301
2302 //euro
2303 page = defpref_page_euro(&data);
2304 gtk_notebook_append_page (GTK_NOTEBOOK (notebook), page, NULL);
2305
2306 //plugins
2307 page = defpref_page_plugins(&data);
2308 gtk_notebook_append_page (GTK_NOTEBOOK (notebook), page, NULL);
2309
2310
2311 //todo:should move this
2312 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(data.CM_euro_enable), PREFS->euro_active);
2313
2314 //connect all our signals
2315 g_signal_connect (window, "destroy", G_CALLBACK (gtk_widget_destroyed), &window);
2316
2317 g_signal_connect (G_OBJECT (data.BT_clear), "clicked", G_CALLBACK (defpref_clear), NULL);
2318
2319 //path selector
2320 g_signal_connect (data.BT_path_hbfile, "pressed", G_CALLBACK (defpref_pathselect), GINT_TO_POINTER(1));
2321 g_signal_connect (data.BT_path_import, "pressed", G_CALLBACK (defpref_pathselect), GINT_TO_POINTER(2));
2322 g_signal_connect (data.BT_path_export, "pressed", G_CALLBACK (defpref_pathselect), GINT_TO_POINTER(3));
2323
2324 g_signal_connect (data.CM_custom_colors, "toggled", G_CALLBACK (defpref_colortoggle), NULL);
2325 g_signal_connect (data.CY_colors, "changed", G_CALLBACK (defpref_colorpreset), NULL);
2326
2327
2328
2329 g_signal_connect (gtk_tree_view_get_selection(GTK_TREE_VIEW(data.LV_page)), "changed", G_CALLBACK (defpref_selection), notebook);
2330
2331 g_signal_connect (data.CM_euro_enable, "toggled", G_CALLBACK (defpref_eurotoggle), NULL);
2332
2333 g_signal_connect (data.CY_euro_preset, "changed", G_CALLBACK (defpref_europreset), NULL);
2334
2335 //date
2336 g_signal_connect (data.ST_datefmt, "changed", G_CALLBACK (defpref_date_sample), NULL);
2337
2338 //report
2339 g_signal_connect (data.CY_color_scheme, "changed", G_CALLBACK (defpref_color_scheme_changed), NULL);
2340
2341
2342 //euro number
2343 g_signal_connect (data.ST_euro_symbol , "changed", G_CALLBACK (defpref_numbereuro_sample), NULL);
2344 g_signal_connect (data.CM_euro_isprefix, "toggled", G_CALLBACK (defpref_numbereuro_sample), NULL);
2345 g_signal_connect (data.ST_euro_decimalchar , "changed", G_CALLBACK (defpref_numbereuro_sample), NULL);
2346 g_signal_connect (data.ST_euro_groupingchar, "changed", G_CALLBACK (defpref_numbereuro_sample), NULL);
2347 g_signal_connect (data.NB_euro_fracdigits, "value-changed", G_CALLBACK (defpref_numbereuro_sample), NULL);
2348
2349 //g_signal_connect (data.BT_default, "pressed", G_CALLBACK (defpref_currency_change), NULL);
2350
2351
2352 //setup, init and show window
2353 //defhbfile_setup(&data);
2354 //defhbfile_update(data.LV_arc, NULL);
2355
2356 defpref_set(&data);
2357
2358 defpref_colortoggle(window, NULL);
2359 defpref_eurotoggle(window, NULL);
2360
2361 gtk_window_resize(GTK_WINDOW(window), 640, 256);
2362
2363
2364 //select first row
2365 GtkTreePath *path = gtk_tree_path_new_from_indices(initial_selection, -1);
2366
2367
2368 gtk_tree_selection_select_path (gtk_tree_view_get_selection(GTK_TREE_VIEW(data.LV_page)), path);
2369
2370
2371
2372 gtk_tree_path_free(path);
2373
2374 gtk_widget_show_all (window);
2375 gtk_notebook_set_current_page(GTK_NOTEBOOK(notebook), initial_selection);
2376
2377 gint result;
2378 gchar *old_lang;
2379
2380
2381 //wait for the user
2382 result = gtk_dialog_run (GTK_DIALOG (window));
2383
2384 switch( result )
2385 {
2386 case GTK_RESPONSE_ACCEPT:
2387 old_lang = g_strdup(PREFS->language);
2388 defpref_get(&data);
2389 homebank_pref_save();
2390 ui_mainwindow_update(GLOBALS->mainwindow, GINT_TO_POINTER(UF_BALANCE+UF_VISUAL));
2391
2392 DB( g_print("old='%s' new='%s'\n", old_lang, PREFS->language) );
2393
2394 if(g_ascii_strncasecmp(old_lang == NULL ? "" : old_lang, PREFS->language == NULL ? "" : PREFS->language, -1) != 0)
2395 {
2396 ui_dialog_msg_infoerror(GTK_WINDOW(window), GTK_MESSAGE_INFO,
2397 _("Info"),
2398 _("You will have to restart HomeBank\nfor the language change to take effect.")
2399 );
2400
2401 }
2402
2403 g_free(old_lang);
2404 break;
2405 }
2406
2407
2408 // cleanup and destroy
2409 //defhbfile_cleanup(&data, result);
2410 gtk_widget_destroy (window);
2411
2412 return window;
2413 }
2414
2415 // -------------------------------
2416
2417
2418 static GtkWidget *pref_list_create(void)
2419 {
2420 GtkListStore *store;
2421 GtkWidget *view;
2422 GtkCellRenderer *renderer;
2423 GtkTreeViewColumn *column;
2424 GtkTreeIter iter;
2425 gint i;
2426
2427 /* create list store */
2428 store = gtk_list_store_new(
2429 LST_PREF_MAX,
2430 G_TYPE_STRING,
2431 G_TYPE_STRING,
2432 G_TYPE_INT
2433 );
2434
2435 //treeview
2436 view = gtk_tree_view_new_with_model(GTK_TREE_MODEL(store));
2437 g_object_unref(store);
2438
2439 gtk_tree_view_set_headers_visible(GTK_TREE_VIEW (view), FALSE);
2440 gtk_tree_selection_set_mode(gtk_tree_view_get_selection(GTK_TREE_VIEW(view)), GTK_SELECTION_SINGLE);
2441
2442 /* column 1: icon */
2443 column = gtk_tree_view_column_new();
2444 renderer = gtk_cell_renderer_pixbuf_new ();
2445 g_object_set(renderer, "stock-size", GTK_ICON_SIZE_DND, NULL);
2446 gtk_tree_view_column_pack_start(column, renderer, FALSE);
2447 gtk_tree_view_column_set_attributes(column, renderer, "icon-name", LST_PREF_ICONNAME, NULL);
2448
2449 renderer = gtk_cell_renderer_text_new ();
2450 gtk_tree_view_column_pack_start(column, renderer, TRUE);
2451 gtk_tree_view_column_set_attributes(column, renderer, "text", LST_PREF_NAME, NULL);
2452
2453 gtk_tree_view_append_column (GTK_TREE_VIEW(view), column);
2454
2455 //populate our combobox model
2456 for(i=0;i<PREF_MAX;i++)
2457 {
2458 gtk_list_store_append(store, &iter);
2459
2460 gtk_list_store_set(store, &iter,
2461 LST_PREF_ICONNAME, pref_iconname[i],
2462 LST_PREF_NAME, _(pref_name[i]),
2463 LST_PREF_PAGE, i,
2464 -1);
2465 }
2466
2467 return(view);
2468 }
2469
2470
2471 /* = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =*/
2472
2473 /*
2474 extern gchar *list_txn_column_label[];
2475
2476
2477 static void
2478 list_txn_colpref_toggled_cell_data_function (GtkCellRendererToggle *cell,
2479 gchar *path_str,
2480 gpointer data)
2481 {
2482 GtkTreeModel *model = (GtkTreeModel *)data;
2483 GtkTreeIter iter;
2484 GtkTreePath *path = gtk_tree_path_new_from_string (path_str);
2485 gboolean fixed;
2486
2487 // get toggled iter
2488 gtk_tree_model_get_iter (model, &iter, path);
2489 gtk_tree_model_get (model, &iter, COLUMN_VISIBLE, &fixed, -1);
2490
2491 // do something with the value
2492 fixed ^= 1;
2493
2494 // set new value
2495 gtk_list_store_set (GTK_LIST_STORE (model), &iter, COLUMN_VISIBLE, fixed, -1);
2496
2497 // clean up
2498 gtk_tree_path_free (path);
2499 }
2500
2501
2502 static void list_txn_colpref_get(GtkTreeView *treeview, gint *columns)
2503 {
2504 GtkTreeModel *model;
2505 GtkTreeIter iter;
2506 gboolean valid;
2507 gboolean visible;
2508 gint i, id;
2509
2510 DB( g_print("[lst_txn-colpref] store column order \n") );
2511
2512 model = gtk_tree_view_get_model(GTK_TREE_VIEW(treeview));
2513 valid = gtk_tree_model_get_iter_first(GTK_TREE_MODEL(model), &iter);
2514 i = 0;
2515 while (valid)
2516 {
2517 gtk_tree_model_get(GTK_TREE_MODEL(model), &iter,
2518 COLUMN_VISIBLE, &visible,
2519 COLUMN_ID, &id,
2520 -1);
2521
2522 DB( g_print(" - column %d: %d\n",id, visible) );
2523 // start at index 2 (status, date always displayed
2524 columns[i+2] = visible == TRUE ? id : -id;
2525
2526 // Make iter point to the next row in the list store
2527 valid = gtk_tree_model_iter_next(GTK_TREE_MODEL(model), &iter);
2528 i++;
2529 }
2530 }
2531
2532
2533 GtkWidget *list_txn_colprefcreate(void)
2534 {
2535 GtkListStore *store;
2536 GtkWidget *view;
2537 GtkCellRenderer *renderer;
2538 GtkTreeViewColumn *column;
2539 GtkTreeIter iter;
2540 gint i;
2541
2542 DB( g_print("[lst_txn-colpref] create\n") );
2543
2544
2545 // create list store
2546 store = gtk_list_store_new(
2547 3,
2548 G_TYPE_BOOLEAN,
2549 G_TYPE_STRING,
2550 G_TYPE_UINT
2551 );
2552
2553 // populate
2554 for(i=0 ; i < NUM_LST_DSPOPE-1; i++ ) //-1 cause account column avoid
2555 {
2556 gint id;
2557 gboolean visible;
2558
2559 DB( g_print("eval %d, %s\n", i, list_txn_column_label[i]) );
2560
2561 if(i <= LST_DSPOPE_DATE) // status, date always displayed
2562 continue;
2563
2564 //[i-1] here because lst_ope_columns[] do not store LST_DSPOPE_DATAS
2565 id = ABS(PREFS->lst_ope_columns[i-1]);
2566 if(id == 0) id = i; //if we pass here, new column or weird into pref file
2567 visible = (PREFS->lst_ope_columns[i-1] > 0) ? TRUE : FALSE;
2568
2569
2570 DB( g_print(" - pos=%2d, id=%2d - %d '%s'\n", i, id, visible, list_txn_column_label[id]) );
2571
2572 gtk_list_store_append (store, &iter);
2573 gtk_list_store_set (store, &iter,
2574 COLUMN_VISIBLE, visible,
2575 COLUMN_NAME, _(list_txn_column_label[id]),
2576 COLUMN_ID , id,
2577 -1);
2578
2579 }
2580
2581 //treeview
2582 view = gtk_tree_view_new_with_model(GTK_TREE_MODEL(store));
2583 g_object_unref(store);
2584
2585
2586
2587 renderer = gtk_cell_renderer_toggle_new ();
2588 column = gtk_tree_view_column_new_with_attributes (_("Visible"),
2589 renderer,
2590 "active", COLUMN_VISIBLE,
2591 NULL);
2592 gtk_tree_view_append_column (GTK_TREE_VIEW(view), column);
2593
2594 g_signal_connect (renderer, "toggled",
2595 G_CALLBACK (list_txn_colpref_toggled_cell_data_function), store);
2596
2597
2598 renderer = gtk_cell_renderer_text_new ();
2599 column = gtk_tree_view_column_new_with_attributes (_("Column"),
2600 renderer,
2601 "text", COLUMN_NAME,
2602 NULL);
2603 gtk_tree_view_append_column (GTK_TREE_VIEW(view), column);
2604
2605 gtk_tree_view_set_reorderable (GTK_TREE_VIEW(view), TRUE);
2606
2607
2608 return(view);
2609 }
2610 */
2611
2612
2613 static void list_ext_colpref_get(GtkTreeView *treeview, GList **columns)
2614 {
2615 GtkTreeModel *model;
2616 GtkTreeIter iter;
2617
2618 g_list_free_full(*columns, g_free);
2619 *columns = NULL;
2620
2621 model = gtk_tree_view_get_model(GTK_TREE_VIEW(treeview));
2622
2623 gboolean valid = gtk_tree_model_get_iter_first(GTK_TREE_MODEL(model), &iter);
2624 while (valid) {
2625 gboolean enabled = FALSE;
2626 const gchar* name;
2627
2628 gtk_tree_model_get(GTK_TREE_MODEL(model), &iter,
2629 EXT_COLUMN_ENABLED, &enabled,
2630 EXT_COLUMN_PLUGIN_NAME, &name,
2631 -1);
2632
2633 if (enabled) {
2634 *columns = g_list_append(*columns, g_strdup(name));
2635 }
2636
2637 valid = gtk_tree_model_iter_next(GTK_TREE_MODEL(model), &iter);
2638 }
2639 }
2640
This page took 0.17003 seconds and 4 git commands to generate.