diff --git a/gnucash/import-export/import-main-matcher.c b/gnucash/import-export/import-main-matcher.c index dcc228ed70..3692220c8c 100644 --- a/gnucash/import-export/import-main-matcher.c +++ b/gnucash/import-export/import-main-matcher.c @@ -177,6 +177,17 @@ void gnc_gen_trans_list_delete (GNCImportMainMatcher *info) g_free (info); } +gboolean gnc_gen_trans_list_empty(GNCImportMainMatcher *info) { + GtkTreeModel *model; + GtkTreeIter iter; + GNCImportTransInfo *trans_info; + + g_assert (info); + + model = gtk_tree_view_get_model (info->view); + return !gtk_tree_model_get_iter_first (model, &iter); +} + void on_matcher_ok_clicked (GtkButton *button, GNCImportMainMatcher *info) { @@ -189,8 +200,11 @@ on_matcher_ok_clicked (GtkButton *button, GNCImportMainMatcher *info) /* DEBUG ("Begin") */ model = gtk_tree_view_get_model (info->view); - if (!gtk_tree_model_get_iter_first (model, &iter)) + if (!gtk_tree_model_get_iter_first (model, &iter)) { + // No transaction, we can just close the dialog. JEAN OK CLICKED NO TRANS + gnc_gen_trans_list_delete (info); return; + } /* Don't run any queries and/or split sorts while processing the matcher results. */ diff --git a/gnucash/import-export/import-main-matcher.h b/gnucash/import-export/import-main-matcher.h index b98c123198..4a30ace76c 100644 --- a/gnucash/import-export/import-main-matcher.h +++ b/gnucash/import-export/import-main-matcher.h @@ -178,5 +178,11 @@ gboolean gnc_gen_trans_list_run (GNCImportMainMatcher *info); */ GtkWidget *gnc_gen_trans_list_widget (GNCImportMainMatcher *info); +/** Checks whether there are no transactions to match. + */ +gboolean gnc_gen_trans_list_empty(GNCImportMainMatcher *info); + + + #endif /**@}*/ diff --git a/gnucash/import-export/ofx/gnc-ofx-import.c b/gnucash/import-export/ofx/gnc-ofx-import.c index 255fbe87f1..f1811c9bfa 100644 --- a/gnucash/import-export/ofx/gnc-ofx-import.c +++ b/gnucash/import-export/ofx/gnc-ofx-import.c @@ -1064,6 +1064,7 @@ void gnc_file_ofx_import (GtkWindow *parent) DEBUG("Filename found: %s", selected_filename); /* Create the Generic transaction importer GUI. */ + // JEAN IMPORT: Trans list UI created gnc_ofx_importer_gui = gnc_gen_trans_list_new (GTK_WIDGET(parent), NULL, FALSE, 42); /* Look up the needed preferences */ @@ -1085,7 +1086,15 @@ void gnc_file_ofx_import (GtkWindow *parent) #endif DEBUG("Opening selected file"); + // JEAN: Where the ofx file is loaded. libofx_proc_file(libofx_context, selected_filename, AUTODETECT); + // Now would be a good time to see whether the view has anything in it! + gboolean is_empty = gnc_gen_trans_list_empty(gnc_ofx_importer_gui); + if(is_empty) { + // JEAN CLOSE THE WINDOW NO TRANS + gnc_gen_trans_list_delete (gnc_ofx_importer_gui); + gnc_info_dialog(parent,_("OFX file imported, no new transactions")); + } g_free(selected_filename); }