~sjrct/homebank/resize-xfer-window

« back to all changes in this revision

Viewing changes to src/hub-reptotal.c

  • Committer: Maxime Doyen
  • Date: 2023-12-09 09:48:49 UTC
  • Revision ID: homebank@free.fr-20231209094849-rdoz0pmsutvxh1r4
5.7.3 release

Show diffs side-by-side

added added

removed removed

Lines of Context:
123
123
 
124
124
        switch( PREFS->hub_tot_view )
125
125
        {
126
 
                case HUB_TOT_VIEW_CATEGORY: 
 
126
                case HUB_TOT_VIEW_TOPCAT: 
127
127
                        title = g_strdup_printf(_("Top %d Spending / Category"), PREFS->rep_maxspenditems);
128
128
                        break;
129
 
                case HUB_TOT_VIEW_PAYEE:
 
129
                case HUB_TOT_VIEW_TOPPAY:
130
130
                        title = g_strdup_printf(_("Top %d Spending / Payee"), PREFS->rep_maxspenditems);
131
131
                        break;
132
 
                case HUB_TOT_VIEW_ACCOUNT:
 
132
                case HUB_TOT_VIEW_TOPACC:
133
133
                        title = g_strdup_printf(_("Top %d Spending / Account"), PREFS->rep_maxspenditems);
134
134
                        break;
135
 
                case HUB_TOT_VIEW_BALANCE: 
 
135
                case HUB_TOT_VIEW_ACCBAL: 
136
136
                        title = g_strdup_printf(_("Account Balance"));
137
137
                        break;
 
138
                case HUB_TOT_VIEW_GRPBAL: 
 
139
                        title = g_strdup_printf(_("Account Group Balance"));
 
140
                        break;
138
141
        }
139
142
 
140
143
        gtk_chart_set_color_scheme(GTK_CHART(data->RE_hubtot_chart), PREFS->report_color_scheme);
189
192
 
190
193
        switch( PREFS->hub_tot_view )
191
194
        {
192
 
                case HUB_TOT_VIEW_CATEGORY: tmpsrc = REPORT_SRC_CATEGORY; break;
193
 
                case HUB_TOT_VIEW_PAYEE   : tmpsrc = REPORT_SRC_PAYEE; break;
194
 
                case HUB_TOT_VIEW_ACCOUNT : tmpsrc = REPORT_SRC_ACCOUNT; break;
195
 
                case HUB_TOT_VIEW_BALANCE : 
 
195
                case HUB_TOT_VIEW_TOPCAT: tmpsrc = REPORT_SRC_CATEGORY; break;
 
196
                case HUB_TOT_VIEW_TOPPAY: tmpsrc = REPORT_SRC_PAYEE; break;
 
197
                case HUB_TOT_VIEW_TOPACC: tmpsrc = REPORT_SRC_ACCOUNT; break;
 
198
                case HUB_TOT_VIEW_ACCBAL: 
196
199
                        tmpsrc = REPORT_SRC_ACCOUNT; 
197
200
                        tmpaccbal = TRUE;
198
201
                        break;
 
202
                case HUB_TOT_VIEW_GRPBAL: 
 
203
                        tmpsrc = REPORT_SRC_ACCGROUP; 
 
204
                        tmpaccbal = TRUE;
 
205
                        break;
199
206
        }
200
207
 
201
208
        //type  = hbtk_radio_button_get_active(GTK_CONTAINER(data->RA_type));
239
246
                g_object_ref(model); /* Make sure the model stays with us after the tree view unrefs it */
240
247
                gtk_tree_view_set_model(GTK_TREE_VIEW(data->LV_hubtot), NULL); /* Detach model from view */
241
248
 
242
 
                DB( g_print("\n -- populate total listview %d rows --\n", dt->nbrows) );
 
249
                DB( g_print(" rows=%d\n", dt->nbrows) );
243
250
 
244
251
                // insert into the treeview
245
252
                for(i=0 ; i<dt->nbrows ; i++)
252
259
                        reskey = dt->keylist[i];
253
260
                        dr = report_data_get_row(dt, reskey);
254
261
 
 
262
                        DB( g_printf(" eval %d: %d '%s' %.2f\n", i, reskey, dr->label, dr->rowexp + dr->rowinc ) );
 
263
 
255
264
                        //if( tmptype == REPORT_TYPE_EXPENSE && !dr->expense[0] ) continue;
256
265
                        //if( tmptype == REPORT_TYPE_INCOME && !dr->income[1] ) continue;
257
266
                        if( !dr->rowexp && !dr->rowinc )
258
267
                        {
259
 
                                DB( g_print(" - %d : %s k='%d' %.2f %.2f, skipped no data\n", i, dr->label, reskey, dr->rowexp, dr->rowinc) );
 
268
                                DB( g_printf("  >skip: no data\n") );
260
269
                                continue;
261
270
                        }
262
271
 
308
317
                                          //LST_TOPSPEND_RATE, (gint)(((ABS(value)*100)/ABS(total)) + 0.5),
309
318
                                          -1);
310
319
 
311
 
                                DB( g_print(" - %d : %s k='%d' v='%f' %f %f, added\n", i, dr->label, reskey, value, dr->rowexp, dr->rowinc) );
 
320
                                DB( g_printf("  >insert\n") );
312
321
                        }
313
322
                        else
314
323
                        {
315
 
                                DB( g_print(" - %d : %s k='%d' v='%f' %f %f, skipped\n", i, dr->label, reskey, value, dr->rowexp, dr->rowinc) );
 
324
                                DB( g_printf("  >skip: no data balance mode\n") );
316
325
                        }
317
326
 
318
327
                }
419
428
 
420
429
        PREFS->hub_tot_view = HUB_TOT_VIEW_NONE;
421
430
 
422
 
        if( !strcmp("cat", g_variant_get_string(new_state, NULL)) )
423
 
                PREFS->hub_tot_view = HUB_TOT_VIEW_CATEGORY;
 
431
        if( !strcmp("topcat", g_variant_get_string(new_state, NULL)) )
 
432
                PREFS->hub_tot_view = HUB_TOT_VIEW_TOPCAT;
424
433
        else    
425
 
        if( !strcmp("pay", g_variant_get_string(new_state, NULL)) )
426
 
                PREFS->hub_tot_view = HUB_TOT_VIEW_PAYEE;
427
 
        else
428
 
        if( !strcmp("acc", g_variant_get_string(new_state, NULL)) )
429
 
                PREFS->hub_tot_view = HUB_TOT_VIEW_ACCOUNT;
430
 
        else
431
 
        if( !strcmp("bal", g_variant_get_string(new_state, NULL)) )
432
 
                PREFS->hub_tot_view = HUB_TOT_VIEW_BALANCE;
 
434
        if( !strcmp("toppay", g_variant_get_string(new_state, NULL)) )
 
435
                PREFS->hub_tot_view = HUB_TOT_VIEW_TOPPAY;
 
436
        else
 
437
        if( !strcmp("topacc", g_variant_get_string(new_state, NULL)) )
 
438
                PREFS->hub_tot_view = HUB_TOT_VIEW_TOPACC;
 
439
        else
 
440
        if( !strcmp("accbal", g_variant_get_string(new_state, NULL)) )
 
441
                PREFS->hub_tot_view = HUB_TOT_VIEW_ACCBAL;
 
442
        else
 
443
        if( !strcmp("grpbal", g_variant_get_string(new_state, NULL)) )
 
444
                PREFS->hub_tot_view = HUB_TOT_VIEW_GRPBAL;
433
445
 
434
446
        g_simple_action_set_state (action, new_state);
435
447
        g_variant_unref (old_state);
440
452
 
441
453
static const GActionEntry actions[] = {
442
454
//      name, function(), type, state, 
443
 
        { "view", ui_hub_reptotal_activate_radio ,  "s", "'cat'", NULL, {0,0,0} }
 
455
        { "view", ui_hub_reptotal_activate_radio ,  "s", "'topcat'", NULL, {0,0,0} }
444
456
};
445
457
 
446
458
 
470
482
 
471
483
                switch( PREFS->hub_tot_view )
472
484
                {
473
 
                        case HUB_TOT_VIEW_CATEGORY: value = "cat"; break;
474
 
                        case HUB_TOT_VIEW_PAYEE:    value = "pay"; break;
475
 
                        case HUB_TOT_VIEW_ACCOUNT:  value = "acc"; break;
476
 
                        case HUB_TOT_VIEW_BALANCE:  value = "bal"; break;
 
485
                        case HUB_TOT_VIEW_TOPCAT: value = "topcat"; break;
 
486
                        case HUB_TOT_VIEW_TOPPAY: value = "toppay"; break;
 
487
                        case HUB_TOT_VIEW_TOPACC: value = "topacc"; break;
 
488
                        case HUB_TOT_VIEW_ACCBAL: value = "accbal"; break;
 
489
                        case HUB_TOT_VIEW_GRPBAL: value = "grpbal"; break;
477
490
                }
478
491
                
479
492
                new_state = g_variant_new_string (value);
559
572
GMenu *menu, *section;
560
573
 
561
574
        menu = g_menu_new ();
562
 
        section = g_menu_new ();
563
 
        g_menu_append (section, _("Category") , "actions.view::cat");
564
 
        g_menu_append (section, _("Payee")    , "actions.view::pay");
565
 
        g_menu_append (section, _("Account")  , "actions.view::acc");
566
 
        g_menu_append (section, _("Balance")  , "actions.view::bal");
567
 
        g_menu_append_section(menu, NULL, G_MENU_MODEL(section));
 
575
        
 
576
        section = g_menu_new ();
 
577
        g_menu_append_section(menu, _("Top by"), G_MENU_MODEL(section));
 
578
        g_menu_append (section, _("Category") , "actions.view::topcat");
 
579
        g_menu_append (section, _("Payee")    , "actions.view::toppay");
 
580
        g_menu_append (section, _("Account")  , "actions.view::topacc");
 
581
        g_object_unref (section);
 
582
 
 
583
        section = g_menu_new ();
 
584
        g_menu_append_section (menu, _("Balance"), G_MENU_MODEL(section));      
 
585
        g_menu_append (section, _("Account"), "actions.view::accbal");
 
586
        g_menu_append (section, _("Account group"), "actions.view::grpbal");
568
587
        g_object_unref (section);
569
588
 
570
589
        gtk_menu_button_set_menu_model (GTK_MENU_BUTTON (widget), G_MENU_MODEL (menu));