~ubuntu-branches/debian/experimental/homebank/experimental

« back to all changes in this revision

Viewing changes to src/rep_stats.c

  • Committer: Bazaar Package Importer
  • Author(s): Francesco Namuri
  • Date: 2008-04-07 16:20:53 UTC
  • mfrom: (1.2.1 upstream) (2.1.5 hardy)
  • Revision ID: james.westby@ubuntu.com-20080407162053-uyoaw9ba5u6swbps
Tags: 3.8-1
* New upstream release.
* debian-copyright: updated copyright information. 
* debian/changelog: applied patch to sync with ubuntu's changelog. 

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/* HomeBank -- Free easy personal accounting for all !
2
 
 * Copyright (C) 1995-2006 Maxime DOYEN
3
 
 *
4
 
 * This program is free software; you can redistribute it and/or modify
5
 
 * it under the terms of the GNU General Public License as published by
6
 
 * the Free Software Foundation; either version 2 of the License, or
7
 
 * (at your option) any later version.
8
 
 *
9
 
 * This program is distributed in the hope that it will be useful,
10
 
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11
 
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12
 
 * GNU General Public License for more details.
13
 
 *
14
 
 * You should have received a copy of the GNU General Public License
15
 
 * along with this program; if not, write to the Free Software
16
 
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 
1
/*  HomeBank -- Free, easy, personal accounting for everyone.
 
2
 *  Copyright (C) 1995-2008 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/>.
17
18
 */
18
19
 
19
20
 
20
21
#include "homebank.h"
21
 
 
 
22
#include "gtkchart.h"
 
23
#include "dsp_wallet.h"
22
24
#include "rep_stats.h"
23
25
#include "list_operation.h"
24
26
#include "def_filter.h"
51
53
struct statistic_data
52
54
{
53
55
        GtkWidget       *window;
 
56
 
 
57
        gint    busy;
 
58
 
54
59
        GtkUIManager    *ui;
 
60
        GtkActionGroup *actions;
55
61
 
56
62
        GtkWidget       *TB_bar;
57
63
        
113
119
static void statistic_action_filter(GtkAction *action, gpointer user_data);
114
120
static void statistic_action_refresh(GtkAction *action, gpointer user_data);
115
121
 
 
122
static void statistic_busy(GtkWidget *widget, gboolean state);
 
123
 
 
124
 
116
125
static GtkActionEntry entries[] = {
117
126
  { "List"    , "hb-stock-view-list" , N_("List")   , NULL,    N_("View results as list"), G_CALLBACK (statistic_action_viewlist) },
118
 
  { "Bar"     , "hb-stock-view-bar"  , N_("Bar")    , NULL,    N_("View results as 2d-bars"), G_CALLBACK (statistic_action_viewbar) },
119
 
  { "Pie"     , "hb-stock-view-pie"  , N_("Pie")    , NULL,    N_("View results as 2d-pies"), G_CALLBACK (statistic_action_viewpie) },
 
127
  { "Bar"     , "hb-stock-view-bar"  , N_("Bar")    , NULL,    N_("View results as bars"), G_CALLBACK (statistic_action_viewbar) },
 
128
  { "Pie"     , "hb-stock-view-pie"  , N_("Pie")    , NULL,    N_("View results as pies"), G_CALLBACK (statistic_action_viewpie) },
120
129
 
121
130
  { "Detail"  , "hb-stock-ope-show"  , N_("Detail") , NULL,    N_("Toggle detail"), G_CALLBACK (statistic_action_detail) },
122
131
  { "Legend"  , "hb-stock-legend"    , N_("Legend") , NULL,    N_("Toggle legend"), G_CALLBACK (statistic_action_legend) },
160
169
};
161
170
 
162
171
 
163
 
void statistic_date_change(GtkWidget *widget, gpointer user_data);
164
 
void statistic_period_change(GtkWidget *widget, gpointer user_data);
165
 
void statistic_range_change(GtkWidget *widget, gpointer user_data);
166
 
void statistic_action(GtkWidget *widget, gpointer user_data);
167
 
void statistic_detail(GtkWidget *widget, gpointer user_data);
168
 
void statistic_update(GtkWidget *widget, gpointer user_data);
169
 
void statistic_update_total(GtkWidget *widget, gpointer user_data);
170
 
void statistic_compute(GtkWidget *widget, gpointer user_data);
171
 
void statistic_sensitive(GtkWidget *widget, gpointer user_data);
172
 
void statistic_toggle_detail(GtkWidget *widget, gpointer user_data);
173
 
void statistic_toggle_legend(GtkWidget *widget, gpointer user_data);
174
 
void statistic_toggle_minor(GtkWidget *widget, gpointer user_data);
175
 
void statistic_toggle_rate(GtkWidget *widget, gpointer user_data);
176
 
GtkWidget *create_list_statistic(void);
 
172
static void statistic_date_change(GtkWidget *widget, gpointer user_data);
 
173
static void statistic_period_change(GtkWidget *widget, gpointer user_data);
 
174
static void statistic_range_change(GtkWidget *widget, gpointer user_data);
 
175
static void statistic_detail(GtkWidget *widget, gpointer user_data);
 
176
static void statistic_update(GtkWidget *widget, gpointer user_data);
 
177
static void statistic_update_total(GtkWidget *widget, gpointer user_data);
 
178
static void statistic_compute(GtkWidget *widget, gpointer user_data);
 
179
static void statistic_sensitive(GtkWidget *widget, gpointer user_data);
 
180
static void statistic_toggle_detail(GtkWidget *widget, gpointer user_data);
 
181
static void statistic_toggle_legend(GtkWidget *widget, gpointer user_data);
 
182
static void statistic_toggle_minor(GtkWidget *widget, gpointer user_data);
 
183
static void statistic_toggle_rate(GtkWidget *widget, gpointer user_data);
 
184
static GtkWidget *create_list_statistic(void);
177
185
 
178
 
gint stat_list_compare_func (GtkTreeModel *model, GtkTreeIter  *a, GtkTreeIter  *b, gpointer      userdata);
 
186
static gint stat_list_compare_func (GtkTreeModel *model, GtkTreeIter  *a, GtkTreeIter  *b, gpointer      userdata);
179
187
 
180
188
 
181
189
 
305
313
 
306
314
        if(create_deffilter_window(data->filter, TRUE) == GTK_RESPONSE_ACCEPT)
307
315
                statistic_compute(data->window, NULL);
308
 
 
309
316
}
310
317
 
311
318
static void statistic_action_refresh(GtkAction *action, gpointer user_data)
331
338
/*
332
339
** return the month list position correponding to the passed date
333
340
*/
334
 
gint DateInPer(guint32 from, guint32 opedate)
 
341
static gint DateInPer(guint32 from, guint32 opedate)
335
342
{
336
343
GDate *date1, *date2;
337
344
gint pos;
355
362
/*
356
363
** return the year list position correponding to the passed date
357
364
*/
358
 
gint DateInYear(guint32 from, guint32 opedate)
 
365
static gint DateInYear(guint32 from, guint32 opedate)
359
366
{
360
367
GDate *date;
361
368
gint year_from, year_ope, pos;
373
380
        return(pos);
374
381
}
375
382
 
376
 
void statistic_date_change(GtkWidget *widget, gpointer user_data)
 
383
static void statistic_date_change(GtkWidget *widget, gpointer user_data)
377
384
{
378
385
struct statistic_data *data;
379
386
 
389
396
}
390
397
 
391
398
 
392
 
void statistic_period_change(GtkWidget *widget, gpointer user_data)
 
399
static void statistic_period_change(GtkWidget *widget, gpointer user_data)
393
400
{
394
401
struct statistic_data *data;
395
402
gint month, year;
433
440
 
434
441
}
435
442
 
436
 
void statistic_range_change(GtkWidget *widget, gpointer user_data)
 
443
static void statistic_range_change(GtkWidget *widget, gpointer user_data)
437
444
{
438
445
struct statistic_data *data;
439
446
GList *list;
496
503
 
497
504
 
498
505
 
499
 
void statistic_detail(GtkWidget *widget, gpointer user_data)
 
506
static void statistic_detail(GtkWidget *widget, gpointer user_data)
500
507
{
501
508
struct statistic_data *data;
502
509
guint active = (gint)user_data;
509
516
 
510
517
        DB( g_print("(statistic) detail\n") );
511
518
 
512
 
        if(data->detail)
 
519
                /* clear and detach our model */
 
520
                model = gtk_tree_view_get_model(GTK_TREE_VIEW(data->LV_detail));
 
521
                gtk_list_store_clear (GTK_LIST_STORE(model));
 
522
 
 
523
        if(data->detail && active != -1)
513
524
        {
514
525
                tmpfor  = gtk_combo_box_get_active(GTK_COMBO_BOX(data->CY_for));
515
526
 
516
 
                /* clear and detach our model */
517
 
                model = gtk_tree_view_get_model(GTK_TREE_VIEW(data->LV_detail));
518
 
                gtk_list_store_clear (GTK_LIST_STORE(model));
519
527
                g_object_ref(model); /* Make sure the model stays with us after the tree view unrefs it */
520
528
                gtk_tree_view_set_model(GTK_TREE_VIEW(data->LV_detail), NULL); /* Detach model from view */
521
529
 
527
535
 
528
536
                        //DB( g_print(" get %s\n", ope->ope_Word) );
529
537
 
530
 
 
531
538
                        //filter here
532
 
                        if( !(ope->flags & OF_REMIND) && ope->date >= data->filter->mindate && ope->date <= data->filter->maxdate)
 
539
                        if(filter_test(data->filter, ope) == 1)
533
540
                        {
534
541
                        gint pos = 0;
535
542
 
582
589
}
583
590
 
584
591
 
585
 
void statistic_update(GtkWidget *widget, gpointer user_data)
 
592
static void statistic_update(GtkWidget *widget, gpointer user_data)
586
593
{
587
594
struct statistic_data *data;
588
595
gboolean byamount;
589
596
GtkTreeModel             *model;
590
 
gint tmpkind, column;
 
597
gint page, tmpkind, column;
591
598
 
592
599
        DB( g_print("(statistic) update\n") );
593
600
 
598
605
        byamount = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(data->CM_byamount));
599
606
        tmpkind = gtk_combo_box_get_active(GTK_COMBO_BOX(data->CY_view));
600
607
 
 
608
        // ensure not exp & inc for piechart
 
609
        page = gtk_notebook_get_current_page(GTK_NOTEBOOK(data->GR_result));
 
610
 
 
611
        if( page == 2 && tmpkind == 0 )
 
612
        {
 
613
                g_signal_handler_block(data->CY_view, data->handler_id[HID_VIEW]);
 
614
                gtk_combo_box_set_active(GTK_COMBO_BOX(data->CY_view), 1);
 
615
                g_signal_handler_unblock(data->CY_view, data->handler_id[HID_VIEW]);
 
616
                tmpkind = 1;
 
617
        }
 
618
 
 
619
 
601
620
        DB( g_print(" tmpkind %d\n\n", tmpkind) );
602
621
 
603
622
 
626
645
        
627
646
}
628
647
 
629
 
void statistic_update_total(GtkWidget *widget, gpointer user_data)
 
648
static void statistic_update_total(GtkWidget *widget, gpointer user_data)
630
649
{
631
650
struct statistic_data *data;
632
651
gboolean minor;
643
662
 
644
663
}
645
664
 
646
 
void statistic_compute(GtkWidget *widget, gpointer user_data)
 
665
static void statistic_compute(GtkWidget *widget, gpointer user_data)
647
666
{
648
667
struct statistic_data *data;
649
668
gint tmpfor, tmpkind;
655
674
gint n_result, i, id;
656
675
GDate *date1, *date2;
657
676
gdouble *tmp_income, *tmp_expense;
 
677
gdouble exprate, incrate, balrate;
658
678
 
659
679
        DB( g_print("(statistic) compute\n") );
660
680
 
840
860
 
841
861
                        DB( g_print(" inserting %2d, %48s, %9.2f %9.2f %9.2f\n", i, name, tmp_expense[i], tmp_income[i], tmp_expense[i] + tmp_income[i]) );
842
862
 
 
863
                        //compute rate
 
864
                        exprate = 0.0;
 
865
                        incrate = 0.0;
 
866
                        balrate = 0.0;
 
867
 
 
868
                        if( data->total_expense )
 
869
                                exprate = (ABS(tmp_expense[i]) * 100 / data->total_expense);
 
870
                        
 
871
                        if( data->total_income )
 
872
                                incrate = (tmp_income[i] * 100 / data->total_income);
 
873
                                
 
874
                        if( (data->total_expense + data->total_income) )
 
875
                                balrate = (ABS(tmp_expense[i]) + tmp_income[i]) * 100 / (data->total_expense + data->total_income);
 
876
 
843
877
                gtk_list_store_append (GTK_LIST_STORE(model), &iter);
844
878
                gtk_list_store_set (GTK_LIST_STORE(model), &iter,
845
879
                                LST_STAT_POS, id++,
848
882
                                LST_STAT_EXPENSE, tmp_expense[i],
849
883
                                LST_STAT_INCOME, tmp_income[i],
850
884
                                LST_STAT_BALANCE, tmp_expense[i] + tmp_income[i],
851
 
                                LST_STAT_EXPRATE, (ABS(tmp_expense[i]) * 100 / data->total_expense),
852
 
                                LST_STAT_INCRATE, (tmp_income[i] * 100 / data->total_income),
853
 
                                LST_STAT_BALRATE, (ABS(tmp_expense[i]) + tmp_income[i]) * 100 / (data->total_expense + data->total_income) ,
 
885
                                LST_STAT_EXPRATE, exprate,
 
886
                                LST_STAT_INCRATE, incrate,
 
887
                                LST_STAT_BALRATE, balrate,
854
888
                                -1);
855
889
 
856
890
                        g_free(fullcatname);
900
934
/*
901
935
** update sensitivity
902
936
*/
903
 
void statistic_sensitive(GtkWidget *widget, gpointer user_data)
 
937
static void statistic_sensitive(GtkWidget *widget, gpointer user_data)
904
938
{
905
939
struct statistic_data *data;
906
940
gboolean active;
907
941
gboolean sensitive;
908
 
gint page;
 
942
gint page, view;
909
943
 
910
944
        DB( g_print("(statistic) sensitive\n") );
911
945
 
919
953
//      gtk_widget_set_sensitive(data->TB_buttons[ACTION_REPBUDGET_DETAIL], sensitive);
920
954
        gtk_action_set_sensitive(gtk_ui_manager_get_action(data->ui, "/ToolBar/Detail"), sensitive);
921
955
 
 
956
        view = gtk_combo_box_get_active(GTK_COMBO_BOX(data->CY_view));
 
957
 
922
958
        sensitive = page == 0 ? FALSE : TRUE;
923
 
        gtk_widget_set_sensitive(data->CY_view, sensitive);
 
959
//      gtk_widget_set_sensitive(data->CY_view, sensitive);
924
960
//      gtk_widget_set_sensitive(data->TB_buttons[ACTION_REPBUDGET_LEGEND], sensitive);
925
961
        gtk_action_set_sensitive(gtk_ui_manager_get_action(data->ui, "/ToolBar/Legend"), sensitive);
926
962
 
927
963
 
928
964
}
929
965
 
930
 
void statistic_update_detail(GtkWidget *widget, gpointer user_data)
 
966
static void statistic_update_detail(GtkWidget *widget, gpointer user_data)
931
967
{
932
968
struct statistic_data *data;
933
969
 
962
998
 
963
999
 
964
1000
 
965
 
void statistic_toggle_detail(GtkWidget *widget, gpointer user_data)
 
1001
static void statistic_toggle_detail(GtkWidget *widget, gpointer user_data)
966
1002
{
967
1003
struct statistic_data *data;
968
1004
 
979
1015
/*
980
1016
** change the chart legend visibility
981
1017
*/
982
 
void statistic_toggle_legend(GtkWidget *widget, gpointer user_data)
 
1018
static void statistic_toggle_legend(GtkWidget *widget, gpointer user_data)
983
1019
{
984
1020
struct statistic_data *data;
985
1021
//gint active;
1000
1036
/*
1001
1037
** change the chart rate columns visibility
1002
1038
*/
1003
 
void statistic_toggle_rate(GtkWidget *widget, gpointer user_data)
 
1039
static void statistic_toggle_rate(GtkWidget *widget, gpointer user_data)
1004
1040
{
1005
1041
struct statistic_data *data;
1006
1042
GtkTreeViewColumn *column;
1023
1059
 
1024
1060
}
1025
1061
 
1026
 
void statistic_toggle_minor(GtkWidget *widget, gpointer user_data)
 
1062
static void statistic_toggle_minor(GtkWidget *widget, gpointer user_data)
1027
1063
{
1028
1064
struct statistic_data *data;
1029
1065
gboolean minor;
1044
1080
}
1045
1081
 
1046
1082
 
 
1083
static void statistic_busy(GtkWidget *widget, gboolean state)
 
1084
{
 
1085
struct statistic_data *data;
 
1086
GtkWidget *window;
 
1087
GdkCursor *cursor;
 
1088
 
 
1089
        DB( g_printf("(statistic) busy\n") );
 
1090
 
 
1091
        window = gtk_widget_get_ancestor(widget, GTK_TYPE_WINDOW);
 
1092
        data = g_object_get_data(G_OBJECT(window), "inst_data");
 
1093
 
 
1094
        // should busy ?
 
1095
        if(state == TRUE)
 
1096
        {
 
1097
                cursor = gdk_cursor_new(GDK_WATCH);
 
1098
                gdk_window_set_cursor(GTK_WIDGET(window)->window, cursor);
 
1099
                gdk_cursor_unref(cursor);
 
1100
                
 
1101
                //gtk_grab_add(data->busy_popup);
 
1102
                
 
1103
                gtk_widget_set_sensitive(window, FALSE);
 
1104
                gtk_action_group_set_sensitive(data->actions, FALSE);
 
1105
 
 
1106
                  /* make sure chnages is up */
 
1107
                  while (gtk_events_pending ())
 
1108
                    gtk_main_iteration ();
 
1109
        }
 
1110
        // unbusy
 
1111
        else
 
1112
        {
 
1113
                gtk_widget_set_sensitive(window, TRUE);
 
1114
                gtk_action_group_set_sensitive(data->actions, TRUE);    
 
1115
                
 
1116
                gdk_window_set_cursor(GTK_WIDGET(window)->window, NULL);
 
1117
                //gtk_grab_remove(data->busy_popup);
 
1118
        }
 
1119
}
 
1120
 
1047
1121
/*
1048
1122
**
1049
1123
*/
1050
 
void statistic_setup(struct statistic_data *data)
 
1124
static void statistic_setup(struct statistic_data *data)
1051
1125
{
1052
1126
        DB( g_print("(statistic) setup\n") );
1053
1127
 
1062
1136
        statistic_toggle_rate(data->window, NULL);
1063
1137
 
1064
1138
        filter_reset(data->filter);
 
1139
        
 
1140
        /* 3.4 : make int transfert out of stats */
 
1141
        data->filter->option[FILTER_PAYMODE] = 1;
 
1142
        data->filter->paymode[PAYMODE_PERSTRANSFERT] = FALSE;
1065
1143
 
1066
1144
        /* if ope get date bounds */
1067
1145
        if(g_list_length(GLOBALS->ope_list) > 0)
1109
1187
 
1110
1188
 
1111
1189
 
1112
 
void statistic_selection(GtkTreeSelection *treeselection, gpointer user_data)
 
1190
static void statistic_selection(GtkTreeSelection *treeselection, gpointer user_data)
1113
1191
{
1114
1192
GtkTreeModel *model;
1115
1193
GtkTreeIter iter;
1116
 
guint key;
 
1194
guint key = -1;
1117
1195
 
1118
1196
        DB( g_print("(statistic) selection\n") );
1119
1197
 
1121
1199
        {
1122
1200
                gtk_tree_model_get(model, &iter, LST_STAT_KEY, &key, -1);
1123
1201
 
1124
 
                DB( g_print(" - active is %d\n", key) );
1125
 
 
1126
 
 
1127
 
                statistic_detail(GTK_WIDGET(gtk_tree_selection_get_tree_view (treeselection)), (gpointer)key);
1128
1202
        }
1129
1203
 
 
1204
        DB( g_print(" - active is %d\n", key) );
 
1205
 
 
1206
        statistic_detail(GTK_WIDGET(gtk_tree_selection_get_tree_view (treeselection)), (gpointer)key);
1130
1207
        statistic_sensitive(GTK_WIDGET(gtk_tree_selection_get_tree_view (treeselection)), NULL);
1131
 
 
1132
1208
}
1133
1209
 
1134
1210
 
1135
1211
/*
1136
1212
**
1137
1213
*/
1138
 
gboolean statistic_dispose(GtkWidget *widget, GdkEvent *event, gpointer user_data)
 
1214
static gboolean statistic_dispose(GtkWidget *widget, GdkEvent *event, gpointer user_data)
1139
1215
{
1140
1216
struct statistic_data *data = user_data;
 
1217
struct WinGeometry *wg;
1141
1218
 
1142
1219
        DB( g_print("(statistic) dispose\n") );
1143
1220
 
1145
1222
 
1146
1223
        g_free(data);
1147
1224
 
 
1225
        //store position and size
 
1226
        wg = &PREFS->sta_wg;
 
1227
        gtk_window_get_position(GTK_WINDOW(widget), &wg->l, &wg->t);
 
1228
        gtk_window_get_size(GTK_WINDOW(widget), &wg->w, &wg->h);
 
1229
        
 
1230
        DB( g_printf(" window: l=%d, t=%d, w=%d, h=%d\n", wg->l, wg->t, wg->w, wg->h) );
 
1231
 
 
1232
 
 
1233
 
1148
1234
        //enable define windows
1149
1235
        GLOBALS->define_off--;
1150
1236
        wallet_update(GLOBALS->mainwindow, (gpointer)2);
1156
1242
GtkWidget *create_statistic_window(void)
1157
1243
{
1158
1244
struct statistic_data *data;
 
1245
struct WinGeometry *wg;
1159
1246
GtkWidget *window, *mainvbox, *hbox, *vbox, *notebook, *treeview;
1160
1247
GtkWidget *label, *widget, *table, *alignment, *vbar, *entry;
1161
1248
gint row;
1180
1267
        gtk_window_set_title (GTK_WINDOW (window), _("Statistics Report"));
1181
1268
 
1182
1269
        //set the window icon
1183
 
        gtk_window_set_icon_from_file(GTK_WINDOW (window), PIXMAPS_DIR "/report_stats.svg", NULL);
 
1270
        homebank_window_set_icon_from_file(GTK_WINDOW (window), "report_stats.svg");
1184
1271
 
1185
1272
 
1186
1273
        //window contents
1298
1385
                g_error_free (error);
1299
1386
        }
1300
1387
 
1301
 
        data->ui = ui;  
 
1388
        data->ui = ui;
 
1389
        data->actions = actions;
1302
1390
 
1303
1391
        //toolbar
1304
1392
        data->TB_bar = gtk_ui_manager_get_widget (ui, "/ToolBar");
1369
1457
        //gtk_scrolled_window_set_placement(GTK_SCROLLED_WINDOW (widget), GTK_CORNER_TOP_RIGHT);
1370
1458
        gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (widget), GTK_SHADOW_ETCHED_IN);
1371
1459
        gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (widget), GTK_POLICY_NEVER, GTK_POLICY_ALWAYS);
1372
 
        treeview = create_list_operation();
 
1460
        treeview = create_list_operation(PREFS->lst_ope_columns);
1373
1461
        data->LV_detail = treeview;
1374
1462
        gtk_container_add (GTK_CONTAINER(widget), treeview);
1375
1463
 
1379
1467
        //page: 2d bar
1380
1468
        widget = gtk_chart_new(CHART_BAR_TYPE);
1381
1469
        data->RE_bar = widget;
1382
 
        gtk_chart_set_minor_prefs(GTK_CHART(widget), PREFS->euro_value, PREFS->euro_symbol);
 
1470
        gtk_chart_set_minor_prefs(GTK_CHART(widget), PREFS->euro_value, PREFS->minor_cur.suffix_symbol);
1383
1471
        gtk_notebook_append_page(GTK_NOTEBOOK(notebook), widget, NULL);
1384
1472
 
1385
1473
        //page: 2d pie
1386
1474
        widget = gtk_chart_new(CHART_PIE_TYPE);
1387
1475
        data->RE_pie = widget;
1388
 
        gtk_chart_set_minor_prefs(GTK_CHART(widget), PREFS->euro_value, PREFS->euro_symbol);
 
1476
        gtk_chart_set_minor_prefs(GTK_CHART(widget), PREFS->euro_value, PREFS->minor_cur.suffix_symbol);
1389
1477
        gtk_notebook_append_page(GTK_NOTEBOOK(notebook), widget, NULL);
1390
1478
 
1391
1479
 
1393
1481
        gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(data->CM_minor), GLOBALS->minor);
1394
1482
        gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(data->CM_byamount), PREFS->stat_byamount);
1395
1483
 
 
1484
        gtk_combo_box_set_active(GTK_COMBO_BOX(data->CY_view), 1);
1396
1485
 
1397
1486
        /* attach our minor to treeview */
1398
1487
        g_object_set_data(G_OBJECT(gtk_tree_view_get_model(GTK_TREE_VIEW(data->LV_report))), "minor", (gpointer)data->CM_minor);
1422
1511
        //setup, init and show window
1423
1512
        statistic_setup(data);
1424
1513
 
1425
 
    /* finish & show */
1426
 
    gtk_window_set_default_size (GTK_WINDOW (window), 640, 480);
 
1514
        /* toolbar */
 
1515
        if(PREFS->toolbar_style == 0)
 
1516
                gtk_toolbar_unset_style(GTK_TOOLBAR(data->TB_bar));
 
1517
        else
 
1518
                gtk_toolbar_set_style(GTK_TOOLBAR(data->TB_bar), PREFS->toolbar_style-1);
 
1519
 
 
1520
        //setup, init and show window
 
1521
        wg = &PREFS->sta_wg;
 
1522
        gtk_window_move(GTK_WINDOW(window), wg->l, wg->t);
 
1523
        gtk_window_resize(GTK_WINDOW(window), wg->w, wg->h);
1427
1524
 
1428
1525
        gtk_widget_show_all (window);
1429
1526
 
 
1527
        statistic_busy(window, TRUE);
1430
1528
 
1431
1529
        //minor ?
1432
1530
        if( PREFS->euro_active )
1448
1546
        else
1449
1547
                statistic_compute(window, NULL);
1450
1548
 
 
1549
        statistic_busy(window, FALSE);
 
1550
 
1451
1551
 
1452
1552
        return window;
1453
1553
}
1456
1556
** ============================================================================
1457
1557
*/
1458
1558
 
1459
 
void statistic_rate_cell_data_function (GtkTreeViewColumn *col,
 
1559
static void statistic_rate_cell_data_function (GtkTreeViewColumn *col,
1460
1560
                           GtkCellRenderer   *renderer,
1461
1561
                           GtkTreeModel      *model,
1462
1562
                           GtkTreeIter       *iter,
1488
1588
}
1489
1589
 
1490
1590
 
1491
 
void statistic_amount_cell_data_function (GtkTreeViewColumn *col,
 
1591
static void statistic_amount_cell_data_function (GtkTreeViewColumn *col,
1492
1592
                           GtkCellRenderer   *renderer,
1493
1593
                           GtkTreeModel      *model,
1494
1594
                           GtkTreeIter       *iter,
1504
1604
        //get datas
1505
1605
        gtk_tree_model_get(model, iter, user_data, &value, -1);
1506
1606
 
1507
 
        widget = g_object_get_data(G_OBJECT(model), "minor");
1508
 
        if(GTK_IS_TOGGLE_BUTTON(widget))
 
1607
        if( value )
1509
1608
        {
1510
 
                minor = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget));
 
1609
                widget = g_object_get_data(G_OBJECT(model), "minor");
 
1610
                if(GTK_IS_TOGGLE_BUTTON(widget))
 
1611
                {
 
1612
                        minor = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget));
 
1613
                }
 
1614
                else
 
1615
                        minor = 0;
 
1616
 
 
1617
                mystrfmon(buf, 127, value, minor);
 
1618
 
 
1619
                color = (value > 0) ? PREFS->color_inc : PREFS->color_exp;
 
1620
 
 
1621
                markuptxt = g_strdup_printf("<span color='#%06x'>%s</span>", color, buf);
 
1622
                g_object_set(renderer, "markup", markuptxt, NULL);
 
1623
                g_free(markuptxt);
1511
1624
        }
1512
1625
        else
1513
 
                minor = 0;
1514
 
 
1515
 
        hb_strfmon(buf, 127, value, minor);
1516
 
 
1517
 
        color = (value > 0) ? PREFS->color_inc : PREFS->color_exp;
1518
 
 
1519
 
        markuptxt = g_strdup_printf("<span color='#%06x'>%s</span>", color, buf);
1520
 
        g_object_set(renderer, "markup", markuptxt, NULL);
1521
 
        g_free(markuptxt);
 
1626
        {
 
1627
                g_object_set(renderer, "text", "", NULL);
 
1628
        }
1522
1629
 
1523
1630
}
1524
1631
 
1525
1632
 
1526
 
GtkTreeViewColumn *amount_list_statistic_column(gchar *name, gint id)
 
1633
static GtkTreeViewColumn *amount_list_statistic_column(gchar *name, gint id)
1527
1634
{
1528
1635
GtkTreeViewColumn  *column;
1529
1636
GtkCellRenderer    *renderer;
1539
1646
        return column;
1540
1647
}
1541
1648
 
1542
 
GtkTreeViewColumn *rate_list_statistic_column(gint id)
 
1649
static GtkTreeViewColumn *rate_list_statistic_column(gint id)
1543
1650
{
1544
1651
GtkTreeViewColumn  *column;
1545
1652
GtkCellRenderer    *renderer;
1562
1669
/*
1563
1670
** create our statistic list
1564
1671
*/
1565
 
GtkWidget *create_list_statistic(void)
 
1672
static GtkWidget *create_list_statistic(void)
1566
1673
{
1567
1674
GtkListStore *store;
1568
1675
GtkWidget *view;
1597
1704
        //gtk_tree_view_column_set_cell_data_func(column, renderer, ope_result_cell_data_function, NULL, NULL);
1598
1705
        gtk_tree_view_column_add_attribute(column, renderer, "text", LST_STAT_NAME);
1599
1706
        //gtk_tree_view_column_set_sort_column_id (column, LST_STAT_NAME);
 
1707
        gtk_tree_view_column_set_resizable(column, TRUE);
1600
1708
        gtk_tree_view_append_column (GTK_TREE_VIEW(view), column);
1601
1709
 
1602
1710
        /* column: Expense */
1631
1739
        return(view);
1632
1740
}
1633
1741
 
1634
 
gint stat_list_compare_func (GtkTreeModel *model, GtkTreeIter *a, GtkTreeIter *b, gpointer userdata)
 
1742
static gint stat_list_compare_func (GtkTreeModel *model, GtkTreeIter *a, GtkTreeIter *b, gpointer userdata)
1635
1743
{
1636
1744
gint sortcol = GPOINTER_TO_INT(userdata);
1637
1745
gint ret = 0;