]> Dogcows Code - chaz/homebank/blob - src/rep_balance.c
Merge branch 'master' into ext-perl
[chaz/homebank] / src / rep_balance.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 "rep_balance.h"
24
25 #include "list_operation.h"
26 #include "gtk-chart.h"
27 #include "gtk-dateentry.h"
28
29 #include "ui-account.h"
30 #include "dsp_mainwindow.h"
31 #include "ui-transaction.h"
32
33
34 /****************************************************************************/
35 /* Debug macros */
36 /****************************************************************************/
37 #define MYDEBUG 0
38
39 #if MYDEBUG
40 #define DB(x) (x);
41 #else
42 #define DB(x);
43 #endif
44
45 /* our global datas */
46 extern struct HomeBank *GLOBALS;
47 extern struct Preferences *PREFS;
48
49
50 /* prototypes */
51 static void repbalance_action_viewlist(GtkAction *action, gpointer user_data);
52 static void repbalance_action_viewline(GtkAction *action, gpointer user_data);
53 static void repbalance_action_detail(GtkAction *action, gpointer user_data);
54 static void repbalance_action_refresh(GtkAction *action, gpointer user_data);
55 static void repbalance_update_daterange(GtkWidget *widget, gpointer user_data);
56 static void repbalance_update_detail(GtkWidget *widget, gpointer user_data);
57 static void repbalance_toggle_detail(GtkWidget *widget, gpointer user_data);
58 static void repbalance_detail(GtkWidget *widget, gpointer user_data);
59 static void repbalance_sensitive(GtkWidget *widget, gpointer user_data);
60 /* prototypes */
61 static void repbalance_date_change(GtkWidget *widget, gpointer user_data);
62 static void repbalance_range_change(GtkWidget *widget, gpointer user_data);
63 static void repbalance_update_info(GtkWidget *widget, gpointer user_data);
64 static void repbalance_toggle_minor(GtkWidget *widget, gpointer user_data);
65 static void repbalance_compute(GtkWidget *widget, gpointer user_data);
66 static void repbalance_setup(struct repbalance_data *data, guint32 accnum);
67 static gboolean repbalance_window_dispose(GtkWidget *widget, GdkEvent *event, gpointer user_data);
68 static GtkWidget *create_list_repbalance(void);
69 static void ui_repbalance_list_set_cur(GtkTreeView *treeview, guint32 kcur);
70
71 //todo amiga/linux
72 //prev
73 //next
74
75 static GtkActionEntry entries[] = {
76 { "List" , ICONNAME_HB_VIEW_LIST , N_("List") , NULL, N_("View results as list"), G_CALLBACK (repbalance_action_viewlist) },
77 { "Line" , ICONNAME_HB_VIEW_LINE , N_("Line") , NULL, N_("View results as lines"), G_CALLBACK (repbalance_action_viewline) },
78 { "Refresh" , ICONNAME_REFRESH , N_("Refresh"), NULL, N_("Refresh results"), G_CALLBACK (repbalance_action_refresh) },
79 };
80
81 static guint n_entries = G_N_ELEMENTS (entries);
82
83 static GtkToggleActionEntry toggle_entries[] = {
84 { "Detail", ICONNAME_HB_OPE_SHOW, /* name, icon-name */
85 N_("Detail"), NULL, /* label, accelerator */
86 N_("Toggle detail"), /* tooltip */
87 G_CALLBACK (repbalance_action_detail),
88 FALSE }, /* is_active */
89 };
90 static guint n_toggle_entries = G_N_ELEMENTS (toggle_entries);
91
92
93 static const gchar *ui_info =
94 "<ui>"
95 " <toolbar name='ToolBar'>"
96 " <toolitem action='List'/>"
97 " <toolitem action='Line'/>"
98 " <separator/>"
99 " <toolitem action='Detail'/>"
100 " <separator/>"
101 " <toolitem action='Refresh'/>"
102 " </toolbar>"
103 "</ui>";
104
105
106 //extern gchar *CYA_FLT_SELECT[];
107
108
109 /* action functions -------------------- */
110 static void repbalance_action_viewlist(GtkAction *action, gpointer user_data)
111 {
112 struct repbalance_data *data = user_data;
113
114 gtk_notebook_set_current_page(GTK_NOTEBOOK(data->GR_result), 0);
115 repbalance_sensitive(data->window, NULL);
116 }
117
118 static void repbalance_action_viewline(GtkAction *action, gpointer user_data)
119 {
120 struct repbalance_data *data = user_data;
121
122 gtk_notebook_set_current_page(GTK_NOTEBOOK(data->GR_result), 1);
123 repbalance_sensitive(data->window, NULL);
124 }
125
126 static void repbalance_action_detail(GtkAction *action, gpointer user_data)
127 {
128 struct repbalance_data *data = user_data;
129
130 repbalance_toggle_detail(data->window, NULL);
131 }
132
133 static void repbalance_action_refresh(GtkAction *action, gpointer user_data)
134 {
135 struct repbalance_data *data = user_data;
136
137 repbalance_compute(data->window, NULL);
138 }
139
140
141
142 /* ======================== */
143
144
145
146
147
148
149 static void repbalance_date_change(GtkWidget *widget, gpointer user_data)
150 {
151 struct repbalance_data *data;
152
153 DB( g_print("(repbalance) date change\n") );
154
155 data = g_object_get_data(G_OBJECT(gtk_widget_get_ancestor(widget, GTK_TYPE_WINDOW)), "inst_data");
156
157 data->filter->mindate = gtk_date_entry_get_date(GTK_DATE_ENTRY(data->PO_mindate));
158 data->filter->maxdate = gtk_date_entry_get_date(GTK_DATE_ENTRY(data->PO_maxdate));
159
160 // set min/max date for both widget
161 gtk_date_entry_set_maxdate(GTK_DATE_ENTRY(data->PO_mindate), data->filter->maxdate);
162 gtk_date_entry_set_mindate(GTK_DATE_ENTRY(data->PO_maxdate), data->filter->mindate);
163
164 g_signal_handler_block(data->CY_range, data->handler_id[HID_REPBALANCE_RANGE]);
165 gtk_combo_box_set_active(GTK_COMBO_BOX(data->CY_range), FLT_RANGE_OTHER);
166 g_signal_handler_unblock(data->CY_range, data->handler_id[HID_REPBALANCE_RANGE]);
167
168
169 repbalance_compute(widget, NULL);
170 repbalance_update_daterange(widget, NULL);
171
172 }
173
174
175 static void repbalance_update_quickdate(GtkWidget *widget, gpointer user_data)
176 {
177 struct repbalance_data *data;
178
179 DB( g_print("(repbalance) update quickdate\n") );
180
181 data = g_object_get_data(G_OBJECT(gtk_widget_get_ancestor(widget, GTK_TYPE_WINDOW)), "inst_data");
182
183 g_signal_handler_block(data->PO_mindate, data->handler_id[HID_REPBALANCE_MINDATE]);
184 g_signal_handler_block(data->PO_maxdate, data->handler_id[HID_REPBALANCE_MAXDATE]);
185
186 gtk_date_entry_set_date(GTK_DATE_ENTRY(data->PO_mindate), data->filter->mindate);
187 gtk_date_entry_set_date(GTK_DATE_ENTRY(data->PO_maxdate), data->filter->maxdate);
188
189 g_signal_handler_unblock(data->PO_mindate, data->handler_id[HID_REPBALANCE_MINDATE]);
190 g_signal_handler_unblock(data->PO_maxdate, data->handler_id[HID_REPBALANCE_MAXDATE]);
191
192 }
193
194
195
196 static void repbalance_range_change(GtkWidget *widget, gpointer user_data)
197 {
198 struct repbalance_data *data;
199 gint range;
200
201 DB( g_print("(repbalance) range change\n") );
202
203 data = g_object_get_data(G_OBJECT(gtk_widget_get_ancestor(widget, GTK_TYPE_WINDOW)), "inst_data");
204
205 range = gtk_combo_box_get_active(GTK_COMBO_BOX(data->CY_range));
206
207 if(range != FLT_RANGE_OTHER)
208 {
209 filter_preset_daterange_set(data->filter, range, data->accnum);
210
211 repbalance_update_quickdate(widget, NULL);
212
213 repbalance_compute(widget, NULL);
214 repbalance_update_daterange(widget, NULL);
215 }
216
217 }
218
219 static void repbalance_update_daterange(GtkWidget *widget, gpointer user_data)
220 {
221 struct repbalance_data *data;
222 gchar *daterange;
223
224 DB( g_print("(repbalance) update daterange\n") );
225
226 data = g_object_get_data(G_OBJECT(gtk_widget_get_ancestor(widget, GTK_TYPE_WINDOW)), "inst_data");
227
228 daterange = filter_daterange_text_get(data->filter);
229 gtk_label_set_markup(GTK_LABEL(data->TX_daterange), daterange);
230 g_free(daterange);
231 }
232
233
234 static void repbalance_selection(GtkTreeSelection *treeselection, gpointer user_data)
235 {
236 GtkTreeModel *model;
237 GtkTreeIter iter;
238 guint key = -1;
239
240 DB( g_print("(repbalance) selection\n") );
241
242 if (gtk_tree_selection_get_selected(treeselection, &model, &iter))
243 {
244 gtk_tree_model_get(model, &iter, LST_OVER_DATE, &key, -1);
245
246 DB( g_print(" - active is %d\n", key) );
247
248 repbalance_detail(GTK_WIDGET(gtk_tree_selection_get_tree_view (treeselection)), GINT_TO_POINTER(key));
249 }
250
251 repbalance_sensitive(GTK_WIDGET(gtk_tree_selection_get_tree_view (treeselection)), NULL);
252 }
253
254
255 /*
256 ** update sensitivity
257 */
258 static void repbalance_sensitive(GtkWidget *widget, gpointer user_data)
259 {
260 struct repbalance_data *data;
261 gboolean active;
262 gboolean sensitive;
263 gint page;
264
265 DB( g_print("(repbalance) sensitive\n") );
266
267 data = g_object_get_data(G_OBJECT(gtk_widget_get_ancestor(widget, GTK_TYPE_WINDOW)), "inst_data");
268
269 active = gtk_tree_selection_get_selected(gtk_tree_view_get_selection(GTK_TREE_VIEW(data->LV_report)), NULL, NULL);
270
271 page = gtk_notebook_get_current_page(GTK_NOTEBOOK(data->GR_result));
272
273 sensitive = page == 0 ? active : FALSE;
274 // gtk_widget_set_sensitive(data->TB_buttons[ACTION_REPBUDGET_DETAIL], sensitive);
275 gtk_action_set_sensitive(gtk_ui_manager_get_action(data->ui, "/ToolBar/Detail"), sensitive);
276
277 sensitive = page == 0 ? FALSE : TRUE;
278 gtk_widget_set_sensitive(data->LB_zoomx, sensitive);
279 gtk_widget_set_sensitive(data->RG_zoomx, sensitive);
280
281
282 }
283
284
285
286
287 static void repbalance_update_info(GtkWidget *widget, gpointer user_data)
288 {
289 struct repbalance_data *data;
290 gchar *info;
291 gchar buf[128];
292 Account *acc;
293
294 DB( g_print("(repbalance) update info\n") );
295
296 data = g_object_get_data(G_OBJECT(gtk_widget_get_ancestor(widget, GTK_TYPE_WINDOW)), "inst_data");
297
298 gboolean selectall = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(data->CM_selectall));
299
300 guint32 acckey = ui_acc_comboboxentry_get_key(GTK_COMBO_BOX(data->PO_acc));
301
302 DB( g_print(" acc key = %d\n", acckey) );
303
304 acc = da_acc_get(acckey);
305 // 1635857
306 if( acc != NULL )
307 {
308 gboolean minor = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(data->CM_minor));
309
310 hb_strfmon(buf, 127, data->minimum, selectall ? GLOBALS->kcur : acc->kcur, minor);
311
312 ////TRANSLATORS: count of transaction in balancedrawn / count of total transaction under abalancedrawn amount threshold
313 info = g_strdup_printf(_("%d/%d under %s"), data->nbbalance, data->nbope, buf);
314 gtk_label_set_text(GTK_LABEL(data->TX_info), info);
315 g_free(info);
316 }
317
318 }
319
320
321 static void repbalance_detail(GtkWidget *widget, gpointer user_data)
322 {
323 struct repbalance_data *data;
324 guint active = GPOINTER_TO_INT(user_data);
325 GList *list;
326 GtkTreeModel *model;
327 GtkTreeIter iter;
328 guint32 acckey;
329
330 data = g_object_get_data(G_OBJECT(gtk_widget_get_ancestor(widget, GTK_TYPE_WINDOW)), "inst_data");
331
332 DB( g_print("(repbalance) detail\n") );
333
334 /* clear and detach our model */
335 model = gtk_tree_view_get_model(GTK_TREE_VIEW(data->LV_detail));
336 gtk_list_store_clear (GTK_LIST_STORE(model));
337
338 if(data->detail)
339 {
340 g_object_ref(model); /* Make sure the model stays with us after the tree view unrefs it */
341 gtk_tree_view_set_model(GTK_TREE_VIEW(data->LV_detail), NULL); /* Detach model from view */
342
343
344 gboolean selectall = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(data->CM_selectall));
345
346 // get the account key
347 acckey = ui_acc_comboboxentry_get_key(GTK_COMBO_BOX(data->PO_acc));
348
349 /* fill in the model */
350 list = g_list_first(data->ope_list);
351 while (list != NULL)
352 {
353 Transaction *ope = list->data;
354
355 //DB( g_print(" get %s\n", ope->ope_Word) );
356
357 //filter here
358 if( ope->date == active && (ope->kacc == acckey || selectall) )
359 {
360 gtk_list_store_append (GTK_LIST_STORE(model), &iter);
361 gtk_list_store_set (GTK_LIST_STORE(model), &iter,
362 LST_DSPOPE_DATAS, ope,
363 -1);
364 }
365 list = g_list_next(list);
366 }
367
368 /* Re-attach model to view */
369 gtk_tree_view_set_model(GTK_TREE_VIEW(data->LV_detail), model);
370 g_object_unref(model);
371
372 gtk_tree_view_columns_autosize( GTK_TREE_VIEW(data->LV_detail) );
373
374 }
375 }
376
377
378 static void repbalance_detail_onRowActivated (GtkTreeView *treeview,
379 GtkTreePath *path,
380 GtkTreeViewColumn *col,
381 gpointer userdata)
382 {
383 struct repbalance_data *data;
384 Transaction *active_txn;
385 gboolean result;
386
387 data = g_object_get_data(G_OBJECT(gtk_widget_get_ancestor(GTK_WIDGET(treeview), GTK_TYPE_WINDOW)), "inst_data");
388
389 DB( g_print ("\n[repbalance] A detail row has been double-clicked!\n") );
390
391 active_txn = list_txn_get_active_transaction(GTK_TREE_VIEW(data->LV_detail));
392 if(active_txn)
393 {
394 Transaction *old_txn, *new_txn;
395
396 old_txn = da_transaction_clone (active_txn);
397 new_txn = active_txn;
398 result = deftransaction_external_edit(GTK_WINDOW(data->window), old_txn, new_txn);
399
400 if(result == GTK_RESPONSE_ACCEPT)
401 {
402 //#1640885
403 GLOBALS->changes_count++;
404 repbalance_compute (data->window, NULL);
405 }
406
407 da_transaction_free (old_txn);
408 }
409 }
410
411
412
413 static void repbalance_update_detail(GtkWidget *widget, gpointer user_data)
414 {
415 struct repbalance_data *data;
416
417 data = g_object_get_data(G_OBJECT(gtk_widget_get_ancestor(widget, GTK_TYPE_WINDOW)), "inst_data");
418
419 if(data->detail)
420 {
421 GtkTreeSelection *treeselection;
422 GtkTreeModel *model;
423 GtkTreeIter iter;
424 guint key;
425
426 treeselection = gtk_tree_view_get_selection (GTK_TREE_VIEW(data->LV_report));
427
428 if (gtk_tree_selection_get_selected(treeselection, &model, &iter))
429 {
430 gtk_tree_model_get(model, &iter, LST_OVER_DATE, &key, -1);
431
432 DB( g_print(" - active is %d\n", key) );
433
434 repbalance_detail(GTK_WIDGET(gtk_tree_selection_get_tree_view (treeselection)), GINT_TO_POINTER(key));
435 }
436
437
438
439 gtk_widget_show(data->GR_detail);
440 }
441 else
442 gtk_widget_hide(data->GR_detail);
443 }
444
445
446 static void repbalance_toggle_detail(GtkWidget *widget, gpointer user_data)
447 {
448 struct repbalance_data *data;
449
450 data = g_object_get_data(G_OBJECT(gtk_widget_get_ancestor(widget, GTK_TYPE_WINDOW)), "inst_data");
451
452 data->detail ^= 1;
453
454 DB( g_print("(repbalance) toggledetail to %d\n", (int)data->detail) );
455
456 repbalance_update_detail(widget, user_data);
457
458 }
459
460
461 static void repbalance_zoomx_callback(GtkWidget *widget, gpointer user_data)
462 {
463 struct repbalance_data *data;
464 gdouble value;
465
466 DB( g_print("(statistic) zoomx\n") );
467
468 data = g_object_get_data(G_OBJECT(gtk_widget_get_ancestor(widget, GTK_TYPE_WINDOW)), "inst_data");
469
470 value = gtk_range_get_value(GTK_RANGE(data->RG_zoomx));
471
472 DB( g_print(" + scale is %f\n", value) );
473
474 gtk_chart_set_barw(GTK_CHART(data->RE_line), value);
475
476 }
477
478
479 static void repbalance_toggle_minor(GtkWidget *widget, gpointer user_data)
480 {
481 struct repbalance_data *data;
482
483 DB( g_print("(repbalance) toggle\n") );
484
485 data = g_object_get_data(G_OBJECT(gtk_widget_get_ancestor(widget, GTK_TYPE_WINDOW)), "inst_data");
486
487 GLOBALS->minor = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(data->CM_minor));
488
489 repbalance_update_info(widget,NULL);
490
491 gtk_tree_view_columns_autosize (GTK_TREE_VIEW(data->LV_report));
492
493 gtk_chart_show_minor(GTK_CHART(data->RE_line), GLOBALS->minor);
494 }
495
496
497 static void repbalance_compute_full_datas(guint32 selkey, gboolean selectall, struct repbalance_data *data)
498 {
499 GList *list;
500
501 DB( g_print("(repbalance) compute_full\n") );
502
503 g_list_free(data->ope_list);
504 data->ope_list = hbfile_transaction_get_all();
505
506 if(g_list_length(data->ope_list) == 0) return;
507
508 Transaction *omin = g_list_first(data->ope_list)->data;
509 Transaction *omax = g_list_last(data->ope_list)->data;
510
511 // total days in the hbfile
512 data->n_result = omax->date - omin->date;
513
514 DB( g_print(" - %d days in slice\n", data->n_result) );
515
516 data->tmp_income = g_malloc0((data->n_result+2) * sizeof(gdouble));
517 data->tmp_expense = g_malloc0((data->n_result+2) * sizeof(gdouble));
518
519 // to store that initial balance was affected
520 gboolean *accounts = g_malloc0((da_acc_get_max_key()+2) * sizeof(gboolean));
521
522 if(data->tmp_income && data->tmp_expense)
523 {
524
525 /* compute the balance */
526 list = g_list_first(data->ope_list);
527 while (list != NULL)
528 {
529 gint pos;
530 gdouble trn_amount;
531 Transaction *ope = list->data;
532
533 if(selkey == ope->kacc || selectall == TRUE)
534 {
535 Account *acc = da_acc_get(ope->kacc);
536
537 if( acc != NULL )
538 {
539 pos = ope->date - omin->date;
540
541 // deal with account initial balance
542 if(accounts[ope->kacc] == 0)
543 {
544 if(selectall)
545 trn_amount = hb_amount_base(acc->initial, acc->kcur);
546 else
547 trn_amount = acc->initial;
548
549 if(trn_amount < 0)
550 data->tmp_expense[pos] += trn_amount;
551 else
552 data->tmp_income[pos] += trn_amount;
553
554 DB( g_print(" - stored initial %.2f for account %d\n", trn_amount, ope->kacc) );
555
556 accounts[ope->kacc] = 1;
557 }
558
559 if(selectall)
560 trn_amount = hb_amount_base(ope->amount, acc->kcur);
561 else
562 trn_amount = ope->amount;
563
564 //deal with transactions
565 if(trn_amount < 0)
566 data->tmp_expense[pos] += trn_amount;
567 else
568 data->tmp_income[pos] += trn_amount;
569 }
570 }
571
572 list = g_list_next(list);
573 }
574
575 }
576
577 g_free(accounts);
578
579 }
580
581
582 static void repbalance_compute(GtkWidget *widget, gpointer user_data)
583 {
584 struct repbalance_data *data;
585 GtkTreeModel *model;
586 GtkTreeIter iter;
587 guint32 acckey, i;
588 gboolean selectall, eachday;
589 Account *acc;
590
591 DB( g_print("(repbalance) compute\n") );
592
593 data = g_object_get_data(G_OBJECT(gtk_widget_get_ancestor(widget, GTK_TYPE_WINDOW)), "inst_data");
594
595 selectall = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(data->CM_selectall));
596 eachday = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(data->CM_eachday));
597
598 // get the account key
599 acckey = ui_acc_comboboxentry_get_key(GTK_COMBO_BOX(data->PO_acc));
600
601 DB( g_print(" acc key = %d\n", acckey) );
602
603 data->nbope = 0;
604 data->nbbalance = 0;
605 data->minimum = 0;
606 data->accnum = 0;
607
608 // for a single account
609 if(!selectall)
610 {
611 acc = da_acc_get(acckey);
612 if(acc != NULL)
613 {
614 data->minimum = acc->minimum;
615 data->accnum = acc->key;
616 ui_repbalance_list_set_cur(GTK_TREE_VIEW(data->LV_report), acc->kcur);
617 gtk_chart_set_currency(GTK_CHART(data->RE_line), acc->kcur);
618 }
619 }
620 else
621 {
622
623 ui_repbalance_list_set_cur(GTK_TREE_VIEW(data->LV_report), GLOBALS->kcur);
624 gtk_chart_set_currency(GTK_CHART(data->RE_line), GLOBALS->kcur);
625 }
626
627 //to remove > 5.0.2
628 //filter_preset_daterange_set(data->filter, data->filter->range, data->accnum);
629 //repbalance_update_quickdate(widget, NULL);
630
631 repbalance_compute_full_datas(acckey, selectall, data);
632
633 /* do nothing if no transaction */
634 if(g_list_length(data->ope_list) == 0) return;
635
636
637 /* clear and detach our model */
638 model = gtk_tree_view_get_model(GTK_TREE_VIEW(data->LV_report));
639 gtk_list_store_clear (GTK_LIST_STORE(model));
640 g_object_ref(model); /* Make sure the model stays with us after the tree view unrefs it */
641 gtk_tree_view_set_model(GTK_TREE_VIEW(data->LV_report), NULL); /* Detach model from view */
642
643 Transaction *omin = g_list_first(data->ope_list)->data;
644 gdouble balance = 0;
645
646 for(i=0;i<=data->n_result;i++)
647 {
648 gboolean is_balance = FALSE;
649 GDate *date;
650 gchar buf[256];
651 guint32 posdate;
652
653 posdate = omin->date + i;
654
655 DB( g_print("omin->date=%d posdate=%d\n", omin->date, posdate) );
656
657
658 balance += data->tmp_expense[i];
659 balance += data->tmp_income[i];
660
661 if(!eachday && data->tmp_expense[i] == 0 && data->tmp_income[i] == 0)
662 continue;
663
664 if( (posdate >= data->filter->mindate) && (posdate <= data->filter->maxdate) )
665 {
666 if(!selectall)
667 is_balance = balance < data->minimum ? TRUE : FALSE;
668
669 date = g_date_new_julian (posdate);
670 g_date_strftime (buf, 256-1, PREFS->date_format, date);
671 g_date_free(date);
672
673 /* column 0: pos (gint) */
674 /* not used: column 1: key (gint) */
675 /* column 2: name (gchar) */
676 /* column x: values (double) */
677
678 gtk_list_store_append (GTK_LIST_STORE(model), &iter);
679 gtk_list_store_set (GTK_LIST_STORE(model), &iter,
680 LST_OVER_OVER, is_balance,
681 LST_OVER_DATE, posdate,
682 LST_OVER_DATESTR, buf,
683 LST_OVER_EXPENSE, data->tmp_expense[i],
684 LST_OVER_INCOME, data->tmp_income[i],
685 LST_OVER_BALANCE, balance,
686 -1);
687 if(is_balance == TRUE)
688 data->nbbalance++;
689
690 data->nbope++;
691
692 }
693
694 }
695
696 g_free(data->tmp_expense);
697 g_free(data->tmp_income);
698
699 repbalance_update_info(widget, NULL);
700
701 gtk_chart_show_legend(GTK_CHART(data->RE_line), FALSE, FALSE);
702 gtk_chart_show_xval(GTK_CHART(data->RE_line), TRUE);
703 gtk_chart_set_overdrawn(GTK_CHART(data->RE_line), data->minimum);
704 gtk_chart_show_overdrawn(GTK_CHART(data->RE_line), !selectall);
705
706 gboolean visible = selectall ? FALSE : TRUE;
707 gtk_widget_set_visible (GTK_WIDGET(data->TX_info), visible);
708
709 /* Re-attach model to view */
710 gtk_tree_view_set_model(GTK_TREE_VIEW(data->LV_report), model);
711 g_object_unref(model);
712
713 /* update bar chart */
714 //DB( g_print(" set bar to %d\n\n", LST_STAT_EXPENSE+tmpkind) );
715 gtk_chart_set_datas(GTK_CHART(data->RE_line), model, LST_OVER_BALANCE, NULL, NULL);
716 //gtk_chart_set_line_datas(GTK_CHART(data->RE_line), model, LST_OVER_BALANCE, LST_OVER_DATE);
717
718
719 }
720
721
722 static void repbalance_toggle_selectall(GtkWidget *widget, gpointer user_data)
723 {
724 struct repbalance_data *data;
725 gboolean selectall;
726
727 DB( g_print("(repbalance) toggle selectall\n") );
728
729 data = g_object_get_data(G_OBJECT(gtk_widget_get_ancestor(widget, GTK_TYPE_WINDOW)), "inst_data");
730
731 selectall = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(data->CM_selectall));
732
733 gtk_widget_set_sensitive(GTK_WIDGET(data->PO_acc), selectall^1);
734
735 repbalance_compute(widget, data);
736
737 }
738
739
740 static void repbalance_setup(struct repbalance_data *data, guint32 accnum)
741 {
742 DB( g_print("(repbalance) setup\n") );
743
744 data->ope_list = NULL;
745
746 data->filter = da_filter_malloc();
747 filter_default_all_set(data->filter);
748
749 data->accnum = accnum;
750 filter_preset_daterange_set(data->filter, PREFS->date_range_rep, data->accnum);
751
752 g_signal_handler_block(data->PO_mindate, data->handler_id[HID_REPBALANCE_MINDATE]);
753 g_signal_handler_block(data->PO_maxdate, data->handler_id[HID_REPBALANCE_MAXDATE]);
754
755 gtk_date_entry_set_date(GTK_DATE_ENTRY(data->PO_mindate), data->filter->mindate);
756 gtk_date_entry_set_date(GTK_DATE_ENTRY(data->PO_maxdate), data->filter->maxdate);
757
758 g_signal_handler_unblock(data->PO_mindate, data->handler_id[HID_REPBALANCE_MINDATE]);
759 g_signal_handler_unblock(data->PO_maxdate, data->handler_id[HID_REPBALANCE_MAXDATE]);
760
761 ui_acc_comboboxentry_populate(GTK_COMBO_BOX(data->PO_acc), GLOBALS->h_acc, ACC_LST_INSERT_REPORT);
762 if( accnum )
763 ui_acc_comboboxentry_set_active(GTK_COMBO_BOX(data->PO_acc), accnum);
764 else
765 gtk_combo_box_set_active(GTK_COMBO_BOX(data->PO_acc), 0);
766
767 }
768
769
770 static gboolean repbalance_window_dispose(GtkWidget *widget, GdkEvent *event, gpointer user_data)
771 {
772 struct repbalance_data *data = user_data;
773 struct WinGeometry *wg;
774
775 DB( g_print("(repbalance) dispose\n") );
776
777 g_list_free (data->ope_list);
778
779 da_filter_free(data->filter);
780
781 g_free(data);
782
783 //store position and size
784 wg = &PREFS->ove_wg;
785 gtk_window_get_position(GTK_WINDOW(widget), &wg->l, &wg->t);
786 gtk_window_get_size(GTK_WINDOW(widget), &wg->w, &wg->h);
787
788 DB( g_print(" window: l=%d, t=%d, w=%d, h=%d\n", wg->l, wg->t, wg->w, wg->h) );
789
790 //enable define windows
791 GLOBALS->define_off--;
792 ui_mainwindow_update(GLOBALS->mainwindow, GINT_TO_POINTER(UF_SENSITIVE));
793
794 return FALSE;
795 }
796
797
798 // the window creation
799 GtkWidget *repbalance_window_new(gint accnum)
800 {
801 struct repbalance_data *data;
802 struct WinGeometry *wg;
803 GtkWidget *window, *mainvbox, *hbox, *vbox, *notebook, *treeview;
804 GtkWidget *label, *widget, *table;
805 gint row;
806 GtkUIManager *ui;
807 GtkActionGroup *actions;
808 GtkAction *action;
809 GError *error = NULL;
810
811 data = g_malloc0(sizeof(struct repbalance_data));
812 if(!data) return NULL;
813
814 DB( g_print("(repbalance) new\n") );
815
816 //disable define windows
817 GLOBALS->define_off++;
818 ui_mainwindow_update(GLOBALS->mainwindow, GINT_TO_POINTER(2));
819
820 /* create window, etc */
821 window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
822 data->window = window;
823
824 //store our window private data
825 g_object_set_data(G_OBJECT(window), "inst_data", (gpointer)data);
826
827 gtk_window_set_title (GTK_WINDOW (window), _("Balance report"));
828
829 //set the window icon
830 gtk_window_set_icon_name(GTK_WINDOW (window), ICONNAME_HB_REP_BALANCE);
831
832 //window contents
833 mainvbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
834 gtk_container_add (GTK_CONTAINER (window), mainvbox);
835
836 hbox = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0);
837 gtk_box_pack_start (GTK_BOX (mainvbox), hbox, TRUE, TRUE, 0);
838
839 //control part
840 table = gtk_grid_new ();
841 gtk_widget_set_hexpand (GTK_WIDGET(table), FALSE);
842 gtk_box_pack_start (GTK_BOX (hbox), table, FALSE, FALSE, 0);
843
844 gtk_container_set_border_width (GTK_CONTAINER (table), SPACING_SMALL);
845 gtk_grid_set_row_spacing (GTK_GRID (table), SPACING_SMALL);
846 gtk_grid_set_column_spacing (GTK_GRID (table), SPACING_MEDIUM);
847
848
849 row = 0;
850 label = make_label_group(_("Display"));
851 gtk_grid_attach (GTK_GRID (table), label, 0, row, 3, 1);
852
853 row++;
854 label = make_label_widget(_("A_ccount:"));
855 gtk_grid_attach (GTK_GRID (table), label, 1, row, 1, 1);
856 widget = ui_acc_comboboxentry_new(label);
857 data->PO_acc = widget;
858 gtk_grid_attach (GTK_GRID (table), widget, 2, row, 1, 1);
859
860 row++;
861 widget = gtk_check_button_new_with_mnemonic (_("Select _all"));
862 data->CM_selectall = widget;
863 gtk_grid_attach (GTK_GRID (table), widget, 2, row, 1, 1);
864
865 row++;
866 widget = gtk_check_button_new_with_mnemonic (_("Each _day"));
867 //gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON(widget), TRUE);
868 data->CM_eachday = widget;
869 gtk_grid_attach (GTK_GRID (table), widget, 2, row, 1, 1);
870
871 row++;
872 widget = gtk_check_button_new_with_mnemonic (_("Euro _minor"));
873 data->CM_minor = widget;
874 gtk_grid_attach (GTK_GRID (table), widget, 2, row, 1, 1);
875
876 row++;
877 label = make_label_widget(_("_Zoom X:"));
878 data->LB_zoomx = label;
879 gtk_grid_attach (GTK_GRID (table), label, 1, row, 1, 1);
880 widget = make_scale(label);
881 data->RG_zoomx = widget;
882 gtk_grid_attach (GTK_GRID (table), widget, 2, row, 1, 1);
883
884 row++;
885 widget = gtk_separator_new(GTK_ORIENTATION_HORIZONTAL);
886 gtk_grid_attach (GTK_GRID (table), widget, 0, row, 3, 1);
887
888 row++;
889 label = make_label_group(_("Date filter"));
890 gtk_grid_attach (GTK_GRID (table), label, 0, row, 3, 1);
891
892 row++;
893 label = make_label_widget(_("_Range:"));
894 gtk_grid_attach (GTK_GRID (table), label, 1, row, 1, 1);
895 data->CY_range = make_daterange(label, FALSE);
896 gtk_grid_attach (GTK_GRID (table), data->CY_range, 2, row, 1, 1);
897
898 row++;
899 label = make_label_widget(_("_From:"));
900 gtk_grid_attach (GTK_GRID (table), label, 1, row, 1, 1);
901 data->PO_mindate = gtk_date_entry_new();
902 gtk_grid_attach (GTK_GRID (table), data->PO_mindate, 2, row, 1, 1);
903
904 row++;
905 label = make_label_widget(_("_To:"));
906 gtk_grid_attach (GTK_GRID (table), label, 1, row, 1, 1);
907 data->PO_maxdate = gtk_date_entry_new();
908 gtk_grid_attach (GTK_GRID (table), data->PO_maxdate, 2, row, 1, 1);
909
910
911 //part: info + report
912 vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
913 gtk_box_pack_start (GTK_BOX (hbox), vbox, TRUE, TRUE, 0);
914
915 //ui manager
916 actions = gtk_action_group_new ("Account");
917
918 //as we use gettext
919 gtk_action_group_set_translation_domain(actions, GETTEXT_PACKAGE);
920
921 // data to action callbacks is set here (data)
922 gtk_action_group_add_actions (actions, entries, n_entries, data);
923
924 gtk_action_group_add_toggle_actions (actions,
925 toggle_entries, n_toggle_entries,
926 data);
927
928
929 /* set which action should have priority in the toolbar */
930 action = gtk_action_group_get_action(actions, "List");
931 g_object_set(action, "is_important", TRUE, NULL);
932
933 action = gtk_action_group_get_action(actions, "Line");
934 g_object_set(action, "is_important", TRUE, NULL);
935
936 action = gtk_action_group_get_action(actions, "Detail");
937 g_object_set(action, "is_important", TRUE, NULL);
938
939 action = gtk_action_group_get_action(actions, "Refresh");
940 g_object_set(action, "is_important", TRUE, NULL);
941
942
943
944 ui = gtk_ui_manager_new ();
945 gtk_ui_manager_insert_action_group (ui, actions, 0);
946 gtk_window_add_accel_group (GTK_WINDOW (window), gtk_ui_manager_get_accel_group (ui));
947
948 if (!gtk_ui_manager_add_ui_from_string (ui, ui_info, -1, &error))
949 {
950 g_message ("building UI failed: %s", error->message);
951 g_error_free (error);
952 }
953
954 data->ui = ui;
955 data->actions = actions;
956
957 //toolbar
958 data->TB_bar = gtk_ui_manager_get_widget (ui, "/ToolBar");
959 gtk_box_pack_start (GTK_BOX (vbox), data->TB_bar, FALSE, FALSE, 0);
960
961 //infos
962 hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, SPACING_SMALL);
963 gtk_container_set_border_width (GTK_CONTAINER(hbox), SPACING_SMALL);
964 gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0);
965
966
967 widget = make_label(NULL, 0.5, 0.5);
968 gimp_label_set_attributes (GTK_LABEL (widget), PANGO_ATTR_SCALE, PANGO_SCALE_SMALL, -1);
969 data->TX_daterange = widget;
970 gtk_box_pack_start (GTK_BOX (hbox), widget, TRUE, TRUE, 0);
971
972
973 label = gtk_label_new(NULL);
974 data->TX_info = label;
975 gtk_box_pack_end (GTK_BOX (hbox), label, FALSE, FALSE, 0);
976
977 notebook = gtk_notebook_new();
978 data->GR_result = notebook;
979 gtk_widget_show(notebook);
980 gtk_notebook_set_show_tabs(GTK_NOTEBOOK(notebook), FALSE);
981 gtk_notebook_set_show_border(GTK_NOTEBOOK(notebook), FALSE);
982
983 gtk_box_pack_start (GTK_BOX (vbox), notebook, TRUE, TRUE, 0);
984
985 //page: list
986 vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
987 gtk_notebook_append_page(GTK_NOTEBOOK(notebook), vbox, NULL);
988
989 widget = gtk_scrolled_window_new (NULL, NULL);
990 gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (widget), GTK_SHADOW_ETCHED_IN);
991 gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (widget), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
992
993 treeview = create_list_repbalance();
994 data->LV_report = treeview;
995 gtk_container_add (GTK_CONTAINER(widget), treeview);
996 //gtk_notebook_append_page(GTK_NOTEBOOK(notebook), widget, NULL);
997 gtk_box_pack_start (GTK_BOX (vbox), widget, TRUE, TRUE, 0);
998
999 //detail
1000 widget = gtk_scrolled_window_new (NULL, NULL);
1001 data->GR_detail = widget;
1002 //gtk_scrolled_window_set_placement(GTK_SCROLLED_WINDOW (widget), GTK_CORNER_TOP_RIGHT);
1003 gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (widget), GTK_SHADOW_ETCHED_IN);
1004 gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (widget), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
1005 treeview = create_list_transaction(LIST_TXN_TYPE_DETAIL, PREFS->lst_ope_columns);
1006 data->LV_detail = treeview;
1007 gtk_container_add (GTK_CONTAINER(widget), treeview);
1008
1009 gtk_box_pack_start (GTK_BOX (vbox), widget, TRUE, TRUE, 0);
1010
1011
1012 //page: 2d lines
1013 widget = gtk_chart_new(CHART_TYPE_LINE);
1014 data->RE_line = widget;
1015 //gtk_chart_set_minor_prefs(GTK_CHART(widget), PREFS->euro_value, PREFS->minor_cur.suffix_symbol);
1016 gtk_notebook_append_page(GTK_NOTEBOOK(notebook), widget, NULL);
1017
1018
1019
1020
1021 //todo:should move this
1022 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(data->CM_minor),GLOBALS->minor);
1023
1024
1025
1026 /* attach our minor to treeview */
1027 g_object_set_data(G_OBJECT(gtk_tree_view_get_model(GTK_TREE_VIEW(data->LV_report))), "minor", (gpointer)data->CM_minor);
1028
1029
1030
1031
1032
1033 /* signal connect */
1034 g_signal_connect (window, "delete-event", G_CALLBACK (repbalance_window_dispose), (gpointer)data);
1035
1036 g_signal_connect (data->CM_minor, "toggled", G_CALLBACK (repbalance_toggle_minor), NULL);
1037
1038
1039 data->handler_id[HID_REPBALANCE_MINDATE] = g_signal_connect (data->PO_mindate, "changed", G_CALLBACK (repbalance_date_change), (gpointer)data);
1040 data->handler_id[HID_REPBALANCE_MAXDATE] = g_signal_connect (data->PO_maxdate, "changed", G_CALLBACK (repbalance_date_change), (gpointer)data);
1041
1042 data->handler_id[HID_REPBALANCE_RANGE] = g_signal_connect (data->CY_range, "changed", G_CALLBACK (repbalance_range_change), NULL);
1043
1044 g_signal_connect (gtk_tree_view_get_selection(GTK_TREE_VIEW(data->LV_report)), "changed", G_CALLBACK (repbalance_selection), NULL);
1045
1046 //setup, init and show window
1047 repbalance_setup(data, accnum);
1048
1049 g_signal_connect (data->CM_selectall, "toggled", G_CALLBACK (repbalance_toggle_selectall), NULL);
1050 g_signal_connect (data->CM_eachday, "toggled", G_CALLBACK (repbalance_compute), NULL);
1051
1052
1053 //let this here or the setup trigger a compute...
1054 g_signal_connect (data->PO_acc, "changed", G_CALLBACK (repbalance_compute), NULL);
1055
1056 g_signal_connect (data->RG_zoomx, "value-changed", G_CALLBACK (repbalance_zoomx_callback), NULL);
1057
1058 g_signal_connect (GTK_TREE_VIEW(data->LV_detail), "row-activated", G_CALLBACK (repbalance_detail_onRowActivated), NULL);
1059
1060
1061 /* toolbar */
1062 if(PREFS->toolbar_style == 0)
1063 gtk_toolbar_unset_style(GTK_TOOLBAR(data->TB_bar));
1064 else
1065 gtk_toolbar_set_style(GTK_TOOLBAR(data->TB_bar), PREFS->toolbar_style-1);
1066
1067
1068 //setup, init and show window
1069 wg = &PREFS->ove_wg;
1070 gtk_window_move(GTK_WINDOW(window), wg->l, wg->t);
1071 gtk_window_resize(GTK_WINDOW(window), wg->w, wg->h);
1072 data->detail = 0;
1073
1074
1075 gtk_widget_show_all (window);
1076
1077 //minor ?
1078 if( PREFS->euro_active )
1079 gtk_widget_show(data->CM_minor);
1080 else
1081 gtk_widget_hide(data->CM_minor);
1082
1083 repbalance_sensitive(window, NULL);
1084 repbalance_update_detail(window, NULL);
1085
1086 gtk_combo_box_set_active(GTK_COMBO_BOX(data->CY_range), PREFS->date_range_rep);
1087
1088
1089 return(window);
1090 }
1091
1092 /*
1093 ** ============================================================================
1094 */
1095
1096
1097 static void repbalance_date_cell_data_function (GtkTreeViewColumn *col, GtkCellRenderer *renderer, GtkTreeModel *model, GtkTreeIter *iter, gpointer user_data)
1098 {
1099 gchar *datestr;
1100 gboolean is_balance;
1101 gchar *color;
1102 gint weight;
1103
1104 gtk_tree_model_get(model, iter,
1105 LST_OVER_DATESTR, &datestr,
1106 LST_OVER_OVER, &is_balance,
1107 -1);
1108
1109 color = NULL;
1110 weight = PANGO_WEIGHT_NORMAL;
1111
1112 if(is_balance==TRUE)
1113 {
1114 if(PREFS->custom_colors == TRUE)
1115 color = PREFS->color_warn;
1116
1117 weight = PANGO_WEIGHT_BOLD;
1118 }
1119
1120 g_object_set(renderer,
1121 "weight", weight,
1122 "foreground", color,
1123 "text", datestr,
1124 NULL);
1125 }
1126
1127
1128 static void repbalance_amount_cell_data_function (GtkTreeViewColumn *col,
1129 GtkCellRenderer *renderer,
1130 GtkTreeModel *model,
1131 GtkTreeIter *iter,
1132 gpointer user_data)
1133 {
1134 gdouble value;
1135 gchar buf[G_ASCII_DTOSTR_BUF_SIZE];
1136 gboolean is_balance;
1137 gchar *color;
1138 gint weight;
1139 guint32 kcur = GPOINTER_TO_UINT(g_object_get_data(G_OBJECT(gtk_tree_view_column_get_tree_view(col)), "kcur_data"));
1140
1141
1142 //get datas
1143 gtk_tree_model_get(model, iter,
1144 LST_OVER_OVER, &is_balance,
1145 GPOINTER_TO_INT(user_data), &value,
1146 -1);
1147
1148 //fix: 400483
1149 if( value == 0.0 )
1150 g_object_set(renderer, "text", NULL, NULL);
1151 else
1152 {
1153 hb_strfmon(buf, G_ASCII_DTOSTR_BUF_SIZE-1, value, kcur, GLOBALS->minor);
1154
1155 color = NULL;
1156 weight = PANGO_WEIGHT_NORMAL;
1157
1158
1159 if(value != 0.0 && PREFS->custom_colors == TRUE)
1160 color = (value > 0.0) ? PREFS->color_inc : PREFS->color_exp;
1161
1162 if(is_balance==TRUE)
1163 {
1164 if(PREFS->custom_colors == TRUE)
1165 color = PREFS->color_warn;
1166
1167 weight = PANGO_WEIGHT_BOLD;
1168 }
1169
1170 g_object_set(renderer,
1171 "weight", weight,
1172 "foreground", color,
1173 "text", buf,
1174 NULL);
1175 }
1176
1177 }
1178
1179 static GtkTreeViewColumn *amount_list_repbalance_column(gchar *name, gint id)
1180 {
1181 GtkTreeViewColumn *column;
1182 GtkCellRenderer *renderer;
1183
1184 column = gtk_tree_view_column_new();
1185 gtk_tree_view_column_set_title(column, name);
1186 renderer = gtk_cell_renderer_text_new ();
1187 g_object_set(renderer, "xalign", 1.0, NULL);
1188 gtk_tree_view_column_pack_start(column, renderer, TRUE);
1189 gtk_tree_view_column_set_cell_data_func(column, renderer, repbalance_amount_cell_data_function, GINT_TO_POINTER(id), NULL);
1190 gtk_tree_view_column_set_alignment (column, 0.5);
1191 //gtk_tree_view_column_set_sort_column_id (column, id);
1192 return column;
1193 }
1194
1195
1196 static void ui_repbalance_list_set_cur(GtkTreeView *treeview, guint32 kcur)
1197 {
1198 g_object_set_data(G_OBJECT(treeview), "kcur_data", GUINT_TO_POINTER(kcur));
1199 }
1200
1201
1202 /*
1203 ** create our statistic list
1204 */
1205 static GtkWidget *create_list_repbalance(void)
1206 {
1207 GtkListStore *store;
1208 GtkWidget *view;
1209 GtkCellRenderer *renderer;
1210 GtkTreeViewColumn *column;
1211
1212 /* create list store */
1213 store = gtk_list_store_new(
1214 NUM_LST_OVER,
1215 G_TYPE_BOOLEAN,
1216 G_TYPE_INT,
1217 G_TYPE_STRING,
1218 G_TYPE_DOUBLE,
1219 G_TYPE_DOUBLE,
1220 G_TYPE_DOUBLE
1221 );
1222
1223 //treeview
1224 view = gtk_tree_view_new_with_model(GTK_TREE_MODEL(store));
1225 g_object_unref(store);
1226
1227 gtk_tree_view_set_grid_lines (GTK_TREE_VIEW (view), PREFS->grid_lines);
1228
1229 /* column debug balance */
1230 /*
1231 column = gtk_tree_view_column_new();
1232 gtk_tree_view_column_set_title(column, "debug balance");
1233 gtk_tree_view_append_column (GTK_TREE_VIEW(view), column);
1234 renderer = gtk_cell_renderer_text_new();
1235 gtk_tree_view_column_pack_start(column, renderer, TRUE);
1236 gtk_tree_view_column_add_attribute(column, renderer, "text", LST_OVER_OVER);
1237 */
1238
1239 /* column date */
1240 column = gtk_tree_view_column_new();
1241 gtk_tree_view_column_set_title(column, _("Date"));
1242 gtk_tree_view_append_column (GTK_TREE_VIEW(view), column);
1243 renderer = gtk_cell_renderer_text_new();
1244 g_object_set(renderer, "xalign", 1.0, NULL);
1245 gtk_tree_view_column_pack_start(column, renderer, TRUE);
1246 //gtk_tree_view_column_add_attribute(column, renderer, "text", LST_OVER_DATE);
1247 gtk_tree_view_column_set_alignment (column, 0.5);
1248 gtk_tree_view_column_set_cell_data_func(column, renderer, repbalance_date_cell_data_function, NULL, NULL);
1249
1250
1251 /* column: Expense */
1252 column = amount_list_repbalance_column(_("Expense"), LST_OVER_EXPENSE);
1253 gtk_tree_view_append_column (GTK_TREE_VIEW(view), column);
1254
1255 /* column: Income */
1256 column = amount_list_repbalance_column(_("Income"), LST_OVER_INCOME);
1257 gtk_tree_view_append_column (GTK_TREE_VIEW(view), column);
1258
1259 /* column: Balance */
1260 column = amount_list_repbalance_column(_("Balance"), LST_OVER_BALANCE);
1261 gtk_tree_view_append_column (GTK_TREE_VIEW(view), column);
1262
1263 /* column last: empty */
1264 column = gtk_tree_view_column_new();
1265 gtk_tree_view_append_column (GTK_TREE_VIEW(view), column);
1266
1267
1268
1269 return(view);
1270 }
This page took 0.096217 seconds and 5 git commands to generate.