Attached is a patch to add a 'Review imported transactions' toggle to the import dialog, which displays a ledger with all imported transactions if selected after importing is complete. This is based on the similar toggle in the since last run dialog.
Thanks, Shawn Faucher
Index: src/import-export/import-main-matcher.c =================================================================== --- src/import-export/import-main-matcher.c (revision 16921) +++ src/import-export/import-main-matcher.c (working copy) @@ -41,6 +41,11 @@ #include "import-match-picker.h" #include "import-backend.h" #include "import-account-matcher.h" +#include "Query.h" +#include "QueryNew.h" +#include "gnc-ledger-display.h" +#include "gnc-plugin-page-register.h" +#include "gnc-main-window.h" #define GCONF_SECTION "dialogs/import/generic_matcher/transaction_list" @@ -52,6 +57,7 @@ GdkColor color_back_red; GdkColor color_back_green; GdkColor color_back_yellow; + GtkToggleButton *review_imported_txns_toggle; int selected_row; }; @@ -87,6 +93,9 @@ refresh_model_row(GNCImportMainMatcher *gui, GtkTreeModel *model, GtkTreeIter *iter, GNCImportTransInfo *info); +static void _show_imported_transactions(GNCImportMainMatcher *info, + GSList *created_txn_guids); + void gnc_gen_trans_list_delete (GNCImportMainMatcher *info) { if (info == NULL) @@ -107,7 +116,7 @@ GtkTreeRowReference *ref; GtkTreeIter iter; GNCImportTransInfo *trans_info; - GSList *refs_list = NULL, *item; + GSList *refs_list = NULL, *item, *guid_list = NULL; g_assert (info); @@ -126,9 +135,16 @@ ref = gtk_tree_row_reference_new(model, path); refs_list = g_slist_append(refs_list, ref); gtk_tree_path_free(path); + guid_list = g_slist_append(guid_list, (GUID*)xaccTransGetGUID(gnc_import_TransInfo_get_trans(trans_info))); } } while (gtk_tree_model_iter_next (model, &iter)); + if (gtk_toggle_button_get_active(info->review_imported_txns_toggle) + && g_slist_length(guid_list) > 0) + { + _show_imported_transactions(info, guid_list); + } + /* DEBUG ("Deleting") */ /* DRH: Is this necessary. Isn't the call to trans_list_delete at the end of this routine going to destroy the entire list store @@ -142,6 +158,7 @@ gtk_tree_row_reference_free(ref); } g_slist_free(refs_list); + g_slist_free(guid_list); gnc_gen_trans_list_delete (info); /* DEBUG ("End") */ @@ -479,6 +496,7 @@ g_assert (info->dialog != NULL); info->view = GTK_TREE_VIEW(glade_xml_get_widget (xml, "downloaded_view")); g_assert (info->view != NULL); + info->review_imported_txns_toggle = GTK_TOGGLE_BUTTON(glade_xml_get_widget(xml, "review_txn_toggle")); show_edit = gnc_import_Settings_get_action_edit_enabled (info->user_settings); gnc_gen_trans_init_view(info, all_from_same_account, show_edit); @@ -753,4 +771,34 @@ } } +static void +_show_imported_transactions(GNCImportMainMatcher *info, GSList *created_txn_guids) +{ + GNCLedgerDisplay *ledger; + GncPluginPage *page; + Query *book_query, *guid_query, *query; + GSList *guid_iter; + + book_query = xaccMallocQuery(); + guid_query = xaccMallocQuery(); + xaccQuerySetBook(book_query, gnc_get_current_book()); + for (guid_iter = created_txn_guids; guid_iter != NULL; guid_iter = guid_iter->next) + { + xaccQueryAddGUIDMatch(guid_query, (GUID*)guid_iter->data, GNC_ID_TRANS, QUERY_OR); + } + query = xaccQueryMerge(book_query, guid_query, QUERY_AND); + + // inspired by dialog-find-transactions:do_find_cb: + ledger = gnc_ledger_display_query(query, SEARCH_LEDGER, REG_STYLE_JOURNAL); + gnc_ledger_display_refresh(ledger); + page = gnc_plugin_page_register_new_ledger(ledger); + g_object_set(G_OBJECT(page), "page-name", _("Imported Transactions"), NULL); + gnc_main_window_open_page(NULL, page); + + xaccFreeQuery(query); + xaccFreeQuery(book_query); + xaccFreeQuery(guid_query); +} + + /** @} */ Index: src/import-export/generic-import.glade =================================================================== --- src/import-export/generic-import.glade (revision 16921) +++ src/import-export/generic-import.glade (working copy) @@ -20,6 +20,7 @@ <property name="type_hint">GDK_WINDOW_TYPE_HINT_DIALOG</property> <property name="gravity">GDK_GRAVITY_NORTH_WEST</property> <property name="focus_on_map">True</property> + <property name="urgency_hint">False</property> <property name="has_separator">True</property> <signal name="map" handler="gnc_ui_generic_account_picker_map_cb"/> @@ -169,6 +170,7 @@ <property name="type_hint">GDK_WINDOW_TYPE_HINT_DIALOG</property> <property name="gravity">GDK_GRAVITY_NORTH_WEST</property> <property name="focus_on_map">True</property> + <property name="urgency_hint">False</property> <property name="has_separator">True</property> <signal name="close" handler="on_matcher_cancel_clicked"/> @@ -296,7 +298,46 @@ </child> <child> - <placeholder/> + <widget class="GtkHBox" id="hbox2"> + <property name="visible">True</property> + <property name="homogeneous">False</property> + <property name="spacing">0</property> + + <child> + <widget class="GtkFixed" id="fixed1"> + <property name="visible">True</property> + </widget> + <packing> + <property name="padding">0</property> + <property name="expand">True</property> + <property name="fill">True</property> + </packing> + </child> + + <child> + <widget class="GtkCheckButton" id="review_txn_toggle"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="label" translatable="yes">Review imported transactions</property> + <property name="use_underline">True</property> + <property name="relief">GTK_RELIEF_NORMAL</property> + <property name="focus_on_click">True</property> + <property name="active">False</property> + <property name="inconsistent">False</property> + <property name="draw_indicator">True</property> + </widget> + <packing> + <property name="padding">0</property> + <property name="expand">False</property> + <property name="fill">False</property> + </packing> + </child> + </widget> + <packing> + <property name="padding">0</property> + <property name="expand">False</property> + <property name="fill">False</property> + </packing> </child> </widget> <packing> @@ -325,6 +366,7 @@ <property name="type_hint">GDK_WINDOW_TYPE_HINT_DIALOG</property> <property name="gravity">GDK_GRAVITY_NORTH_WEST</property> <property name="focus_on_map">True</property> + <property name="urgency_hint">False</property> <property name="has_separator">True</property> <signal name="close" handler="on_matcher_cancel_clicked"/> @@ -623,6 +665,7 @@ <property name="type_hint">GDK_WINDOW_TYPE_HINT_DIALOG</property> <property name="gravity">GDK_GRAVITY_NORTH_WEST</property> <property name="focus_on_map">True</property> + <property name="urgency_hint">False</property> <property name="has_separator">True</property> <child internal-child="vbox"> @@ -810,6 +853,7 @@ <property name="type_hint">GDK_WINDOW_TYPE_HINT_DIALOG</property> <property name="gravity">GDK_GRAVITY_NORTH_WEST</property> <property name="focus_on_map">True</property> + <property name="urgency_hint">False</property> <property name="has_separator">True</property> <child internal-child="vbox"> @@ -986,6 +1030,7 @@ <property name="type_hint">GDK_WINDOW_TYPE_HINT_NORMAL</property> <property name="gravity">GDK_GRAVITY_NORTH_WEST</property> <property name="focus_on_map">True</property> + <property name="urgency_hint">False</property> <child> <widget class="GtkTable" id="matcher_prefs"> @@ -1324,6 +1369,7 @@ <property name="type_hint">GDK_WINDOW_TYPE_HINT_DIALOG</property> <property name="gravity">GDK_GRAVITY_NORTH_WEST</property> <property name="focus_on_map">True</property> + <property name="urgency_hint">False</property> <property name="has_separator">True</property> <signal name="close" handler="on_matcher_help_close_clicked" last_modification_time="Tue, 22 Nov 2005 08:11:11 GMT"/> Index: src/import-export/Makefile.am =================================================================== --- src/import-export/Makefile.am (revision 16921) +++ src/import-export/Makefile.am (working copy) @@ -47,6 +47,9 @@ ${top_builddir}/src/engine/libgncmod-engine.la \ ${top_builddir}/src/core-utils/libgnc-core-utils.la \ ${top_builddir}/src/gnc-module/libgnc-module.la \ + ${top_builddir}/src/register/ledger-core/libgncmod-ledger-core.la \ + ${top_builddir}/src/register/register-gnome/libgncmod-register-gnome.la \ + ${top_builddir}/src/register/register-core/libgncmod-register-core.la \ ${GNOME_LIBS} \ ${GLADE_LIBS} \ ${QOF_LIBS} \ @@ -66,6 +69,9 @@ -I${top_srcdir}/src/app-utils \ -I${top_srcdir}/src/gnome \ -I${top_srcdir}/src/gnome-utils \ + -I${top_srcdir}/src/register/ledger-core \ + -I${top_srcdir}/src/register/register-core \ + -I${top_srcdir}/src/register/register-gnome \ ${GNOME_CFLAGS} \ ${GTKHTML_CFLAGS} \ ${GDK_PIXBUF_CFLAGS} \
_______________________________________________ gnucash-devel mailing list gnucash-devel@gnucash.org https://lists.gnucash.org/mailman/listinfo/gnucash-devel