From 48f2aab77bdd6b8499be977e2713ffd70b87e0f7 Mon Sep 17 00:00:00 2001 From: jean Date: Sun, 15 Mar 2020 11:32:25 -0700 Subject: [PATCH] Add code to delay showing dialog until we know we have transactions to show --- gnucash/import-export/aqb/gnc-ab-utils.c | 2 +- gnucash/import-export/import-main-matcher.c | 11 +++++++++-- gnucash/import-export/import-main-matcher.h | 11 ++++++++++- gnucash/import-export/ofx/gnc-ofx-import.c | 14 +++++++++----- 4 files changed, 29 insertions(+), 9 deletions(-) diff --git a/gnucash/import-export/aqb/gnc-ab-utils.c b/gnucash/import-export/aqb/gnc-ab-utils.c index 4e965fa351..f101e34056 100644 --- a/gnucash/import-export/aqb/gnc-ab-utils.c +++ b/gnucash/import-export/aqb/gnc-ab-utils.c @@ -940,7 +940,7 @@ txn_accountinfo_cb(AB_IMEXPORTER_ACCOUNTINFO *element, gpointer user_data) if (!data->generic_importer) { data->generic_importer = gnc_gen_trans_list_new(data->parent, NULL, - TRUE, 14); + TRUE, 14, TRUE); if (data->execute_txns) { gnc_gen_trans_list_add_tp_cb(data->generic_importer, diff --git a/gnucash/import-export/import-main-matcher.c b/gnucash/import-export/import-main-matcher.c index 284a19b284..16aca27790 100644 --- a/gnucash/import-export/import-main-matcher.c +++ b/gnucash/import-export/import-main-matcher.c @@ -187,6 +187,11 @@ gboolean gnc_gen_trans_list_empty(GNCImportMainMatcher *info) return !gtk_tree_model_get_iter_first (model, &iter); } +void gnc_gen_trans_list_show_all(GNCImportMainMatcher *info) +{ + gtk_widget_show_all (GTK_WIDGET (info->main_widget)); +} + void on_matcher_ok_clicked (GtkButton *button, GNCImportMainMatcher *info) { @@ -907,7 +912,8 @@ show_account_column_toggled_cb (GtkToggleButton *togglebutton, GNCImportMainMatcher *gnc_gen_trans_list_new (GtkWidget *parent, const gchar* heading, gboolean all_from_same_account, - gint match_date_hardlimit) + gint match_date_hardlimit, + gboolean show_all) { GNCImportMainMatcher *info; GtkBuilder *builder; @@ -962,7 +968,8 @@ GNCImportMainMatcher *gnc_gen_trans_list_new (GtkWidget *parent, gtk_label_set_text (GTK_LABEL (heading_label), heading); gnc_restore_window_size (GNC_PREFS_GROUP, GTK_WINDOW(info->main_widget), GTK_WINDOW (parent)); - gtk_widget_show_all (GTK_WIDGET (info->main_widget)); + if(show_all) + gtk_widget_show_all (GTK_WIDGET (info->main_widget)); info->transaction_processed_cb = NULL; diff --git a/gnucash/import-export/import-main-matcher.h b/gnucash/import-export/import-main-matcher.h index 76db5bc9e6..7e1e33dd56 100644 --- a/gnucash/import-export/import-main-matcher.h +++ b/gnucash/import-export/import-main-matcher.h @@ -62,12 +62,15 @@ typedef void (*GNCTransactionProcessedCB) (GNCImportTransInfo *trans_info, * with paper checks (e.g. OFX, QIF), values like 42 (days) seem more * appropriate. * + @param show_all if true, all widgets are shown + * * @return A pointer to the GNCImportMainMatcher which has been setup. */ GNCImportMainMatcher *gnc_gen_trans_list_new (GtkWidget *parent, const gchar* heading, gboolean all_from_same_account, - gint match_date_hardlimit); + gint match_date_hardlimit, + gboolean show_all); @@ -187,5 +190,11 @@ GtkWidget *gnc_gen_trans_list_widget (GNCImportMainMatcher *info); * @return A boolean indicating whether the transaction list is empty. */ gboolean gnc_gen_trans_list_empty(GNCImportMainMatcher *info); + +/** Shows widgets. + * @param info A pointer to a the GNCImportMainMatcher structure. + */ +void gnc_gen_trans_list_show_all(GNCImportMainMatcher *info); + #endif /**@}*/ diff --git a/gnucash/import-export/ofx/gnc-ofx-import.c b/gnucash/import-export/ofx/gnc-ofx-import.c index a9a931a36d..b0f7edecf3 100644 --- a/gnucash/import-export/ofx/gnc-ofx-import.c +++ b/gnucash/import-export/ofx/gnc-ofx-import.c @@ -412,7 +412,6 @@ int ofx_proc_transaction_cb(struct OfxTransactionData data, void *user_data) GtkWindow *parent = GTK_WINDOW (user_data); g_assert(gnc_ofx_importer_gui); - num_trans_processed += 1; if (!data.account_id_valid) { @@ -891,7 +890,7 @@ int ofx_proc_transaction_cb(struct OfxTransactionData data, void *user_data) xaccTransDestroy(transaction); xaccTransCommitEdit(transaction); } - + num_trans_processed += 1; return 0; }//end ofx_proc_transaction() @@ -1066,7 +1065,7 @@ void gnc_file_ofx_import (GtkWindow *parent) DEBUG("Filename found: %s", selected_filename); /* Create the Generic transaction importer GUI. */ - gnc_ofx_importer_gui = gnc_gen_trans_list_new (GTK_WIDGET(parent), NULL, FALSE, 42); + gnc_ofx_importer_gui = gnc_gen_trans_list_new (GTK_WIDGET(parent), NULL, FALSE, 42, FALSE); /* Look up the needed preferences */ auto_create_commodity = @@ -1093,10 +1092,15 @@ void gnc_file_ofx_import (GtkWindow *parent) if(gnc_gen_trans_list_empty(gnc_ofx_importer_gui)) { gnc_gen_trans_list_delete (gnc_ofx_importer_gui); - g_print("%d transactions imported\n",num_trans_processed); - gnc_info_dialog(parent,_("OFX file imported, %d transactions processed, no new transactions"),num_trans_processed); + if(num_trans_processed) + gnc_info_dialog(parent,_("OFX file imported, %d transactions processed, no transactions to match"),num_trans_processed); + } + else + { + gnc_gen_trans_list_show_all(gnc_ofx_importer_gui); } g_free(selected_filename); + } if (ofx_created_commodites)