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