add gitignore
[chaz/homebank] / src / ui-filter.c
1 /* HomeBank -- Free, easy, personal accounting for everyone.
2 * Copyright (C) 1995-2014 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-filter.h"
24 #include "ui-account.h"
25 #include "ui-payee.h"
26 #include "ui-category.h"
27 #include "gtk-dateentry.h"
28
29
30 /****************************************************************************/
31 /* Debug macros */
32 /****************************************************************************/
33 #define MYDEBUG 0
34
35 #if MYDEBUG
36 #define DB(x) (x);
37 #else
38 #define DB(x);
39 #endif
40
41 /* our global datas */
42 extern struct HomeBank *GLOBALS;
43
44
45 extern char *paymode_label_names[];
46 extern GdkPixbuf *paymode_icons[];
47
48 gchar *CYA_FLT_TYPE[] = {
49 N_("Expense"),
50 N_("Income"),
51 "",
52 N_("Any Type"),
53 NULL
54 };
55
56 gchar *CYA_FLT_STATUS[] = {
57 N_("Uncategorized"),
58 N_("Unreconciled"),
59 "",
60 N_("Any Status"),
61 NULL
62 };
63
64 gchar *CYA_FLT_RANGE[] = {
65 N_("This Month"),
66 N_("Last Month"),
67 N_("This Quarter"),
68 N_("Last Quarter"),
69 N_("This Year"),
70 N_("Last Year"),
71 "",
72 N_("Last 30 days"),
73 N_("Last 60 days"),
74 N_("Last 90 days"),
75 N_("Last 12 months"),
76 "",
77 N_("Other..."),
78 "",
79 N_("All date"),
80 NULL
81 };
82
83
84 gchar *CYA_SELECT[] =
85 {
86 "----",
87 N_("All month"),
88 N_("January"),
89 N_("February"),
90 N_("March"),
91 N_("April"),
92 N_("May"),
93 N_("June"),
94 N_("July"),
95 N_("August"),
96 N_("September"),
97 N_("October"),
98 N_("November"),
99 N_("December"),
100 NULL
101 };
102
103
104 /* = = = = = = = = = = = = = = = = = = = = */
105
106 /*
107 **
108 */
109 static void ui_flt_manage_acc_select(GtkWidget *widget, gpointer user_data)
110 {
111 struct ui_flt_manage_data *data;
112 gint select = GPOINTER_TO_INT(user_data);
113 GtkTreeModel *model;
114 GtkTreeIter iter;
115 gboolean valid;
116 gboolean toggle;
117
118 DB( g_print("(ui_flt_manage) acc select\n") );
119
120 data = g_object_get_data(G_OBJECT(gtk_widget_get_ancestor(widget, GTK_TYPE_WINDOW)), "inst_data");
121
122 model = gtk_tree_view_get_model(GTK_TREE_VIEW(data->LV_acc));
123 valid = gtk_tree_model_get_iter_first(GTK_TREE_MODEL(model), &iter);
124 while (valid)
125 {
126 switch(select)
127 {
128 case BUTTON_ALL:
129 gtk_list_store_set (GTK_LIST_STORE (model), &iter, LST_DEFACC_TOGGLE, TRUE, -1);
130 break;
131 case BUTTON_NONE:
132 gtk_list_store_set (GTK_LIST_STORE (model), &iter, LST_DEFACC_TOGGLE, FALSE, -1);
133 break;
134 case BUTTON_INVERT:
135 gtk_tree_model_get (model, &iter, LST_DEFACC_TOGGLE, &toggle, -1);
136 toggle ^= 1;
137 gtk_list_store_set (GTK_LIST_STORE (model), &iter, LST_DEFACC_TOGGLE, toggle, -1);
138 break;
139 }
140 valid = gtk_tree_model_iter_next(GTK_TREE_MODEL(model), &iter);
141 }
142 }
143
144 /*
145 **
146 */
147 static void ui_flt_manage_pay_select(GtkWidget *widget, gpointer user_data)
148 {
149 struct ui_flt_manage_data *data;
150 gint select = GPOINTER_TO_INT(user_data);
151 GtkTreeModel *model;
152 GtkTreeIter iter;
153 gboolean valid;
154 gboolean toggle;
155
156 DB( g_print("(ui_flt_manage) pay select\n") );
157
158 data = g_object_get_data(G_OBJECT(gtk_widget_get_ancestor(widget, GTK_TYPE_WINDOW)), "inst_data");
159
160 model = gtk_tree_view_get_model(GTK_TREE_VIEW(data->LV_pay));
161 valid = gtk_tree_model_get_iter_first(GTK_TREE_MODEL(model), &iter);
162 while (valid)
163 {
164 switch(select)
165 {
166 case BUTTON_ALL:
167 gtk_list_store_set (GTK_LIST_STORE (model), &iter, LST_DEFPAY_TOGGLE, TRUE, -1);
168 break;
169 case BUTTON_NONE:
170 gtk_list_store_set (GTK_LIST_STORE (model), &iter, LST_DEFPAY_TOGGLE, FALSE, -1);
171 break;
172 case BUTTON_INVERT:
173 gtk_tree_model_get (model, &iter, LST_DEFPAY_TOGGLE, &toggle, -1);
174 toggle ^= 1;
175 gtk_list_store_set (GTK_LIST_STORE (model), &iter, LST_DEFPAY_TOGGLE, toggle, -1);
176 break;
177 }
178 valid = gtk_tree_model_iter_next(GTK_TREE_MODEL(model), &iter);
179 }
180 }
181
182 /*
183 **
184 */
185 static void ui_flt_manage_cat_select(GtkWidget *widget, gpointer user_data)
186 {
187 struct ui_flt_manage_data *data;
188 gint select = GPOINTER_TO_INT(user_data);
189 GtkTreeModel *model;
190 GtkTreeIter iter, child;
191 gboolean valid;
192 gint n_child;
193 gboolean toggle;
194
195 DB( g_print("(ui_flt_manage) pay select\n") );
196
197 data = g_object_get_data(G_OBJECT(gtk_widget_get_ancestor(widget, GTK_TYPE_WINDOW)), "inst_data");
198
199 model = gtk_tree_view_get_model(GTK_TREE_VIEW(data->LV_cat));
200 valid = gtk_tree_model_get_iter_first(GTK_TREE_MODEL(model), &iter);
201 while (valid)
202 {
203 switch(select)
204 {
205 case BUTTON_ALL:
206 gtk_tree_store_set (GTK_TREE_STORE (model), &iter, LST_DEFCAT_TOGGLE, TRUE, -1);
207 break;
208 case BUTTON_NONE:
209 gtk_tree_store_set (GTK_TREE_STORE (model), &iter, LST_DEFCAT_TOGGLE, FALSE, -1);
210 break;
211 case BUTTON_INVERT:
212 gtk_tree_model_get (model, &iter, LST_DEFCAT_TOGGLE, &toggle, -1);
213 toggle ^= 1;
214 gtk_tree_store_set (GTK_TREE_STORE (model), &iter, LST_DEFCAT_TOGGLE, toggle, -1);
215 break;
216 }
217
218 n_child = gtk_tree_model_iter_n_children (GTK_TREE_MODEL(model), &iter);
219 gtk_tree_model_iter_children (GTK_TREE_MODEL(model), &child, &iter);
220 while(n_child > 0)
221 {
222
223 switch(select)
224 {
225 case BUTTON_ALL:
226 gtk_tree_store_set (GTK_TREE_STORE (model), &child, LST_DEFCAT_TOGGLE, TRUE, -1);
227 break;
228 case BUTTON_NONE:
229 gtk_tree_store_set (GTK_TREE_STORE (model), &child, LST_DEFCAT_TOGGLE, FALSE, -1);
230 break;
231 case BUTTON_INVERT:
232 gtk_tree_model_get (model, &child, LST_DEFCAT_TOGGLE, &toggle, -1);
233 toggle ^= 1;
234 gtk_tree_store_set (GTK_TREE_STORE (model), &child, LST_DEFCAT_TOGGLE, toggle, -1);
235 break;
236 }
237
238 n_child--;
239 gtk_tree_model_iter_next(GTK_TREE_MODEL(model), &child);
240 }
241
242 valid = gtk_tree_model_iter_next(GTK_TREE_MODEL(model), &iter);
243 }
244
245 }
246
247 /*
248 **
249 */
250 static void ui_flt_manage_option_update(GtkWidget *widget, gpointer user_data)
251 {
252 struct ui_flt_manage_data *data;
253 gint active, i;
254 gboolean sensitive;
255
256 DB( g_print("(ui_flt_manage) update\n") );
257
258 data = g_object_get_data(G_OBJECT(gtk_widget_get_ancestor(widget, GTK_TYPE_WINDOW)), "inst_data");
259
260 // status
261 active = gtk_combo_box_get_active(GTK_COMBO_BOX(data->CY_option[FILTER_STATUS]));
262 sensitive = active == 0 ? FALSE : TRUE;
263 gtk_widget_set_sensitive(data->CM_reconciled, sensitive);
264 gtk_widget_set_sensitive(data->CM_reminded, sensitive);
265
266 // date
267 active = gtk_combo_box_get_active(GTK_COMBO_BOX(data->CY_option[FILTER_DATE]));
268 sensitive = active == 0 ? FALSE : TRUE;
269 gtk_widget_set_sensitive(data->PO_mindate, sensitive);
270 gtk_widget_set_sensitive(data->PO_maxdate, sensitive);
271 gtk_widget_set_sensitive(data->CY_month, sensitive);
272 gtk_widget_set_sensitive(data->NB_year, sensitive);
273
274 // amount
275 active = gtk_combo_box_get_active(GTK_COMBO_BOX(data->CY_option[FILTER_AMOUNT]));
276 sensitive = active == 0 ? FALSE : TRUE;
277 gtk_widget_set_sensitive(data->ST_minamount, sensitive);
278 gtk_widget_set_sensitive(data->ST_maxamount, sensitive);
279
280 // text
281 active = gtk_combo_box_get_active(GTK_COMBO_BOX(data->CY_option[FILTER_TEXT]));
282 sensitive = active == 0 ? FALSE : TRUE;
283 gtk_widget_set_sensitive(data->CM_exact, sensitive);
284 gtk_widget_set_sensitive(data->ST_wording, sensitive);
285 gtk_widget_set_sensitive(data->ST_info, sensitive);
286 gtk_widget_set_sensitive(data->ST_tag, sensitive);
287
288 //paymode
289 active = gtk_combo_box_get_active(GTK_COMBO_BOX(data->CY_option[FILTER_PAYMODE]));
290 sensitive = active == 0 ? FALSE : TRUE;
291 for(i=0;i<NUM_PAYMODE_MAX;i++)
292 {
293 gtk_widget_set_sensitive(data->CM_paymode[i], sensitive);
294 }
295
296 //account
297 if(data->show_account == TRUE)
298 {
299 active = gtk_combo_box_get_active(GTK_COMBO_BOX(data->CY_option[FILTER_ACCOUNT]));
300 sensitive = active == 0 ? FALSE : TRUE;
301 gtk_widget_set_sensitive(data->LV_acc, sensitive);
302 for(i=0;i<MAX_BUTTON;i++)
303 {
304 gtk_widget_set_sensitive(data->BT_acc[i], sensitive);
305 }
306
307
308 }
309
310 //payee
311 active = gtk_combo_box_get_active(GTK_COMBO_BOX(data->CY_option[FILTER_PAYEE]));
312 sensitive = active == 0 ? FALSE : TRUE;
313 gtk_widget_set_sensitive(data->LV_pay, sensitive);
314 for(i=0;i<MAX_BUTTON;i++)
315 {
316 gtk_widget_set_sensitive(data->BT_pay[i], sensitive);
317 }
318
319 //category
320 active = gtk_combo_box_get_active(GTK_COMBO_BOX(data->CY_option[FILTER_CATEGORY]));
321 sensitive = active == 0 ? FALSE : TRUE;
322 gtk_widget_set_sensitive(data->LV_cat, sensitive);
323 for(i=0;i<MAX_BUTTON;i++)
324 {
325 gtk_widget_set_sensitive(data->BT_cat[i], sensitive);
326 }
327
328
329
330 }
331
332
333 /*
334 **
335 */
336 static void ui_flt_manage_get(struct ui_flt_manage_data *data)
337 {
338 gint i;
339 gchar *txt;
340
341 DB( g_print("(ui_flt_manage) get\n") );
342
343 if(data->filter !=NULL)
344 {
345 GtkTreeModel *model;
346 //GtkTreeSelection *selection;
347 GtkTreeIter iter, child;
348 gint n_child;
349 gboolean valid;
350 gboolean toggled;
351
352 for(i=0;i<FILTER_MAX;i++)
353 {
354 if(data->show_account == FALSE && i == FILTER_ACCOUNT)
355 continue;
356
357 data->filter->option[i] = gtk_combo_box_get_active(GTK_COMBO_BOX(data->CY_option[i]));
358 }
359
360 //date
361 DB( g_print(" date\n") );
362 data->filter->mindate = gtk_dateentry_get_date(GTK_DATE_ENTRY(data->PO_mindate));
363 data->filter->maxdate = gtk_dateentry_get_date(GTK_DATE_ENTRY(data->PO_maxdate));
364
365 //status
366 DB( g_print(" status\n") );
367 data->filter->reconciled = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(data->CM_reconciled));
368 data->filter->reminded = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(data->CM_reminded));
369
370 data->filter->forceadd = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(data->CM_forceadd));
371 data->filter->forcechg = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(data->CM_forcechg));
372
373 //paymode
374 DB( g_print(" paymode\n") );
375 for(i=0;i<NUM_PAYMODE_MAX;i++)
376 data->filter->paymode[i] = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(data->CM_paymode[i]));
377
378 //amount
379 data->filter->minamount = gtk_spin_button_get_value(GTK_SPIN_BUTTON(data->ST_minamount));
380 data->filter->maxamount = gtk_spin_button_get_value(GTK_SPIN_BUTTON(data->ST_maxamount));
381
382 //text:wording
383 data->filter->exact = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(data->CM_exact));
384 //free any previous string
385 if( data->filter->wording )
386 {
387 g_free(data->filter->wording);
388 data->filter->wording = NULL;
389 }
390 txt = (gchar *)gtk_entry_get_text(GTK_ENTRY(data->ST_wording));
391
392 if (txt && *txt) // ignore if entry is empty
393 {
394 data->filter->wording = g_strdup(txt);
395 }
396
397 //text:info
398 //free any previous string
399 if( data->filter->info )
400 {
401 g_free(data->filter->info);
402 data->filter->info = NULL;
403 }
404 txt = (gchar *)gtk_entry_get_text(GTK_ENTRY(data->ST_info));
405 // ignore if entry is empty
406 if (txt && *txt)
407 {
408 data->filter->info = g_strdup(txt);
409 }
410
411 //text:tag
412 //free any previous string
413 if( data->filter->tag )
414 {
415 g_free(data->filter->tag);
416 data->filter->tag = NULL;
417 }
418 txt = (gchar *)gtk_entry_get_text(GTK_ENTRY(data->ST_tag));
419 // ignore if entry is empty
420 if (txt && *txt)
421 {
422 data->filter->tag = g_strdup(txt);
423 }
424
425
426 // account
427 if(data->show_account == TRUE)
428 {
429 DB( g_print(" account\n") );
430
431 model = gtk_tree_view_get_model(GTK_TREE_VIEW(data->LV_acc));
432 //selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(data->LV_acc));
433 i=0; valid = gtk_tree_model_get_iter_first(GTK_TREE_MODEL(model), &iter);
434 while (valid)
435 {
436 Account *accitem;
437
438 gtk_tree_model_get (model, &iter,
439 LST_DEFACC_TOGGLE, &toggled,
440 LST_DEFACC_DATAS, &accitem,
441 -1);
442
443 //data->filter->acc[i] = gtk_tree_selection_iter_is_selected(selection, &iter);
444 accitem->filter = toggled;
445
446 /* Make iter point to the next row in the list store */
447 i++; valid = gtk_tree_model_iter_next(GTK_TREE_MODEL(model), &iter);
448 }
449 }
450
451 // payee
452 DB( g_print(" payee\n") );
453
454 model = gtk_tree_view_get_model(GTK_TREE_VIEW(data->LV_pay));
455 //selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(data->LV_pay));
456 i=0; valid = gtk_tree_model_get_iter_first(GTK_TREE_MODEL(model), &iter);
457 while (valid)
458 {
459 Payee *payitem;
460
461 gtk_tree_model_get (model, &iter,
462 LST_DEFPAY_TOGGLE, &toggled,
463 LST_DEFPAY_DATAS, &payitem,
464 -1);
465
466 //data->filter->pay[i] = gtk_tree_selection_iter_is_selected(selection, &iter);
467 payitem->filter = toggled;
468
469 /* Make iter point to the next row in the list store */
470 i++; valid = gtk_tree_model_iter_next(GTK_TREE_MODEL(model), &iter);
471 }
472
473 // category
474 DB( g_print(" category\n") );
475
476 model = gtk_tree_view_get_model(GTK_TREE_VIEW(data->LV_cat));
477 //selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(data->LV_cat));
478 i=0; valid = gtk_tree_model_get_iter_first(GTK_TREE_MODEL(model), &iter);
479 while (valid)
480 {
481 Category *catitem;
482
483 gtk_tree_model_get (model, &iter,
484 LST_DEFCAT_TOGGLE, &toggled,
485 LST_DEFCAT_DATAS, &catitem,
486 -1);
487
488 //data->filter->cat[i] = gtk_tree_selection_iter_is_selected(selection, &iter);
489 //data->filter->cat[i] = toggled;
490 catitem->filter = toggled;
491
492 n_child = gtk_tree_model_iter_n_children (GTK_TREE_MODEL(model), &iter);
493 gtk_tree_model_iter_children (GTK_TREE_MODEL(model), &child, &iter);
494 while(n_child > 0)
495 {
496 i++;
497
498 gtk_tree_model_get (model, &child,
499 LST_DEFCAT_TOGGLE, &toggled,
500 LST_DEFCAT_DATAS, &catitem,
501 -1);
502
503
504 //data->filter->cat[i] = toggled;
505 //data->filter->cat[i] = gtk_tree_selection_iter_is_selected(selection, &child);
506 catitem->filter = toggled;
507
508 n_child--;
509 gtk_tree_model_iter_next(GTK_TREE_MODEL(model), &child);
510 }
511
512 /* Make iter point to the next row in the list store */
513 i++; valid = gtk_tree_model_iter_next(GTK_TREE_MODEL(model), &iter);
514 }
515
516 // active tab
517 data->filter->last_tab = gtk_notebook_get_current_page(GTK_NOTEBOOK(data->notebook));
518 DB( g_print(" page is %d\n", data->filter->last_tab) );
519
520
521 }
522 }
523
524
525 /*
526 **
527 */
528 static void ui_flt_manage_set(struct ui_flt_manage_data *data)
529 {
530
531 DB( g_print("(ui_flt_manage) set\n") );
532
533 if(data->filter != NULL)
534 {
535 GtkTreeModel *model;
536 //GtkTreeSelection *selection;
537 GtkTreeIter iter, child;
538 GDate *date;
539 gint n_child;
540 gboolean valid;
541 gint i;
542
543 DB( g_print(" options\n") );
544
545 for(i=0;i<FILTER_MAX;i++)
546 {
547 if(data->show_account == FALSE && i == FILTER_ACCOUNT)
548 continue;
549
550 gtk_combo_box_set_active(GTK_COMBO_BOX(data->CY_option[i]), data->filter->option[i]);
551 }
552
553 //DB( g_print(" setdate %d to %x\n", data->filter->mindate, data->PO_mindate) );
554 //DB( g_print(" setdate %d to %x\n", 0, data->PO_mindate) );
555 //date
556 DB( g_print(" date\n") );
557 gtk_dateentry_set_date(GTK_DATE_ENTRY(data->PO_mindate), data->filter->mindate);
558 gtk_dateentry_set_date(GTK_DATE_ENTRY(data->PO_maxdate), data->filter->maxdate);
559 date = g_date_new_julian(data->filter->maxdate);
560 gtk_spin_button_set_value(GTK_SPIN_BUTTON(data->NB_year), g_date_get_year(date));
561 g_date_free(date);
562
563 //status
564 DB( g_print(" status\n") );
565 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(data->CM_reconciled), data->filter->reconciled);
566 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(data->CM_reminded), data->filter->reminded);
567
568 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(data->CM_forceadd), data->filter->forceadd);
569 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(data->CM_forcechg), data->filter->forcechg);
570
571 //paymode
572 DB( g_print(" paymode\n") );
573
574 for(i=0;i<NUM_PAYMODE_MAX;i++)
575 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(data->CM_paymode[i]), data->filter->paymode[i]);
576
577 //amount
578 gtk_spin_button_set_value(GTK_SPIN_BUTTON(data->ST_minamount), data->filter->minamount);
579 gtk_spin_button_set_value(GTK_SPIN_BUTTON(data->ST_maxamount), data->filter->maxamount);
580
581 //text
582 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(data->CM_exact), data->filter->exact);
583 gtk_entry_set_text(GTK_ENTRY(data->ST_info), (data->filter->info != NULL) ? data->filter->info : "");
584 gtk_entry_set_text(GTK_ENTRY(data->ST_wording), (data->filter->wording != NULL) ? data->filter->wording : "");
585 gtk_entry_set_text(GTK_ENTRY(data->ST_tag), (data->filter->tag != NULL) ? data->filter->tag : "");
586
587 //account
588 if(data->show_account == TRUE)
589 {
590 DB( g_print(" account\n") );
591
592 model = gtk_tree_view_get_model(GTK_TREE_VIEW(data->LV_acc));
593 //selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(data->LV_acc));
594 i=0; valid = gtk_tree_model_get_iter_first(GTK_TREE_MODEL(model), &iter);
595 while (valid)
596 {
597 Account *accitem;
598
599 gtk_tree_model_get (model, &iter,
600 LST_DEFACC_DATAS, &accitem,
601 -1);
602
603 if(accitem->filter == TRUE)
604 //gtk_tree_selection_select_iter(selection, &iter);
605 gtk_list_store_set (GTK_LIST_STORE (model), &iter,
606 LST_DEFACC_TOGGLE, TRUE, -1);
607
608 /* Make iter point to the next row in the list store */
609 i++; valid = gtk_tree_model_iter_next(GTK_TREE_MODEL(model), &iter);
610 }
611 }
612
613 // payee
614 DB( g_print(" payee\n") );
615
616 model = gtk_tree_view_get_model(GTK_TREE_VIEW(data->LV_pay));
617 //selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(data->LV_pay));
618 i=0; valid = gtk_tree_model_get_iter_first(GTK_TREE_MODEL(model), &iter);
619 while (valid)
620 {
621 Payee *payitem;
622
623 gtk_tree_model_get (model, &iter,
624 LST_DEFPAY_DATAS, &payitem,
625 -1);
626
627 if(payitem->filter == TRUE)
628 gtk_list_store_set (GTK_LIST_STORE (model), &iter, LST_DEFPAY_TOGGLE, TRUE, -1);
629
630 /* Make iter point to the next row in the list store */
631 i++; valid = gtk_tree_model_iter_next(GTK_TREE_MODEL(model), &iter);
632 }
633
634 // category
635 DB( g_print(" category\n") );
636
637 model = gtk_tree_view_get_model(GTK_TREE_VIEW(data->LV_cat));
638 //selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(data->LV_cat));
639 i=0; valid = gtk_tree_model_get_iter_first(GTK_TREE_MODEL(model), &iter);
640 while (valid)
641 {
642 Category *catitem;
643
644 gtk_tree_model_get (model, &iter,
645 LST_DEFCAT_DATAS, &catitem,
646 -1);
647
648 if(catitem->filter == TRUE)
649 gtk_tree_store_set (GTK_TREE_STORE (model), &iter, LST_DEFCAT_TOGGLE, TRUE, -1);
650
651 n_child = gtk_tree_model_iter_n_children (GTK_TREE_MODEL(model), &iter);
652 gtk_tree_model_iter_children (GTK_TREE_MODEL(model), &child, &iter);
653 while(n_child > 0)
654 {
655 i++;
656
657 gtk_tree_model_get (model, &child,
658 LST_DEFCAT_DATAS, &catitem,
659 -1);
660
661 if(catitem->filter == TRUE)
662 gtk_tree_store_set (GTK_TREE_STORE (model), &child, LST_DEFCAT_TOGGLE, TRUE, -1);
663
664 n_child--;
665 gtk_tree_model_iter_next(GTK_TREE_MODEL(model), &child);
666 }
667
668 /* Make iter point to the next row in the list store */
669 i++; valid = gtk_tree_model_iter_next(GTK_TREE_MODEL(model), &iter);
670 }
671
672 // active tab
673 gtk_notebook_set_current_page(GTK_NOTEBOOK(data->notebook), data->filter->last_tab);
674 DB( g_print(" set page %d\n", data->filter->last_tab) );
675
676 }
677 }
678
679
680 /*
681 **
682 */
683 static void ui_flt_manage_clear(GtkWidget *widget, gpointer user_data)
684 {
685 struct ui_flt_manage_data *data;
686
687 data = g_object_get_data(G_OBJECT(gtk_widget_get_ancestor(GTK_WIDGET(widget), GTK_TYPE_WINDOW)), "inst_data");
688
689 DB( g_print("(ui_flt_manage) clear\n") );
690
691 filter_default_all_set(data->filter);
692
693 ui_flt_manage_set(data);
694
695 }
696
697
698 /*
699 **
700 */
701 static void ui_flt_manage_setup(struct ui_flt_manage_data *data)
702 {
703
704 DB( g_print("(ui_flt_manage) setup\n") );
705
706 if(data->show_account == TRUE && data->LV_acc != NULL)
707 {
708 //gtk_tree_selection_set_mode(GTK_TREE_SELECTION(gtk_tree_view_get_selection(GTK_TREE_VIEW(data->LV_acc))), GTK_SELECTION_MULTIPLE);
709
710 ui_acc_listview_populate(data->LV_acc, ACC_LST_INSERT_REPORT);
711 //populate_view_acc(data->LV_acc, GLOBALS->acc_list, FALSE);
712 }
713
714 if(data->LV_pay)
715 {
716 //gtk_tree_selection_set_mode(GTK_TREE_SELECTION(gtk_tree_view_get_selection(GTK_TREE_VIEW(data->LV_pay))), GTK_SELECTION_MULTIPLE);
717
718 ui_pay_listview_populate(data->LV_pay);
719 //populate_view_pay(data->LV_pay, GLOBALS->pay_list, FALSE);
720 }
721
722 if(data->LV_cat)
723 {
724 //gtk_tree_selection_set_mode(GTK_TREE_SELECTION(gtk_tree_view_get_selection(GTK_TREE_VIEW(data->LV_cat))), GTK_SELECTION_MULTIPLE);
725
726 //populate_view_cat(data->LV_cat, GLOBALS->cat_list, FALSE);
727 ui_cat_listview_populate(data->LV_cat);
728 gtk_tree_view_expand_all (GTK_TREE_VIEW(data->LV_cat));
729 }
730 }
731
732 /*
733 **
734 */
735 static GtkWidget *ui_flt_manage_page_category (struct ui_flt_manage_data *data)
736 {
737 GtkWidget *container, *scrollwin, *hbox, *vbox, *label, *widget;
738
739 container = gtk_vbox_new(FALSE, HB_BOX_SPACING);
740 gtk_container_set_border_width (GTK_CONTAINER (container), HB_MAINBOX_SPACING);
741
742 hbox = gtk_hbox_new(FALSE, HB_BOX_SPACING);
743 gtk_box_pack_start (GTK_BOX (container), hbox, FALSE, FALSE, 0);
744
745 label = make_label(_("_Option:"), 1.0, 0.5);
746 gtk_box_pack_start (GTK_BOX (hbox), label, TRUE, TRUE, 0);
747 data->CY_option[FILTER_CATEGORY] = make_nainex(label);
748 gtk_box_pack_start (GTK_BOX (hbox), data->CY_option[FILTER_CATEGORY], TRUE, TRUE, 0);
749
750 hbox = gtk_hbox_new(FALSE, HB_BOX_SPACING);
751 gtk_box_pack_start (GTK_BOX (container), hbox, TRUE, TRUE, 0);
752
753 scrollwin = gtk_scrolled_window_new(NULL,NULL);
754 gtk_box_pack_start (GTK_BOX (hbox), scrollwin, TRUE, TRUE, 0);
755
756 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrollwin), GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC);
757 gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (scrollwin), GTK_SHADOW_ETCHED_IN);
758 //gtk_container_set_border_width (GTK_CONTAINER(scrollwin), HB_BOX_SPACING);
759
760 data->LV_cat = (GtkWidget *)ui_cat_listview_new(TRUE);
761 gtk_container_add(GTK_CONTAINER(scrollwin), data->LV_cat);
762
763 vbox = gtk_vbox_new(FALSE, HB_BOX_SPACING);
764 gtk_box_pack_start (GTK_BOX (hbox), vbox, FALSE, FALSE, 0);
765
766 widget = gtk_button_new_with_label(_("All"));
767 gtk_box_pack_start (GTK_BOX (vbox), widget, FALSE, FALSE, 0);
768 data->BT_cat[BUTTON_ALL] = widget;
769
770 widget = gtk_button_new_with_label(_("None"));
771 gtk_box_pack_start (GTK_BOX (vbox), widget, FALSE, FALSE, 0);
772 data->BT_cat[BUTTON_NONE] = widget;
773
774 widget = gtk_button_new_with_label(_("Invert"));
775 gtk_box_pack_start (GTK_BOX (vbox), widget, FALSE, FALSE, 0);
776 data->BT_cat[BUTTON_INVERT] = widget;
777
778 return(container);
779 }
780
781 /*
782 **
783 */
784 static GtkWidget *ui_flt_manage_page_payee (struct ui_flt_manage_data *data)
785 {
786 GtkWidget *container, *scrollwin, *hbox, *vbox, *label, *widget;
787
788 container = gtk_vbox_new(FALSE, HB_BOX_SPACING);
789 gtk_container_set_border_width (GTK_CONTAINER (container), HB_MAINBOX_SPACING);
790
791 hbox = gtk_hbox_new(FALSE, HB_BOX_SPACING);
792 gtk_box_pack_start (GTK_BOX (container), hbox, FALSE, FALSE, 0);
793
794 label = make_label(_("_Option:"), 1.0, 0.5);
795 gtk_box_pack_start (GTK_BOX (hbox), label, TRUE, TRUE, 0);
796 data->CY_option[FILTER_PAYEE] = make_nainex(label);
797 gtk_box_pack_start (GTK_BOX (hbox), data->CY_option[FILTER_PAYEE], TRUE, TRUE, 0);
798
799 hbox = gtk_hbox_new(FALSE, HB_BOX_SPACING);
800 gtk_box_pack_start (GTK_BOX (container), hbox, TRUE, TRUE, 0);
801
802 scrollwin = gtk_scrolled_window_new(NULL,NULL);
803 gtk_box_pack_start (GTK_BOX (hbox), scrollwin, TRUE, TRUE, 0);
804
805 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrollwin), GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC);
806 gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (scrollwin), GTK_SHADOW_ETCHED_IN);
807 //gtk_container_set_border_width (GTK_CONTAINER(scrollwin), HB_BOX_SPACING);
808
809 data->LV_pay = (GtkWidget *)ui_pay_listview_new(TRUE);
810 gtk_container_add(GTK_CONTAINER(scrollwin), data->LV_pay);
811
812 vbox = gtk_vbox_new(FALSE, HB_BOX_SPACING);
813 gtk_box_pack_start (GTK_BOX (hbox), vbox, FALSE, FALSE, 0);
814
815 widget = gtk_button_new_with_label(_("All"));
816 gtk_box_pack_start (GTK_BOX (vbox), widget, FALSE, FALSE, 0);
817 data->BT_pay[BUTTON_ALL] = widget;
818
819 widget = gtk_button_new_with_label(_("None"));
820 gtk_box_pack_start (GTK_BOX (vbox), widget, FALSE, FALSE, 0);
821 data->BT_pay[BUTTON_NONE] = widget;
822
823 widget = gtk_button_new_with_label(_("Invert"));
824 gtk_box_pack_start (GTK_BOX (vbox), widget, FALSE, FALSE, 0);
825 data->BT_pay[BUTTON_INVERT] = widget;
826
827 return(container);
828 }
829
830 /*
831 ** account filter
832 */
833 static GtkWidget *ui_flt_manage_page_account (struct ui_flt_manage_data *data)
834 {
835 GtkWidget *container, *scrollwin, *hbox, *vbox, *label, *widget;
836
837 container = gtk_vbox_new(FALSE, HB_BOX_SPACING);
838 gtk_container_set_border_width (GTK_CONTAINER (container), HB_MAINBOX_SPACING);
839
840 hbox = gtk_hbox_new(FALSE, HB_BOX_SPACING);
841 gtk_box_pack_start (GTK_BOX (container), hbox, FALSE, FALSE, 0);
842
843 label = make_label(_("_Option:"), 1.0, 0.5);
844 gtk_box_pack_start (GTK_BOX (hbox), label, TRUE, TRUE, 0);
845 data->CY_option[FILTER_ACCOUNT] = make_nainex(label);
846 gtk_box_pack_start (GTK_BOX (hbox), data->CY_option[FILTER_ACCOUNT], TRUE, TRUE, 0);
847
848 hbox = gtk_hbox_new(FALSE, HB_BOX_SPACING);
849 gtk_box_pack_start (GTK_BOX (container), hbox, TRUE, TRUE, 0);
850
851 scrollwin = gtk_scrolled_window_new(NULL,NULL);
852 gtk_box_pack_start (GTK_BOX (hbox), scrollwin, TRUE, TRUE, 0);
853
854 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrollwin), GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC);
855 gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (scrollwin), GTK_SHADOW_ETCHED_IN);
856 //gtk_container_set_border_width (GTK_CONTAINER(scrollwin), HB_BOX_SPACING);
857
858 data->LV_acc = ui_acc_listview_new(TRUE);
859 gtk_container_add(GTK_CONTAINER(scrollwin), data->LV_acc);
860
861 vbox = gtk_vbox_new(FALSE, HB_BOX_SPACING);
862 gtk_box_pack_start (GTK_BOX (hbox), vbox, FALSE, FALSE, 0);
863
864 widget = gtk_button_new_with_label(_("All"));
865 gtk_box_pack_start (GTK_BOX (vbox), widget, FALSE, FALSE, 0);
866 data->BT_acc[BUTTON_ALL] = widget;
867
868 widget = gtk_button_new_with_label(_("None"));
869 gtk_box_pack_start (GTK_BOX (vbox), widget, FALSE, FALSE, 0);
870 data->BT_acc[BUTTON_NONE] = widget;
871
872 widget = gtk_button_new_with_label(_("Invert"));
873 gtk_box_pack_start (GTK_BOX (vbox), widget, FALSE, FALSE, 0);
874 data->BT_acc[BUTTON_INVERT] = widget;
875
876 return(container);
877 }
878
879
880 static void get_period_minmax(guint month, guint year, guint32 *mindate, guint32 *maxdate)
881 {
882 GDate *date;
883
884 date = g_date_new();
885 if(month)
886 {
887 // mindate is month 1, year :: maxdate is last day of month, year
888 g_date_set_dmy(date, 1, month, year);
889 *mindate = g_date_get_julian(date);
890 g_date_add_days(date, g_date_get_days_in_month(month, year));
891 *maxdate = g_date_get_julian(date)-1;
892 }
893 else
894 {
895 g_date_set_dmy(date, 1, 1, year);
896 *mindate = g_date_get_julian(date);
897 g_date_set_dmy(date, 31, 12, year);
898 *maxdate = g_date_get_julian(date);
899 }
900 g_date_free(date);
901 }
902
903
904
905 static void ui_flt_manage_period_change(GtkWidget *widget, gpointer user_data)
906 {
907 struct ui_flt_manage_data *data;
908 gint month, year;
909
910 DB( g_print("(ui_flt_manage) period change\n") );
911
912 data = g_object_get_data(G_OBJECT(gtk_widget_get_ancestor(widget, GTK_TYPE_WINDOW)), "inst_data");
913
914
915 month = gtk_combo_box_get_active(GTK_COMBO_BOX(data->CY_month));
916 year = gtk_spin_button_get_value(GTK_SPIN_BUTTON(data->NB_year));
917
918 DB( g_print(" month=%d, year=%d\n", month, year) );
919
920
921 if(month != 0)
922 get_period_minmax(month-1, year, &data->filter->mindate, &data->filter->maxdate);
923 else
924 get_period_minmax(0, year, &data->filter->mindate, &data->filter->maxdate);
925
926 gtk_dateentry_set_date(GTK_DATE_ENTRY(data->PO_mindate), data->filter->mindate);
927 gtk_dateentry_set_date(GTK_DATE_ENTRY(data->PO_maxdate), data->filter->maxdate);
928 }
929
930
931
932 static GtkWidget *ui_flt_manage_part_date(struct ui_flt_manage_data *data)
933 {
934 GtkWidget *table, *label;
935 GtkWidget *alignment;
936 gint row;
937
938 // filter date
939 table = gtk_table_new (3, 3, FALSE);
940 gtk_table_set_row_spacings (GTK_TABLE (table), HB_TABROW_SPACING);
941 gtk_table_set_col_spacings (GTK_TABLE (table), HB_TABCOL_SPACING);
942
943 //gtk_box_pack_start (GTK_BOX (container), table, TRUE, TRUE, 0);
944 // gtk_alignment_new(xalign, yalign, xscale, yscale)
945 alignment = gtk_alignment_new(0.5, 0, 1.0, 0.0);
946 gtk_container_add(GTK_CONTAINER(alignment), table);
947
948
949 row = 0;
950 label = make_label(_("Filter Date"), 0.0, 0.5);
951 gimp_label_set_attributes(GTK_LABEL(label), PANGO_ATTR_WEIGHT, PANGO_WEIGHT_BOLD, -1);
952 gtk_table_attach_defaults (GTK_TABLE (table), label, 0, 3, row, row+1);
953 //gtk_table_attach (GTK_TABLE (table), label, 0, 3, row, row+1, (GtkAttachOptions) (GTK_FILL), (GtkAttachOptions) (0), 0, 0);
954
955 row++;
956 label = make_label("", 0.0, 0.5);
957 gtk_misc_set_padding (GTK_MISC (label), HB_BOX_SPACING, 0);
958 gtk_table_attach (GTK_TABLE (table), label, 0, 1, row, row+1, (GtkAttachOptions) (GTK_FILL), (GtkAttachOptions) (0), 0, 0);
959
960 label = make_label(_("_Option:"), 0, 0.5);
961 //----------------------------------------- l, r, t, b
962 gtk_table_attach (GTK_TABLE (table), label, 1, 2, row, row+1, (GtkAttachOptions) (GTK_FILL), (GtkAttachOptions) (0), 0, 0);
963 data->CY_option[FILTER_DATE] = make_nainex(label);
964 //gtk_table_attach_defaults (GTK_TABLE (table), data->CY_option[FILTER_DATE], 1, 2, row, row+1);
965 gtk_table_attach (GTK_TABLE (table), data->CY_option[FILTER_DATE], 2, 3, row, row+1, (GtkAttachOptions) (GTK_FILL|GTK_EXPAND), (GtkAttachOptions) (0), 0, 0);
966
967 row++;
968 label = make_label(_("_From:"), 0, 0.5);
969 gtk_table_attach (GTK_TABLE (table), label, 1, 2, row, row+1, (GtkAttachOptions) (GTK_FILL), (GtkAttachOptions) (0), 0, 0);
970 data->PO_mindate = gtk_dateentry_new();
971 //data->PO_mindate = gtk_entry_new();
972 //gtk_table_attach_defaults (GTK_TABLE (table), data->PO_mindate, 1, 2, row, row+1);
973 gtk_table_attach (GTK_TABLE (table), data->PO_mindate, 2, 3, row, row+1, (GtkAttachOptions) (GTK_FILL|GTK_EXPAND), (GtkAttachOptions) (0), 0, 0);
974
975 row++;
976 label = make_label(_("_To:"), 0, 0.5);
977 gtk_table_attach (GTK_TABLE (table), label, 1, 2, row, row+1, (GtkAttachOptions) (GTK_FILL), (GtkAttachOptions) (0), 0, 0);
978 data->PO_maxdate = gtk_dateentry_new();
979 //data->PO_maxdate = gtk_entry_new();
980 //gtk_table_attach_defaults (GTK_TABLE (table), data->PO_maxdate, 1, 2, row, row+1);
981 gtk_table_attach (GTK_TABLE (table), data->PO_maxdate, 2, 3, row, row+1, (GtkAttachOptions) (GTK_FILL|GTK_EXPAND), (GtkAttachOptions) (0), 0, 0);
982
983 row++;
984 label = make_label(_("_Month:"), 0, 0.5);
985 gtk_table_attach (GTK_TABLE (table), label, 1, 2, row, row+1, (GtkAttachOptions) (GTK_FILL), (GtkAttachOptions) (0), 0, 0);
986 data->CY_month = make_cycle(label, CYA_SELECT);
987 gtk_table_attach (GTK_TABLE (table), data->CY_month, 2, 3, row, row+1, (GtkAttachOptions) (GTK_FILL|GTK_EXPAND), (GtkAttachOptions) (0), 0, 0);
988
989 row++;
990 label = make_label(_("_Year:"), 0, 0.5);
991 gtk_table_attach (GTK_TABLE (table), label, 1, 2, row, row+1, (GtkAttachOptions) (GTK_FILL), (GtkAttachOptions) (0), 0, 0);
992 data->NB_year = make_year(label);
993 gtk_table_attach (GTK_TABLE (table), data->NB_year, 2, 3, row, row+1, (GtkAttachOptions) (GTK_FILL|GTK_EXPAND), (GtkAttachOptions) (0), 0, 0);
994
995 gtk_container_set_border_width(GTK_CONTAINER(alignment), HB_BOX_SPACING);
996
997 return alignment;
998 }
999
1000
1001 static GtkWidget *ui_flt_manage_part_text(struct ui_flt_manage_data *data)
1002 {
1003 GtkWidget *table, *label;
1004 GtkWidget *alignment;
1005 gint row;
1006
1007 table = gtk_table_new (3, 3, FALSE);
1008 gtk_table_set_row_spacings (GTK_TABLE (table), HB_TABROW_SPACING);
1009 gtk_table_set_col_spacings (GTK_TABLE (table), HB_TABCOL_SPACING);
1010
1011 //gtk_box_pack_start (GTK_BOX (container), table, TRUE, TRUE, 0);
1012 // gtk_alignment_new(xalign, yalign, xscale, yscale)
1013 alignment = gtk_alignment_new(0.5, 0, 1.0, 0.0);
1014 gtk_container_add(GTK_CONTAINER(alignment), table);
1015
1016
1017 row = 0;
1018 label = make_label(_("Filter Text"), 0.0, 0.5);
1019 gimp_label_set_attributes(GTK_LABEL(label), PANGO_ATTR_WEIGHT, PANGO_WEIGHT_BOLD, -1);
1020 gtk_table_attach_defaults (GTK_TABLE (table), label, 0, 3, row, row+1);
1021
1022 row++;
1023 label = make_label("", 0.0, 0.5);
1024 gtk_misc_set_padding (GTK_MISC (label), HB_BOX_SPACING, 0);
1025 gtk_table_attach (GTK_TABLE (table), label, 0, 1, row, row+1, (GtkAttachOptions) (GTK_FILL), (GtkAttachOptions) (0), 0, 0);
1026
1027 label = make_label(_("_Option:"), 0, 0.5);
1028 //----------------------------------------- l, r, t, b
1029 gtk_table_attach (GTK_TABLE (table), label, 1, 2, row, row+1, (GtkAttachOptions) (GTK_FILL), (GtkAttachOptions) (0), 0, 0);
1030
1031 //gtk_table_attach (GTK_TABLE (table), label, 0, 1, row, row+1, (GtkAttachOptions) (GTK_FILL), (GtkAttachOptions) (0), 0, 0);
1032 data->CY_option[FILTER_TEXT] = make_nainex(label);
1033 gtk_table_attach (GTK_TABLE (table), data->CY_option[FILTER_TEXT], 2, 3, row, row+1, (GtkAttachOptions) (GTK_FILL|GTK_EXPAND), (GtkAttachOptions) (0), 0, 0);
1034
1035 row++;
1036 data->CM_exact = gtk_check_button_new_with_mnemonic (_("Case _sensitive"));
1037 gtk_table_attach (GTK_TABLE (table), data->CM_exact, 2, 3, row, row+1, (GtkAttachOptions) (GTK_FILL|GTK_EXPAND), (GtkAttachOptions) (0), 0, 0);
1038
1039 row++;
1040 label = make_label(_("_Memo:"), 0, 0.5);
1041 gtk_table_attach (GTK_TABLE (table), label, 1, 2, row, row+1, (GtkAttachOptions) (GTK_FILL), (GtkAttachOptions) (0), 0, 0);
1042 data->ST_wording = make_string(label);
1043 gtk_table_attach (GTK_TABLE (table), data->ST_wording, 2, 3, row, row+1, (GtkAttachOptions) (GTK_FILL|GTK_EXPAND), (GtkAttachOptions) (0), 0, 0);
1044
1045 row++;
1046 label = make_label(_("_Info:"), 0, 0.5);
1047 //----------------------------------------- l, r, t, b
1048 gtk_table_attach (GTK_TABLE (table), label, 1, 2, row, row+1, (GtkAttachOptions) (GTK_FILL), (GtkAttachOptions) (0), 0, 0);
1049 data->ST_info = make_string(label);
1050 gtk_table_attach (GTK_TABLE (table), data->ST_info, 2, 3, row, row+1, (GtkAttachOptions) (GTK_FILL|GTK_EXPAND), (GtkAttachOptions) (0), 0, 0);
1051
1052 row++;
1053 label = make_label(_("_Tag:"), 0, 0.5);
1054 //----------------------------------------- l, r, t, b
1055 gtk_table_attach (GTK_TABLE (table), label, 1, 2, row, row+1, (GtkAttachOptions) (GTK_FILL), (GtkAttachOptions) (0), 0, 0);
1056 data->ST_tag = make_string(label);
1057 gtk_table_attach (GTK_TABLE (table), data->ST_tag, 2, 3, row, row+1, (GtkAttachOptions) (GTK_FILL|GTK_EXPAND), (GtkAttachOptions) (0), 0, 0);
1058
1059 gtk_container_set_border_width(GTK_CONTAINER(alignment), HB_BOX_SPACING);
1060
1061 return alignment;
1062 }
1063
1064 static GtkWidget *ui_flt_manage_part_amount(struct ui_flt_manage_data *data)
1065 {
1066 GtkWidget *table, *label;
1067 GtkWidget *alignment;
1068 gint row;
1069
1070
1071 table = gtk_table_new (3, 3, FALSE);
1072 gtk_table_set_row_spacings (GTK_TABLE (table), HB_TABROW_SPACING);
1073 gtk_table_set_col_spacings (GTK_TABLE (table), HB_TABCOL_SPACING);
1074
1075 //gtk_box_pack_start (GTK_BOX (container), table, TRUE, TRUE, 0);
1076 // gtk_alignment_new(xalign, yalign, xscale, yscale)
1077 alignment = gtk_alignment_new(0.5, 0, 1.0, 0.0);
1078 gtk_container_add(GTK_CONTAINER(alignment), table);
1079
1080 // Amount section
1081 row = 0;
1082
1083 label = make_label(_("Filter Amount"), 0.0, 0.5);
1084 gimp_label_set_attributes(GTK_LABEL(label), PANGO_ATTR_WEIGHT, PANGO_WEIGHT_BOLD, -1);
1085 gtk_table_attach_defaults (GTK_TABLE (table), label, 0, 3, row, row+1);
1086
1087 row++;
1088 label = make_label("", 0.0, 0.5);
1089 gtk_misc_set_padding (GTK_MISC (label), HB_BOX_SPACING, 0);
1090 gtk_table_attach (GTK_TABLE (table), label, 0, 1, row, row+1, (GtkAttachOptions) (GTK_FILL), (GtkAttachOptions) (0), 0, 0);
1091
1092 label = make_label(_("_Option:"), 0, 0.5);
1093 //----------------------------------------- l, r, t, b
1094 gtk_table_attach (GTK_TABLE (table), label, 1, 2, row, row+1, (GtkAttachOptions) (GTK_FILL), (GtkAttachOptions) (0), 0, 0);
1095
1096 //gtk_table_attach (GTK_TABLE (table), label, 0, 1, row, row+1, (GtkAttachOptions) (GTK_FILL), (GtkAttachOptions) (0), 0, 0);
1097 data->CY_option[FILTER_AMOUNT] = make_nainex(label);
1098 gtk_table_attach (GTK_TABLE (table), data->CY_option[FILTER_AMOUNT], 2, 3, row, row+1, (GtkAttachOptions) (GTK_FILL|GTK_EXPAND), (GtkAttachOptions) (0), 0, 0);
1099
1100 row++;
1101 label = make_label(_("_From:"), 0, 0.5);
1102 //----------------------------------------- l, r, t, b
1103 gtk_table_attach (GTK_TABLE (table), label, 1, 2, row, row+1, (GtkAttachOptions) (GTK_FILL), (GtkAttachOptions) (0), 0, 0);
1104 data->ST_minamount = make_amount(label);
1105 gtk_table_attach (GTK_TABLE (table), data->ST_minamount, 2, 3, row, row+1, (GtkAttachOptions) (GTK_FILL|GTK_EXPAND), (GtkAttachOptions) (0), 0, 0);
1106
1107 row++;
1108 label = make_label(_("_To:"), 0, 0.5);
1109 gtk_table_attach (GTK_TABLE (table), label, 1, 2, row, row+1, (GtkAttachOptions) (GTK_FILL), (GtkAttachOptions) (0), 0, 0);
1110 data->ST_maxamount = make_amount(label);
1111 gtk_table_attach (GTK_TABLE (table), data->ST_maxamount, 2, 3, row, row+1, (GtkAttachOptions) (GTK_FILL|GTK_EXPAND), (GtkAttachOptions) (0), 0, 0);
1112
1113 gtk_container_set_border_width(GTK_CONTAINER(alignment), HB_BOX_SPACING);
1114
1115
1116 return alignment;
1117 }
1118
1119
1120 static GtkWidget *ui_flt_manage_part_status(struct ui_flt_manage_data *data)
1121 {
1122 GtkWidget *table, *label, *vbox, *widget;
1123 GtkWidget *alignment;
1124 gint row;
1125
1126
1127 // column 2
1128
1129 // filter status
1130 table = gtk_table_new (3, 3, FALSE);
1131 gtk_table_set_row_spacings (GTK_TABLE (table), HB_TABROW_SPACING);
1132 gtk_table_set_col_spacings (GTK_TABLE (table), HB_TABCOL_SPACING);
1133
1134 //gtk_box_pack_start (GTK_BOX (container), table, TRUE, TRUE, 0);
1135 // gtk_alignment_new(xalign, yalign, xscale, yscale)
1136 alignment = gtk_alignment_new(0.5, 0, 1.0, 0.0);
1137 gtk_container_add(GTK_CONTAINER(alignment), table);
1138
1139
1140 row = 0;
1141 label = make_label(_("Filter Status"), 0.0, 0.5);
1142 gimp_label_set_attributes(GTK_LABEL(label), PANGO_ATTR_WEIGHT, PANGO_WEIGHT_BOLD, -1);
1143 gtk_table_attach_defaults (GTK_TABLE (table), label, 0, 3, row, row+1);
1144
1145 row++;
1146 label = make_label("", 0.0, 0.5);
1147 gtk_misc_set_padding (GTK_MISC (label), HB_BOX_SPACING, 0);
1148 gtk_table_attach (GTK_TABLE (table), label, 0, 1, row, row+1, (GtkAttachOptions) (GTK_FILL), (GtkAttachOptions) (0), 0, 0);
1149
1150 label = make_label(_("_Option:"), 0, 0.5);
1151 //----------------------------------------- l, r, t, b
1152 gtk_table_attach (GTK_TABLE (table), label, 1, 2, row, row+1, (GtkAttachOptions) (GTK_FILL), (GtkAttachOptions) (0), 0, 0);
1153
1154 data->CY_option[FILTER_STATUS] = make_nainex(label);
1155 gtk_table_attach (GTK_TABLE (table), data->CY_option[FILTER_STATUS], 2, 3, row, row+1, (GtkAttachOptions) (GTK_FILL|GTK_EXPAND), (GtkAttachOptions) (0), 0, 0);
1156
1157 row++;
1158 vbox = gtk_vbox_new (FALSE, 0);
1159 gtk_table_attach (GTK_TABLE (table), vbox, 2, 3, row, row+1, (GtkAttachOptions) (GTK_FILL|GTK_EXPAND), (GtkAttachOptions) (0), 0, 0);
1160
1161 widget = gtk_check_button_new_with_mnemonic (_("reconciled"));
1162 data->CM_reconciled = widget;
1163 gtk_box_pack_start (GTK_BOX (vbox), widget, TRUE, TRUE, 0);
1164
1165 widget = gtk_check_button_new_with_mnemonic (_("remind"));
1166 data->CM_reminded = widget;
1167 gtk_box_pack_start (GTK_BOX (vbox), widget, TRUE, TRUE, 0);
1168
1169 row++;
1170 label = make_label(_("Force:"), 0, 0.5);
1171 gtk_table_attach (GTK_TABLE (table), label, 1, 2, row, row+1, (GtkAttachOptions) (GTK_FILL), (GtkAttachOptions) (0), 0, 0);
1172
1173 vbox = gtk_vbox_new (FALSE, 0);
1174 gtk_table_attach (GTK_TABLE (table), vbox, 2, 3, row, row+1, (GtkAttachOptions) (GTK_FILL|GTK_EXPAND), (GtkAttachOptions) (0), 0, 0);
1175
1176 widget = gtk_check_button_new_with_mnemonic (_("display 'Added'"));
1177 data->CM_forceadd = widget;
1178 gtk_box_pack_start (GTK_BOX (vbox), widget, TRUE, TRUE, 0);
1179
1180 widget = gtk_check_button_new_with_mnemonic (_("display 'Edited'"));
1181 data->CM_forcechg = widget;
1182 gtk_box_pack_start (GTK_BOX (vbox), widget, TRUE, TRUE, 0);
1183
1184 gtk_container_set_border_width(GTK_CONTAINER(alignment), HB_BOX_SPACING);
1185
1186
1187 return alignment;
1188 }
1189
1190
1191 static GtkWidget *ui_flt_manage_part_paymode(struct ui_flt_manage_data *data)
1192 {
1193 GtkWidget *table, *label, *table1, *image;
1194 GtkWidget *alignment;
1195 gint i, row;
1196
1197 // Filter Payment
1198 table = gtk_table_new (3, 3, FALSE);
1199 gtk_table_set_row_spacings (GTK_TABLE (table), HB_TABROW_SPACING);
1200 gtk_table_set_col_spacings (GTK_TABLE (table), HB_TABCOL_SPACING);
1201
1202 //gtk_box_pack_start (GTK_BOX (container), table, TRUE, TRUE, 0);
1203 // gtk_alignment_new(xalign, yalign, xscale, yscale)
1204 alignment = gtk_alignment_new(0.5, 0, 1.0, 0.0);
1205 gtk_container_add(GTK_CONTAINER(alignment), table);
1206
1207
1208 row = 0;
1209 label = make_label(_("Filter Payment"), 0.0, 0.5);
1210 gimp_label_set_attributes(GTK_LABEL(label), PANGO_ATTR_WEIGHT, PANGO_WEIGHT_BOLD, -1);
1211 gtk_table_attach_defaults (GTK_TABLE (table), label, 0, 3, row, row+1);
1212
1213
1214 row++;
1215 label = make_label("", 0.0, 0.5);
1216 gtk_misc_set_padding (GTK_MISC (label), HB_BOX_SPACING, 0);
1217 gtk_table_attach (GTK_TABLE (table), label, 0, 1, row, row+1, (GtkAttachOptions) (GTK_FILL), (GtkAttachOptions) (0), 0, 0);
1218
1219 label = make_label(_("_Option:"), 1.0, 0.5);
1220 //----------------------------------------- l, r, t, b
1221 gtk_table_attach (GTK_TABLE (table), label, 1, 2, row, row+1, (GtkAttachOptions) (GTK_FILL), (GtkAttachOptions) (0), 0, 0);
1222 data->CY_option[FILTER_PAYMODE] = make_nainex(label);
1223 gtk_table_attach (GTK_TABLE (table), data->CY_option[FILTER_PAYMODE], 2, 3, row, row+1, (GtkAttachOptions) (GTK_FILL|GTK_EXPAND), (GtkAttachOptions) (0), 0, 0);
1224
1225 table1 = gtk_table_new (1, 1, FALSE);
1226 gtk_table_set_row_spacings (GTK_TABLE (table1), 0);
1227 gtk_table_set_col_spacings (GTK_TABLE (table1), 2);
1228
1229 row++;
1230 gtk_table_attach (GTK_TABLE (table), table1, 2, 3, row, row+1, (GtkAttachOptions) (GTK_FILL|GTK_EXPAND), (GtkAttachOptions) (0), 0, 0);
1231
1232 for(i=0;i<NUM_PAYMODE_MAX;i++)
1233 {
1234 row = i;
1235
1236 image = gtk_image_new_from_pixbuf(paymode_icons[i]);
1237 gtk_table_attach (GTK_TABLE (table1), image, 0, 1, row, row+1, (GtkAttachOptions) (GTK_FILL), (GtkAttachOptions) (0), 0, 0);
1238
1239 data->CM_paymode[i] = gtk_check_button_new();
1240 gtk_table_attach (GTK_TABLE (table1), data->CM_paymode[i], 1, 2, row, row+1, (GtkAttachOptions) (GTK_FILL), (GtkAttachOptions) (0), 0, 0);
1241
1242
1243 label = make_label(_(paymode_label_names[i]), 0.0, 0.5);
1244 gtk_table_attach (GTK_TABLE (table1), label, 2, 3, row, row+1, (GtkAttachOptions) (GTK_FILL|GTK_EXPAND), (GtkAttachOptions) (0), 0, 0);
1245
1246 }
1247
1248 gtk_container_set_border_width(GTK_CONTAINER(alignment), HB_BOX_SPACING);
1249
1250
1251 return alignment;
1252 }
1253
1254
1255 /*
1256 ** general page: date, amount, status, payment
1257 */
1258 /*
1259 static GtkWidget *ui_flt_manage_page_general (struct ui_flt_manage_data *data)
1260 {
1261 GtkWidget *container, *part;
1262
1263 //container = gtk_hbox_new(FALSE, HB_BOX_SPACING);
1264 // gtk_alignment_new(xalign, yalign, xscale, yscale)
1265 //gtk_container_set_border_width(GTK_CONTAINER(container), HB_BOX_SPACING);
1266
1267 container = gtk_table_new (2, 3, FALSE);
1268 gtk_table_set_row_spacings (GTK_TABLE (container), HB_TABROW_SPACING*2);
1269 gtk_table_set_col_spacings (GTK_TABLE (container), HB_TABCOL_SPACING*2);
1270 gtk_container_set_border_width(GTK_CONTAINER(container), HB_BOX_SPACING);
1271
1272 // date: r=1, c=1
1273 part = ui_flt_manage_part_date(data);
1274 gtk_table_attach_defaults(GTK_TABLE (container), part, 0, 1, 0, 1);
1275
1276 // amount: r=2, c=2
1277 part = ui_flt_manage_part_amount(data);
1278 gtk_table_attach_defaults (GTK_TABLE (container), part, 0, 1, 1, 2);
1279
1280 // paymode:
1281 part = ui_flt_manage_part_paymode(data);
1282 gtk_table_attach_defaults (GTK_TABLE (container), part, 1, 2, 0, 2);
1283
1284 // status: r=2, c=1
1285 part = ui_flt_manage_part_status(data);
1286 gtk_table_attach_defaults (GTK_TABLE (container), part, 2, 3, 0, 1);
1287
1288 // text: r=2, c=1
1289 part = ui_flt_manage_part_text(data);
1290 gtk_table_attach_defaults (GTK_TABLE (container), part, 2, 3, 1, 2);
1291
1292 gtk_container_set_border_width(GTK_CONTAINER(container), HB_BOX_SPACING);
1293
1294 return(container);
1295 }
1296 */
1297
1298
1299
1300 /*
1301 **
1302 */
1303 gint ui_flt_manage_dialog_new(Filter *filter, gboolean show_account)
1304 {
1305 struct ui_flt_manage_data data;
1306 GtkWidget *window, *content, *mainbox, *notebook, *label, *page;
1307
1308 //data = g_malloc0(sizeof(struct ui_flt_manage_data));
1309 //if(!data) return NULL;
1310 memset(&data, 0, sizeof(data));
1311
1312 data.filter = filter;
1313
1314 window = gtk_dialog_new_with_buttons (_("Edit Filter"),
1315 //GTK_WINDOW (do_widget),
1316 NULL,
1317 0,
1318 GTK_STOCK_CLEAR,
1319 55,
1320 GTK_STOCK_CANCEL,
1321 GTK_RESPONSE_REJECT,
1322 GTK_STOCK_OK,
1323 GTK_RESPONSE_ACCEPT,
1324 NULL);
1325
1326 //homebank_window_set_icon_from_file(GTK_WINDOW (window), "filter.svg");
1327 gtk_window_set_icon_name(GTK_WINDOW (window), HB_STOCK_FILTER);
1328
1329 //store our window private data
1330 g_object_set_data(G_OBJECT(window), "inst_data", (gpointer)&data);
1331 DB( g_print("(ui_flt_manage) window=%x, inst_data=%x\n", (guint)window, (guint)&data) );
1332
1333 g_signal_connect (window, "destroy",
1334 G_CALLBACK (gtk_widget_destroyed), &window);
1335
1336 content = gtk_dialog_get_content_area(GTK_DIALOG (window));
1337 mainbox = gtk_vbox_new (FALSE, HB_BOX_SPACING);
1338 gtk_box_pack_start (GTK_BOX (content), mainbox, TRUE, TRUE, 0);
1339 gtk_container_set_border_width (GTK_CONTAINER(mainbox), HB_MAINBOX_SPACING);
1340
1341
1342 notebook = gtk_notebook_new();
1343 gtk_notebook_set_tab_pos(GTK_NOTEBOOK (notebook), GTK_POS_LEFT);
1344 gtk_box_pack_start (GTK_BOX (mainbox), notebook, TRUE, TRUE, 0);
1345 data.notebook = notebook;
1346
1347 //common (date + status + amount)
1348 /* label = gtk_label_new(_("General"));
1349 page = ui_flt_manage_page_general(&data);
1350 gtk_notebook_append_page (GTK_NOTEBOOK (notebook), page, label);
1351 */
1352
1353 label = gtk_label_new(_("Date"));
1354 page = ui_flt_manage_part_date(&data);
1355 gtk_widget_show(GTK_WIDGET(page));
1356 gtk_notebook_append_page (GTK_NOTEBOOK (notebook), page, label);
1357
1358 label = gtk_label_new(_("Status"));
1359 page = ui_flt_manage_part_status(&data);
1360 gtk_widget_show(GTK_WIDGET(page));
1361 gtk_notebook_append_page (GTK_NOTEBOOK (notebook), page, label);
1362
1363 label = gtk_label_new(_("Paymode"));
1364 page = ui_flt_manage_part_paymode(&data);
1365 gtk_widget_show(GTK_WIDGET(page));
1366 gtk_notebook_append_page (GTK_NOTEBOOK (notebook), page, label);
1367
1368 label = gtk_label_new(_("Amount"));
1369 page = ui_flt_manage_part_amount(&data);
1370 gtk_widget_show(GTK_WIDGET(page));
1371 gtk_notebook_append_page (GTK_NOTEBOOK (notebook), page, label);
1372
1373 label = gtk_label_new(_("Text"));
1374 page = ui_flt_manage_part_text(&data);
1375 gtk_widget_show(GTK_WIDGET(page));
1376 gtk_notebook_append_page (GTK_NOTEBOOK (notebook), page, label);
1377
1378 label = gtk_label_new(_("Category"));
1379 page = ui_flt_manage_page_category(&data);
1380 gtk_widget_show(GTK_WIDGET(page));
1381 gtk_notebook_append_page (GTK_NOTEBOOK (notebook), page, label);
1382
1383 label = gtk_label_new(_("Payee"));
1384 page = ui_flt_manage_page_payee(&data);
1385 gtk_widget_show(GTK_WIDGET(page));
1386 gtk_notebook_append_page (GTK_NOTEBOOK (notebook), page, label);
1387
1388 data.show_account = show_account;
1389 if(show_account == TRUE)
1390 {
1391 label = gtk_label_new(_("Account"));
1392 page = ui_flt_manage_page_account(&data);
1393 gtk_widget_show(GTK_WIDGET(page));
1394 gtk_notebook_append_page (GTK_NOTEBOOK (notebook), page, label);
1395 }
1396
1397 //setup, init and show window
1398 ui_flt_manage_setup(&data);
1399 ui_flt_manage_set(&data);
1400
1401 ui_flt_manage_option_update(window, NULL);
1402
1403
1404 /* signal connect */
1405 g_signal_connect (data.CY_option[FILTER_STATUS] , "changed", G_CALLBACK (ui_flt_manage_option_update), NULL);
1406 g_signal_connect (data.CY_option[FILTER_DATE] , "changed", G_CALLBACK (ui_flt_manage_option_update), NULL);
1407 g_signal_connect (data.CY_option[FILTER_AMOUNT] , "changed", G_CALLBACK (ui_flt_manage_option_update), NULL);
1408 g_signal_connect (data.CY_option[FILTER_PAYMODE] , "changed", G_CALLBACK (ui_flt_manage_option_update), NULL);
1409
1410 g_signal_connect (data.CY_option[FILTER_PAYEE] , "changed", G_CALLBACK (ui_flt_manage_option_update), NULL);
1411 g_signal_connect (data.CY_option[FILTER_CATEGORY], "changed", G_CALLBACK (ui_flt_manage_option_update), NULL);
1412 g_signal_connect (data.CY_option[FILTER_TEXT] , "changed", G_CALLBACK (ui_flt_manage_option_update), NULL);
1413
1414 if(show_account == TRUE)
1415 {
1416 g_signal_connect (data.CY_option[FILTER_ACCOUNT] , "changed", G_CALLBACK (ui_flt_manage_option_update), NULL);
1417
1418 g_signal_connect (data.BT_acc[BUTTON_ALL] , "clicked", G_CALLBACK (ui_flt_manage_acc_select), GINT_TO_POINTER(BUTTON_ALL));
1419 g_signal_connect (data.BT_acc[BUTTON_NONE] , "clicked", G_CALLBACK (ui_flt_manage_acc_select), GINT_TO_POINTER(BUTTON_NONE));
1420 g_signal_connect (data.BT_acc[BUTTON_INVERT], "clicked", G_CALLBACK (ui_flt_manage_acc_select), GINT_TO_POINTER(BUTTON_INVERT));
1421 }
1422
1423 g_signal_connect (data.CY_month, "changed", G_CALLBACK (ui_flt_manage_period_change), NULL);
1424 g_signal_connect (data.NB_year, "value-changed", G_CALLBACK (ui_flt_manage_period_change), NULL);
1425
1426 g_signal_connect (data.BT_pay[BUTTON_ALL] , "clicked", G_CALLBACK (ui_flt_manage_pay_select), GINT_TO_POINTER(BUTTON_ALL));
1427 g_signal_connect (data.BT_pay[BUTTON_NONE] , "clicked", G_CALLBACK (ui_flt_manage_pay_select), GINT_TO_POINTER(BUTTON_NONE));
1428 g_signal_connect (data.BT_pay[BUTTON_INVERT], "clicked", G_CALLBACK (ui_flt_manage_pay_select), GINT_TO_POINTER(BUTTON_INVERT));
1429
1430 g_signal_connect (data.BT_cat[BUTTON_ALL] , "clicked", G_CALLBACK (ui_flt_manage_cat_select), GINT_TO_POINTER(BUTTON_ALL));
1431 g_signal_connect (data.BT_cat[BUTTON_NONE] , "clicked", G_CALLBACK (ui_flt_manage_cat_select), GINT_TO_POINTER(BUTTON_NONE));
1432 g_signal_connect (data.BT_cat[BUTTON_INVERT], "clicked", G_CALLBACK (ui_flt_manage_cat_select), GINT_TO_POINTER(BUTTON_INVERT));
1433
1434
1435 gtk_widget_show_all (window);
1436
1437
1438 //wait for the user
1439 gint retval; // = 55;
1440
1441 //while( result == 55 )
1442 //{
1443 retval = gtk_dialog_run (GTK_DIALOG (window));
1444
1445 switch (retval)
1446 {
1447 case GTK_RESPONSE_ACCEPT:
1448 //do_application_specific_something ();
1449 ui_flt_manage_get(&data);
1450 break;
1451 case 55:
1452 ui_flt_manage_clear(window, NULL);
1453 ui_flt_manage_get(&data);
1454 break;
1455 default:
1456 //do_nothing_since_dialog_was_cancelled ();
1457 break;
1458 }
1459 //}
1460
1461 // cleanup and destroy
1462 //ui_flt_manage_cleanup(&data, result);
1463
1464
1465 DB( g_print(" free\n") );
1466 //g_free(data);
1467
1468 DB( g_print(" destroy\n") );
1469 gtk_widget_destroy (window);
1470
1471 DB( g_print(" all ok\n") );
1472
1473 return retval;
1474 }
This page took 0.144123 seconds and 4 git commands to generate.