Add code to delay showing dialog until we know we have transactions to show

This commit is contained in:
jean 2020-03-15 11:32:25 -07:00
parent 3aa9009c67
commit 48f2aab77b
4 changed files with 29 additions and 9 deletions

View File

@ -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,

View File

@ -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;

View File

@ -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
/**@}*/

View File

@ -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)