X-Git-Url: https://git.dogcows.com/gitweb?p=chaz%2Fhomebank;a=blobdiff_plain;f=src%2Fdsp_mainwindow.c;h=2cb2ecd2d5e6c47b7ab8eeb3ecef0ddee12a3d19;hp=c96fdc6ba305a3a4a1fe5f3b14e3ba30bb9ba836;hb=cd13d9691c46c2b2d6d459e9e6a76bed1c21b7a6;hpb=996fa4ab9f6b836001f8ad0eecbfd3821687fea7 diff --git a/src/dsp_mainwindow.c b/src/dsp_mainwindow.c index c96fdc6..2cb2ecd 100644 --- a/src/dsp_mainwindow.c +++ b/src/dsp_mainwindow.c @@ -1,5 +1,5 @@ /* HomeBank -- Free, easy, personal accounting for everyone. - * Copyright (C) 1995-2016 Maxime DOYEN + * Copyright (C) 1995-2018 Maxime DOYEN * * This file is part of HomeBank. * @@ -48,11 +48,17 @@ #include "gtk-chart.h" +//old url prior 2018 //#define HOMEBANK_URL_HELP "http://homebank.free.fr/help/" +//#define HOMEBANK_URL_HELP_ONLINE "https://launchpad.net/homebank/+addquestion" +//#define HOMEBANK_URL_HELP_PROBLEM "https://launchpad.net/homebank/+filebug" +//#define HOMEBANK_URL_HELP_TRANSLATE "https://launchpad.net/homebank/+translations" + #define HOMEBANK_URL_HELP "index.html" -#define HOMEBANK_URL_HELP_ONLINE "https://launchpad.net/homebank/+addquestion" -#define HOMEBANK_URL_HELP_TRANSLATE "https://launchpad.net/homebank/+translations" -#define HOMEBANK_URL_HELP_PROBLEM "https://launchpad.net/homebank/+filebug" +#define HOMEBANK_URL_HELP_ONLINE "http://homebank.free.fr/support.php" +#define HOMEBANK_URL_HELP_UPDATES "http://homebank.free.fr/downloads.php" +#define HOMEBANK_URL_HELP_PROBLEM "http://homebank.free.fr/development.php#bug" +#define HOMEBANK_URL_HELP_TRANSLATE "http://homebank.free.fr/development.php#translate" /****************************************************************************/ @@ -114,6 +120,8 @@ static void ui_mainwindow_action_file_statistics(void); static void ui_mainwindow_action_help(void); void ui_mainwindow_action_help_welcome(void); static void ui_mainwindow_action_help_online(void); +static void ui_mainwindow_action_help_updates(void); +static void ui_mainwindow_action_help_releasenotes(void); static void ui_mainwindow_action_help_translate(void); static void ui_mainwindow_action_help_problem(void); static void ui_mainwindow_action_about(void); @@ -137,11 +145,15 @@ void ui_mainwindow_update(GtkWidget *widget, gpointer user_data); void ui_mainwindow_addtransactions(GtkWidget *widget, gpointer user_data); void ui_mainwindow_recent_add (struct hbfile_data *data, const gchar *path); +static void ui_panel_topspending_update(GtkWidget *widget, gpointer user_data); + static void ui_mainwindow_scheduled_populate(GtkWidget *widget, gpointer user_data); void ui_mainwindow_scheduled_postall(GtkWidget *widget, gpointer user_data); void ui_mainwindow_recent_add (struct hbfile_data *data, const gchar *path); +static void ui_panel_accounts_setup(struct hbfile_data *data); + extern gchar *CYA_ACC_TYPE[]; gchar *CYA_CATSUBCAT[] = { @@ -220,8 +232,11 @@ static GtkActionEntry entries[] = { /* HelpMenu */ { "Contents" , ICONNAME_HELP , N_("_Contents") , "F1", N_("Documentation about HomeBank"), G_CALLBACK (ui_mainwindow_action_help) }, { "Online" , "lpi-help" , N_("Get Help Online...") , NULL, N_("Connect to the LaunchPad website for online help"), G_CALLBACK (ui_mainwindow_action_help_online) }, - { "Translate" , "lpi-translate" , N_("Translate this Application..."), NULL, N_("Connect to the LaunchPad website to help translate this application"), G_CALLBACK (ui_mainwindow_action_help_translate) }, + + { "Updates" , NULL , N_("Check for updates...") , NULL, N_("Visit HomeBank website to check for update"), G_CALLBACK (ui_mainwindow_action_help_updates) }, + { "ReleaseNotes", NULL , N_("Release Notes") , NULL, N_("Display the release notes"), G_CALLBACK (ui_mainwindow_action_help_releasenotes) }, { "Problem" , "lpi-bug" , N_("Report a Problem...") , NULL, N_("Connect to the LaunchPad website to help fix problems"), G_CALLBACK (ui_mainwindow_action_help_problem) }, + { "Translate" , "lpi-translate" , N_("Translate this Application..."), NULL, N_("Connect to the LaunchPad website to help translate this application"), G_CALLBACK (ui_mainwindow_action_help_translate) }, { "About" , ICONNAME_ABOUT , N_("_About") , NULL, N_("About HomeBank") ,G_CALLBACK (ui_mainwindow_action_about) }, @@ -308,10 +323,12 @@ static const gchar *ui_info = " " " " " " -" " " " -" " +" " +" " +" " " " +" " " " " " " " @@ -384,9 +401,9 @@ gint result; { DB( g_print(" - should revert\n") ); - hbfile_change_filepath(hb_util_filename_new_with_extension(GLOBALS->xhb_filepath, "xhb~")); + hbfile_change_filepath(hb_filename_new_with_extension(GLOBALS->xhb_filepath, "xhb~")); ui_mainwindow_open_internal(widget, NULL); - hbfile_change_filepath(hb_util_filename_new_with_extension(GLOBALS->xhb_filepath, "xhb")); + hbfile_change_filepath(hb_filename_new_with_extension(GLOBALS->xhb_filepath, "xhb")); } } @@ -429,7 +446,7 @@ gchar *version; }; */ - static const gchar *copyright = "Copyright \xc2\xa9 1995-2016 - Maxime DOYEN"; + static const gchar *copyright = "Copyright \xc2\xa9 1995-2018 - Maxime DOYEN"; @@ -493,9 +510,9 @@ GtkWidget *widget = GLOBALS->mainwindow; ui_mainwindow_update(widget, GINT_TO_POINTER(UF_TITLE+UF_SENSITIVE+UF_REFRESHALL)); ui_start_assistant(); - ui_mainwindow_populate_accounts(GLOBALS->mainwindow, NULL); - ui_mainwindow_scheduled_populate(GLOBALS->mainwindow, NULL); - ui_mainwindow_populate_topspending(GLOBALS->mainwindow, NULL); + //ui_mainwindow_populate_accounts(GLOBALS->mainwindow, NULL); + //ui_mainwindow_scheduled_populate(GLOBALS->mainwindow, NULL); + //ui_mainwindow_populate_topspending(GLOBALS->mainwindow, NULL); } } @@ -537,13 +554,11 @@ static void ui_mainwindow_action_quit(void) { gboolean result; - //gtk_widget_destroy(GLOBALS->mainwindow); - + //emulate the wm close button g_signal_emit_by_name(GLOBALS->mainwindow, "delete-event", NULL, &result); - - //gtk_main_quit(); } + static void ui_mainwindow_action_file_statistics(void) { ui_dialog_file_statistics(); @@ -575,11 +590,14 @@ gchar *secondtext; _("_Anonymize") ); - if( result == GTK_RESPONSE_CANCEL ) - return; - - hbfile_anonymize(); - ui_mainwindow_update(GLOBALS->mainwindow, GINT_TO_POINTER(UF_TITLE+UF_SENSITIVE+UF_REFRESHALL)); + //#1707201 + //if( result == GTK_RESPONSE_CANCEL ) + // return; + if( result == GTK_RESPONSE_OK ) + { + hbfile_anonymize(); + ui_mainwindow_update(GLOBALS->mainwindow, GINT_TO_POINTER(UF_TITLE+UF_SENSITIVE+UF_REFRESHALL)); + } } @@ -710,7 +728,8 @@ struct hbfile_data *data = g_object_get_data(G_OBJECT(GLOBALS->mainwindow), "ins // top spending gtk_chart_show_minor(GTK_CHART(data->RE_pie), GLOBALS->minor); - hb_label_set_amount(GTK_LABEL(data->TX_topamount), data->toptotal, GLOBALS->kcur, GLOBALS->minor); + + ui_panel_topspending_update(data->window, data); } @@ -806,6 +825,7 @@ static void ui_mainwindow_action_about(void) } + static void ui_mainwindow_action_export(void) { gchar *filename; @@ -817,13 +837,27 @@ gchar *filename; } } + static void ui_mainwindow_action_help(void) { gchar *link; link = g_build_filename("file:///", homebank_app_get_help_dir(), HOMEBANK_URL_HELP, NULL ); homebank_util_url_show (link); + g_free(link); +} + +static void ui_mainwindow_action_help_releasenotes(void) +{ +gchar *link; + + #ifdef G_OS_WIN32 + link = g_build_filename("file:///", homebank_app_get_datas_dir(), "ChangeLog.txt", NULL ); + #else + link = g_build_filename("file:///", homebank_app_get_datas_dir(), "ChangeLog", NULL ); + #endif + homebank_util_url_show (link); g_free(link); } @@ -946,39 +980,41 @@ GtkWidget *mainvbox, *widget, *label; } +static void ui_mainwindow_action_help_updates(void) +{ +const gchar *link = HOMEBANK_URL_HELP_UPDATES; + + homebank_util_url_show (link); +} + static void ui_mainwindow_action_help_online(void) { const gchar *link = HOMEBANK_URL_HELP_ONLINE; homebank_util_url_show (link); - } + static void ui_mainwindow_action_help_translate(void) { const gchar *link = HOMEBANK_URL_HELP_TRANSLATE; homebank_util_url_show (link); - } + static void ui_mainwindow_action_help_problem(void) { const gchar *link = HOMEBANK_URL_HELP_PROBLEM; homebank_util_url_show (link); - } - - /* hbfile functions -------------------- */ - - /* ** */ @@ -1032,6 +1068,9 @@ gboolean file_clear = GPOINTER_TO_INT(user_data); gtk_list_store_clear(GTK_LIST_STORE(gtk_tree_view_get_model(GTK_TREE_VIEW(data->LV_upc)))); gtk_list_store_clear(GTK_LIST_STORE(gtk_tree_view_get_model(GTK_TREE_VIEW(data->LV_top)))); + data->showall = FALSE; + ui_panel_accounts_setup(data); + hbfile_cleanup(file_clear); hbfile_setup(file_clear); @@ -1055,8 +1094,9 @@ gint account, count; /* init the transaction */ date = homebank_app_date_get_julian(); - //todo: maybe think about set a default account here - account = 1; + + //#1656531 + account = 0; if(data->acc != NULL) account = data->acc->key; @@ -1070,7 +1110,7 @@ gint account, count; if( result == GTK_RESPONSE_ADD ) { ope = da_transaction_malloc(); - ope->date = date; + ope->date = date; ope->kacc = account; if( PREFS->heritdate == FALSE ) //fix: 318733 @@ -1088,7 +1128,7 @@ gint account, count; if(result == GTK_RESPONSE_ADD || result == GTK_RESPONSE_ADDKEEP || result == GTK_RESPONSE_ACCEPT) { deftransaction_get(window, NULL); - transaction_add(ope, NULL, ope->kacc); + transaction_add(ope); DB( g_print(" - added 1 transaction to %d\n", ope->kacc) ); @@ -1125,12 +1165,44 @@ struct tmptop gdouble value; }; + +#define MAX_TOPSPENDING 10 + + static gint tmptop_compare_func(struct tmptop *tt1, struct tmptop *tt2) { return tt1->value > tt2->value ? 1 : -1; } +static void ui_panel_topspending_update(GtkWidget *widget, gpointer user_data) +{ +struct hbfile_data *data; +GtkTreeModel *model; +gchar *title; +gchar strbuffer[G_ASCII_DTOSTR_BUF_SIZE]; + + DB( g_print("\n[ui-mainwindow] topspending_update\n") ); + + data = g_object_get_data(G_OBJECT(gtk_widget_get_ancestor(widget, GTK_TYPE_WINDOW)), "inst_data"); + + hb_strfmon(strbuffer, G_ASCII_DTOSTR_BUF_SIZE-1, data->toptotal, GLOBALS->kcur, GLOBALS->minor); + //hb_label_set_amount(GTK_LABEL(data->TX_topamount), total, GLOBALS->kcur, GLOBALS->minor); + title = g_strdup_printf("%s %s", _("Top spending"), strbuffer); + + model = gtk_tree_view_get_model(GTK_TREE_VIEW(data->LV_top)); + + gtk_chart_set_color_scheme(GTK_CHART(data->RE_pie), PREFS->report_color_scheme); + gtk_chart_set_currency(GTK_CHART(data->RE_pie), GLOBALS->kcur); + gtk_chart_set_datas(GTK_CHART(data->RE_pie), model, LST_TOPSPEND_AMOUNT, title, NULL); + + g_free(title); + + //future usage + gchar *fu = _("Top %d spending"); title = fu; +} + + static void ui_mainwindow_populate_topspending(GtkWidget *widget, gpointer user_data) { struct hbfile_data *data; @@ -1143,7 +1215,6 @@ GArray *garray; gdouble total, other; Account *acc; -#define MAX_TOPSPENDING 5 DB( g_print("\n[ui-mainwindow] populate_topspending\n") ); @@ -1196,7 +1267,7 @@ Account *acc; { Transaction *ope = list->data; - //DB( g_print(" - eval txn: '%s', cat=%d ==> flt-test=%d\n", ope->wording, ope->kcat, filter_test(data->filter, ope)) ); + //DB( g_print(" - eval txn: '%s', cat=%d ==> flt-test=%d\n", ope->memo, ope->kcat, filter_test(data->filter, ope)) ); if( !(ope->paymode == PAYMODE_INTXFER) ) { @@ -1209,7 +1280,7 @@ Account *acc; if(acc) trn_amount = hb_amount_base(ope->amount, acc->kcur); - if( ope->flags & OF_SPLIT ) + if( ope->flags & OF_SPLIT ) { guint nbsplit = da_splits_count(ope->splits); Split *split; @@ -1326,18 +1397,14 @@ Account *acc; gtk_tree_view_set_model(GTK_TREE_VIEW(data->LV_top), model); g_object_unref(model); - data->toptotal = total; - hb_label_set_amount(GTK_LABEL(data->TX_topamount), total, GLOBALS->kcur, GLOBALS->minor); - - gtk_chart_set_color_scheme(GTK_CHART(data->RE_pie), PREFS->report_color_scheme); - gtk_chart_set_currency(GTK_CHART(data->RE_pie), GLOBALS->kcur); - gtk_chart_set_datas(GTK_CHART(data->RE_pie), model, LST_TOPSPEND_AMOUNT, NULL, NULL); - //gtk_chart_show_legend(GTK_CHART(data->RE_pie), FALSE); - - /* update info range text */ + + // update chart and widgets { gchar *daterange; - + + data->toptotal = total; + ui_panel_topspending_update(widget, data); + daterange = filter_daterange_text_get(data->filter); gtk_widget_set_tooltip_markup(GTK_WIDGET(data->CY_range), daterange); g_free(daterange); @@ -1413,7 +1480,7 @@ Transaction *txn; if(result == GTK_RESPONSE_ADD || result == GTK_RESPONSE_ACCEPT) { deftransaction_get(window, NULL); - transaction_add(txn, NULL, txn->kacc); + transaction_add(txn); GLOBALS->changes_count++; scheduled_date_advance(arc); @@ -1447,6 +1514,8 @@ static void ui_mainwindow_scheduled_post_cb(GtkWidget *widget, gpointer user_dat { struct hbfile_data *data = user_data; + DB( g_print("\n[ui-mainwindow] scheduled post\n") ); + Archive *arc = ui_mainwindow_scheduled_get_selected_item(GTK_TREE_VIEW(data->LV_upc)); if( (arc != NULL) ) @@ -1457,7 +1526,7 @@ struct hbfile_data *data = user_data; da_transaction_init_from_template(txn, arc); txn->date = scheduled_get_postdate(arc, arc->nextdate); - transaction_add(txn, NULL, 0); + transaction_add(txn); GLOBALS->changes_count++; scheduled_date_advance(arc); @@ -1506,7 +1575,7 @@ struct hbfile_data *data; if(arc) { - DB( g_print("archive is %s\n", arc->wording) ); + DB( g_print("archive is %s\n", arc->memo) ); gtk_widget_set_sensitive(GTK_WIDGET(data->BT_sched_skip), TRUE); gtk_widget_set_sensitive(GTK_WIDGET(data->BT_sched_post), TRUE); @@ -1618,7 +1687,7 @@ GDate *date; nbdays = arc->nextdate - maxpostdate; nblate = scheduled_get_latepost_count(arc, GLOBALS->today); - DB( g_print(" - append '%s' : %d\n", arc->wording, nbdays) ); + DB( g_print(" - append '%s' : %d\n", arc->memo, nbdays) ); if(arc->flags & OF_INCOME) { @@ -1642,7 +1711,7 @@ GDate *date; gtk_list_store_set (GTK_LIST_STORE(model), &iter, LST_DSPUPC_DATAS, arc, LST_DSPUPC_ACCOUNT, acc, - LST_DSPUPC_WORDING, arc->wording, + LST_DSPUPC_MEMO, arc->memo, LST_DSPUPC_EXPENSE, exp, LST_DSPUPC_INCOME, inc, LST_DSPUPC_REMAINING, nbdays, @@ -1662,7 +1731,7 @@ GDate *date; gtk_list_store_set (GTK_LIST_STORE(model), &iter, LST_DSPUPC_DATAS, arc, LST_DSPUPC_ACCOUNT, acc, - LST_DSPUPC_WORDING, arc->wording, + LST_DSPUPC_MEMO, arc->memo, LST_DSPUPC_EXPENSE, -inc, LST_DSPUPC_INCOME, -exp, LST_DSPUPC_REMAINING, nbdays, @@ -1681,18 +1750,42 @@ GDate *date; gtk_list_store_set (GTK_LIST_STORE(model), &iter, LST_DSPUPC_DATAS, NULL, LST_DSPUPC_ACCOUNT, NULL, - LST_DSPUPC_WORDING, _("Total"), + LST_DSPUPC_MEMO, _("Total"), LST_DSPUPC_EXPENSE, totexp, LST_DSPUPC_INCOME, totinc, -1); } - ui_mainwindow_scheduled_update(widget, NULL); } +gboolean ui_mainwindow_open_backup_check_confirm(gchar *filepath) +{ +gboolean retval = FALSE; +gchar *basename, *secondtext; +gboolean result; + + basename = g_path_get_basename(filepath); + secondtext = g_strdup_printf ( + _("Your are about to open the backup file '%s'.\n\nAre you sure you want to do this ?"), basename); + + result = ui_dialog_msg_confirm_alert( + GTK_WINDOW(GLOBALS->mainwindow), + _("Open a backup file ?"), + secondtext, + _("_Open backup") + ); + + g_free(secondtext); + g_free(basename); + + if( result == GTK_RESPONSE_OK ) + retval = TRUE; + + return retval; +} /* @@ -1709,17 +1802,29 @@ gchar *filename = NULL; if( ui_dialog_msg_savechanges(widget,NULL) == TRUE ) { - if(ui_file_chooser_xhb(GTK_FILE_CHOOSER_ACTION_OPEN, &filename) == TRUE) + if( ui_file_chooser_xhb(GTK_FILE_CHOOSER_ACTION_OPEN, &filename) == TRUE ) { - hbfile_change_filepath(filename); + //#1710955 test for backup open + if( hbfile_file_isbackup(filename) ) + { + if( ui_mainwindow_open_backup_check_confirm(filename) == TRUE ) + { + GLOBALS->hbfile_is_bak = TRUE; + } + else + { + g_free(filename); + return; + } + } + hbfile_change_filepath(filename); ui_mainwindow_open_internal(widget, NULL); - - } } } + /* * open the file stored in GLOBALS->xhb_filepath */ @@ -1732,10 +1837,10 @@ gint r; data = g_object_get_data(G_OBJECT(gtk_widget_get_ancestor(widget, GTK_TYPE_WINDOW)), "inst_data"); - DB( g_print(" - filename: '%s'\n", GLOBALS->xhb_filepath) ); - if( GLOBALS->xhb_filepath != NULL ) { + DB( g_print(" - filename: '%s'\n", GLOBALS->xhb_filepath) ); + ui_mainwindow_clear(GLOBALS->mainwindow, GINT_TO_POINTER(FALSE)); GLOBALS->hbfile_is_new = FALSE; @@ -1795,6 +1900,7 @@ gint r; } + /* ** */ @@ -1812,6 +1918,14 @@ gint r = XML_UNSET; if( GLOBALS->hbfile_is_new == TRUE ) saveas = 1; + //#1710955 test for backup open + if( GLOBALS->hbfile_is_bak == TRUE ) + { + //todo: later for backup, should also remove datetime and .bak + hbfile_change_filepath(hb_filename_new_with_extension(GLOBALS->xhb_filepath, "xhb")); + saveas = 1; + } + if(saveas == 1) { if(ui_file_chooser_xhb(GTK_FILE_CHOOSER_ACTION_SAVE, &filename) == TRUE) @@ -1821,6 +1935,7 @@ gint r = XML_UNSET; homebank_backup_current_file(); r = homebank_save_xml(GLOBALS->xhb_filepath); GLOBALS->hbfile_is_new = FALSE; + GLOBALS->hbfile_is_bak = FALSE; } else return; @@ -1855,6 +1970,85 @@ gint r = XML_UNSET; } +static void ui_panel_accounts_expand_all(GtkWidget *widget, gpointer user_data) +{ +struct hbfile_data *data; + + data = g_object_get_data(G_OBJECT(gtk_widget_get_ancestor(widget, GTK_TYPE_WINDOW)), "inst_data"); + gtk_tree_view_expand_all(GTK_TREE_VIEW(data->LV_acc)); +} + + +static void ui_panel_accounts_collapse_all(GtkWidget *widget, gpointer user_data) +{ +struct hbfile_data *data; + + data = g_object_get_data(G_OBJECT(gtk_widget_get_ancestor(widget, GTK_TYPE_WINDOW)), "inst_data"); + gtk_tree_view_collapse_all(GTK_TREE_VIEW(data->LV_acc)); +} + + + +static GHashTable *ui_panel_accounts_groups_get(GList *lacc, gint groupby, gboolean showall) +{ +GHashTable *hash; +GList *elt; +gchar *groupname; +gint nballoc; + + DB( g_print("\n[ui-mainwindow] accounts_groups_get\n") ); + + nballoc = da_acc_length (); + + DB( g_print(" %d accounts\n", nballoc) ); + + hash = g_hash_table_new_full(g_str_hash, g_str_equal, (GDestroyNotify)g_free, NULL); + elt = g_list_first(lacc); + while (elt != NULL) + { + Account *acc = elt->data; + GPtrArray *group; + + //#1674045 ony rely on nosummary + //if( showall || !(acc->flags & (AF_CLOSED|AF_NOSUMMARY)) ) + if( showall || !(acc->flags & AF_NOSUMMARY) ) + { + if( groupby == DSPACC_GROUP_BY_BANK ) + { + groupname = _("(no institution)"); + if( (acc->bankname != NULL) && strlen(acc->bankname) > 0 ) + groupname = acc->bankname; + } + else + { + //pre 5.1.3 historical by type display + groupname = _(CYA_ACC_TYPE[acc->type]); + } + + if( g_hash_table_contains(hash, groupname) == FALSE ) + { + g_hash_table_insert(hash, g_strdup(groupname), g_ptr_array_sized_new(nballoc) ); + //DB( g_print(" - type hash insert '%s' = %d\n", groupname, inserted) ); + } + + group = g_hash_table_lookup(hash, groupname); + if( group != NULL ) + { + g_ptr_array_add(group, (gpointer)acc); + DB( g_print(" -- add '%s' to group '%s'\n", acc->name, groupname) ); + } + } + elt = g_list_next(elt); + } + + return hash; +} + + + + + + void ui_mainwindow_populate_accounts(GtkWidget *widget, gpointer user_data) { struct hbfile_data *data; @@ -1862,59 +2056,66 @@ GtkTreeModel *model; GtkTreeIter iter1, child_iter; GList *lacc, *elt; Account *acc; -guint i, j, nbtype; +guint j, nbtype; gdouble gtbank, gttoday, gtfuture; +GHashTable *h_group; +GHashTableIter grp_iter; +gpointer key, value; + DB( g_print("\n[ui-mainwindow] populate accounts\n") ); data = g_object_get_data(G_OBJECT(gtk_widget_get_ancestor(widget, GTK_TYPE_WINDOW)), "inst_data"); /* here we create a count and a list of every account pointer by type */ - - GPtrArray *typeacc[ACC_TYPE_MAXVALUE] = {0}; lacc = elt = g_hash_table_get_values(GLOBALS->h_acc); - while (elt != NULL) - { - acc = elt->data; - //#1339572 - if( !(acc->flags & (AF_CLOSED|AF_NOSUMMARY)) ) - { - DB( g_print(" - insert %d:%s\n", acc->key, acc->name) ); - - if(typeacc[acc->type] == NULL) - typeacc[acc->type] = g_ptr_array_sized_new(da_acc_length ()); - - g_ptr_array_add(typeacc[acc->type], (gpointer)acc); - } - elt = g_list_next(elt); - } + + h_group = ui_panel_accounts_groups_get(lacc, PREFS->pnl_acc_show_by, data->showall); g_list_free(lacc); - gtbank = gttoday = gtfuture = 0; - DB( g_print(" - populate listview\n") ); + gtbank = gttoday = gtfuture = 0; + DB( g_print(" - populate listview, %d group(s)\n", g_hash_table_size(h_group)) ); - /* then populate the listview */ model = gtk_tree_view_get_model(GTK_TREE_VIEW(data->LV_acc)); gtk_tree_store_clear (GTK_TREE_STORE(model)); nbtype = 0; - for(i=0;ipnl_acc_show_by == DSPACC_GROUP_BY_TYPE ) + { + gint t = 0; + + while(CYA_ACC_TYPE[t] != NULL && t < 15) + { + if( !strcmp(CYA_ACC_TYPE[t], key) ) + break; + t++; + } + + position = t; + } gtk_tree_store_append (GTK_TREE_STORE(model), &iter1, NULL); gtk_tree_store_set (GTK_TREE_STORE(model), &iter1, + LST_DSPACC_POS, position, LST_DSPACC_DATATYPE, DSPACC_TYPE_HEADER, - LST_DSPACC_NAME, _(CYA_ACC_TYPE[i]), + LST_DSPACC_NAME, key, -1); tbank = ttoday = tfuture = 0; @@ -1931,7 +2132,7 @@ gdouble gtbank, gttoday, gtfuture; ttoday += hb_amount_base(acc->bal_today, acc->kcur); tfuture += hb_amount_base(acc->bal_future, acc->kcur); - DB( g_print(" - insert '%s' :: %.2f %.2f %.2f\n", acc->name, acc->bal_bank, acc->bal_today, acc->bal_future) ); + DB( g_print(" - add account '%s' :: %.2f %.2f %.2f\n", acc->name, acc->bal_bank, acc->bal_today, acc->bal_future) ); gtk_tree_store_append (GTK_TREE_STORE(model), &child_iter, &iter1); gtk_tree_store_set (GTK_TREE_STORE(model), &child_iter, @@ -1945,7 +2146,7 @@ gdouble gtbank, gttoday, gtfuture; if(gpa->len > 1) { - DB( g_print(" - type totals :: %.2f %.2f %.2f\n", tbank, ttoday, tfuture) ); + DB( g_print(" - group total :: %.2f %.2f %.2f\n", tbank, ttoday, tfuture) ); // insert the total line gtk_tree_store_append (GTK_TREE_STORE(model), &child_iter, &iter1); @@ -1959,6 +2160,7 @@ gdouble gtbank, gttoday, gtfuture; } /* set balance to header to display when collasped */ + DB( g_print(" - enrich group total header :: %.2f %.2f %.2f\n", tbank, ttoday, tfuture) ); gtk_tree_store_set (GTK_TREE_STORE(model), &iter1, LST_DSPACC_BANK, tbank, LST_DSPACC_TODAY, ttoday, @@ -1974,7 +2176,7 @@ gdouble gtbank, gttoday, gtfuture; } - DB( g_print(" - grand totals :: %.2f %.2f %.2f\n", gtbank, gttoday, gtfuture) ); + DB( g_print(" - grand total :: %.2f %.2f %.2f\n", gtbank, gttoday, gtfuture) ); // Grand total if( nbtype > 1 ) @@ -1994,16 +2196,12 @@ gdouble gtbank, gttoday, gtfuture; DB( g_print(" - free ressources\n") ); - - /* free all temp stuff */ - for(i=0;iwintitle) ); + DB( g_print(" 1: wintitle %p\n", data->wintitle) ); basename = g_path_get_basename(GLOBALS->xhb_filepath); @@ -2052,10 +2250,12 @@ gint flags; GtkTreePath *path; gboolean active,sensitive; - DB( g_print(" + 2: disabled, opelist count\n") ); + DB( g_print(" 2: disabled, opelist count\n") ); - selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(data->LV_acc)); + //#1656531 + data->acc = NULL; + selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(data->LV_acc)); active = gtk_tree_selection_get_selected(selection, &model, &iter); if(active) { @@ -2071,16 +2271,10 @@ gint flags; gtk_tree_model_get(GTK_TREE_MODEL(model), &iter, LST_DSPACC_DATAS, &acc, -1); data->acc = acc; - } else active = FALSE; } - else - { - //ensure data->acc will not be null - data->acc = da_acc_get(1); - } // no change: disable save @@ -2143,7 +2337,7 @@ gint flags; /* update toolbar, list */ if(flags & UF_VISUAL) { - DB( g_print(" + 8: visual\n") ); + DB( g_print(" 8: visual\n") ); if(PREFS->toolbar_style == 0) gtk_toolbar_unset_style(GTK_TOOLBAR(data->toolbar)); @@ -2188,7 +2382,7 @@ gint flags; if(flags & UF_BALANCE) { - DB( g_print(" + 4: balances\n") ); + DB( g_print(" 4: balances\n") ); gtk_tree_view_columns_autosize (GTK_TREE_VIEW(data->LV_acc)); @@ -2203,7 +2397,7 @@ gint flags; if(flags & UF_REFRESHALL) { - DB( g_print(" + 8: refreshall\n") ); + DB( g_print(" 16: refreshall\n") ); ui_mainwindow_populate_accounts(GLOBALS->mainwindow, NULL); ui_mainwindow_populate_topspending(GLOBALS->mainwindow, NULL); @@ -2246,6 +2440,14 @@ static void } } + +static void ui_mainwindow_destroy(GtkTreeView *treeview, gpointer user_data) +{ + DB( g_print("\n[ui-mainwindow] destroy\n") ); + +} + + /* ** */ @@ -2255,7 +2457,7 @@ struct hbfile_data *data = user_data; struct WinGeometry *wg; gboolean retval = FALSE; - DB( g_print("\n[ui-mainwindow] dispose\n") ); + DB( g_print("\n[ui-mainwindow] delete-event\n") ); //store position and size wg = &PREFS->wal_wg; @@ -2279,19 +2481,18 @@ gboolean retval = FALSE; } else { - DB( g_print(" free wintitle %x\n", (gint)data->wintitle) ); - + //todo: retval is useless and below should move to destroy + retval = TRUE; gtk_widget_destroy(data->LV_top); g_free(data->wintitle); da_filter_free(data->filter); g_free(user_data); + gtk_main_quit(); } - - - //delete-event TRUE abort/FALSE destroy + //TRUE:stop other handlers from being invoked for the event | FALSE: propagate return retval; } @@ -2422,9 +2623,9 @@ static void ui_mainwindow_drag_data_received (GtkWidget *widget, GtkSelectionData *selection_data, guint info, guint time, GtkWindow *window) { - gchar **uris, **str; - gchar *newseldata; - gint filetype, slen; +gchar **uris, **str; +gchar *newseldata; +gint filetype, slen; if (info != TARGET_URI_LIST) return; @@ -2439,6 +2640,8 @@ static void ui_mainwindow_drag_data_received (GtkWidget *widget, uris = g_uri_list_extract_uris (newseldata); + DB( g_print(" - dragged %d %d files\n", slen, g_strv_length(uris) ) ); + str = uris; //for (str = uris; *str; str++) if( *str ) @@ -2460,6 +2663,9 @@ static void ui_mainwindow_drag_data_received (GtkWidget *widget, else { //todo: future here to implement import for other filetype + // ui_import_assistant_new(); + // + write a method into assistant to catch other filename + ui_dialog_msg_infoerror(GTK_WINDOW(window), GTK_MESSAGE_ERROR, _("File error"), @@ -2517,7 +2723,7 @@ GtkRecentFilter *filter; static void ui_mainwindow_create_menu_bar_and_toolbar(struct hbfile_data *data, GtkWidget *mainvbox) { GtkUIManager *manager; -GtkActionGroup *action_group; +GtkActionGroup *actions; GtkAction *action; GError *error = NULL; @@ -2527,62 +2733,62 @@ GError *error = NULL; gtk_window_add_accel_group (GTK_WINDOW (data->window), gtk_ui_manager_get_accel_group(manager)); - action_group = gtk_action_group_new ("MainWindow"); - gtk_action_group_set_translation_domain(action_group, GETTEXT_PACKAGE); + actions = gtk_action_group_new ("MainWindow"); + gtk_action_group_set_translation_domain(actions, GETTEXT_PACKAGE); - gtk_action_group_add_actions (action_group, + gtk_action_group_add_actions (actions, entries, n_entries, NULL); - gtk_action_group_add_toggle_actions (action_group, + gtk_action_group_add_toggle_actions (actions, toggle_entries, n_toggle_entries, NULL); - gtk_ui_manager_insert_action_group (data->manager, action_group, 0); - g_object_unref (action_group); - data->actions = action_group; + gtk_ui_manager_insert_action_group (data->manager, actions, 0); + g_object_unref (actions); + data->actions = actions; /* set short labels to use in the toolbar */ - action = gtk_action_group_get_action(action_group, "Open"); + action = gtk_action_group_get_action(actions, "Open"); g_object_set(action, "short_label", _("Open"), NULL); //action = gtk_action_group_get_action(action_group, "Save"); //g_object_set(action, "is_important", TRUE, NULL); - action = gtk_action_group_get_action(action_group, "Account"); + action = gtk_action_group_get_action(actions, "Account"); g_object_set(action, "short_label", _("Account"), NULL); - action = gtk_action_group_get_action(action_group, "Payee"); + action = gtk_action_group_get_action(actions, "Payee"); g_object_set(action, "short_label", _("Payee"), NULL); - action = gtk_action_group_get_action(action_group, "Category"); + action = gtk_action_group_get_action(actions, "Category"); g_object_set(action, "short_label", _("Category"), NULL); - action = gtk_action_group_get_action(action_group, "Archive"); + action = gtk_action_group_get_action(actions, "Archive"); //TRANSLATORS: an archive is stored transaction buffers (kind of bookmark to prefill manual insertion) g_object_set(action, "short_label", _("Archive"), NULL); - action = gtk_action_group_get_action(action_group, "Budget"); + action = gtk_action_group_get_action(actions, "Budget"); g_object_set(action, "short_label", _("Budget"), NULL); - action = gtk_action_group_get_action(action_group, "ShowOpe"); + action = gtk_action_group_get_action(actions, "ShowOpe"); g_object_set(action, "short_label", _("Show"), NULL); - action = gtk_action_group_get_action(action_group, "AddOpe"); + action = gtk_action_group_get_action(actions, "AddOpe"); g_object_set(action, "is_important", TRUE, "short_label", _("Add"), NULL); - action = gtk_action_group_get_action(action_group, "RStatistics"); + action = gtk_action_group_get_action(actions, "RStatistics"); g_object_set(action, "short_label", _("Statistics"), NULL); - action = gtk_action_group_get_action(action_group, "RBudget"); + action = gtk_action_group_get_action(actions, "RBudget"); g_object_set(action, "short_label", _("Budget"), NULL); - action = gtk_action_group_get_action(action_group, "RBalance"); + action = gtk_action_group_get_action(actions, "RBalance"); g_object_set(action, "short_label", _("Balance"), NULL); - action = gtk_action_group_get_action(action_group, "RVehiculeCost"); + action = gtk_action_group_get_action(actions, "RVehiculeCost"); g_object_set(action, "short_label", _("Vehicle cost"), NULL); /* now load the UI definition */ @@ -2644,70 +2850,230 @@ GError *error = NULL; } -static GtkWidget *ui_mainwindow_create_youraccounts(struct hbfile_data *data) +/* Callback function for the undo action */ +/*static void +activate_action (GSimpleAction *action, GVariant *parameter, gpointer user_data) { -GtkWidget *mainvbox, *label, *widget, *sw; + g_print ("Action %s activated\n", g_action_get_name (G_ACTION (action))); +}*/ - mainvbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0); +static void +activate_toggle (GSimpleAction *action, GVariant *parameter, gpointer user_data) +{ +struct hbfile_data *data = user_data; + GVariant *old_state, *new_state; + + old_state = g_action_get_state (G_ACTION (action)); + new_state = g_variant_new_boolean (!g_variant_get_boolean (old_state)); + + DB( g_print ("Toggle action %s activated, state changes from %d to %d\n", + g_action_get_name (G_ACTION (action)), + g_variant_get_boolean (old_state), + g_variant_get_boolean (new_state)) ); + + data->showall = g_variant_get_boolean (new_state); + ui_mainwindow_populate_accounts(GLOBALS->mainwindow, NULL); + + g_simple_action_set_state (action, new_state); + g_variant_unref (old_state); +} + +static void +activate_radio (GSimpleAction *action, GVariant *parameter, gpointer user_data) +{ +//struct hbfile_data *data = user_data; +GVariant *old_state, *new_state; + + old_state = g_action_get_state (G_ACTION (action)); + new_state = g_variant_new_string (g_variant_get_string (parameter, NULL)); + + DB( g_print ("Radio action %s activated, state changes from %s to %s\n", + g_action_get_name (G_ACTION (action)), + g_variant_get_string (old_state, NULL), + g_variant_get_string (new_state, NULL)) ); + + PREFS->pnl_acc_show_by = DSPACC_GROUP_BY_TYPE; + if( !strcmp("bank", g_variant_get_string(new_state, NULL)) ) + PREFS->pnl_acc_show_by = DSPACC_GROUP_BY_BANK; + + ui_mainwindow_populate_accounts(GLOBALS->mainwindow, NULL); + + g_simple_action_set_state (action, new_state); + g_variant_unref (old_state); +} + + +static const GActionEntry actions[] = { +// { "paste", activate_action, NULL, NULL, NULL, {0,0,0} }, + { "showall", activate_toggle, NULL, "false" , NULL, {0,0,0} }, + { "groupby", activate_radio , "s", "'type'", NULL, {0,0,0} } +}; - label = make_label_group(_("Your accounts")); - gtk_widget_set_margin_top(GTK_WIDGET(label), SPACING_SMALL/2); - gtk_widget_set_margin_bottom(GTK_WIDGET(label), SPACING_SMALL/2); - gtk_widget_set_margin_start(GTK_WIDGET(label), SPACING_SMALL); - gtk_widget_set_margin_end(GTK_WIDGET(label), SPACING_SMALL); - gtk_box_pack_start (GTK_BOX (mainvbox), label, FALSE, FALSE, 0); + +static void ui_panel_accounts_setup(struct hbfile_data *data) +{ +GAction *action; +GVariant *new_state; + + if( !G_IS_SIMPLE_ACTION_GROUP(data->action_group_acc) ) + return; + + action = g_action_map_lookup_action (G_ACTION_MAP (data->action_group_acc), "showall"); + if( action ) + { + new_state = g_variant_new_boolean (data->showall); + g_simple_action_set_state (G_SIMPLE_ACTION(action), new_state); + } + + action = g_action_map_lookup_action (G_ACTION_MAP (data->action_group_acc), "groupby"); + if( action ) + { + const gchar *value = (PREFS->pnl_acc_show_by == DSPACC_GROUP_BY_TYPE) ? "type" : "bank"; + new_state = g_variant_new_string (value); + g_simple_action_set_state (G_SIMPLE_ACTION (action), new_state); + } + +} + + +static GtkWidget *ui_mainwindow_create_youraccounts(struct hbfile_data *data) +{ +GtkWidget *panel, *label, *widget, *sw, *tbar, *hbox, *image; +GtkToolItem *toolitem; + + panel = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0); + gtk_container_set_border_width(GTK_CONTAINER(panel), SPACING_SMALL); sw = gtk_scrolled_window_new (NULL, NULL); gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (sw), GTK_SHADOW_ETCHED_IN); gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (sw), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); - //gtk_widget_set_margin_top(GTK_WIDGET(sw), 0); - gtk_widget_set_margin_bottom(GTK_WIDGET(sw), SPACING_SMALL); - gtk_widget_set_margin_start(GTK_WIDGET(sw), 2*SPACING_SMALL); - gtk_widget_set_margin_end(GTK_WIDGET(sw), SPACING_SMALL); - gtk_box_pack_start (GTK_BOX (mainvbox), sw, TRUE, TRUE, 0); - + gtk_box_pack_start (GTK_BOX (panel), sw, TRUE, TRUE, 0); widget = (GtkWidget *)create_list_account(); data->LV_acc = widget; gtk_container_add (GTK_CONTAINER (sw), widget); - return mainvbox; + //list toolbar + tbar = gtk_toolbar_new(); + gtk_toolbar_set_icon_size (GTK_TOOLBAR(tbar), GTK_ICON_SIZE_MENU); + gtk_toolbar_set_style(GTK_TOOLBAR(tbar), GTK_TOOLBAR_ICONS); + gtk_style_context_add_class (gtk_widget_get_style_context (tbar), GTK_STYLE_CLASS_INLINE_TOOLBAR); + gtk_box_pack_start (GTK_BOX (panel), tbar, FALSE, FALSE, 0); + + label = make_label_group(_("Your accounts")); + toolitem = gtk_tool_item_new(); + gtk_container_add (GTK_CONTAINER(toolitem), label); + gtk_toolbar_insert(GTK_TOOLBAR(tbar), GTK_TOOL_ITEM(toolitem), -1); + + toolitem = gtk_separator_tool_item_new (); + gtk_tool_item_set_expand (toolitem, TRUE); + gtk_separator_tool_item_set_draw(GTK_SEPARATOR_TOOL_ITEM(toolitem), FALSE); + gtk_toolbar_insert(GTK_TOOLBAR(tbar), GTK_TOOL_ITEM(toolitem), -1); + + hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0); + toolitem = gtk_tool_item_new(); + gtk_container_add (GTK_CONTAINER(toolitem), hbox); + gtk_toolbar_insert(GTK_TOOLBAR(tbar), GTK_TOOL_ITEM(toolitem), -1); + + widget = make_image_button(ICONNAME_HB_BUTTON_EXPAND, _("Expand all")); + data->BT_expandall = widget; + gtk_box_pack_start (GTK_BOX (hbox), widget, FALSE, FALSE, 0); + + widget = make_image_button(ICONNAME_HB_BUTTON_COLLAPSE, _("Collapse all")); + data->BT_collapseall = widget; + gtk_box_pack_start (GTK_BOX (hbox), widget, FALSE, FALSE, 0); + + toolitem = gtk_separator_tool_item_new (); + gtk_tool_item_set_expand (toolitem, FALSE); + gtk_separator_tool_item_set_draw(GTK_SEPARATOR_TOOL_ITEM(toolitem), FALSE); + gtk_toolbar_insert(GTK_TOOLBAR(tbar), GTK_TOOL_ITEM(toolitem), -1); + + + //gmenu test (see test folder into gtk) +GMenu *menu, *section; + + menu = g_menu_new (); + //g_menu_append (menumodel, "About", "actions.undo"); + //g_menu_append (menumodel, "Test", "actions.redo"); + section = g_menu_new (); + g_menu_append (section, _("Show all"), "actions.showall"); + g_menu_append_section(menu, NULL, G_MENU_MODEL(section)); + g_object_unref (section); + + section = g_menu_new (); + g_menu_append (section, _("By type"), "actions.groupby::type"); + g_menu_append (section, _("By institition"), "actions.groupby::bank"); + g_menu_append_section(menu, NULL, G_MENU_MODEL(section)); + g_object_unref (section); + + + GSimpleActionGroup *group = g_simple_action_group_new (); + data->action_group_acc = group; + g_action_map_add_action_entries (G_ACTION_MAP (group), actions, G_N_ELEMENTS (actions), data); + + + widget = gtk_menu_button_new(); + gtk_menu_button_set_direction (GTK_MENU_BUTTON(widget), GTK_ARROW_UP); + gtk_widget_set_halign (widget, GTK_ALIGN_END); + image = gtk_image_new_from_icon_name (ICONNAME_EMBLEM_SYSTEM, GTK_ICON_SIZE_MENU); + g_object_set (widget, "image", image, NULL); + + toolitem = gtk_tool_item_new(); + gtk_container_add (GTK_CONTAINER(toolitem), widget); + gtk_toolbar_insert(GTK_TOOLBAR(tbar), GTK_TOOL_ITEM(toolitem), -1); + + gtk_widget_insert_action_group (widget, "actions", G_ACTION_GROUP(group)); + gtk_menu_button_set_menu_model (GTK_MENU_BUTTON (widget), G_MENU_MODEL (menu)); + + return panel; } static GtkWidget *ui_mainwindow_create_topspending(struct hbfile_data *data) { -GtkWidget *mainvbox, *hbox, *vbox; +GtkWidget *panel, *hbox, *tbar; GtkWidget *label, *widget; +GtkToolItem *toolitem; - mainvbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0); - data->GR_top = mainvbox; + widget = (GtkWidget *)create_list_topspending(); + data->LV_top = widget; + + panel = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0); + gtk_container_set_border_width(GTK_CONTAINER(panel), SPACING_SMALL); + data->GR_top = panel; + + /* chart + listview */ + hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0); + gtk_box_pack_start (GTK_BOX (panel), hbox, TRUE, TRUE, 0); + + widget = gtk_chart_new(CHART_TYPE_PIE); + data->RE_pie = widget; + gtk_chart_set_minor_prefs(GTK_CHART(widget), PREFS->euro_value, PREFS->minor_cur.symbol); + gtk_chart_show_legend(GTK_CHART(data->RE_pie), TRUE, TRUE); + gtk_box_pack_start (GTK_BOX (hbox), widget, TRUE, TRUE, 0); + + //list toolbar + tbar = gtk_toolbar_new(); + gtk_toolbar_set_icon_size (GTK_TOOLBAR(tbar), GTK_ICON_SIZE_MENU); + gtk_toolbar_set_style(GTK_TOOLBAR(tbar), GTK_TOOLBAR_ICONS); + gtk_style_context_add_class (gtk_widget_get_style_context (tbar), GTK_STYLE_CLASS_INLINE_TOOLBAR); + gtk_box_pack_start (GTK_BOX (panel), tbar, FALSE, FALSE, 0); label = make_label_group(_("Where your money goes")); - gtk_widget_set_margin_top(GTK_WIDGET(label), SPACING_SMALL/2); - gtk_widget_set_margin_bottom(GTK_WIDGET(label), SPACING_SMALL/2); - gtk_widget_set_margin_start(GTK_WIDGET(label), SPACING_SMALL); - gtk_widget_set_margin_end(GTK_WIDGET(label), SPACING_SMALL); - gtk_box_pack_start (GTK_BOX (mainvbox), label, FALSE, FALSE, 0); + toolitem = gtk_tool_item_new(); + gtk_container_add (GTK_CONTAINER(toolitem), label); + gtk_toolbar_insert(GTK_TOOLBAR(tbar), GTK_TOOL_ITEM(toolitem), -1); + toolitem = gtk_separator_tool_item_new (); + gtk_tool_item_set_expand (toolitem, TRUE); + gtk_separator_tool_item_set_draw(GTK_SEPARATOR_TOOL_ITEM(toolitem), FALSE); + gtk_toolbar_insert(GTK_TOOLBAR(tbar), GTK_TOOL_ITEM(toolitem), -1); - vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, SPACING_SMALL); - //gtk_widget_set_margin_top(GTK_WIDGET(vbox), 0); - gtk_widget_set_margin_bottom(GTK_WIDGET(vbox), SPACING_SMALL); - gtk_widget_set_margin_start(GTK_WIDGET(vbox), 2*SPACING_SMALL); - gtk_widget_set_margin_end(GTK_WIDGET(vbox), SPACING_SMALL); - gtk_box_pack_start (GTK_BOX (mainvbox), vbox, TRUE, TRUE, 0); - /* total + date range */ hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, SPACING_SMALL); - gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0); - - label = make_label(_("Top spending"), 0.0, 0.5); - gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0); + toolitem = gtk_tool_item_new(); + gtk_container_add (GTK_CONTAINER(toolitem), hbox); + gtk_toolbar_insert(GTK_TOOLBAR(tbar), GTK_TOOL_ITEM(toolitem), -1); - label = make_label(NULL, 0.0, 0.5); - data->TX_topamount = label; - gtk_box_pack_start (GTK_BOX (hbox), label, TRUE, TRUE, 0); - data->CY_range = make_daterange(label, FALSE); gtk_box_pack_end (GTK_BOX (hbox), data->CY_range, FALSE, FALSE, 0); @@ -2715,67 +3081,26 @@ GtkWidget *label, *widget; data->RA_type = widget; gtk_box_pack_end (GTK_BOX (hbox), widget, FALSE, FALSE, 0); - /* pie + listview */ - hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0); - gtk_box_pack_start (GTK_BOX (vbox), hbox, TRUE, TRUE, 0); - - widget = gtk_chart_new(CHART_TYPE_PIE); - data->RE_pie = widget; - gtk_chart_set_minor_prefs(GTK_CHART(widget), PREFS->euro_value, PREFS->minor_cur.symbol); - gtk_box_pack_start (GTK_BOX (hbox), widget, TRUE, TRUE, 0); - -/* - sw = gtk_scrolled_window_new (NULL, NULL); - gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (sw), GTK_SHADOW_ETCHED_IN); - gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (sw), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); - gtk_box_pack_start (GTK_BOX (hbox), sw, FALSE, FALSE, 0); - */ - - widget = (GtkWidget *)create_list_topspending(); - data->LV_top = widget; - - gtk_chart_show_legend(GTK_CHART(data->RE_pie), TRUE, TRUE); - -// gtk_container_add (GTK_CONTAINER (sw), widget); - - return mainvbox; + return panel; } static GtkWidget *ui_mainwindow_scheduled_create(struct hbfile_data *data) { -GtkWidget *mainvbox, *hbox, *vbox, *bbox, *sw, *tbar; +GtkWidget *panel, *hbox, *vbox, *bbox, *sw, *tbar; GtkWidget *label, *widget; GtkToolItem *toolitem; - mainvbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0); - data->GR_upc = mainvbox; + panel = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0); + gtk_container_set_border_width(GTK_CONTAINER(panel), SPACING_SMALL); + data->GR_upc = panel; - hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, SPACING_SMALL); - gtk_box_pack_start (GTK_BOX (mainvbox), hbox, FALSE, FALSE, 0); - - label = make_label_group(_("Scheduled transactions")); - gtk_widget_set_margin_top(GTK_WIDGET(label), SPACING_SMALL/2); - gtk_widget_set_margin_bottom(GTK_WIDGET(label), SPACING_SMALL/2); - gtk_widget_set_margin_start(GTK_WIDGET(label), SPACING_SMALL); - gtk_widget_set_margin_end(GTK_WIDGET(label), SPACING_SMALL); - gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0); - - label = make_label(_("maximum post date"), 0.0, 0.7); - gimp_label_set_attributes (GTK_LABEL (label), PANGO_ATTR_SCALE, PANGO_SCALE_SMALL, -1); - gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0); - - label = make_label(NULL, 0.0, 0.7); - data->LB_maxpostdate = label; - gimp_label_set_attributes (GTK_LABEL (label), PANGO_ATTR_SCALE, PANGO_SCALE_SMALL, -1); - gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0); - vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0); //gtk_widget_set_margin_top(GTK_WIDGET(vbox), 0); - gtk_widget_set_margin_bottom(GTK_WIDGET(vbox), SPACING_SMALL); - gtk_widget_set_margin_start(GTK_WIDGET(vbox), 2*SPACING_SMALL); - gtk_widget_set_margin_end(GTK_WIDGET(vbox), SPACING_SMALL); - gtk_box_pack_start (GTK_BOX (mainvbox), vbox, TRUE, TRUE, 0); + //gtk_widget_set_margin_bottom(GTK_WIDGET(vbox), SPACING_SMALL); + //gtk_widget_set_margin_start(GTK_WIDGET(vbox), 2*SPACING_SMALL); + //gtk_widget_set_margin_end(GTK_WIDGET(vbox), SPACING_SMALL); + gtk_box_pack_start (GTK_BOX (panel), vbox, TRUE, TRUE, 0); sw = gtk_scrolled_window_new (NULL, NULL); gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (sw), GTK_SHADOW_ETCHED_IN); @@ -2792,43 +3117,62 @@ GtkToolItem *toolitem; gtk_style_context_add_class (gtk_widget_get_style_context (tbar), GTK_STYLE_CLASS_INLINE_TOOLBAR); gtk_box_pack_start (GTK_BOX (vbox), tbar, FALSE, FALSE, 0); + label = make_label_group(_("Scheduled transactions")); + toolitem = gtk_tool_item_new(); + gtk_container_add (GTK_CONTAINER(toolitem), label); + gtk_toolbar_insert(GTK_TOOLBAR(tbar), GTK_TOOL_ITEM(toolitem), -1); + + toolitem = gtk_separator_tool_item_new (); + gtk_tool_item_set_expand (toolitem, FALSE); + gtk_separator_tool_item_set_draw(GTK_SEPARATOR_TOOL_ITEM(toolitem), FALSE); + gtk_toolbar_insert(GTK_TOOLBAR(tbar), GTK_TOOL_ITEM(toolitem), -1); + + bbox = gtk_button_box_new (GTK_ORIENTATION_HORIZONTAL); toolitem = gtk_tool_item_new(); gtk_container_add (GTK_CONTAINER(toolitem), bbox); gtk_toolbar_insert(GTK_TOOLBAR(tbar), GTK_TOOL_ITEM(toolitem), -1); - widget = gtk_button_new_with_label(_("Skip")); - data->BT_sched_skip = widget; - gtk_box_pack_start (GTK_BOX (bbox), widget, FALSE, FALSE, 0); - - widget = gtk_button_new_with_label(_("Edit & Post")); - data->BT_sched_editpost = widget; - gtk_box_pack_start (GTK_BOX (bbox), widget, FALSE, FALSE, 0); + widget = gtk_button_new_with_label(_("Skip")); + data->BT_sched_skip = widget; + gtk_box_pack_start (GTK_BOX (bbox), widget, FALSE, FALSE, 0); - //TRANSLATORS: Posting a scheduled transaction is the action to materialize it into its target account. - //TRANSLATORS: Before that action the automated transaction occurrence is pending and not yet really existing. - widget = gtk_button_new_with_label (_("Post")); - data->BT_sched_post = widget; - gtk_box_pack_start (GTK_BOX (bbox), widget, FALSE, FALSE, 0); + widget = gtk_button_new_with_label(_("Edit & Post")); + data->BT_sched_editpost = widget; + gtk_box_pack_start (GTK_BOX (bbox), widget, FALSE, FALSE, 0); + //TRANSLATORS: Posting a scheduled transaction is the action to materialize it into its target account. + //TRANSLATORS: Before that action the automated transaction occurrence is pending and not yet really existing. + widget = gtk_button_new_with_label (_("Post")); + data->BT_sched_post = widget; + gtk_box_pack_start (GTK_BOX (bbox), widget, FALSE, FALSE, 0); -/* image = gtk_image_new_from_icon_name (ICONNAME_HB_SCHED_SKIP, GTK_ICON_SIZE_MENU); - toolitem = gtk_tool_button_new(image, NULL); - data->BT_sched_skip = toolitem; + toolitem = gtk_separator_tool_item_new (); + gtk_tool_item_set_expand (toolitem, FALSE); + gtk_separator_tool_item_set_draw(GTK_SEPARATOR_TOOL_ITEM(toolitem), FALSE); gtk_toolbar_insert(GTK_TOOLBAR(tbar), GTK_TOOL_ITEM(toolitem), -1); - gtk_widget_set_tooltip_text(GTK_WIDGET(toolitem), _("Skip")); - image = gtk_image_new_from_icon_name (ICONNAME_HB_SCHED_POST, GTK_ICON_SIZE_MENU); - toolitem = gtk_tool_button_new(image, NULL); - data->BT_sched_post = toolitem; + hbox = gtk_box_new(GTK_ORIENTATION_VERTICAL, 0); + gtk_widget_set_valign (hbox, GTK_ALIGN_CENTER); + toolitem = gtk_tool_item_new(); + gtk_container_add (GTK_CONTAINER(toolitem), hbox); gtk_toolbar_insert(GTK_TOOLBAR(tbar), GTK_TOOL_ITEM(toolitem), -1); - gtk_widget_set_tooltip_text(GTK_WIDGET(toolitem), _("Post")); -*/ - - return mainvbox; + label = make_label(_("maximum post date"), 0.0, 0.7); + gtk_widget_set_halign (label, GTK_ALIGN_CENTER); + gimp_label_set_attributes (GTK_LABEL (label), PANGO_ATTR_SCALE, PANGO_SCALE_SMALL, -1); + gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0); + + label = make_label(NULL, 0.0, 0.7); + data->LB_maxpostdate = label; + gtk_widget_set_halign (label, GTK_ALIGN_CENTER); + gimp_label_set_attributes (GTK_LABEL (label), PANGO_ATTR_SCALE, PANGO_SCALE_SMALL, -1); + gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0); + + return panel; } + /* ** the window creation */ @@ -2850,7 +3194,7 @@ GtkAction *action; //store our window private data g_object_set_data(G_OBJECT(window), "inst_data", (gpointer)data); - DB( g_print(" - new window=%x, inst_data=%0x\n", (gint)window, (gint)data) ); + DB( g_print(" - new window=%p, inst_data=%p\n", window, data) ); // this is our mainwindow, so store it to GLOBALS data data->window = window; @@ -2861,7 +3205,7 @@ GtkAction *action; ui_mainwindow_create_menu_bar_and_toolbar (data, mainvbox); -#if HB_UNSTABLE == TRUE +#if HB_UNSTABLE_SHOW == TRUE GtkWidget *bar, *label; bar = gtk_info_bar_new (); @@ -2886,21 +3230,16 @@ GtkWidget *bar, *label; gtk_paned_pack1 (GTK_PANED(vpaned), hpaned, FALSE, FALSE); widget = ui_mainwindow_scheduled_create(data); - gtk_paned_pack2 (GTK_PANED(vpaned), widget, FALSE, FALSE); + gtk_paned_pack2 (GTK_PANED(vpaned), widget, TRUE, FALSE); widget = ui_mainwindow_create_youraccounts(data); + //gtk_widget_set_size_request (widget, 100, -1); gtk_paned_pack1 (GTK_PANED(hpaned), widget, FALSE, FALSE); widget = ui_mainwindow_create_topspending(data); - gtk_paned_pack2 (GTK_PANED(hpaned), widget, FALSE, FALSE); - + //gtk_widget_set_size_request (widget, -1, 100); + gtk_paned_pack2 (GTK_PANED(hpaned), widget, TRUE, FALSE); - DB( g_print(" - vpaned=%d hpaned=%d\n", PREFS->wal_vpaned, PREFS->wal_hpaned) ); - - if(PREFS->wal_hpaned > 0) - gtk_paned_set_position(GTK_PANED(data->hpaned), PREFS->wal_hpaned); - if(PREFS->wal_vpaned > 0) - gtk_paned_set_position(GTK_PANED(data->vpaned), PREFS->wal_vpaned); //setup, init and show window wg = &PREFS->wal_wg; @@ -2913,7 +3252,15 @@ GtkWidget *bar, *label; gtk_window_maximize(GTK_WINDOW(window)); gtk_widget_show_all (window); - + + //#1662197/1660910 moved after resize/show + DB( g_print(" - vpaned=%d hpaned=%d\n", PREFS->wal_vpaned, PREFS->wal_hpaned) ); + + if(PREFS->wal_hpaned > 0) + gtk_paned_set_position(GTK_PANED(data->hpaned), PREFS->wal_hpaned); + if(PREFS->wal_vpaned > 0) + gtk_paned_set_position(GTK_PANED(data->vpaned), PREFS->wal_vpaned); + //todo: move this elsewhere DB( g_print(" - setup stuff\n") ); @@ -2921,8 +3268,6 @@ GtkWidget *bar, *label; filter_default_all_set(data->filter); gtk_combo_box_set_active(GTK_COMBO_BOX(data->CY_range), PREFS->date_range_wal); - - action = gtk_ui_manager_get_action(data->manager, "/MenuBar/ViewMenu/Toolbar"); gtk_toggle_action_set_active(GTK_TOGGLE_ACTION(action), PREFS->wal_toolbar); action = gtk_ui_manager_get_action(data->manager, "/MenuBar/ViewMenu/Spending"); @@ -2950,7 +3295,9 @@ GtkWidget *bar, *label; g_signal_connect (gtk_tree_view_get_selection(GTK_TREE_VIEW(data->LV_acc)), "changed", G_CALLBACK (ui_mainwindow_selection), NULL); - g_signal_connect (GTK_TREE_VIEW(data->LV_acc), "row-activated", G_CALLBACK (ui_mainwindow_onRowActivated), GINT_TO_POINTER(2)); + g_signal_connect (GTK_TREE_VIEW(data->LV_acc ), "row-activated", G_CALLBACK (ui_mainwindow_onRowActivated), GINT_TO_POINTER(2)); + g_signal_connect (G_OBJECT (data->BT_expandall ), "clicked" , G_CALLBACK (ui_panel_accounts_expand_all), NULL); + g_signal_connect (G_OBJECT (data->BT_collapseall), "clicked" , G_CALLBACK (ui_panel_accounts_collapse_all), NULL); g_signal_connect (gtk_tree_view_get_selection(GTK_TREE_VIEW(data->LV_upc)), "changed", G_CALLBACK (ui_mainwindow_scheduled_selection_cb), NULL); g_signal_connect (GTK_TREE_VIEW(data->LV_upc), "row-activated", G_CALLBACK (ui_mainwindow_scheduled_onRowActivated), NULL); @@ -2967,6 +3314,7 @@ GtkWidget *bar, *label; /* GtkWindow events */ g_signal_connect (window, "delete-event", G_CALLBACK (ui_mainwindow_dispose), (gpointer)data); + g_signal_connect (window, "destroy", G_CALLBACK (ui_mainwindow_destroy), NULL); g_signal_connect (window, "screen-changed",