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