r23567 - gnucash/trunk - Rename some directories in src/import-export

John Ralls jralls at code.gnucash.org
Sun Dec 15 12:21:29 EST 2013


Author: jralls
Date: 2013-12-15 12:21:20 -0500 (Sun, 15 Dec 2013)
New Revision: 23567
Trac: http://svn.gnucash.org/trac/changeset/23567

Added:
   gnucash/trunk/src/import-export/aqb/
   gnucash/trunk/src/import-export/aqb/CMakeLists.txt
   gnucash/trunk/src/import-export/aqb/Makefile.am
   gnucash/trunk/src/import-export/aqb/assistant-ab-initial.c
   gnucash/trunk/src/import-export/aqb/assistant-ab-initial.glade
   gnucash/trunk/src/import-export/aqb/assistant-ab-initial.h
   gnucash/trunk/src/import-export/aqb/dialog-ab-daterange.c
   gnucash/trunk/src/import-export/aqb/dialog-ab-daterange.h
   gnucash/trunk/src/import-export/aqb/dialog-ab-trans.c
   gnucash/trunk/src/import-export/aqb/dialog-ab-trans.h
   gnucash/trunk/src/import-export/aqb/dialog-ab.glade
   gnucash/trunk/src/import-export/aqb/gnc-ab-getbalance.c
   gnucash/trunk/src/import-export/aqb/gnc-ab-getbalance.h
   gnucash/trunk/src/import-export/aqb/gnc-ab-gettrans.c
   gnucash/trunk/src/import-export/aqb/gnc-ab-gettrans.h
   gnucash/trunk/src/import-export/aqb/gnc-ab-kvp.c
   gnucash/trunk/src/import-export/aqb/gnc-ab-kvp.h
   gnucash/trunk/src/import-export/aqb/gnc-ab-trans-templ.c
   gnucash/trunk/src/import-export/aqb/gnc-ab-trans-templ.h
   gnucash/trunk/src/import-export/aqb/gnc-ab-transfer.c
   gnucash/trunk/src/import-export/aqb/gnc-ab-transfer.h
   gnucash/trunk/src/import-export/aqb/gnc-ab-utils.c
   gnucash/trunk/src/import-export/aqb/gnc-ab-utils.h
   gnucash/trunk/src/import-export/aqb/gnc-file-aqb-import.c
   gnucash/trunk/src/import-export/aqb/gnc-file-aqb-import.h
   gnucash/trunk/src/import-export/aqb/gnc-gwen-gui.c
   gnucash/trunk/src/import-export/aqb/gnc-gwen-gui.h
   gnucash/trunk/src/import-export/aqb/gnc-plugin-aqbanking-ui.xml
   gnucash/trunk/src/import-export/aqb/gnc-plugin-aqbanking.c
   gnucash/trunk/src/import-export/aqb/gnc-plugin-aqbanking.h
   gnucash/trunk/src/import-export/aqb/gncmod-aqbanking.c
   gnucash/trunk/src/import-export/aqb/gschemas/
   gnucash/trunk/src/import-export/aqb/gschemas/Makefile.am
   gnucash/trunk/src/import-export/aqb/gschemas/org.gnucash.dialogs.import.hbci.gschema.xml.in.in
   gnucash/trunk/src/import-export/aqb/migratable-prefs-aqbanking.xml
   gnucash/trunk/src/import-export/csv-exp/
   gnucash/trunk/src/import-export/csv-exp/Makefile.am
   gnucash/trunk/src/import-export/csv-exp/assistant-csv-export.c
   gnucash/trunk/src/import-export/csv-exp/assistant-csv-export.glade
   gnucash/trunk/src/import-export/csv-exp/assistant-csv-export.h
   gnucash/trunk/src/import-export/csv-exp/csv-transactions-export.c
   gnucash/trunk/src/import-export/csv-exp/csv-transactions-export.h
   gnucash/trunk/src/import-export/csv-exp/csv-tree-export.c
   gnucash/trunk/src/import-export/csv-exp/csv-tree-export.h
   gnucash/trunk/src/import-export/csv-exp/gnc-plugin-csv-export-ui.xml
   gnucash/trunk/src/import-export/csv-exp/gnc-plugin-csv-export.c
   gnucash/trunk/src/import-export/csv-exp/gnc-plugin-csv-export.h
   gnucash/trunk/src/import-export/csv-exp/gncmod-csv-export.c
   gnucash/trunk/src/import-export/csv-exp/gschemas/
   gnucash/trunk/src/import-export/csv-exp/gschemas/Makefile.am
   gnucash/trunk/src/import-export/csv-exp/gschemas/org.gnucash.dialogs.export.csv.gschema.xml.in.in
   gnucash/trunk/src/import-export/csv-imp/
   gnucash/trunk/src/import-export/csv-imp/Makefile.am
   gnucash/trunk/src/import-export/csv-imp/assistant-csv-account-import.c
   gnucash/trunk/src/import-export/csv-imp/assistant-csv-account-import.glade
   gnucash/trunk/src/import-export/csv-imp/assistant-csv-account-import.h
   gnucash/trunk/src/import-export/csv-imp/assistant-csv-trans-import.c
   gnucash/trunk/src/import-export/csv-imp/assistant-csv-trans-import.glade
   gnucash/trunk/src/import-export/csv-imp/assistant-csv-trans-import.h
   gnucash/trunk/src/import-export/csv-imp/csv-account-import.c
   gnucash/trunk/src/import-export/csv-imp/csv-account-import.h
   gnucash/trunk/src/import-export/csv-imp/gnc-csv-gnumeric-popup.c
   gnucash/trunk/src/import-export/csv-imp/gnc-csv-gnumeric-popup.h
   gnucash/trunk/src/import-export/csv-imp/gnc-csv-model.c
   gnucash/trunk/src/import-export/csv-imp/gnc-csv-model.h
   gnucash/trunk/src/import-export/csv-imp/gnc-plugin-csv-import-ui.xml
   gnucash/trunk/src/import-export/csv-imp/gnc-plugin-csv-import.c
   gnucash/trunk/src/import-export/csv-imp/gnc-plugin-csv-import.h
   gnucash/trunk/src/import-export/csv-imp/gncmod-csv-import.c
   gnucash/trunk/src/import-export/csv-imp/gschemas/
   gnucash/trunk/src/import-export/csv-imp/gschemas/Makefile.am
   gnucash/trunk/src/import-export/csv-imp/gschemas/org.gnucash.dialogs.import.csv.gschema.xml.in.in
   gnucash/trunk/src/import-export/qif-imp/
   gnucash/trunk/src/import-export/qif-imp/Makefile.am
   gnucash/trunk/src/import-export/qif-imp/assistant-qif-import.c
   gnucash/trunk/src/import-export/qif-imp/assistant-qif-import.glade
   gnucash/trunk/src/import-export/qif-imp/assistant-qif-import.h
   gnucash/trunk/src/import-export/qif-imp/dialog-account-picker.c
   gnucash/trunk/src/import-export/qif-imp/dialog-account-picker.glade
   gnucash/trunk/src/import-export/qif-imp/dialog-account-picker.h
   gnucash/trunk/src/import-export/qif-imp/file-format.txt
   gnucash/trunk/src/import-export/qif-imp/gnc-plugin-qif-import-ui.xml
   gnucash/trunk/src/import-export/qif-imp/gnc-plugin-qif-import.c
   gnucash/trunk/src/import-export/qif-imp/gnc-plugin-qif-import.h
   gnucash/trunk/src/import-export/qif-imp/gncmod-qif-import.c
   gnucash/trunk/src/import-export/qif-imp/gschemas/
   gnucash/trunk/src/import-export/qif-imp/gschemas/Makefile.am
   gnucash/trunk/src/import-export/qif-imp/gschemas/org.gnucash.dialogs.import.qif.gschema.xml.in.in
   gnucash/trunk/src/import-export/qif-imp/qif-dialog-utils.scm
   gnucash/trunk/src/import-export/qif-imp/qif-file.scm
   gnucash/trunk/src/import-export/qif-imp/qif-guess-map.scm
   gnucash/trunk/src/import-export/qif-imp/qif-import.scm
   gnucash/trunk/src/import-export/qif-imp/qif-merge-groups.scm
   gnucash/trunk/src/import-export/qif-imp/qif-objects.scm
   gnucash/trunk/src/import-export/qif-imp/qif-parse.scm
   gnucash/trunk/src/import-export/qif-imp/qif-to-gnc.scm
   gnucash/trunk/src/import-export/qif-imp/qif-utils.scm
   gnucash/trunk/src/import-export/qif-imp/test/
   gnucash/trunk/src/import-export/qif-imp/test/Makefile.am
   gnucash/trunk/src/import-export/qif-imp/test/test-link.c
Removed:
   gnucash/trunk/src/import-export/aqbanking/CMakeLists.txt
   gnucash/trunk/src/import-export/aqbanking/Makefile.am
   gnucash/trunk/src/import-export/aqbanking/assistant-ab-initial.c
   gnucash/trunk/src/import-export/aqbanking/assistant-ab-initial.glade
   gnucash/trunk/src/import-export/aqbanking/assistant-ab-initial.h
   gnucash/trunk/src/import-export/aqbanking/dialog-ab-daterange.c
   gnucash/trunk/src/import-export/aqbanking/dialog-ab-daterange.h
   gnucash/trunk/src/import-export/aqbanking/dialog-ab-trans.c
   gnucash/trunk/src/import-export/aqbanking/dialog-ab-trans.h
   gnucash/trunk/src/import-export/aqbanking/dialog-ab.glade
   gnucash/trunk/src/import-export/aqbanking/gnc-ab-getbalance.c
   gnucash/trunk/src/import-export/aqbanking/gnc-ab-getbalance.h
   gnucash/trunk/src/import-export/aqbanking/gnc-ab-gettrans.c
   gnucash/trunk/src/import-export/aqbanking/gnc-ab-gettrans.h
   gnucash/trunk/src/import-export/aqbanking/gnc-ab-kvp.c
   gnucash/trunk/src/import-export/aqbanking/gnc-ab-kvp.h
   gnucash/trunk/src/import-export/aqbanking/gnc-ab-trans-templ.c
   gnucash/trunk/src/import-export/aqbanking/gnc-ab-trans-templ.h
   gnucash/trunk/src/import-export/aqbanking/gnc-ab-transfer.c
   gnucash/trunk/src/import-export/aqbanking/gnc-ab-transfer.h
   gnucash/trunk/src/import-export/aqbanking/gnc-ab-utils.c
   gnucash/trunk/src/import-export/aqbanking/gnc-ab-utils.h
   gnucash/trunk/src/import-export/aqbanking/gnc-file-aqb-import.c
   gnucash/trunk/src/import-export/aqbanking/gnc-file-aqb-import.h
   gnucash/trunk/src/import-export/aqbanking/gnc-gwen-gui.c
   gnucash/trunk/src/import-export/aqbanking/gnc-gwen-gui.h
   gnucash/trunk/src/import-export/aqbanking/gnc-plugin-aqbanking-ui.xml
   gnucash/trunk/src/import-export/aqbanking/gnc-plugin-aqbanking.c
   gnucash/trunk/src/import-export/aqbanking/gnc-plugin-aqbanking.h
   gnucash/trunk/src/import-export/aqbanking/gncmod-aqbanking.c
   gnucash/trunk/src/import-export/aqbanking/gschemas/Makefile.am
   gnucash/trunk/src/import-export/aqbanking/gschemas/org.gnucash.dialogs.import.hbci.gschema.xml.in.in
   gnucash/trunk/src/import-export/aqbanking/migratable-prefs-aqbanking.xml
   gnucash/trunk/src/import-export/csv-export/Makefile.am
   gnucash/trunk/src/import-export/csv-export/assistant-csv-export.c
   gnucash/trunk/src/import-export/csv-export/assistant-csv-export.glade
   gnucash/trunk/src/import-export/csv-export/assistant-csv-export.h
   gnucash/trunk/src/import-export/csv-export/csv-transactions-export.c
   gnucash/trunk/src/import-export/csv-export/csv-transactions-export.h
   gnucash/trunk/src/import-export/csv-export/csv-tree-export.c
   gnucash/trunk/src/import-export/csv-export/csv-tree-export.h
   gnucash/trunk/src/import-export/csv-export/gnc-plugin-csv-export-ui.xml
   gnucash/trunk/src/import-export/csv-export/gnc-plugin-csv-export.c
   gnucash/trunk/src/import-export/csv-export/gnc-plugin-csv-export.h
   gnucash/trunk/src/import-export/csv-export/gncmod-csv-export.c
   gnucash/trunk/src/import-export/csv-export/gschemas/Makefile.am
   gnucash/trunk/src/import-export/csv-export/gschemas/org.gnucash.dialogs.export.csv.gschema.xml.in.in
   gnucash/trunk/src/import-export/csv-import/Makefile.am
   gnucash/trunk/src/import-export/csv-import/assistant-csv-account-import.c
   gnucash/trunk/src/import-export/csv-import/assistant-csv-account-import.glade
   gnucash/trunk/src/import-export/csv-import/assistant-csv-account-import.h
   gnucash/trunk/src/import-export/csv-import/assistant-csv-trans-import.c
   gnucash/trunk/src/import-export/csv-import/assistant-csv-trans-import.glade
   gnucash/trunk/src/import-export/csv-import/assistant-csv-trans-import.h
   gnucash/trunk/src/import-export/csv-import/csv-account-import.c
   gnucash/trunk/src/import-export/csv-import/csv-account-import.h
   gnucash/trunk/src/import-export/csv-import/gnc-csv-gnumeric-popup.c
   gnucash/trunk/src/import-export/csv-import/gnc-csv-gnumeric-popup.h
   gnucash/trunk/src/import-export/csv-import/gnc-csv-model.c
   gnucash/trunk/src/import-export/csv-import/gnc-csv-model.h
   gnucash/trunk/src/import-export/csv-import/gnc-plugin-csv-import-ui.xml
   gnucash/trunk/src/import-export/csv-import/gnc-plugin-csv-import.c
   gnucash/trunk/src/import-export/csv-import/gnc-plugin-csv-import.h
   gnucash/trunk/src/import-export/csv-import/gncmod-csv-import.c
   gnucash/trunk/src/import-export/csv-import/gschemas/Makefile.am
   gnucash/trunk/src/import-export/csv-import/gschemas/org.gnucash.dialogs.import.csv.gschema.xml.in.in
   gnucash/trunk/src/import-export/qif-import/Makefile.am
   gnucash/trunk/src/import-export/qif-import/assistant-qif-import.c
   gnucash/trunk/src/import-export/qif-import/assistant-qif-import.glade
   gnucash/trunk/src/import-export/qif-import/assistant-qif-import.h
   gnucash/trunk/src/import-export/qif-import/dialog-account-picker.c
   gnucash/trunk/src/import-export/qif-import/dialog-account-picker.glade
   gnucash/trunk/src/import-export/qif-import/dialog-account-picker.h
   gnucash/trunk/src/import-export/qif-import/file-format.txt
   gnucash/trunk/src/import-export/qif-import/gnc-plugin-qif-import-ui.xml
   gnucash/trunk/src/import-export/qif-import/gnc-plugin-qif-import.c
   gnucash/trunk/src/import-export/qif-import/gnc-plugin-qif-import.h
   gnucash/trunk/src/import-export/qif-import/gncmod-qif-import.c
   gnucash/trunk/src/import-export/qif-import/gschemas/Makefile.am
   gnucash/trunk/src/import-export/qif-import/gschemas/org.gnucash.dialogs.import.qif.gschema.xml.in.in
   gnucash/trunk/src/import-export/qif-import/qif-dialog-utils.scm
   gnucash/trunk/src/import-export/qif-import/qif-file.scm
   gnucash/trunk/src/import-export/qif-import/qif-guess-map.scm
   gnucash/trunk/src/import-export/qif-import/qif-import.scm
   gnucash/trunk/src/import-export/qif-import/qif-merge-groups.scm
   gnucash/trunk/src/import-export/qif-import/qif-objects.scm
   gnucash/trunk/src/import-export/qif-import/qif-parse.scm
   gnucash/trunk/src/import-export/qif-import/qif-to-gnc.scm
   gnucash/trunk/src/import-export/qif-import/qif-utils.scm
   gnucash/trunk/src/import-export/qif-import/test/Makefile.am
   gnucash/trunk/src/import-export/qif-import/test/test-link.c
Modified:
   gnucash/trunk/configure.ac
   gnucash/trunk/po/POTFILES.in
   gnucash/trunk/po/POTFILES.skip
   gnucash/trunk/src/import-export/Makefile.am
Log:
Rename some directories in src/import-export

The gschema.xml.in.in pathnames were too long for versions with more than
5 characters, e.g. 2.5.10, so tar was rejecting them. aqbanking, csv-import,
csv-export, and qif-import are now aqb, csv-imp, csv-exp, and qif-imp,
respectively.

Modified: gnucash/trunk/configure.ac
===================================================================
--- gnucash/trunk/configure.ac	2013-12-15 17:20:10 UTC (rev 23566)
+++ gnucash/trunk/configure.ac	2013-12-15 17:21:20 UTC (rev 23567)
@@ -779,7 +779,7 @@
   AC_SUBST(AQBANKING_LIBS)
   AC_SUBST(AQBANKING_CFLAGS)
   _COMPONENTS="$_COMPONENTS aqbanking"
-  MIGRATABLE_PREFS_AQBANKING="$srcdir/src/import-export/aqbanking/migratable-prefs-aqbanking.xml"
+  MIGRATABLE_PREFS_AQBANKING="$srcdir/src/import-export/aqb/migratable-prefs-aqbanking.xml"
 fi
 AM_CONDITIONAL([WITH_AQBANKING], [test x${want_aqbanking} = xyes])
 AC_SUBST_FILE([MIGRATABLE_PREFS_AQBANKING])
@@ -1397,21 +1397,21 @@
   src/import-export/Makefile
   src/import-export/test/Makefile
   src/import-export/ofx/gschemas/Makefile
-  src/import-export/qif-import/Makefile
+  src/import-export/qif-imp/Makefile
   src/import-export/qif/Makefile
   src/import-export/qif/test/Makefile
-  src/import-export/qif-import/gschemas/Makefile
-  src/import-export/qif-import/test/Makefile
+  src/import-export/qif-imp/gschemas/Makefile
+  src/import-export/qif-imp/test/Makefile
   src/import-export/gschemas/Makefile
   src/import-export/ofx/Makefile
   src/import-export/ofx/test/Makefile
-  src/import-export/csv-import/Makefile
-  src/import-export/csv-import/gschemas/Makefile
-  src/import-export/csv-export/Makefile
-  src/import-export/csv-export/gschemas/Makefile
+  src/import-export/csv-imp/Makefile
+  src/import-export/csv-imp/gschemas/Makefile
+  src/import-export/csv-exp/Makefile
+  src/import-export/csv-exp/gschemas/Makefile
   src/import-export/log-replay/Makefile
-  src/import-export/aqbanking/Makefile
-  src/import-export/aqbanking/gschemas/Makefile
+  src/import-export/aqb/Makefile
+  src/import-export/aqb/gschemas/Makefile
   src/libqof/Makefile
   src/libqof/qof/Makefile
   src/libqof/qof/test/Makefile
@@ -1487,12 +1487,12 @@
   src/gnome/gschemas/org.gnucash.window.pages.gschema.xml.in
   src/gnome-utils/gschemas/org.gnucash.history.gschema.xml.in
   src/gnome-utils/gschemas/org.gnucash.warnings.gschema.xml.in
-  src/import-export/aqbanking/gschemas/org.gnucash.dialogs.import.hbci.gschema.xml.in
-  src/import-export/csv-export/gschemas/org.gnucash.dialogs.export.csv.gschema.xml.in
-  src/import-export/csv-import/gschemas/org.gnucash.dialogs.import.csv.gschema.xml.in
+  src/import-export/aqb/gschemas/org.gnucash.dialogs.import.hbci.gschema.xml.in
+  src/import-export/csv-exp/gschemas/org.gnucash.dialogs.export.csv.gschema.xml.in
+  src/import-export/csv-imp/gschemas/org.gnucash.dialogs.import.csv.gschema.xml.in
   src/import-export/gschemas/org.gnucash.dialogs.import.generic.gschema.xml.in
   src/import-export/ofx/gschemas/org.gnucash.dialogs.import.ofx.gschema.xml.in
-  src/import-export/qif-import/gschemas/org.gnucash.dialogs.import.qif.gschema.xml.in
+  src/import-export/qif-imp/gschemas/org.gnucash.dialogs.import.qif.gschema.xml.in
   dnl # Please read doc/build-system before adding *anything* here
   ,
   dnl # init-commands go here

Modified: gnucash/trunk/po/POTFILES.in
===================================================================
--- gnucash/trunk/po/POTFILES.in	2013-12-15 17:20:10 UTC (rev 23566)
+++ gnucash/trunk/po/POTFILES.in	2013-12-15 17:21:20 UTC (rev 23567)
@@ -362,39 +362,39 @@
 src/html/gnc-html-history.c
 src/html/gnc-html-webkit.c
 src/html/gncmod-html.c
-src/import-export/aqbanking/assistant-ab-initial.c
-src/import-export/aqbanking/assistant-ab-initial.glade
-src/import-export/aqbanking/dialog-ab-daterange.c
-src/import-export/aqbanking/dialog-ab.glade
-src/import-export/aqbanking/dialog-ab-trans.c
-src/import-export/aqbanking/gnc-ab-getbalance.c
-src/import-export/aqbanking/gnc-ab-gettrans.c
-src/import-export/aqbanking/gnc-ab-kvp.c
-src/import-export/aqbanking/gnc-ab-transfer.c
-src/import-export/aqbanking/gnc-ab-trans-templ.c
-src/import-export/aqbanking/gnc-ab-utils.c
-src/import-export/aqbanking/gnc-file-aqb-import.c
-src/import-export/aqbanking/gnc-gwen-gui.c
-src/import-export/aqbanking/gncmod-aqbanking.c
-src/import-export/aqbanking/gnc-plugin-aqbanking.c
-[type: gettext/gsettings]src/import-export/aqbanking/gschemas/org.gnucash.dialogs.import.hbci.gschema.xml.in.in
-src/import-export/csv-export/assistant-csv-export.c
-src/import-export/csv-export/assistant-csv-export.glade
-src/import-export/csv-export/csv-transactions-export.c
-src/import-export/csv-export/csv-tree-export.c
-src/import-export/csv-export/gncmod-csv-export.c
-src/import-export/csv-export/gnc-plugin-csv-export.c
-[type: gettext/gsettings]src/import-export/csv-export/gschemas/org.gnucash.dialogs.export.csv.gschema.xml.in.in
-src/import-export/csv-import/assistant-csv-account-import.c
-src/import-export/csv-import/assistant-csv-account-import.glade
-src/import-export/csv-import/assistant-csv-trans-import.c
-src/import-export/csv-import/assistant-csv-trans-import.glade
-src/import-export/csv-import/csv-account-import.c
-src/import-export/csv-import/gnc-csv-gnumeric-popup.c
-src/import-export/csv-import/gnc-csv-model.c
-src/import-export/csv-import/gncmod-csv-import.c
-src/import-export/csv-import/gnc-plugin-csv-import.c
-[type: gettext/gsettings]src/import-export/csv-import/gschemas/org.gnucash.dialogs.import.csv.gschema.xml.in.in
+src/import-export/aqb/assistant-ab-initial.c
+src/import-export/aqb/assistant-ab-initial.glade
+src/import-export/aqb/dialog-ab-daterange.c
+src/import-export/aqb/dialog-ab.glade
+src/import-export/aqb/dialog-ab-trans.c
+src/import-export/aqb/gnc-ab-getbalance.c
+src/import-export/aqb/gnc-ab-gettrans.c
+src/import-export/aqb/gnc-ab-kvp.c
+src/import-export/aqb/gnc-ab-transfer.c
+src/import-export/aqb/gnc-ab-trans-templ.c
+src/import-export/aqb/gnc-ab-utils.c
+src/import-export/aqb/gnc-file-aqb-import.c
+src/import-export/aqb/gnc-gwen-gui.c
+src/import-export/aqb/gncmod-aqbanking.c
+src/import-export/aqb/gnc-plugin-aqbanking.c
+[type: gettext/gsettings]src/import-export/aqb/gschemas/org.gnucash.dialogs.import.hbci.gschema.xml.in.in
+src/import-export/csv-exp/assistant-csv-export.c
+src/import-export/csv-exp/assistant-csv-export.glade
+src/import-export/csv-exp/csv-transactions-export.c
+src/import-export/csv-exp/csv-tree-export.c
+src/import-export/csv-exp/gncmod-csv-export.c
+src/import-export/csv-exp/gnc-plugin-csv-export.c
+[type: gettext/gsettings]src/import-export/csv-exp/gschemas/org.gnucash.dialogs.export.csv.gschema.xml.in.in
+src/import-export/csv-imp/assistant-csv-account-import.c
+src/import-export/csv-imp/assistant-csv-account-import.glade
+src/import-export/csv-imp/assistant-csv-trans-import.c
+src/import-export/csv-imp/assistant-csv-trans-import.glade
+src/import-export/csv-imp/csv-account-import.c
+src/import-export/csv-imp/gnc-csv-gnumeric-popup.c
+src/import-export/csv-imp/gnc-csv-model.c
+src/import-export/csv-imp/gncmod-csv-import.c
+src/import-export/csv-imp/gnc-plugin-csv-import.c
+[type: gettext/gsettings]src/import-export/csv-imp/gschemas/org.gnucash.dialogs.import.csv.gschema.xml.in.in
 src/import-export/dialog-import.glade
 src/import-export/gncmod-generic-import.c
 [type: gettext/gsettings]src/import-export/gschemas/org.gnucash.dialogs.import.generic.gschema.xml.in.in
@@ -416,13 +416,13 @@
 src/import-export/ofx/gnc-ofx-kvp.c
 src/import-export/ofx/gnc-plugin-ofx.c
 [type: gettext/gsettings]src/import-export/ofx/gschemas/org.gnucash.dialogs.import.ofx.gschema.xml.in.in
-src/import-export/qif-import/assistant-qif-import.c
-src/import-export/qif-import/assistant-qif-import.glade
-src/import-export/qif-import/dialog-account-picker.c
-src/import-export/qif-import/dialog-account-picker.glade
-src/import-export/qif-import/gncmod-qif-import.c
-src/import-export/qif-import/gnc-plugin-qif-import.c
-[type: gettext/gsettings]src/import-export/qif-import/gschemas/org.gnucash.dialogs.import.qif.gschema.xml.in.in
+src/import-export/qif-imp/assistant-qif-import.c
+src/import-export/qif-imp/assistant-qif-import.glade
+src/import-export/qif-imp/dialog-account-picker.c
+src/import-export/qif-imp/dialog-account-picker.glade
+src/import-export/qif-imp/gncmod-qif-import.c
+src/import-export/qif-imp/gnc-plugin-qif-import.c
+[type: gettext/gsettings]src/import-export/qif-imp/gschemas/org.gnucash.dialogs.import.qif.gschema.xml.in.in
 src/import-export/qif/qif-context.c
 src/import-export/qif/qif-file.c
 src/import-export/qif/qif-objects.c

Modified: gnucash/trunk/po/POTFILES.skip
===================================================================
--- gnucash/trunk/po/POTFILES.skip	2013-12-15 17:20:10 UTC (rev 23566)
+++ gnucash/trunk/po/POTFILES.skip	2013-12-15 17:21:20 UTC (rev 23567)
@@ -30,16 +30,16 @@
 src/app-utils/date-utilities.scm
 src/app-utils/gnucash/app-utils.scm
 src/app-utils/prefs.scm
-src/import-export/qif-import/qif-dialog-utils.scm
-src/import-export/qif-import/qif-file.scm
-src/import-export/qif-import/qif-import/qif-dialog-utils.scm
-src/import-export/qif-import/qif-import/qif-file.scm
-src/import-export/qif-import/qif-import/qif-merge-groups.scm
-src/import-export/qif-import/qif-import/qif-parse.scm
-src/import-export/qif-import/qif-import/qif-to-gnc.scm
-src/import-export/qif-import/qif-merge-groups.scm
-src/import-export/qif-import/qif-parse.scm
-src/import-export/qif-import/qif-to-gnc.scm
+src/import-export/qif-imp/qif-dialog-utils.scm
+src/import-export/qif-imp/qif-file.scm
+src/import-export/qif-imp/qif-import/qif-dialog-utils.scm
+src/import-export/qif-imp/qif-import/qif-file.scm
+src/import-export/qif-imp/qif-import/qif-merge-groups.scm
+src/import-export/qif-imp/qif-import/qif-parse.scm
+src/import-export/qif-imp/qif-import/qif-to-gnc.scm
+src/import-export/qif-imp/qif-merge-groups.scm
+src/import-export/qif-imp/qif-parse.scm
+src/import-export/qif-imp/qif-to-gnc.scm
 src/report/business-reports/aging.scm
 src/report/business-reports/balsheet-eg.eguile.scm
 src/report/business-reports/balsheet-eg.scm

Modified: gnucash/trunk/src/import-export/Makefile.am
===================================================================
--- gnucash/trunk/src/import-export/Makefile.am	2013-12-15 17:20:10 UTC (rev 23566)
+++ gnucash/trunk/src/import-export/Makefile.am	2013-12-15 17:21:20 UTC (rev 23567)
@@ -2,10 +2,10 @@
     OFX_DIR=ofx
 endif
 if WITH_AQBANKING
-    AQBANKING_DIR=aqbanking
+    AQBANKING_DIR=aqb
 endif
-SUBDIRS = . gschemas qif qif-import \
-	${OFX_DIR} ${AQBANKING_DIR} log-replay test csv-import csv-export
+SUBDIRS = . gschemas qif qif-imp \
+	${OFX_DIR} ${AQBANKING_DIR} log-replay test csv-imp csv-exp
 
 pkglib_LTLIBRARIES=libgncmod-generic-import.la
 

Copied: gnucash/trunk/src/import-export/aqb/CMakeLists.txt (from rev 23566, gnucash/trunk/src/import-export/aqbanking/CMakeLists.txt)
===================================================================
--- gnucash/trunk/src/import-export/aqb/CMakeLists.txt	                        (rev 0)
+++ gnucash/trunk/src/import-export/aqb/CMakeLists.txt	2013-12-15 17:21:20 UTC (rev 23567)
@@ -0,0 +1,41 @@
+# CMakeLists.txt for src/import-export/aqbanking
+
+# ############################################################
+
+ADD_DEFINITIONS (-DG_LOG_DOMAIN=\"gnc.import.aqbanking\")
+
+INCLUDE_DIRECTORIES (${GLIB2_INCLUDE_DIRS})
+INCLUDE_DIRECTORIES (${GCONF2_INCLUDE_DIRS})
+#INCLUDE_DIRECTORIES (${LIBINTL_INCLUDE_PATH})
+#INCLUDE_DIRECTORIES (${REGEX_INCLUDE_PATH})
+#INCLUDE_DIRECTORIES (${GUILE_INCLUDE_DIRS})
+INCLUDE_DIRECTORIES (${GWENHYWFAR_INCLUDE_DIRS})
+INCLUDE_DIRECTORIES (${AQBANKING_INCLUDE_DIRS})
+INCLUDE_DIRECTORIES (${CMAKE_BINARY_DIR}/src ) # for config.h
+INCLUDE_DIRECTORIES (${CMAKE_SOURCE_DIR}/lib/libc) # for pow.h
+INCLUDE_DIRECTORIES (${CMAKE_SOURCE_DIR}/src ) # for gnc-ui.h
+INCLUDE_DIRECTORIES (${CMAKE_SOURCE_DIR}/src/libqof/qof) # for qof.h
+INCLUDE_DIRECTORIES (${CMAKE_SOURCE_DIR}/src/gnc-module) # for gnc-module.h
+INCLUDE_DIRECTORIES (${CMAKE_SOURCE_DIR}/src/core-utils) # for gnc-glib-utils.h
+INCLUDE_DIRECTORIES (${CMAKE_SOURCE_DIR}/src/engine)
+INCLUDE_DIRECTORIES (${CMAKE_SOURCE_DIR}/src/app-utils)
+
+SET (libgnc_aqbanking_SOURCES
+  gnc-ab-kvp.c
+#  gnc-ab-utils.c
+#  gnc-gwen-gui.c
+)
+
+# Add dependency on config.h
+SET_SOURCE_FILES_PROPERTIES (${libgnc_aqbanking_SOURCES} PROPERTIES OBJECT_DEPENDS ${CONFIG_H})
+
+SET (libgnc_aqbanking_HEADERS
+  gnc-ab-kvp.h
+#  gnc-ab-utils.h
+#  gnc-gwen-gui.h
+)
+
+ADD_LIBRARY (gnc-aqbanking
+  ${libgnc_aqbanking_SOURCES}
+  ${libgnc_aqbanking_HEADERS}
+  )

Copied: gnucash/trunk/src/import-export/aqb/Makefile.am (from rev 23566, gnucash/trunk/src/import-export/aqbanking/Makefile.am)
===================================================================
--- gnucash/trunk/src/import-export/aqb/Makefile.am	                        (rev 0)
+++ gnucash/trunk/src/import-export/aqb/Makefile.am	2013-12-15 17:21:20 UTC (rev 23567)
@@ -0,0 +1,80 @@
+SUBDIRS = . gschemas
+
+pkglib_LTLIBRARIES = libgncmod-aqbanking.la
+
+libgncmod_aqbanking_la_SOURCES = \
+  dialog-ab-trans.c \
+  dialog-ab-daterange.c \
+  assistant-ab-initial.c \
+  gnc-ab-getbalance.c \
+  gnc-ab-gettrans.c \
+  gnc-ab-kvp.c \
+  gnc-ab-trans-templ.c \
+  gnc-ab-transfer.c \
+  gnc-ab-utils.c \
+  gnc-file-aqb-import.c \
+  gnc-gwen-gui.c \
+  gnc-plugin-aqbanking.c \
+  gncmod-aqbanking.c
+
+noinst_HEADERS = \
+  dialog-ab-trans.h \
+  dialog-ab-daterange.h \
+  assistant-ab-initial.h \
+  gnc-ab-getbalance.h \
+  gnc-ab-gettrans.h \
+  gnc-ab-kvp.h \
+  gnc-ab-trans-templ.h \
+  gnc-ab-transfer.h \
+  gnc-ab-utils.h \
+  gnc-file-aqb-import.h \
+  gnc-gwen-gui.h \
+  gnc-plugin-aqbanking.h
+
+libgncmod_aqbanking_la_LDFLAGS = -avoid-version
+if OS_WIN32
+libgncmod_aqbanking_la_LDFLAGS += -export-symbols-regex .*
+endif
+libgncmod_aqbanking_la_LIBADD = \
+  ${top_builddir}/src/import-export/libgncmod-generic-import.la \
+  ${top_builddir}/src/gnome/libgnc-gnome.la \
+  ${top_builddir}/src/gnome-utils/libgncmod-gnome-utils.la \
+  ${top_builddir}/src/app-utils/libgncmod-app-utils.la \
+  ${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/libqof/qof/libgnc-qof.la \
+  ${GTK_LIBS} \
+  ${GLIB_LIBS} \
+  ${GWENGUI_GTK2_LIBS} \
+  ${AQBANKING_LIBS}
+
+AM_CPPFLAGS = \
+  -I${top_srcdir}/src \
+  -I${top_srcdir}/src/import-export \
+  -I${top_srcdir}/src/gnome \
+  -I${top_srcdir}/src/register/ledger-core \
+  -I${top_srcdir}/src/register/register-gnome \
+  -I${top_srcdir}/src/register/register-core \
+  -I${top_srcdir}/src/gnome-utils \
+  -I${top_srcdir}/src/app-utils \
+  -I${top_srcdir}/src/engine \
+  -I${top_srcdir}/src/core-utils \
+  -I${top_srcdir}/src/gnc-module \
+  -I${top_srcdir}/src/libqof/qof \
+  ${GTK_CFLAGS} \
+  ${GLIB_CFLAGS} \
+  ${AQBANKING_CFLAGS}
+
+uidir = $(GNC_UI_DIR)
+ui_DATA = \
+  gnc-plugin-aqbanking-ui.xml
+
+gtkbuilderdir = $(GNC_GTKBUILDER_DIR)
+gtkbuilder_DATA = \
+  assistant-ab-initial.glade \
+  dialog-ab.glade
+
+EXTRA_DIST = ${ui_DATA} ${gtkbuilder_DATA} migratable-prefs-aqbanking.xml
+
+AM_CPPFLAGS += -DG_LOG_DOMAIN=\"gnc.import.aqbanking\"

Copied: gnucash/trunk/src/import-export/aqb/assistant-ab-initial.c (from rev 23566, gnucash/trunk/src/import-export/aqbanking/assistant-ab-initial.c)
===================================================================
--- gnucash/trunk/src/import-export/aqb/assistant-ab-initial.c	                        (rev 0)
+++ gnucash/trunk/src/import-export/aqb/assistant-ab-initial.c	2013-12-15 17:21:20 UTC (rev 23567)
@@ -0,0 +1,915 @@
+/*
+ * assistant-ab-initial.c -- Initialise the AqBanking wizard
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, contact:
+ *
+ * Free Software Foundation           Voice:  +1-617-542-5942
+ * 51 Franklin Street, Fifth Floor    Fax:    +1-617-542-2652
+ * Boston, MA  02110-1301,  USA       gnu at gnu.org
+ */
+
+/**
+ * @internal
+ * @file assistant-ab-initial.c
+ * @brief AqBanking setup functionality
+ * @author Copyright (C) 2002 Christian Stimming <stimming at tuhh.de>
+ * @author Copyright (C) 2006 David Hampton <hampton at employees.org>
+ * @author Copyright (C) 2008 Andreas Koehler <andi5.py at gmx.net>
+ * @author Copyright (C) 2011 Robert Fewell
+ */
+
+#include "config.h"
+
+#include <aqbanking/banking.h>
+#include <glib.h>
+#include <glib/gi18n.h>
+#include <glib/gstdio.h>
+#include <gdk/gdkkeysyms.h>
+#ifdef HAVE_SYS_WAIT_H
+#    include <sys/wait.h>
+#endif
+#include <fcntl.h>
+#include <unistd.h>
+
+#include "dialog-utils.h"
+#include "assistant-ab-initial.h"
+#include "assistant-utils.h"
+#include "gnc-ab-kvp.h"
+#include "gnc-ab-utils.h"
+#include "gnc-component-manager.h"
+#include "gnc-glib-utils.h"
+#include "gnc-ui.h"
+#include "gnc-ui-util.h"
+#include "gnc-session.h"
+#include "import-account-matcher.h"
+
+#if AQBANKING_VERSION_INT > 49908
+/* For aqbanking > 4.99.8. See below. */
+# include <aqbanking/dlg_setup.h>
+#endif
+
+/* This static indicates the debugging module that this .o belongs to.  */
+static QofLogModule log_module = GNC_MOD_ASSISTANT;
+
+#define GNC_PREFS_GROUP "dialogs.ab-initial"
+#define ASSISTANT_AB_INITIAL_CM_CLASS "assistant-ab-initial"
+
+typedef struct _ABInitialInfo ABInitialInfo;
+typedef struct _DeferredInfo DeferredInfo;
+typedef struct _AccCbData AccCbData;
+typedef struct _RevLookupData RevLookupData;
+
+void aai_on_prepare (GtkAssistant  *assistant, GtkWidget *page,
+                     gpointer user_data);
+
+void aai_on_finish (GtkAssistant *gtkassistant, gpointer user_data);
+void aai_on_cancel (GtkAssistant *assistant, gpointer user_data);
+void aai_destroy_cb(GtkObject *object, gpointer user_data);
+
+gboolean aai_key_press_event_cb(GtkWidget *widget, GdkEventKey *event, gpointer user_data);
+
+void aai_wizard_page_prepare (GtkAssistant *assistant, gpointer user_data);
+void aai_wizard_button_clicked_cb(GtkButton *button, gpointer user_data);
+
+void aai_match_page_prepare (GtkAssistant *assistant, gpointer user_data);
+
+static gboolean banking_has_accounts(AB_BANKING *banking);
+static void hash_from_kvp_acc_cb(Account *gnc_acc, gpointer user_data);
+#if AQBANKING_VERSION_INT <= 49908
+static void child_exit_cb(GPid pid, gint status, gpointer data);
+#endif
+static gchar *ab_account_longname(const AB_ACCOUNT *ab_acc);
+static AB_ACCOUNT *update_account_list_acc_cb(AB_ACCOUNT *ab_acc, gpointer user_data);
+static void update_account_list(ABInitialInfo *info);
+static gboolean find_gnc_acc_cb(gpointer key, gpointer value, gpointer user_data);
+static gboolean clear_line_cb(GtkTreeModel *model, GtkTreePath *path, GtkTreeIter *iter, gpointer user_data);
+static void account_list_clicked_cb (GtkTreeView *view, GtkTreePath *path,
+                                     GtkTreeViewColumn  *col, gpointer user_data);
+static void clear_kvp_acc_cb(Account *gnc_acc, gpointer user_data);
+static void save_kvp_acc_cb(gpointer key, gpointer value, gpointer user_data);
+static void aai_close_handler(gpointer user_data);
+
+struct _ABInitialInfo
+{
+    GtkWidget *window;
+    GtkWidget *assistant;
+
+    /* account match page */
+    gboolean match_page_prepared;
+    GtkTreeView *account_view;
+    GtkListStore *account_store;
+
+    /* managed by child_exit_cb */
+    DeferredInfo *deferred_info;
+
+    /* AqBanking stuff */
+    AB_BANKING *api;
+    /* AB_ACCOUNT* -> Account* -- DO NOT DELETE THE KEYS! */
+    GHashTable *gnc_hash;
+};
+
+struct _DeferredInfo
+{
+    ABInitialInfo *initial_info;
+    gchar *wizard_path;
+    gboolean qt_probably_unavailable;
+};
+
+struct _AccCbData
+{
+    AB_BANKING *api;
+    GHashTable *hash;
+};
+
+struct _RevLookupData
+{
+    Account *gnc_acc;
+    AB_ACCOUNT *ab_acc;
+};
+
+enum account_list_cols
+{
+    ACCOUNT_LIST_COL_INDEX = 0,
+    ACCOUNT_LIST_COL_AB_NAME,
+    ACCOUNT_LIST_COL_AB_ACCT,
+    ACCOUNT_LIST_COL_GNC_NAME,
+    ACCOUNT_LIST_COL_CHECKED,
+    NUM_ACCOUNT_LIST_COLS
+};
+
+gboolean
+aai_key_press_event_cb(GtkWidget *widget, GdkEventKey *event, gpointer user_data)
+{
+    if (event->keyval == GDK_Escape)
+    {
+        gtk_widget_destroy(widget);
+        return TRUE;
+    }
+    else
+    {
+        return FALSE;
+    }
+}
+
+void
+aai_on_cancel (GtkAssistant *gtkassistant, gpointer user_data)
+{
+    ABInitialInfo *info = user_data;
+
+    gtk_widget_destroy(info->window);
+}
+
+void
+aai_destroy_cb(GtkObject *object, gpointer user_data)
+{
+    ABInitialInfo *info = user_data;
+
+    gnc_unregister_gui_component_by_data(ASSISTANT_AB_INITIAL_CM_CLASS, info);
+
+    if (info->deferred_info)
+    {
+        g_message("Online Banking assistant is being closed but the wizard is still "
+                  "running.  Inoring.");
+
+        /* Tell child_exit_cb() that there is no assistant anymore */
+        info->deferred_info->initial_info = NULL;
+    }
+
+    if (info->gnc_hash)
+    {
+#ifdef AQBANKING_VERSION_4_EXACTLY
+        AB_Banking_OnlineFini(info->api, 0);
+#else
+        AB_Banking_OnlineFini(info->api);
+#endif
+        g_hash_table_destroy(info->gnc_hash);
+        info->gnc_hash = NULL;
+    }
+
+    if (info->api)
+    {
+        gnc_AB_BANKING_delete(info->api);
+        info->api = NULL;
+    }
+
+    gtk_widget_destroy(info->window);
+    info->window = NULL;
+
+    g_free(info);
+}
+
+void
+aai_wizard_page_prepare (GtkAssistant *assistant, gpointer user_data)
+{
+    ABInitialInfo *info = user_data;
+    gint num = gtk_assistant_get_current_page (assistant);
+    GtkWidget *page = gtk_assistant_get_nth_page (assistant, num);
+
+    g_return_if_fail(info->api);
+
+    /* Enable the Assistant Buttons if we accounts */
+    if (banking_has_accounts(info->api))
+        gtk_assistant_set_page_complete (assistant, page, TRUE);
+    else
+        gtk_assistant_set_page_complete (assistant, page, FALSE);
+}
+
+void
+aai_wizard_button_clicked_cb(GtkButton *button, gpointer user_data)
+{
+    ABInitialInfo *info = user_data;
+    gint num = gtk_assistant_get_current_page (GTK_ASSISTANT(info->window));
+    GtkWidget *page = gtk_assistant_get_nth_page (GTK_ASSISTANT(info->window), num);
+
+    AB_BANKING *banking = info->api;
+#if AQBANKING_VERSION_INT <= 49908
+    GWEN_BUFFER *buf;
+    gboolean wizard_exists;
+    const gchar *wizard_path;
+    gboolean qt_probably_unavailable = FALSE;
+#endif /* AQBANKING_VERSION_INT */
+    g_return_if_fail(banking);
+
+    ENTER("user_data: %p", user_data);
+
+    if (info->deferred_info)
+    {
+        LEAVE("Wizard is still running");
+        return;
+    }
+
+#if AQBANKING_VERSION_INT > 49908
+    /* For aqbanking5 > 4.99.8: Use AB_Banking_GetNewUserDialog(). */
+    {
+        GWEN_DIALOG *dlg =
+            AB_SetupDialog_new(banking);
+
+        if (AB_Banking_OnlineInit(banking) != 0)
+        {
+            PERR("Got error on AB_Banking_OnlineInit!");
+        }
+
+        if (!dlg)
+        {
+            PERR("Could not lookup Setup Dialog of aqbanking!");
+        }
+        else
+        {
+            int rv = GWEN_Gui_ExecDialog(dlg, 0);
+            if (rv <= 0)
+            {
+                /* Dialog was aborted/rejected */
+                PERR("Setup Dialog of aqbanking aborted/rejected !");
+            }
+            GWEN_Dialog_free(dlg);
+        }
+
+        if (AB_Banking_OnlineFini(banking) != 0)
+        {
+            PERR("Got error on AB_Banking_OnlineFini!");
+        }
+    }
+#else
+    /* Previous implementation for aqbanking <= 4.99.8: Use the
+     * external application. */
+
+
+    /* This is the point where we look for and start an external
+     * application shipped with aqbanking that contains the setup assistant
+     * for AqBanking related stuff.  It requires qt (but not kde).  This
+     * application contains the very verbose step-by-step setup wizard
+     * for the AqBanking account, and the application is shared with
+     * other AqBanking-based financial managers that offer the AqBanking
+     * features (e.g. KMyMoney).  See gnucash-devel discussion here
+     * https://lists.gnucash.org/pipermail/gnucash-devel/2004-December/012351.html
+     */
+    buf = GWEN_Buffer_new(NULL, 300, 0, 0);
+    AB_Banking_FindWizard(banking, "", NULL, buf);
+    wizard_exists = *GWEN_Buffer_GetStart(buf) != 0;
+    wizard_path = GWEN_Buffer_GetStart(buf);
+
+    if (wizard_exists)
+    {
+        /* Really check whether the file exists */
+        gint fd = g_open(wizard_path, O_RDONLY, 0);
+        if (fd == -1)
+            wizard_exists = FALSE;
+        else
+            close(fd);
+    }
+
+#ifdef G_OS_WIN32
+    {
+        const char *check_file = "qtdemo.exe";
+        gchar *found_program = g_find_program_in_path(check_file);
+        if (found_program)
+        {
+            g_debug("Yes, we found the Qt demo program in %s\n", found_program);
+            g_free(found_program);
+        }
+        else
+        {
+            g_warning("Ouch, no Qt demo program was found. Qt not installed?\n");
+            qt_probably_unavailable = TRUE;
+        }
+    }
+#endif
+
+    if (wizard_exists)
+    {
+        /* Call the qt wizard. See the note above about why this
+         * approach is chosen. */
+
+        GPid pid;
+        GError *error = NULL;
+        gchar *argv[2];
+        gboolean spawned;
+
+        argv[0] = g_strdup (wizard_path);
+        argv[1] = NULL;
+        spawned = g_spawn_async (NULL, argv, NULL, G_SPAWN_DO_NOT_REAP_CHILD,
+                                 NULL, NULL, &pid, &error);
+        g_free (argv[0]);
+
+        if (error)
+            g_critical(
+                "Error on starting AqBanking setup wizard: Code %d: %s",
+                error->code, error->message ? error->message : "(null)");
+
+        if (!spawned)
+        {
+            g_critical("Could not start AqBanking setup wizard: %s",
+                       error->message ? error->message : "(null)");
+            g_error_free (error);
+        }
+        else
+        {
+            /* Keep a reference to info that can survive info */
+            info->deferred_info = g_new0(DeferredInfo, 1);
+            info->deferred_info->initial_info = info;
+            info->deferred_info->wizard_path = g_strdup(wizard_path);
+            info->deferred_info->qt_probably_unavailable =
+                qt_probably_unavailable;
+
+            g_child_watch_add (pid, child_exit_cb, info->deferred_info);
+        }
+    }
+    else
+    {
+        g_warning("on_aqhbci_button: Oops, no aqhbci setup wizard found.");
+        gnc_error_dialog
+        (info->window,
+         _("The external program \"AqBanking Setup Wizard\" has not "
+           "been found. \n\n"
+           "The %s package should include the "
+           "program \"qt3-wizard\". Please check your installation to "
+           "ensure this program is present. On some distributions this "
+           "may require installing additional packages."),
+         QT3_WIZARD_PACKAGE);
+    }
+
+    GWEN_Buffer_free(buf);
+#endif
+
+    /* Enable the Assistant Buttons if we accounts */
+    if (banking_has_accounts(info->api))
+        gtk_assistant_set_page_complete (GTK_ASSISTANT(info->window), page, TRUE);
+    else
+        gtk_assistant_set_page_complete (GTK_ASSISTANT(info->window), page, FALSE);
+
+    LEAVE(" ");
+}
+
+void
+aai_match_page_prepare (GtkAssistant *assistant, gpointer user_data)
+{
+    ABInitialInfo *info = user_data;
+    gint num = gtk_assistant_get_current_page (assistant);
+    GtkWidget *page = gtk_assistant_get_nth_page (assistant, num);
+
+    Account *root;
+    AccCbData data;
+
+    g_return_if_fail(info && info->api);
+
+    /* Do not run this twice */
+    if (!info->match_page_prepared)
+    {
+        /* Load aqbanking accounts */
+#ifdef AQBANKING_VERSION_4_EXACTLY
+        AB_Banking_OnlineInit(info->api, 0);
+#else
+        AB_Banking_OnlineInit(info->api);
+#endif
+        /* Determine current mapping */
+        root = gnc_book_get_root_account(gnc_get_current_book());
+        info->gnc_hash = g_hash_table_new(&g_direct_hash, &g_direct_equal);
+        data.api = info->api;
+        data.hash = info->gnc_hash;
+        gnc_account_foreach_descendant(
+            root, (AccountCb) hash_from_kvp_acc_cb, &data);
+
+        info->match_page_prepared = TRUE;
+    }
+    /* Update the graphical representation */
+    update_account_list(info);
+
+    /* Enable the Assistant Buttons */
+    gtk_assistant_set_page_complete (assistant, page, TRUE);
+}
+
+void
+aai_on_finish (GtkAssistant *assistant, gpointer user_data)
+{
+    ABInitialInfo *info = user_data;
+    Account *root;
+
+    g_return_if_fail(info && info->gnc_hash);
+
+    /* Commit the changes */
+    root = gnc_book_get_root_account(gnc_get_current_book());
+    gnc_account_foreach_descendant(root, (AccountCb) clear_kvp_acc_cb, NULL);
+    g_hash_table_foreach(info->gnc_hash, (GHFunc) save_kvp_acc_cb, NULL);
+
+    gtk_widget_destroy(info->window);
+}
+
+static gboolean
+banking_has_accounts(AB_BANKING *banking)
+{
+    AB_ACCOUNT_LIST2 *accl;
+    gboolean result;
+
+    g_return_val_if_fail(banking, FALSE);
+
+#ifdef AQBANKING_VERSION_4_EXACTLY
+    AB_Banking_OnlineInit(banking, 0);
+#else
+    AB_Banking_OnlineInit(banking);
+#endif
+
+    accl = AB_Banking_GetAccounts(banking);
+    if (accl && (AB_Account_List2_GetSize(accl) > 0))
+        result = TRUE;
+    else
+        result = FALSE;
+
+    if (accl)
+        AB_Account_List2_free(accl);
+
+#ifdef AQBANKING_VERSION_4_EXACTLY
+    AB_Banking_OnlineFini(banking, 0);
+#else
+    AB_Banking_OnlineFini(banking);
+#endif
+
+    return result;
+}
+
+static void
+hash_from_kvp_acc_cb(Account *gnc_acc, gpointer user_data)
+{
+    AccCbData *data = user_data;
+    AB_ACCOUNT *ab_acc;
+
+    ab_acc = gnc_ab_get_ab_account(data->api, gnc_acc);
+    if (ab_acc)
+        g_hash_table_insert(data->hash, ab_acc, gnc_acc);
+}
+
+#if AQBANKING_VERSION_INT <= 49908
+static void
+child_exit_cb(GPid pid, gint status, gpointer data)
+{
+    DeferredInfo *deferred_info = data;
+    ABInitialInfo *info = deferred_info->initial_info;
+    gint num = gtk_assistant_get_current_page (GTK_ASSISTANT(info->window));
+    GtkWidget *page = gtk_assistant_get_nth_page (GTK_ASSISTANT(info->window), num);
+
+    gint exit_status;
+
+#ifdef G_OS_WIN32
+    exit_status = status;
+#else
+    exit_status = WEXITSTATUS(status);
+#endif
+
+    g_spawn_close_pid(pid);
+
+    if (!info)
+    {
+        g_message("Online Banking wizard exited, but the assistant has been "
+                  "destroyed already");
+        goto cleanup_child_exit_cb;
+    }
+
+    if (exit_status == 0)
+    {
+        gtk_assistant_set_page_complete (GTK_ASSISTANT(info->window), page, TRUE);
+    }
+    else
+    {
+        if (deferred_info->qt_probably_unavailable)
+        {
+            g_warning("on_aqhbci_button: Oops, aqhbci wizard return nonzero "
+                      "value: %d. The called program was \"%s\".\n",
+                      exit_status, deferred_info->wizard_path);
+            gnc_error_dialog
+            (info->window, "%s",
+             _("The external program \"AqBanking Setup Wizard\" failed "
+               "to run successfully because the "
+               "additional software \"Qt\" was not found. "
+               "Please install the \"Qt/Windows Open Source Edition\" "
+               "from Trolltech by downloading it from www.trolltech.com"
+               "\n\n"
+               "If you have installed Qt already, you will have to adapt "
+               "the PATH variable of your system appropriately. "
+               "Contact the GnuCash developers if you need further "
+               "assistance on how to install Qt correctly."
+               "\n\n"
+               "Online Banking cannot be setup without Qt. Press \"Close\" "
+               "now, then \"Cancel\" to cancel the Online Banking setup."));
+        }
+        else
+        {
+            g_warning("on_aqhbci_button: Oops, aqhbci wizard return nonzero "
+                      "value: %d. The called program was \"%s\".\n",
+                      exit_status, deferred_info->wizard_path);
+            gnc_error_dialog
+            (info->window, "%s",
+             _("The external program \"AqBanking Setup Wizard\" failed "
+               "to run successfully. Online Banking can only be setup "
+               "if this wizard has run successfully. "
+               "Please try running the \"AqBanking Setup Wizard\" again."));
+        }
+        gtk_assistant_set_page_complete (GTK_ASSISTANT(info->window), page, FALSE);
+    }
+
+cleanup_child_exit_cb:
+    g_free(deferred_info->wizard_path);
+    g_free(deferred_info);
+    if (info)
+        info->deferred_info = NULL;
+}
+#endif /* AQBANKING_VERSION_INT <= 49908 */
+
+static gchar *
+ab_account_longname(const AB_ACCOUNT *ab_acc)
+{
+    gchar *bankname;
+    gchar *result;
+    const char *ab_bankname, *bankcode;
+
+    g_return_val_if_fail(ab_acc, NULL);
+
+    ab_bankname = AB_Account_GetBankName(ab_acc);
+    bankname = ab_bankname ? gnc_utf8_strip_invalid_strdup(ab_bankname) : NULL;
+    bankcode = AB_Account_GetBankCode(ab_acc);
+
+    /* Translators: Strings are 1. Account code, 2. Bank name, 3. Bank code. */
+    if (bankname && *bankname)
+        result = g_strdup_printf(_("%s at %s (code %s)"),
+                                 AB_Account_GetAccountNumber(ab_acc),
+                                 bankname,
+                                 bankcode);
+    else
+        result = g_strdup_printf(_("%s at bank code %s"),
+                                 AB_Account_GetAccountNumber(ab_acc),
+                                 bankcode);
+    g_free(bankname);
+
+    return result;
+
+}
+
+static AB_ACCOUNT *
+update_account_list_acc_cb(AB_ACCOUNT *ab_acc, gpointer user_data)
+{
+    ABInitialInfo *info = user_data;
+    gchar *gnc_name, *ab_name;
+    Account *gnc_acc;
+    GtkTreeIter iter;
+
+    g_return_val_if_fail(ab_acc && info, NULL);
+
+    ab_name = ab_account_longname(ab_acc);
+
+    /* Get corresponding gnucash account */
+    gnc_acc = g_hash_table_lookup(info->gnc_hash, ab_acc);
+
+    /* Build the text for the gnucash account. */
+    if (gnc_acc)
+        gnc_name = gnc_account_get_full_name(gnc_acc);
+    else
+        gnc_name = g_strdup("");
+
+    /* Add item to the list store */
+    gtk_list_store_append(info->account_store, &iter);
+    gtk_list_store_set(info->account_store, &iter,
+                       ACCOUNT_LIST_COL_AB_NAME, ab_name,
+                       ACCOUNT_LIST_COL_AB_ACCT, ab_acc,
+                       ACCOUNT_LIST_COL_GNC_NAME, gnc_name,
+                       ACCOUNT_LIST_COL_CHECKED, FALSE,
+                       -1);
+    g_free(gnc_name);
+    g_free(ab_name);
+
+    return NULL;
+}
+
+static void
+update_account_list(ABInitialInfo *info)
+{
+    AB_ACCOUNT_LIST2 *acclist;
+
+    g_return_if_fail(info && info->api && info->gnc_hash);
+
+    /* Detach model from view while updating */
+    g_object_ref(info->account_store);
+    gtk_tree_view_set_model(info->account_view, NULL);
+
+    /* Refill the list */
+    gtk_list_store_clear(info->account_store);
+    acclist = AB_Banking_GetAccounts(info->api);
+    if (acclist)
+        AB_Account_List2_ForEach(acclist, update_account_list_acc_cb, info);
+    else
+        g_warning("update_account_list: Oops, account list from AB_Banking "
+                  "is NULL");
+
+    /* Attach model to view again */
+    gtk_tree_view_set_model(info->account_view,
+                            GTK_TREE_MODEL(info->account_store));
+
+    g_object_unref(info->account_store);
+}
+
+static gboolean
+find_gnc_acc_cb(gpointer key, gpointer value, gpointer user_data)
+{
+    RevLookupData *data = user_data;
+
+    g_return_val_if_fail(data, TRUE);
+
+    if (value == data->gnc_acc)
+    {
+        data->ab_acc = (AB_ACCOUNT*) key;
+        return TRUE;
+    }
+    return FALSE;
+}
+
+static gboolean
+clear_line_cb(GtkTreeModel *model, GtkTreePath *path, GtkTreeIter *iter,
+              gpointer user_data)
+{
+    RevLookupData *data = user_data;
+    GtkListStore *store = GTK_LIST_STORE(model);
+    gpointer ab_acc;
+
+    g_return_val_if_fail(data && store, FALSE);
+
+    gtk_tree_model_get(model, iter, ACCOUNT_LIST_COL_AB_ACCT, &ab_acc, -1);
+
+    if (ab_acc == data->ab_acc)
+    {
+        gtk_list_store_set(store, iter, ACCOUNT_LIST_COL_GNC_NAME, "",
+                           ACCOUNT_LIST_COL_CHECKED, TRUE, -1);
+        return TRUE;
+    }
+    return FALSE;
+}
+
+static void
+account_list_clicked_cb (GtkTreeView *view, GtkTreePath *path,
+                         GtkTreeViewColumn  *col, gpointer user_data)
+{
+    ABInitialInfo *info = user_data;
+    GtkTreeModel *model;
+    GtkTreeIter iter;
+    AB_ACCOUNT *ab_acc;
+    gchar *longname, *gnc_name;
+    Account *old_value, *gnc_acc;
+    const gchar *currency;
+    gnc_commodity *commodity = NULL;
+    gboolean ok_pressed;
+
+    g_return_if_fail(info);
+
+    PINFO("Row has been double-clicked.");
+
+    model = gtk_tree_view_get_model(view);
+
+    if (!gtk_tree_model_get_iter(model, &iter, path))
+        return; /* path describes a non-existing row - should not happen */
+
+    gtk_tree_model_get(model, &iter, ACCOUNT_LIST_COL_AB_ACCT, &ab_acc, -1);
+
+    if (ab_acc)
+    {
+        old_value = g_hash_table_lookup(info->gnc_hash, ab_acc);
+
+        longname = ab_account_longname(ab_acc);
+        currency = AB_Account_GetCurrency(ab_acc);
+        if (currency && *currency)
+        {
+            commodity = gnc_commodity_table_lookup(
+                            gnc_commodity_table_get_table(gnc_get_current_book()),
+                            GNC_COMMODITY_NS_CURRENCY,
+                            currency);
+        }
+
+        gnc_acc = gnc_import_select_account(info->window, NULL, TRUE,
+                                            longname, commodity, ACCT_TYPE_BANK,
+                                            old_value, &ok_pressed);
+        g_free(longname);
+
+        if (ok_pressed && old_value != gnc_acc)
+        {
+            if (gnc_acc)
+            {
+                RevLookupData data;
+
+                /* Lookup and clear other mappings to gnc_acc */
+                data.gnc_acc = gnc_acc;
+                data.ab_acc = NULL;
+                g_hash_table_find(info->gnc_hash, (GHRFunc) find_gnc_acc_cb,
+                                  &data);
+                if (data.ab_acc)
+                {
+                    g_hash_table_remove(info->gnc_hash, data.ab_acc);
+                    gtk_tree_model_foreach(
+                        GTK_TREE_MODEL(info->account_store),
+                        (GtkTreeModelForeachFunc) clear_line_cb,
+                        &data);
+                }
+
+                /* Map ab_acc to gnc_acc */
+                g_hash_table_insert(info->gnc_hash, ab_acc, gnc_acc);
+                gnc_name = gnc_account_get_full_name(gnc_acc);
+                gtk_list_store_set(info->account_store, &iter,
+                                   ACCOUNT_LIST_COL_GNC_NAME, gnc_name,
+                                   ACCOUNT_LIST_COL_CHECKED, TRUE,
+                                   -1);
+                g_free(gnc_name);
+
+            }
+            else
+            {
+                g_hash_table_remove(info->gnc_hash, ab_acc);
+                gtk_list_store_set(info->account_store, &iter,
+                                   ACCOUNT_LIST_COL_GNC_NAME, "",
+                                   ACCOUNT_LIST_COL_CHECKED, TRUE,
+                                   -1);
+            }
+        }
+    }
+}
+
+static void
+clear_kvp_acc_cb(Account *gnc_acc, gpointer user_data)
+{
+    if (gnc_ab_get_account_uid(gnc_acc))
+        gnc_ab_set_account_uid(gnc_acc, 0);
+    if (gnc_ab_get_account_accountid(gnc_acc))
+        gnc_ab_set_account_accountid(gnc_acc, "");
+    if (gnc_ab_get_account_bankcode(gnc_acc))
+        gnc_ab_set_account_bankcode(gnc_acc, "");
+}
+
+static void
+save_kvp_acc_cb(gpointer key, gpointer value, gpointer user_data)
+{
+    AB_ACCOUNT *ab_acc = key;
+    Account *gnc_acc = value;
+    guint32 ab_account_uid;
+    const gchar *ab_accountid, *gnc_accountid;
+    const gchar *ab_bankcode, *gnc_bankcode;
+
+    g_return_if_fail(ab_acc && gnc_acc);
+
+    ab_account_uid = AB_Account_GetUniqueId(ab_acc);
+    if (gnc_ab_get_account_uid(gnc_acc) != ab_account_uid)
+        gnc_ab_set_account_uid(gnc_acc, ab_account_uid);
+
+    ab_accountid = AB_Account_GetAccountNumber(ab_acc);
+    gnc_accountid = gnc_ab_get_account_accountid(gnc_acc);
+    if (ab_accountid
+            && (!gnc_accountid
+                || (strcmp(ab_accountid, gnc_accountid) != 0)))
+        gnc_ab_set_account_accountid(gnc_acc, ab_accountid);
+
+    ab_bankcode = AB_Account_GetBankCode(ab_acc);
+    gnc_bankcode = gnc_ab_get_account_bankcode(gnc_acc);
+    if (ab_bankcode
+            && (!gnc_bankcode
+                || (strcmp(gnc_bankcode, ab_bankcode) != 0)))
+        gnc_ab_set_account_bankcode(gnc_acc, ab_bankcode);
+}
+
+static void
+aai_close_handler(gpointer user_data)
+{
+    ABInitialInfo *info = user_data;
+
+    gnc_save_window_size(GNC_PREFS_GROUP, GTK_WINDOW(info->window));
+    gtk_widget_destroy(info->window);
+}
+
+void aai_on_prepare (GtkAssistant  *assistant, GtkWidget *page,
+                     gpointer user_data)
+{
+    switch (gtk_assistant_get_current_page(assistant))
+    {
+    case 1:
+        /* Current page is wizard button page */
+        aai_wizard_page_prepare (assistant , user_data );
+        break;
+    case 2:
+        /* Current page is match page */
+        aai_match_page_prepare (assistant , user_data );
+        break;
+    }
+}
+
+void
+gnc_ab_initial_assistant(void)
+{
+    ABInitialInfo *info;
+    GtkBuilder *builder;
+    GtkTreeViewColumn *column;
+    GtkTreeSelection *selection;
+    gint component_id;
+
+    info = g_new0(ABInitialInfo, 1);
+    builder = gtk_builder_new();
+    gnc_builder_add_from_file (builder, "assistant-ab-initial.glade", "AqBanking Init Assistant");
+
+    info->window = GTK_WIDGET(gtk_builder_get_object (builder, "AqBanking Init Assistant"));
+
+    gnc_assistant_set_colors (GTK_ASSISTANT (info->assistant));
+
+    info->api = gnc_AB_BANKING_new();
+    info->deferred_info = NULL;
+    info->gnc_hash = NULL;
+
+    info->match_page_prepared = FALSE;
+    info->account_view =
+        GTK_TREE_VIEW(gtk_builder_get_object (builder, "account_page_view"));
+
+    info->account_store = gtk_list_store_new(NUM_ACCOUNT_LIST_COLS,
+                          G_TYPE_INT, G_TYPE_STRING,
+                          G_TYPE_POINTER, G_TYPE_STRING,
+                          G_TYPE_BOOLEAN);
+    gtk_tree_view_set_model(info->account_view,
+                            GTK_TREE_MODEL(info->account_store));
+    g_object_unref(info->account_store);
+
+    column = gtk_tree_view_column_new_with_attributes(
+                 _("Online Banking Account Name"), gtk_cell_renderer_text_new(),
+                 "text", ACCOUNT_LIST_COL_AB_NAME, (gchar*) NULL);
+    gtk_tree_view_append_column(info->account_view, column);
+
+    column = gtk_tree_view_column_new_with_attributes(
+                 _("GnuCash Account Name"), gtk_cell_renderer_text_new(),
+                 "text", ACCOUNT_LIST_COL_GNC_NAME, (gchar*) NULL);
+    gtk_tree_view_column_set_expand(column, TRUE);
+    gtk_tree_view_append_column(info->account_view, column);
+
+    column = gtk_tree_view_column_new_with_attributes(
+                 _("New?"), gtk_cell_renderer_toggle_new(),
+                 "active", ACCOUNT_LIST_COL_CHECKED, (gchar*) NULL);
+    gtk_tree_view_append_column(info->account_view, column);
+
+    selection = gtk_tree_view_get_selection(info->account_view);
+    gtk_tree_selection_set_mode (selection, GTK_SELECTION_SINGLE);
+
+    gnc_restore_window_size (GNC_PREFS_GROUP, GTK_WINDOW(info->window));
+
+    g_signal_connect(info->account_view, "row-activated",
+                     G_CALLBACK(account_list_clicked_cb), info);
+
+    g_signal_connect (G_OBJECT(info->window), "destroy",
+                      G_CALLBACK (aai_destroy_cb), info);
+
+    gtk_builder_connect_signals(builder, info);
+    g_object_unref(G_OBJECT(builder));
+
+    component_id = gnc_register_gui_component(ASSISTANT_AB_INITIAL_CM_CLASS,
+                   NULL, aai_close_handler, info);
+
+    gnc_gui_component_set_session(component_id, gnc_get_current_session());
+
+    gtk_widget_show(info->window);
+}

Copied: gnucash/trunk/src/import-export/aqb/assistant-ab-initial.glade (from rev 23566, gnucash/trunk/src/import-export/aqbanking/assistant-ab-initial.glade)
===================================================================
--- gnucash/trunk/src/import-export/aqb/assistant-ab-initial.glade	                        (rev 0)
+++ gnucash/trunk/src/import-export/aqb/assistant-ab-initial.glade	2013-12-15 17:21:20 UTC (rev 23567)
@@ -0,0 +1,162 @@
+<?xml version="1.0"?>
+<interface>
+  <requires lib="gtk+" version="2.16"/>
+  <!-- interface-naming-policy project-wide -->
+  <object class="GtkAssistant" id="AqBanking Init Assistant">
+    <property name="can_focus">False</property>
+    <property name="border_width">12</property>
+    <property name="title" translatable="yes">AqBanking Initial Assistant</property>
+    <signal name="close" handler="aai_on_finish" swapped="no"/>
+    <signal name="prepare" handler="aai_on_prepare" swapped="no"/>
+    <signal name="cancel" handler="aai_on_cancel" swapped="no"/>
+    <child>
+      <object class="GtkLabel" id="start_page">
+        <property name="visible">True</property>
+        <property name="can_focus">False</property>
+        <property name="label" translatable="yes">
+This assistant helps you setting up your Online Banking connection with your bank.
+
+You first need to apply for Online Banking access at your bank. If your bank  decides to grant you electronic access, they will send you a letter containing 
+
+* The bank code of your bank
+* The user ID that identifies you to your bank
+* The Internet address of your bank's Online Banking server
+* For HBCI Online Banking, information about the cryptographic public key of your bank ("Ini-Letter").
+
+This information will be needed in the following. Press "Forward" now.
+
+NOTE: NO WARRANTIES FOR ANYTHING. Some banks run a poorly implemented Online Banking server. You should not rely on time-critical transfers through Online Banking, because sometimes the bank does not give you correct feedback when a transfer is rejected.
+
+Press "Cancel" if you do not wish to setup any Online Banking connection now.
+</property>
+        <property name="wrap">True</property>
+      </object>
+      <packing>
+        <property name="page_type">intro</property>
+        <property name="title" translatable="yes">Initial Online Banking Setup</property>
+        <property name="complete">True</property>
+      </packing>
+    </child>
+    <child>
+      <object class="GtkVBox" id="wizard_page">
+        <property name="visible">True</property>
+        <property name="can_focus">False</property>
+        <property name="border_width">12</property>
+        <property name="spacing">12</property>
+        <child>
+          <object class="GtkLabel" id="label8877441">
+            <property name="visible">True</property>
+            <property name="can_focus">False</property>
+            <property name="label" translatable="yes">The Setup of your Online Banking connection is handled by the external program "AqBanking Setup Wizard". Please press the button below to start this program.</property>
+            <property name="wrap">True</property>
+          </object>
+          <packing>
+            <property name="expand">True</property>
+            <property name="fill">False</property>
+            <property name="position">0</property>
+          </packing>
+        </child>
+        <child>
+          <object class="GtkAlignment" id="alignment7">
+            <property name="visible">True</property>
+            <property name="can_focus">False</property>
+            <property name="xscale">0</property>
+            <child>
+              <object class="GtkButton" id="ab_wizard_button">
+                <property name="label" translatable="yes">_Start AqBanking Wizard</property>
+                <property name="visible">True</property>
+                <property name="can_focus">True</property>
+                <property name="receives_default">True</property>
+                <property name="use_action_appearance">False</property>
+                <property name="use_underline">True</property>
+                <signal name="clicked" handler="aai_wizard_button_clicked_cb" swapped="no"/>
+              </object>
+            </child>
+          </object>
+          <packing>
+            <property name="expand">True</property>
+            <property name="fill">False</property>
+            <property name="position">1</property>
+          </packing>
+        </child>
+      </object>
+      <packing>
+        <property name="page_type">intro</property>
+        <property name="title" translatable="yes">Start Online Banking Wizard</property>
+      </packing>
+    </child>
+    <child>
+      <object class="GtkVBox" id="account_match_page">
+        <property name="visible">True</property>
+        <property name="can_focus">False</property>
+        <property name="border_width">12</property>
+        <child>
+          <object class="GtkVBox" id="vbox157">
+            <property name="visible">True</property>
+            <property name="can_focus">False</property>
+            <property name="spacing">12</property>
+            <child>
+              <object class="GtkScrolledWindow" id="scrolledwindow25">
+                <property name="visible">True</property>
+                <property name="can_focus">True</property>
+                <property name="hscrollbar_policy">automatic</property>
+                <property name="vscrollbar_policy">automatic</property>
+                <property name="shadow_type">in</property>
+                <child>
+                  <object class="GtkTreeView" id="account_page_view">
+                    <property name="visible">True</property>
+                    <property name="can_focus">True</property>
+                    <property name="rules_hint">True</property>
+                  </object>
+                </child>
+              </object>
+              <packing>
+                <property name="expand">True</property>
+                <property name="fill">True</property>
+                <property name="position">0</property>
+              </packing>
+            </child>
+            <child>
+              <object class="GtkLabel" id="label828">
+                <property name="visible">True</property>
+                <property name="can_focus">False</property>
+                <property name="label" translatable="yes">Double Click on the line of an Online Banking account name if you want to match it to a GnuCash account. Click "Forward" when all desired accounts are matching.</property>
+                <property name="wrap">True</property>
+              </object>
+              <packing>
+                <property name="expand">False</property>
+                <property name="fill">False</property>
+                <property name="position">1</property>
+              </packing>
+            </child>
+          </object>
+          <packing>
+            <property name="expand">True</property>
+            <property name="fill">True</property>
+            <property name="position">0</property>
+          </packing>
+        </child>
+      </object>
+      <packing>
+        <property name="title" translatable="yes">Match Online accounts with GnuCash accounts</property>
+      </packing>
+    </child>
+    <child>
+      <object class="GtkLabel" id="finish_page">
+        <property name="visible">True</property>
+        <property name="can_focus">False</property>
+        <property name="label" translatable="yes">The setup for matching Online Banking accounts to GnuCash accounts is now finished. You can now invoke Online Banking actions on those accounts.
+
+If you want to add another bank, user, or account, you can start this assistant again anytime.
+
+Press "Apply" now.</property>
+        <property name="wrap">True</property>
+      </object>
+      <packing>
+        <property name="page_type">confirm</property>
+        <property name="title" translatable="yes">Online Banking Setup Finished</property>
+        <property name="complete">True</property>
+      </packing>
+    </child>
+  </object>
+</interface>

Copied: gnucash/trunk/src/import-export/aqb/assistant-ab-initial.h (from rev 23566, gnucash/trunk/src/import-export/aqbanking/assistant-ab-initial.h)
===================================================================
--- gnucash/trunk/src/import-export/aqb/assistant-ab-initial.h	                        (rev 0)
+++ gnucash/trunk/src/import-export/aqb/assistant-ab-initial.h	2013-12-15 17:21:20 UTC (rev 23567)
@@ -0,0 +1,51 @@
+/*
+ * assistant-ab-initial.h -- aqbanking creation functionality
+ *
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, contact:
+ *
+ * Free Software Foundation           Voice:  +1-617-542-5942
+ * 51 Franklin Street, Fifth Floor    Fax:    +1-617-542-2652
+ * Boston, MA  02110-1301,  USA       gnu at gnu.org
+ */
+
+/**
+ * @addtogroup Import_Export
+ * @{
+ * @addtogroup AqBanking
+ * @{
+ * @file assistant-ab-initial.h
+ * @brief AqBanking setup functionality
+ * @author Copyright (C) 2002 Christian Stimming <stimming at tuhh.de>
+ * @author Copyright (C) 2008 Andreas Koehler <andi5.py at gmx.net>
+ */
+
+#ifndef ASSISTANT_AB_INITIAL_H
+#define ASSISTANT_AB_INITIAL_H
+
+#include <glib.h>
+
+G_BEGIN_DECLS
+
+/**
+ * Create and show an assistant for the aqbanking setup.
+ */
+void gnc_ab_initial_assistant(void);
+
+G_END_DECLS
+
+/** @} */
+/** @} */
+
+#endif /* ASSISTANT_AB_INITIAL_H */

Copied: gnucash/trunk/src/import-export/aqb/dialog-ab-daterange.c (from rev 23566, gnucash/trunk/src/import-export/aqbanking/dialog-ab-daterange.c)
===================================================================
--- gnucash/trunk/src/import-export/aqb/dialog-ab-daterange.c	                        (rev 0)
+++ gnucash/trunk/src/import-export/aqb/dialog-ab-daterange.c	2013-12-15 17:21:20 UTC (rev 23567)
@@ -0,0 +1,158 @@
+/*
+ * dialog-ab-daterange.c --
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, contact:
+ *
+ * Free Software Foundation           Voice:  +1-617-542-5942
+ * 51 Franklin Street, Fifth Floor    Fax:    +1-617-542-2652
+ * Boston, MA  02110-1301,  USA       gnu at gnu.org
+ */
+
+/**
+ * @internal
+ * @file dialog-daterange.c
+ * @brief Dialog for date range entry
+ * @author Copyright (C) 2002 Christian Stimming <stimming at tuhh.de>
+ * @author Copyright (C) 2008 Andreas Koehler <andi5.py at gmx.net>
+ */
+
+#include "config.h"
+
+#include "dialog-ab-daterange.h"
+#include "dialog-utils.h"
+#include "gnc-date-edit.h"
+
+/* This static indicates the debugging module that this .o belongs to.  */
+static QofLogModule log_module = G_LOG_DOMAIN;
+
+typedef struct _DaterangeInfo DaterangeInfo;
+
+void ddr_toggled_cb(GtkToggleButton *button, gpointer user_data);
+
+struct _DaterangeInfo
+{
+    GtkWidget *enter_from_button;
+    GtkWidget *enter_to_button;
+    GtkWidget *from_dateedit;
+    GtkWidget *to_dateedit;
+};
+
+gboolean
+gnc_ab_enter_daterange(GtkWidget *parent,
+                       const char *heading,
+                       Timespec *from_date,
+                       gboolean *last_retv_date,
+                       gboolean *first_possible_date,
+                       Timespec *to_date,
+                       gboolean *to_now)
+{
+    GtkBuilder *builder;
+    GtkWidget *dialog;
+    GtkWidget *heading_label;
+    GtkWidget *first_button;
+    GtkWidget *last_retrieval_button;
+    GtkWidget *now_button;
+    DaterangeInfo info;
+    gint result;
+
+    ENTER("");
+
+    builder = gtk_builder_new();
+    gnc_builder_add_from_file (builder, "dialog-ab.glade", "Date Range Dialog");
+
+    dialog = GTK_WIDGET(gtk_builder_get_object (builder, "Date Range Dialog"));
+
+    /* Connect the signals */
+    gtk_builder_connect_signals_full (builder, gnc_builder_connect_full_func, &info );
+
+    if (parent)
+        gtk_window_set_transient_for(GTK_WINDOW(dialog), GTK_WINDOW(parent));
+
+    heading_label  = GTK_WIDGET(gtk_builder_get_object (builder, "heading_label"));
+    first_button  = GTK_WIDGET(gtk_builder_get_object (builder, "first_button"));
+    last_retrieval_button  = GTK_WIDGET(gtk_builder_get_object (builder, "last_retrieval_button"));
+    info.enter_from_button  = GTK_WIDGET(gtk_builder_get_object (builder, "enter_from_button"));
+    now_button  = GTK_WIDGET(gtk_builder_get_object (builder, "now_button"));
+    info.enter_to_button  = GTK_WIDGET(gtk_builder_get_object (builder, "enter_to_button"));
+
+    info.from_dateedit = gnc_date_edit_new_ts(*from_date, FALSE, FALSE);
+    gtk_container_add(GTK_CONTAINER(gtk_builder_get_object (builder, "enter_from_box")),
+                      info.from_dateedit);
+    gtk_widget_show(info.from_dateedit);
+
+    info.to_dateedit = gnc_date_edit_new_ts(*to_date, FALSE, FALSE);
+    gtk_container_add(GTK_CONTAINER(gtk_builder_get_object (builder, "enter_to_box")),
+                      info.to_dateedit);
+    gtk_widget_show(info.to_dateedit);
+
+    if (*last_retv_date)
+    {
+        gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(last_retrieval_button),
+                                     TRUE);
+    }
+    else
+    {
+        gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(first_button), TRUE);
+        gtk_widget_set_sensitive(last_retrieval_button, FALSE);
+    }
+
+    gtk_widget_set_sensitive(info.from_dateedit, FALSE);
+    gtk_widget_set_sensitive(info.to_dateedit, FALSE);
+
+    gtk_dialog_set_default_response(GTK_DIALOG(dialog), GTK_RESPONSE_OK);
+
+    if (heading)
+        gtk_label_set_text(GTK_LABEL(heading_label), heading);
+
+    gtk_widget_show(dialog);
+
+    result = gtk_dialog_run(GTK_DIALOG(dialog));
+    gtk_widget_hide(dialog);
+
+    if (result == GTK_RESPONSE_OK)
+    {
+        *from_date = gnc_date_edit_get_date_ts(
+                         GNC_DATE_EDIT(info.from_dateedit));
+        *last_retv_date = gtk_toggle_button_get_active(
+                              GTK_TOGGLE_BUTTON(last_retrieval_button));
+        *first_possible_date = gtk_toggle_button_get_active(
+                                   GTK_TOGGLE_BUTTON(first_button));
+        *to_date = gnc_date_edit_get_date_ts(
+                       GNC_DATE_EDIT(info.to_dateedit));
+        *to_now = gtk_toggle_button_get_active(
+                      GTK_TOGGLE_BUTTON(now_button));
+    }
+
+    g_object_unref(G_OBJECT(builder));
+
+    gtk_widget_destroy(dialog);
+
+    LEAVE("");
+    return result == GTK_RESPONSE_OK;
+}
+
+void
+ddr_toggled_cb(GtkToggleButton *button, gpointer user_data)
+{
+    DaterangeInfo *info = user_data;
+
+    g_return_if_fail(info);
+
+    gtk_widget_set_sensitive(info->from_dateedit,
+                             gtk_toggle_button_get_active(
+                                 GTK_TOGGLE_BUTTON(info->enter_from_button)));
+    gtk_widget_set_sensitive(info->to_dateedit,
+                             gtk_toggle_button_get_active(
+                                 GTK_TOGGLE_BUTTON(info->enter_to_button)));
+}

Copied: gnucash/trunk/src/import-export/aqb/dialog-ab-daterange.h (from rev 23566, gnucash/trunk/src/import-export/aqbanking/dialog-ab-daterange.h)
===================================================================
--- gnucash/trunk/src/import-export/aqb/dialog-ab-daterange.h	                        (rev 0)
+++ gnucash/trunk/src/import-export/aqb/dialog-ab-daterange.h	2013-12-15 17:21:20 UTC (rev 23567)
@@ -0,0 +1,69 @@
+/*
+ * dialog-ab-daterange.h --
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, contact:
+ *
+ * Free Software Foundation           Voice:  +1-617-542-5942
+ * 51 Franklin Street, Fifth Floor    Fax:    +1-617-542-2652
+ * Boston, MA  02110-1301,  USA       gnu at gnu.org
+ */
+
+/**
+ * @addtogroup Import_Export
+ * @{
+ * @addtogroup AqBanking
+ * @{
+ * @file aqbanking/dialog-ab-daterange.h
+ * @brief Dialog for date range entry
+ * @author Copyright (C) 2002 Christian Stimming <stimming at tuhh.de>
+ * @author Copyright (C) 2008 Andreas Koehler <andi5.py at gmx.net>
+ */
+
+#ifndef DIALOG_DATERANGE_H
+#define DIALOG_DATERANGE_H
+
+#include <gtk/gtk.h>
+
+#include "qof.h"
+
+G_BEGIN_DECLS
+
+/**
+ * Show a dialog to pick a time frame using a sensible set of default options.
+ *
+ * @param parent Widget to use as parent, may be NULL
+ * @param heading Descriptive text showed at the top, may be NULL
+ * @param from_date Location to read from the initial and write to the final
+ * value of the from date entry
+ * @param last_retv_date Location to read from whether the caller knows the last
+ * retrieval date and write to whether the corresponding button has been chosen
+ * @param first_possible_date Location to write to whether the earliest possible
+ * date button has been chosen
+ * @param to_date Location to read from the initial and write to the final value
+ * of the to date entry
+ * @param to_now Location to write to whether the to now button has been chosen
+ */
+gboolean gnc_ab_enter_daterange(GtkWidget *parent,
+                                const char *heading,
+                                Timespec *from_date,
+                                gboolean *last_retv_date,
+                                gboolean *first_possible_date,
+                                Timespec *to_date,
+                                gboolean *to_now);
+
+G_END_DECLS
+
+#endif /* DIALOG_DATERANGE_H */
+/** @} */
+/** @} */

Copied: gnucash/trunk/src/import-export/aqb/dialog-ab-trans.c (from rev 23566, gnucash/trunk/src/import-export/aqbanking/dialog-ab-trans.c)
===================================================================
--- gnucash/trunk/src/import-export/aqb/dialog-ab-trans.c	                        (rev 0)
+++ gnucash/trunk/src/import-export/aqb/dialog-ab-trans.c	2013-12-15 17:21:20 UTC (rev 23567)
@@ -0,0 +1,1260 @@
+/*
+ * dialog-ab-trans.c --
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, contact:
+ *
+ * Free Software Foundation           Voice:  +1-617-542-5942
+ * 51 Franklin Street, Fifth Floor    Fax:    +1-617-542-2652
+ * Boston, MA  02110-1301,  USA       gnu at gnu.org
+ */
+
+/**
+ * @internal
+ * @file dialog-ab-trans.c
+ * @brief Templates for AqBanking transactions
+ * @author Copyright (C) 2002 Christian Stimming <stimming at tuhh.de>
+ * @author Copyright (C) 2004 Bernd Wagner
+ * @author Copyright (C) 2006 David Hampton <hampton at employees.org>
+ * @author Copyright (C) 2008 Andreas Koehler <andi5.py at gmx.net>
+ */
+
+#include "config.h"
+
+#include <glib/gi18n.h>
+#if HAVE_KTOBLZCHECK_H
+#    include <ktoblzcheck.h>
+#endif
+#include <aqbanking/jobsingletransfer.h>
+#include <aqbanking/jobsingledebitnote.h>
+#include <aqbanking/jobinternaltransfer.h>
+#include <aqbanking/jobsepatransfer.h>
+#include <aqbanking/jobsepadebitnote.h>
+
+#include "dialog-ab-trans.h"
+#include "dialog-transfer.h"
+#include "dialog-utils.h"
+#include "gnc-ab-trans-templ.h"
+#include "gnc-ab-utils.h"
+#include "gnc-amount-edit.h"
+#include "gnc-ui.h"
+
+/* This static indicates the debugging module that this .o belongs to.  */
+static QofLogModule log_module = G_LOG_DOMAIN;
+
+/* Template handling */
+static void gnc_ab_trans_dialog_fill_templ_helper(gpointer data, gpointer user_data);
+static gboolean gnc_ab_trans_dialog_clear_templ_helper(GtkTreeModel *model,
+        GtkTreePath *path,
+        GtkTreeIter *iter,
+        gpointer user_data);
+static gboolean gnc_ab_trans_dialog_get_templ_helper(GtkTreeModel *model,
+        GtkTreePath *path,
+        GtkTreeIter *iter,
+        gpointer data);
+
+static AB_TRANSACTION *gnc_ab_trans_dialog_fill_values(GncABTransDialog *td);
+static AB_JOB *gnc_ab_trans_dialog_get_available_empty_job(AB_ACCOUNT *ab_acc,
+        GncABTransType trans_type);
+
+static void gnc_ab_trans_dialog_check_ktoblzcheck(const GncABTransDialog *td,
+        const AB_TRANSACTION *trans);
+
+/* Callbacks - connected with GtkBuilder */
+G_MODULE_EXPORT void gnc_ab_trans_dialog_bankcode_changed_cb(GtkEditable *editable, gpointer user_data);
+G_MODULE_EXPORT void gnc_ab_trans_dialog_add_templ_cb(GtkButton *button, gpointer user_data);
+G_MODULE_EXPORT void gnc_ab_trans_dialog_moveup_templ_cb(GtkButton *button, gpointer user_data);
+G_MODULE_EXPORT void gnc_ab_trans_dialog_movedown_templ_cb(GtkButton *button, gpointer user_data);
+G_MODULE_EXPORT void gnc_ab_trans_dialog_sort_templ_cb(GtkButton *button, gpointer user_data);
+G_MODULE_EXPORT void gnc_ab_trans_dialog_del_templ_cb(GtkButton *button, gpointer user_data);
+G_MODULE_EXPORT void gnc_ab_trans_dialog_entry_filter_cb (GtkEditable *editable,
+        const gchar *text,
+        gint         length,
+        gint        *position,
+        gpointer     user_data);
+G_MODULE_EXPORT void gnc_ab_trans_dialog_templ_list_row_activated_cb(GtkTreeView *view,
+        GtkTreePath *path,
+        GtkTreeViewColumn *column,
+        gpointer user_data);
+G_MODULE_EXPORT void gnc_ab_trans_dialog_verify_values(GncABTransDialog *td);
+
+
+enum
+{
+    TEMPLATE_NAME,
+    TEMPLATE_POINTER,
+    TEMPLATE_NUM_COLUMNS
+};
+
+struct _GncABTransDialog
+{
+    /* The dialog itself */
+    GtkWidget *dialog;
+    GtkWidget *parent;
+    AB_ACCOUNT *ab_acc;
+
+    /* Whether this is a transfer or a direct debit */
+    GncABTransType trans_type;
+
+    /* Recipient */
+    GtkWidget *recp_name_entry;
+    GtkWidget *recp_account_entry;
+    GtkWidget *recp_bankcode_entry;
+
+    /* Amount */
+    GtkWidget *amount_edit;
+
+    /* Purpose, description */
+    GtkWidget *purpose_entry;
+    GtkWidget *purpose_cont_entry;
+    GtkWidget *purpose_cont2_entry;
+    GtkWidget *purpose_cont3_entry;
+
+    /* Recipient's bank name (may be filled in automatically sometime later) */
+    GtkWidget *recp_bankname_label;
+
+    /* The template choosing GtkTreeView/GtkListStore */
+    GtkTreeView *template_gtktreeview;
+    GtkListStore *template_list_store;
+
+    /* Exec button */
+    GtkWidget *exec_button;
+
+    /* Flag, if template list has been changed */
+    gboolean templ_changed;
+
+    /* The aqbanking transaction that got created here */
+    AB_TRANSACTION *ab_trans;
+
+    /* The gnucash transaction that got created here */
+    Transaction *gnc_trans;
+
+#if HAVE_KTOBLZCHECK_H
+    /* object for Account number checking */
+    AccountNumberCheck *blzcheck;
+#endif
+};
+
+gboolean gnc_ab_trans_isSEPA(GncABTransType t)
+{
+    switch (t)
+    {
+    case SEPA_TRANSFER:
+    case SEPA_DEBITNOTE:
+        return TRUE;
+    default:
+        return FALSE;
+    }
+}
+
+static void
+gnc_ab_trans_dialog_fill_templ_helper(gpointer data, gpointer user_data)
+{
+    GncABTransTempl *templ = data;
+    GtkListStore *store = user_data;
+    GtkTreeIter iter;
+
+    g_return_if_fail(templ && store);
+    gtk_list_store_append(store, &iter);
+    gtk_list_store_set(store, &iter,
+                       TEMPLATE_NAME, gnc_ab_trans_templ_get_name(templ),
+                       TEMPLATE_POINTER, templ,
+                       -1);
+}
+
+/**
+ * Create a new AB_TRANSACTION, fill the values from the entry fields into it
+ * and return it.  The caller must AB_TRANSACTION_free() it when finished.
+ */
+static AB_TRANSACTION *
+gnc_ab_trans_dialog_fill_values(GncABTransDialog *td)
+{
+    /* Fill in the user-entered values */
+    AB_TRANSACTION *trans = AB_Transaction_new();
+    AB_VALUE *value;
+
+    AB_Transaction_FillLocalFromAccount(trans, td->ab_acc);
+    //AB_Transaction_SetLocalBankCode(trans, AB_Account_GetBankCode(td->ab_acc));
+    //AB_Transaction_SetLocalAccountNumber(
+    //  trans, AB_Account_GetAccountNumber(td->ab_acc));
+    //AB_Transaction_SetLocalCountry(trans, "DE");
+
+    if (gnc_ab_trans_isSEPA(td->trans_type))
+    {
+        AB_Transaction_SetRemoteBic(
+                    trans, gtk_entry_get_text(GTK_ENTRY(td->recp_bankcode_entry)));
+        AB_Transaction_SetRemoteIban(
+                    trans, gtk_entry_get_text(GTK_ENTRY(td->recp_account_entry)));
+    }
+    else
+    {
+        AB_Transaction_SetRemoteBankCode(
+                    trans, gtk_entry_get_text(GTK_ENTRY(td->recp_bankcode_entry)));
+        AB_Transaction_SetRemoteAccountNumber(
+                    trans, gtk_entry_get_text(GTK_ENTRY(td->recp_account_entry)));
+    }
+    AB_Transaction_SetRemoteCountry(trans, "DE");
+    AB_Transaction_AddRemoteName(
+        trans, gtk_entry_get_text(GTK_ENTRY(td->recp_name_entry)), FALSE);
+
+    AB_Transaction_AddPurpose(
+        trans, gtk_entry_get_text(GTK_ENTRY(td->purpose_entry)), FALSE);
+    AB_Transaction_AddPurpose(
+        trans, gtk_entry_get_text(GTK_ENTRY(td->purpose_cont_entry)), FALSE);
+    AB_Transaction_AddPurpose(
+        trans, gtk_entry_get_text(GTK_ENTRY(td->purpose_cont2_entry)), FALSE);
+    AB_Transaction_AddPurpose(
+        trans, gtk_entry_get_text(GTK_ENTRY(td->purpose_cont3_entry)), FALSE);
+
+    value = AB_Value_fromDouble(gnc_amount_edit_get_damount(
+                                    GNC_AMOUNT_EDIT(td->amount_edit)));
+    /* FIXME: Replace "EUR" by account-dependent string here. */
+    AB_Value_SetCurrency(value, "EUR");
+    AB_Transaction_SetValue(trans, value);
+    AB_Value_free(value);
+
+    /* If this is a direct debit, a textkey/ "Textschluessel"/transactionCode
+     * different from the default has to be set. */
+    switch (td->trans_type)
+    {
+    case SINGLE_DEBITNOTE:
+        /* AB_Transaction_SetTransactionCode (trans, 05); */
+        AB_Transaction_SetTextKey(trans, 05);
+        break;
+    default:
+        /* AB_Transaction_SetTransactionCode (trans, 51); */
+        AB_Transaction_SetTextKey (trans, 51);
+        break;
+    }
+
+    return trans;
+}
+
+GncABTransDialog *
+gnc_ab_trans_dialog_new(GtkWidget *parent, AB_ACCOUNT *ab_acc,
+                        gint commodity_scu, GncABTransType trans_type,
+                        GList *templates)
+{
+    GncABTransDialog *td;
+    GtkBuilder  *builder;
+    const gchar *ab_ownername;
+    const gchar *ab_accountnumber;
+    const gchar *ab_bankname;
+    const gchar *ab_bankcode;
+    G_GNUC_UNUSED GtkWidget *trans_vbox;
+    GtkWidget *heading_label;
+    GtkWidget *recp_name_heading;
+    GtkWidget *recp_account_heading;
+    GtkWidget *recp_bankcode_heading;
+    GtkWidget *amount_hbox;
+    GtkWidget *orig_name_heading;
+    GtkWidget *orig_name_label;
+    GtkWidget *orig_account_heading;
+    GtkWidget *orig_account_label;
+    G_GNUC_UNUSED GtkWidget *orig_bankname_heading;
+    GtkWidget *orig_bankname_label;
+    GtkWidget *orig_bankcode_heading;
+    GtkWidget *orig_bankcode_label;
+    GtkCellRenderer *renderer;
+    GtkTreeViewColumn *column;
+
+    g_return_val_if_fail(ab_acc, NULL);
+
+    ab_ownername = AB_Account_GetOwnerName(ab_acc);
+    if (!ab_ownername)
+        ab_ownername = "";
+    ab_accountnumber = AB_Account_GetAccountNumber(ab_acc);
+    ab_bankcode = AB_Account_GetBankCode(ab_acc);
+    ab_bankname = AB_Account_GetBankName(ab_acc);
+    if (!ab_bankname || !*ab_bankname)
+        ab_bankname = _("(unknown)");
+
+    td = g_new0(GncABTransDialog, 1);
+    td->parent = parent;
+    td->ab_acc = ab_acc;
+    td->trans_type = trans_type;
+
+#if HAVE_KTOBLZCHECK_H
+    td->blzcheck = AccountNumberCheck_new();
+#endif
+
+    builder = gtk_builder_new();
+    gnc_builder_add_from_file (builder, "dialog-ab.glade", "Transaction Dialog");
+    td->dialog = GTK_WIDGET(gtk_builder_get_object (builder, "Transaction Dialog"));
+
+    if (parent)
+        gtk_window_set_transient_for(GTK_WINDOW(td->dialog), GTK_WINDOW(parent));
+
+    /* Extract widgets */
+    trans_vbox = GTK_WIDGET(gtk_builder_get_object (builder, "trans_vbox"));
+    heading_label = GTK_WIDGET(gtk_builder_get_object (builder, "heading_label"));
+    recp_name_heading = GTK_WIDGET(gtk_builder_get_object (builder, "recp_name_heading"));
+    td->recp_name_entry = GTK_WIDGET(gtk_builder_get_object (builder, "recp_name_entry"));
+    recp_account_heading = GTK_WIDGET(gtk_builder_get_object (builder, "recp_account_heading"));
+    td->recp_account_entry = GTK_WIDGET(gtk_builder_get_object (builder, "recp_account_entry"));
+    recp_bankcode_heading = GTK_WIDGET(gtk_builder_get_object (builder, "recp_bankcode_heading"));
+    td->recp_bankcode_entry = GTK_WIDGET(gtk_builder_get_object (builder, "recp_bankcode_entry"));
+    td->recp_bankname_label = GTK_WIDGET(gtk_builder_get_object (builder, "recp_bankname_label"));
+    amount_hbox = GTK_WIDGET(gtk_builder_get_object (builder, "amount_hbox"));
+    td->purpose_entry = GTK_WIDGET(gtk_builder_get_object (builder, "purpose_entry"));
+    td->purpose_cont_entry = GTK_WIDGET(gtk_builder_get_object (builder, "purpose_cont_entry"));
+    td->purpose_cont2_entry = GTK_WIDGET(gtk_builder_get_object (builder, "purpose_cont2_entry"));
+    td->purpose_cont3_entry = GTK_WIDGET(gtk_builder_get_object (builder, "purpose_cont3_entry"));
+    td->exec_button = GTK_WIDGET(gtk_builder_get_object(builder, "exec_now_button"));
+    orig_name_heading = GTK_WIDGET(gtk_builder_get_object (builder, "orig_name_heading"));
+    orig_name_label = GTK_WIDGET(gtk_builder_get_object (builder, "orig_name_label"));
+    orig_account_heading = GTK_WIDGET(gtk_builder_get_object (builder, "orig_account_heading"));
+    orig_account_label = GTK_WIDGET(gtk_builder_get_object (builder, "orig_account_label"));
+    orig_bankname_heading = GTK_WIDGET(gtk_builder_get_object (builder, "orig_bankname_heading"));
+    orig_bankname_label = GTK_WIDGET(gtk_builder_get_object (builder, "orig_bankname_label"));
+    orig_bankcode_heading = GTK_WIDGET(gtk_builder_get_object (builder, "orig_bankcode_heading"));
+    orig_bankcode_label = GTK_WIDGET(gtk_builder_get_object (builder, "orig_bankcode_label"));
+    td->template_gtktreeview =
+        GTK_TREE_VIEW(gtk_builder_get_object (builder, "template_list"));
+
+    /* Amount edit */
+    td->amount_edit = gnc_amount_edit_new();
+    gtk_box_pack_start(GTK_BOX(amount_hbox), td->amount_edit, TRUE, TRUE, 0);
+    gnc_amount_edit_set_evaluate_on_enter(GNC_AMOUNT_EDIT(td->amount_edit),
+                                          TRUE);
+    gnc_amount_edit_set_fraction(GNC_AMOUNT_EDIT(td->amount_edit),
+                                 commodity_scu);
+
+    /* Use "focus-out" signal because "amount-changed" is only sent when ENTER is pressed */
+    g_signal_connect_swapped (gnc_amount_edit_gtk_entry(GNC_AMOUNT_EDIT(td->amount_edit)), "focus-out-event",
+                              G_CALLBACK(gnc_ab_trans_dialog_verify_values), td);
+
+    /* Check for what kind of transaction this should be, and change the
+     * labels accordingly */
+    switch (trans_type)
+    {
+    case SINGLE_TRANSFER:
+    case SINGLE_INTERNAL_TRANSFER:
+    case SEPA_TRANSFER:
+        /* all labels are already set */
+        break;
+    case SINGLE_DEBITNOTE:
+    case SEPA_DEBITNOTE:
+        gtk_label_set_text(GTK_LABEL (heading_label),
+                           /* Translators: Strings from this file are
+                             * needed only in countries that have one of
+                             * aqbanking's Online Banking techniques
+                             * available. This is 'OFX DirectConnect'
+                             * (U.S. and others), 'HBCI' (in Germany),
+                             * or 'YellowNet' (Switzerland). If none of
+                             * these techniques are available in your
+                             * country, you may safely ignore strings
+                             * from the import-export/hbci
+                             * subdirectory. */
+                           _("Enter an Online Direct Debit Note"));
+
+        gtk_label_set_text(GTK_LABEL(recp_name_heading),
+                           _("Debited Account Owner"));
+        gtk_label_set_text(GTK_LABEL(recp_account_heading),
+                           _("Debited Account Number"));
+        gtk_label_set_text(GTK_LABEL(recp_bankcode_heading),
+                           _("Debited Account Bank Code"));
+
+        gtk_label_set_text(GTK_LABEL(orig_name_heading),
+                           _("Credited Account Owner"));
+        gtk_label_set_text(GTK_LABEL(orig_account_heading),
+                           _("Credited Account Number"));
+        gtk_label_set_text(GTK_LABEL(orig_bankcode_heading),
+                           _("Credited Account Bank Code"));
+        break;
+
+    default:
+        g_critical("gnc_ab_trans_dialog_new: Oops, unknown GncABTransType %d",
+                   trans_type);
+        break;
+    }
+
+    /* Additionally change the labels for the European (SEPA) transactions */
+    switch (trans_type)
+    {
+    case SEPA_TRANSFER:
+        gtk_label_set_text(GTK_LABEL(recp_account_heading),
+                           _("Recipient IBAN (International Account Number)"));
+        gtk_label_set_text(GTK_LABEL(recp_bankcode_heading),
+                           _("Recipient BIC (Bank Code)"));
+        break;
+    case SEPA_DEBITNOTE:
+        gtk_label_set_text(GTK_LABEL(recp_account_heading),
+                           _("Debited IBAN (International Account Number)"));
+        gtk_label_set_text(GTK_LABEL(recp_bankcode_heading),
+                           _("Debited BIC (Bank Code)"));
+        break;
+    default:
+        // do nothing
+        break;
+    }
+    if (gnc_ab_trans_isSEPA(trans_type))
+    {
+        // Also, SEPA might have much longer IBAN (up to 34 chars) and BIC (11)
+        gtk_entry_set_max_length(GTK_ENTRY(td->recp_bankcode_entry), 11);
+        gtk_entry_set_max_length(GTK_ENTRY(td->recp_account_entry), 34);
+    }
+
+    gtk_label_set_text(GTK_LABEL(orig_name_label), ab_ownername);
+    gtk_label_set_text(GTK_LABEL(orig_account_label), ab_accountnumber);
+    gtk_label_set_text(GTK_LABEL(orig_bankname_label), ab_bankname);
+    gtk_label_set_text (GTK_LABEL (orig_bankcode_label), ab_bankcode);
+
+    /* Fill list for choosing a transaction template */
+    td->template_list_store = gtk_list_store_new(TEMPLATE_NUM_COLUMNS,
+                              G_TYPE_STRING, G_TYPE_POINTER);
+    g_list_foreach(templates, gnc_ab_trans_dialog_fill_templ_helper, td->template_list_store);
+    gtk_tree_view_set_model(td->template_gtktreeview,
+                            GTK_TREE_MODEL(td->template_list_store));
+    td->templ_changed = FALSE;
+    /* Keep a reference to the store */
+
+    /* Show this list */
+    renderer = gtk_cell_renderer_text_new();
+    column = gtk_tree_view_column_new_with_attributes(
+                 "Template Name", renderer, "text", TEMPLATE_NAME, NULL);
+    gtk_tree_view_append_column(td->template_gtktreeview, column);
+
+    /* Connect the Signals */
+    gtk_builder_connect_signals_full(builder, gnc_builder_connect_full_func, td);
+
+    g_object_unref(G_OBJECT(builder));
+
+    /* Disabled OK button until suitable values are filled */
+    gnc_ab_trans_dialog_verify_values(td);
+
+    return td;
+}
+
+static void
+gnc_ab_trans_dialog_entry_set (GtkWidget* entry,
+                               const gchar* message,
+                               const gchar* stock_icon)
+{
+    g_object_set (entry,
+                  "secondary-icon-stock", stock_icon,
+                  "secondary-icon-tooltip-text", message,
+                  NULL);
+}
+
+static void
+gnc_ab_trans_dialog_check_ktoblzcheck(const GncABTransDialog *td,
+                                      const AB_TRANSACTION *trans)
+{
+#ifndef HAVE_KTOBLZCHECK_H
+    return;
+#else
+    gint blzresult;
+    const char *blztext;
+    gchar* message;
+
+    ENTER(" ");
+
+    if (gnc_ab_trans_isSEPA(td->trans_type))
+    {
+        // FIXME: libktoblzcheck also has <iban.h>, maybe add this here?
+        LEAVE("No ktoblzcheck implemented for IBAN");
+        return;
+    }
+
+    blzresult = AccountNumberCheck_check(
+                    td->blzcheck,
+                    AB_Transaction_GetRemoteBankCode(trans),
+                    AB_Transaction_GetRemoteAccountNumber(trans));
+    switch (blzresult)
+    {
+    case 2:
+        message = g_strdup_printf(_("The internal check of the destination account number '%s' "
+                                    "at the specified bank with bank code '%s' failed. This means "
+                                    "the account number might contain an error."),
+                                  AB_Transaction_GetRemoteAccountNumber(trans),
+                                  AB_Transaction_GetRemoteBankCode(trans));
+        gnc_ab_trans_dialog_entry_set (td->recp_bankcode_entry, message,
+                                       GTK_STOCK_DIALOG_WARNING);
+        gnc_ab_trans_dialog_entry_set (td->recp_account_entry, message,
+                                       GTK_STOCK_DIALOG_WARNING);
+
+        blztext = "Kontonummer wahrscheinlich falsch";
+        break;
+    case 0:
+        blztext = "Kontonummer ok";
+        break;
+    case 3:
+        blztext = "bank unbekannt";
+        break;
+    case 1:
+    default:
+        blztext = "unbekannt aus unbekanntem grund";
+        break;
+    }
+
+    if (blzresult != 2)
+    {
+        gnc_ab_trans_dialog_entry_set (td->recp_bankcode_entry, "",
+                                       NULL);
+        gnc_ab_trans_dialog_entry_set (td->recp_account_entry, "",
+                                       NULL);
+    }
+
+    LEAVE("KtoBlzCheck said check is %d = %s",
+          blzresult, blztext ? blztext : "(none)");
+#endif
+}
+
+static void
+gnc_ab_trans_dialog_clear_transaction(GncABTransDialog *td)
+{
+    AB_Transaction_free(td->ab_trans);
+    td->ab_trans = NULL;
+}
+
+void
+gnc_ab_trans_dialog_verify_values(GncABTransDialog *td)
+{
+    gchar* purpose;
+    gchar* othername;
+    const gchar* account;
+    const gchar* bankcode;
+
+    gboolean values_ok = TRUE;
+
+    GtkWidget *amount_entry = gnc_amount_edit_gtk_entry(GNC_AMOUNT_EDIT(td->amount_edit));
+
+    /* Fill in the values from the entry fields into a new
+     * AB_TRANSACTION */
+    td->ab_trans = gnc_ab_trans_dialog_fill_values(td);
+
+    // Verify that we have a local IBAN and BIC
+    if (gnc_ab_trans_isSEPA(td->trans_type))
+    {
+        const char* localBIC = AB_Transaction_GetLocalBic(td->ab_trans);
+        const char* localIBAN = AB_Transaction_GetLocalIban(td->ab_trans);
+        if (!localBIC || !localIBAN
+                || (strlen(localBIC) == 0) || (strlen(localIBAN) == 0))
+        {
+            const char* localBankCode = AB_Transaction_GetLocalBankCode(td->ab_trans);
+            const char* localAccountCode = AB_Transaction_GetLocalAccountNumber(td->ab_trans);
+            values_ok = FALSE;
+            gnc_error_dialog(td->dialog,
+                             _("Your local bank account does not yet have the SEPA account information stored."
+                               " We are sorry, but in this development version one additional step is necessary "
+                               "which has not yet been implemented directly in gnucash. "
+                               "Please execute the command line program \"aqhbci-tool\" for your account, as follows: "
+                               "aqhbci-tool4 getaccsepa -b %s -a %s"),
+                             (localBankCode ? localBankCode : ""),
+                             (localAccountCode ? localAccountCode : ""));
+        }
+    }
+
+    /* Check recipient / remote name */
+    othername = gnc_ab_get_remote_name(td->ab_trans);
+    if (!othername || !strlen(othername))
+    {
+        gnc_ab_trans_dialog_entry_set (td->recp_name_entry,
+                                       _("You did not enter a recipient name. A recipient name is "
+                                         "required for an online transfer.\n"),
+                                       GTK_STOCK_CANCEL);
+
+        g_free (othername);
+        values_ok = FALSE;
+    }
+    else
+    {
+        gnc_ab_trans_dialog_entry_set (td->recp_name_entry, "", NULL);
+        g_free(othername);
+    }
+
+    /* Check account */
+    account = gnc_ab_trans_isSEPA(td->trans_type)
+            ? AB_Transaction_GetRemoteIban(td->ab_trans)
+            : AB_Transaction_GetRemoteAccountNumber(td->ab_trans);
+    if (!account || !strlen(account))
+    {
+        gnc_ab_trans_dialog_entry_set (td->recp_account_entry,
+                                       _("You did not enter a recipient account. A recipient account is "
+                                         "required for an online transfer.\n"),
+                                       GTK_STOCK_CANCEL);
+        values_ok = FALSE;
+    }
+    else
+    {
+        gnc_ab_trans_dialog_entry_set (td->recp_account_entry, "", NULL);
+    }
+    /* Check bank */
+    bankcode = gnc_ab_trans_isSEPA(td->trans_type)
+            ? AB_Transaction_GetRemoteBic(td->ab_trans)
+            : AB_Transaction_GetRemoteBankCode(td->ab_trans);
+    if (!bankcode || !strlen(bankcode))
+    {
+        gnc_ab_trans_dialog_entry_set (td->recp_bankcode_entry,
+                                       _("You did not enter a recipient bank. A recipient bank is "
+                                         "required for an online transfer.\n"),
+                                       GTK_STOCK_CANCEL);
+        values_ok = FALSE;
+    }
+    else
+    {
+        gnc_ab_trans_dialog_entry_set (td->recp_bankcode_entry, "", NULL);
+    }
+    /* Check if account details are correct - gives warning only */
+    if (values_ok)
+        gnc_ab_trans_dialog_check_ktoblzcheck(td, td->ab_trans);
+
+    /* Check transaction value */
+    if (AB_Value_GetValueAsDouble(AB_Transaction_GetValue(td->ab_trans))
+            == 0.0)
+    {
+        gnc_ab_trans_dialog_entry_set (amount_entry,
+                                       _("The amount is zero or the amount field could not be "
+                                         "interpreted correctly. You might have mixed up decimal "
+                                         "point and comma, compared to your locale settings. "
+                                         "This does not result in a valid online transfer job."),
+                                       GTK_STOCK_CANCEL);
+        values_ok = FALSE;
+    }
+    else
+    {
+        gnc_ab_trans_dialog_entry_set (amount_entry, "", NULL);
+    }
+
+    /* Check transaction purpose */
+    purpose = gnc_ab_get_purpose(td->ab_trans);
+    if (!purpose || !strlen(purpose))
+    {
+        gnc_ab_trans_dialog_entry_set (td->purpose_entry,
+                                       _("You did not enter any transaction purpose. A purpose is "
+                                         "required for an online transfer.\n"),
+                                       GTK_STOCK_CANCEL);
+        g_free (purpose);
+        values_ok = FALSE;
+    }
+    else
+    {
+        gnc_ab_trans_dialog_entry_set (td->purpose_entry, "", NULL);
+        g_free(purpose);
+    }
+
+    gtk_widget_set_sensitive(td->exec_button, values_ok);
+    gnc_ab_trans_dialog_clear_transaction(td);
+}
+
+gint
+gnc_ab_trans_dialog_run_until_ok(GncABTransDialog *td)
+{
+    gint result;
+    AB_JOB *job;
+    const AB_TRANSACTION_LIMITS *joblimits;
+    guint8 max_purpose_lines;
+
+    /* Check whether the account supports this job */
+    job = gnc_ab_trans_dialog_get_available_empty_job(td->ab_acc, td->trans_type);
+    if (!job)
+    {
+        g_warning("gnc_ab_trans_dialog_run_until_ok: Oops, job not available");
+        return GTK_RESPONSE_CANCEL;
+    }
+
+    /* Activate as many purpose entries as available for the job */
+    joblimits = AB_JobSingleTransfer_GetFieldLimits(job);
+    max_purpose_lines = joblimits ?
+                        AB_TransactionLimits_GetMaxLinesPurpose(joblimits) : 2;
+    gtk_widget_set_sensitive(td->purpose_cont_entry, max_purpose_lines > 1);
+    gtk_widget_set_sensitive(td->purpose_cont2_entry, max_purpose_lines > 2);
+    gtk_widget_set_sensitive(td->purpose_cont3_entry, max_purpose_lines > 3);
+
+    /* Show the dialog */
+    gtk_widget_show(td->dialog);
+
+    /* Now run the dialog until it gets closed by a button press */
+    result = gtk_dialog_run (GTK_DIALOG (td->dialog));
+
+    /* Was cancel pressed or dialog closed?
+     *  GNC_RESPONSE_NOW == execute now
+     *  GNC_RESPONSE_LATER == scheduled for later execution (unimplemented)
+     *  GTK_RESPONSE_CANCEL == cancel
+     *  GTK_RESPONSE_DELETE_EVENT == window destroyed */
+    if (result != GNC_RESPONSE_NOW && result != GNC_RESPONSE_LATER)
+    {
+        gtk_widget_destroy(td->dialog);
+        td->dialog = NULL;
+        return result;
+    }
+
+    /* Get the transaction details - have been checked beforehand */
+    td->ab_trans = gnc_ab_trans_dialog_fill_values(td);
+
+    /* FIXME: If this is a direct debit, set the textkey/ "Textschluessel"/
+     * transactionCode according to some GUI selection here!! */
+    /*if (td->trans_type == SINGLE_DEBITNOTE)
+    AB_TRANSACTION_setTextKey (td->hbci_trans, 05); */
+
+
+    /* Hide the dialog */
+    if (td->dialog)
+        gtk_widget_hide(td->dialog);
+
+    return result;
+}
+
+static gboolean
+gnc_ab_trans_dialog_clear_templ_helper(GtkTreeModel *model,
+                                       GtkTreePath *path,
+                                       GtkTreeIter *iter,
+                                       gpointer user_data)
+{
+    GncABTransTempl *templ;
+
+    g_return_val_if_fail(model && iter, TRUE);
+
+    gtk_tree_model_get(model, iter, TEMPLATE_POINTER, &templ, -1);
+    gnc_ab_trans_templ_free(templ);
+    return FALSE;
+}
+
+void
+gnc_ab_trans_dialog_free(GncABTransDialog *td)
+{
+    if (!td) return;
+    if (td->ab_trans)
+        AB_Transaction_free(td->ab_trans);
+    if (td->dialog)
+        gtk_widget_destroy(td->dialog);
+    if (td->template_list_store)
+    {
+        gtk_tree_model_foreach(GTK_TREE_MODEL(td->template_list_store),
+                               gnc_ab_trans_dialog_clear_templ_helper, NULL);
+        g_object_unref(td->template_list_store);
+    }
+#if HAVE_KTOBLZCHECK_H
+    AccountNumberCheck_delete(td->blzcheck);
+#endif
+    g_free(td);
+}
+
+static gboolean
+gnc_ab_trans_dialog_get_templ_helper(GtkTreeModel *model,
+                                     GtkTreePath *path,
+                                     GtkTreeIter *iter,
+                                     gpointer data)
+{
+    GList **list = data;
+    GncABTransTempl *templ;
+
+    g_return_val_if_fail(model && iter, TRUE);
+
+    gtk_tree_model_get(model, iter, TEMPLATE_POINTER, &templ, -1);
+    *list = g_list_prepend(*list, templ);
+    return FALSE;
+}
+
+GList *
+gnc_ab_trans_dialog_get_templ(const GncABTransDialog *td, gboolean *changed)
+{
+    GList *list = NULL;
+
+    g_return_val_if_fail(td, NULL);
+
+    if (changed)
+    {
+        *changed = td->templ_changed;
+        if (!*changed)
+            return NULL;
+    }
+
+    gtk_tree_model_foreach(GTK_TREE_MODEL(td->template_list_store),
+                           gnc_ab_trans_dialog_get_templ_helper, &list);
+    list = g_list_reverse(list);
+    return list;
+}
+
+GtkWidget *
+gnc_ab_trans_dialog_get_parent(const GncABTransDialog *td)
+{
+    g_return_val_if_fail(td, NULL);
+    return td->parent;
+}
+
+const AB_TRANSACTION *
+gnc_ab_trans_dialog_get_ab_trans(const GncABTransDialog *td)
+{
+    g_return_val_if_fail(td, NULL);
+    return td->ab_trans;
+}
+
+static AB_JOB *
+gnc_ab_trans_dialog_get_available_empty_job(AB_ACCOUNT *ab_acc, GncABTransType trans_type)
+{
+    AB_JOB *job;
+
+    switch (trans_type)
+    {
+    case SINGLE_DEBITNOTE:
+        job = AB_JobSingleDebitNote_new(ab_acc);
+        break;
+    case SINGLE_INTERNAL_TRANSFER:
+        job = AB_JobInternalTransfer_new(ab_acc);
+        break;
+    case SEPA_TRANSFER:
+        job = AB_JobSepaTransfer_new(ab_acc);
+        break;
+    case SEPA_DEBITNOTE:
+        job = AB_JobSepaDebitNote_new(ab_acc);
+        break;
+    case SINGLE_TRANSFER:
+    default:
+        job = AB_JobSingleTransfer_new(ab_acc);
+        break;
+    };
+
+    if (!job || AB_Job_CheckAvailability(job
+#ifndef AQBANKING_VERSION_5_PLUS
+                                         , 0
+#endif
+                                        ))
+    {
+        if (job) AB_Job_free(job);
+        return NULL;
+    }
+    return job;
+}
+
+AB_JOB *
+gnc_ab_trans_dialog_get_job(const GncABTransDialog *td)
+{
+    g_return_val_if_fail(td, NULL);
+    return gnc_ab_get_trans_job(td->ab_acc, td->ab_trans, td->trans_type);
+}
+
+AB_JOB *
+gnc_ab_get_trans_job(AB_ACCOUNT *ab_acc, const AB_TRANSACTION *ab_trans,
+                     GncABTransType trans_type)
+{
+    AB_JOB *job;
+
+    g_return_val_if_fail(ab_acc && ab_trans, NULL);
+
+    job = gnc_ab_trans_dialog_get_available_empty_job(ab_acc, trans_type);
+    if (job)
+    {
+        switch (trans_type)
+        {
+        case SINGLE_DEBITNOTE:
+            AB_JobSingleDebitNote_SetTransaction(job, ab_trans);
+            break;
+        case SINGLE_INTERNAL_TRANSFER:
+            AB_JobInternalTransfer_SetTransaction(job, ab_trans);
+            break;
+        case SEPA_TRANSFER:
+            AB_JobSepaTransfer_SetTransaction(job, ab_trans);
+            break;
+        case SEPA_DEBITNOTE:
+            AB_JobSepaDebitNote_SetTransaction(job, ab_trans);
+            break;
+        case SINGLE_TRANSFER:
+        default:
+            AB_JobSingleTransfer_SetTransaction(job, ab_trans);
+            break;
+        };
+    }
+    return job;
+}
+
+void
+gnc_ab_trans_dialog_templ_list_row_activated_cb(GtkTreeView *view,
+        GtkTreePath *path,
+        GtkTreeViewColumn *column,
+        gpointer user_data)
+{
+    GncABTransDialog *td = user_data;
+    GtkTreeIter iter;
+    GncABTransTempl *templ;
+    const gchar *old_name, *new_name;
+    const gchar *old_account, *new_account;
+    const gchar *old_bankcode, *new_bankcode;
+    const gchar *old_purpose, *new_purpose;
+    const gchar *old_purpose_cont, *new_purpose_cont;
+    GtkWidget *amount_widget;
+    const gchar *old_amount_text;
+    gnc_numeric old_amount, new_amount;
+
+    g_return_if_fail(td);
+
+    ENTER("td=%p", td);
+    if (!gtk_tree_model_get_iter(GTK_TREE_MODEL(td->template_list_store), &iter,
+                                 path))
+    {
+        LEAVE("Could not get iter");
+        return;
+    }
+    gtk_tree_model_get(GTK_TREE_MODEL(td->template_list_store), &iter,
+                       TEMPLATE_POINTER, &templ, -1);
+
+    /* Get old values */
+    old_name = gtk_entry_get_text(GTK_ENTRY(td->recp_name_entry));
+    old_account = gtk_entry_get_text(GTK_ENTRY(td->recp_account_entry));
+    old_bankcode = gtk_entry_get_text(GTK_ENTRY(td->recp_bankcode_entry));
+    old_purpose = gtk_entry_get_text(GTK_ENTRY(td->purpose_entry));
+    old_purpose_cont = gtk_entry_get_text(GTK_ENTRY(td->purpose_cont_entry));
+    amount_widget = gnc_amount_edit_gtk_entry(GNC_AMOUNT_EDIT(td->amount_edit));
+    old_amount_text = gtk_entry_get_text(GTK_ENTRY(amount_widget));
+    old_amount = gnc_amount_edit_get_amount(GNC_AMOUNT_EDIT(td->amount_edit));
+
+    /* Get new values */
+    new_name = gnc_ab_trans_templ_get_recp_name(templ);
+    new_account = gnc_ab_trans_templ_get_recp_account(templ);
+    new_bankcode = gnc_ab_trans_templ_get_recp_bankcode(templ);
+    new_purpose = gnc_ab_trans_templ_get_purpose(templ);
+    new_purpose_cont = gnc_ab_trans_templ_get_purpose_cont(templ);
+    new_amount = gnc_ab_trans_templ_get_amount(templ);
+    if (!new_name) new_name = "";
+    if (!new_account) new_account = "";
+    if (!new_bankcode) new_bankcode = "";
+    if (!new_purpose) new_purpose = "";
+    if (!new_purpose_cont) new_purpose_cont = "";
+
+    /* Fill in */
+    gtk_entry_set_text(GTK_ENTRY(td->recp_name_entry), new_name);
+    gtk_entry_set_text(GTK_ENTRY(td->recp_account_entry), new_account);
+    gtk_entry_set_text(GTK_ENTRY(td->recp_bankcode_entry), new_bankcode);
+    gtk_entry_set_text(GTK_ENTRY(td->purpose_entry), new_purpose);
+    gtk_entry_set_text(GTK_ENTRY(td->purpose_cont_entry), new_purpose_cont);
+    gnc_amount_edit_set_amount(GNC_AMOUNT_EDIT(td->amount_edit), new_amount);
+    LEAVE(" ");
+}
+
+void
+gnc_ab_trans_dialog_bankcode_changed_cb(GtkEditable *editable, gpointer user_data)
+{
+#if HAVE_KTOBLZCHECK_H
+    GncABTransDialog *td = user_data;
+    const AccountNumberCheck_Record *record;
+    const gchar *input = gtk_entry_get_text(GTK_ENTRY(td->recp_bankcode_entry));
+
+    g_return_if_fail(td);
+
+    // FIXME: If this is a SEPA transaction, totally different verification
+    // rules apply anyway. There are some initial verification functions in
+    // <ktoblzcheck/iban.h>, but those need to be implemented here as well.
+    if (gnc_ab_trans_isSEPA(td->trans_type))
+        return;
+
+    ENTER("td=%p, input=%s", td, input);
+    record = AccountNumberCheck_findBank(td->blzcheck, input);
+
+    if (record)
+    {
+        const char *bankname = AccountNumberCheck_Record_bankName(record);
+        GError *error = NULL;
+        const char *ktoblzcheck_encoding =
+#ifdef KTOBLZCHECK_VERSION_MAJOR
+            /* This version number macro has been added in ktoblzcheck-1.10, but
+             * this function exists already since ktoblzcheck-1.7, so we're on
+             * the safe side. */
+            AccountNumberCheck_stringEncoding()
+#else
+            /* Every ktoblzcheck release before 1.10 is guaranteed to return
+             * strings only in ISO-8859-15. */
+            "ISO-8859-15"
+#endif
+            ;
+        gchar *utf8_bankname = g_convert(bankname, strlen(bankname), "UTF-8",
+                                         ktoblzcheck_encoding, NULL, NULL,
+                                         &error);
+
+        if (error)
+        {
+            g_critical("Error converting bankname \"%s\" to UTF-8", bankname);
+            g_error_free (error);
+            /* Conversion was erroneous, so don't use the string */
+            utf8_bankname = g_strdup(_("(unknown)"));
+        }
+        gtk_label_set_text(GTK_LABEL(td->recp_bankname_label),
+                           *utf8_bankname ? utf8_bankname : _("(unknown)"));
+        DEBUG("Found: %s", utf8_bankname);
+        g_free(utf8_bankname);
+    }
+    else
+    {
+        gtk_label_set_text(GTK_LABEL(td->recp_bankname_label), _("(unknown)"));
+    }
+    gnc_ab_trans_dialog_verify_values(td);
+    LEAVE(" ");
+#endif
+}
+
+struct _FindTemplData
+{
+    const gchar *name;
+    const GncABTransTempl *pointer;
+};
+
+static gboolean
+find_templ_helper(GtkTreeModel *model, GtkTreePath *path, GtkTreeIter *iter,
+                  gpointer user_data)
+{
+    struct _FindTemplData *data = user_data;
+    gchar *name;
+    GncABTransTempl *templ;
+    gboolean match;
+
+    g_return_val_if_fail(model && data, TRUE);
+    gtk_tree_model_get(model, iter,
+                       TEMPLATE_NAME, &name,
+                       TEMPLATE_POINTER, &templ,
+                       -1);
+    if (data->name)
+    {
+        /* Search for the template by name */
+        g_return_val_if_fail(!data->pointer, TRUE);
+        match = strcmp(name, data->name) == 0;
+        if (match) data->pointer = templ;
+    }
+    else
+    {
+        /* Search for the template by template pointer */
+        g_return_val_if_fail(!data->name, TRUE);
+        match = templ == data->pointer;
+        if (match) data->name = g_strdup(name);
+    }
+    g_free(name);
+    return match;
+}
+
+void
+gnc_ab_trans_dialog_add_templ_cb(GtkButton *button, gpointer user_data)
+{
+    GncABTransDialog *td = user_data;
+    GtkBuilder *builder;
+    GtkWidget *dialog;
+    GtkWidget *entry;
+    gint retval;
+    const gchar *name;
+    GncABTransTempl *templ;
+    struct _FindTemplData data;
+    GtkTreeSelection *selection;
+    GtkTreeIter cur_iter;
+    GtkTreeIter new_iter;
+
+    g_return_if_fail(td);
+
+    ENTER("td=%p", td);
+    builder = gtk_builder_new();
+    gnc_builder_add_from_file (builder, "dialog-ab.glade", "Template Name Dialog");
+    dialog = GTK_WIDGET(gtk_builder_get_object (builder, "Template Name Dialog"));
+
+    entry = GTK_WIDGET(gtk_builder_get_object (builder, "template_name"));
+
+    /* Suggest recipient name as name of the template */
+    gtk_entry_set_text(GTK_ENTRY(entry),
+                       gtk_entry_get_text(GTK_ENTRY(td->recp_name_entry)));
+
+    do
+    {
+        retval = gtk_dialog_run(GTK_DIALOG(dialog));
+        if (retval != GTK_RESPONSE_OK)
+            break;
+
+        name = gtk_entry_get_text(GTK_ENTRY(entry));
+        if (!*name)
+            break;
+
+        data.name = name;
+        data.pointer = NULL;
+        gtk_tree_model_foreach(GTK_TREE_MODEL(td->template_list_store),
+                               find_templ_helper, &data);
+        if (data.pointer)
+        {
+            gnc_error_dialog(dialog, "%s",
+                             _("A template with the given name already exists. "
+                               "Please enter another name."));
+            continue;
+        }
+
+        /* Create a new template */
+        templ = gnc_ab_trans_templ_new_full(
+                    name,
+                    gtk_entry_get_text(GTK_ENTRY(td->recp_name_entry)),
+                    gtk_entry_get_text(GTK_ENTRY(td->recp_account_entry)),
+                    gtk_entry_get_text(GTK_ENTRY(td->recp_bankcode_entry)),
+                    gnc_amount_edit_get_amount(GNC_AMOUNT_EDIT(td->amount_edit)),
+                    gtk_entry_get_text(GTK_ENTRY(td->purpose_entry)),
+                    gtk_entry_get_text (GTK_ENTRY(td->purpose_cont_entry)));
+
+        /* Insert it, either after the selected one or at the end */
+        selection = gtk_tree_view_get_selection(td->template_gtktreeview);
+        if (gtk_tree_selection_get_selected(selection, NULL, &cur_iter))
+        {
+            gtk_list_store_insert_after(td->template_list_store,
+                                        &new_iter, &cur_iter);
+        }
+        else
+        {
+            gtk_list_store_append(td->template_list_store, &new_iter);
+        }
+        gtk_list_store_set(td->template_list_store, &new_iter,
+                           TEMPLATE_NAME, name,
+                           TEMPLATE_POINTER, templ,
+                           -1);
+        td->templ_changed = TRUE;
+        DEBUG("Added template with name %s", name);
+        break;
+    }
+    while (TRUE);
+
+    g_object_unref(G_OBJECT(builder));
+
+    gtk_widget_destroy(dialog);
+
+    LEAVE(" ");
+}
+
+void
+gnc_ab_trans_dialog_moveup_templ_cb(GtkButton *button, gpointer user_data)
+{
+    GncABTransDialog *td = user_data;
+    GtkTreeSelection *selection;
+    GtkTreeModel *model;
+    GtkTreeIter iter;
+    GtkTreePath *prev_path;
+    GtkTreeIter prev_iter;
+
+    g_return_if_fail(td);
+
+    selection = gtk_tree_view_get_selection(td->template_gtktreeview);
+    if (!gtk_tree_selection_get_selected(selection, &model, &iter))
+        return;
+
+    prev_path = gtk_tree_model_get_path(model, &iter);
+    if (gtk_tree_path_prev(prev_path))
+    {
+        if (gtk_tree_model_get_iter(model, &prev_iter, prev_path))
+        {
+            gtk_list_store_move_before(GTK_LIST_STORE(model), &iter, &prev_iter);
+            td->templ_changed = TRUE;
+        }
+    }
+    gtk_tree_path_free(prev_path);
+}
+
+void
+gnc_ab_trans_dialog_movedown_templ_cb(GtkButton *button, gpointer user_data)
+{
+    GncABTransDialog *td = user_data;
+    GtkTreeSelection *selection;
+    GtkTreeModel *model;
+    GtkTreeIter iter;
+    GtkTreeIter next_iter;
+
+    g_return_if_fail(td);
+
+    selection = gtk_tree_view_get_selection(td->template_gtktreeview);
+    if (!gtk_tree_selection_get_selected (selection, &model, &iter))
+        return;
+
+    next_iter = iter;
+    if (gtk_tree_model_iter_next(model, &next_iter))
+    {
+        gtk_list_store_move_after(GTK_LIST_STORE(model), &iter, &next_iter);
+        td->templ_changed = TRUE;
+    }
+}
+
+void
+gnc_ab_trans_dialog_sort_templ_cb(GtkButton *button, gpointer user_data)
+{
+    GncABTransDialog *td = user_data;
+
+    g_return_if_fail(td);
+
+    ENTER("td=%p", td);
+    gtk_tree_sortable_set_sort_column_id(
+        GTK_TREE_SORTABLE(td->template_list_store),
+        TEMPLATE_NAME, GTK_SORT_ASCENDING);
+    gtk_tree_sortable_set_sort_column_id(
+        GTK_TREE_SORTABLE(td->template_list_store),
+        GTK_TREE_SORTABLE_UNSORTED_SORT_COLUMN_ID,
+        GTK_SORT_ASCENDING);
+    td->templ_changed = TRUE;
+    LEAVE(" ");
+}
+
+void
+gnc_ab_trans_dialog_del_templ_cb(GtkButton *button, gpointer user_data)
+{
+    GncABTransDialog *td = user_data;
+    GtkTreeSelection *selection;
+    GtkTreeModel *model;
+    GtkTreeIter iter;
+    gchar *name;
+
+    g_return_if_fail(td);
+
+    ENTER("td=%p", td);
+    selection = gtk_tree_view_get_selection(td->template_gtktreeview);
+    if (!gtk_tree_selection_get_selected (selection, &model, &iter))
+    {
+        LEAVE("None selected");
+        return;
+    }
+
+    gtk_tree_model_get(model, &iter, TEMPLATE_NAME, &name, -1);
+    if (gnc_verify_dialog(
+                td->parent, FALSE,
+                _("Do you really want to delete the template with the name \"%s\"?"),
+                name))
+    {
+        gtk_list_store_remove(GTK_LIST_STORE(model), &iter);
+        td->templ_changed = TRUE;
+        DEBUG("Deleted template with name %s", name);
+    }
+    g_free(name);
+    LEAVE(" ");
+}
+
+void
+gnc_ab_trans_dialog_entry_filter_cb (GtkEditable *editable,
+                                     const gchar *text,
+                                     gint         length,
+                                     gint        *position,
+                                     gpointer     data)
+{
+    GString* result = g_string_new(NULL);
+    gint i;
+    GncABTransDialog *td = data;
+
+    if (length == -1)
+        length = strlen(text);
+
+    /* Filter non digits */
+    for (i = 0; i < length; i++)
+    {
+        gchar c = text[i];
+
+        // Only accept digits. FIXME: In the SEPA dialogs, alphanumerics are
+        // allowed, but we could also verify the input according to actual BIC
+        // and IBAN rules. This is not yet done here.
+        if (g_ascii_isdigit(c)
+                || (gnc_ab_trans_isSEPA(td->trans_type) && g_ascii_isalnum(c)))
+        {
+            g_string_append_c(result, c);
+        }
+    }
+
+    g_signal_handlers_block_by_func (editable,
+                                     (gpointer) gnc_ab_trans_dialog_entry_filter_cb, data);
+    gtk_editable_insert_text (editable, result->str, result->len, position);
+    g_signal_handlers_unblock_by_func (editable,
+                                       (gpointer) gnc_ab_trans_dialog_entry_filter_cb, data);
+    g_signal_stop_emission_by_name (editable, "insert_text");
+    g_string_free (result, TRUE);
+}

Copied: gnucash/trunk/src/import-export/aqb/dialog-ab-trans.h (from rev 23566, gnucash/trunk/src/import-export/aqbanking/dialog-ab-trans.h)
===================================================================
--- gnucash/trunk/src/import-export/aqb/dialog-ab-trans.h	                        (rev 0)
+++ gnucash/trunk/src/import-export/aqb/dialog-ab-trans.h	2013-12-15 17:21:20 UTC (rev 23567)
@@ -0,0 +1,153 @@
+/*
+ * dialog-ab-trans.h --
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, contact:
+ *
+ * Free Software Foundation           Voice:  +1-617-542-5942
+ * 51 Franklin Street, Fifth Floor    Fax:    +1-617-542-2652
+ * Boston, MA  02110-1301,  USA       gnu at gnu.org
+ */
+
+/**
+ * @addtogroup Import_Export
+ * @{
+ * @addtogroup AqBanking
+ * @{
+ * @file dialog-ab-trans.h
+ * @brief Dialog for AqBanking transaction data
+ * @author Copyright (C) 2002 Christian Stimming <stimming at tuhh.de>
+ * @author Copyright (C) 2004 Bernd Wagner
+ * @author Copyright (C) 2006 David Hampton <hampton at employees.org>
+ * @author Copyright (C) 2008 Andreas Koehler <andi5.py at gmx.net>
+ */
+
+#ifndef DIALOG_AB_TRANS_H
+#define DIALOG_AB_TRANS_H
+
+#include <gtk/gtk.h>
+#include <aqbanking/banking.h>
+
+#include "Account.h"
+
+G_BEGIN_DECLS
+
+#define GNC_RESPONSE_NOW GTK_RESPONSE_YES
+#define GNC_RESPONSE_LATER GTK_RESPONSE_NO
+
+typedef struct _GncABTransDialog GncABTransDialog;
+
+typedef enum _GncABTransType GncABTransType;
+enum _GncABTransType
+{
+    SINGLE_TRANSFER = 0,
+    SINGLE_DEBITNOTE,
+    SINGLE_INTERNAL_TRANSFER
+    , SEPA_TRANSFER
+    , SEPA_DEBITNOTE
+};
+/**
+  * Returns true if the given GncABTransType is an European (SEPA) transaction
+  * (transfer or debit note), otherwise false.
+  */
+gboolean gnc_ab_trans_isSEPA(GncABTransType t);
+
+/**
+ * Create a new AqBanking transfer dialog
+ *
+ * @param parent Widget to use as parent, may be NULL
+ * @param ab_acc Aqbanking account
+ * @param commodity_scu commodity used for the amount
+ * @param trans_type Type of transaction
+ * @param templates A GList of template transactions which will become fully
+ * managed by the dialog, so do not free it and retrieve snapshots via
+ * gnc_ab_trans_dialog_get_templ()
+ * @return A new GncABTransDialog, free with gnc_ab_trans_dialog_free()
+ */
+GncABTransDialog *gnc_ab_trans_dialog_new(GtkWidget *parent, AB_ACCOUNT *ab_acc,
+        gint commodity_scu,
+        GncABTransType trans_type,
+        GList *templates);
+
+/**
+ * Run the Aqbanking transfer dialog until correct values where entered or
+ * the user cancelled the dialog.
+ *
+ * @param td Transaction dialog
+ * @param ab_acc AqBanking account
+ * @return GTK_RESPONSE_CANCEL or GTK_RESPONSE_DESTROY_EVENT if the user cancelled the dialog
+ * and GNC_RESPONSE_NOW otherwise.
+ */
+gint gnc_ab_trans_dialog_run_until_ok(GncABTransDialog *td);
+
+/**
+ * Free a Aqbanking transfer dialog
+ *
+ * @param td Transaction dialog
+ */
+void gnc_ab_trans_dialog_free(GncABTransDialog *td);
+
+/**
+ * Retrieve the current list of transaction templates from the dialog @a
+ * td, unless @a changed is a specified location and the templates have
+ * not been touched by the user.
+ *
+ * @param td Transaction dialog
+ * @param changed Location to store whether the templates have been
+ * changed, may be NULL
+ * @return The a newly allocated list of the internal transaction
+ * templates. Free this one via g_list_free().
+ */
+GList *gnc_ab_trans_dialog_get_templ(const GncABTransDialog *td,
+                                     gboolean *changed);
+
+/**
+ * Retrieve the widget used as parent.
+ *
+ * @param td Transaction dialog
+ * @return The parent
+ */
+GtkWidget *gnc_ab_trans_dialog_get_parent(const GncABTransDialog *td);
+
+/**
+ * Receive the Aqbanking Transaction filled by the dialog
+ *
+ * @param td Transaction dialog
+ * @return An Aqbanking transaction
+ */
+const AB_TRANSACTION *gnc_ab_trans_dialog_get_ab_trans(
+    const GncABTransDialog *td);
+
+/**
+ * Receive the Aqbanking job associated with the transaction
+ *
+ * @param td Transaction dialog
+ * @return An Aqbanking job
+ */
+AB_JOB *gnc_ab_trans_dialog_get_job(const GncABTransDialog *td);
+
+/**
+ * FIXME
+ *
+ * @param td Transaction dialog
+ * @return FIXME
+ */
+AB_JOB *gnc_ab_get_trans_job(AB_ACCOUNT *ab_acc, const AB_TRANSACTION *ab_trans,
+                             GncABTransType trans_type);
+
+G_END_DECLS
+
+/** @} */
+/** @} */
+
+#endif /* DIALOG_AB_TRANS_H */

Copied: gnucash/trunk/src/import-export/aqb/dialog-ab.glade (from rev 23566, gnucash/trunk/src/import-export/aqbanking/dialog-ab.glade)
===================================================================
--- gnucash/trunk/src/import-export/aqb/dialog-ab.glade	                        (rev 0)
+++ gnucash/trunk/src/import-export/aqb/dialog-ab.glade	2013-12-15 17:21:20 UTC (rev 23567)
@@ -0,0 +1,1868 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<interface>
+  <requires lib="gtk+" version="2.16"/>
+  <object class="GtkDialog" id="Connection Dialog">
+    <property name="can_focus">False</property>
+    <property name="border_width">5</property>
+    <property name="title" translatable="yes">Online Banking Connection Window</property>
+    <property name="default_width">350</property>
+    <property name="default_height">420</property>
+    <property name="type_hint">dialog</property>
+    <signal name="delete-event" handler="ggg_delete_event_cb" swapped="no"/>
+    <child internal-child="vbox">
+      <object class="GtkBox" id="dialog-vbox9">
+        <property name="visible">True</property>
+        <property name="can_focus">False</property>
+        <property name="spacing">2</property>
+        <child internal-child="action_area">
+          <object class="GtkButtonBox" id="dialog-action_area9">
+            <property name="visible">True</property>
+            <property name="can_focus">False</property>
+            <property name="layout_style">end</property>
+            <child>
+              <object class="GtkButton" id="abort_button">
+                <property name="label">gtk-cancel</property>
+                <property name="visible">True</property>
+                <property name="sensitive">False</property>
+                <property name="can_focus">True</property>
+                <property name="can_default">True</property>
+                <property name="receives_default">True</property>
+                <property name="use_action_appearance">False</property>
+                <property name="use_stock">True</property>
+                <signal name="clicked" handler="ggg_abort_clicked_cb" swapped="no"/>
+              </object>
+              <packing>
+                <property name="expand">False</property>
+                <property name="fill">False</property>
+                <property name="position">0</property>
+              </packing>
+            </child>
+            <child>
+              <object class="GtkButton" id="close_button">
+                <property name="label">gtk-close</property>
+                <property name="visible">True</property>
+                <property name="can_focus">True</property>
+                <property name="can_default">True</property>
+                <property name="receives_default">True</property>
+                <property name="use_action_appearance">False</property>
+                <property name="use_stock">True</property>
+                <signal name="clicked" handler="ggg_close_clicked_cb" swapped="no"/>
+              </object>
+              <packing>
+                <property name="expand">False</property>
+                <property name="fill">False</property>
+                <property name="position">1</property>
+              </packing>
+            </child>
+          </object>
+          <packing>
+            <property name="expand">False</property>
+            <property name="fill">True</property>
+            <property name="pack_type">end</property>
+            <property name="position">0</property>
+          </packing>
+        </child>
+        <child>
+          <object class="GtkVBox" id="vbox149">
+            <property name="visible">True</property>
+            <property name="can_focus">False</property>
+            <property name="border_width">5</property>
+            <property name="spacing">18</property>
+            <child>
+              <object class="GtkVBox" id="vbox160">
+                <property name="visible">True</property>
+                <property name="can_focus">False</property>
+                <property name="spacing">6</property>
+                <child>
+                  <object class="GtkLabel" id="label8877443">
+                    <property name="visible">True</property>
+                    <property name="can_focus">False</property>
+                    <property name="xalign">0</property>
+                    <property name="label" translatable="yes"><b>Progress</b></property>
+                    <property name="use_markup">True</property>
+                  </object>
+                  <packing>
+                    <property name="expand">False</property>
+                    <property name="fill">False</property>
+                    <property name="position">0</property>
+                  </packing>
+                </child>
+                <child>
+                  <object class="GtkAlignment" id="alignment2">
+                    <property name="visible">True</property>
+                    <property name="can_focus">False</property>
+                    <property name="left_padding">12</property>
+                    <child>
+                      <object class="GtkTable" id="entries_table">
+                        <property name="visible">True</property>
+                        <property name="can_focus">False</property>
+                        <property name="n_rows">3</property>
+                        <property name="n_columns">2</property>
+                        <property name="column_spacing">12</property>
+                        <property name="row_spacing">6</property>
+                        <child>
+                          <object class="GtkLabel" id="label8877424">
+                            <property name="visible">True</property>
+                            <property name="can_focus">False</property>
+                            <property name="xalign">0</property>
+                            <property name="label" translatable="yes">Current Job</property>
+                            <property name="justify">center</property>
+                          </object>
+                          <packing>
+                            <property name="x_options">GTK_FILL</property>
+                            <property name="y_options"></property>
+                          </packing>
+                        </child>
+                        <child>
+                          <object class="GtkEntry" id="top_entry">
+                            <property name="visible">True</property>
+                            <property name="can_focus">True</property>
+                            <property name="invisible_char">●</property>
+                            <property name="invisible_char_set">True</property>
+                            <property name="primary_icon_activatable">False</property>
+                            <property name="secondary_icon_activatable">False</property>
+                          </object>
+                          <packing>
+                            <property name="left_attach">1</property>
+                            <property name="right_attach">2</property>
+                            <property name="y_options"></property>
+                          </packing>
+                        </child>
+                        <child>
+                          <object class="GtkProgressBar" id="top_progress">
+                            <property name="visible">True</property>
+                            <property name="sensitive">False</property>
+                            <property name="can_focus">False</property>
+                            <property name="pulse_step">0.10000000149</property>
+                          </object>
+                          <packing>
+                            <property name="left_attach">1</property>
+                            <property name="right_attach">2</property>
+                            <property name="top_attach">1</property>
+                            <property name="bottom_attach">2</property>
+                            <property name="x_options">GTK_FILL</property>
+                            <property name="y_options"></property>
+                          </packing>
+                        </child>
+                        <child>
+                          <object class="GtkLabel" id="label8877426">
+                            <property name="visible">True</property>
+                            <property name="can_focus">False</property>
+                            <property name="xalign">0</property>
+                            <property name="label" translatable="yes">Progress</property>
+                            <property name="justify">center</property>
+                          </object>
+                          <packing>
+                            <property name="top_attach">1</property>
+                            <property name="bottom_attach">2</property>
+                            <property name="x_options">GTK_FILL</property>
+                            <property name="y_options"></property>
+                          </packing>
+                        </child>
+                        <child>
+                          <object class="GtkLabel" id="label8877425">
+                            <property name="visible">True</property>
+                            <property name="can_focus">False</property>
+                            <property name="xalign">0</property>
+                            <property name="label" translatable="yes">Current Action</property>
+                            <property name="justify">center</property>
+                          </object>
+                          <packing>
+                            <property name="top_attach">2</property>
+                            <property name="bottom_attach">3</property>
+                            <property name="x_options">GTK_FILL</property>
+                            <property name="y_options"></property>
+                          </packing>
+                        </child>
+                        <child>
+                          <object class="GtkEntry" id="second_entry">
+                            <property name="visible">True</property>
+                            <property name="can_focus">True</property>
+                            <property name="invisible_char">●</property>
+                            <property name="invisible_char_set">True</property>
+                            <property name="primary_icon_activatable">False</property>
+                            <property name="secondary_icon_activatable">False</property>
+                          </object>
+                          <packing>
+                            <property name="left_attach">1</property>
+                            <property name="right_attach">2</property>
+                            <property name="top_attach">2</property>
+                            <property name="bottom_attach">3</property>
+                            <property name="y_options"></property>
+                          </packing>
+                        </child>
+                      </object>
+                    </child>
+                  </object>
+                  <packing>
+                    <property name="expand">True</property>
+                    <property name="fill">True</property>
+                    <property name="position">1</property>
+                  </packing>
+                </child>
+              </object>
+              <packing>
+                <property name="expand">False</property>
+                <property name="fill">False</property>
+                <property name="position">0</property>
+              </packing>
+            </child>
+            <child>
+              <object class="GtkVBox" id="vbox162">
+                <property name="visible">True</property>
+                <property name="can_focus">False</property>
+                <property name="spacing">6</property>
+                <child>
+                  <object class="GtkLabel" id="label8877444">
+                    <property name="visible">True</property>
+                    <property name="can_focus">False</property>
+                    <property name="xalign">0</property>
+                    <property name="label" translatable="yes"><b>Log Messages</b></property>
+                    <property name="use_markup">True</property>
+                  </object>
+                  <packing>
+                    <property name="expand">False</property>
+                    <property name="fill">False</property>
+                    <property name="position">0</property>
+                  </packing>
+                </child>
+                <child>
+                  <object class="GtkAlignment" id="alignment1">
+                    <property name="visible">True</property>
+                    <property name="can_focus">False</property>
+                    <property name="left_padding">12</property>
+                    <child>
+                      <object class="GtkScrolledWindow" id="scrolledwindow30">
+                        <property name="visible">True</property>
+                        <property name="can_focus">True</property>
+                        <property name="shadow_type">in</property>
+                        <child>
+                          <object class="GtkTextView" id="log_text">
+                            <property name="visible">True</property>
+                            <property name="can_focus">True</property>
+                            <property name="editable">False</property>
+                            <property name="wrap_mode">word</property>
+                          </object>
+                        </child>
+                      </object>
+                    </child>
+                  </object>
+                  <packing>
+                    <property name="expand">True</property>
+                    <property name="fill">True</property>
+                    <property name="position">1</property>
+                  </packing>
+                </child>
+              </object>
+              <packing>
+                <property name="expand">True</property>
+                <property name="fill">True</property>
+                <property name="position">1</property>
+              </packing>
+            </child>
+            <child>
+              <object class="GtkCheckButton" id="close_checkbutton">
+                <property name="label" translatable="yes">Close when finished</property>
+                <property name="visible">True</property>
+                <property name="can_focus">True</property>
+                <property name="receives_default">False</property>
+                <property name="use_action_appearance">False</property>
+                <property name="use_underline">True</property>
+                <property name="active">True</property>
+                <property name="draw_indicator">True</property>
+                <signal name="toggled" handler="ggg_close_toggled_cb" swapped="no"/>
+              </object>
+              <packing>
+                <property name="expand">False</property>
+                <property name="fill">False</property>
+                <property name="position">2</property>
+              </packing>
+            </child>
+          </object>
+          <packing>
+            <property name="expand">True</property>
+            <property name="fill">True</property>
+            <property name="position">2</property>
+          </packing>
+        </child>
+      </object>
+    </child>
+    <action-widgets>
+      <action-widget response="0">abort_button</action-widget>
+      <action-widget response="0">close_button</action-widget>
+    </action-widgets>
+  </object>
+  <object class="GtkDialog" id="Date Range Dialog">
+    <property name="can_focus">False</property>
+    <property name="border_width">5</property>
+    <property name="title" translatable="yes">Get Transactions Online</property>
+    <property name="type_hint">dialog</property>
+    <child internal-child="vbox">
+      <object class="GtkBox" id="dialog-vbox1">
+        <property name="visible">True</property>
+        <property name="can_focus">False</property>
+        <property name="spacing">2</property>
+        <child internal-child="action_area">
+          <object class="GtkButtonBox" id="dialog-action_area1">
+            <property name="visible">True</property>
+            <property name="can_focus">False</property>
+            <property name="layout_style">end</property>
+            <child>
+              <object class="GtkButton" id="cancel_button1">
+                <property name="label">gtk-cancel</property>
+                <property name="visible">True</property>
+                <property name="can_focus">True</property>
+                <property name="can_default">True</property>
+                <property name="receives_default">True</property>
+                <property name="use_action_appearance">False</property>
+                <property name="use_stock">True</property>
+              </object>
+              <packing>
+                <property name="expand">False</property>
+                <property name="fill">False</property>
+                <property name="position">0</property>
+              </packing>
+            </child>
+            <child>
+              <object class="GtkButton" id="ok_button">
+                <property name="label">gtk-ok</property>
+                <property name="visible">True</property>
+                <property name="can_focus">True</property>
+                <property name="can_default">True</property>
+                <property name="receives_default">True</property>
+                <property name="use_action_appearance">False</property>
+                <property name="use_stock">True</property>
+              </object>
+              <packing>
+                <property name="expand">False</property>
+                <property name="fill">False</property>
+                <property name="position">1</property>
+              </packing>
+            </child>
+          </object>
+          <packing>
+            <property name="expand">False</property>
+            <property name="fill">True</property>
+            <property name="pack_type">end</property>
+            <property name="position">0</property>
+          </packing>
+        </child>
+        <child>
+          <object class="GtkVBox" id="vbox152">
+            <property name="visible">True</property>
+            <property name="can_focus">False</property>
+            <property name="border_width">5</property>
+            <property name="spacing">18</property>
+            <child>
+              <object class="GtkLabel" id="heading_label1">
+                <property name="visible">True</property>
+                <property name="can_focus">False</property>
+                <property name="label" translatable="yes">Date range of transactions to retrieve:</property>
+                <property name="justify">center</property>
+                <property name="wrap">True</property>
+              </object>
+              <packing>
+                <property name="expand">False</property>
+                <property name="fill">False</property>
+                <property name="position">0</property>
+              </packing>
+            </child>
+            <child>
+              <object class="GtkVBox" id="vbox163">
+                <property name="visible">True</property>
+                <property name="can_focus">False</property>
+                <property name="spacing">6</property>
+                <child>
+                  <object class="GtkLabel" id="label8877445">
+                    <property name="visible">True</property>
+                    <property name="can_focus">False</property>
+                    <property name="xalign">0</property>
+                    <property name="label" translatable="yes"><b>From</b></property>
+                    <property name="use_markup">True</property>
+                  </object>
+                  <packing>
+                    <property name="expand">False</property>
+                    <property name="fill">False</property>
+                    <property name="position">0</property>
+                  </packing>
+                </child>
+                <child>
+                  <object class="GtkAlignment" id="alignment9">
+                    <property name="visible">True</property>
+                    <property name="can_focus">False</property>
+                    <property name="left_padding">12</property>
+                    <child>
+                      <object class="GtkVBox" id="vbox164">
+                        <property name="visible">True</property>
+                        <property name="can_focus">False</property>
+                        <property name="spacing">6</property>
+                        <child>
+                          <object class="GtkRadioButton" id="first_button">
+                            <property name="label" translatable="yes">_Earliest possible date</property>
+                            <property name="visible">True</property>
+                            <property name="can_focus">True</property>
+                            <property name="receives_default">False</property>
+                            <property name="use_action_appearance">False</property>
+                            <property name="use_underline">True</property>
+                            <property name="active">True</property>
+                            <property name="draw_indicator">True</property>
+                          </object>
+                          <packing>
+                            <property name="expand">False</property>
+                            <property name="fill">False</property>
+                            <property name="position">0</property>
+                          </packing>
+                        </child>
+                        <child>
+                          <object class="GtkRadioButton" id="last_retrieval_button">
+                            <property name="label" translatable="yes">_Last retrieval date</property>
+                            <property name="visible">True</property>
+                            <property name="can_focus">True</property>
+                            <property name="receives_default">False</property>
+                            <property name="use_action_appearance">False</property>
+                            <property name="use_underline">True</property>
+                            <property name="draw_indicator">True</property>
+                            <property name="group">first_button</property>
+                          </object>
+                          <packing>
+                            <property name="expand">False</property>
+                            <property name="fill">False</property>
+                            <property name="position">1</property>
+                          </packing>
+                        </child>
+                        <child>
+                          <object class="GtkHBox" id="hbox123">
+                            <property name="visible">True</property>
+                            <property name="can_focus">False</property>
+                            <property name="spacing">12</property>
+                            <child>
+                              <object class="GtkRadioButton" id="enter_from_button">
+                                <property name="label" translatable="yes">E_nter date:</property>
+                                <property name="visible">True</property>
+                                <property name="can_focus">True</property>
+                                <property name="receives_default">False</property>
+                                <property name="use_action_appearance">False</property>
+                                <property name="use_underline">True</property>
+                                <property name="draw_indicator">True</property>
+                                <property name="group">first_button</property>
+                                <signal name="toggled" handler="ddr_toggled_cb" swapped="no"/>
+                              </object>
+                              <packing>
+                                <property name="expand">False</property>
+                                <property name="fill">False</property>
+                                <property name="position">0</property>
+                              </packing>
+                            </child>
+                            <child>
+                              <object class="GtkHBox" id="enter_from_box">
+                                <property name="visible">True</property>
+                                <property name="can_focus">False</property>
+                                <child>
+                                  <placeholder/>
+                                </child>
+                              </object>
+                              <packing>
+                                <property name="expand">True</property>
+                                <property name="fill">True</property>
+                                <property name="position">1</property>
+                              </packing>
+                            </child>
+                          </object>
+                          <packing>
+                            <property name="expand">False</property>
+                            <property name="fill">False</property>
+                            <property name="position">2</property>
+                          </packing>
+                        </child>
+                      </object>
+                    </child>
+                  </object>
+                  <packing>
+                    <property name="expand">True</property>
+                    <property name="fill">True</property>
+                    <property name="position">1</property>
+                  </packing>
+                </child>
+              </object>
+              <packing>
+                <property name="expand">False</property>
+                <property name="fill">False</property>
+                <property name="position">1</property>
+              </packing>
+            </child>
+            <child>
+              <object class="GtkVBox" id="vbox165">
+                <property name="visible">True</property>
+                <property name="can_focus">False</property>
+                <property name="spacing">6</property>
+                <child>
+                  <object class="GtkLabel" id="label8877446">
+                    <property name="visible">True</property>
+                    <property name="can_focus">False</property>
+                    <property name="xalign">0</property>
+                    <property name="label" translatable="yes"><b>To</b></property>
+                    <property name="use_markup">True</property>
+                  </object>
+                  <packing>
+                    <property name="expand">False</property>
+                    <property name="fill">False</property>
+                    <property name="position">0</property>
+                  </packing>
+                </child>
+                <child>
+                  <object class="GtkAlignment" id="alignment10">
+                    <property name="visible">True</property>
+                    <property name="can_focus">False</property>
+                    <property name="left_padding">12</property>
+                    <child>
+                      <object class="GtkVBox" id="vbox166">
+                        <property name="visible">True</property>
+                        <property name="can_focus">False</property>
+                        <property name="spacing">6</property>
+                        <child>
+                          <object class="GtkRadioButton" id="now_button">
+                            <property name="label" translatable="yes">_Now</property>
+                            <property name="visible">True</property>
+                            <property name="can_focus">True</property>
+                            <property name="receives_default">False</property>
+                            <property name="use_action_appearance">False</property>
+                            <property name="use_underline">True</property>
+                            <property name="active">True</property>
+                            <property name="draw_indicator">True</property>
+                          </object>
+                          <packing>
+                            <property name="expand">False</property>
+                            <property name="fill">False</property>
+                            <property name="position">0</property>
+                          </packing>
+                        </child>
+                        <child>
+                          <object class="GtkHBox" id="hbox124">
+                            <property name="visible">True</property>
+                            <property name="can_focus">False</property>
+                            <property name="spacing">12</property>
+                            <child>
+                              <object class="GtkRadioButton" id="enter_to_button">
+                                <property name="label" translatable="yes">Ente_r date:</property>
+                                <property name="visible">True</property>
+                                <property name="can_focus">True</property>
+                                <property name="receives_default">False</property>
+                                <property name="use_action_appearance">False</property>
+                                <property name="use_underline">True</property>
+                                <property name="draw_indicator">True</property>
+                                <property name="group">now_button</property>
+                                <signal name="toggled" handler="ddr_toggled_cb" swapped="no"/>
+                              </object>
+                              <packing>
+                                <property name="expand">False</property>
+                                <property name="fill">False</property>
+                                <property name="position">0</property>
+                              </packing>
+                            </child>
+                            <child>
+                              <object class="GtkHBox" id="enter_to_box">
+                                <property name="visible">True</property>
+                                <property name="can_focus">False</property>
+                                <child>
+                                  <placeholder/>
+                                </child>
+                              </object>
+                              <packing>
+                                <property name="expand">True</property>
+                                <property name="fill">True</property>
+                                <property name="position">1</property>
+                              </packing>
+                            </child>
+                          </object>
+                          <packing>
+                            <property name="expand">True</property>
+                            <property name="fill">True</property>
+                            <property name="position">1</property>
+                          </packing>
+                        </child>
+                      </object>
+                    </child>
+                  </object>
+                  <packing>
+                    <property name="expand">True</property>
+                    <property name="fill">True</property>
+                    <property name="position">1</property>
+                  </packing>
+                </child>
+              </object>
+              <packing>
+                <property name="expand">False</property>
+                <property name="fill">False</property>
+                <property name="position">2</property>
+              </packing>
+            </child>
+          </object>
+          <packing>
+            <property name="expand">True</property>
+            <property name="fill">True</property>
+            <property name="position">2</property>
+          </packing>
+        </child>
+      </object>
+    </child>
+    <action-widgets>
+      <action-widget response="-6">cancel_button1</action-widget>
+      <action-widget response="-5">ok_button</action-widget>
+    </action-widgets>
+  </object>
+  <object class="GtkDialog" id="Password Dialog">
+    <property name="can_focus">False</property>
+    <property name="border_width">5</property>
+    <property name="title" translatable="yes">Enter Password</property>
+    <property name="type_hint">dialog</property>
+    <child internal-child="vbox">
+      <object class="GtkBox" id="dialog-vbox3">
+        <property name="visible">True</property>
+        <property name="can_focus">False</property>
+        <child internal-child="action_area">
+          <object class="GtkButtonBox" id="dialog-action_area3">
+            <property name="visible">True</property>
+            <property name="can_focus">False</property>
+            <property name="layout_style">end</property>
+            <child>
+              <object class="GtkButton" id="cancelbutton2">
+                <property name="label">gtk-cancel</property>
+                <property name="visible">True</property>
+                <property name="can_focus">True</property>
+                <property name="can_default">True</property>
+                <property name="receives_default">True</property>
+                <property name="use_action_appearance">False</property>
+                <property name="use_stock">True</property>
+              </object>
+              <packing>
+                <property name="expand">False</property>
+                <property name="fill">False</property>
+                <property name="position">0</property>
+              </packing>
+            </child>
+            <child>
+              <object class="GtkButton" id="okbutton2">
+                <property name="label">gtk-ok</property>
+                <property name="visible">True</property>
+                <property name="can_focus">True</property>
+                <property name="can_default">True</property>
+                <property name="receives_default">True</property>
+                <property name="use_action_appearance">False</property>
+                <property name="use_stock">True</property>
+              </object>
+              <packing>
+                <property name="expand">False</property>
+                <property name="fill">False</property>
+                <property name="position">1</property>
+              </packing>
+            </child>
+          </object>
+          <packing>
+            <property name="expand">False</property>
+            <property name="fill">True</property>
+            <property name="pack_type">end</property>
+            <property name="position">0</property>
+          </packing>
+        </child>
+        <child>
+          <object class="GtkVBox" id="vbox167">
+            <property name="visible">True</property>
+            <property name="can_focus">False</property>
+            <property name="border_width">5</property>
+            <property name="spacing">18</property>
+            <child>
+              <object class="GtkLabel" id="heading_pw_label">
+                <property name="visible">True</property>
+                <property name="can_focus">False</property>
+                <property name="label" translatable="yes">Enter your password</property>
+                <property name="wrap">True</property>
+              </object>
+              <packing>
+                <property name="expand">False</property>
+                <property name="fill">False</property>
+                <property name="position">0</property>
+              </packing>
+            </child>
+            <child>
+              <object class="GtkTable" id="table7">
+                <property name="visible">True</property>
+                <property name="can_focus">False</property>
+                <property name="n_rows">3</property>
+                <property name="n_columns">2</property>
+                <property name="column_spacing">12</property>
+                <property name="row_spacing">6</property>
+                <child>
+                  <object class="GtkLabel" id="label8877456">
+                    <property name="visible">True</property>
+                    <property name="can_focus">False</property>
+                    <property name="xalign">0</property>
+                    <property name="label" translatable="yes">Password:</property>
+                  </object>
+                  <packing>
+                    <property name="x_options">GTK_FILL</property>
+                    <property name="y_options"></property>
+                  </packing>
+                </child>
+                <child>
+                  <object class="GtkLabel" id="confirm_label">
+                    <property name="visible">True</property>
+                    <property name="can_focus">False</property>
+                    <property name="xalign">0</property>
+                    <property name="label" translatable="yes">Confirm Password:</property>
+                  </object>
+                  <packing>
+                    <property name="top_attach">1</property>
+                    <property name="bottom_attach">2</property>
+                    <property name="x_options">GTK_FILL</property>
+                    <property name="y_options"></property>
+                  </packing>
+                </child>
+                <child>
+                  <object class="GtkEntry" id="input_entry">
+                    <property name="visible">True</property>
+                    <property name="can_focus">True</property>
+                    <property name="visibility">False</property>
+                    <property name="invisible_char">●</property>
+                    <property name="invisible_char_set">True</property>
+                    <property name="primary_icon_activatable">False</property>
+                    <property name="secondary_icon_activatable">False</property>
+                  </object>
+                  <packing>
+                    <property name="left_attach">1</property>
+                    <property name="right_attach">2</property>
+                    <property name="y_options"></property>
+                  </packing>
+                </child>
+                <child>
+                  <object class="GtkEntry" id="confirm_entry">
+                    <property name="visible">True</property>
+                    <property name="can_focus">True</property>
+                    <property name="visibility">False</property>
+                    <property name="invisible_char">●</property>
+                    <property name="invisible_char_set">True</property>
+                    <property name="primary_icon_activatable">False</property>
+                    <property name="secondary_icon_activatable">False</property>
+                  </object>
+                  <packing>
+                    <property name="left_attach">1</property>
+                    <property name="right_attach">2</property>
+                    <property name="top_attach">1</property>
+                    <property name="bottom_attach">2</property>
+                    <property name="y_options"></property>
+                  </packing>
+                </child>
+                <child>
+                  <object class="GtkCheckButton" id="remember_pin">
+                    <property name="label" translatable="yes">Remember _PIN</property>
+                    <property name="visible">True</property>
+                    <property name="can_focus">True</property>
+                    <property name="receives_default">False</property>
+                    <property name="use_action_appearance">False</property>
+                    <property name="use_underline">True</property>
+                    <property name="draw_indicator">True</property>
+                  </object>
+                  <packing>
+                    <property name="right_attach">2</property>
+                    <property name="top_attach">2</property>
+                    <property name="bottom_attach">3</property>
+                    <property name="x_options">GTK_FILL</property>
+                    <property name="y_options"></property>
+                  </packing>
+                </child>
+              </object>
+              <packing>
+                <property name="expand">True</property>
+                <property name="fill">True</property>
+                <property name="position">1</property>
+              </packing>
+            </child>
+          </object>
+          <packing>
+            <property name="expand">True</property>
+            <property name="fill">True</property>
+            <property name="position">2</property>
+          </packing>
+        </child>
+      </object>
+    </child>
+    <action-widgets>
+      <action-widget response="-6">cancelbutton2</action-widget>
+      <action-widget response="-5">okbutton2</action-widget>
+    </action-widgets>
+  </object>
+  <object class="GtkWindow" id="Preferences">
+    <property name="visible">True</property>
+    <property name="can_focus">False</property>
+    <property name="title" translatable="yes">window1</property>
+    <child>
+      <object class="GtkTable" id="aqbanking_prefs">
+        <property name="visible">True</property>
+        <property name="can_focus">False</property>
+        <property name="n_rows">4</property>
+        <property name="n_columns">4</property>
+        <child>
+          <object class="GtkLabel" id="label8877457">
+            <property name="visible">True</property>
+            <property name="can_focus">False</property>
+            <property name="xalign">0</property>
+            <property name="label" translatable="yes"><b>Online Banking</b></property>
+            <property name="use_markup">True</property>
+          </object>
+          <packing>
+            <property name="right_attach">4</property>
+            <property name="x_options">GTK_FILL</property>
+            <property name="y_options"></property>
+          </packing>
+        </child>
+        <child>
+          <object class="GtkCheckButton" id="pref/dialogs.import.hbci/close-on-finish">
+            <property name="label" translatable="yes">_Close log window when finished</property>
+            <property name="visible">True</property>
+            <property name="can_focus">True</property>
+            <property name="receives_default">False</property>
+            <property name="use_action_appearance">False</property>
+            <property name="use_underline">True</property>
+            <property name="draw_indicator">True</property>
+          </object>
+          <packing>
+            <property name="right_attach">4</property>
+            <property name="top_attach">1</property>
+            <property name="bottom_attach">2</property>
+            <property name="x_options">GTK_FILL</property>
+            <property name="y_options"></property>
+            <property name="x_padding">12</property>
+          </packing>
+        </child>
+        <child>
+          <object class="GtkCheckButton" id="pref/dialogs.import.hbci/remember-pin">
+            <property name="label" translatable="yes">Remember _PIN</property>
+            <property name="visible">True</property>
+            <property name="can_focus">True</property>
+            <property name="receives_default">False</property>
+            <property name="use_action_appearance">False</property>
+            <property name="use_underline">True</property>
+            <property name="draw_indicator">True</property>
+          </object>
+          <packing>
+            <property name="right_attach">4</property>
+            <property name="top_attach">2</property>
+            <property name="bottom_attach">3</property>
+            <property name="x_options">GTK_FILL</property>
+            <property name="y_options"></property>
+            <property name="x_padding">12</property>
+          </packing>
+        </child>
+        <child>
+          <object class="GtkCheckButton" id="checkbutton3">
+            <property name="label" translatable="yes">_Verbose debug messages</property>
+            <property name="visible">True</property>
+            <property name="can_focus">True</property>
+            <property name="receives_default">False</property>
+            <property name="use_action_appearance">False</property>
+            <property name="use_underline">True</property>
+            <property name="draw_indicator">True</property>
+          </object>
+          <packing>
+            <property name="right_attach">4</property>
+            <property name="top_attach">3</property>
+            <property name="bottom_attach">4</property>
+            <property name="x_options">GTK_FILL</property>
+            <property name="y_options"></property>
+            <property name="x_padding">12</property>
+          </packing>
+        </child>
+      </object>
+    </child>
+  </object>
+  <object class="GtkDialog" id="Template Name Dialog">
+    <property name="can_focus">False</property>
+    <property name="border_width">5</property>
+    <property name="title" translatable="yes">Name for new template</property>
+    <property name="type_hint">dialog</property>
+    <child internal-child="vbox">
+      <object class="GtkBox" id="dialog-vbox2">
+        <property name="visible">True</property>
+        <property name="can_focus">False</property>
+        <child internal-child="action_area">
+          <object class="GtkButtonBox" id="dialog-action_area2">
+            <property name="visible">True</property>
+            <property name="can_focus">False</property>
+            <property name="layout_style">end</property>
+            <child>
+              <object class="GtkButton" id="cancelbutton1">
+                <property name="label">gtk-cancel</property>
+                <property name="visible">True</property>
+                <property name="can_focus">True</property>
+                <property name="can_default">True</property>
+                <property name="receives_default">True</property>
+                <property name="use_action_appearance">False</property>
+                <property name="use_stock">True</property>
+              </object>
+              <packing>
+                <property name="expand">False</property>
+                <property name="fill">False</property>
+                <property name="position">0</property>
+              </packing>
+            </child>
+            <child>
+              <object class="GtkButton" id="okbutton1">
+                <property name="label">gtk-ok</property>
+                <property name="visible">True</property>
+                <property name="can_focus">True</property>
+                <property name="can_default">True</property>
+                <property name="has_default">True</property>
+                <property name="receives_default">True</property>
+                <property name="use_action_appearance">False</property>
+                <property name="use_stock">True</property>
+              </object>
+              <packing>
+                <property name="expand">False</property>
+                <property name="fill">False</property>
+                <property name="position">1</property>
+              </packing>
+            </child>
+          </object>
+          <packing>
+            <property name="expand">False</property>
+            <property name="fill">True</property>
+            <property name="pack_type">end</property>
+            <property name="position">0</property>
+          </packing>
+        </child>
+        <child>
+          <object class="GtkVBox" id="vbox159">
+            <property name="visible">True</property>
+            <property name="can_focus">False</property>
+            <property name="border_width">5</property>
+            <property name="spacing">12</property>
+            <child>
+              <object class="GtkLabel" id="label8877450">
+                <property name="visible">True</property>
+                <property name="can_focus">False</property>
+                <property name="label" translatable="yes">Enter name for new template:</property>
+              </object>
+              <packing>
+                <property name="expand">False</property>
+                <property name="fill">False</property>
+                <property name="position">0</property>
+              </packing>
+            </child>
+            <child>
+              <object class="GtkEntry" id="template_name">
+                <property name="visible">True</property>
+                <property name="can_focus">True</property>
+                <property name="max_length">250</property>
+                <property name="invisible_char">●</property>
+                <property name="activates_default">True</property>
+                <property name="invisible_char_set">True</property>
+                <property name="primary_icon_activatable">False</property>
+                <property name="secondary_icon_activatable">False</property>
+              </object>
+              <packing>
+                <property name="expand">False</property>
+                <property name="fill">False</property>
+                <property name="position">1</property>
+              </packing>
+            </child>
+          </object>
+          <packing>
+            <property name="expand">True</property>
+            <property name="fill">True</property>
+            <property name="position">2</property>
+          </packing>
+        </child>
+      </object>
+    </child>
+    <action-widgets>
+      <action-widget response="-6">cancelbutton1</action-widget>
+      <action-widget response="-5">okbutton1</action-widget>
+    </action-widgets>
+  </object>
+  <object class="GtkDialog" id="Transaction Dialog">
+    <property name="can_focus">False</property>
+    <property name="border_width">5</property>
+    <property name="title" translatable="yes">Online Transaction</property>
+    <property name="type_hint">dialog</property>
+    <child internal-child="vbox">
+      <object class="GtkBox" id="dialog-vbox7">
+        <property name="visible">True</property>
+        <property name="can_focus">False</property>
+        <property name="orientation">vertical</property>
+        <property name="spacing">2</property>
+        <child>
+          <object class="GtkVBox" id="trans_vbox">
+            <property name="visible">True</property>
+            <property name="can_focus">False</property>
+            <property name="border_width">5</property>
+            <child>
+              <object class="GtkLabel" id="heading_label">
+                <property name="visible">True</property>
+                <property name="can_focus">False</property>
+                <property name="label" translatable="yes">Enter an Online Transaction</property>
+                <property name="justify">center</property>
+              </object>
+              <packing>
+                <property name="expand">False</property>
+                <property name="fill">False</property>
+                <property name="position">0</property>
+              </packing>
+            </child>
+            <child>
+              <object class="GtkTable" id="table6">
+                <property name="visible">True</property>
+                <property name="can_focus">False</property>
+                <property name="n_rows">21</property>
+                <property name="n_columns">3</property>
+                <child>
+                  <object class="GtkEntry" id="recp_account_entry">
+                    <property name="visible">True</property>
+                    <property name="can_focus">True</property>
+                    <property name="max_length">12</property>
+                    <property name="invisible_char">●</property>
+                    <property name="invisible_char_set">True</property>
+                    <property name="primary_icon_activatable">False</property>
+                    <property name="secondary_icon_activatable">False</property>
+                    <signal name="changed" handler="gnc_ab_trans_dialog_verify_values" swapped="yes"/>
+                    <signal name="insert-text" handler="gnc_ab_trans_dialog_entry_filter_cb" swapped="no"/>
+                  </object>
+                  <packing>
+                    <property name="top_attach">3</property>
+                    <property name="bottom_attach">4</property>
+                    <property name="y_options"></property>
+                  </packing>
+                </child>
+                <child>
+                  <object class="GtkLabel" id="recp_account_heading">
+                    <property name="visible">True</property>
+                    <property name="can_focus">False</property>
+                    <property name="xalign">0</property>
+                    <property name="label" translatable="yes">Recipient Account Number</property>
+                  </object>
+                  <packing>
+                    <property name="top_attach">2</property>
+                    <property name="bottom_attach">3</property>
+                    <property name="x_options">GTK_FILL</property>
+                    <property name="y_options"></property>
+                  </packing>
+                </child>
+                <child>
+                  <object class="GtkEntry" id="recp_bankcode_entry">
+                    <property name="visible">True</property>
+                    <property name="can_focus">True</property>
+                    <property name="max_length">8</property>
+                    <property name="invisible_char">●</property>
+                    <property name="invisible_char_set">True</property>
+                    <property name="primary_icon_activatable">False</property>
+                    <property name="secondary_icon_activatable">False</property>
+                    <signal name="changed" handler="gnc_ab_trans_dialog_bankcode_changed_cb" swapped="no"/>
+                    <signal name="insert-text" handler="gnc_ab_trans_dialog_entry_filter_cb" swapped="no"/>
+                  </object>
+                  <packing>
+                    <property name="left_attach">2</property>
+                    <property name="right_attach">3</property>
+                    <property name="top_attach">3</property>
+                    <property name="bottom_attach">4</property>
+                    <property name="y_options"></property>
+                  </packing>
+                </child>
+                <child>
+                  <object class="GtkLabel" id="recp_bankcode_heading">
+                    <property name="visible">True</property>
+                    <property name="can_focus">False</property>
+                    <property name="xalign">0</property>
+                    <property name="label" translatable="yes">Recipient Bank Code</property>
+                  </object>
+                  <packing>
+                    <property name="left_attach">2</property>
+                    <property name="right_attach">3</property>
+                    <property name="top_attach">2</property>
+                    <property name="bottom_attach">3</property>
+                    <property name="x_options">GTK_FILL</property>
+                    <property name="y_options"></property>
+                  </packing>
+                </child>
+                <child>
+                  <object class="GtkEntry" id="recp_name_entry">
+                    <property name="visible">True</property>
+                    <property name="can_focus">True</property>
+                    <property name="max_length">27</property>
+                    <property name="invisible_char">●</property>
+                    <property name="invisible_char_set">True</property>
+                    <property name="primary_icon_activatable">False</property>
+                    <property name="secondary_icon_activatable">False</property>
+                    <signal name="changed" handler="gnc_ab_trans_dialog_verify_values" swapped="yes"/>
+                  </object>
+                  <packing>
+                    <property name="right_attach">3</property>
+                    <property name="top_attach">1</property>
+                    <property name="bottom_attach">2</property>
+                    <property name="y_options"></property>
+                  </packing>
+                </child>
+                <child>
+                  <object class="GtkLabel" id="recp_name_heading">
+                    <property name="visible">True</property>
+                    <property name="can_focus">False</property>
+                    <property name="xalign">0</property>
+                    <property name="label" translatable="yes">Recipient Name</property>
+                    <property name="justify">center</property>
+                  </object>
+                  <packing>
+                    <property name="right_attach">3</property>
+                    <property name="x_options">GTK_FILL</property>
+                    <property name="y_options"></property>
+                  </packing>
+                </child>
+                <child>
+                  <object class="GtkLabel" id="recp_bankname_heading">
+                    <property name="visible">True</property>
+                    <property name="can_focus">False</property>
+                    <property name="xalign">0</property>
+                    <property name="label" translatable="yes">at Bank</property>
+                  </object>
+                  <packing>
+                    <property name="right_attach">3</property>
+                    <property name="top_attach">4</property>
+                    <property name="bottom_attach">5</property>
+                    <property name="x_options">GTK_FILL</property>
+                    <property name="y_options"></property>
+                  </packing>
+                </child>
+                <child>
+                  <object class="GtkLabel" id="recp_bankname_label">
+                    <property name="visible">True</property>
+                    <property name="can_focus">False</property>
+                    <property name="xalign">0</property>
+                    <property name="label" translatable="yes">(filled in automatically)</property>
+                    <property name="justify">center</property>
+                  </object>
+                  <packing>
+                    <property name="right_attach">3</property>
+                    <property name="top_attach">5</property>
+                    <property name="bottom_attach">6</property>
+                    <property name="x_options">GTK_FILL</property>
+                    <property name="y_options"></property>
+                  </packing>
+                </child>
+                <child>
+                  <object class="GtkLabel" id="label8877434">
+                    <property name="visible">True</property>
+                    <property name="can_focus">False</property>
+                    <property name="xalign">0</property>
+                    <property name="label" translatable="yes">Amount</property>
+                    <property name="justify">center</property>
+                  </object>
+                  <packing>
+                    <property name="top_attach">7</property>
+                    <property name="bottom_attach">8</property>
+                    <property name="x_options">GTK_FILL</property>
+                    <property name="y_options"></property>
+                  </packing>
+                </child>
+                <child>
+                  <object class="GtkLabel" id="label8877433">
+                    <property name="visible">True</property>
+                    <property name="can_focus">False</property>
+                    <property name="xalign">0</property>
+                    <property name="label" translatable="yes">Payment Purpose (only for recipient)</property>
+                    <property name="justify">center</property>
+                  </object>
+                  <packing>
+                    <property name="right_attach">3</property>
+                    <property name="top_attach">10</property>
+                    <property name="bottom_attach">11</property>
+                    <property name="x_options">GTK_FILL</property>
+                    <property name="y_options"></property>
+                  </packing>
+                </child>
+                <child>
+                  <object class="GtkLabel" id="label8877435">
+                    <property name="visible">True</property>
+                    <property name="can_focus">False</property>
+                    <property name="xalign">0</property>
+                    <property name="label" translatable="yes">Payment Purpose continued</property>
+                    <property name="justify">center</property>
+                  </object>
+                  <packing>
+                    <property name="right_attach">3</property>
+                    <property name="top_attach">12</property>
+                    <property name="bottom_attach">13</property>
+                    <property name="x_options">GTK_FILL</property>
+                    <property name="y_options"></property>
+                  </packing>
+                </child>
+                <child>
+                  <object class="GtkLabel" id="orig_name_heading">
+                    <property name="visible">True</property>
+                    <property name="can_focus">False</property>
+                    <property name="xalign">0</property>
+                    <property name="label" translatable="yes">Originator Name</property>
+                  </object>
+                  <packing>
+                    <property name="top_attach">15</property>
+                    <property name="bottom_attach">16</property>
+                    <property name="x_options">GTK_FILL</property>
+                    <property name="y_options"></property>
+                  </packing>
+                </child>
+                <child>
+                  <object class="GtkLabel" id="orig_name_label">
+                    <property name="visible">True</property>
+                    <property name="can_focus">False</property>
+                    <property name="xalign">0</property>
+                    <property name="label" translatable="yes">something</property>
+                  </object>
+                  <packing>
+                    <property name="top_attach">16</property>
+                    <property name="bottom_attach">17</property>
+                    <property name="x_options">GTK_FILL</property>
+                    <property name="y_options"></property>
+                  </packing>
+                </child>
+                <child>
+                  <object class="GtkLabel" id="orig_bankname_heading">
+                    <property name="visible">True</property>
+                    <property name="can_focus">False</property>
+                    <property name="xalign">0</property>
+                    <property name="label" translatable="yes">at Bank</property>
+                  </object>
+                  <packing>
+                    <property name="top_attach">17</property>
+                    <property name="bottom_attach">18</property>
+                    <property name="x_options">GTK_FILL</property>
+                    <property name="y_options"></property>
+                  </packing>
+                </child>
+                <child>
+                  <object class="GtkLabel" id="orig_bankname_label">
+                    <property name="visible">True</property>
+                    <property name="can_focus">False</property>
+                    <property name="xalign">0</property>
+                    <property name="label" translatable="yes">something</property>
+                  </object>
+                  <packing>
+                    <property name="top_attach">18</property>
+                    <property name="bottom_attach">19</property>
+                    <property name="x_options">GTK_FILL</property>
+                    <property name="y_options"></property>
+                  </packing>
+                </child>
+                <child>
+                  <object class="GtkLabel" id="orig_account_heading">
+                    <property name="visible">True</property>
+                    <property name="can_focus">False</property>
+                    <property name="xalign">0</property>
+                    <property name="label" translatable="yes">Originator Account Number</property>
+                  </object>
+                  <packing>
+                    <property name="left_attach">2</property>
+                    <property name="right_attach">3</property>
+                    <property name="top_attach">15</property>
+                    <property name="bottom_attach">16</property>
+                    <property name="x_options">GTK_FILL</property>
+                    <property name="y_options"></property>
+                  </packing>
+                </child>
+                <child>
+                  <object class="GtkLabel" id="orig_account_label">
+                    <property name="visible">True</property>
+                    <property name="can_focus">False</property>
+                    <property name="xalign">0</property>
+                    <property name="label" translatable="yes">something</property>
+                  </object>
+                  <packing>
+                    <property name="left_attach">2</property>
+                    <property name="right_attach">3</property>
+                    <property name="top_attach">16</property>
+                    <property name="bottom_attach">17</property>
+                    <property name="x_options">GTK_FILL</property>
+                    <property name="y_options"></property>
+                  </packing>
+                </child>
+                <child>
+                  <object class="GtkLabel" id="orig_bankcode_heading">
+                    <property name="visible">True</property>
+                    <property name="can_focus">False</property>
+                    <property name="xalign">0</property>
+                    <property name="label" translatable="yes">Bank Code</property>
+                  </object>
+                  <packing>
+                    <property name="left_attach">2</property>
+                    <property name="right_attach">3</property>
+                    <property name="top_attach">17</property>
+                    <property name="bottom_attach">18</property>
+                    <property name="x_options">GTK_FILL</property>
+                    <property name="y_options"></property>
+                  </packing>
+                </child>
+                <child>
+                  <object class="GtkLabel" id="orig_bankcode_label">
+                    <property name="visible">True</property>
+                    <property name="can_focus">False</property>
+                    <property name="xalign">0</property>
+                    <property name="label" translatable="yes">something</property>
+                  </object>
+                  <packing>
+                    <property name="left_attach">2</property>
+                    <property name="right_attach">3</property>
+                    <property name="top_attach">18</property>
+                    <property name="bottom_attach">19</property>
+                    <property name="x_options">GTK_FILL</property>
+                    <property name="y_options"></property>
+                  </packing>
+                </child>
+                <child>
+                  <object class="GtkEntry" id="purpose_entry">
+                    <property name="visible">True</property>
+                    <property name="can_focus">True</property>
+                    <property name="max_length">27</property>
+                    <property name="invisible_char">●</property>
+                    <property name="invisible_char_set">True</property>
+                    <property name="primary_icon_activatable">False</property>
+                    <property name="secondary_icon_activatable">False</property>
+                    <signal name="changed" handler="gnc_ab_trans_dialog_verify_values" swapped="yes"/>
+                  </object>
+                  <packing>
+                    <property name="top_attach">11</property>
+                    <property name="bottom_attach">12</property>
+                    <property name="y_options"></property>
+                  </packing>
+                </child>
+                <child>
+                  <object class="GtkEntry" id="purpose_cont2_entry">
+                    <property name="visible">True</property>
+                    <property name="can_focus">True</property>
+                    <property name="max_length">27</property>
+                    <property name="invisible_char">●</property>
+                    <property name="invisible_char_set">True</property>
+                    <property name="primary_icon_activatable">False</property>
+                    <property name="secondary_icon_activatable">False</property>
+                    <signal name="changed" handler="gnc_ab_trans_dialog_verify_values" swapped="yes"/>
+                  </object>
+                  <packing>
+                    <property name="top_attach">13</property>
+                    <property name="bottom_attach">14</property>
+                    <property name="y_options"></property>
+                  </packing>
+                </child>
+                <child>
+                  <object class="GtkEntry" id="purpose_cont_entry">
+                    <property name="visible">True</property>
+                    <property name="can_focus">True</property>
+                    <property name="max_length">27</property>
+                    <property name="invisible_char">●</property>
+                    <property name="invisible_char_set">True</property>
+                    <property name="primary_icon_activatable">False</property>
+                    <property name="secondary_icon_activatable">False</property>
+                    <signal name="changed" handler="gnc_ab_trans_dialog_verify_values" swapped="yes"/>
+                  </object>
+                  <packing>
+                    <property name="left_attach">2</property>
+                    <property name="right_attach">3</property>
+                    <property name="top_attach">11</property>
+                    <property name="bottom_attach">12</property>
+                    <property name="y_options"></property>
+                  </packing>
+                </child>
+                <child>
+                  <object class="GtkEntry" id="purpose_cont3_entry">
+                    <property name="visible">True</property>
+                    <property name="can_focus">True</property>
+                    <property name="max_length">27</property>
+                    <property name="invisible_char">●</property>
+                    <property name="invisible_char_set">True</property>
+                    <property name="primary_icon_activatable">False</property>
+                    <property name="secondary_icon_activatable">False</property>
+                    <signal name="changed" handler="gnc_ab_trans_dialog_verify_values" swapped="yes"/>
+                  </object>
+                  <packing>
+                    <property name="left_attach">2</property>
+                    <property name="right_attach">3</property>
+                    <property name="top_attach">13</property>
+                    <property name="bottom_attach">14</property>
+                    <property name="y_options"></property>
+                  </packing>
+                </child>
+                <child>
+                  <object class="GtkHBox" id="amount_hbox">
+                    <property name="visible">True</property>
+                    <property name="can_focus">False</property>
+                    <child>
+                      <placeholder/>
+                    </child>
+                  </object>
+                  <packing>
+                    <property name="top_attach">8</property>
+                    <property name="bottom_attach">9</property>
+                    <property name="y_options"></property>
+                  </packing>
+                </child>
+                <child>
+                  <object class="GtkHSeparator" id="hseparator8">
+                    <property name="visible">True</property>
+                    <property name="can_focus">False</property>
+                  </object>
+                  <packing>
+                    <property name="right_attach">3</property>
+                    <property name="top_attach">19</property>
+                    <property name="bottom_attach">20</property>
+                    <property name="x_options">GTK_FILL</property>
+                    <property name="y_options"></property>
+                    <property name="y_padding">1</property>
+                  </packing>
+                </child>
+                <child>
+                  <object class="GtkHSeparator" id="hseparator4">
+                    <property name="visible">True</property>
+                    <property name="can_focus">False</property>
+                  </object>
+                  <packing>
+                    <property name="right_attach">3</property>
+                    <property name="top_attach">14</property>
+                    <property name="bottom_attach">15</property>
+                    <property name="x_options">GTK_FILL</property>
+                    <property name="y_options"></property>
+                  </packing>
+                </child>
+                <child>
+                  <object class="GtkHSeparator" id="hseparator5">
+                    <property name="visible">True</property>
+                    <property name="can_focus">False</property>
+                  </object>
+                  <packing>
+                    <property name="right_attach">3</property>
+                    <property name="top_attach">6</property>
+                    <property name="bottom_attach">7</property>
+                    <property name="x_options">GTK_FILL</property>
+                    <property name="y_options"></property>
+                    <property name="y_padding">1</property>
+                  </packing>
+                </child>
+                <child>
+                  <object class="GtkHSeparator" id="hseparator6">
+                    <property name="visible">True</property>
+                    <property name="can_focus">False</property>
+                  </object>
+                  <packing>
+                    <property name="right_attach">3</property>
+                    <property name="top_attach">9</property>
+                    <property name="bottom_attach">10</property>
+                    <property name="x_options">GTK_FILL</property>
+                    <property name="y_options"></property>
+                  </packing>
+                </child>
+                <child>
+                  <placeholder/>
+                </child>
+                <child>
+                  <placeholder/>
+                </child>
+                <child>
+                  <placeholder/>
+                </child>
+                <child>
+                  <placeholder/>
+                </child>
+                <child>
+                  <placeholder/>
+                </child>
+                <child>
+                  <placeholder/>
+                </child>
+                <child>
+                  <placeholder/>
+                </child>
+                <child>
+                  <placeholder/>
+                </child>
+                <child>
+                  <placeholder/>
+                </child>
+                <child>
+                  <placeholder/>
+                </child>
+                <child>
+                  <placeholder/>
+                </child>
+                <child>
+                  <placeholder/>
+                </child>
+                <child>
+                  <placeholder/>
+                </child>
+                <child>
+                  <placeholder/>
+                </child>
+                <child>
+                  <placeholder/>
+                </child>
+              </object>
+              <packing>
+                <property name="expand">True</property>
+                <property name="fill">True</property>
+                <property name="position">1</property>
+              </packing>
+            </child>
+            <child>
+              <object class="GtkExpander" id="expander1">
+                <property name="visible">True</property>
+                <property name="can_focus">True</property>
+                <child>
+                  <object class="GtkHBox" id="hbox117">
+                    <property name="visible">True</property>
+                    <property name="can_focus">False</property>
+                    <property name="spacing">4</property>
+                    <child>
+                      <object class="GtkVButtonBox" id="vbutonbox158">
+                        <property name="visible">True</property>
+                        <property name="can_focus">False</property>
+                        <property name="homogeneous">True</property>
+                        <child>
+                          <object class="GtkButton" id="add_templ_button">
+                            <property name="visible">True</property>
+                            <property name="can_focus">True</property>
+                            <property name="receives_default">True</property>
+                            <property name="has_tooltip">True</property>
+                            <property name="tooltip_markup">Add the current online transaction as a new transaction template</property>
+                            <property name="tooltip_text" translatable="yes">Add the current online transaction as a new transaction template</property>
+                            <property name="use_action_appearance">False</property>
+                            <signal name="clicked" handler="gnc_ab_trans_dialog_add_templ_cb" swapped="no"/>
+                            <child>
+                              <object class="GtkAlignment" id="alignment3">
+                                <property name="visible">True</property>
+                                <property name="can_focus">False</property>
+                                <property name="xscale">0</property>
+                                <property name="yscale">0</property>
+                                <child>
+                                  <object class="GtkHBox" id="hbox119">
+                                    <property name="visible">True</property>
+                                    <property name="can_focus">False</property>
+                                    <property name="spacing">2</property>
+                                    <child>
+                                      <object class="GtkImage" id="image1">
+                                        <property name="visible">True</property>
+                                        <property name="can_focus">False</property>
+                                        <property name="stock">gtk-add</property>
+                                      </object>
+                                      <packing>
+                                        <property name="expand">False</property>
+                                        <property name="fill">False</property>
+                                        <property name="position">0</property>
+                                      </packing>
+                                    </child>
+                                    <child>
+                                      <object class="GtkLabel" id="label8877451">
+                                        <property name="visible">True</property>
+                                        <property name="can_focus">False</property>
+                                        <property name="label" translatable="yes">Add current</property>
+                                        <property name="use_underline">True</property>
+                                      </object>
+                                      <packing>
+                                        <property name="expand">False</property>
+                                        <property name="fill">False</property>
+                                        <property name="position">1</property>
+                                      </packing>
+                                    </child>
+                                  </object>
+                                </child>
+                              </object>
+                            </child>
+                          </object>
+                          <packing>
+                            <property name="expand">False</property>
+                            <property name="fill">False</property>
+                            <property name="position">0</property>
+                          </packing>
+                        </child>
+                        <child>
+                          <object class="GtkButton" id="moveup_templ_button">
+                            <property name="label">gtk-go-up</property>
+                            <property name="visible">True</property>
+                            <property name="can_focus">True</property>
+                            <property name="receives_default">True</property>
+                            <property name="has_tooltip">True</property>
+                            <property name="tooltip_markup">Move the selected transaction template one row up</property>
+                            <property name="tooltip_text" translatable="yes">Move the selected transaction template one row up</property>
+                            <property name="use_action_appearance">False</property>
+                            <property name="use_stock">True</property>
+                            <signal name="clicked" handler="gnc_ab_trans_dialog_moveup_templ_cb" swapped="no"/>
+                          </object>
+                          <packing>
+                            <property name="expand">False</property>
+                            <property name="fill">False</property>
+                            <property name="position">1</property>
+                          </packing>
+                        </child>
+                        <child>
+                          <object class="GtkButton" id="movedown_templ_button">
+                            <property name="label">gtk-go-down</property>
+                            <property name="visible">True</property>
+                            <property name="can_focus">True</property>
+                            <property name="receives_default">True</property>
+                            <property name="has_tooltip">True</property>
+                            <property name="tooltip_markup">Move the selected transaction template one row down</property>
+                            <property name="tooltip_text" translatable="yes">Move the selected transaction template one row down</property>
+                            <property name="use_action_appearance">False</property>
+                            <property name="use_stock">True</property>
+                            <signal name="clicked" handler="gnc_ab_trans_dialog_movedown_templ_cb" swapped="no"/>
+                          </object>
+                          <packing>
+                            <property name="expand">False</property>
+                            <property name="fill">False</property>
+                            <property name="position">2</property>
+                          </packing>
+                        </child>
+                        <child>
+                          <object class="GtkButton" id="sort_templ_button">
+                            <property name="visible">True</property>
+                            <property name="can_focus">True</property>
+                            <property name="receives_default">True</property>
+                            <property name="has_tooltip">True</property>
+                            <property name="tooltip_markup">Sort the list of transaction templates alphabetically</property>
+                            <property name="tooltip_text" translatable="yes">Sort the list of transaction templates alphabetically</property>
+                            <property name="use_action_appearance">False</property>
+                            <signal name="clicked" handler="gnc_ab_trans_dialog_sort_templ_cb" swapped="no"/>
+                            <child>
+                              <object class="GtkAlignment" id="alignment4">
+                                <property name="visible">True</property>
+                                <property name="can_focus">False</property>
+                                <property name="xscale">0</property>
+                                <property name="yscale">0</property>
+                                <child>
+                                  <object class="GtkHBox" id="hbox120">
+                                    <property name="visible">True</property>
+                                    <property name="can_focus">False</property>
+                                    <property name="spacing">2</property>
+                                    <child>
+                                      <object class="GtkImage" id="image2">
+                                        <property name="visible">True</property>
+                                        <property name="can_focus">False</property>
+                                        <property name="stock">gtk-sort-ascending</property>
+                                      </object>
+                                      <packing>
+                                        <property name="expand">False</property>
+                                        <property name="fill">False</property>
+                                        <property name="position">0</property>
+                                      </packing>
+                                    </child>
+                                    <child>
+                                      <object class="GtkLabel" id="label8877452">
+                                        <property name="visible">True</property>
+                                        <property name="can_focus">False</property>
+                                        <property name="label" translatable="yes">Sort</property>
+                                        <property name="use_underline">True</property>
+                                      </object>
+                                      <packing>
+                                        <property name="expand">False</property>
+                                        <property name="fill">False</property>
+                                        <property name="position">1</property>
+                                      </packing>
+                                    </child>
+                                  </object>
+                                </child>
+                              </object>
+                            </child>
+                          </object>
+                          <packing>
+                            <property name="expand">False</property>
+                            <property name="fill">False</property>
+                            <property name="position">3</property>
+                          </packing>
+                        </child>
+                        <child>
+                          <object class="GtkButton" id="del_templ_button">
+                            <property name="label">gtk-delete</property>
+                            <property name="visible">True</property>
+                            <property name="can_focus">True</property>
+                            <property name="receives_default">True</property>
+                            <property name="has_tooltip">True</property>
+                            <property name="tooltip_markup">Delete the currently selected transaction template</property>
+                            <property name="tooltip_text" translatable="yes">Delete the currently selected transaction template</property>
+                            <property name="use_action_appearance">False</property>
+                            <property name="use_stock">True</property>
+                            <signal name="clicked" handler="gnc_ab_trans_dialog_del_templ_cb" swapped="no"/>
+                          </object>
+                          <packing>
+                            <property name="expand">False</property>
+                            <property name="fill">False</property>
+                            <property name="position">4</property>
+                          </packing>
+                        </child>
+                      </object>
+                      <packing>
+                        <property name="expand">False</property>
+                        <property name="fill">False</property>
+                        <property name="pack_type">end</property>
+                        <property name="position">0</property>
+                      </packing>
+                    </child>
+                    <child>
+                      <object class="GtkScrolledWindow" id="template_scrolledwindow">
+                        <property name="visible">True</property>
+                        <property name="can_focus">True</property>
+                        <property name="shadow_type">in</property>
+                        <child>
+                          <object class="GtkTreeView" id="template_list">
+                            <property name="visible">True</property>
+                            <property name="can_focus">True</property>
+                            <property name="headers_visible">False</property>
+                            <property name="rules_hint">True</property>
+                            <signal name="row-activated" handler="gnc_ab_trans_dialog_templ_list_row_activated_cb" swapped="no"/>
+                            <child internal-child="selection">
+                              <object class="GtkTreeSelection" id="treeview-selection1"/>
+                            </child>
+                          </object>
+                        </child>
+                      </object>
+                      <packing>
+                        <property name="expand">True</property>
+                        <property name="fill">True</property>
+                        <property name="pack_type">end</property>
+                        <property name="position">2</property>
+                      </packing>
+                    </child>
+                  </object>
+                </child>
+                <child type="label">
+                  <object class="GtkLabel" id="label1">
+                    <property name="visible">True</property>
+                    <property name="can_focus">False</property>
+                    <property name="label" translatable="yes">Templates</property>
+                  </object>
+                </child>
+              </object>
+              <packing>
+                <property name="expand">False</property>
+                <property name="fill">False</property>
+                <property name="position">2</property>
+              </packing>
+            </child>
+            <child>
+              <object class="GtkHSeparator" id="hseparator7">
+                <property name="visible">True</property>
+                <property name="can_focus">False</property>
+              </object>
+              <packing>
+                <property name="expand">False</property>
+                <property name="fill">False</property>
+                <property name="position">3</property>
+              </packing>
+            </child>
+          </object>
+          <packing>
+            <property name="expand">True</property>
+            <property name="fill">True</property>
+            <property name="position">0</property>
+          </packing>
+        </child>
+        <child internal-child="action_area">
+          <object class="GtkButtonBox" id="dialog-action_area7">
+            <property name="visible">True</property>
+            <property name="can_focus">False</property>
+            <property name="layout_style">end</property>
+            <child>
+              <object class="GtkButton" id="exec_later_button">
+                <property name="label" translatable="yes">Execute later (unimpl.)</property>
+                <property name="can_focus">True</property>
+                <property name="can_default">True</property>
+                <property name="receives_default">True</property>
+                <property name="use_action_appearance">False</property>
+                <property name="use_underline">True</property>
+              </object>
+              <packing>
+                <property name="expand">False</property>
+                <property name="fill">False</property>
+                <property name="position">0</property>
+              </packing>
+            </child>
+            <child>
+              <object class="GtkButton" id="cancel_button">
+                <property name="label">gtk-cancel</property>
+                <property name="visible">True</property>
+                <property name="can_focus">True</property>
+                <property name="can_default">True</property>
+                <property name="receives_default">True</property>
+                <property name="use_action_appearance">False</property>
+                <property name="use_stock">True</property>
+              </object>
+              <packing>
+                <property name="expand">False</property>
+                <property name="fill">False</property>
+                <property name="position">1</property>
+              </packing>
+            </child>
+            <child>
+              <object class="GtkButton" id="exec_now_button">
+                <property name="visible">True</property>
+                <property name="can_focus">True</property>
+                <property name="can_default">True</property>
+                <property name="has_default">True</property>
+                <property name="receives_default">True</property>
+                <property name="has_tooltip">True</property>
+                <property name="tooltip_markup">Execute this online transaction now</property>
+                <property name="tooltip_text" translatable="yes">Execute this online transaction now</property>
+                <property name="use_action_appearance">False</property>
+                <child>
+                  <object class="GtkAlignment" id="alignment6">
+                    <property name="visible">True</property>
+                    <property name="can_focus">False</property>
+                    <property name="xscale">0</property>
+                    <property name="yscale">0</property>
+                    <child>
+                      <object class="GtkHBox" id="hbox122">
+                        <property name="visible">True</property>
+                        <property name="can_focus">False</property>
+                        <property name="spacing">2</property>
+                        <child>
+                          <object class="GtkImage" id="image4">
+                            <property name="visible">True</property>
+                            <property name="can_focus">False</property>
+                            <property name="stock">gtk-execute</property>
+                          </object>
+                          <packing>
+                            <property name="expand">False</property>
+                            <property name="fill">False</property>
+                            <property name="position">0</property>
+                          </packing>
+                        </child>
+                        <child>
+                          <object class="GtkLabel" id="label8877454">
+                            <property name="visible">True</property>
+                            <property name="can_focus">False</property>
+                            <property name="label" translatable="yes">Execute Now</property>
+                            <property name="use_underline">True</property>
+                          </object>
+                          <packing>
+                            <property name="expand">False</property>
+                            <property name="fill">False</property>
+                            <property name="position">1</property>
+                          </packing>
+                        </child>
+                      </object>
+                    </child>
+                  </object>
+                </child>
+              </object>
+              <packing>
+                <property name="expand">False</property>
+                <property name="fill">False</property>
+                <property name="position">2</property>
+              </packing>
+            </child>
+          </object>
+          <packing>
+            <property name="expand">False</property>
+            <property name="fill">True</property>
+            <property name="pack_type">end</property>
+            <property name="position">1</property>
+          </packing>
+        </child>
+      </object>
+    </child>
+    <action-widgets>
+      <action-widget response="-9">exec_later_button</action-widget>
+      <action-widget response="-6">cancel_button</action-widget>
+      <action-widget response="-8">exec_now_button</action-widget>
+    </action-widgets>
+  </object>
+</interface>

Copied: gnucash/trunk/src/import-export/aqb/gnc-ab-getbalance.c (from rev 23566, gnucash/trunk/src/import-export/aqbanking/gnc-ab-getbalance.c)
===================================================================
--- gnucash/trunk/src/import-export/aqb/gnc-ab-getbalance.c	                        (rev 0)
+++ gnucash/trunk/src/import-export/aqb/gnc-ab-getbalance.c	2013-12-15 17:21:20 UTC (rev 23567)
@@ -0,0 +1,157 @@
+/*
+ * gnc-ab-getbalance.c --
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, contact:
+ *
+ * Free Software Foundation           Voice:  +1-617-542-5942
+ * 51 Franklin Street, Fifth Floor    Fax:    +1-617-542-2652
+ * Boston, MA  02110-1301,  USA       gnu at gnu.org
+ */
+
+/**
+ * @internal
+ * @file gnc-ab-getbalance.c
+ * @brief AqBanking getbalance functions
+ * @author Copyright (C) 2002 Christian Stimming <stimming at tuhh.de>
+ * @author Copyright (C) 2008 Andreas Koehler <andi5.py at gmx.net>
+ */
+
+#include "config.h"
+
+#include <glib/gi18n.h>
+#include <aqbanking/banking.h>
+#include <aqbanking/jobgetbalance.h>
+
+#include "gnc-ab-getbalance.h"
+#include "gnc-ab-kvp.h"
+#include "gnc-ab-utils.h"
+#include "gnc-gwen-gui.h"
+#include "gnc-ui.h"
+
+/* This static indicates the debugging module that this .o belongs to.  */
+G_GNUC_UNUSED static QofLogModule log_module = G_LOG_DOMAIN;
+
+void
+gnc_ab_getbalance(GtkWidget *parent, Account *gnc_acc)
+{
+    AB_BANKING *api;
+    gboolean online = FALSE;
+    AB_ACCOUNT *ab_acc;
+    AB_JOB *job = NULL;
+    AB_JOB_LIST2 *job_list = NULL;
+    GncGWENGui *gui = NULL;
+    AB_IMEXPORTER_CONTEXT *context = NULL;
+    GncABImExContextImport *ieci = NULL;
+    AB_JOB_STATUS job_status;
+
+    g_return_if_fail(parent && gnc_acc);
+
+    /* Get the API */
+    api = gnc_AB_BANKING_new();
+    if (!api)
+    {
+        g_warning("gnc_ab_gettrans: Couldn't get AqBanking API");
+        return;
+    }
+    if (AB_Banking_OnlineInit(api
+#ifdef AQBANKING_VERSION_4_EXACTLY
+                              , 0
+#endif
+                             ) != 0)
+    {
+        g_warning("gnc_ab_gettrans: Couldn't initialize AqBanking API");
+        goto cleanup;
+    }
+    online = TRUE;
+
+    /* Get the AqBanking Account */
+    ab_acc = gnc_ab_get_ab_account(api, gnc_acc);
+    if (!ab_acc)
+    {
+        g_warning("gnc_ab_getbalance: No AqBanking account found");
+        gnc_error_dialog(parent, _("No valid online banking account assigned."));
+        goto cleanup;
+    }
+
+    /* Get a GetBalance job and enqueue it */
+    job = AB_JobGetBalance_new(ab_acc);
+    if (!job || AB_Job_CheckAvailability(job
+#ifndef AQBANKING_VERSION_5_PLUS
+                                         , 0
+#endif
+                                        ))
+    {
+        g_warning("gnc_ab_getbalance: JobGetBalance not available for this "
+                  "account");
+        gnc_error_dialog(parent, _("Online action \"Get Balance\" not available for this account."));
+        goto cleanup;
+    }
+    job_list = AB_Job_List2_new();
+    AB_Job_List2_PushBack(job_list, job);
+
+    /* Get a GUI object */
+    gui = gnc_GWEN_Gui_get(parent);
+    if (!gui)
+    {
+        g_warning("gnc_ab_getbalance: Couldn't initialize Gwenhywfar GUI");
+        goto cleanup;
+    }
+
+    /* Create a context to store the results */
+    context = AB_ImExporterContext_new();
+
+    /* Execute the job */
+    AB_Banking_ExecuteJobs(api, job_list, context
+#ifndef AQBANKING_VERSION_5_PLUS
+                           , 0
+#endif
+                          );
+    /* Ignore the return value of AB_Banking_ExecuteJobs(), as the job's
+     * status always describes better whether the job was actually
+     * transferred to and accepted by the bank.  See also
+     * http://lists.gnucash.org/pipermail/gnucash-de/2008-September/006389.html
+     */
+    job_status = AB_Job_GetStatus(job);
+    if (job_status != AB_Job_StatusFinished
+            && job_status != AB_Job_StatusPending)
+    {
+        g_warning("gnc_ab_getbalance: Error on executing job");
+        gnc_error_dialog(parent, _("Error on executing job.\n\nStatus: %s - %s")
+                         , AB_Job_Status2Char(job_status)
+                         , AB_Job_GetResultText(job));
+        goto cleanup;
+    }
+
+    /* Import the results */
+    ieci = gnc_ab_import_context(context, AWAIT_BALANCES, FALSE, NULL, parent);
+
+cleanup:
+    if (ieci)
+        g_free(ieci);
+    if (context)
+        AB_ImExporterContext_free(context);
+    if (gui)
+        gnc_GWEN_Gui_release(gui);
+    if (job_list)
+        AB_Job_List2_free(job_list);
+    if (job)
+        AB_Job_free(job);
+    if (online)
+#ifdef AQBANKING_VERSION_4_EXACTLY
+        AB_Banking_OnlineFini(api, 0);
+#else
+        AB_Banking_OnlineFini(api);
+#endif
+    gnc_AB_BANKING_fini(api);
+}

Copied: gnucash/trunk/src/import-export/aqb/gnc-ab-getbalance.h (from rev 23566, gnucash/trunk/src/import-export/aqbanking/gnc-ab-getbalance.h)
===================================================================
--- gnucash/trunk/src/import-export/aqb/gnc-ab-getbalance.h	                        (rev 0)
+++ gnucash/trunk/src/import-export/aqb/gnc-ab-getbalance.h	2013-12-15 17:21:20 UTC (rev 23567)
@@ -0,0 +1,55 @@
+/*
+ * gnc-ab-get-balance.h --
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, contact:
+ *
+ * Free Software Foundation           Voice:  +1-617-542-5942
+ * 51 Franklin Street, Fifth Floor    Fax:    +1-617-542-2652
+ * Boston, MA  02110-1301,  USA       gnu at gnu.org
+ */
+
+/**
+ * @addtogroup Import_Export
+ * @{
+ * @addtogroup AqBanking
+ * @{
+ * @file gnc-ab-getbalance.h
+ * @brief AqBanking getbalance functions
+ * @author Copyright (C) 2002 Christian Stimming <stimming at tuhh.de>
+ * @author Copyright (C) 2008 Andreas Koehler <andi5.py at gmx.net>
+ */
+
+#ifndef GNC_AB_GETBALANCE_H
+#define GNC_AB_GETBALANCE_H
+
+#include <gtk/gtk.h>
+
+#include "Account.h"
+
+G_BEGIN_DECLS
+
+/**
+ * Execute a GetBalance job, show the resulting balance and offer to reconcile
+ * the GnuCash account.
+ *
+ * @param parent Widget to use as parent, may be NULL
+ * @param gnc_acc GnuCash account to fetch balance for
+ */
+void gnc_ab_getbalance(GtkWidget *parent, Account *gnc_acc);
+
+G_END_DECLS
+
+#endif /* GNC_AB_GETBALANCE_H */
+/** @} */
+/** @} */

Copied: gnucash/trunk/src/import-export/aqb/gnc-ab-gettrans.c (from rev 23566, gnucash/trunk/src/import-export/aqbanking/gnc-ab-gettrans.c)
===================================================================
--- gnucash/trunk/src/import-export/aqb/gnc-ab-gettrans.c	                        (rev 0)
+++ gnucash/trunk/src/import-export/aqb/gnc-ab-gettrans.c	2013-12-15 17:21:20 UTC (rev 23567)
@@ -0,0 +1,244 @@
+/*
+ * gnc-ab-gettrans.c --
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, contact:
+ *
+ * Free Software Foundation           Voice:  +1-617-542-5942
+ * 51 Franklin Street, Fifth Floor    Fax:    +1-617-542-2652
+ * Boston, MA  02110-1301,  USA       gnu at gnu.org
+ */
+
+/**
+ * @internal
+ * @file gnc-ab-gettrans.c
+ * @brief AqBanking get transactions functions
+ * @author Copyright (C) 2002 Christian Stimming <stimming at tuhh.de>
+ * @author Copyright (C) 2008 Andreas Koehler <andi5.py at gmx.net>
+ */
+
+#include "config.h"
+
+#include <glib/gi18n.h>
+#include <aqbanking/banking.h>
+#include <aqbanking/jobgettransactions.h>
+
+#include "Account.h"
+#include "dialog-ab-daterange.h"
+#include "gnc-ab-gettrans.h"
+#include "gnc-ab-kvp.h"
+#include "gnc-ab-utils.h"
+#include "gnc-gwen-gui.h"
+#include "gnc-ui.h"
+
+/* This static indicates the debugging module that this .o belongs to.  */
+G_GNUC_UNUSED static QofLogModule log_module = G_LOG_DOMAIN;
+
+static gboolean gettrans_dates(GtkWidget *parent, Account *gnc_acc, GWEN_TIME **from_date, GWEN_TIME **to_date);
+
+static gboolean
+gettrans_dates(GtkWidget *parent, Account *gnc_acc,
+               GWEN_TIME **from_date, GWEN_TIME **to_date)
+{
+    Timespec last_timespec, until_timespec;
+    time64 now = gnc_time (NULL);
+    gboolean use_last_date = TRUE;
+    gboolean use_earliest_date = TRUE;
+    gboolean use_until_now = TRUE;
+
+    g_return_val_if_fail(from_date && to_date, FALSE);
+
+    /* Get time of last retrieval */
+    last_timespec = gnc_ab_get_account_trans_retrieval(gnc_acc);
+    if (last_timespec.tv_sec == 0)
+    {
+        use_last_date = FALSE;
+        timespecFromTime64 (&last_timespec, now);
+    }
+    timespecFromTime64 (&until_timespec, now);
+
+    /* Let the user choose the date range of retrieval */
+    if (!gnc_ab_enter_daterange(parent, NULL,
+                                &last_timespec,
+                                &use_last_date, &use_earliest_date,
+                                &until_timespec, &use_until_now))
+        return FALSE;
+
+    /* Now calculate from date */
+    if (use_earliest_date)
+    {
+        *from_date = NULL;
+    }
+    else
+    {
+        if (use_last_date)
+            last_timespec = gnc_ab_get_account_trans_retrieval(gnc_acc);
+        *from_date = GWEN_Time_fromSeconds(timespecToTime64(last_timespec));
+    }
+
+    /* Now calculate to date */
+    if (use_until_now)
+        timespecFromTime64(&until_timespec, now);
+    *to_date = GWEN_Time_fromSeconds(timespecToTime64(until_timespec));
+
+    return TRUE;
+}
+
+void
+gnc_ab_gettrans(GtkWidget *parent, Account *gnc_acc)
+{
+    AB_BANKING *api;
+    gboolean online = FALSE;
+    AB_ACCOUNT *ab_acc;
+    GWEN_TIME *from_date = NULL, *to_date = NULL;
+    Timespec until_timespec;
+    AB_JOB *job = NULL;
+    AB_JOB_LIST2 *job_list = NULL;
+    GncGWENGui *gui = NULL;
+    AB_IMEXPORTER_CONTEXT *context = NULL;
+    GncABImExContextImport *ieci = NULL;
+    AB_JOB_STATUS job_status;
+
+    g_return_if_fail(parent && gnc_acc);
+
+    /* Get the API */
+    api = gnc_AB_BANKING_new();
+    if (!api)
+    {
+        g_warning("gnc_ab_gettrans: Couldn't get AqBanking API");
+        return;
+    }
+    if (AB_Banking_OnlineInit(api
+#ifdef AQBANKING_VERSION_4_EXACTLY
+                              , 0
+#endif
+                             ) != 0)
+    {
+        g_warning("gnc_ab_gettrans: Couldn't initialize AqBanking API");
+        goto cleanup;
+    }
+    online = TRUE;
+
+    /* Get the AqBanking Account */
+    ab_acc = gnc_ab_get_ab_account(api, gnc_acc);
+    if (!ab_acc)
+    {
+        g_warning("gnc_ab_gettrans: No AqBanking account found");
+        gnc_error_dialog(parent, _("No valid online banking account assigned."));
+        goto cleanup;
+    }
+
+    /* Get the start and end dates for the GetTransactions job.  */
+    if (!gettrans_dates(parent, gnc_acc, &from_date, &to_date))
+    {
+        g_debug("gnc_ab_gettrans: gettrans_dates aborted");
+        goto cleanup;
+    }
+    /* Use this as a local storage for the until_time below. */
+    timespecFromTime64(&until_timespec, GWEN_Time_toTime_t(to_date));
+
+    /* Get a GetTransactions job and enqueue it */
+    job = AB_JobGetTransactions_new(ab_acc);
+    if (!job || AB_Job_CheckAvailability(job
+#ifndef AQBANKING_VERSION_5_PLUS
+                                         , 0
+#endif
+                                        ))
+    {
+        g_warning("gnc_ab_gettrans: JobGetTransactions not available for this "
+                  "account");
+        gnc_error_dialog(parent, _("Online action \"Get Transactions\" not available for this account."));
+        goto cleanup;
+    }
+    AB_JobGetTransactions_SetFromTime(job, from_date);
+    AB_JobGetTransactions_SetToTime(job, to_date);
+    job_list = AB_Job_List2_new();
+    AB_Job_List2_PushBack(job_list, job);
+
+    /* Get a GUI object */
+    gui = gnc_GWEN_Gui_get(parent);
+    if (!gui)
+    {
+        g_warning("gnc_ab_gettrans: Couldn't initialize Gwenhywfar GUI");
+        goto cleanup;
+    }
+
+    /* Create a context to store the results */
+    context = AB_ImExporterContext_new();
+
+    /* Execute the job */
+    AB_Banking_ExecuteJobs(api, job_list, context
+#ifndef AQBANKING_VERSION_5_PLUS
+                           , 0
+#endif
+                          );
+    /* Ignore the return value of AB_Banking_ExecuteJobs(), as the job's
+     * status always describes better whether the job was actually
+     * transferred to and accepted by the bank.  See also
+     * http://lists.gnucash.org/pipermail/gnucash-de/2008-September/006389.html
+     */
+    job_status = AB_Job_GetStatus(job);
+    if (job_status != AB_Job_StatusFinished
+            && job_status != AB_Job_StatusPending)
+    {
+        g_warning("gnc_ab_gettrans: Error on executing job");
+        gnc_error_dialog(parent, _("Error on executing job.\n\nStatus: %s - %s")
+                         , AB_Job_Status2Char(job_status)
+                         , AB_Job_GetResultText(job));
+        goto cleanup;
+    }
+
+    /* Import the results */
+    ieci = gnc_ab_import_context(context, AWAIT_TRANSACTIONS, FALSE, NULL,
+                                 parent);
+    if (!(gnc_ab_ieci_get_found(ieci) & FOUND_TRANSACTIONS))
+    {
+        /* No transaction found */
+        GtkWidget *dialog = gtk_message_dialog_new(
+                                GTK_WINDOW(parent),
+                                GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT,
+                                GTK_MESSAGE_INFO,
+                                GTK_BUTTONS_OK,
+                                "%s",
+                                _("The Online Banking import returned no transactions "
+                                  "for the selected time period."));
+        gtk_dialog_run(GTK_DIALOG(dialog));
+        gtk_widget_destroy(dialog);
+    }
+
+    /* Store the date of this retrieval */
+    gnc_ab_set_account_trans_retrieval(gnc_acc, until_timespec);
+
+cleanup:
+    if (ieci)
+        g_free(ieci);
+    if (context)
+        AB_ImExporterContext_free(context);
+    if (gui)
+        gnc_GWEN_Gui_release(gui);
+    if (job_list)
+        AB_Job_List2_free(job_list);
+    if (job)
+        AB_Job_free(job);
+    if (to_date)
+        GWEN_Time_free(to_date);
+    if (from_date)
+        GWEN_Time_free(from_date);
+    if (online)
+#ifdef AQBANKING_VERSION_4_EXACTLY
+        AB_Banking_OnlineFini(api, 0);
+#else
+        AB_Banking_OnlineFini(api);
+#endif
+    gnc_AB_BANKING_fini(api);
+}

Copied: gnucash/trunk/src/import-export/aqb/gnc-ab-gettrans.h (from rev 23566, gnucash/trunk/src/import-export/aqbanking/gnc-ab-gettrans.h)
===================================================================
--- gnucash/trunk/src/import-export/aqb/gnc-ab-gettrans.h	                        (rev 0)
+++ gnucash/trunk/src/import-export/aqb/gnc-ab-gettrans.h	2013-12-15 17:21:20 UTC (rev 23567)
@@ -0,0 +1,52 @@
+/*
+ * gnc-ab-get-balance.h --
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, contact:
+ *
+ * Free Software Foundation           Voice:  +1-617-542-5942
+ * 51 Franklin Street, Fifth Floor    Fax:    +1-617-542-2652
+ * Boston, MA  02110-1301,  USA       gnu at gnu.org
+ */
+
+/**
+ * @addtogroup Import_Export
+ * @{
+ * @addtogroup AqBanking
+ * @{
+ * @file gnc-ab-getbalance.h
+ * @brief AqBanking getbalance functions
+ * @author Copyright (C) 2002 Christian Stimming
+ * @author Copyright (C) 2008 Andreas Koehler <andi5.py at gmx.net>
+ */
+
+#ifndef GNC_AB_GETTRANS_H
+#define GNC_AB_GETTRANS_H
+
+#include <glib.h>
+
+G_BEGIN_DECLS
+
+/**
+ * Execute a GetTransactions job.
+ *
+ * @param parent Widget to use as parent, may be NULL
+ * @param gnc_acc GnuCash account to fetch transactions for
+ */
+void gnc_ab_gettrans(GtkWidget *parent, Account *gnc_acc);
+
+G_END_DECLS
+
+#endif /* GNC_AB_GETTRANS_H */
+/** @} */
+/** @} */

Copied: gnucash/trunk/src/import-export/aqb/gnc-ab-kvp.c (from rev 23566, gnucash/trunk/src/import-export/aqbanking/gnc-ab-kvp.c)
===================================================================
--- gnucash/trunk/src/import-export/aqb/gnc-ab-kvp.c	                        (rev 0)
+++ gnucash/trunk/src/import-export/aqb/gnc-ab-kvp.c	2013-12-15 17:21:20 UTC (rev 23567)
@@ -0,0 +1,165 @@
+/*
+ * gnc-ab-kvp.c --
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, contact:
+ *
+ * Free Software Foundation           Voice:  +1-617-542-5942
+ * 51 Franklin Street, Fifth Floor    Fax:    +1-617-542-2652
+ * Boston, MA  02110-1301,  USA       gnu at gnu.org
+ */
+
+/**
+ * @internal
+ * @file gnc-ab-kvp.c
+ * @brief AqBanking KVP handling
+ * @author Copyright (C) 2002 Christian Stimming <stimming at tuhh.de>
+ * @author Copyright (C) 2008 Andreas Koehler <andi5.py at gmx.net>
+ */
+
+#include "config.h"
+#include "gnc-ui-util.h"
+
+#include "gnc-ab-kvp.h"
+
+#define AB_KEY "hbci"
+#define AB_ACCOUNT_ID "account-id"
+#define AB_ACCOUNT_UID "account-uid"
+#define AB_BANK_CODE "bank-code"
+#define AB_TRANS_RETRIEVAL "trans-retrieval"
+#define AB_TEMPLATES "template-list"
+
+/* This static indicates the debugging module that this .o belongs to.  */
+G_GNUC_UNUSED static QofLogModule log_module = G_LOG_DOMAIN;
+
+static kvp_frame *gnc_ab_get_account_kvp(const Account *a, gboolean create);
+static kvp_frame *gnc_ab_get_book_kvp(QofBook *b, gboolean create);
+
+const gchar *
+gnc_ab_get_account_accountid(const Account *a)
+{
+    kvp_frame *frame = gnc_ab_get_account_kvp(a, FALSE);
+    kvp_value *value = kvp_frame_get_slot(frame, AB_ACCOUNT_ID);
+    return kvp_value_get_string(value);
+}
+
+void
+gnc_ab_set_account_accountid(Account *a, const gchar *id)
+{
+    kvp_frame *frame = gnc_ab_get_account_kvp(a, TRUE);
+    kvp_value *value = kvp_value_new_string(id);
+    xaccAccountBeginEdit(a);
+    kvp_frame_set_slot_nc(frame, AB_ACCOUNT_ID, value);
+    qof_instance_set_dirty(QOF_INSTANCE (a));
+    xaccAccountCommitEdit(a);
+}
+
+const gchar *
+gnc_ab_get_account_bankcode(const Account *a)
+{
+    kvp_frame *frame = gnc_ab_get_account_kvp(a, FALSE);
+    kvp_value *value = kvp_frame_get_slot(frame, AB_BANK_CODE);
+    return kvp_value_get_string(value);
+}
+
+void
+gnc_ab_set_account_bankcode(Account *a, const gchar *code)
+{
+    kvp_frame *frame = gnc_ab_get_account_kvp(a, TRUE);
+    kvp_value *value = kvp_value_new_string(code);
+    xaccAccountBeginEdit(a);
+    kvp_frame_set_slot_nc(frame, AB_BANK_CODE, value);
+    qof_instance_set_dirty(QOF_INSTANCE (a));
+    xaccAccountCommitEdit(a);
+}
+
+guint32
+gnc_ab_get_account_uid(const Account *a)
+{
+    kvp_frame *frame = gnc_ab_get_account_kvp(a, FALSE);
+    kvp_value *value = kvp_frame_get_slot(frame, AB_ACCOUNT_UID);
+    return (guint32) kvp_value_get_gint64(value);
+}
+
+void
+gnc_ab_set_account_uid(Account *a, guint32 uid)
+{
+    kvp_frame *frame = gnc_ab_get_account_kvp(a, TRUE);
+    kvp_value *value = kvp_value_new_gint64(uid);
+    xaccAccountBeginEdit(a);
+    kvp_frame_set_slot_nc(frame, AB_ACCOUNT_UID, value);
+    qof_instance_set_dirty(QOF_INSTANCE (a));
+    xaccAccountCommitEdit(a);
+}
+
+Timespec
+gnc_ab_get_account_trans_retrieval(const Account *a)
+{
+    kvp_frame *frame = gnc_ab_get_account_kvp(a, FALSE);
+    kvp_value *value = kvp_frame_get_slot(frame, AB_TRANS_RETRIEVAL);
+    return kvp_value_get_timespec(value);
+}
+
+void
+gnc_ab_set_account_trans_retrieval(Account *a, Timespec time)
+{
+    kvp_frame *frame = gnc_ab_get_account_kvp(a, TRUE);
+    kvp_value *value = kvp_value_new_timespec(time);
+    xaccAccountBeginEdit(a);
+    kvp_frame_set_slot_nc(frame, AB_TRANS_RETRIEVAL, value);
+    qof_instance_set_dirty(QOF_INSTANCE (a));
+    xaccAccountCommitEdit(a);
+}
+
+GList *
+gnc_ab_get_book_template_list(QofBook *b)
+{
+    kvp_frame *frame = gnc_ab_get_book_kvp(b, FALSE);
+    kvp_value *value = kvp_frame_get_slot(frame, AB_TEMPLATES);
+    return kvp_value_get_glist(value);
+}
+
+void
+gnc_ab_set_book_template_list(QofBook *b, GList *template_list)
+{
+    kvp_frame *frame = gnc_ab_get_book_kvp(b, TRUE);
+    kvp_value *value = kvp_value_new_glist_nc(template_list);
+    kvp_frame_set_slot_nc(frame, AB_TEMPLATES, value);
+    qof_book_kvp_changed (b);
+}
+
+static kvp_frame *
+gnc_ab_get_account_kvp(const Account *a, gboolean create)
+{
+    kvp_frame *toplevel = xaccAccountGetSlots(a);
+    kvp_frame *result = kvp_frame_get_frame(toplevel, AB_KEY);
+    if (!result && create)
+    {
+        result = kvp_frame_new();
+        kvp_frame_add_frame_nc(toplevel, AB_KEY, result);
+    }
+    return result;
+}
+
+static kvp_frame *
+gnc_ab_get_book_kvp(QofBook *b, gboolean create)
+{
+    kvp_frame *toplevel = qof_book_get_slots(b);
+    kvp_frame *result = kvp_frame_get_frame(toplevel, AB_KEY);
+    if (!result && create)
+    {
+        result = kvp_frame_new();
+        kvp_frame_add_frame_nc(toplevel, AB_KEY, result);
+    }
+    return result;
+}

Copied: gnucash/trunk/src/import-export/aqb/gnc-ab-kvp.h (from rev 23566, gnucash/trunk/src/import-export/aqbanking/gnc-ab-kvp.h)
===================================================================
--- gnucash/trunk/src/import-export/aqb/gnc-ab-kvp.h	                        (rev 0)
+++ gnucash/trunk/src/import-export/aqb/gnc-ab-kvp.h	2013-12-15 17:21:20 UTC (rev 23567)
@@ -0,0 +1,148 @@
+/*
+ * gnc-ab-kvp.h --
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, contact:
+ *
+ * Free Software Foundation           Voice:  +1-617-542-5942
+ * 51 Franklin Street, Fifth Floor    Fax:    +1-617-542-2652
+ * Boston, MA  02110-1301,  USA       gnu at gnu.org
+ */
+
+/**
+ * @addtogroup Import_Export
+ * @{
+ * @addtogroup AqBanking
+ * @{
+ * @file gnc-ab-kvp.h
+ * @brief AqBanking KVP handling
+ * @author Copyright (C) 2002 Christian Stimming <stimming at tuhh.de>
+ * @author Copyright (C) 2008 Andreas Koehler <andi5.py at gmx.net>
+ */
+
+#ifndef GNC_AB_KVP_H
+#define GNC_AB_KVP_H
+
+#include <glib.h>
+
+#include "Account.h"
+
+G_BEGIN_DECLS
+
+/** @name Account
+ *  @{ */
+
+/**
+ * Return a non-copied pointer to the accountid string in the Account @a a.
+ * The gchar* is still owned by the kvp_frame, so don't free it until you want
+ * to delete the whole kvp_frame.
+ *
+ * @param a Account
+ * @return Account ID
+ */
+const gchar *gnc_ab_get_account_accountid(const Account *a);
+
+/**
+ * Set the accountid string in the Account @a a to @a id.  A copy of the string
+ * will be stored.  The Account will be marked as "dirty".
+ *
+ * @param a Account
+ * @param id Account ID
+ */
+void gnc_ab_set_account_accountid(Account *a, const gchar *id);
+
+/**
+ * Return a non-copied pointer to the bankcode string in the Account @a a.  The
+ * gchar* is still owned by the kvp_frame, so don't free it until you want to
+ * delete the whole kvp_frame.
+ *
+ * @param a Account
+ * @return Bank code
+ */
+const gchar *gnc_ab_get_account_bankcode(const Account *a);
+
+/**
+ * Set the bankcode string in the Account @a a to @a code.  A copy of the string
+ * will be stored.  The Account will be marked as "dirty".
+ *
+ * @param a Account
+ * @param code Bank code
+ */
+void gnc_ab_set_account_bankcode(Account *a, const gchar *code);
+
+/**
+ * Return the unique id for the AB_BANKING account in the Account @a a.
+ *
+ * @param a Account
+ * @return Unique ID
+ */
+guint32 gnc_ab_get_account_uid(const Account *a);
+
+/**
+ * Set the unique id for the AB_BANKING account in the Account @a a to @a uid.
+ * The Account will be marked as "dirty".
+ *
+ * @param a Account
+ * @param uid Unique ID
+ */
+void gnc_ab_set_account_uid(Account *a, guint32 uid);
+
+/**
+ * Return the time of last online transaction retrieval for Account @a a.
+ *
+ * @param a Account
+ * @return Retrieval time
+ */
+Timespec gnc_ab_get_account_trans_retrieval(const Account *a);
+
+/**
+ * Set the time of last online transaction retrieval for Account @a a.  The
+ * account will be marked as "dirty".
+ *
+ * @param a Account
+ * @param time Retrieval time
+ */
+void gnc_ab_set_account_trans_retrieval(Account *a, Timespec time);
+
+/** @} */
+
+/** @name Book
+ *  @{ */
+
+/**
+ * Return a non-copied pointer to the GList of kvp_frames which eventually are
+ * the template transactions, stored in the given book.
+ *
+ * @param b Book
+ * @return Template list
+ */
+GList *gnc_ab_get_book_template_list(QofBook *b);
+
+/**
+ * Set the GList of kvp_frames of template transactions in the Book @a b to @a
+ * template_list.  No copy of the GList will be stored, the callee becomes the
+ * owner and the caller must not free it.  The book will be marked "dirty".
+ *
+ * @param b Book
+ * @param template_list Template list
+ */
+void gnc_ab_set_book_template_list(QofBook *b, GList *template_list);
+
+/** @} */
+
+G_END_DECLS
+
+/** @} */
+/** @} */
+
+#endif /* GNC_AB_KVP_H */

Copied: gnucash/trunk/src/import-export/aqb/gnc-ab-trans-templ.c (from rev 23566, gnucash/trunk/src/import-export/aqbanking/gnc-ab-trans-templ.c)
===================================================================
--- gnucash/trunk/src/import-export/aqb/gnc-ab-trans-templ.c	                        (rev 0)
+++ gnucash/trunk/src/import-export/aqb/gnc-ab-trans-templ.c	2013-12-15 17:21:20 UTC (rev 23567)
@@ -0,0 +1,287 @@
+/*
+ * gnc-ab-trans-templ.c --
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, contact:
+ *
+ * Free Software Foundation           Voice:  +1-617-542-5942
+ * 51 Franklin Street, Fifth Floor    Fax:    +1-617-542-2652
+ * Boston, MA  02110-1301,  USA       gnu at gnu.org
+ */
+
+/**
+ * @internal
+ * @file gnc-ab-trans-templ.c
+ * @brief Templates for AqBanking transactions
+ * @author Copyright (C) 2002 Christian Stimming <stimming at tuhh.de>
+ * @author Copyright (C) 2008 Andreas Koehler <andi5.py at gmx.net>
+ */
+
+#include "config.h"
+
+#include "gnc-ab-trans-templ.h"
+
+/* This static indicates the debugging module that this .o belongs to.  */
+G_GNUC_UNUSED static QofLogModule log_module = G_LOG_DOMAIN;
+
+/* kvp_frame slot names */
+#define TT_NAME "name"
+#define TT_RNAME "rnam"
+#define TT_RACC "racc"
+#define TT_RBCODE "rbcd"
+#define TT_PURPOS "purp"
+#define TT_PURPOSCT "purc"
+#define TT_AMOUNT "amou"
+
+struct _GncABTransTempl
+{
+    /* Name of this Template */
+    gchar *name;
+    gchar *name_key; /* Collation key */
+
+    /* Recipient */
+    gchar *recp_name;
+    gchar *recp_account;
+    gchar *recp_bankcode;
+
+    /* Amount */
+    gnc_numeric amount;
+
+    /* Purpose, description */
+    gchar *purpose;
+    gchar *purpose_cont;
+};
+
+
+GncABTransTempl *
+gnc_ab_trans_templ_new(void)
+{
+    return gnc_ab_trans_templ_new_full(NULL, NULL, NULL, NULL,
+                                       gnc_numeric_zero(), NULL, NULL);
+}
+
+GncABTransTempl *
+gnc_ab_trans_templ_new_full(const char *name, const char *recp_name,
+                            const char *recp_account, const char *recp_bankcode,
+                            gnc_numeric amount, const char *purpose,
+                            const char *purpose_cont)
+{
+    GncABTransTempl *r = g_new(GncABTransTempl, 1);
+    r->name = g_strdup(name);
+    r->name_key = g_utf8_collate_key(name, -1);
+    r->recp_name = g_strdup(recp_name);
+    r->recp_account = g_strdup(recp_account);
+    r->recp_bankcode = g_strdup(recp_bankcode);
+    r->amount = amount;
+    r->purpose = g_strdup(purpose);
+    r->purpose_cont = g_strdup(purpose_cont);
+
+    return r;
+}
+
+GncABTransTempl *
+gnc_ab_trans_templ_new_from_kvp(const kvp_frame *k)
+{
+    g_return_val_if_fail(k, NULL);
+
+    return gnc_ab_trans_templ_new_full(
+               kvp_value_get_string(kvp_frame_get_slot(k, TT_NAME)),
+               kvp_value_get_string(kvp_frame_get_slot(k, TT_RNAME)),
+               kvp_value_get_string(kvp_frame_get_slot(k, TT_RACC)),
+               kvp_value_get_string(kvp_frame_get_slot(k, TT_RBCODE)),
+               kvp_value_get_numeric(kvp_frame_get_slot(k, TT_AMOUNT)),
+               kvp_value_get_string(kvp_frame_get_slot(k, TT_PURPOS)),
+               kvp_value_get_string(kvp_frame_get_slot(k, TT_PURPOSCT)));
+}
+
+GList *
+gnc_ab_trans_templ_list_new_from_kvp_list(GList *v)
+{
+    GList *res = NULL;
+    GList *iter;
+
+    for (iter = v; iter; iter = iter->next)
+    {
+        kvp_frame *frame = kvp_value_get_frame((kvp_value*) iter->data);
+        res = g_list_prepend(res, gnc_ab_trans_templ_new_from_kvp(frame));
+    }
+    res = g_list_reverse(res);
+
+    return res;
+}
+
+void
+gnc_ab_trans_templ_free(GncABTransTempl *t)
+{
+    if (!t) return;
+    g_free(t->name);
+    g_free(t->name_key);
+    g_free(t->recp_name);
+    g_free(t->recp_account);
+    g_free(t->recp_bankcode);
+    g_free(t->purpose);
+    g_free(t->purpose_cont);
+    g_free(t);
+}
+
+void
+gnc_ab_trans_templ_list_free(GList *l)
+{
+    GList *iter;
+    for (iter = l; iter; iter = iter->next)
+        gnc_ab_trans_templ_free((GncABTransTempl*) iter->data);
+    g_list_free(l);
+}
+
+kvp_frame *
+gnc_ab_trans_templ_to_kvp(const GncABTransTempl *t)
+{
+    kvp_frame *k;
+
+    g_return_val_if_fail(t, NULL);
+
+    k = kvp_frame_new();
+    kvp_frame_set_slot(k, TT_NAME, kvp_value_new_string(t->name));
+    kvp_frame_set_slot(k, TT_RNAME, kvp_value_new_string(t->recp_name));
+    kvp_frame_set_slot(k, TT_RACC, kvp_value_new_string(t->recp_account));
+    kvp_frame_set_slot(k, TT_RBCODE, kvp_value_new_string(t->recp_bankcode));
+    kvp_frame_set_slot(k, TT_AMOUNT, kvp_value_new_gnc_numeric(t->amount));
+    kvp_frame_set_slot(k, TT_PURPOS, kvp_value_new_string(t->purpose));
+    kvp_frame_set_slot(k, TT_PURPOSCT, kvp_value_new_string(t->purpose_cont));
+
+    return k;
+}
+
+GList *
+gnc_ab_trans_templ_list_to_kvp_list(GList *k)
+{
+    GList *res = NULL;
+    GList *iter;
+
+    for (iter = k; iter; iter = iter->next)
+    {
+        GncABTransTempl *t = (GncABTransTempl*) iter->data;
+        kvp_value *value = kvp_value_new_frame_nc(gnc_ab_trans_templ_to_kvp(t));
+        res = g_list_prepend(res, value);
+    }
+    res = g_list_reverse(res);
+
+    return res;
+}
+
+const gchar *
+gnc_ab_trans_templ_get_name(const GncABTransTempl *t)
+{
+    g_return_val_if_fail(t, NULL);
+    return t->name;
+}
+
+const gchar *
+gnc_ab_trans_templ_get_recp_name(const GncABTransTempl *t)
+{
+    g_return_val_if_fail(t, NULL);
+    return t->recp_name;
+}
+
+const gchar *
+gnc_ab_trans_templ_get_recp_account(const GncABTransTempl *t)
+{
+    g_return_val_if_fail(t, NULL);
+    return t->recp_account;
+}
+
+const gchar *
+gnc_ab_trans_templ_get_recp_bankcode(const GncABTransTempl *t)
+{
+    g_return_val_if_fail(t, NULL);
+    return t->recp_bankcode;
+}
+
+gnc_numeric
+gnc_ab_trans_templ_get_amount(const GncABTransTempl *t)
+{
+    g_return_val_if_fail(t, gnc_numeric_zero());
+    return t->amount;
+}
+
+const gchar *
+gnc_ab_trans_templ_get_purpose(const GncABTransTempl *t)
+{
+    g_return_val_if_fail(t, NULL);
+    return t->purpose;
+}
+
+const gchar *
+gnc_ab_trans_templ_get_purpose_cont(const GncABTransTempl *t)
+{
+    g_return_val_if_fail(t, NULL);
+    return t->purpose_cont;
+}
+
+void
+gnc_ab_trans_templ_set_name(GncABTransTempl *t, const gchar *name)
+{
+    g_return_if_fail(t);
+    g_free(t->name);
+    t->name = g_strdup(name);
+}
+
+void
+gnc_ab_trans_templ_set_recp_name(GncABTransTempl *t, const gchar *recp_name)
+{
+    g_return_if_fail(t);
+    g_free(t->recp_name);
+    t->recp_name = g_strdup(recp_name);
+}
+
+void
+gnc_ab_trans_templ_set_recp_account(GncABTransTempl *t,
+                                    const gchar *recp_account)
+{
+    g_return_if_fail(t);
+    g_free(t->recp_account);
+    t->recp_account = g_strdup(recp_account);
+}
+
+void
+gnc_ab_trans_templ_set_recp_bankcode(GncABTransTempl *t,
+                                     const gchar *recp_bankcode)
+{
+    g_return_if_fail(t);
+    g_free(t->recp_bankcode);
+    t->recp_bankcode = g_strdup(recp_bankcode);
+}
+
+void
+gnc_ab_trans_templ_set_amount(GncABTransTempl *t, gnc_numeric amount)
+{
+    g_return_if_fail(t);
+    t->amount = amount;
+}
+
+void
+gnc_ab_trans_templ_set_purpose(GncABTransTempl *t, const gchar *purpose)
+{
+    g_return_if_fail(t);
+    g_free(t->purpose);
+    t->purpose = g_strdup(purpose);
+}
+
+void
+gnc_ab_trans_templ_set_purpose_cont(GncABTransTempl *t,
+                                    const gchar *purpose_cont)
+{
+    g_return_if_fail(t);
+    g_free(t->purpose_cont);
+    t->purpose_cont = g_strdup(purpose_cont);
+}

Copied: gnucash/trunk/src/import-export/aqb/gnc-ab-trans-templ.h (from rev 23566, gnucash/trunk/src/import-export/aqbanking/gnc-ab-trans-templ.h)
===================================================================
--- gnucash/trunk/src/import-export/aqb/gnc-ab-trans-templ.h	                        (rev 0)
+++ gnucash/trunk/src/import-export/aqb/gnc-ab-trans-templ.h	2013-12-15 17:21:20 UTC (rev 23567)
@@ -0,0 +1,223 @@
+/*
+ * gnc-ab-trans-templ.h --
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, contact:
+ *
+ * Free Software Foundation           Voice:  +1-617-542-5942
+ * 51 Franklin Street, Fifth Floor    Fax:    +1-617-542-2652
+ * Boston, MA  02110-1301,  USA       gnu at gnu.org
+ */
+
+/**
+ * @addtogroup Import_Export
+ * @{
+ * @addtogroup AqBanking
+ * @{
+ * @file gnc-ab-trans-templ.h
+ * @brief Templates for AqBanking transactions
+ * @author Copyright (C) 2003 Christian Stimming <stimming at tuhh.de>
+ * @author Copyright (C) 2008 Andreas Koehler <andi5.py at gmx.net>
+ */
+
+#ifndef GNC_AB_TRANS_TEMPL_H
+#define GNC_AB_TRANS_TEMPL_H
+
+#include <glib.h>
+
+#include "qof.h"
+
+G_BEGIN_DECLS
+
+/** A template for an AqBanking transaction */
+typedef struct _GncABTransTempl GncABTransTempl;
+
+/**
+ * Create a template with unset contents.
+ *
+ * @return A newly allocated GncABTransTempl
+ */
+GncABTransTempl *gnc_ab_trans_templ_new(void);
+
+/**
+ * Create a template with given contents.
+ *
+ * @param name Name of the template
+ * @param recp_name Name of the recipient
+ * @param recp_account Account Number of the recipient
+ * @param recp_bankcode Bank Code of the recipient
+ * @param amount Amount
+ * @param purpose First purpose line
+ * @param purpose_cont Second purpose line
+ * @return A newly allocated GncABTransTempl
+ */
+GncABTransTempl *gnc_ab_trans_templ_new_full(
+    const gchar *name, const gchar *recp_name, const gchar *recp_account,
+    const gchar *recp_bankcode, gnc_numeric amount, const gchar *purpose,
+    const gchar *purpose_cont);
+
+/**
+ * Create a template, taking the values from a kvp_frame.
+ *
+ * @param k kvp_frame
+ * @return A newly allocated GncABTransTempl
+ */
+GncABTransTempl *gnc_ab_trans_templ_new_from_kvp(const kvp_frame *k);
+
+/**
+ * Create a list of templates from a list of kvp_values which in turn
+ * contain a kvp_frame.
+ *
+ * @param v GList of kvp_values
+ * @return A GList of newly allocated GncABTransTempls
+ */
+GList *gnc_ab_trans_templ_list_new_from_kvp_list(GList *v);
+
+/**
+ * Free the memory used by a template.
+ *
+ * @param t GncABTransTempl to be freed
+ */
+void gnc_ab_trans_templ_free(GncABTransTempl *t);
+
+/**
+ * Free the memory used by a list of templates, including the list itself.
+ *
+ * @param l GList of GncABTransTempl
+ */
+void gnc_ab_trans_templ_list_free(GList *l);
+
+/**
+ * Create a kvp_frame a given template.
+ *
+ * @param t Template
+ * @return A newly allocated kvp_frame
+ */
+kvp_frame *gnc_ab_trans_templ_to_kvp(const GncABTransTempl *t);
+
+/**
+ * Create a list of kvp_values, which in turn contain a kvp_frame, from a list
+ * of templates.
+ *
+ * @param k GList of GncABTransTempls
+ * @return GList of newly allocated kvp_values
+ */
+GList *gnc_ab_trans_templ_list_to_kvp_list(GList *k);
+
+/**
+ * @param t Template
+ * @return Name of the template, an internal string
+ */
+const gchar *gnc_ab_trans_templ_get_name(const GncABTransTempl *t);
+
+/**
+ * @param t Template
+ * @return Name of the recipient, an internal string
+ */
+const gchar *gnc_ab_trans_templ_get_recp_name(const GncABTransTempl *t);
+
+/**
+ * @param t Template
+ * @return Account Number of the recipient, an internal string
+ */
+const gchar *gnc_ab_trans_templ_get_recp_account(const GncABTransTempl *t);
+
+/**
+ * @param t Template
+ * @return Bank Code of the recipient, an internal string
+ */
+const gchar *gnc_ab_trans_templ_get_recp_bankcode(const GncABTransTempl *t);
+
+/**
+ * @param t Template
+ * @return Amount
+ */
+gnc_numeric gnc_ab_trans_templ_get_amount(const GncABTransTempl *t);
+
+/**
+ * @param t Template
+ * @return First purpose line, an internal string
+ */
+const gchar *gnc_ab_trans_templ_get_purpose(const GncABTransTempl *t);
+
+/**
+ * @param t Template
+ * @return Second purpose line, an internal string
+ */
+const gchar *gnc_ab_trans_templ_get_purpose_cont(const GncABTransTempl *t);
+
+/**
+ * Set the name of a template.
+ *
+ * @param t Template
+ * @param name Name
+ */
+void gnc_ab_trans_templ_set_name(GncABTransTempl *t, const gchar *name);
+
+/**
+ * Replace the Account Number of the recipient stored in a template.
+ *
+ * @param t Template
+ * @param recp_name Account Number of the recipient
+ */
+void gnc_ab_trans_templ_set_recp_name(GncABTransTempl *t,
+                                      const gchar *recp_name);
+
+/**
+ * Replace the Account Number of the recipient stored in a template.
+ *
+ * @param t Template
+ * @param recp_account Account Number of the recipient
+ */
+void gnc_ab_trans_templ_set_recp_account(GncABTransTempl *t,
+        const gchar *recp_account);
+
+/**
+ * Replace the Bank Code of the recipient stored in a template.
+ *
+ * @param t Template
+ * @param recp_bankcode Bank Code of the recipient
+ */
+void gnc_ab_trans_templ_set_recp_bankcode(GncABTransTempl *t,
+        const gchar *recp_bankcode);
+
+/**
+ * Replace the amount stored in a template.
+ *
+ * @param t Template
+ * @param amount Amount
+ */
+void gnc_ab_trans_templ_set_amount(GncABTransTempl *t, gnc_numeric amount);
+
+/**
+ * Replace the first purpose line stored in a template.
+ *
+ * @param t Template
+ * @param purpose First purpose line
+ */
+void gnc_ab_trans_templ_set_purpose(GncABTransTempl *t, const gchar *purpose);
+
+/**
+ * Replace the second purpose line stored in a template.
+ *
+ * @param t Template
+ * @param purpose_cont Second purpose line
+ */
+void gnc_ab_trans_templ_set_purpose_cont(GncABTransTempl *t,
+        const gchar *purpose_cont);
+
+G_END_DECLS
+
+#endif /* GNC_AB_TRANS_TEMPL_H */
+/** @} */
+/** @} */

Copied: gnucash/trunk/src/import-export/aqb/gnc-ab-transfer.c (from rev 23566, gnucash/trunk/src/import-export/aqbanking/gnc-ab-transfer.c)
===================================================================
--- gnucash/trunk/src/import-export/aqb/gnc-ab-transfer.c	                        (rev 0)
+++ gnucash/trunk/src/import-export/aqb/gnc-ab-transfer.c	2013-12-15 17:21:20 UTC (rev 23567)
@@ -0,0 +1,357 @@
+/*
+ * gnc-ab-transfer.c --
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, contact:
+ *
+ * Free Software Foundation           Voice:  +1-617-542-5942
+ * 51 Franklin Street, Fifth Floor    Fax:    +1-617-542-2652
+ * Boston, MA  02110-1301,  USA       gnu at gnu.org
+ */
+
+/**
+ * @internal
+ * @file gnc-ab-utils.c
+ * @brief AqBanking transfer functions
+ * @author Copyright (C) 2002 Christian Stimming <stimming at tuhh.de>
+ * @author Copyright (C) 2004 Bernd Wagner
+ * @author Copyright (C) 2006 David Hampton <hampton at employees.org>
+ * @author Copyright (C) 2008 Andreas Koehler <andi5.py at gmx.net>
+ */
+
+#include "config.h"
+
+#include <glib/gi18n.h>
+#include <gtk/gtk.h>
+#include <aqbanking/banking.h>
+
+#include "Transaction.h"
+#include "dialog-transfer.h"
+#include "gnc-ab-transfer.h"
+#include "gnc-ab-kvp.h"
+#include "gnc-ab-utils.h"
+#include "gnc-ab-trans-templ.h"
+#include "gnc-gwen-gui.h"
+#include "gnc-ui.h"
+
+/* This static indicates the debugging module that this .o belongs to.  */
+G_GNUC_UNUSED static QofLogModule log_module = G_LOG_DOMAIN;
+
+static void save_templates(GtkWidget *parent, Account *gnc_acc, GList *templates,
+                           gboolean dont_ask);
+static void txn_created_cb(Transaction *trans, gpointer user_data);
+
+static void
+save_templates(GtkWidget *parent, Account *gnc_acc, GList *templates,
+               gboolean dont_ask)
+{
+    g_return_if_fail(gnc_acc);
+    if (dont_ask || gnc_verify_dialog(
+                parent, FALSE, "%s",
+                _("You have changed the list of online transfer templates, "
+                  "but you cancelled the transfer dialog. "
+                  "Do you nevertheless want to store the changes?")))
+    {
+        GList *kvp_list = gnc_ab_trans_templ_list_to_kvp_list(templates);
+        gnc_ab_set_book_template_list(gnc_account_get_book(gnc_acc), kvp_list);
+    }
+}
+
+static void
+txn_created_cb(Transaction *trans, gpointer user_data)
+{
+    Transaction **trans_loc = user_data;
+
+    if (!trans) return;
+    g_return_if_fail(trans_loc);
+    *trans_loc = trans;
+}
+
+void
+gnc_ab_maketrans(GtkWidget *parent, Account *gnc_acc,
+                 GncABTransType trans_type)
+{
+    AB_BANKING *api;
+    gboolean online = FALSE;
+    AB_ACCOUNT *ab_acc;
+    GList *templates = NULL;
+    GncABTransDialog *td = NULL;
+    gboolean successful = FALSE;
+    gboolean aborted = FALSE;
+
+    g_return_if_fail(parent && gnc_acc);
+
+    /* Get the API */
+    api = gnc_AB_BANKING_new();
+    if (!api)
+    {
+        g_warning("gnc_ab_maketrans: Couldn't get AqBanking API");
+        return;
+    }
+    if (AB_Banking_OnlineInit(api
+#ifdef AQBANKING_VERSION_4_EXACTLY
+                              , 0
+#endif
+                             ) != 0)
+    {
+        g_warning("gnc_ab_maketrans: Couldn't initialize AqBanking API");
+        goto cleanup;
+    }
+    online = TRUE;
+
+    /* Get the AqBanking Account */
+    ab_acc = gnc_ab_get_ab_account(api, gnc_acc);
+    if (!ab_acc)
+    {
+        g_warning("gnc_ab_gettrans: No AqBanking account found");
+        gnc_error_dialog(parent, _("No valid online banking account assigned."));
+        goto cleanup;
+    }
+
+    /* Get list of template transactions */
+    templates = gnc_ab_trans_templ_list_new_from_kvp_list(
+                    gnc_ab_get_book_template_list(gnc_account_get_book(gnc_acc)));
+
+    /* Create new ABTransDialog */
+    td = gnc_ab_trans_dialog_new(parent, ab_acc,
+                                 xaccAccountGetCommoditySCU(gnc_acc),
+                                 trans_type, templates);
+    templates = NULL;
+
+    /* Repeat until AqBanking action was successful or user pressed cancel */
+    do
+    {
+        GncGWENGui *gui = NULL;
+        gint result;
+        gboolean changed;
+        const AB_TRANSACTION *ab_trans;
+        AB_JOB *job = NULL;
+        AB_JOB_LIST2 *job_list = NULL;
+        XferDialog *xfer_dialog = NULL;
+        gnc_numeric amount;
+        gchar *description;
+        gchar *memo;
+        Transaction *gnc_trans = NULL;
+        AB_IMEXPORTER_CONTEXT *context = NULL;
+        AB_JOB_STATUS job_status;
+        GncABImExContextImport *ieci = NULL;
+
+        /* Get a GUI object */
+        gui = gnc_GWEN_Gui_get(parent);
+        if (!gui)
+        {
+            g_warning("gnc_ab_maketrans: Couldn't initialize Gwenhywfar GUI");
+            aborted = TRUE;
+            goto repeat;
+        }
+
+        /* Let the user enter the values */
+        result = gnc_ab_trans_dialog_run_until_ok(td);
+
+        if (result != GNC_RESPONSE_NOW && result != GNC_RESPONSE_LATER)
+        {
+            aborted = TRUE;
+            goto repeat;
+        }
+
+        /* Save the templates */
+        templates = gnc_ab_trans_dialog_get_templ(td, &changed);
+        if (changed)
+            save_templates(parent, gnc_acc, templates,
+                           (result == GNC_RESPONSE_NOW));
+        g_list_free(templates);
+        templates = NULL;
+
+        /* Get a job and enqueue it */
+        ab_trans = gnc_ab_trans_dialog_get_ab_trans(td);
+        job = gnc_ab_trans_dialog_get_job(td);
+        if (!job || AB_Job_CheckAvailability(job
+#ifndef AQBANKING_VERSION_5_PLUS
+                                             , 0
+#endif
+                                            ))
+        {
+            if (!gnc_verify_dialog(
+                        parent, FALSE, "%s",
+                        _("The backend found an error during the preparation "
+                          "of the job. It is not possible to execute this job. \n"
+                          "\n"
+                          "Most probable the bank does not support your chosen "
+                          "job or your Online Banking account does not have the permission "
+                          "to execute this job. More error messages might be "
+                          "visible on your console log.\n"
+                          "\n"
+                          "Do you want to enter the job again?")))
+                aborted = TRUE;
+            goto repeat;
+        }
+        job_list = AB_Job_List2_new();
+        AB_Job_List2_PushBack(job_list, job);
+
+        /* Setup a Transfer Dialog for the GnuCash transaction */
+        xfer_dialog = gnc_xfer_dialog(gnc_ab_trans_dialog_get_parent(td),
+                                      gnc_acc);
+        switch (trans_type)
+        {
+        case SINGLE_DEBITNOTE:
+            gnc_xfer_dialog_set_title(
+                xfer_dialog, _("Online Banking Direct Debit Note"));
+            gnc_xfer_dialog_lock_to_account_tree(xfer_dialog);
+            break;
+        case SINGLE_INTERNAL_TRANSFER:
+            gnc_xfer_dialog_set_title(
+                xfer_dialog, _("Online Banking Bank-Internal Transfer"));
+            gnc_xfer_dialog_lock_from_account_tree(xfer_dialog);
+            break;
+        case SEPA_TRANSFER:
+            gnc_xfer_dialog_set_title(
+                xfer_dialog, _("Online Banking European (SEPA) Transfer"));
+            gnc_xfer_dialog_lock_from_account_tree(xfer_dialog);
+            break;
+        case SEPA_DEBITNOTE:
+            gnc_xfer_dialog_set_title(
+                xfer_dialog, _("Online Banking European (SEPA) Debit Note"));
+            gnc_xfer_dialog_lock_to_account_tree(xfer_dialog);
+            break;
+        case SINGLE_TRANSFER:
+        default:
+            gnc_xfer_dialog_set_title(
+                xfer_dialog, _("Online Banking Transaction"));
+            gnc_xfer_dialog_lock_from_account_tree(xfer_dialog);
+        }
+        gnc_xfer_dialog_set_to_show_button_active(xfer_dialog, TRUE);
+
+        amount = double_to_gnc_numeric(
+                     AB_Value_GetValueAsDouble(AB_Transaction_GetValue(ab_trans)),
+                     xaccAccountGetCommoditySCU(gnc_acc),
+                     GNC_HOW_RND_ROUND_HALF_UP);
+        gnc_xfer_dialog_set_amount(xfer_dialog, amount);
+        gnc_xfer_dialog_set_amount_sensitive(xfer_dialog, FALSE);
+        gnc_xfer_dialog_set_date_sensitive(xfer_dialog, FALSE);
+
+        description = gnc_ab_description_to_gnc(ab_trans);
+        gnc_xfer_dialog_set_description(xfer_dialog, description);
+        g_free(description);
+
+        memo = gnc_ab_memo_to_gnc(ab_trans);
+        gnc_xfer_dialog_set_memo(xfer_dialog, memo);
+        g_free(memo);
+
+        gnc_xfer_dialog_set_txn_cb(xfer_dialog, txn_created_cb, &gnc_trans);
+
+        /* And run it */
+        successful = gnc_xfer_dialog_run_until_done(xfer_dialog);
+
+        /* On cancel, go back to the AB transaction dialog */
+        if (!successful || !gnc_trans)
+        {
+            successful = FALSE;
+            goto repeat;
+        }
+
+        if (result == GNC_RESPONSE_NOW)
+        {
+            /* Create a context to store possible results */
+            context = AB_ImExporterContext_new();
+
+            gui = gnc_GWEN_Gui_get(parent);
+            if (!gui)
+            {
+                g_warning("gnc_ab_maketrans: Couldn't initialize Gwenhywfar GUI");
+                aborted = TRUE;
+                goto repeat;
+            }
+
+            /* Finally, execute the job */
+            AB_Banking_ExecuteJobs(api, job_list, context
+#ifndef AQBANKING_VERSION_5_PLUS
+                                   , 0
+#endif
+                                  );
+
+            /* Ignore the return value of AB_Banking_ExecuteJobs(), as the job's
+             * status always describes better whether the job was actually
+             * transferred to and accepted by the bank.  See also
+             * http://lists.gnucash.org/pipermail/gnucash-de/2008-September/006389.html
+             */
+            job_status = AB_Job_GetStatus(job);
+            if (job_status != AB_Job_StatusFinished
+                    && job_status != AB_Job_StatusPending)
+            {
+                successful = FALSE;
+                if (!gnc_verify_dialog(
+                            parent, FALSE, "%s",
+                            _("An error occurred while executing the job. Please check "
+                              "the log window for the exact error message.\n"
+                              "\n"
+                              "Do you want to enter the job again?")))
+                {
+                    aborted = TRUE;
+                }
+            }
+            else
+            {
+                successful = TRUE;
+            }
+
+            if (successful)
+            {
+                /* Import the results, awaiting nothing */
+                ieci = gnc_ab_import_context(context, 0, FALSE, NULL, parent);
+            }
+        }
+        /* Simply ignore any other case */
+
+repeat:
+        /* Clean up */
+        if (gnc_trans && !successful)
+        {
+            xaccTransBeginEdit(gnc_trans);
+            xaccTransDestroy(gnc_trans);
+            xaccTransCommitEdit(gnc_trans);
+            gnc_trans = NULL;
+        }
+        if (ieci)
+            g_free(ieci);
+        if (context)
+            AB_ImExporterContext_free(context);
+        if (job_list)
+        {
+            AB_Job_List2_free(job_list);
+            job_list = NULL;
+        }
+        if (job)
+        {
+            AB_Job_free(job);
+            job = NULL;
+        }
+        if (gui)
+        {
+            gnc_GWEN_Gui_release(gui);
+            gui = NULL;
+        }
+
+    }
+    while (!successful && !aborted);
+
+cleanup:
+    if (td)
+        gnc_ab_trans_dialog_free(td);
+    if (online)
+#ifdef AQBANKING_VERSION_4_EXACTLY
+        AB_Banking_OnlineFini(api, 0);
+#else
+        AB_Banking_OnlineFini(api);
+#endif
+    gnc_AB_BANKING_fini(api);
+}

Copied: gnucash/trunk/src/import-export/aqb/gnc-ab-transfer.h (from rev 23566, gnucash/trunk/src/import-export/aqbanking/gnc-ab-transfer.h)
===================================================================
--- gnucash/trunk/src/import-export/aqb/gnc-ab-transfer.h	                        (rev 0)
+++ gnucash/trunk/src/import-export/aqb/gnc-ab-transfer.h	2013-12-15 17:21:20 UTC (rev 23567)
@@ -0,0 +1,58 @@
+/*
+ * gnc-ab-transfer.h --
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, contact:
+ *
+ * Free Software Foundation           Voice:  +1-617-542-5942
+ * 51 Franklin Street, Fifth Floor    Fax:    +1-617-542-2652
+ * Boston, MA  02110-1301,  USA       gnu at gnu.org
+ */
+
+/**
+ * @addtogroup Import_Export
+ * @{
+ * @addtogroup AqBanking
+ * @{
+ * @file gnc-ab-transfer.h
+ * @brief Dialog for AqBanking transaction data
+ * @author Copyright (C) 2002 Christian Stimming <stimming at tuhh.de>
+ * @author Copyright (C) 2008 Andreas Koehler <andi5.py at gmx.net>
+ */
+
+#ifndef GNC_AB_TRANSFER_H
+#define GNC_AB_TRANSFER_H
+
+#include <gtk/gtk.h>
+
+#include "Account.h"
+#include "dialog-ab-trans.h"
+
+G_BEGIN_DECLS
+
+/**
+ * FIXME
+ *
+ * @param parent Widget to use as parent, may be NULL
+ * @param gnc_acc GnuCash account to fetch balance for
+ * @param trans_type Type of transaction
+ */
+void gnc_ab_maketrans(GtkWidget *parent, Account *gnc_acc,
+                      GncABTransType trans_type);
+
+G_END_DECLS
+
+/** @} */
+/** @} */
+
+#endif /* GNC_AB_TRANSFER_H */

Copied: gnucash/trunk/src/import-export/aqb/gnc-ab-utils.c (from rev 23566, gnucash/trunk/src/import-export/aqbanking/gnc-ab-utils.c)
===================================================================
--- gnucash/trunk/src/import-export/aqb/gnc-ab-utils.c	                        (rev 0)
+++ gnucash/trunk/src/import-export/aqb/gnc-ab-utils.c	2013-12-15 17:21:20 UTC (rev 23567)
@@ -0,0 +1,1099 @@
+/*
+ * gnc-ab-utils.c --
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, contact:
+ *
+ * Free Software Foundation           Voice:  +1-617-542-5942
+ * 51 Franklin Street, Fifth Floor    Fax:    +1-617-542-2652
+ * Boston, MA  02110-1301,  USA       gnu at gnu.org
+ */
+
+/**
+ * @internal
+ * @file gnc-ab-utils.c
+ * @brief AqBanking utility functions
+ * @author Copyright (C) 2002 Christian Stimming <stimming at tuhh.de>
+ * @author Copyright (C) 2008 Andreas Koehler <andi5.py at gmx.net>
+ */
+
+#include "config.h"
+
+#include <glib/gi18n.h>
+#include <gwenhywfar/gwenhywfar.h>
+#include <aqbanking/banking.h>
+
+#include "window-reconcile.h"
+#include "Transaction.h"
+#include "dialog-ab-trans.h"
+#include "gnc-ab-kvp.h"
+#include "gnc-ab-utils.h"
+#include "gnc-glib-utils.h"
+#include "gnc-gwen-gui.h"
+#include "gnc-prefs.h"
+#include "gnc-ui.h"
+#include "import-account-matcher.h"
+#include "import-main-matcher.h"
+#include "import-utilities.h"
+#include "qof.h"
+#include "engine-helpers.h"
+
+#ifdef AQBANKING_VERSION_5_PLUS
+# include <aqbanking/abgui.h>
+#endif /* AQBANKING_VERSION_5_PLUS */
+
+/* This static indicates the debugging module that this .o belongs to.  */
+G_GNUC_UNUSED static QofLogModule log_module = G_LOG_DOMAIN;
+
+/* Global variables for AB_BANKING caching. */
+static AB_BANKING *gnc_AB_BANKING = NULL;
+static gint gnc_AB_BANKING_refcount = 0;
+
+static gpointer join_ab_strings_cb(const gchar *str, gpointer user_data);
+static Account *gnc_ab_accinfo_to_gnc_acc(
+    AB_IMEXPORTER_ACCOUNTINFO *account_info);
+static const AB_TRANSACTION *txn_transaction_cb(
+    const AB_TRANSACTION *element, gpointer user_data);
+static AB_IMEXPORTER_ACCOUNTINFO *txn_accountinfo_cb(
+    AB_IMEXPORTER_ACCOUNTINFO *element, gpointer user_data);
+static AB_IMEXPORTER_ACCOUNTINFO *bal_accountinfo_cb(
+    AB_IMEXPORTER_ACCOUNTINFO *element, gpointer user_data);
+
+struct _GncABImExContextImport
+{
+    guint awaiting;
+    gboolean txn_found;
+    Account *gnc_acc;
+    AB_ACCOUNT *ab_acc;
+    gboolean execute_txns;
+    AB_BANKING *api;
+    GtkWidget *parent;
+    AB_JOB_LIST2 *job_list;
+    GNCImportMainMatcher *generic_importer;
+    GData *tmp_job_list;
+};
+
+void
+gnc_GWEN_Init(void)
+{
+    gchar* gwen_logging = g_strdup(g_getenv("GWEN_LOGLEVEL"));
+    gchar* aqb_logging = g_strdup(g_getenv("AQBANKING_LOGLEVEL"));
+
+    /* Initialize gwen library */
+    GWEN_Init();
+
+    /* Initialize gwen logging */
+    if (gnc_prefs_get_bool(GNC_PREFS_GROUP_AQBANKING, GNC_PREF_VERBOSE_DEBUG))
+    {
+        if (!gwen_logging)
+        {
+            GWEN_Logger_SetLevel(NULL, GWEN_LoggerLevel_Info);
+            GWEN_Logger_SetLevel(GWEN_LOGDOMAIN, GWEN_LoggerLevel_Info);
+        }
+        if (!aqb_logging)
+            GWEN_Logger_SetLevel(AQBANKING_LOGDOMAIN, GWEN_LoggerLevel_Debug);
+    }
+    else
+    {
+        if (!gwen_logging)
+        {
+            GWEN_Logger_SetLevel(NULL, GWEN_LoggerLevel_Error);
+            GWEN_Logger_SetLevel(GWEN_LOGDOMAIN, GWEN_LoggerLevel_Error);
+        }
+        if (!aqb_logging)
+            GWEN_Logger_SetLevel(AQBANKING_LOGDOMAIN, GWEN_LoggerLevel_Warning);
+    }
+    g_free(gwen_logging);
+    g_free(aqb_logging);
+    gnc_GWEN_Gui_log_init();
+}
+
+void
+gnc_GWEN_Fini(void)
+{
+    /* Shutdown the GWEN_GUIs */
+    gnc_GWEN_Gui_shutdown();
+    GWEN_Logger_SetLevel(NULL, GWEN_LoggerLevel_Error);
+    GWEN_Logger_SetLevel(GWEN_LOGDOMAIN, GWEN_LoggerLevel_Warning);
+    GWEN_Logger_SetLevel(AQBANKING_LOGDOMAIN, GWEN_LoggerLevel_Warning);
+
+    /* Finalize gwen library */
+    GWEN_Fini();
+}
+
+static GWEN_GUI *gnc_gwengui_extended_by_ABBanking;
+
+AB_BANKING *
+gnc_AB_BANKING_new(void)
+{
+    AB_BANKING *api;
+
+    if (gnc_AB_BANKING)
+    {
+        /* API cached. */
+        api = gnc_AB_BANKING;
+
+        /* Init the API again. */
+        if (gnc_AB_BANKING_refcount == 0)
+            g_return_val_if_fail(AB_Banking_Init(api) == 0, NULL);
+
+    }
+    else
+    {
+        api = AB_Banking_new("gnucash", NULL, 0);
+        g_return_val_if_fail(api, NULL);
+
+#ifdef AQBANKING_VERSION_4_PLUS
+        /* Check for config migration */
+        if (AB_Banking_HasConf4(api
+# ifndef AQBANKING_VERSION_5_PLUS
+                                , 0
+# endif
+                               ) != 0)
+        {
+            if (AB_Banking_HasConf3(api
+# ifndef AQBANKING_VERSION_5_PLUS
+                                    , 0
+# endif
+                                   ) == 0)
+            {
+                g_message("gnc_AB_BANKING_new: importing aqbanking3 configuration\n");
+                if (AB_Banking_ImportConf3(api
+# ifndef AQBANKING_VERSION_5_PLUS
+                                           , 0
+# endif
+                                          ) < 0)
+                {
+                    g_message("gnc_AB_BANKING_new: unable to import aqbanking3 configuration\n");
+                }
+            }
+            else if (AB_Banking_HasConf2(api
+# ifndef AQBANKING_VERSION_5_PLUS
+                                         , 0
+# endif
+                                        ) == 0)
+            {
+                g_message("gnc_AB_BANKING_new: importing aqbanking2 configuration\n");
+                if (AB_Banking_ImportConf2(api
+# ifndef AQBANKING_VERSION_5_PLUS
+                                           , 0
+# endif
+                                          ) < 0)
+                {
+                    g_message("gnc_AB_BANKING_new: unable to import aqbanking2 configuration\n");
+                }
+            }
+        }
+#endif /* AQBANKING_VERSION_4_PLUS */
+
+        /* Init the API */
+        g_return_val_if_fail(AB_Banking_Init(api) == 0, NULL);
+
+#ifdef AQBANKING_VERSION_5_PLUS
+        gnc_gwengui_extended_by_ABBanking = GWEN_Gui_GetGui();
+        AB_Gui_Extend(gnc_gwengui_extended_by_ABBanking, api);
+#endif /* AQBANKING_VERSION_5_PLUS */
+
+        /* Cache it */
+        gnc_AB_BANKING = api;
+        gnc_AB_BANKING_refcount = 0;
+    }
+
+    gnc_AB_BANKING_refcount++;
+
+    return api;
+}
+
+void
+gnc_AB_BANKING_delete(AB_BANKING *api)
+{
+    if (!api)
+        api = gnc_AB_BANKING;
+
+    if (api)
+    {
+        if (api == gnc_AB_BANKING)
+        {
+            gnc_AB_BANKING = NULL;
+            gnc_AB_BANKING_fini(api);
+        }
+
+        AB_Banking_free(api);
+    }
+}
+
+
+gint
+gnc_AB_BANKING_fini(AB_BANKING *api)
+{
+    if (api == gnc_AB_BANKING)
+    {
+        if (--gnc_AB_BANKING_refcount == 0)
+        {
+#ifdef AQBANKING_VERSION_5_PLUS
+            if (gnc_gwengui_extended_by_ABBanking)
+                AB_Gui_Unextend(gnc_gwengui_extended_by_ABBanking);
+            gnc_gwengui_extended_by_ABBanking = NULL;
+#endif /* AQBANKING_VERSION_5_PLUS */
+            return AB_Banking_Fini(api);
+        }
+    }
+    else
+    {
+#ifdef AQBANKING_VERSION_5_PLUS
+        if (gnc_gwengui_extended_by_ABBanking)
+            AB_Gui_Unextend(gnc_gwengui_extended_by_ABBanking);
+        gnc_gwengui_extended_by_ABBanking = NULL;
+#endif /* AQBANKING_VERSION_5_PLUS */
+        return AB_Banking_Fini(api);
+    }
+    return 0;
+}
+
+AB_ACCOUNT *
+gnc_ab_get_ab_account(const AB_BANKING *api, Account *gnc_acc)
+{
+    AB_ACCOUNT *ab_account = NULL;
+    const gchar *bankcode = NULL;
+    const gchar *accountid = NULL;
+    guint32 account_uid = 0;
+
+    bankcode = gnc_ab_get_account_bankcode(gnc_acc);
+    accountid = gnc_ab_get_account_accountid(gnc_acc);
+    account_uid = gnc_ab_get_account_uid (gnc_acc);
+
+    if (account_uid > 0)
+    {
+        ab_account = AB_Banking_GetAccount(api, account_uid);
+
+        if (!ab_account && bankcode && *bankcode && accountid && *accountid)
+        {
+            g_message("gnc_ab_get_ab_account: No AB_ACCOUNT found for UID %d, "
+                      "trying bank code\n", account_uid);
+            ab_account = AB_Banking_GetAccountByCodeAndNumber(api, bankcode,
+                         accountid);
+        }
+        return ab_account;
+
+    }
+    else if (bankcode && *bankcode && accountid && *accountid)
+    {
+        ab_account = AB_Banking_GetAccountByCodeAndNumber(api, bankcode,
+                     accountid);
+        return ab_account;
+    }
+
+    return NULL;
+}
+
+gchar *
+gnc_AB_VALUE_to_readable_string(const AB_VALUE *value)
+{
+    if (value)
+        return g_strdup_printf("%.2f %s",
+                               AB_Value_GetValueAsDouble(value),
+                               AB_Value_GetCurrency(value));
+    else
+        return g_strdup_printf("%.2f", 0.0);
+}
+
+/**
+ * Take a string from a GWEN_STRINGLIST, strip invalid utf8 and join it
+ * to the rest.
+ */
+static gpointer
+join_ab_strings_cb(const gchar *str, gpointer user_data)
+{
+    gchar **acc = user_data;
+    gchar *tmp;
+
+    if (!str || !*str)
+        return NULL;
+
+    tmp = g_strdup(str);
+    g_strstrip(tmp);
+    gnc_utf8_strip_invalid(tmp);
+
+    if (*acc)
+    {
+        gchar *join = g_strjoin(" ", *acc, tmp, (gchar*) NULL);
+        g_free(*acc);
+        g_free(tmp);
+        *acc = join;
+    }
+    else
+    {
+        *acc = tmp;
+    }
+    return NULL;
+}
+
+gchar *
+gnc_ab_get_remote_name(const AB_TRANSACTION *ab_trans)
+{
+    const GWEN_STRINGLIST *ab_remote_name;
+    gchar *gnc_other_name = NULL;
+
+    g_return_val_if_fail(ab_trans, NULL);
+
+    ab_remote_name = AB_Transaction_GetRemoteName(ab_trans);
+    if (ab_remote_name)
+        GWEN_StringList_ForEach(ab_remote_name, join_ab_strings_cb,
+                                &gnc_other_name);
+
+    if (!gnc_other_name || !*gnc_other_name)
+    {
+        g_free(gnc_other_name);
+        gnc_other_name = NULL;
+    }
+
+    return gnc_other_name;
+}
+
+gchar *
+gnc_ab_get_purpose(const AB_TRANSACTION *ab_trans)
+{
+    const GWEN_STRINGLIST *ab_purpose;
+    gchar *gnc_description = NULL;
+
+    g_return_val_if_fail(ab_trans, g_strdup(""));
+
+    ab_purpose = AB_Transaction_GetPurpose(ab_trans);
+    if (ab_purpose)
+        GWEN_StringList_ForEach(ab_purpose, join_ab_strings_cb,
+                                &gnc_description);
+
+    if (!gnc_description)
+        gnc_description = g_strdup("");
+
+    return gnc_description;
+}
+
+gchar *
+gnc_ab_description_to_gnc(const AB_TRANSACTION *ab_trans)
+{
+    /* Description */
+    gchar *description = gnc_ab_get_purpose(ab_trans);
+    gchar *other_name = gnc_ab_get_remote_name(ab_trans);
+    gchar *retval;
+
+    if (other_name)
+    {
+        if (description && *description)
+        {
+            retval = g_strdup_printf("%s; %s", description, other_name);
+        }
+        else
+        {
+            retval = g_strdup(other_name);
+        }
+    }
+    else
+    {
+        if (description && *description)
+        {
+            retval = g_strdup(description);
+        }
+        else
+        {
+            retval = g_strdup(_("Unspecified"));
+        }
+    }
+    g_free(description);
+    g_free(other_name);
+
+    return retval;
+}
+
+gchar *
+gnc_ab_memo_to_gnc(const AB_TRANSACTION *ab_trans)
+{
+    const gchar *ab_remote_accountnumber =
+        AB_Transaction_GetRemoteAccountNumber(ab_trans);
+    const gchar *ab_remote_bankcode =
+        AB_Transaction_GetRemoteBankCode(ab_trans);
+
+    gchar *ab_other_accountid;
+    gchar *ab_other_bankcode;
+
+    gboolean have_accountid;
+    gboolean have_bankcode;
+
+    gchar *retval;
+
+    // For SEPA transactions, we need to ask for something different here
+    if (!ab_remote_accountnumber)
+        ab_remote_accountnumber = AB_Transaction_GetRemoteIban(ab_trans);
+    if (!ab_remote_bankcode)
+        ab_remote_bankcode = AB_Transaction_GetRemoteBic(ab_trans);
+
+    ab_other_accountid = g_strdup(ab_remote_accountnumber ? ab_remote_accountnumber : "");
+    ab_other_bankcode = g_strdup(ab_remote_bankcode ? ab_remote_bankcode : "");
+
+    /* Ensure string is in utf8 */
+    gnc_utf8_strip_invalid(ab_other_accountid);
+    gnc_utf8_strip_invalid(ab_other_bankcode);
+
+    /* and -then- trim it */
+    g_strstrip(ab_other_accountid);
+    g_strstrip(ab_other_bankcode);
+
+
+    have_accountid = ab_other_accountid && *ab_other_accountid;
+    have_bankcode = ab_other_bankcode && *ab_other_bankcode;
+
+    if ( have_accountid || have_bankcode )
+    {
+        retval = g_strdup_printf("%s %s %s %s",
+                                 have_accountid ? _("Account") : "",
+                                 have_accountid ? ab_other_accountid : "",
+                                 have_bankcode  ? _("Bank") : "",
+                                 have_bankcode  ? ab_other_bankcode : ""
+                                );
+        g_strstrip(retval);
+    }
+    else
+    {
+        retval = g_strdup("");
+    }
+
+    g_free(ab_other_accountid);
+    g_free(ab_other_bankcode);
+
+    return retval;
+}
+
+Transaction *
+gnc_ab_trans_to_gnc(const AB_TRANSACTION *ab_trans, Account *gnc_acc)
+{
+    QofBook *book;
+    Transaction *gnc_trans;
+    const gchar *fitid;
+    const GWEN_TIME *valuta_date;
+    time64 current_time;
+    const char *custref;
+    gchar *description;
+    Split *split;
+    gchar *memo;
+
+    g_return_val_if_fail(ab_trans && gnc_acc, NULL);
+
+    /* Create new GnuCash transaction for the given AqBanking one */
+    book = gnc_account_get_book(gnc_acc);
+    gnc_trans = xaccMallocTransaction(book);
+    xaccTransBeginEdit(gnc_trans);
+
+    /* Date / Time */
+    valuta_date = AB_Transaction_GetValutaDate(ab_trans);
+    if (!valuta_date)
+    {
+        const GWEN_TIME *normal_date = AB_Transaction_GetDate(ab_trans);
+        if (normal_date)
+            valuta_date = normal_date;
+    }
+    if (valuta_date)
+        xaccTransSetDatePostedSecsNormalized(gnc_trans, GWEN_Time_toTime_t(valuta_date));
+    else
+        g_warning("transaction_cb: Oops, date 'valuta_date' was NULL");
+
+    xaccTransSetDateEnteredSecs(gnc_trans, gnc_time_utc (NULL));
+
+    /* Currency.  We take simply the default currency of the gnucash account */
+    xaccTransSetCurrency(gnc_trans, xaccAccountGetCommodity(gnc_acc));
+
+    /* Trans-Num or Split-Action set with gnc_set_num_action below per book
+     * option */
+
+    /* Description */
+    description = gnc_ab_description_to_gnc(ab_trans);
+    xaccTransSetDescription(gnc_trans, description);
+    g_free(description);
+
+    /* Notes. */
+    /* xaccTransSetNotes(gnc_trans, g_notes); */
+    /* But Nobody ever uses the Notes field? */
+
+    /* Add one split */
+    split = xaccMallocSplit(book);
+    xaccSplitSetParent(split, gnc_trans);
+    xaccSplitSetAccount(split, gnc_acc);
+
+    /* Set the transaction number or split action field based on book option.
+     * We use the "customer reference", if there is one. */
+    custref = AB_Transaction_GetCustomerReference(ab_trans);
+    if (custref && *custref
+            && g_ascii_strncasecmp(custref, "NONREF", 6) != 0)
+        gnc_set_num_action (gnc_trans, split, custref, NULL);
+
+    /* Set OFX unique transaction ID */
+    fitid = AB_Transaction_GetFiId(ab_trans);
+    if (fitid && *fitid)
+        gnc_import_set_split_online_id(split, fitid);
+
+    {
+        /* Amount into the split */
+        const AB_VALUE *ab_value = AB_Transaction_GetValue(ab_trans);
+        double d_value = ab_value ? AB_Value_GetValueAsDouble (ab_value) : 0.0;
+        AB_TRANSACTION_TYPE ab_type = AB_Transaction_GetType (ab_trans);
+        gnc_numeric gnc_amount;
+
+        /*printf("Transaction with value %f has type %d\n", d_value, ab_type);*/
+        /* If the value is positive, but the transaction type says the
+           money is transferred away from our account (Transfer instead of
+           DebitNote), we switch the value to negative. */
+        if (d_value > 0.0 && ab_type == AB_Transaction_TypeTransfer)
+            d_value = -d_value;
+
+        gnc_amount = double_to_gnc_numeric(
+                         d_value,
+                         xaccAccountGetCommoditySCU(gnc_acc),
+                         GNC_HOW_RND_ROUND_HALF_UP);
+        if (!ab_value)
+            g_warning("transaction_cb: Oops, value was NULL.  Using 0");
+        xaccSplitSetBaseValue(split, gnc_amount, xaccAccountGetCommodity(gnc_acc));
+    }
+
+    /* Memo in the Split. */
+    memo = gnc_ab_memo_to_gnc(ab_trans);
+    xaccSplitSetMemo(split, memo);
+    g_free(memo);
+
+    return gnc_trans;
+}
+
+/**
+ * Call gnc_import_select_account() on the online id constructed using
+ * the information in @a acc_info.
+ *
+ * @param acc_info AB_IMEXPORTER_ACCOUNTINFO
+ * @return A GnuCash account, or NULL otherwise
+ */
+static Account *
+gnc_ab_accinfo_to_gnc_acc(AB_IMEXPORTER_ACCOUNTINFO *acc_info)
+{
+    const gchar *bankcode, *accountnumber;
+    gchar *online_id;
+    Account *gnc_acc;
+
+    g_return_val_if_fail(acc_info, NULL);
+
+    bankcode = AB_ImExporterAccountInfo_GetBankCode(acc_info);
+    accountnumber = AB_ImExporterAccountInfo_GetAccountNumber(acc_info);
+    online_id = g_strconcat(bankcode ? bankcode : "",
+                            accountnumber ? accountnumber : "",
+                            (gchar*)NULL);
+    gnc_acc = gnc_import_select_account(
+                  NULL, online_id, 1, AB_ImExporterAccountInfo_GetAccountName(acc_info),
+                  NULL, ACCT_TYPE_NONE, NULL, NULL);
+    if (!gnc_acc)
+    {
+        g_warning("gnc_ab_accinfo_to_gnc_acc: Could not determine source account"
+                  " for online_id %s", online_id);
+    }
+    g_free(online_id);
+
+    return gnc_acc;
+}
+
+static const AB_TRANSACTION *
+txn_transaction_cb(const AB_TRANSACTION *element, gpointer user_data)
+{
+    GncABImExContextImport *data = user_data;
+    Transaction *gnc_trans;
+    GncABTransType trans_type;
+
+    g_return_val_if_fail(element && data, NULL);
+
+    /* Create a GnuCash transaction from ab_trans */
+    gnc_trans = gnc_ab_trans_to_gnc(element, data->gnc_acc);
+
+    if (data->execute_txns && data->ab_acc)
+    {
+        AB_TRANSACTION *ab_trans = AB_Transaction_dup(element);
+        AB_JOB *job;
+
+        /* NEW: The imported transaction has been imported into gnucash.
+         * Now also add it as a job to aqbanking */
+        AB_Transaction_SetLocalBankCode(
+            ab_trans, AB_Account_GetBankCode(data->ab_acc));
+        AB_Transaction_SetLocalAccountNumber(
+            ab_trans, AB_Account_GetAccountNumber(data->ab_acc));
+        AB_Transaction_SetLocalCountry(ab_trans, "DE");
+
+
+        switch (AB_Transaction_GetType(ab_trans))
+        {
+        case AB_Transaction_TypeDebitNote:
+            trans_type = SINGLE_DEBITNOTE;
+            break;
+        case AB_Transaction_TypeEuTransfer:
+            trans_type = SEPA_TRANSFER;
+            break;
+        case AB_Transaction_TypeTransaction:
+            /* trans_type = SINGLE_INTERNAL_TRANSFER;
+             * break; */
+        case AB_Transaction_TypeTransfer:
+        default:
+            trans_type = SINGLE_TRANSFER;
+        } /* switch */
+
+        job = gnc_ab_get_trans_job(data->ab_acc, ab_trans, trans_type);
+
+        /* Check whether we really got a job */
+        if (!job || AB_Job_CheckAvailability(job
+#ifndef AQBANKING_VERSION_5_PLUS
+                                             , 0
+#endif
+                                            ))
+        {
+            /* Oops, no job, probably not supported by bank */
+            if (gnc_verify_dialog(
+                        NULL, FALSE, "%s",
+                        _("The backend found an error during the preparation "
+                          "of the job. It is not possible to execute this job. \n"
+                          "\n"
+                          "Most probably the bank does not support your chosen "
+                          "job or your Online Banking account does not have the permission "
+                          "to execute this job. More error messages might be "
+                          "visible on your console log.\n"
+                          "\n"
+                          "Do you want to enter the job again?")))
+            {
+                gnc_error_dialog(NULL, "Sorry, not implemented yet. Please check the console or trace file logs to see which job was rejected.");
+            }
+        }
+        else
+        {
+            gnc_gen_trans_list_add_trans_with_ref_id(data->generic_importer, gnc_trans, AB_Job_GetJobId(job));
+
+            /* AB_Job_List2_PushBack(data->job_list, job); -> delayed until trans is successfully imported */
+            g_datalist_set_data(&data->tmp_job_list, gnc_AB_JOB_to_readable_string(job), job);
+        }
+        AB_Transaction_free(ab_trans);
+    }
+    else
+    {
+        /* Instead of xaccTransCommitEdit(gnc_trans)  */
+        gnc_gen_trans_list_add_trans(data->generic_importer, gnc_trans);
+    }
+
+    return NULL;
+}
+
+static void gnc_ab_trans_processed_cb(GNCImportTransInfo *trans_info,
+                                      gboolean imported,
+                                      gpointer user_data)
+{
+    GncABImExContextImport *data = user_data;
+    gchar *jobname = gnc_AB_JOB_ID_to_string(gnc_import_TransInfo_get_ref_id(trans_info));
+    AB_JOB *job = g_datalist_get_data(&data->tmp_job_list, jobname);
+
+    if (imported)
+    {
+        AB_Job_List2_PushBack(data->job_list, job);
+    }
+    else
+    {
+        AB_Job_free(job);
+    }
+
+    g_datalist_remove_data(&data->tmp_job_list, jobname);
+}
+
+gchar *
+gnc_AB_JOB_to_readable_string(const AB_JOB *job)
+{
+    if (job)
+    {
+        return gnc_AB_JOB_ID_to_string(AB_Job_GetJobId(job));
+    }
+    else
+    {
+        return gnc_AB_JOB_ID_to_string(0);
+    }
+}
+gchar *
+gnc_AB_JOB_ID_to_string(gulong job_id)
+{
+    return g_strdup_printf("job_%lu", job_id);
+}
+
+
+
+static AB_IMEXPORTER_ACCOUNTINFO *
+txn_accountinfo_cb(AB_IMEXPORTER_ACCOUNTINFO *element, gpointer user_data)
+{
+    GncABImExContextImport *data = user_data;
+    Account *gnc_acc;
+
+    g_return_val_if_fail(element && data, NULL);
+
+    if (data->awaiting & IGNORE_TRANSACTIONS)
+        /* Ignore them */
+        return NULL;
+
+    if (!AB_ImExporterAccountInfo_GetFirstTransaction(element))
+        /* No transaction found */
+        return NULL;
+    else
+        data->awaiting |= FOUND_TRANSACTIONS;
+
+    if (!(data->awaiting & AWAIT_TRANSACTIONS))
+    {
+        if (gnc_verify_dialog(data->parent, TRUE, "%s",
+                              _("The bank has sent transaction information "
+                                "in its response."
+                                "\n"
+                                "Do you want to import it?")))
+        {
+            data->awaiting |= AWAIT_TRANSACTIONS;
+        }
+        else
+        {
+            data->awaiting |= IGNORE_TRANSACTIONS;
+            return NULL;
+        }
+    }
+
+    /* Lookup the corresponding gnucash account */
+    gnc_acc = gnc_ab_accinfo_to_gnc_acc(element);
+    if (!gnc_acc) return NULL;
+    data->gnc_acc = gnc_acc;
+
+    if (data->execute_txns)
+    {
+        /* Retrieve the aqbanking account that belongs to this gnucash
+         * account */
+        data->ab_acc = gnc_ab_get_ab_account(data->api, gnc_acc);
+        if (!data->ab_acc)
+        {
+            gnc_error_dialog(NULL, "%s",
+                             _("No Online Banking account found for this "
+                               "gnucash account. These transactions will "
+                               "not be executed by Online Banking."));
+        }
+    }
+    else
+    {
+        data->ab_acc = NULL;
+    }
+
+    if (!data->generic_importer)
+    {
+        data->generic_importer = gnc_gen_trans_list_new(data->parent, NULL,
+                                 TRUE, 14);
+        if (data->execute_txns)
+        {
+            gnc_gen_trans_list_add_tp_cb(data->generic_importer,
+                                         gnc_ab_trans_processed_cb, data);
+        }
+    }
+
+    /* Iterate through all transactions */
+    AB_ImExporterAccountInfo_TransactionsForEach(element, txn_transaction_cb,
+            data);
+
+    return NULL;
+}
+
+static AB_IMEXPORTER_ACCOUNTINFO *
+bal_accountinfo_cb(AB_IMEXPORTER_ACCOUNTINFO *element, gpointer user_data)
+{
+    GncABImExContextImport *data = user_data;
+    Account *gnc_acc;
+    AB_ACCOUNT_STATUS *item, *best = NULL;
+    const GWEN_TIME *best_time = NULL;
+    const AB_BALANCE *booked_bal, *noted_bal;
+    const AB_VALUE *booked_val = NULL, *noted_val = NULL;
+    gdouble booked_value, noted_value;
+    gnc_numeric value;
+    time64 booked_tt = 0;
+    GtkWidget *dialog;
+    gboolean show_recn_window = FALSE;
+
+    g_return_val_if_fail(element && data, NULL);
+
+    if (data->awaiting & IGNORE_BALANCES)
+        /* Ignore them */
+        return NULL;
+
+    if (!AB_ImExporterAccountInfo_GetFirstAccountStatus(element))
+        /* No balance found */
+        return NULL;
+    else
+        data->awaiting |= FOUND_BALANCES;
+
+    /* Lookup the most recent ACCOUNT_STATUS available */
+    item = AB_ImExporterAccountInfo_GetFirstAccountStatus(element);
+    while (item)
+    {
+        const GWEN_TIME *item_time = AB_AccountStatus_GetTime(item);
+        if (!best || GWEN_Time_Diff(best_time, item_time) < 0.0)
+        {
+            best = item;
+            best_time = item_time;
+        }
+        item = AB_ImExporterAccountInfo_GetNextAccountStatus(element);
+    }
+
+    booked_bal = AB_AccountStatus_GetBookedBalance(best);
+    if (!(data->awaiting & AWAIT_BALANCES))
+    {
+        /* Ignore zero balances if we don't await a balance */
+        if (!booked_bal || AB_Value_IsZero(AB_Balance_GetValue(booked_bal)))
+            return NULL;
+
+        /* Ask the user whether to import unawaited non-zero balance */
+        if (gnc_verify_dialog(data->parent, TRUE, "%s",
+                              _("The bank has sent balance information "
+                                "in its response."
+                                "\n"
+                                "Do you want to import it?")))
+        {
+            data->awaiting |= AWAIT_BALANCES;
+        }
+        else
+        {
+            data->awaiting |= IGNORE_BALANCES;
+            return NULL;
+        }
+    }
+
+    /* Lookup the corresponding gnucash account */
+    gnc_acc = gnc_ab_accinfo_to_gnc_acc(element);
+    if (!gnc_acc) return NULL;
+    data->gnc_acc = gnc_acc;
+
+    /* Lookup booked balance and time */
+    if (booked_bal)
+    {
+        const GWEN_TIME *ti = AB_Balance_GetTime(booked_bal);
+        if (ti)
+        {
+            booked_tt =  GWEN_Time_toTime_t(ti);
+        }
+        else
+        {
+            /* No time found? Use today because the HBCI query asked for today's
+             * balance. */
+            booked_tt = gnc_time64_get_day_start(gnc_time(NULL));
+        }
+        booked_val = AB_Balance_GetValue(booked_bal);
+        if (booked_val)
+        {
+            booked_value = AB_Value_GetValueAsDouble(booked_val);
+        }
+        else
+        {
+            g_warning("bal_accountinfo_cb: booked_val == NULL.  Assuming 0");
+            booked_value = 0.0;
+        }
+    }
+    else
+    {
+        g_warning("bal_accountinfo_cb: booked_bal == NULL.  Assuming 0");
+        booked_tt = 0;
+        booked_value = 0.0;
+    }
+
+    /* Lookup noted balance */
+    noted_bal = AB_AccountStatus_GetNotedBalance(best);
+    if (noted_bal)
+    {
+        noted_val = AB_Balance_GetValue(noted_bal);
+        if (noted_val)
+            noted_value = AB_Value_GetValueAsDouble(noted_val);
+        else
+        {
+            g_warning("bal_accountinfo_cb: noted_val == NULL.  Assuming 0");
+            noted_value = 0.0;
+        }
+    }
+    else
+    {
+        g_warning("bal_accountinfo_cb: noted_bal == NULL.  Assuming 0");
+        noted_value = 0.0;
+    }
+
+    value = double_to_gnc_numeric(booked_value,
+                                  xaccAccountGetCommoditySCU(gnc_acc),
+                                  GNC_HOW_RND_ROUND_HALF_UP);
+    if (noted_value == 0.0 && booked_value == 0.0)
+    {
+        dialog = gtk_message_dialog_new(
+                     GTK_WINDOW(data->parent),
+                     GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT,
+                     GTK_MESSAGE_INFO,
+                     GTK_BUTTONS_OK,
+                     "%s",
+                     /* Translators: Strings from this file are needed only in
+                      * countries that have one of aqbanking's Online Banking
+                      * techniques available. This is 'OFX DirectConnect'
+                      * (U.S. and others), 'HBCI' (in Germany), or 'YellowNet'
+                      * (Switzerland). If none of these techniques are available
+                      * in your country, you may safely ignore strings from the
+                      * import-export/hbci subdirectory. */
+                     _("The downloaded Online Banking Balance was zero.\n\n"
+                       "Either this is the correct balance, or your bank does not "
+                       "support Balance download in this Online Banking version. "
+                       "In the latter case you should choose a different "
+                       "Online Banking version number in the Online Banking "
+                       "(AqBanking or HBCI) Setup. After that, try again to "
+                       "download the Online Banking Balance."));
+        gtk_dialog_run(GTK_DIALOG(dialog));
+        gtk_widget_destroy(dialog);
+
+    }
+    else
+    {
+        gnc_numeric reconc_balance = xaccAccountGetReconciledBalance(gnc_acc);
+
+        gchar *booked_str = gnc_AB_VALUE_to_readable_string(booked_val);
+        gchar *message1 = g_strdup_printf(
+                              _("Result of Online Banking job: \n"
+                                "Account booked balance is %s"),
+                              booked_str);
+        gchar *message2 =
+            (noted_value == 0.0) ?
+            g_strdup("") :
+            g_strdup_printf(_("For your information: This account also "
+                              "has a noted balance of %s\n"),
+                            gnc_AB_VALUE_to_readable_string(noted_val));
+
+        if (gnc_numeric_equal(value, reconc_balance))
+        {
+            const gchar *message3 =
+                _("The booked balance is identical to the current "
+                  "reconciled balance of the account.");
+            dialog = gtk_message_dialog_new(
+                         GTK_WINDOW(data->parent),
+                         GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT,
+                         GTK_MESSAGE_INFO,
+                         GTK_BUTTONS_OK,
+                         "%s\n%s\n%s",
+                         message1, message2, message3);
+            gtk_dialog_run(GTK_DIALOG(dialog));
+            gtk_widget_destroy(GTK_WIDGET(dialog));
+
+        }
+        else
+        {
+            const char *message3 = _("Reconcile account now?");
+
+            show_recn_window = gnc_verify_dialog(data->parent, TRUE, "%s\n%s\n%s",
+                                                 message1, message2, message3);
+        }
+        g_free(booked_str);
+        g_free(message1);
+        g_free(message2);
+    }
+
+    /* Show reconciliation window */
+    if (show_recn_window)
+        recnWindowWithBalance(data->parent, gnc_acc, value, booked_tt);
+
+    return NULL;
+}
+
+GncABImExContextImport *
+gnc_ab_import_context(AB_IMEXPORTER_CONTEXT *context,
+                      guint awaiting, gboolean execute_txns,
+                      AB_BANKING *api, GtkWidget *parent)
+{
+    GncABImExContextImport *data = g_new(GncABImExContextImport, 1);
+
+    g_return_val_if_fail(context, NULL);
+    /* Do not await and ignore at the same time */
+    g_return_val_if_fail(!(awaiting & AWAIT_BALANCES)
+                         || !(awaiting & IGNORE_BALANCES),
+                         NULL);
+    g_return_val_if_fail(!(awaiting & AWAIT_TRANSACTIONS)
+                         || !(awaiting & IGNORE_TRANSACTIONS),
+                         NULL);
+    /* execute_txns must be FALSE if txns are not awaited */
+    g_return_val_if_fail(awaiting & AWAIT_TRANSACTIONS || !execute_txns, NULL);
+    /* An api is needed for the jobs */
+    g_return_val_if_fail(!execute_txns || api, NULL);
+
+    data->awaiting = awaiting;
+    data->txn_found = FALSE;
+    data->execute_txns = execute_txns;
+    data->api = api;
+    data->parent = parent;
+    data->job_list = AB_Job_List2_new();
+    data->tmp_job_list = NULL;
+    data->generic_importer = NULL;
+
+    g_datalist_init(&data->tmp_job_list);
+
+    /* Import transactions */
+    if (!(awaiting & IGNORE_TRANSACTIONS))
+        AB_ImExporterContext_AccountInfoForEach(context, txn_accountinfo_cb,
+                                                data);
+
+    /* Check balances */
+    if (!(awaiting & IGNORE_BALANCES))
+        AB_ImExporterContext_AccountInfoForEach(context, bal_accountinfo_cb,
+                                                data);
+
+    return data;
+}
+
+guint
+gnc_ab_ieci_get_found(GncABImExContextImport *ieci)
+{
+    g_return_val_if_fail(ieci, 0);
+
+    return ieci->awaiting;
+}
+
+AB_JOB_LIST2 *
+gnc_ab_ieci_get_job_list(GncABImExContextImport *ieci)
+{
+    g_return_val_if_fail(ieci, NULL);
+
+    return ieci->job_list;
+}
+
+gboolean
+gnc_ab_ieci_run_matcher(GncABImExContextImport *ieci)
+{
+    g_return_val_if_fail(ieci, FALSE);
+
+    return gnc_gen_trans_list_run(ieci->generic_importer);
+}
+
+GWEN_DB_NODE *
+gnc_ab_get_permanent_certs(void)
+{
+    int rv;
+    GWEN_DB_NODE *perm_certs = NULL;
+    AB_BANKING *banking = gnc_AB_BANKING_new();
+
+    g_return_val_if_fail(banking, NULL);
+#ifdef AQBANKING_VERSION_4_PLUS
+    rv = AB_Banking_LoadSharedConfig(banking, "certs", &perm_certs
+# ifndef AQBANKING_VERSION_5_PLUS
+                                     , 0
+# endif
+                                    );
+#else
+    /* FIXME: Add code for older AqBanking versions */
+    /* See QBankmanager 0.9.50 in src/kbanking/libs/kbanking.cpp lines 323ff
+       for a proper example of how to do this */
+    rv = 0;
+#endif
+    gnc_AB_BANKING_fini(banking);
+    g_return_val_if_fail(rv >= 0, NULL);
+    return perm_certs;
+}

Copied: gnucash/trunk/src/import-export/aqb/gnc-ab-utils.h (from rev 23566, gnucash/trunk/src/import-export/aqbanking/gnc-ab-utils.h)
===================================================================
--- gnucash/trunk/src/import-export/aqb/gnc-ab-utils.h	                        (rev 0)
+++ gnucash/trunk/src/import-export/aqb/gnc-ab-utils.h	2013-12-15 17:21:20 UTC (rev 23567)
@@ -0,0 +1,280 @@
+/*
+ * gnc-ab-utils.h --
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, contact:
+ *
+ * Free Software Foundation           Voice:  +1-617-542-5942
+ * 51 Franklin Street, Fifth Floor    Fax:    +1-617-542-2652
+ * Boston, MA  02110-1301,  USA       gnu at gnu.org
+ */
+
+/**
+ * @addtogroup Import_Export
+ * @{
+ * @addtogroup AqBanking
+ * @{
+ * @file gnc-ab-utils.h
+ * @brief AqBanking utility functions
+ * @author Copyright (C) 2002 Christian Stimming <stimming at tuhh.de>
+ * @author Copyright (C) 2008 Andreas Koehler <andi5.py at gmx.net>
+ */
+
+#ifndef GNC_AB_UTILS_H
+#define GNC_AB_UTILS_H
+
+#include <glib.h>
+#include <gtk/gtk.h>
+#include <aqbanking/banking.h>
+#include <gwenhywfar/version.h>
+
+#include "Account.h"
+
+G_BEGIN_DECLS
+
+/** A define that combines the aqbanking version number into one single
+ * integer number. Assumption: Both MINOR and PATCHLEVEL numbers are
+ * in the interval [0..99]. */
+#define AQBANKING_VERSION_INT (10000 * AQBANKING_VERSION_MAJOR + 100 * AQBANKING_VERSION_MINOR + AQBANKING_VERSION_PATCHLEVEL)
+
+/** A define that combines the gwenhywfar version number into one single
+ * integer number. Assumption: Both MINOR and PATCHLEVEL numbers are
+ * in the interval [0..99]. */
+#define GWENHYWFAR_VERSION_INT (10000 * GWENHYWFAR_VERSION_MAJOR + 100 * GWENHYWFAR_VERSION_MINOR + GWENHYWFAR_VERSION_PATCHLEVEL)
+
+#if AQBANKING_VERSION_INT >= 39900
+/** Defined if libaqbanking4 as opposed to libaqbanking3 or earlier is
+ * being used */
+# define AQBANKING_VERSION_4_PLUS
+#endif
+
+#if AQBANKING_VERSION_INT >= 49900
+/** Defined if libaqbanking5 as opposed to libaqbanking4 or earlier is
+ * being used */
+# define AQBANKING_VERSION_5_PLUS
+#endif
+
+#if defined(AQBANKING_VERSION_4_PLUS) && !defined(AQBANKING_VERSION_5_PLUS)
+/** Defined if libaqbanking4 is used and neither a newer nor an older
+ * version of libaqbanking. */
+# define AQBANKING_VERSION_4_EXACTLY
+#endif
+
+#define GNC_PREFS_GROUP_AQBANKING "dialogs.import.hbci"
+#define GNC_PREF_FORMAT_SWIFT940  "format-swift-mt940"
+#define GNC_PREF_FORMAT_SWIFT942  "format-swift-mt942"
+#define GNC_PREF_FORMAT_DTAUS     "format-dtaus"
+#define GNC_PREF_VERBOSE_DEBUG    "verbose-debug"
+
+typedef struct _GncABImExContextImport GncABImExContextImport;
+
+#define AWAIT_BALANCES      1 << 1
+#define FOUND_BALANCES      1 << 2
+#define IGNORE_BALANCES     1 << 3
+#define AWAIT_TRANSACTIONS  1 << 4
+#define FOUND_TRANSACTIONS  1 << 5
+#define IGNORE_TRANSACTIONS 1 << 6
+
+/**
+ * Initialize the gwenhywfar library by calling GWEN_Init() and setting up
+ * gwenhywfar logging.
+ */
+void gnc_GWEN_Init(void);
+
+/**
+ * Finalize the gwenhywfar library.
+ */
+void gnc_GWEN_Fini(void);
+
+/**
+ * If there is a cached AB_BANKING object, return it initialized.  Otherwise,
+ * create a new AB_BANKING, let it load its environment from its default
+ * configuration and cache it.
+ *
+ * @return The AB_BANKING object
+ */
+AB_BANKING *gnc_AB_BANKING_new(void);
+
+/**
+ * Delete the AB_BANKING @a api.  If this is also the one that was cached by
+ * gnc_AB_BANKING_new(), then all references are deleted, too.
+ *
+ * @param api AB_BANKING or NULL for the cached AB_BANKING object
+ */
+void gnc_AB_BANKING_delete(AB_BANKING *api);
+
+/**
+ * Finish the AB_BANKING @a api.  If this is also the one that was cached by
+ * gnc_AB_BANKING_new(), then finish only if the decremented reference count
+ * reaches zero.  After this call, you may only call gnc_AB_BANKING_new() to get
+ * the api again in a properly initialized state.
+ *
+ * @param api AB_BANKING object
+ * @return Zero on success
+ */
+gint gnc_AB_BANKING_fini(AB_BANKING *api);
+
+/**
+ * Get the corresponding AqBanking account to the GnuCash account @a gnc_acc.
+ * Of course this only works after the GnuCash account has been set up for
+ * AqBanking use, i.e. the kvp_frame "hbci/..." has been filled with
+ * information.
+ *
+ * @param api The AB_BANKING to get the AB_ACCOUNT from
+ * @param gnc_acc The GnuCash account to query for AB_ACCOUNT reference data
+ * @return The AB_ACCOUNT found or NULL otherwise
+ */
+AB_ACCOUNT *gnc_ab_get_ab_account(const AB_BANKING *api, Account *gnc_acc);
+
+/**
+ * Print the value of @a value with two decimal places and @a value's
+ * currency appended, or 0.0 otherwise
+ *
+ * @param value AB_VALUE or NULL
+ * @return A newly allocated string
+ */
+gchar *gnc_AB_VALUE_to_readable_string(const AB_VALUE *value);
+
+/**
+ * Return the job as string.
+ *
+ * @param value AB_JOB or NULL
+ * @return A newly allocated string
+ */
+gchar *gnc_AB_JOB_to_readable_string(const AB_JOB *job);
+
+/**
+ * Return the job_id as string.
+ *
+ * @param job_id
+ * @return A newly allocated string
+ */
+gchar *gnc_AB_JOB_ID_to_string(gulong job_id);
+
+/**
+ * Retrieve the merged "remote name" fields from a transaction.  The returned
+ * string must be g_free'd by the caller.  If there was no "remote name" field,
+ * NULL (!) is returned.
+ *
+ * @param ab_trans AqBanking transaction
+ * @return A newly allocated string or NULL otherwise
+ */
+gchar *gnc_ab_get_remote_name(const AB_TRANSACTION *ab_trans);
+
+/**
+ * Retrieve the merged purpose fields from a transaction.  The returned string
+ * must be g_free'd by the caller.  If there was no purpose, an empty (but
+ * allocated) string is returned.
+ *
+ * @param ab_trans AqBanking transaction
+ * @return A newly allocated string, may be ""
+ */
+gchar *gnc_ab_get_purpose(const AB_TRANSACTION *ab_trans);
+
+/**
+ * Create the appropriate description field for a GnuCash Transaction by the
+ * information given in the AB_TRANSACTION @a ab_trans.  The returned string
+ * must be g_free'd by the caller.
+ *
+ * @param ab_trans AqBanking transaction
+ * @return A newly allocated string, may be ""
+ */
+gchar *gnc_ab_description_to_gnc(const AB_TRANSACTION *ab_trans);
+
+/**
+ * Create the appropriate memo field for a GnuCash Split by the information
+ * given in the AB_TRANSACTION @a ab_trans.  The returned string must be
+ * g_free'd by the caller.
+ *
+ * @param ab_trans AqBanking transaction
+ * @return A newly allocated string, may be ""
+ */
+gchar *gnc_ab_memo_to_gnc(const AB_TRANSACTION *ab_trans);
+
+/**
+ * Create an unbalanced and dirty GnuCash transaction with a split to @a gnc_acc
+ * from the information available in the AqBanking transaction @a ab_trans.
+ *
+ * @param ab_trans AqBanking transaction
+ * @param gnc_acc Account of to use for the split
+ * @return A dirty GnuCash transaction or NULL otherwise
+ */
+Transaction *gnc_ab_trans_to_gnc(const AB_TRANSACTION *ab_trans, Account *gnc_acc);
+
+/**
+ * Import balances and transactions found in a AB_IMEXPORTER_CONTEXT into
+ * GnuCash.  By using @a awaiting the caller can specify what the user will
+ * expect to receive.  By using @a execute_txns, transactions in @a context can
+ * be used to generate corresponding AqBanking jobs, e.g. after a file import.
+ *
+ * @param context AB_IMEXPORTER_CONTEXT to import
+ *
+ * @param awaiting Information the caller expects to receive or wants to ignore,
+ * bitmask of AWAIT_* or IGNORE_* values
+ *
+ * @param execute_txns If @a awaiting contains AWAIT_TRANSACTIONS, whether to
+ * create an aqbanking job for each of the transactions found
+ *
+ * @param api If @a execute_txns is TRUE, the AB_BANKING to get
+ * AB_ACCOUNTs from
+ *
+ * @param parent Widget to set new dialogs transient for, may be NULL
+ *
+ * @return A new GncABImExContextImport object which must be freed with
+ * g_free(), or NULL otherwise.  If execute_txns is TRUE, additionally
+ * gnc_ab_ieci_get_job_list() must be called and the result freed with
+ * AB_Job_List2_FreeAll()
+ */
+GncABImExContextImport *gnc_ab_import_context(
+    AB_IMEXPORTER_CONTEXT *context, guint awaiting, gboolean execute_txns,
+    AB_BANKING *api, GtkWidget *parent);
+
+/**
+ * Extract awaiting from @a data.
+ *
+ * @param ieci The return value of gnc_ab_import_context()
+ * @return The initial awaiting bitmask plus IGNORE_* for unexpected and then
+ * ignored items, and FOUND_* for non-empty items
+ */
+guint gnc_ab_ieci_get_found(GncABImExContextImport *ieci);
+
+/**
+ * Extract the job list from @a data.
+ *
+ * @param ieci The return value of gnc_ab_import_context()
+ * @return The list of jobs, freeable with AB_Job_List2_FreeAll()
+ */
+AB_JOB_LIST2 *gnc_ab_ieci_get_job_list(GncABImExContextImport *ieci);
+
+/**
+ * Run the generic transaction matcher dialog.
+ *
+ * @param ieci The return value of gnc_ab_import_context()
+ * @return The return value of gnc_gen_trans_list_run().
+ */
+gboolean gnc_ab_ieci_run_matcher(GncABImExContextImport *ieci);
+
+
+/**
+ * get the GWEN_DB_NODE from AqBanking configuration files
+ *
+ * @return a GWEN_DB containing all permanently accepted SSL certificates (hashed).
+ */
+GWEN_DB_NODE *gnc_ab_get_permanent_certs(void);
+
+G_END_DECLS
+
+/** @} */
+/** @} */
+
+#endif /* GNC_AB_UTILS_H */

Copied: gnucash/trunk/src/import-export/aqb/gnc-file-aqb-import.c (from rev 23566, gnucash/trunk/src/import-export/aqbanking/gnc-file-aqb-import.c)
===================================================================
--- gnucash/trunk/src/import-export/aqb/gnc-file-aqb-import.c	                        (rev 0)
+++ gnucash/trunk/src/import-export/aqb/gnc-file-aqb-import.c	2013-12-15 17:21:20 UTC (rev 23567)
@@ -0,0 +1,380 @@
+/*
+ * gnc-file-aqb-import.c --
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, contact:
+ *
+ * Free Software Foundation           Voice:  +1-617-542-5942
+ * 51 Franklin Street, Fifth Floor    Fax:    +1-617-542-2652
+ * Boston, MA  02110-1301,  USA       gnu at gnu.org
+ */
+
+/**
+ * @internal
+ * @file gnc-file-aqb-import.c
+ * @brief DTAUS import module code
+ * @author Copyright (C) 2002 Benoit Grégoire <bock at step.polymtl.ca>
+ * @author Copyright (C) 2003 Jan-Pascal van Best <janpascal at vanbest.org>
+ * @author Copyright (C) 2006 Florian Steinel
+ * @author Copyright (C) 2006 Christian Stimming
+ * @author Copyright (C) 2008 Andreas Koehler <andi5.py at gmx.net>
+ */
+
+#include "config.h"
+
+#include <glib/gi18n.h>
+#include <glib/gstdio.h>
+#include <fcntl.h>
+#include <unistd.h>
+
+#include "gnc-ab-utils.h"
+
+#ifdef AQBANKING_VERSION_5_PLUS
+# include <gwenhywfar/syncio_file.h>
+# include <gwenhywfar/syncio_buffered.h>
+typedef GWEN_SYNCIO GWEN_IO_LAYER;
+#else
+# include <gwenhywfar/io_file.h>
+# include <gwenhywfar/io_buffered.h>
+# include <gwenhywfar/iomanager.h>
+#endif
+
+#include "dialog-ab-trans.h"
+#include "dialog-utils.h"
+#include "gnc-file.h"
+#include "gnc-file-aqb-import.h"
+#include "gnc-gwen-gui.h"
+#include "gnc-ui.h"
+#include "gnc-ui-util.h"
+#include "import-account-matcher.h"
+#include "import-main-matcher.h"
+
+/* This static indicates the debugging module that this .o belongs to.  */
+static QofLogModule log_module = GNC_MOD_IMPORT;
+
+void
+gnc_file_aqbanking_import(const gchar *aqbanking_importername,
+                          const gchar *aqbanking_profilename,
+                          gboolean execute_transactions)
+{
+    gchar *default_dir;
+    gchar *selected_filename = NULL;
+    gint dtaus_fd = -1;
+    AB_BANKING *api = NULL;
+    gboolean online = FALSE;
+    GncGWENGui *gui = NULL;
+    AB_IMEXPORTER *importer;
+    GWEN_DB_NODE *db_profiles = NULL;
+    GWEN_DB_NODE *db_profile;
+    AB_IMEXPORTER_CONTEXT *context = NULL;
+    GWEN_IO_LAYER *io = NULL;
+    GncABImExContextImport *ieci = NULL;
+    AB_JOB_LIST2 *job_list = NULL;
+    AB_JOB_LIST2_ITERATOR *jit;
+    AB_JOB *job;
+    AB_JOB_STATUS job_status;
+    gboolean successful = TRUE;
+    int num_jobs = 0;
+    int num_jobs_failed = 0;
+    int max_failures = 5;
+    GString *errstr = NULL;
+
+    /* Select a file */
+    default_dir = gnc_get_default_directory(GNC_PREFS_GROUP_AQBANKING);
+    selected_filename = gnc_file_dialog(_("Select a file to import"),
+                                        NULL, default_dir,
+                                        GNC_FILE_DIALOG_IMPORT);
+    g_free(default_dir);
+
+    if (!selected_filename)
+        goto cleanup;
+    DEBUG("filename: %s", selected_filename);
+
+    /* Remember the directory as the default */
+    default_dir = g_path_get_dirname(selected_filename);
+    gnc_set_default_directory(GNC_PREFS_GROUP_AQBANKING, default_dir);
+    g_free(default_dir);
+
+    dtaus_fd = g_open(selected_filename, O_RDONLY, 0);
+    if (dtaus_fd == -1)
+    {
+        DEBUG("Could not open file %s", selected_filename);
+        goto cleanup;
+    }
+
+    /* Get the API */
+    api = gnc_AB_BANKING_new();
+    if (!api)
+    {
+        g_warning("gnc_file_aqbanking_import: Couldn't get AqBanking API");
+        goto cleanup;
+    }
+    if (AB_Banking_OnlineInit(api
+#ifdef AQBANKING_VERSION_4_EXACTLY
+                              , 0
+#endif
+                             ) != 0)
+    {
+        g_warning("gnc_file_aqbanking_import: "
+                  "Couldn't initialize AqBanking API");
+        goto cleanup;
+    }
+    online = TRUE;
+
+    /* Get import module */
+    importer = AB_Banking_GetImExporter(api, aqbanking_importername);
+    if (!importer)
+    {
+        g_warning("Import module %s not found", aqbanking_importername);
+        gnc_error_dialog(NULL, "%s",
+                         _("Import module for DTAUS import not found."));
+        goto cleanup;
+    }
+
+    /* Load the import profile */
+    db_profiles = AB_Banking_GetImExporterProfiles(api, aqbanking_importername);
+
+    /* Select profile */
+    db_profile = GWEN_DB_GetFirstGroup(db_profiles);
+    while (db_profile)
+    {
+        const gchar *name;
+
+        name = GWEN_DB_GetCharValue(db_profile, "name", 0, 0);
+        g_return_if_fail(name);
+        if (g_ascii_strcasecmp(name, aqbanking_profilename) == 0)
+            break;
+        db_profile = GWEN_DB_GetNextGroup(db_profile);
+    }
+    if (!db_profile)
+    {
+        g_warning("Profile \"%s\" for importer \"%s\" not found",
+                  aqbanking_profilename, aqbanking_importername);
+        /* For debugging: Print those available names that have been found */
+        db_profile = GWEN_DB_GetFirstGroup(db_profiles);
+        while (db_profile)
+        {
+            const char *name = GWEN_DB_GetCharValue(db_profile, "name", 0, 0);
+            g_warning("Only found profile \"%s\"\n", name ? name : "(null)");
+            db_profile = GWEN_DB_GetNextGroup(db_profile);
+        }
+        goto cleanup;
+    }
+
+    /* Create a context to store the results */
+    context = AB_ImExporterContext_new();
+
+    /* Wrap file in buffered gwen io */
+#ifdef AQBANKING_VERSION_5_PLUS
+    close(dtaus_fd);
+    io = GWEN_SyncIo_File_new(selected_filename, GWEN_SyncIo_File_CreationMode_OpenExisting);
+    g_assert(io);
+    GWEN_SyncIo_AddFlags(io, GWEN_SYNCIO_FILE_FLAGS_READ);
+    {
+        /* We must explicitly call "Connect" on the GWEN_SYNCIO
+         * object. */
+        int rv = GWEN_SyncIo_Connect(io);
+        if (rv < 0)
+        {
+            g_warning("gnc_file_aqbanking_import: Failed to open file %s: %d", selected_filename, rv);
+            goto cleanup;
+        }
+        g_assert(GWEN_SyncIo_GetStatus(io) == GWEN_SyncIo_Status_Connected);
+    }
+#else
+    io = GWEN_Io_LayerFile_new(dtaus_fd, -1);
+    g_assert(io);
+    if (GWEN_Io_Manager_RegisterLayer(io))
+    {
+        g_warning("gnc_file_aqbanking_import: Failed to wrap file");
+        goto cleanup;
+    }
+#endif
+    dtaus_fd = -1;
+
+    /* Run the import */
+    if (AB_ImExporter_Import(importer, context, io, db_profile
+#ifndef AQBANKING_VERSION_5_PLUS
+                             , 0
+#endif
+                            ))
+    {
+        g_warning("gnc_file_aqbanking_import: Error on import");
+        goto cleanup;
+    }
+
+    /* Close the file */
+#ifdef AQBANKING_VERSION_5_PLUS
+    GWEN_SyncIo_free(io);
+#else
+    GWEN_Io_Layer_free(io);
+#endif
+    io = NULL;
+
+    /* Before importing the results, if this is a new book, let user specify
+     * book options, since they affect how transactions are created */
+    if (gnc_is_new_book())
+        gnc_new_book_option_display();
+
+    /* Import the results */
+    ieci = gnc_ab_import_context(context, AWAIT_TRANSACTIONS,
+                                 execute_transactions,
+                                 execute_transactions ? api : NULL,
+                                 NULL);
+
+    if (execute_transactions)
+    {
+        if (gnc_ab_ieci_run_matcher(ieci))
+        {
+            AB_IMEXPORTER_CONTEXT *execution_context;
+
+            /* Extract the list of jobs */
+            job_list = gnc_ab_ieci_get_job_list(ieci);
+
+            /* Create a context to store possible results */
+            execution_context = AB_ImExporterContext_new();
+
+            /* Get a GUI object */
+            gui = gnc_GWEN_Gui_get(NULL);
+            if (!gui)
+            {
+                g_warning("gnc_file_aqbanking_import: Couldn't initialize Gwenhywfar GUI");
+                goto cleanup;
+            }
+
+            /* And execute the jobs */
+            AB_Banking_ExecuteJobs(api, job_list, execution_context
+#ifndef AQBANKING_VERSION_5_PLUS
+                                   , 0
+#endif
+                                  );
+
+            /* Ignore the return value of AB_Banking_ExecuteJobs(), as the job's
+             * status always describes better whether the job was actually
+             * transferred to and accepted by the bank.  See also
+             * http://lists.gnucash.org/pipermail/gnucash-de/2008-September/006389.html
+             */
+
+            /* So we must go through all jobs and check AB_Job_GetStatus(job)
+             * to give the appropriate feedback if any of the jobs didn't
+             * work. */
+
+            jit = AB_Job_List2_First(job_list);
+            if (jit)
+            {
+
+                job = AB_Job_List2Iterator_Data(jit);
+                while (job)
+                {
+                    num_jobs += 1;
+                    job_status = AB_Job_GetStatus(job);
+                    if (job_status != AB_Job_StatusFinished
+                            && job_status != AB_Job_StatusPending)
+                    {
+                        successful = FALSE;
+                        num_jobs_failed += 1;
+
+                        if (num_jobs_failed <= max_failures)
+                        {
+                            if (num_jobs_failed == 1)
+                            {
+                                errstr = g_string_new("Failed jobs:\n");
+                            }
+                            g_string_append_printf(errstr, _("Job %d status %d - %s: %s \n")
+                                                   , num_jobs
+                                                   , job_status
+                                                   , AB_Job_Status2Char(job_status)
+                                                   , AB_Job_GetResultText(job));
+                        }
+                        else
+                        {
+                            if (num_jobs_failed == (max_failures + 1) )
+                            {
+                                /* indicate that additional failures exist */
+                                g_string_append(errstr, _("...\n"));
+                            }
+                        }
+                    }
+                    job = AB_Job_List2Iterator_Next(jit);
+                } /* while */
+
+                AB_Job_List2Iterator_free(jit);
+            }
+
+            if (!successful)
+            {
+                g_warning("%s", errstr->str);
+                gnc_error_dialog(NULL,
+                                 _("An error occurred while executing jobs: %d of %d failed. "
+                                   "Please check the log window or gnucash.trace for the exact "
+                                   "error message.\n\n%s")
+                                 , num_jobs_failed, num_jobs, errstr->str);
+            }
+            else
+            {
+                if (num_jobs == 0)
+                {
+                    gnc_info_dialog(NULL,
+                                    _("No jobs to be send.")
+                                   );
+                }
+                else
+                {
+                    gnc_info_dialog(NULL, ngettext
+                                    ("The job was executed successfully, but as a precaution "
+                                     "please check the log window for potential errors.",
+                                     "All %d jobs were executed successfully, but as a precaution "
+                                     "please check the log window for potential errors.",
+                                     num_jobs), num_jobs);
+                }
+            }
+            AB_ImExporterContext_free(execution_context);
+        }
+    }
+
+cleanup:
+    if (io)
+    {
+#ifdef AQBANKING_VERSION_5_PLUS
+        GWEN_SyncIo_free(io);
+#else
+        GWEN_Io_Layer_free(io);
+#endif
+    }
+
+    if (job_list)
+        AB_Job_List2_FreeAll(job_list);
+    if (ieci)
+        g_free(ieci);
+    if (context)
+        AB_ImExporterContext_free(context);
+    if (db_profiles)
+        GWEN_DB_Group_free(db_profiles);
+    if (gui)
+        gnc_GWEN_Gui_release(gui);
+    if (online)
+#ifdef AQBANKING_VERSION_4_EXACTLY
+        AB_Banking_OnlineFini(api, 0);
+#else
+        AB_Banking_OnlineFini(api);
+#endif
+    if (api)
+        gnc_AB_BANKING_fini(api);
+    if (dtaus_fd != -1)
+        close(dtaus_fd);
+    if (selected_filename)
+        g_free(selected_filename);
+    if (errstr)
+        g_string_free(errstr, TRUE);
+
+}

Copied: gnucash/trunk/src/import-export/aqb/gnc-file-aqb-import.h (from rev 23566, gnucash/trunk/src/import-export/aqbanking/gnc-file-aqb-import.h)
===================================================================
--- gnucash/trunk/src/import-export/aqb/gnc-file-aqb-import.h	                        (rev 0)
+++ gnucash/trunk/src/import-export/aqb/gnc-file-aqb-import.h	2013-12-15 17:21:20 UTC (rev 23567)
@@ -0,0 +1,69 @@
+/*
+ * gnc-file-aqb-import.h --
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, contact:
+ *
+ * Free Software Foundation           Voice:  +1-617-542-5942
+ * 51 Franklin Street, Fifth Floor    Fax:    +1-617-542-2652
+ * Boston, MA  02110-1301,  USA       gnu at gnu.org
+ */
+
+/**
+ * @addtogroup Import_Export
+ * @{
+ * @addtogroup AqBanking
+ * @{
+ * @file aqbanking/gnc-file-aqb-import.h
+ * @brief DTAUS import module interface
+ * @author Copyright (C) 2002 Benoit Grégoire <bock at step.polymtl.ca>
+ * @author Copyright (C) 2008 Andreas Koehler <andi5.py at gmx.net>
+ */
+
+#ifndef GNC_FILE_AQB_IMPORT_H
+#define GNC_FILE_AQB_IMPORT_H
+
+#include <glib.h>
+
+G_BEGIN_DECLS
+
+/**
+ * This routine will pop up a standard file selection dialog asking the user to
+ * pick a file to import.  This file will be opened and read.  Its contents will
+ * be imported into the current book, using the import matcher from
+ * import-main-matcher.h.
+ *
+ * @param aqbanking_importername The aqbanking importer module that should be
+ * used.  Possible values: "dtaus", "csv", "swift", or more.
+ *
+ * @param aqbanking_formatname In aqbanking, each importer has one or more data
+ * formats available which define the actual data fields that should be used.
+ * In aqbanking, such a different format is called a "profile".  Possible values
+ * for swift: "swift-mt940" or "swift-mt942", but for all others: "default", or
+ * more precisely: Look into $datadir/aqbanking/imexporters and look into the
+ * "name" field of the foo.conf files.
+ *
+ * @param exec_as_aqbanking_jobs If TRUE, additionally queue the imported
+ * transactions as online jobs over aqbanking/HBCI.  If FALSE, just import the
+ * transactions and that's it.
+ */
+void gnc_file_aqbanking_import (const gchar *aqbanking_importername,
+                                const gchar *aqbanking_formatname,
+                                gboolean exec_as_aqbanking_jobs);
+
+G_END_DECLS
+
+/** @} */
+/** @} */
+
+#endif /* GNC_FILE_AQB_IMPORT_H */

Copied: gnucash/trunk/src/import-export/aqb/gnc-gwen-gui.c (from rev 23566, gnucash/trunk/src/import-export/aqbanking/gnc-gwen-gui.c)
===================================================================
--- gnucash/trunk/src/import-export/aqb/gnc-gwen-gui.c	                        (rev 0)
+++ gnucash/trunk/src/import-export/aqb/gnc-gwen-gui.c	2013-12-15 17:21:20 UTC (rev 23567)
@@ -0,0 +1,1624 @@
+/*
+ * gnc-gwen-gui.c --
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, contact:
+ *
+ * Free Software Foundation           Voice:  +1-617-542-5942
+ * 51 Franklin Street, Fifth Floor    Fax:    +1-617-542-2652
+ * Boston, MA  02110-1301,  USA       gnu at gnu.org
+ */
+
+/**
+ * @internal
+ * @file gnc-gwen-gui.c
+ * @brief GUI callbacks for AqBanking
+ * @author Copyright (C) 2002 Christian Stimming <stimming at tuhh.de>
+ * @author Copyright (C) 2006 David Hampton <hampton at employees.org>
+ * @author Copyright (C) 2008 Andreas Koehler <andi5.py at gmx.net>
+ */
+
+#include "config.h"
+
+#include <ctype.h>
+#include <glib/gi18n.h>
+#include <gwenhywfar/gui_be.h>
+#include <gwenhywfar/inherit.h>
+
+#include "dialog-utils.h"
+#include "gnc-ab-utils.h"
+#include "gnc-component-manager.h"
+#include "gnc-gwen-gui.h"
+#include "gnc-session.h"
+#include "gnc-prefs.h"
+#include "gnc-ui.h"
+#include "gnc-plugin-aqbanking.h"
+#include "md5.h"
+#include "qof.h"
+
+#if GWENHYWFAR_VERSION_INT >= 39921
+/* For sufficiently new gwenhywfar (>=3.99.21) the gtk2 gui object is
+ * working fine and it is enabled here here. */
+# define USING_GWENHYWFAR_GTK2_GUI
+# define GNC_GWENHYWFAR_CB GWENHYWFAR_CB
+#else
+# define GNC_GWENHYWFAR_CB
+#endif
+
+#define GWEN_GUI_CM_CLASS "dialog-hbcilog"
+#define GNC_PREFS_GROUP_CONNECTION GNC_PREFS_GROUP_AQBANKING ".connection-dialog"
+#define GNC_PREF_CLOSE_ON_FINISH   "close-on-finish"
+#define GNC_PREF_REMEMBER_PIN      "remember-pin"
+
+#ifdef USING_GWENHYWFAR_GTK2_GUI
+# include <gwen-gui-gtk2/gtk2_gui.h>
+#endif
+
+/* This static indicates the debugging module that this .o belongs to.  */
+static QofLogModule log_module = G_LOG_DOMAIN;
+
+/* The following block can be enabled, but the gwen-gtk2 widgets might
+ * still need some work. */
+#if 0 /*#ifdef USING_GWENHYWFAR_GTK2_GUI*/
+
+/* A GWEN_GUI implementation using gtk2 widgets  */
+static GWEN_GUI *gwen_gui = NULL;
+
+void gnc_GWEN_Gui_log_init(void)
+{
+    if (!gwen_gui)
+    {
+        gwen_gui = Gtk2_Gui_new();
+        GWEN_Gui_SetGui(gwen_gui);
+    }
+}
+GncGWENGui *gnc_GWEN_Gui_get(GtkWidget *parent)
+{
+    if (!gwen_gui)
+        gnc_GWEN_Gui_log_init();
+    return (GncGWENGui*) gwen_gui;
+}
+void gnc_GWEN_Gui_release(GncGWENGui *gui)
+{
+}
+void gnc_GWEN_Gui_shutdown(void)
+{
+    if (gwen_gui)
+    {
+        GWEN_Gui_free(gwen_gui);
+        gwen_gui = NULL;
+        GWEN_Gui_SetGui(NULL);
+    }
+}
+void
+gnc_GWEN_Gui_set_close_flag(gboolean close_when_finished)
+{
+    gnc_prefs_set_bool(
+        GNC_PREFS_GROUP_AQBANKING, GNC_PREF_CLOSE_ON_FINISH,
+        close_when_finished);
+}
+gboolean
+gnc_GWEN_Gui_get_close_flag()
+{
+    return gnc_prefs_get_bool (GNC_PREFS_GROUP_AQBANKING, GNC_PREF_CLOSE_ON_FINISH);
+}
+
+gboolean
+gnc_GWEN_Gui_show_dialog()
+{
+    return TRUE;
+}
+
+void
+gnc_GWEN_Gui_hide_dialog()
+{
+}
+
+#else
+
+/* A unique full-blown GUI, featuring  */
+static GncGWENGui *full_gui = NULL;
+
+/* A unique Gwenhywfar GUI for hooking our logging into the gwenhywfar logging
+ * framework */
+static GWEN_GUI *log_gwen_gui = NULL;
+
+/* A mapping from gwenhywfar log levels to glib ones */
+static GLogLevelFlags log_levels[] =
+{
+    G_LOG_LEVEL_ERROR,     /* GWEN_LoggerLevel_Emergency */
+    G_LOG_LEVEL_ERROR,     /* GWEN_LoggerLevel_Alert */
+    G_LOG_LEVEL_CRITICAL,  /* GWEN_LoggerLevel_Critical */
+    G_LOG_LEVEL_CRITICAL,  /* GWEN_LoggerLevel_Error */
+    G_LOG_LEVEL_WARNING,   /* GWEN_LoggerLevel_Warning */
+    G_LOG_LEVEL_MESSAGE,   /* GWEN_LoggerLevel_Notice */
+    G_LOG_LEVEL_INFO,      /* GWEN_LoggerLevel_Info */
+    G_LOG_LEVEL_DEBUG,     /* GWEN_LoggerLevel_Debug */
+    G_LOG_LEVEL_DEBUG      /* GWEN_LoggerLevel_Verbous */
+};
+static guint8 n_log_levels = G_N_ELEMENTS(log_levels);
+
+/* Macros to determine the GncGWENGui* from a GWEN_GUI* */
+GWEN_INHERIT(GWEN_GUI, GncGWENGui)
+#define SETDATA_GUI(gwen_gui, gui) GWEN_INHERIT_SETDATA(GWEN_GUI, GncGWENGui, \
+                                                        (gwen_gui), (gui), NULL)
+#define GETDATA_GUI(gwen_gui) GWEN_INHERIT_GETDATA(GWEN_GUI, GncGWENGui, (gwen_gui))
+
+#define OTHER_ENTRIES_ROW_OFFSET 3
+
+typedef struct _Progress Progress;
+typedef enum _GuiState GuiState;
+
+static void register_callbacks(GncGWENGui *gui);
+static void unregister_callbacks(GncGWENGui *gui);
+static void setup_dialog(GncGWENGui *gui);
+static void enable_password_cache(GncGWENGui *gui, gboolean enabled);
+static void reset_dialog(GncGWENGui *gui);
+static void set_finished(GncGWENGui *gui);
+static void set_aborted(GncGWENGui *gui);
+static void show_dialog(GncGWENGui *gui, gboolean clear_log);
+static void hide_dialog(GncGWENGui *gui);
+static gboolean show_progress_cb(gpointer user_data);
+static void show_progress(GncGWENGui *gui, Progress *progress);
+static void hide_progress(GncGWENGui *gui, Progress *progress);
+static void free_progress(Progress *progress, gpointer unused);
+static gboolean keep_alive(GncGWENGui *gui);
+static void cm_close_handler(gpointer user_data);
+static void erase_password(gchar *password);
+static gchar *strip_html(gchar *text);
+static void get_input(GncGWENGui *gui, guint32 flags, const gchar *title,
+                      const gchar *text, gchar **input, gint min_len,
+                      gint max_len);
+static gint messagebox_cb(GWEN_GUI *gwen_gui, guint32 flags, const gchar *title,
+                          const gchar *text, const gchar *b1, const gchar *b2,
+                          const gchar *b3, guint32 guiid);
+static gint inputbox_cb(GWEN_GUI *gwen_gui, guint32 flags, const gchar *title,
+                        const gchar *text, gchar *buffer, gint min_len,
+                        gint max_len, guint32 guiid);
+static guint32 showbox_cb(GWEN_GUI *gwen_gui, guint32 flags, const gchar *title,
+                          const gchar *text, guint32 guiid);
+static void hidebox_cb(GWEN_GUI *gwen_gui, guint32 id);
+static guint32 progress_start_cb(GWEN_GUI *gwen_gui, uint32_t progressFlags,
+                                 const char *title, const char *text,
+                                 uint64_t total, uint32_t guiid);
+static gint progress_advance_cb(GWEN_GUI *gwen_gui, uint32_t id,
+                                uint64_t new_progress);
+static gint progress_log_cb(GWEN_GUI *gwen_gui, guint32 id,
+                            GWEN_LOGGER_LEVEL level, const gchar *text);
+static gint progress_end_cb(GWEN_GUI *gwen_gui, guint32 id);
+static gint GNC_GWENHYWFAR_CB getpassword_cb(GWEN_GUI *gwen_gui, guint32 flags, const gchar *token,
+        const gchar *title, const gchar *text, gchar *buffer,
+        gint min_len, gint max_len, guint32 guiid);
+static gint GNC_GWENHYWFAR_CB setpasswordstatus_cb(GWEN_GUI *gwen_gui, const gchar *token,
+        const gchar *pin,
+        GWEN_GUI_PASSWORD_STATUS status, guint32 guiid);
+static gint GNC_GWENHYWFAR_CB loghook_cb(GWEN_GUI *gwen_gui, const gchar *log_domain,
+        GWEN_LOGGER_LEVEL priority, const gchar *text);
+#ifdef AQBANKING_VERSION_5_PLUS
+typedef GWEN_SYNCIO GWEN_IO_LAYER;
+#endif
+static gint GNC_GWENHYWFAR_CB checkcert_cb(GWEN_GUI *gwen_gui, const GWEN_SSLCERTDESCR *cert,
+        GWEN_IO_LAYER *io, guint32 guiid);
+
+gboolean ggg_delete_event_cb(GtkWidget *widget, GdkEvent *event,
+                             gpointer user_data);
+void ggg_abort_clicked_cb(GtkButton *button, gpointer user_data);
+void ggg_close_clicked_cb(GtkButton *button, gpointer user_data);
+void ggg_close_toggled_cb(GtkToggleButton *button, gpointer user_data);
+
+enum _GuiState
+{
+    INIT,
+    RUNNING,
+    FINISHED,
+    ABORTED,
+    HIDDEN
+};
+
+struct _GncGWENGui
+{
+    GWEN_GUI *gwen_gui;
+    GtkWidget *parent;
+    GtkWidget *dialog;
+
+    /* Progress bars */
+    GtkWidget *entries_table;
+    GtkWidget *top_entry;
+    GtkWidget *top_progress;
+    GtkWidget *second_entry;
+    GtkWidget *other_entries_box;
+
+    /* Stack of nested Progresses */
+    GList *progresses;
+
+    /* Number of steps in top-level progress or -1 */
+    guint64 max_actions;
+    guint64 current_action;
+
+    /* Log window */
+    GtkWidget *log_text;
+
+    /* Buttons */
+    GtkWidget *abort_button;
+    GtkWidget *close_button;
+    GtkWidget *close_checkbutton;
+
+    /* Flags to keep track on whether an HBCI action is running or not */
+    gboolean keep_alive;
+    GuiState state;
+
+    /* Password caching */
+    gboolean cache_passwords;
+    GHashTable *passwords;
+
+    /* Certificates handling */
+    GHashTable *accepted_certs;
+    GWEN_DB_NODE *permanently_accepted_certs;
+    GWEN_GUI_CHECKCERT_FN builtin_checkcert;
+
+    /* Dialogs */
+    guint32 showbox_id;
+    GHashTable *showbox_hash;
+    GtkWidget *showbox_last;
+
+    /* Cache the lowest loglevel, corresponding to the most serious warning */
+    GWEN_LOGGER_LEVEL min_loglevel;
+};
+
+struct _Progress
+{
+    GncGWENGui *gui;
+
+    /* Title of the process */
+    gchar *title;
+
+    /* Event source id for showing delayed */
+    guint source;
+};
+
+void
+gnc_GWEN_Gui_log_init(void)
+{
+    if (!log_gwen_gui)
+    {
+        log_gwen_gui =
+#ifdef USING_GWENHYWFAR_GTK2_GUI
+            Gtk2_Gui_new()
+#else
+            GWEN_Gui_new()
+#endif
+            ;
+
+        /* Always use our own logging */
+        GWEN_Gui_SetLogHookFn(log_gwen_gui, loghook_cb);
+
+        /* Keep a reference so that the GWEN_GUI survives a GUI switch */
+        GWEN_Gui_Attach(log_gwen_gui);
+    }
+    GWEN_Gui_SetGui(log_gwen_gui);
+}
+
+GncGWENGui *
+gnc_GWEN_Gui_get(GtkWidget *parent)
+{
+    GncGWENGui *gui;
+
+    ENTER("parent=%p", parent);
+
+    if (full_gui)
+    {
+        if (full_gui->state == INIT || full_gui->state == RUNNING)
+        {
+            LEAVE("full_gui in use, state=%d", full_gui->state);
+            return NULL;
+        }
+
+        gui = full_gui;
+        gui->parent = parent;
+        reset_dialog(gui);
+        register_callbacks(gui);
+
+        LEAVE("gui=%p", gui);
+        return gui;
+    }
+
+    gui = g_new0(GncGWENGui, 1);
+    gui->parent = parent;
+    setup_dialog(gui);
+    register_callbacks(gui);
+
+    full_gui = gui;
+
+    LEAVE("new gui=%p", gui);
+    return gui;
+}
+
+void
+gnc_GWEN_Gui_release(GncGWENGui *gui)
+{
+    g_return_if_fail(gui && gui == full_gui);
+
+    /* Currently a no-op */
+    ENTER("gui=%p", gui);
+    LEAVE(" ");
+}
+
+void
+gnc_GWEN_Gui_shutdown(void)
+{
+    GncGWENGui *gui = full_gui;
+
+    ENTER(" ");
+
+    if (log_gwen_gui)
+    {
+        GWEN_Gui_free(log_gwen_gui);
+        log_gwen_gui = NULL;
+    }
+    GWEN_Gui_SetGui(NULL);
+
+    if (!gui)
+        return;
+
+    gui->parent = NULL;
+    reset_dialog(gui);
+    if (gui->passwords)
+        g_hash_table_destroy(gui->passwords);
+    if (gui->showbox_hash)
+        g_hash_table_destroy(gui->showbox_hash);
+    if (gui->permanently_accepted_certs)
+        GWEN_DB_Group_free(gui->permanently_accepted_certs);
+    if (gui->accepted_certs)
+        g_hash_table_destroy(gui->accepted_certs);
+    gtk_widget_destroy(gui->dialog);
+    g_free(gui);
+
+    full_gui = NULL;
+
+    LEAVE(" ");
+}
+
+void
+gnc_GWEN_Gui_set_close_flag(gboolean close_when_finished)
+{
+    gnc_prefs_set_bool(
+        GNC_PREFS_GROUP_AQBANKING, GNC_PREF_CLOSE_ON_FINISH,
+        close_when_finished);
+
+    if (full_gui)
+    {
+        if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(full_gui->close_checkbutton))
+                != close_when_finished)
+        {
+            gtk_toggle_button_set_active(
+                GTK_TOGGLE_BUTTON(full_gui->close_checkbutton),
+                close_when_finished);
+        }
+    }
+}
+
+gboolean
+gnc_GWEN_Gui_get_close_flag()
+{
+    return gnc_prefs_get_bool (GNC_PREFS_GROUP_AQBANKING, GNC_PREF_CLOSE_ON_FINISH);
+}
+
+gboolean
+gnc_GWEN_Gui_show_dialog()
+{
+    GncGWENGui *gui = full_gui;
+
+    if (!gui)
+    {
+        gnc_GWEN_Gui_get(NULL);
+    }
+
+    if (gui)
+    {
+        if (gui->state == HIDDEN)
+        {
+            gui->state = FINISHED;
+        }
+        gtk_toggle_button_set_active(
+            GTK_TOGGLE_BUTTON(gui->close_checkbutton),
+            gnc_prefs_get_bool (GNC_PREFS_GROUP_AQBANKING, GNC_PREF_CLOSE_ON_FINISH));
+
+        show_dialog(gui, FALSE);
+
+        return TRUE;
+    }
+
+    return FALSE;
+}
+
+void
+gnc_GWEN_Gui_hide_dialog()
+{
+    GncGWENGui *gui = full_gui;
+
+    if (gui)
+    {
+        hide_dialog(gui);
+    }
+}
+
+static void
+register_callbacks(GncGWENGui *gui)
+{
+    GWEN_GUI *gwen_gui;
+
+    g_return_if_fail(gui && !gui->gwen_gui);
+
+    ENTER("gui=%p", gui);
+
+    gwen_gui =
+#ifdef USING_GWENHYWFAR_GTK2_GUI
+        Gtk2_Gui_new()
+#else
+        GWEN_Gui_new()
+#endif
+        ;
+    gui->gwen_gui = gwen_gui;
+
+    GWEN_Gui_SetMessageBoxFn(gwen_gui, messagebox_cb);
+    GWEN_Gui_SetInputBoxFn(gwen_gui, inputbox_cb);
+    GWEN_Gui_SetShowBoxFn(gwen_gui, showbox_cb);
+    GWEN_Gui_SetHideBoxFn(gwen_gui, hidebox_cb);
+    GWEN_Gui_SetProgressStartFn(gwen_gui, progress_start_cb);
+    GWEN_Gui_SetProgressAdvanceFn(gwen_gui, progress_advance_cb);
+    GWEN_Gui_SetProgressLogFn(gwen_gui, progress_log_cb);
+    GWEN_Gui_SetProgressEndFn(gwen_gui, progress_end_cb);
+    GWEN_Gui_SetGetPasswordFn(gwen_gui, getpassword_cb);
+    GWEN_Gui_SetSetPasswordStatusFn(gwen_gui, setpasswordstatus_cb);
+    GWEN_Gui_SetLogHookFn(gwen_gui, loghook_cb);
+    gui->builtin_checkcert = GWEN_Gui_SetCheckCertFn(gwen_gui, checkcert_cb);
+
+    GWEN_Gui_SetGui(gwen_gui);
+    SETDATA_GUI(gwen_gui, gui);
+
+    LEAVE(" ");
+}
+
+static void
+unregister_callbacks(GncGWENGui *gui)
+{
+    g_return_if_fail(gui);
+
+    ENTER("gui=%p", gui);
+
+    if (!gui->gwen_gui)
+    {
+        LEAVE("already unregistered");
+        return;
+    }
+
+    /* Switch to log_gwen_gui and free gui->gwen_gui */
+    gnc_GWEN_Gui_log_init();
+
+    gui->gwen_gui = NULL;
+
+    LEAVE(" ");
+}
+
+static void
+setup_dialog(GncGWENGui *gui)
+{
+    GtkBuilder *builder;
+    gint component_id;
+
+    g_return_if_fail(gui);
+
+    ENTER("gui=%p", gui);
+
+    builder = gtk_builder_new();
+    gnc_builder_add_from_file (builder, "dialog-ab.glade", "Connection Dialog");
+
+    gui->dialog = GTK_WIDGET(gtk_builder_get_object (builder, "Connection Dialog"));
+
+    gui->entries_table = GTK_WIDGET(gtk_builder_get_object (builder, "entries_table"));
+    gui->top_entry = GTK_WIDGET(gtk_builder_get_object (builder, "top_entry"));
+    gui->top_progress = GTK_WIDGET(gtk_builder_get_object (builder, "top_progress"));
+    gui->second_entry = GTK_WIDGET(gtk_builder_get_object (builder, "second_entry"));
+    gui->other_entries_box = NULL;
+    gui->progresses = NULL;
+    gui->log_text = GTK_WIDGET(gtk_builder_get_object (builder, "log_text"));
+    gui->abort_button = GTK_WIDGET(gtk_builder_get_object (builder, "abort_button"));
+    gui->close_button = GTK_WIDGET(gtk_builder_get_object (builder, "close_button"));
+    gui->close_checkbutton = GTK_WIDGET(gtk_builder_get_object (builder, "close_checkbutton"));
+    gui->accepted_certs = NULL;
+    gui->permanently_accepted_certs = NULL;
+    gui->showbox_hash = NULL;
+    gui->showbox_id = 1;
+
+    /* Connect the Signals */
+    gtk_builder_connect_signals_full (builder, gnc_builder_connect_full_func, gui);
+
+    gtk_toggle_button_set_active(
+        GTK_TOGGLE_BUTTON(gui->close_checkbutton),
+        gnc_prefs_get_bool (GNC_PREFS_GROUP_AQBANKING, GNC_PREF_CLOSE_ON_FINISH));
+
+    component_id = gnc_register_gui_component(GWEN_GUI_CM_CLASS, NULL,
+                   cm_close_handler, gui);
+    gnc_gui_component_set_session(component_id, gnc_get_current_session());
+
+
+
+    g_object_unref(G_OBJECT(builder));
+
+    reset_dialog(gui);
+
+    LEAVE(" ");
+}
+
+static void
+enable_password_cache(GncGWENGui *gui, gboolean enabled)
+{
+    g_return_if_fail(gui);
+
+    if (enabled && !gui->passwords)
+    {
+        /* Remember passwords in memory, mapping tokens to passwords */
+        gui->passwords = g_hash_table_new_full(
+                             g_str_hash, g_str_equal, (GDestroyNotify) g_free,
+                             (GDestroyNotify) erase_password);
+    }
+    else if (!enabled && gui->passwords)
+    {
+        /* Erase and free remembered passwords from memory */
+        g_hash_table_destroy(gui->passwords);
+        gui->passwords = NULL;
+    }
+    gui->cache_passwords = enabled;
+}
+
+static void
+reset_dialog(GncGWENGui *gui)
+{
+    gboolean cache_passwords;
+
+    g_return_if_fail(gui);
+
+    ENTER("gui=%p", gui);
+
+    gtk_entry_set_text(GTK_ENTRY(gui->top_entry), "");
+    gtk_entry_set_text(GTK_ENTRY(gui->second_entry), "");
+    g_list_foreach(gui->progresses, (GFunc) free_progress, NULL);
+    g_list_free(gui->progresses);
+    gui->progresses = NULL;
+
+    if (gui->other_entries_box)
+    {
+        gtk_table_resize(GTK_TABLE(gui->entries_table),
+                         OTHER_ENTRIES_ROW_OFFSET, 2);
+        gtk_widget_destroy(gui->other_entries_box);
+        gui->other_entries_box = NULL;
+    }
+    if (gui->showbox_hash)
+        g_hash_table_destroy(gui->showbox_hash);
+    gui->showbox_last = NULL;
+    gui->showbox_hash = g_hash_table_new_full(
+                            NULL, NULL, NULL, (GDestroyNotify) gtk_widget_destroy);
+
+    if (gui->parent)
+        gtk_window_set_transient_for(GTK_WINDOW(gui->dialog),
+                                     GTK_WINDOW(gui->parent));
+    gnc_restore_window_size(GNC_PREFS_GROUP_CONNECTION, GTK_WINDOW(gui->dialog));
+
+    gui->keep_alive = TRUE;
+    gui->state = INIT;
+    gui->min_loglevel = GWEN_LoggerLevel_Verbous;
+
+    cache_passwords = gnc_prefs_get_bool(GNC_PREFS_GROUP_AQBANKING,
+                                         GNC_PREF_REMEMBER_PIN);
+    enable_password_cache(gui, cache_passwords);
+
+    if (!gui->accepted_certs)
+        gui->accepted_certs = g_hash_table_new_full(
+                                  g_str_hash, g_str_equal, (GDestroyNotify) g_free, NULL);
+    if (!gui->permanently_accepted_certs)
+        gui->permanently_accepted_certs = gnc_ab_get_permanent_certs();
+
+    LEAVE(" ");
+}
+
+static void
+set_running(GncGWENGui *gui)
+{
+    g_return_if_fail(gui);
+
+    ENTER("gui=%p", gui);
+
+    gui->state = RUNNING;
+    gtk_widget_set_sensitive(gui->abort_button, TRUE);
+    gtk_widget_set_sensitive(gui->close_button, FALSE);
+    gui->keep_alive = TRUE;
+
+    LEAVE(" ");
+}
+
+static void
+set_finished(GncGWENGui *gui)
+{
+    g_return_if_fail(gui);
+
+    ENTER("gui=%p", gui);
+
+    /* Do not serve as GUI anymore */
+    gui->state = FINISHED;
+    unregister_callbacks(gui);
+
+    gtk_widget_set_sensitive(gui->abort_button, FALSE);
+    gtk_widget_set_sensitive(gui->close_button, TRUE);
+    if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(gui->close_checkbutton)))
+        hide_dialog(gui);
+
+    LEAVE(" ");
+}
+
+static void
+set_aborted(GncGWENGui *gui)
+{
+    g_return_if_fail(gui);
+
+    ENTER("gui=%p", gui);
+
+    /* Do not serve as GUI anymore */
+    gui->state = ABORTED;
+    unregister_callbacks(gui);
+
+    gtk_widget_set_sensitive(gui->abort_button, FALSE);
+    gtk_widget_set_sensitive(gui->close_button, TRUE);
+    gui->keep_alive = FALSE;
+
+    LEAVE(" ");
+}
+
+static void
+show_dialog(GncGWENGui *gui, gboolean clear_log)
+{
+    g_return_if_fail(gui);
+
+    ENTER("gui=%p, clear_log=%d", gui, clear_log);
+
+    gtk_widget_show(gui->dialog);
+
+    gnc_plugin_aqbanking_set_logwindow_visible(TRUE);
+
+    /* Clear the log window */
+    if (clear_log)
+    {
+        gtk_text_buffer_set_text(
+            gtk_text_view_get_buffer(GTK_TEXT_VIEW(gui->log_text)), "", 0);
+    }
+
+    LEAVE(" ");
+}
+
+static void
+hide_dialog(GncGWENGui *gui)
+{
+    g_return_if_fail(gui);
+
+    ENTER("gui=%p", gui);
+
+    /* Hide the dialog */
+    gtk_widget_hide(gui->dialog);
+
+    gnc_plugin_aqbanking_set_logwindow_visible(FALSE);
+
+    /* Remember whether the dialog is to be closed when finished */
+    gnc_prefs_set_bool(
+        GNC_PREFS_GROUP_AQBANKING, GNC_PREF_CLOSE_ON_FINISH,
+        gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(gui->close_checkbutton)));
+
+    /* Remember size and position of the dialog */
+    gnc_save_window_size(GNC_PREFS_GROUP_CONNECTION, GTK_WINDOW(gui->dialog));
+
+    /* Do not serve as GUI anymore */
+    gui->state = HIDDEN;
+    unregister_callbacks(gui);
+
+    LEAVE(" ");
+}
+
+static gboolean
+show_progress_cb(gpointer user_data)
+{
+    Progress *progress = user_data;
+
+    g_return_val_if_fail(progress, FALSE);
+
+    ENTER("progress=%p", progress);
+
+    show_progress(progress->gui, progress);
+
+    LEAVE(" ");
+    return FALSE;
+}
+
+/**
+ * Show all processes down to and including @a progress.
+ */
+static void
+show_progress(GncGWENGui *gui, Progress *progress)
+{
+    GList *item;
+    Progress *current;
+
+    g_return_if_fail(gui);
+
+    ENTER("gui=%p, progress=%p", gui, progress);
+
+    for (item = g_list_last(gui->progresses); item; item = item->prev)
+    {
+        current = (Progress*) item->data;
+
+        if (!current->source
+                && current != progress)
+            /* Already showed */
+            continue;
+
+        /* Show it */
+        if (!item->next)
+        {
+            /* Top-level progress */
+            show_dialog(gui, TRUE);
+            gtk_entry_set_text(GTK_ENTRY(gui->top_entry), current->title);
+        }
+        else if (!item->next->next)
+        {
+            /* Second-level progress */
+            gtk_entry_set_text(GTK_ENTRY(gui->second_entry), current->title);
+        }
+        else
+        {
+            /* Other progress */
+            GtkWidget *entry = gtk_entry_new();
+            GtkWidget *box = gui->other_entries_box;
+            gboolean new_box = box == NULL;
+
+            gtk_entry_set_text(GTK_ENTRY(entry), current->title);
+            if (new_box)
+                gui->other_entries_box = box = gtk_vbox_new(TRUE, 6);
+            gtk_box_pack_start(GTK_BOX(box), entry, TRUE, TRUE, 0);
+            gtk_widget_show(entry);
+            if (new_box)
+            {
+                gtk_table_resize(GTK_TABLE(gui->entries_table),
+                                 OTHER_ENTRIES_ROW_OFFSET + 1, 2);
+                gtk_table_attach_defaults(
+                    GTK_TABLE(gui->entries_table), box, 1, 2,
+                    OTHER_ENTRIES_ROW_OFFSET, OTHER_ENTRIES_ROW_OFFSET + 1);
+                gtk_widget_show(box);
+            }
+        }
+
+        if (current->source)
+        {
+            /* Stop delayed call */
+            g_source_remove(current->source);
+            current->source = 0;
+        }
+
+        if (current == progress)
+            break;
+    }
+
+    LEAVE(" ");
+}
+
+/**
+ * Hide all processes up to and including @a progress.
+ */
+static void
+hide_progress(GncGWENGui *gui, Progress *progress)
+{
+    GList *item;
+    Progress *current;
+
+    g_return_if_fail(gui);
+
+    ENTER("gui=%p, progress=%p", gui, progress);
+
+    for (item = gui->progresses; item; item = item->next)
+    {
+        current = (Progress*) item->data;
+
+        if (current->source)
+        {
+            /* Not yet showed */
+            g_source_remove(current->source);
+            current->source = 0;
+            if (current == progress)
+                break;
+            else
+                continue;
+        }
+
+        /* Hide it */
+        if (!item->next)
+        {
+            /* Top-level progress */
+            gtk_entry_set_text(GTK_ENTRY(gui->second_entry), "");
+        }
+        else if (!item->next->next)
+        {
+            /* Second-level progress */
+            gtk_entry_set_text(GTK_ENTRY(gui->second_entry), "");
+        }
+        else
+        {
+            /* Other progress */
+            GtkWidget *box = gui->other_entries_box;
+            GList *entries;
+
+            g_return_if_fail(box);
+            entries = gtk_container_get_children(GTK_CONTAINER(box));
+            g_return_if_fail(entries);
+            if (entries->next)
+            {
+                /* Another progress is still to be showed */
+                gtk_widget_destroy(GTK_WIDGET(g_list_last(entries)->data));
+            }
+            else
+            {
+                /* Last other progress to be hided */
+                gtk_table_resize(GTK_TABLE(gui->entries_table),
+                                 OTHER_ENTRIES_ROW_OFFSET, 2);
+                gtk_widget_destroy(box);
+                gui->other_entries_box = NULL;
+            }
+            g_list_free(entries);
+        }
+
+        if (current == progress)
+            break;
+    }
+
+    LEAVE(" ");
+}
+
+static void
+free_progress(Progress *progress, gpointer unused)
+{
+    if (progress->source)
+        g_source_remove(progress->source);
+    g_free(progress->title);
+    g_free(progress);
+}
+
+static gboolean
+keep_alive(GncGWENGui *gui)
+{
+    g_return_val_if_fail(gui, FALSE);
+
+    ENTER("gui=%p", gui);
+
+    /* Let the widgets be redrawn */
+    while (g_main_context_iteration(NULL, FALSE));
+
+    LEAVE("alive=%d", gui->keep_alive);
+    return gui->keep_alive;
+}
+
+static void
+cm_close_handler(gpointer user_data)
+{
+    GncGWENGui *gui = user_data;
+
+    g_return_if_fail(gui);
+
+    ENTER("gui=%p", gui);
+
+    /* FIXME */
+    set_aborted(gui);
+
+    LEAVE(" ");
+}
+
+static void
+erase_password(gchar *password)
+{
+    g_return_if_fail(password);
+
+    ENTER(" ");
+
+    memset(password, 0, strlen(password));
+    g_free(password);
+
+    LEAVE(" ");
+}
+
+/**
+ * Find first <[Hh][Tt][Mm][Ll]> and cut off the string there.
+ */
+static gchar *
+strip_html(gchar *text)
+{
+    gchar *p, *q;
+
+    if (!text)
+        return NULL;
+
+    p = text;
+    while (strchr(p, '<'))
+    {
+        q = p + 1;
+        if (*q && toupper(*q++) == 'H'
+                && *q && toupper(*q++) == 'T'
+                && *q && toupper(*q++) == 'M'
+                && *q && toupper(*q) == 'L')
+        {
+            *p = '\0';
+            return text;
+        }
+        p++;
+    }
+    return text;
+}
+
+static void
+get_input(GncGWENGui *gui, guint32 flags, const gchar *title, const gchar *text,
+          gchar **input, gint min_len, gint max_len)
+{
+    GtkBuilder *builder;
+    GtkWidget *dialog;
+    GtkWidget *heading_label;
+    GtkWidget *input_entry;
+    GtkWidget *confirm_entry;
+    GtkWidget *confirm_label;
+    GtkWidget *remember_pin_checkbutton;
+    const gchar *internal_input, *internal_confirmed;
+    gboolean confirm = (flags & GWEN_GUI_INPUT_FLAGS_CONFIRM) != 0;
+    gboolean is_tan = (flags & GWEN_GUI_INPUT_FLAGS_TAN) != 0;
+
+    g_return_if_fail(input);
+    g_return_if_fail(max_len >= min_len && max_len > 0);
+
+    ENTER(" ");
+
+    /* Set up dialog */
+    builder = gtk_builder_new();
+    gnc_builder_add_from_file (builder, "dialog-ab.glade", "Password Dialog");
+    dialog = GTK_WIDGET(gtk_builder_get_object (builder, "Password Dialog"));
+
+    heading_label = GTK_WIDGET(gtk_builder_get_object (builder, "heading_pw_label"));
+    input_entry = GTK_WIDGET(gtk_builder_get_object (builder, "input_entry"));
+    confirm_entry = GTK_WIDGET(gtk_builder_get_object (builder, "confirm_entry"));
+    confirm_label = GTK_WIDGET(gtk_builder_get_object (builder, "confirm_label"));
+    remember_pin_checkbutton = GTK_WIDGET(gtk_builder_get_object (builder, "remember_pin"));
+    if (is_tan)
+    {
+        gtk_widget_hide(remember_pin_checkbutton);
+    }
+    else
+    {
+        gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(remember_pin_checkbutton),
+                                     gui->cache_passwords);
+    }
+
+    if (gui->parent)
+        gtk_window_set_transient_for(GTK_WINDOW(dialog),
+                                     GTK_WINDOW(gui->parent));
+    if (title)
+        gtk_window_set_title(GTK_WINDOW(dialog), title);
+
+    if (text)
+    {
+        gchar *raw_text = strip_html(g_strdup(text));
+        gtk_label_set_text(GTK_LABEL(heading_label), raw_text);
+        g_free(raw_text);
+    }
+
+    if (*input)
+    {
+        gtk_entry_set_text(GTK_ENTRY(input_entry), *input);
+        erase_password(*input);
+        *input = NULL;
+    }
+
+    if (confirm)
+    {
+        gtk_entry_set_activates_default(GTK_ENTRY(input_entry), FALSE);
+        gtk_entry_set_activates_default(GTK_ENTRY(confirm_entry), TRUE);
+        gtk_entry_set_max_length(GTK_ENTRY(input_entry), max_len);
+        gtk_entry_set_max_length(GTK_ENTRY(confirm_entry), max_len);
+    }
+    else
+    {
+        gtk_entry_set_activates_default(GTK_ENTRY(input_entry), TRUE);
+        gtk_entry_set_max_length(GTK_ENTRY(input_entry), max_len);
+        gtk_widget_hide(confirm_entry);
+        gtk_widget_hide(confirm_label);
+    }
+    gtk_dialog_set_default_response(GTK_DIALOG(dialog), GTK_RESPONSE_OK);
+
+    /* Ask the user until he enters a valid input or cancels */
+    while (TRUE)
+    {
+        gboolean remember_pin;
+
+        if (gtk_dialog_run(GTK_DIALOG(dialog)) != GTK_RESPONSE_OK)
+            break;
+
+        if (!is_tan)
+        {
+            /* Enable or disable the password cache */
+            remember_pin = gtk_toggle_button_get_active(
+                               GTK_TOGGLE_BUTTON(remember_pin_checkbutton));
+            enable_password_cache(gui, remember_pin);
+            gnc_prefs_set_bool(GNC_PREFS_GROUP_AQBANKING, GNC_PREF_REMEMBER_PIN,
+                               remember_pin);
+        }
+
+        internal_input = gtk_entry_get_text(GTK_ENTRY(input_entry));
+        if (strlen(internal_input) < min_len)
+        {
+            gboolean retval;
+            gchar *msg = g_strdup_printf(
+                             _("The PIN needs to be at least %d characters \n"
+                               "long. Do you want to try again?"), min_len);
+            retval = gnc_verify_dialog(gui->parent, TRUE, "%s", msg);
+            g_free(msg);
+            if (!retval)
+                break;
+            continue;
+        }
+
+        if (!confirm)
+        {
+            *input = g_strdup(internal_input);
+            break;
+        }
+
+        internal_confirmed = gtk_entry_get_text(GTK_ENTRY(confirm_entry));
+        if (strcmp(internal_input, internal_confirmed) == 0)
+        {
+            *input = g_strdup(internal_input);
+            break;
+        }
+    }
+
+    g_object_unref(G_OBJECT(builder));
+
+    /* This trashes passwords in the entries' memory as well */
+    gtk_widget_destroy(dialog);
+
+    LEAVE("input %s", *input ? "non-NULL" : "NULL");
+}
+
+static gint
+messagebox_cb(GWEN_GUI *gwen_gui, guint32 flags, const gchar *title,
+              const gchar *text, const gchar *b1, const gchar *b2,
+              const gchar *b3, guint32 guiid)
+{
+    GncGWENGui *gui = GETDATA_GUI(gwen_gui);
+    GtkWidget *dialog;
+    GtkWidget *vbox;
+    GtkWidget *label;
+    gchar *raw_text;
+    gint result;
+
+    ENTER("gui=%p, flags=%d, title=%s, b1=%s, b2=%s, b3=%s", gui, flags,
+          title ? title : "(null)", b1 ? b1 : "(null)", b2 ? b2 : "(null)",
+          b3 ? b3 : "(null)");
+
+    dialog = gtk_dialog_new_with_buttons(
+                 title, gui->parent ? GTK_WINDOW(gui->parent) : NULL,
+                 GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT,
+                 b1, 1, b2, 2, b3, 3, (gchar*) NULL);
+
+    raw_text = strip_html(g_strdup(text));
+    label = gtk_label_new(raw_text);
+    g_free(raw_text);
+    gtk_label_set_justify(GTK_LABEL(label), GTK_JUSTIFY_LEFT);
+    vbox = gtk_vbox_new(TRUE, 0);
+    gtk_container_set_border_width(GTK_CONTAINER(vbox), 5);
+    gtk_container_add(GTK_CONTAINER(vbox), label);
+    gtk_container_set_border_width(GTK_CONTAINER(dialog), 5);
+    gtk_container_add(GTK_CONTAINER(GTK_DIALOG(dialog)->vbox), vbox);
+    gtk_widget_show_all(dialog);
+
+    result = gtk_dialog_run(GTK_DIALOG(dialog));
+    gtk_widget_destroy(dialog);
+
+    if (result < 1 || result > 3)
+    {
+        g_warning("messagebox_cb: Bad result %d", result);
+        result = 0;
+    }
+
+    LEAVE("result=%d", result);
+    return result;
+}
+
+static gint
+inputbox_cb(GWEN_GUI *gwen_gui, guint32 flags, const gchar *title,
+            const gchar *text, gchar *buffer, gint min_len, gint max_len,
+            guint32 guiid)
+{
+    GncGWENGui *gui = GETDATA_GUI(gwen_gui);
+    gchar *input = NULL;
+
+    g_return_val_if_fail(gui, -1);
+
+    ENTER("gui=%p, flags=%d", gui, flags);
+
+    get_input(gui, flags, title, text, &input, min_len, max_len);
+
+    if (input)
+    {
+        /* Copy the input to the result buffer */
+        strncpy(buffer, input, max_len);
+        buffer[max_len-1] = '\0';
+    }
+
+    LEAVE(" ");
+    return input ? 0 : -1;
+}
+
+static guint32
+showbox_cb(GWEN_GUI *gwen_gui, guint32 flags, const gchar *title,
+           const gchar *text, guint32 guiid)
+{
+    GncGWENGui *gui = GETDATA_GUI(gwen_gui);
+    GtkWidget *dialog;
+    guint32 showbox_id;
+
+    g_return_val_if_fail(gui, -1);
+
+    ENTER("gui=%p, flags=%d, title=%s", gui, flags, title ? title : "(null)");
+
+    dialog = gtk_message_dialog_new(
+                 gui->parent ? GTK_WINDOW(gui->parent) : NULL, 0, GTK_MESSAGE_INFO,
+                 GTK_BUTTONS_OK, "%s", text);
+
+    if (title)
+        gtk_window_set_title(GTK_WINDOW(dialog), title);
+
+    g_signal_connect(dialog, "response", G_CALLBACK(gtk_widget_hide), NULL);
+    gtk_widget_show_all(dialog);
+
+    showbox_id = gui->showbox_id++;
+    g_hash_table_insert(gui->showbox_hash, GUINT_TO_POINTER(showbox_id),
+                        dialog);
+    gui->showbox_last = dialog;
+
+    /* Give it a change to be showed */
+    if (!keep_alive(gui))
+        showbox_id = 0;
+
+    LEAVE("id=%" G_GUINT32_FORMAT, showbox_id);
+    return showbox_id;
+}
+
+static void
+hidebox_cb(GWEN_GUI *gwen_gui, guint32 id)
+{
+    GncGWENGui *gui = GETDATA_GUI(gwen_gui);
+
+    g_return_if_fail(gui && gui->showbox_hash);
+
+    ENTER("gui=%p, id=%d", gui, id);
+
+    if (id == 0)
+    {
+        if (gui->showbox_last)
+        {
+            g_hash_table_remove(gui->showbox_hash,
+                                GUINT_TO_POINTER(gui->showbox_id));
+            gui->showbox_last = NULL;
+        }
+        else
+        {
+            g_warning("hidebox_cb: Last showed message box already destroyed");
+        }
+    }
+    else
+    {
+        gpointer p_var;
+        p_var = g_hash_table_lookup(gui->showbox_hash, GUINT_TO_POINTER(id));
+        if (p_var)
+        {
+            g_hash_table_remove(gui->showbox_hash, GUINT_TO_POINTER(id));
+            if (p_var == gui->showbox_last)
+                gui->showbox_last = NULL;
+        }
+        else
+        {
+            g_warning("hidebox_cb: Message box %d could not been found", id);
+        }
+    }
+
+    LEAVE(" ");
+}
+
+static guint32
+progress_start_cb(GWEN_GUI *gwen_gui, uint32_t progressFlags, const char *title,
+                  const char *text, uint64_t total, uint32_t guiid)
+{
+    GncGWENGui *gui = GETDATA_GUI(gwen_gui);
+    Progress *progress;
+
+    g_return_val_if_fail(gui, -1);
+
+    ENTER("gui=%p, flags=%d, title=%s, total=%" G_GUINT64_FORMAT, gui,
+          progressFlags, title ? title : "(null)", (guint64)total);
+
+    if (!gui->progresses)
+    {
+        /* Top-level progress */
+        if (progressFlags & GWEN_GUI_PROGRESS_SHOW_PROGRESS)
+        {
+            gtk_widget_set_sensitive(gui->top_progress, TRUE);
+            gtk_progress_bar_set_fraction(
+                GTK_PROGRESS_BAR(gui->top_progress), 0.0);
+            gui->max_actions = total;
+        }
+        else
+        {
+            gtk_widget_set_sensitive(gui->top_progress, FALSE);
+            gui->max_actions = -1;
+        }
+        set_running(gui);
+    }
+
+    /* Put progress onto the stack */
+    progress = g_new0(Progress, 1);
+    progress->gui = gui;
+    progress->title = title ? g_strdup(title) : "";
+    gui->progresses = g_list_prepend(gui->progresses, progress);
+
+    if (progressFlags & GWEN_GUI_PROGRESS_DELAY)
+    {
+        /* Show progress later */
+        progress->source = g_timeout_add(GWEN_GUI_DELAY_SECS * 1000,
+                                         (GSourceFunc) show_progress_cb,
+                                         progress);
+    }
+    else
+    {
+        /* Show it now */
+        progress->source = 0;
+        show_progress(gui, progress);
+    }
+
+    LEAVE(" ");
+    return g_list_length(gui->progresses);
+}
+
+static gint
+progress_advance_cb(GWEN_GUI *gwen_gui, uint32_t id, uint64_t progress)
+{
+    GncGWENGui *gui = GETDATA_GUI(gwen_gui);
+
+    g_return_val_if_fail(gui, -1);
+
+    ENTER("gui=%p, progress=%" G_GUINT64_FORMAT, gui, (guint64)progress);
+
+    if (id == 1                                  /* top-level progress */
+            && gui->max_actions > 0                  /* progressbar active */
+            && progress != GWEN_GUI_PROGRESS_NONE)   /* progressbar update needed */
+    {
+        if (progress == GWEN_GUI_PROGRESS_ONE)
+            gui->current_action++;
+        else
+            gui->current_action = progress;
+
+        gtk_progress_bar_set_fraction(
+            GTK_PROGRESS_BAR(gui->top_progress),
+            ((gdouble) gui->current_action) / ((gdouble) gui->max_actions));
+    }
+
+    LEAVE(" ");
+    return !keep_alive(gui);
+}
+
+static gint
+progress_log_cb(GWEN_GUI *gwen_gui, guint32 id, GWEN_LOGGER_LEVEL level,
+                const gchar *text)
+{
+    GncGWENGui *gui = GETDATA_GUI(gwen_gui);
+    GtkTextBuffer *tb;
+    GtkTextView *tv;
+
+    g_return_val_if_fail(gui, -1);
+
+    ENTER("gui=%p, text=%s", gui, text ? text : "(null)");
+
+    tv = GTK_TEXT_VIEW(gui->log_text);
+    tb = gtk_text_view_get_buffer(tv);
+    gtk_text_buffer_insert_at_cursor(tb, text, -1);
+    gtk_text_buffer_insert_at_cursor(tb, "\n", -1);
+
+    /* Scroll to the end of the buffer */
+    gtk_text_view_scroll_to_mark(tv, gtk_text_buffer_get_insert(tb),
+                                 0.0, FALSE, 0.0, 0.0);
+
+    /* Cache loglevel */
+    if (level < gui->min_loglevel)
+        gui->min_loglevel = level;
+
+    LEAVE(" ");
+    return !keep_alive(gui);
+}
+
+static gint
+progress_end_cb(GWEN_GUI *gwen_gui, guint32 id)
+{
+    GncGWENGui *gui = GETDATA_GUI(gwen_gui);
+    Progress *progress;
+
+    g_return_val_if_fail(gui, -1);
+    g_return_val_if_fail(id == g_list_length(gui->progresses), -1);
+
+    ENTER("gui=%p, id=%d", gui, id);
+
+    if (gui->state != RUNNING)
+    {
+        /* Ignore finishes of progresses we do not track */
+        LEAVE("not running anymore");
+        return 0;
+    }
+
+    /* Hide progress */
+    progress = (Progress*) gui->progresses->data;
+    hide_progress(gui, progress);
+
+    /* Remove progress from stack and free memory */
+    gui->progresses = g_list_delete_link(gui->progresses, gui->progresses);
+    free_progress(progress, NULL);
+
+    if (!gui->progresses)
+    {
+        /* top-level progress finished */
+        set_finished(gui);
+    }
+
+    LEAVE(" ");
+    return 0;
+}
+
+static gint GNC_GWENHYWFAR_CB
+getpassword_cb(GWEN_GUI *gwen_gui, guint32 flags, const gchar *token,
+               const gchar *title, const gchar *text, gchar *buffer,
+               gint min_len, gint max_len, guint32 guiid)
+{
+    GncGWENGui *gui = GETDATA_GUI(gwen_gui);
+    gchar *password = NULL;
+    gboolean is_tan = (flags & GWEN_GUI_INPUT_FLAGS_TAN) != 0;
+
+    g_return_val_if_fail(gui, -1);
+
+    ENTER("gui=%p, flags=%d, token=%s", gui, flags, token ? token : "(null");
+
+    /* Check remembered passwords, excluding TANs */
+    if (!is_tan && gui->cache_passwords && gui->passwords && token)
+    {
+        if (flags & GWEN_GUI_INPUT_FLAGS_RETRY)
+        {
+            /* If remembered, remove password from memory */
+            g_hash_table_remove(gui->passwords, token);
+        }
+        else
+        {
+            gpointer p_var;
+            if (g_hash_table_lookup_extended(gui->passwords, token, NULL,
+                                             &p_var))
+            {
+                /* Copy the password to the result buffer */
+                password = p_var;
+                strncpy(buffer, password, max_len);
+                buffer[max_len-1] = '\0';
+
+                LEAVE("chose remembered password");
+                return 0;
+            }
+        }
+    }
+
+    get_input(gui, flags, title, text, &password, min_len, max_len);
+
+    if (password)
+    {
+        /* Copy the password to the result buffer */
+        strncpy(buffer, password, max_len);
+        buffer[max_len-1] = '\0';
+
+        if (!is_tan && token)
+        {
+            if (gui->cache_passwords && gui->passwords)
+            {
+                /* Remember password */
+                DEBUG("Remember password, token=%s", token);
+                g_hash_table_insert(gui->passwords, g_strdup(token), password);
+            }
+            else
+            {
+                /* Remove the password from memory */
+                DEBUG("Forget password, token=%s", token);
+                erase_password(password);
+            }
+        }
+    }
+
+    LEAVE(" ");
+    return password ? 0 : -1;
+}
+
+static gint GNC_GWENHYWFAR_CB
+setpasswordstatus_cb(GWEN_GUI *gwen_gui, const gchar *token, const gchar *pin,
+                     GWEN_GUI_PASSWORD_STATUS status, guint32 guiid)
+{
+    GncGWENGui *gui = GETDATA_GUI(gwen_gui);
+
+    g_return_val_if_fail(gui, -1);
+
+    ENTER("gui=%p, token=%s, status=%d", gui, token ? token : "(null)", status);
+
+    if (gui->passwords && status != GWEN_Gui_PasswordStatus_Ok)
+    {
+        /* If remembered, remove password from memory */
+        g_hash_table_remove(gui->passwords, token);
+    }
+
+    LEAVE(" ");
+    return 0;
+}
+
+static gint GNC_GWENHYWFAR_CB
+loghook_cb(GWEN_GUI *gwen_gui, const gchar *log_domain,
+           GWEN_LOGGER_LEVEL priority, const gchar *text)
+{
+    if (G_LIKELY(priority < n_log_levels))
+        g_log(log_domain, log_levels[priority], "%s", text);
+
+    return 1;
+}
+
+static gint GNC_GWENHYWFAR_CB
+checkcert_cb(GWEN_GUI *gwen_gui, const GWEN_SSLCERTDESCR *cert,
+             GWEN_IO_LAYER *io, guint32 guiid)
+{
+    GncGWENGui *gui = GETDATA_GUI(gwen_gui);
+    const gchar *hash, *status;
+    struct md5_ctx md5_context;
+    gchar cert_hash[16];
+    gchar *cert_hash_hex;
+    gint retval, i;
+
+    g_return_val_if_fail(gui && gui->accepted_certs, -1);
+
+    ENTER("gui=%p, cert=%p", gui, cert);
+
+    hash = GWEN_SslCertDescr_GetFingerPrint(cert);
+    status = GWEN_SslCertDescr_GetStatusText(cert);
+
+    /* Operate on an md5sum of the pair of hash and status */
+    md5_init_ctx(&md5_context);
+    md5_process_bytes(hash, strlen(hash), &md5_context);
+    md5_process_bytes(status, strlen(status), &md5_context);
+    md5_finish_ctx(&md5_context, cert_hash);
+
+    /* Did we get the permanently accepted certs from AqBanking? */
+    if (gui->permanently_accepted_certs)
+    {
+        /* Generate a hex string of the cert_hash for usage by AqBanking cert store */
+        cert_hash_hex = g_new0(gchar, 33);
+        for (i = 0; i < 16; i++)
+            g_snprintf(cert_hash_hex + 2 * i, 3, "%02X", (unsigned char)cert_hash[i]);
+
+        retval = GWEN_DB_GetIntValue(gui->permanently_accepted_certs, cert_hash_hex, 0, -1);
+        g_free(cert_hash_hex);
+        if (retval == 0)
+        {
+            /* Certificate is marked as accepted in AqBanking's cert store */
+            LEAVE("Certificate accepted by AqBanking's permanent cert store");
+            return 0;
+        }
+    }
+    else
+    {
+        g_warning("Can't check permanently accepted certs from invalid AqBanking cert store.");
+    }
+
+    if (g_hash_table_lookup(gui->accepted_certs, cert_hash))
+    {
+        /* Certificate has been accepted by Gnucash before */
+        LEAVE("Automatically accepting certificate");
+        return 0;
+    }
+
+    retval = gui->builtin_checkcert(gwen_gui, cert, io, guiid);
+    if (retval == 0)
+    {
+        /* Certificate has been accepted */
+        g_hash_table_insert(gui->accepted_certs, g_strdup(cert_hash), cert_hash);
+    }
+
+    LEAVE("retval=%d", retval);
+    return retval;
+}
+
+gboolean
+ggg_delete_event_cb(GtkWidget *widget, GdkEvent *event, gpointer user_data)
+{
+    GncGWENGui *gui = user_data;
+
+    g_return_val_if_fail(gui, FALSE);
+
+    ENTER("gui=%p, state=%d", gui, gui->state);
+
+    if (gui->state == RUNNING)
+    {
+        const char *still_running_msg =
+            _("The Online Banking job is still running; are you "
+              "sure you want to cancel?");
+        if (!gnc_verify_dialog(gui->dialog, FALSE, "%s", still_running_msg))
+            return FALSE;
+
+        set_aborted(gui);
+    }
+
+    hide_dialog(gui);
+
+    LEAVE(" ");
+    return TRUE;
+}
+
+void
+ggg_abort_clicked_cb(GtkButton *button, gpointer user_data)
+{
+    GncGWENGui *gui = user_data;
+
+    g_return_if_fail(gui && gui->state == RUNNING);
+
+    ENTER("gui=%p", gui);
+
+    set_aborted(gui);
+
+    LEAVE(" ");
+}
+
+void
+ggg_close_clicked_cb(GtkButton *button, gpointer user_data)
+{
+    GncGWENGui *gui = user_data;
+
+    g_return_if_fail(gui);
+    g_return_if_fail(gui->state == FINISHED || gui->state == ABORTED);
+
+    ENTER("gui=%p", gui);
+
+    hide_dialog(gui);
+
+    LEAVE(" ");
+}
+
+void
+ggg_close_toggled_cb(GtkToggleButton *button, gpointer user_data)
+{
+    GncGWENGui *gui = user_data;
+
+    g_return_if_fail(gui);
+    g_return_if_fail(gui->parent);
+
+    ENTER("gui=%p", gui);
+
+    gnc_prefs_set_bool(
+        GNC_PREFS_GROUP_AQBANKING, GNC_PREF_CLOSE_ON_FINISH,
+        gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(button)));
+
+    LEAVE(" ");
+}
+#endif

Copied: gnucash/trunk/src/import-export/aqb/gnc-gwen-gui.h (from rev 23566, gnucash/trunk/src/import-export/aqbanking/gnc-gwen-gui.h)
===================================================================
--- gnucash/trunk/src/import-export/aqb/gnc-gwen-gui.h	                        (rev 0)
+++ gnucash/trunk/src/import-export/aqb/gnc-gwen-gui.h	2013-12-15 17:21:20 UTC (rev 23567)
@@ -0,0 +1,107 @@
+/*
+ * gnc-gwen-gui.h --
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, contact:
+ *
+ * Free Software Foundation           Voice:  +1-617-542-5942
+ * 51 Franklin Street, Fifth Floor    Fax:    +1-617-542-2652
+ * Boston, MA  02110-1301,  USA       gnu at gnu.org
+ */
+
+/**
+ * @addtogroup Import_Export
+ * @{
+ * @addtogroup AqBanking
+ * @{
+ * @file gnc-gwen-gui.h
+ * @brief GUI callbacks for AqBanking
+ * @author Copyright (C) 2002 Christian Stimming <stimming at tuhh.de>
+ * @author Copyright (C) 2008 Andreas Koehler <andi5.py at gmx.net>
+ */
+
+#ifndef GNC_GWEN_GUI_H
+#define GNC_GWEN_GUI_H
+
+#include <gtk/gtk.h>
+
+G_BEGIN_DECLS
+
+typedef struct _GncGWENGui GncGWENGui;
+
+/**
+ * Hook our logging into the gwenhywfar logging framework by creating a
+ * minimalistic GWEN_GUI with only a callback for Gwen_Gui_LogHook().  This
+ * function can be called more than once, it will unref and replace the
+ * currently set GWEN_GUI though.
+ */
+void gnc_GWEN_Gui_log_init(void);
+
+/**
+ * When called for the first time, create a unique GncGWENGui object featuring a
+ * GWEN_GUI with all necessary callbacks, which can serve as a user interface
+ * for AqBanking jobs.  On later calls, return the object only when it is not
+ * active and save to use.  Typically, you only need to call
+ * gnc_GWEN_Gui_release() once your job has finished.
+ *
+ * @param parent Widget to set new dialogs transient for, may be NULL
+ * @return The unique GncGWENGui object or NULL otherwise
+ */
+GncGWENGui *gnc_GWEN_Gui_get(GtkWidget *parent);
+
+/**
+ * Currently a no-op.  The GncGWENGui will not be freed and it is considered
+ * finished once the first tracked progress has ended.
+ *
+ * @param gui The GncGwenGUI returned by gnc_GWEN_Gui_get()
+ */
+void gnc_GWEN_Gui_release(GncGWENGui *gui);
+
+/**
+ * Free all memory related to both the full-blown and minimalistic GUI objects.
+ */
+void gnc_GWEN_Gui_shutdown(void);
+
+/**
+ * Set "Close when finished" flag
+ *
+ * @param gboolean close_when_finished
+ */
+void gnc_GWEN_Gui_set_close_flag(gboolean close_when_finished);
+
+/**
+ * Get "Close when finished" flag
+ *
+ * @return gboolean close_when_finished
+ */
+gboolean gnc_GWEN_Gui_get_close_flag(void);
+
+/**
+ * Unhides Online Banking Connection Window (Make log visible)
+ *
+ * @return gboolean window is visible
+ */
+gboolean gnc_GWEN_Gui_show_dialog(void);
+
+/**
+ * Hides Online Banking Connection Window (Close log window)
+ *
+ */
+void gnc_GWEN_Gui_hide_dialog(void);
+
+G_END_DECLS
+
+/** @} */
+/** @} */
+
+#endif /* GNC_GWEN_GUI_H */

Copied: gnucash/trunk/src/import-export/aqb/gnc-plugin-aqbanking-ui.xml (from rev 23566, gnucash/trunk/src/import-export/aqbanking/gnc-plugin-aqbanking-ui.xml)
===================================================================
--- gnucash/trunk/src/import-export/aqb/gnc-plugin-aqbanking-ui.xml	                        (rev 0)
+++ gnucash/trunk/src/import-export/aqb/gnc-plugin-aqbanking-ui.xml	2013-12-15 17:21:20 UTC (rev 23567)
@@ -0,0 +1,39 @@
+<ui>
+  <menubar>
+    <menu name="File" action="FileAction">
+      <menu name="FileImport" action="FileImportAction">
+        <placeholder name="FileImportPlaceholder">
+           <menuitem name="FileMt940Import"     action="Mt940ImportAction"/>
+           <menuitem name="FileMt942Import"     action="Mt942ImportAction"/>
+           <menuitem name="FileDtausImport"     action="DtausImportAction"/>
+           <menuitem name="FileDtausImportsend" action="DtausImportSendAction"/>
+           <!-- When CsvImport works:
+           <menuitem name="FileCsvImport"       action="CsvImportAction"/>
+           <menuitem name="FileCsvImportsend"   action="CsvImportSendAction"/>
+           -->
+        </placeholder>
+      </menu>
+    </menu>
+    <menu name="Actions" action="ActionsAction">
+      <placeholder name="ActionsPlaceholder">
+        <menu name="OnlineActions" action="OnlineActionsAction">
+          <menuitem name="ABGetBalance"         action="ABGetBalanceAction"/>
+          <menuitem name="ABGetTrans"           action="ABGetTransAction"/>
+          <separator name="OnlineActionsSep1"/>
+          <menuitem name="ABIssueTrans"         action="ABIssueTransAction"/>
+          <menuitem name="ABIssueSepaTrans"         action="ABIssueSepaTransAction"/>
+          <menuitem name="ABIssueIntTrans"      action="ABIssueIntTransAction"/>
+          <menuitem name="ABIssueDirectDebit"   action="ABIssueDirectDebitAction"/>
+          <!--menuitem name="ABIssueSepaDirectDebit"         action="ABIssueSepaDirectDebitAction"/-->
+          <separator name="OnlineActionsSep2"/>
+          <menuitem name="ABViewLogwindow"   action="ABViewLogwindowAction"/>
+        </menu>
+      </placeholder>
+    </menu>
+    <menu name="Tools" action="ToolsAction">
+      <placeholder name="ToolsPlaceholder">
+        <menuitem name="ABSetup"                action="ABSetupAction"/>
+     </placeholder>
+    </menu>
+  </menubar>
+</ui>

Copied: gnucash/trunk/src/import-export/aqb/gnc-plugin-aqbanking.c (from rev 23566, gnucash/trunk/src/import-export/aqbanking/gnc-plugin-aqbanking.c)
===================================================================
--- gnucash/trunk/src/import-export/aqb/gnc-plugin-aqbanking.c	                        (rev 0)
+++ gnucash/trunk/src/import-export/aqb/gnc-plugin-aqbanking.c	2013-12-15 17:21:20 UTC (rev 23567)
@@ -0,0 +1,712 @@
+/*
+ * gnc-plugin-aqbanking.c --
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, contact:
+ *
+ * Free Software Foundation           Voice:  +1-617-542-5942
+ * 51 Franklin Street, Fifth Floor    Fax:    +1-617-542-2652
+ * Boston, MA  02110-1301,  USA       gnu at gnu.org
+ */
+
+/**
+ * @internal
+ * @file gnc-plugin-aqbanking.c
+ * @brief Plugin registration of the AqBanking module
+ * @author Copyright (C) 2002 Christian Stimming <stimming at tuhh.de>
+ * @author Copyright (C) 2003 David Hampton <hampton at employees.org>
+ * @author Copyright (C) 2008 Andreas Koehler <andi5.py at gmx.net>
+ */
+
+#include "config.h"
+
+#include <glib/gi18n.h>
+
+#include "Account.h"
+#include "dialog-ab-trans.h"
+#include "assistant-ab-initial.h"
+#include "gnc-ab-getbalance.h"
+#include "gnc-ab-gettrans.h"
+#include "gnc-ab-transfer.h"
+#include "gnc-ab-utils.h"
+#include "gnc-ab-kvp.h"
+#include "gnc-gwen-gui.h"
+#include "gnc-file-aqb-import.h"
+#include "gnc-plugin-aqbanking.h"
+#include "gnc-plugin-manager.h"
+#include "gnc-plugin-page-account-tree.h"
+#include "gnc-plugin-page-register.h"
+#include "gnc-plugin-page-register2.h"
+#include "gnc-main-window.h"
+#include "gnc-prefs.h"
+#include "gnc-ui-util.h" // for gnc_get_current_book
+
+/* This static indicates the debugging module that this .o belongs to.  */
+static QofLogModule log_module = G_LOG_DOMAIN;
+
+static void gnc_plugin_aqbanking_class_init(GncPluginAqBankingClass *klass);
+static void gnc_plugin_aqbanking_init(GncPluginAqBanking *plugin);
+static void gnc_plugin_aqbanking_add_to_window(GncPlugin *plugin, GncMainWindow *window, GQuark type);
+static void gnc_plugin_aqbanking_remove_from_window(GncPlugin *plugin, GncMainWindow *window, GQuark type);
+
+/* Object callbacks */
+static void gnc_plugin_ab_main_window_page_added(GncMainWindow *window, GncPluginPage *page, gpointer user_data);
+static void gnc_plugin_ab_main_window_page_changed(GncMainWindow *window, GncPluginPage *page, gpointer user_data);
+static void gnc_plugin_ab_account_selected(GncPluginPage *plugin_page, Account *account, gpointer user_data);
+
+/* Auxiliary functions */
+static Account *main_window_to_account(GncMainWindow *window);
+
+/* Command callbacks */
+static void gnc_plugin_ab_cmd_setup(GtkAction *action, GncMainWindowActionData *data);
+static void gnc_plugin_ab_cmd_get_balance(GtkAction *action, GncMainWindowActionData *data);
+static void gnc_plugin_ab_cmd_get_transactions(GtkAction *action, GncMainWindowActionData *data);
+static void gnc_plugin_ab_cmd_issue_transaction(GtkAction *action, GncMainWindowActionData *data);
+static void gnc_plugin_ab_cmd_issue_sepatransaction(GtkAction *action, GncMainWindowActionData *data);
+static void gnc_plugin_ab_cmd_issue_inttransaction(GtkAction *action, GncMainWindowActionData *data);
+static void gnc_plugin_ab_cmd_issue_direct_debit(GtkAction *action, GncMainWindowActionData *data);
+static void gnc_plugin_ab_cmd_issue_sepa_direct_debit(GtkAction *action, GncMainWindowActionData *data);
+static void gnc_plugin_ab_cmd_view_logwindow(GtkToggleAction *action, GncMainWindow *window);
+static void gnc_plugin_ab_cmd_mt940_import(GtkAction *action, GncMainWindowActionData *data);
+static void gnc_plugin_ab_cmd_mt942_import(GtkAction *action, GncMainWindowActionData *data);
+static void gnc_plugin_ab_cmd_dtaus_import(GtkAction *action, GncMainWindowActionData *data);
+static void gnc_plugin_ab_cmd_dtaus_importsend(GtkAction *action, GncMainWindowActionData *data);
+
+#define PLUGIN_ACTIONS_NAME "gnc-plugin-aqbanking-actions"
+#define PLUGIN_UI_FILENAME  "gnc-plugin-aqbanking-ui.xml"
+
+#define MENU_TOGGLE_ACTION_AB_VIEW_LOGWINDOW "ABViewLogwindowAction"
+
+
+static GtkActionEntry gnc_plugin_actions [] =
+{
+    /* Menus */
+    { "OnlineActionsAction", NULL, N_("_Online Actions"), NULL, NULL, NULL },
+
+    /* Menu Items */
+    {
+        "ABSetupAction", NULL, N_("_Online Banking Setup..."), NULL,
+        N_("Initial setup of Online Banking access (HBCI, or OFX DirectConnect, using AqBanking)"),
+        G_CALLBACK(gnc_plugin_ab_cmd_setup)
+    },
+    {
+        "ABGetBalanceAction", NULL, N_("Get _Balance"), NULL,
+        N_("Get the account balance online through Online Banking"),
+        G_CALLBACK(gnc_plugin_ab_cmd_get_balance)
+    },
+    {
+        "ABGetTransAction", NULL, N_("Get _Transactions..."), NULL,
+        N_("Get the transactions online through Online Banking"),
+        G_CALLBACK(gnc_plugin_ab_cmd_get_transactions)
+    },
+    {
+        "ABIssueTransAction", NULL, N_("_Issue Transaction..."), NULL,
+        N_("Issue a new transaction online through Online Banking"),
+        G_CALLBACK(gnc_plugin_ab_cmd_issue_transaction)
+    },
+    {
+        "ABIssueSepaTransAction", NULL, N_("_Issue SEPA Transaction..."), NULL,
+        N_("Issue a new international European (SEPA) transaction online through Online Banking"),
+        G_CALLBACK(gnc_plugin_ab_cmd_issue_sepatransaction)
+    },
+    {
+        "ABIssueIntTransAction", NULL, N_("I_nternal Transaction..."), NULL,
+        N_("Issue a new bank-internal transaction online through Online Banking"),
+        G_CALLBACK(gnc_plugin_ab_cmd_issue_inttransaction)
+    },
+    {
+        "ABIssueDirectDebitAction", NULL, N_("_Direct Debit..."), NULL,
+        N_("Issue a new direct debit note online through Online Banking"),
+        G_CALLBACK(gnc_plugin_ab_cmd_issue_direct_debit)
+    },
+    {
+        "ABIssueSepaDirectDebitAction", NULL, N_("_Issue SEPA Direct Debit..."), NULL,
+        N_("Issue a new international European (SEPA) direct debit note online through Online Banking"),
+        G_CALLBACK(gnc_plugin_ab_cmd_issue_sepa_direct_debit)
+    },
+
+    /* File -> Import menu item */
+    {
+        "Mt940ImportAction", GTK_STOCK_CONVERT, N_("Import _MT940"), NULL,
+        N_("Import a MT940 file into GnuCash"),
+        G_CALLBACK(gnc_plugin_ab_cmd_mt940_import)
+    },
+    {
+        "Mt942ImportAction", GTK_STOCK_CONVERT, N_("Import MT94_2"), NULL,
+        N_("Import a MT942 file into GnuCash"),
+        G_CALLBACK(gnc_plugin_ab_cmd_mt942_import)
+    },
+    {
+        "DtausImportAction", GTK_STOCK_CONVERT, N_("Import _DTAUS"), NULL,
+        N_("Import a DTAUS file into GnuCash"),
+        G_CALLBACK(gnc_plugin_ab_cmd_dtaus_import)
+    },
+    /* #ifdef CSV_IMPORT_FUNCTIONAL */
+    /*     { "CsvImportAction", GTK_STOCK_CONVERT, N_("Import _CSV"), NULL, */
+    /*       N_("Import a CSV file into GnuCash"), */
+    /*       G_CALLBACK(gnc_plugin_ab_cmd_csv_import) }, */
+    /*     { "CsvImportSendAction", GTK_STOCK_CONVERT, N_("Import CSV and s_end..."), NULL, */
+    /*       N_("Import a CSV file into GnuCash and send the transfers online through Online Banking"), */
+    /*       G_CALLBACK(gnc_plugin_ab_cmd_csv_importsend) }, */
+    /* #endif */
+    {
+        "DtausImportSendAction", GTK_STOCK_CONVERT, N_("Import DTAUS and _send..."), NULL,
+        N_("Import a DTAUS file into GnuCash and send the transfers online through Online Banking"),
+        G_CALLBACK(gnc_plugin_ab_cmd_dtaus_importsend)
+    },
+};
+static guint gnc_plugin_n_actions = G_N_ELEMENTS(gnc_plugin_actions);
+
+static GtkToggleActionEntry gnc_plugin_toggle_actions [] =
+{
+    {
+        MENU_TOGGLE_ACTION_AB_VIEW_LOGWINDOW, NULL,
+        N_("Show _log window"), NULL,
+        N_("Show the online banking log window."),
+        G_CALLBACK(gnc_plugin_ab_cmd_view_logwindow), TRUE
+    },
+};
+static guint gnc_plugin_n_toggle_actions = G_N_ELEMENTS(gnc_plugin_toggle_actions);
+
+static const gchar *need_account_actions[] =
+{
+    "ABGetBalanceAction",
+    "ABGetTransAction",
+    "ABIssueTransAction",
+    "ABIssueSepaTransAction",
+    "ABIssueIntTransAction",
+    "ABIssueDirectDebitAction",
+    "ABIssueSepaDirectDebitAction",
+    NULL
+};
+
+static const gchar *readonly_inactive_actions[] =
+{
+    "OnlineActionsAction",
+    "ABSetupAction",
+    NULL
+};
+
+static GncMainWindow *gnc_main_window = NULL;
+
+/************************************************************
+ *                   Object Implementation                  *
+ ************************************************************/
+
+G_DEFINE_TYPE(GncPluginAqBanking, gnc_plugin_aqbanking, GNC_TYPE_PLUGIN)
+
+GncPlugin *
+gnc_plugin_aqbanking_new(void)
+{
+    return GNC_PLUGIN(g_object_new(GNC_TYPE_PLUGIN_AQBANKING, (gchar*) NULL));
+}
+
+static void
+gnc_plugin_aqbanking_class_init(GncPluginAqBankingClass *klass)
+{
+    GncPluginClass *plugin_class = GNC_PLUGIN_CLASS(klass);
+
+    /* plugin info */
+    plugin_class->plugin_name  = GNC_PLUGIN_AQBANKING_NAME;
+
+    /* widget addition/removal */
+    plugin_class->actions_name       = PLUGIN_ACTIONS_NAME;
+    plugin_class->actions            = gnc_plugin_actions;
+    plugin_class->n_actions          = gnc_plugin_n_actions;
+    plugin_class->toggle_actions     = gnc_plugin_toggle_actions;
+    plugin_class->n_toggle_actions   = gnc_plugin_n_toggle_actions;
+    plugin_class->ui_filename        = PLUGIN_UI_FILENAME;
+    plugin_class->add_to_window      = gnc_plugin_aqbanking_add_to_window;
+    plugin_class->remove_from_window = gnc_plugin_aqbanking_remove_from_window;
+}
+
+static void
+gnc_plugin_aqbanking_init(GncPluginAqBanking *plugin)
+{
+}
+
+/**
+ * Called when this plugin is added to a main window.  Connect a few callbacks
+ * here to track page changes.
+ */
+static void
+gnc_plugin_aqbanking_add_to_window(GncPlugin *plugin, GncMainWindow *window,
+                                   GQuark type)
+{
+    GtkAction *action;
+
+    gnc_main_window = window;
+
+    g_signal_connect(window, "page_added",
+                     G_CALLBACK(gnc_plugin_ab_main_window_page_added),
+                     plugin);
+    g_signal_connect(window, "page_changed",
+                     G_CALLBACK(gnc_plugin_ab_main_window_page_changed),
+                     plugin);
+
+    action = gnc_main_window_find_action(window, MENU_TOGGLE_ACTION_AB_VIEW_LOGWINDOW);
+
+    gtk_toggle_action_set_active(GTK_TOGGLE_ACTION(action), FALSE);
+}
+
+static void
+gnc_plugin_aqbanking_remove_from_window(GncPlugin *plugin, GncMainWindow *window,
+                                        GQuark type)
+{
+    g_signal_handlers_disconnect_by_func(
+        window, G_CALLBACK(gnc_plugin_ab_main_window_page_changed), plugin);
+    g_signal_handlers_disconnect_by_func(
+        window, G_CALLBACK(gnc_plugin_ab_main_window_page_added), plugin);
+}
+
+/************************************************************
+ *                     Object Callbacks                     *
+ ************************************************************/
+
+/**
+ * A new page has been added to a main window.  Connect a signal to it so that
+ * we can track when accounts are selected.
+ */
+static void
+gnc_plugin_ab_main_window_page_added(GncMainWindow *window, GncPluginPage *page,
+                                     gpointer user_data)
+{
+    const gchar *page_name;
+
+    ENTER("main window %p, page %p", window, page);
+    if (!GNC_IS_PLUGIN_PAGE(page))
+    {
+        LEAVE("no plugin_page");
+        return;
+    }
+
+    page_name = gnc_plugin_page_get_plugin_name(page);
+    if (!page_name)
+    {
+        LEAVE("no page_name of plugin_page");
+        return;
+    }
+
+    if (strcmp(page_name, GNC_PLUGIN_PAGE_ACCOUNT_TREE_NAME) == 0)
+    {
+        DEBUG("account tree page, adding signal");
+        g_signal_connect(page, "account_selected",
+                         G_CALLBACK(gnc_plugin_ab_account_selected), NULL);
+    }
+
+    gnc_plugin_ab_main_window_page_changed(window, page, user_data);
+
+    LEAVE(" ");
+}
+
+/** Update the actions sensitivity
+*/
+static void update_inactive_actions(GncPluginPage *plugin_page)
+{
+    GncMainWindow  *window;
+    GtkActionGroup *action_group;
+
+    // We are readonly - so we have to switch particular actions to inactive.
+    gboolean is_readwrite = !qof_book_is_readonly(gnc_get_current_book());
+
+    // We continue only if the current page is a plugin page
+    if (!plugin_page || !GNC_IS_PLUGIN_PAGE(plugin_page))
+        return;
+
+    window = GNC_MAIN_WINDOW(plugin_page->window);
+    g_return_if_fail(GNC_IS_MAIN_WINDOW(window));
+    action_group = gnc_main_window_get_action_group(window, PLUGIN_ACTIONS_NAME);
+    g_return_if_fail(GTK_IS_ACTION_GROUP(action_group));
+
+    /* Set the action's sensitivity */
+    gnc_plugin_update_actions (action_group, readonly_inactive_actions,
+                               "sensitive", is_readwrite);
+}
+
+
+/**
+ * Whenever the current page has changed, update the aqbanking menus based upon
+ * the page that is currently selected.
+ */
+static void
+gnc_plugin_ab_main_window_page_changed(GncMainWindow *window,
+                                       GncPluginPage *page, gpointer user_data)
+{
+    Account *account = main_window_to_account(window);
+
+    /* Make sure not to call this with a NULL GncPluginPage */
+    if (page)
+    {
+        // Update the menu items according to the selected account
+        gnc_plugin_ab_account_selected(page, account, user_data);
+
+        // Also update the action sensitivity due to read-only
+        update_inactive_actions(page);
+    }
+}
+
+/**
+ * An account had been (de)selected either in an "account tree" page or by
+ * selecting another register page. Update the aqbanking menus appropriately.
+ */
+static void
+gnc_plugin_ab_account_selected(GncPluginPage *plugin_page, Account *account,
+                               gpointer user_data)
+{
+    GncMainWindow  *window;
+    GtkActionGroup *action_group;
+    const gchar *bankcode = NULL;
+    const gchar *accountid = NULL;
+
+    g_return_if_fail(GNC_IS_PLUGIN_PAGE(plugin_page));
+    window = GNC_MAIN_WINDOW(plugin_page->window);
+    g_return_if_fail(GNC_IS_MAIN_WINDOW(window));
+    action_group = gnc_main_window_get_action_group(window, PLUGIN_ACTIONS_NAME);
+    g_return_if_fail(GTK_IS_ACTION_GROUP(action_group));
+
+    if (account)
+    {
+        bankcode = gnc_ab_get_account_bankcode(account);
+        accountid = gnc_ab_get_account_accountid(account);
+
+        gnc_plugin_update_actions(action_group, need_account_actions,
+                                  "sensitive",
+                                  (account && bankcode && *bankcode
+                                   && accountid && *accountid));
+        gnc_plugin_update_actions(action_group, need_account_actions,
+                                  "visible", TRUE);
+    }
+    else
+    {
+        gnc_plugin_update_actions(action_group, need_account_actions,
+                                  "sensitive", FALSE);
+        gnc_plugin_update_actions(action_group, need_account_actions,
+                                  "visible", FALSE);
+    }
+
+}
+
+/************************************************************
+ *                    Auxiliary Functions                   *
+ ************************************************************/
+
+/**
+ * Given a pointer to a main window, try and extract an Account from it.  If the
+ * current page is an "account tree" page, get the account corresponding to the
+ * selected account.  (What if multiple accounts are selected?)  If the current
+ * page is a "register" page, get the head account for the register. (Returns
+ * NULL for a general ledger or search register.)
+ *
+ * @param window A pointer to a GncMainWindow object.
+ * @return A pointer to an account, if one can be determined from the current
+ * page. NULL otherwise.
+ */
+static Account *
+main_window_to_account(GncMainWindow *window)
+{
+    GncPluginPage  *page;
+    const gchar    *page_name;
+    Account        *account = NULL;
+    const gchar    *account_name;
+
+    ENTER("main window %p", window);
+    if (!GNC_IS_MAIN_WINDOW(window))
+    {
+        LEAVE("no main_window");
+        return NULL;
+    }
+
+    page = gnc_main_window_get_current_page(window);
+    if (!GNC_IS_PLUGIN_PAGE(page))
+    {
+        LEAVE("no plugin_page");
+        return NULL;
+    }
+    page_name = gnc_plugin_page_get_plugin_name(page);
+    if (!page_name)
+    {
+        LEAVE("no page_name of plugin_page");
+        return NULL;
+    }
+
+    if (strcmp(page_name, GNC_PLUGIN_PAGE_REGISTER_NAME) == 0)
+    {
+        DEBUG("register page");
+        account = gnc_plugin_page_register_get_account(
+                      GNC_PLUGIN_PAGE_REGISTER(page));
+    }
+    else if (strcmp(page_name, GNC_PLUGIN_PAGE_REGISTER2_NAME) == 0)
+    {
+        DEBUG("register2 page");
+        account = gnc_plugin_page_register2_get_account(
+                      GNC_PLUGIN_PAGE_REGISTER2(page));
+    }
+    else if (strcmp(page_name, GNC_PLUGIN_PAGE_ACCOUNT_TREE_NAME) == 0)
+    {
+        DEBUG("account tree page");
+        account = gnc_plugin_page_account_tree_get_current_account(
+                      GNC_PLUGIN_PAGE_ACCOUNT_TREE(page));
+    }
+    else
+    {
+        account = NULL;
+    }
+    account_name = account ? xaccAccountGetName(account) : NULL;
+    LEAVE("account %s(%p)", account_name ? account_name : "(null)", account);
+    return account;
+}
+
+void
+gnc_plugin_aqbanking_set_logwindow_visible(gboolean logwindow_visible)
+{
+    GtkAction *action;
+
+    action = gnc_main_window_find_action(gnc_main_window,
+                                         MENU_TOGGLE_ACTION_AB_VIEW_LOGWINDOW);
+    if (action)
+    {
+        gtk_toggle_action_set_active(GTK_TOGGLE_ACTION(action),
+                                     logwindow_visible);
+    }
+}
+
+/************************************************************
+ *                    Command Callbacks                     *
+ ************************************************************/
+
+static void
+gnc_plugin_ab_cmd_setup(GtkAction *action, GncMainWindowActionData *data)
+{
+    ENTER("action %p, main window data %p", action, data);
+    gnc_main_window = data->window;
+    gnc_ab_initial_assistant();
+    LEAVE(" ");
+}
+
+static void
+gnc_plugin_ab_cmd_get_balance(GtkAction *action, GncMainWindowActionData *data)
+{
+    Account *account;
+
+    ENTER("action %p, main window data %p", action, data);
+    account = main_window_to_account(data->window);
+    if (account == NULL)
+    {
+        g_message("No AqBanking account selected");
+        LEAVE("no account");
+        return;
+    }
+
+    gnc_main_window = data->window;
+    gnc_ab_getbalance(GTK_WIDGET(data->window), account);
+
+    LEAVE(" ");
+}
+
+static void
+gnc_plugin_ab_cmd_get_transactions(GtkAction *action,
+                                   GncMainWindowActionData *data)
+{
+    Account *account;
+
+    ENTER("action %p, main window data %p", action, data);
+    account = main_window_to_account(data->window);
+    if (account == NULL)
+    {
+        g_message("No AqBanking account selected");
+        LEAVE("no account");
+        return;
+    }
+
+    gnc_main_window = data->window;
+    gnc_ab_gettrans(GTK_WIDGET(data->window), account);
+
+    LEAVE(" ");
+}
+
+static void
+gnc_plugin_ab_cmd_issue_transaction(GtkAction *action,
+                                    GncMainWindowActionData *data)
+{
+    Account *account;
+
+    ENTER("action %p, main window data %p", action, data);
+    account = main_window_to_account(data->window);
+    if (account == NULL)
+    {
+        g_message("No AqBanking account selected");
+        LEAVE("no account");
+        return;
+    }
+
+    gnc_main_window = data->window;
+    gnc_ab_maketrans(GTK_WIDGET(data->window), account, SINGLE_TRANSFER);
+
+    LEAVE(" ");
+}
+
+static void
+gnc_plugin_ab_cmd_issue_sepatransaction(GtkAction *action,
+                                    GncMainWindowActionData *data)
+{
+    Account *account;
+
+    ENTER("action %p, main window data %p", action, data);
+    account = main_window_to_account(data->window);
+    if (account == NULL)
+    {
+        g_message("No AqBanking account selected");
+        LEAVE("no account");
+        return;
+    }
+
+    gnc_main_window = data->window;
+    gnc_ab_maketrans(GTK_WIDGET(data->window), account, SEPA_TRANSFER);
+
+    LEAVE(" ");
+}
+
+static void
+gnc_plugin_ab_cmd_issue_inttransaction(GtkAction *action,
+                                       GncMainWindowActionData *data)
+{
+    Account *account;
+
+    ENTER("action %p, main window data %p", action, data);
+    account = main_window_to_account(data->window);
+    if (account == NULL)
+    {
+        g_message("No AqBanking account selected");
+        LEAVE("no account");
+        return;
+    }
+
+    gnc_main_window = data->window;
+    gnc_ab_maketrans(GTK_WIDGET(data->window), account,
+                     SINGLE_INTERNAL_TRANSFER);
+
+    LEAVE(" ");
+}
+
+static void
+gnc_plugin_ab_cmd_issue_direct_debit(GtkAction *action,
+                                     GncMainWindowActionData *data)
+{
+    Account *account;
+
+    ENTER("action %p, main window data %p", action, data);
+    account = main_window_to_account(data->window);
+    if (account == NULL)
+    {
+        g_message("No AqBanking account selected");
+        LEAVE("no account");
+        return;
+    }
+
+    gnc_main_window = data->window;
+    gnc_ab_maketrans(GTK_WIDGET(data->window), account, SINGLE_DEBITNOTE);
+
+    LEAVE(" ");
+}
+
+static void
+gnc_plugin_ab_cmd_issue_sepa_direct_debit(GtkAction *action,
+                                          GncMainWindowActionData *data)
+{
+    Account *account;
+
+    ENTER("action %p, main window data %p", action, data);
+    account = main_window_to_account(data->window);
+    if (account == NULL)
+    {
+        g_message("No AqBanking account selected");
+        LEAVE("no account");
+        return;
+    }
+
+    gnc_main_window = data->window;
+    gnc_ab_maketrans(GTK_WIDGET(data->window), account, SEPA_DEBITNOTE);
+
+    LEAVE(" ");
+}
+
+static void
+gnc_plugin_ab_cmd_view_logwindow(GtkToggleAction *action, GncMainWindow *window)
+{
+    if (gtk_toggle_action_get_active(GTK_TOGGLE_ACTION(action)))
+    {
+        if (!gnc_GWEN_Gui_show_dialog())
+        {
+            /* Log window could not be made visible */
+            gtk_toggle_action_set_active(GTK_TOGGLE_ACTION(action), FALSE);
+        }
+    }
+    else
+    {
+        gnc_GWEN_Gui_hide_dialog();
+    }
+}
+
+
+static void
+gnc_plugin_ab_cmd_mt940_import(GtkAction *action, GncMainWindowActionData *data)
+{
+    gchar *format = gnc_prefs_get_string(GNC_PREFS_GROUP_AQBANKING,
+                                         GNC_PREF_FORMAT_SWIFT940);
+    gnc_main_window = data->window;
+    gnc_file_aqbanking_import("swift", format ? format : "swift-mt940", FALSE);
+    g_free(format);
+}
+
+static void
+gnc_plugin_ab_cmd_mt942_import(GtkAction *action, GncMainWindowActionData *data)
+{
+    gchar *format = gnc_prefs_get_string(GNC_PREFS_GROUP_AQBANKING,
+                                         GNC_PREF_FORMAT_SWIFT942);
+    gnc_main_window = data->window;
+    gnc_file_aqbanking_import("swift", format ? format : "swift-mt942", FALSE);
+    g_free(format);
+}
+
+static void
+gnc_plugin_ab_cmd_dtaus_import(GtkAction *action, GncMainWindowActionData *data)
+{
+    gchar *format = gnc_prefs_get_string(GNC_PREFS_GROUP_AQBANKING,
+                                         GNC_PREF_FORMAT_DTAUS);
+    gnc_main_window = data->window;
+    gnc_file_aqbanking_import("dtaus", format ? format : "default", FALSE);
+    g_free(format);
+}
+
+static void
+gnc_plugin_ab_cmd_dtaus_importsend(GtkAction *action,
+                                   GncMainWindowActionData *data)
+{
+    gchar *format = gnc_prefs_get_string(GNC_PREFS_GROUP_AQBANKING,
+                                         GNC_PREF_FORMAT_DTAUS);
+    gnc_main_window = data->window;
+    gnc_file_aqbanking_import("dtaus", format ? format : "default", TRUE);
+    g_free(format);
+}
+
+/************************************************************
+ *                    Plugin Bootstrapping                  *
+ ************************************************************/
+
+void
+gnc_plugin_aqbanking_create_plugin(void)
+{
+    GncPlugin *plugin = gnc_plugin_aqbanking_new();
+
+    gnc_plugin_manager_add_plugin(gnc_plugin_manager_get(), plugin);
+}

Copied: gnucash/trunk/src/import-export/aqb/gnc-plugin-aqbanking.h (from rev 23566, gnucash/trunk/src/import-export/aqbanking/gnc-plugin-aqbanking.h)
===================================================================
--- gnucash/trunk/src/import-export/aqb/gnc-plugin-aqbanking.h	                        (rev 0)
+++ gnucash/trunk/src/import-export/aqb/gnc-plugin-aqbanking.h	2013-12-15 17:21:20 UTC (rev 23567)
@@ -0,0 +1,90 @@
+/*
+ * gnc-plugin-aqbanking.h --
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, contact:
+ *
+ * Free Software Foundation           Voice:  +1-617-542-5942
+ * 51 Franklin Street, Fifth Floor    Fax:    +1-617-542-2652
+ * Boston, MA  02110-1301,  USA       gnu at gnu.org
+ */
+
+/**
+ * @addtogroup Import_Export
+ * @{
+ * @addtogroup AqBanking
+ * @{
+ * @file gnc-plugin-aqbanking.h
+ * @brief Plugin registration of the AqBanking module
+ * @author Copyright (C) 2003 David Hampton <hampton at employees.org>
+ * @author Copyright (C) 2008 Andreas Koehler <andi5.py at gmx.net>
+ */
+
+#ifndef GNC_PLUGIN_AQBANKING_H
+#define GNC_PLUGIN_AQBANKING_H
+
+#include <glib.h>
+
+#include "gnc-plugin.h"
+
+G_BEGIN_DECLS
+
+/* type macros */
+#define GNC_TYPE_PLUGIN_AQBANKING            (gnc_plugin_aqbanking_get_type())
+#define GNC_PLUGIN_AQBANKING(obj)            (G_TYPE_CHECK_INSTANCE_CAST((obj), GNC_TYPE_PLUGIN_AQBANKING, GncPluginAqBanking))
+#define GNC_PLUGIN_AQBANKING_CLASS(klass)    (G_TYPE_CHECK_CLASS_CAST((klass), GNC_TYPE_PLUGIN_AQBANKING, GncPluginAqBankingClass))
+#define GNC_IS_PLUGIN_AQBANKING(obj)         (G_TYPE_CHECK_INSTANCE_TYPE((obj), GNC_TYPE_PLUGIN_AQBANKING))
+#define GNC_IS_PLUGIN_AQBANKING_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), GNC_TYPE_PLUGIN_AQBANKING))
+#define GNC_PLUGIN_AQBANKING_GET_CLASS(obj)  (G_TYPE_INSTANCE_GET_CLASS((obj), GNC_TYPE_PLUGIN_AQBANKING, GncPluginAqBankingClass))
+
+#define GNC_PLUGIN_AQBANKING_NAME "gnc-plugin-aqbanking"
+
+/* typedefs & structures */
+typedef struct
+{
+    GncPlugin gnc_plugin;
+} GncPluginAqBanking;
+
+typedef struct
+{
+    GncPluginClass gnc_plugin;
+} GncPluginAqBankingClass;
+
+/* function prototypes */
+
+/**
+ * @return The glib runtime type of an aqbanking plugin page
+ **/
+GType gnc_plugin_aqbanking_get_type(void);
+
+/**
+ * @return A new GncPluginAqBanking object
+ */
+GncPlugin* gnc_plugin_aqbanking_new(void);
+
+/**
+ * Create a new GncPluginAqBanking object and register it.
+ */
+void gnc_plugin_aqbanking_create_plugin(void);
+
+/**
+ * Set MENU_TOGGLE_ACTION_AB_VIEW_LOGWINDOW
+ */
+void gnc_plugin_aqbanking_set_logwindow_visible(gboolean logwindow_visible);
+
+G_END_DECLS
+
+/** @} */
+/** @} */
+
+#endif /* GNC_PLUGIN_AQBANKING_H */

Copied: gnucash/trunk/src/import-export/aqb/gncmod-aqbanking.c (from rev 23566, gnucash/trunk/src/import-export/aqbanking/gncmod-aqbanking.c)
===================================================================
--- gnucash/trunk/src/import-export/aqb/gncmod-aqbanking.c	                        (rev 0)
+++ gnucash/trunk/src/import-export/aqb/gncmod-aqbanking.c	2013-12-15 17:21:20 UTC (rev 23567)
@@ -0,0 +1,97 @@
+/*
+ * gncmod-aqbanking.c --
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, contact:
+ *
+ * Free Software Foundation           Voice:  +1-617-542-5942
+ * 51 Franklin Street, Fifth Floor    Fax:    +1-617-542-2652
+ * Boston, MA  02110-1301,  USA       gnu at gnu.org
+ */
+
+/**
+ * @internal
+ * @file gncmod-aqbanking.c
+ * @brief Module definition/initialization for AqBanking support
+ * @author Copyright (C) 2002 Christian Stimming <stimming at tuhh.de>
+ * @author Copyright (C) 2008 Andreas Koehler <andi5.py at gmx.net>
+ */
+
+#include "config.h"
+#include <glib/gi18n.h>
+
+#include "gnc-ab-utils.h"
+#include "gnc-module.h"
+#include "gnc-module-api.h"
+#include "gnc-plugin-aqbanking.h"
+#include "dialog-preferences.h"
+
+GNC_MODULE_API_DECL(libgncmod_aqbanking)
+
+/* version of the gnc module system interface we require */
+gint libgncmod_aqbanking_gnc_module_system_interface = 0;
+
+/* module versioning uses libtool semantics. */
+gint libgncmod_aqbanking_gnc_module_current  = 0;
+gint libgncmod_aqbanking_gnc_module_revision = 0;
+gint libgncmod_aqbanking_gnc_module_age      = 0;
+
+gchar *
+libgncmod_aqbanking_gnc_module_path(void)
+{
+    return g_strdup("gnucash/import-export/aqbanking");
+}
+
+gchar *
+libgncmod_aqbanking_gnc_module_description(void)
+{
+    return g_strdup("Support for Online Banking protocols");
+}
+
+gint
+libgncmod_aqbanking_gnc_module_init(gint refcount)
+{
+    /* Load modules we depend on */
+    if (!gnc_module_load("gnucash/engine", 0)
+            || !gnc_module_load("gnucash/app-utils", 0)
+            || !gnc_module_load("gnucash/gnome-utils", 0)
+            || !gnc_module_load("gnucash/import-export", 0))
+    {
+        return FALSE;
+    }
+
+    /* Add menu items with C callbacks */
+    gnc_plugin_aqbanking_create_plugin();
+
+
+    /* Add AqBanking preferences to the preferences dialog */
+    gnc_preferences_add_to_page("dialog-ab.glade", "aqbanking_prefs",
+                                _("Online Banking"));
+
+    /* Initialize gwen library */
+    gnc_GWEN_Init();
+
+    return 1;
+}
+
+gint
+libgncmod_aqbanking_gnc_module_end(gint refcount)
+{
+    /* Delete the shared AB_BANKING object */
+    gnc_AB_BANKING_delete(NULL);
+
+    /* Finalize gwen library */
+    gnc_GWEN_Fini();
+
+    return 1;
+}

Copied: gnucash/trunk/src/import-export/aqb/gschemas/Makefile.am (from rev 23566, gnucash/trunk/src/import-export/aqbanking/gschemas/Makefile.am)
===================================================================
--- gnucash/trunk/src/import-export/aqb/gschemas/Makefile.am	                        (rev 0)
+++ gnucash/trunk/src/import-export/aqb/gschemas/Makefile.am	2013-12-15 17:21:20 UTC (rev 23567)
@@ -0,0 +1,10 @@
+ at INTLTOOL_XML_NOMERGE_RULE@
+
+gschema_in_files = \
+  org.gnucash.dialogs.import.hbci.gschema.xml.in
+
+gsettings_SCHEMAS = $(gschema_in_files:.gschema.xml.in=.gschema.xml)
+
+ at GSETTINGS_RULES@
+
+CLEANFILES = $(gsettings_SCHEMAS)

Copied: gnucash/trunk/src/import-export/aqb/gschemas/org.gnucash.dialogs.import.hbci.gschema.xml.in.in (from rev 23566, gnucash/trunk/src/import-export/aqbanking/gschemas/org.gnucash.dialogs.import.hbci.gschema.xml.in.in)
===================================================================
--- gnucash/trunk/src/import-export/aqb/gschemas/org.gnucash.dialogs.import.hbci.gschema.xml.in.in	                        (rev 0)
+++ gnucash/trunk/src/import-export/aqb/gschemas/org.gnucash.dialogs.import.hbci.gschema.xml.in.in	2013-12-15 17:21:20 UTC (rev 23567)
@@ -0,0 +1,65 @@
+<schemalist gettext-domain="@GETTEXT_PACKAGE@">
+  <schema id="org.gnucash.dialogs.ab-initial" path="/org/gnucash/dialogs/ab-initial/">
+    <key name="last-geometry" type="(iiii)">
+      <default>(-1,-1,-1,-1)</default>
+      <summary>Last window position and size</summary>
+      <description>This setting describes the size and position of the window when it was last closed.
+        The numbers are the X and Y coordinates of the top left corner of the window
+        followed by the width and height of the window.</description>
+    </key>
+  </schema>
+
+  <schema id="org.gnucash.dialogs.import.hbci" path="/org/gnucash/dialogs/import/hbci/">
+    <key name="close-on-finish" type="b">
+      <default>true</default>
+      <summary>Close window when finished</summary>
+      <description>If active, the window will be closed automatically when you finish the HBCI/AqBanking import process. Otherwise it will stay open.</description>
+    </key>
+    <key name="remember-pin" type="b">
+      <default>false</default>
+      <summary>Remember the PIN in memory</summary>
+      <description>If active, the PIN for HBCI/AqBanking actions will be remembered in memory during a session. Otherwise it will have to be entered again each time during a session when it is needed.</description>
+    </key>
+    <key name="verbose-debug" type="b">
+      <default>false</default>
+      <summary>Verbose HBCI debug messages</summary>
+      <description>Enables verbose debug messages for HBCI/AqBanking Online Banking.</description>
+    </key>
+    <key name="format-dtaus" type="s">
+      <default>'default'</default>
+      <summary>DTAUS import data format</summary>
+      <description>This setting specifies the data format when importing DTAUS files.  The AqBanking library offers various import formats (called "profiles") of which you can choose one here.</description>
+    </key>
+    <key name="format-csv" type="s">
+      <default>'default'</default>
+      <summary>CSV import data format</summary>
+      <description>This setting specifies the data format when importing CSV files.  The AqBanking library offers various import formats (called "profiles") of which you can choose one here.</description>
+    </key>
+    <key name="format-swift-mt940" type="s">
+      <default>'swift-mt940'</default>
+      <summary>SWIFT MT940 import data format</summary>
+      <description>This setting specifies the data format when importing SWIFT MT940 files.  The AqBanking library offers various import formats (called "profiles") of which you can choose one here.</description>
+    </key>
+    <key name="format-swift-mt942" type="s">
+      <default>'swift-mt942'</default>
+      <summary>SWIFT MT942 import data format</summary>
+      <description>This setting specifies the data format when importing SWIFT MT942 files.  The AqBanking library offers various import formats (called "profiles") of which you can choose one here.</description>
+    </key>
+    <key name="last-path" type="s">
+      <default>''</default>
+      <summary>Last pathname used</summary>
+      <description>This field contains the last pathname used by this window. It will be used as the initial filename/pathname the next time this window is opened.</description>
+    </key>
+    <child name="connection-dialog" schema="org.gnucash.dialogs.import.hbci.connection-dialog"/>
+  </schema>
+
+  <schema id="org.gnucash.dialogs.import.hbci.connection-dialog" path="/org/gnucash/dialogs/import/hbci/connection-dialog/">
+    <key name="last-geometry" type="(iiii)">
+      <default>(-1,-1,-1,-1)</default>
+      <summary>Last window position and size</summary>
+      <description>This setting describes the size and position of the window when it was last closed.
+        The numbers are the X and Y coordinates of the top left corner of the window
+        followed by the width and height of the window.</description>
+    </key>
+  </schema>
+</schemalist>

Copied: gnucash/trunk/src/import-export/aqb/migratable-prefs-aqbanking.xml (from rev 23566, gnucash/trunk/src/import-export/aqbanking/migratable-prefs-aqbanking.xml)
===================================================================
--- gnucash/trunk/src/import-export/aqb/migratable-prefs-aqbanking.xml	                        (rev 0)
+++ gnucash/trunk/src/import-export/aqb/migratable-prefs-aqbanking.xml	2013-12-15 17:21:20 UTC (rev 23567)
@@ -0,0 +1,45 @@
+  <prefsgroup>
+    <gschemaid>org.gnucash.dialogs.import.hbci</gschemaid>
+    <gconfpath>dialogs-import-hbci.xml</gconfpath>
+    
+    <pref>
+      <gschemaname>close-on-finish</gschemaname>
+      <gschematype>b</gschematype>
+      <gconfkey>close_on_finish</gconfkey>
+    </pref>
+    <pref>
+      <gschemaname>remember-pin</gschemaname>
+      <gschematype>b</gschematype>
+      <gconfkey>remember_pin</gconfkey>
+    </pref>
+    <pref>
+      <gschemaname>verbose-debug</gschemaname>
+      <gschematype>b</gschematype>
+      <gconfkey>verbose_debug</gconfkey>
+    </pref>
+    <pref>
+      <gschemaname>format-dtaus</gschemaname>
+      <gschematype>s</gschematype>
+      <gconfkey>format_dtaus</gconfkey>
+    </pref>
+    <pref>
+      <gschemaname>format-csv</gschemaname>
+      <gschematype>s</gschematype>
+      <gconfkey>format_csv</gconfkey>
+    </pref>
+    <pref>
+      <gschemaname>format-swift-mt940</gschemaname>
+      <gschematype>s</gschematype>
+      <gconfkey>format_swift_mt940</gconfkey>
+    </pref>
+    <pref>
+      <gschemaname>format-swift-mt942</gschemaname>
+      <gschematype>s</gschematype>
+      <gconfkey>format_swift_mt942</gconfkey>
+    </pref>
+    <pref>
+      <gschemaname>last-path</gschemaname>
+      <gschematype>s</gschematype>
+      <gconfkey>last_path</gconfkey>
+    </pref>
+  </prefsgroup>

Deleted: gnucash/trunk/src/import-export/aqbanking/CMakeLists.txt
===================================================================
--- gnucash/trunk/src/import-export/aqbanking/CMakeLists.txt	2013-12-15 17:20:10 UTC (rev 23566)
+++ gnucash/trunk/src/import-export/aqbanking/CMakeLists.txt	2013-12-15 17:21:20 UTC (rev 23567)
@@ -1,41 +0,0 @@
-# CMakeLists.txt for src/import-export/aqbanking
-
-# ############################################################
-
-ADD_DEFINITIONS (-DG_LOG_DOMAIN=\"gnc.import.aqbanking\")
-
-INCLUDE_DIRECTORIES (${GLIB2_INCLUDE_DIRS})
-INCLUDE_DIRECTORIES (${GCONF2_INCLUDE_DIRS})
-#INCLUDE_DIRECTORIES (${LIBINTL_INCLUDE_PATH})
-#INCLUDE_DIRECTORIES (${REGEX_INCLUDE_PATH})
-#INCLUDE_DIRECTORIES (${GUILE_INCLUDE_DIRS})
-INCLUDE_DIRECTORIES (${GWENHYWFAR_INCLUDE_DIRS})
-INCLUDE_DIRECTORIES (${AQBANKING_INCLUDE_DIRS})
-INCLUDE_DIRECTORIES (${CMAKE_BINARY_DIR}/src ) # for config.h
-INCLUDE_DIRECTORIES (${CMAKE_SOURCE_DIR}/lib/libc) # for pow.h
-INCLUDE_DIRECTORIES (${CMAKE_SOURCE_DIR}/src ) # for gnc-ui.h
-INCLUDE_DIRECTORIES (${CMAKE_SOURCE_DIR}/src/libqof/qof) # for qof.h
-INCLUDE_DIRECTORIES (${CMAKE_SOURCE_DIR}/src/gnc-module) # for gnc-module.h
-INCLUDE_DIRECTORIES (${CMAKE_SOURCE_DIR}/src/core-utils) # for gnc-glib-utils.h
-INCLUDE_DIRECTORIES (${CMAKE_SOURCE_DIR}/src/engine)
-INCLUDE_DIRECTORIES (${CMAKE_SOURCE_DIR}/src/app-utils)
-
-SET (libgnc_aqbanking_SOURCES
-  gnc-ab-kvp.c
-#  gnc-ab-utils.c
-#  gnc-gwen-gui.c
-)
-
-# Add dependency on config.h
-SET_SOURCE_FILES_PROPERTIES (${libgnc_aqbanking_SOURCES} PROPERTIES OBJECT_DEPENDS ${CONFIG_H})
-
-SET (libgnc_aqbanking_HEADERS
-  gnc-ab-kvp.h
-#  gnc-ab-utils.h
-#  gnc-gwen-gui.h
-)
-
-ADD_LIBRARY (gnc-aqbanking
-  ${libgnc_aqbanking_SOURCES}
-  ${libgnc_aqbanking_HEADERS}
-  )

Deleted: gnucash/trunk/src/import-export/aqbanking/Makefile.am
===================================================================
--- gnucash/trunk/src/import-export/aqbanking/Makefile.am	2013-12-15 17:20:10 UTC (rev 23566)
+++ gnucash/trunk/src/import-export/aqbanking/Makefile.am	2013-12-15 17:21:20 UTC (rev 23567)
@@ -1,80 +0,0 @@
-SUBDIRS = . gschemas
-
-pkglib_LTLIBRARIES = libgncmod-aqbanking.la
-
-libgncmod_aqbanking_la_SOURCES = \
-  dialog-ab-trans.c \
-  dialog-ab-daterange.c \
-  assistant-ab-initial.c \
-  gnc-ab-getbalance.c \
-  gnc-ab-gettrans.c \
-  gnc-ab-kvp.c \
-  gnc-ab-trans-templ.c \
-  gnc-ab-transfer.c \
-  gnc-ab-utils.c \
-  gnc-file-aqb-import.c \
-  gnc-gwen-gui.c \
-  gnc-plugin-aqbanking.c \
-  gncmod-aqbanking.c
-
-noinst_HEADERS = \
-  dialog-ab-trans.h \
-  dialog-ab-daterange.h \
-  assistant-ab-initial.h \
-  gnc-ab-getbalance.h \
-  gnc-ab-gettrans.h \
-  gnc-ab-kvp.h \
-  gnc-ab-trans-templ.h \
-  gnc-ab-transfer.h \
-  gnc-ab-utils.h \
-  gnc-file-aqb-import.h \
-  gnc-gwen-gui.h \
-  gnc-plugin-aqbanking.h
-
-libgncmod_aqbanking_la_LDFLAGS = -avoid-version
-if OS_WIN32
-libgncmod_aqbanking_la_LDFLAGS += -export-symbols-regex .*
-endif
-libgncmod_aqbanking_la_LIBADD = \
-  ${top_builddir}/src/import-export/libgncmod-generic-import.la \
-  ${top_builddir}/src/gnome/libgnc-gnome.la \
-  ${top_builddir}/src/gnome-utils/libgncmod-gnome-utils.la \
-  ${top_builddir}/src/app-utils/libgncmod-app-utils.la \
-  ${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/libqof/qof/libgnc-qof.la \
-  ${GTK_LIBS} \
-  ${GLIB_LIBS} \
-  ${GWENGUI_GTK2_LIBS} \
-  ${AQBANKING_LIBS}
-
-AM_CPPFLAGS = \
-  -I${top_srcdir}/src \
-  -I${top_srcdir}/src/import-export \
-  -I${top_srcdir}/src/gnome \
-  -I${top_srcdir}/src/register/ledger-core \
-  -I${top_srcdir}/src/register/register-gnome \
-  -I${top_srcdir}/src/register/register-core \
-  -I${top_srcdir}/src/gnome-utils \
-  -I${top_srcdir}/src/app-utils \
-  -I${top_srcdir}/src/engine \
-  -I${top_srcdir}/src/core-utils \
-  -I${top_srcdir}/src/gnc-module \
-  -I${top_srcdir}/src/libqof/qof \
-  ${GTK_CFLAGS} \
-  ${GLIB_CFLAGS} \
-  ${AQBANKING_CFLAGS}
-
-uidir = $(GNC_UI_DIR)
-ui_DATA = \
-  gnc-plugin-aqbanking-ui.xml
-
-gtkbuilderdir = $(GNC_GTKBUILDER_DIR)
-gtkbuilder_DATA = \
-  assistant-ab-initial.glade \
-  dialog-ab.glade
-
-EXTRA_DIST = ${ui_DATA} ${gtkbuilder_DATA} migratable-prefs-aqbanking.xml
-
-AM_CPPFLAGS += -DG_LOG_DOMAIN=\"gnc.import.aqbanking\"

Deleted: gnucash/trunk/src/import-export/aqbanking/assistant-ab-initial.c
===================================================================
--- gnucash/trunk/src/import-export/aqbanking/assistant-ab-initial.c	2013-12-15 17:20:10 UTC (rev 23566)
+++ gnucash/trunk/src/import-export/aqbanking/assistant-ab-initial.c	2013-12-15 17:21:20 UTC (rev 23567)
@@ -1,915 +0,0 @@
-/*
- * assistant-ab-initial.c -- Initialise the AqBanking wizard
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation; either version 2 of
- * the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, contact:
- *
- * Free Software Foundation           Voice:  +1-617-542-5942
- * 51 Franklin Street, Fifth Floor    Fax:    +1-617-542-2652
- * Boston, MA  02110-1301,  USA       gnu at gnu.org
- */
-
-/**
- * @internal
- * @file assistant-ab-initial.c
- * @brief AqBanking setup functionality
- * @author Copyright (C) 2002 Christian Stimming <stimming at tuhh.de>
- * @author Copyright (C) 2006 David Hampton <hampton at employees.org>
- * @author Copyright (C) 2008 Andreas Koehler <andi5.py at gmx.net>
- * @author Copyright (C) 2011 Robert Fewell
- */
-
-#include "config.h"
-
-#include <aqbanking/banking.h>
-#include <glib.h>
-#include <glib/gi18n.h>
-#include <glib/gstdio.h>
-#include <gdk/gdkkeysyms.h>
-#ifdef HAVE_SYS_WAIT_H
-#    include <sys/wait.h>
-#endif
-#include <fcntl.h>
-#include <unistd.h>
-
-#include "dialog-utils.h"
-#include "assistant-ab-initial.h"
-#include "assistant-utils.h"
-#include "gnc-ab-kvp.h"
-#include "gnc-ab-utils.h"
-#include "gnc-component-manager.h"
-#include "gnc-glib-utils.h"
-#include "gnc-ui.h"
-#include "gnc-ui-util.h"
-#include "gnc-session.h"
-#include "import-account-matcher.h"
-
-#if AQBANKING_VERSION_INT > 49908
-/* For aqbanking > 4.99.8. See below. */
-# include <aqbanking/dlg_setup.h>
-#endif
-
-/* This static indicates the debugging module that this .o belongs to.  */
-static QofLogModule log_module = GNC_MOD_ASSISTANT;
-
-#define GNC_PREFS_GROUP "dialogs.ab-initial"
-#define ASSISTANT_AB_INITIAL_CM_CLASS "assistant-ab-initial"
-
-typedef struct _ABInitialInfo ABInitialInfo;
-typedef struct _DeferredInfo DeferredInfo;
-typedef struct _AccCbData AccCbData;
-typedef struct _RevLookupData RevLookupData;
-
-void aai_on_prepare (GtkAssistant  *assistant, GtkWidget *page,
-                     gpointer user_data);
-
-void aai_on_finish (GtkAssistant *gtkassistant, gpointer user_data);
-void aai_on_cancel (GtkAssistant *assistant, gpointer user_data);
-void aai_destroy_cb(GtkObject *object, gpointer user_data);
-
-gboolean aai_key_press_event_cb(GtkWidget *widget, GdkEventKey *event, gpointer user_data);
-
-void aai_wizard_page_prepare (GtkAssistant *assistant, gpointer user_data);
-void aai_wizard_button_clicked_cb(GtkButton *button, gpointer user_data);
-
-void aai_match_page_prepare (GtkAssistant *assistant, gpointer user_data);
-
-static gboolean banking_has_accounts(AB_BANKING *banking);
-static void hash_from_kvp_acc_cb(Account *gnc_acc, gpointer user_data);
-#if AQBANKING_VERSION_INT <= 49908
-static void child_exit_cb(GPid pid, gint status, gpointer data);
-#endif
-static gchar *ab_account_longname(const AB_ACCOUNT *ab_acc);
-static AB_ACCOUNT *update_account_list_acc_cb(AB_ACCOUNT *ab_acc, gpointer user_data);
-static void update_account_list(ABInitialInfo *info);
-static gboolean find_gnc_acc_cb(gpointer key, gpointer value, gpointer user_data);
-static gboolean clear_line_cb(GtkTreeModel *model, GtkTreePath *path, GtkTreeIter *iter, gpointer user_data);
-static void account_list_clicked_cb (GtkTreeView *view, GtkTreePath *path,
-                                     GtkTreeViewColumn  *col, gpointer user_data);
-static void clear_kvp_acc_cb(Account *gnc_acc, gpointer user_data);
-static void save_kvp_acc_cb(gpointer key, gpointer value, gpointer user_data);
-static void aai_close_handler(gpointer user_data);
-
-struct _ABInitialInfo
-{
-    GtkWidget *window;
-    GtkWidget *assistant;
-
-    /* account match page */
-    gboolean match_page_prepared;
-    GtkTreeView *account_view;
-    GtkListStore *account_store;
-
-    /* managed by child_exit_cb */
-    DeferredInfo *deferred_info;
-
-    /* AqBanking stuff */
-    AB_BANKING *api;
-    /* AB_ACCOUNT* -> Account* -- DO NOT DELETE THE KEYS! */
-    GHashTable *gnc_hash;
-};
-
-struct _DeferredInfo
-{
-    ABInitialInfo *initial_info;
-    gchar *wizard_path;
-    gboolean qt_probably_unavailable;
-};
-
-struct _AccCbData
-{
-    AB_BANKING *api;
-    GHashTable *hash;
-};
-
-struct _RevLookupData
-{
-    Account *gnc_acc;
-    AB_ACCOUNT *ab_acc;
-};
-
-enum account_list_cols
-{
-    ACCOUNT_LIST_COL_INDEX = 0,
-    ACCOUNT_LIST_COL_AB_NAME,
-    ACCOUNT_LIST_COL_AB_ACCT,
-    ACCOUNT_LIST_COL_GNC_NAME,
-    ACCOUNT_LIST_COL_CHECKED,
-    NUM_ACCOUNT_LIST_COLS
-};
-
-gboolean
-aai_key_press_event_cb(GtkWidget *widget, GdkEventKey *event, gpointer user_data)
-{
-    if (event->keyval == GDK_Escape)
-    {
-        gtk_widget_destroy(widget);
-        return TRUE;
-    }
-    else
-    {
-        return FALSE;
-    }
-}
-
-void
-aai_on_cancel (GtkAssistant *gtkassistant, gpointer user_data)
-{
-    ABInitialInfo *info = user_data;
-
-    gtk_widget_destroy(info->window);
-}
-
-void
-aai_destroy_cb(GtkObject *object, gpointer user_data)
-{
-    ABInitialInfo *info = user_data;
-
-    gnc_unregister_gui_component_by_data(ASSISTANT_AB_INITIAL_CM_CLASS, info);
-
-    if (info->deferred_info)
-    {
-        g_message("Online Banking assistant is being closed but the wizard is still "
-                  "running.  Inoring.");
-
-        /* Tell child_exit_cb() that there is no assistant anymore */
-        info->deferred_info->initial_info = NULL;
-    }
-
-    if (info->gnc_hash)
-    {
-#ifdef AQBANKING_VERSION_4_EXACTLY
-        AB_Banking_OnlineFini(info->api, 0);
-#else
-        AB_Banking_OnlineFini(info->api);
-#endif
-        g_hash_table_destroy(info->gnc_hash);
-        info->gnc_hash = NULL;
-    }
-
-    if (info->api)
-    {
-        gnc_AB_BANKING_delete(info->api);
-        info->api = NULL;
-    }
-
-    gtk_widget_destroy(info->window);
-    info->window = NULL;
-
-    g_free(info);
-}
-
-void
-aai_wizard_page_prepare (GtkAssistant *assistant, gpointer user_data)
-{
-    ABInitialInfo *info = user_data;
-    gint num = gtk_assistant_get_current_page (assistant);
-    GtkWidget *page = gtk_assistant_get_nth_page (assistant, num);
-
-    g_return_if_fail(info->api);
-
-    /* Enable the Assistant Buttons if we accounts */
-    if (banking_has_accounts(info->api))
-        gtk_assistant_set_page_complete (assistant, page, TRUE);
-    else
-        gtk_assistant_set_page_complete (assistant, page, FALSE);
-}
-
-void
-aai_wizard_button_clicked_cb(GtkButton *button, gpointer user_data)
-{
-    ABInitialInfo *info = user_data;
-    gint num = gtk_assistant_get_current_page (GTK_ASSISTANT(info->window));
-    GtkWidget *page = gtk_assistant_get_nth_page (GTK_ASSISTANT(info->window), num);
-
-    AB_BANKING *banking = info->api;
-#if AQBANKING_VERSION_INT <= 49908
-    GWEN_BUFFER *buf;
-    gboolean wizard_exists;
-    const gchar *wizard_path;
-    gboolean qt_probably_unavailable = FALSE;
-#endif /* AQBANKING_VERSION_INT */
-    g_return_if_fail(banking);
-
-    ENTER("user_data: %p", user_data);
-
-    if (info->deferred_info)
-    {
-        LEAVE("Wizard is still running");
-        return;
-    }
-
-#if AQBANKING_VERSION_INT > 49908
-    /* For aqbanking5 > 4.99.8: Use AB_Banking_GetNewUserDialog(). */
-    {
-        GWEN_DIALOG *dlg =
-            AB_SetupDialog_new(banking);
-
-        if (AB_Banking_OnlineInit(banking) != 0)
-        {
-            PERR("Got error on AB_Banking_OnlineInit!");
-        }
-
-        if (!dlg)
-        {
-            PERR("Could not lookup Setup Dialog of aqbanking!");
-        }
-        else
-        {
-            int rv = GWEN_Gui_ExecDialog(dlg, 0);
-            if (rv <= 0)
-            {
-                /* Dialog was aborted/rejected */
-                PERR("Setup Dialog of aqbanking aborted/rejected !");
-            }
-            GWEN_Dialog_free(dlg);
-        }
-
-        if (AB_Banking_OnlineFini(banking) != 0)
-        {
-            PERR("Got error on AB_Banking_OnlineFini!");
-        }
-    }
-#else
-    /* Previous implementation for aqbanking <= 4.99.8: Use the
-     * external application. */
-
-
-    /* This is the point where we look for and start an external
-     * application shipped with aqbanking that contains the setup assistant
-     * for AqBanking related stuff.  It requires qt (but not kde).  This
-     * application contains the very verbose step-by-step setup wizard
-     * for the AqBanking account, and the application is shared with
-     * other AqBanking-based financial managers that offer the AqBanking
-     * features (e.g. KMyMoney).  See gnucash-devel discussion here
-     * https://lists.gnucash.org/pipermail/gnucash-devel/2004-December/012351.html
-     */
-    buf = GWEN_Buffer_new(NULL, 300, 0, 0);
-    AB_Banking_FindWizard(banking, "", NULL, buf);
-    wizard_exists = *GWEN_Buffer_GetStart(buf) != 0;
-    wizard_path = GWEN_Buffer_GetStart(buf);
-
-    if (wizard_exists)
-    {
-        /* Really check whether the file exists */
-        gint fd = g_open(wizard_path, O_RDONLY, 0);
-        if (fd == -1)
-            wizard_exists = FALSE;
-        else
-            close(fd);
-    }
-
-#ifdef G_OS_WIN32
-    {
-        const char *check_file = "qtdemo.exe";
-        gchar *found_program = g_find_program_in_path(check_file);
-        if (found_program)
-        {
-            g_debug("Yes, we found the Qt demo program in %s\n", found_program);
-            g_free(found_program);
-        }
-        else
-        {
-            g_warning("Ouch, no Qt demo program was found. Qt not installed?\n");
-            qt_probably_unavailable = TRUE;
-        }
-    }
-#endif
-
-    if (wizard_exists)
-    {
-        /* Call the qt wizard. See the note above about why this
-         * approach is chosen. */
-
-        GPid pid;
-        GError *error = NULL;
-        gchar *argv[2];
-        gboolean spawned;
-
-        argv[0] = g_strdup (wizard_path);
-        argv[1] = NULL;
-        spawned = g_spawn_async (NULL, argv, NULL, G_SPAWN_DO_NOT_REAP_CHILD,
-                                 NULL, NULL, &pid, &error);
-        g_free (argv[0]);
-
-        if (error)
-            g_critical(
-                "Error on starting AqBanking setup wizard: Code %d: %s",
-                error->code, error->message ? error->message : "(null)");
-
-        if (!spawned)
-        {
-            g_critical("Could not start AqBanking setup wizard: %s",
-                       error->message ? error->message : "(null)");
-            g_error_free (error);
-        }
-        else
-        {
-            /* Keep a reference to info that can survive info */
-            info->deferred_info = g_new0(DeferredInfo, 1);
-            info->deferred_info->initial_info = info;
-            info->deferred_info->wizard_path = g_strdup(wizard_path);
-            info->deferred_info->qt_probably_unavailable =
-                qt_probably_unavailable;
-
-            g_child_watch_add (pid, child_exit_cb, info->deferred_info);
-        }
-    }
-    else
-    {
-        g_warning("on_aqhbci_button: Oops, no aqhbci setup wizard found.");
-        gnc_error_dialog
-        (info->window,
-         _("The external program \"AqBanking Setup Wizard\" has not "
-           "been found. \n\n"
-           "The %s package should include the "
-           "program \"qt3-wizard\". Please check your installation to "
-           "ensure this program is present. On some distributions this "
-           "may require installing additional packages."),
-         QT3_WIZARD_PACKAGE);
-    }
-
-    GWEN_Buffer_free(buf);
-#endif
-
-    /* Enable the Assistant Buttons if we accounts */
-    if (banking_has_accounts(info->api))
-        gtk_assistant_set_page_complete (GTK_ASSISTANT(info->window), page, TRUE);
-    else
-        gtk_assistant_set_page_complete (GTK_ASSISTANT(info->window), page, FALSE);
-
-    LEAVE(" ");
-}
-
-void
-aai_match_page_prepare (GtkAssistant *assistant, gpointer user_data)
-{
-    ABInitialInfo *info = user_data;
-    gint num = gtk_assistant_get_current_page (assistant);
-    GtkWidget *page = gtk_assistant_get_nth_page (assistant, num);
-
-    Account *root;
-    AccCbData data;
-
-    g_return_if_fail(info && info->api);
-
-    /* Do not run this twice */
-    if (!info->match_page_prepared)
-    {
-        /* Load aqbanking accounts */
-#ifdef AQBANKING_VERSION_4_EXACTLY
-        AB_Banking_OnlineInit(info->api, 0);
-#else
-        AB_Banking_OnlineInit(info->api);
-#endif
-        /* Determine current mapping */
-        root = gnc_book_get_root_account(gnc_get_current_book());
-        info->gnc_hash = g_hash_table_new(&g_direct_hash, &g_direct_equal);
-        data.api = info->api;
-        data.hash = info->gnc_hash;
-        gnc_account_foreach_descendant(
-            root, (AccountCb) hash_from_kvp_acc_cb, &data);
-
-        info->match_page_prepared = TRUE;
-    }
-    /* Update the graphical representation */
-    update_account_list(info);
-
-    /* Enable the Assistant Buttons */
-    gtk_assistant_set_page_complete (assistant, page, TRUE);
-}
-
-void
-aai_on_finish (GtkAssistant *assistant, gpointer user_data)
-{
-    ABInitialInfo *info = user_data;
-    Account *root;
-
-    g_return_if_fail(info && info->gnc_hash);
-
-    /* Commit the changes */
-    root = gnc_book_get_root_account(gnc_get_current_book());
-    gnc_account_foreach_descendant(root, (AccountCb) clear_kvp_acc_cb, NULL);
-    g_hash_table_foreach(info->gnc_hash, (GHFunc) save_kvp_acc_cb, NULL);
-
-    gtk_widget_destroy(info->window);
-}
-
-static gboolean
-banking_has_accounts(AB_BANKING *banking)
-{
-    AB_ACCOUNT_LIST2 *accl;
-    gboolean result;
-
-    g_return_val_if_fail(banking, FALSE);
-
-#ifdef AQBANKING_VERSION_4_EXACTLY
-    AB_Banking_OnlineInit(banking, 0);
-#else
-    AB_Banking_OnlineInit(banking);
-#endif
-
-    accl = AB_Banking_GetAccounts(banking);
-    if (accl && (AB_Account_List2_GetSize(accl) > 0))
-        result = TRUE;
-    else
-        result = FALSE;
-
-    if (accl)
-        AB_Account_List2_free(accl);
-
-#ifdef AQBANKING_VERSION_4_EXACTLY
-    AB_Banking_OnlineFini(banking, 0);
-#else
-    AB_Banking_OnlineFini(banking);
-#endif
-
-    return result;
-}
-
-static void
-hash_from_kvp_acc_cb(Account *gnc_acc, gpointer user_data)
-{
-    AccCbData *data = user_data;
-    AB_ACCOUNT *ab_acc;
-
-    ab_acc = gnc_ab_get_ab_account(data->api, gnc_acc);
-    if (ab_acc)
-        g_hash_table_insert(data->hash, ab_acc, gnc_acc);
-}
-
-#if AQBANKING_VERSION_INT <= 49908
-static void
-child_exit_cb(GPid pid, gint status, gpointer data)
-{
-    DeferredInfo *deferred_info = data;
-    ABInitialInfo *info = deferred_info->initial_info;
-    gint num = gtk_assistant_get_current_page (GTK_ASSISTANT(info->window));
-    GtkWidget *page = gtk_assistant_get_nth_page (GTK_ASSISTANT(info->window), num);
-
-    gint exit_status;
-
-#ifdef G_OS_WIN32
-    exit_status = status;
-#else
-    exit_status = WEXITSTATUS(status);
-#endif
-
-    g_spawn_close_pid(pid);
-
-    if (!info)
-    {
-        g_message("Online Banking wizard exited, but the assistant has been "
-                  "destroyed already");
-        goto cleanup_child_exit_cb;
-    }
-
-    if (exit_status == 0)
-    {
-        gtk_assistant_set_page_complete (GTK_ASSISTANT(info->window), page, TRUE);
-    }
-    else
-    {
-        if (deferred_info->qt_probably_unavailable)
-        {
-            g_warning("on_aqhbci_button: Oops, aqhbci wizard return nonzero "
-                      "value: %d. The called program was \"%s\".\n",
-                      exit_status, deferred_info->wizard_path);
-            gnc_error_dialog
-            (info->window, "%s",
-             _("The external program \"AqBanking Setup Wizard\" failed "
-               "to run successfully because the "
-               "additional software \"Qt\" was not found. "
-               "Please install the \"Qt/Windows Open Source Edition\" "
-               "from Trolltech by downloading it from www.trolltech.com"
-               "\n\n"
-               "If you have installed Qt already, you will have to adapt "
-               "the PATH variable of your system appropriately. "
-               "Contact the GnuCash developers if you need further "
-               "assistance on how to install Qt correctly."
-               "\n\n"
-               "Online Banking cannot be setup without Qt. Press \"Close\" "
-               "now, then \"Cancel\" to cancel the Online Banking setup."));
-        }
-        else
-        {
-            g_warning("on_aqhbci_button: Oops, aqhbci wizard return nonzero "
-                      "value: %d. The called program was \"%s\".\n",
-                      exit_status, deferred_info->wizard_path);
-            gnc_error_dialog
-            (info->window, "%s",
-             _("The external program \"AqBanking Setup Wizard\" failed "
-               "to run successfully. Online Banking can only be setup "
-               "if this wizard has run successfully. "
-               "Please try running the \"AqBanking Setup Wizard\" again."));
-        }
-        gtk_assistant_set_page_complete (GTK_ASSISTANT(info->window), page, FALSE);
-    }
-
-cleanup_child_exit_cb:
-    g_free(deferred_info->wizard_path);
-    g_free(deferred_info);
-    if (info)
-        info->deferred_info = NULL;
-}
-#endif /* AQBANKING_VERSION_INT <= 49908 */
-
-static gchar *
-ab_account_longname(const AB_ACCOUNT *ab_acc)
-{
-    gchar *bankname;
-    gchar *result;
-    const char *ab_bankname, *bankcode;
-
-    g_return_val_if_fail(ab_acc, NULL);
-
-    ab_bankname = AB_Account_GetBankName(ab_acc);
-    bankname = ab_bankname ? gnc_utf8_strip_invalid_strdup(ab_bankname) : NULL;
-    bankcode = AB_Account_GetBankCode(ab_acc);
-
-    /* Translators: Strings are 1. Account code, 2. Bank name, 3. Bank code. */
-    if (bankname && *bankname)
-        result = g_strdup_printf(_("%s at %s (code %s)"),
-                                 AB_Account_GetAccountNumber(ab_acc),
-                                 bankname,
-                                 bankcode);
-    else
-        result = g_strdup_printf(_("%s at bank code %s"),
-                                 AB_Account_GetAccountNumber(ab_acc),
-                                 bankcode);
-    g_free(bankname);
-
-    return result;
-
-}
-
-static AB_ACCOUNT *
-update_account_list_acc_cb(AB_ACCOUNT *ab_acc, gpointer user_data)
-{
-    ABInitialInfo *info = user_data;
-    gchar *gnc_name, *ab_name;
-    Account *gnc_acc;
-    GtkTreeIter iter;
-
-    g_return_val_if_fail(ab_acc && info, NULL);
-
-    ab_name = ab_account_longname(ab_acc);
-
-    /* Get corresponding gnucash account */
-    gnc_acc = g_hash_table_lookup(info->gnc_hash, ab_acc);
-
-    /* Build the text for the gnucash account. */
-    if (gnc_acc)
-        gnc_name = gnc_account_get_full_name(gnc_acc);
-    else
-        gnc_name = g_strdup("");
-
-    /* Add item to the list store */
-    gtk_list_store_append(info->account_store, &iter);
-    gtk_list_store_set(info->account_store, &iter,
-                       ACCOUNT_LIST_COL_AB_NAME, ab_name,
-                       ACCOUNT_LIST_COL_AB_ACCT, ab_acc,
-                       ACCOUNT_LIST_COL_GNC_NAME, gnc_name,
-                       ACCOUNT_LIST_COL_CHECKED, FALSE,
-                       -1);
-    g_free(gnc_name);
-    g_free(ab_name);
-
-    return NULL;
-}
-
-static void
-update_account_list(ABInitialInfo *info)
-{
-    AB_ACCOUNT_LIST2 *acclist;
-
-    g_return_if_fail(info && info->api && info->gnc_hash);
-
-    /* Detach model from view while updating */
-    g_object_ref(info->account_store);
-    gtk_tree_view_set_model(info->account_view, NULL);
-
-    /* Refill the list */
-    gtk_list_store_clear(info->account_store);
-    acclist = AB_Banking_GetAccounts(info->api);
-    if (acclist)
-        AB_Account_List2_ForEach(acclist, update_account_list_acc_cb, info);
-    else
-        g_warning("update_account_list: Oops, account list from AB_Banking "
-                  "is NULL");
-
-    /* Attach model to view again */
-    gtk_tree_view_set_model(info->account_view,
-                            GTK_TREE_MODEL(info->account_store));
-
-    g_object_unref(info->account_store);
-}
-
-static gboolean
-find_gnc_acc_cb(gpointer key, gpointer value, gpointer user_data)
-{
-    RevLookupData *data = user_data;
-
-    g_return_val_if_fail(data, TRUE);
-
-    if (value == data->gnc_acc)
-    {
-        data->ab_acc = (AB_ACCOUNT*) key;
-        return TRUE;
-    }
-    return FALSE;
-}
-
-static gboolean
-clear_line_cb(GtkTreeModel *model, GtkTreePath *path, GtkTreeIter *iter,
-              gpointer user_data)
-{
-    RevLookupData *data = user_data;
-    GtkListStore *store = GTK_LIST_STORE(model);
-    gpointer ab_acc;
-
-    g_return_val_if_fail(data && store, FALSE);
-
-    gtk_tree_model_get(model, iter, ACCOUNT_LIST_COL_AB_ACCT, &ab_acc, -1);
-
-    if (ab_acc == data->ab_acc)
-    {
-        gtk_list_store_set(store, iter, ACCOUNT_LIST_COL_GNC_NAME, "",
-                           ACCOUNT_LIST_COL_CHECKED, TRUE, -1);
-        return TRUE;
-    }
-    return FALSE;
-}
-
-static void
-account_list_clicked_cb (GtkTreeView *view, GtkTreePath *path,
-                         GtkTreeViewColumn  *col, gpointer user_data)
-{
-    ABInitialInfo *info = user_data;
-    GtkTreeModel *model;
-    GtkTreeIter iter;
-    AB_ACCOUNT *ab_acc;
-    gchar *longname, *gnc_name;
-    Account *old_value, *gnc_acc;
-    const gchar *currency;
-    gnc_commodity *commodity = NULL;
-    gboolean ok_pressed;
-
-    g_return_if_fail(info);
-
-    PINFO("Row has been double-clicked.");
-
-    model = gtk_tree_view_get_model(view);
-
-    if (!gtk_tree_model_get_iter(model, &iter, path))
-        return; /* path describes a non-existing row - should not happen */
-
-    gtk_tree_model_get(model, &iter, ACCOUNT_LIST_COL_AB_ACCT, &ab_acc, -1);
-
-    if (ab_acc)
-    {
-        old_value = g_hash_table_lookup(info->gnc_hash, ab_acc);
-
-        longname = ab_account_longname(ab_acc);
-        currency = AB_Account_GetCurrency(ab_acc);
-        if (currency && *currency)
-        {
-            commodity = gnc_commodity_table_lookup(
-                            gnc_commodity_table_get_table(gnc_get_current_book()),
-                            GNC_COMMODITY_NS_CURRENCY,
-                            currency);
-        }
-
-        gnc_acc = gnc_import_select_account(info->window, NULL, TRUE,
-                                            longname, commodity, ACCT_TYPE_BANK,
-                                            old_value, &ok_pressed);
-        g_free(longname);
-
-        if (ok_pressed && old_value != gnc_acc)
-        {
-            if (gnc_acc)
-            {
-                RevLookupData data;
-
-                /* Lookup and clear other mappings to gnc_acc */
-                data.gnc_acc = gnc_acc;
-                data.ab_acc = NULL;
-                g_hash_table_find(info->gnc_hash, (GHRFunc) find_gnc_acc_cb,
-                                  &data);
-                if (data.ab_acc)
-                {
-                    g_hash_table_remove(info->gnc_hash, data.ab_acc);
-                    gtk_tree_model_foreach(
-                        GTK_TREE_MODEL(info->account_store),
-                        (GtkTreeModelForeachFunc) clear_line_cb,
-                        &data);
-                }
-
-                /* Map ab_acc to gnc_acc */
-                g_hash_table_insert(info->gnc_hash, ab_acc, gnc_acc);
-                gnc_name = gnc_account_get_full_name(gnc_acc);
-                gtk_list_store_set(info->account_store, &iter,
-                                   ACCOUNT_LIST_COL_GNC_NAME, gnc_name,
-                                   ACCOUNT_LIST_COL_CHECKED, TRUE,
-                                   -1);
-                g_free(gnc_name);
-
-            }
-            else
-            {
-                g_hash_table_remove(info->gnc_hash, ab_acc);
-                gtk_list_store_set(info->account_store, &iter,
-                                   ACCOUNT_LIST_COL_GNC_NAME, "",
-                                   ACCOUNT_LIST_COL_CHECKED, TRUE,
-                                   -1);
-            }
-        }
-    }
-}
-
-static void
-clear_kvp_acc_cb(Account *gnc_acc, gpointer user_data)
-{
-    if (gnc_ab_get_account_uid(gnc_acc))
-        gnc_ab_set_account_uid(gnc_acc, 0);
-    if (gnc_ab_get_account_accountid(gnc_acc))
-        gnc_ab_set_account_accountid(gnc_acc, "");
-    if (gnc_ab_get_account_bankcode(gnc_acc))
-        gnc_ab_set_account_bankcode(gnc_acc, "");
-}
-
-static void
-save_kvp_acc_cb(gpointer key, gpointer value, gpointer user_data)
-{
-    AB_ACCOUNT *ab_acc = key;
-    Account *gnc_acc = value;
-    guint32 ab_account_uid;
-    const gchar *ab_accountid, *gnc_accountid;
-    const gchar *ab_bankcode, *gnc_bankcode;
-
-    g_return_if_fail(ab_acc && gnc_acc);
-
-    ab_account_uid = AB_Account_GetUniqueId(ab_acc);
-    if (gnc_ab_get_account_uid(gnc_acc) != ab_account_uid)
-        gnc_ab_set_account_uid(gnc_acc, ab_account_uid);
-
-    ab_accountid = AB_Account_GetAccountNumber(ab_acc);
-    gnc_accountid = gnc_ab_get_account_accountid(gnc_acc);
-    if (ab_accountid
-            && (!gnc_accountid
-                || (strcmp(ab_accountid, gnc_accountid) != 0)))
-        gnc_ab_set_account_accountid(gnc_acc, ab_accountid);
-
-    ab_bankcode = AB_Account_GetBankCode(ab_acc);
-    gnc_bankcode = gnc_ab_get_account_bankcode(gnc_acc);
-    if (ab_bankcode
-            && (!gnc_bankcode
-                || (strcmp(gnc_bankcode, ab_bankcode) != 0)))
-        gnc_ab_set_account_bankcode(gnc_acc, ab_bankcode);
-}
-
-static void
-aai_close_handler(gpointer user_data)
-{
-    ABInitialInfo *info = user_data;
-
-    gnc_save_window_size(GNC_PREFS_GROUP, GTK_WINDOW(info->window));
-    gtk_widget_destroy(info->window);
-}
-
-void aai_on_prepare (GtkAssistant  *assistant, GtkWidget *page,
-                     gpointer user_data)
-{
-    switch (gtk_assistant_get_current_page(assistant))
-    {
-    case 1:
-        /* Current page is wizard button page */
-        aai_wizard_page_prepare (assistant , user_data );
-        break;
-    case 2:
-        /* Current page is match page */
-        aai_match_page_prepare (assistant , user_data );
-        break;
-    }
-}
-
-void
-gnc_ab_initial_assistant(void)
-{
-    ABInitialInfo *info;
-    GtkBuilder *builder;
-    GtkTreeViewColumn *column;
-    GtkTreeSelection *selection;
-    gint component_id;
-
-    info = g_new0(ABInitialInfo, 1);
-    builder = gtk_builder_new();
-    gnc_builder_add_from_file (builder, "assistant-ab-initial.glade", "AqBanking Init Assistant");
-
-    info->window = GTK_WIDGET(gtk_builder_get_object (builder, "AqBanking Init Assistant"));
-
-    gnc_assistant_set_colors (GTK_ASSISTANT (info->assistant));
-
-    info->api = gnc_AB_BANKING_new();
-    info->deferred_info = NULL;
-    info->gnc_hash = NULL;
-
-    info->match_page_prepared = FALSE;
-    info->account_view =
-        GTK_TREE_VIEW(gtk_builder_get_object (builder, "account_page_view"));
-
-    info->account_store = gtk_list_store_new(NUM_ACCOUNT_LIST_COLS,
-                          G_TYPE_INT, G_TYPE_STRING,
-                          G_TYPE_POINTER, G_TYPE_STRING,
-                          G_TYPE_BOOLEAN);
-    gtk_tree_view_set_model(info->account_view,
-                            GTK_TREE_MODEL(info->account_store));
-    g_object_unref(info->account_store);
-
-    column = gtk_tree_view_column_new_with_attributes(
-                 _("Online Banking Account Name"), gtk_cell_renderer_text_new(),
-                 "text", ACCOUNT_LIST_COL_AB_NAME, (gchar*) NULL);
-    gtk_tree_view_append_column(info->account_view, column);
-
-    column = gtk_tree_view_column_new_with_attributes(
-                 _("GnuCash Account Name"), gtk_cell_renderer_text_new(),
-                 "text", ACCOUNT_LIST_COL_GNC_NAME, (gchar*) NULL);
-    gtk_tree_view_column_set_expand(column, TRUE);
-    gtk_tree_view_append_column(info->account_view, column);
-
-    column = gtk_tree_view_column_new_with_attributes(
-                 _("New?"), gtk_cell_renderer_toggle_new(),
-                 "active", ACCOUNT_LIST_COL_CHECKED, (gchar*) NULL);
-    gtk_tree_view_append_column(info->account_view, column);
-
-    selection = gtk_tree_view_get_selection(info->account_view);
-    gtk_tree_selection_set_mode (selection, GTK_SELECTION_SINGLE);
-
-    gnc_restore_window_size (GNC_PREFS_GROUP, GTK_WINDOW(info->window));
-
-    g_signal_connect(info->account_view, "row-activated",
-                     G_CALLBACK(account_list_clicked_cb), info);
-
-    g_signal_connect (G_OBJECT(info->window), "destroy",
-                      G_CALLBACK (aai_destroy_cb), info);
-
-    gtk_builder_connect_signals(builder, info);
-    g_object_unref(G_OBJECT(builder));
-
-    component_id = gnc_register_gui_component(ASSISTANT_AB_INITIAL_CM_CLASS,
-                   NULL, aai_close_handler, info);
-
-    gnc_gui_component_set_session(component_id, gnc_get_current_session());
-
-    gtk_widget_show(info->window);
-}

Deleted: gnucash/trunk/src/import-export/aqbanking/assistant-ab-initial.glade
===================================================================
--- gnucash/trunk/src/import-export/aqbanking/assistant-ab-initial.glade	2013-12-15 17:20:10 UTC (rev 23566)
+++ gnucash/trunk/src/import-export/aqbanking/assistant-ab-initial.glade	2013-12-15 17:21:20 UTC (rev 23567)
@@ -1,162 +0,0 @@
-<?xml version="1.0"?>
-<interface>
-  <requires lib="gtk+" version="2.16"/>
-  <!-- interface-naming-policy project-wide -->
-  <object class="GtkAssistant" id="AqBanking Init Assistant">
-    <property name="can_focus">False</property>
-    <property name="border_width">12</property>
-    <property name="title" translatable="yes">AqBanking Initial Assistant</property>
-    <signal name="close" handler="aai_on_finish" swapped="no"/>
-    <signal name="prepare" handler="aai_on_prepare" swapped="no"/>
-    <signal name="cancel" handler="aai_on_cancel" swapped="no"/>
-    <child>
-      <object class="GtkLabel" id="start_page">
-        <property name="visible">True</property>
-        <property name="can_focus">False</property>
-        <property name="label" translatable="yes">
-This assistant helps you setting up your Online Banking connection with your bank.
-
-You first need to apply for Online Banking access at your bank. If your bank  decides to grant you electronic access, they will send you a letter containing 
-
-* The bank code of your bank
-* The user ID that identifies you to your bank
-* The Internet address of your bank's Online Banking server
-* For HBCI Online Banking, information about the cryptographic public key of your bank ("Ini-Letter").
-
-This information will be needed in the following. Press "Forward" now.
-
-NOTE: NO WARRANTIES FOR ANYTHING. Some banks run a poorly implemented Online Banking server. You should not rely on time-critical transfers through Online Banking, because sometimes the bank does not give you correct feedback when a transfer is rejected.
-
-Press "Cancel" if you do not wish to setup any Online Banking connection now.
-</property>
-        <property name="wrap">True</property>
-      </object>
-      <packing>
-        <property name="page_type">intro</property>
-        <property name="title" translatable="yes">Initial Online Banking Setup</property>
-        <property name="complete">True</property>
-      </packing>
-    </child>
-    <child>
-      <object class="GtkVBox" id="wizard_page">
-        <property name="visible">True</property>
-        <property name="can_focus">False</property>
-        <property name="border_width">12</property>
-        <property name="spacing">12</property>
-        <child>
-          <object class="GtkLabel" id="label8877441">
-            <property name="visible">True</property>
-            <property name="can_focus">False</property>
-            <property name="label" translatable="yes">The Setup of your Online Banking connection is handled by the external program "AqBanking Setup Wizard". Please press the button below to start this program.</property>
-            <property name="wrap">True</property>
-          </object>
-          <packing>
-            <property name="expand">True</property>
-            <property name="fill">False</property>
-            <property name="position">0</property>
-          </packing>
-        </child>
-        <child>
-          <object class="GtkAlignment" id="alignment7">
-            <property name="visible">True</property>
-            <property name="can_focus">False</property>
-            <property name="xscale">0</property>
-            <child>
-              <object class="GtkButton" id="ab_wizard_button">
-                <property name="label" translatable="yes">_Start AqBanking Wizard</property>
-                <property name="visible">True</property>
-                <property name="can_focus">True</property>
-                <property name="receives_default">True</property>
-                <property name="use_action_appearance">False</property>
-                <property name="use_underline">True</property>
-                <signal name="clicked" handler="aai_wizard_button_clicked_cb" swapped="no"/>
-              </object>
-            </child>
-          </object>
-          <packing>
-            <property name="expand">True</property>
-            <property name="fill">False</property>
-            <property name="position">1</property>
-          </packing>
-        </child>
-      </object>
-      <packing>
-        <property name="page_type">intro</property>
-        <property name="title" translatable="yes">Start Online Banking Wizard</property>
-      </packing>
-    </child>
-    <child>
-      <object class="GtkVBox" id="account_match_page">
-        <property name="visible">True</property>
-        <property name="can_focus">False</property>
-        <property name="border_width">12</property>
-        <child>
-          <object class="GtkVBox" id="vbox157">
-            <property name="visible">True</property>
-            <property name="can_focus">False</property>
-            <property name="spacing">12</property>
-            <child>
-              <object class="GtkScrolledWindow" id="scrolledwindow25">
-                <property name="visible">True</property>
-                <property name="can_focus">True</property>
-                <property name="hscrollbar_policy">automatic</property>
-                <property name="vscrollbar_policy">automatic</property>
-                <property name="shadow_type">in</property>
-                <child>
-                  <object class="GtkTreeView" id="account_page_view">
-                    <property name="visible">True</property>
-                    <property name="can_focus">True</property>
-                    <property name="rules_hint">True</property>
-                  </object>
-                </child>
-              </object>
-              <packing>
-                <property name="expand">True</property>
-                <property name="fill">True</property>
-                <property name="position">0</property>
-              </packing>
-            </child>
-            <child>
-              <object class="GtkLabel" id="label828">
-                <property name="visible">True</property>
-                <property name="can_focus">False</property>
-                <property name="label" translatable="yes">Double Click on the line of an Online Banking account name if you want to match it to a GnuCash account. Click "Forward" when all desired accounts are matching.</property>
-                <property name="wrap">True</property>
-              </object>
-              <packing>
-                <property name="expand">False</property>
-                <property name="fill">False</property>
-                <property name="position">1</property>
-              </packing>
-            </child>
-          </object>
-          <packing>
-            <property name="expand">True</property>
-            <property name="fill">True</property>
-            <property name="position">0</property>
-          </packing>
-        </child>
-      </object>
-      <packing>
-        <property name="title" translatable="yes">Match Online accounts with GnuCash accounts</property>
-      </packing>
-    </child>
-    <child>
-      <object class="GtkLabel" id="finish_page">
-        <property name="visible">True</property>
-        <property name="can_focus">False</property>
-        <property name="label" translatable="yes">The setup for matching Online Banking accounts to GnuCash accounts is now finished. You can now invoke Online Banking actions on those accounts.
-
-If you want to add another bank, user, or account, you can start this assistant again anytime.
-
-Press "Apply" now.</property>
-        <property name="wrap">True</property>
-      </object>
-      <packing>
-        <property name="page_type">confirm</property>
-        <property name="title" translatable="yes">Online Banking Setup Finished</property>
-        <property name="complete">True</property>
-      </packing>
-    </child>
-  </object>
-</interface>

Deleted: gnucash/trunk/src/import-export/aqbanking/assistant-ab-initial.h
===================================================================
--- gnucash/trunk/src/import-export/aqbanking/assistant-ab-initial.h	2013-12-15 17:20:10 UTC (rev 23566)
+++ gnucash/trunk/src/import-export/aqbanking/assistant-ab-initial.h	2013-12-15 17:21:20 UTC (rev 23567)
@@ -1,51 +0,0 @@
-/*
- * assistant-ab-initial.h -- aqbanking creation functionality
- *
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation; either version 2 of
- * the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, contact:
- *
- * Free Software Foundation           Voice:  +1-617-542-5942
- * 51 Franklin Street, Fifth Floor    Fax:    +1-617-542-2652
- * Boston, MA  02110-1301,  USA       gnu at gnu.org
- */
-
-/**
- * @addtogroup Import_Export
- * @{
- * @addtogroup AqBanking
- * @{
- * @file assistant-ab-initial.h
- * @brief AqBanking setup functionality
- * @author Copyright (C) 2002 Christian Stimming <stimming at tuhh.de>
- * @author Copyright (C) 2008 Andreas Koehler <andi5.py at gmx.net>
- */
-
-#ifndef ASSISTANT_AB_INITIAL_H
-#define ASSISTANT_AB_INITIAL_H
-
-#include <glib.h>
-
-G_BEGIN_DECLS
-
-/**
- * Create and show an assistant for the aqbanking setup.
- */
-void gnc_ab_initial_assistant(void);
-
-G_END_DECLS
-
-/** @} */
-/** @} */
-
-#endif /* ASSISTANT_AB_INITIAL_H */

Deleted: gnucash/trunk/src/import-export/aqbanking/dialog-ab-daterange.c
===================================================================
--- gnucash/trunk/src/import-export/aqbanking/dialog-ab-daterange.c	2013-12-15 17:20:10 UTC (rev 23566)
+++ gnucash/trunk/src/import-export/aqbanking/dialog-ab-daterange.c	2013-12-15 17:21:20 UTC (rev 23567)
@@ -1,158 +0,0 @@
-/*
- * dialog-ab-daterange.c --
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation; either version 2 of
- * the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, contact:
- *
- * Free Software Foundation           Voice:  +1-617-542-5942
- * 51 Franklin Street, Fifth Floor    Fax:    +1-617-542-2652
- * Boston, MA  02110-1301,  USA       gnu at gnu.org
- */
-
-/**
- * @internal
- * @file dialog-daterange.c
- * @brief Dialog for date range entry
- * @author Copyright (C) 2002 Christian Stimming <stimming at tuhh.de>
- * @author Copyright (C) 2008 Andreas Koehler <andi5.py at gmx.net>
- */
-
-#include "config.h"
-
-#include "dialog-ab-daterange.h"
-#include "dialog-utils.h"
-#include "gnc-date-edit.h"
-
-/* This static indicates the debugging module that this .o belongs to.  */
-static QofLogModule log_module = G_LOG_DOMAIN;
-
-typedef struct _DaterangeInfo DaterangeInfo;
-
-void ddr_toggled_cb(GtkToggleButton *button, gpointer user_data);
-
-struct _DaterangeInfo
-{
-    GtkWidget *enter_from_button;
-    GtkWidget *enter_to_button;
-    GtkWidget *from_dateedit;
-    GtkWidget *to_dateedit;
-};
-
-gboolean
-gnc_ab_enter_daterange(GtkWidget *parent,
-                       const char *heading,
-                       Timespec *from_date,
-                       gboolean *last_retv_date,
-                       gboolean *first_possible_date,
-                       Timespec *to_date,
-                       gboolean *to_now)
-{
-    GtkBuilder *builder;
-    GtkWidget *dialog;
-    GtkWidget *heading_label;
-    GtkWidget *first_button;
-    GtkWidget *last_retrieval_button;
-    GtkWidget *now_button;
-    DaterangeInfo info;
-    gint result;
-
-    ENTER("");
-
-    builder = gtk_builder_new();
-    gnc_builder_add_from_file (builder, "dialog-ab.glade", "Date Range Dialog");
-
-    dialog = GTK_WIDGET(gtk_builder_get_object (builder, "Date Range Dialog"));
-
-    /* Connect the signals */
-    gtk_builder_connect_signals_full (builder, gnc_builder_connect_full_func, &info );
-
-    if (parent)
-        gtk_window_set_transient_for(GTK_WINDOW(dialog), GTK_WINDOW(parent));
-
-    heading_label  = GTK_WIDGET(gtk_builder_get_object (builder, "heading_label"));
-    first_button  = GTK_WIDGET(gtk_builder_get_object (builder, "first_button"));
-    last_retrieval_button  = GTK_WIDGET(gtk_builder_get_object (builder, "last_retrieval_button"));
-    info.enter_from_button  = GTK_WIDGET(gtk_builder_get_object (builder, "enter_from_button"));
-    now_button  = GTK_WIDGET(gtk_builder_get_object (builder, "now_button"));
-    info.enter_to_button  = GTK_WIDGET(gtk_builder_get_object (builder, "enter_to_button"));
-
-    info.from_dateedit = gnc_date_edit_new_ts(*from_date, FALSE, FALSE);
-    gtk_container_add(GTK_CONTAINER(gtk_builder_get_object (builder, "enter_from_box")),
-                      info.from_dateedit);
-    gtk_widget_show(info.from_dateedit);
-
-    info.to_dateedit = gnc_date_edit_new_ts(*to_date, FALSE, FALSE);
-    gtk_container_add(GTK_CONTAINER(gtk_builder_get_object (builder, "enter_to_box")),
-                      info.to_dateedit);
-    gtk_widget_show(info.to_dateedit);
-
-    if (*last_retv_date)
-    {
-        gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(last_retrieval_button),
-                                     TRUE);
-    }
-    else
-    {
-        gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(first_button), TRUE);
-        gtk_widget_set_sensitive(last_retrieval_button, FALSE);
-    }
-
-    gtk_widget_set_sensitive(info.from_dateedit, FALSE);
-    gtk_widget_set_sensitive(info.to_dateedit, FALSE);
-
-    gtk_dialog_set_default_response(GTK_DIALOG(dialog), GTK_RESPONSE_OK);
-
-    if (heading)
-        gtk_label_set_text(GTK_LABEL(heading_label), heading);
-
-    gtk_widget_show(dialog);
-
-    result = gtk_dialog_run(GTK_DIALOG(dialog));
-    gtk_widget_hide(dialog);
-
-    if (result == GTK_RESPONSE_OK)
-    {
-        *from_date = gnc_date_edit_get_date_ts(
-                         GNC_DATE_EDIT(info.from_dateedit));
-        *last_retv_date = gtk_toggle_button_get_active(
-                              GTK_TOGGLE_BUTTON(last_retrieval_button));
-        *first_possible_date = gtk_toggle_button_get_active(
-                                   GTK_TOGGLE_BUTTON(first_button));
-        *to_date = gnc_date_edit_get_date_ts(
-                       GNC_DATE_EDIT(info.to_dateedit));
-        *to_now = gtk_toggle_button_get_active(
-                      GTK_TOGGLE_BUTTON(now_button));
-    }
-
-    g_object_unref(G_OBJECT(builder));
-
-    gtk_widget_destroy(dialog);
-
-    LEAVE("");
-    return result == GTK_RESPONSE_OK;
-}
-
-void
-ddr_toggled_cb(GtkToggleButton *button, gpointer user_data)
-{
-    DaterangeInfo *info = user_data;
-
-    g_return_if_fail(info);
-
-    gtk_widget_set_sensitive(info->from_dateedit,
-                             gtk_toggle_button_get_active(
-                                 GTK_TOGGLE_BUTTON(info->enter_from_button)));
-    gtk_widget_set_sensitive(info->to_dateedit,
-                             gtk_toggle_button_get_active(
-                                 GTK_TOGGLE_BUTTON(info->enter_to_button)));
-}

Deleted: gnucash/trunk/src/import-export/aqbanking/dialog-ab-daterange.h
===================================================================
--- gnucash/trunk/src/import-export/aqbanking/dialog-ab-daterange.h	2013-12-15 17:20:10 UTC (rev 23566)
+++ gnucash/trunk/src/import-export/aqbanking/dialog-ab-daterange.h	2013-12-15 17:21:20 UTC (rev 23567)
@@ -1,69 +0,0 @@
-/*
- * dialog-ab-daterange.h --
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation; either version 2 of
- * the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, contact:
- *
- * Free Software Foundation           Voice:  +1-617-542-5942
- * 51 Franklin Street, Fifth Floor    Fax:    +1-617-542-2652
- * Boston, MA  02110-1301,  USA       gnu at gnu.org
- */
-
-/**
- * @addtogroup Import_Export
- * @{
- * @addtogroup AqBanking
- * @{
- * @file aqbanking/dialog-ab-daterange.h
- * @brief Dialog for date range entry
- * @author Copyright (C) 2002 Christian Stimming <stimming at tuhh.de>
- * @author Copyright (C) 2008 Andreas Koehler <andi5.py at gmx.net>
- */
-
-#ifndef DIALOG_DATERANGE_H
-#define DIALOG_DATERANGE_H
-
-#include <gtk/gtk.h>
-
-#include "qof.h"
-
-G_BEGIN_DECLS
-
-/**
- * Show a dialog to pick a time frame using a sensible set of default options.
- *
- * @param parent Widget to use as parent, may be NULL
- * @param heading Descriptive text showed at the top, may be NULL
- * @param from_date Location to read from the initial and write to the final
- * value of the from date entry
- * @param last_retv_date Location to read from whether the caller knows the last
- * retrieval date and write to whether the corresponding button has been chosen
- * @param first_possible_date Location to write to whether the earliest possible
- * date button has been chosen
- * @param to_date Location to read from the initial and write to the final value
- * of the to date entry
- * @param to_now Location to write to whether the to now button has been chosen
- */
-gboolean gnc_ab_enter_daterange(GtkWidget *parent,
-                                const char *heading,
-                                Timespec *from_date,
-                                gboolean *last_retv_date,
-                                gboolean *first_possible_date,
-                                Timespec *to_date,
-                                gboolean *to_now);
-
-G_END_DECLS
-
-#endif /* DIALOG_DATERANGE_H */
-/** @} */
-/** @} */

Deleted: gnucash/trunk/src/import-export/aqbanking/dialog-ab-trans.c
===================================================================
--- gnucash/trunk/src/import-export/aqbanking/dialog-ab-trans.c	2013-12-15 17:20:10 UTC (rev 23566)
+++ gnucash/trunk/src/import-export/aqbanking/dialog-ab-trans.c	2013-12-15 17:21:20 UTC (rev 23567)
@@ -1,1260 +0,0 @@
-/*
- * dialog-ab-trans.c --
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation; either version 2 of
- * the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, contact:
- *
- * Free Software Foundation           Voice:  +1-617-542-5942
- * 51 Franklin Street, Fifth Floor    Fax:    +1-617-542-2652
- * Boston, MA  02110-1301,  USA       gnu at gnu.org
- */
-
-/**
- * @internal
- * @file dialog-ab-trans.c
- * @brief Templates for AqBanking transactions
- * @author Copyright (C) 2002 Christian Stimming <stimming at tuhh.de>
- * @author Copyright (C) 2004 Bernd Wagner
- * @author Copyright (C) 2006 David Hampton <hampton at employees.org>
- * @author Copyright (C) 2008 Andreas Koehler <andi5.py at gmx.net>
- */
-
-#include "config.h"
-
-#include <glib/gi18n.h>
-#if HAVE_KTOBLZCHECK_H
-#    include <ktoblzcheck.h>
-#endif
-#include <aqbanking/jobsingletransfer.h>
-#include <aqbanking/jobsingledebitnote.h>
-#include <aqbanking/jobinternaltransfer.h>
-#include <aqbanking/jobsepatransfer.h>
-#include <aqbanking/jobsepadebitnote.h>
-
-#include "dialog-ab-trans.h"
-#include "dialog-transfer.h"
-#include "dialog-utils.h"
-#include "gnc-ab-trans-templ.h"
-#include "gnc-ab-utils.h"
-#include "gnc-amount-edit.h"
-#include "gnc-ui.h"
-
-/* This static indicates the debugging module that this .o belongs to.  */
-static QofLogModule log_module = G_LOG_DOMAIN;
-
-/* Template handling */
-static void gnc_ab_trans_dialog_fill_templ_helper(gpointer data, gpointer user_data);
-static gboolean gnc_ab_trans_dialog_clear_templ_helper(GtkTreeModel *model,
-        GtkTreePath *path,
-        GtkTreeIter *iter,
-        gpointer user_data);
-static gboolean gnc_ab_trans_dialog_get_templ_helper(GtkTreeModel *model,
-        GtkTreePath *path,
-        GtkTreeIter *iter,
-        gpointer data);
-
-static AB_TRANSACTION *gnc_ab_trans_dialog_fill_values(GncABTransDialog *td);
-static AB_JOB *gnc_ab_trans_dialog_get_available_empty_job(AB_ACCOUNT *ab_acc,
-        GncABTransType trans_type);
-
-static void gnc_ab_trans_dialog_check_ktoblzcheck(const GncABTransDialog *td,
-        const AB_TRANSACTION *trans);
-
-/* Callbacks - connected with GtkBuilder */
-G_MODULE_EXPORT void gnc_ab_trans_dialog_bankcode_changed_cb(GtkEditable *editable, gpointer user_data);
-G_MODULE_EXPORT void gnc_ab_trans_dialog_add_templ_cb(GtkButton *button, gpointer user_data);
-G_MODULE_EXPORT void gnc_ab_trans_dialog_moveup_templ_cb(GtkButton *button, gpointer user_data);
-G_MODULE_EXPORT void gnc_ab_trans_dialog_movedown_templ_cb(GtkButton *button, gpointer user_data);
-G_MODULE_EXPORT void gnc_ab_trans_dialog_sort_templ_cb(GtkButton *button, gpointer user_data);
-G_MODULE_EXPORT void gnc_ab_trans_dialog_del_templ_cb(GtkButton *button, gpointer user_data);
-G_MODULE_EXPORT void gnc_ab_trans_dialog_entry_filter_cb (GtkEditable *editable,
-        const gchar *text,
-        gint         length,
-        gint        *position,
-        gpointer     user_data);
-G_MODULE_EXPORT void gnc_ab_trans_dialog_templ_list_row_activated_cb(GtkTreeView *view,
-        GtkTreePath *path,
-        GtkTreeViewColumn *column,
-        gpointer user_data);
-G_MODULE_EXPORT void gnc_ab_trans_dialog_verify_values(GncABTransDialog *td);
-
-
-enum
-{
-    TEMPLATE_NAME,
-    TEMPLATE_POINTER,
-    TEMPLATE_NUM_COLUMNS
-};
-
-struct _GncABTransDialog
-{
-    /* The dialog itself */
-    GtkWidget *dialog;
-    GtkWidget *parent;
-    AB_ACCOUNT *ab_acc;
-
-    /* Whether this is a transfer or a direct debit */
-    GncABTransType trans_type;
-
-    /* Recipient */
-    GtkWidget *recp_name_entry;
-    GtkWidget *recp_account_entry;
-    GtkWidget *recp_bankcode_entry;
-
-    /* Amount */
-    GtkWidget *amount_edit;
-
-    /* Purpose, description */
-    GtkWidget *purpose_entry;
-    GtkWidget *purpose_cont_entry;
-    GtkWidget *purpose_cont2_entry;
-    GtkWidget *purpose_cont3_entry;
-
-    /* Recipient's bank name (may be filled in automatically sometime later) */
-    GtkWidget *recp_bankname_label;
-
-    /* The template choosing GtkTreeView/GtkListStore */
-    GtkTreeView *template_gtktreeview;
-    GtkListStore *template_list_store;
-
-    /* Exec button */
-    GtkWidget *exec_button;
-
-    /* Flag, if template list has been changed */
-    gboolean templ_changed;
-
-    /* The aqbanking transaction that got created here */
-    AB_TRANSACTION *ab_trans;
-
-    /* The gnucash transaction that got created here */
-    Transaction *gnc_trans;
-
-#if HAVE_KTOBLZCHECK_H
-    /* object for Account number checking */
-    AccountNumberCheck *blzcheck;
-#endif
-};
-
-gboolean gnc_ab_trans_isSEPA(GncABTransType t)
-{
-    switch (t)
-    {
-    case SEPA_TRANSFER:
-    case SEPA_DEBITNOTE:
-        return TRUE;
-    default:
-        return FALSE;
-    }
-}
-
-static void
-gnc_ab_trans_dialog_fill_templ_helper(gpointer data, gpointer user_data)
-{
-    GncABTransTempl *templ = data;
-    GtkListStore *store = user_data;
-    GtkTreeIter iter;
-
-    g_return_if_fail(templ && store);
-    gtk_list_store_append(store, &iter);
-    gtk_list_store_set(store, &iter,
-                       TEMPLATE_NAME, gnc_ab_trans_templ_get_name(templ),
-                       TEMPLATE_POINTER, templ,
-                       -1);
-}
-
-/**
- * Create a new AB_TRANSACTION, fill the values from the entry fields into it
- * and return it.  The caller must AB_TRANSACTION_free() it when finished.
- */
-static AB_TRANSACTION *
-gnc_ab_trans_dialog_fill_values(GncABTransDialog *td)
-{
-    /* Fill in the user-entered values */
-    AB_TRANSACTION *trans = AB_Transaction_new();
-    AB_VALUE *value;
-
-    AB_Transaction_FillLocalFromAccount(trans, td->ab_acc);
-    //AB_Transaction_SetLocalBankCode(trans, AB_Account_GetBankCode(td->ab_acc));
-    //AB_Transaction_SetLocalAccountNumber(
-    //  trans, AB_Account_GetAccountNumber(td->ab_acc));
-    //AB_Transaction_SetLocalCountry(trans, "DE");
-
-    if (gnc_ab_trans_isSEPA(td->trans_type))
-    {
-        AB_Transaction_SetRemoteBic(
-                    trans, gtk_entry_get_text(GTK_ENTRY(td->recp_bankcode_entry)));
-        AB_Transaction_SetRemoteIban(
-                    trans, gtk_entry_get_text(GTK_ENTRY(td->recp_account_entry)));
-    }
-    else
-    {
-        AB_Transaction_SetRemoteBankCode(
-                    trans, gtk_entry_get_text(GTK_ENTRY(td->recp_bankcode_entry)));
-        AB_Transaction_SetRemoteAccountNumber(
-                    trans, gtk_entry_get_text(GTK_ENTRY(td->recp_account_entry)));
-    }
-    AB_Transaction_SetRemoteCountry(trans, "DE");
-    AB_Transaction_AddRemoteName(
-        trans, gtk_entry_get_text(GTK_ENTRY(td->recp_name_entry)), FALSE);
-
-    AB_Transaction_AddPurpose(
-        trans, gtk_entry_get_text(GTK_ENTRY(td->purpose_entry)), FALSE);
-    AB_Transaction_AddPurpose(
-        trans, gtk_entry_get_text(GTK_ENTRY(td->purpose_cont_entry)), FALSE);
-    AB_Transaction_AddPurpose(
-        trans, gtk_entry_get_text(GTK_ENTRY(td->purpose_cont2_entry)), FALSE);
-    AB_Transaction_AddPurpose(
-        trans, gtk_entry_get_text(GTK_ENTRY(td->purpose_cont3_entry)), FALSE);
-
-    value = AB_Value_fromDouble(gnc_amount_edit_get_damount(
-                                    GNC_AMOUNT_EDIT(td->amount_edit)));
-    /* FIXME: Replace "EUR" by account-dependent string here. */
-    AB_Value_SetCurrency(value, "EUR");
-    AB_Transaction_SetValue(trans, value);
-    AB_Value_free(value);
-
-    /* If this is a direct debit, a textkey/ "Textschluessel"/transactionCode
-     * different from the default has to be set. */
-    switch (td->trans_type)
-    {
-    case SINGLE_DEBITNOTE:
-        /* AB_Transaction_SetTransactionCode (trans, 05); */
-        AB_Transaction_SetTextKey(trans, 05);
-        break;
-    default:
-        /* AB_Transaction_SetTransactionCode (trans, 51); */
-        AB_Transaction_SetTextKey (trans, 51);
-        break;
-    }
-
-    return trans;
-}
-
-GncABTransDialog *
-gnc_ab_trans_dialog_new(GtkWidget *parent, AB_ACCOUNT *ab_acc,
-                        gint commodity_scu, GncABTransType trans_type,
-                        GList *templates)
-{
-    GncABTransDialog *td;
-    GtkBuilder  *builder;
-    const gchar *ab_ownername;
-    const gchar *ab_accountnumber;
-    const gchar *ab_bankname;
-    const gchar *ab_bankcode;
-    G_GNUC_UNUSED GtkWidget *trans_vbox;
-    GtkWidget *heading_label;
-    GtkWidget *recp_name_heading;
-    GtkWidget *recp_account_heading;
-    GtkWidget *recp_bankcode_heading;
-    GtkWidget *amount_hbox;
-    GtkWidget *orig_name_heading;
-    GtkWidget *orig_name_label;
-    GtkWidget *orig_account_heading;
-    GtkWidget *orig_account_label;
-    G_GNUC_UNUSED GtkWidget *orig_bankname_heading;
-    GtkWidget *orig_bankname_label;
-    GtkWidget *orig_bankcode_heading;
-    GtkWidget *orig_bankcode_label;
-    GtkCellRenderer *renderer;
-    GtkTreeViewColumn *column;
-
-    g_return_val_if_fail(ab_acc, NULL);
-
-    ab_ownername = AB_Account_GetOwnerName(ab_acc);
-    if (!ab_ownername)
-        ab_ownername = "";
-    ab_accountnumber = AB_Account_GetAccountNumber(ab_acc);
-    ab_bankcode = AB_Account_GetBankCode(ab_acc);
-    ab_bankname = AB_Account_GetBankName(ab_acc);
-    if (!ab_bankname || !*ab_bankname)
-        ab_bankname = _("(unknown)");
-
-    td = g_new0(GncABTransDialog, 1);
-    td->parent = parent;
-    td->ab_acc = ab_acc;
-    td->trans_type = trans_type;
-
-#if HAVE_KTOBLZCHECK_H
-    td->blzcheck = AccountNumberCheck_new();
-#endif
-
-    builder = gtk_builder_new();
-    gnc_builder_add_from_file (builder, "dialog-ab.glade", "Transaction Dialog");
-    td->dialog = GTK_WIDGET(gtk_builder_get_object (builder, "Transaction Dialog"));
-
-    if (parent)
-        gtk_window_set_transient_for(GTK_WINDOW(td->dialog), GTK_WINDOW(parent));
-
-    /* Extract widgets */
-    trans_vbox = GTK_WIDGET(gtk_builder_get_object (builder, "trans_vbox"));
-    heading_label = GTK_WIDGET(gtk_builder_get_object (builder, "heading_label"));
-    recp_name_heading = GTK_WIDGET(gtk_builder_get_object (builder, "recp_name_heading"));
-    td->recp_name_entry = GTK_WIDGET(gtk_builder_get_object (builder, "recp_name_entry"));
-    recp_account_heading = GTK_WIDGET(gtk_builder_get_object (builder, "recp_account_heading"));
-    td->recp_account_entry = GTK_WIDGET(gtk_builder_get_object (builder, "recp_account_entry"));
-    recp_bankcode_heading = GTK_WIDGET(gtk_builder_get_object (builder, "recp_bankcode_heading"));
-    td->recp_bankcode_entry = GTK_WIDGET(gtk_builder_get_object (builder, "recp_bankcode_entry"));
-    td->recp_bankname_label = GTK_WIDGET(gtk_builder_get_object (builder, "recp_bankname_label"));
-    amount_hbox = GTK_WIDGET(gtk_builder_get_object (builder, "amount_hbox"));
-    td->purpose_entry = GTK_WIDGET(gtk_builder_get_object (builder, "purpose_entry"));
-    td->purpose_cont_entry = GTK_WIDGET(gtk_builder_get_object (builder, "purpose_cont_entry"));
-    td->purpose_cont2_entry = GTK_WIDGET(gtk_builder_get_object (builder, "purpose_cont2_entry"));
-    td->purpose_cont3_entry = GTK_WIDGET(gtk_builder_get_object (builder, "purpose_cont3_entry"));
-    td->exec_button = GTK_WIDGET(gtk_builder_get_object(builder, "exec_now_button"));
-    orig_name_heading = GTK_WIDGET(gtk_builder_get_object (builder, "orig_name_heading"));
-    orig_name_label = GTK_WIDGET(gtk_builder_get_object (builder, "orig_name_label"));
-    orig_account_heading = GTK_WIDGET(gtk_builder_get_object (builder, "orig_account_heading"));
-    orig_account_label = GTK_WIDGET(gtk_builder_get_object (builder, "orig_account_label"));
-    orig_bankname_heading = GTK_WIDGET(gtk_builder_get_object (builder, "orig_bankname_heading"));
-    orig_bankname_label = GTK_WIDGET(gtk_builder_get_object (builder, "orig_bankname_label"));
-    orig_bankcode_heading = GTK_WIDGET(gtk_builder_get_object (builder, "orig_bankcode_heading"));
-    orig_bankcode_label = GTK_WIDGET(gtk_builder_get_object (builder, "orig_bankcode_label"));
-    td->template_gtktreeview =
-        GTK_TREE_VIEW(gtk_builder_get_object (builder, "template_list"));
-
-    /* Amount edit */
-    td->amount_edit = gnc_amount_edit_new();
-    gtk_box_pack_start(GTK_BOX(amount_hbox), td->amount_edit, TRUE, TRUE, 0);
-    gnc_amount_edit_set_evaluate_on_enter(GNC_AMOUNT_EDIT(td->amount_edit),
-                                          TRUE);
-    gnc_amount_edit_set_fraction(GNC_AMOUNT_EDIT(td->amount_edit),
-                                 commodity_scu);
-
-    /* Use "focus-out" signal because "amount-changed" is only sent when ENTER is pressed */
-    g_signal_connect_swapped (gnc_amount_edit_gtk_entry(GNC_AMOUNT_EDIT(td->amount_edit)), "focus-out-event",
-                              G_CALLBACK(gnc_ab_trans_dialog_verify_values), td);
-
-    /* Check for what kind of transaction this should be, and change the
-     * labels accordingly */
-    switch (trans_type)
-    {
-    case SINGLE_TRANSFER:
-    case SINGLE_INTERNAL_TRANSFER:
-    case SEPA_TRANSFER:
-        /* all labels are already set */
-        break;
-    case SINGLE_DEBITNOTE:
-    case SEPA_DEBITNOTE:
-        gtk_label_set_text(GTK_LABEL (heading_label),
-                           /* Translators: Strings from this file are
-                             * needed only in countries that have one of
-                             * aqbanking's Online Banking techniques
-                             * available. This is 'OFX DirectConnect'
-                             * (U.S. and others), 'HBCI' (in Germany),
-                             * or 'YellowNet' (Switzerland). If none of
-                             * these techniques are available in your
-                             * country, you may safely ignore strings
-                             * from the import-export/hbci
-                             * subdirectory. */
-                           _("Enter an Online Direct Debit Note"));
-
-        gtk_label_set_text(GTK_LABEL(recp_name_heading),
-                           _("Debited Account Owner"));
-        gtk_label_set_text(GTK_LABEL(recp_account_heading),
-                           _("Debited Account Number"));
-        gtk_label_set_text(GTK_LABEL(recp_bankcode_heading),
-                           _("Debited Account Bank Code"));
-
-        gtk_label_set_text(GTK_LABEL(orig_name_heading),
-                           _("Credited Account Owner"));
-        gtk_label_set_text(GTK_LABEL(orig_account_heading),
-                           _("Credited Account Number"));
-        gtk_label_set_text(GTK_LABEL(orig_bankcode_heading),
-                           _("Credited Account Bank Code"));
-        break;
-
-    default:
-        g_critical("gnc_ab_trans_dialog_new: Oops, unknown GncABTransType %d",
-                   trans_type);
-        break;
-    }
-
-    /* Additionally change the labels for the European (SEPA) transactions */
-    switch (trans_type)
-    {
-    case SEPA_TRANSFER:
-        gtk_label_set_text(GTK_LABEL(recp_account_heading),
-                           _("Recipient IBAN (International Account Number)"));
-        gtk_label_set_text(GTK_LABEL(recp_bankcode_heading),
-                           _("Recipient BIC (Bank Code)"));
-        break;
-    case SEPA_DEBITNOTE:
-        gtk_label_set_text(GTK_LABEL(recp_account_heading),
-                           _("Debited IBAN (International Account Number)"));
-        gtk_label_set_text(GTK_LABEL(recp_bankcode_heading),
-                           _("Debited BIC (Bank Code)"));
-        break;
-    default:
-        // do nothing
-        break;
-    }
-    if (gnc_ab_trans_isSEPA(trans_type))
-    {
-        // Also, SEPA might have much longer IBAN (up to 34 chars) and BIC (11)
-        gtk_entry_set_max_length(GTK_ENTRY(td->recp_bankcode_entry), 11);
-        gtk_entry_set_max_length(GTK_ENTRY(td->recp_account_entry), 34);
-    }
-
-    gtk_label_set_text(GTK_LABEL(orig_name_label), ab_ownername);
-    gtk_label_set_text(GTK_LABEL(orig_account_label), ab_accountnumber);
-    gtk_label_set_text(GTK_LABEL(orig_bankname_label), ab_bankname);
-    gtk_label_set_text (GTK_LABEL (orig_bankcode_label), ab_bankcode);
-
-    /* Fill list for choosing a transaction template */
-    td->template_list_store = gtk_list_store_new(TEMPLATE_NUM_COLUMNS,
-                              G_TYPE_STRING, G_TYPE_POINTER);
-    g_list_foreach(templates, gnc_ab_trans_dialog_fill_templ_helper, td->template_list_store);
-    gtk_tree_view_set_model(td->template_gtktreeview,
-                            GTK_TREE_MODEL(td->template_list_store));
-    td->templ_changed = FALSE;
-    /* Keep a reference to the store */
-
-    /* Show this list */
-    renderer = gtk_cell_renderer_text_new();
-    column = gtk_tree_view_column_new_with_attributes(
-                 "Template Name", renderer, "text", TEMPLATE_NAME, NULL);
-    gtk_tree_view_append_column(td->template_gtktreeview, column);
-
-    /* Connect the Signals */
-    gtk_builder_connect_signals_full(builder, gnc_builder_connect_full_func, td);
-
-    g_object_unref(G_OBJECT(builder));
-
-    /* Disabled OK button until suitable values are filled */
-    gnc_ab_trans_dialog_verify_values(td);
-
-    return td;
-}
-
-static void
-gnc_ab_trans_dialog_entry_set (GtkWidget* entry,
-                               const gchar* message,
-                               const gchar* stock_icon)
-{
-    g_object_set (entry,
-                  "secondary-icon-stock", stock_icon,
-                  "secondary-icon-tooltip-text", message,
-                  NULL);
-}
-
-static void
-gnc_ab_trans_dialog_check_ktoblzcheck(const GncABTransDialog *td,
-                                      const AB_TRANSACTION *trans)
-{
-#ifndef HAVE_KTOBLZCHECK_H
-    return;
-#else
-    gint blzresult;
-    const char *blztext;
-    gchar* message;
-
-    ENTER(" ");
-
-    if (gnc_ab_trans_isSEPA(td->trans_type))
-    {
-        // FIXME: libktoblzcheck also has <iban.h>, maybe add this here?
-        LEAVE("No ktoblzcheck implemented for IBAN");
-        return;
-    }
-
-    blzresult = AccountNumberCheck_check(
-                    td->blzcheck,
-                    AB_Transaction_GetRemoteBankCode(trans),
-                    AB_Transaction_GetRemoteAccountNumber(trans));
-    switch (blzresult)
-    {
-    case 2:
-        message = g_strdup_printf(_("The internal check of the destination account number '%s' "
-                                    "at the specified bank with bank code '%s' failed. This means "
-                                    "the account number might contain an error."),
-                                  AB_Transaction_GetRemoteAccountNumber(trans),
-                                  AB_Transaction_GetRemoteBankCode(trans));
-        gnc_ab_trans_dialog_entry_set (td->recp_bankcode_entry, message,
-                                       GTK_STOCK_DIALOG_WARNING);
-        gnc_ab_trans_dialog_entry_set (td->recp_account_entry, message,
-                                       GTK_STOCK_DIALOG_WARNING);
-
-        blztext = "Kontonummer wahrscheinlich falsch";
-        break;
-    case 0:
-        blztext = "Kontonummer ok";
-        break;
-    case 3:
-        blztext = "bank unbekannt";
-        break;
-    case 1:
-    default:
-        blztext = "unbekannt aus unbekanntem grund";
-        break;
-    }
-
-    if (blzresult != 2)
-    {
-        gnc_ab_trans_dialog_entry_set (td->recp_bankcode_entry, "",
-                                       NULL);
-        gnc_ab_trans_dialog_entry_set (td->recp_account_entry, "",
-                                       NULL);
-    }
-
-    LEAVE("KtoBlzCheck said check is %d = %s",
-          blzresult, blztext ? blztext : "(none)");
-#endif
-}
-
-static void
-gnc_ab_trans_dialog_clear_transaction(GncABTransDialog *td)
-{
-    AB_Transaction_free(td->ab_trans);
-    td->ab_trans = NULL;
-}
-
-void
-gnc_ab_trans_dialog_verify_values(GncABTransDialog *td)
-{
-    gchar* purpose;
-    gchar* othername;
-    const gchar* account;
-    const gchar* bankcode;
-
-    gboolean values_ok = TRUE;
-
-    GtkWidget *amount_entry = gnc_amount_edit_gtk_entry(GNC_AMOUNT_EDIT(td->amount_edit));
-
-    /* Fill in the values from the entry fields into a new
-     * AB_TRANSACTION */
-    td->ab_trans = gnc_ab_trans_dialog_fill_values(td);
-
-    // Verify that we have a local IBAN and BIC
-    if (gnc_ab_trans_isSEPA(td->trans_type))
-    {
-        const char* localBIC = AB_Transaction_GetLocalBic(td->ab_trans);
-        const char* localIBAN = AB_Transaction_GetLocalIban(td->ab_trans);
-        if (!localBIC || !localIBAN
-                || (strlen(localBIC) == 0) || (strlen(localIBAN) == 0))
-        {
-            const char* localBankCode = AB_Transaction_GetLocalBankCode(td->ab_trans);
-            const char* localAccountCode = AB_Transaction_GetLocalAccountNumber(td->ab_trans);
-            values_ok = FALSE;
-            gnc_error_dialog(td->dialog,
-                             _("Your local bank account does not yet have the SEPA account information stored."
-                               " We are sorry, but in this development version one additional step is necessary "
-                               "which has not yet been implemented directly in gnucash. "
-                               "Please execute the command line program \"aqhbci-tool\" for your account, as follows: "
-                               "aqhbci-tool4 getaccsepa -b %s -a %s"),
-                             (localBankCode ? localBankCode : ""),
-                             (localAccountCode ? localAccountCode : ""));
-        }
-    }
-
-    /* Check recipient / remote name */
-    othername = gnc_ab_get_remote_name(td->ab_trans);
-    if (!othername || !strlen(othername))
-    {
-        gnc_ab_trans_dialog_entry_set (td->recp_name_entry,
-                                       _("You did not enter a recipient name. A recipient name is "
-                                         "required for an online transfer.\n"),
-                                       GTK_STOCK_CANCEL);
-
-        g_free (othername);
-        values_ok = FALSE;
-    }
-    else
-    {
-        gnc_ab_trans_dialog_entry_set (td->recp_name_entry, "", NULL);
-        g_free(othername);
-    }
-
-    /* Check account */
-    account = gnc_ab_trans_isSEPA(td->trans_type)
-            ? AB_Transaction_GetRemoteIban(td->ab_trans)
-            : AB_Transaction_GetRemoteAccountNumber(td->ab_trans);
-    if (!account || !strlen(account))
-    {
-        gnc_ab_trans_dialog_entry_set (td->recp_account_entry,
-                                       _("You did not enter a recipient account. A recipient account is "
-                                         "required for an online transfer.\n"),
-                                       GTK_STOCK_CANCEL);
-        values_ok = FALSE;
-    }
-    else
-    {
-        gnc_ab_trans_dialog_entry_set (td->recp_account_entry, "", NULL);
-    }
-    /* Check bank */
-    bankcode = gnc_ab_trans_isSEPA(td->trans_type)
-            ? AB_Transaction_GetRemoteBic(td->ab_trans)
-            : AB_Transaction_GetRemoteBankCode(td->ab_trans);
-    if (!bankcode || !strlen(bankcode))
-    {
-        gnc_ab_trans_dialog_entry_set (td->recp_bankcode_entry,
-                                       _("You did not enter a recipient bank. A recipient bank is "
-                                         "required for an online transfer.\n"),
-                                       GTK_STOCK_CANCEL);
-        values_ok = FALSE;
-    }
-    else
-    {
-        gnc_ab_trans_dialog_entry_set (td->recp_bankcode_entry, "", NULL);
-    }
-    /* Check if account details are correct - gives warning only */
-    if (values_ok)
-        gnc_ab_trans_dialog_check_ktoblzcheck(td, td->ab_trans);
-
-    /* Check transaction value */
-    if (AB_Value_GetValueAsDouble(AB_Transaction_GetValue(td->ab_trans))
-            == 0.0)
-    {
-        gnc_ab_trans_dialog_entry_set (amount_entry,
-                                       _("The amount is zero or the amount field could not be "
-                                         "interpreted correctly. You might have mixed up decimal "
-                                         "point and comma, compared to your locale settings. "
-                                         "This does not result in a valid online transfer job."),
-                                       GTK_STOCK_CANCEL);
-        values_ok = FALSE;
-    }
-    else
-    {
-        gnc_ab_trans_dialog_entry_set (amount_entry, "", NULL);
-    }
-
-    /* Check transaction purpose */
-    purpose = gnc_ab_get_purpose(td->ab_trans);
-    if (!purpose || !strlen(purpose))
-    {
-        gnc_ab_trans_dialog_entry_set (td->purpose_entry,
-                                       _("You did not enter any transaction purpose. A purpose is "
-                                         "required for an online transfer.\n"),
-                                       GTK_STOCK_CANCEL);
-        g_free (purpose);
-        values_ok = FALSE;
-    }
-    else
-    {
-        gnc_ab_trans_dialog_entry_set (td->purpose_entry, "", NULL);
-        g_free(purpose);
-    }
-
-    gtk_widget_set_sensitive(td->exec_button, values_ok);
-    gnc_ab_trans_dialog_clear_transaction(td);
-}
-
-gint
-gnc_ab_trans_dialog_run_until_ok(GncABTransDialog *td)
-{
-    gint result;
-    AB_JOB *job;
-    const AB_TRANSACTION_LIMITS *joblimits;
-    guint8 max_purpose_lines;
-
-    /* Check whether the account supports this job */
-    job = gnc_ab_trans_dialog_get_available_empty_job(td->ab_acc, td->trans_type);
-    if (!job)
-    {
-        g_warning("gnc_ab_trans_dialog_run_until_ok: Oops, job not available");
-        return GTK_RESPONSE_CANCEL;
-    }
-
-    /* Activate as many purpose entries as available for the job */
-    joblimits = AB_JobSingleTransfer_GetFieldLimits(job);
-    max_purpose_lines = joblimits ?
-                        AB_TransactionLimits_GetMaxLinesPurpose(joblimits) : 2;
-    gtk_widget_set_sensitive(td->purpose_cont_entry, max_purpose_lines > 1);
-    gtk_widget_set_sensitive(td->purpose_cont2_entry, max_purpose_lines > 2);
-    gtk_widget_set_sensitive(td->purpose_cont3_entry, max_purpose_lines > 3);
-
-    /* Show the dialog */
-    gtk_widget_show(td->dialog);
-
-    /* Now run the dialog until it gets closed by a button press */
-    result = gtk_dialog_run (GTK_DIALOG (td->dialog));
-
-    /* Was cancel pressed or dialog closed?
-     *  GNC_RESPONSE_NOW == execute now
-     *  GNC_RESPONSE_LATER == scheduled for later execution (unimplemented)
-     *  GTK_RESPONSE_CANCEL == cancel
-     *  GTK_RESPONSE_DELETE_EVENT == window destroyed */
-    if (result != GNC_RESPONSE_NOW && result != GNC_RESPONSE_LATER)
-    {
-        gtk_widget_destroy(td->dialog);
-        td->dialog = NULL;
-        return result;
-    }
-
-    /* Get the transaction details - have been checked beforehand */
-    td->ab_trans = gnc_ab_trans_dialog_fill_values(td);
-
-    /* FIXME: If this is a direct debit, set the textkey/ "Textschluessel"/
-     * transactionCode according to some GUI selection here!! */
-    /*if (td->trans_type == SINGLE_DEBITNOTE)
-    AB_TRANSACTION_setTextKey (td->hbci_trans, 05); */
-
-
-    /* Hide the dialog */
-    if (td->dialog)
-        gtk_widget_hide(td->dialog);
-
-    return result;
-}
-
-static gboolean
-gnc_ab_trans_dialog_clear_templ_helper(GtkTreeModel *model,
-                                       GtkTreePath *path,
-                                       GtkTreeIter *iter,
-                                       gpointer user_data)
-{
-    GncABTransTempl *templ;
-
-    g_return_val_if_fail(model && iter, TRUE);
-
-    gtk_tree_model_get(model, iter, TEMPLATE_POINTER, &templ, -1);
-    gnc_ab_trans_templ_free(templ);
-    return FALSE;
-}
-
-void
-gnc_ab_trans_dialog_free(GncABTransDialog *td)
-{
-    if (!td) return;
-    if (td->ab_trans)
-        AB_Transaction_free(td->ab_trans);
-    if (td->dialog)
-        gtk_widget_destroy(td->dialog);
-    if (td->template_list_store)
-    {
-        gtk_tree_model_foreach(GTK_TREE_MODEL(td->template_list_store),
-                               gnc_ab_trans_dialog_clear_templ_helper, NULL);
-        g_object_unref(td->template_list_store);
-    }
-#if HAVE_KTOBLZCHECK_H
-    AccountNumberCheck_delete(td->blzcheck);
-#endif
-    g_free(td);
-}
-
-static gboolean
-gnc_ab_trans_dialog_get_templ_helper(GtkTreeModel *model,
-                                     GtkTreePath *path,
-                                     GtkTreeIter *iter,
-                                     gpointer data)
-{
-    GList **list = data;
-    GncABTransTempl *templ;
-
-    g_return_val_if_fail(model && iter, TRUE);
-
-    gtk_tree_model_get(model, iter, TEMPLATE_POINTER, &templ, -1);
-    *list = g_list_prepend(*list, templ);
-    return FALSE;
-}
-
-GList *
-gnc_ab_trans_dialog_get_templ(const GncABTransDialog *td, gboolean *changed)
-{
-    GList *list = NULL;
-
-    g_return_val_if_fail(td, NULL);
-
-    if (changed)
-    {
-        *changed = td->templ_changed;
-        if (!*changed)
-            return NULL;
-    }
-
-    gtk_tree_model_foreach(GTK_TREE_MODEL(td->template_list_store),
-                           gnc_ab_trans_dialog_get_templ_helper, &list);
-    list = g_list_reverse(list);
-    return list;
-}
-
-GtkWidget *
-gnc_ab_trans_dialog_get_parent(const GncABTransDialog *td)
-{
-    g_return_val_if_fail(td, NULL);
-    return td->parent;
-}
-
-const AB_TRANSACTION *
-gnc_ab_trans_dialog_get_ab_trans(const GncABTransDialog *td)
-{
-    g_return_val_if_fail(td, NULL);
-    return td->ab_trans;
-}
-
-static AB_JOB *
-gnc_ab_trans_dialog_get_available_empty_job(AB_ACCOUNT *ab_acc, GncABTransType trans_type)
-{
-    AB_JOB *job;
-
-    switch (trans_type)
-    {
-    case SINGLE_DEBITNOTE:
-        job = AB_JobSingleDebitNote_new(ab_acc);
-        break;
-    case SINGLE_INTERNAL_TRANSFER:
-        job = AB_JobInternalTransfer_new(ab_acc);
-        break;
-    case SEPA_TRANSFER:
-        job = AB_JobSepaTransfer_new(ab_acc);
-        break;
-    case SEPA_DEBITNOTE:
-        job = AB_JobSepaDebitNote_new(ab_acc);
-        break;
-    case SINGLE_TRANSFER:
-    default:
-        job = AB_JobSingleTransfer_new(ab_acc);
-        break;
-    };
-
-    if (!job || AB_Job_CheckAvailability(job
-#ifndef AQBANKING_VERSION_5_PLUS
-                                         , 0
-#endif
-                                        ))
-    {
-        if (job) AB_Job_free(job);
-        return NULL;
-    }
-    return job;
-}
-
-AB_JOB *
-gnc_ab_trans_dialog_get_job(const GncABTransDialog *td)
-{
-    g_return_val_if_fail(td, NULL);
-    return gnc_ab_get_trans_job(td->ab_acc, td->ab_trans, td->trans_type);
-}
-
-AB_JOB *
-gnc_ab_get_trans_job(AB_ACCOUNT *ab_acc, const AB_TRANSACTION *ab_trans,
-                     GncABTransType trans_type)
-{
-    AB_JOB *job;
-
-    g_return_val_if_fail(ab_acc && ab_trans, NULL);
-
-    job = gnc_ab_trans_dialog_get_available_empty_job(ab_acc, trans_type);
-    if (job)
-    {
-        switch (trans_type)
-        {
-        case SINGLE_DEBITNOTE:
-            AB_JobSingleDebitNote_SetTransaction(job, ab_trans);
-            break;
-        case SINGLE_INTERNAL_TRANSFER:
-            AB_JobInternalTransfer_SetTransaction(job, ab_trans);
-            break;
-        case SEPA_TRANSFER:
-            AB_JobSepaTransfer_SetTransaction(job, ab_trans);
-            break;
-        case SEPA_DEBITNOTE:
-            AB_JobSepaDebitNote_SetTransaction(job, ab_trans);
-            break;
-        case SINGLE_TRANSFER:
-        default:
-            AB_JobSingleTransfer_SetTransaction(job, ab_trans);
-            break;
-        };
-    }
-    return job;
-}
-
-void
-gnc_ab_trans_dialog_templ_list_row_activated_cb(GtkTreeView *view,
-        GtkTreePath *path,
-        GtkTreeViewColumn *column,
-        gpointer user_data)
-{
-    GncABTransDialog *td = user_data;
-    GtkTreeIter iter;
-    GncABTransTempl *templ;
-    const gchar *old_name, *new_name;
-    const gchar *old_account, *new_account;
-    const gchar *old_bankcode, *new_bankcode;
-    const gchar *old_purpose, *new_purpose;
-    const gchar *old_purpose_cont, *new_purpose_cont;
-    GtkWidget *amount_widget;
-    const gchar *old_amount_text;
-    gnc_numeric old_amount, new_amount;
-
-    g_return_if_fail(td);
-
-    ENTER("td=%p", td);
-    if (!gtk_tree_model_get_iter(GTK_TREE_MODEL(td->template_list_store), &iter,
-                                 path))
-    {
-        LEAVE("Could not get iter");
-        return;
-    }
-    gtk_tree_model_get(GTK_TREE_MODEL(td->template_list_store), &iter,
-                       TEMPLATE_POINTER, &templ, -1);
-
-    /* Get old values */
-    old_name = gtk_entry_get_text(GTK_ENTRY(td->recp_name_entry));
-    old_account = gtk_entry_get_text(GTK_ENTRY(td->recp_account_entry));
-    old_bankcode = gtk_entry_get_text(GTK_ENTRY(td->recp_bankcode_entry));
-    old_purpose = gtk_entry_get_text(GTK_ENTRY(td->purpose_entry));
-    old_purpose_cont = gtk_entry_get_text(GTK_ENTRY(td->purpose_cont_entry));
-    amount_widget = gnc_amount_edit_gtk_entry(GNC_AMOUNT_EDIT(td->amount_edit));
-    old_amount_text = gtk_entry_get_text(GTK_ENTRY(amount_widget));
-    old_amount = gnc_amount_edit_get_amount(GNC_AMOUNT_EDIT(td->amount_edit));
-
-    /* Get new values */
-    new_name = gnc_ab_trans_templ_get_recp_name(templ);
-    new_account = gnc_ab_trans_templ_get_recp_account(templ);
-    new_bankcode = gnc_ab_trans_templ_get_recp_bankcode(templ);
-    new_purpose = gnc_ab_trans_templ_get_purpose(templ);
-    new_purpose_cont = gnc_ab_trans_templ_get_purpose_cont(templ);
-    new_amount = gnc_ab_trans_templ_get_amount(templ);
-    if (!new_name) new_name = "";
-    if (!new_account) new_account = "";
-    if (!new_bankcode) new_bankcode = "";
-    if (!new_purpose) new_purpose = "";
-    if (!new_purpose_cont) new_purpose_cont = "";
-
-    /* Fill in */
-    gtk_entry_set_text(GTK_ENTRY(td->recp_name_entry), new_name);
-    gtk_entry_set_text(GTK_ENTRY(td->recp_account_entry), new_account);
-    gtk_entry_set_text(GTK_ENTRY(td->recp_bankcode_entry), new_bankcode);
-    gtk_entry_set_text(GTK_ENTRY(td->purpose_entry), new_purpose);
-    gtk_entry_set_text(GTK_ENTRY(td->purpose_cont_entry), new_purpose_cont);
-    gnc_amount_edit_set_amount(GNC_AMOUNT_EDIT(td->amount_edit), new_amount);
-    LEAVE(" ");
-}
-
-void
-gnc_ab_trans_dialog_bankcode_changed_cb(GtkEditable *editable, gpointer user_data)
-{
-#if HAVE_KTOBLZCHECK_H
-    GncABTransDialog *td = user_data;
-    const AccountNumberCheck_Record *record;
-    const gchar *input = gtk_entry_get_text(GTK_ENTRY(td->recp_bankcode_entry));
-
-    g_return_if_fail(td);
-
-    // FIXME: If this is a SEPA transaction, totally different verification
-    // rules apply anyway. There are some initial verification functions in
-    // <ktoblzcheck/iban.h>, but those need to be implemented here as well.
-    if (gnc_ab_trans_isSEPA(td->trans_type))
-        return;
-
-    ENTER("td=%p, input=%s", td, input);
-    record = AccountNumberCheck_findBank(td->blzcheck, input);
-
-    if (record)
-    {
-        const char *bankname = AccountNumberCheck_Record_bankName(record);
-        GError *error = NULL;
-        const char *ktoblzcheck_encoding =
-#ifdef KTOBLZCHECK_VERSION_MAJOR
-            /* This version number macro has been added in ktoblzcheck-1.10, but
-             * this function exists already since ktoblzcheck-1.7, so we're on
-             * the safe side. */
-            AccountNumberCheck_stringEncoding()
-#else
-            /* Every ktoblzcheck release before 1.10 is guaranteed to return
-             * strings only in ISO-8859-15. */
-            "ISO-8859-15"
-#endif
-            ;
-        gchar *utf8_bankname = g_convert(bankname, strlen(bankname), "UTF-8",
-                                         ktoblzcheck_encoding, NULL, NULL,
-                                         &error);
-
-        if (error)
-        {
-            g_critical("Error converting bankname \"%s\" to UTF-8", bankname);
-            g_error_free (error);
-            /* Conversion was erroneous, so don't use the string */
-            utf8_bankname = g_strdup(_("(unknown)"));
-        }
-        gtk_label_set_text(GTK_LABEL(td->recp_bankname_label),
-                           *utf8_bankname ? utf8_bankname : _("(unknown)"));
-        DEBUG("Found: %s", utf8_bankname);
-        g_free(utf8_bankname);
-    }
-    else
-    {
-        gtk_label_set_text(GTK_LABEL(td->recp_bankname_label), _("(unknown)"));
-    }
-    gnc_ab_trans_dialog_verify_values(td);
-    LEAVE(" ");
-#endif
-}
-
-struct _FindTemplData
-{
-    const gchar *name;
-    const GncABTransTempl *pointer;
-};
-
-static gboolean
-find_templ_helper(GtkTreeModel *model, GtkTreePath *path, GtkTreeIter *iter,
-                  gpointer user_data)
-{
-    struct _FindTemplData *data = user_data;
-    gchar *name;
-    GncABTransTempl *templ;
-    gboolean match;
-
-    g_return_val_if_fail(model && data, TRUE);
-    gtk_tree_model_get(model, iter,
-                       TEMPLATE_NAME, &name,
-                       TEMPLATE_POINTER, &templ,
-                       -1);
-    if (data->name)
-    {
-        /* Search for the template by name */
-        g_return_val_if_fail(!data->pointer, TRUE);
-        match = strcmp(name, data->name) == 0;
-        if (match) data->pointer = templ;
-    }
-    else
-    {
-        /* Search for the template by template pointer */
-        g_return_val_if_fail(!data->name, TRUE);
-        match = templ == data->pointer;
-        if (match) data->name = g_strdup(name);
-    }
-    g_free(name);
-    return match;
-}
-
-void
-gnc_ab_trans_dialog_add_templ_cb(GtkButton *button, gpointer user_data)
-{
-    GncABTransDialog *td = user_data;
-    GtkBuilder *builder;
-    GtkWidget *dialog;
-    GtkWidget *entry;
-    gint retval;
-    const gchar *name;
-    GncABTransTempl *templ;
-    struct _FindTemplData data;
-    GtkTreeSelection *selection;
-    GtkTreeIter cur_iter;
-    GtkTreeIter new_iter;
-
-    g_return_if_fail(td);
-
-    ENTER("td=%p", td);
-    builder = gtk_builder_new();
-    gnc_builder_add_from_file (builder, "dialog-ab.glade", "Template Name Dialog");
-    dialog = GTK_WIDGET(gtk_builder_get_object (builder, "Template Name Dialog"));
-
-    entry = GTK_WIDGET(gtk_builder_get_object (builder, "template_name"));
-
-    /* Suggest recipient name as name of the template */
-    gtk_entry_set_text(GTK_ENTRY(entry),
-                       gtk_entry_get_text(GTK_ENTRY(td->recp_name_entry)));
-
-    do
-    {
-        retval = gtk_dialog_run(GTK_DIALOG(dialog));
-        if (retval != GTK_RESPONSE_OK)
-            break;
-
-        name = gtk_entry_get_text(GTK_ENTRY(entry));
-        if (!*name)
-            break;
-
-        data.name = name;
-        data.pointer = NULL;
-        gtk_tree_model_foreach(GTK_TREE_MODEL(td->template_list_store),
-                               find_templ_helper, &data);
-        if (data.pointer)
-        {
-            gnc_error_dialog(dialog, "%s",
-                             _("A template with the given name already exists. "
-                               "Please enter another name."));
-            continue;
-        }
-
-        /* Create a new template */
-        templ = gnc_ab_trans_templ_new_full(
-                    name,
-                    gtk_entry_get_text(GTK_ENTRY(td->recp_name_entry)),
-                    gtk_entry_get_text(GTK_ENTRY(td->recp_account_entry)),
-                    gtk_entry_get_text(GTK_ENTRY(td->recp_bankcode_entry)),
-                    gnc_amount_edit_get_amount(GNC_AMOUNT_EDIT(td->amount_edit)),
-                    gtk_entry_get_text(GTK_ENTRY(td->purpose_entry)),
-                    gtk_entry_get_text (GTK_ENTRY(td->purpose_cont_entry)));
-
-        /* Insert it, either after the selected one or at the end */
-        selection = gtk_tree_view_get_selection(td->template_gtktreeview);
-        if (gtk_tree_selection_get_selected(selection, NULL, &cur_iter))
-        {
-            gtk_list_store_insert_after(td->template_list_store,
-                                        &new_iter, &cur_iter);
-        }
-        else
-        {
-            gtk_list_store_append(td->template_list_store, &new_iter);
-        }
-        gtk_list_store_set(td->template_list_store, &new_iter,
-                           TEMPLATE_NAME, name,
-                           TEMPLATE_POINTER, templ,
-                           -1);
-        td->templ_changed = TRUE;
-        DEBUG("Added template with name %s", name);
-        break;
-    }
-    while (TRUE);
-
-    g_object_unref(G_OBJECT(builder));
-
-    gtk_widget_destroy(dialog);
-
-    LEAVE(" ");
-}
-
-void
-gnc_ab_trans_dialog_moveup_templ_cb(GtkButton *button, gpointer user_data)
-{
-    GncABTransDialog *td = user_data;
-    GtkTreeSelection *selection;
-    GtkTreeModel *model;
-    GtkTreeIter iter;
-    GtkTreePath *prev_path;
-    GtkTreeIter prev_iter;
-
-    g_return_if_fail(td);
-
-    selection = gtk_tree_view_get_selection(td->template_gtktreeview);
-    if (!gtk_tree_selection_get_selected(selection, &model, &iter))
-        return;
-
-    prev_path = gtk_tree_model_get_path(model, &iter);
-    if (gtk_tree_path_prev(prev_path))
-    {
-        if (gtk_tree_model_get_iter(model, &prev_iter, prev_path))
-        {
-            gtk_list_store_move_before(GTK_LIST_STORE(model), &iter, &prev_iter);
-            td->templ_changed = TRUE;
-        }
-    }
-    gtk_tree_path_free(prev_path);
-}
-
-void
-gnc_ab_trans_dialog_movedown_templ_cb(GtkButton *button, gpointer user_data)
-{
-    GncABTransDialog *td = user_data;
-    GtkTreeSelection *selection;
-    GtkTreeModel *model;
-    GtkTreeIter iter;
-    GtkTreeIter next_iter;
-
-    g_return_if_fail(td);
-
-    selection = gtk_tree_view_get_selection(td->template_gtktreeview);
-    if (!gtk_tree_selection_get_selected (selection, &model, &iter))
-        return;
-
-    next_iter = iter;
-    if (gtk_tree_model_iter_next(model, &next_iter))
-    {
-        gtk_list_store_move_after(GTK_LIST_STORE(model), &iter, &next_iter);
-        td->templ_changed = TRUE;
-    }
-}
-
-void
-gnc_ab_trans_dialog_sort_templ_cb(GtkButton *button, gpointer user_data)
-{
-    GncABTransDialog *td = user_data;
-
-    g_return_if_fail(td);
-
-    ENTER("td=%p", td);
-    gtk_tree_sortable_set_sort_column_id(
-        GTK_TREE_SORTABLE(td->template_list_store),
-        TEMPLATE_NAME, GTK_SORT_ASCENDING);
-    gtk_tree_sortable_set_sort_column_id(
-        GTK_TREE_SORTABLE(td->template_list_store),
-        GTK_TREE_SORTABLE_UNSORTED_SORT_COLUMN_ID,
-        GTK_SORT_ASCENDING);
-    td->templ_changed = TRUE;
-    LEAVE(" ");
-}
-
-void
-gnc_ab_trans_dialog_del_templ_cb(GtkButton *button, gpointer user_data)
-{
-    GncABTransDialog *td = user_data;
-    GtkTreeSelection *selection;
-    GtkTreeModel *model;
-    GtkTreeIter iter;
-    gchar *name;
-
-    g_return_if_fail(td);
-
-    ENTER("td=%p", td);
-    selection = gtk_tree_view_get_selection(td->template_gtktreeview);
-    if (!gtk_tree_selection_get_selected (selection, &model, &iter))
-    {
-        LEAVE("None selected");
-        return;
-    }
-
-    gtk_tree_model_get(model, &iter, TEMPLATE_NAME, &name, -1);
-    if (gnc_verify_dialog(
-                td->parent, FALSE,
-                _("Do you really want to delete the template with the name \"%s\"?"),
-                name))
-    {
-        gtk_list_store_remove(GTK_LIST_STORE(model), &iter);
-        td->templ_changed = TRUE;
-        DEBUG("Deleted template with name %s", name);
-    }
-    g_free(name);
-    LEAVE(" ");
-}
-
-void
-gnc_ab_trans_dialog_entry_filter_cb (GtkEditable *editable,
-                                     const gchar *text,
-                                     gint         length,
-                                     gint        *position,
-                                     gpointer     data)
-{
-    GString* result = g_string_new(NULL);
-    gint i;
-    GncABTransDialog *td = data;
-
-    if (length == -1)
-        length = strlen(text);
-
-    /* Filter non digits */
-    for (i = 0; i < length; i++)
-    {
-        gchar c = text[i];
-
-        // Only accept digits. FIXME: In the SEPA dialogs, alphanumerics are
-        // allowed, but we could also verify the input according to actual BIC
-        // and IBAN rules. This is not yet done here.
-        if (g_ascii_isdigit(c)
-                || (gnc_ab_trans_isSEPA(td->trans_type) && g_ascii_isalnum(c)))
-        {
-            g_string_append_c(result, c);
-        }
-    }
-
-    g_signal_handlers_block_by_func (editable,
-                                     (gpointer) gnc_ab_trans_dialog_entry_filter_cb, data);
-    gtk_editable_insert_text (editable, result->str, result->len, position);
-    g_signal_handlers_unblock_by_func (editable,
-                                       (gpointer) gnc_ab_trans_dialog_entry_filter_cb, data);
-    g_signal_stop_emission_by_name (editable, "insert_text");
-    g_string_free (result, TRUE);
-}

Deleted: gnucash/trunk/src/import-export/aqbanking/dialog-ab-trans.h
===================================================================
--- gnucash/trunk/src/import-export/aqbanking/dialog-ab-trans.h	2013-12-15 17:20:10 UTC (rev 23566)
+++ gnucash/trunk/src/import-export/aqbanking/dialog-ab-trans.h	2013-12-15 17:21:20 UTC (rev 23567)
@@ -1,153 +0,0 @@
-/*
- * dialog-ab-trans.h --
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation; either version 2 of
- * the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, contact:
- *
- * Free Software Foundation           Voice:  +1-617-542-5942
- * 51 Franklin Street, Fifth Floor    Fax:    +1-617-542-2652
- * Boston, MA  02110-1301,  USA       gnu at gnu.org
- */
-
-/**
- * @addtogroup Import_Export
- * @{
- * @addtogroup AqBanking
- * @{
- * @file dialog-ab-trans.h
- * @brief Dialog for AqBanking transaction data
- * @author Copyright (C) 2002 Christian Stimming <stimming at tuhh.de>
- * @author Copyright (C) 2004 Bernd Wagner
- * @author Copyright (C) 2006 David Hampton <hampton at employees.org>
- * @author Copyright (C) 2008 Andreas Koehler <andi5.py at gmx.net>
- */
-
-#ifndef DIALOG_AB_TRANS_H
-#define DIALOG_AB_TRANS_H
-
-#include <gtk/gtk.h>
-#include <aqbanking/banking.h>
-
-#include "Account.h"
-
-G_BEGIN_DECLS
-
-#define GNC_RESPONSE_NOW GTK_RESPONSE_YES
-#define GNC_RESPONSE_LATER GTK_RESPONSE_NO
-
-typedef struct _GncABTransDialog GncABTransDialog;
-
-typedef enum _GncABTransType GncABTransType;
-enum _GncABTransType
-{
-    SINGLE_TRANSFER = 0,
-    SINGLE_DEBITNOTE,
-    SINGLE_INTERNAL_TRANSFER
-    , SEPA_TRANSFER
-    , SEPA_DEBITNOTE
-};
-/**
-  * Returns true if the given GncABTransType is an European (SEPA) transaction
-  * (transfer or debit note), otherwise false.
-  */
-gboolean gnc_ab_trans_isSEPA(GncABTransType t);
-
-/**
- * Create a new AqBanking transfer dialog
- *
- * @param parent Widget to use as parent, may be NULL
- * @param ab_acc Aqbanking account
- * @param commodity_scu commodity used for the amount
- * @param trans_type Type of transaction
- * @param templates A GList of template transactions which will become fully
- * managed by the dialog, so do not free it and retrieve snapshots via
- * gnc_ab_trans_dialog_get_templ()
- * @return A new GncABTransDialog, free with gnc_ab_trans_dialog_free()
- */
-GncABTransDialog *gnc_ab_trans_dialog_new(GtkWidget *parent, AB_ACCOUNT *ab_acc,
-        gint commodity_scu,
-        GncABTransType trans_type,
-        GList *templates);
-
-/**
- * Run the Aqbanking transfer dialog until correct values where entered or
- * the user cancelled the dialog.
- *
- * @param td Transaction dialog
- * @param ab_acc AqBanking account
- * @return GTK_RESPONSE_CANCEL or GTK_RESPONSE_DESTROY_EVENT if the user cancelled the dialog
- * and GNC_RESPONSE_NOW otherwise.
- */
-gint gnc_ab_trans_dialog_run_until_ok(GncABTransDialog *td);
-
-/**
- * Free a Aqbanking transfer dialog
- *
- * @param td Transaction dialog
- */
-void gnc_ab_trans_dialog_free(GncABTransDialog *td);
-
-/**
- * Retrieve the current list of transaction templates from the dialog @a
- * td, unless @a changed is a specified location and the templates have
- * not been touched by the user.
- *
- * @param td Transaction dialog
- * @param changed Location to store whether the templates have been
- * changed, may be NULL
- * @return The a newly allocated list of the internal transaction
- * templates. Free this one via g_list_free().
- */
-GList *gnc_ab_trans_dialog_get_templ(const GncABTransDialog *td,
-                                     gboolean *changed);
-
-/**
- * Retrieve the widget used as parent.
- *
- * @param td Transaction dialog
- * @return The parent
- */
-GtkWidget *gnc_ab_trans_dialog_get_parent(const GncABTransDialog *td);
-
-/**
- * Receive the Aqbanking Transaction filled by the dialog
- *
- * @param td Transaction dialog
- * @return An Aqbanking transaction
- */
-const AB_TRANSACTION *gnc_ab_trans_dialog_get_ab_trans(
-    const GncABTransDialog *td);
-
-/**
- * Receive the Aqbanking job associated with the transaction
- *
- * @param td Transaction dialog
- * @return An Aqbanking job
- */
-AB_JOB *gnc_ab_trans_dialog_get_job(const GncABTransDialog *td);
-
-/**
- * FIXME
- *
- * @param td Transaction dialog
- * @return FIXME
- */
-AB_JOB *gnc_ab_get_trans_job(AB_ACCOUNT *ab_acc, const AB_TRANSACTION *ab_trans,
-                             GncABTransType trans_type);
-
-G_END_DECLS
-
-/** @} */
-/** @} */
-
-#endif /* DIALOG_AB_TRANS_H */

Deleted: gnucash/trunk/src/import-export/aqbanking/dialog-ab.glade
===================================================================
--- gnucash/trunk/src/import-export/aqbanking/dialog-ab.glade	2013-12-15 17:20:10 UTC (rev 23566)
+++ gnucash/trunk/src/import-export/aqbanking/dialog-ab.glade	2013-12-15 17:21:20 UTC (rev 23567)
@@ -1,1868 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<interface>
-  <requires lib="gtk+" version="2.16"/>
-  <object class="GtkDialog" id="Connection Dialog">
-    <property name="can_focus">False</property>
-    <property name="border_width">5</property>
-    <property name="title" translatable="yes">Online Banking Connection Window</property>
-    <property name="default_width">350</property>
-    <property name="default_height">420</property>
-    <property name="type_hint">dialog</property>
-    <signal name="delete-event" handler="ggg_delete_event_cb" swapped="no"/>
-    <child internal-child="vbox">
-      <object class="GtkBox" id="dialog-vbox9">
-        <property name="visible">True</property>
-        <property name="can_focus">False</property>
-        <property name="spacing">2</property>
-        <child internal-child="action_area">
-          <object class="GtkButtonBox" id="dialog-action_area9">
-            <property name="visible">True</property>
-            <property name="can_focus">False</property>
-            <property name="layout_style">end</property>
-            <child>
-              <object class="GtkButton" id="abort_button">
-                <property name="label">gtk-cancel</property>
-                <property name="visible">True</property>
-                <property name="sensitive">False</property>
-                <property name="can_focus">True</property>
-                <property name="can_default">True</property>
-                <property name="receives_default">True</property>
-                <property name="use_action_appearance">False</property>
-                <property name="use_stock">True</property>
-                <signal name="clicked" handler="ggg_abort_clicked_cb" swapped="no"/>
-              </object>
-              <packing>
-                <property name="expand">False</property>
-                <property name="fill">False</property>
-                <property name="position">0</property>
-              </packing>
-            </child>
-            <child>
-              <object class="GtkButton" id="close_button">
-                <property name="label">gtk-close</property>
-                <property name="visible">True</property>
-                <property name="can_focus">True</property>
-                <property name="can_default">True</property>
-                <property name="receives_default">True</property>
-                <property name="use_action_appearance">False</property>
-                <property name="use_stock">True</property>
-                <signal name="clicked" handler="ggg_close_clicked_cb" swapped="no"/>
-              </object>
-              <packing>
-                <property name="expand">False</property>
-                <property name="fill">False</property>
-                <property name="position">1</property>
-              </packing>
-            </child>
-          </object>
-          <packing>
-            <property name="expand">False</property>
-            <property name="fill">True</property>
-            <property name="pack_type">end</property>
-            <property name="position">0</property>
-          </packing>
-        </child>
-        <child>
-          <object class="GtkVBox" id="vbox149">
-            <property name="visible">True</property>
-            <property name="can_focus">False</property>
-            <property name="border_width">5</property>
-            <property name="spacing">18</property>
-            <child>
-              <object class="GtkVBox" id="vbox160">
-                <property name="visible">True</property>
-                <property name="can_focus">False</property>
-                <property name="spacing">6</property>
-                <child>
-                  <object class="GtkLabel" id="label8877443">
-                    <property name="visible">True</property>
-                    <property name="can_focus">False</property>
-                    <property name="xalign">0</property>
-                    <property name="label" translatable="yes"><b>Progress</b></property>
-                    <property name="use_markup">True</property>
-                  </object>
-                  <packing>
-                    <property name="expand">False</property>
-                    <property name="fill">False</property>
-                    <property name="position">0</property>
-                  </packing>
-                </child>
-                <child>
-                  <object class="GtkAlignment" id="alignment2">
-                    <property name="visible">True</property>
-                    <property name="can_focus">False</property>
-                    <property name="left_padding">12</property>
-                    <child>
-                      <object class="GtkTable" id="entries_table">
-                        <property name="visible">True</property>
-                        <property name="can_focus">False</property>
-                        <property name="n_rows">3</property>
-                        <property name="n_columns">2</property>
-                        <property name="column_spacing">12</property>
-                        <property name="row_spacing">6</property>
-                        <child>
-                          <object class="GtkLabel" id="label8877424">
-                            <property name="visible">True</property>
-                            <property name="can_focus">False</property>
-                            <property name="xalign">0</property>
-                            <property name="label" translatable="yes">Current Job</property>
-                            <property name="justify">center</property>
-                          </object>
-                          <packing>
-                            <property name="x_options">GTK_FILL</property>
-                            <property name="y_options"></property>
-                          </packing>
-                        </child>
-                        <child>
-                          <object class="GtkEntry" id="top_entry">
-                            <property name="visible">True</property>
-                            <property name="can_focus">True</property>
-                            <property name="invisible_char">●</property>
-                            <property name="invisible_char_set">True</property>
-                            <property name="primary_icon_activatable">False</property>
-                            <property name="secondary_icon_activatable">False</property>
-                          </object>
-                          <packing>
-                            <property name="left_attach">1</property>
-                            <property name="right_attach">2</property>
-                            <property name="y_options"></property>
-                          </packing>
-                        </child>
-                        <child>
-                          <object class="GtkProgressBar" id="top_progress">
-                            <property name="visible">True</property>
-                            <property name="sensitive">False</property>
-                            <property name="can_focus">False</property>
-                            <property name="pulse_step">0.10000000149</property>
-                          </object>
-                          <packing>
-                            <property name="left_attach">1</property>
-                            <property name="right_attach">2</property>
-                            <property name="top_attach">1</property>
-                            <property name="bottom_attach">2</property>
-                            <property name="x_options">GTK_FILL</property>
-                            <property name="y_options"></property>
-                          </packing>
-                        </child>
-                        <child>
-                          <object class="GtkLabel" id="label8877426">
-                            <property name="visible">True</property>
-                            <property name="can_focus">False</property>
-                            <property name="xalign">0</property>
-                            <property name="label" translatable="yes">Progress</property>
-                            <property name="justify">center</property>
-                          </object>
-                          <packing>
-                            <property name="top_attach">1</property>
-                            <property name="bottom_attach">2</property>
-                            <property name="x_options">GTK_FILL</property>
-                            <property name="y_options"></property>
-                          </packing>
-                        </child>
-                        <child>
-                          <object class="GtkLabel" id="label8877425">
-                            <property name="visible">True</property>
-                            <property name="can_focus">False</property>
-                            <property name="xalign">0</property>
-                            <property name="label" translatable="yes">Current Action</property>
-                            <property name="justify">center</property>
-                          </object>
-                          <packing>
-                            <property name="top_attach">2</property>
-                            <property name="bottom_attach">3</property>
-                            <property name="x_options">GTK_FILL</property>
-                            <property name="y_options"></property>
-                          </packing>
-                        </child>
-                        <child>
-                          <object class="GtkEntry" id="second_entry">
-                            <property name="visible">True</property>
-                            <property name="can_focus">True</property>
-                            <property name="invisible_char">●</property>
-                            <property name="invisible_char_set">True</property>
-                            <property name="primary_icon_activatable">False</property>
-                            <property name="secondary_icon_activatable">False</property>
-                          </object>
-                          <packing>
-                            <property name="left_attach">1</property>
-                            <property name="right_attach">2</property>
-                            <property name="top_attach">2</property>
-                            <property name="bottom_attach">3</property>
-                            <property name="y_options"></property>
-                          </packing>
-                        </child>
-                      </object>
-                    </child>
-                  </object>
-                  <packing>
-                    <property name="expand">True</property>
-                    <property name="fill">True</property>
-                    <property name="position">1</property>
-                  </packing>
-                </child>
-              </object>
-              <packing>
-                <property name="expand">False</property>
-                <property name="fill">False</property>
-                <property name="position">0</property>
-              </packing>
-            </child>
-            <child>
-              <object class="GtkVBox" id="vbox162">
-                <property name="visible">True</property>
-                <property name="can_focus">False</property>
-                <property name="spacing">6</property>
-                <child>
-                  <object class="GtkLabel" id="label8877444">
-                    <property name="visible">True</property>
-                    <property name="can_focus">False</property>
-                    <property name="xalign">0</property>
-                    <property name="label" translatable="yes"><b>Log Messages</b></property>
-                    <property name="use_markup">True</property>
-                  </object>
-                  <packing>
-                    <property name="expand">False</property>
-                    <property name="fill">False</property>
-                    <property name="position">0</property>
-                  </packing>
-                </child>
-                <child>
-                  <object class="GtkAlignment" id="alignment1">
-                    <property name="visible">True</property>
-                    <property name="can_focus">False</property>
-                    <property name="left_padding">12</property>
-                    <child>
-                      <object class="GtkScrolledWindow" id="scrolledwindow30">
-                        <property name="visible">True</property>
-                        <property name="can_focus">True</property>
-                        <property name="shadow_type">in</property>
-                        <child>
-                          <object class="GtkTextView" id="log_text">
-                            <property name="visible">True</property>
-                            <property name="can_focus">True</property>
-                            <property name="editable">False</property>
-                            <property name="wrap_mode">word</property>
-                          </object>
-                        </child>
-                      </object>
-                    </child>
-                  </object>
-                  <packing>
-                    <property name="expand">True</property>
-                    <property name="fill">True</property>
-                    <property name="position">1</property>
-                  </packing>
-                </child>
-              </object>
-              <packing>
-                <property name="expand">True</property>
-                <property name="fill">True</property>
-                <property name="position">1</property>
-              </packing>
-            </child>
-            <child>
-              <object class="GtkCheckButton" id="close_checkbutton">
-                <property name="label" translatable="yes">Close when finished</property>
-                <property name="visible">True</property>
-                <property name="can_focus">True</property>
-                <property name="receives_default">False</property>
-                <property name="use_action_appearance">False</property>
-                <property name="use_underline">True</property>
-                <property name="active">True</property>
-                <property name="draw_indicator">True</property>
-                <signal name="toggled" handler="ggg_close_toggled_cb" swapped="no"/>
-              </object>
-              <packing>
-                <property name="expand">False</property>
-                <property name="fill">False</property>
-                <property name="position">2</property>
-              </packing>
-            </child>
-          </object>
-          <packing>
-            <property name="expand">True</property>
-            <property name="fill">True</property>
-            <property name="position">2</property>
-          </packing>
-        </child>
-      </object>
-    </child>
-    <action-widgets>
-      <action-widget response="0">abort_button</action-widget>
-      <action-widget response="0">close_button</action-widget>
-    </action-widgets>
-  </object>
-  <object class="GtkDialog" id="Date Range Dialog">
-    <property name="can_focus">False</property>
-    <property name="border_width">5</property>
-    <property name="title" translatable="yes">Get Transactions Online</property>
-    <property name="type_hint">dialog</property>
-    <child internal-child="vbox">
-      <object class="GtkBox" id="dialog-vbox1">
-        <property name="visible">True</property>
-        <property name="can_focus">False</property>
-        <property name="spacing">2</property>
-        <child internal-child="action_area">
-          <object class="GtkButtonBox" id="dialog-action_area1">
-            <property name="visible">True</property>
-            <property name="can_focus">False</property>
-            <property name="layout_style">end</property>
-            <child>
-              <object class="GtkButton" id="cancel_button1">
-                <property name="label">gtk-cancel</property>
-                <property name="visible">True</property>
-                <property name="can_focus">True</property>
-                <property name="can_default">True</property>
-                <property name="receives_default">True</property>
-                <property name="use_action_appearance">False</property>
-                <property name="use_stock">True</property>
-              </object>
-              <packing>
-                <property name="expand">False</property>
-                <property name="fill">False</property>
-                <property name="position">0</property>
-              </packing>
-            </child>
-            <child>
-              <object class="GtkButton" id="ok_button">
-                <property name="label">gtk-ok</property>
-                <property name="visible">True</property>
-                <property name="can_focus">True</property>
-                <property name="can_default">True</property>
-                <property name="receives_default">True</property>
-                <property name="use_action_appearance">False</property>
-                <property name="use_stock">True</property>
-              </object>
-              <packing>
-                <property name="expand">False</property>
-                <property name="fill">False</property>
-                <property name="position">1</property>
-              </packing>
-            </child>
-          </object>
-          <packing>
-            <property name="expand">False</property>
-            <property name="fill">True</property>
-            <property name="pack_type">end</property>
-            <property name="position">0</property>
-          </packing>
-        </child>
-        <child>
-          <object class="GtkVBox" id="vbox152">
-            <property name="visible">True</property>
-            <property name="can_focus">False</property>
-            <property name="border_width">5</property>
-            <property name="spacing">18</property>
-            <child>
-              <object class="GtkLabel" id="heading_label1">
-                <property name="visible">True</property>
-                <property name="can_focus">False</property>
-                <property name="label" translatable="yes">Date range of transactions to retrieve:</property>
-                <property name="justify">center</property>
-                <property name="wrap">True</property>
-              </object>
-              <packing>
-                <property name="expand">False</property>
-                <property name="fill">False</property>
-                <property name="position">0</property>
-              </packing>
-            </child>
-            <child>
-              <object class="GtkVBox" id="vbox163">
-                <property name="visible">True</property>
-                <property name="can_focus">False</property>
-                <property name="spacing">6</property>
-                <child>
-                  <object class="GtkLabel" id="label8877445">
-                    <property name="visible">True</property>
-                    <property name="can_focus">False</property>
-                    <property name="xalign">0</property>
-                    <property name="label" translatable="yes"><b>From</b></property>
-                    <property name="use_markup">True</property>
-                  </object>
-                  <packing>
-                    <property name="expand">False</property>
-                    <property name="fill">False</property>
-                    <property name="position">0</property>
-                  </packing>
-                </child>
-                <child>
-                  <object class="GtkAlignment" id="alignment9">
-                    <property name="visible">True</property>
-                    <property name="can_focus">False</property>
-                    <property name="left_padding">12</property>
-                    <child>
-                      <object class="GtkVBox" id="vbox164">
-                        <property name="visible">True</property>
-                        <property name="can_focus">False</property>
-                        <property name="spacing">6</property>
-                        <child>
-                          <object class="GtkRadioButton" id="first_button">
-                            <property name="label" translatable="yes">_Earliest possible date</property>
-                            <property name="visible">True</property>
-                            <property name="can_focus">True</property>
-                            <property name="receives_default">False</property>
-                            <property name="use_action_appearance">False</property>
-                            <property name="use_underline">True</property>
-                            <property name="active">True</property>
-                            <property name="draw_indicator">True</property>
-                          </object>
-                          <packing>
-                            <property name="expand">False</property>
-                            <property name="fill">False</property>
-                            <property name="position">0</property>
-                          </packing>
-                        </child>
-                        <child>
-                          <object class="GtkRadioButton" id="last_retrieval_button">
-                            <property name="label" translatable="yes">_Last retrieval date</property>
-                            <property name="visible">True</property>
-                            <property name="can_focus">True</property>
-                            <property name="receives_default">False</property>
-                            <property name="use_action_appearance">False</property>
-                            <property name="use_underline">True</property>
-                            <property name="draw_indicator">True</property>
-                            <property name="group">first_button</property>
-                          </object>
-                          <packing>
-                            <property name="expand">False</property>
-                            <property name="fill">False</property>
-                            <property name="position">1</property>
-                          </packing>
-                        </child>
-                        <child>
-                          <object class="GtkHBox" id="hbox123">
-                            <property name="visible">True</property>
-                            <property name="can_focus">False</property>
-                            <property name="spacing">12</property>
-                            <child>
-                              <object class="GtkRadioButton" id="enter_from_button">
-                                <property name="label" translatable="yes">E_nter date:</property>
-                                <property name="visible">True</property>
-                                <property name="can_focus">True</property>
-                                <property name="receives_default">False</property>
-                                <property name="use_action_appearance">False</property>
-                                <property name="use_underline">True</property>
-                                <property name="draw_indicator">True</property>
-                                <property name="group">first_button</property>
-                                <signal name="toggled" handler="ddr_toggled_cb" swapped="no"/>
-                              </object>
-                              <packing>
-                                <property name="expand">False</property>
-                                <property name="fill">False</property>
-                                <property name="position">0</property>
-                              </packing>
-                            </child>
-                            <child>
-                              <object class="GtkHBox" id="enter_from_box">
-                                <property name="visible">True</property>
-                                <property name="can_focus">False</property>
-                                <child>
-                                  <placeholder/>
-                                </child>
-                              </object>
-                              <packing>
-                                <property name="expand">True</property>
-                                <property name="fill">True</property>
-                                <property name="position">1</property>
-                              </packing>
-                            </child>
-                          </object>
-                          <packing>
-                            <property name="expand">False</property>
-                            <property name="fill">False</property>
-                            <property name="position">2</property>
-                          </packing>
-                        </child>
-                      </object>
-                    </child>
-                  </object>
-                  <packing>
-                    <property name="expand">True</property>
-                    <property name="fill">True</property>
-                    <property name="position">1</property>
-                  </packing>
-                </child>
-              </object>
-              <packing>
-                <property name="expand">False</property>
-                <property name="fill">False</property>
-                <property name="position">1</property>
-              </packing>
-            </child>
-            <child>
-              <object class="GtkVBox" id="vbox165">
-                <property name="visible">True</property>
-                <property name="can_focus">False</property>
-                <property name="spacing">6</property>
-                <child>
-                  <object class="GtkLabel" id="label8877446">
-                    <property name="visible">True</property>
-                    <property name="can_focus">False</property>
-                    <property name="xalign">0</property>
-                    <property name="label" translatable="yes"><b>To</b></property>
-                    <property name="use_markup">True</property>
-                  </object>
-                  <packing>
-                    <property name="expand">False</property>
-                    <property name="fill">False</property>
-                    <property name="position">0</property>
-                  </packing>
-                </child>
-                <child>
-                  <object class="GtkAlignment" id="alignment10">
-                    <property name="visible">True</property>
-                    <property name="can_focus">False</property>
-                    <property name="left_padding">12</property>
-                    <child>
-                      <object class="GtkVBox" id="vbox166">
-                        <property name="visible">True</property>
-                        <property name="can_focus">False</property>
-                        <property name="spacing">6</property>
-                        <child>
-                          <object class="GtkRadioButton" id="now_button">
-                            <property name="label" translatable="yes">_Now</property>
-                            <property name="visible">True</property>
-                            <property name="can_focus">True</property>
-                            <property name="receives_default">False</property>
-                            <property name="use_action_appearance">False</property>
-                            <property name="use_underline">True</property>
-                            <property name="active">True</property>
-                            <property name="draw_indicator">True</property>
-                          </object>
-                          <packing>
-                            <property name="expand">False</property>
-                            <property name="fill">False</property>
-                            <property name="position">0</property>
-                          </packing>
-                        </child>
-                        <child>
-                          <object class="GtkHBox" id="hbox124">
-                            <property name="visible">True</property>
-                            <property name="can_focus">False</property>
-                            <property name="spacing">12</property>
-                            <child>
-                              <object class="GtkRadioButton" id="enter_to_button">
-                                <property name="label" translatable="yes">Ente_r date:</property>
-                                <property name="visible">True</property>
-                                <property name="can_focus">True</property>
-                                <property name="receives_default">False</property>
-                                <property name="use_action_appearance">False</property>
-                                <property name="use_underline">True</property>
-                                <property name="draw_indicator">True</property>
-                                <property name="group">now_button</property>
-                                <signal name="toggled" handler="ddr_toggled_cb" swapped="no"/>
-                              </object>
-                              <packing>
-                                <property name="expand">False</property>
-                                <property name="fill">False</property>
-                                <property name="position">0</property>
-                              </packing>
-                            </child>
-                            <child>
-                              <object class="GtkHBox" id="enter_to_box">
-                                <property name="visible">True</property>
-                                <property name="can_focus">False</property>
-                                <child>
-                                  <placeholder/>
-                                </child>
-                              </object>
-                              <packing>
-                                <property name="expand">True</property>
-                                <property name="fill">True</property>
-                                <property name="position">1</property>
-                              </packing>
-                            </child>
-                          </object>
-                          <packing>
-                            <property name="expand">True</property>
-                            <property name="fill">True</property>
-                            <property name="position">1</property>
-                          </packing>
-                        </child>
-                      </object>
-                    </child>
-                  </object>
-                  <packing>
-                    <property name="expand">True</property>
-                    <property name="fill">True</property>
-                    <property name="position">1</property>
-                  </packing>
-                </child>
-              </object>
-              <packing>
-                <property name="expand">False</property>
-                <property name="fill">False</property>
-                <property name="position">2</property>
-              </packing>
-            </child>
-          </object>
-          <packing>
-            <property name="expand">True</property>
-            <property name="fill">True</property>
-            <property name="position">2</property>
-          </packing>
-        </child>
-      </object>
-    </child>
-    <action-widgets>
-      <action-widget response="-6">cancel_button1</action-widget>
-      <action-widget response="-5">ok_button</action-widget>
-    </action-widgets>
-  </object>
-  <object class="GtkDialog" id="Password Dialog">
-    <property name="can_focus">False</property>
-    <property name="border_width">5</property>
-    <property name="title" translatable="yes">Enter Password</property>
-    <property name="type_hint">dialog</property>
-    <child internal-child="vbox">
-      <object class="GtkBox" id="dialog-vbox3">
-        <property name="visible">True</property>
-        <property name="can_focus">False</property>
-        <child internal-child="action_area">
-          <object class="GtkButtonBox" id="dialog-action_area3">
-            <property name="visible">True</property>
-            <property name="can_focus">False</property>
-            <property name="layout_style">end</property>
-            <child>
-              <object class="GtkButton" id="cancelbutton2">
-                <property name="label">gtk-cancel</property>
-                <property name="visible">True</property>
-                <property name="can_focus">True</property>
-                <property name="can_default">True</property>
-                <property name="receives_default">True</property>
-                <property name="use_action_appearance">False</property>
-                <property name="use_stock">True</property>
-              </object>
-              <packing>
-                <property name="expand">False</property>
-                <property name="fill">False</property>
-                <property name="position">0</property>
-              </packing>
-            </child>
-            <child>
-              <object class="GtkButton" id="okbutton2">
-                <property name="label">gtk-ok</property>
-                <property name="visible">True</property>
-                <property name="can_focus">True</property>
-                <property name="can_default">True</property>
-                <property name="receives_default">True</property>
-                <property name="use_action_appearance">False</property>
-                <property name="use_stock">True</property>
-              </object>
-              <packing>
-                <property name="expand">False</property>
-                <property name="fill">False</property>
-                <property name="position">1</property>
-              </packing>
-            </child>
-          </object>
-          <packing>
-            <property name="expand">False</property>
-            <property name="fill">True</property>
-            <property name="pack_type">end</property>
-            <property name="position">0</property>
-          </packing>
-        </child>
-        <child>
-          <object class="GtkVBox" id="vbox167">
-            <property name="visible">True</property>
-            <property name="can_focus">False</property>
-            <property name="border_width">5</property>
-            <property name="spacing">18</property>
-            <child>
-              <object class="GtkLabel" id="heading_pw_label">
-                <property name="visible">True</property>
-                <property name="can_focus">False</property>
-                <property name="label" translatable="yes">Enter your password</property>
-                <property name="wrap">True</property>
-              </object>
-              <packing>
-                <property name="expand">False</property>
-                <property name="fill">False</property>
-                <property name="position">0</property>
-              </packing>
-            </child>
-            <child>
-              <object class="GtkTable" id="table7">
-                <property name="visible">True</property>
-                <property name="can_focus">False</property>
-                <property name="n_rows">3</property>
-                <property name="n_columns">2</property>
-                <property name="column_spacing">12</property>
-                <property name="row_spacing">6</property>
-                <child>
-                  <object class="GtkLabel" id="label8877456">
-                    <property name="visible">True</property>
-                    <property name="can_focus">False</property>
-                    <property name="xalign">0</property>
-                    <property name="label" translatable="yes">Password:</property>
-                  </object>
-                  <packing>
-                    <property name="x_options">GTK_FILL</property>
-                    <property name="y_options"></property>
-                  </packing>
-                </child>
-                <child>
-                  <object class="GtkLabel" id="confirm_label">
-                    <property name="visible">True</property>
-                    <property name="can_focus">False</property>
-                    <property name="xalign">0</property>
-                    <property name="label" translatable="yes">Confirm Password:</property>
-                  </object>
-                  <packing>
-                    <property name="top_attach">1</property>
-                    <property name="bottom_attach">2</property>
-                    <property name="x_options">GTK_FILL</property>
-                    <property name="y_options"></property>
-                  </packing>
-                </child>
-                <child>
-                  <object class="GtkEntry" id="input_entry">
-                    <property name="visible">True</property>
-                    <property name="can_focus">True</property>
-                    <property name="visibility">False</property>
-                    <property name="invisible_char">●</property>
-                    <property name="invisible_char_set">True</property>
-                    <property name="primary_icon_activatable">False</property>
-                    <property name="secondary_icon_activatable">False</property>
-                  </object>
-                  <packing>
-                    <property name="left_attach">1</property>
-                    <property name="right_attach">2</property>
-                    <property name="y_options"></property>
-                  </packing>
-                </child>
-                <child>
-                  <object class="GtkEntry" id="confirm_entry">
-                    <property name="visible">True</property>
-                    <property name="can_focus">True</property>
-                    <property name="visibility">False</property>
-                    <property name="invisible_char">●</property>
-                    <property name="invisible_char_set">True</property>
-                    <property name="primary_icon_activatable">False</property>
-                    <property name="secondary_icon_activatable">False</property>
-                  </object>
-                  <packing>
-                    <property name="left_attach">1</property>
-                    <property name="right_attach">2</property>
-                    <property name="top_attach">1</property>
-                    <property name="bottom_attach">2</property>
-                    <property name="y_options"></property>
-                  </packing>
-                </child>
-                <child>
-                  <object class="GtkCheckButton" id="remember_pin">
-                    <property name="label" translatable="yes">Remember _PIN</property>
-                    <property name="visible">True</property>
-                    <property name="can_focus">True</property>
-                    <property name="receives_default">False</property>
-                    <property name="use_action_appearance">False</property>
-                    <property name="use_underline">True</property>
-                    <property name="draw_indicator">True</property>
-                  </object>
-                  <packing>
-                    <property name="right_attach">2</property>
-                    <property name="top_attach">2</property>
-                    <property name="bottom_attach">3</property>
-                    <property name="x_options">GTK_FILL</property>
-                    <property name="y_options"></property>
-                  </packing>
-                </child>
-              </object>
-              <packing>
-                <property name="expand">True</property>
-                <property name="fill">True</property>
-                <property name="position">1</property>
-              </packing>
-            </child>
-          </object>
-          <packing>
-            <property name="expand">True</property>
-            <property name="fill">True</property>
-            <property name="position">2</property>
-          </packing>
-        </child>
-      </object>
-    </child>
-    <action-widgets>
-      <action-widget response="-6">cancelbutton2</action-widget>
-      <action-widget response="-5">okbutton2</action-widget>
-    </action-widgets>
-  </object>
-  <object class="GtkWindow" id="Preferences">
-    <property name="visible">True</property>
-    <property name="can_focus">False</property>
-    <property name="title" translatable="yes">window1</property>
-    <child>
-      <object class="GtkTable" id="aqbanking_prefs">
-        <property name="visible">True</property>
-        <property name="can_focus">False</property>
-        <property name="n_rows">4</property>
-        <property name="n_columns">4</property>
-        <child>
-          <object class="GtkLabel" id="label8877457">
-            <property name="visible">True</property>
-            <property name="can_focus">False</property>
-            <property name="xalign">0</property>
-            <property name="label" translatable="yes"><b>Online Banking</b></property>
-            <property name="use_markup">True</property>
-          </object>
-          <packing>
-            <property name="right_attach">4</property>
-            <property name="x_options">GTK_FILL</property>
-            <property name="y_options"></property>
-          </packing>
-        </child>
-        <child>
-          <object class="GtkCheckButton" id="pref/dialogs.import.hbci/close-on-finish">
-            <property name="label" translatable="yes">_Close log window when finished</property>
-            <property name="visible">True</property>
-            <property name="can_focus">True</property>
-            <property name="receives_default">False</property>
-            <property name="use_action_appearance">False</property>
-            <property name="use_underline">True</property>
-            <property name="draw_indicator">True</property>
-          </object>
-          <packing>
-            <property name="right_attach">4</property>
-            <property name="top_attach">1</property>
-            <property name="bottom_attach">2</property>
-            <property name="x_options">GTK_FILL</property>
-            <property name="y_options"></property>
-            <property name="x_padding">12</property>
-          </packing>
-        </child>
-        <child>
-          <object class="GtkCheckButton" id="pref/dialogs.import.hbci/remember-pin">
-            <property name="label" translatable="yes">Remember _PIN</property>
-            <property name="visible">True</property>
-            <property name="can_focus">True</property>
-            <property name="receives_default">False</property>
-            <property name="use_action_appearance">False</property>
-            <property name="use_underline">True</property>
-            <property name="draw_indicator">True</property>
-          </object>
-          <packing>
-            <property name="right_attach">4</property>
-            <property name="top_attach">2</property>
-            <property name="bottom_attach">3</property>
-            <property name="x_options">GTK_FILL</property>
-            <property name="y_options"></property>
-            <property name="x_padding">12</property>
-          </packing>
-        </child>
-        <child>
-          <object class="GtkCheckButton" id="checkbutton3">
-            <property name="label" translatable="yes">_Verbose debug messages</property>
-            <property name="visible">True</property>
-            <property name="can_focus">True</property>
-            <property name="receives_default">False</property>
-            <property name="use_action_appearance">False</property>
-            <property name="use_underline">True</property>
-            <property name="draw_indicator">True</property>
-          </object>
-          <packing>
-            <property name="right_attach">4</property>
-            <property name="top_attach">3</property>
-            <property name="bottom_attach">4</property>
-            <property name="x_options">GTK_FILL</property>
-            <property name="y_options"></property>
-            <property name="x_padding">12</property>
-          </packing>
-        </child>
-      </object>
-    </child>
-  </object>
-  <object class="GtkDialog" id="Template Name Dialog">
-    <property name="can_focus">False</property>
-    <property name="border_width">5</property>
-    <property name="title" translatable="yes">Name for new template</property>
-    <property name="type_hint">dialog</property>
-    <child internal-child="vbox">
-      <object class="GtkBox" id="dialog-vbox2">
-        <property name="visible">True</property>
-        <property name="can_focus">False</property>
-        <child internal-child="action_area">
-          <object class="GtkButtonBox" id="dialog-action_area2">
-            <property name="visible">True</property>
-            <property name="can_focus">False</property>
-            <property name="layout_style">end</property>
-            <child>
-              <object class="GtkButton" id="cancelbutton1">
-                <property name="label">gtk-cancel</property>
-                <property name="visible">True</property>
-                <property name="can_focus">True</property>
-                <property name="can_default">True</property>
-                <property name="receives_default">True</property>
-                <property name="use_action_appearance">False</property>
-                <property name="use_stock">True</property>
-              </object>
-              <packing>
-                <property name="expand">False</property>
-                <property name="fill">False</property>
-                <property name="position">0</property>
-              </packing>
-            </child>
-            <child>
-              <object class="GtkButton" id="okbutton1">
-                <property name="label">gtk-ok</property>
-                <property name="visible">True</property>
-                <property name="can_focus">True</property>
-                <property name="can_default">True</property>
-                <property name="has_default">True</property>
-                <property name="receives_default">True</property>
-                <property name="use_action_appearance">False</property>
-                <property name="use_stock">True</property>
-              </object>
-              <packing>
-                <property name="expand">False</property>
-                <property name="fill">False</property>
-                <property name="position">1</property>
-              </packing>
-            </child>
-          </object>
-          <packing>
-            <property name="expand">False</property>
-            <property name="fill">True</property>
-            <property name="pack_type">end</property>
-            <property name="position">0</property>
-          </packing>
-        </child>
-        <child>
-          <object class="GtkVBox" id="vbox159">
-            <property name="visible">True</property>
-            <property name="can_focus">False</property>
-            <property name="border_width">5</property>
-            <property name="spacing">12</property>
-            <child>
-              <object class="GtkLabel" id="label8877450">
-                <property name="visible">True</property>
-                <property name="can_focus">False</property>
-                <property name="label" translatable="yes">Enter name for new template:</property>
-              </object>
-              <packing>
-                <property name="expand">False</property>
-                <property name="fill">False</property>
-                <property name="position">0</property>
-              </packing>
-            </child>
-            <child>
-              <object class="GtkEntry" id="template_name">
-                <property name="visible">True</property>
-                <property name="can_focus">True</property>
-                <property name="max_length">250</property>
-                <property name="invisible_char">●</property>
-                <property name="activates_default">True</property>
-                <property name="invisible_char_set">True</property>
-                <property name="primary_icon_activatable">False</property>
-                <property name="secondary_icon_activatable">False</property>
-              </object>
-              <packing>
-                <property name="expand">False</property>
-                <property name="fill">False</property>
-                <property name="position">1</property>
-              </packing>
-            </child>
-          </object>
-          <packing>
-            <property name="expand">True</property>
-            <property name="fill">True</property>
-            <property name="position">2</property>
-          </packing>
-        </child>
-      </object>
-    </child>
-    <action-widgets>
-      <action-widget response="-6">cancelbutton1</action-widget>
-      <action-widget response="-5">okbutton1</action-widget>
-    </action-widgets>
-  </object>
-  <object class="GtkDialog" id="Transaction Dialog">
-    <property name="can_focus">False</property>
-    <property name="border_width">5</property>
-    <property name="title" translatable="yes">Online Transaction</property>
-    <property name="type_hint">dialog</property>
-    <child internal-child="vbox">
-      <object class="GtkBox" id="dialog-vbox7">
-        <property name="visible">True</property>
-        <property name="can_focus">False</property>
-        <property name="orientation">vertical</property>
-        <property name="spacing">2</property>
-        <child>
-          <object class="GtkVBox" id="trans_vbox">
-            <property name="visible">True</property>
-            <property name="can_focus">False</property>
-            <property name="border_width">5</property>
-            <child>
-              <object class="GtkLabel" id="heading_label">
-                <property name="visible">True</property>
-                <property name="can_focus">False</property>
-                <property name="label" translatable="yes">Enter an Online Transaction</property>
-                <property name="justify">center</property>
-              </object>
-              <packing>
-                <property name="expand">False</property>
-                <property name="fill">False</property>
-                <property name="position">0</property>
-              </packing>
-            </child>
-            <child>
-              <object class="GtkTable" id="table6">
-                <property name="visible">True</property>
-                <property name="can_focus">False</property>
-                <property name="n_rows">21</property>
-                <property name="n_columns">3</property>
-                <child>
-                  <object class="GtkEntry" id="recp_account_entry">
-                    <property name="visible">True</property>
-                    <property name="can_focus">True</property>
-                    <property name="max_length">12</property>
-                    <property name="invisible_char">●</property>
-                    <property name="invisible_char_set">True</property>
-                    <property name="primary_icon_activatable">False</property>
-                    <property name="secondary_icon_activatable">False</property>
-                    <signal name="changed" handler="gnc_ab_trans_dialog_verify_values" swapped="yes"/>
-                    <signal name="insert-text" handler="gnc_ab_trans_dialog_entry_filter_cb" swapped="no"/>
-                  </object>
-                  <packing>
-                    <property name="top_attach">3</property>
-                    <property name="bottom_attach">4</property>
-                    <property name="y_options"></property>
-                  </packing>
-                </child>
-                <child>
-                  <object class="GtkLabel" id="recp_account_heading">
-                    <property name="visible">True</property>
-                    <property name="can_focus">False</property>
-                    <property name="xalign">0</property>
-                    <property name="label" translatable="yes">Recipient Account Number</property>
-                  </object>
-                  <packing>
-                    <property name="top_attach">2</property>
-                    <property name="bottom_attach">3</property>
-                    <property name="x_options">GTK_FILL</property>
-                    <property name="y_options"></property>
-                  </packing>
-                </child>
-                <child>
-                  <object class="GtkEntry" id="recp_bankcode_entry">
-                    <property name="visible">True</property>
-                    <property name="can_focus">True</property>
-                    <property name="max_length">8</property>
-                    <property name="invisible_char">●</property>
-                    <property name="invisible_char_set">True</property>
-                    <property name="primary_icon_activatable">False</property>
-                    <property name="secondary_icon_activatable">False</property>
-                    <signal name="changed" handler="gnc_ab_trans_dialog_bankcode_changed_cb" swapped="no"/>
-                    <signal name="insert-text" handler="gnc_ab_trans_dialog_entry_filter_cb" swapped="no"/>
-                  </object>
-                  <packing>
-                    <property name="left_attach">2</property>
-                    <property name="right_attach">3</property>
-                    <property name="top_attach">3</property>
-                    <property name="bottom_attach">4</property>
-                    <property name="y_options"></property>
-                  </packing>
-                </child>
-                <child>
-                  <object class="GtkLabel" id="recp_bankcode_heading">
-                    <property name="visible">True</property>
-                    <property name="can_focus">False</property>
-                    <property name="xalign">0</property>
-                    <property name="label" translatable="yes">Recipient Bank Code</property>
-                  </object>
-                  <packing>
-                    <property name="left_attach">2</property>
-                    <property name="right_attach">3</property>
-                    <property name="top_attach">2</property>
-                    <property name="bottom_attach">3</property>
-                    <property name="x_options">GTK_FILL</property>
-                    <property name="y_options"></property>
-                  </packing>
-                </child>
-                <child>
-                  <object class="GtkEntry" id="recp_name_entry">
-                    <property name="visible">True</property>
-                    <property name="can_focus">True</property>
-                    <property name="max_length">27</property>
-                    <property name="invisible_char">●</property>
-                    <property name="invisible_char_set">True</property>
-                    <property name="primary_icon_activatable">False</property>
-                    <property name="secondary_icon_activatable">False</property>
-                    <signal name="changed" handler="gnc_ab_trans_dialog_verify_values" swapped="yes"/>
-                  </object>
-                  <packing>
-                    <property name="right_attach">3</property>
-                    <property name="top_attach">1</property>
-                    <property name="bottom_attach">2</property>
-                    <property name="y_options"></property>
-                  </packing>
-                </child>
-                <child>
-                  <object class="GtkLabel" id="recp_name_heading">
-                    <property name="visible">True</property>
-                    <property name="can_focus">False</property>
-                    <property name="xalign">0</property>
-                    <property name="label" translatable="yes">Recipient Name</property>
-                    <property name="justify">center</property>
-                  </object>
-                  <packing>
-                    <property name="right_attach">3</property>
-                    <property name="x_options">GTK_FILL</property>
-                    <property name="y_options"></property>
-                  </packing>
-                </child>
-                <child>
-                  <object class="GtkLabel" id="recp_bankname_heading">
-                    <property name="visible">True</property>
-                    <property name="can_focus">False</property>
-                    <property name="xalign">0</property>
-                    <property name="label" translatable="yes">at Bank</property>
-                  </object>
-                  <packing>
-                    <property name="right_attach">3</property>
-                    <property name="top_attach">4</property>
-                    <property name="bottom_attach">5</property>
-                    <property name="x_options">GTK_FILL</property>
-                    <property name="y_options"></property>
-                  </packing>
-                </child>
-                <child>
-                  <object class="GtkLabel" id="recp_bankname_label">
-                    <property name="visible">True</property>
-                    <property name="can_focus">False</property>
-                    <property name="xalign">0</property>
-                    <property name="label" translatable="yes">(filled in automatically)</property>
-                    <property name="justify">center</property>
-                  </object>
-                  <packing>
-                    <property name="right_attach">3</property>
-                    <property name="top_attach">5</property>
-                    <property name="bottom_attach">6</property>
-                    <property name="x_options">GTK_FILL</property>
-                    <property name="y_options"></property>
-                  </packing>
-                </child>
-                <child>
-                  <object class="GtkLabel" id="label8877434">
-                    <property name="visible">True</property>
-                    <property name="can_focus">False</property>
-                    <property name="xalign">0</property>
-                    <property name="label" translatable="yes">Amount</property>
-                    <property name="justify">center</property>
-                  </object>
-                  <packing>
-                    <property name="top_attach">7</property>
-                    <property name="bottom_attach">8</property>
-                    <property name="x_options">GTK_FILL</property>
-                    <property name="y_options"></property>
-                  </packing>
-                </child>
-                <child>
-                  <object class="GtkLabel" id="label8877433">
-                    <property name="visible">True</property>
-                    <property name="can_focus">False</property>
-                    <property name="xalign">0</property>
-                    <property name="label" translatable="yes">Payment Purpose (only for recipient)</property>
-                    <property name="justify">center</property>
-                  </object>
-                  <packing>
-                    <property name="right_attach">3</property>
-                    <property name="top_attach">10</property>
-                    <property name="bottom_attach">11</property>
-                    <property name="x_options">GTK_FILL</property>
-                    <property name="y_options"></property>
-                  </packing>
-                </child>
-                <child>
-                  <object class="GtkLabel" id="label8877435">
-                    <property name="visible">True</property>
-                    <property name="can_focus">False</property>
-                    <property name="xalign">0</property>
-                    <property name="label" translatable="yes">Payment Purpose continued</property>
-                    <property name="justify">center</property>
-                  </object>
-                  <packing>
-                    <property name="right_attach">3</property>
-                    <property name="top_attach">12</property>
-                    <property name="bottom_attach">13</property>
-                    <property name="x_options">GTK_FILL</property>
-                    <property name="y_options"></property>
-                  </packing>
-                </child>
-                <child>
-                  <object class="GtkLabel" id="orig_name_heading">
-                    <property name="visible">True</property>
-                    <property name="can_focus">False</property>
-                    <property name="xalign">0</property>
-                    <property name="label" translatable="yes">Originator Name</property>
-                  </object>
-                  <packing>
-                    <property name="top_attach">15</property>
-                    <property name="bottom_attach">16</property>
-                    <property name="x_options">GTK_FILL</property>
-                    <property name="y_options"></property>
-                  </packing>
-                </child>
-                <child>
-                  <object class="GtkLabel" id="orig_name_label">
-                    <property name="visible">True</property>
-                    <property name="can_focus">False</property>
-                    <property name="xalign">0</property>
-                    <property name="label" translatable="yes">something</property>
-                  </object>
-                  <packing>
-                    <property name="top_attach">16</property>
-                    <property name="bottom_attach">17</property>
-                    <property name="x_options">GTK_FILL</property>
-                    <property name="y_options"></property>
-                  </packing>
-                </child>
-                <child>
-                  <object class="GtkLabel" id="orig_bankname_heading">
-                    <property name="visible">True</property>
-                    <property name="can_focus">False</property>
-                    <property name="xalign">0</property>
-                    <property name="label" translatable="yes">at Bank</property>
-                  </object>
-                  <packing>
-                    <property name="top_attach">17</property>
-                    <property name="bottom_attach">18</property>
-                    <property name="x_options">GTK_FILL</property>
-                    <property name="y_options"></property>
-                  </packing>
-                </child>
-                <child>
-                  <object class="GtkLabel" id="orig_bankname_label">
-                    <property name="visible">True</property>
-                    <property name="can_focus">False</property>
-                    <property name="xalign">0</property>
-                    <property name="label" translatable="yes">something</property>
-                  </object>
-                  <packing>
-                    <property name="top_attach">18</property>
-                    <property name="bottom_attach">19</property>
-                    <property name="x_options">GTK_FILL</property>
-                    <property name="y_options"></property>
-                  </packing>
-                </child>
-                <child>
-                  <object class="GtkLabel" id="orig_account_heading">
-                    <property name="visible">True</property>
-                    <property name="can_focus">False</property>
-                    <property name="xalign">0</property>
-                    <property name="label" translatable="yes">Originator Account Number</property>
-                  </object>
-                  <packing>
-                    <property name="left_attach">2</property>
-                    <property name="right_attach">3</property>
-                    <property name="top_attach">15</property>
-                    <property name="bottom_attach">16</property>
-                    <property name="x_options">GTK_FILL</property>
-                    <property name="y_options"></property>
-                  </packing>
-                </child>
-                <child>
-                  <object class="GtkLabel" id="orig_account_label">
-                    <property name="visible">True</property>
-                    <property name="can_focus">False</property>
-                    <property name="xalign">0</property>
-                    <property name="label" translatable="yes">something</property>
-                  </object>
-                  <packing>
-                    <property name="left_attach">2</property>
-                    <property name="right_attach">3</property>
-                    <property name="top_attach">16</property>
-                    <property name="bottom_attach">17</property>
-                    <property name="x_options">GTK_FILL</property>
-                    <property name="y_options"></property>
-                  </packing>
-                </child>
-                <child>
-                  <object class="GtkLabel" id="orig_bankcode_heading">
-                    <property name="visible">True</property>
-                    <property name="can_focus">False</property>
-                    <property name="xalign">0</property>
-                    <property name="label" translatable="yes">Bank Code</property>
-                  </object>
-                  <packing>
-                    <property name="left_attach">2</property>
-                    <property name="right_attach">3</property>
-                    <property name="top_attach">17</property>
-                    <property name="bottom_attach">18</property>
-                    <property name="x_options">GTK_FILL</property>
-                    <property name="y_options"></property>
-                  </packing>
-                </child>
-                <child>
-                  <object class="GtkLabel" id="orig_bankcode_label">
-                    <property name="visible">True</property>
-                    <property name="can_focus">False</property>
-                    <property name="xalign">0</property>
-                    <property name="label" translatable="yes">something</property>
-                  </object>
-                  <packing>
-                    <property name="left_attach">2</property>
-                    <property name="right_attach">3</property>
-                    <property name="top_attach">18</property>
-                    <property name="bottom_attach">19</property>
-                    <property name="x_options">GTK_FILL</property>
-                    <property name="y_options"></property>
-                  </packing>
-                </child>
-                <child>
-                  <object class="GtkEntry" id="purpose_entry">
-                    <property name="visible">True</property>
-                    <property name="can_focus">True</property>
-                    <property name="max_length">27</property>
-                    <property name="invisible_char">●</property>
-                    <property name="invisible_char_set">True</property>
-                    <property name="primary_icon_activatable">False</property>
-                    <property name="secondary_icon_activatable">False</property>
-                    <signal name="changed" handler="gnc_ab_trans_dialog_verify_values" swapped="yes"/>
-                  </object>
-                  <packing>
-                    <property name="top_attach">11</property>
-                    <property name="bottom_attach">12</property>
-                    <property name="y_options"></property>
-                  </packing>
-                </child>
-                <child>
-                  <object class="GtkEntry" id="purpose_cont2_entry">
-                    <property name="visible">True</property>
-                    <property name="can_focus">True</property>
-                    <property name="max_length">27</property>
-                    <property name="invisible_char">●</property>
-                    <property name="invisible_char_set">True</property>
-                    <property name="primary_icon_activatable">False</property>
-                    <property name="secondary_icon_activatable">False</property>
-                    <signal name="changed" handler="gnc_ab_trans_dialog_verify_values" swapped="yes"/>
-                  </object>
-                  <packing>
-                    <property name="top_attach">13</property>
-                    <property name="bottom_attach">14</property>
-                    <property name="y_options"></property>
-                  </packing>
-                </child>
-                <child>
-                  <object class="GtkEntry" id="purpose_cont_entry">
-                    <property name="visible">True</property>
-                    <property name="can_focus">True</property>
-                    <property name="max_length">27</property>
-                    <property name="invisible_char">●</property>
-                    <property name="invisible_char_set">True</property>
-                    <property name="primary_icon_activatable">False</property>
-                    <property name="secondary_icon_activatable">False</property>
-                    <signal name="changed" handler="gnc_ab_trans_dialog_verify_values" swapped="yes"/>
-                  </object>
-                  <packing>
-                    <property name="left_attach">2</property>
-                    <property name="right_attach">3</property>
-                    <property name="top_attach">11</property>
-                    <property name="bottom_attach">12</property>
-                    <property name="y_options"></property>
-                  </packing>
-                </child>
-                <child>
-                  <object class="GtkEntry" id="purpose_cont3_entry">
-                    <property name="visible">True</property>
-                    <property name="can_focus">True</property>
-                    <property name="max_length">27</property>
-                    <property name="invisible_char">●</property>
-                    <property name="invisible_char_set">True</property>
-                    <property name="primary_icon_activatable">False</property>
-                    <property name="secondary_icon_activatable">False</property>
-                    <signal name="changed" handler="gnc_ab_trans_dialog_verify_values" swapped="yes"/>
-                  </object>
-                  <packing>
-                    <property name="left_attach">2</property>
-                    <property name="right_attach">3</property>
-                    <property name="top_attach">13</property>
-                    <property name="bottom_attach">14</property>
-                    <property name="y_options"></property>
-                  </packing>
-                </child>
-                <child>
-                  <object class="GtkHBox" id="amount_hbox">
-                    <property name="visible">True</property>
-                    <property name="can_focus">False</property>
-                    <child>
-                      <placeholder/>
-                    </child>
-                  </object>
-                  <packing>
-                    <property name="top_attach">8</property>
-                    <property name="bottom_attach">9</property>
-                    <property name="y_options"></property>
-                  </packing>
-                </child>
-                <child>
-                  <object class="GtkHSeparator" id="hseparator8">
-                    <property name="visible">True</property>
-                    <property name="can_focus">False</property>
-                  </object>
-                  <packing>
-                    <property name="right_attach">3</property>
-                    <property name="top_attach">19</property>
-                    <property name="bottom_attach">20</property>
-                    <property name="x_options">GTK_FILL</property>
-                    <property name="y_options"></property>
-                    <property name="y_padding">1</property>
-                  </packing>
-                </child>
-                <child>
-                  <object class="GtkHSeparator" id="hseparator4">
-                    <property name="visible">True</property>
-                    <property name="can_focus">False</property>
-                  </object>
-                  <packing>
-                    <property name="right_attach">3</property>
-                    <property name="top_attach">14</property>
-                    <property name="bottom_attach">15</property>
-                    <property name="x_options">GTK_FILL</property>
-                    <property name="y_options"></property>
-                  </packing>
-                </child>
-                <child>
-                  <object class="GtkHSeparator" id="hseparator5">
-                    <property name="visible">True</property>
-                    <property name="can_focus">False</property>
-                  </object>
-                  <packing>
-                    <property name="right_attach">3</property>
-                    <property name="top_attach">6</property>
-                    <property name="bottom_attach">7</property>
-                    <property name="x_options">GTK_FILL</property>
-                    <property name="y_options"></property>
-                    <property name="y_padding">1</property>
-                  </packing>
-                </child>
-                <child>
-                  <object class="GtkHSeparator" id="hseparator6">
-                    <property name="visible">True</property>
-                    <property name="can_focus">False</property>
-                  </object>
-                  <packing>
-                    <property name="right_attach">3</property>
-                    <property name="top_attach">9</property>
-                    <property name="bottom_attach">10</property>
-                    <property name="x_options">GTK_FILL</property>
-                    <property name="y_options"></property>
-                  </packing>
-                </child>
-                <child>
-                  <placeholder/>
-                </child>
-                <child>
-                  <placeholder/>
-                </child>
-                <child>
-                  <placeholder/>
-                </child>
-                <child>
-                  <placeholder/>
-                </child>
-                <child>
-                  <placeholder/>
-                </child>
-                <child>
-                  <placeholder/>
-                </child>
-                <child>
-                  <placeholder/>
-                </child>
-                <child>
-                  <placeholder/>
-                </child>
-                <child>
-                  <placeholder/>
-                </child>
-                <child>
-                  <placeholder/>
-                </child>
-                <child>
-                  <placeholder/>
-                </child>
-                <child>
-                  <placeholder/>
-                </child>
-                <child>
-                  <placeholder/>
-                </child>
-                <child>
-                  <placeholder/>
-                </child>
-                <child>
-                  <placeholder/>
-                </child>
-              </object>
-              <packing>
-                <property name="expand">True</property>
-                <property name="fill">True</property>
-                <property name="position">1</property>
-              </packing>
-            </child>
-            <child>
-              <object class="GtkExpander" id="expander1">
-                <property name="visible">True</property>
-                <property name="can_focus">True</property>
-                <child>
-                  <object class="GtkHBox" id="hbox117">
-                    <property name="visible">True</property>
-                    <property name="can_focus">False</property>
-                    <property name="spacing">4</property>
-                    <child>
-                      <object class="GtkVButtonBox" id="vbutonbox158">
-                        <property name="visible">True</property>
-                        <property name="can_focus">False</property>
-                        <property name="homogeneous">True</property>
-                        <child>
-                          <object class="GtkButton" id="add_templ_button">
-                            <property name="visible">True</property>
-                            <property name="can_focus">True</property>
-                            <property name="receives_default">True</property>
-                            <property name="has_tooltip">True</property>
-                            <property name="tooltip_markup">Add the current online transaction as a new transaction template</property>
-                            <property name="tooltip_text" translatable="yes">Add the current online transaction as a new transaction template</property>
-                            <property name="use_action_appearance">False</property>
-                            <signal name="clicked" handler="gnc_ab_trans_dialog_add_templ_cb" swapped="no"/>
-                            <child>
-                              <object class="GtkAlignment" id="alignment3">
-                                <property name="visible">True</property>
-                                <property name="can_focus">False</property>
-                                <property name="xscale">0</property>
-                                <property name="yscale">0</property>
-                                <child>
-                                  <object class="GtkHBox" id="hbox119">
-                                    <property name="visible">True</property>
-                                    <property name="can_focus">False</property>
-                                    <property name="spacing">2</property>
-                                    <child>
-                                      <object class="GtkImage" id="image1">
-                                        <property name="visible">True</property>
-                                        <property name="can_focus">False</property>
-                                        <property name="stock">gtk-add</property>
-                                      </object>
-                                      <packing>
-                                        <property name="expand">False</property>
-                                        <property name="fill">False</property>
-                                        <property name="position">0</property>
-                                      </packing>
-                                    </child>
-                                    <child>
-                                      <object class="GtkLabel" id="label8877451">
-                                        <property name="visible">True</property>
-                                        <property name="can_focus">False</property>
-                                        <property name="label" translatable="yes">Add current</property>
-                                        <property name="use_underline">True</property>
-                                      </object>
-                                      <packing>
-                                        <property name="expand">False</property>
-                                        <property name="fill">False</property>
-                                        <property name="position">1</property>
-                                      </packing>
-                                    </child>
-                                  </object>
-                                </child>
-                              </object>
-                            </child>
-                          </object>
-                          <packing>
-                            <property name="expand">False</property>
-                            <property name="fill">False</property>
-                            <property name="position">0</property>
-                          </packing>
-                        </child>
-                        <child>
-                          <object class="GtkButton" id="moveup_templ_button">
-                            <property name="label">gtk-go-up</property>
-                            <property name="visible">True</property>
-                            <property name="can_focus">True</property>
-                            <property name="receives_default">True</property>
-                            <property name="has_tooltip">True</property>
-                            <property name="tooltip_markup">Move the selected transaction template one row up</property>
-                            <property name="tooltip_text" translatable="yes">Move the selected transaction template one row up</property>
-                            <property name="use_action_appearance">False</property>
-                            <property name="use_stock">True</property>
-                            <signal name="clicked" handler="gnc_ab_trans_dialog_moveup_templ_cb" swapped="no"/>
-                          </object>
-                          <packing>
-                            <property name="expand">False</property>
-                            <property name="fill">False</property>
-                            <property name="position">1</property>
-                          </packing>
-                        </child>
-                        <child>
-                          <object class="GtkButton" id="movedown_templ_button">
-                            <property name="label">gtk-go-down</property>
-                            <property name="visible">True</property>
-                            <property name="can_focus">True</property>
-                            <property name="receives_default">True</property>
-                            <property name="has_tooltip">True</property>
-                            <property name="tooltip_markup">Move the selected transaction template one row down</property>
-                            <property name="tooltip_text" translatable="yes">Move the selected transaction template one row down</property>
-                            <property name="use_action_appearance">False</property>
-                            <property name="use_stock">True</property>
-                            <signal name="clicked" handler="gnc_ab_trans_dialog_movedown_templ_cb" swapped="no"/>
-                          </object>
-                          <packing>
-                            <property name="expand">False</property>
-                            <property name="fill">False</property>
-                            <property name="position">2</property>
-                          </packing>
-                        </child>
-                        <child>
-                          <object class="GtkButton" id="sort_templ_button">
-                            <property name="visible">True</property>
-                            <property name="can_focus">True</property>
-                            <property name="receives_default">True</property>
-                            <property name="has_tooltip">True</property>
-                            <property name="tooltip_markup">Sort the list of transaction templates alphabetically</property>
-                            <property name="tooltip_text" translatable="yes">Sort the list of transaction templates alphabetically</property>
-                            <property name="use_action_appearance">False</property>
-                            <signal name="clicked" handler="gnc_ab_trans_dialog_sort_templ_cb" swapped="no"/>
-                            <child>
-                              <object class="GtkAlignment" id="alignment4">
-                                <property name="visible">True</property>
-                                <property name="can_focus">False</property>
-                                <property name="xscale">0</property>
-                                <property name="yscale">0</property>
-                                <child>
-                                  <object class="GtkHBox" id="hbox120">
-                                    <property name="visible">True</property>
-                                    <property name="can_focus">False</property>
-                                    <property name="spacing">2</property>
-                                    <child>
-                                      <object class="GtkImage" id="image2">
-                                        <property name="visible">True</property>
-                                        <property name="can_focus">False</property>
-                                        <property name="stock">gtk-sort-ascending</property>
-                                      </object>
-                                      <packing>
-                                        <property name="expand">False</property>
-                                        <property name="fill">False</property>
-                                        <property name="position">0</property>
-                                      </packing>
-                                    </child>
-                                    <child>
-                                      <object class="GtkLabel" id="label8877452">
-                                        <property name="visible">True</property>
-                                        <property name="can_focus">False</property>
-                                        <property name="label" translatable="yes">Sort</property>
-                                        <property name="use_underline">True</property>
-                                      </object>
-                                      <packing>
-                                        <property name="expand">False</property>
-                                        <property name="fill">False</property>
-                                        <property name="position">1</property>
-                                      </packing>
-                                    </child>
-                                  </object>
-                                </child>
-                              </object>
-                            </child>
-                          </object>
-                          <packing>
-                            <property name="expand">False</property>
-                            <property name="fill">False</property>
-                            <property name="position">3</property>
-                          </packing>
-                        </child>
-                        <child>
-                          <object class="GtkButton" id="del_templ_button">
-                            <property name="label">gtk-delete</property>
-                            <property name="visible">True</property>
-                            <property name="can_focus">True</property>
-                            <property name="receives_default">True</property>
-                            <property name="has_tooltip">True</property>
-                            <property name="tooltip_markup">Delete the currently selected transaction template</property>
-                            <property name="tooltip_text" translatable="yes">Delete the currently selected transaction template</property>
-                            <property name="use_action_appearance">False</property>
-                            <property name="use_stock">True</property>
-                            <signal name="clicked" handler="gnc_ab_trans_dialog_del_templ_cb" swapped="no"/>
-                          </object>
-                          <packing>
-                            <property name="expand">False</property>
-                            <property name="fill">False</property>
-                            <property name="position">4</property>
-                          </packing>
-                        </child>
-                      </object>
-                      <packing>
-                        <property name="expand">False</property>
-                        <property name="fill">False</property>
-                        <property name="pack_type">end</property>
-                        <property name="position">0</property>
-                      </packing>
-                    </child>
-                    <child>
-                      <object class="GtkScrolledWindow" id="template_scrolledwindow">
-                        <property name="visible">True</property>
-                        <property name="can_focus">True</property>
-                        <property name="shadow_type">in</property>
-                        <child>
-                          <object class="GtkTreeView" id="template_list">
-                            <property name="visible">True</property>
-                            <property name="can_focus">True</property>
-                            <property name="headers_visible">False</property>
-                            <property name="rules_hint">True</property>
-                            <signal name="row-activated" handler="gnc_ab_trans_dialog_templ_list_row_activated_cb" swapped="no"/>
-                            <child internal-child="selection">
-                              <object class="GtkTreeSelection" id="treeview-selection1"/>
-                            </child>
-                          </object>
-                        </child>
-                      </object>
-                      <packing>
-                        <property name="expand">True</property>
-                        <property name="fill">True</property>
-                        <property name="pack_type">end</property>
-                        <property name="position">2</property>
-                      </packing>
-                    </child>
-                  </object>
-                </child>
-                <child type="label">
-                  <object class="GtkLabel" id="label1">
-                    <property name="visible">True</property>
-                    <property name="can_focus">False</property>
-                    <property name="label" translatable="yes">Templates</property>
-                  </object>
-                </child>
-              </object>
-              <packing>
-                <property name="expand">False</property>
-                <property name="fill">False</property>
-                <property name="position">2</property>
-              </packing>
-            </child>
-            <child>
-              <object class="GtkHSeparator" id="hseparator7">
-                <property name="visible">True</property>
-                <property name="can_focus">False</property>
-              </object>
-              <packing>
-                <property name="expand">False</property>
-                <property name="fill">False</property>
-                <property name="position">3</property>
-              </packing>
-            </child>
-          </object>
-          <packing>
-            <property name="expand">True</property>
-            <property name="fill">True</property>
-            <property name="position">0</property>
-          </packing>
-        </child>
-        <child internal-child="action_area">
-          <object class="GtkButtonBox" id="dialog-action_area7">
-            <property name="visible">True</property>
-            <property name="can_focus">False</property>
-            <property name="layout_style">end</property>
-            <child>
-              <object class="GtkButton" id="exec_later_button">
-                <property name="label" translatable="yes">Execute later (unimpl.)</property>
-                <property name="can_focus">True</property>
-                <property name="can_default">True</property>
-                <property name="receives_default">True</property>
-                <property name="use_action_appearance">False</property>
-                <property name="use_underline">True</property>
-              </object>
-              <packing>
-                <property name="expand">False</property>
-                <property name="fill">False</property>
-                <property name="position">0</property>
-              </packing>
-            </child>
-            <child>
-              <object class="GtkButton" id="cancel_button">
-                <property name="label">gtk-cancel</property>
-                <property name="visible">True</property>
-                <property name="can_focus">True</property>
-                <property name="can_default">True</property>
-                <property name="receives_default">True</property>
-                <property name="use_action_appearance">False</property>
-                <property name="use_stock">True</property>
-              </object>
-              <packing>
-                <property name="expand">False</property>
-                <property name="fill">False</property>
-                <property name="position">1</property>
-              </packing>
-            </child>
-            <child>
-              <object class="GtkButton" id="exec_now_button">
-                <property name="visible">True</property>
-                <property name="can_focus">True</property>
-                <property name="can_default">True</property>
-                <property name="has_default">True</property>
-                <property name="receives_default">True</property>
-                <property name="has_tooltip">True</property>
-                <property name="tooltip_markup">Execute this online transaction now</property>
-                <property name="tooltip_text" translatable="yes">Execute this online transaction now</property>
-                <property name="use_action_appearance">False</property>
-                <child>
-                  <object class="GtkAlignment" id="alignment6">
-                    <property name="visible">True</property>
-                    <property name="can_focus">False</property>
-                    <property name="xscale">0</property>
-                    <property name="yscale">0</property>
-                    <child>
-                      <object class="GtkHBox" id="hbox122">
-                        <property name="visible">True</property>
-                        <property name="can_focus">False</property>
-                        <property name="spacing">2</property>
-                        <child>
-                          <object class="GtkImage" id="image4">
-                            <property name="visible">True</property>
-                            <property name="can_focus">False</property>
-                            <property name="stock">gtk-execute</property>
-                          </object>
-                          <packing>
-                            <property name="expand">False</property>
-                            <property name="fill">False</property>
-                            <property name="position">0</property>
-                          </packing>
-                        </child>
-                        <child>
-                          <object class="GtkLabel" id="label8877454">
-                            <property name="visible">True</property>
-                            <property name="can_focus">False</property>
-                            <property name="label" translatable="yes">Execute Now</property>
-                            <property name="use_underline">True</property>
-                          </object>
-                          <packing>
-                            <property name="expand">False</property>
-                            <property name="fill">False</property>
-                            <property name="position">1</property>
-                          </packing>
-                        </child>
-                      </object>
-                    </child>
-                  </object>
-                </child>
-              </object>
-              <packing>
-                <property name="expand">False</property>
-                <property name="fill">False</property>
-                <property name="position">2</property>
-              </packing>
-            </child>
-          </object>
-          <packing>
-            <property name="expand">False</property>
-            <property name="fill">True</property>
-            <property name="pack_type">end</property>
-            <property name="position">1</property>
-          </packing>
-        </child>
-      </object>
-    </child>
-    <action-widgets>
-      <action-widget response="-9">exec_later_button</action-widget>
-      <action-widget response="-6">cancel_button</action-widget>
-      <action-widget response="-8">exec_now_button</action-widget>
-    </action-widgets>
-  </object>
-</interface>

Deleted: gnucash/trunk/src/import-export/aqbanking/gnc-ab-getbalance.c
===================================================================
--- gnucash/trunk/src/import-export/aqbanking/gnc-ab-getbalance.c	2013-12-15 17:20:10 UTC (rev 23566)
+++ gnucash/trunk/src/import-export/aqbanking/gnc-ab-getbalance.c	2013-12-15 17:21:20 UTC (rev 23567)
@@ -1,157 +0,0 @@
-/*
- * gnc-ab-getbalance.c --
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation; either version 2 of
- * the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, contact:
- *
- * Free Software Foundation           Voice:  +1-617-542-5942
- * 51 Franklin Street, Fifth Floor    Fax:    +1-617-542-2652
- * Boston, MA  02110-1301,  USA       gnu at gnu.org
- */
-
-/**
- * @internal
- * @file gnc-ab-getbalance.c
- * @brief AqBanking getbalance functions
- * @author Copyright (C) 2002 Christian Stimming <stimming at tuhh.de>
- * @author Copyright (C) 2008 Andreas Koehler <andi5.py at gmx.net>
- */
-
-#include "config.h"
-
-#include <glib/gi18n.h>
-#include <aqbanking/banking.h>
-#include <aqbanking/jobgetbalance.h>
-
-#include "gnc-ab-getbalance.h"
-#include "gnc-ab-kvp.h"
-#include "gnc-ab-utils.h"
-#include "gnc-gwen-gui.h"
-#include "gnc-ui.h"
-
-/* This static indicates the debugging module that this .o belongs to.  */
-G_GNUC_UNUSED static QofLogModule log_module = G_LOG_DOMAIN;
-
-void
-gnc_ab_getbalance(GtkWidget *parent, Account *gnc_acc)
-{
-    AB_BANKING *api;
-    gboolean online = FALSE;
-    AB_ACCOUNT *ab_acc;
-    AB_JOB *job = NULL;
-    AB_JOB_LIST2 *job_list = NULL;
-    GncGWENGui *gui = NULL;
-    AB_IMEXPORTER_CONTEXT *context = NULL;
-    GncABImExContextImport *ieci = NULL;
-    AB_JOB_STATUS job_status;
-
-    g_return_if_fail(parent && gnc_acc);
-
-    /* Get the API */
-    api = gnc_AB_BANKING_new();
-    if (!api)
-    {
-        g_warning("gnc_ab_gettrans: Couldn't get AqBanking API");
-        return;
-    }
-    if (AB_Banking_OnlineInit(api
-#ifdef AQBANKING_VERSION_4_EXACTLY
-                              , 0
-#endif
-                             ) != 0)
-    {
-        g_warning("gnc_ab_gettrans: Couldn't initialize AqBanking API");
-        goto cleanup;
-    }
-    online = TRUE;
-
-    /* Get the AqBanking Account */
-    ab_acc = gnc_ab_get_ab_account(api, gnc_acc);
-    if (!ab_acc)
-    {
-        g_warning("gnc_ab_getbalance: No AqBanking account found");
-        gnc_error_dialog(parent, _("No valid online banking account assigned."));
-        goto cleanup;
-    }
-
-    /* Get a GetBalance job and enqueue it */
-    job = AB_JobGetBalance_new(ab_acc);
-    if (!job || AB_Job_CheckAvailability(job
-#ifndef AQBANKING_VERSION_5_PLUS
-                                         , 0
-#endif
-                                        ))
-    {
-        g_warning("gnc_ab_getbalance: JobGetBalance not available for this "
-                  "account");
-        gnc_error_dialog(parent, _("Online action \"Get Balance\" not available for this account."));
-        goto cleanup;
-    }
-    job_list = AB_Job_List2_new();
-    AB_Job_List2_PushBack(job_list, job);
-
-    /* Get a GUI object */
-    gui = gnc_GWEN_Gui_get(parent);
-    if (!gui)
-    {
-        g_warning("gnc_ab_getbalance: Couldn't initialize Gwenhywfar GUI");
-        goto cleanup;
-    }
-
-    /* Create a context to store the results */
-    context = AB_ImExporterContext_new();
-
-    /* Execute the job */
-    AB_Banking_ExecuteJobs(api, job_list, context
-#ifndef AQBANKING_VERSION_5_PLUS
-                           , 0
-#endif
-                          );
-    /* Ignore the return value of AB_Banking_ExecuteJobs(), as the job's
-     * status always describes better whether the job was actually
-     * transferred to and accepted by the bank.  See also
-     * http://lists.gnucash.org/pipermail/gnucash-de/2008-September/006389.html
-     */
-    job_status = AB_Job_GetStatus(job);
-    if (job_status != AB_Job_StatusFinished
-            && job_status != AB_Job_StatusPending)
-    {
-        g_warning("gnc_ab_getbalance: Error on executing job");
-        gnc_error_dialog(parent, _("Error on executing job.\n\nStatus: %s - %s")
-                         , AB_Job_Status2Char(job_status)
-                         , AB_Job_GetResultText(job));
-        goto cleanup;
-    }
-
-    /* Import the results */
-    ieci = gnc_ab_import_context(context, AWAIT_BALANCES, FALSE, NULL, parent);
-
-cleanup:
-    if (ieci)
-        g_free(ieci);
-    if (context)
-        AB_ImExporterContext_free(context);
-    if (gui)
-        gnc_GWEN_Gui_release(gui);
-    if (job_list)
-        AB_Job_List2_free(job_list);
-    if (job)
-        AB_Job_free(job);
-    if (online)
-#ifdef AQBANKING_VERSION_4_EXACTLY
-        AB_Banking_OnlineFini(api, 0);
-#else
-        AB_Banking_OnlineFini(api);
-#endif
-    gnc_AB_BANKING_fini(api);
-}

Deleted: gnucash/trunk/src/import-export/aqbanking/gnc-ab-getbalance.h
===================================================================
--- gnucash/trunk/src/import-export/aqbanking/gnc-ab-getbalance.h	2013-12-15 17:20:10 UTC (rev 23566)
+++ gnucash/trunk/src/import-export/aqbanking/gnc-ab-getbalance.h	2013-12-15 17:21:20 UTC (rev 23567)
@@ -1,55 +0,0 @@
-/*
- * gnc-ab-get-balance.h --
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation; either version 2 of
- * the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, contact:
- *
- * Free Software Foundation           Voice:  +1-617-542-5942
- * 51 Franklin Street, Fifth Floor    Fax:    +1-617-542-2652
- * Boston, MA  02110-1301,  USA       gnu at gnu.org
- */
-
-/**
- * @addtogroup Import_Export
- * @{
- * @addtogroup AqBanking
- * @{
- * @file gnc-ab-getbalance.h
- * @brief AqBanking getbalance functions
- * @author Copyright (C) 2002 Christian Stimming <stimming at tuhh.de>
- * @author Copyright (C) 2008 Andreas Koehler <andi5.py at gmx.net>
- */
-
-#ifndef GNC_AB_GETBALANCE_H
-#define GNC_AB_GETBALANCE_H
-
-#include <gtk/gtk.h>
-
-#include "Account.h"
-
-G_BEGIN_DECLS
-
-/**
- * Execute a GetBalance job, show the resulting balance and offer to reconcile
- * the GnuCash account.
- *
- * @param parent Widget to use as parent, may be NULL
- * @param gnc_acc GnuCash account to fetch balance for
- */
-void gnc_ab_getbalance(GtkWidget *parent, Account *gnc_acc);
-
-G_END_DECLS
-
-#endif /* GNC_AB_GETBALANCE_H */
-/** @} */
-/** @} */

Deleted: gnucash/trunk/src/import-export/aqbanking/gnc-ab-gettrans.c
===================================================================
--- gnucash/trunk/src/import-export/aqbanking/gnc-ab-gettrans.c	2013-12-15 17:20:10 UTC (rev 23566)
+++ gnucash/trunk/src/import-export/aqbanking/gnc-ab-gettrans.c	2013-12-15 17:21:20 UTC (rev 23567)
@@ -1,244 +0,0 @@
-/*
- * gnc-ab-gettrans.c --
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation; either version 2 of
- * the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, contact:
- *
- * Free Software Foundation           Voice:  +1-617-542-5942
- * 51 Franklin Street, Fifth Floor    Fax:    +1-617-542-2652
- * Boston, MA  02110-1301,  USA       gnu at gnu.org
- */
-
-/**
- * @internal
- * @file gnc-ab-gettrans.c
- * @brief AqBanking get transactions functions
- * @author Copyright (C) 2002 Christian Stimming <stimming at tuhh.de>
- * @author Copyright (C) 2008 Andreas Koehler <andi5.py at gmx.net>
- */
-
-#include "config.h"
-
-#include <glib/gi18n.h>
-#include <aqbanking/banking.h>
-#include <aqbanking/jobgettransactions.h>
-
-#include "Account.h"
-#include "dialog-ab-daterange.h"
-#include "gnc-ab-gettrans.h"
-#include "gnc-ab-kvp.h"
-#include "gnc-ab-utils.h"
-#include "gnc-gwen-gui.h"
-#include "gnc-ui.h"
-
-/* This static indicates the debugging module that this .o belongs to.  */
-G_GNUC_UNUSED static QofLogModule log_module = G_LOG_DOMAIN;
-
-static gboolean gettrans_dates(GtkWidget *parent, Account *gnc_acc, GWEN_TIME **from_date, GWEN_TIME **to_date);
-
-static gboolean
-gettrans_dates(GtkWidget *parent, Account *gnc_acc,
-               GWEN_TIME **from_date, GWEN_TIME **to_date)
-{
-    Timespec last_timespec, until_timespec;
-    time64 now = gnc_time (NULL);
-    gboolean use_last_date = TRUE;
-    gboolean use_earliest_date = TRUE;
-    gboolean use_until_now = TRUE;
-
-    g_return_val_if_fail(from_date && to_date, FALSE);
-
-    /* Get time of last retrieval */
-    last_timespec = gnc_ab_get_account_trans_retrieval(gnc_acc);
-    if (last_timespec.tv_sec == 0)
-    {
-        use_last_date = FALSE;
-        timespecFromTime64 (&last_timespec, now);
-    }
-    timespecFromTime64 (&until_timespec, now);
-
-    /* Let the user choose the date range of retrieval */
-    if (!gnc_ab_enter_daterange(parent, NULL,
-                                &last_timespec,
-                                &use_last_date, &use_earliest_date,
-                                &until_timespec, &use_until_now))
-        return FALSE;
-
-    /* Now calculate from date */
-    if (use_earliest_date)
-    {
-        *from_date = NULL;
-    }
-    else
-    {
-        if (use_last_date)
-            last_timespec = gnc_ab_get_account_trans_retrieval(gnc_acc);
-        *from_date = GWEN_Time_fromSeconds(timespecToTime64(last_timespec));
-    }
-
-    /* Now calculate to date */
-    if (use_until_now)
-        timespecFromTime64(&until_timespec, now);
-    *to_date = GWEN_Time_fromSeconds(timespecToTime64(until_timespec));
-
-    return TRUE;
-}
-
-void
-gnc_ab_gettrans(GtkWidget *parent, Account *gnc_acc)
-{
-    AB_BANKING *api;
-    gboolean online = FALSE;
-    AB_ACCOUNT *ab_acc;
-    GWEN_TIME *from_date = NULL, *to_date = NULL;
-    Timespec until_timespec;
-    AB_JOB *job = NULL;
-    AB_JOB_LIST2 *job_list = NULL;
-    GncGWENGui *gui = NULL;
-    AB_IMEXPORTER_CONTEXT *context = NULL;
-    GncABImExContextImport *ieci = NULL;
-    AB_JOB_STATUS job_status;
-
-    g_return_if_fail(parent && gnc_acc);
-
-    /* Get the API */
-    api = gnc_AB_BANKING_new();
-    if (!api)
-    {
-        g_warning("gnc_ab_gettrans: Couldn't get AqBanking API");
-        return;
-    }
-    if (AB_Banking_OnlineInit(api
-#ifdef AQBANKING_VERSION_4_EXACTLY
-                              , 0
-#endif
-                             ) != 0)
-    {
-        g_warning("gnc_ab_gettrans: Couldn't initialize AqBanking API");
-        goto cleanup;
-    }
-    online = TRUE;
-
-    /* Get the AqBanking Account */
-    ab_acc = gnc_ab_get_ab_account(api, gnc_acc);
-    if (!ab_acc)
-    {
-        g_warning("gnc_ab_gettrans: No AqBanking account found");
-        gnc_error_dialog(parent, _("No valid online banking account assigned."));
-        goto cleanup;
-    }
-
-    /* Get the start and end dates for the GetTransactions job.  */
-    if (!gettrans_dates(parent, gnc_acc, &from_date, &to_date))
-    {
-        g_debug("gnc_ab_gettrans: gettrans_dates aborted");
-        goto cleanup;
-    }
-    /* Use this as a local storage for the until_time below. */
-    timespecFromTime64(&until_timespec, GWEN_Time_toTime_t(to_date));
-
-    /* Get a GetTransactions job and enqueue it */
-    job = AB_JobGetTransactions_new(ab_acc);
-    if (!job || AB_Job_CheckAvailability(job
-#ifndef AQBANKING_VERSION_5_PLUS
-                                         , 0
-#endif
-                                        ))
-    {
-        g_warning("gnc_ab_gettrans: JobGetTransactions not available for this "
-                  "account");
-        gnc_error_dialog(parent, _("Online action \"Get Transactions\" not available for this account."));
-        goto cleanup;
-    }
-    AB_JobGetTransactions_SetFromTime(job, from_date);
-    AB_JobGetTransactions_SetToTime(job, to_date);
-    job_list = AB_Job_List2_new();
-    AB_Job_List2_PushBack(job_list, job);
-
-    /* Get a GUI object */
-    gui = gnc_GWEN_Gui_get(parent);
-    if (!gui)
-    {
-        g_warning("gnc_ab_gettrans: Couldn't initialize Gwenhywfar GUI");
-        goto cleanup;
-    }
-
-    /* Create a context to store the results */
-    context = AB_ImExporterContext_new();
-
-    /* Execute the job */
-    AB_Banking_ExecuteJobs(api, job_list, context
-#ifndef AQBANKING_VERSION_5_PLUS
-                           , 0
-#endif
-                          );
-    /* Ignore the return value of AB_Banking_ExecuteJobs(), as the job's
-     * status always describes better whether the job was actually
-     * transferred to and accepted by the bank.  See also
-     * http://lists.gnucash.org/pipermail/gnucash-de/2008-September/006389.html
-     */
-    job_status = AB_Job_GetStatus(job);
-    if (job_status != AB_Job_StatusFinished
-            && job_status != AB_Job_StatusPending)
-    {
-        g_warning("gnc_ab_gettrans: Error on executing job");
-        gnc_error_dialog(parent, _("Error on executing job.\n\nStatus: %s - %s")
-                         , AB_Job_Status2Char(job_status)
-                         , AB_Job_GetResultText(job));
-        goto cleanup;
-    }
-
-    /* Import the results */
-    ieci = gnc_ab_import_context(context, AWAIT_TRANSACTIONS, FALSE, NULL,
-                                 parent);
-    if (!(gnc_ab_ieci_get_found(ieci) & FOUND_TRANSACTIONS))
-    {
-        /* No transaction found */
-        GtkWidget *dialog = gtk_message_dialog_new(
-                                GTK_WINDOW(parent),
-                                GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT,
-                                GTK_MESSAGE_INFO,
-                                GTK_BUTTONS_OK,
-                                "%s",
-                                _("The Online Banking import returned no transactions "
-                                  "for the selected time period."));
-        gtk_dialog_run(GTK_DIALOG(dialog));
-        gtk_widget_destroy(dialog);
-    }
-
-    /* Store the date of this retrieval */
-    gnc_ab_set_account_trans_retrieval(gnc_acc, until_timespec);
-
-cleanup:
-    if (ieci)
-        g_free(ieci);
-    if (context)
-        AB_ImExporterContext_free(context);
-    if (gui)
-        gnc_GWEN_Gui_release(gui);
-    if (job_list)
-        AB_Job_List2_free(job_list);
-    if (job)
-        AB_Job_free(job);
-    if (to_date)
-        GWEN_Time_free(to_date);
-    if (from_date)
-        GWEN_Time_free(from_date);
-    if (online)
-#ifdef AQBANKING_VERSION_4_EXACTLY
-        AB_Banking_OnlineFini(api, 0);
-#else
-        AB_Banking_OnlineFini(api);
-#endif
-    gnc_AB_BANKING_fini(api);
-}

Deleted: gnucash/trunk/src/import-export/aqbanking/gnc-ab-gettrans.h
===================================================================
--- gnucash/trunk/src/import-export/aqbanking/gnc-ab-gettrans.h	2013-12-15 17:20:10 UTC (rev 23566)
+++ gnucash/trunk/src/import-export/aqbanking/gnc-ab-gettrans.h	2013-12-15 17:21:20 UTC (rev 23567)
@@ -1,52 +0,0 @@
-/*
- * gnc-ab-get-balance.h --
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation; either version 2 of
- * the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, contact:
- *
- * Free Software Foundation           Voice:  +1-617-542-5942
- * 51 Franklin Street, Fifth Floor    Fax:    +1-617-542-2652
- * Boston, MA  02110-1301,  USA       gnu at gnu.org
- */
-
-/**
- * @addtogroup Import_Export
- * @{
- * @addtogroup AqBanking
- * @{
- * @file gnc-ab-getbalance.h
- * @brief AqBanking getbalance functions
- * @author Copyright (C) 2002 Christian Stimming
- * @author Copyright (C) 2008 Andreas Koehler <andi5.py at gmx.net>
- */
-
-#ifndef GNC_AB_GETTRANS_H
-#define GNC_AB_GETTRANS_H
-
-#include <glib.h>
-
-G_BEGIN_DECLS
-
-/**
- * Execute a GetTransactions job.
- *
- * @param parent Widget to use as parent, may be NULL
- * @param gnc_acc GnuCash account to fetch transactions for
- */
-void gnc_ab_gettrans(GtkWidget *parent, Account *gnc_acc);
-
-G_END_DECLS
-
-#endif /* GNC_AB_GETTRANS_H */
-/** @} */
-/** @} */

Deleted: gnucash/trunk/src/import-export/aqbanking/gnc-ab-kvp.c
===================================================================
--- gnucash/trunk/src/import-export/aqbanking/gnc-ab-kvp.c	2013-12-15 17:20:10 UTC (rev 23566)
+++ gnucash/trunk/src/import-export/aqbanking/gnc-ab-kvp.c	2013-12-15 17:21:20 UTC (rev 23567)
@@ -1,165 +0,0 @@
-/*
- * gnc-ab-kvp.c --
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation; either version 2 of
- * the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, contact:
- *
- * Free Software Foundation           Voice:  +1-617-542-5942
- * 51 Franklin Street, Fifth Floor    Fax:    +1-617-542-2652
- * Boston, MA  02110-1301,  USA       gnu at gnu.org
- */
-
-/**
- * @internal
- * @file gnc-ab-kvp.c
- * @brief AqBanking KVP handling
- * @author Copyright (C) 2002 Christian Stimming <stimming at tuhh.de>
- * @author Copyright (C) 2008 Andreas Koehler <andi5.py at gmx.net>
- */
-
-#include "config.h"
-#include "gnc-ui-util.h"
-
-#include "gnc-ab-kvp.h"
-
-#define AB_KEY "hbci"
-#define AB_ACCOUNT_ID "account-id"
-#define AB_ACCOUNT_UID "account-uid"
-#define AB_BANK_CODE "bank-code"
-#define AB_TRANS_RETRIEVAL "trans-retrieval"
-#define AB_TEMPLATES "template-list"
-
-/* This static indicates the debugging module that this .o belongs to.  */
-G_GNUC_UNUSED static QofLogModule log_module = G_LOG_DOMAIN;
-
-static kvp_frame *gnc_ab_get_account_kvp(const Account *a, gboolean create);
-static kvp_frame *gnc_ab_get_book_kvp(QofBook *b, gboolean create);
-
-const gchar *
-gnc_ab_get_account_accountid(const Account *a)
-{
-    kvp_frame *frame = gnc_ab_get_account_kvp(a, FALSE);
-    kvp_value *value = kvp_frame_get_slot(frame, AB_ACCOUNT_ID);
-    return kvp_value_get_string(value);
-}
-
-void
-gnc_ab_set_account_accountid(Account *a, const gchar *id)
-{
-    kvp_frame *frame = gnc_ab_get_account_kvp(a, TRUE);
-    kvp_value *value = kvp_value_new_string(id);
-    xaccAccountBeginEdit(a);
-    kvp_frame_set_slot_nc(frame, AB_ACCOUNT_ID, value);
-    qof_instance_set_dirty(QOF_INSTANCE (a));
-    xaccAccountCommitEdit(a);
-}
-
-const gchar *
-gnc_ab_get_account_bankcode(const Account *a)
-{
-    kvp_frame *frame = gnc_ab_get_account_kvp(a, FALSE);
-    kvp_value *value = kvp_frame_get_slot(frame, AB_BANK_CODE);
-    return kvp_value_get_string(value);
-}
-
-void
-gnc_ab_set_account_bankcode(Account *a, const gchar *code)
-{
-    kvp_frame *frame = gnc_ab_get_account_kvp(a, TRUE);
-    kvp_value *value = kvp_value_new_string(code);
-    xaccAccountBeginEdit(a);
-    kvp_frame_set_slot_nc(frame, AB_BANK_CODE, value);
-    qof_instance_set_dirty(QOF_INSTANCE (a));
-    xaccAccountCommitEdit(a);
-}
-
-guint32
-gnc_ab_get_account_uid(const Account *a)
-{
-    kvp_frame *frame = gnc_ab_get_account_kvp(a, FALSE);
-    kvp_value *value = kvp_frame_get_slot(frame, AB_ACCOUNT_UID);
-    return (guint32) kvp_value_get_gint64(value);
-}
-
-void
-gnc_ab_set_account_uid(Account *a, guint32 uid)
-{
-    kvp_frame *frame = gnc_ab_get_account_kvp(a, TRUE);
-    kvp_value *value = kvp_value_new_gint64(uid);
-    xaccAccountBeginEdit(a);
-    kvp_frame_set_slot_nc(frame, AB_ACCOUNT_UID, value);
-    qof_instance_set_dirty(QOF_INSTANCE (a));
-    xaccAccountCommitEdit(a);
-}
-
-Timespec
-gnc_ab_get_account_trans_retrieval(const Account *a)
-{
-    kvp_frame *frame = gnc_ab_get_account_kvp(a, FALSE);
-    kvp_value *value = kvp_frame_get_slot(frame, AB_TRANS_RETRIEVAL);
-    return kvp_value_get_timespec(value);
-}
-
-void
-gnc_ab_set_account_trans_retrieval(Account *a, Timespec time)
-{
-    kvp_frame *frame = gnc_ab_get_account_kvp(a, TRUE);
-    kvp_value *value = kvp_value_new_timespec(time);
-    xaccAccountBeginEdit(a);
-    kvp_frame_set_slot_nc(frame, AB_TRANS_RETRIEVAL, value);
-    qof_instance_set_dirty(QOF_INSTANCE (a));
-    xaccAccountCommitEdit(a);
-}
-
-GList *
-gnc_ab_get_book_template_list(QofBook *b)
-{
-    kvp_frame *frame = gnc_ab_get_book_kvp(b, FALSE);
-    kvp_value *value = kvp_frame_get_slot(frame, AB_TEMPLATES);
-    return kvp_value_get_glist(value);
-}
-
-void
-gnc_ab_set_book_template_list(QofBook *b, GList *template_list)
-{
-    kvp_frame *frame = gnc_ab_get_book_kvp(b, TRUE);
-    kvp_value *value = kvp_value_new_glist_nc(template_list);
-    kvp_frame_set_slot_nc(frame, AB_TEMPLATES, value);
-    qof_book_kvp_changed (b);
-}
-
-static kvp_frame *
-gnc_ab_get_account_kvp(const Account *a, gboolean create)
-{
-    kvp_frame *toplevel = xaccAccountGetSlots(a);
-    kvp_frame *result = kvp_frame_get_frame(toplevel, AB_KEY);
-    if (!result && create)
-    {
-        result = kvp_frame_new();
-        kvp_frame_add_frame_nc(toplevel, AB_KEY, result);
-    }
-    return result;
-}
-
-static kvp_frame *
-gnc_ab_get_book_kvp(QofBook *b, gboolean create)
-{
-    kvp_frame *toplevel = qof_book_get_slots(b);
-    kvp_frame *result = kvp_frame_get_frame(toplevel, AB_KEY);
-    if (!result && create)
-    {
-        result = kvp_frame_new();
-        kvp_frame_add_frame_nc(toplevel, AB_KEY, result);
-    }
-    return result;
-}

Deleted: gnucash/trunk/src/import-export/aqbanking/gnc-ab-kvp.h
===================================================================
--- gnucash/trunk/src/import-export/aqbanking/gnc-ab-kvp.h	2013-12-15 17:20:10 UTC (rev 23566)
+++ gnucash/trunk/src/import-export/aqbanking/gnc-ab-kvp.h	2013-12-15 17:21:20 UTC (rev 23567)
@@ -1,148 +0,0 @@
-/*
- * gnc-ab-kvp.h --
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation; either version 2 of
- * the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, contact:
- *
- * Free Software Foundation           Voice:  +1-617-542-5942
- * 51 Franklin Street, Fifth Floor    Fax:    +1-617-542-2652
- * Boston, MA  02110-1301,  USA       gnu at gnu.org
- */
-
-/**
- * @addtogroup Import_Export
- * @{
- * @addtogroup AqBanking
- * @{
- * @file gnc-ab-kvp.h
- * @brief AqBanking KVP handling
- * @author Copyright (C) 2002 Christian Stimming <stimming at tuhh.de>
- * @author Copyright (C) 2008 Andreas Koehler <andi5.py at gmx.net>
- */
-
-#ifndef GNC_AB_KVP_H
-#define GNC_AB_KVP_H
-
-#include <glib.h>
-
-#include "Account.h"
-
-G_BEGIN_DECLS
-
-/** @name Account
- *  @{ */
-
-/**
- * Return a non-copied pointer to the accountid string in the Account @a a.
- * The gchar* is still owned by the kvp_frame, so don't free it until you want
- * to delete the whole kvp_frame.
- *
- * @param a Account
- * @return Account ID
- */
-const gchar *gnc_ab_get_account_accountid(const Account *a);
-
-/**
- * Set the accountid string in the Account @a a to @a id.  A copy of the string
- * will be stored.  The Account will be marked as "dirty".
- *
- * @param a Account
- * @param id Account ID
- */
-void gnc_ab_set_account_accountid(Account *a, const gchar *id);
-
-/**
- * Return a non-copied pointer to the bankcode string in the Account @a a.  The
- * gchar* is still owned by the kvp_frame, so don't free it until you want to
- * delete the whole kvp_frame.
- *
- * @param a Account
- * @return Bank code
- */
-const gchar *gnc_ab_get_account_bankcode(const Account *a);
-
-/**
- * Set the bankcode string in the Account @a a to @a code.  A copy of the string
- * will be stored.  The Account will be marked as "dirty".
- *
- * @param a Account
- * @param code Bank code
- */
-void gnc_ab_set_account_bankcode(Account *a, const gchar *code);
-
-/**
- * Return the unique id for the AB_BANKING account in the Account @a a.
- *
- * @param a Account
- * @return Unique ID
- */
-guint32 gnc_ab_get_account_uid(const Account *a);
-
-/**
- * Set the unique id for the AB_BANKING account in the Account @a a to @a uid.
- * The Account will be marked as "dirty".
- *
- * @param a Account
- * @param uid Unique ID
- */
-void gnc_ab_set_account_uid(Account *a, guint32 uid);
-
-/**
- * Return the time of last online transaction retrieval for Account @a a.
- *
- * @param a Account
- * @return Retrieval time
- */
-Timespec gnc_ab_get_account_trans_retrieval(const Account *a);
-
-/**
- * Set the time of last online transaction retrieval for Account @a a.  The
- * account will be marked as "dirty".
- *
- * @param a Account
- * @param time Retrieval time
- */
-void gnc_ab_set_account_trans_retrieval(Account *a, Timespec time);
-
-/** @} */
-
-/** @name Book
- *  @{ */
-
-/**
- * Return a non-copied pointer to the GList of kvp_frames which eventually are
- * the template transactions, stored in the given book.
- *
- * @param b Book
- * @return Template list
- */
-GList *gnc_ab_get_book_template_list(QofBook *b);
-
-/**
- * Set the GList of kvp_frames of template transactions in the Book @a b to @a
- * template_list.  No copy of the GList will be stored, the callee becomes the
- * owner and the caller must not free it.  The book will be marked "dirty".
- *
- * @param b Book
- * @param template_list Template list
- */
-void gnc_ab_set_book_template_list(QofBook *b, GList *template_list);
-
-/** @} */
-
-G_END_DECLS
-
-/** @} */
-/** @} */
-
-#endif /* GNC_AB_KVP_H */

Deleted: gnucash/trunk/src/import-export/aqbanking/gnc-ab-trans-templ.c
===================================================================
--- gnucash/trunk/src/import-export/aqbanking/gnc-ab-trans-templ.c	2013-12-15 17:20:10 UTC (rev 23566)
+++ gnucash/trunk/src/import-export/aqbanking/gnc-ab-trans-templ.c	2013-12-15 17:21:20 UTC (rev 23567)
@@ -1,287 +0,0 @@
-/*
- * gnc-ab-trans-templ.c --
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation; either version 2 of
- * the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, contact:
- *
- * Free Software Foundation           Voice:  +1-617-542-5942
- * 51 Franklin Street, Fifth Floor    Fax:    +1-617-542-2652
- * Boston, MA  02110-1301,  USA       gnu at gnu.org
- */
-
-/**
- * @internal
- * @file gnc-ab-trans-templ.c
- * @brief Templates for AqBanking transactions
- * @author Copyright (C) 2002 Christian Stimming <stimming at tuhh.de>
- * @author Copyright (C) 2008 Andreas Koehler <andi5.py at gmx.net>
- */
-
-#include "config.h"
-
-#include "gnc-ab-trans-templ.h"
-
-/* This static indicates the debugging module that this .o belongs to.  */
-G_GNUC_UNUSED static QofLogModule log_module = G_LOG_DOMAIN;
-
-/* kvp_frame slot names */
-#define TT_NAME "name"
-#define TT_RNAME "rnam"
-#define TT_RACC "racc"
-#define TT_RBCODE "rbcd"
-#define TT_PURPOS "purp"
-#define TT_PURPOSCT "purc"
-#define TT_AMOUNT "amou"
-
-struct _GncABTransTempl
-{
-    /* Name of this Template */
-    gchar *name;
-    gchar *name_key; /* Collation key */
-
-    /* Recipient */
-    gchar *recp_name;
-    gchar *recp_account;
-    gchar *recp_bankcode;
-
-    /* Amount */
-    gnc_numeric amount;
-
-    /* Purpose, description */
-    gchar *purpose;
-    gchar *purpose_cont;
-};
-
-
-GncABTransTempl *
-gnc_ab_trans_templ_new(void)
-{
-    return gnc_ab_trans_templ_new_full(NULL, NULL, NULL, NULL,
-                                       gnc_numeric_zero(), NULL, NULL);
-}
-
-GncABTransTempl *
-gnc_ab_trans_templ_new_full(const char *name, const char *recp_name,
-                            const char *recp_account, const char *recp_bankcode,
-                            gnc_numeric amount, const char *purpose,
-                            const char *purpose_cont)
-{
-    GncABTransTempl *r = g_new(GncABTransTempl, 1);
-    r->name = g_strdup(name);
-    r->name_key = g_utf8_collate_key(name, -1);
-    r->recp_name = g_strdup(recp_name);
-    r->recp_account = g_strdup(recp_account);
-    r->recp_bankcode = g_strdup(recp_bankcode);
-    r->amount = amount;
-    r->purpose = g_strdup(purpose);
-    r->purpose_cont = g_strdup(purpose_cont);
-
-    return r;
-}
-
-GncABTransTempl *
-gnc_ab_trans_templ_new_from_kvp(const kvp_frame *k)
-{
-    g_return_val_if_fail(k, NULL);
-
-    return gnc_ab_trans_templ_new_full(
-               kvp_value_get_string(kvp_frame_get_slot(k, TT_NAME)),
-               kvp_value_get_string(kvp_frame_get_slot(k, TT_RNAME)),
-               kvp_value_get_string(kvp_frame_get_slot(k, TT_RACC)),
-               kvp_value_get_string(kvp_frame_get_slot(k, TT_RBCODE)),
-               kvp_value_get_numeric(kvp_frame_get_slot(k, TT_AMOUNT)),
-               kvp_value_get_string(kvp_frame_get_slot(k, TT_PURPOS)),
-               kvp_value_get_string(kvp_frame_get_slot(k, TT_PURPOSCT)));
-}
-
-GList *
-gnc_ab_trans_templ_list_new_from_kvp_list(GList *v)
-{
-    GList *res = NULL;
-    GList *iter;
-
-    for (iter = v; iter; iter = iter->next)
-    {
-        kvp_frame *frame = kvp_value_get_frame((kvp_value*) iter->data);
-        res = g_list_prepend(res, gnc_ab_trans_templ_new_from_kvp(frame));
-    }
-    res = g_list_reverse(res);
-
-    return res;
-}
-
-void
-gnc_ab_trans_templ_free(GncABTransTempl *t)
-{
-    if (!t) return;
-    g_free(t->name);
-    g_free(t->name_key);
-    g_free(t->recp_name);
-    g_free(t->recp_account);
-    g_free(t->recp_bankcode);
-    g_free(t->purpose);
-    g_free(t->purpose_cont);
-    g_free(t);
-}
-
-void
-gnc_ab_trans_templ_list_free(GList *l)
-{
-    GList *iter;
-    for (iter = l; iter; iter = iter->next)
-        gnc_ab_trans_templ_free((GncABTransTempl*) iter->data);
-    g_list_free(l);
-}
-
-kvp_frame *
-gnc_ab_trans_templ_to_kvp(const GncABTransTempl *t)
-{
-    kvp_frame *k;
-
-    g_return_val_if_fail(t, NULL);
-
-    k = kvp_frame_new();
-    kvp_frame_set_slot(k, TT_NAME, kvp_value_new_string(t->name));
-    kvp_frame_set_slot(k, TT_RNAME, kvp_value_new_string(t->recp_name));
-    kvp_frame_set_slot(k, TT_RACC, kvp_value_new_string(t->recp_account));
-    kvp_frame_set_slot(k, TT_RBCODE, kvp_value_new_string(t->recp_bankcode));
-    kvp_frame_set_slot(k, TT_AMOUNT, kvp_value_new_gnc_numeric(t->amount));
-    kvp_frame_set_slot(k, TT_PURPOS, kvp_value_new_string(t->purpose));
-    kvp_frame_set_slot(k, TT_PURPOSCT, kvp_value_new_string(t->purpose_cont));
-
-    return k;
-}
-
-GList *
-gnc_ab_trans_templ_list_to_kvp_list(GList *k)
-{
-    GList *res = NULL;
-    GList *iter;
-
-    for (iter = k; iter; iter = iter->next)
-    {
-        GncABTransTempl *t = (GncABTransTempl*) iter->data;
-        kvp_value *value = kvp_value_new_frame_nc(gnc_ab_trans_templ_to_kvp(t));
-        res = g_list_prepend(res, value);
-    }
-    res = g_list_reverse(res);
-
-    return res;
-}
-
-const gchar *
-gnc_ab_trans_templ_get_name(const GncABTransTempl *t)
-{
-    g_return_val_if_fail(t, NULL);
-    return t->name;
-}
-
-const gchar *
-gnc_ab_trans_templ_get_recp_name(const GncABTransTempl *t)
-{
-    g_return_val_if_fail(t, NULL);
-    return t->recp_name;
-}
-
-const gchar *
-gnc_ab_trans_templ_get_recp_account(const GncABTransTempl *t)
-{
-    g_return_val_if_fail(t, NULL);
-    return t->recp_account;
-}
-
-const gchar *
-gnc_ab_trans_templ_get_recp_bankcode(const GncABTransTempl *t)
-{
-    g_return_val_if_fail(t, NULL);
-    return t->recp_bankcode;
-}
-
-gnc_numeric
-gnc_ab_trans_templ_get_amount(const GncABTransTempl *t)
-{
-    g_return_val_if_fail(t, gnc_numeric_zero());
-    return t->amount;
-}
-
-const gchar *
-gnc_ab_trans_templ_get_purpose(const GncABTransTempl *t)
-{
-    g_return_val_if_fail(t, NULL);
-    return t->purpose;
-}
-
-const gchar *
-gnc_ab_trans_templ_get_purpose_cont(const GncABTransTempl *t)
-{
-    g_return_val_if_fail(t, NULL);
-    return t->purpose_cont;
-}
-
-void
-gnc_ab_trans_templ_set_name(GncABTransTempl *t, const gchar *name)
-{
-    g_return_if_fail(t);
-    g_free(t->name);
-    t->name = g_strdup(name);
-}
-
-void
-gnc_ab_trans_templ_set_recp_name(GncABTransTempl *t, const gchar *recp_name)
-{
-    g_return_if_fail(t);
-    g_free(t->recp_name);
-    t->recp_name = g_strdup(recp_name);
-}
-
-void
-gnc_ab_trans_templ_set_recp_account(GncABTransTempl *t,
-                                    const gchar *recp_account)
-{
-    g_return_if_fail(t);
-    g_free(t->recp_account);
-    t->recp_account = g_strdup(recp_account);
-}
-
-void
-gnc_ab_trans_templ_set_recp_bankcode(GncABTransTempl *t,
-                                     const gchar *recp_bankcode)
-{
-    g_return_if_fail(t);
-    g_free(t->recp_bankcode);
-    t->recp_bankcode = g_strdup(recp_bankcode);
-}
-
-void
-gnc_ab_trans_templ_set_amount(GncABTransTempl *t, gnc_numeric amount)
-{
-    g_return_if_fail(t);
-    t->amount = amount;
-}
-
-void
-gnc_ab_trans_templ_set_purpose(GncABTransTempl *t, const gchar *purpose)
-{
-    g_return_if_fail(t);
-    g_free(t->purpose);
-    t->purpose = g_strdup(purpose);
-}
-
-void
-gnc_ab_trans_templ_set_purpose_cont(GncABTransTempl *t,
-                                    const gchar *purpose_cont)
-{
-    g_return_if_fail(t);
-    g_free(t->purpose_cont);
-    t->purpose_cont = g_strdup(purpose_cont);
-}

Deleted: gnucash/trunk/src/import-export/aqbanking/gnc-ab-trans-templ.h
===================================================================
--- gnucash/trunk/src/import-export/aqbanking/gnc-ab-trans-templ.h	2013-12-15 17:20:10 UTC (rev 23566)
+++ gnucash/trunk/src/import-export/aqbanking/gnc-ab-trans-templ.h	2013-12-15 17:21:20 UTC (rev 23567)
@@ -1,223 +0,0 @@
-/*
- * gnc-ab-trans-templ.h --
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation; either version 2 of
- * the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, contact:
- *
- * Free Software Foundation           Voice:  +1-617-542-5942
- * 51 Franklin Street, Fifth Floor    Fax:    +1-617-542-2652
- * Boston, MA  02110-1301,  USA       gnu at gnu.org
- */
-
-/**
- * @addtogroup Import_Export
- * @{
- * @addtogroup AqBanking
- * @{
- * @file gnc-ab-trans-templ.h
- * @brief Templates for AqBanking transactions
- * @author Copyright (C) 2003 Christian Stimming <stimming at tuhh.de>
- * @author Copyright (C) 2008 Andreas Koehler <andi5.py at gmx.net>
- */
-
-#ifndef GNC_AB_TRANS_TEMPL_H
-#define GNC_AB_TRANS_TEMPL_H
-
-#include <glib.h>
-
-#include "qof.h"
-
-G_BEGIN_DECLS
-
-/** A template for an AqBanking transaction */
-typedef struct _GncABTransTempl GncABTransTempl;
-
-/**
- * Create a template with unset contents.
- *
- * @return A newly allocated GncABTransTempl
- */
-GncABTransTempl *gnc_ab_trans_templ_new(void);
-
-/**
- * Create a template with given contents.
- *
- * @param name Name of the template
- * @param recp_name Name of the recipient
- * @param recp_account Account Number of the recipient
- * @param recp_bankcode Bank Code of the recipient
- * @param amount Amount
- * @param purpose First purpose line
- * @param purpose_cont Second purpose line
- * @return A newly allocated GncABTransTempl
- */
-GncABTransTempl *gnc_ab_trans_templ_new_full(
-    const gchar *name, const gchar *recp_name, const gchar *recp_account,
-    const gchar *recp_bankcode, gnc_numeric amount, const gchar *purpose,
-    const gchar *purpose_cont);
-
-/**
- * Create a template, taking the values from a kvp_frame.
- *
- * @param k kvp_frame
- * @return A newly allocated GncABTransTempl
- */
-GncABTransTempl *gnc_ab_trans_templ_new_from_kvp(const kvp_frame *k);
-
-/**
- * Create a list of templates from a list of kvp_values which in turn
- * contain a kvp_frame.
- *
- * @param v GList of kvp_values
- * @return A GList of newly allocated GncABTransTempls
- */
-GList *gnc_ab_trans_templ_list_new_from_kvp_list(GList *v);
-
-/**
- * Free the memory used by a template.
- *
- * @param t GncABTransTempl to be freed
- */
-void gnc_ab_trans_templ_free(GncABTransTempl *t);
-
-/**
- * Free the memory used by a list of templates, including the list itself.
- *
- * @param l GList of GncABTransTempl
- */
-void gnc_ab_trans_templ_list_free(GList *l);
-
-/**
- * Create a kvp_frame a given template.
- *
- * @param t Template
- * @return A newly allocated kvp_frame
- */
-kvp_frame *gnc_ab_trans_templ_to_kvp(const GncABTransTempl *t);
-
-/**
- * Create a list of kvp_values, which in turn contain a kvp_frame, from a list
- * of templates.
- *
- * @param k GList of GncABTransTempls
- * @return GList of newly allocated kvp_values
- */
-GList *gnc_ab_trans_templ_list_to_kvp_list(GList *k);
-
-/**
- * @param t Template
- * @return Name of the template, an internal string
- */
-const gchar *gnc_ab_trans_templ_get_name(const GncABTransTempl *t);
-
-/**
- * @param t Template
- * @return Name of the recipient, an internal string
- */
-const gchar *gnc_ab_trans_templ_get_recp_name(const GncABTransTempl *t);
-
-/**
- * @param t Template
- * @return Account Number of the recipient, an internal string
- */
-const gchar *gnc_ab_trans_templ_get_recp_account(const GncABTransTempl *t);
-
-/**
- * @param t Template
- * @return Bank Code of the recipient, an internal string
- */
-const gchar *gnc_ab_trans_templ_get_recp_bankcode(const GncABTransTempl *t);
-
-/**
- * @param t Template
- * @return Amount
- */
-gnc_numeric gnc_ab_trans_templ_get_amount(const GncABTransTempl *t);
-
-/**
- * @param t Template
- * @return First purpose line, an internal string
- */
-const gchar *gnc_ab_trans_templ_get_purpose(const GncABTransTempl *t);
-
-/**
- * @param t Template
- * @return Second purpose line, an internal string
- */
-const gchar *gnc_ab_trans_templ_get_purpose_cont(const GncABTransTempl *t);
-
-/**
- * Set the name of a template.
- *
- * @param t Template
- * @param name Name
- */
-void gnc_ab_trans_templ_set_name(GncABTransTempl *t, const gchar *name);
-
-/**
- * Replace the Account Number of the recipient stored in a template.
- *
- * @param t Template
- * @param recp_name Account Number of the recipient
- */
-void gnc_ab_trans_templ_set_recp_name(GncABTransTempl *t,
-                                      const gchar *recp_name);
-
-/**
- * Replace the Account Number of the recipient stored in a template.
- *
- * @param t Template
- * @param recp_account Account Number of the recipient
- */
-void gnc_ab_trans_templ_set_recp_account(GncABTransTempl *t,
-        const gchar *recp_account);
-
-/**
- * Replace the Bank Code of the recipient stored in a template.
- *
- * @param t Template
- * @param recp_bankcode Bank Code of the recipient
- */
-void gnc_ab_trans_templ_set_recp_bankcode(GncABTransTempl *t,
-        const gchar *recp_bankcode);
-
-/**
- * Replace the amount stored in a template.
- *
- * @param t Template
- * @param amount Amount
- */
-void gnc_ab_trans_templ_set_amount(GncABTransTempl *t, gnc_numeric amount);
-
-/**
- * Replace the first purpose line stored in a template.
- *
- * @param t Template
- * @param purpose First purpose line
- */
-void gnc_ab_trans_templ_set_purpose(GncABTransTempl *t, const gchar *purpose);
-
-/**
- * Replace the second purpose line stored in a template.
- *
- * @param t Template
- * @param purpose_cont Second purpose line
- */
-void gnc_ab_trans_templ_set_purpose_cont(GncABTransTempl *t,
-        const gchar *purpose_cont);
-
-G_END_DECLS
-
-#endif /* GNC_AB_TRANS_TEMPL_H */
-/** @} */
-/** @} */

Deleted: gnucash/trunk/src/import-export/aqbanking/gnc-ab-transfer.c
===================================================================
--- gnucash/trunk/src/import-export/aqbanking/gnc-ab-transfer.c	2013-12-15 17:20:10 UTC (rev 23566)
+++ gnucash/trunk/src/import-export/aqbanking/gnc-ab-transfer.c	2013-12-15 17:21:20 UTC (rev 23567)
@@ -1,357 +0,0 @@
-/*
- * gnc-ab-transfer.c --
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation; either version 2 of
- * the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, contact:
- *
- * Free Software Foundation           Voice:  +1-617-542-5942
- * 51 Franklin Street, Fifth Floor    Fax:    +1-617-542-2652
- * Boston, MA  02110-1301,  USA       gnu at gnu.org
- */
-
-/**
- * @internal
- * @file gnc-ab-utils.c
- * @brief AqBanking transfer functions
- * @author Copyright (C) 2002 Christian Stimming <stimming at tuhh.de>
- * @author Copyright (C) 2004 Bernd Wagner
- * @author Copyright (C) 2006 David Hampton <hampton at employees.org>
- * @author Copyright (C) 2008 Andreas Koehler <andi5.py at gmx.net>
- */
-
-#include "config.h"
-
-#include <glib/gi18n.h>
-#include <gtk/gtk.h>
-#include <aqbanking/banking.h>
-
-#include "Transaction.h"
-#include "dialog-transfer.h"
-#include "gnc-ab-transfer.h"
-#include "gnc-ab-kvp.h"
-#include "gnc-ab-utils.h"
-#include "gnc-ab-trans-templ.h"
-#include "gnc-gwen-gui.h"
-#include "gnc-ui.h"
-
-/* This static indicates the debugging module that this .o belongs to.  */
-G_GNUC_UNUSED static QofLogModule log_module = G_LOG_DOMAIN;
-
-static void save_templates(GtkWidget *parent, Account *gnc_acc, GList *templates,
-                           gboolean dont_ask);
-static void txn_created_cb(Transaction *trans, gpointer user_data);
-
-static void
-save_templates(GtkWidget *parent, Account *gnc_acc, GList *templates,
-               gboolean dont_ask)
-{
-    g_return_if_fail(gnc_acc);
-    if (dont_ask || gnc_verify_dialog(
-                parent, FALSE, "%s",
-                _("You have changed the list of online transfer templates, "
-                  "but you cancelled the transfer dialog. "
-                  "Do you nevertheless want to store the changes?")))
-    {
-        GList *kvp_list = gnc_ab_trans_templ_list_to_kvp_list(templates);
-        gnc_ab_set_book_template_list(gnc_account_get_book(gnc_acc), kvp_list);
-    }
-}
-
-static void
-txn_created_cb(Transaction *trans, gpointer user_data)
-{
-    Transaction **trans_loc = user_data;
-
-    if (!trans) return;
-    g_return_if_fail(trans_loc);
-    *trans_loc = trans;
-}
-
-void
-gnc_ab_maketrans(GtkWidget *parent, Account *gnc_acc,
-                 GncABTransType trans_type)
-{
-    AB_BANKING *api;
-    gboolean online = FALSE;
-    AB_ACCOUNT *ab_acc;
-    GList *templates = NULL;
-    GncABTransDialog *td = NULL;
-    gboolean successful = FALSE;
-    gboolean aborted = FALSE;
-
-    g_return_if_fail(parent && gnc_acc);
-
-    /* Get the API */
-    api = gnc_AB_BANKING_new();
-    if (!api)
-    {
-        g_warning("gnc_ab_maketrans: Couldn't get AqBanking API");
-        return;
-    }
-    if (AB_Banking_OnlineInit(api
-#ifdef AQBANKING_VERSION_4_EXACTLY
-                              , 0
-#endif
-                             ) != 0)
-    {
-        g_warning("gnc_ab_maketrans: Couldn't initialize AqBanking API");
-        goto cleanup;
-    }
-    online = TRUE;
-
-    /* Get the AqBanking Account */
-    ab_acc = gnc_ab_get_ab_account(api, gnc_acc);
-    if (!ab_acc)
-    {
-        g_warning("gnc_ab_gettrans: No AqBanking account found");
-        gnc_error_dialog(parent, _("No valid online banking account assigned."));
-        goto cleanup;
-    }
-
-    /* Get list of template transactions */
-    templates = gnc_ab_trans_templ_list_new_from_kvp_list(
-                    gnc_ab_get_book_template_list(gnc_account_get_book(gnc_acc)));
-
-    /* Create new ABTransDialog */
-    td = gnc_ab_trans_dialog_new(parent, ab_acc,
-                                 xaccAccountGetCommoditySCU(gnc_acc),
-                                 trans_type, templates);
-    templates = NULL;
-
-    /* Repeat until AqBanking action was successful or user pressed cancel */
-    do
-    {
-        GncGWENGui *gui = NULL;
-        gint result;
-        gboolean changed;
-        const AB_TRANSACTION *ab_trans;
-        AB_JOB *job = NULL;
-        AB_JOB_LIST2 *job_list = NULL;
-        XferDialog *xfer_dialog = NULL;
-        gnc_numeric amount;
-        gchar *description;
-        gchar *memo;
-        Transaction *gnc_trans = NULL;
-        AB_IMEXPORTER_CONTEXT *context = NULL;
-        AB_JOB_STATUS job_status;
-        GncABImExContextImport *ieci = NULL;
-
-        /* Get a GUI object */
-        gui = gnc_GWEN_Gui_get(parent);
-        if (!gui)
-        {
-            g_warning("gnc_ab_maketrans: Couldn't initialize Gwenhywfar GUI");
-            aborted = TRUE;
-            goto repeat;
-        }
-
-        /* Let the user enter the values */
-        result = gnc_ab_trans_dialog_run_until_ok(td);
-
-        if (result != GNC_RESPONSE_NOW && result != GNC_RESPONSE_LATER)
-        {
-            aborted = TRUE;
-            goto repeat;
-        }
-
-        /* Save the templates */
-        templates = gnc_ab_trans_dialog_get_templ(td, &changed);
-        if (changed)
-            save_templates(parent, gnc_acc, templates,
-                           (result == GNC_RESPONSE_NOW));
-        g_list_free(templates);
-        templates = NULL;
-
-        /* Get a job and enqueue it */
-        ab_trans = gnc_ab_trans_dialog_get_ab_trans(td);
-        job = gnc_ab_trans_dialog_get_job(td);
-        if (!job || AB_Job_CheckAvailability(job
-#ifndef AQBANKING_VERSION_5_PLUS
-                                             , 0
-#endif
-                                            ))
-        {
-            if (!gnc_verify_dialog(
-                        parent, FALSE, "%s",
-                        _("The backend found an error during the preparation "
-                          "of the job. It is not possible to execute this job. \n"
-                          "\n"
-                          "Most probable the bank does not support your chosen "
-                          "job or your Online Banking account does not have the permission "
-                          "to execute this job. More error messages might be "
-                          "visible on your console log.\n"
-                          "\n"
-                          "Do you want to enter the job again?")))
-                aborted = TRUE;
-            goto repeat;
-        }
-        job_list = AB_Job_List2_new();
-        AB_Job_List2_PushBack(job_list, job);
-
-        /* Setup a Transfer Dialog for the GnuCash transaction */
-        xfer_dialog = gnc_xfer_dialog(gnc_ab_trans_dialog_get_parent(td),
-                                      gnc_acc);
-        switch (trans_type)
-        {
-        case SINGLE_DEBITNOTE:
-            gnc_xfer_dialog_set_title(
-                xfer_dialog, _("Online Banking Direct Debit Note"));
-            gnc_xfer_dialog_lock_to_account_tree(xfer_dialog);
-            break;
-        case SINGLE_INTERNAL_TRANSFER:
-            gnc_xfer_dialog_set_title(
-                xfer_dialog, _("Online Banking Bank-Internal Transfer"));
-            gnc_xfer_dialog_lock_from_account_tree(xfer_dialog);
-            break;
-        case SEPA_TRANSFER:
-            gnc_xfer_dialog_set_title(
-                xfer_dialog, _("Online Banking European (SEPA) Transfer"));
-            gnc_xfer_dialog_lock_from_account_tree(xfer_dialog);
-            break;
-        case SEPA_DEBITNOTE:
-            gnc_xfer_dialog_set_title(
-                xfer_dialog, _("Online Banking European (SEPA) Debit Note"));
-            gnc_xfer_dialog_lock_to_account_tree(xfer_dialog);
-            break;
-        case SINGLE_TRANSFER:
-        default:
-            gnc_xfer_dialog_set_title(
-                xfer_dialog, _("Online Banking Transaction"));
-            gnc_xfer_dialog_lock_from_account_tree(xfer_dialog);
-        }
-        gnc_xfer_dialog_set_to_show_button_active(xfer_dialog, TRUE);
-
-        amount = double_to_gnc_numeric(
-                     AB_Value_GetValueAsDouble(AB_Transaction_GetValue(ab_trans)),
-                     xaccAccountGetCommoditySCU(gnc_acc),
-                     GNC_HOW_RND_ROUND_HALF_UP);
-        gnc_xfer_dialog_set_amount(xfer_dialog, amount);
-        gnc_xfer_dialog_set_amount_sensitive(xfer_dialog, FALSE);
-        gnc_xfer_dialog_set_date_sensitive(xfer_dialog, FALSE);
-
-        description = gnc_ab_description_to_gnc(ab_trans);
-        gnc_xfer_dialog_set_description(xfer_dialog, description);
-        g_free(description);
-
-        memo = gnc_ab_memo_to_gnc(ab_trans);
-        gnc_xfer_dialog_set_memo(xfer_dialog, memo);
-        g_free(memo);
-
-        gnc_xfer_dialog_set_txn_cb(xfer_dialog, txn_created_cb, &gnc_trans);
-
-        /* And run it */
-        successful = gnc_xfer_dialog_run_until_done(xfer_dialog);
-
-        /* On cancel, go back to the AB transaction dialog */
-        if (!successful || !gnc_trans)
-        {
-            successful = FALSE;
-            goto repeat;
-        }
-
-        if (result == GNC_RESPONSE_NOW)
-        {
-            /* Create a context to store possible results */
-            context = AB_ImExporterContext_new();
-
-            gui = gnc_GWEN_Gui_get(parent);
-            if (!gui)
-            {
-                g_warning("gnc_ab_maketrans: Couldn't initialize Gwenhywfar GUI");
-                aborted = TRUE;
-                goto repeat;
-            }
-
-            /* Finally, execute the job */
-            AB_Banking_ExecuteJobs(api, job_list, context
-#ifndef AQBANKING_VERSION_5_PLUS
-                                   , 0
-#endif
-                                  );
-
-            /* Ignore the return value of AB_Banking_ExecuteJobs(), as the job's
-             * status always describes better whether the job was actually
-             * transferred to and accepted by the bank.  See also
-             * http://lists.gnucash.org/pipermail/gnucash-de/2008-September/006389.html
-             */
-            job_status = AB_Job_GetStatus(job);
-            if (job_status != AB_Job_StatusFinished
-                    && job_status != AB_Job_StatusPending)
-            {
-                successful = FALSE;
-                if (!gnc_verify_dialog(
-                            parent, FALSE, "%s",
-                            _("An error occurred while executing the job. Please check "
-                              "the log window for the exact error message.\n"
-                              "\n"
-                              "Do you want to enter the job again?")))
-                {
-                    aborted = TRUE;
-                }
-            }
-            else
-            {
-                successful = TRUE;
-            }
-
-            if (successful)
-            {
-                /* Import the results, awaiting nothing */
-                ieci = gnc_ab_import_context(context, 0, FALSE, NULL, parent);
-            }
-        }
-        /* Simply ignore any other case */
-
-repeat:
-        /* Clean up */
-        if (gnc_trans && !successful)
-        {
-            xaccTransBeginEdit(gnc_trans);
-            xaccTransDestroy(gnc_trans);
-            xaccTransCommitEdit(gnc_trans);
-            gnc_trans = NULL;
-        }
-        if (ieci)
-            g_free(ieci);
-        if (context)
-            AB_ImExporterContext_free(context);
-        if (job_list)
-        {
-            AB_Job_List2_free(job_list);
-            job_list = NULL;
-        }
-        if (job)
-        {
-            AB_Job_free(job);
-            job = NULL;
-        }
-        if (gui)
-        {
-            gnc_GWEN_Gui_release(gui);
-            gui = NULL;
-        }
-
-    }
-    while (!successful && !aborted);
-
-cleanup:
-    if (td)
-        gnc_ab_trans_dialog_free(td);
-    if (online)
-#ifdef AQBANKING_VERSION_4_EXACTLY
-        AB_Banking_OnlineFini(api, 0);
-#else
-        AB_Banking_OnlineFini(api);
-#endif
-    gnc_AB_BANKING_fini(api);
-}

Deleted: gnucash/trunk/src/import-export/aqbanking/gnc-ab-transfer.h
===================================================================
--- gnucash/trunk/src/import-export/aqbanking/gnc-ab-transfer.h	2013-12-15 17:20:10 UTC (rev 23566)
+++ gnucash/trunk/src/import-export/aqbanking/gnc-ab-transfer.h	2013-12-15 17:21:20 UTC (rev 23567)
@@ -1,58 +0,0 @@
-/*
- * gnc-ab-transfer.h --
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation; either version 2 of
- * the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, contact:
- *
- * Free Software Foundation           Voice:  +1-617-542-5942
- * 51 Franklin Street, Fifth Floor    Fax:    +1-617-542-2652
- * Boston, MA  02110-1301,  USA       gnu at gnu.org
- */
-
-/**
- * @addtogroup Import_Export
- * @{
- * @addtogroup AqBanking
- * @{
- * @file gnc-ab-transfer.h
- * @brief Dialog for AqBanking transaction data
- * @author Copyright (C) 2002 Christian Stimming <stimming at tuhh.de>
- * @author Copyright (C) 2008 Andreas Koehler <andi5.py at gmx.net>
- */
-
-#ifndef GNC_AB_TRANSFER_H
-#define GNC_AB_TRANSFER_H
-
-#include <gtk/gtk.h>
-
-#include "Account.h"
-#include "dialog-ab-trans.h"
-
-G_BEGIN_DECLS
-
-/**
- * FIXME
- *
- * @param parent Widget to use as parent, may be NULL
- * @param gnc_acc GnuCash account to fetch balance for
- * @param trans_type Type of transaction
- */
-void gnc_ab_maketrans(GtkWidget *parent, Account *gnc_acc,
-                      GncABTransType trans_type);
-
-G_END_DECLS
-
-/** @} */
-/** @} */
-
-#endif /* GNC_AB_TRANSFER_H */

Deleted: gnucash/trunk/src/import-export/aqbanking/gnc-ab-utils.c
===================================================================
--- gnucash/trunk/src/import-export/aqbanking/gnc-ab-utils.c	2013-12-15 17:20:10 UTC (rev 23566)
+++ gnucash/trunk/src/import-export/aqbanking/gnc-ab-utils.c	2013-12-15 17:21:20 UTC (rev 23567)
@@ -1,1099 +0,0 @@
-/*
- * gnc-ab-utils.c --
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation; either version 2 of
- * the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, contact:
- *
- * Free Software Foundation           Voice:  +1-617-542-5942
- * 51 Franklin Street, Fifth Floor    Fax:    +1-617-542-2652
- * Boston, MA  02110-1301,  USA       gnu at gnu.org
- */
-
-/**
- * @internal
- * @file gnc-ab-utils.c
- * @brief AqBanking utility functions
- * @author Copyright (C) 2002 Christian Stimming <stimming at tuhh.de>
- * @author Copyright (C) 2008 Andreas Koehler <andi5.py at gmx.net>
- */
-
-#include "config.h"
-
-#include <glib/gi18n.h>
-#include <gwenhywfar/gwenhywfar.h>
-#include <aqbanking/banking.h>
-
-#include "window-reconcile.h"
-#include "Transaction.h"
-#include "dialog-ab-trans.h"
-#include "gnc-ab-kvp.h"
-#include "gnc-ab-utils.h"
-#include "gnc-glib-utils.h"
-#include "gnc-gwen-gui.h"
-#include "gnc-prefs.h"
-#include "gnc-ui.h"
-#include "import-account-matcher.h"
-#include "import-main-matcher.h"
-#include "import-utilities.h"
-#include "qof.h"
-#include "engine-helpers.h"
-
-#ifdef AQBANKING_VERSION_5_PLUS
-# include <aqbanking/abgui.h>
-#endif /* AQBANKING_VERSION_5_PLUS */
-
-/* This static indicates the debugging module that this .o belongs to.  */
-G_GNUC_UNUSED static QofLogModule log_module = G_LOG_DOMAIN;
-
-/* Global variables for AB_BANKING caching. */
-static AB_BANKING *gnc_AB_BANKING = NULL;
-static gint gnc_AB_BANKING_refcount = 0;
-
-static gpointer join_ab_strings_cb(const gchar *str, gpointer user_data);
-static Account *gnc_ab_accinfo_to_gnc_acc(
-    AB_IMEXPORTER_ACCOUNTINFO *account_info);
-static const AB_TRANSACTION *txn_transaction_cb(
-    const AB_TRANSACTION *element, gpointer user_data);
-static AB_IMEXPORTER_ACCOUNTINFO *txn_accountinfo_cb(
-    AB_IMEXPORTER_ACCOUNTINFO *element, gpointer user_data);
-static AB_IMEXPORTER_ACCOUNTINFO *bal_accountinfo_cb(
-    AB_IMEXPORTER_ACCOUNTINFO *element, gpointer user_data);
-
-struct _GncABImExContextImport
-{
-    guint awaiting;
-    gboolean txn_found;
-    Account *gnc_acc;
-    AB_ACCOUNT *ab_acc;
-    gboolean execute_txns;
-    AB_BANKING *api;
-    GtkWidget *parent;
-    AB_JOB_LIST2 *job_list;
-    GNCImportMainMatcher *generic_importer;
-    GData *tmp_job_list;
-};
-
-void
-gnc_GWEN_Init(void)
-{
-    gchar* gwen_logging = g_strdup(g_getenv("GWEN_LOGLEVEL"));
-    gchar* aqb_logging = g_strdup(g_getenv("AQBANKING_LOGLEVEL"));
-
-    /* Initialize gwen library */
-    GWEN_Init();
-
-    /* Initialize gwen logging */
-    if (gnc_prefs_get_bool(GNC_PREFS_GROUP_AQBANKING, GNC_PREF_VERBOSE_DEBUG))
-    {
-        if (!gwen_logging)
-        {
-            GWEN_Logger_SetLevel(NULL, GWEN_LoggerLevel_Info);
-            GWEN_Logger_SetLevel(GWEN_LOGDOMAIN, GWEN_LoggerLevel_Info);
-        }
-        if (!aqb_logging)
-            GWEN_Logger_SetLevel(AQBANKING_LOGDOMAIN, GWEN_LoggerLevel_Debug);
-    }
-    else
-    {
-        if (!gwen_logging)
-        {
-            GWEN_Logger_SetLevel(NULL, GWEN_LoggerLevel_Error);
-            GWEN_Logger_SetLevel(GWEN_LOGDOMAIN, GWEN_LoggerLevel_Error);
-        }
-        if (!aqb_logging)
-            GWEN_Logger_SetLevel(AQBANKING_LOGDOMAIN, GWEN_LoggerLevel_Warning);
-    }
-    g_free(gwen_logging);
-    g_free(aqb_logging);
-    gnc_GWEN_Gui_log_init();
-}
-
-void
-gnc_GWEN_Fini(void)
-{
-    /* Shutdown the GWEN_GUIs */
-    gnc_GWEN_Gui_shutdown();
-    GWEN_Logger_SetLevel(NULL, GWEN_LoggerLevel_Error);
-    GWEN_Logger_SetLevel(GWEN_LOGDOMAIN, GWEN_LoggerLevel_Warning);
-    GWEN_Logger_SetLevel(AQBANKING_LOGDOMAIN, GWEN_LoggerLevel_Warning);
-
-    /* Finalize gwen library */
-    GWEN_Fini();
-}
-
-static GWEN_GUI *gnc_gwengui_extended_by_ABBanking;
-
-AB_BANKING *
-gnc_AB_BANKING_new(void)
-{
-    AB_BANKING *api;
-
-    if (gnc_AB_BANKING)
-    {
-        /* API cached. */
-        api = gnc_AB_BANKING;
-
-        /* Init the API again. */
-        if (gnc_AB_BANKING_refcount == 0)
-            g_return_val_if_fail(AB_Banking_Init(api) == 0, NULL);
-
-    }
-    else
-    {
-        api = AB_Banking_new("gnucash", NULL, 0);
-        g_return_val_if_fail(api, NULL);
-
-#ifdef AQBANKING_VERSION_4_PLUS
-        /* Check for config migration */
-        if (AB_Banking_HasConf4(api
-# ifndef AQBANKING_VERSION_5_PLUS
-                                , 0
-# endif
-                               ) != 0)
-        {
-            if (AB_Banking_HasConf3(api
-# ifndef AQBANKING_VERSION_5_PLUS
-                                    , 0
-# endif
-                                   ) == 0)
-            {
-                g_message("gnc_AB_BANKING_new: importing aqbanking3 configuration\n");
-                if (AB_Banking_ImportConf3(api
-# ifndef AQBANKING_VERSION_5_PLUS
-                                           , 0
-# endif
-                                          ) < 0)
-                {
-                    g_message("gnc_AB_BANKING_new: unable to import aqbanking3 configuration\n");
-                }
-            }
-            else if (AB_Banking_HasConf2(api
-# ifndef AQBANKING_VERSION_5_PLUS
-                                         , 0
-# endif
-                                        ) == 0)
-            {
-                g_message("gnc_AB_BANKING_new: importing aqbanking2 configuration\n");
-                if (AB_Banking_ImportConf2(api
-# ifndef AQBANKING_VERSION_5_PLUS
-                                           , 0
-# endif
-                                          ) < 0)
-                {
-                    g_message("gnc_AB_BANKING_new: unable to import aqbanking2 configuration\n");
-                }
-            }
-        }
-#endif /* AQBANKING_VERSION_4_PLUS */
-
-        /* Init the API */
-        g_return_val_if_fail(AB_Banking_Init(api) == 0, NULL);
-
-#ifdef AQBANKING_VERSION_5_PLUS
-        gnc_gwengui_extended_by_ABBanking = GWEN_Gui_GetGui();
-        AB_Gui_Extend(gnc_gwengui_extended_by_ABBanking, api);
-#endif /* AQBANKING_VERSION_5_PLUS */
-
-        /* Cache it */
-        gnc_AB_BANKING = api;
-        gnc_AB_BANKING_refcount = 0;
-    }
-
-    gnc_AB_BANKING_refcount++;
-
-    return api;
-}
-
-void
-gnc_AB_BANKING_delete(AB_BANKING *api)
-{
-    if (!api)
-        api = gnc_AB_BANKING;
-
-    if (api)
-    {
-        if (api == gnc_AB_BANKING)
-        {
-            gnc_AB_BANKING = NULL;
-            gnc_AB_BANKING_fini(api);
-        }
-
-        AB_Banking_free(api);
-    }
-}
-
-
-gint
-gnc_AB_BANKING_fini(AB_BANKING *api)
-{
-    if (api == gnc_AB_BANKING)
-    {
-        if (--gnc_AB_BANKING_refcount == 0)
-        {
-#ifdef AQBANKING_VERSION_5_PLUS
-            if (gnc_gwengui_extended_by_ABBanking)
-                AB_Gui_Unextend(gnc_gwengui_extended_by_ABBanking);
-            gnc_gwengui_extended_by_ABBanking = NULL;
-#endif /* AQBANKING_VERSION_5_PLUS */
-            return AB_Banking_Fini(api);
-        }
-    }
-    else
-    {
-#ifdef AQBANKING_VERSION_5_PLUS
-        if (gnc_gwengui_extended_by_ABBanking)
-            AB_Gui_Unextend(gnc_gwengui_extended_by_ABBanking);
-        gnc_gwengui_extended_by_ABBanking = NULL;
-#endif /* AQBANKING_VERSION_5_PLUS */
-        return AB_Banking_Fini(api);
-    }
-    return 0;
-}
-
-AB_ACCOUNT *
-gnc_ab_get_ab_account(const AB_BANKING *api, Account *gnc_acc)
-{
-    AB_ACCOUNT *ab_account = NULL;
-    const gchar *bankcode = NULL;
-    const gchar *accountid = NULL;
-    guint32 account_uid = 0;
-
-    bankcode = gnc_ab_get_account_bankcode(gnc_acc);
-    accountid = gnc_ab_get_account_accountid(gnc_acc);
-    account_uid = gnc_ab_get_account_uid (gnc_acc);
-
-    if (account_uid > 0)
-    {
-        ab_account = AB_Banking_GetAccount(api, account_uid);
-
-        if (!ab_account && bankcode && *bankcode && accountid && *accountid)
-        {
-            g_message("gnc_ab_get_ab_account: No AB_ACCOUNT found for UID %d, "
-                      "trying bank code\n", account_uid);
-            ab_account = AB_Banking_GetAccountByCodeAndNumber(api, bankcode,
-                         accountid);
-        }
-        return ab_account;
-
-    }
-    else if (bankcode && *bankcode && accountid && *accountid)
-    {
-        ab_account = AB_Banking_GetAccountByCodeAndNumber(api, bankcode,
-                     accountid);
-        return ab_account;
-    }
-
-    return NULL;
-}
-
-gchar *
-gnc_AB_VALUE_to_readable_string(const AB_VALUE *value)
-{
-    if (value)
-        return g_strdup_printf("%.2f %s",
-                               AB_Value_GetValueAsDouble(value),
-                               AB_Value_GetCurrency(value));
-    else
-        return g_strdup_printf("%.2f", 0.0);
-}
-
-/**
- * Take a string from a GWEN_STRINGLIST, strip invalid utf8 and join it
- * to the rest.
- */
-static gpointer
-join_ab_strings_cb(const gchar *str, gpointer user_data)
-{
-    gchar **acc = user_data;
-    gchar *tmp;
-
-    if (!str || !*str)
-        return NULL;
-
-    tmp = g_strdup(str);
-    g_strstrip(tmp);
-    gnc_utf8_strip_invalid(tmp);
-
-    if (*acc)
-    {
-        gchar *join = g_strjoin(" ", *acc, tmp, (gchar*) NULL);
-        g_free(*acc);
-        g_free(tmp);
-        *acc = join;
-    }
-    else
-    {
-        *acc = tmp;
-    }
-    return NULL;
-}
-
-gchar *
-gnc_ab_get_remote_name(const AB_TRANSACTION *ab_trans)
-{
-    const GWEN_STRINGLIST *ab_remote_name;
-    gchar *gnc_other_name = NULL;
-
-    g_return_val_if_fail(ab_trans, NULL);
-
-    ab_remote_name = AB_Transaction_GetRemoteName(ab_trans);
-    if (ab_remote_name)
-        GWEN_StringList_ForEach(ab_remote_name, join_ab_strings_cb,
-                                &gnc_other_name);
-
-    if (!gnc_other_name || !*gnc_other_name)
-    {
-        g_free(gnc_other_name);
-        gnc_other_name = NULL;
-    }
-
-    return gnc_other_name;
-}
-
-gchar *
-gnc_ab_get_purpose(const AB_TRANSACTION *ab_trans)
-{
-    const GWEN_STRINGLIST *ab_purpose;
-    gchar *gnc_description = NULL;
-
-    g_return_val_if_fail(ab_trans, g_strdup(""));
-
-    ab_purpose = AB_Transaction_GetPurpose(ab_trans);
-    if (ab_purpose)
-        GWEN_StringList_ForEach(ab_purpose, join_ab_strings_cb,
-                                &gnc_description);
-
-    if (!gnc_description)
-        gnc_description = g_strdup("");
-
-    return gnc_description;
-}
-
-gchar *
-gnc_ab_description_to_gnc(const AB_TRANSACTION *ab_trans)
-{
-    /* Description */
-    gchar *description = gnc_ab_get_purpose(ab_trans);
-    gchar *other_name = gnc_ab_get_remote_name(ab_trans);
-    gchar *retval;
-
-    if (other_name)
-    {
-        if (description && *description)
-        {
-            retval = g_strdup_printf("%s; %s", description, other_name);
-        }
-        else
-        {
-            retval = g_strdup(other_name);
-        }
-    }
-    else
-    {
-        if (description && *description)
-        {
-            retval = g_strdup(description);
-        }
-        else
-        {
-            retval = g_strdup(_("Unspecified"));
-        }
-    }
-    g_free(description);
-    g_free(other_name);
-
-    return retval;
-}
-
-gchar *
-gnc_ab_memo_to_gnc(const AB_TRANSACTION *ab_trans)
-{
-    const gchar *ab_remote_accountnumber =
-        AB_Transaction_GetRemoteAccountNumber(ab_trans);
-    const gchar *ab_remote_bankcode =
-        AB_Transaction_GetRemoteBankCode(ab_trans);
-
-    gchar *ab_other_accountid;
-    gchar *ab_other_bankcode;
-
-    gboolean have_accountid;
-    gboolean have_bankcode;
-
-    gchar *retval;
-
-    // For SEPA transactions, we need to ask for something different here
-    if (!ab_remote_accountnumber)
-        ab_remote_accountnumber = AB_Transaction_GetRemoteIban(ab_trans);
-    if (!ab_remote_bankcode)
-        ab_remote_bankcode = AB_Transaction_GetRemoteBic(ab_trans);
-
-    ab_other_accountid = g_strdup(ab_remote_accountnumber ? ab_remote_accountnumber : "");
-    ab_other_bankcode = g_strdup(ab_remote_bankcode ? ab_remote_bankcode : "");
-
-    /* Ensure string is in utf8 */
-    gnc_utf8_strip_invalid(ab_other_accountid);
-    gnc_utf8_strip_invalid(ab_other_bankcode);
-
-    /* and -then- trim it */
-    g_strstrip(ab_other_accountid);
-    g_strstrip(ab_other_bankcode);
-
-
-    have_accountid = ab_other_accountid && *ab_other_accountid;
-    have_bankcode = ab_other_bankcode && *ab_other_bankcode;
-
-    if ( have_accountid || have_bankcode )
-    {
-        retval = g_strdup_printf("%s %s %s %s",
-                                 have_accountid ? _("Account") : "",
-                                 have_accountid ? ab_other_accountid : "",
-                                 have_bankcode  ? _("Bank") : "",
-                                 have_bankcode  ? ab_other_bankcode : ""
-                                );
-        g_strstrip(retval);
-    }
-    else
-    {
-        retval = g_strdup("");
-    }
-
-    g_free(ab_other_accountid);
-    g_free(ab_other_bankcode);
-
-    return retval;
-}
-
-Transaction *
-gnc_ab_trans_to_gnc(const AB_TRANSACTION *ab_trans, Account *gnc_acc)
-{
-    QofBook *book;
-    Transaction *gnc_trans;
-    const gchar *fitid;
-    const GWEN_TIME *valuta_date;
-    time64 current_time;
-    const char *custref;
-    gchar *description;
-    Split *split;
-    gchar *memo;
-
-    g_return_val_if_fail(ab_trans && gnc_acc, NULL);
-
-    /* Create new GnuCash transaction for the given AqBanking one */
-    book = gnc_account_get_book(gnc_acc);
-    gnc_trans = xaccMallocTransaction(book);
-    xaccTransBeginEdit(gnc_trans);
-
-    /* Date / Time */
-    valuta_date = AB_Transaction_GetValutaDate(ab_trans);
-    if (!valuta_date)
-    {
-        const GWEN_TIME *normal_date = AB_Transaction_GetDate(ab_trans);
-        if (normal_date)
-            valuta_date = normal_date;
-    }
-    if (valuta_date)
-        xaccTransSetDatePostedSecsNormalized(gnc_trans, GWEN_Time_toTime_t(valuta_date));
-    else
-        g_warning("transaction_cb: Oops, date 'valuta_date' was NULL");
-
-    xaccTransSetDateEnteredSecs(gnc_trans, gnc_time_utc (NULL));
-
-    /* Currency.  We take simply the default currency of the gnucash account */
-    xaccTransSetCurrency(gnc_trans, xaccAccountGetCommodity(gnc_acc));
-
-    /* Trans-Num or Split-Action set with gnc_set_num_action below per book
-     * option */
-
-    /* Description */
-    description = gnc_ab_description_to_gnc(ab_trans);
-    xaccTransSetDescription(gnc_trans, description);
-    g_free(description);
-
-    /* Notes. */
-    /* xaccTransSetNotes(gnc_trans, g_notes); */
-    /* But Nobody ever uses the Notes field? */
-
-    /* Add one split */
-    split = xaccMallocSplit(book);
-    xaccSplitSetParent(split, gnc_trans);
-    xaccSplitSetAccount(split, gnc_acc);
-
-    /* Set the transaction number or split action field based on book option.
-     * We use the "customer reference", if there is one. */
-    custref = AB_Transaction_GetCustomerReference(ab_trans);
-    if (custref && *custref
-            && g_ascii_strncasecmp(custref, "NONREF", 6) != 0)
-        gnc_set_num_action (gnc_trans, split, custref, NULL);
-
-    /* Set OFX unique transaction ID */
-    fitid = AB_Transaction_GetFiId(ab_trans);
-    if (fitid && *fitid)
-        gnc_import_set_split_online_id(split, fitid);
-
-    {
-        /* Amount into the split */
-        const AB_VALUE *ab_value = AB_Transaction_GetValue(ab_trans);
-        double d_value = ab_value ? AB_Value_GetValueAsDouble (ab_value) : 0.0;
-        AB_TRANSACTION_TYPE ab_type = AB_Transaction_GetType (ab_trans);
-        gnc_numeric gnc_amount;
-
-        /*printf("Transaction with value %f has type %d\n", d_value, ab_type);*/
-        /* If the value is positive, but the transaction type says the
-           money is transferred away from our account (Transfer instead of
-           DebitNote), we switch the value to negative. */
-        if (d_value > 0.0 && ab_type == AB_Transaction_TypeTransfer)
-            d_value = -d_value;
-
-        gnc_amount = double_to_gnc_numeric(
-                         d_value,
-                         xaccAccountGetCommoditySCU(gnc_acc),
-                         GNC_HOW_RND_ROUND_HALF_UP);
-        if (!ab_value)
-            g_warning("transaction_cb: Oops, value was NULL.  Using 0");
-        xaccSplitSetBaseValue(split, gnc_amount, xaccAccountGetCommodity(gnc_acc));
-    }
-
-    /* Memo in the Split. */
-    memo = gnc_ab_memo_to_gnc(ab_trans);
-    xaccSplitSetMemo(split, memo);
-    g_free(memo);
-
-    return gnc_trans;
-}
-
-/**
- * Call gnc_import_select_account() on the online id constructed using
- * the information in @a acc_info.
- *
- * @param acc_info AB_IMEXPORTER_ACCOUNTINFO
- * @return A GnuCash account, or NULL otherwise
- */
-static Account *
-gnc_ab_accinfo_to_gnc_acc(AB_IMEXPORTER_ACCOUNTINFO *acc_info)
-{
-    const gchar *bankcode, *accountnumber;
-    gchar *online_id;
-    Account *gnc_acc;
-
-    g_return_val_if_fail(acc_info, NULL);
-
-    bankcode = AB_ImExporterAccountInfo_GetBankCode(acc_info);
-    accountnumber = AB_ImExporterAccountInfo_GetAccountNumber(acc_info);
-    online_id = g_strconcat(bankcode ? bankcode : "",
-                            accountnumber ? accountnumber : "",
-                            (gchar*)NULL);
-    gnc_acc = gnc_import_select_account(
-                  NULL, online_id, 1, AB_ImExporterAccountInfo_GetAccountName(acc_info),
-                  NULL, ACCT_TYPE_NONE, NULL, NULL);
-    if (!gnc_acc)
-    {
-        g_warning("gnc_ab_accinfo_to_gnc_acc: Could not determine source account"
-                  " for online_id %s", online_id);
-    }
-    g_free(online_id);
-
-    return gnc_acc;
-}
-
-static const AB_TRANSACTION *
-txn_transaction_cb(const AB_TRANSACTION *element, gpointer user_data)
-{
-    GncABImExContextImport *data = user_data;
-    Transaction *gnc_trans;
-    GncABTransType trans_type;
-
-    g_return_val_if_fail(element && data, NULL);
-
-    /* Create a GnuCash transaction from ab_trans */
-    gnc_trans = gnc_ab_trans_to_gnc(element, data->gnc_acc);
-
-    if (data->execute_txns && data->ab_acc)
-    {
-        AB_TRANSACTION *ab_trans = AB_Transaction_dup(element);
-        AB_JOB *job;
-
-        /* NEW: The imported transaction has been imported into gnucash.
-         * Now also add it as a job to aqbanking */
-        AB_Transaction_SetLocalBankCode(
-            ab_trans, AB_Account_GetBankCode(data->ab_acc));
-        AB_Transaction_SetLocalAccountNumber(
-            ab_trans, AB_Account_GetAccountNumber(data->ab_acc));
-        AB_Transaction_SetLocalCountry(ab_trans, "DE");
-
-
-        switch (AB_Transaction_GetType(ab_trans))
-        {
-        case AB_Transaction_TypeDebitNote:
-            trans_type = SINGLE_DEBITNOTE;
-            break;
-        case AB_Transaction_TypeEuTransfer:
-            trans_type = SEPA_TRANSFER;
-            break;
-        case AB_Transaction_TypeTransaction:
-            /* trans_type = SINGLE_INTERNAL_TRANSFER;
-             * break; */
-        case AB_Transaction_TypeTransfer:
-        default:
-            trans_type = SINGLE_TRANSFER;
-        } /* switch */
-
-        job = gnc_ab_get_trans_job(data->ab_acc, ab_trans, trans_type);
-
-        /* Check whether we really got a job */
-        if (!job || AB_Job_CheckAvailability(job
-#ifndef AQBANKING_VERSION_5_PLUS
-                                             , 0
-#endif
-                                            ))
-        {
-            /* Oops, no job, probably not supported by bank */
-            if (gnc_verify_dialog(
-                        NULL, FALSE, "%s",
-                        _("The backend found an error during the preparation "
-                          "of the job. It is not possible to execute this job. \n"
-                          "\n"
-                          "Most probably the bank does not support your chosen "
-                          "job or your Online Banking account does not have the permission "
-                          "to execute this job. More error messages might be "
-                          "visible on your console log.\n"
-                          "\n"
-                          "Do you want to enter the job again?")))
-            {
-                gnc_error_dialog(NULL, "Sorry, not implemented yet. Please check the console or trace file logs to see which job was rejected.");
-            }
-        }
-        else
-        {
-            gnc_gen_trans_list_add_trans_with_ref_id(data->generic_importer, gnc_trans, AB_Job_GetJobId(job));
-
-            /* AB_Job_List2_PushBack(data->job_list, job); -> delayed until trans is successfully imported */
-            g_datalist_set_data(&data->tmp_job_list, gnc_AB_JOB_to_readable_string(job), job);
-        }
-        AB_Transaction_free(ab_trans);
-    }
-    else
-    {
-        /* Instead of xaccTransCommitEdit(gnc_trans)  */
-        gnc_gen_trans_list_add_trans(data->generic_importer, gnc_trans);
-    }
-
-    return NULL;
-}
-
-static void gnc_ab_trans_processed_cb(GNCImportTransInfo *trans_info,
-                                      gboolean imported,
-                                      gpointer user_data)
-{
-    GncABImExContextImport *data = user_data;
-    gchar *jobname = gnc_AB_JOB_ID_to_string(gnc_import_TransInfo_get_ref_id(trans_info));
-    AB_JOB *job = g_datalist_get_data(&data->tmp_job_list, jobname);
-
-    if (imported)
-    {
-        AB_Job_List2_PushBack(data->job_list, job);
-    }
-    else
-    {
-        AB_Job_free(job);
-    }
-
-    g_datalist_remove_data(&data->tmp_job_list, jobname);
-}
-
-gchar *
-gnc_AB_JOB_to_readable_string(const AB_JOB *job)
-{
-    if (job)
-    {
-        return gnc_AB_JOB_ID_to_string(AB_Job_GetJobId(job));
-    }
-    else
-    {
-        return gnc_AB_JOB_ID_to_string(0);
-    }
-}
-gchar *
-gnc_AB_JOB_ID_to_string(gulong job_id)
-{
-    return g_strdup_printf("job_%lu", job_id);
-}
-
-
-
-static AB_IMEXPORTER_ACCOUNTINFO *
-txn_accountinfo_cb(AB_IMEXPORTER_ACCOUNTINFO *element, gpointer user_data)
-{
-    GncABImExContextImport *data = user_data;
-    Account *gnc_acc;
-
-    g_return_val_if_fail(element && data, NULL);
-
-    if (data->awaiting & IGNORE_TRANSACTIONS)
-        /* Ignore them */
-        return NULL;
-
-    if (!AB_ImExporterAccountInfo_GetFirstTransaction(element))
-        /* No transaction found */
-        return NULL;
-    else
-        data->awaiting |= FOUND_TRANSACTIONS;
-
-    if (!(data->awaiting & AWAIT_TRANSACTIONS))
-    {
-        if (gnc_verify_dialog(data->parent, TRUE, "%s",
-                              _("The bank has sent transaction information "
-                                "in its response."
-                                "\n"
-                                "Do you want to import it?")))
-        {
-            data->awaiting |= AWAIT_TRANSACTIONS;
-        }
-        else
-        {
-            data->awaiting |= IGNORE_TRANSACTIONS;
-            return NULL;
-        }
-    }
-
-    /* Lookup the corresponding gnucash account */
-    gnc_acc = gnc_ab_accinfo_to_gnc_acc(element);
-    if (!gnc_acc) return NULL;
-    data->gnc_acc = gnc_acc;
-
-    if (data->execute_txns)
-    {
-        /* Retrieve the aqbanking account that belongs to this gnucash
-         * account */
-        data->ab_acc = gnc_ab_get_ab_account(data->api, gnc_acc);
-        if (!data->ab_acc)
-        {
-            gnc_error_dialog(NULL, "%s",
-                             _("No Online Banking account found for this "
-                               "gnucash account. These transactions will "
-                               "not be executed by Online Banking."));
-        }
-    }
-    else
-    {
-        data->ab_acc = NULL;
-    }
-
-    if (!data->generic_importer)
-    {
-        data->generic_importer = gnc_gen_trans_list_new(data->parent, NULL,
-                                 TRUE, 14);
-        if (data->execute_txns)
-        {
-            gnc_gen_trans_list_add_tp_cb(data->generic_importer,
-                                         gnc_ab_trans_processed_cb, data);
-        }
-    }
-
-    /* Iterate through all transactions */
-    AB_ImExporterAccountInfo_TransactionsForEach(element, txn_transaction_cb,
-            data);
-
-    return NULL;
-}
-
-static AB_IMEXPORTER_ACCOUNTINFO *
-bal_accountinfo_cb(AB_IMEXPORTER_ACCOUNTINFO *element, gpointer user_data)
-{
-    GncABImExContextImport *data = user_data;
-    Account *gnc_acc;
-    AB_ACCOUNT_STATUS *item, *best = NULL;
-    const GWEN_TIME *best_time = NULL;
-    const AB_BALANCE *booked_bal, *noted_bal;
-    const AB_VALUE *booked_val = NULL, *noted_val = NULL;
-    gdouble booked_value, noted_value;
-    gnc_numeric value;
-    time64 booked_tt = 0;
-    GtkWidget *dialog;
-    gboolean show_recn_window = FALSE;
-
-    g_return_val_if_fail(element && data, NULL);
-
-    if (data->awaiting & IGNORE_BALANCES)
-        /* Ignore them */
-        return NULL;
-
-    if (!AB_ImExporterAccountInfo_GetFirstAccountStatus(element))
-        /* No balance found */
-        return NULL;
-    else
-        data->awaiting |= FOUND_BALANCES;
-
-    /* Lookup the most recent ACCOUNT_STATUS available */
-    item = AB_ImExporterAccountInfo_GetFirstAccountStatus(element);
-    while (item)
-    {
-        const GWEN_TIME *item_time = AB_AccountStatus_GetTime(item);
-        if (!best || GWEN_Time_Diff(best_time, item_time) < 0.0)
-        {
-            best = item;
-            best_time = item_time;
-        }
-        item = AB_ImExporterAccountInfo_GetNextAccountStatus(element);
-    }
-
-    booked_bal = AB_AccountStatus_GetBookedBalance(best);
-    if (!(data->awaiting & AWAIT_BALANCES))
-    {
-        /* Ignore zero balances if we don't await a balance */
-        if (!booked_bal || AB_Value_IsZero(AB_Balance_GetValue(booked_bal)))
-            return NULL;
-
-        /* Ask the user whether to import unawaited non-zero balance */
-        if (gnc_verify_dialog(data->parent, TRUE, "%s",
-                              _("The bank has sent balance information "
-                                "in its response."
-                                "\n"
-                                "Do you want to import it?")))
-        {
-            data->awaiting |= AWAIT_BALANCES;
-        }
-        else
-        {
-            data->awaiting |= IGNORE_BALANCES;
-            return NULL;
-        }
-    }
-
-    /* Lookup the corresponding gnucash account */
-    gnc_acc = gnc_ab_accinfo_to_gnc_acc(element);
-    if (!gnc_acc) return NULL;
-    data->gnc_acc = gnc_acc;
-
-    /* Lookup booked balance and time */
-    if (booked_bal)
-    {
-        const GWEN_TIME *ti = AB_Balance_GetTime(booked_bal);
-        if (ti)
-        {
-            booked_tt =  GWEN_Time_toTime_t(ti);
-        }
-        else
-        {
-            /* No time found? Use today because the HBCI query asked for today's
-             * balance. */
-            booked_tt = gnc_time64_get_day_start(gnc_time(NULL));
-        }
-        booked_val = AB_Balance_GetValue(booked_bal);
-        if (booked_val)
-        {
-            booked_value = AB_Value_GetValueAsDouble(booked_val);
-        }
-        else
-        {
-            g_warning("bal_accountinfo_cb: booked_val == NULL.  Assuming 0");
-            booked_value = 0.0;
-        }
-    }
-    else
-    {
-        g_warning("bal_accountinfo_cb: booked_bal == NULL.  Assuming 0");
-        booked_tt = 0;
-        booked_value = 0.0;
-    }
-
-    /* Lookup noted balance */
-    noted_bal = AB_AccountStatus_GetNotedBalance(best);
-    if (noted_bal)
-    {
-        noted_val = AB_Balance_GetValue(noted_bal);
-        if (noted_val)
-            noted_value = AB_Value_GetValueAsDouble(noted_val);
-        else
-        {
-            g_warning("bal_accountinfo_cb: noted_val == NULL.  Assuming 0");
-            noted_value = 0.0;
-        }
-    }
-    else
-    {
-        g_warning("bal_accountinfo_cb: noted_bal == NULL.  Assuming 0");
-        noted_value = 0.0;
-    }
-
-    value = double_to_gnc_numeric(booked_value,
-                                  xaccAccountGetCommoditySCU(gnc_acc),
-                                  GNC_HOW_RND_ROUND_HALF_UP);
-    if (noted_value == 0.0 && booked_value == 0.0)
-    {
-        dialog = gtk_message_dialog_new(
-                     GTK_WINDOW(data->parent),
-                     GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT,
-                     GTK_MESSAGE_INFO,
-                     GTK_BUTTONS_OK,
-                     "%s",
-                     /* Translators: Strings from this file are needed only in
-                      * countries that have one of aqbanking's Online Banking
-                      * techniques available. This is 'OFX DirectConnect'
-                      * (U.S. and others), 'HBCI' (in Germany), or 'YellowNet'
-                      * (Switzerland). If none of these techniques are available
-                      * in your country, you may safely ignore strings from the
-                      * import-export/hbci subdirectory. */
-                     _("The downloaded Online Banking Balance was zero.\n\n"
-                       "Either this is the correct balance, or your bank does not "
-                       "support Balance download in this Online Banking version. "
-                       "In the latter case you should choose a different "
-                       "Online Banking version number in the Online Banking "
-                       "(AqBanking or HBCI) Setup. After that, try again to "
-                       "download the Online Banking Balance."));
-        gtk_dialog_run(GTK_DIALOG(dialog));
-        gtk_widget_destroy(dialog);
-
-    }
-    else
-    {
-        gnc_numeric reconc_balance = xaccAccountGetReconciledBalance(gnc_acc);
-
-        gchar *booked_str = gnc_AB_VALUE_to_readable_string(booked_val);
-        gchar *message1 = g_strdup_printf(
-                              _("Result of Online Banking job: \n"
-                                "Account booked balance is %s"),
-                              booked_str);
-        gchar *message2 =
-            (noted_value == 0.0) ?
-            g_strdup("") :
-            g_strdup_printf(_("For your information: This account also "
-                              "has a noted balance of %s\n"),
-                            gnc_AB_VALUE_to_readable_string(noted_val));
-
-        if (gnc_numeric_equal(value, reconc_balance))
-        {
-            const gchar *message3 =
-                _("The booked balance is identical to the current "
-                  "reconciled balance of the account.");
-            dialog = gtk_message_dialog_new(
-                         GTK_WINDOW(data->parent),
-                         GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT,
-                         GTK_MESSAGE_INFO,
-                         GTK_BUTTONS_OK,
-                         "%s\n%s\n%s",
-                         message1, message2, message3);
-            gtk_dialog_run(GTK_DIALOG(dialog));
-            gtk_widget_destroy(GTK_WIDGET(dialog));
-
-        }
-        else
-        {
-            const char *message3 = _("Reconcile account now?");
-
-            show_recn_window = gnc_verify_dialog(data->parent, TRUE, "%s\n%s\n%s",
-                                                 message1, message2, message3);
-        }
-        g_free(booked_str);
-        g_free(message1);
-        g_free(message2);
-    }
-
-    /* Show reconciliation window */
-    if (show_recn_window)
-        recnWindowWithBalance(data->parent, gnc_acc, value, booked_tt);
-
-    return NULL;
-}
-
-GncABImExContextImport *
-gnc_ab_import_context(AB_IMEXPORTER_CONTEXT *context,
-                      guint awaiting, gboolean execute_txns,
-                      AB_BANKING *api, GtkWidget *parent)
-{
-    GncABImExContextImport *data = g_new(GncABImExContextImport, 1);
-
-    g_return_val_if_fail(context, NULL);
-    /* Do not await and ignore at the same time */
-    g_return_val_if_fail(!(awaiting & AWAIT_BALANCES)
-                         || !(awaiting & IGNORE_BALANCES),
-                         NULL);
-    g_return_val_if_fail(!(awaiting & AWAIT_TRANSACTIONS)
-                         || !(awaiting & IGNORE_TRANSACTIONS),
-                         NULL);
-    /* execute_txns must be FALSE if txns are not awaited */
-    g_return_val_if_fail(awaiting & AWAIT_TRANSACTIONS || !execute_txns, NULL);
-    /* An api is needed for the jobs */
-    g_return_val_if_fail(!execute_txns || api, NULL);
-
-    data->awaiting = awaiting;
-    data->txn_found = FALSE;
-    data->execute_txns = execute_txns;
-    data->api = api;
-    data->parent = parent;
-    data->job_list = AB_Job_List2_new();
-    data->tmp_job_list = NULL;
-    data->generic_importer = NULL;
-
-    g_datalist_init(&data->tmp_job_list);
-
-    /* Import transactions */
-    if (!(awaiting & IGNORE_TRANSACTIONS))
-        AB_ImExporterContext_AccountInfoForEach(context, txn_accountinfo_cb,
-                                                data);
-
-    /* Check balances */
-    if (!(awaiting & IGNORE_BALANCES))
-        AB_ImExporterContext_AccountInfoForEach(context, bal_accountinfo_cb,
-                                                data);
-
-    return data;
-}
-
-guint
-gnc_ab_ieci_get_found(GncABImExContextImport *ieci)
-{
-    g_return_val_if_fail(ieci, 0);
-
-    return ieci->awaiting;
-}
-
-AB_JOB_LIST2 *
-gnc_ab_ieci_get_job_list(GncABImExContextImport *ieci)
-{
-    g_return_val_if_fail(ieci, NULL);
-
-    return ieci->job_list;
-}
-
-gboolean
-gnc_ab_ieci_run_matcher(GncABImExContextImport *ieci)
-{
-    g_return_val_if_fail(ieci, FALSE);
-
-    return gnc_gen_trans_list_run(ieci->generic_importer);
-}
-
-GWEN_DB_NODE *
-gnc_ab_get_permanent_certs(void)
-{
-    int rv;
-    GWEN_DB_NODE *perm_certs = NULL;
-    AB_BANKING *banking = gnc_AB_BANKING_new();
-
-    g_return_val_if_fail(banking, NULL);
-#ifdef AQBANKING_VERSION_4_PLUS
-    rv = AB_Banking_LoadSharedConfig(banking, "certs", &perm_certs
-# ifndef AQBANKING_VERSION_5_PLUS
-                                     , 0
-# endif
-                                    );
-#else
-    /* FIXME: Add code for older AqBanking versions */
-    /* See QBankmanager 0.9.50 in src/kbanking/libs/kbanking.cpp lines 323ff
-       for a proper example of how to do this */
-    rv = 0;
-#endif
-    gnc_AB_BANKING_fini(banking);
-    g_return_val_if_fail(rv >= 0, NULL);
-    return perm_certs;
-}

Deleted: gnucash/trunk/src/import-export/aqbanking/gnc-ab-utils.h
===================================================================
--- gnucash/trunk/src/import-export/aqbanking/gnc-ab-utils.h	2013-12-15 17:20:10 UTC (rev 23566)
+++ gnucash/trunk/src/import-export/aqbanking/gnc-ab-utils.h	2013-12-15 17:21:20 UTC (rev 23567)
@@ -1,280 +0,0 @@
-/*
- * gnc-ab-utils.h --
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation; either version 2 of
- * the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, contact:
- *
- * Free Software Foundation           Voice:  +1-617-542-5942
- * 51 Franklin Street, Fifth Floor    Fax:    +1-617-542-2652
- * Boston, MA  02110-1301,  USA       gnu at gnu.org
- */
-
-/**
- * @addtogroup Import_Export
- * @{
- * @addtogroup AqBanking
- * @{
- * @file gnc-ab-utils.h
- * @brief AqBanking utility functions
- * @author Copyright (C) 2002 Christian Stimming <stimming at tuhh.de>
- * @author Copyright (C) 2008 Andreas Koehler <andi5.py at gmx.net>
- */
-
-#ifndef GNC_AB_UTILS_H
-#define GNC_AB_UTILS_H
-
-#include <glib.h>
-#include <gtk/gtk.h>
-#include <aqbanking/banking.h>
-#include <gwenhywfar/version.h>
-
-#include "Account.h"
-
-G_BEGIN_DECLS
-
-/** A define that combines the aqbanking version number into one single
- * integer number. Assumption: Both MINOR and PATCHLEVEL numbers are
- * in the interval [0..99]. */
-#define AQBANKING_VERSION_INT (10000 * AQBANKING_VERSION_MAJOR + 100 * AQBANKING_VERSION_MINOR + AQBANKING_VERSION_PATCHLEVEL)
-
-/** A define that combines the gwenhywfar version number into one single
- * integer number. Assumption: Both MINOR and PATCHLEVEL numbers are
- * in the interval [0..99]. */
-#define GWENHYWFAR_VERSION_INT (10000 * GWENHYWFAR_VERSION_MAJOR + 100 * GWENHYWFAR_VERSION_MINOR + GWENHYWFAR_VERSION_PATCHLEVEL)
-
-#if AQBANKING_VERSION_INT >= 39900
-/** Defined if libaqbanking4 as opposed to libaqbanking3 or earlier is
- * being used */
-# define AQBANKING_VERSION_4_PLUS
-#endif
-
-#if AQBANKING_VERSION_INT >= 49900
-/** Defined if libaqbanking5 as opposed to libaqbanking4 or earlier is
- * being used */
-# define AQBANKING_VERSION_5_PLUS
-#endif
-
-#if defined(AQBANKING_VERSION_4_PLUS) && !defined(AQBANKING_VERSION_5_PLUS)
-/** Defined if libaqbanking4 is used and neither a newer nor an older
- * version of libaqbanking. */
-# define AQBANKING_VERSION_4_EXACTLY
-#endif
-
-#define GNC_PREFS_GROUP_AQBANKING "dialogs.import.hbci"
-#define GNC_PREF_FORMAT_SWIFT940  "format-swift-mt940"
-#define GNC_PREF_FORMAT_SWIFT942  "format-swift-mt942"
-#define GNC_PREF_FORMAT_DTAUS     "format-dtaus"
-#define GNC_PREF_VERBOSE_DEBUG    "verbose-debug"
-
-typedef struct _GncABImExContextImport GncABImExContextImport;
-
-#define AWAIT_BALANCES      1 << 1
-#define FOUND_BALANCES      1 << 2
-#define IGNORE_BALANCES     1 << 3
-#define AWAIT_TRANSACTIONS  1 << 4
-#define FOUND_TRANSACTIONS  1 << 5
-#define IGNORE_TRANSACTIONS 1 << 6
-
-/**
- * Initialize the gwenhywfar library by calling GWEN_Init() and setting up
- * gwenhywfar logging.
- */
-void gnc_GWEN_Init(void);
-
-/**
- * Finalize the gwenhywfar library.
- */
-void gnc_GWEN_Fini(void);
-
-/**
- * If there is a cached AB_BANKING object, return it initialized.  Otherwise,
- * create a new AB_BANKING, let it load its environment from its default
- * configuration and cache it.
- *
- * @return The AB_BANKING object
- */
-AB_BANKING *gnc_AB_BANKING_new(void);
-
-/**
- * Delete the AB_BANKING @a api.  If this is also the one that was cached by
- * gnc_AB_BANKING_new(), then all references are deleted, too.
- *
- * @param api AB_BANKING or NULL for the cached AB_BANKING object
- */
-void gnc_AB_BANKING_delete(AB_BANKING *api);
-
-/**
- * Finish the AB_BANKING @a api.  If this is also the one that was cached by
- * gnc_AB_BANKING_new(), then finish only if the decremented reference count
- * reaches zero.  After this call, you may only call gnc_AB_BANKING_new() to get
- * the api again in a properly initialized state.
- *
- * @param api AB_BANKING object
- * @return Zero on success
- */
-gint gnc_AB_BANKING_fini(AB_BANKING *api);
-
-/**
- * Get the corresponding AqBanking account to the GnuCash account @a gnc_acc.
- * Of course this only works after the GnuCash account has been set up for
- * AqBanking use, i.e. the kvp_frame "hbci/..." has been filled with
- * information.
- *
- * @param api The AB_BANKING to get the AB_ACCOUNT from
- * @param gnc_acc The GnuCash account to query for AB_ACCOUNT reference data
- * @return The AB_ACCOUNT found or NULL otherwise
- */
-AB_ACCOUNT *gnc_ab_get_ab_account(const AB_BANKING *api, Account *gnc_acc);
-
-/**
- * Print the value of @a value with two decimal places and @a value's
- * currency appended, or 0.0 otherwise
- *
- * @param value AB_VALUE or NULL
- * @return A newly allocated string
- */
-gchar *gnc_AB_VALUE_to_readable_string(const AB_VALUE *value);
-
-/**
- * Return the job as string.
- *
- * @param value AB_JOB or NULL
- * @return A newly allocated string
- */
-gchar *gnc_AB_JOB_to_readable_string(const AB_JOB *job);
-
-/**
- * Return the job_id as string.
- *
- * @param job_id
- * @return A newly allocated string
- */
-gchar *gnc_AB_JOB_ID_to_string(gulong job_id);
-
-/**
- * Retrieve the merged "remote name" fields from a transaction.  The returned
- * string must be g_free'd by the caller.  If there was no "remote name" field,
- * NULL (!) is returned.
- *
- * @param ab_trans AqBanking transaction
- * @return A newly allocated string or NULL otherwise
- */
-gchar *gnc_ab_get_remote_name(const AB_TRANSACTION *ab_trans);
-
-/**
- * Retrieve the merged purpose fields from a transaction.  The returned string
- * must be g_free'd by the caller.  If there was no purpose, an empty (but
- * allocated) string is returned.
- *
- * @param ab_trans AqBanking transaction
- * @return A newly allocated string, may be ""
- */
-gchar *gnc_ab_get_purpose(const AB_TRANSACTION *ab_trans);
-
-/**
- * Create the appropriate description field for a GnuCash Transaction by the
- * information given in the AB_TRANSACTION @a ab_trans.  The returned string
- * must be g_free'd by the caller.
- *
- * @param ab_trans AqBanking transaction
- * @return A newly allocated string, may be ""
- */
-gchar *gnc_ab_description_to_gnc(const AB_TRANSACTION *ab_trans);
-
-/**
- * Create the appropriate memo field for a GnuCash Split by the information
- * given in the AB_TRANSACTION @a ab_trans.  The returned string must be
- * g_free'd by the caller.
- *
- * @param ab_trans AqBanking transaction
- * @return A newly allocated string, may be ""
- */
-gchar *gnc_ab_memo_to_gnc(const AB_TRANSACTION *ab_trans);
-
-/**
- * Create an unbalanced and dirty GnuCash transaction with a split to @a gnc_acc
- * from the information available in the AqBanking transaction @a ab_trans.
- *
- * @param ab_trans AqBanking transaction
- * @param gnc_acc Account of to use for the split
- * @return A dirty GnuCash transaction or NULL otherwise
- */
-Transaction *gnc_ab_trans_to_gnc(const AB_TRANSACTION *ab_trans, Account *gnc_acc);
-
-/**
- * Import balances and transactions found in a AB_IMEXPORTER_CONTEXT into
- * GnuCash.  By using @a awaiting the caller can specify what the user will
- * expect to receive.  By using @a execute_txns, transactions in @a context can
- * be used to generate corresponding AqBanking jobs, e.g. after a file import.
- *
- * @param context AB_IMEXPORTER_CONTEXT to import
- *
- * @param awaiting Information the caller expects to receive or wants to ignore,
- * bitmask of AWAIT_* or IGNORE_* values
- *
- * @param execute_txns If @a awaiting contains AWAIT_TRANSACTIONS, whether to
- * create an aqbanking job for each of the transactions found
- *
- * @param api If @a execute_txns is TRUE, the AB_BANKING to get
- * AB_ACCOUNTs from
- *
- * @param parent Widget to set new dialogs transient for, may be NULL
- *
- * @return A new GncABImExContextImport object which must be freed with
- * g_free(), or NULL otherwise.  If execute_txns is TRUE, additionally
- * gnc_ab_ieci_get_job_list() must be called and the result freed with
- * AB_Job_List2_FreeAll()
- */
-GncABImExContextImport *gnc_ab_import_context(
-    AB_IMEXPORTER_CONTEXT *context, guint awaiting, gboolean execute_txns,
-    AB_BANKING *api, GtkWidget *parent);
-
-/**
- * Extract awaiting from @a data.
- *
- * @param ieci The return value of gnc_ab_import_context()
- * @return The initial awaiting bitmask plus IGNORE_* for unexpected and then
- * ignored items, and FOUND_* for non-empty items
- */
-guint gnc_ab_ieci_get_found(GncABImExContextImport *ieci);
-
-/**
- * Extract the job list from @a data.
- *
- * @param ieci The return value of gnc_ab_import_context()
- * @return The list of jobs, freeable with AB_Job_List2_FreeAll()
- */
-AB_JOB_LIST2 *gnc_ab_ieci_get_job_list(GncABImExContextImport *ieci);
-
-/**
- * Run the generic transaction matcher dialog.
- *
- * @param ieci The return value of gnc_ab_import_context()
- * @return The return value of gnc_gen_trans_list_run().
- */
-gboolean gnc_ab_ieci_run_matcher(GncABImExContextImport *ieci);
-
-
-/**
- * get the GWEN_DB_NODE from AqBanking configuration files
- *
- * @return a GWEN_DB containing all permanently accepted SSL certificates (hashed).
- */
-GWEN_DB_NODE *gnc_ab_get_permanent_certs(void);
-
-G_END_DECLS
-
-/** @} */
-/** @} */
-
-#endif /* GNC_AB_UTILS_H */

Deleted: gnucash/trunk/src/import-export/aqbanking/gnc-file-aqb-import.c
===================================================================
--- gnucash/trunk/src/import-export/aqbanking/gnc-file-aqb-import.c	2013-12-15 17:20:10 UTC (rev 23566)
+++ gnucash/trunk/src/import-export/aqbanking/gnc-file-aqb-import.c	2013-12-15 17:21:20 UTC (rev 23567)
@@ -1,380 +0,0 @@
-/*
- * gnc-file-aqb-import.c --
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation; either version 2 of
- * the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, contact:
- *
- * Free Software Foundation           Voice:  +1-617-542-5942
- * 51 Franklin Street, Fifth Floor    Fax:    +1-617-542-2652
- * Boston, MA  02110-1301,  USA       gnu at gnu.org
- */
-
-/**
- * @internal
- * @file gnc-file-aqb-import.c
- * @brief DTAUS import module code
- * @author Copyright (C) 2002 Benoit Grégoire <bock at step.polymtl.ca>
- * @author Copyright (C) 2003 Jan-Pascal van Best <janpascal at vanbest.org>
- * @author Copyright (C) 2006 Florian Steinel
- * @author Copyright (C) 2006 Christian Stimming
- * @author Copyright (C) 2008 Andreas Koehler <andi5.py at gmx.net>
- */
-
-#include "config.h"
-
-#include <glib/gi18n.h>
-#include <glib/gstdio.h>
-#include <fcntl.h>
-#include <unistd.h>
-
-#include "gnc-ab-utils.h"
-
-#ifdef AQBANKING_VERSION_5_PLUS
-# include <gwenhywfar/syncio_file.h>
-# include <gwenhywfar/syncio_buffered.h>
-typedef GWEN_SYNCIO GWEN_IO_LAYER;
-#else
-# include <gwenhywfar/io_file.h>
-# include <gwenhywfar/io_buffered.h>
-# include <gwenhywfar/iomanager.h>
-#endif
-
-#include "dialog-ab-trans.h"
-#include "dialog-utils.h"
-#include "gnc-file.h"
-#include "gnc-file-aqb-import.h"
-#include "gnc-gwen-gui.h"
-#include "gnc-ui.h"
-#include "gnc-ui-util.h"
-#include "import-account-matcher.h"
-#include "import-main-matcher.h"
-
-/* This static indicates the debugging module that this .o belongs to.  */
-static QofLogModule log_module = GNC_MOD_IMPORT;
-
-void
-gnc_file_aqbanking_import(const gchar *aqbanking_importername,
-                          const gchar *aqbanking_profilename,
-                          gboolean execute_transactions)
-{
-    gchar *default_dir;
-    gchar *selected_filename = NULL;
-    gint dtaus_fd = -1;
-    AB_BANKING *api = NULL;
-    gboolean online = FALSE;
-    GncGWENGui *gui = NULL;
-    AB_IMEXPORTER *importer;
-    GWEN_DB_NODE *db_profiles = NULL;
-    GWEN_DB_NODE *db_profile;
-    AB_IMEXPORTER_CONTEXT *context = NULL;
-    GWEN_IO_LAYER *io = NULL;
-    GncABImExContextImport *ieci = NULL;
-    AB_JOB_LIST2 *job_list = NULL;
-    AB_JOB_LIST2_ITERATOR *jit;
-    AB_JOB *job;
-    AB_JOB_STATUS job_status;
-    gboolean successful = TRUE;
-    int num_jobs = 0;
-    int num_jobs_failed = 0;
-    int max_failures = 5;
-    GString *errstr = NULL;
-
-    /* Select a file */
-    default_dir = gnc_get_default_directory(GNC_PREFS_GROUP_AQBANKING);
-    selected_filename = gnc_file_dialog(_("Select a file to import"),
-                                        NULL, default_dir,
-                                        GNC_FILE_DIALOG_IMPORT);
-    g_free(default_dir);
-
-    if (!selected_filename)
-        goto cleanup;
-    DEBUG("filename: %s", selected_filename);
-
-    /* Remember the directory as the default */
-    default_dir = g_path_get_dirname(selected_filename);
-    gnc_set_default_directory(GNC_PREFS_GROUP_AQBANKING, default_dir);
-    g_free(default_dir);
-
-    dtaus_fd = g_open(selected_filename, O_RDONLY, 0);
-    if (dtaus_fd == -1)
-    {
-        DEBUG("Could not open file %s", selected_filename);
-        goto cleanup;
-    }
-
-    /* Get the API */
-    api = gnc_AB_BANKING_new();
-    if (!api)
-    {
-        g_warning("gnc_file_aqbanking_import: Couldn't get AqBanking API");
-        goto cleanup;
-    }
-    if (AB_Banking_OnlineInit(api
-#ifdef AQBANKING_VERSION_4_EXACTLY
-                              , 0
-#endif
-                             ) != 0)
-    {
-        g_warning("gnc_file_aqbanking_import: "
-                  "Couldn't initialize AqBanking API");
-        goto cleanup;
-    }
-    online = TRUE;
-
-    /* Get import module */
-    importer = AB_Banking_GetImExporter(api, aqbanking_importername);
-    if (!importer)
-    {
-        g_warning("Import module %s not found", aqbanking_importername);
-        gnc_error_dialog(NULL, "%s",
-                         _("Import module for DTAUS import not found."));
-        goto cleanup;
-    }
-
-    /* Load the import profile */
-    db_profiles = AB_Banking_GetImExporterProfiles(api, aqbanking_importername);
-
-    /* Select profile */
-    db_profile = GWEN_DB_GetFirstGroup(db_profiles);
-    while (db_profile)
-    {
-        const gchar *name;
-
-        name = GWEN_DB_GetCharValue(db_profile, "name", 0, 0);
-        g_return_if_fail(name);
-        if (g_ascii_strcasecmp(name, aqbanking_profilename) == 0)
-            break;
-        db_profile = GWEN_DB_GetNextGroup(db_profile);
-    }
-    if (!db_profile)
-    {
-        g_warning("Profile \"%s\" for importer \"%s\" not found",
-                  aqbanking_profilename, aqbanking_importername);
-        /* For debugging: Print those available names that have been found */
-        db_profile = GWEN_DB_GetFirstGroup(db_profiles);
-        while (db_profile)
-        {
-            const char *name = GWEN_DB_GetCharValue(db_profile, "name", 0, 0);
-            g_warning("Only found profile \"%s\"\n", name ? name : "(null)");
-            db_profile = GWEN_DB_GetNextGroup(db_profile);
-        }
-        goto cleanup;
-    }
-
-    /* Create a context to store the results */
-    context = AB_ImExporterContext_new();
-
-    /* Wrap file in buffered gwen io */
-#ifdef AQBANKING_VERSION_5_PLUS
-    close(dtaus_fd);
-    io = GWEN_SyncIo_File_new(selected_filename, GWEN_SyncIo_File_CreationMode_OpenExisting);
-    g_assert(io);
-    GWEN_SyncIo_AddFlags(io, GWEN_SYNCIO_FILE_FLAGS_READ);
-    {
-        /* We must explicitly call "Connect" on the GWEN_SYNCIO
-         * object. */
-        int rv = GWEN_SyncIo_Connect(io);
-        if (rv < 0)
-        {
-            g_warning("gnc_file_aqbanking_import: Failed to open file %s: %d", selected_filename, rv);
-            goto cleanup;
-        }
-        g_assert(GWEN_SyncIo_GetStatus(io) == GWEN_SyncIo_Status_Connected);
-    }
-#else
-    io = GWEN_Io_LayerFile_new(dtaus_fd, -1);
-    g_assert(io);
-    if (GWEN_Io_Manager_RegisterLayer(io))
-    {
-        g_warning("gnc_file_aqbanking_import: Failed to wrap file");
-        goto cleanup;
-    }
-#endif
-    dtaus_fd = -1;
-
-    /* Run the import */
-    if (AB_ImExporter_Import(importer, context, io, db_profile
-#ifndef AQBANKING_VERSION_5_PLUS
-                             , 0
-#endif
-                            ))
-    {
-        g_warning("gnc_file_aqbanking_import: Error on import");
-        goto cleanup;
-    }
-
-    /* Close the file */
-#ifdef AQBANKING_VERSION_5_PLUS
-    GWEN_SyncIo_free(io);
-#else
-    GWEN_Io_Layer_free(io);
-#endif
-    io = NULL;
-
-    /* Before importing the results, if this is a new book, let user specify
-     * book options, since they affect how transactions are created */
-    if (gnc_is_new_book())
-        gnc_new_book_option_display();
-
-    /* Import the results */
-    ieci = gnc_ab_import_context(context, AWAIT_TRANSACTIONS,
-                                 execute_transactions,
-                                 execute_transactions ? api : NULL,
-                                 NULL);
-
-    if (execute_transactions)
-    {
-        if (gnc_ab_ieci_run_matcher(ieci))
-        {
-            AB_IMEXPORTER_CONTEXT *execution_context;
-
-            /* Extract the list of jobs */
-            job_list = gnc_ab_ieci_get_job_list(ieci);
-
-            /* Create a context to store possible results */
-            execution_context = AB_ImExporterContext_new();
-
-            /* Get a GUI object */
-            gui = gnc_GWEN_Gui_get(NULL);
-            if (!gui)
-            {
-                g_warning("gnc_file_aqbanking_import: Couldn't initialize Gwenhywfar GUI");
-                goto cleanup;
-            }
-
-            /* And execute the jobs */
-            AB_Banking_ExecuteJobs(api, job_list, execution_context
-#ifndef AQBANKING_VERSION_5_PLUS
-                                   , 0
-#endif
-                                  );
-
-            /* Ignore the return value of AB_Banking_ExecuteJobs(), as the job's
-             * status always describes better whether the job was actually
-             * transferred to and accepted by the bank.  See also
-             * http://lists.gnucash.org/pipermail/gnucash-de/2008-September/006389.html
-             */
-
-            /* So we must go through all jobs and check AB_Job_GetStatus(job)
-             * to give the appropriate feedback if any of the jobs didn't
-             * work. */
-
-            jit = AB_Job_List2_First(job_list);
-            if (jit)
-            {
-
-                job = AB_Job_List2Iterator_Data(jit);
-                while (job)
-                {
-                    num_jobs += 1;
-                    job_status = AB_Job_GetStatus(job);
-                    if (job_status != AB_Job_StatusFinished
-                            && job_status != AB_Job_StatusPending)
-                    {
-                        successful = FALSE;
-                        num_jobs_failed += 1;
-
-                        if (num_jobs_failed <= max_failures)
-                        {
-                            if (num_jobs_failed == 1)
-                            {
-                                errstr = g_string_new("Failed jobs:\n");
-                            }
-                            g_string_append_printf(errstr, _("Job %d status %d - %s: %s \n")
-                                                   , num_jobs
-                                                   , job_status
-                                                   , AB_Job_Status2Char(job_status)
-                                                   , AB_Job_GetResultText(job));
-                        }
-                        else
-                        {
-                            if (num_jobs_failed == (max_failures + 1) )
-                            {
-                                /* indicate that additional failures exist */
-                                g_string_append(errstr, _("...\n"));
-                            }
-                        }
-                    }
-                    job = AB_Job_List2Iterator_Next(jit);
-                } /* while */
-
-                AB_Job_List2Iterator_free(jit);
-            }
-
-            if (!successful)
-            {
-                g_warning("%s", errstr->str);
-                gnc_error_dialog(NULL,
-                                 _("An error occurred while executing jobs: %d of %d failed. "
-                                   "Please check the log window or gnucash.trace for the exact "
-                                   "error message.\n\n%s")
-                                 , num_jobs_failed, num_jobs, errstr->str);
-            }
-            else
-            {
-                if (num_jobs == 0)
-                {
-                    gnc_info_dialog(NULL,
-                                    _("No jobs to be send.")
-                                   );
-                }
-                else
-                {
-                    gnc_info_dialog(NULL, ngettext
-                                    ("The job was executed successfully, but as a precaution "
-                                     "please check the log window for potential errors.",
-                                     "All %d jobs were executed successfully, but as a precaution "
-                                     "please check the log window for potential errors.",
-                                     num_jobs), num_jobs);
-                }
-            }
-            AB_ImExporterContext_free(execution_context);
-        }
-    }
-
-cleanup:
-    if (io)
-    {
-#ifdef AQBANKING_VERSION_5_PLUS
-        GWEN_SyncIo_free(io);
-#else
-        GWEN_Io_Layer_free(io);
-#endif
-    }
-
-    if (job_list)
-        AB_Job_List2_FreeAll(job_list);
-    if (ieci)
-        g_free(ieci);
-    if (context)
-        AB_ImExporterContext_free(context);
-    if (db_profiles)
-        GWEN_DB_Group_free(db_profiles);
-    if (gui)
-        gnc_GWEN_Gui_release(gui);
-    if (online)
-#ifdef AQBANKING_VERSION_4_EXACTLY
-        AB_Banking_OnlineFini(api, 0);
-#else
-        AB_Banking_OnlineFini(api);
-#endif
-    if (api)
-        gnc_AB_BANKING_fini(api);
-    if (dtaus_fd != -1)
-        close(dtaus_fd);
-    if (selected_filename)
-        g_free(selected_filename);
-    if (errstr)
-        g_string_free(errstr, TRUE);
-
-}

Deleted: gnucash/trunk/src/import-export/aqbanking/gnc-file-aqb-import.h
===================================================================
--- gnucash/trunk/src/import-export/aqbanking/gnc-file-aqb-import.h	2013-12-15 17:20:10 UTC (rev 23566)
+++ gnucash/trunk/src/import-export/aqbanking/gnc-file-aqb-import.h	2013-12-15 17:21:20 UTC (rev 23567)
@@ -1,69 +0,0 @@
-/*
- * gnc-file-aqb-import.h --
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation; either version 2 of
- * the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, contact:
- *
- * Free Software Foundation           Voice:  +1-617-542-5942
- * 51 Franklin Street, Fifth Floor    Fax:    +1-617-542-2652
- * Boston, MA  02110-1301,  USA       gnu at gnu.org
- */
-
-/**
- * @addtogroup Import_Export
- * @{
- * @addtogroup AqBanking
- * @{
- * @file aqbanking/gnc-file-aqb-import.h
- * @brief DTAUS import module interface
- * @author Copyright (C) 2002 Benoit Grégoire <bock at step.polymtl.ca>
- * @author Copyright (C) 2008 Andreas Koehler <andi5.py at gmx.net>
- */
-
-#ifndef GNC_FILE_AQB_IMPORT_H
-#define GNC_FILE_AQB_IMPORT_H
-
-#include <glib.h>
-
-G_BEGIN_DECLS
-
-/**
- * This routine will pop up a standard file selection dialog asking the user to
- * pick a file to import.  This file will be opened and read.  Its contents will
- * be imported into the current book, using the import matcher from
- * import-main-matcher.h.
- *
- * @param aqbanking_importername The aqbanking importer module that should be
- * used.  Possible values: "dtaus", "csv", "swift", or more.
- *
- * @param aqbanking_formatname In aqbanking, each importer has one or more data
- * formats available which define the actual data fields that should be used.
- * In aqbanking, such a different format is called a "profile".  Possible values
- * for swift: "swift-mt940" or "swift-mt942", but for all others: "default", or
- * more precisely: Look into $datadir/aqbanking/imexporters and look into the
- * "name" field of the foo.conf files.
- *
- * @param exec_as_aqbanking_jobs If TRUE, additionally queue the imported
- * transactions as online jobs over aqbanking/HBCI.  If FALSE, just import the
- * transactions and that's it.
- */
-void gnc_file_aqbanking_import (const gchar *aqbanking_importername,
-                                const gchar *aqbanking_formatname,
-                                gboolean exec_as_aqbanking_jobs);
-
-G_END_DECLS
-
-/** @} */
-/** @} */
-
-#endif /* GNC_FILE_AQB_IMPORT_H */

Deleted: gnucash/trunk/src/import-export/aqbanking/gnc-gwen-gui.c
===================================================================
--- gnucash/trunk/src/import-export/aqbanking/gnc-gwen-gui.c	2013-12-15 17:20:10 UTC (rev 23566)
+++ gnucash/trunk/src/import-export/aqbanking/gnc-gwen-gui.c	2013-12-15 17:21:20 UTC (rev 23567)
@@ -1,1624 +0,0 @@
-/*
- * gnc-gwen-gui.c --
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation; either version 2 of
- * the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, contact:
- *
- * Free Software Foundation           Voice:  +1-617-542-5942
- * 51 Franklin Street, Fifth Floor    Fax:    +1-617-542-2652
- * Boston, MA  02110-1301,  USA       gnu at gnu.org
- */
-
-/**
- * @internal
- * @file gnc-gwen-gui.c
- * @brief GUI callbacks for AqBanking
- * @author Copyright (C) 2002 Christian Stimming <stimming at tuhh.de>
- * @author Copyright (C) 2006 David Hampton <hampton at employees.org>
- * @author Copyright (C) 2008 Andreas Koehler <andi5.py at gmx.net>
- */
-
-#include "config.h"
-
-#include <ctype.h>
-#include <glib/gi18n.h>
-#include <gwenhywfar/gui_be.h>
-#include <gwenhywfar/inherit.h>
-
-#include "dialog-utils.h"
-#include "gnc-ab-utils.h"
-#include "gnc-component-manager.h"
-#include "gnc-gwen-gui.h"
-#include "gnc-session.h"
-#include "gnc-prefs.h"
-#include "gnc-ui.h"
-#include "gnc-plugin-aqbanking.h"
-#include "md5.h"
-#include "qof.h"
-
-#if GWENHYWFAR_VERSION_INT >= 39921
-/* For sufficiently new gwenhywfar (>=3.99.21) the gtk2 gui object is
- * working fine and it is enabled here here. */
-# define USING_GWENHYWFAR_GTK2_GUI
-# define GNC_GWENHYWFAR_CB GWENHYWFAR_CB
-#else
-# define GNC_GWENHYWFAR_CB
-#endif
-
-#define GWEN_GUI_CM_CLASS "dialog-hbcilog"
-#define GNC_PREFS_GROUP_CONNECTION GNC_PREFS_GROUP_AQBANKING ".connection-dialog"
-#define GNC_PREF_CLOSE_ON_FINISH   "close-on-finish"
-#define GNC_PREF_REMEMBER_PIN      "remember-pin"
-
-#ifdef USING_GWENHYWFAR_GTK2_GUI
-# include <gwen-gui-gtk2/gtk2_gui.h>
-#endif
-
-/* This static indicates the debugging module that this .o belongs to.  */
-static QofLogModule log_module = G_LOG_DOMAIN;
-
-/* The following block can be enabled, but the gwen-gtk2 widgets might
- * still need some work. */
-#if 0 /*#ifdef USING_GWENHYWFAR_GTK2_GUI*/
-
-/* A GWEN_GUI implementation using gtk2 widgets  */
-static GWEN_GUI *gwen_gui = NULL;
-
-void gnc_GWEN_Gui_log_init(void)
-{
-    if (!gwen_gui)
-    {
-        gwen_gui = Gtk2_Gui_new();
-        GWEN_Gui_SetGui(gwen_gui);
-    }
-}
-GncGWENGui *gnc_GWEN_Gui_get(GtkWidget *parent)
-{
-    if (!gwen_gui)
-        gnc_GWEN_Gui_log_init();
-    return (GncGWENGui*) gwen_gui;
-}
-void gnc_GWEN_Gui_release(GncGWENGui *gui)
-{
-}
-void gnc_GWEN_Gui_shutdown(void)
-{
-    if (gwen_gui)
-    {
-        GWEN_Gui_free(gwen_gui);
-        gwen_gui = NULL;
-        GWEN_Gui_SetGui(NULL);
-    }
-}
-void
-gnc_GWEN_Gui_set_close_flag(gboolean close_when_finished)
-{
-    gnc_prefs_set_bool(
-        GNC_PREFS_GROUP_AQBANKING, GNC_PREF_CLOSE_ON_FINISH,
-        close_when_finished);
-}
-gboolean
-gnc_GWEN_Gui_get_close_flag()
-{
-    return gnc_prefs_get_bool (GNC_PREFS_GROUP_AQBANKING, GNC_PREF_CLOSE_ON_FINISH);
-}
-
-gboolean
-gnc_GWEN_Gui_show_dialog()
-{
-    return TRUE;
-}
-
-void
-gnc_GWEN_Gui_hide_dialog()
-{
-}
-
-#else
-
-/* A unique full-blown GUI, featuring  */
-static GncGWENGui *full_gui = NULL;
-
-/* A unique Gwenhywfar GUI for hooking our logging into the gwenhywfar logging
- * framework */
-static GWEN_GUI *log_gwen_gui = NULL;
-
-/* A mapping from gwenhywfar log levels to glib ones */
-static GLogLevelFlags log_levels[] =
-{
-    G_LOG_LEVEL_ERROR,     /* GWEN_LoggerLevel_Emergency */
-    G_LOG_LEVEL_ERROR,     /* GWEN_LoggerLevel_Alert */
-    G_LOG_LEVEL_CRITICAL,  /* GWEN_LoggerLevel_Critical */
-    G_LOG_LEVEL_CRITICAL,  /* GWEN_LoggerLevel_Error */
-    G_LOG_LEVEL_WARNING,   /* GWEN_LoggerLevel_Warning */
-    G_LOG_LEVEL_MESSAGE,   /* GWEN_LoggerLevel_Notice */
-    G_LOG_LEVEL_INFO,      /* GWEN_LoggerLevel_Info */
-    G_LOG_LEVEL_DEBUG,     /* GWEN_LoggerLevel_Debug */
-    G_LOG_LEVEL_DEBUG      /* GWEN_LoggerLevel_Verbous */
-};
-static guint8 n_log_levels = G_N_ELEMENTS(log_levels);
-
-/* Macros to determine the GncGWENGui* from a GWEN_GUI* */
-GWEN_INHERIT(GWEN_GUI, GncGWENGui)
-#define SETDATA_GUI(gwen_gui, gui) GWEN_INHERIT_SETDATA(GWEN_GUI, GncGWENGui, \
-                                                        (gwen_gui), (gui), NULL)
-#define GETDATA_GUI(gwen_gui) GWEN_INHERIT_GETDATA(GWEN_GUI, GncGWENGui, (gwen_gui))
-
-#define OTHER_ENTRIES_ROW_OFFSET 3
-
-typedef struct _Progress Progress;
-typedef enum _GuiState GuiState;
-
-static void register_callbacks(GncGWENGui *gui);
-static void unregister_callbacks(GncGWENGui *gui);
-static void setup_dialog(GncGWENGui *gui);
-static void enable_password_cache(GncGWENGui *gui, gboolean enabled);
-static void reset_dialog(GncGWENGui *gui);
-static void set_finished(GncGWENGui *gui);
-static void set_aborted(GncGWENGui *gui);
-static void show_dialog(GncGWENGui *gui, gboolean clear_log);
-static void hide_dialog(GncGWENGui *gui);
-static gboolean show_progress_cb(gpointer user_data);
-static void show_progress(GncGWENGui *gui, Progress *progress);
-static void hide_progress(GncGWENGui *gui, Progress *progress);
-static void free_progress(Progress *progress, gpointer unused);
-static gboolean keep_alive(GncGWENGui *gui);
-static void cm_close_handler(gpointer user_data);
-static void erase_password(gchar *password);
-static gchar *strip_html(gchar *text);
-static void get_input(GncGWENGui *gui, guint32 flags, const gchar *title,
-                      const gchar *text, gchar **input, gint min_len,
-                      gint max_len);
-static gint messagebox_cb(GWEN_GUI *gwen_gui, guint32 flags, const gchar *title,
-                          const gchar *text, const gchar *b1, const gchar *b2,
-                          const gchar *b3, guint32 guiid);
-static gint inputbox_cb(GWEN_GUI *gwen_gui, guint32 flags, const gchar *title,
-                        const gchar *text, gchar *buffer, gint min_len,
-                        gint max_len, guint32 guiid);
-static guint32 showbox_cb(GWEN_GUI *gwen_gui, guint32 flags, const gchar *title,
-                          const gchar *text, guint32 guiid);
-static void hidebox_cb(GWEN_GUI *gwen_gui, guint32 id);
-static guint32 progress_start_cb(GWEN_GUI *gwen_gui, uint32_t progressFlags,
-                                 const char *title, const char *text,
-                                 uint64_t total, uint32_t guiid);
-static gint progress_advance_cb(GWEN_GUI *gwen_gui, uint32_t id,
-                                uint64_t new_progress);
-static gint progress_log_cb(GWEN_GUI *gwen_gui, guint32 id,
-                            GWEN_LOGGER_LEVEL level, const gchar *text);
-static gint progress_end_cb(GWEN_GUI *gwen_gui, guint32 id);
-static gint GNC_GWENHYWFAR_CB getpassword_cb(GWEN_GUI *gwen_gui, guint32 flags, const gchar *token,
-        const gchar *title, const gchar *text, gchar *buffer,
-        gint min_len, gint max_len, guint32 guiid);
-static gint GNC_GWENHYWFAR_CB setpasswordstatus_cb(GWEN_GUI *gwen_gui, const gchar *token,
-        const gchar *pin,
-        GWEN_GUI_PASSWORD_STATUS status, guint32 guiid);
-static gint GNC_GWENHYWFAR_CB loghook_cb(GWEN_GUI *gwen_gui, const gchar *log_domain,
-        GWEN_LOGGER_LEVEL priority, const gchar *text);
-#ifdef AQBANKING_VERSION_5_PLUS
-typedef GWEN_SYNCIO GWEN_IO_LAYER;
-#endif
-static gint GNC_GWENHYWFAR_CB checkcert_cb(GWEN_GUI *gwen_gui, const GWEN_SSLCERTDESCR *cert,
-        GWEN_IO_LAYER *io, guint32 guiid);
-
-gboolean ggg_delete_event_cb(GtkWidget *widget, GdkEvent *event,
-                             gpointer user_data);
-void ggg_abort_clicked_cb(GtkButton *button, gpointer user_data);
-void ggg_close_clicked_cb(GtkButton *button, gpointer user_data);
-void ggg_close_toggled_cb(GtkToggleButton *button, gpointer user_data);
-
-enum _GuiState
-{
-    INIT,
-    RUNNING,
-    FINISHED,
-    ABORTED,
-    HIDDEN
-};
-
-struct _GncGWENGui
-{
-    GWEN_GUI *gwen_gui;
-    GtkWidget *parent;
-    GtkWidget *dialog;
-
-    /* Progress bars */
-    GtkWidget *entries_table;
-    GtkWidget *top_entry;
-    GtkWidget *top_progress;
-    GtkWidget *second_entry;
-    GtkWidget *other_entries_box;
-
-    /* Stack of nested Progresses */
-    GList *progresses;
-
-    /* Number of steps in top-level progress or -1 */
-    guint64 max_actions;
-    guint64 current_action;
-
-    /* Log window */
-    GtkWidget *log_text;
-
-    /* Buttons */
-    GtkWidget *abort_button;
-    GtkWidget *close_button;
-    GtkWidget *close_checkbutton;
-
-    /* Flags to keep track on whether an HBCI action is running or not */
-    gboolean keep_alive;
-    GuiState state;
-
-    /* Password caching */
-    gboolean cache_passwords;
-    GHashTable *passwords;
-
-    /* Certificates handling */
-    GHashTable *accepted_certs;
-    GWEN_DB_NODE *permanently_accepted_certs;
-    GWEN_GUI_CHECKCERT_FN builtin_checkcert;
-
-    /* Dialogs */
-    guint32 showbox_id;
-    GHashTable *showbox_hash;
-    GtkWidget *showbox_last;
-
-    /* Cache the lowest loglevel, corresponding to the most serious warning */
-    GWEN_LOGGER_LEVEL min_loglevel;
-};
-
-struct _Progress
-{
-    GncGWENGui *gui;
-
-    /* Title of the process */
-    gchar *title;
-
-    /* Event source id for showing delayed */
-    guint source;
-};
-
-void
-gnc_GWEN_Gui_log_init(void)
-{
-    if (!log_gwen_gui)
-    {
-        log_gwen_gui =
-#ifdef USING_GWENHYWFAR_GTK2_GUI
-            Gtk2_Gui_new()
-#else
-            GWEN_Gui_new()
-#endif
-            ;
-
-        /* Always use our own logging */
-        GWEN_Gui_SetLogHookFn(log_gwen_gui, loghook_cb);
-
-        /* Keep a reference so that the GWEN_GUI survives a GUI switch */
-        GWEN_Gui_Attach(log_gwen_gui);
-    }
-    GWEN_Gui_SetGui(log_gwen_gui);
-}
-
-GncGWENGui *
-gnc_GWEN_Gui_get(GtkWidget *parent)
-{
-    GncGWENGui *gui;
-
-    ENTER("parent=%p", parent);
-
-    if (full_gui)
-    {
-        if (full_gui->state == INIT || full_gui->state == RUNNING)
-        {
-            LEAVE("full_gui in use, state=%d", full_gui->state);
-            return NULL;
-        }
-
-        gui = full_gui;
-        gui->parent = parent;
-        reset_dialog(gui);
-        register_callbacks(gui);
-
-        LEAVE("gui=%p", gui);
-        return gui;
-    }
-
-    gui = g_new0(GncGWENGui, 1);
-    gui->parent = parent;
-    setup_dialog(gui);
-    register_callbacks(gui);
-
-    full_gui = gui;
-
-    LEAVE("new gui=%p", gui);
-    return gui;
-}
-
-void
-gnc_GWEN_Gui_release(GncGWENGui *gui)
-{
-    g_return_if_fail(gui && gui == full_gui);
-
-    /* Currently a no-op */
-    ENTER("gui=%p", gui);
-    LEAVE(" ");
-}
-
-void
-gnc_GWEN_Gui_shutdown(void)
-{
-    GncGWENGui *gui = full_gui;
-
-    ENTER(" ");
-
-    if (log_gwen_gui)
-    {
-        GWEN_Gui_free(log_gwen_gui);
-        log_gwen_gui = NULL;
-    }
-    GWEN_Gui_SetGui(NULL);
-
-    if (!gui)
-        return;
-
-    gui->parent = NULL;
-    reset_dialog(gui);
-    if (gui->passwords)
-        g_hash_table_destroy(gui->passwords);
-    if (gui->showbox_hash)
-        g_hash_table_destroy(gui->showbox_hash);
-    if (gui->permanently_accepted_certs)
-        GWEN_DB_Group_free(gui->permanently_accepted_certs);
-    if (gui->accepted_certs)
-        g_hash_table_destroy(gui->accepted_certs);
-    gtk_widget_destroy(gui->dialog);
-    g_free(gui);
-
-    full_gui = NULL;
-
-    LEAVE(" ");
-}
-
-void
-gnc_GWEN_Gui_set_close_flag(gboolean close_when_finished)
-{
-    gnc_prefs_set_bool(
-        GNC_PREFS_GROUP_AQBANKING, GNC_PREF_CLOSE_ON_FINISH,
-        close_when_finished);
-
-    if (full_gui)
-    {
-        if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(full_gui->close_checkbutton))
-                != close_when_finished)
-        {
-            gtk_toggle_button_set_active(
-                GTK_TOGGLE_BUTTON(full_gui->close_checkbutton),
-                close_when_finished);
-        }
-    }
-}
-
-gboolean
-gnc_GWEN_Gui_get_close_flag()
-{
-    return gnc_prefs_get_bool (GNC_PREFS_GROUP_AQBANKING, GNC_PREF_CLOSE_ON_FINISH);
-}
-
-gboolean
-gnc_GWEN_Gui_show_dialog()
-{
-    GncGWENGui *gui = full_gui;
-
-    if (!gui)
-    {
-        gnc_GWEN_Gui_get(NULL);
-    }
-
-    if (gui)
-    {
-        if (gui->state == HIDDEN)
-        {
-            gui->state = FINISHED;
-        }
-        gtk_toggle_button_set_active(
-            GTK_TOGGLE_BUTTON(gui->close_checkbutton),
-            gnc_prefs_get_bool (GNC_PREFS_GROUP_AQBANKING, GNC_PREF_CLOSE_ON_FINISH));
-
-        show_dialog(gui, FALSE);
-
-        return TRUE;
-    }
-
-    return FALSE;
-}
-
-void
-gnc_GWEN_Gui_hide_dialog()
-{
-    GncGWENGui *gui = full_gui;
-
-    if (gui)
-    {
-        hide_dialog(gui);
-    }
-}
-
-static void
-register_callbacks(GncGWENGui *gui)
-{
-    GWEN_GUI *gwen_gui;
-
-    g_return_if_fail(gui && !gui->gwen_gui);
-
-    ENTER("gui=%p", gui);
-
-    gwen_gui =
-#ifdef USING_GWENHYWFAR_GTK2_GUI
-        Gtk2_Gui_new()
-#else
-        GWEN_Gui_new()
-#endif
-        ;
-    gui->gwen_gui = gwen_gui;
-
-    GWEN_Gui_SetMessageBoxFn(gwen_gui, messagebox_cb);
-    GWEN_Gui_SetInputBoxFn(gwen_gui, inputbox_cb);
-    GWEN_Gui_SetShowBoxFn(gwen_gui, showbox_cb);
-    GWEN_Gui_SetHideBoxFn(gwen_gui, hidebox_cb);
-    GWEN_Gui_SetProgressStartFn(gwen_gui, progress_start_cb);
-    GWEN_Gui_SetProgressAdvanceFn(gwen_gui, progress_advance_cb);
-    GWEN_Gui_SetProgressLogFn(gwen_gui, progress_log_cb);
-    GWEN_Gui_SetProgressEndFn(gwen_gui, progress_end_cb);
-    GWEN_Gui_SetGetPasswordFn(gwen_gui, getpassword_cb);
-    GWEN_Gui_SetSetPasswordStatusFn(gwen_gui, setpasswordstatus_cb);
-    GWEN_Gui_SetLogHookFn(gwen_gui, loghook_cb);
-    gui->builtin_checkcert = GWEN_Gui_SetCheckCertFn(gwen_gui, checkcert_cb);
-
-    GWEN_Gui_SetGui(gwen_gui);
-    SETDATA_GUI(gwen_gui, gui);
-
-    LEAVE(" ");
-}
-
-static void
-unregister_callbacks(GncGWENGui *gui)
-{
-    g_return_if_fail(gui);
-
-    ENTER("gui=%p", gui);
-
-    if (!gui->gwen_gui)
-    {
-        LEAVE("already unregistered");
-        return;
-    }
-
-    /* Switch to log_gwen_gui and free gui->gwen_gui */
-    gnc_GWEN_Gui_log_init();
-
-    gui->gwen_gui = NULL;
-
-    LEAVE(" ");
-}
-
-static void
-setup_dialog(GncGWENGui *gui)
-{
-    GtkBuilder *builder;
-    gint component_id;
-
-    g_return_if_fail(gui);
-
-    ENTER("gui=%p", gui);
-
-    builder = gtk_builder_new();
-    gnc_builder_add_from_file (builder, "dialog-ab.glade", "Connection Dialog");
-
-    gui->dialog = GTK_WIDGET(gtk_builder_get_object (builder, "Connection Dialog"));
-
-    gui->entries_table = GTK_WIDGET(gtk_builder_get_object (builder, "entries_table"));
-    gui->top_entry = GTK_WIDGET(gtk_builder_get_object (builder, "top_entry"));
-    gui->top_progress = GTK_WIDGET(gtk_builder_get_object (builder, "top_progress"));
-    gui->second_entry = GTK_WIDGET(gtk_builder_get_object (builder, "second_entry"));
-    gui->other_entries_box = NULL;
-    gui->progresses = NULL;
-    gui->log_text = GTK_WIDGET(gtk_builder_get_object (builder, "log_text"));
-    gui->abort_button = GTK_WIDGET(gtk_builder_get_object (builder, "abort_button"));
-    gui->close_button = GTK_WIDGET(gtk_builder_get_object (builder, "close_button"));
-    gui->close_checkbutton = GTK_WIDGET(gtk_builder_get_object (builder, "close_checkbutton"));
-    gui->accepted_certs = NULL;
-    gui->permanently_accepted_certs = NULL;
-    gui->showbox_hash = NULL;
-    gui->showbox_id = 1;
-
-    /* Connect the Signals */
-    gtk_builder_connect_signals_full (builder, gnc_builder_connect_full_func, gui);
-
-    gtk_toggle_button_set_active(
-        GTK_TOGGLE_BUTTON(gui->close_checkbutton),
-        gnc_prefs_get_bool (GNC_PREFS_GROUP_AQBANKING, GNC_PREF_CLOSE_ON_FINISH));
-
-    component_id = gnc_register_gui_component(GWEN_GUI_CM_CLASS, NULL,
-                   cm_close_handler, gui);
-    gnc_gui_component_set_session(component_id, gnc_get_current_session());
-
-
-
-    g_object_unref(G_OBJECT(builder));
-
-    reset_dialog(gui);
-
-    LEAVE(" ");
-}
-
-static void
-enable_password_cache(GncGWENGui *gui, gboolean enabled)
-{
-    g_return_if_fail(gui);
-
-    if (enabled && !gui->passwords)
-    {
-        /* Remember passwords in memory, mapping tokens to passwords */
-        gui->passwords = g_hash_table_new_full(
-                             g_str_hash, g_str_equal, (GDestroyNotify) g_free,
-                             (GDestroyNotify) erase_password);
-    }
-    else if (!enabled && gui->passwords)
-    {
-        /* Erase and free remembered passwords from memory */
-        g_hash_table_destroy(gui->passwords);
-        gui->passwords = NULL;
-    }
-    gui->cache_passwords = enabled;
-}
-
-static void
-reset_dialog(GncGWENGui *gui)
-{
-    gboolean cache_passwords;
-
-    g_return_if_fail(gui);
-
-    ENTER("gui=%p", gui);
-
-    gtk_entry_set_text(GTK_ENTRY(gui->top_entry), "");
-    gtk_entry_set_text(GTK_ENTRY(gui->second_entry), "");
-    g_list_foreach(gui->progresses, (GFunc) free_progress, NULL);
-    g_list_free(gui->progresses);
-    gui->progresses = NULL;
-
-    if (gui->other_entries_box)
-    {
-        gtk_table_resize(GTK_TABLE(gui->entries_table),
-                         OTHER_ENTRIES_ROW_OFFSET, 2);
-        gtk_widget_destroy(gui->other_entries_box);
-        gui->other_entries_box = NULL;
-    }
-    if (gui->showbox_hash)
-        g_hash_table_destroy(gui->showbox_hash);
-    gui->showbox_last = NULL;
-    gui->showbox_hash = g_hash_table_new_full(
-                            NULL, NULL, NULL, (GDestroyNotify) gtk_widget_destroy);
-
-    if (gui->parent)
-        gtk_window_set_transient_for(GTK_WINDOW(gui->dialog),
-                                     GTK_WINDOW(gui->parent));
-    gnc_restore_window_size(GNC_PREFS_GROUP_CONNECTION, GTK_WINDOW(gui->dialog));
-
-    gui->keep_alive = TRUE;
-    gui->state = INIT;
-    gui->min_loglevel = GWEN_LoggerLevel_Verbous;
-
-    cache_passwords = gnc_prefs_get_bool(GNC_PREFS_GROUP_AQBANKING,
-                                         GNC_PREF_REMEMBER_PIN);
-    enable_password_cache(gui, cache_passwords);
-
-    if (!gui->accepted_certs)
-        gui->accepted_certs = g_hash_table_new_full(
-                                  g_str_hash, g_str_equal, (GDestroyNotify) g_free, NULL);
-    if (!gui->permanently_accepted_certs)
-        gui->permanently_accepted_certs = gnc_ab_get_permanent_certs();
-
-    LEAVE(" ");
-}
-
-static void
-set_running(GncGWENGui *gui)
-{
-    g_return_if_fail(gui);
-
-    ENTER("gui=%p", gui);
-
-    gui->state = RUNNING;
-    gtk_widget_set_sensitive(gui->abort_button, TRUE);
-    gtk_widget_set_sensitive(gui->close_button, FALSE);
-    gui->keep_alive = TRUE;
-
-    LEAVE(" ");
-}
-
-static void
-set_finished(GncGWENGui *gui)
-{
-    g_return_if_fail(gui);
-
-    ENTER("gui=%p", gui);
-
-    /* Do not serve as GUI anymore */
-    gui->state = FINISHED;
-    unregister_callbacks(gui);
-
-    gtk_widget_set_sensitive(gui->abort_button, FALSE);
-    gtk_widget_set_sensitive(gui->close_button, TRUE);
-    if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(gui->close_checkbutton)))
-        hide_dialog(gui);
-
-    LEAVE(" ");
-}
-
-static void
-set_aborted(GncGWENGui *gui)
-{
-    g_return_if_fail(gui);
-
-    ENTER("gui=%p", gui);
-
-    /* Do not serve as GUI anymore */
-    gui->state = ABORTED;
-    unregister_callbacks(gui);
-
-    gtk_widget_set_sensitive(gui->abort_button, FALSE);
-    gtk_widget_set_sensitive(gui->close_button, TRUE);
-    gui->keep_alive = FALSE;
-
-    LEAVE(" ");
-}
-
-static void
-show_dialog(GncGWENGui *gui, gboolean clear_log)
-{
-    g_return_if_fail(gui);
-
-    ENTER("gui=%p, clear_log=%d", gui, clear_log);
-
-    gtk_widget_show(gui->dialog);
-
-    gnc_plugin_aqbanking_set_logwindow_visible(TRUE);
-
-    /* Clear the log window */
-    if (clear_log)
-    {
-        gtk_text_buffer_set_text(
-            gtk_text_view_get_buffer(GTK_TEXT_VIEW(gui->log_text)), "", 0);
-    }
-
-    LEAVE(" ");
-}
-
-static void
-hide_dialog(GncGWENGui *gui)
-{
-    g_return_if_fail(gui);
-
-    ENTER("gui=%p", gui);
-
-    /* Hide the dialog */
-    gtk_widget_hide(gui->dialog);
-
-    gnc_plugin_aqbanking_set_logwindow_visible(FALSE);
-
-    /* Remember whether the dialog is to be closed when finished */
-    gnc_prefs_set_bool(
-        GNC_PREFS_GROUP_AQBANKING, GNC_PREF_CLOSE_ON_FINISH,
-        gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(gui->close_checkbutton)));
-
-    /* Remember size and position of the dialog */
-    gnc_save_window_size(GNC_PREFS_GROUP_CONNECTION, GTK_WINDOW(gui->dialog));
-
-    /* Do not serve as GUI anymore */
-    gui->state = HIDDEN;
-    unregister_callbacks(gui);
-
-    LEAVE(" ");
-}
-
-static gboolean
-show_progress_cb(gpointer user_data)
-{
-    Progress *progress = user_data;
-
-    g_return_val_if_fail(progress, FALSE);
-
-    ENTER("progress=%p", progress);
-
-    show_progress(progress->gui, progress);
-
-    LEAVE(" ");
-    return FALSE;
-}
-
-/**
- * Show all processes down to and including @a progress.
- */
-static void
-show_progress(GncGWENGui *gui, Progress *progress)
-{
-    GList *item;
-    Progress *current;
-
-    g_return_if_fail(gui);
-
-    ENTER("gui=%p, progress=%p", gui, progress);
-
-    for (item = g_list_last(gui->progresses); item; item = item->prev)
-    {
-        current = (Progress*) item->data;
-
-        if (!current->source
-                && current != progress)
-            /* Already showed */
-            continue;
-
-        /* Show it */
-        if (!item->next)
-        {
-            /* Top-level progress */
-            show_dialog(gui, TRUE);
-            gtk_entry_set_text(GTK_ENTRY(gui->top_entry), current->title);
-        }
-        else if (!item->next->next)
-        {
-            /* Second-level progress */
-            gtk_entry_set_text(GTK_ENTRY(gui->second_entry), current->title);
-        }
-        else
-        {
-            /* Other progress */
-            GtkWidget *entry = gtk_entry_new();
-            GtkWidget *box = gui->other_entries_box;
-            gboolean new_box = box == NULL;
-
-            gtk_entry_set_text(GTK_ENTRY(entry), current->title);
-            if (new_box)
-                gui->other_entries_box = box = gtk_vbox_new(TRUE, 6);
-            gtk_box_pack_start(GTK_BOX(box), entry, TRUE, TRUE, 0);
-            gtk_widget_show(entry);
-            if (new_box)
-            {
-                gtk_table_resize(GTK_TABLE(gui->entries_table),
-                                 OTHER_ENTRIES_ROW_OFFSET + 1, 2);
-                gtk_table_attach_defaults(
-                    GTK_TABLE(gui->entries_table), box, 1, 2,
-                    OTHER_ENTRIES_ROW_OFFSET, OTHER_ENTRIES_ROW_OFFSET + 1);
-                gtk_widget_show(box);
-            }
-        }
-
-        if (current->source)
-        {
-            /* Stop delayed call */
-            g_source_remove(current->source);
-            current->source = 0;
-        }
-
-        if (current == progress)
-            break;
-    }
-
-    LEAVE(" ");
-}
-
-/**
- * Hide all processes up to and including @a progress.
- */
-static void
-hide_progress(GncGWENGui *gui, Progress *progress)
-{
-    GList *item;
-    Progress *current;
-
-    g_return_if_fail(gui);
-
-    ENTER("gui=%p, progress=%p", gui, progress);
-
-    for (item = gui->progresses; item; item = item->next)
-    {
-        current = (Progress*) item->data;
-
-        if (current->source)
-        {
-            /* Not yet showed */
-            g_source_remove(current->source);
-            current->source = 0;
-            if (current == progress)
-                break;
-            else
-                continue;
-        }
-
-        /* Hide it */
-        if (!item->next)
-        {
-            /* Top-level progress */
-            gtk_entry_set_text(GTK_ENTRY(gui->second_entry), "");
-        }
-        else if (!item->next->next)
-        {
-            /* Second-level progress */
-            gtk_entry_set_text(GTK_ENTRY(gui->second_entry), "");
-        }
-        else
-        {
-            /* Other progress */
-            GtkWidget *box = gui->other_entries_box;
-            GList *entries;
-
-            g_return_if_fail(box);
-            entries = gtk_container_get_children(GTK_CONTAINER(box));
-            g_return_if_fail(entries);
-            if (entries->next)
-            {
-                /* Another progress is still to be showed */
-                gtk_widget_destroy(GTK_WIDGET(g_list_last(entries)->data));
-            }
-            else
-            {
-                /* Last other progress to be hided */
-                gtk_table_resize(GTK_TABLE(gui->entries_table),
-                                 OTHER_ENTRIES_ROW_OFFSET, 2);
-                gtk_widget_destroy(box);
-                gui->other_entries_box = NULL;
-            }
-            g_list_free(entries);
-        }
-
-        if (current == progress)
-            break;
-    }
-
-    LEAVE(" ");
-}
-
-static void
-free_progress(Progress *progress, gpointer unused)
-{
-    if (progress->source)
-        g_source_remove(progress->source);
-    g_free(progress->title);
-    g_free(progress);
-}
-
-static gboolean
-keep_alive(GncGWENGui *gui)
-{
-    g_return_val_if_fail(gui, FALSE);
-
-    ENTER("gui=%p", gui);
-
-    /* Let the widgets be redrawn */
-    while (g_main_context_iteration(NULL, FALSE));
-
-    LEAVE("alive=%d", gui->keep_alive);
-    return gui->keep_alive;
-}
-
-static void
-cm_close_handler(gpointer user_data)
-{
-    GncGWENGui *gui = user_data;
-
-    g_return_if_fail(gui);
-
-    ENTER("gui=%p", gui);
-
-    /* FIXME */
-    set_aborted(gui);
-
-    LEAVE(" ");
-}
-
-static void
-erase_password(gchar *password)
-{
-    g_return_if_fail(password);
-
-    ENTER(" ");
-
-    memset(password, 0, strlen(password));
-    g_free(password);
-
-    LEAVE(" ");
-}
-
-/**
- * Find first <[Hh][Tt][Mm][Ll]> and cut off the string there.
- */
-static gchar *
-strip_html(gchar *text)
-{
-    gchar *p, *q;
-
-    if (!text)
-        return NULL;
-
-    p = text;
-    while (strchr(p, '<'))
-    {
-        q = p + 1;
-        if (*q && toupper(*q++) == 'H'
-                && *q && toupper(*q++) == 'T'
-                && *q && toupper(*q++) == 'M'
-                && *q && toupper(*q) == 'L')
-        {
-            *p = '\0';
-            return text;
-        }
-        p++;
-    }
-    return text;
-}
-
-static void
-get_input(GncGWENGui *gui, guint32 flags, const gchar *title, const gchar *text,
-          gchar **input, gint min_len, gint max_len)
-{
-    GtkBuilder *builder;
-    GtkWidget *dialog;
-    GtkWidget *heading_label;
-    GtkWidget *input_entry;
-    GtkWidget *confirm_entry;
-    GtkWidget *confirm_label;
-    GtkWidget *remember_pin_checkbutton;
-    const gchar *internal_input, *internal_confirmed;
-    gboolean confirm = (flags & GWEN_GUI_INPUT_FLAGS_CONFIRM) != 0;
-    gboolean is_tan = (flags & GWEN_GUI_INPUT_FLAGS_TAN) != 0;
-
-    g_return_if_fail(input);
-    g_return_if_fail(max_len >= min_len && max_len > 0);
-
-    ENTER(" ");
-
-    /* Set up dialog */
-    builder = gtk_builder_new();
-    gnc_builder_add_from_file (builder, "dialog-ab.glade", "Password Dialog");
-    dialog = GTK_WIDGET(gtk_builder_get_object (builder, "Password Dialog"));
-
-    heading_label = GTK_WIDGET(gtk_builder_get_object (builder, "heading_pw_label"));
-    input_entry = GTK_WIDGET(gtk_builder_get_object (builder, "input_entry"));
-    confirm_entry = GTK_WIDGET(gtk_builder_get_object (builder, "confirm_entry"));
-    confirm_label = GTK_WIDGET(gtk_builder_get_object (builder, "confirm_label"));
-    remember_pin_checkbutton = GTK_WIDGET(gtk_builder_get_object (builder, "remember_pin"));
-    if (is_tan)
-    {
-        gtk_widget_hide(remember_pin_checkbutton);
-    }
-    else
-    {
-        gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(remember_pin_checkbutton),
-                                     gui->cache_passwords);
-    }
-
-    if (gui->parent)
-        gtk_window_set_transient_for(GTK_WINDOW(dialog),
-                                     GTK_WINDOW(gui->parent));
-    if (title)
-        gtk_window_set_title(GTK_WINDOW(dialog), title);
-
-    if (text)
-    {
-        gchar *raw_text = strip_html(g_strdup(text));
-        gtk_label_set_text(GTK_LABEL(heading_label), raw_text);
-        g_free(raw_text);
-    }
-
-    if (*input)
-    {
-        gtk_entry_set_text(GTK_ENTRY(input_entry), *input);
-        erase_password(*input);
-        *input = NULL;
-    }
-
-    if (confirm)
-    {
-        gtk_entry_set_activates_default(GTK_ENTRY(input_entry), FALSE);
-        gtk_entry_set_activates_default(GTK_ENTRY(confirm_entry), TRUE);
-        gtk_entry_set_max_length(GTK_ENTRY(input_entry), max_len);
-        gtk_entry_set_max_length(GTK_ENTRY(confirm_entry), max_len);
-    }
-    else
-    {
-        gtk_entry_set_activates_default(GTK_ENTRY(input_entry), TRUE);
-        gtk_entry_set_max_length(GTK_ENTRY(input_entry), max_len);
-        gtk_widget_hide(confirm_entry);
-        gtk_widget_hide(confirm_label);
-    }
-    gtk_dialog_set_default_response(GTK_DIALOG(dialog), GTK_RESPONSE_OK);
-
-    /* Ask the user until he enters a valid input or cancels */
-    while (TRUE)
-    {
-        gboolean remember_pin;
-
-        if (gtk_dialog_run(GTK_DIALOG(dialog)) != GTK_RESPONSE_OK)
-            break;
-
-        if (!is_tan)
-        {
-            /* Enable or disable the password cache */
-            remember_pin = gtk_toggle_button_get_active(
-                               GTK_TOGGLE_BUTTON(remember_pin_checkbutton));
-            enable_password_cache(gui, remember_pin);
-            gnc_prefs_set_bool(GNC_PREFS_GROUP_AQBANKING, GNC_PREF_REMEMBER_PIN,
-                               remember_pin);
-        }
-
-        internal_input = gtk_entry_get_text(GTK_ENTRY(input_entry));
-        if (strlen(internal_input) < min_len)
-        {
-            gboolean retval;
-            gchar *msg = g_strdup_printf(
-                             _("The PIN needs to be at least %d characters \n"
-                               "long. Do you want to try again?"), min_len);
-            retval = gnc_verify_dialog(gui->parent, TRUE, "%s", msg);
-            g_free(msg);
-            if (!retval)
-                break;
-            continue;
-        }
-
-        if (!confirm)
-        {
-            *input = g_strdup(internal_input);
-            break;
-        }
-
-        internal_confirmed = gtk_entry_get_text(GTK_ENTRY(confirm_entry));
-        if (strcmp(internal_input, internal_confirmed) == 0)
-        {
-            *input = g_strdup(internal_input);
-            break;
-        }
-    }
-
-    g_object_unref(G_OBJECT(builder));
-
-    /* This trashes passwords in the entries' memory as well */
-    gtk_widget_destroy(dialog);
-
-    LEAVE("input %s", *input ? "non-NULL" : "NULL");
-}
-
-static gint
-messagebox_cb(GWEN_GUI *gwen_gui, guint32 flags, const gchar *title,
-              const gchar *text, const gchar *b1, const gchar *b2,
-              const gchar *b3, guint32 guiid)
-{
-    GncGWENGui *gui = GETDATA_GUI(gwen_gui);
-    GtkWidget *dialog;
-    GtkWidget *vbox;
-    GtkWidget *label;
-    gchar *raw_text;
-    gint result;
-
-    ENTER("gui=%p, flags=%d, title=%s, b1=%s, b2=%s, b3=%s", gui, flags,
-          title ? title : "(null)", b1 ? b1 : "(null)", b2 ? b2 : "(null)",
-          b3 ? b3 : "(null)");
-
-    dialog = gtk_dialog_new_with_buttons(
-                 title, gui->parent ? GTK_WINDOW(gui->parent) : NULL,
-                 GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT,
-                 b1, 1, b2, 2, b3, 3, (gchar*) NULL);
-
-    raw_text = strip_html(g_strdup(text));
-    label = gtk_label_new(raw_text);
-    g_free(raw_text);
-    gtk_label_set_justify(GTK_LABEL(label), GTK_JUSTIFY_LEFT);
-    vbox = gtk_vbox_new(TRUE, 0);
-    gtk_container_set_border_width(GTK_CONTAINER(vbox), 5);
-    gtk_container_add(GTK_CONTAINER(vbox), label);
-    gtk_container_set_border_width(GTK_CONTAINER(dialog), 5);
-    gtk_container_add(GTK_CONTAINER(GTK_DIALOG(dialog)->vbox), vbox);
-    gtk_widget_show_all(dialog);
-
-    result = gtk_dialog_run(GTK_DIALOG(dialog));
-    gtk_widget_destroy(dialog);
-
-    if (result < 1 || result > 3)
-    {
-        g_warning("messagebox_cb: Bad result %d", result);
-        result = 0;
-    }
-
-    LEAVE("result=%d", result);
-    return result;
-}
-
-static gint
-inputbox_cb(GWEN_GUI *gwen_gui, guint32 flags, const gchar *title,
-            const gchar *text, gchar *buffer, gint min_len, gint max_len,
-            guint32 guiid)
-{
-    GncGWENGui *gui = GETDATA_GUI(gwen_gui);
-    gchar *input = NULL;
-
-    g_return_val_if_fail(gui, -1);
-
-    ENTER("gui=%p, flags=%d", gui, flags);
-
-    get_input(gui, flags, title, text, &input, min_len, max_len);
-
-    if (input)
-    {
-        /* Copy the input to the result buffer */
-        strncpy(buffer, input, max_len);
-        buffer[max_len-1] = '\0';
-    }
-
-    LEAVE(" ");
-    return input ? 0 : -1;
-}
-
-static guint32
-showbox_cb(GWEN_GUI *gwen_gui, guint32 flags, const gchar *title,
-           const gchar *text, guint32 guiid)
-{
-    GncGWENGui *gui = GETDATA_GUI(gwen_gui);
-    GtkWidget *dialog;
-    guint32 showbox_id;
-
-    g_return_val_if_fail(gui, -1);
-
-    ENTER("gui=%p, flags=%d, title=%s", gui, flags, title ? title : "(null)");
-
-    dialog = gtk_message_dialog_new(
-                 gui->parent ? GTK_WINDOW(gui->parent) : NULL, 0, GTK_MESSAGE_INFO,
-                 GTK_BUTTONS_OK, "%s", text);
-
-    if (title)
-        gtk_window_set_title(GTK_WINDOW(dialog), title);
-
-    g_signal_connect(dialog, "response", G_CALLBACK(gtk_widget_hide), NULL);
-    gtk_widget_show_all(dialog);
-
-    showbox_id = gui->showbox_id++;
-    g_hash_table_insert(gui->showbox_hash, GUINT_TO_POINTER(showbox_id),
-                        dialog);
-    gui->showbox_last = dialog;
-
-    /* Give it a change to be showed */
-    if (!keep_alive(gui))
-        showbox_id = 0;
-
-    LEAVE("id=%" G_GUINT32_FORMAT, showbox_id);
-    return showbox_id;
-}
-
-static void
-hidebox_cb(GWEN_GUI *gwen_gui, guint32 id)
-{
-    GncGWENGui *gui = GETDATA_GUI(gwen_gui);
-
-    g_return_if_fail(gui && gui->showbox_hash);
-
-    ENTER("gui=%p, id=%d", gui, id);
-
-    if (id == 0)
-    {
-        if (gui->showbox_last)
-        {
-            g_hash_table_remove(gui->showbox_hash,
-                                GUINT_TO_POINTER(gui->showbox_id));
-            gui->showbox_last = NULL;
-        }
-        else
-        {
-            g_warning("hidebox_cb: Last showed message box already destroyed");
-        }
-    }
-    else
-    {
-        gpointer p_var;
-        p_var = g_hash_table_lookup(gui->showbox_hash, GUINT_TO_POINTER(id));
-        if (p_var)
-        {
-            g_hash_table_remove(gui->showbox_hash, GUINT_TO_POINTER(id));
-            if (p_var == gui->showbox_last)
-                gui->showbox_last = NULL;
-        }
-        else
-        {
-            g_warning("hidebox_cb: Message box %d could not been found", id);
-        }
-    }
-
-    LEAVE(" ");
-}
-
-static guint32
-progress_start_cb(GWEN_GUI *gwen_gui, uint32_t progressFlags, const char *title,
-                  const char *text, uint64_t total, uint32_t guiid)
-{
-    GncGWENGui *gui = GETDATA_GUI(gwen_gui);
-    Progress *progress;
-
-    g_return_val_if_fail(gui, -1);
-
-    ENTER("gui=%p, flags=%d, title=%s, total=%" G_GUINT64_FORMAT, gui,
-          progressFlags, title ? title : "(null)", (guint64)total);
-
-    if (!gui->progresses)
-    {
-        /* Top-level progress */
-        if (progressFlags & GWEN_GUI_PROGRESS_SHOW_PROGRESS)
-        {
-            gtk_widget_set_sensitive(gui->top_progress, TRUE);
-            gtk_progress_bar_set_fraction(
-                GTK_PROGRESS_BAR(gui->top_progress), 0.0);
-            gui->max_actions = total;
-        }
-        else
-        {
-            gtk_widget_set_sensitive(gui->top_progress, FALSE);
-            gui->max_actions = -1;
-        }
-        set_running(gui);
-    }
-
-    /* Put progress onto the stack */
-    progress = g_new0(Progress, 1);
-    progress->gui = gui;
-    progress->title = title ? g_strdup(title) : "";
-    gui->progresses = g_list_prepend(gui->progresses, progress);
-
-    if (progressFlags & GWEN_GUI_PROGRESS_DELAY)
-    {
-        /* Show progress later */
-        progress->source = g_timeout_add(GWEN_GUI_DELAY_SECS * 1000,
-                                         (GSourceFunc) show_progress_cb,
-                                         progress);
-    }
-    else
-    {
-        /* Show it now */
-        progress->source = 0;
-        show_progress(gui, progress);
-    }
-
-    LEAVE(" ");
-    return g_list_length(gui->progresses);
-}
-
-static gint
-progress_advance_cb(GWEN_GUI *gwen_gui, uint32_t id, uint64_t progress)
-{
-    GncGWENGui *gui = GETDATA_GUI(gwen_gui);
-
-    g_return_val_if_fail(gui, -1);
-
-    ENTER("gui=%p, progress=%" G_GUINT64_FORMAT, gui, (guint64)progress);
-
-    if (id == 1                                  /* top-level progress */
-            && gui->max_actions > 0                  /* progressbar active */
-            && progress != GWEN_GUI_PROGRESS_NONE)   /* progressbar update needed */
-    {
-        if (progress == GWEN_GUI_PROGRESS_ONE)
-            gui->current_action++;
-        else
-            gui->current_action = progress;
-
-        gtk_progress_bar_set_fraction(
-            GTK_PROGRESS_BAR(gui->top_progress),
-            ((gdouble) gui->current_action) / ((gdouble) gui->max_actions));
-    }
-
-    LEAVE(" ");
-    return !keep_alive(gui);
-}
-
-static gint
-progress_log_cb(GWEN_GUI *gwen_gui, guint32 id, GWEN_LOGGER_LEVEL level,
-                const gchar *text)
-{
-    GncGWENGui *gui = GETDATA_GUI(gwen_gui);
-    GtkTextBuffer *tb;
-    GtkTextView *tv;
-
-    g_return_val_if_fail(gui, -1);
-
-    ENTER("gui=%p, text=%s", gui, text ? text : "(null)");
-
-    tv = GTK_TEXT_VIEW(gui->log_text);
-    tb = gtk_text_view_get_buffer(tv);
-    gtk_text_buffer_insert_at_cursor(tb, text, -1);
-    gtk_text_buffer_insert_at_cursor(tb, "\n", -1);
-
-    /* Scroll to the end of the buffer */
-    gtk_text_view_scroll_to_mark(tv, gtk_text_buffer_get_insert(tb),
-                                 0.0, FALSE, 0.0, 0.0);
-
-    /* Cache loglevel */
-    if (level < gui->min_loglevel)
-        gui->min_loglevel = level;
-
-    LEAVE(" ");
-    return !keep_alive(gui);
-}
-
-static gint
-progress_end_cb(GWEN_GUI *gwen_gui, guint32 id)
-{
-    GncGWENGui *gui = GETDATA_GUI(gwen_gui);
-    Progress *progress;
-
-    g_return_val_if_fail(gui, -1);
-    g_return_val_if_fail(id == g_list_length(gui->progresses), -1);
-
-    ENTER("gui=%p, id=%d", gui, id);
-
-    if (gui->state != RUNNING)
-    {
-        /* Ignore finishes of progresses we do not track */
-        LEAVE("not running anymore");
-        return 0;
-    }
-
-    /* Hide progress */
-    progress = (Progress*) gui->progresses->data;
-    hide_progress(gui, progress);
-
-    /* Remove progress from stack and free memory */
-    gui->progresses = g_list_delete_link(gui->progresses, gui->progresses);
-    free_progress(progress, NULL);
-
-    if (!gui->progresses)
-    {
-        /* top-level progress finished */
-        set_finished(gui);
-    }
-
-    LEAVE(" ");
-    return 0;
-}
-
-static gint GNC_GWENHYWFAR_CB
-getpassword_cb(GWEN_GUI *gwen_gui, guint32 flags, const gchar *token,
-               const gchar *title, const gchar *text, gchar *buffer,
-               gint min_len, gint max_len, guint32 guiid)
-{
-    GncGWENGui *gui = GETDATA_GUI(gwen_gui);
-    gchar *password = NULL;
-    gboolean is_tan = (flags & GWEN_GUI_INPUT_FLAGS_TAN) != 0;
-
-    g_return_val_if_fail(gui, -1);
-
-    ENTER("gui=%p, flags=%d, token=%s", gui, flags, token ? token : "(null");
-
-    /* Check remembered passwords, excluding TANs */
-    if (!is_tan && gui->cache_passwords && gui->passwords && token)
-    {
-        if (flags & GWEN_GUI_INPUT_FLAGS_RETRY)
-        {
-            /* If remembered, remove password from memory */
-            g_hash_table_remove(gui->passwords, token);
-        }
-        else
-        {
-            gpointer p_var;
-            if (g_hash_table_lookup_extended(gui->passwords, token, NULL,
-                                             &p_var))
-            {
-                /* Copy the password to the result buffer */
-                password = p_var;
-                strncpy(buffer, password, max_len);
-                buffer[max_len-1] = '\0';
-
-                LEAVE("chose remembered password");
-                return 0;
-            }
-        }
-    }
-
-    get_input(gui, flags, title, text, &password, min_len, max_len);
-
-    if (password)
-    {
-        /* Copy the password to the result buffer */
-        strncpy(buffer, password, max_len);
-        buffer[max_len-1] = '\0';
-
-        if (!is_tan && token)
-        {
-            if (gui->cache_passwords && gui->passwords)
-            {
-                /* Remember password */
-                DEBUG("Remember password, token=%s", token);
-                g_hash_table_insert(gui->passwords, g_strdup(token), password);
-            }
-            else
-            {
-                /* Remove the password from memory */
-                DEBUG("Forget password, token=%s", token);
-                erase_password(password);
-            }
-        }
-    }
-
-    LEAVE(" ");
-    return password ? 0 : -1;
-}
-
-static gint GNC_GWENHYWFAR_CB
-setpasswordstatus_cb(GWEN_GUI *gwen_gui, const gchar *token, const gchar *pin,
-                     GWEN_GUI_PASSWORD_STATUS status, guint32 guiid)
-{
-    GncGWENGui *gui = GETDATA_GUI(gwen_gui);
-
-    g_return_val_if_fail(gui, -1);
-
-    ENTER("gui=%p, token=%s, status=%d", gui, token ? token : "(null)", status);
-
-    if (gui->passwords && status != GWEN_Gui_PasswordStatus_Ok)
-    {
-        /* If remembered, remove password from memory */
-        g_hash_table_remove(gui->passwords, token);
-    }
-
-    LEAVE(" ");
-    return 0;
-}
-
-static gint GNC_GWENHYWFAR_CB
-loghook_cb(GWEN_GUI *gwen_gui, const gchar *log_domain,
-           GWEN_LOGGER_LEVEL priority, const gchar *text)
-{
-    if (G_LIKELY(priority < n_log_levels))
-        g_log(log_domain, log_levels[priority], "%s", text);
-
-    return 1;
-}
-
-static gint GNC_GWENHYWFAR_CB
-checkcert_cb(GWEN_GUI *gwen_gui, const GWEN_SSLCERTDESCR *cert,
-             GWEN_IO_LAYER *io, guint32 guiid)
-{
-    GncGWENGui *gui = GETDATA_GUI(gwen_gui);
-    const gchar *hash, *status;
-    struct md5_ctx md5_context;
-    gchar cert_hash[16];
-    gchar *cert_hash_hex;
-    gint retval, i;
-
-    g_return_val_if_fail(gui && gui->accepted_certs, -1);
-
-    ENTER("gui=%p, cert=%p", gui, cert);
-
-    hash = GWEN_SslCertDescr_GetFingerPrint(cert);
-    status = GWEN_SslCertDescr_GetStatusText(cert);
-
-    /* Operate on an md5sum of the pair of hash and status */
-    md5_init_ctx(&md5_context);
-    md5_process_bytes(hash, strlen(hash), &md5_context);
-    md5_process_bytes(status, strlen(status), &md5_context);
-    md5_finish_ctx(&md5_context, cert_hash);
-
-    /* Did we get the permanently accepted certs from AqBanking? */
-    if (gui->permanently_accepted_certs)
-    {
-        /* Generate a hex string of the cert_hash for usage by AqBanking cert store */
-        cert_hash_hex = g_new0(gchar, 33);
-        for (i = 0; i < 16; i++)
-            g_snprintf(cert_hash_hex + 2 * i, 3, "%02X", (unsigned char)cert_hash[i]);
-
-        retval = GWEN_DB_GetIntValue(gui->permanently_accepted_certs, cert_hash_hex, 0, -1);
-        g_free(cert_hash_hex);
-        if (retval == 0)
-        {
-            /* Certificate is marked as accepted in AqBanking's cert store */
-            LEAVE("Certificate accepted by AqBanking's permanent cert store");
-            return 0;
-        }
-    }
-    else
-    {
-        g_warning("Can't check permanently accepted certs from invalid AqBanking cert store.");
-    }
-
-    if (g_hash_table_lookup(gui->accepted_certs, cert_hash))
-    {
-        /* Certificate has been accepted by Gnucash before */
-        LEAVE("Automatically accepting certificate");
-        return 0;
-    }
-
-    retval = gui->builtin_checkcert(gwen_gui, cert, io, guiid);
-    if (retval == 0)
-    {
-        /* Certificate has been accepted */
-        g_hash_table_insert(gui->accepted_certs, g_strdup(cert_hash), cert_hash);
-    }
-
-    LEAVE("retval=%d", retval);
-    return retval;
-}
-
-gboolean
-ggg_delete_event_cb(GtkWidget *widget, GdkEvent *event, gpointer user_data)
-{
-    GncGWENGui *gui = user_data;
-
-    g_return_val_if_fail(gui, FALSE);
-
-    ENTER("gui=%p, state=%d", gui, gui->state);
-
-    if (gui->state == RUNNING)
-    {
-        const char *still_running_msg =
-            _("The Online Banking job is still running; are you "
-              "sure you want to cancel?");
-        if (!gnc_verify_dialog(gui->dialog, FALSE, "%s", still_running_msg))
-            return FALSE;
-
-        set_aborted(gui);
-    }
-
-    hide_dialog(gui);
-
-    LEAVE(" ");
-    return TRUE;
-}
-
-void
-ggg_abort_clicked_cb(GtkButton *button, gpointer user_data)
-{
-    GncGWENGui *gui = user_data;
-
-    g_return_if_fail(gui && gui->state == RUNNING);
-
-    ENTER("gui=%p", gui);
-
-    set_aborted(gui);
-
-    LEAVE(" ");
-}
-
-void
-ggg_close_clicked_cb(GtkButton *button, gpointer user_data)
-{
-    GncGWENGui *gui = user_data;
-
-    g_return_if_fail(gui);
-    g_return_if_fail(gui->state == FINISHED || gui->state == ABORTED);
-
-    ENTER("gui=%p", gui);
-
-    hide_dialog(gui);
-
-    LEAVE(" ");
-}
-
-void
-ggg_close_toggled_cb(GtkToggleButton *button, gpointer user_data)
-{
-    GncGWENGui *gui = user_data;
-
-    g_return_if_fail(gui);
-    g_return_if_fail(gui->parent);
-
-    ENTER("gui=%p", gui);
-
-    gnc_prefs_set_bool(
-        GNC_PREFS_GROUP_AQBANKING, GNC_PREF_CLOSE_ON_FINISH,
-        gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(button)));
-
-    LEAVE(" ");
-}
-#endif

Deleted: gnucash/trunk/src/import-export/aqbanking/gnc-gwen-gui.h
===================================================================
--- gnucash/trunk/src/import-export/aqbanking/gnc-gwen-gui.h	2013-12-15 17:20:10 UTC (rev 23566)
+++ gnucash/trunk/src/import-export/aqbanking/gnc-gwen-gui.h	2013-12-15 17:21:20 UTC (rev 23567)
@@ -1,107 +0,0 @@
-/*
- * gnc-gwen-gui.h --
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation; either version 2 of
- * the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, contact:
- *
- * Free Software Foundation           Voice:  +1-617-542-5942
- * 51 Franklin Street, Fifth Floor    Fax:    +1-617-542-2652
- * Boston, MA  02110-1301,  USA       gnu at gnu.org
- */
-
-/**
- * @addtogroup Import_Export
- * @{
- * @addtogroup AqBanking
- * @{
- * @file gnc-gwen-gui.h
- * @brief GUI callbacks for AqBanking
- * @author Copyright (C) 2002 Christian Stimming <stimming at tuhh.de>
- * @author Copyright (C) 2008 Andreas Koehler <andi5.py at gmx.net>
- */
-
-#ifndef GNC_GWEN_GUI_H
-#define GNC_GWEN_GUI_H
-
-#include <gtk/gtk.h>
-
-G_BEGIN_DECLS
-
-typedef struct _GncGWENGui GncGWENGui;
-
-/**
- * Hook our logging into the gwenhywfar logging framework by creating a
- * minimalistic GWEN_GUI with only a callback for Gwen_Gui_LogHook().  This
- * function can be called more than once, it will unref and replace the
- * currently set GWEN_GUI though.
- */
-void gnc_GWEN_Gui_log_init(void);
-
-/**
- * When called for the first time, create a unique GncGWENGui object featuring a
- * GWEN_GUI with all necessary callbacks, which can serve as a user interface
- * for AqBanking jobs.  On later calls, return the object only when it is not
- * active and save to use.  Typically, you only need to call
- * gnc_GWEN_Gui_release() once your job has finished.
- *
- * @param parent Widget to set new dialogs transient for, may be NULL
- * @return The unique GncGWENGui object or NULL otherwise
- */
-GncGWENGui *gnc_GWEN_Gui_get(GtkWidget *parent);
-
-/**
- * Currently a no-op.  The GncGWENGui will not be freed and it is considered
- * finished once the first tracked progress has ended.
- *
- * @param gui The GncGwenGUI returned by gnc_GWEN_Gui_get()
- */
-void gnc_GWEN_Gui_release(GncGWENGui *gui);
-
-/**
- * Free all memory related to both the full-blown and minimalistic GUI objects.
- */
-void gnc_GWEN_Gui_shutdown(void);
-
-/**
- * Set "Close when finished" flag
- *
- * @param gboolean close_when_finished
- */
-void gnc_GWEN_Gui_set_close_flag(gboolean close_when_finished);
-
-/**
- * Get "Close when finished" flag
- *
- * @return gboolean close_when_finished
- */
-gboolean gnc_GWEN_Gui_get_close_flag(void);
-
-/**
- * Unhides Online Banking Connection Window (Make log visible)
- *
- * @return gboolean window is visible
- */
-gboolean gnc_GWEN_Gui_show_dialog(void);
-
-/**
- * Hides Online Banking Connection Window (Close log window)
- *
- */
-void gnc_GWEN_Gui_hide_dialog(void);
-
-G_END_DECLS
-
-/** @} */
-/** @} */
-
-#endif /* GNC_GWEN_GUI_H */

Deleted: gnucash/trunk/src/import-export/aqbanking/gnc-plugin-aqbanking-ui.xml
===================================================================
--- gnucash/trunk/src/import-export/aqbanking/gnc-plugin-aqbanking-ui.xml	2013-12-15 17:20:10 UTC (rev 23566)
+++ gnucash/trunk/src/import-export/aqbanking/gnc-plugin-aqbanking-ui.xml	2013-12-15 17:21:20 UTC (rev 23567)
@@ -1,39 +0,0 @@
-<ui>
-  <menubar>
-    <menu name="File" action="FileAction">
-      <menu name="FileImport" action="FileImportAction">
-        <placeholder name="FileImportPlaceholder">
-           <menuitem name="FileMt940Import"     action="Mt940ImportAction"/>
-           <menuitem name="FileMt942Import"     action="Mt942ImportAction"/>
-           <menuitem name="FileDtausImport"     action="DtausImportAction"/>
-           <menuitem name="FileDtausImportsend" action="DtausImportSendAction"/>
-           <!-- When CsvImport works:
-           <menuitem name="FileCsvImport"       action="CsvImportAction"/>
-           <menuitem name="FileCsvImportsend"   action="CsvImportSendAction"/>
-           -->
-        </placeholder>
-      </menu>
-    </menu>
-    <menu name="Actions" action="ActionsAction">
-      <placeholder name="ActionsPlaceholder">
-        <menu name="OnlineActions" action="OnlineActionsAction">
-          <menuitem name="ABGetBalance"         action="ABGetBalanceAction"/>
-          <menuitem name="ABGetTrans"           action="ABGetTransAction"/>
-          <separator name="OnlineActionsSep1"/>
-          <menuitem name="ABIssueTrans"         action="ABIssueTransAction"/>
-          <menuitem name="ABIssueSepaTrans"         action="ABIssueSepaTransAction"/>
-          <menuitem name="ABIssueIntTrans"      action="ABIssueIntTransAction"/>
-          <menuitem name="ABIssueDirectDebit"   action="ABIssueDirectDebitAction"/>
-          <!--menuitem name="ABIssueSepaDirectDebit"         action="ABIssueSepaDirectDebitAction"/-->
-          <separator name="OnlineActionsSep2"/>
-          <menuitem name="ABViewLogwindow"   action="ABViewLogwindowAction"/>
-        </menu>
-      </placeholder>
-    </menu>
-    <menu name="Tools" action="ToolsAction">
-      <placeholder name="ToolsPlaceholder">
-        <menuitem name="ABSetup"                action="ABSetupAction"/>
-     </placeholder>
-    </menu>
-  </menubar>
-</ui>

Deleted: gnucash/trunk/src/import-export/aqbanking/gnc-plugin-aqbanking.c
===================================================================
--- gnucash/trunk/src/import-export/aqbanking/gnc-plugin-aqbanking.c	2013-12-15 17:20:10 UTC (rev 23566)
+++ gnucash/trunk/src/import-export/aqbanking/gnc-plugin-aqbanking.c	2013-12-15 17:21:20 UTC (rev 23567)
@@ -1,712 +0,0 @@
-/*
- * gnc-plugin-aqbanking.c --
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation; either version 2 of
- * the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, contact:
- *
- * Free Software Foundation           Voice:  +1-617-542-5942
- * 51 Franklin Street, Fifth Floor    Fax:    +1-617-542-2652
- * Boston, MA  02110-1301,  USA       gnu at gnu.org
- */
-
-/**
- * @internal
- * @file gnc-plugin-aqbanking.c
- * @brief Plugin registration of the AqBanking module
- * @author Copyright (C) 2002 Christian Stimming <stimming at tuhh.de>
- * @author Copyright (C) 2003 David Hampton <hampton at employees.org>
- * @author Copyright (C) 2008 Andreas Koehler <andi5.py at gmx.net>
- */
-
-#include "config.h"
-
-#include <glib/gi18n.h>
-
-#include "Account.h"
-#include "dialog-ab-trans.h"
-#include "assistant-ab-initial.h"
-#include "gnc-ab-getbalance.h"
-#include "gnc-ab-gettrans.h"
-#include "gnc-ab-transfer.h"
-#include "gnc-ab-utils.h"
-#include "gnc-ab-kvp.h"
-#include "gnc-gwen-gui.h"
-#include "gnc-file-aqb-import.h"
-#include "gnc-plugin-aqbanking.h"
-#include "gnc-plugin-manager.h"
-#include "gnc-plugin-page-account-tree.h"
-#include "gnc-plugin-page-register.h"
-#include "gnc-plugin-page-register2.h"
-#include "gnc-main-window.h"
-#include "gnc-prefs.h"
-#include "gnc-ui-util.h" // for gnc_get_current_book
-
-/* This static indicates the debugging module that this .o belongs to.  */
-static QofLogModule log_module = G_LOG_DOMAIN;
-
-static void gnc_plugin_aqbanking_class_init(GncPluginAqBankingClass *klass);
-static void gnc_plugin_aqbanking_init(GncPluginAqBanking *plugin);
-static void gnc_plugin_aqbanking_add_to_window(GncPlugin *plugin, GncMainWindow *window, GQuark type);
-static void gnc_plugin_aqbanking_remove_from_window(GncPlugin *plugin, GncMainWindow *window, GQuark type);
-
-/* Object callbacks */
-static void gnc_plugin_ab_main_window_page_added(GncMainWindow *window, GncPluginPage *page, gpointer user_data);
-static void gnc_plugin_ab_main_window_page_changed(GncMainWindow *window, GncPluginPage *page, gpointer user_data);
-static void gnc_plugin_ab_account_selected(GncPluginPage *plugin_page, Account *account, gpointer user_data);
-
-/* Auxiliary functions */
-static Account *main_window_to_account(GncMainWindow *window);
-
-/* Command callbacks */
-static void gnc_plugin_ab_cmd_setup(GtkAction *action, GncMainWindowActionData *data);
-static void gnc_plugin_ab_cmd_get_balance(GtkAction *action, GncMainWindowActionData *data);
-static void gnc_plugin_ab_cmd_get_transactions(GtkAction *action, GncMainWindowActionData *data);
-static void gnc_plugin_ab_cmd_issue_transaction(GtkAction *action, GncMainWindowActionData *data);
-static void gnc_plugin_ab_cmd_issue_sepatransaction(GtkAction *action, GncMainWindowActionData *data);
-static void gnc_plugin_ab_cmd_issue_inttransaction(GtkAction *action, GncMainWindowActionData *data);
-static void gnc_plugin_ab_cmd_issue_direct_debit(GtkAction *action, GncMainWindowActionData *data);
-static void gnc_plugin_ab_cmd_issue_sepa_direct_debit(GtkAction *action, GncMainWindowActionData *data);
-static void gnc_plugin_ab_cmd_view_logwindow(GtkToggleAction *action, GncMainWindow *window);
-static void gnc_plugin_ab_cmd_mt940_import(GtkAction *action, GncMainWindowActionData *data);
-static void gnc_plugin_ab_cmd_mt942_import(GtkAction *action, GncMainWindowActionData *data);
-static void gnc_plugin_ab_cmd_dtaus_import(GtkAction *action, GncMainWindowActionData *data);
-static void gnc_plugin_ab_cmd_dtaus_importsend(GtkAction *action, GncMainWindowActionData *data);
-
-#define PLUGIN_ACTIONS_NAME "gnc-plugin-aqbanking-actions"
-#define PLUGIN_UI_FILENAME  "gnc-plugin-aqbanking-ui.xml"
-
-#define MENU_TOGGLE_ACTION_AB_VIEW_LOGWINDOW "ABViewLogwindowAction"
-
-
-static GtkActionEntry gnc_plugin_actions [] =
-{
-    /* Menus */
-    { "OnlineActionsAction", NULL, N_("_Online Actions"), NULL, NULL, NULL },
-
-    /* Menu Items */
-    {
-        "ABSetupAction", NULL, N_("_Online Banking Setup..."), NULL,
-        N_("Initial setup of Online Banking access (HBCI, or OFX DirectConnect, using AqBanking)"),
-        G_CALLBACK(gnc_plugin_ab_cmd_setup)
-    },
-    {
-        "ABGetBalanceAction", NULL, N_("Get _Balance"), NULL,
-        N_("Get the account balance online through Online Banking"),
-        G_CALLBACK(gnc_plugin_ab_cmd_get_balance)
-    },
-    {
-        "ABGetTransAction", NULL, N_("Get _Transactions..."), NULL,
-        N_("Get the transactions online through Online Banking"),
-        G_CALLBACK(gnc_plugin_ab_cmd_get_transactions)
-    },
-    {
-        "ABIssueTransAction", NULL, N_("_Issue Transaction..."), NULL,
-        N_("Issue a new transaction online through Online Banking"),
-        G_CALLBACK(gnc_plugin_ab_cmd_issue_transaction)
-    },
-    {
-        "ABIssueSepaTransAction", NULL, N_("_Issue SEPA Transaction..."), NULL,
-        N_("Issue a new international European (SEPA) transaction online through Online Banking"),
-        G_CALLBACK(gnc_plugin_ab_cmd_issue_sepatransaction)
-    },
-    {
-        "ABIssueIntTransAction", NULL, N_("I_nternal Transaction..."), NULL,
-        N_("Issue a new bank-internal transaction online through Online Banking"),
-        G_CALLBACK(gnc_plugin_ab_cmd_issue_inttransaction)
-    },
-    {
-        "ABIssueDirectDebitAction", NULL, N_("_Direct Debit..."), NULL,
-        N_("Issue a new direct debit note online through Online Banking"),
-        G_CALLBACK(gnc_plugin_ab_cmd_issue_direct_debit)
-    },
-    {
-        "ABIssueSepaDirectDebitAction", NULL, N_("_Issue SEPA Direct Debit..."), NULL,
-        N_("Issue a new international European (SEPA) direct debit note online through Online Banking"),
-        G_CALLBACK(gnc_plugin_ab_cmd_issue_sepa_direct_debit)
-    },
-
-    /* File -> Import menu item */
-    {
-        "Mt940ImportAction", GTK_STOCK_CONVERT, N_("Import _MT940"), NULL,
-        N_("Import a MT940 file into GnuCash"),
-        G_CALLBACK(gnc_plugin_ab_cmd_mt940_import)
-    },
-    {
-        "Mt942ImportAction", GTK_STOCK_CONVERT, N_("Import MT94_2"), NULL,
-        N_("Import a MT942 file into GnuCash"),
-        G_CALLBACK(gnc_plugin_ab_cmd_mt942_import)
-    },
-    {
-        "DtausImportAction", GTK_STOCK_CONVERT, N_("Import _DTAUS"), NULL,
-        N_("Import a DTAUS file into GnuCash"),
-        G_CALLBACK(gnc_plugin_ab_cmd_dtaus_import)
-    },
-    /* #ifdef CSV_IMPORT_FUNCTIONAL */
-    /*     { "CsvImportAction", GTK_STOCK_CONVERT, N_("Import _CSV"), NULL, */
-    /*       N_("Import a CSV file into GnuCash"), */
-    /*       G_CALLBACK(gnc_plugin_ab_cmd_csv_import) }, */
-    /*     { "CsvImportSendAction", GTK_STOCK_CONVERT, N_("Import CSV and s_end..."), NULL, */
-    /*       N_("Import a CSV file into GnuCash and send the transfers online through Online Banking"), */
-    /*       G_CALLBACK(gnc_plugin_ab_cmd_csv_importsend) }, */
-    /* #endif */
-    {
-        "DtausImportSendAction", GTK_STOCK_CONVERT, N_("Import DTAUS and _send..."), NULL,
-        N_("Import a DTAUS file into GnuCash and send the transfers online through Online Banking"),
-        G_CALLBACK(gnc_plugin_ab_cmd_dtaus_importsend)
-    },
-};
-static guint gnc_plugin_n_actions = G_N_ELEMENTS(gnc_plugin_actions);
-
-static GtkToggleActionEntry gnc_plugin_toggle_actions [] =
-{
-    {
-        MENU_TOGGLE_ACTION_AB_VIEW_LOGWINDOW, NULL,
-        N_("Show _log window"), NULL,
-        N_("Show the online banking log window."),
-        G_CALLBACK(gnc_plugin_ab_cmd_view_logwindow), TRUE
-    },
-};
-static guint gnc_plugin_n_toggle_actions = G_N_ELEMENTS(gnc_plugin_toggle_actions);
-
-static const gchar *need_account_actions[] =
-{
-    "ABGetBalanceAction",
-    "ABGetTransAction",
-    "ABIssueTransAction",
-    "ABIssueSepaTransAction",
-    "ABIssueIntTransAction",
-    "ABIssueDirectDebitAction",
-    "ABIssueSepaDirectDebitAction",
-    NULL
-};
-
-static const gchar *readonly_inactive_actions[] =
-{
-    "OnlineActionsAction",
-    "ABSetupAction",
-    NULL
-};
-
-static GncMainWindow *gnc_main_window = NULL;
-
-/************************************************************
- *                   Object Implementation                  *
- ************************************************************/
-
-G_DEFINE_TYPE(GncPluginAqBanking, gnc_plugin_aqbanking, GNC_TYPE_PLUGIN)
-
-GncPlugin *
-gnc_plugin_aqbanking_new(void)
-{
-    return GNC_PLUGIN(g_object_new(GNC_TYPE_PLUGIN_AQBANKING, (gchar*) NULL));
-}
-
-static void
-gnc_plugin_aqbanking_class_init(GncPluginAqBankingClass *klass)
-{
-    GncPluginClass *plugin_class = GNC_PLUGIN_CLASS(klass);
-
-    /* plugin info */
-    plugin_class->plugin_name  = GNC_PLUGIN_AQBANKING_NAME;
-
-    /* widget addition/removal */
-    plugin_class->actions_name       = PLUGIN_ACTIONS_NAME;
-    plugin_class->actions            = gnc_plugin_actions;
-    plugin_class->n_actions          = gnc_plugin_n_actions;
-    plugin_class->toggle_actions     = gnc_plugin_toggle_actions;
-    plugin_class->n_toggle_actions   = gnc_plugin_n_toggle_actions;
-    plugin_class->ui_filename        = PLUGIN_UI_FILENAME;
-    plugin_class->add_to_window      = gnc_plugin_aqbanking_add_to_window;
-    plugin_class->remove_from_window = gnc_plugin_aqbanking_remove_from_window;
-}
-
-static void
-gnc_plugin_aqbanking_init(GncPluginAqBanking *plugin)
-{
-}
-
-/**
- * Called when this plugin is added to a main window.  Connect a few callbacks
- * here to track page changes.
- */
-static void
-gnc_plugin_aqbanking_add_to_window(GncPlugin *plugin, GncMainWindow *window,
-                                   GQuark type)
-{
-    GtkAction *action;
-
-    gnc_main_window = window;
-
-    g_signal_connect(window, "page_added",
-                     G_CALLBACK(gnc_plugin_ab_main_window_page_added),
-                     plugin);
-    g_signal_connect(window, "page_changed",
-                     G_CALLBACK(gnc_plugin_ab_main_window_page_changed),
-                     plugin);
-
-    action = gnc_main_window_find_action(window, MENU_TOGGLE_ACTION_AB_VIEW_LOGWINDOW);
-
-    gtk_toggle_action_set_active(GTK_TOGGLE_ACTION(action), FALSE);
-}
-
-static void
-gnc_plugin_aqbanking_remove_from_window(GncPlugin *plugin, GncMainWindow *window,
-                                        GQuark type)
-{
-    g_signal_handlers_disconnect_by_func(
-        window, G_CALLBACK(gnc_plugin_ab_main_window_page_changed), plugin);
-    g_signal_handlers_disconnect_by_func(
-        window, G_CALLBACK(gnc_plugin_ab_main_window_page_added), plugin);
-}
-
-/************************************************************
- *                     Object Callbacks                     *
- ************************************************************/
-
-/**
- * A new page has been added to a main window.  Connect a signal to it so that
- * we can track when accounts are selected.
- */
-static void
-gnc_plugin_ab_main_window_page_added(GncMainWindow *window, GncPluginPage *page,
-                                     gpointer user_data)
-{
-    const gchar *page_name;
-
-    ENTER("main window %p, page %p", window, page);
-    if (!GNC_IS_PLUGIN_PAGE(page))
-    {
-        LEAVE("no plugin_page");
-        return;
-    }
-
-    page_name = gnc_plugin_page_get_plugin_name(page);
-    if (!page_name)
-    {
-        LEAVE("no page_name of plugin_page");
-        return;
-    }
-
-    if (strcmp(page_name, GNC_PLUGIN_PAGE_ACCOUNT_TREE_NAME) == 0)
-    {
-        DEBUG("account tree page, adding signal");
-        g_signal_connect(page, "account_selected",
-                         G_CALLBACK(gnc_plugin_ab_account_selected), NULL);
-    }
-
-    gnc_plugin_ab_main_window_page_changed(window, page, user_data);
-
-    LEAVE(" ");
-}
-
-/** Update the actions sensitivity
-*/
-static void update_inactive_actions(GncPluginPage *plugin_page)
-{
-    GncMainWindow  *window;
-    GtkActionGroup *action_group;
-
-    // We are readonly - so we have to switch particular actions to inactive.
-    gboolean is_readwrite = !qof_book_is_readonly(gnc_get_current_book());
-
-    // We continue only if the current page is a plugin page
-    if (!plugin_page || !GNC_IS_PLUGIN_PAGE(plugin_page))
-        return;
-
-    window = GNC_MAIN_WINDOW(plugin_page->window);
-    g_return_if_fail(GNC_IS_MAIN_WINDOW(window));
-    action_group = gnc_main_window_get_action_group(window, PLUGIN_ACTIONS_NAME);
-    g_return_if_fail(GTK_IS_ACTION_GROUP(action_group));
-
-    /* Set the action's sensitivity */
-    gnc_plugin_update_actions (action_group, readonly_inactive_actions,
-                               "sensitive", is_readwrite);
-}
-
-
-/**
- * Whenever the current page has changed, update the aqbanking menus based upon
- * the page that is currently selected.
- */
-static void
-gnc_plugin_ab_main_window_page_changed(GncMainWindow *window,
-                                       GncPluginPage *page, gpointer user_data)
-{
-    Account *account = main_window_to_account(window);
-
-    /* Make sure not to call this with a NULL GncPluginPage */
-    if (page)
-    {
-        // Update the menu items according to the selected account
-        gnc_plugin_ab_account_selected(page, account, user_data);
-
-        // Also update the action sensitivity due to read-only
-        update_inactive_actions(page);
-    }
-}
-
-/**
- * An account had been (de)selected either in an "account tree" page or by
- * selecting another register page. Update the aqbanking menus appropriately.
- */
-static void
-gnc_plugin_ab_account_selected(GncPluginPage *plugin_page, Account *account,
-                               gpointer user_data)
-{
-    GncMainWindow  *window;
-    GtkActionGroup *action_group;
-    const gchar *bankcode = NULL;
-    const gchar *accountid = NULL;
-
-    g_return_if_fail(GNC_IS_PLUGIN_PAGE(plugin_page));
-    window = GNC_MAIN_WINDOW(plugin_page->window);
-    g_return_if_fail(GNC_IS_MAIN_WINDOW(window));
-    action_group = gnc_main_window_get_action_group(window, PLUGIN_ACTIONS_NAME);
-    g_return_if_fail(GTK_IS_ACTION_GROUP(action_group));
-
-    if (account)
-    {
-        bankcode = gnc_ab_get_account_bankcode(account);
-        accountid = gnc_ab_get_account_accountid(account);
-
-        gnc_plugin_update_actions(action_group, need_account_actions,
-                                  "sensitive",
-                                  (account && bankcode && *bankcode
-                                   && accountid && *accountid));
-        gnc_plugin_update_actions(action_group, need_account_actions,
-                                  "visible", TRUE);
-    }
-    else
-    {
-        gnc_plugin_update_actions(action_group, need_account_actions,
-                                  "sensitive", FALSE);
-        gnc_plugin_update_actions(action_group, need_account_actions,
-                                  "visible", FALSE);
-    }
-
-}
-
-/************************************************************
- *                    Auxiliary Functions                   *
- ************************************************************/
-
-/**
- * Given a pointer to a main window, try and extract an Account from it.  If the
- * current page is an "account tree" page, get the account corresponding to the
- * selected account.  (What if multiple accounts are selected?)  If the current
- * page is a "register" page, get the head account for the register. (Returns
- * NULL for a general ledger or search register.)
- *
- * @param window A pointer to a GncMainWindow object.
- * @return A pointer to an account, if one can be determined from the current
- * page. NULL otherwise.
- */
-static Account *
-main_window_to_account(GncMainWindow *window)
-{
-    GncPluginPage  *page;
-    const gchar    *page_name;
-    Account        *account = NULL;
-    const gchar    *account_name;
-
-    ENTER("main window %p", window);
-    if (!GNC_IS_MAIN_WINDOW(window))
-    {
-        LEAVE("no main_window");
-        return NULL;
-    }
-
-    page = gnc_main_window_get_current_page(window);
-    if (!GNC_IS_PLUGIN_PAGE(page))
-    {
-        LEAVE("no plugin_page");
-        return NULL;
-    }
-    page_name = gnc_plugin_page_get_plugin_name(page);
-    if (!page_name)
-    {
-        LEAVE("no page_name of plugin_page");
-        return NULL;
-    }
-
-    if (strcmp(page_name, GNC_PLUGIN_PAGE_REGISTER_NAME) == 0)
-    {
-        DEBUG("register page");
-        account = gnc_plugin_page_register_get_account(
-                      GNC_PLUGIN_PAGE_REGISTER(page));
-    }
-    else if (strcmp(page_name, GNC_PLUGIN_PAGE_REGISTER2_NAME) == 0)
-    {
-        DEBUG("register2 page");
-        account = gnc_plugin_page_register2_get_account(
-                      GNC_PLUGIN_PAGE_REGISTER2(page));
-    }
-    else if (strcmp(page_name, GNC_PLUGIN_PAGE_ACCOUNT_TREE_NAME) == 0)
-    {
-        DEBUG("account tree page");
-        account = gnc_plugin_page_account_tree_get_current_account(
-                      GNC_PLUGIN_PAGE_ACCOUNT_TREE(page));
-    }
-    else
-    {
-        account = NULL;
-    }
-    account_name = account ? xaccAccountGetName(account) : NULL;
-    LEAVE("account %s(%p)", account_name ? account_name : "(null)", account);
-    return account;
-}
-
-void
-gnc_plugin_aqbanking_set_logwindow_visible(gboolean logwindow_visible)
-{
-    GtkAction *action;
-
-    action = gnc_main_window_find_action(gnc_main_window,
-                                         MENU_TOGGLE_ACTION_AB_VIEW_LOGWINDOW);
-    if (action)
-    {
-        gtk_toggle_action_set_active(GTK_TOGGLE_ACTION(action),
-                                     logwindow_visible);
-    }
-}
-
-/************************************************************
- *                    Command Callbacks                     *
- ************************************************************/
-
-static void
-gnc_plugin_ab_cmd_setup(GtkAction *action, GncMainWindowActionData *data)
-{
-    ENTER("action %p, main window data %p", action, data);
-    gnc_main_window = data->window;
-    gnc_ab_initial_assistant();
-    LEAVE(" ");
-}
-
-static void
-gnc_plugin_ab_cmd_get_balance(GtkAction *action, GncMainWindowActionData *data)
-{
-    Account *account;
-
-    ENTER("action %p, main window data %p", action, data);
-    account = main_window_to_account(data->window);
-    if (account == NULL)
-    {
-        g_message("No AqBanking account selected");
-        LEAVE("no account");
-        return;
-    }
-
-    gnc_main_window = data->window;
-    gnc_ab_getbalance(GTK_WIDGET(data->window), account);
-
-    LEAVE(" ");
-}
-
-static void
-gnc_plugin_ab_cmd_get_transactions(GtkAction *action,
-                                   GncMainWindowActionData *data)
-{
-    Account *account;
-
-    ENTER("action %p, main window data %p", action, data);
-    account = main_window_to_account(data->window);
-    if (account == NULL)
-    {
-        g_message("No AqBanking account selected");
-        LEAVE("no account");
-        return;
-    }
-
-    gnc_main_window = data->window;
-    gnc_ab_gettrans(GTK_WIDGET(data->window), account);
-
-    LEAVE(" ");
-}
-
-static void
-gnc_plugin_ab_cmd_issue_transaction(GtkAction *action,
-                                    GncMainWindowActionData *data)
-{
-    Account *account;
-
-    ENTER("action %p, main window data %p", action, data);
-    account = main_window_to_account(data->window);
-    if (account == NULL)
-    {
-        g_message("No AqBanking account selected");
-        LEAVE("no account");
-        return;
-    }
-
-    gnc_main_window = data->window;
-    gnc_ab_maketrans(GTK_WIDGET(data->window), account, SINGLE_TRANSFER);
-
-    LEAVE(" ");
-}
-
-static void
-gnc_plugin_ab_cmd_issue_sepatransaction(GtkAction *action,
-                                    GncMainWindowActionData *data)
-{
-    Account *account;
-
-    ENTER("action %p, main window data %p", action, data);
-    account = main_window_to_account(data->window);
-    if (account == NULL)
-    {
-        g_message("No AqBanking account selected");
-        LEAVE("no account");
-        return;
-    }
-
-    gnc_main_window = data->window;
-    gnc_ab_maketrans(GTK_WIDGET(data->window), account, SEPA_TRANSFER);
-
-    LEAVE(" ");
-}
-
-static void
-gnc_plugin_ab_cmd_issue_inttransaction(GtkAction *action,
-                                       GncMainWindowActionData *data)
-{
-    Account *account;
-
-    ENTER("action %p, main window data %p", action, data);
-    account = main_window_to_account(data->window);
-    if (account == NULL)
-    {
-        g_message("No AqBanking account selected");
-        LEAVE("no account");
-        return;
-    }
-
-    gnc_main_window = data->window;
-    gnc_ab_maketrans(GTK_WIDGET(data->window), account,
-                     SINGLE_INTERNAL_TRANSFER);
-
-    LEAVE(" ");
-}
-
-static void
-gnc_plugin_ab_cmd_issue_direct_debit(GtkAction *action,
-                                     GncMainWindowActionData *data)
-{
-    Account *account;
-
-    ENTER("action %p, main window data %p", action, data);
-    account = main_window_to_account(data->window);
-    if (account == NULL)
-    {
-        g_message("No AqBanking account selected");
-        LEAVE("no account");
-        return;
-    }
-
-    gnc_main_window = data->window;
-    gnc_ab_maketrans(GTK_WIDGET(data->window), account, SINGLE_DEBITNOTE);
-
-    LEAVE(" ");
-}
-
-static void
-gnc_plugin_ab_cmd_issue_sepa_direct_debit(GtkAction *action,
-                                          GncMainWindowActionData *data)
-{
-    Account *account;
-
-    ENTER("action %p, main window data %p", action, data);
-    account = main_window_to_account(data->window);
-    if (account == NULL)
-    {
-        g_message("No AqBanking account selected");
-        LEAVE("no account");
-        return;
-    }
-
-    gnc_main_window = data->window;
-    gnc_ab_maketrans(GTK_WIDGET(data->window), account, SEPA_DEBITNOTE);
-
-    LEAVE(" ");
-}
-
-static void
-gnc_plugin_ab_cmd_view_logwindow(GtkToggleAction *action, GncMainWindow *window)
-{
-    if (gtk_toggle_action_get_active(GTK_TOGGLE_ACTION(action)))
-    {
-        if (!gnc_GWEN_Gui_show_dialog())
-        {
-            /* Log window could not be made visible */
-            gtk_toggle_action_set_active(GTK_TOGGLE_ACTION(action), FALSE);
-        }
-    }
-    else
-    {
-        gnc_GWEN_Gui_hide_dialog();
-    }
-}
-
-
-static void
-gnc_plugin_ab_cmd_mt940_import(GtkAction *action, GncMainWindowActionData *data)
-{
-    gchar *format = gnc_prefs_get_string(GNC_PREFS_GROUP_AQBANKING,
-                                         GNC_PREF_FORMAT_SWIFT940);
-    gnc_main_window = data->window;
-    gnc_file_aqbanking_import("swift", format ? format : "swift-mt940", FALSE);
-    g_free(format);
-}
-
-static void
-gnc_plugin_ab_cmd_mt942_import(GtkAction *action, GncMainWindowActionData *data)
-{
-    gchar *format = gnc_prefs_get_string(GNC_PREFS_GROUP_AQBANKING,
-                                         GNC_PREF_FORMAT_SWIFT942);
-    gnc_main_window = data->window;
-    gnc_file_aqbanking_import("swift", format ? format : "swift-mt942", FALSE);
-    g_free(format);
-}
-
-static void
-gnc_plugin_ab_cmd_dtaus_import(GtkAction *action, GncMainWindowActionData *data)
-{
-    gchar *format = gnc_prefs_get_string(GNC_PREFS_GROUP_AQBANKING,
-                                         GNC_PREF_FORMAT_DTAUS);
-    gnc_main_window = data->window;
-    gnc_file_aqbanking_import("dtaus", format ? format : "default", FALSE);
-    g_free(format);
-}
-
-static void
-gnc_plugin_ab_cmd_dtaus_importsend(GtkAction *action,
-                                   GncMainWindowActionData *data)
-{
-    gchar *format = gnc_prefs_get_string(GNC_PREFS_GROUP_AQBANKING,
-                                         GNC_PREF_FORMAT_DTAUS);
-    gnc_main_window = data->window;
-    gnc_file_aqbanking_import("dtaus", format ? format : "default", TRUE);
-    g_free(format);
-}
-
-/************************************************************
- *                    Plugin Bootstrapping                  *
- ************************************************************/
-
-void
-gnc_plugin_aqbanking_create_plugin(void)
-{
-    GncPlugin *plugin = gnc_plugin_aqbanking_new();
-
-    gnc_plugin_manager_add_plugin(gnc_plugin_manager_get(), plugin);
-}

Deleted: gnucash/trunk/src/import-export/aqbanking/gnc-plugin-aqbanking.h
===================================================================
--- gnucash/trunk/src/import-export/aqbanking/gnc-plugin-aqbanking.h	2013-12-15 17:20:10 UTC (rev 23566)
+++ gnucash/trunk/src/import-export/aqbanking/gnc-plugin-aqbanking.h	2013-12-15 17:21:20 UTC (rev 23567)
@@ -1,90 +0,0 @@
-/*
- * gnc-plugin-aqbanking.h --
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation; either version 2 of
- * the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, contact:
- *
- * Free Software Foundation           Voice:  +1-617-542-5942
- * 51 Franklin Street, Fifth Floor    Fax:    +1-617-542-2652
- * Boston, MA  02110-1301,  USA       gnu at gnu.org
- */
-
-/**
- * @addtogroup Import_Export
- * @{
- * @addtogroup AqBanking
- * @{
- * @file gnc-plugin-aqbanking.h
- * @brief Plugin registration of the AqBanking module
- * @author Copyright (C) 2003 David Hampton <hampton at employees.org>
- * @author Copyright (C) 2008 Andreas Koehler <andi5.py at gmx.net>
- */
-
-#ifndef GNC_PLUGIN_AQBANKING_H
-#define GNC_PLUGIN_AQBANKING_H
-
-#include <glib.h>
-
-#include "gnc-plugin.h"
-
-G_BEGIN_DECLS
-
-/* type macros */
-#define GNC_TYPE_PLUGIN_AQBANKING            (gnc_plugin_aqbanking_get_type())
-#define GNC_PLUGIN_AQBANKING(obj)            (G_TYPE_CHECK_INSTANCE_CAST((obj), GNC_TYPE_PLUGIN_AQBANKING, GncPluginAqBanking))
-#define GNC_PLUGIN_AQBANKING_CLASS(klass)    (G_TYPE_CHECK_CLASS_CAST((klass), GNC_TYPE_PLUGIN_AQBANKING, GncPluginAqBankingClass))
-#define GNC_IS_PLUGIN_AQBANKING(obj)         (G_TYPE_CHECK_INSTANCE_TYPE((obj), GNC_TYPE_PLUGIN_AQBANKING))
-#define GNC_IS_PLUGIN_AQBANKING_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), GNC_TYPE_PLUGIN_AQBANKING))
-#define GNC_PLUGIN_AQBANKING_GET_CLASS(obj)  (G_TYPE_INSTANCE_GET_CLASS((obj), GNC_TYPE_PLUGIN_AQBANKING, GncPluginAqBankingClass))
-
-#define GNC_PLUGIN_AQBANKING_NAME "gnc-plugin-aqbanking"
-
-/* typedefs & structures */
-typedef struct
-{
-    GncPlugin gnc_plugin;
-} GncPluginAqBanking;
-
-typedef struct
-{
-    GncPluginClass gnc_plugin;
-} GncPluginAqBankingClass;
-
-/* function prototypes */
-
-/**
- * @return The glib runtime type of an aqbanking plugin page
- **/
-GType gnc_plugin_aqbanking_get_type(void);
-
-/**
- * @return A new GncPluginAqBanking object
- */
-GncPlugin* gnc_plugin_aqbanking_new(void);
-
-/**
- * Create a new GncPluginAqBanking object and register it.
- */
-void gnc_plugin_aqbanking_create_plugin(void);
-
-/**
- * Set MENU_TOGGLE_ACTION_AB_VIEW_LOGWINDOW
- */
-void gnc_plugin_aqbanking_set_logwindow_visible(gboolean logwindow_visible);
-
-G_END_DECLS
-
-/** @} */
-/** @} */
-
-#endif /* GNC_PLUGIN_AQBANKING_H */

Deleted: gnucash/trunk/src/import-export/aqbanking/gncmod-aqbanking.c
===================================================================
--- gnucash/trunk/src/import-export/aqbanking/gncmod-aqbanking.c	2013-12-15 17:20:10 UTC (rev 23566)
+++ gnucash/trunk/src/import-export/aqbanking/gncmod-aqbanking.c	2013-12-15 17:21:20 UTC (rev 23567)
@@ -1,97 +0,0 @@
-/*
- * gncmod-aqbanking.c --
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation; either version 2 of
- * the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, contact:
- *
- * Free Software Foundation           Voice:  +1-617-542-5942
- * 51 Franklin Street, Fifth Floor    Fax:    +1-617-542-2652
- * Boston, MA  02110-1301,  USA       gnu at gnu.org
- */
-
-/**
- * @internal
- * @file gncmod-aqbanking.c
- * @brief Module definition/initialization for AqBanking support
- * @author Copyright (C) 2002 Christian Stimming <stimming at tuhh.de>
- * @author Copyright (C) 2008 Andreas Koehler <andi5.py at gmx.net>
- */
-
-#include "config.h"
-#include <glib/gi18n.h>
-
-#include "gnc-ab-utils.h"
-#include "gnc-module.h"
-#include "gnc-module-api.h"
-#include "gnc-plugin-aqbanking.h"
-#include "dialog-preferences.h"
-
-GNC_MODULE_API_DECL(libgncmod_aqbanking)
-
-/* version of the gnc module system interface we require */
-gint libgncmod_aqbanking_gnc_module_system_interface = 0;
-
-/* module versioning uses libtool semantics. */
-gint libgncmod_aqbanking_gnc_module_current  = 0;
-gint libgncmod_aqbanking_gnc_module_revision = 0;
-gint libgncmod_aqbanking_gnc_module_age      = 0;
-
-gchar *
-libgncmod_aqbanking_gnc_module_path(void)
-{
-    return g_strdup("gnucash/import-export/aqbanking");
-}
-
-gchar *
-libgncmod_aqbanking_gnc_module_description(void)
-{
-    return g_strdup("Support for Online Banking protocols");
-}
-
-gint
-libgncmod_aqbanking_gnc_module_init(gint refcount)
-{
-    /* Load modules we depend on */
-    if (!gnc_module_load("gnucash/engine", 0)
-            || !gnc_module_load("gnucash/app-utils", 0)
-            || !gnc_module_load("gnucash/gnome-utils", 0)
-            || !gnc_module_load("gnucash/import-export", 0))
-    {
-        return FALSE;
-    }
-
-    /* Add menu items with C callbacks */
-    gnc_plugin_aqbanking_create_plugin();
-
-
-    /* Add AqBanking preferences to the preferences dialog */
-    gnc_preferences_add_to_page("dialog-ab.glade", "aqbanking_prefs",
-                                _("Online Banking"));
-
-    /* Initialize gwen library */
-    gnc_GWEN_Init();
-
-    return 1;
-}
-
-gint
-libgncmod_aqbanking_gnc_module_end(gint refcount)
-{
-    /* Delete the shared AB_BANKING object */
-    gnc_AB_BANKING_delete(NULL);
-
-    /* Finalize gwen library */
-    gnc_GWEN_Fini();
-
-    return 1;
-}

Deleted: gnucash/trunk/src/import-export/aqbanking/gschemas/Makefile.am
===================================================================
--- gnucash/trunk/src/import-export/aqbanking/gschemas/Makefile.am	2013-12-15 17:20:10 UTC (rev 23566)
+++ gnucash/trunk/src/import-export/aqbanking/gschemas/Makefile.am	2013-12-15 17:21:20 UTC (rev 23567)
@@ -1,10 +0,0 @@
- at INTLTOOL_XML_NOMERGE_RULE@
-
-gschema_in_files = \
-  org.gnucash.dialogs.import.hbci.gschema.xml.in
-
-gsettings_SCHEMAS = $(gschema_in_files:.gschema.xml.in=.gschema.xml)
-
- at GSETTINGS_RULES@
-
-CLEANFILES = $(gsettings_SCHEMAS)

Deleted: gnucash/trunk/src/import-export/aqbanking/gschemas/org.gnucash.dialogs.import.hbci.gschema.xml.in.in
===================================================================
--- gnucash/trunk/src/import-export/aqbanking/gschemas/org.gnucash.dialogs.import.hbci.gschema.xml.in.in	2013-12-15 17:20:10 UTC (rev 23566)
+++ gnucash/trunk/src/import-export/aqbanking/gschemas/org.gnucash.dialogs.import.hbci.gschema.xml.in.in	2013-12-15 17:21:20 UTC (rev 23567)
@@ -1,65 +0,0 @@
-<schemalist gettext-domain="@GETTEXT_PACKAGE@">
-  <schema id="org.gnucash.dialogs.ab-initial" path="/org/gnucash/dialogs/ab-initial/">
-    <key name="last-geometry" type="(iiii)">
-      <default>(-1,-1,-1,-1)</default>
-      <summary>Last window position and size</summary>
-      <description>This setting describes the size and position of the window when it was last closed.
-        The numbers are the X and Y coordinates of the top left corner of the window
-        followed by the width and height of the window.</description>
-    </key>
-  </schema>
-
-  <schema id="org.gnucash.dialogs.import.hbci" path="/org/gnucash/dialogs/import/hbci/">
-    <key name="close-on-finish" type="b">
-      <default>true</default>
-      <summary>Close window when finished</summary>
-      <description>If active, the window will be closed automatically when you finish the HBCI/AqBanking import process. Otherwise it will stay open.</description>
-    </key>
-    <key name="remember-pin" type="b">
-      <default>false</default>
-      <summary>Remember the PIN in memory</summary>
-      <description>If active, the PIN for HBCI/AqBanking actions will be remembered in memory during a session. Otherwise it will have to be entered again each time during a session when it is needed.</description>
-    </key>
-    <key name="verbose-debug" type="b">
-      <default>false</default>
-      <summary>Verbose HBCI debug messages</summary>
-      <description>Enables verbose debug messages for HBCI/AqBanking Online Banking.</description>
-    </key>
-    <key name="format-dtaus" type="s">
-      <default>'default'</default>
-      <summary>DTAUS import data format</summary>
-      <description>This setting specifies the data format when importing DTAUS files.  The AqBanking library offers various import formats (called "profiles") of which you can choose one here.</description>
-    </key>
-    <key name="format-csv" type="s">
-      <default>'default'</default>
-      <summary>CSV import data format</summary>
-      <description>This setting specifies the data format when importing CSV files.  The AqBanking library offers various import formats (called "profiles") of which you can choose one here.</description>
-    </key>
-    <key name="format-swift-mt940" type="s">
-      <default>'swift-mt940'</default>
-      <summary>SWIFT MT940 import data format</summary>
-      <description>This setting specifies the data format when importing SWIFT MT940 files.  The AqBanking library offers various import formats (called "profiles") of which you can choose one here.</description>
-    </key>
-    <key name="format-swift-mt942" type="s">
-      <default>'swift-mt942'</default>
-      <summary>SWIFT MT942 import data format</summary>
-      <description>This setting specifies the data format when importing SWIFT MT942 files.  The AqBanking library offers various import formats (called "profiles") of which you can choose one here.</description>
-    </key>
-    <key name="last-path" type="s">
-      <default>''</default>
-      <summary>Last pathname used</summary>
-      <description>This field contains the last pathname used by this window. It will be used as the initial filename/pathname the next time this window is opened.</description>
-    </key>
-    <child name="connection-dialog" schema="org.gnucash.dialogs.import.hbci.connection-dialog"/>
-  </schema>
-
-  <schema id="org.gnucash.dialogs.import.hbci.connection-dialog" path="/org/gnucash/dialogs/import/hbci/connection-dialog/">
-    <key name="last-geometry" type="(iiii)">
-      <default>(-1,-1,-1,-1)</default>
-      <summary>Last window position and size</summary>
-      <description>This setting describes the size and position of the window when it was last closed.
-        The numbers are the X and Y coordinates of the top left corner of the window
-        followed by the width and height of the window.</description>
-    </key>
-  </schema>
-</schemalist>

Deleted: gnucash/trunk/src/import-export/aqbanking/migratable-prefs-aqbanking.xml
===================================================================
--- gnucash/trunk/src/import-export/aqbanking/migratable-prefs-aqbanking.xml	2013-12-15 17:20:10 UTC (rev 23566)
+++ gnucash/trunk/src/import-export/aqbanking/migratable-prefs-aqbanking.xml	2013-12-15 17:21:20 UTC (rev 23567)
@@ -1,45 +0,0 @@
-  <prefsgroup>
-    <gschemaid>org.gnucash.dialogs.import.hbci</gschemaid>
-    <gconfpath>dialogs-import-hbci.xml</gconfpath>
-    
-    <pref>
-      <gschemaname>close-on-finish</gschemaname>
-      <gschematype>b</gschematype>
-      <gconfkey>close_on_finish</gconfkey>
-    </pref>
-    <pref>
-      <gschemaname>remember-pin</gschemaname>
-      <gschematype>b</gschematype>
-      <gconfkey>remember_pin</gconfkey>
-    </pref>
-    <pref>
-      <gschemaname>verbose-debug</gschemaname>
-      <gschematype>b</gschematype>
-      <gconfkey>verbose_debug</gconfkey>
-    </pref>
-    <pref>
-      <gschemaname>format-dtaus</gschemaname>
-      <gschematype>s</gschematype>
-      <gconfkey>format_dtaus</gconfkey>
-    </pref>
-    <pref>
-      <gschemaname>format-csv</gschemaname>
-      <gschematype>s</gschematype>
-      <gconfkey>format_csv</gconfkey>
-    </pref>
-    <pref>
-      <gschemaname>format-swift-mt940</gschemaname>
-      <gschematype>s</gschematype>
-      <gconfkey>format_swift_mt940</gconfkey>
-    </pref>
-    <pref>
-      <gschemaname>format-swift-mt942</gschemaname>
-      <gschematype>s</gschematype>
-      <gconfkey>format_swift_mt942</gconfkey>
-    </pref>
-    <pref>
-      <gschemaname>last-path</gschemaname>
-      <gschematype>s</gschematype>
-      <gconfkey>last_path</gconfkey>
-    </pref>
-  </prefsgroup>

Copied: gnucash/trunk/src/import-export/csv-exp/Makefile.am (from rev 23566, gnucash/trunk/src/import-export/csv-export/Makefile.am)
===================================================================
--- gnucash/trunk/src/import-export/csv-exp/Makefile.am	                        (rev 0)
+++ gnucash/trunk/src/import-export/csv-exp/Makefile.am	2013-12-15 17:21:20 UTC (rev 23567)
@@ -0,0 +1,59 @@
+SUBDIRS = . gschemas
+
+pkglib_LTLIBRARIES=libgncmod-csv-export.la
+
+libgncmod_csv_export_la_SOURCES = \
+  gncmod-csv-export.c \
+  gnc-plugin-csv-export.c \
+  assistant-csv-export.c \
+  csv-tree-export.c \
+  csv-transactions-export.c
+
+noinst_HEADERS = \
+  gnc-plugin-csv-export.h \
+  assistant-csv-export.h \
+  csv-tree-export.h \
+  csv-transactions-export.h
+
+libgncmod_csv_export_la_LDFLAGS = -avoid-version
+
+libgncmod_csv_export_la_LIBADD = \
+  ${top_builddir}/src/import-export/libgncmod-generic-import.la \
+  ${top_builddir}/src/gnome-utils/libgncmod-gnome-utils.la \
+  ${top_builddir}/src/app-utils/libgncmod-app-utils.la \
+  ${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}/lib/stf/libgnc-stf.la \
+  ${top_builddir}/lib/libc/libc-missing.la \
+  ${top_builddir}/src/libqof/qof/libgnc-qof.la \
+  ${GOFFICE_LIBS} \
+  ${GLIB_LIBS}
+
+AM_CPPFLAGS = \
+  -I${top_srcdir}/src \
+  -I${top_srcdir}/src/core-utils \
+  -I${top_srcdir}/src/engine \
+  -I${top_srcdir}/src/gnc-module \
+  -I${top_srcdir}/src/app-utils \
+  -I${top_srcdir}/src/gnome \
+  -I${top_srcdir}/src/gnome-utils \
+  -I${top_srcdir}/src/import-export \
+  -I${top_srcdir}/src/libqof/qof \
+  -I${top_srcdir}/lib/libc \
+  -I${top_srcdir}/lib \
+  ${GUILE_CFLAGS} \
+  ${GLIB_CFLAGS} \
+  $(GOFFICE_CFLAGS)
+
+uidir = $(GNC_UI_DIR)
+ui_DATA = \
+	gnc-plugin-csv-export-ui.xml
+
+gtkbuilderdir = ${GNC_GTKBUILDER_DIR}
+gtkbuilder_DATA = \
+	assistant-csv-export.glade
+
+EXTRA_DIST = $(ui_DATA) $(gtkbuilder_DATA)
+
+AM_CPPFLAGS += -DG_LOG_DOMAIN=\"gnc.export.csv\"

Copied: gnucash/trunk/src/import-export/csv-exp/assistant-csv-export.c (from rev 23566, gnucash/trunk/src/import-export/csv-export/assistant-csv-export.c)
===================================================================
--- gnucash/trunk/src/import-export/csv-exp/assistant-csv-export.c	                        (rev 0)
+++ gnucash/trunk/src/import-export/csv-exp/assistant-csv-export.c	2013-12-15 17:21:20 UTC (rev 23567)
@@ -0,0 +1,1035 @@
+/*******************************************************************\
+ * assistant-csv-export.c -- An assistant for exporting Accounts    *
+ *                            and Transactions to a file            *
+ *                                                                  *
+ * Copyright (C) 2012 Robert Fewell                                 *
+ *                                                                  *
+ * This program is free software; you can redistribute it and/or    *
+ * modify it under the terms of the GNU General Public License as   *
+ * published by the Free Software Foundation; either version 2 of   *
+ * the License, or (at your option) any later version.              *
+ *                                                                  *
+ * This program is distributed in the hope that it will be useful,  *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of   *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the    *
+ * GNU General Public License for more details.                     *
+ *                                                                  *
+ * You should have received a copy of the GNU General Public License*
+ * along with this program; if not, contact:                        *
+ *                                                                  *
+ * Free Software Foundation           Voice:  +1-617-542-5942       *
+ * 51 Franklin Street, Fifth Floor    Fax:    +1-617-542-2652       *
+ * Boston, MA  02110-1301,  USA       gnu at gnu.org                   *
+\********************************************************************/
+/** @file assistant-csv-export.c
+    @brief CSV Export Assistant
+    @author Copyright (c) 2012 Robert Fewell
+*/
+#include "config.h"
+
+#include <gtk/gtk.h>
+#include <glib/gi18n.h>
+
+#include "gnc-ui.h"
+#include "gnc-uri-utils.h"
+#include "gnc-component-manager.h"
+#include "gnc-date-edit.h"
+#include "gnc-prefs.h"
+#include "gnc-tree-view-account.h"
+#include "dialog-utils.h"
+#include "Query.h"
+#include "Transaction.h"
+
+#include "assistant-utils.h"
+#include "assistant-csv-export.h"
+#include "csv-tree-export.h"
+#include "csv-transactions-export.h"
+
+#define GNC_PREFS_GROUP    "dialogs.export.csv"
+#define GNC_PREF_PANED_POS "paned-position"
+#define ASSISTANT_CSV_EXPORT_CM_CLASS "assistant-csv-export"
+
+/* This static indicates the debugging module that this .o belongs to.  */
+static QofLogModule log_module = GNC_MOD_ASSISTANT;
+
+/*************************************************************************/
+
+void csv_export_assistant_prepare (GtkAssistant  *assistant, GtkWidget *page, gpointer user_data);
+void csv_export_assistant_finish (GtkAssistant *gtkassistant, gpointer user_data);
+void csv_export_assistant_cancel (GtkAssistant *gtkassistant, gpointer user_data);
+void csv_export_assistant_close (GtkAssistant *gtkassistant, gpointer user_data);
+
+void csv_export_assistant_start_page_prepare (GtkAssistant *assistant, gpointer user_data);
+void csv_export_assistant_account_page_prepare (GtkAssistant *gtkassistant, gpointer user_data);
+void csv_export_assistant_file_page_prepare (GtkAssistant *assistant, gpointer user_data);
+void csv_export_assistant_finish_page_prepare (GtkAssistant *assistant, gpointer user_data);
+void csv_export_assistant_summary_page_prepare (GtkAssistant *assistant, gpointer user_data);
+
+void csv_export_quote_cb (GtkToggleButton *button, gpointer user_data );
+void csv_export_sep_cb (GtkWidget *radio, gpointer user_data );
+void csv_export_custom_entry_cb (GtkWidget *widget, gpointer user_data );
+
+void csv_export_show_range_cb (GtkRadioButton *button, gpointer user_data);
+void csv_export_start_date_cb (GtkWidget *radio, gpointer user_data);
+void csv_export_end_date_cb (GtkWidget *radio, gpointer user_data);
+
+void csv_export_file_chooser_confirm_cb (GtkWidget *button, CsvExportInfo *info);
+
+static const gchar *finish_tree_string = N_(
+            /* Translators: %s is the file name string. */
+            "The account tree will be exported to the file '%s' when you click 'Apply'.\n\n"
+            "You can also go back and verify your selections by clicking on 'Back'"
+            " or 'Cancel' to Abort Export.\n");
+
+static const gchar *finish_trans_string = N_(
+            /* Translators: %s is the file name string and %u the number of accounts. */
+            "When you click 'Apply', the transactions will be exported to the file '%s' and"
+            " the number of accounts exported is %u.\n\n"
+            "You can also go back and verify your selections by clicking on 'Back'"
+            " or 'Cancel' to Abort Export.\n");
+
+static const gchar *start_tree_string = N_(
+        "This assistant will help you export the Account Tree to a file.\n\n"
+        "Select the settings you require for the file and then click 'Forward' to proceed"
+        " or 'Cancel' to Abort Export.\n");
+
+static const gchar *start_trans_string = N_(
+            "This assistant will help you export the Transactions to a file.\n\n"
+            "Select the settings you require for the file and then click 'Forward' to proceed"
+            " or 'Cancel' to Abort Export.\n");
+
+
+/**************************************************
+ * csv_export_file_chooser_confirm_cb
+ *
+ * call back for ok button in file chooser widget
+ **************************************************/
+void
+csv_export_file_chooser_confirm_cb (GtkWidget *button, CsvExportInfo *info)
+{
+    GtkAssistant *assistant = GTK_ASSISTANT(info->window);
+    gint num = gtk_assistant_get_current_page (assistant);
+    GtkWidget *page = gtk_assistant_get_nth_page (assistant, num);
+
+    gchar *file_name;
+
+    gtk_assistant_set_page_complete (assistant, page, FALSE);
+
+    file_name = gtk_file_chooser_get_filename ( GTK_FILE_CHOOSER(info->file_chooser ));
+
+    if (file_name)
+    {
+        if (g_file_test(file_name, G_FILE_TEST_EXISTS ))
+        {
+            const char *format = _("The file %s already exists. "
+                                   "Are you sure you want to overwrite it?");
+
+            /* if user says cancel, we should break out */
+            if (!gnc_verify_dialog (NULL, FALSE, format, file_name))
+                return;
+        }
+
+        info->file_name = g_strdup(file_name);
+        gtk_assistant_set_page_complete (assistant, page, TRUE);
+    }
+
+    if (file_name)
+    {
+        gchar *filepath = gnc_uri_get_path ( file_name );
+        gchar *filedir = g_path_get_dirname( filepath );
+        info->starting_dir = g_strdup(filedir);
+        g_free ( filedir );
+        g_free ( filepath );
+    }
+    g_free(file_name);
+
+    DEBUG("file_name selected is %s", info->file_name);
+    DEBUG("starting directory is %s", info->starting_dir);
+
+    /* Step to next page if page is complete */
+    if(gtk_assistant_get_page_complete(assistant, page))
+        gtk_assistant_set_current_page (assistant, num + 1);
+}
+
+
+/*******************************************************
+ * csv_export_sep_cb
+ *
+ * call back for type of separartor required
+ *******************************************************/
+void csv_export_sep_cb (GtkWidget *radio, gpointer user_data )
+{
+    CsvExportInfo *info = user_data;
+    const gchar *name;
+
+    GtkAssistant *assistant = GTK_ASSISTANT(info->window);
+    gint num = gtk_assistant_get_current_page (assistant);
+    GtkWidget *page = gtk_assistant_get_nth_page (assistant, num);
+
+    if (!gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(radio)))
+    {
+        LEAVE("1st callback of pair. Defer to 2nd callback.");
+        return;
+    }
+
+    name = gtk_buildable_get_name(GTK_BUILDABLE(radio));
+
+    gtk_widget_set_sensitive(info->custom_entry, FALSE);
+    info->use_custom = FALSE;
+    gtk_assistant_set_page_complete (assistant, page, TRUE);
+
+    if (g_strcmp0(name, "comma_radio") == 0)
+        info->separator_str = ",";
+    if (g_strcmp0(name, "colon_radio") == 0)
+        info->separator_str = ":";
+    if (g_strcmp0(name, "semicolon_radio") == 0)
+        info->separator_str = ";";
+
+    if (g_strcmp0(name, "custom_radio") == 0)
+    {
+        gtk_widget_set_sensitive(info->custom_entry, TRUE);
+        info->use_custom = TRUE;
+        if (gtk_entry_get_text_length (GTK_ENTRY(info->custom_entry)) == 0)
+            gtk_assistant_set_page_complete (assistant, page, FALSE);
+    }
+}
+
+
+/*******************************************************
+ * csv_export_quote_cb
+ *
+ * call back for use of quotes
+ *******************************************************/
+void csv_export_quote_cb (GtkToggleButton *button, gpointer user_data )
+{
+    CsvExportInfo *info = user_data;
+
+    if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(button)))
+        info->use_quotes = TRUE;
+    else
+        info->use_quotes = FALSE;
+}
+
+
+/*******************************************************
+ * csv_export_custom_entry_cb
+ *
+ * call back for custom separator
+ *******************************************************/
+void csv_export_custom_entry_cb (GtkWidget *widget, gpointer user_data )
+{
+    CsvExportInfo *info = user_data;
+    const gchar *custom_str;
+
+    GtkAssistant *assistant = GTK_ASSISTANT(info->window);
+    gint num = gtk_assistant_get_current_page (assistant);
+    GtkWidget *page = gtk_assistant_get_nth_page (assistant, num);
+
+    custom_str = gtk_entry_get_text(GTK_ENTRY(info->custom_entry));
+    info->separator_str = strdup(custom_str);
+
+    if (info->use_custom == TRUE && gtk_entry_get_text_length (GTK_ENTRY(info->custom_entry)) == 0)
+
+        gtk_assistant_set_page_complete (assistant, page, FALSE);
+    else
+        gtk_assistant_set_page_complete (assistant, page, TRUE);
+}
+
+
+/*******************************************************
+ * load_settings
+ *
+ * load the default settings for the assistant
+ *******************************************************/
+static
+void load_settings (CsvExportInfo *info)
+{
+    info->use_quotes = TRUE;
+    info->separator_str = ",";
+    info->file_name = NULL;
+    info->starting_dir = NULL;
+
+    /* The default directory for the user to select files. */
+    info->starting_dir = gnc_get_default_directory(GNC_PREFS_GROUP);
+}
+
+/* =============================================================== */
+
+/*******************************************************
+ * csv_export_cursor_changed_cb
+ *
+ * call back for cursor selection in account tree
+ *******************************************************/
+static void
+csv_export_cursor_changed_cb (GtkWidget *widget, gpointer user_data)
+{
+    CsvExportInfo *info = user_data;
+    GncTreeViewAccount *account_tree;
+    Account *account;
+    gint num_children;
+
+    account_tree = GNC_TREE_VIEW_ACCOUNT (info->csva.account_treeview);
+    account = gnc_tree_view_account_get_cursor_account (account_tree);
+    if (!account)
+    {
+        gtk_widget_set_sensitive(info->csva.select_button, FALSE);
+        return;
+    }
+    num_children = gnc_tree_view_account_count_children(account_tree, account);
+    gtk_widget_set_sensitive(info->csva.select_button, num_children > 0);
+}
+
+
+/*******************************************************
+ * show_acct_type_accounts
+ *
+ * show required accounts in account tree
+ *******************************************************/
+static void
+show_acct_type_accounts (CsvExportInfo *info)
+{
+    GncTreeViewAccount *tree;
+    AccountViewInfo Viewinfo;
+    GNCAccountType type;
+
+    tree = GNC_TREE_VIEW_ACCOUNT (info->csva.account_treeview);
+
+    gnc_tree_view_account_get_view_info (tree, &Viewinfo);
+
+    for (type = 0; type < NUM_ACCOUNT_TYPES; type++) /* from Account.h */
+    {
+        if (info->csva.account_type == ACCT_TYPE_EXPENSE)
+            Viewinfo.include_type[type] = (type == ACCT_TYPE_EXPENSE);
+        else if (info->csva.account_type == ACCT_TYPE_INCOME)
+            Viewinfo.include_type[type] = (type == ACCT_TYPE_INCOME);
+        else if (info->csva.account_type == ACCT_TYPE_ASSET)
+            Viewinfo.include_type[type] = ((type == ACCT_TYPE_BANK)  ||
+                                           (type == ACCT_TYPE_CASH)      ||
+                                           (type == ACCT_TYPE_ASSET)     ||
+                                           (type == ACCT_TYPE_STOCK)     ||
+                                           (type == ACCT_TYPE_MUTUAL)    ||
+                                           (type == ACCT_TYPE_RECEIVABLE));
+        else if (info->csva.account_type == ACCT_TYPE_LIABILITY)
+            Viewinfo.include_type[type] = ((type == ACCT_TYPE_CREDIT) ||
+                                           (type == ACCT_TYPE_LIABILITY) ||
+                                           (type == ACCT_TYPE_EQUITY)    ||
+                                           (type == ACCT_TYPE_PAYABLE));
+        else
+            Viewinfo.include_type[type] = FALSE;
+    }
+    gnc_tree_view_account_set_view_info (tree, &Viewinfo);
+    csv_export_cursor_changed_cb(GTK_WIDGET(tree), info);
+}
+
+
+/*******************************************************
+ * account_filter_func
+ *
+ * update filter for account tree
+ *******************************************************/
+static gboolean
+account_filter_func (Account *account, gpointer user_data)
+{
+    CsvExportInfo *info = user_data;
+    gboolean included = FALSE;
+
+    if ((info->csva.account_type == ACCT_TYPE_INCOME) ||
+            (info->csva.account_type == ACCT_TYPE_EXPENSE))
+        included = (xaccAccountGetType (account) == info->csva.account_type);
+    else if (info->csva.account_type == ACCT_TYPE_ASSET)
+        included = ((xaccAccountGetType (account) == ACCT_TYPE_BANK) ||
+                    (xaccAccountGetType (account) == ACCT_TYPE_CASH) ||
+                    (xaccAccountGetType (account) == ACCT_TYPE_ASSET) ||
+                    (xaccAccountGetType (account) == ACCT_TYPE_STOCK) ||
+                    (xaccAccountGetType (account) == ACCT_TYPE_MUTUAL) ||
+                    (xaccAccountGetType (account) == ACCT_TYPE_RECEIVABLE));
+    else if (info->csva.account_type == ACCT_TYPE_LIABILITY)
+        included = ((xaccAccountGetType (account) == ACCT_TYPE_CREDIT) ||
+                    (xaccAccountGetType (account) == ACCT_TYPE_LIABILITY) ||
+                    (xaccAccountGetType (account) == ACCT_TYPE_EQUITY) ||
+                    (xaccAccountGetType (account) == ACCT_TYPE_PAYABLE));
+    else
+        included = FALSE;
+    return included;
+}
+
+
+/*******************************************************
+ * update_accounts_tree
+ *
+ * update the account tree
+ *******************************************************/
+static int
+update_accounts_tree (CsvExportInfo *info)
+{
+    GncTreeViewAccount *tree;
+    GtkTreeSelection* selection;
+    GtkWidget *label;
+    int num_accounts;
+    char *string;
+
+    tree = GNC_TREE_VIEW_ACCOUNT(info->csva.account_treeview);
+    selection = gtk_tree_view_get_selection (GTK_TREE_VIEW(tree));
+    num_accounts = gtk_tree_selection_count_selected_rows (selection);
+
+    label = info->csva.num_acct_label;
+
+    string = g_strdup_printf ("%d", num_accounts);
+    gtk_label_set_text (GTK_LABEL (label), string);
+    g_free (string);
+
+    return num_accounts;
+}
+
+
+/*******************************************************
+ * csv_export_account_changed_cb
+ *
+ * update account list after selection changed
+ *******************************************************/
+static void
+csv_export_account_changed_cb (GtkTreeSelection *selection,
+                               gpointer user_data)
+{
+    CsvExportInfo *info = user_data;
+    GtkAssistant *assistant = GTK_ASSISTANT(info->window);
+    gint num = gtk_assistant_get_current_page (assistant);
+    GtkWidget *page = gtk_assistant_get_nth_page (assistant, num);
+
+    GncTreeViewAccount *view;
+
+    g_return_if_fail(GTK_IS_TREE_SELECTION(selection));
+
+    info->csva.num_accounts = update_accounts_tree (info);
+
+    /* Enable the Forward Assistant Button if we have accounts */
+    if (info->csva.num_accounts > 0)
+        gtk_assistant_set_page_complete (assistant, page, TRUE);
+    else
+        gtk_assistant_set_page_complete (assistant, page, FALSE);
+
+    view = GNC_TREE_VIEW_ACCOUNT(info->csva.account_treeview);
+    info->csva.account_list = gnc_tree_view_account_get_selected_accounts (view);
+}
+
+
+/*******************************************************
+ * csv_export_select_subaccounts_clicked_cb
+ *
+ * select all the sub accounts
+ *******************************************************/
+static void
+csv_export_select_subaccounts_clicked_cb (GtkWidget *widget, gpointer user_data)
+{
+    CsvExportInfo *info = user_data;
+    GncTreeViewAccount *account_tree;
+    Account *account;
+
+    account_tree = GNC_TREE_VIEW_ACCOUNT (info->csva.account_treeview);
+    account = gnc_tree_view_account_get_cursor_account (account_tree);
+    if (!account)
+        return;
+
+    gnc_tree_view_account_select_subaccounts (account_tree, account);
+
+    gtk_widget_grab_focus (info->csva.account_treeview);
+}
+
+
+/*******************************************************
+ * csv_export_info_acct_type_cb
+ *
+ * select which type of accounts to display
+ *******************************************************/
+static void
+csv_export_info_acct_type_cb (GtkWidget *w, gpointer user_data)
+{
+    CsvExportInfo *info = user_data;
+    const gchar *button_name;
+
+    if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (w)))
+    {
+        button_name = gtk_buildable_get_name(GTK_BUILDABLE(w));
+        if (g_strcmp0 (button_name, "income_radio") == 0)
+            info->csva.account_type = ACCT_TYPE_INCOME;
+        else if (g_strcmp0 (button_name, "expense_radio") == 0)
+            info->csva.account_type = ACCT_TYPE_EXPENSE;
+        else if (g_strcmp0 (button_name, "asset_radio") == 0)
+            info->csva.account_type = ACCT_TYPE_ASSET;
+        else if (g_strcmp0 (button_name, "liab_eq_radio") == 0)
+            info->csva.account_type = ACCT_TYPE_LIABILITY;
+        else
+            return;
+
+        show_acct_type_accounts (info);
+        gnc_tree_view_account_refilter
+        (GNC_TREE_VIEW_ACCOUNT (info->csva.account_treeview));
+        update_accounts_tree (info);
+    }
+    else
+        return;
+}
+
+/* =============================================================== */
+
+/*******************************************************
+ * get_filter_times
+ *
+ * get the start and end times from the dialog
+ *******************************************************/
+static void
+get_filter_times (CsvExportInfo *info)
+{
+    time64 time_val;
+
+    if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(info->csvd.start_date_choose)))
+    {
+        time_val = gnc_date_edit_get_date(GNC_DATE_EDIT(info->csvd.start_date));
+        time_val = gnc_time64_get_day_start(time_val);
+        info->csvd.start_time = time_val;
+    }
+    else
+    {
+        if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(info->csvd.start_date_today)))
+        {
+            info->csvd.start_time = gnc_time64_get_today_start();
+        }
+        else
+        {
+            info->csvd.start_time = 0;
+        }
+    }
+
+    if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(info->csvd.end_date_choose)))
+    {
+        time_val = gnc_date_edit_get_date(GNC_DATE_EDIT(info->csvd.end_date));
+        time_val = gnc_time64_get_day_end(time_val);
+        info->csvd.end_time = time_val;
+    }
+    else
+    {
+        if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(info->csvd.start_date_today)))
+        {
+            info->csvd.end_time = gnc_time64_get_today_end();
+        }
+        else
+        {
+            info->csvd.end_time = gnc_time (NULL);
+        }
+    }
+}
+
+
+/*******************************************************
+ * csv_export_show_range_cb
+ *
+ * call back for show range button
+ *******************************************************/
+void
+csv_export_show_range_cb (GtkRadioButton *button, gpointer user_data)
+{
+    CsvExportInfo *info = user_data;
+    gboolean active;
+
+    g_return_if_fail(GTK_IS_RADIO_BUTTON(button));
+
+    active = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(button));
+    gtk_widget_set_sensitive(info->csvd.table, active);
+}
+
+
+/*******************************************************
+ * csv_export_date_changed_cb
+ *
+ * call back for when a date changes
+ *******************************************************/
+static void
+csv_export_date_changed_cb (GtkWidget *w, gpointer user_data)
+{
+    CsvExportInfo *info = user_data;
+
+    get_filter_times(info);
+}
+
+
+/*******************************************************
+ * csv_export_start_date_cb
+ *
+ * call back for when the start date changes
+ *******************************************************/
+void
+csv_export_start_date_cb (GtkWidget *radio, gpointer user_data)
+{
+    CsvExportInfo *info = user_data;
+    const gchar *name;
+    gboolean active;
+
+    g_return_if_fail(GTK_IS_RADIO_BUTTON(radio));
+
+    if (!gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(radio)))
+    {
+        LEAVE("1st callback of pair. Defer to 2nd callback.");
+        return;
+    }
+
+    name = gtk_buildable_get_name(GTK_BUILDABLE(radio));
+    active = ( g_strcmp0(name, g_strdup("start_date_choose")) == 0 ? 1 : 0 );
+    gtk_widget_set_sensitive(info->csvd.start_date, active);
+    get_filter_times(info);
+}
+
+
+/*******************************************************
+ * csv_export_end_date_cb
+ *
+ * call back for when the end date changes
+ *******************************************************/
+void
+csv_export_end_date_cb (GtkWidget *radio, gpointer user_data)
+{
+    CsvExportInfo *info = user_data;
+    const gchar *name;
+    gboolean active;
+
+    g_return_if_fail(GTK_IS_RADIO_BUTTON(radio));
+
+    if (!gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(radio)))
+    {
+        LEAVE("1st callback of pair. Defer to 2nd callback.");
+        return;
+    }
+
+    name = gtk_buildable_get_name(GTK_BUILDABLE(radio));
+    active = ( g_strcmp0(name, g_strdup("end_date_choose")) == 0 ? 1 : 0 );
+    gtk_widget_set_sensitive(info->csvd.end_date, active);
+    get_filter_times(info);
+}
+
+
+/*******************************************************************
+ * get_earliest_in_book
+ *
+ * Find the earliest date occuring in the book.  Do this by making
+ * a query and sorting by date. Since the truncated sort returns
+ * only the *last* search results, sort in decreasing order.
+ *******************************************************************/
+static time64
+get_earliest_in_book (QofBook *book)
+{
+    QofQuery *q;
+    GSList *p1, *p2;
+    GList *res;
+    time64 earliest;
+
+    q = qof_query_create_for(GNC_ID_SPLIT);
+    qof_query_set_max_results(q, 1);
+    qof_query_set_book (q, book);
+
+    /* Sort by transaction date */
+    p1 = g_slist_prepend (NULL, TRANS_DATE_POSTED);
+    p1 = g_slist_prepend (p1, SPLIT_TRANS);
+    p2 = g_slist_prepend (NULL, QUERY_DEFAULT_SORT);
+    qof_query_set_sort_order (q, p1, p2, NULL);
+
+    /* Reverse the sort order */
+    qof_query_set_sort_increasing (q, FALSE, FALSE, FALSE);
+
+    /* Run the query, find the earliest transaction date */
+    res = qof_query_run (q);
+
+    if (res)
+    {
+        earliest = xaccQueryGetEarliestDateFound (q);
+    }
+    else
+    {
+        /* If no results, we don't want to bomb totally */
+        earliest = gnc_time (0);
+    }
+
+    qof_query_destroy (q);
+    return earliest;
+}
+
+
+/* =============================================================== */
+
+
+/*******************************************************
+ * Assistant page prepare functions
+ *******************************************************/
+void
+csv_export_assistant_start_page_prepare (GtkAssistant *assistant,
+        gpointer user_data)
+{
+    CsvExportInfo *info = user_data;
+    gint num = gtk_assistant_get_current_page (assistant);
+    GtkWidget *page = gtk_assistant_get_nth_page (assistant, num);
+
+    /* Set Start page text */
+    if (info->export_type == XML_EXPORT_TREE)
+        gtk_label_set_text (GTK_LABEL(info->start_label), gettext (start_tree_string));
+    else
+        gtk_label_set_text (GTK_LABEL(info->start_label), gettext (start_trans_string));
+
+    /* Enable the Assistant Buttons */
+    gtk_assistant_set_page_complete (assistant, page, TRUE);
+}
+
+
+void
+csv_export_assistant_account_page_prepare (GtkAssistant *assistant,
+        gpointer user_data)
+{
+    CsvExportInfo *info = user_data;
+    gint num = gtk_assistant_get_current_page (assistant);
+    GtkWidget *page = gtk_assistant_get_nth_page (assistant, num);
+
+    /* If we are doing tree export, step over account select page */
+    if (info->export_type == XML_EXPORT_TREE)
+        gtk_assistant_set_current_page (assistant, num + 1 );
+
+    /* Enable the Forward Assistant Button if we have accounts */
+    if (info->csva.num_accounts > 0)
+        gtk_assistant_set_page_complete (assistant, page, TRUE);
+    else
+        gtk_assistant_set_page_complete (assistant, page, FALSE);
+}
+
+
+void
+csv_export_assistant_file_page_prepare (GtkAssistant *assistant,
+                                        gpointer user_data)
+{
+    CsvExportInfo *info = user_data;
+    gint num = gtk_assistant_get_current_page (assistant);
+    GtkWidget *page = gtk_assistant_get_nth_page (assistant, num);
+
+    /* Set the default directory */
+    if (info->starting_dir)
+        gtk_file_chooser_set_current_folder(GTK_FILE_CHOOSER(info->file_chooser), info->starting_dir);
+    gtk_file_chooser_set_current_name (GTK_FILE_CHOOSER(info->file_chooser), "");
+
+    /* Disable the Forward Assistant Button */
+    gtk_assistant_set_page_complete (assistant, page, FALSE);
+}
+
+
+void
+csv_export_assistant_finish_page_prepare (GtkAssistant *assistant,
+        gpointer user_data)
+{
+    CsvExportInfo *info = user_data;
+    gint num = gtk_assistant_get_current_page (assistant);
+    GtkWidget *page = gtk_assistant_get_nth_page (assistant, num);
+    gchar *text;
+
+    /* Set Finish page text */
+    if (info->export_type == XML_EXPORT_TREE)
+        text = g_strdup_printf (gettext (finish_tree_string), info->file_name);
+    else
+        text = g_strdup_printf (gettext (finish_trans_string), info->file_name, info->csva.num_accounts);
+
+    gtk_label_set_text (GTK_LABEL(info->finish_label), text);
+    g_free(text);
+
+    /* Enable the Assistant Buttons */
+    gtk_assistant_set_page_complete (assistant, page, TRUE);
+}
+
+
+void
+csv_export_assistant_summary_page_prepare (GtkAssistant *assistant,
+        gpointer user_data)
+{
+    CsvExportInfo *info = user_data;
+    gchar *text, *mtext;
+    gnc_set_default_directory(GNC_PREFS_GROUP, info->starting_dir);
+
+    if (info->failed)
+        text = _("There was a problem with the export, this could be due to lack of space, "
+                 "permissions or unable to access folder. Check the trace file for further logging!\n"
+                 "You may need to enable debugging.\n");
+    else
+        text = _("File exported successfully!\n");
+
+    mtext = g_strdup_printf("<span size=\"medium\"><b>%s</b></span>", text);
+
+    gtk_label_set_markup(GTK_LABEL(info->summary_label), mtext);
+
+    g_free(mtext);
+}
+
+
+void
+csv_export_assistant_prepare (GtkAssistant *assistant, GtkWidget *page,
+                              gpointer user_data)
+{
+    gint currentpage = gtk_assistant_get_current_page(assistant);
+
+    switch (currentpage)
+    {
+    case 0:
+        /* Current page is Start page */
+        csv_export_assistant_start_page_prepare (assistant, user_data);
+        break;
+    case 1:
+        /* Current page is Account select page */
+        csv_export_assistant_account_page_prepare (assistant, user_data);
+        break;
+    case 2:
+        /* Current page is file select page */
+        csv_export_assistant_file_page_prepare (assistant, user_data);
+        break;
+    case 3:
+        /* Current page is Finish page */
+        csv_export_assistant_finish_page_prepare (assistant, user_data);
+        break;
+    case 4:
+        /* Current page is Summary page */
+        csv_export_assistant_summary_page_prepare (assistant, user_data);
+        break;
+    }
+}
+
+
+/*******************************************************
+ * Assistant call back functions
+ *******************************************************/
+static void
+csv_export_assistant_destroy_cb (GtkObject *object, gpointer user_data)
+{
+    CsvExportInfo *info = user_data;
+    gnc_unregister_gui_component_by_data (ASSISTANT_CSV_EXPORT_CM_CLASS, info);
+    g_free (info);
+}
+
+void
+csv_export_assistant_cancel (GtkAssistant *assistant, gpointer user_data)
+{
+    CsvExportInfo *info = user_data;
+    gnc_close_gui_component_by_data (ASSISTANT_CSV_EXPORT_CM_CLASS, info);
+}
+
+void
+csv_export_assistant_close (GtkAssistant *assistant, gpointer user_data)
+{
+    CsvExportInfo *info = user_data;
+    gnc_close_gui_component_by_data (ASSISTANT_CSV_EXPORT_CM_CLASS, info);
+}
+
+void
+csv_export_assistant_finish (GtkAssistant *assistant, gpointer user_data)
+{
+    CsvExportInfo *info = user_data;
+
+    if (info->export_type == XML_EXPORT_TREE)
+        csv_tree_export (info);
+    else
+        csv_transactions_export (info);
+}
+
+static void
+csv_export_close_handler (gpointer user_data)
+{
+    CsvExportInfo *info = user_data;
+
+    g_free(info->file_name);
+    g_free(info->starting_dir);
+
+    gnc_save_window_size(GNC_PREFS_GROUP, GTK_WINDOW(info->window));
+    gtk_widget_destroy (info->window);
+}
+
+/*******************************************************
+ * Create the Assistant
+ *******************************************************/
+static GtkWidget *
+csv_export_assistant_create (CsvExportInfo *info)
+{
+    GtkBuilder *builder;
+    GtkWidget *window;
+    GtkWidget *box, *h_box;
+    GtkWidget *button;
+    GtkWidget *table, *hbox;
+    time64 start_time, end_time;
+
+    builder = gtk_builder_new();
+    gnc_builder_add_from_file  (builder , "assistant-csv-export.glade", "CSV Export Assistant");
+    window = GTK_WIDGET(gtk_builder_get_object (builder, "CSV Export Assistant"));
+    info->window = window;
+
+    /* Set the assistant colors */
+    gnc_assistant_set_colors (GTK_ASSISTANT (info->window));
+
+    /* Load default settings */
+    load_settings (info);
+
+    /* Start Page */
+    info->start_label = GTK_WIDGET(gtk_builder_get_object(builder, "start_label"));
+    info->custom_entry = GTK_WIDGET(gtk_builder_get_object(builder, "custom_entry"));
+    gtk_widget_set_sensitive(info->custom_entry, FALSE);
+
+    /* Account Page */
+    {
+        GtkTreeView *tree_view;
+        GtkTreeSelection *selection;
+        GtkWidget *income_radio, *expense_radio, *asset_radio,
+                  *liab_eq_radio, *box, *label;
+
+        info->csva.acct_info = GTK_WIDGET(gtk_builder_get_object (builder, "acct_info_vbox"));
+        info->csva.num_acct_label = GTK_WIDGET(gtk_builder_get_object (builder, "num_accounts_label"));
+
+        tree_view = gnc_tree_view_account_new (FALSE);
+        gnc_tree_view_account_set_filter (GNC_TREE_VIEW_ACCOUNT(tree_view),
+                                          account_filter_func, info, NULL);
+        info->csva.account_treeview = GTK_WIDGET(tree_view);
+
+        selection = gtk_tree_view_get_selection (tree_view);
+        gtk_tree_selection_set_mode (selection, GTK_SELECTION_EXTENDED);
+        g_signal_connect (G_OBJECT (selection), "changed",
+                          G_CALLBACK (csv_export_account_changed_cb), info);
+
+        gtk_widget_show (info->csva.account_treeview);
+        box = GTK_WIDGET(gtk_builder_get_object (builder, "account_scroll"));
+        gtk_container_add (GTK_CONTAINER (box), info->csva.account_treeview);
+
+        label = GTK_WIDGET(gtk_builder_get_object (builder, "accounts_label"));
+        gtk_label_set_mnemonic_widget(GTK_LABEL(label), GTK_WIDGET(tree_view));
+
+        income_radio = GTK_WIDGET(gtk_builder_get_object (builder, "income_radio"));
+        expense_radio = GTK_WIDGET(gtk_builder_get_object (builder, "expense_radio"));
+        info->csva.expense_radio = expense_radio;
+        asset_radio = GTK_WIDGET(gtk_builder_get_object (builder, "asset_radio"));
+        info->csva.asset_radio = asset_radio;
+        liab_eq_radio = GTK_WIDGET(gtk_builder_get_object (builder, "liab_eq_radio"));
+        info->csva.liab_eq_radio = liab_eq_radio;
+        info->csva.account_type = ACCT_TYPE_EXPENSE;
+        gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(expense_radio), TRUE);
+
+        g_signal_connect (G_OBJECT (income_radio), "toggled",
+                          G_CALLBACK  (csv_export_info_acct_type_cb), info);
+        g_signal_connect (G_OBJECT (expense_radio), "toggled",
+                          G_CALLBACK  (csv_export_info_acct_type_cb), info);
+        g_signal_connect (G_OBJECT (asset_radio), "toggled",
+                          G_CALLBACK  (csv_export_info_acct_type_cb), info);
+        g_signal_connect (G_OBJECT (liab_eq_radio), "toggled",
+                          G_CALLBACK  (csv_export_info_acct_type_cb), info);
+    }
+
+    /* select subaccounts button */
+    {
+        GtkWidget *button;
+
+        button = GTK_WIDGET(gtk_builder_get_object (builder, "select_subaccounts_button"));
+        info->csva.select_button = button;
+
+        g_signal_connect (G_OBJECT (button), "clicked",
+                          G_CALLBACK  (csv_export_select_subaccounts_clicked_cb), info);
+        g_signal_connect (G_OBJECT (info->csva.account_treeview), "cursor_changed",
+                          G_CALLBACK  (csv_export_cursor_changed_cb), info);
+    }
+
+    /* Set the date info */
+    button = GTK_WIDGET(gtk_builder_get_object (builder, "show_range"));
+
+    /* Earliest and Latest in Book */
+    start_time = get_earliest_in_book (gnc_get_current_book());
+    end_time = gnc_time (NULL);
+
+    info->csvd.start_time = start_time;
+    info->csvd.end_time = end_time;
+    gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(button), FALSE);
+
+    table = GTK_WIDGET(gtk_builder_get_object (builder, "select_range_table"));
+    info->csvd.table = table;
+    gtk_widget_set_sensitive(GTK_WIDGET(table), FALSE);
+
+    info->csvd.start_date_choose = GTK_WIDGET(gtk_builder_get_object (builder, "start_date_choose"));
+    info->csvd.start_date_today = GTK_WIDGET(gtk_builder_get_object (builder, "start_date_today"));
+    info->csvd.end_date_choose = GTK_WIDGET(gtk_builder_get_object (builder, "end_date_choose"));
+    info->csvd.end_date_today = GTK_WIDGET(gtk_builder_get_object (builder, "end_date_today"));
+
+    /* Start date info */
+    info->csvd.start_date = gnc_date_edit_new (gnc_time (NULL), FALSE, FALSE);
+    hbox = GTK_WIDGET(gtk_builder_get_object (builder, "start_date_hbox"));
+    gtk_box_pack_start (GTK_BOX (hbox), info->csvd.start_date, TRUE, TRUE, 0);
+    gtk_widget_show (info->csvd.start_date);
+    gnc_date_edit_set_time (GNC_DATE_EDIT(info->csvd.start_date), start_time);
+    g_signal_connect (G_OBJECT (info->csvd.start_date), "date-changed",
+                      G_CALLBACK (csv_export_date_changed_cb), info);
+
+    /* End date info */
+    info->csvd.end_date = gnc_date_edit_new (gnc_time (NULL), FALSE, FALSE);
+    hbox = GTK_WIDGET(gtk_builder_get_object (builder, "end_date_hbox"));
+    gtk_box_pack_start (GTK_BOX (hbox), info->csvd.end_date, TRUE, TRUE, 0);
+    gtk_widget_show (info->csvd.end_date);
+    gnc_date_edit_set_time (GNC_DATE_EDIT(info->csvd.end_date), end_time);
+    g_signal_connect (G_OBJECT (info->csvd.end_date), "date-changed",
+                      G_CALLBACK (csv_export_date_changed_cb), info);
+
+    /* Load Accounts */
+    show_acct_type_accounts (info);
+    update_accounts_tree (info);
+
+    /* File chooser Page */
+    info->file_chooser = gtk_file_chooser_widget_new (GTK_FILE_CHOOSER_ACTION_SAVE);
+    button = gtk_button_new_from_stock(GTK_STOCK_OK);
+    gtk_widget_set_size_request (button, 100, -1);
+    gtk_widget_show (button);
+    h_box = gtk_hbox_new(TRUE, 0);
+    gtk_box_pack_start(GTK_BOX(h_box), button, FALSE, FALSE, 0);
+    gtk_file_chooser_set_extra_widget (GTK_FILE_CHOOSER(info->file_chooser), h_box);
+    g_signal_connect (G_OBJECT (button), "clicked",
+                      G_CALLBACK (csv_export_file_chooser_confirm_cb), info);
+
+
+
+
+    box = GTK_WIDGET(gtk_builder_get_object(builder, "file_page"));
+    gtk_box_pack_start (GTK_BOX (box), info->file_chooser, TRUE, TRUE, 6);
+    gtk_widget_show (info->file_chooser);
+
+    /* Finish Page */
+    info->finish_label = GTK_WIDGET(gtk_builder_get_object(builder, "end_page"));
+
+    /* Summary Page */
+    info->summary_label = GTK_WIDGET(gtk_builder_get_object(builder, "summary_page"));
+
+    g_signal_connect (G_OBJECT(window), "destroy",
+                      G_CALLBACK (csv_export_assistant_destroy_cb), info);
+
+    gnc_restore_window_size (GNC_PREFS_GROUP, GTK_WINDOW(info->window));
+    if (gnc_prefs_get_bool(GNC_PREFS_GROUP_GENERAL, GNC_PREF_SAVE_GEOMETRY))
+    {
+        GObject *object = gtk_builder_get_object (builder, "paned");
+        gnc_prefs_bind (GNC_PREFS_GROUP, GNC_PREF_PANED_POS, object, "position");
+    }
+
+    gtk_builder_connect_signals(builder, info);
+    g_object_unref(G_OBJECT(builder));
+    return window;
+}
+
+
+/********************************************************************\
+ * gnc_file_csv_export                                              *
+ * opens up a assistant to export accounts or transactions based on *
+ * the type.                                                        *
+ * Args:   export_type                                              *
+ * Return: nothing                                                  *
+\********************************************************************/
+void
+gnc_file_csv_export (CsvExportType export_type)
+{
+    CsvExportInfo *info;
+
+    info = g_new0 (CsvExportInfo, 1);
+    info->export_type = export_type;
+    csv_export_assistant_create (info);
+    gnc_register_gui_component (ASSISTANT_CSV_EXPORT_CM_CLASS,
+                                NULL, csv_export_close_handler,
+                                info);
+    gtk_widget_show_all (info->window);
+    gnc_window_adjust_for_screen (GTK_WINDOW(info->window));
+}

Copied: gnucash/trunk/src/import-export/csv-exp/assistant-csv-export.glade (from rev 23566, gnucash/trunk/src/import-export/csv-export/assistant-csv-export.glade)
===================================================================
--- gnucash/trunk/src/import-export/csv-exp/assistant-csv-export.glade	                        (rev 0)
+++ gnucash/trunk/src/import-export/csv-exp/assistant-csv-export.glade	2013-12-15 17:21:20 UTC (rev 23567)
@@ -0,0 +1,913 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<interface>
+  <requires lib="gtk+" version="2.16"/>
+  <!-- interface-naming-policy project-wide -->
+  <object class="GtkAssistant" id="CSV Export Assistant">
+    <property name="can_focus">False</property>
+    <property name="border_width">12</property>
+    <property name="title" translatable="yes">CSV Export Assistant</property>
+    <property name="default_width">400</property>
+    <property name="default_height">500</property>
+    <signal name="close" handler="csv_export_assistant_close" swapped="no"/>
+    <signal name="apply" handler="csv_export_assistant_finish" swapped="no"/>
+    <signal name="prepare" handler="csv_export_assistant_prepare" swapped="no"/>
+    <signal name="cancel" handler="csv_export_assistant_cancel" swapped="no"/>
+    <child>
+      <object class="GtkVBox" id="start_page">
+        <property name="visible">True</property>
+        <property name="can_focus">False</property>
+        <property name="border_width">12</property>
+        <child>
+          <object class="GtkLabel" id="start_label">
+            <property name="visible">True</property>
+            <property name="can_focus">False</property>
+            <property name="label" translatable="yes">
+Select the type of Export required and the separator that will be used.
+</property>
+            <property name="justify">center</property>
+            <property name="wrap">True</property>
+          </object>
+          <packing>
+            <property name="expand">False</property>
+            <property name="fill">False</property>
+            <property name="position">0</property>
+          </packing>
+        </child>
+        <child>
+          <placeholder/>
+        </child>
+        <child>
+          <object class="GtkHSeparator" id="hseparator1">
+            <property name="visible">True</property>
+            <property name="can_focus">False</property>
+          </object>
+          <packing>
+            <property name="expand">False</property>
+            <property name="fill">True</property>
+            <property name="padding">6</property>
+            <property name="position">2</property>
+          </packing>
+        </child>
+        <child>
+          <placeholder/>
+        </child>
+        <child>
+          <object class="GtkFrame" id="frame1">
+            <property name="visible">True</property>
+            <property name="can_focus">False</property>
+            <property name="border_width">6</property>
+            <property name="label_xalign">0</property>
+            <property name="shadow_type">none</property>
+            <child>
+              <object class="GtkAlignment" id="alignment1">
+                <property name="visible">True</property>
+                <property name="can_focus">False</property>
+                <property name="left_padding">20</property>
+                <child>
+                  <object class="GtkTable" id="table1">
+                    <property name="visible">True</property>
+                    <property name="can_focus">False</property>
+                    <property name="n_columns">3</property>
+                    <property name="column_spacing">3</property>
+                    <property name="row_spacing">3</property>
+                    <child>
+                      <object class="GtkCheckButton" id="quote_tbutton">
+                        <property name="label" translatable="yes">Quotes</property>
+                        <property name="visible">True</property>
+                        <property name="can_focus">True</property>
+                        <property name="receives_default">False</property>
+                        <property name="use_action_appearance">False</property>
+                        <property name="active">True</property>
+                        <property name="draw_indicator">True</property>
+                        <signal name="toggled" handler="csv_export_quote_cb" swapped="no"/>
+                      </object>
+                      <packing>
+                        <property name="y_options">GTK_FILL</property>
+                      </packing>
+                    </child>
+                    <child>
+                      <placeholder/>
+                    </child>
+                    <child>
+                      <placeholder/>
+                    </child>
+                  </object>
+                </child>
+              </object>
+            </child>
+            <child type="label">
+              <object class="GtkLabel" id="label1">
+                <property name="visible">True</property>
+                <property name="can_focus">False</property>
+                <property name="label" translatable="yes">Use Quotes</property>
+                <property name="use_markup">True</property>
+              </object>
+            </child>
+          </object>
+          <packing>
+            <property name="expand">False</property>
+            <property name="fill">True</property>
+            <property name="position">4</property>
+          </packing>
+        </child>
+        <child>
+          <object class="GtkFrame" id="frame2">
+            <property name="visible">True</property>
+            <property name="can_focus">False</property>
+            <property name="border_width">6</property>
+            <property name="label_xalign">0</property>
+            <property name="shadow_type">none</property>
+            <child>
+              <object class="GtkAlignment" id="alignment2">
+                <property name="visible">True</property>
+                <property name="can_focus">False</property>
+                <property name="left_padding">20</property>
+                <child>
+                  <object class="GtkTable" id="table2">
+                    <property name="visible">True</property>
+                    <property name="can_focus">False</property>
+                    <property name="n_rows">2</property>
+                    <property name="n_columns">3</property>
+                    <property name="column_spacing">3</property>
+                    <property name="row_spacing">3</property>
+                    <property name="homogeneous">True</property>
+                    <child>
+                      <object class="GtkRadioButton" id="comma_radio">
+                        <property name="label" translatable="yes">Comma (,)</property>
+                        <property name="visible">True</property>
+                        <property name="can_focus">True</property>
+                        <property name="receives_default">False</property>
+                        <property name="use_action_appearance">False</property>
+                        <property name="active">True</property>
+                        <property name="draw_indicator">True</property>
+                        <signal name="toggled" handler="csv_export_sep_cb" swapped="no"/>
+                      </object>
+                      <packing>
+                        <property name="y_options">GTK_FILL</property>
+                      </packing>
+                    </child>
+                    <child>
+                      <object class="GtkRadioButton" id="colon_radio">
+                        <property name="label" translatable="yes">Colon (:)</property>
+                        <property name="visible">True</property>
+                        <property name="can_focus">True</property>
+                        <property name="receives_default">False</property>
+                        <property name="use_action_appearance">False</property>
+                        <property name="active">True</property>
+                        <property name="draw_indicator">True</property>
+                        <property name="group">comma_radio</property>
+                        <signal name="toggled" handler="csv_export_sep_cb" swapped="no"/>
+                      </object>
+                      <packing>
+                        <property name="left_attach">1</property>
+                        <property name="right_attach">2</property>
+                        <property name="x_options">GTK_FILL</property>
+                        <property name="y_options">GTK_FILL</property>
+                      </packing>
+                    </child>
+                    <child>
+                      <object class="GtkRadioButton" id="semicolon_radio">
+                        <property name="label" translatable="yes">Semicolon (;)</property>
+                        <property name="visible">True</property>
+                        <property name="can_focus">True</property>
+                        <property name="receives_default">False</property>
+                        <property name="use_action_appearance">False</property>
+                        <property name="active">True</property>
+                        <property name="draw_indicator">True</property>
+                        <property name="group">comma_radio</property>
+                        <signal name="toggled" handler="csv_export_sep_cb" swapped="no"/>
+                      </object>
+                      <packing>
+                        <property name="left_attach">2</property>
+                        <property name="right_attach">3</property>
+                        <property name="x_options">GTK_FILL</property>
+                        <property name="y_options">GTK_FILL</property>
+                      </packing>
+                    </child>
+                    <child>
+                      <object class="GtkRadioButton" id="custom_radio">
+                        <property name="label" translatable="yes">Custom</property>
+                        <property name="visible">True</property>
+                        <property name="can_focus">True</property>
+                        <property name="receives_default">False</property>
+                        <property name="use_action_appearance">False</property>
+                        <property name="active">True</property>
+                        <property name="draw_indicator">True</property>
+                        <property name="group">comma_radio</property>
+                        <signal name="toggled" handler="csv_export_sep_cb" swapped="no"/>
+                      </object>
+                      <packing>
+                        <property name="top_attach">1</property>
+                        <property name="bottom_attach">2</property>
+                        <property name="x_options">GTK_FILL</property>
+                        <property name="y_options">GTK_FILL</property>
+                      </packing>
+                    </child>
+                    <child>
+                      <object class="GtkEntry" id="custom_entry">
+                        <property name="visible">True</property>
+                        <property name="can_focus">True</property>
+                        <property name="invisible_char">&#x25CF;</property>
+                        <property name="invisible_char_set">True</property>
+                        <property name="primary_icon_activatable">False</property>
+                        <property name="secondary_icon_activatable">False</property>
+                        <property name="primary_icon_sensitive">True</property>
+                        <property name="secondary_icon_sensitive">True</property>
+                        <signal name="changed" handler="csv_export_custom_entry_cb" swapped="no"/>
+                      </object>
+                      <packing>
+                        <property name="left_attach">1</property>
+                        <property name="right_attach">3</property>
+                        <property name="top_attach">1</property>
+                        <property name="bottom_attach">2</property>
+                        <property name="x_options">GTK_FILL</property>
+                        <property name="y_options">GTK_FILL</property>
+                      </packing>
+                    </child>
+                  </object>
+                </child>
+              </object>
+            </child>
+            <child type="label">
+              <object class="GtkLabel" id="label2">
+                <property name="visible">True</property>
+                <property name="can_focus">False</property>
+                <property name="label" translatable="yes">Separators</property>
+                <property name="use_markup">True</property>
+              </object>
+            </child>
+          </object>
+          <packing>
+            <property name="expand">False</property>
+            <property name="fill">True</property>
+            <property name="position">5</property>
+          </packing>
+        </child>
+      </object>
+      <packing>
+        <property name="page_type">intro</property>
+        <property name="title" translatable="yes">Choose Export Settings</property>
+        <property name="complete">True</property>
+      </packing>
+    </child>
+    <child>
+      <object class="GtkVBox" id="account_page">
+        <property name="visible">True</property>
+        <property name="can_focus">False</property>
+        <property name="border_width">12</property>
+        <child>
+          <object class="GtkLabel" id="label5">
+            <property name="visible">True</property>
+            <property name="can_focus">False</property>
+            <property name="label" translatable="yes">Select the accounts to be exported and date range if required.</property>
+            <property name="wrap">True</property>
+          </object>
+          <packing>
+            <property name="expand">False</property>
+            <property name="fill">False</property>
+            <property name="position">0</property>
+          </packing>
+        </child>
+        <child>
+          <object class="GtkHPaned" id="paned">
+            <property name="visible">True</property>
+            <property name="can_focus">True</property>
+            <property name="position">1</property>
+            <child>
+              <object class="GtkVBox" id="acct_info_vbox">
+                <property name="visible">True</property>
+                <property name="can_focus">False</property>
+                <property name="border_width">6</property>
+                <child>
+                  <object class="GtkLabel" id="accounts_label">
+                    <property name="visible">True</property>
+                    <property name="can_focus">False</property>
+                    <property name="xalign">0</property>
+                    <property name="ypad">2</property>
+                    <property name="label" translatable="yes"><b>_Accounts</b></property>
+                    <property name="use_markup">True</property>
+                    <property name="use_underline">True</property>
+                  </object>
+                  <packing>
+                    <property name="expand">False</property>
+                    <property name="fill">False</property>
+                    <property name="position">0</property>
+                  </packing>
+                </child>
+                <child>
+                  <object class="GtkAlignment" id="alignment3">
+                    <property name="visible">True</property>
+                    <property name="can_focus">False</property>
+                    <property name="left_padding">12</property>
+                    <child>
+                      <object class="GtkVBox" id="vbox96">
+                        <property name="visible">True</property>
+                        <property name="can_focus">False</property>
+                        <child>
+                          <object class="GtkTable" id="table3">
+                            <property name="visible">True</property>
+                            <property name="can_focus">False</property>
+                            <property name="n_rows">2</property>
+                            <property name="n_columns">2</property>
+                            <child>
+                              <object class="GtkRadioButton" id="income_radio">
+                                <property name="label" translatable="yes">_Income</property>
+                                <property name="visible">True</property>
+                                <property name="can_focus">True</property>
+                                <property name="receives_default">False</property>
+                                <property name="use_action_appearance">False</property>
+                                <property name="use_underline">True</property>
+                                <property name="active">True</property>
+                                <property name="draw_indicator">True</property>
+                              </object>
+                            </child>
+                            <child>
+                              <object class="GtkRadioButton" id="expense_radio">
+                                <property name="label" translatable="yes">_Expense</property>
+                                <property name="visible">True</property>
+                                <property name="can_focus">True</property>
+                                <property name="receives_default">False</property>
+                                <property name="use_action_appearance">False</property>
+                                <property name="use_underline">True</property>
+                                <property name="draw_indicator">True</property>
+                                <property name="group">income_radio</property>
+                              </object>
+                              <packing>
+                                <property name="left_attach">1</property>
+                                <property name="right_attach">2</property>
+                              </packing>
+                            </child>
+                            <child>
+                              <object class="GtkRadioButton" id="asset_radio">
+                                <property name="label" translatable="yes">_Asset</property>
+                                <property name="visible">True</property>
+                                <property name="can_focus">True</property>
+                                <property name="receives_default">False</property>
+                                <property name="use_action_appearance">False</property>
+                                <property name="use_underline">True</property>
+                                <property name="draw_indicator">True</property>
+                                <property name="group">income_radio</property>
+                              </object>
+                              <packing>
+                                <property name="top_attach">1</property>
+                                <property name="bottom_attach">2</property>
+                              </packing>
+                            </child>
+                            <child>
+                              <object class="GtkRadioButton" id="liab_eq_radio">
+                                <property name="label" translatable="yes">_Liability/Equity</property>
+                                <property name="visible">True</property>
+                                <property name="can_focus">True</property>
+                                <property name="receives_default">False</property>
+                                <property name="use_action_appearance">False</property>
+                                <property name="use_underline">True</property>
+                                <property name="draw_indicator">True</property>
+                                <property name="group">income_radio</property>
+                              </object>
+                              <packing>
+                                <property name="left_attach">1</property>
+                                <property name="right_attach">2</property>
+                                <property name="top_attach">1</property>
+                                <property name="bottom_attach">2</property>
+                              </packing>
+                            </child>
+                          </object>
+                          <packing>
+                            <property name="expand">False</property>
+                            <property name="fill">True</property>
+                            <property name="position">0</property>
+                          </packing>
+                        </child>
+                        <child>
+                          <object class="GtkScrolledWindow" id="account_scroll">
+                            <property name="visible">True</property>
+                            <property name="can_focus">True</property>
+                            <property name="hscrollbar_policy">automatic</property>
+                            <property name="vscrollbar_policy">automatic</property>
+                            <property name="shadow_type">in</property>
+                            <child>
+                              <placeholder/>
+                            </child>
+                          </object>
+                          <packing>
+                            <property name="expand">True</property>
+                            <property name="fill">True</property>
+                            <property name="position">1</property>
+                          </packing>
+                        </child>
+                        <child>
+                          <object class="GtkHBox" id="hbox98">
+                            <property name="visible">True</property>
+                            <property name="can_focus">False</property>
+                            <property name="border_width">3</property>
+                            <property name="spacing">2</property>
+                            <child>
+                              <object class="GtkLabel" id="label42">
+                                <property name="visible">True</property>
+                                <property name="can_focus">False</property>
+                              </object>
+                              <packing>
+                                <property name="expand">True</property>
+                                <property name="fill">False</property>
+                                <property name="position">0</property>
+                              </packing>
+                            </child>
+                            <child>
+                              <object class="GtkLabel" id="label847733">
+                                <property name="visible">True</property>
+                                <property name="can_focus">False</property>
+                                <property name="xalign">1</property>
+                                <property name="label" translatable="yes">Accounts Selected:</property>
+                                <property name="justify">center</property>
+                              </object>
+                              <packing>
+                                <property name="expand">False</property>
+                                <property name="fill">False</property>
+                                <property name="position">1</property>
+                              </packing>
+                            </child>
+                            <child>
+                              <object class="GtkLabel" id="num_accounts_label">
+                                <property name="visible">True</property>
+                                <property name="can_focus">False</property>
+                                <property name="label" translatable="yes">0</property>
+                                <property name="justify">center</property>
+                              </object>
+                              <packing>
+                                <property name="expand">False</property>
+                                <property name="fill">False</property>
+                                <property name="position">2</property>
+                              </packing>
+                            </child>
+                            <child>
+                              <object class="GtkLabel" id="label43">
+                                <property name="visible">True</property>
+                                <property name="can_focus">False</property>
+                              </object>
+                              <packing>
+                                <property name="expand">True</property>
+                                <property name="fill">False</property>
+                                <property name="position">3</property>
+                              </packing>
+                            </child>
+                          </object>
+                          <packing>
+                            <property name="expand">False</property>
+                            <property name="fill">True</property>
+                            <property name="position">2</property>
+                          </packing>
+                        </child>
+                        <child>
+                          <object class="GtkHButtonBox" id="hbox99">
+                            <property name="visible">True</property>
+                            <property name="can_focus">False</property>
+                            <child>
+                              <object class="GtkButton" id="select_subaccounts_button">
+                                <property name="visible">True</property>
+                                <property name="can_focus">True</property>
+                                <property name="receives_default">True</property>
+                                <property name="border_width">3</property>
+                                <property name="use_action_appearance">False</property>
+                                <child>
+                                  <object class="GtkAlignment" id="alignment5">
+                                    <property name="visible">True</property>
+                                    <property name="can_focus">False</property>
+                                    <property name="xscale">0</property>
+                                    <property name="yscale">0</property>
+                                    <child>
+                                      <object class="GtkHBox" id="hbox100">
+                                        <property name="visible">True</property>
+                                        <property name="can_focus">False</property>
+                                        <property name="spacing">2</property>
+                                        <child>
+                                          <object class="GtkImage" id="image1">
+                                            <property name="visible">True</property>
+                                            <property name="can_focus">False</property>
+                                            <property name="stock">gtk-add</property>
+                                          </object>
+                                          <packing>
+                                            <property name="expand">False</property>
+                                            <property name="fill">False</property>
+                                            <property name="position">0</property>
+                                          </packing>
+                                        </child>
+                                        <child>
+                                          <object class="GtkLabel" id="label847737">
+                                            <property name="visible">True</property>
+                                            <property name="can_focus">False</property>
+                                            <property name="label" translatable="yes">_Select Subaccounts</property>
+                                            <property name="use_underline">True</property>
+                                          </object>
+                                          <packing>
+                                            <property name="expand">False</property>
+                                            <property name="fill">False</property>
+                                            <property name="position">1</property>
+                                          </packing>
+                                        </child>
+                                      </object>
+                                    </child>
+                                  </object>
+                                </child>
+                              </object>
+                              <packing>
+                                <property name="expand">False</property>
+                                <property name="fill">False</property>
+                                <property name="position">0</property>
+                              </packing>
+                            </child>
+                          </object>
+                          <packing>
+                            <property name="expand">False</property>
+                            <property name="fill">True</property>
+                            <property name="position">3</property>
+                          </packing>
+                        </child>
+                      </object>
+                    </child>
+                  </object>
+                  <packing>
+                    <property name="expand">True</property>
+                    <property name="fill">True</property>
+                    <property name="position">1</property>
+                  </packing>
+                </child>
+              </object>
+              <packing>
+                <property name="resize">False</property>
+                <property name="shrink">False</property>
+              </packing>
+            </child>
+            <child>
+              <object class="GtkVBox" id="date_vbox">
+                <property name="visible">True</property>
+                <property name="can_focus">False</property>
+                <property name="border_width">12</property>
+                <child>
+                  <object class="GtkLabel" id="label847680">
+                    <property name="visible">True</property>
+                    <property name="can_focus">False</property>
+                    <property name="xalign">0</property>
+                    <property name="label" translatable="yes"><b>_Dates</b></property>
+                    <property name="use_markup">True</property>
+                    <property name="use_underline">True</property>
+                  </object>
+                  <packing>
+                    <property name="expand">False</property>
+                    <property name="fill">False</property>
+                    <property name="position">0</property>
+                  </packing>
+                </child>
+                <child>
+                  <object class="GtkRadioButton" id="show_all">
+                    <property name="label" translatable="yes">Show _All</property>
+                    <property name="visible">True</property>
+                    <property name="can_focus">True</property>
+                    <property name="receives_default">False</property>
+                    <property name="use_action_appearance">False</property>
+                    <property name="use_underline">True</property>
+                    <property name="active">True</property>
+                    <property name="draw_indicator">True</property>
+                  </object>
+                  <packing>
+                    <property name="expand">False</property>
+                    <property name="fill">False</property>
+                    <property name="position">1</property>
+                  </packing>
+                </child>
+                <child>
+                  <object class="GtkRadioButton" id="show_range">
+                    <property name="label" translatable="yes">Select Range:</property>
+                    <property name="visible">True</property>
+                    <property name="can_focus">True</property>
+                    <property name="receives_default">False</property>
+                    <property name="use_action_appearance">False</property>
+                    <property name="use_underline">True</property>
+                    <property name="draw_indicator">True</property>
+                    <property name="group">show_all</property>
+                    <signal name="toggled" handler="csv_export_show_range_cb" swapped="no"/>
+                  </object>
+                  <packing>
+                    <property name="expand">False</property>
+                    <property name="fill">False</property>
+                    <property name="position">2</property>
+                  </packing>
+                </child>
+                <child>
+                  <object class="GtkTable" id="select_range_table">
+                    <property name="visible">True</property>
+                    <property name="can_focus">False</property>
+                    <property name="n_rows">7</property>
+                    <property name="n_columns">3</property>
+                    <property name="column_spacing">6</property>
+                    <child>
+                      <object class="GtkLabel" id="label847682">
+                        <property name="visible">True</property>
+                        <property name="can_focus">False</property>
+                        <property name="xalign">0</property>
+                        <property name="label" translatable="yes">Start:</property>
+                      </object>
+                      <packing>
+                        <property name="x_options">GTK_FILL</property>
+                        <property name="y_options"></property>
+                        <property name="x_padding">12</property>
+                      </packing>
+                    </child>
+                    <child>
+                      <object class="GtkRadioButton" id="start_date_earliest">
+                        <property name="label" translatable="yes">_Earliest</property>
+                        <property name="visible">True</property>
+                        <property name="can_focus">True</property>
+                        <property name="receives_default">False</property>
+                        <property name="use_action_appearance">False</property>
+                        <property name="use_underline">True</property>
+                        <property name="active">True</property>
+                        <property name="draw_indicator">True</property>
+                        <signal name="clicked" handler="csv_export_start_date_cb" swapped="no"/>
+                      </object>
+                      <packing>
+                        <property name="left_attach">1</property>
+                        <property name="right_attach">2</property>
+                        <property name="x_options">GTK_FILL</property>
+                        <property name="y_options"></property>
+                      </packing>
+                    </child>
+                    <child>
+                      <object class="GtkRadioButton" id="end_date_choose">
+                        <property name="label" translatable="yes">Choo_se Date:</property>
+                        <property name="visible">True</property>
+                        <property name="can_focus">True</property>
+                        <property name="receives_default">False</property>
+                        <property name="use_action_appearance">False</property>
+                        <property name="use_underline">True</property>
+                        <property name="draw_indicator">True</property>
+                        <signal name="clicked" handler="csv_export_end_date_cb" swapped="no"/>
+                      </object>
+                      <packing>
+                        <property name="left_attach">1</property>
+                        <property name="right_attach">2</property>
+                        <property name="top_attach">6</property>
+                        <property name="bottom_attach">7</property>
+                        <property name="x_options">GTK_FILL</property>
+                        <property name="y_options"></property>
+                      </packing>
+                    </child>
+                    <child>
+                      <object class="GtkRadioButton" id="end_date_today">
+                        <property name="label" translatable="yes">Toda_y</property>
+                        <property name="visible">True</property>
+                        <property name="can_focus">True</property>
+                        <property name="receives_default">False</property>
+                        <property name="use_action_appearance">False</property>
+                        <property name="use_underline">True</property>
+                        <property name="draw_indicator">True</property>
+                        <property name="group">end_date_choose</property>
+                        <signal name="clicked" handler="csv_export_end_date_cb" swapped="no"/>
+                      </object>
+                      <packing>
+                        <property name="left_attach">1</property>
+                        <property name="right_attach">2</property>
+                        <property name="top_attach">5</property>
+                        <property name="bottom_attach">6</property>
+                        <property name="x_options">GTK_FILL</property>
+                        <property name="y_options"></property>
+                      </packing>
+                    </child>
+                    <child>
+                      <object class="GtkRadioButton" id="end_date_latest">
+                        <property name="label" translatable="yes">_Latest</property>
+                        <property name="visible">True</property>
+                        <property name="can_focus">True</property>
+                        <property name="receives_default">False</property>
+                        <property name="use_action_appearance">False</property>
+                        <property name="use_underline">True</property>
+                        <property name="active">True</property>
+                        <property name="draw_indicator">True</property>
+                        <property name="group">end_date_choose</property>
+                        <signal name="clicked" handler="csv_export_end_date_cb" swapped="no"/>
+                      </object>
+                      <packing>
+                        <property name="left_attach">1</property>
+                        <property name="right_attach">2</property>
+                        <property name="top_attach">4</property>
+                        <property name="bottom_attach">5</property>
+                        <property name="x_options">GTK_FILL</property>
+                        <property name="y_options"></property>
+                      </packing>
+                    </child>
+                    <child>
+                      <object class="GtkLabel" id="label847683">
+                        <property name="visible">True</property>
+                        <property name="can_focus">False</property>
+                        <property name="xalign">0</property>
+                      </object>
+                      <packing>
+                        <property name="top_attach">3</property>
+                        <property name="bottom_attach">4</property>
+                        <property name="x_options">GTK_FILL</property>
+                        <property name="y_options"></property>
+                      </packing>
+                    </child>
+                    <child>
+                      <object class="GtkLabel" id="label847684">
+                        <property name="visible">True</property>
+                        <property name="can_focus">False</property>
+                        <property name="xalign">0</property>
+                        <property name="label" translatable="yes">End:</property>
+                      </object>
+                      <packing>
+                        <property name="top_attach">4</property>
+                        <property name="bottom_attach">5</property>
+                        <property name="x_options">GTK_FILL</property>
+                        <property name="y_options"></property>
+                        <property name="x_padding">12</property>
+                      </packing>
+                    </child>
+                    <child>
+                      <object class="GtkRadioButton" id="start_date_choose">
+                        <property name="label" translatable="yes">C_hoose Date:</property>
+                        <property name="visible">True</property>
+                        <property name="can_focus">True</property>
+                        <property name="receives_default">False</property>
+                        <property name="use_action_appearance">False</property>
+                        <property name="use_underline">True</property>
+                        <property name="draw_indicator">True</property>
+                        <property name="group">start_date_earliest</property>
+                        <signal name="clicked" handler="csv_export_start_date_cb" swapped="no"/>
+                      </object>
+                      <packing>
+                        <property name="left_attach">1</property>
+                        <property name="right_attach">2</property>
+                        <property name="top_attach">2</property>
+                        <property name="bottom_attach">3</property>
+                        <property name="x_options">GTK_FILL</property>
+                        <property name="y_options"></property>
+                      </packing>
+                    </child>
+                    <child>
+                      <object class="GtkRadioButton" id="start_date_today">
+                        <property name="label" translatable="yes">_Today</property>
+                        <property name="visible">True</property>
+                        <property name="can_focus">True</property>
+                        <property name="receives_default">False</property>
+                        <property name="use_action_appearance">False</property>
+                        <property name="use_underline">True</property>
+                        <property name="draw_indicator">True</property>
+                        <property name="group">start_date_earliest</property>
+                        <signal name="clicked" handler="csv_export_start_date_cb" swapped="no"/>
+                      </object>
+                      <packing>
+                        <property name="left_attach">1</property>
+                        <property name="right_attach">2</property>
+                        <property name="top_attach">1</property>
+                        <property name="bottom_attach">2</property>
+                        <property name="x_options">GTK_FILL</property>
+                        <property name="y_options"></property>
+                      </packing>
+                    </child>
+                    <child>
+                      <object class="GtkHBox" id="start_date_hbox">
+                        <property name="visible">True</property>
+                        <property name="can_focus">False</property>
+                        <child>
+                          <placeholder/>
+                        </child>
+                      </object>
+                      <packing>
+                        <property name="left_attach">2</property>
+                        <property name="right_attach">3</property>
+                        <property name="top_attach">2</property>
+                        <property name="bottom_attach">3</property>
+                        <property name="x_options"></property>
+                      </packing>
+                    </child>
+                    <child>
+                      <object class="GtkHBox" id="end_date_hbox">
+                        <property name="visible">True</property>
+                        <property name="can_focus">False</property>
+                        <child>
+                          <placeholder/>
+                        </child>
+                      </object>
+                      <packing>
+                        <property name="left_attach">2</property>
+                        <property name="right_attach">3</property>
+                        <property name="top_attach">6</property>
+                        <property name="bottom_attach">7</property>
+                        <property name="x_options"></property>
+                      </packing>
+                    </child>
+                    <child>
+                      <placeholder/>
+                    </child>
+                    <child>
+                      <placeholder/>
+                    </child>
+                    <child>
+                      <placeholder/>
+                    </child>
+                    <child>
+                      <placeholder/>
+                    </child>
+                    <child>
+                      <placeholder/>
+                    </child>
+                    <child>
+                      <placeholder/>
+                    </child>
+                    <child>
+                      <placeholder/>
+                    </child>
+                    <child>
+                      <placeholder/>
+                    </child>
+                    <child>
+                      <placeholder/>
+                    </child>
+                    <child>
+                      <placeholder/>
+                    </child>
+                  </object>
+                  <packing>
+                    <property name="expand">False</property>
+                    <property name="fill">False</property>
+                    <property name="position">3</property>
+                  </packing>
+                </child>
+              </object>
+              <packing>
+                <property name="resize">False</property>
+                <property name="shrink">False</property>
+              </packing>
+            </child>
+          </object>
+          <packing>
+            <property name="expand">True</property>
+            <property name="fill">True</property>
+            <property name="position">1</property>
+          </packing>
+        </child>
+        <child>
+          <placeholder/>
+        </child>
+      </object>
+      <packing>
+        <property name="page_type">progress</property>
+        <property name="title" translatable="yes">Account Selection</property>
+      </packing>
+    </child>
+    <child>
+      <object class="GtkVBox" id="file_page">
+        <property name="visible">True</property>
+        <property name="can_focus">False</property>
+        <property name="border_width">12</property>
+        <child>
+          <object class="GtkLabel" id="label4">
+            <property name="visible">True</property>
+            <property name="can_focus">False</property>
+            <property name="label" translatable="yes">
+Enter file name and location for the Export...
+</property>
+            <property name="wrap">True</property>
+          </object>
+          <packing>
+            <property name="expand">False</property>
+            <property name="fill">False</property>
+            <property name="position">0</property>
+          </packing>
+        </child>
+        <child>
+          <placeholder/>
+        </child>
+      </object>
+      <packing>
+        <property name="title" translatable="yes">Choose File Name for Export</property>
+      </packing>
+    </child>
+    <child>
+      <object class="GtkLabel" id="end_page">
+        <property name="visible">True</property>
+        <property name="can_focus">False</property>
+        <property name="label" translatable="yes">Press Apply to create export file.
+Cancel to abort.</property>
+        <property name="wrap">True</property>
+      </object>
+      <packing>
+        <property name="page_type">confirm</property>
+        <property name="title" translatable="yes">Export Now...</property>
+      </packing>
+    </child>
+    <child>
+      <object class="GtkLabel" id="summary_page">
+        <property name="visible">True</property>
+        <property name="can_focus">False</property>
+        <property name="label" translatable="yes">Summary</property>
+        <property name="wrap">True</property>
+      </object>
+      <packing>
+        <property name="page_type">summary</property>
+        <property name="title" translatable="yes">Export Summary</property>
+        <property name="complete">True</property>
+      </packing>
+    </child>
+  </object>
+</interface>

Copied: gnucash/trunk/src/import-export/csv-exp/assistant-csv-export.h (from rev 23566, gnucash/trunk/src/import-export/csv-export/assistant-csv-export.h)
===================================================================
--- gnucash/trunk/src/import-export/csv-exp/assistant-csv-export.h	                        (rev 0)
+++ gnucash/trunk/src/import-export/csv-exp/assistant-csv-export.h	2013-12-15 17:21:20 UTC (rev 23567)
@@ -0,0 +1,98 @@
+/*******************************************************************\
+ * assistant-csv-export.h -- An assistant for exporting Accounts    *
+ *                            and Transactions to a file            *
+ *                                                                  *
+ * Copyright (C) 2012 Robert Fewell                                 *
+ *                                                                  *
+ * This program is free software; you can redistribute it and/or    *
+ * modify it under the terms of the GNU General Public License as   *
+ * published by the Free Software Foundation; either version 2 of   *
+ * the License, or (at your option) any later version.              *
+ *                                                                  *
+ * This program is distributed in the hope that it will be useful,  *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of   *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the    *
+ * GNU General Public License for more details.                     *
+ *                                                                  *
+ * You should have received a copy of the GNU General Public License*
+ * along with this program; if not, contact:                        *
+ *                                                                  *
+ * Free Software Foundation           Voice:  +1-617-542-5942       *
+ * 51 Franklin Street, Fifth Floor    Fax:    +1-617-542-2652       *
+ * Boston, MA  02110-1301,  USA       gnu at gnu.org                   *
+\********************************************************************/
+/** @file assistant-csv-export.h
+    @brief CSV Export Assistant
+    @author Copyright (c) 2012 Robert Fewell
+*/
+#ifndef GNC_ASSISTANT_CSV_EXPORT_H
+#define GNC_ASSISTANT_CSV_EXPORT_H
+
+#include "Account.h"
+
+typedef enum
+{
+    XML_EXPORT_TREE,
+    XML_EXPORT_TRANS
+} CsvExportType;
+
+typedef struct
+{
+    GtkWidget *table;
+    GtkWidget *start_date_choose;
+    GtkWidget *start_date_today;
+    GtkWidget *start_date;
+    GtkWidget *end_date_choose;
+    GtkWidget *end_date_today;
+    GtkWidget *end_date;
+
+    time64     start_time;
+    time64     end_time;
+} CsvExportDate;
+
+typedef struct
+{
+    GtkWidget        *acct_info;
+    GtkWidget        *expense_radio;
+    GtkWidget        *asset_radio;
+    GtkWidget        *liab_eq_radio;
+    GtkWidget        *account_treeview;
+    GtkWidget        *select_button;
+    GtkWidget        *num_acct_label;
+    GList            *account_list;
+    int               num_accounts;
+    GNCAccountType    account_type;
+} CsvExportAcc;
+
+
+typedef struct
+{
+    CsvExportType export_type;
+    CsvExportDate csvd;
+    CsvExportAcc  csva;
+
+    GtkWidget    *window;
+    GtkWidget    *assistant;
+    GtkWidget    *start_label;
+    GtkWidget    *custom_entry;
+
+    GtkWidget    *file_chooser;
+    GtkWidget    *finish_label;
+    GtkWidget    *summary_label;
+
+    gchar        *starting_dir;
+    gchar        *file_name;
+
+    char         *separator_str;
+    gboolean      use_quotes;
+    gboolean      use_custom;
+    gboolean      failed;
+} CsvExportInfo;
+
+
+/** The gnc_file_csv_export() will let the user export thte
+ *  account tree or transactions to a delimited file.
+ */
+void gnc_file_csv_export (CsvExportType export_type);
+
+#endif

Copied: gnucash/trunk/src/import-export/csv-exp/csv-transactions-export.c (from rev 23566, gnucash/trunk/src/import-export/csv-export/csv-transactions-export.c)
===================================================================
--- gnucash/trunk/src/import-export/csv-exp/csv-transactions-export.c	                        (rev 0)
+++ gnucash/trunk/src/import-export/csv-exp/csv-transactions-export.c	2013-12-15 17:21:20 UTC (rev 23567)
@@ -0,0 +1,385 @@
+/*******************************************************************\
+ * csv-transactions-export.c -- Export Transactions to a file       *
+ *                                                                  *
+ * Copyright (C) 2012 Robert Fewell                                 *
+ *                                                                  *
+ * This program is free software; you can redistribute it and/or    *
+ * modify it under the terms of the GNU General Public License as   *
+ * published by the Free Software Foundation; either version 2 of   *
+ * the License, or (at your option) any later version.              *
+ *                                                                  *
+ * This program is distributed in the hope that it will be useful,  *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of   *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the    *
+ * GNU General Public License for more details.                     *
+ *                                                                  *
+ * You should have received a copy of the GNU General Public License*
+ * along with this program; if not, contact:                        *
+ *                                                                  *
+ * Free Software Foundation           Voice:  +1-617-542-5942       *
+ * 51 Franklin Street, Fifth Floor    Fax:    +1-617-542-2652       *
+ * Boston, MA  02110-1301,  USA       gnu at gnu.org                   *
+\********************************************************************/
+/** @file csv-transactions-export.c
+    @brief CSV Export Transactions
+    @author Copyright (c) 2012 Robert Fewell
+*/
+#include "config.h"
+
+#include <gtk/gtk.h>
+#include <glib/gi18n.h>
+#include <glib/gstdio.h>
+
+#include "gnc-commodity.h"
+#include "gnc-ui-util.h"
+#include "Query.h"
+#include "Transaction.h"
+#include "engine-helpers.h"
+#include "qofbookslots.h"
+
+#include "csv-transactions-export.h"
+
+/* This static indicates the debugging module that this .o belongs to.  */
+static QofLogModule log_module = GNC_MOD_ASSISTANT;
+
+/*******************************************************************/
+
+/*******************************************************
+ * write_line_to_file
+ *
+ * write a text string to a file pointer, return TRUE if
+ * successfull.
+ *******************************************************/
+static
+gboolean write_line_to_file (FILE *fh, char * line)
+{
+    int len, written;
+    DEBUG("Account String: %s", line);
+
+    /* Write account line */
+    len = strlen( line );
+    written = fwrite( line, 1, len, fh );
+
+    if ( written != len )
+        return FALSE;
+    else
+        return TRUE;
+}
+
+
+/*******************************************************
+ * account_splits
+ *
+ * gather the splits / transactions for an account and
+ * send them to a file
+ *******************************************************/
+static
+void account_splits (CsvExportInfo *info, Account *acc, FILE *fh )
+{
+    Query   *q;
+    GSList  *p1, *p2;
+    GList   *splits;
+    QofBook *book;
+
+    gchar   *end_sep;
+    gchar   *mid_sep;
+
+    q = qof_query_create_for(GNC_ID_SPLIT);
+    book = gnc_get_current_book();
+    qof_query_set_book (q, book);
+
+    /* Set up separators */
+    if (info->use_quotes)
+    {
+        end_sep = "\"";
+        mid_sep = g_strconcat ( "\"", info->separator_str, "\"", NULL);
+    }
+    else
+    {
+        end_sep = "";
+        mid_sep = g_strconcat ( info->separator_str, NULL);
+    }
+
+    /* Sort by transaction date */
+    p1 = g_slist_prepend (NULL, TRANS_DATE_POSTED);
+    p1 = g_slist_prepend (p1, SPLIT_TRANS);
+    p2 = g_slist_prepend (NULL, QUERY_DEFAULT_SORT);
+    qof_query_set_sort_order (q, p1, p2, NULL);
+
+    xaccQueryAddSingleAccountMatch (q, acc, QOF_QUERY_AND);
+    xaccQueryAddDateMatchTT (q, TRUE, info->csvd.start_time, TRUE, info->csvd.end_time, QOF_QUERY_AND);
+
+    /* Run the query */
+    for (splits = qof_query_run(q); splits; splits = splits->next)
+    {
+        Split       *split;
+        Transaction *trans;
+        SplitList   *s_list;
+        GList       *node;
+        Split       *t_split;
+        int          nSplits;
+        int          cnt;
+        gchar       *part1;
+        gchar       *part2;
+        gchar       *date;
+        const gchar *currentSel;
+        const gchar *split_amount;
+
+        split = splits->data;
+        trans = xaccSplitGetParent(split);
+        nSplits = xaccTransCountSplits(trans);
+        s_list = xaccTransGetSplitList(trans);
+
+        /* Date */
+        date = qof_print_date ( xaccTransGetDate(trans));
+        part1 = g_strconcat ( end_sep, date, mid_sep, NULL);
+        g_free(date);
+        /* Name */
+        currentSel = xaccAccountGetName(acc);
+        part2 = g_strconcat ( part1, currentSel, mid_sep, NULL);
+        g_free(part1);
+        /* Number */
+        currentSel = gnc_get_num_action(trans, NULL);
+        part1 = g_strconcat ( part2, currentSel, mid_sep, NULL);
+        g_free(part2);
+        /* Description */
+        currentSel = xaccTransGetDescription(trans);
+        part2 = g_strconcat ( part1, currentSel, mid_sep, NULL);
+        g_free(part1);
+        /* Notes */
+        currentSel = xaccTransGetNotes(trans);
+        if (currentSel == NULL)
+            part1 = g_strconcat ( part2, mid_sep, NULL);
+        else
+            part1 = g_strconcat ( part2, currentSel, mid_sep, NULL);
+        g_free(part2);
+        /* Memo */
+        currentSel = xaccSplitGetMemo(split);
+        part2 = g_strconcat ( part1, currentSel, mid_sep, NULL);
+        g_free(part1);
+        /* Category */
+        currentSel = xaccSplitGetCorrAccountName(split);
+        part1 = g_strconcat ( part2, currentSel, mid_sep, "T", mid_sep, NULL);
+        g_free(part2);
+        /* Action */
+        currentSel =  gnc_get_num_action(NULL, split);
+        part2 = g_strconcat ( part1, currentSel, mid_sep, NULL);
+        g_free(part1);
+        /* Reconcile */
+        switch (xaccSplitGetReconcile (split))
+        {
+        case NREC:
+            currentSel = "N";
+            break;
+        case CREC:
+            currentSel = "C";
+            break;
+        case YREC:
+            currentSel = "Y";
+            break;
+        case FREC:
+            currentSel = "F";
+            break;
+        case VREC:
+            currentSel = "V";
+            break;
+        default:
+            currentSel = "N";
+        }
+        part1 = g_strconcat ( part2, currentSel, mid_sep, NULL);
+        g_free(part2);
+        /* To with Symbol */
+        split_amount = xaccPrintAmount(xaccSplitGetAmount(split), gnc_split_amount_print_info(split, TRUE));
+        part2 = g_strconcat ( part1, split_amount, mid_sep, NULL);
+        g_free(part1);
+
+        /* From with Symbol */
+        part1 = g_strconcat ( part2, "", mid_sep, NULL);
+        g_free(part2);
+
+        /* To Number Only */
+        split_amount = xaccPrintAmount(xaccSplitGetAmount(split), gnc_split_amount_print_info(split, FALSE));
+        part2 = g_strconcat ( part1, split_amount, mid_sep, NULL);
+        g_free(part1);
+
+        /* From Number Only */
+        part1 = g_strconcat ( part2, "", mid_sep, "", mid_sep, "", end_sep, "\n", NULL);
+        g_free(part2);
+
+        /* Write to file */
+        if (!write_line_to_file(fh, part1))
+        {
+            info->failed = TRUE;
+            break;
+        }
+        g_free(part1);
+
+        /* Loop through the list of splits for the Transcation */
+        node = s_list;
+        cnt = 0;
+        while ( (cnt < nSplits) && (info->failed == FALSE))
+        {
+            t_split = node->data;
+
+            /* Start of line */
+            part1 = g_strconcat ( end_sep, mid_sep, mid_sep, mid_sep, mid_sep, mid_sep, NULL);
+
+            /* Memo */
+            currentSel = xaccSplitGetMemo(t_split);
+            part2 = g_strconcat ( part1, currentSel, mid_sep, NULL);
+            g_free(part1);
+
+            /* Account */
+            currentSel = xaccAccountGetName( xaccSplitGetAccount(t_split));
+            part1 = g_strconcat ( part2, currentSel, mid_sep, "S", mid_sep, NULL);
+            g_free(part2);
+
+            /* Action */
+            currentSel = gnc_get_num_action(NULL, t_split);
+            part2 = g_strconcat ( part1, currentSel, mid_sep, NULL);
+            g_free(part1);
+
+            /* Reconcile */
+            switch (xaccSplitGetReconcile (split))
+            {
+            case NREC:
+                currentSel = "N";
+                break;
+            case CREC:
+                currentSel = "C";
+                break;
+            case YREC:
+                currentSel = "Y";
+                break;
+            case FREC:
+                currentSel = "F";
+                break;
+            case VREC:
+                currentSel = "V";
+                break;
+            default:
+                currentSel = "N";
+            }
+            part1 = g_strconcat ( part2, currentSel, mid_sep, NULL);
+            g_free(part2);
+
+            /* From / To with Symbol */
+            split_amount = xaccPrintAmount(xaccSplitGetAmount(t_split), gnc_split_amount_print_info(t_split, TRUE));
+            if (xaccSplitGetAccount(t_split) == acc)
+                part2 = g_strconcat ( part1,  split_amount, mid_sep, mid_sep, NULL);
+            else
+                part2 = g_strconcat ( part1, mid_sep, split_amount, mid_sep, NULL);
+            g_free(part1);
+
+            /* From / To Numbers only */
+            split_amount = xaccPrintAmount(xaccSplitGetAmount(t_split), gnc_split_amount_print_info(t_split, FALSE));
+            if (xaccSplitGetAccount(t_split) == acc)
+                part1 = g_strconcat ( part2,  split_amount, mid_sep, mid_sep, NULL);
+            else
+                part1 = g_strconcat ( part2, mid_sep, split_amount, mid_sep, NULL);
+            g_free(part2);
+
+            /* From / To - Share Price / Conversion factor */
+            split_amount = xaccPrintAmount(xaccSplitGetSharePrice(t_split), gnc_split_amount_print_info(t_split, FALSE));
+            if (xaccSplitGetAccount(t_split) == acc)
+                part2 = g_strconcat ( part1,  split_amount, mid_sep, end_sep, "\n", NULL);
+            else
+                part2 = g_strconcat ( part1, mid_sep, split_amount, end_sep, "\n", NULL);
+            g_free(part1);
+
+            if (!write_line_to_file(fh, part2))
+                info->failed = TRUE;
+
+            g_free(part2);
+            cnt++;
+            node = node->next;
+        }
+    }
+    g_free(mid_sep);
+    qof_query_destroy (q);
+    g_list_free( splits );
+}
+
+
+/*******************************************************
+ * csv_transactions_export
+ *
+ * write a list of transactions to a text file
+ *******************************************************/
+void csv_transactions_export (CsvExportInfo *info)
+{
+    FILE    *fh;
+    Account *acc;
+    GList   *ptr;
+    gboolean num_action = qof_book_use_split_action_for_num_field(gnc_get_current_book());
+
+    ENTER("");
+    DEBUG("File name is : %s", info->file_name);
+
+    info->failed = FALSE;
+
+    /* Open File for writing */
+    fh = g_fopen( info->file_name, "w" );
+    if ( fh != NULL )
+    {
+        gchar *header;
+        gchar *end_sep;
+        gchar *mid_sep;
+        int i;
+
+        /* Set up separators */
+        if (info->use_quotes)
+        {
+            end_sep = "\"";
+            mid_sep = g_strconcat ( "\"", info->separator_str, "\"", NULL);
+        }
+        else
+        {
+            end_sep = "";
+            mid_sep = g_strconcat ( info->separator_str, NULL);
+        }
+
+        /* Header string */
+        header = g_strconcat ( end_sep, _("Date"), mid_sep, _("Account Name"), mid_sep,
+                               (num_action ? _("Transaction Number") : _("Number")),
+                               mid_sep, _("Description"), mid_sep, _("Notes"),
+                               mid_sep, _("Memo"), mid_sep, _("Category"), mid_sep,
+                               _("Type"), mid_sep,
+                               (num_action ? _("Number/Action") : _("Action")),
+                               mid_sep, _("Reconcile"), mid_sep,
+                               _("To With Sym"), mid_sep, _("From With Sym"), mid_sep,
+                               _("To Num."), mid_sep, _("From Num."), mid_sep,
+                               _("To Rate/Price"), mid_sep, _("From Rate/Price"),
+                               end_sep, "\n", NULL);
+        DEBUG("Header String: %s", header);
+
+        /* Write header line */
+        if (!write_line_to_file(fh, header))
+        {
+            info->failed = TRUE;
+            g_free(mid_sep);
+            g_free(header);
+            return;
+        }
+        g_free(mid_sep);
+        g_free(header);
+
+        /* Go through list of accounts */
+        for (ptr = info->csva.account_list, i = 0; ptr; ptr = g_list_next(ptr), i++)
+        {
+            acc = ptr->data;
+            DEBUG("Account being processed is : %s", xaccAccountGetName(acc));
+            account_splits (info, acc, fh);
+        }
+    }
+    else
+        info->failed = TRUE;
+    if (fh)
+        fclose (fh);
+    LEAVE("");
+}
+
+
+
+
+

Copied: gnucash/trunk/src/import-export/csv-exp/csv-transactions-export.h (from rev 23566, gnucash/trunk/src/import-export/csv-export/csv-transactions-export.h)
===================================================================
--- gnucash/trunk/src/import-export/csv-exp/csv-transactions-export.h	                        (rev 0)
+++ gnucash/trunk/src/import-export/csv-exp/csv-transactions-export.h	2013-12-15 17:21:20 UTC (rev 23567)
@@ -0,0 +1,39 @@
+/*******************************************************************\
+ * csv-transactions-export.h -- Export Transactions to a file       *
+ *                                                                  *
+ * Copyright (C) 2012 Robert Fewell                                 *
+ *                                                                  *
+ * This program is free software; you can redistribute it and/or    *
+ * modify it under the terms of the GNU General Public License as   *
+ * published by the Free Software Foundation; either version 2 of   *
+ * the License, or (at your option) any later version.              *
+ *                                                                  *
+ * This program is distributed in the hope that it will be useful,  *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of   *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the    *
+ * GNU General Public License for more details.                     *
+ *                                                                  *
+ * You should have received a copy of the GNU General Public License*
+ * along with this program; if not, contact:                        *
+ *                                                                  *
+ * Free Software Foundation           Voice:  +1-617-542-5942       *
+ * 51 Franklin Street, Fifth Floor    Fax:    +1-617-542-2652       *
+ * Boston, MA  02110-1301,  USA       gnu at gnu.org                   *
+\********************************************************************/
+/** @file csv-transactions-export.h
+    @brief CSV Export Transactions
+    @author Copyright (c) 2012 Robert Fewell
+*/
+
+#ifndef CSV_TRANSACTIONS_EXPORT
+#define CSV_TRANSACTIONS_EXPORT
+
+#include "assistant-csv-export.h"
+
+/** The csv_transactions_export() will let the user export the
+ *  transactions to a delimited file.
+ */
+void csv_transactions_export (CsvExportInfo *info);
+
+#endif
+

Copied: gnucash/trunk/src/import-export/csv-exp/csv-tree-export.c (from rev 23566, gnucash/trunk/src/import-export/csv-export/csv-tree-export.c)
===================================================================
--- gnucash/trunk/src/import-export/csv-exp/csv-tree-export.c	                        (rev 0)
+++ gnucash/trunk/src/import-export/csv-exp/csv-tree-export.c	2013-12-15 17:21:20 UTC (rev 23567)
@@ -0,0 +1,217 @@
+/*******************************************************************\
+ * csv-tree-export.c -- Export Account Tree to a file               *
+ *                                                                  *
+ * Copyright (C) 2012 Robert Fewell                                 *
+ *                                                                  *
+ * This program is free software; you can redistribute it and/or    *
+ * modify it under the terms of the GNU General Public License as   *
+ * published by the Free Software Foundation; either version 2 of   *
+ * the License, or (at your option) any later version.              *
+ *                                                                  *
+ * This program is distributed in the hope that it will be useful,  *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of   *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the    *
+ * GNU General Public License for more details.                     *
+ *                                                                  *
+ * You should have received a copy of the GNU General Public License*
+ * along with this program; if not, contact:                        *
+ *                                                                  *
+ * Free Software Foundation           Voice:  +1-617-542-5942       *
+ * 51 Franklin Street, Fifth Floor    Fax:    +1-617-542-2652       *
+ * Boston, MA  02110-1301,  USA       gnu at gnu.org                   *
+\********************************************************************/
+/** @file csv-tree-export.c
+    @brief CSV Export Account Tree
+    @author Copyright (c) 2012 Robert Fewell
+*/
+#include "config.h"
+
+#include <gtk/gtk.h>
+#include <glib/gi18n.h>
+#include <glib/gstdio.h>
+
+#include "gnc-commodity.h"
+#include "gnc-ui-util.h"
+
+#include "csv-tree-export.h"
+
+/* This static indicates the debugging module that this .o belongs to.  */
+static QofLogModule log_module = GNC_MOD_ASSISTANT;
+
+/******************************************************************/
+
+/*******************************************************
+ * write_line_to_file
+ *
+ * write a text string to a file pointer, return TRUE if
+ * successfull.
+ *******************************************************/
+static
+gboolean write_line_to_file ( FILE *fh, char * line)
+{
+    int len, written;
+    DEBUG("Account String: %s", line);
+
+    /* Write account line */
+    len = strlen( line );
+    written = fwrite( line, 1, len, fh );
+
+    if ( written != len )
+        return FALSE;
+    else
+        return TRUE;
+}
+
+
+/*******************************************************
+ * csv_tree_export
+ *
+ * write a list of accounts settings to a text file
+ *******************************************************/
+void csv_tree_export (CsvExportInfo *info)
+{
+    FILE    *fh;
+    Account *root;
+    Account *acc;
+    GList   *accts, *ptr;
+
+    ENTER("");
+    DEBUG("File name is : %s", info->file_name);
+
+    /* Get list of Accounts */
+    root = gnc_book_get_root_account( gnc_get_current_book() );
+    accts = gnc_account_get_descendants_sorted( root );
+    info->failed = FALSE;
+
+    /* Open File for writing */
+    fh = g_fopen( info->file_name, "w" );
+    if ( fh != NULL )
+    {
+        gchar *header;
+        gchar *part1;
+        gchar *part2;
+        const gchar *currentSel;
+        gchar *end_sep;
+        gchar *mid_sep;
+        int i;
+
+
+        /* Set up separators */
+        if (info->use_quotes)
+        {
+            end_sep = "\"";
+            mid_sep = g_strconcat ( "\"", info->separator_str, "\"", NULL);
+        }
+        else
+        {
+            end_sep = "";
+            mid_sep = g_strconcat ( info->separator_str, NULL);
+        }
+
+        /* Header string */
+        header = g_strconcat ( end_sep, _("type"), mid_sep, _("full_name"), mid_sep,
+                               _("name"), mid_sep, _("code"), mid_sep,
+                               _("description"), mid_sep, _("color"), mid_sep, _("notes"), mid_sep,
+                               _("commoditym"), mid_sep, _("commodityn"), mid_sep,
+                               _("hidden"), mid_sep, _("tax"), mid_sep, _("place_holder"), end_sep, "\n", NULL);
+        DEBUG("Header String: %s", header);
+
+        /* Write header line */
+        if (!write_line_to_file(fh, header))
+        {
+            info->failed = TRUE;
+            g_free(mid_sep);
+            g_free(header);
+            return;
+        }
+        g_free(header);
+
+        /* Go through list of accounts */
+        for (ptr = accts, i = 0; ptr; ptr = g_list_next(ptr), i++)
+        {
+            gchar *fullname = NULL;
+            gchar *notes_out = NULL;
+            acc = ptr->data;
+            DEBUG("Account being processed is : %s", xaccAccountGetName(acc));
+            /* Type */
+            currentSel = xaccAccountTypeEnumAsString( xaccAccountGetType (acc));
+            part1 = g_strconcat ( end_sep, currentSel, mid_sep, NULL);
+            /* Full Name */
+            fullname = gnc_account_get_full_name(acc);
+            part2 = g_strconcat ( part1, fullname, mid_sep, NULL);
+            g_free(fullname);
+            g_free(part1);
+            /* Name */
+            currentSel = xaccAccountGetName(acc);
+            part1 = g_strconcat ( part2, currentSel, mid_sep, NULL);
+            g_free(part2);
+            /* Code */
+            currentSel = xaccAccountGetCode(acc) ? xaccAccountGetCode(acc) : "" ;
+            part2 = g_strconcat ( part1, currentSel, mid_sep, NULL);
+            g_free(part1);
+            /* Description */
+            currentSel = xaccAccountGetDescription(acc) ? xaccAccountGetDescription(acc) : "" ;
+            part1 = g_strconcat ( part2, currentSel, mid_sep, NULL);
+            g_free(part2);
+            /* Color */
+            currentSel = xaccAccountGetColor(acc) ? xaccAccountGetColor(acc) : "" ;
+            part2 = g_strconcat ( part1, currentSel, mid_sep, NULL);
+            g_free(part1);
+            /* Notes */
+            currentSel = xaccAccountGetNotes(acc) ? xaccAccountGetNotes(acc) : "" ;
+            if (!g_strcmp0(currentSel, "") == 0)
+            {
+                /* Check for multiple lines */
+                gchar **parts;
+                parts = g_strsplit(currentSel, "\n", -1);
+                notes_out = g_strjoinv("\\n", parts);
+                currentSel = notes_out;
+                g_strfreev(parts);
+            }
+            part1 = g_strconcat ( part2, currentSel, mid_sep, NULL);
+            g_free(part2);
+            g_free(notes_out);
+            /* Commodity Mnemonic */
+            currentSel = gnc_commodity_get_mnemonic(xaccAccountGetCommodity (acc));
+            part2 = g_strconcat ( part1, currentSel, mid_sep, NULL);
+            g_free(part1);
+            /* Commodity Namespace */
+            currentSel = gnc_commodity_get_namespace(xaccAccountGetCommodity (acc));
+            part1 = g_strconcat ( part2, currentSel, mid_sep, NULL);
+            g_free(part2);
+            /* Hidden */
+            currentSel = xaccAccountGetHidden(acc) ? "T" : "F" ;
+            part2 = g_strconcat ( part1, currentSel, mid_sep, NULL);
+            g_free(part1);
+            /* Tax */
+            currentSel = xaccAccountGetTaxRelated(acc) ? "T" : "F" ;
+            part1 = g_strconcat ( part2, currentSel, mid_sep, NULL);
+            g_free(part2);
+            /* Place Holder */
+            currentSel = xaccAccountGetPlaceholder(acc) ? "T" : "F" ;
+            part2 = g_strconcat ( part1, currentSel, end_sep, "\n", NULL);
+            g_free(part1);
+
+            DEBUG("Account String: %s", part2);
+
+            /* Write to file */
+            if (!write_line_to_file(fh, part2))
+            {
+                info->failed = TRUE;
+                break;
+            }
+            g_free(part2);
+        }
+        g_free(mid_sep);
+    }
+    else
+        info->failed = TRUE;
+    if (fh)
+        fclose (fh);
+
+    g_list_free( accts );
+    LEAVE("");
+}
+
+
+

Copied: gnucash/trunk/src/import-export/csv-exp/csv-tree-export.h (from rev 23566, gnucash/trunk/src/import-export/csv-export/csv-tree-export.h)
===================================================================
--- gnucash/trunk/src/import-export/csv-exp/csv-tree-export.h	                        (rev 0)
+++ gnucash/trunk/src/import-export/csv-exp/csv-tree-export.h	2013-12-15 17:21:20 UTC (rev 23567)
@@ -0,0 +1,38 @@
+/*******************************************************************\
+ * csv-tree-export.h -- Export Account Tree to a file               *
+ *                                                                  *
+ * Copyright (C) 2012 Robert Fewell                                 *
+ *                                                                  *
+ * This program is free software; you can redistribute it and/or    *
+ * modify it under the terms of the GNU General Public License as   *
+ * published by the Free Software Foundation; either version 2 of   *
+ * the License, or (at your option) any later version.              *
+ *                                                                  *
+ * This program is distributed in the hope that it will be useful,  *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of   *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the    *
+ * GNU General Public License for more details.                     *
+ *                                                                  *
+ * You should have received a copy of the GNU General Public License*
+ * along with this program; if not, contact:                        *
+ *                                                                  *
+ * Free Software Foundation           Voice:  +1-617-542-5942       *
+ * 51 Franklin Street, Fifth Floor    Fax:    +1-617-542-2652       *
+ * Boston, MA  02110-1301,  USA       gnu at gnu.org                   *
+\********************************************************************/
+/** @file csv-tree-export.h
+    @brief CSV Export Account Tree
+    @author Copyright (c) 2012 Robert Fewell
+*/
+#ifndef CSV_TREE_EXPORT
+#define CSV_TREE_EXPORT
+
+#include "assistant-csv-export.h"
+
+/** The csv_tree_export() will let the user export the
+ *  account tree to a delimited file.
+ */
+void csv_tree_export (CsvExportInfo *info);
+
+#endif
+

Copied: gnucash/trunk/src/import-export/csv-exp/gnc-plugin-csv-export-ui.xml (from rev 23566, gnucash/trunk/src/import-export/csv-export/gnc-plugin-csv-export-ui.xml)
===================================================================
--- gnucash/trunk/src/import-export/csv-exp/gnc-plugin-csv-export-ui.xml	                        (rev 0)
+++ gnucash/trunk/src/import-export/csv-exp/gnc-plugin-csv-export-ui.xml	2013-12-15 17:21:20 UTC (rev 23567)
@@ -0,0 +1,12 @@
+<ui>
+  <menubar>
+    <menu name="File" action="FileAction">
+      <menu name="FileExport" action="FileExportAction">
+      	<placeholder name="FileExportPlaceholder">
+      	   <menuitem name="FileCsvExportTree" action="CsvExportTreeAction"/>
+      	   <menuitem name="FileCsvExportTrans" action="CsvExportTransAction"/>
+      	</placeholder>
+      </menu>
+    </menu>
+  </menubar>
+</ui>

Copied: gnucash/trunk/src/import-export/csv-exp/gnc-plugin-csv-export.c (from rev 23566, gnucash/trunk/src/import-export/csv-export/gnc-plugin-csv-export.c)
===================================================================
--- gnucash/trunk/src/import-export/csv-exp/gnc-plugin-csv-export.c	                        (rev 0)
+++ gnucash/trunk/src/import-export/csv-exp/gnc-plugin-csv-export.c	2013-12-15 17:21:20 UTC (rev 23567)
@@ -0,0 +1,168 @@
+/*
+ * gnc-plugin-csv-export.c -- csv export plugin
+ * Copyright (C) 2012 Robert Fewell
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, contact:
+ *
+ * Free Software Foundation           Voice:  +1-617-542-5942
+ * 51 Franklin Street, Fifth Floor    Fax:    +1-617-542-2652
+ * Boston, MA  02110-1301,  USA       gnu at gnu.org
+ */
+
+#include "config.h"
+
+#include <gtk/gtk.h>
+#include <glib/gi18n.h>
+
+#include "gnc-plugin-csv-export.h"
+#include "gnc-plugin-manager.h"
+
+#include "assistant-csv-export.h"
+
+static void gnc_plugin_csv_export_class_init (GncPluginCsvExportClass *klass);
+static void gnc_plugin_csv_export_init (GncPluginCsvExport *plugin);
+static void gnc_plugin_csv_export_finalize (GObject *object);
+
+/* Command callbacks */
+static void gnc_plugin_csv_export_tree_cmd (GtkAction *action, GncMainWindowActionData *data);
+static void gnc_plugin_csv_export_trans_cmd (GtkAction *action, GncMainWindowActionData *data);
+
+#define PLUGIN_ACTIONS_NAME "gnc-plugin-csv-export-actions"
+#define PLUGIN_UI_FILENAME  "gnc-plugin-csv-export-ui.xml"
+
+static GtkActionEntry gnc_plugin_actions [] =
+{
+    {
+        "CsvExportTreeAction", GTK_STOCK_CONVERT, N_("Export Account T_ree to CSV..."), NULL,
+        N_("Export the Account Tree to a CSV file"),
+        G_CALLBACK (gnc_plugin_csv_export_tree_cmd)
+    },
+    {
+        "CsvExportTransAction", GTK_STOCK_CONVERT, N_("Export _Transactions to CSV..."), NULL,
+        N_("Export the Transactions to a CSV file"),
+        G_CALLBACK (gnc_plugin_csv_export_trans_cmd)
+    },
+};
+static guint gnc_plugin_n_actions = G_N_ELEMENTS (gnc_plugin_actions);
+
+typedef struct GncPluginCsvExportPrivate
+{
+    gpointer dummy;
+} GncPluginCsvExportPrivate;
+
+#define GNC_PLUGIN_CSV_EXPORT_GET_PRIVATE(o)  \
+   (G_TYPE_INSTANCE_GET_PRIVATE ((o), GNC_TYPE_PLUGIN_CSV_EXPORT, GncPluginCsvExportPrivate))
+
+static GObjectClass *parent_class = NULL;
+
+GType
+gnc_plugin_csv_export_get_type (void)
+{
+    static GType gnc_plugin_csv_export_type = 0;
+
+    if (gnc_plugin_csv_export_type == 0)
+    {
+        static const GTypeInfo our_info =
+        {
+            sizeof (GncPluginCsvExportClass),
+            NULL,		/* base_init */
+            NULL,		/* base_finalize */
+            (GClassInitFunc) gnc_plugin_csv_export_class_init,
+            NULL,		/* class_finalize */
+            NULL,		/* class_data */
+            sizeof (GncPluginCsvExport),
+            0,		/* n_preallocs */
+            (GInstanceInitFunc) gnc_plugin_csv_export_init,
+        };
+
+        gnc_plugin_csv_export_type = g_type_register_static (GNC_TYPE_PLUGIN,
+                                     "GncPluginCsvExport",
+                                     &our_info, 0);
+    }
+
+    return gnc_plugin_csv_export_type;
+}
+
+GncPlugin *
+gnc_plugin_csv_export_new (void)
+{
+    return GNC_PLUGIN (g_object_new (GNC_TYPE_PLUGIN_CSV_EXPORT, NULL));
+}
+
+static void
+gnc_plugin_csv_export_class_init (GncPluginCsvExportClass *klass)
+{
+    GObjectClass *object_class = G_OBJECT_CLASS (klass);
+    GncPluginClass *plugin_class = GNC_PLUGIN_CLASS (klass);
+
+    parent_class = g_type_class_peek_parent (klass);
+
+    object_class->finalize = gnc_plugin_csv_export_finalize;
+
+    /* plugin info */
+    plugin_class->plugin_name  = GNC_PLUGIN_CSV_EXPORT_NAME;
+
+    /* widget addition/removal */
+    plugin_class->actions_name = PLUGIN_ACTIONS_NAME;
+    plugin_class->actions      = gnc_plugin_actions;
+    plugin_class->n_actions    = gnc_plugin_n_actions;
+    plugin_class->ui_filename  = PLUGIN_UI_FILENAME;
+
+    g_type_class_add_private(klass, sizeof(GncPluginCsvExportPrivate));
+}
+
+static void
+gnc_plugin_csv_export_init (GncPluginCsvExport *plugin)
+{
+}
+
+static void
+gnc_plugin_csv_export_finalize (GObject *object)
+{
+    g_return_if_fail (GNC_IS_PLUGIN_CSV_EXPORT (object));
+
+    G_OBJECT_CLASS (parent_class)->finalize (object);
+}
+
+/************************************************************
+ *              Plugin Function Implementation              *
+ ************************************************************/
+
+/************************************************************
+ *                    Command Callbacks                     *
+ ************************************************************/
+static void
+gnc_plugin_csv_export_tree_cmd (GtkAction *action,
+                                GncMainWindowActionData *data)
+{
+    gnc_file_csv_export(XML_EXPORT_TREE);
+}
+
+static void
+gnc_plugin_csv_export_trans_cmd (GtkAction *action,
+                                 GncMainWindowActionData *data)
+{
+    gnc_file_csv_export(XML_EXPORT_TRANS);
+}
+
+/************************************************************
+ *                    Plugin Bootstrapping                   *
+ ************************************************************/
+void
+gnc_plugin_csv_export_create_plugin (void)
+{
+    GncPlugin *plugin = gnc_plugin_csv_export_new ();
+
+    gnc_plugin_manager_add_plugin (gnc_plugin_manager_get (), plugin);
+}

Copied: gnucash/trunk/src/import-export/csv-exp/gnc-plugin-csv-export.h (from rev 23566, gnucash/trunk/src/import-export/csv-export/gnc-plugin-csv-export.h)
===================================================================
--- gnucash/trunk/src/import-export/csv-exp/gnc-plugin-csv-export.h	                        (rev 0)
+++ gnucash/trunk/src/import-export/csv-exp/gnc-plugin-csv-export.h	2013-12-15 17:21:20 UTC (rev 23567)
@@ -0,0 +1,62 @@
+/*
+ * gnc-plugin-csv-export.h -- csv export plugin
+ * Copyright (C) 2012 Robert Fewell
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, contact:
+ *
+ * Free Software Foundation           Voice:  +1-617-542-5942
+ * 51 Franklin Street, Fifth Floor    Fax:    +1-617-542-2652
+ * Boston, MA  02110-1301,  USA       gnu at gnu.org
+ */
+
+#ifndef __GNC_PLUGIN_CSV_EXPORT_H
+#define __GNC_PLUGIN_CSV_EXPORT_H
+
+#include <gtk/gtk.h>
+
+#include "gnc-plugin.h"
+
+G_BEGIN_DECLS
+
+/* type macros */
+#define GNC_TYPE_PLUGIN_CSV_EXPORT            (gnc_plugin_csv_export_get_type ())
+#define GNC_PLUGIN_CSV_EXPORT(obj)            (G_TYPE_CHECK_INSTANCE_CAST ((obj), GNC_TYPE_PLUGIN_CSV_EXPORT, GncPluginCsvExport))
+#define GNC_PLUGIN_CSV_EXPORT_CLASS(klass)    (G_TYPE_CHECK_CLASS_CAST ((klass), GNC_TYPE_PLUGIN_CSV_EXPORT, GncPluginCsvExportClass))
+#define GNC_IS_PLUGIN_CSV_EXPORT(obj)         (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GNC_TYPE_PLUGIN_CSV_EXPORT))
+#define GNC_IS_PLUGIN_CSV_EXPORT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GNC_TYPE_PLUGIN_CSV_EXPORT))
+#define GNC_PLUGIN_CSV_EXPORT_GET_CLASS(obj)  (G_TYPE_INSTANCE_GET_CLASS ((obj), GNC_TYPE_PLUGIN_CSV_EXPORT, GncPluginCsvExportClass))
+
+#define GNC_PLUGIN_CSV_EXPORT_NAME "gnc-plugin-csv-export"
+
+/* typedefs & structures */
+typedef struct
+{
+    GncPlugin gnc_plugin;
+} GncPluginCsvExport;
+
+typedef struct
+{
+    GncPluginClass gnc_plugin;
+} GncPluginCsvExportClass;
+
+/* function prototypes */
+GType      gnc_plugin_csv_export_get_type (void);
+
+GncPlugin *gnc_plugin_csv_export_new      (void);
+
+void       gnc_plugin_csv_export_create_plugin (void);
+
+G_END_DECLS
+
+#endif /* __GNC_PLUGIN_CSV_EXPORT_H */

Copied: gnucash/trunk/src/import-export/csv-exp/gncmod-csv-export.c (from rev 23566, gnucash/trunk/src/import-export/csv-export/gncmod-csv-export.c)
===================================================================
--- gnucash/trunk/src/import-export/csv-exp/gncmod-csv-export.c	                        (rev 0)
+++ gnucash/trunk/src/import-export/csv-exp/gncmod-csv-export.c	2013-12-15 17:21:20 UTC (rev 23567)
@@ -0,0 +1,90 @@
+/********************************************************************\
+ * This program is free software; you can redistribute it and/or    *
+ * modify it under the terms of the GNU General Public License as   *
+ * published by the Free Software Foundation; either version 2 of   *
+ * the License, or (at your option) any later version.              *
+ *                                                                  *
+ * This program is distributed in the hope that it will be useful,  *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of   *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the    *
+ * GNU General Public License for more details.                     *
+ *                                                                  *
+ * You should have received a copy of the GNU General Public License*
+ * along with this program; if not, contact:                        *
+ *                                                                  *
+ * Free Software Foundation           Voice:  +1-617-542-5942       *
+ * 51 Franklin Street, Fifth Floor    Fax:    +1-617-542-2652       *
+ * Boston, MA  02110-1301,  USA       gnu at gnu.org                   *
+\********************************************************************/
+/** @addtogroup Import_Export
+    @{ */
+/**@internal
+ at file gncmod-csv-export.c
+ at brief module definition/initialization for the csv exporter
+ at author Copyright (c) 2012 Robert Fewell
+*/
+#include "config.h"
+
+#include <gmodule.h>
+
+#include "gnc-module.h"
+#include "gnc-module-api.h"
+#include "gnc-plugin-csv-export.h"
+
+GNC_MODULE_API_DECL(libgncmod_csv_export)
+
+/* version of the gnc module system interface we require */
+int libgncmod_csv_export_gnc_module_system_interface = 0;
+
+/* module versioning uses libtool semantics. */
+int libgncmod_csv_export_gnc_module_current  = 0;
+int libgncmod_csv_export_gnc_module_revision = 0;
+int libgncmod_csv_export_gnc_module_age      = 0;
+
+//static GNCModule bus_core;
+//static GNCModule file;
+
+char *
+libgncmod_csv_export_gnc_module_path(void)
+{
+    return g_strdup("gnucash/import-export/csv-export");
+}
+
+char *
+libgncmod_csv_export_gnc_module_description(void)
+{
+    return g_strdup("Gnome GUI and C code for CSV exporter.");
+}
+
+int
+libgncmod_csv_export_gnc_module_init(int refcount)
+{
+    if (!gnc_module_load("gnucash/engine", 0))
+    {
+        return FALSE;
+    }
+    if (!gnc_module_load("gnucash/app-utils", 0))
+    {
+        return FALSE;
+    }
+    if (!gnc_module_load("gnucash/gnome-utils", 0))
+    {
+        return FALSE;
+    }
+    if (!gnc_module_load("gnucash/import-export", 0))
+    {
+        return FALSE;
+    }
+
+    /* Add menu items with C callbacks */
+    gnc_plugin_csv_export_create_plugin();
+
+    return TRUE;
+}
+
+int
+libgncmod_csv_export_gnc_module_end(int refcount)
+{
+    return TRUE;
+}
+/** @}*/

Copied: gnucash/trunk/src/import-export/csv-exp/gschemas/Makefile.am (from rev 23566, gnucash/trunk/src/import-export/csv-export/gschemas/Makefile.am)
===================================================================
--- gnucash/trunk/src/import-export/csv-exp/gschemas/Makefile.am	                        (rev 0)
+++ gnucash/trunk/src/import-export/csv-exp/gschemas/Makefile.am	2013-12-15 17:21:20 UTC (rev 23567)
@@ -0,0 +1,10 @@
+ at INTLTOOL_XML_NOMERGE_RULE@
+
+gschema_in_files = \
+  org.gnucash.dialogs.export.csv.gschema.xml.in
+
+gsettings_SCHEMAS = $(gschema_in_files:.gschema.xml.in=.gschema.xml)
+
+ at GSETTINGS_RULES@
+
+CLEANFILES = $(gsettings_SCHEMAS)

Copied: gnucash/trunk/src/import-export/csv-exp/gschemas/org.gnucash.dialogs.export.csv.gschema.xml.in.in (from rev 23566, gnucash/trunk/src/import-export/csv-export/gschemas/org.gnucash.dialogs.export.csv.gschema.xml.in.in)
===================================================================
--- gnucash/trunk/src/import-export/csv-exp/gschemas/org.gnucash.dialogs.export.csv.gschema.xml.in.in	                        (rev 0)
+++ gnucash/trunk/src/import-export/csv-exp/gschemas/org.gnucash.dialogs.export.csv.gschema.xml.in.in	2013-12-15 17:21:20 UTC (rev 23567)
@@ -0,0 +1,21 @@
+<schemalist gettext-domain="@GETTEXT_PACKAGE@">
+  <schema id="org.gnucash.dialogs.export.csv" path="/org/gnucash/dialogs/export/csv/">
+    <key name="last-geometry" type="(iiii)">
+      <default>(-1,-1,-1,-1)</default>
+      <summary>Last window position and size</summary>
+      <description>This setting describes the size and position of the window when it was last closed.
+        The numbers are the X and Y coordinates of the top left corner of the window
+        followed by the width and height of the window.</description>
+    </key>
+    <key name="last-path" type="s">
+      <default>''</default>
+      <summary>Last pathname used</summary>
+      <description>This field contains the last pathname used by this window. It will be used as the initial filename/pathname the next time this window is opened.</description>
+    </key>
+    <key name="paned-position" type="i">
+      <default>0</default>
+      <summary>Window geometry</summary>
+      <description>The position of paned window when it was last closed.</description>
+    </key>
+  </schema>
+</schemalist>

Deleted: gnucash/trunk/src/import-export/csv-export/Makefile.am
===================================================================
--- gnucash/trunk/src/import-export/csv-export/Makefile.am	2013-12-15 17:20:10 UTC (rev 23566)
+++ gnucash/trunk/src/import-export/csv-export/Makefile.am	2013-12-15 17:21:20 UTC (rev 23567)
@@ -1,59 +0,0 @@
-SUBDIRS = . gschemas
-
-pkglib_LTLIBRARIES=libgncmod-csv-export.la
-
-libgncmod_csv_export_la_SOURCES = \
-  gncmod-csv-export.c \
-  gnc-plugin-csv-export.c \
-  assistant-csv-export.c \
-  csv-tree-export.c \
-  csv-transactions-export.c
-
-noinst_HEADERS = \
-  gnc-plugin-csv-export.h \
-  assistant-csv-export.h \
-  csv-tree-export.h \
-  csv-transactions-export.h
-
-libgncmod_csv_export_la_LDFLAGS = -avoid-version
-
-libgncmod_csv_export_la_LIBADD = \
-  ${top_builddir}/src/import-export/libgncmod-generic-import.la \
-  ${top_builddir}/src/gnome-utils/libgncmod-gnome-utils.la \
-  ${top_builddir}/src/app-utils/libgncmod-app-utils.la \
-  ${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}/lib/stf/libgnc-stf.la \
-  ${top_builddir}/lib/libc/libc-missing.la \
-  ${top_builddir}/src/libqof/qof/libgnc-qof.la \
-  ${GOFFICE_LIBS} \
-  ${GLIB_LIBS}
-
-AM_CPPFLAGS = \
-  -I${top_srcdir}/src \
-  -I${top_srcdir}/src/core-utils \
-  -I${top_srcdir}/src/engine \
-  -I${top_srcdir}/src/gnc-module \
-  -I${top_srcdir}/src/app-utils \
-  -I${top_srcdir}/src/gnome \
-  -I${top_srcdir}/src/gnome-utils \
-  -I${top_srcdir}/src/import-export \
-  -I${top_srcdir}/src/libqof/qof \
-  -I${top_srcdir}/lib/libc \
-  -I${top_srcdir}/lib \
-  ${GUILE_CFLAGS} \
-  ${GLIB_CFLAGS} \
-  $(GOFFICE_CFLAGS)
-
-uidir = $(GNC_UI_DIR)
-ui_DATA = \
-	gnc-plugin-csv-export-ui.xml
-
-gtkbuilderdir = ${GNC_GTKBUILDER_DIR}
-gtkbuilder_DATA = \
-	assistant-csv-export.glade
-
-EXTRA_DIST = $(ui_DATA) $(gtkbuilder_DATA)
-
-AM_CPPFLAGS += -DG_LOG_DOMAIN=\"gnc.export.csv\"

Deleted: gnucash/trunk/src/import-export/csv-export/assistant-csv-export.c
===================================================================
--- gnucash/trunk/src/import-export/csv-export/assistant-csv-export.c	2013-12-15 17:20:10 UTC (rev 23566)
+++ gnucash/trunk/src/import-export/csv-export/assistant-csv-export.c	2013-12-15 17:21:20 UTC (rev 23567)
@@ -1,1035 +0,0 @@
-/*******************************************************************\
- * assistant-csv-export.c -- An assistant for exporting Accounts    *
- *                            and Transactions to a file            *
- *                                                                  *
- * Copyright (C) 2012 Robert Fewell                                 *
- *                                                                  *
- * This program is free software; you can redistribute it and/or    *
- * modify it under the terms of the GNU General Public License as   *
- * published by the Free Software Foundation; either version 2 of   *
- * the License, or (at your option) any later version.              *
- *                                                                  *
- * This program is distributed in the hope that it will be useful,  *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of   *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the    *
- * GNU General Public License for more details.                     *
- *                                                                  *
- * You should have received a copy of the GNU General Public License*
- * along with this program; if not, contact:                        *
- *                                                                  *
- * Free Software Foundation           Voice:  +1-617-542-5942       *
- * 51 Franklin Street, Fifth Floor    Fax:    +1-617-542-2652       *
- * Boston, MA  02110-1301,  USA       gnu at gnu.org                   *
-\********************************************************************/
-/** @file assistant-csv-export.c
-    @brief CSV Export Assistant
-    @author Copyright (c) 2012 Robert Fewell
-*/
-#include "config.h"
-
-#include <gtk/gtk.h>
-#include <glib/gi18n.h>
-
-#include "gnc-ui.h"
-#include "gnc-uri-utils.h"
-#include "gnc-component-manager.h"
-#include "gnc-date-edit.h"
-#include "gnc-prefs.h"
-#include "gnc-tree-view-account.h"
-#include "dialog-utils.h"
-#include "Query.h"
-#include "Transaction.h"
-
-#include "assistant-utils.h"
-#include "assistant-csv-export.h"
-#include "csv-tree-export.h"
-#include "csv-transactions-export.h"
-
-#define GNC_PREFS_GROUP    "dialogs.export.csv"
-#define GNC_PREF_PANED_POS "paned-position"
-#define ASSISTANT_CSV_EXPORT_CM_CLASS "assistant-csv-export"
-
-/* This static indicates the debugging module that this .o belongs to.  */
-static QofLogModule log_module = GNC_MOD_ASSISTANT;
-
-/*************************************************************************/
-
-void csv_export_assistant_prepare (GtkAssistant  *assistant, GtkWidget *page, gpointer user_data);
-void csv_export_assistant_finish (GtkAssistant *gtkassistant, gpointer user_data);
-void csv_export_assistant_cancel (GtkAssistant *gtkassistant, gpointer user_data);
-void csv_export_assistant_close (GtkAssistant *gtkassistant, gpointer user_data);
-
-void csv_export_assistant_start_page_prepare (GtkAssistant *assistant, gpointer user_data);
-void csv_export_assistant_account_page_prepare (GtkAssistant *gtkassistant, gpointer user_data);
-void csv_export_assistant_file_page_prepare (GtkAssistant *assistant, gpointer user_data);
-void csv_export_assistant_finish_page_prepare (GtkAssistant *assistant, gpointer user_data);
-void csv_export_assistant_summary_page_prepare (GtkAssistant *assistant, gpointer user_data);
-
-void csv_export_quote_cb (GtkToggleButton *button, gpointer user_data );
-void csv_export_sep_cb (GtkWidget *radio, gpointer user_data );
-void csv_export_custom_entry_cb (GtkWidget *widget, gpointer user_data );
-
-void csv_export_show_range_cb (GtkRadioButton *button, gpointer user_data);
-void csv_export_start_date_cb (GtkWidget *radio, gpointer user_data);
-void csv_export_end_date_cb (GtkWidget *radio, gpointer user_data);
-
-void csv_export_file_chooser_confirm_cb (GtkWidget *button, CsvExportInfo *info);
-
-static const gchar *finish_tree_string = N_(
-            /* Translators: %s is the file name string. */
-            "The account tree will be exported to the file '%s' when you click 'Apply'.\n\n"
-            "You can also go back and verify your selections by clicking on 'Back'"
-            " or 'Cancel' to Abort Export.\n");
-
-static const gchar *finish_trans_string = N_(
-            /* Translators: %s is the file name string and %u the number of accounts. */
-            "When you click 'Apply', the transactions will be exported to the file '%s' and"
-            " the number of accounts exported is %u.\n\n"
-            "You can also go back and verify your selections by clicking on 'Back'"
-            " or 'Cancel' to Abort Export.\n");
-
-static const gchar *start_tree_string = N_(
-        "This assistant will help you export the Account Tree to a file.\n\n"
-        "Select the settings you require for the file and then click 'Forward' to proceed"
-        " or 'Cancel' to Abort Export.\n");
-
-static const gchar *start_trans_string = N_(
-            "This assistant will help you export the Transactions to a file.\n\n"
-            "Select the settings you require for the file and then click 'Forward' to proceed"
-            " or 'Cancel' to Abort Export.\n");
-
-
-/**************************************************
- * csv_export_file_chooser_confirm_cb
- *
- * call back for ok button in file chooser widget
- **************************************************/
-void
-csv_export_file_chooser_confirm_cb (GtkWidget *button, CsvExportInfo *info)
-{
-    GtkAssistant *assistant = GTK_ASSISTANT(info->window);
-    gint num = gtk_assistant_get_current_page (assistant);
-    GtkWidget *page = gtk_assistant_get_nth_page (assistant, num);
-
-    gchar *file_name;
-
-    gtk_assistant_set_page_complete (assistant, page, FALSE);
-
-    file_name = gtk_file_chooser_get_filename ( GTK_FILE_CHOOSER(info->file_chooser ));
-
-    if (file_name)
-    {
-        if (g_file_test(file_name, G_FILE_TEST_EXISTS ))
-        {
-            const char *format = _("The file %s already exists. "
-                                   "Are you sure you want to overwrite it?");
-
-            /* if user says cancel, we should break out */
-            if (!gnc_verify_dialog (NULL, FALSE, format, file_name))
-                return;
-        }
-
-        info->file_name = g_strdup(file_name);
-        gtk_assistant_set_page_complete (assistant, page, TRUE);
-    }
-
-    if (file_name)
-    {
-        gchar *filepath = gnc_uri_get_path ( file_name );
-        gchar *filedir = g_path_get_dirname( filepath );
-        info->starting_dir = g_strdup(filedir);
-        g_free ( filedir );
-        g_free ( filepath );
-    }
-    g_free(file_name);
-
-    DEBUG("file_name selected is %s", info->file_name);
-    DEBUG("starting directory is %s", info->starting_dir);
-
-    /* Step to next page if page is complete */
-    if(gtk_assistant_get_page_complete(assistant, page))
-        gtk_assistant_set_current_page (assistant, num + 1);
-}
-
-
-/*******************************************************
- * csv_export_sep_cb
- *
- * call back for type of separartor required
- *******************************************************/
-void csv_export_sep_cb (GtkWidget *radio, gpointer user_data )
-{
-    CsvExportInfo *info = user_data;
-    const gchar *name;
-
-    GtkAssistant *assistant = GTK_ASSISTANT(info->window);
-    gint num = gtk_assistant_get_current_page (assistant);
-    GtkWidget *page = gtk_assistant_get_nth_page (assistant, num);
-
-    if (!gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(radio)))
-    {
-        LEAVE("1st callback of pair. Defer to 2nd callback.");
-        return;
-    }
-
-    name = gtk_buildable_get_name(GTK_BUILDABLE(radio));
-
-    gtk_widget_set_sensitive(info->custom_entry, FALSE);
-    info->use_custom = FALSE;
-    gtk_assistant_set_page_complete (assistant, page, TRUE);
-
-    if (g_strcmp0(name, "comma_radio") == 0)
-        info->separator_str = ",";
-    if (g_strcmp0(name, "colon_radio") == 0)
-        info->separator_str = ":";
-    if (g_strcmp0(name, "semicolon_radio") == 0)
-        info->separator_str = ";";
-
-    if (g_strcmp0(name, "custom_radio") == 0)
-    {
-        gtk_widget_set_sensitive(info->custom_entry, TRUE);
-        info->use_custom = TRUE;
-        if (gtk_entry_get_text_length (GTK_ENTRY(info->custom_entry)) == 0)
-            gtk_assistant_set_page_complete (assistant, page, FALSE);
-    }
-}
-
-
-/*******************************************************
- * csv_export_quote_cb
- *
- * call back for use of quotes
- *******************************************************/
-void csv_export_quote_cb (GtkToggleButton *button, gpointer user_data )
-{
-    CsvExportInfo *info = user_data;
-
-    if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(button)))
-        info->use_quotes = TRUE;
-    else
-        info->use_quotes = FALSE;
-}
-
-
-/*******************************************************
- * csv_export_custom_entry_cb
- *
- * call back for custom separator
- *******************************************************/
-void csv_export_custom_entry_cb (GtkWidget *widget, gpointer user_data )
-{
-    CsvExportInfo *info = user_data;
-    const gchar *custom_str;
-
-    GtkAssistant *assistant = GTK_ASSISTANT(info->window);
-    gint num = gtk_assistant_get_current_page (assistant);
-    GtkWidget *page = gtk_assistant_get_nth_page (assistant, num);
-
-    custom_str = gtk_entry_get_text(GTK_ENTRY(info->custom_entry));
-    info->separator_str = strdup(custom_str);
-
-    if (info->use_custom == TRUE && gtk_entry_get_text_length (GTK_ENTRY(info->custom_entry)) == 0)
-
-        gtk_assistant_set_page_complete (assistant, page, FALSE);
-    else
-        gtk_assistant_set_page_complete (assistant, page, TRUE);
-}
-
-
-/*******************************************************
- * load_settings
- *
- * load the default settings for the assistant
- *******************************************************/
-static
-void load_settings (CsvExportInfo *info)
-{
-    info->use_quotes = TRUE;
-    info->separator_str = ",";
-    info->file_name = NULL;
-    info->starting_dir = NULL;
-
-    /* The default directory for the user to select files. */
-    info->starting_dir = gnc_get_default_directory(GNC_PREFS_GROUP);
-}
-
-/* =============================================================== */
-
-/*******************************************************
- * csv_export_cursor_changed_cb
- *
- * call back for cursor selection in account tree
- *******************************************************/
-static void
-csv_export_cursor_changed_cb (GtkWidget *widget, gpointer user_data)
-{
-    CsvExportInfo *info = user_data;
-    GncTreeViewAccount *account_tree;
-    Account *account;
-    gint num_children;
-
-    account_tree = GNC_TREE_VIEW_ACCOUNT (info->csva.account_treeview);
-    account = gnc_tree_view_account_get_cursor_account (account_tree);
-    if (!account)
-    {
-        gtk_widget_set_sensitive(info->csva.select_button, FALSE);
-        return;
-    }
-    num_children = gnc_tree_view_account_count_children(account_tree, account);
-    gtk_widget_set_sensitive(info->csva.select_button, num_children > 0);
-}
-
-
-/*******************************************************
- * show_acct_type_accounts
- *
- * show required accounts in account tree
- *******************************************************/
-static void
-show_acct_type_accounts (CsvExportInfo *info)
-{
-    GncTreeViewAccount *tree;
-    AccountViewInfo Viewinfo;
-    GNCAccountType type;
-
-    tree = GNC_TREE_VIEW_ACCOUNT (info->csva.account_treeview);
-
-    gnc_tree_view_account_get_view_info (tree, &Viewinfo);
-
-    for (type = 0; type < NUM_ACCOUNT_TYPES; type++) /* from Account.h */
-    {
-        if (info->csva.account_type == ACCT_TYPE_EXPENSE)
-            Viewinfo.include_type[type] = (type == ACCT_TYPE_EXPENSE);
-        else if (info->csva.account_type == ACCT_TYPE_INCOME)
-            Viewinfo.include_type[type] = (type == ACCT_TYPE_INCOME);
-        else if (info->csva.account_type == ACCT_TYPE_ASSET)
-            Viewinfo.include_type[type] = ((type == ACCT_TYPE_BANK)  ||
-                                           (type == ACCT_TYPE_CASH)      ||
-                                           (type == ACCT_TYPE_ASSET)     ||
-                                           (type == ACCT_TYPE_STOCK)     ||
-                                           (type == ACCT_TYPE_MUTUAL)    ||
-                                           (type == ACCT_TYPE_RECEIVABLE));
-        else if (info->csva.account_type == ACCT_TYPE_LIABILITY)
-            Viewinfo.include_type[type] = ((type == ACCT_TYPE_CREDIT) ||
-                                           (type == ACCT_TYPE_LIABILITY) ||
-                                           (type == ACCT_TYPE_EQUITY)    ||
-                                           (type == ACCT_TYPE_PAYABLE));
-        else
-            Viewinfo.include_type[type] = FALSE;
-    }
-    gnc_tree_view_account_set_view_info (tree, &Viewinfo);
-    csv_export_cursor_changed_cb(GTK_WIDGET(tree), info);
-}
-
-
-/*******************************************************
- * account_filter_func
- *
- * update filter for account tree
- *******************************************************/
-static gboolean
-account_filter_func (Account *account, gpointer user_data)
-{
-    CsvExportInfo *info = user_data;
-    gboolean included = FALSE;
-
-    if ((info->csva.account_type == ACCT_TYPE_INCOME) ||
-            (info->csva.account_type == ACCT_TYPE_EXPENSE))
-        included = (xaccAccountGetType (account) == info->csva.account_type);
-    else if (info->csva.account_type == ACCT_TYPE_ASSET)
-        included = ((xaccAccountGetType (account) == ACCT_TYPE_BANK) ||
-                    (xaccAccountGetType (account) == ACCT_TYPE_CASH) ||
-                    (xaccAccountGetType (account) == ACCT_TYPE_ASSET) ||
-                    (xaccAccountGetType (account) == ACCT_TYPE_STOCK) ||
-                    (xaccAccountGetType (account) == ACCT_TYPE_MUTUAL) ||
-                    (xaccAccountGetType (account) == ACCT_TYPE_RECEIVABLE));
-    else if (info->csva.account_type == ACCT_TYPE_LIABILITY)
-        included = ((xaccAccountGetType (account) == ACCT_TYPE_CREDIT) ||
-                    (xaccAccountGetType (account) == ACCT_TYPE_LIABILITY) ||
-                    (xaccAccountGetType (account) == ACCT_TYPE_EQUITY) ||
-                    (xaccAccountGetType (account) == ACCT_TYPE_PAYABLE));
-    else
-        included = FALSE;
-    return included;
-}
-
-
-/*******************************************************
- * update_accounts_tree
- *
- * update the account tree
- *******************************************************/
-static int
-update_accounts_tree (CsvExportInfo *info)
-{
-    GncTreeViewAccount *tree;
-    GtkTreeSelection* selection;
-    GtkWidget *label;
-    int num_accounts;
-    char *string;
-
-    tree = GNC_TREE_VIEW_ACCOUNT(info->csva.account_treeview);
-    selection = gtk_tree_view_get_selection (GTK_TREE_VIEW(tree));
-    num_accounts = gtk_tree_selection_count_selected_rows (selection);
-
-    label = info->csva.num_acct_label;
-
-    string = g_strdup_printf ("%d", num_accounts);
-    gtk_label_set_text (GTK_LABEL (label), string);
-    g_free (string);
-
-    return num_accounts;
-}
-
-
-/*******************************************************
- * csv_export_account_changed_cb
- *
- * update account list after selection changed
- *******************************************************/
-static void
-csv_export_account_changed_cb (GtkTreeSelection *selection,
-                               gpointer user_data)
-{
-    CsvExportInfo *info = user_data;
-    GtkAssistant *assistant = GTK_ASSISTANT(info->window);
-    gint num = gtk_assistant_get_current_page (assistant);
-    GtkWidget *page = gtk_assistant_get_nth_page (assistant, num);
-
-    GncTreeViewAccount *view;
-
-    g_return_if_fail(GTK_IS_TREE_SELECTION(selection));
-
-    info->csva.num_accounts = update_accounts_tree (info);
-
-    /* Enable the Forward Assistant Button if we have accounts */
-    if (info->csva.num_accounts > 0)
-        gtk_assistant_set_page_complete (assistant, page, TRUE);
-    else
-        gtk_assistant_set_page_complete (assistant, page, FALSE);
-
-    view = GNC_TREE_VIEW_ACCOUNT(info->csva.account_treeview);
-    info->csva.account_list = gnc_tree_view_account_get_selected_accounts (view);
-}
-
-
-/*******************************************************
- * csv_export_select_subaccounts_clicked_cb
- *
- * select all the sub accounts
- *******************************************************/
-static void
-csv_export_select_subaccounts_clicked_cb (GtkWidget *widget, gpointer user_data)
-{
-    CsvExportInfo *info = user_data;
-    GncTreeViewAccount *account_tree;
-    Account *account;
-
-    account_tree = GNC_TREE_VIEW_ACCOUNT (info->csva.account_treeview);
-    account = gnc_tree_view_account_get_cursor_account (account_tree);
-    if (!account)
-        return;
-
-    gnc_tree_view_account_select_subaccounts (account_tree, account);
-
-    gtk_widget_grab_focus (info->csva.account_treeview);
-}
-
-
-/*******************************************************
- * csv_export_info_acct_type_cb
- *
- * select which type of accounts to display
- *******************************************************/
-static void
-csv_export_info_acct_type_cb (GtkWidget *w, gpointer user_data)
-{
-    CsvExportInfo *info = user_data;
-    const gchar *button_name;
-
-    if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (w)))
-    {
-        button_name = gtk_buildable_get_name(GTK_BUILDABLE(w));
-        if (g_strcmp0 (button_name, "income_radio") == 0)
-            info->csva.account_type = ACCT_TYPE_INCOME;
-        else if (g_strcmp0 (button_name, "expense_radio") == 0)
-            info->csva.account_type = ACCT_TYPE_EXPENSE;
-        else if (g_strcmp0 (button_name, "asset_radio") == 0)
-            info->csva.account_type = ACCT_TYPE_ASSET;
-        else if (g_strcmp0 (button_name, "liab_eq_radio") == 0)
-            info->csva.account_type = ACCT_TYPE_LIABILITY;
-        else
-            return;
-
-        show_acct_type_accounts (info);
-        gnc_tree_view_account_refilter
-        (GNC_TREE_VIEW_ACCOUNT (info->csva.account_treeview));
-        update_accounts_tree (info);
-    }
-    else
-        return;
-}
-
-/* =============================================================== */
-
-/*******************************************************
- * get_filter_times
- *
- * get the start and end times from the dialog
- *******************************************************/
-static void
-get_filter_times (CsvExportInfo *info)
-{
-    time64 time_val;
-
-    if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(info->csvd.start_date_choose)))
-    {
-        time_val = gnc_date_edit_get_date(GNC_DATE_EDIT(info->csvd.start_date));
-        time_val = gnc_time64_get_day_start(time_val);
-        info->csvd.start_time = time_val;
-    }
-    else
-    {
-        if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(info->csvd.start_date_today)))
-        {
-            info->csvd.start_time = gnc_time64_get_today_start();
-        }
-        else
-        {
-            info->csvd.start_time = 0;
-        }
-    }
-
-    if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(info->csvd.end_date_choose)))
-    {
-        time_val = gnc_date_edit_get_date(GNC_DATE_EDIT(info->csvd.end_date));
-        time_val = gnc_time64_get_day_end(time_val);
-        info->csvd.end_time = time_val;
-    }
-    else
-    {
-        if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(info->csvd.start_date_today)))
-        {
-            info->csvd.end_time = gnc_time64_get_today_end();
-        }
-        else
-        {
-            info->csvd.end_time = gnc_time (NULL);
-        }
-    }
-}
-
-
-/*******************************************************
- * csv_export_show_range_cb
- *
- * call back for show range button
- *******************************************************/
-void
-csv_export_show_range_cb (GtkRadioButton *button, gpointer user_data)
-{
-    CsvExportInfo *info = user_data;
-    gboolean active;
-
-    g_return_if_fail(GTK_IS_RADIO_BUTTON(button));
-
-    active = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(button));
-    gtk_widget_set_sensitive(info->csvd.table, active);
-}
-
-
-/*******************************************************
- * csv_export_date_changed_cb
- *
- * call back for when a date changes
- *******************************************************/
-static void
-csv_export_date_changed_cb (GtkWidget *w, gpointer user_data)
-{
-    CsvExportInfo *info = user_data;
-
-    get_filter_times(info);
-}
-
-
-/*******************************************************
- * csv_export_start_date_cb
- *
- * call back for when the start date changes
- *******************************************************/
-void
-csv_export_start_date_cb (GtkWidget *radio, gpointer user_data)
-{
-    CsvExportInfo *info = user_data;
-    const gchar *name;
-    gboolean active;
-
-    g_return_if_fail(GTK_IS_RADIO_BUTTON(radio));
-
-    if (!gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(radio)))
-    {
-        LEAVE("1st callback of pair. Defer to 2nd callback.");
-        return;
-    }
-
-    name = gtk_buildable_get_name(GTK_BUILDABLE(radio));
-    active = ( g_strcmp0(name, g_strdup("start_date_choose")) == 0 ? 1 : 0 );
-    gtk_widget_set_sensitive(info->csvd.start_date, active);
-    get_filter_times(info);
-}
-
-
-/*******************************************************
- * csv_export_end_date_cb
- *
- * call back for when the end date changes
- *******************************************************/
-void
-csv_export_end_date_cb (GtkWidget *radio, gpointer user_data)
-{
-    CsvExportInfo *info = user_data;
-    const gchar *name;
-    gboolean active;
-
-    g_return_if_fail(GTK_IS_RADIO_BUTTON(radio));
-
-    if (!gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(radio)))
-    {
-        LEAVE("1st callback of pair. Defer to 2nd callback.");
-        return;
-    }
-
-    name = gtk_buildable_get_name(GTK_BUILDABLE(radio));
-    active = ( g_strcmp0(name, g_strdup("end_date_choose")) == 0 ? 1 : 0 );
-    gtk_widget_set_sensitive(info->csvd.end_date, active);
-    get_filter_times(info);
-}
-
-
-/*******************************************************************
- * get_earliest_in_book
- *
- * Find the earliest date occuring in the book.  Do this by making
- * a query and sorting by date. Since the truncated sort returns
- * only the *last* search results, sort in decreasing order.
- *******************************************************************/
-static time64
-get_earliest_in_book (QofBook *book)
-{
-    QofQuery *q;
-    GSList *p1, *p2;
-    GList *res;
-    time64 earliest;
-
-    q = qof_query_create_for(GNC_ID_SPLIT);
-    qof_query_set_max_results(q, 1);
-    qof_query_set_book (q, book);
-
-    /* Sort by transaction date */
-    p1 = g_slist_prepend (NULL, TRANS_DATE_POSTED);
-    p1 = g_slist_prepend (p1, SPLIT_TRANS);
-    p2 = g_slist_prepend (NULL, QUERY_DEFAULT_SORT);
-    qof_query_set_sort_order (q, p1, p2, NULL);
-
-    /* Reverse the sort order */
-    qof_query_set_sort_increasing (q, FALSE, FALSE, FALSE);
-
-    /* Run the query, find the earliest transaction date */
-    res = qof_query_run (q);
-
-    if (res)
-    {
-        earliest = xaccQueryGetEarliestDateFound (q);
-    }
-    else
-    {
-        /* If no results, we don't want to bomb totally */
-        earliest = gnc_time (0);
-    }
-
-    qof_query_destroy (q);
-    return earliest;
-}
-
-
-/* =============================================================== */
-
-
-/*******************************************************
- * Assistant page prepare functions
- *******************************************************/
-void
-csv_export_assistant_start_page_prepare (GtkAssistant *assistant,
-        gpointer user_data)
-{
-    CsvExportInfo *info = user_data;
-    gint num = gtk_assistant_get_current_page (assistant);
-    GtkWidget *page = gtk_assistant_get_nth_page (assistant, num);
-
-    /* Set Start page text */
-    if (info->export_type == XML_EXPORT_TREE)
-        gtk_label_set_text (GTK_LABEL(info->start_label), gettext (start_tree_string));
-    else
-        gtk_label_set_text (GTK_LABEL(info->start_label), gettext (start_trans_string));
-
-    /* Enable the Assistant Buttons */
-    gtk_assistant_set_page_complete (assistant, page, TRUE);
-}
-
-
-void
-csv_export_assistant_account_page_prepare (GtkAssistant *assistant,
-        gpointer user_data)
-{
-    CsvExportInfo *info = user_data;
-    gint num = gtk_assistant_get_current_page (assistant);
-    GtkWidget *page = gtk_assistant_get_nth_page (assistant, num);
-
-    /* If we are doing tree export, step over account select page */
-    if (info->export_type == XML_EXPORT_TREE)
-        gtk_assistant_set_current_page (assistant, num + 1 );
-
-    /* Enable the Forward Assistant Button if we have accounts */
-    if (info->csva.num_accounts > 0)
-        gtk_assistant_set_page_complete (assistant, page, TRUE);
-    else
-        gtk_assistant_set_page_complete (assistant, page, FALSE);
-}
-
-
-void
-csv_export_assistant_file_page_prepare (GtkAssistant *assistant,
-                                        gpointer user_data)
-{
-    CsvExportInfo *info = user_data;
-    gint num = gtk_assistant_get_current_page (assistant);
-    GtkWidget *page = gtk_assistant_get_nth_page (assistant, num);
-
-    /* Set the default directory */
-    if (info->starting_dir)
-        gtk_file_chooser_set_current_folder(GTK_FILE_CHOOSER(info->file_chooser), info->starting_dir);
-    gtk_file_chooser_set_current_name (GTK_FILE_CHOOSER(info->file_chooser), "");
-
-    /* Disable the Forward Assistant Button */
-    gtk_assistant_set_page_complete (assistant, page, FALSE);
-}
-
-
-void
-csv_export_assistant_finish_page_prepare (GtkAssistant *assistant,
-        gpointer user_data)
-{
-    CsvExportInfo *info = user_data;
-    gint num = gtk_assistant_get_current_page (assistant);
-    GtkWidget *page = gtk_assistant_get_nth_page (assistant, num);
-    gchar *text;
-
-    /* Set Finish page text */
-    if (info->export_type == XML_EXPORT_TREE)
-        text = g_strdup_printf (gettext (finish_tree_string), info->file_name);
-    else
-        text = g_strdup_printf (gettext (finish_trans_string), info->file_name, info->csva.num_accounts);
-
-    gtk_label_set_text (GTK_LABEL(info->finish_label), text);
-    g_free(text);
-
-    /* Enable the Assistant Buttons */
-    gtk_assistant_set_page_complete (assistant, page, TRUE);
-}
-
-
-void
-csv_export_assistant_summary_page_prepare (GtkAssistant *assistant,
-        gpointer user_data)
-{
-    CsvExportInfo *info = user_data;
-    gchar *text, *mtext;
-    gnc_set_default_directory(GNC_PREFS_GROUP, info->starting_dir);
-
-    if (info->failed)
-        text = _("There was a problem with the export, this could be due to lack of space, "
-                 "permissions or unable to access folder. Check the trace file for further logging!\n"
-                 "You may need to enable debugging.\n");
-    else
-        text = _("File exported successfully!\n");
-
-    mtext = g_strdup_printf("<span size=\"medium\"><b>%s</b></span>", text);
-
-    gtk_label_set_markup(GTK_LABEL(info->summary_label), mtext);
-
-    g_free(mtext);
-}
-
-
-void
-csv_export_assistant_prepare (GtkAssistant *assistant, GtkWidget *page,
-                              gpointer user_data)
-{
-    gint currentpage = gtk_assistant_get_current_page(assistant);
-
-    switch (currentpage)
-    {
-    case 0:
-        /* Current page is Start page */
-        csv_export_assistant_start_page_prepare (assistant, user_data);
-        break;
-    case 1:
-        /* Current page is Account select page */
-        csv_export_assistant_account_page_prepare (assistant, user_data);
-        break;
-    case 2:
-        /* Current page is file select page */
-        csv_export_assistant_file_page_prepare (assistant, user_data);
-        break;
-    case 3:
-        /* Current page is Finish page */
-        csv_export_assistant_finish_page_prepare (assistant, user_data);
-        break;
-    case 4:
-        /* Current page is Summary page */
-        csv_export_assistant_summary_page_prepare (assistant, user_data);
-        break;
-    }
-}
-
-
-/*******************************************************
- * Assistant call back functions
- *******************************************************/
-static void
-csv_export_assistant_destroy_cb (GtkObject *object, gpointer user_data)
-{
-    CsvExportInfo *info = user_data;
-    gnc_unregister_gui_component_by_data (ASSISTANT_CSV_EXPORT_CM_CLASS, info);
-    g_free (info);
-}
-
-void
-csv_export_assistant_cancel (GtkAssistant *assistant, gpointer user_data)
-{
-    CsvExportInfo *info = user_data;
-    gnc_close_gui_component_by_data (ASSISTANT_CSV_EXPORT_CM_CLASS, info);
-}
-
-void
-csv_export_assistant_close (GtkAssistant *assistant, gpointer user_data)
-{
-    CsvExportInfo *info = user_data;
-    gnc_close_gui_component_by_data (ASSISTANT_CSV_EXPORT_CM_CLASS, info);
-}
-
-void
-csv_export_assistant_finish (GtkAssistant *assistant, gpointer user_data)
-{
-    CsvExportInfo *info = user_data;
-
-    if (info->export_type == XML_EXPORT_TREE)
-        csv_tree_export (info);
-    else
-        csv_transactions_export (info);
-}
-
-static void
-csv_export_close_handler (gpointer user_data)
-{
-    CsvExportInfo *info = user_data;
-
-    g_free(info->file_name);
-    g_free(info->starting_dir);
-
-    gnc_save_window_size(GNC_PREFS_GROUP, GTK_WINDOW(info->window));
-    gtk_widget_destroy (info->window);
-}
-
-/*******************************************************
- * Create the Assistant
- *******************************************************/
-static GtkWidget *
-csv_export_assistant_create (CsvExportInfo *info)
-{
-    GtkBuilder *builder;
-    GtkWidget *window;
-    GtkWidget *box, *h_box;
-    GtkWidget *button;
-    GtkWidget *table, *hbox;
-    time64 start_time, end_time;
-
-    builder = gtk_builder_new();
-    gnc_builder_add_from_file  (builder , "assistant-csv-export.glade", "CSV Export Assistant");
-    window = GTK_WIDGET(gtk_builder_get_object (builder, "CSV Export Assistant"));
-    info->window = window;
-
-    /* Set the assistant colors */
-    gnc_assistant_set_colors (GTK_ASSISTANT (info->window));
-
-    /* Load default settings */
-    load_settings (info);
-
-    /* Start Page */
-    info->start_label = GTK_WIDGET(gtk_builder_get_object(builder, "start_label"));
-    info->custom_entry = GTK_WIDGET(gtk_builder_get_object(builder, "custom_entry"));
-    gtk_widget_set_sensitive(info->custom_entry, FALSE);
-
-    /* Account Page */
-    {
-        GtkTreeView *tree_view;
-        GtkTreeSelection *selection;
-        GtkWidget *income_radio, *expense_radio, *asset_radio,
-                  *liab_eq_radio, *box, *label;
-
-        info->csva.acct_info = GTK_WIDGET(gtk_builder_get_object (builder, "acct_info_vbox"));
-        info->csva.num_acct_label = GTK_WIDGET(gtk_builder_get_object (builder, "num_accounts_label"));
-
-        tree_view = gnc_tree_view_account_new (FALSE);
-        gnc_tree_view_account_set_filter (GNC_TREE_VIEW_ACCOUNT(tree_view),
-                                          account_filter_func, info, NULL);
-        info->csva.account_treeview = GTK_WIDGET(tree_view);
-
-        selection = gtk_tree_view_get_selection (tree_view);
-        gtk_tree_selection_set_mode (selection, GTK_SELECTION_EXTENDED);
-        g_signal_connect (G_OBJECT (selection), "changed",
-                          G_CALLBACK (csv_export_account_changed_cb), info);
-
-        gtk_widget_show (info->csva.account_treeview);
-        box = GTK_WIDGET(gtk_builder_get_object (builder, "account_scroll"));
-        gtk_container_add (GTK_CONTAINER (box), info->csva.account_treeview);
-
-        label = GTK_WIDGET(gtk_builder_get_object (builder, "accounts_label"));
-        gtk_label_set_mnemonic_widget(GTK_LABEL(label), GTK_WIDGET(tree_view));
-
-        income_radio = GTK_WIDGET(gtk_builder_get_object (builder, "income_radio"));
-        expense_radio = GTK_WIDGET(gtk_builder_get_object (builder, "expense_radio"));
-        info->csva.expense_radio = expense_radio;
-        asset_radio = GTK_WIDGET(gtk_builder_get_object (builder, "asset_radio"));
-        info->csva.asset_radio = asset_radio;
-        liab_eq_radio = GTK_WIDGET(gtk_builder_get_object (builder, "liab_eq_radio"));
-        info->csva.liab_eq_radio = liab_eq_radio;
-        info->csva.account_type = ACCT_TYPE_EXPENSE;
-        gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(expense_radio), TRUE);
-
-        g_signal_connect (G_OBJECT (income_radio), "toggled",
-                          G_CALLBACK  (csv_export_info_acct_type_cb), info);
-        g_signal_connect (G_OBJECT (expense_radio), "toggled",
-                          G_CALLBACK  (csv_export_info_acct_type_cb), info);
-        g_signal_connect (G_OBJECT (asset_radio), "toggled",
-                          G_CALLBACK  (csv_export_info_acct_type_cb), info);
-        g_signal_connect (G_OBJECT (liab_eq_radio), "toggled",
-                          G_CALLBACK  (csv_export_info_acct_type_cb), info);
-    }
-
-    /* select subaccounts button */
-    {
-        GtkWidget *button;
-
-        button = GTK_WIDGET(gtk_builder_get_object (builder, "select_subaccounts_button"));
-        info->csva.select_button = button;
-
-        g_signal_connect (G_OBJECT (button), "clicked",
-                          G_CALLBACK  (csv_export_select_subaccounts_clicked_cb), info);
-        g_signal_connect (G_OBJECT (info->csva.account_treeview), "cursor_changed",
-                          G_CALLBACK  (csv_export_cursor_changed_cb), info);
-    }
-
-    /* Set the date info */
-    button = GTK_WIDGET(gtk_builder_get_object (builder, "show_range"));
-
-    /* Earliest and Latest in Book */
-    start_time = get_earliest_in_book (gnc_get_current_book());
-    end_time = gnc_time (NULL);
-
-    info->csvd.start_time = start_time;
-    info->csvd.end_time = end_time;
-    gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(button), FALSE);
-
-    table = GTK_WIDGET(gtk_builder_get_object (builder, "select_range_table"));
-    info->csvd.table = table;
-    gtk_widget_set_sensitive(GTK_WIDGET(table), FALSE);
-
-    info->csvd.start_date_choose = GTK_WIDGET(gtk_builder_get_object (builder, "start_date_choose"));
-    info->csvd.start_date_today = GTK_WIDGET(gtk_builder_get_object (builder, "start_date_today"));
-    info->csvd.end_date_choose = GTK_WIDGET(gtk_builder_get_object (builder, "end_date_choose"));
-    info->csvd.end_date_today = GTK_WIDGET(gtk_builder_get_object (builder, "end_date_today"));
-
-    /* Start date info */
-    info->csvd.start_date = gnc_date_edit_new (gnc_time (NULL), FALSE, FALSE);
-    hbox = GTK_WIDGET(gtk_builder_get_object (builder, "start_date_hbox"));
-    gtk_box_pack_start (GTK_BOX (hbox), info->csvd.start_date, TRUE, TRUE, 0);
-    gtk_widget_show (info->csvd.start_date);
-    gnc_date_edit_set_time (GNC_DATE_EDIT(info->csvd.start_date), start_time);
-    g_signal_connect (G_OBJECT (info->csvd.start_date), "date-changed",
-                      G_CALLBACK (csv_export_date_changed_cb), info);
-
-    /* End date info */
-    info->csvd.end_date = gnc_date_edit_new (gnc_time (NULL), FALSE, FALSE);
-    hbox = GTK_WIDGET(gtk_builder_get_object (builder, "end_date_hbox"));
-    gtk_box_pack_start (GTK_BOX (hbox), info->csvd.end_date, TRUE, TRUE, 0);
-    gtk_widget_show (info->csvd.end_date);
-    gnc_date_edit_set_time (GNC_DATE_EDIT(info->csvd.end_date), end_time);
-    g_signal_connect (G_OBJECT (info->csvd.end_date), "date-changed",
-                      G_CALLBACK (csv_export_date_changed_cb), info);
-
-    /* Load Accounts */
-    show_acct_type_accounts (info);
-    update_accounts_tree (info);
-
-    /* File chooser Page */
-    info->file_chooser = gtk_file_chooser_widget_new (GTK_FILE_CHOOSER_ACTION_SAVE);
-    button = gtk_button_new_from_stock(GTK_STOCK_OK);
-    gtk_widget_set_size_request (button, 100, -1);
-    gtk_widget_show (button);
-    h_box = gtk_hbox_new(TRUE, 0);
-    gtk_box_pack_start(GTK_BOX(h_box), button, FALSE, FALSE, 0);
-    gtk_file_chooser_set_extra_widget (GTK_FILE_CHOOSER(info->file_chooser), h_box);
-    g_signal_connect (G_OBJECT (button), "clicked",
-                      G_CALLBACK (csv_export_file_chooser_confirm_cb), info);
-
-
-
-
-    box = GTK_WIDGET(gtk_builder_get_object(builder, "file_page"));
-    gtk_box_pack_start (GTK_BOX (box), info->file_chooser, TRUE, TRUE, 6);
-    gtk_widget_show (info->file_chooser);
-
-    /* Finish Page */
-    info->finish_label = GTK_WIDGET(gtk_builder_get_object(builder, "end_page"));
-
-    /* Summary Page */
-    info->summary_label = GTK_WIDGET(gtk_builder_get_object(builder, "summary_page"));
-
-    g_signal_connect (G_OBJECT(window), "destroy",
-                      G_CALLBACK (csv_export_assistant_destroy_cb), info);
-
-    gnc_restore_window_size (GNC_PREFS_GROUP, GTK_WINDOW(info->window));
-    if (gnc_prefs_get_bool(GNC_PREFS_GROUP_GENERAL, GNC_PREF_SAVE_GEOMETRY))
-    {
-        GObject *object = gtk_builder_get_object (builder, "paned");
-        gnc_prefs_bind (GNC_PREFS_GROUP, GNC_PREF_PANED_POS, object, "position");
-    }
-
-    gtk_builder_connect_signals(builder, info);
-    g_object_unref(G_OBJECT(builder));
-    return window;
-}
-
-
-/********************************************************************\
- * gnc_file_csv_export                                              *
- * opens up a assistant to export accounts or transactions based on *
- * the type.                                                        *
- * Args:   export_type                                              *
- * Return: nothing                                                  *
-\********************************************************************/
-void
-gnc_file_csv_export (CsvExportType export_type)
-{
-    CsvExportInfo *info;
-
-    info = g_new0 (CsvExportInfo, 1);
-    info->export_type = export_type;
-    csv_export_assistant_create (info);
-    gnc_register_gui_component (ASSISTANT_CSV_EXPORT_CM_CLASS,
-                                NULL, csv_export_close_handler,
-                                info);
-    gtk_widget_show_all (info->window);
-    gnc_window_adjust_for_screen (GTK_WINDOW(info->window));
-}

Deleted: gnucash/trunk/src/import-export/csv-export/assistant-csv-export.glade
===================================================================
--- gnucash/trunk/src/import-export/csv-export/assistant-csv-export.glade	2013-12-15 17:20:10 UTC (rev 23566)
+++ gnucash/trunk/src/import-export/csv-export/assistant-csv-export.glade	2013-12-15 17:21:20 UTC (rev 23567)
@@ -1,913 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<interface>
-  <requires lib="gtk+" version="2.16"/>
-  <!-- interface-naming-policy project-wide -->
-  <object class="GtkAssistant" id="CSV Export Assistant">
-    <property name="can_focus">False</property>
-    <property name="border_width">12</property>
-    <property name="title" translatable="yes">CSV Export Assistant</property>
-    <property name="default_width">400</property>
-    <property name="default_height">500</property>
-    <signal name="close" handler="csv_export_assistant_close" swapped="no"/>
-    <signal name="apply" handler="csv_export_assistant_finish" swapped="no"/>
-    <signal name="prepare" handler="csv_export_assistant_prepare" swapped="no"/>
-    <signal name="cancel" handler="csv_export_assistant_cancel" swapped="no"/>
-    <child>
-      <object class="GtkVBox" id="start_page">
-        <property name="visible">True</property>
-        <property name="can_focus">False</property>
-        <property name="border_width">12</property>
-        <child>
-          <object class="GtkLabel" id="start_label">
-            <property name="visible">True</property>
-            <property name="can_focus">False</property>
-            <property name="label" translatable="yes">
-Select the type of Export required and the separator that will be used.
-</property>
-            <property name="justify">center</property>
-            <property name="wrap">True</property>
-          </object>
-          <packing>
-            <property name="expand">False</property>
-            <property name="fill">False</property>
-            <property name="position">0</property>
-          </packing>
-        </child>
-        <child>
-          <placeholder/>
-        </child>
-        <child>
-          <object class="GtkHSeparator" id="hseparator1">
-            <property name="visible">True</property>
-            <property name="can_focus">False</property>
-          </object>
-          <packing>
-            <property name="expand">False</property>
-            <property name="fill">True</property>
-            <property name="padding">6</property>
-            <property name="position">2</property>
-          </packing>
-        </child>
-        <child>
-          <placeholder/>
-        </child>
-        <child>
-          <object class="GtkFrame" id="frame1">
-            <property name="visible">True</property>
-            <property name="can_focus">False</property>
-            <property name="border_width">6</property>
-            <property name="label_xalign">0</property>
-            <property name="shadow_type">none</property>
-            <child>
-              <object class="GtkAlignment" id="alignment1">
-                <property name="visible">True</property>
-                <property name="can_focus">False</property>
-                <property name="left_padding">20</property>
-                <child>
-                  <object class="GtkTable" id="table1">
-                    <property name="visible">True</property>
-                    <property name="can_focus">False</property>
-                    <property name="n_columns">3</property>
-                    <property name="column_spacing">3</property>
-                    <property name="row_spacing">3</property>
-                    <child>
-                      <object class="GtkCheckButton" id="quote_tbutton">
-                        <property name="label" translatable="yes">Quotes</property>
-                        <property name="visible">True</property>
-                        <property name="can_focus">True</property>
-                        <property name="receives_default">False</property>
-                        <property name="use_action_appearance">False</property>
-                        <property name="active">True</property>
-                        <property name="draw_indicator">True</property>
-                        <signal name="toggled" handler="csv_export_quote_cb" swapped="no"/>
-                      </object>
-                      <packing>
-                        <property name="y_options">GTK_FILL</property>
-                      </packing>
-                    </child>
-                    <child>
-                      <placeholder/>
-                    </child>
-                    <child>
-                      <placeholder/>
-                    </child>
-                  </object>
-                </child>
-              </object>
-            </child>
-            <child type="label">
-              <object class="GtkLabel" id="label1">
-                <property name="visible">True</property>
-                <property name="can_focus">False</property>
-                <property name="label" translatable="yes">Use Quotes</property>
-                <property name="use_markup">True</property>
-              </object>
-            </child>
-          </object>
-          <packing>
-            <property name="expand">False</property>
-            <property name="fill">True</property>
-            <property name="position">4</property>
-          </packing>
-        </child>
-        <child>
-          <object class="GtkFrame" id="frame2">
-            <property name="visible">True</property>
-            <property name="can_focus">False</property>
-            <property name="border_width">6</property>
-            <property name="label_xalign">0</property>
-            <property name="shadow_type">none</property>
-            <child>
-              <object class="GtkAlignment" id="alignment2">
-                <property name="visible">True</property>
-                <property name="can_focus">False</property>
-                <property name="left_padding">20</property>
-                <child>
-                  <object class="GtkTable" id="table2">
-                    <property name="visible">True</property>
-                    <property name="can_focus">False</property>
-                    <property name="n_rows">2</property>
-                    <property name="n_columns">3</property>
-                    <property name="column_spacing">3</property>
-                    <property name="row_spacing">3</property>
-                    <property name="homogeneous">True</property>
-                    <child>
-                      <object class="GtkRadioButton" id="comma_radio">
-                        <property name="label" translatable="yes">Comma (,)</property>
-                        <property name="visible">True</property>
-                        <property name="can_focus">True</property>
-                        <property name="receives_default">False</property>
-                        <property name="use_action_appearance">False</property>
-                        <property name="active">True</property>
-                        <property name="draw_indicator">True</property>
-                        <signal name="toggled" handler="csv_export_sep_cb" swapped="no"/>
-                      </object>
-                      <packing>
-                        <property name="y_options">GTK_FILL</property>
-                      </packing>
-                    </child>
-                    <child>
-                      <object class="GtkRadioButton" id="colon_radio">
-                        <property name="label" translatable="yes">Colon (:)</property>
-                        <property name="visible">True</property>
-                        <property name="can_focus">True</property>
-                        <property name="receives_default">False</property>
-                        <property name="use_action_appearance">False</property>
-                        <property name="active">True</property>
-                        <property name="draw_indicator">True</property>
-                        <property name="group">comma_radio</property>
-                        <signal name="toggled" handler="csv_export_sep_cb" swapped="no"/>
-                      </object>
-                      <packing>
-                        <property name="left_attach">1</property>
-                        <property name="right_attach">2</property>
-                        <property name="x_options">GTK_FILL</property>
-                        <property name="y_options">GTK_FILL</property>
-                      </packing>
-                    </child>
-                    <child>
-                      <object class="GtkRadioButton" id="semicolon_radio">
-                        <property name="label" translatable="yes">Semicolon (;)</property>
-                        <property name="visible">True</property>
-                        <property name="can_focus">True</property>
-                        <property name="receives_default">False</property>
-                        <property name="use_action_appearance">False</property>
-                        <property name="active">True</property>
-                        <property name="draw_indicator">True</property>
-                        <property name="group">comma_radio</property>
-                        <signal name="toggled" handler="csv_export_sep_cb" swapped="no"/>
-                      </object>
-                      <packing>
-                        <property name="left_attach">2</property>
-                        <property name="right_attach">3</property>
-                        <property name="x_options">GTK_FILL</property>
-                        <property name="y_options">GTK_FILL</property>
-                      </packing>
-                    </child>
-                    <child>
-                      <object class="GtkRadioButton" id="custom_radio">
-                        <property name="label" translatable="yes">Custom</property>
-                        <property name="visible">True</property>
-                        <property name="can_focus">True</property>
-                        <property name="receives_default">False</property>
-                        <property name="use_action_appearance">False</property>
-                        <property name="active">True</property>
-                        <property name="draw_indicator">True</property>
-                        <property name="group">comma_radio</property>
-                        <signal name="toggled" handler="csv_export_sep_cb" swapped="no"/>
-                      </object>
-                      <packing>
-                        <property name="top_attach">1</property>
-                        <property name="bottom_attach">2</property>
-                        <property name="x_options">GTK_FILL</property>
-                        <property name="y_options">GTK_FILL</property>
-                      </packing>
-                    </child>
-                    <child>
-                      <object class="GtkEntry" id="custom_entry">
-                        <property name="visible">True</property>
-                        <property name="can_focus">True</property>
-                        <property name="invisible_char">&#x25CF;</property>
-                        <property name="invisible_char_set">True</property>
-                        <property name="primary_icon_activatable">False</property>
-                        <property name="secondary_icon_activatable">False</property>
-                        <property name="primary_icon_sensitive">True</property>
-                        <property name="secondary_icon_sensitive">True</property>
-                        <signal name="changed" handler="csv_export_custom_entry_cb" swapped="no"/>
-                      </object>
-                      <packing>
-                        <property name="left_attach">1</property>
-                        <property name="right_attach">3</property>
-                        <property name="top_attach">1</property>
-                        <property name="bottom_attach">2</property>
-                        <property name="x_options">GTK_FILL</property>
-                        <property name="y_options">GTK_FILL</property>
-                      </packing>
-                    </child>
-                  </object>
-                </child>
-              </object>
-            </child>
-            <child type="label">
-              <object class="GtkLabel" id="label2">
-                <property name="visible">True</property>
-                <property name="can_focus">False</property>
-                <property name="label" translatable="yes">Separators</property>
-                <property name="use_markup">True</property>
-              </object>
-            </child>
-          </object>
-          <packing>
-            <property name="expand">False</property>
-            <property name="fill">True</property>
-            <property name="position">5</property>
-          </packing>
-        </child>
-      </object>
-      <packing>
-        <property name="page_type">intro</property>
-        <property name="title" translatable="yes">Choose Export Settings</property>
-        <property name="complete">True</property>
-      </packing>
-    </child>
-    <child>
-      <object class="GtkVBox" id="account_page">
-        <property name="visible">True</property>
-        <property name="can_focus">False</property>
-        <property name="border_width">12</property>
-        <child>
-          <object class="GtkLabel" id="label5">
-            <property name="visible">True</property>
-            <property name="can_focus">False</property>
-            <property name="label" translatable="yes">Select the accounts to be exported and date range if required.</property>
-            <property name="wrap">True</property>
-          </object>
-          <packing>
-            <property name="expand">False</property>
-            <property name="fill">False</property>
-            <property name="position">0</property>
-          </packing>
-        </child>
-        <child>
-          <object class="GtkHPaned" id="paned">
-            <property name="visible">True</property>
-            <property name="can_focus">True</property>
-            <property name="position">1</property>
-            <child>
-              <object class="GtkVBox" id="acct_info_vbox">
-                <property name="visible">True</property>
-                <property name="can_focus">False</property>
-                <property name="border_width">6</property>
-                <child>
-                  <object class="GtkLabel" id="accounts_label">
-                    <property name="visible">True</property>
-                    <property name="can_focus">False</property>
-                    <property name="xalign">0</property>
-                    <property name="ypad">2</property>
-                    <property name="label" translatable="yes"><b>_Accounts</b></property>
-                    <property name="use_markup">True</property>
-                    <property name="use_underline">True</property>
-                  </object>
-                  <packing>
-                    <property name="expand">False</property>
-                    <property name="fill">False</property>
-                    <property name="position">0</property>
-                  </packing>
-                </child>
-                <child>
-                  <object class="GtkAlignment" id="alignment3">
-                    <property name="visible">True</property>
-                    <property name="can_focus">False</property>
-                    <property name="left_padding">12</property>
-                    <child>
-                      <object class="GtkVBox" id="vbox96">
-                        <property name="visible">True</property>
-                        <property name="can_focus">False</property>
-                        <child>
-                          <object class="GtkTable" id="table3">
-                            <property name="visible">True</property>
-                            <property name="can_focus">False</property>
-                            <property name="n_rows">2</property>
-                            <property name="n_columns">2</property>
-                            <child>
-                              <object class="GtkRadioButton" id="income_radio">
-                                <property name="label" translatable="yes">_Income</property>
-                                <property name="visible">True</property>
-                                <property name="can_focus">True</property>
-                                <property name="receives_default">False</property>
-                                <property name="use_action_appearance">False</property>
-                                <property name="use_underline">True</property>
-                                <property name="active">True</property>
-                                <property name="draw_indicator">True</property>
-                              </object>
-                            </child>
-                            <child>
-                              <object class="GtkRadioButton" id="expense_radio">
-                                <property name="label" translatable="yes">_Expense</property>
-                                <property name="visible">True</property>
-                                <property name="can_focus">True</property>
-                                <property name="receives_default">False</property>
-                                <property name="use_action_appearance">False</property>
-                                <property name="use_underline">True</property>
-                                <property name="draw_indicator">True</property>
-                                <property name="group">income_radio</property>
-                              </object>
-                              <packing>
-                                <property name="left_attach">1</property>
-                                <property name="right_attach">2</property>
-                              </packing>
-                            </child>
-                            <child>
-                              <object class="GtkRadioButton" id="asset_radio">
-                                <property name="label" translatable="yes">_Asset</property>
-                                <property name="visible">True</property>
-                                <property name="can_focus">True</property>
-                                <property name="receives_default">False</property>
-                                <property name="use_action_appearance">False</property>
-                                <property name="use_underline">True</property>
-                                <property name="draw_indicator">True</property>
-                                <property name="group">income_radio</property>
-                              </object>
-                              <packing>
-                                <property name="top_attach">1</property>
-                                <property name="bottom_attach">2</property>
-                              </packing>
-                            </child>
-                            <child>
-                              <object class="GtkRadioButton" id="liab_eq_radio">
-                                <property name="label" translatable="yes">_Liability/Equity</property>
-                                <property name="visible">True</property>
-                                <property name="can_focus">True</property>
-                                <property name="receives_default">False</property>
-                                <property name="use_action_appearance">False</property>
-                                <property name="use_underline">True</property>
-                                <property name="draw_indicator">True</property>
-                                <property name="group">income_radio</property>
-                              </object>
-                              <packing>
-                                <property name="left_attach">1</property>
-                                <property name="right_attach">2</property>
-                                <property name="top_attach">1</property>
-                                <property name="bottom_attach">2</property>
-                              </packing>
-                            </child>
-                          </object>
-                          <packing>
-                            <property name="expand">False</property>
-                            <property name="fill">True</property>
-                            <property name="position">0</property>
-                          </packing>
-                        </child>
-                        <child>
-                          <object class="GtkScrolledWindow" id="account_scroll">
-                            <property name="visible">True</property>
-                            <property name="can_focus">True</property>
-                            <property name="hscrollbar_policy">automatic</property>
-                            <property name="vscrollbar_policy">automatic</property>
-                            <property name="shadow_type">in</property>
-                            <child>
-                              <placeholder/>
-                            </child>
-                          </object>
-                          <packing>
-                            <property name="expand">True</property>
-                            <property name="fill">True</property>
-                            <property name="position">1</property>
-                          </packing>
-                        </child>
-                        <child>
-                          <object class="GtkHBox" id="hbox98">
-                            <property name="visible">True</property>
-                            <property name="can_focus">False</property>
-                            <property name="border_width">3</property>
-                            <property name="spacing">2</property>
-                            <child>
-                              <object class="GtkLabel" id="label42">
-                                <property name="visible">True</property>
-                                <property name="can_focus">False</property>
-                              </object>
-                              <packing>
-                                <property name="expand">True</property>
-                                <property name="fill">False</property>
-                                <property name="position">0</property>
-                              </packing>
-                            </child>
-                            <child>
-                              <object class="GtkLabel" id="label847733">
-                                <property name="visible">True</property>
-                                <property name="can_focus">False</property>
-                                <property name="xalign">1</property>
-                                <property name="label" translatable="yes">Accounts Selected:</property>
-                                <property name="justify">center</property>
-                              </object>
-                              <packing>
-                                <property name="expand">False</property>
-                                <property name="fill">False</property>
-                                <property name="position">1</property>
-                              </packing>
-                            </child>
-                            <child>
-                              <object class="GtkLabel" id="num_accounts_label">
-                                <property name="visible">True</property>
-                                <property name="can_focus">False</property>
-                                <property name="label" translatable="yes">0</property>
-                                <property name="justify">center</property>
-                              </object>
-                              <packing>
-                                <property name="expand">False</property>
-                                <property name="fill">False</property>
-                                <property name="position">2</property>
-                              </packing>
-                            </child>
-                            <child>
-                              <object class="GtkLabel" id="label43">
-                                <property name="visible">True</property>
-                                <property name="can_focus">False</property>
-                              </object>
-                              <packing>
-                                <property name="expand">True</property>
-                                <property name="fill">False</property>
-                                <property name="position">3</property>
-                              </packing>
-                            </child>
-                          </object>
-                          <packing>
-                            <property name="expand">False</property>
-                            <property name="fill">True</property>
-                            <property name="position">2</property>
-                          </packing>
-                        </child>
-                        <child>
-                          <object class="GtkHButtonBox" id="hbox99">
-                            <property name="visible">True</property>
-                            <property name="can_focus">False</property>
-                            <child>
-                              <object class="GtkButton" id="select_subaccounts_button">
-                                <property name="visible">True</property>
-                                <property name="can_focus">True</property>
-                                <property name="receives_default">True</property>
-                                <property name="border_width">3</property>
-                                <property name="use_action_appearance">False</property>
-                                <child>
-                                  <object class="GtkAlignment" id="alignment5">
-                                    <property name="visible">True</property>
-                                    <property name="can_focus">False</property>
-                                    <property name="xscale">0</property>
-                                    <property name="yscale">0</property>
-                                    <child>
-                                      <object class="GtkHBox" id="hbox100">
-                                        <property name="visible">True</property>
-                                        <property name="can_focus">False</property>
-                                        <property name="spacing">2</property>
-                                        <child>
-                                          <object class="GtkImage" id="image1">
-                                            <property name="visible">True</property>
-                                            <property name="can_focus">False</property>
-                                            <property name="stock">gtk-add</property>
-                                          </object>
-                                          <packing>
-                                            <property name="expand">False</property>
-                                            <property name="fill">False</property>
-                                            <property name="position">0</property>
-                                          </packing>
-                                        </child>
-                                        <child>
-                                          <object class="GtkLabel" id="label847737">
-                                            <property name="visible">True</property>
-                                            <property name="can_focus">False</property>
-                                            <property name="label" translatable="yes">_Select Subaccounts</property>
-                                            <property name="use_underline">True</property>
-                                          </object>
-                                          <packing>
-                                            <property name="expand">False</property>
-                                            <property name="fill">False</property>
-                                            <property name="position">1</property>
-                                          </packing>
-                                        </child>
-                                      </object>
-                                    </child>
-                                  </object>
-                                </child>
-                              </object>
-                              <packing>
-                                <property name="expand">False</property>
-                                <property name="fill">False</property>
-                                <property name="position">0</property>
-                              </packing>
-                            </child>
-                          </object>
-                          <packing>
-                            <property name="expand">False</property>
-                            <property name="fill">True</property>
-                            <property name="position">3</property>
-                          </packing>
-                        </child>
-                      </object>
-                    </child>
-                  </object>
-                  <packing>
-                    <property name="expand">True</property>
-                    <property name="fill">True</property>
-                    <property name="position">1</property>
-                  </packing>
-                </child>
-              </object>
-              <packing>
-                <property name="resize">False</property>
-                <property name="shrink">False</property>
-              </packing>
-            </child>
-            <child>
-              <object class="GtkVBox" id="date_vbox">
-                <property name="visible">True</property>
-                <property name="can_focus">False</property>
-                <property name="border_width">12</property>
-                <child>
-                  <object class="GtkLabel" id="label847680">
-                    <property name="visible">True</property>
-                    <property name="can_focus">False</property>
-                    <property name="xalign">0</property>
-                    <property name="label" translatable="yes"><b>_Dates</b></property>
-                    <property name="use_markup">True</property>
-                    <property name="use_underline">True</property>
-                  </object>
-                  <packing>
-                    <property name="expand">False</property>
-                    <property name="fill">False</property>
-                    <property name="position">0</property>
-                  </packing>
-                </child>
-                <child>
-                  <object class="GtkRadioButton" id="show_all">
-                    <property name="label" translatable="yes">Show _All</property>
-                    <property name="visible">True</property>
-                    <property name="can_focus">True</property>
-                    <property name="receives_default">False</property>
-                    <property name="use_action_appearance">False</property>
-                    <property name="use_underline">True</property>
-                    <property name="active">True</property>
-                    <property name="draw_indicator">True</property>
-                  </object>
-                  <packing>
-                    <property name="expand">False</property>
-                    <property name="fill">False</property>
-                    <property name="position">1</property>
-                  </packing>
-                </child>
-                <child>
-                  <object class="GtkRadioButton" id="show_range">
-                    <property name="label" translatable="yes">Select Range:</property>
-                    <property name="visible">True</property>
-                    <property name="can_focus">True</property>
-                    <property name="receives_default">False</property>
-                    <property name="use_action_appearance">False</property>
-                    <property name="use_underline">True</property>
-                    <property name="draw_indicator">True</property>
-                    <property name="group">show_all</property>
-                    <signal name="toggled" handler="csv_export_show_range_cb" swapped="no"/>
-                  </object>
-                  <packing>
-                    <property name="expand">False</property>
-                    <property name="fill">False</property>
-                    <property name="position">2</property>
-                  </packing>
-                </child>
-                <child>
-                  <object class="GtkTable" id="select_range_table">
-                    <property name="visible">True</property>
-                    <property name="can_focus">False</property>
-                    <property name="n_rows">7</property>
-                    <property name="n_columns">3</property>
-                    <property name="column_spacing">6</property>
-                    <child>
-                      <object class="GtkLabel" id="label847682">
-                        <property name="visible">True</property>
-                        <property name="can_focus">False</property>
-                        <property name="xalign">0</property>
-                        <property name="label" translatable="yes">Start:</property>
-                      </object>
-                      <packing>
-                        <property name="x_options">GTK_FILL</property>
-                        <property name="y_options"></property>
-                        <property name="x_padding">12</property>
-                      </packing>
-                    </child>
-                    <child>
-                      <object class="GtkRadioButton" id="start_date_earliest">
-                        <property name="label" translatable="yes">_Earliest</property>
-                        <property name="visible">True</property>
-                        <property name="can_focus">True</property>
-                        <property name="receives_default">False</property>
-                        <property name="use_action_appearance">False</property>
-                        <property name="use_underline">True</property>
-                        <property name="active">True</property>
-                        <property name="draw_indicator">True</property>
-                        <signal name="clicked" handler="csv_export_start_date_cb" swapped="no"/>
-                      </object>
-                      <packing>
-                        <property name="left_attach">1</property>
-                        <property name="right_attach">2</property>
-                        <property name="x_options">GTK_FILL</property>
-                        <property name="y_options"></property>
-                      </packing>
-                    </child>
-                    <child>
-                      <object class="GtkRadioButton" id="end_date_choose">
-                        <property name="label" translatable="yes">Choo_se Date:</property>
-                        <property name="visible">True</property>
-                        <property name="can_focus">True</property>
-                        <property name="receives_default">False</property>
-                        <property name="use_action_appearance">False</property>
-                        <property name="use_underline">True</property>
-                        <property name="draw_indicator">True</property>
-                        <signal name="clicked" handler="csv_export_end_date_cb" swapped="no"/>
-                      </object>
-                      <packing>
-                        <property name="left_attach">1</property>
-                        <property name="right_attach">2</property>
-                        <property name="top_attach">6</property>
-                        <property name="bottom_attach">7</property>
-                        <property name="x_options">GTK_FILL</property>
-                        <property name="y_options"></property>
-                      </packing>
-                    </child>
-                    <child>
-                      <object class="GtkRadioButton" id="end_date_today">
-                        <property name="label" translatable="yes">Toda_y</property>
-                        <property name="visible">True</property>
-                        <property name="can_focus">True</property>
-                        <property name="receives_default">False</property>
-                        <property name="use_action_appearance">False</property>
-                        <property name="use_underline">True</property>
-                        <property name="draw_indicator">True</property>
-                        <property name="group">end_date_choose</property>
-                        <signal name="clicked" handler="csv_export_end_date_cb" swapped="no"/>
-                      </object>
-                      <packing>
-                        <property name="left_attach">1</property>
-                        <property name="right_attach">2</property>
-                        <property name="top_attach">5</property>
-                        <property name="bottom_attach">6</property>
-                        <property name="x_options">GTK_FILL</property>
-                        <property name="y_options"></property>
-                      </packing>
-                    </child>
-                    <child>
-                      <object class="GtkRadioButton" id="end_date_latest">
-                        <property name="label" translatable="yes">_Latest</property>
-                        <property name="visible">True</property>
-                        <property name="can_focus">True</property>
-                        <property name="receives_default">False</property>
-                        <property name="use_action_appearance">False</property>
-                        <property name="use_underline">True</property>
-                        <property name="active">True</property>
-                        <property name="draw_indicator">True</property>
-                        <property name="group">end_date_choose</property>
-                        <signal name="clicked" handler="csv_export_end_date_cb" swapped="no"/>
-                      </object>
-                      <packing>
-                        <property name="left_attach">1</property>
-                        <property name="right_attach">2</property>
-                        <property name="top_attach">4</property>
-                        <property name="bottom_attach">5</property>
-                        <property name="x_options">GTK_FILL</property>
-                        <property name="y_options"></property>
-                      </packing>
-                    </child>
-                    <child>
-                      <object class="GtkLabel" id="label847683">
-                        <property name="visible">True</property>
-                        <property name="can_focus">False</property>
-                        <property name="xalign">0</property>
-                      </object>
-                      <packing>
-                        <property name="top_attach">3</property>
-                        <property name="bottom_attach">4</property>
-                        <property name="x_options">GTK_FILL</property>
-                        <property name="y_options"></property>
-                      </packing>
-                    </child>
-                    <child>
-                      <object class="GtkLabel" id="label847684">
-                        <property name="visible">True</property>
-                        <property name="can_focus">False</property>
-                        <property name="xalign">0</property>
-                        <property name="label" translatable="yes">End:</property>
-                      </object>
-                      <packing>
-                        <property name="top_attach">4</property>
-                        <property name="bottom_attach">5</property>
-                        <property name="x_options">GTK_FILL</property>
-                        <property name="y_options"></property>
-                        <property name="x_padding">12</property>
-                      </packing>
-                    </child>
-                    <child>
-                      <object class="GtkRadioButton" id="start_date_choose">
-                        <property name="label" translatable="yes">C_hoose Date:</property>
-                        <property name="visible">True</property>
-                        <property name="can_focus">True</property>
-                        <property name="receives_default">False</property>
-                        <property name="use_action_appearance">False</property>
-                        <property name="use_underline">True</property>
-                        <property name="draw_indicator">True</property>
-                        <property name="group">start_date_earliest</property>
-                        <signal name="clicked" handler="csv_export_start_date_cb" swapped="no"/>
-                      </object>
-                      <packing>
-                        <property name="left_attach">1</property>
-                        <property name="right_attach">2</property>
-                        <property name="top_attach">2</property>
-                        <property name="bottom_attach">3</property>
-                        <property name="x_options">GTK_FILL</property>
-                        <property name="y_options"></property>
-                      </packing>
-                    </child>
-                    <child>
-                      <object class="GtkRadioButton" id="start_date_today">
-                        <property name="label" translatable="yes">_Today</property>
-                        <property name="visible">True</property>
-                        <property name="can_focus">True</property>
-                        <property name="receives_default">False</property>
-                        <property name="use_action_appearance">False</property>
-                        <property name="use_underline">True</property>
-                        <property name="draw_indicator">True</property>
-                        <property name="group">start_date_earliest</property>
-                        <signal name="clicked" handler="csv_export_start_date_cb" swapped="no"/>
-                      </object>
-                      <packing>
-                        <property name="left_attach">1</property>
-                        <property name="right_attach">2</property>
-                        <property name="top_attach">1</property>
-                        <property name="bottom_attach">2</property>
-                        <property name="x_options">GTK_FILL</property>
-                        <property name="y_options"></property>
-                      </packing>
-                    </child>
-                    <child>
-                      <object class="GtkHBox" id="start_date_hbox">
-                        <property name="visible">True</property>
-                        <property name="can_focus">False</property>
-                        <child>
-                          <placeholder/>
-                        </child>
-                      </object>
-                      <packing>
-                        <property name="left_attach">2</property>
-                        <property name="right_attach">3</property>
-                        <property name="top_attach">2</property>
-                        <property name="bottom_attach">3</property>
-                        <property name="x_options"></property>
-                      </packing>
-                    </child>
-                    <child>
-                      <object class="GtkHBox" id="end_date_hbox">
-                        <property name="visible">True</property>
-                        <property name="can_focus">False</property>
-                        <child>
-                          <placeholder/>
-                        </child>
-                      </object>
-                      <packing>
-                        <property name="left_attach">2</property>
-                        <property name="right_attach">3</property>
-                        <property name="top_attach">6</property>
-                        <property name="bottom_attach">7</property>
-                        <property name="x_options"></property>
-                      </packing>
-                    </child>
-                    <child>
-                      <placeholder/>
-                    </child>
-                    <child>
-                      <placeholder/>
-                    </child>
-                    <child>
-                      <placeholder/>
-                    </child>
-                    <child>
-                      <placeholder/>
-                    </child>
-                    <child>
-                      <placeholder/>
-                    </child>
-                    <child>
-                      <placeholder/>
-                    </child>
-                    <child>
-                      <placeholder/>
-                    </child>
-                    <child>
-                      <placeholder/>
-                    </child>
-                    <child>
-                      <placeholder/>
-                    </child>
-                    <child>
-                      <placeholder/>
-                    </child>
-                  </object>
-                  <packing>
-                    <property name="expand">False</property>
-                    <property name="fill">False</property>
-                    <property name="position">3</property>
-                  </packing>
-                </child>
-              </object>
-              <packing>
-                <property name="resize">False</property>
-                <property name="shrink">False</property>
-              </packing>
-            </child>
-          </object>
-          <packing>
-            <property name="expand">True</property>
-            <property name="fill">True</property>
-            <property name="position">1</property>
-          </packing>
-        </child>
-        <child>
-          <placeholder/>
-        </child>
-      </object>
-      <packing>
-        <property name="page_type">progress</property>
-        <property name="title" translatable="yes">Account Selection</property>
-      </packing>
-    </child>
-    <child>
-      <object class="GtkVBox" id="file_page">
-        <property name="visible">True</property>
-        <property name="can_focus">False</property>
-        <property name="border_width">12</property>
-        <child>
-          <object class="GtkLabel" id="label4">
-            <property name="visible">True</property>
-            <property name="can_focus">False</property>
-            <property name="label" translatable="yes">
-Enter file name and location for the Export...
-</property>
-            <property name="wrap">True</property>
-          </object>
-          <packing>
-            <property name="expand">False</property>
-            <property name="fill">False</property>
-            <property name="position">0</property>
-          </packing>
-        </child>
-        <child>
-          <placeholder/>
-        </child>
-      </object>
-      <packing>
-        <property name="title" translatable="yes">Choose File Name for Export</property>
-      </packing>
-    </child>
-    <child>
-      <object class="GtkLabel" id="end_page">
-        <property name="visible">True</property>
-        <property name="can_focus">False</property>
-        <property name="label" translatable="yes">Press Apply to create export file.
-Cancel to abort.</property>
-        <property name="wrap">True</property>
-      </object>
-      <packing>
-        <property name="page_type">confirm</property>
-        <property name="title" translatable="yes">Export Now...</property>
-      </packing>
-    </child>
-    <child>
-      <object class="GtkLabel" id="summary_page">
-        <property name="visible">True</property>
-        <property name="can_focus">False</property>
-        <property name="label" translatable="yes">Summary</property>
-        <property name="wrap">True</property>
-      </object>
-      <packing>
-        <property name="page_type">summary</property>
-        <property name="title" translatable="yes">Export Summary</property>
-        <property name="complete">True</property>
-      </packing>
-    </child>
-  </object>
-</interface>

Deleted: gnucash/trunk/src/import-export/csv-export/assistant-csv-export.h
===================================================================
--- gnucash/trunk/src/import-export/csv-export/assistant-csv-export.h	2013-12-15 17:20:10 UTC (rev 23566)
+++ gnucash/trunk/src/import-export/csv-export/assistant-csv-export.h	2013-12-15 17:21:20 UTC (rev 23567)
@@ -1,98 +0,0 @@
-/*******************************************************************\
- * assistant-csv-export.h -- An assistant for exporting Accounts    *
- *                            and Transactions to a file            *
- *                                                                  *
- * Copyright (C) 2012 Robert Fewell                                 *
- *                                                                  *
- * This program is free software; you can redistribute it and/or    *
- * modify it under the terms of the GNU General Public License as   *
- * published by the Free Software Foundation; either version 2 of   *
- * the License, or (at your option) any later version.              *
- *                                                                  *
- * This program is distributed in the hope that it will be useful,  *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of   *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the    *
- * GNU General Public License for more details.                     *
- *                                                                  *
- * You should have received a copy of the GNU General Public License*
- * along with this program; if not, contact:                        *
- *                                                                  *
- * Free Software Foundation           Voice:  +1-617-542-5942       *
- * 51 Franklin Street, Fifth Floor    Fax:    +1-617-542-2652       *
- * Boston, MA  02110-1301,  USA       gnu at gnu.org                   *
-\********************************************************************/
-/** @file assistant-csv-export.h
-    @brief CSV Export Assistant
-    @author Copyright (c) 2012 Robert Fewell
-*/
-#ifndef GNC_ASSISTANT_CSV_EXPORT_H
-#define GNC_ASSISTANT_CSV_EXPORT_H
-
-#include "Account.h"
-
-typedef enum
-{
-    XML_EXPORT_TREE,
-    XML_EXPORT_TRANS
-} CsvExportType;
-
-typedef struct
-{
-    GtkWidget *table;
-    GtkWidget *start_date_choose;
-    GtkWidget *start_date_today;
-    GtkWidget *start_date;
-    GtkWidget *end_date_choose;
-    GtkWidget *end_date_today;
-    GtkWidget *end_date;
-
-    time64     start_time;
-    time64     end_time;
-} CsvExportDate;
-
-typedef struct
-{
-    GtkWidget        *acct_info;
-    GtkWidget        *expense_radio;
-    GtkWidget        *asset_radio;
-    GtkWidget        *liab_eq_radio;
-    GtkWidget        *account_treeview;
-    GtkWidget        *select_button;
-    GtkWidget        *num_acct_label;
-    GList            *account_list;
-    int               num_accounts;
-    GNCAccountType    account_type;
-} CsvExportAcc;
-
-
-typedef struct
-{
-    CsvExportType export_type;
-    CsvExportDate csvd;
-    CsvExportAcc  csva;
-
-    GtkWidget    *window;
-    GtkWidget    *assistant;
-    GtkWidget    *start_label;
-    GtkWidget    *custom_entry;
-
-    GtkWidget    *file_chooser;
-    GtkWidget    *finish_label;
-    GtkWidget    *summary_label;
-
-    gchar        *starting_dir;
-    gchar        *file_name;
-
-    char         *separator_str;
-    gboolean      use_quotes;
-    gboolean      use_custom;
-    gboolean      failed;
-} CsvExportInfo;
-
-
-/** The gnc_file_csv_export() will let the user export thte
- *  account tree or transactions to a delimited file.
- */
-void gnc_file_csv_export (CsvExportType export_type);
-
-#endif

Deleted: gnucash/trunk/src/import-export/csv-export/csv-transactions-export.c
===================================================================
--- gnucash/trunk/src/import-export/csv-export/csv-transactions-export.c	2013-12-15 17:20:10 UTC (rev 23566)
+++ gnucash/trunk/src/import-export/csv-export/csv-transactions-export.c	2013-12-15 17:21:20 UTC (rev 23567)
@@ -1,385 +0,0 @@
-/*******************************************************************\
- * csv-transactions-export.c -- Export Transactions to a file       *
- *                                                                  *
- * Copyright (C) 2012 Robert Fewell                                 *
- *                                                                  *
- * This program is free software; you can redistribute it and/or    *
- * modify it under the terms of the GNU General Public License as   *
- * published by the Free Software Foundation; either version 2 of   *
- * the License, or (at your option) any later version.              *
- *                                                                  *
- * This program is distributed in the hope that it will be useful,  *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of   *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the    *
- * GNU General Public License for more details.                     *
- *                                                                  *
- * You should have received a copy of the GNU General Public License*
- * along with this program; if not, contact:                        *
- *                                                                  *
- * Free Software Foundation           Voice:  +1-617-542-5942       *
- * 51 Franklin Street, Fifth Floor    Fax:    +1-617-542-2652       *
- * Boston, MA  02110-1301,  USA       gnu at gnu.org                   *
-\********************************************************************/
-/** @file csv-transactions-export.c
-    @brief CSV Export Transactions
-    @author Copyright (c) 2012 Robert Fewell
-*/
-#include "config.h"
-
-#include <gtk/gtk.h>
-#include <glib/gi18n.h>
-#include <glib/gstdio.h>
-
-#include "gnc-commodity.h"
-#include "gnc-ui-util.h"
-#include "Query.h"
-#include "Transaction.h"
-#include "engine-helpers.h"
-#include "qofbookslots.h"
-
-#include "csv-transactions-export.h"
-
-/* This static indicates the debugging module that this .o belongs to.  */
-static QofLogModule log_module = GNC_MOD_ASSISTANT;
-
-/*******************************************************************/
-
-/*******************************************************
- * write_line_to_file
- *
- * write a text string to a file pointer, return TRUE if
- * successfull.
- *******************************************************/
-static
-gboolean write_line_to_file (FILE *fh, char * line)
-{
-    int len, written;
-    DEBUG("Account String: %s", line);
-
-    /* Write account line */
-    len = strlen( line );
-    written = fwrite( line, 1, len, fh );
-
-    if ( written != len )
-        return FALSE;
-    else
-        return TRUE;
-}
-
-
-/*******************************************************
- * account_splits
- *
- * gather the splits / transactions for an account and
- * send them to a file
- *******************************************************/
-static
-void account_splits (CsvExportInfo *info, Account *acc, FILE *fh )
-{
-    Query   *q;
-    GSList  *p1, *p2;
-    GList   *splits;
-    QofBook *book;
-
-    gchar   *end_sep;
-    gchar   *mid_sep;
-
-    q = qof_query_create_for(GNC_ID_SPLIT);
-    book = gnc_get_current_book();
-    qof_query_set_book (q, book);
-
-    /* Set up separators */
-    if (info->use_quotes)
-    {
-        end_sep = "\"";
-        mid_sep = g_strconcat ( "\"", info->separator_str, "\"", NULL);
-    }
-    else
-    {
-        end_sep = "";
-        mid_sep = g_strconcat ( info->separator_str, NULL);
-    }
-
-    /* Sort by transaction date */
-    p1 = g_slist_prepend (NULL, TRANS_DATE_POSTED);
-    p1 = g_slist_prepend (p1, SPLIT_TRANS);
-    p2 = g_slist_prepend (NULL, QUERY_DEFAULT_SORT);
-    qof_query_set_sort_order (q, p1, p2, NULL);
-
-    xaccQueryAddSingleAccountMatch (q, acc, QOF_QUERY_AND);
-    xaccQueryAddDateMatchTT (q, TRUE, info->csvd.start_time, TRUE, info->csvd.end_time, QOF_QUERY_AND);
-
-    /* Run the query */
-    for (splits = qof_query_run(q); splits; splits = splits->next)
-    {
-        Split       *split;
-        Transaction *trans;
-        SplitList   *s_list;
-        GList       *node;
-        Split       *t_split;
-        int          nSplits;
-        int          cnt;
-        gchar       *part1;
-        gchar       *part2;
-        gchar       *date;
-        const gchar *currentSel;
-        const gchar *split_amount;
-
-        split = splits->data;
-        trans = xaccSplitGetParent(split);
-        nSplits = xaccTransCountSplits(trans);
-        s_list = xaccTransGetSplitList(trans);
-
-        /* Date */
-        date = qof_print_date ( xaccTransGetDate(trans));
-        part1 = g_strconcat ( end_sep, date, mid_sep, NULL);
-        g_free(date);
-        /* Name */
-        currentSel = xaccAccountGetName(acc);
-        part2 = g_strconcat ( part1, currentSel, mid_sep, NULL);
-        g_free(part1);
-        /* Number */
-        currentSel = gnc_get_num_action(trans, NULL);
-        part1 = g_strconcat ( part2, currentSel, mid_sep, NULL);
-        g_free(part2);
-        /* Description */
-        currentSel = xaccTransGetDescription(trans);
-        part2 = g_strconcat ( part1, currentSel, mid_sep, NULL);
-        g_free(part1);
-        /* Notes */
-        currentSel = xaccTransGetNotes(trans);
-        if (currentSel == NULL)
-            part1 = g_strconcat ( part2, mid_sep, NULL);
-        else
-            part1 = g_strconcat ( part2, currentSel, mid_sep, NULL);
-        g_free(part2);
-        /* Memo */
-        currentSel = xaccSplitGetMemo(split);
-        part2 = g_strconcat ( part1, currentSel, mid_sep, NULL);
-        g_free(part1);
-        /* Category */
-        currentSel = xaccSplitGetCorrAccountName(split);
-        part1 = g_strconcat ( part2, currentSel, mid_sep, "T", mid_sep, NULL);
-        g_free(part2);
-        /* Action */
-        currentSel =  gnc_get_num_action(NULL, split);
-        part2 = g_strconcat ( part1, currentSel, mid_sep, NULL);
-        g_free(part1);
-        /* Reconcile */
-        switch (xaccSplitGetReconcile (split))
-        {
-        case NREC:
-            currentSel = "N";
-            break;
-        case CREC:
-            currentSel = "C";
-            break;
-        case YREC:
-            currentSel = "Y";
-            break;
-        case FREC:
-            currentSel = "F";
-            break;
-        case VREC:
-            currentSel = "V";
-            break;
-        default:
-            currentSel = "N";
-        }
-        part1 = g_strconcat ( part2, currentSel, mid_sep, NULL);
-        g_free(part2);
-        /* To with Symbol */
-        split_amount = xaccPrintAmount(xaccSplitGetAmount(split), gnc_split_amount_print_info(split, TRUE));
-        part2 = g_strconcat ( part1, split_amount, mid_sep, NULL);
-        g_free(part1);
-
-        /* From with Symbol */
-        part1 = g_strconcat ( part2, "", mid_sep, NULL);
-        g_free(part2);
-
-        /* To Number Only */
-        split_amount = xaccPrintAmount(xaccSplitGetAmount(split), gnc_split_amount_print_info(split, FALSE));
-        part2 = g_strconcat ( part1, split_amount, mid_sep, NULL);
-        g_free(part1);
-
-        /* From Number Only */
-        part1 = g_strconcat ( part2, "", mid_sep, "", mid_sep, "", end_sep, "\n", NULL);
-        g_free(part2);
-
-        /* Write to file */
-        if (!write_line_to_file(fh, part1))
-        {
-            info->failed = TRUE;
-            break;
-        }
-        g_free(part1);
-
-        /* Loop through the list of splits for the Transcation */
-        node = s_list;
-        cnt = 0;
-        while ( (cnt < nSplits) && (info->failed == FALSE))
-        {
-            t_split = node->data;
-
-            /* Start of line */
-            part1 = g_strconcat ( end_sep, mid_sep, mid_sep, mid_sep, mid_sep, mid_sep, NULL);
-
-            /* Memo */
-            currentSel = xaccSplitGetMemo(t_split);
-            part2 = g_strconcat ( part1, currentSel, mid_sep, NULL);
-            g_free(part1);
-
-            /* Account */
-            currentSel = xaccAccountGetName( xaccSplitGetAccount(t_split));
-            part1 = g_strconcat ( part2, currentSel, mid_sep, "S", mid_sep, NULL);
-            g_free(part2);
-
-            /* Action */
-            currentSel = gnc_get_num_action(NULL, t_split);
-            part2 = g_strconcat ( part1, currentSel, mid_sep, NULL);
-            g_free(part1);
-
-            /* Reconcile */
-            switch (xaccSplitGetReconcile (split))
-            {
-            case NREC:
-                currentSel = "N";
-                break;
-            case CREC:
-                currentSel = "C";
-                break;
-            case YREC:
-                currentSel = "Y";
-                break;
-            case FREC:
-                currentSel = "F";
-                break;
-            case VREC:
-                currentSel = "V";
-                break;
-            default:
-                currentSel = "N";
-            }
-            part1 = g_strconcat ( part2, currentSel, mid_sep, NULL);
-            g_free(part2);
-
-            /* From / To with Symbol */
-            split_amount = xaccPrintAmount(xaccSplitGetAmount(t_split), gnc_split_amount_print_info(t_split, TRUE));
-            if (xaccSplitGetAccount(t_split) == acc)
-                part2 = g_strconcat ( part1,  split_amount, mid_sep, mid_sep, NULL);
-            else
-                part2 = g_strconcat ( part1, mid_sep, split_amount, mid_sep, NULL);
-            g_free(part1);
-
-            /* From / To Numbers only */
-            split_amount = xaccPrintAmount(xaccSplitGetAmount(t_split), gnc_split_amount_print_info(t_split, FALSE));
-            if (xaccSplitGetAccount(t_split) == acc)
-                part1 = g_strconcat ( part2,  split_amount, mid_sep, mid_sep, NULL);
-            else
-                part1 = g_strconcat ( part2, mid_sep, split_amount, mid_sep, NULL);
-            g_free(part2);
-
-            /* From / To - Share Price / Conversion factor */
-            split_amount = xaccPrintAmount(xaccSplitGetSharePrice(t_split), gnc_split_amount_print_info(t_split, FALSE));
-            if (xaccSplitGetAccount(t_split) == acc)
-                part2 = g_strconcat ( part1,  split_amount, mid_sep, end_sep, "\n", NULL);
-            else
-                part2 = g_strconcat ( part1, mid_sep, split_amount, end_sep, "\n", NULL);
-            g_free(part1);
-
-            if (!write_line_to_file(fh, part2))
-                info->failed = TRUE;
-
-            g_free(part2);
-            cnt++;
-            node = node->next;
-        }
-    }
-    g_free(mid_sep);
-    qof_query_destroy (q);
-    g_list_free( splits );
-}
-
-
-/*******************************************************
- * csv_transactions_export
- *
- * write a list of transactions to a text file
- *******************************************************/
-void csv_transactions_export (CsvExportInfo *info)
-{
-    FILE    *fh;
-    Account *acc;
-    GList   *ptr;
-    gboolean num_action = qof_book_use_split_action_for_num_field(gnc_get_current_book());
-
-    ENTER("");
-    DEBUG("File name is : %s", info->file_name);
-
-    info->failed = FALSE;
-
-    /* Open File for writing */
-    fh = g_fopen( info->file_name, "w" );
-    if ( fh != NULL )
-    {
-        gchar *header;
-        gchar *end_sep;
-        gchar *mid_sep;
-        int i;
-
-        /* Set up separators */
-        if (info->use_quotes)
-        {
-            end_sep = "\"";
-            mid_sep = g_strconcat ( "\"", info->separator_str, "\"", NULL);
-        }
-        else
-        {
-            end_sep = "";
-            mid_sep = g_strconcat ( info->separator_str, NULL);
-        }
-
-        /* Header string */
-        header = g_strconcat ( end_sep, _("Date"), mid_sep, _("Account Name"), mid_sep,
-                               (num_action ? _("Transaction Number") : _("Number")),
-                               mid_sep, _("Description"), mid_sep, _("Notes"),
-                               mid_sep, _("Memo"), mid_sep, _("Category"), mid_sep,
-                               _("Type"), mid_sep,
-                               (num_action ? _("Number/Action") : _("Action")),
-                               mid_sep, _("Reconcile"), mid_sep,
-                               _("To With Sym"), mid_sep, _("From With Sym"), mid_sep,
-                               _("To Num."), mid_sep, _("From Num."), mid_sep,
-                               _("To Rate/Price"), mid_sep, _("From Rate/Price"),
-                               end_sep, "\n", NULL);
-        DEBUG("Header String: %s", header);
-
-        /* Write header line */
-        if (!write_line_to_file(fh, header))
-        {
-            info->failed = TRUE;
-            g_free(mid_sep);
-            g_free(header);
-            return;
-        }
-        g_free(mid_sep);
-        g_free(header);
-
-        /* Go through list of accounts */
-        for (ptr = info->csva.account_list, i = 0; ptr; ptr = g_list_next(ptr), i++)
-        {
-            acc = ptr->data;
-            DEBUG("Account being processed is : %s", xaccAccountGetName(acc));
-            account_splits (info, acc, fh);
-        }
-    }
-    else
-        info->failed = TRUE;
-    if (fh)
-        fclose (fh);
-    LEAVE("");
-}
-
-
-
-
-

Deleted: gnucash/trunk/src/import-export/csv-export/csv-transactions-export.h
===================================================================
--- gnucash/trunk/src/import-export/csv-export/csv-transactions-export.h	2013-12-15 17:20:10 UTC (rev 23566)
+++ gnucash/trunk/src/import-export/csv-export/csv-transactions-export.h	2013-12-15 17:21:20 UTC (rev 23567)
@@ -1,39 +0,0 @@
-/*******************************************************************\
- * csv-transactions-export.h -- Export Transactions to a file       *
- *                                                                  *
- * Copyright (C) 2012 Robert Fewell                                 *
- *                                                                  *
- * This program is free software; you can redistribute it and/or    *
- * modify it under the terms of the GNU General Public License as   *
- * published by the Free Software Foundation; either version 2 of   *
- * the License, or (at your option) any later version.              *
- *                                                                  *
- * This program is distributed in the hope that it will be useful,  *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of   *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the    *
- * GNU General Public License for more details.                     *
- *                                                                  *
- * You should have received a copy of the GNU General Public License*
- * along with this program; if not, contact:                        *
- *                                                                  *
- * Free Software Foundation           Voice:  +1-617-542-5942       *
- * 51 Franklin Street, Fifth Floor    Fax:    +1-617-542-2652       *
- * Boston, MA  02110-1301,  USA       gnu at gnu.org                   *
-\********************************************************************/
-/** @file csv-transactions-export.h
-    @brief CSV Export Transactions
-    @author Copyright (c) 2012 Robert Fewell
-*/
-
-#ifndef CSV_TRANSACTIONS_EXPORT
-#define CSV_TRANSACTIONS_EXPORT
-
-#include "assistant-csv-export.h"
-
-/** The csv_transactions_export() will let the user export the
- *  transactions to a delimited file.
- */
-void csv_transactions_export (CsvExportInfo *info);
-
-#endif
-

Deleted: gnucash/trunk/src/import-export/csv-export/csv-tree-export.c
===================================================================
--- gnucash/trunk/src/import-export/csv-export/csv-tree-export.c	2013-12-15 17:20:10 UTC (rev 23566)
+++ gnucash/trunk/src/import-export/csv-export/csv-tree-export.c	2013-12-15 17:21:20 UTC (rev 23567)
@@ -1,217 +0,0 @@
-/*******************************************************************\
- * csv-tree-export.c -- Export Account Tree to a file               *
- *                                                                  *
- * Copyright (C) 2012 Robert Fewell                                 *
- *                                                                  *
- * This program is free software; you can redistribute it and/or    *
- * modify it under the terms of the GNU General Public License as   *
- * published by the Free Software Foundation; either version 2 of   *
- * the License, or (at your option) any later version.              *
- *                                                                  *
- * This program is distributed in the hope that it will be useful,  *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of   *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the    *
- * GNU General Public License for more details.                     *
- *                                                                  *
- * You should have received a copy of the GNU General Public License*
- * along with this program; if not, contact:                        *
- *                                                                  *
- * Free Software Foundation           Voice:  +1-617-542-5942       *
- * 51 Franklin Street, Fifth Floor    Fax:    +1-617-542-2652       *
- * Boston, MA  02110-1301,  USA       gnu at gnu.org                   *
-\********************************************************************/
-/** @file csv-tree-export.c
-    @brief CSV Export Account Tree
-    @author Copyright (c) 2012 Robert Fewell
-*/
-#include "config.h"
-
-#include <gtk/gtk.h>
-#include <glib/gi18n.h>
-#include <glib/gstdio.h>
-
-#include "gnc-commodity.h"
-#include "gnc-ui-util.h"
-
-#include "csv-tree-export.h"
-
-/* This static indicates the debugging module that this .o belongs to.  */
-static QofLogModule log_module = GNC_MOD_ASSISTANT;
-
-/******************************************************************/
-
-/*******************************************************
- * write_line_to_file
- *
- * write a text string to a file pointer, return TRUE if
- * successfull.
- *******************************************************/
-static
-gboolean write_line_to_file ( FILE *fh, char * line)
-{
-    int len, written;
-    DEBUG("Account String: %s", line);
-
-    /* Write account line */
-    len = strlen( line );
-    written = fwrite( line, 1, len, fh );
-
-    if ( written != len )
-        return FALSE;
-    else
-        return TRUE;
-}
-
-
-/*******************************************************
- * csv_tree_export
- *
- * write a list of accounts settings to a text file
- *******************************************************/
-void csv_tree_export (CsvExportInfo *info)
-{
-    FILE    *fh;
-    Account *root;
-    Account *acc;
-    GList   *accts, *ptr;
-
-    ENTER("");
-    DEBUG("File name is : %s", info->file_name);
-
-    /* Get list of Accounts */
-    root = gnc_book_get_root_account( gnc_get_current_book() );
-    accts = gnc_account_get_descendants_sorted( root );
-    info->failed = FALSE;
-
-    /* Open File for writing */
-    fh = g_fopen( info->file_name, "w" );
-    if ( fh != NULL )
-    {
-        gchar *header;
-        gchar *part1;
-        gchar *part2;
-        const gchar *currentSel;
-        gchar *end_sep;
-        gchar *mid_sep;
-        int i;
-
-
-        /* Set up separators */
-        if (info->use_quotes)
-        {
-            end_sep = "\"";
-            mid_sep = g_strconcat ( "\"", info->separator_str, "\"", NULL);
-        }
-        else
-        {
-            end_sep = "";
-            mid_sep = g_strconcat ( info->separator_str, NULL);
-        }
-
-        /* Header string */
-        header = g_strconcat ( end_sep, _("type"), mid_sep, _("full_name"), mid_sep,
-                               _("name"), mid_sep, _("code"), mid_sep,
-                               _("description"), mid_sep, _("color"), mid_sep, _("notes"), mid_sep,
-                               _("commoditym"), mid_sep, _("commodityn"), mid_sep,
-                               _("hidden"), mid_sep, _("tax"), mid_sep, _("place_holder"), end_sep, "\n", NULL);
-        DEBUG("Header String: %s", header);
-
-        /* Write header line */
-        if (!write_line_to_file(fh, header))
-        {
-            info->failed = TRUE;
-            g_free(mid_sep);
-            g_free(header);
-            return;
-        }
-        g_free(header);
-
-        /* Go through list of accounts */
-        for (ptr = accts, i = 0; ptr; ptr = g_list_next(ptr), i++)
-        {
-            gchar *fullname = NULL;
-            gchar *notes_out = NULL;
-            acc = ptr->data;
-            DEBUG("Account being processed is : %s", xaccAccountGetName(acc));
-            /* Type */
-            currentSel = xaccAccountTypeEnumAsString( xaccAccountGetType (acc));
-            part1 = g_strconcat ( end_sep, currentSel, mid_sep, NULL);
-            /* Full Name */
-            fullname = gnc_account_get_full_name(acc);
-            part2 = g_strconcat ( part1, fullname, mid_sep, NULL);
-            g_free(fullname);
-            g_free(part1);
-            /* Name */
-            currentSel = xaccAccountGetName(acc);
-            part1 = g_strconcat ( part2, currentSel, mid_sep, NULL);
-            g_free(part2);
-            /* Code */
-            currentSel = xaccAccountGetCode(acc) ? xaccAccountGetCode(acc) : "" ;
-            part2 = g_strconcat ( part1, currentSel, mid_sep, NULL);
-            g_free(part1);
-            /* Description */
-            currentSel = xaccAccountGetDescription(acc) ? xaccAccountGetDescription(acc) : "" ;
-            part1 = g_strconcat ( part2, currentSel, mid_sep, NULL);
-            g_free(part2);
-            /* Color */
-            currentSel = xaccAccountGetColor(acc) ? xaccAccountGetColor(acc) : "" ;
-            part2 = g_strconcat ( part1, currentSel, mid_sep, NULL);
-            g_free(part1);
-            /* Notes */
-            currentSel = xaccAccountGetNotes(acc) ? xaccAccountGetNotes(acc) : "" ;
-            if (!g_strcmp0(currentSel, "") == 0)
-            {
-                /* Check for multiple lines */
-                gchar **parts;
-                parts = g_strsplit(currentSel, "\n", -1);
-                notes_out = g_strjoinv("\\n", parts);
-                currentSel = notes_out;
-                g_strfreev(parts);
-            }
-            part1 = g_strconcat ( part2, currentSel, mid_sep, NULL);
-            g_free(part2);
-            g_free(notes_out);
-            /* Commodity Mnemonic */
-            currentSel = gnc_commodity_get_mnemonic(xaccAccountGetCommodity (acc));
-            part2 = g_strconcat ( part1, currentSel, mid_sep, NULL);
-            g_free(part1);
-            /* Commodity Namespace */
-            currentSel = gnc_commodity_get_namespace(xaccAccountGetCommodity (acc));
-            part1 = g_strconcat ( part2, currentSel, mid_sep, NULL);
-            g_free(part2);
-            /* Hidden */
-            currentSel = xaccAccountGetHidden(acc) ? "T" : "F" ;
-            part2 = g_strconcat ( part1, currentSel, mid_sep, NULL);
-            g_free(part1);
-            /* Tax */
-            currentSel = xaccAccountGetTaxRelated(acc) ? "T" : "F" ;
-            part1 = g_strconcat ( part2, currentSel, mid_sep, NULL);
-            g_free(part2);
-            /* Place Holder */
-            currentSel = xaccAccountGetPlaceholder(acc) ? "T" : "F" ;
-            part2 = g_strconcat ( part1, currentSel, end_sep, "\n", NULL);
-            g_free(part1);
-
-            DEBUG("Account String: %s", part2);
-
-            /* Write to file */
-            if (!write_line_to_file(fh, part2))
-            {
-                info->failed = TRUE;
-                break;
-            }
-            g_free(part2);
-        }
-        g_free(mid_sep);
-    }
-    else
-        info->failed = TRUE;
-    if (fh)
-        fclose (fh);
-
-    g_list_free( accts );
-    LEAVE("");
-}
-
-
-

Deleted: gnucash/trunk/src/import-export/csv-export/csv-tree-export.h
===================================================================
--- gnucash/trunk/src/import-export/csv-export/csv-tree-export.h	2013-12-15 17:20:10 UTC (rev 23566)
+++ gnucash/trunk/src/import-export/csv-export/csv-tree-export.h	2013-12-15 17:21:20 UTC (rev 23567)
@@ -1,38 +0,0 @@
-/*******************************************************************\
- * csv-tree-export.h -- Export Account Tree to a file               *
- *                                                                  *
- * Copyright (C) 2012 Robert Fewell                                 *
- *                                                                  *
- * This program is free software; you can redistribute it and/or    *
- * modify it under the terms of the GNU General Public License as   *
- * published by the Free Software Foundation; either version 2 of   *
- * the License, or (at your option) any later version.              *
- *                                                                  *
- * This program is distributed in the hope that it will be useful,  *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of   *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the    *
- * GNU General Public License for more details.                     *
- *                                                                  *
- * You should have received a copy of the GNU General Public License*
- * along with this program; if not, contact:                        *
- *                                                                  *
- * Free Software Foundation           Voice:  +1-617-542-5942       *
- * 51 Franklin Street, Fifth Floor    Fax:    +1-617-542-2652       *
- * Boston, MA  02110-1301,  USA       gnu at gnu.org                   *
-\********************************************************************/
-/** @file csv-tree-export.h
-    @brief CSV Export Account Tree
-    @author Copyright (c) 2012 Robert Fewell
-*/
-#ifndef CSV_TREE_EXPORT
-#define CSV_TREE_EXPORT
-
-#include "assistant-csv-export.h"
-
-/** The csv_tree_export() will let the user export the
- *  account tree to a delimited file.
- */
-void csv_tree_export (CsvExportInfo *info);
-
-#endif
-

Deleted: gnucash/trunk/src/import-export/csv-export/gnc-plugin-csv-export-ui.xml
===================================================================
--- gnucash/trunk/src/import-export/csv-export/gnc-plugin-csv-export-ui.xml	2013-12-15 17:20:10 UTC (rev 23566)
+++ gnucash/trunk/src/import-export/csv-export/gnc-plugin-csv-export-ui.xml	2013-12-15 17:21:20 UTC (rev 23567)
@@ -1,12 +0,0 @@
-<ui>
-  <menubar>
-    <menu name="File" action="FileAction">
-      <menu name="FileExport" action="FileExportAction">
-      	<placeholder name="FileExportPlaceholder">
-      	   <menuitem name="FileCsvExportTree" action="CsvExportTreeAction"/>
-      	   <menuitem name="FileCsvExportTrans" action="CsvExportTransAction"/>
-      	</placeholder>
-      </menu>
-    </menu>
-  </menubar>
-</ui>

Deleted: gnucash/trunk/src/import-export/csv-export/gnc-plugin-csv-export.c
===================================================================
--- gnucash/trunk/src/import-export/csv-export/gnc-plugin-csv-export.c	2013-12-15 17:20:10 UTC (rev 23566)
+++ gnucash/trunk/src/import-export/csv-export/gnc-plugin-csv-export.c	2013-12-15 17:21:20 UTC (rev 23567)
@@ -1,168 +0,0 @@
-/*
- * gnc-plugin-csv-export.c -- csv export plugin
- * Copyright (C) 2012 Robert Fewell
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation; either version 2 of
- * the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, contact:
- *
- * Free Software Foundation           Voice:  +1-617-542-5942
- * 51 Franklin Street, Fifth Floor    Fax:    +1-617-542-2652
- * Boston, MA  02110-1301,  USA       gnu at gnu.org
- */
-
-#include "config.h"
-
-#include <gtk/gtk.h>
-#include <glib/gi18n.h>
-
-#include "gnc-plugin-csv-export.h"
-#include "gnc-plugin-manager.h"
-
-#include "assistant-csv-export.h"
-
-static void gnc_plugin_csv_export_class_init (GncPluginCsvExportClass *klass);
-static void gnc_plugin_csv_export_init (GncPluginCsvExport *plugin);
-static void gnc_plugin_csv_export_finalize (GObject *object);
-
-/* Command callbacks */
-static void gnc_plugin_csv_export_tree_cmd (GtkAction *action, GncMainWindowActionData *data);
-static void gnc_plugin_csv_export_trans_cmd (GtkAction *action, GncMainWindowActionData *data);
-
-#define PLUGIN_ACTIONS_NAME "gnc-plugin-csv-export-actions"
-#define PLUGIN_UI_FILENAME  "gnc-plugin-csv-export-ui.xml"
-
-static GtkActionEntry gnc_plugin_actions [] =
-{
-    {
-        "CsvExportTreeAction", GTK_STOCK_CONVERT, N_("Export Account T_ree to CSV..."), NULL,
-        N_("Export the Account Tree to a CSV file"),
-        G_CALLBACK (gnc_plugin_csv_export_tree_cmd)
-    },
-    {
-        "CsvExportTransAction", GTK_STOCK_CONVERT, N_("Export _Transactions to CSV..."), NULL,
-        N_("Export the Transactions to a CSV file"),
-        G_CALLBACK (gnc_plugin_csv_export_trans_cmd)
-    },
-};
-static guint gnc_plugin_n_actions = G_N_ELEMENTS (gnc_plugin_actions);
-
-typedef struct GncPluginCsvExportPrivate
-{
-    gpointer dummy;
-} GncPluginCsvExportPrivate;
-
-#define GNC_PLUGIN_CSV_EXPORT_GET_PRIVATE(o)  \
-   (G_TYPE_INSTANCE_GET_PRIVATE ((o), GNC_TYPE_PLUGIN_CSV_EXPORT, GncPluginCsvExportPrivate))
-
-static GObjectClass *parent_class = NULL;
-
-GType
-gnc_plugin_csv_export_get_type (void)
-{
-    static GType gnc_plugin_csv_export_type = 0;
-
-    if (gnc_plugin_csv_export_type == 0)
-    {
-        static const GTypeInfo our_info =
-        {
-            sizeof (GncPluginCsvExportClass),
-            NULL,		/* base_init */
-            NULL,		/* base_finalize */
-            (GClassInitFunc) gnc_plugin_csv_export_class_init,
-            NULL,		/* class_finalize */
-            NULL,		/* class_data */
-            sizeof (GncPluginCsvExport),
-            0,		/* n_preallocs */
-            (GInstanceInitFunc) gnc_plugin_csv_export_init,
-        };
-
-        gnc_plugin_csv_export_type = g_type_register_static (GNC_TYPE_PLUGIN,
-                                     "GncPluginCsvExport",
-                                     &our_info, 0);
-    }
-
-    return gnc_plugin_csv_export_type;
-}
-
-GncPlugin *
-gnc_plugin_csv_export_new (void)
-{
-    return GNC_PLUGIN (g_object_new (GNC_TYPE_PLUGIN_CSV_EXPORT, NULL));
-}
-
-static void
-gnc_plugin_csv_export_class_init (GncPluginCsvExportClass *klass)
-{
-    GObjectClass *object_class = G_OBJECT_CLASS (klass);
-    GncPluginClass *plugin_class = GNC_PLUGIN_CLASS (klass);
-
-    parent_class = g_type_class_peek_parent (klass);
-
-    object_class->finalize = gnc_plugin_csv_export_finalize;
-
-    /* plugin info */
-    plugin_class->plugin_name  = GNC_PLUGIN_CSV_EXPORT_NAME;
-
-    /* widget addition/removal */
-    plugin_class->actions_name = PLUGIN_ACTIONS_NAME;
-    plugin_class->actions      = gnc_plugin_actions;
-    plugin_class->n_actions    = gnc_plugin_n_actions;
-    plugin_class->ui_filename  = PLUGIN_UI_FILENAME;
-
-    g_type_class_add_private(klass, sizeof(GncPluginCsvExportPrivate));
-}
-
-static void
-gnc_plugin_csv_export_init (GncPluginCsvExport *plugin)
-{
-}
-
-static void
-gnc_plugin_csv_export_finalize (GObject *object)
-{
-    g_return_if_fail (GNC_IS_PLUGIN_CSV_EXPORT (object));
-
-    G_OBJECT_CLASS (parent_class)->finalize (object);
-}
-
-/************************************************************
- *              Plugin Function Implementation              *
- ************************************************************/
-
-/************************************************************
- *                    Command Callbacks                     *
- ************************************************************/
-static void
-gnc_plugin_csv_export_tree_cmd (GtkAction *action,
-                                GncMainWindowActionData *data)
-{
-    gnc_file_csv_export(XML_EXPORT_TREE);
-}
-
-static void
-gnc_plugin_csv_export_trans_cmd (GtkAction *action,
-                                 GncMainWindowActionData *data)
-{
-    gnc_file_csv_export(XML_EXPORT_TRANS);
-}
-
-/************************************************************
- *                    Plugin Bootstrapping                   *
- ************************************************************/
-void
-gnc_plugin_csv_export_create_plugin (void)
-{
-    GncPlugin *plugin = gnc_plugin_csv_export_new ();
-
-    gnc_plugin_manager_add_plugin (gnc_plugin_manager_get (), plugin);
-}

Deleted: gnucash/trunk/src/import-export/csv-export/gnc-plugin-csv-export.h
===================================================================
--- gnucash/trunk/src/import-export/csv-export/gnc-plugin-csv-export.h	2013-12-15 17:20:10 UTC (rev 23566)
+++ gnucash/trunk/src/import-export/csv-export/gnc-plugin-csv-export.h	2013-12-15 17:21:20 UTC (rev 23567)
@@ -1,62 +0,0 @@
-/*
- * gnc-plugin-csv-export.h -- csv export plugin
- * Copyright (C) 2012 Robert Fewell
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation; either version 2 of
- * the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, contact:
- *
- * Free Software Foundation           Voice:  +1-617-542-5942
- * 51 Franklin Street, Fifth Floor    Fax:    +1-617-542-2652
- * Boston, MA  02110-1301,  USA       gnu at gnu.org
- */
-
-#ifndef __GNC_PLUGIN_CSV_EXPORT_H
-#define __GNC_PLUGIN_CSV_EXPORT_H
-
-#include <gtk/gtk.h>
-
-#include "gnc-plugin.h"
-
-G_BEGIN_DECLS
-
-/* type macros */
-#define GNC_TYPE_PLUGIN_CSV_EXPORT            (gnc_plugin_csv_export_get_type ())
-#define GNC_PLUGIN_CSV_EXPORT(obj)            (G_TYPE_CHECK_INSTANCE_CAST ((obj), GNC_TYPE_PLUGIN_CSV_EXPORT, GncPluginCsvExport))
-#define GNC_PLUGIN_CSV_EXPORT_CLASS(klass)    (G_TYPE_CHECK_CLASS_CAST ((klass), GNC_TYPE_PLUGIN_CSV_EXPORT, GncPluginCsvExportClass))
-#define GNC_IS_PLUGIN_CSV_EXPORT(obj)         (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GNC_TYPE_PLUGIN_CSV_EXPORT))
-#define GNC_IS_PLUGIN_CSV_EXPORT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GNC_TYPE_PLUGIN_CSV_EXPORT))
-#define GNC_PLUGIN_CSV_EXPORT_GET_CLASS(obj)  (G_TYPE_INSTANCE_GET_CLASS ((obj), GNC_TYPE_PLUGIN_CSV_EXPORT, GncPluginCsvExportClass))
-
-#define GNC_PLUGIN_CSV_EXPORT_NAME "gnc-plugin-csv-export"
-
-/* typedefs & structures */
-typedef struct
-{
-    GncPlugin gnc_plugin;
-} GncPluginCsvExport;
-
-typedef struct
-{
-    GncPluginClass gnc_plugin;
-} GncPluginCsvExportClass;
-
-/* function prototypes */
-GType      gnc_plugin_csv_export_get_type (void);
-
-GncPlugin *gnc_plugin_csv_export_new      (void);
-
-void       gnc_plugin_csv_export_create_plugin (void);
-
-G_END_DECLS
-
-#endif /* __GNC_PLUGIN_CSV_EXPORT_H */

Deleted: gnucash/trunk/src/import-export/csv-export/gncmod-csv-export.c
===================================================================
--- gnucash/trunk/src/import-export/csv-export/gncmod-csv-export.c	2013-12-15 17:20:10 UTC (rev 23566)
+++ gnucash/trunk/src/import-export/csv-export/gncmod-csv-export.c	2013-12-15 17:21:20 UTC (rev 23567)
@@ -1,90 +0,0 @@
-/********************************************************************\
- * This program is free software; you can redistribute it and/or    *
- * modify it under the terms of the GNU General Public License as   *
- * published by the Free Software Foundation; either version 2 of   *
- * the License, or (at your option) any later version.              *
- *                                                                  *
- * This program is distributed in the hope that it will be useful,  *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of   *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the    *
- * GNU General Public License for more details.                     *
- *                                                                  *
- * You should have received a copy of the GNU General Public License*
- * along with this program; if not, contact:                        *
- *                                                                  *
- * Free Software Foundation           Voice:  +1-617-542-5942       *
- * 51 Franklin Street, Fifth Floor    Fax:    +1-617-542-2652       *
- * Boston, MA  02110-1301,  USA       gnu at gnu.org                   *
-\********************************************************************/
-/** @addtogroup Import_Export
-    @{ */
-/**@internal
- at file gncmod-csv-export.c
- at brief module definition/initialization for the csv exporter
- at author Copyright (c) 2012 Robert Fewell
-*/
-#include "config.h"
-
-#include <gmodule.h>
-
-#include "gnc-module.h"
-#include "gnc-module-api.h"
-#include "gnc-plugin-csv-export.h"
-
-GNC_MODULE_API_DECL(libgncmod_csv_export)
-
-/* version of the gnc module system interface we require */
-int libgncmod_csv_export_gnc_module_system_interface = 0;
-
-/* module versioning uses libtool semantics. */
-int libgncmod_csv_export_gnc_module_current  = 0;
-int libgncmod_csv_export_gnc_module_revision = 0;
-int libgncmod_csv_export_gnc_module_age      = 0;
-
-//static GNCModule bus_core;
-//static GNCModule file;
-
-char *
-libgncmod_csv_export_gnc_module_path(void)
-{
-    return g_strdup("gnucash/import-export/csv-export");
-}
-
-char *
-libgncmod_csv_export_gnc_module_description(void)
-{
-    return g_strdup("Gnome GUI and C code for CSV exporter.");
-}
-
-int
-libgncmod_csv_export_gnc_module_init(int refcount)
-{
-    if (!gnc_module_load("gnucash/engine", 0))
-    {
-        return FALSE;
-    }
-    if (!gnc_module_load("gnucash/app-utils", 0))
-    {
-        return FALSE;
-    }
-    if (!gnc_module_load("gnucash/gnome-utils", 0))
-    {
-        return FALSE;
-    }
-    if (!gnc_module_load("gnucash/import-export", 0))
-    {
-        return FALSE;
-    }
-
-    /* Add menu items with C callbacks */
-    gnc_plugin_csv_export_create_plugin();
-
-    return TRUE;
-}
-
-int
-libgncmod_csv_export_gnc_module_end(int refcount)
-{
-    return TRUE;
-}
-/** @}*/

Deleted: gnucash/trunk/src/import-export/csv-export/gschemas/Makefile.am
===================================================================
--- gnucash/trunk/src/import-export/csv-export/gschemas/Makefile.am	2013-12-15 17:20:10 UTC (rev 23566)
+++ gnucash/trunk/src/import-export/csv-export/gschemas/Makefile.am	2013-12-15 17:21:20 UTC (rev 23567)
@@ -1,10 +0,0 @@
- at INTLTOOL_XML_NOMERGE_RULE@
-
-gschema_in_files = \
-  org.gnucash.dialogs.export.csv.gschema.xml.in
-
-gsettings_SCHEMAS = $(gschema_in_files:.gschema.xml.in=.gschema.xml)
-
- at GSETTINGS_RULES@
-
-CLEANFILES = $(gsettings_SCHEMAS)

Deleted: gnucash/trunk/src/import-export/csv-export/gschemas/org.gnucash.dialogs.export.csv.gschema.xml.in.in
===================================================================
--- gnucash/trunk/src/import-export/csv-export/gschemas/org.gnucash.dialogs.export.csv.gschema.xml.in.in	2013-12-15 17:20:10 UTC (rev 23566)
+++ gnucash/trunk/src/import-export/csv-export/gschemas/org.gnucash.dialogs.export.csv.gschema.xml.in.in	2013-12-15 17:21:20 UTC (rev 23567)
@@ -1,21 +0,0 @@
-<schemalist gettext-domain="@GETTEXT_PACKAGE@">
-  <schema id="org.gnucash.dialogs.export.csv" path="/org/gnucash/dialogs/export/csv/">
-    <key name="last-geometry" type="(iiii)">
-      <default>(-1,-1,-1,-1)</default>
-      <summary>Last window position and size</summary>
-      <description>This setting describes the size and position of the window when it was last closed.
-        The numbers are the X and Y coordinates of the top left corner of the window
-        followed by the width and height of the window.</description>
-    </key>
-    <key name="last-path" type="s">
-      <default>''</default>
-      <summary>Last pathname used</summary>
-      <description>This field contains the last pathname used by this window. It will be used as the initial filename/pathname the next time this window is opened.</description>
-    </key>
-    <key name="paned-position" type="i">
-      <default>0</default>
-      <summary>Window geometry</summary>
-      <description>The position of paned window when it was last closed.</description>
-    </key>
-  </schema>
-</schemalist>

Copied: gnucash/trunk/src/import-export/csv-imp/Makefile.am (from rev 23566, gnucash/trunk/src/import-export/csv-import/Makefile.am)
===================================================================
--- gnucash/trunk/src/import-export/csv-imp/Makefile.am	                        (rev 0)
+++ gnucash/trunk/src/import-export/csv-imp/Makefile.am	2013-12-15 17:21:20 UTC (rev 23567)
@@ -0,0 +1,64 @@
+SUBDIRS = . gschemas
+
+pkglib_LTLIBRARIES=libgncmod-csv-import.la
+
+libgncmod_csv_import_la_SOURCES = \
+  gncmod-csv-import.c \
+  assistant-csv-account-import.c \
+  assistant-csv-trans-import.c \
+  gnc-plugin-csv-import.c \
+  csv-account-import.c \
+  gnc-csv-model.c \
+  gnc-csv-gnumeric-popup.c
+
+noinst_HEADERS = \
+  assistant-csv-account-import.h \
+  assistant-csv-trans-import.h \
+  gnc-plugin-csv-import.h \
+  csv-account-import.h \
+  gnc-csv-model.h \
+  gnc-csv-gnumeric-popup.h
+
+libgncmod_csv_import_la_LDFLAGS = -avoid-version
+
+libgncmod_csv_import_la_LIBADD = \
+  ${top_builddir}/src/import-export/libgncmod-generic-import.la \
+  ${top_builddir}/src/gnome-utils/libgncmod-gnome-utils.la \
+  ${top_builddir}/src/app-utils/libgncmod-app-utils.la \
+  ${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}/lib/stf/libgnc-stf.la \
+  ${top_builddir}/lib/libc/libc-missing.la \
+  ${top_builddir}/src/libqof/qof/libgnc-qof.la \
+  ${GOFFICE_LIBS} \
+  ${GLIB_LIBS}
+
+AM_CPPFLAGS = \
+  -I${top_srcdir}/src \
+  -I${top_srcdir}/src/core-utils \
+  -I${top_srcdir}/src/engine \
+  -I${top_srcdir}/src/gnc-module \
+  -I${top_srcdir}/src/app-utils \
+  -I${top_srcdir}/src/gnome \
+  -I${top_srcdir}/src/gnome-utils \
+  -I${top_srcdir}/src/import-export \
+  -I${top_srcdir}/src/libqof/qof \
+  -I${top_srcdir}/lib/libc \
+  -I${top_srcdir}/lib \
+  ${GUILE_CFLAGS} \
+  ${GLIB_CFLAGS} \
+  $(GOFFICE_CFLAGS)
+
+uidir = $(GNC_UI_DIR)
+ui_DATA = \
+	gnc-plugin-csv-import-ui.xml
+
+gtkbuilderdir = ${GNC_GTKBUILDER_DIR}
+gtkbuilder_DATA = \
+	assistant-csv-account-import.glade \
+	assistant-csv-trans-import.glade
+
+EXTRA_DIST = $(ui_DATA) $(gtkbuilder_DATA)
+
+AM_CPPFLAGS += -DG_LOG_DOMAIN=\"gnc.import.csv\"

Copied: gnucash/trunk/src/import-export/csv-imp/assistant-csv-account-import.c (from rev 23566, gnucash/trunk/src/import-export/csv-import/assistant-csv-account-import.c)
===================================================================
--- gnucash/trunk/src/import-export/csv-imp/assistant-csv-account-import.c	                        (rev 0)
+++ gnucash/trunk/src/import-export/csv-imp/assistant-csv-account-import.c	2013-12-15 17:21:20 UTC (rev 23567)
@@ -0,0 +1,681 @@
+/*******************************************************************\
+ * assistant-csv-account-import.c -- An assistant for importing     *
+ *                                         Accounts from a file.    *
+ *                                                                  *
+ * Copyright (C) 2012 Robert Fewell                                 *
+ *                                                                  *
+ * This program is free software; you can redistribute it and/or    *
+ * modify it under the terms of the GNU General Public License as   *
+ * published by the Free Software Foundation; either version 2 of   *
+ * the License, or (at your option) any later version.              *
+ *                                                                  *
+ * This program is distributed in the hope that it will be useful,  *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of   *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the    *
+ * GNU General Public License for more details.                     *
+ *                                                                  *
+ * You should have received a copy of the GNU General Public License*
+ * along with this program; if not, contact:                        *
+ *                                                                  *
+ * Free Software Foundation           Voice:  +1-617-542-5942       *
+ * 51 Franklin Street, Fifth Floor    Fax:    +1-617-542-2652       *
+ * Boston, MA  02110-1301,  USA       gnu at gnu.org                   *
+\********************************************************************/
+/** @file assistant-csv-account-import.c
+    @brief CSV Import Assistant
+    @author Copyright (c) 2012 Robert Fewell
+*/
+#include "config.h"
+
+#include <gtk/gtk.h>
+#include <glib/gi18n.h>
+
+#include "dialog-utils.h"
+#include "gnc-ui.h"
+#include "gnc-uri-utils.h"
+#include "gnc-ui-util.h"
+
+#include "gnc-component-manager.h"
+
+#include "assistant-utils.h"
+#include "assistant-csv-account-import.h"
+#include "csv-account-import.h"
+
+#define GNC_PREFS_GROUP "dialogs.import.csv"
+#define ASSISTANT_CSV_IMPORT_CM_CLASS "assistant-csv-account-import"
+
+/* This static indicates the debugging module that this .o belongs to.  */
+static QofLogModule log_module = GNC_MOD_ASSISTANT;
+
+/*************************************************************************/
+
+void csv_import_assistant_prepare (GtkAssistant  *assistant, GtkWidget *page, gpointer user_data);
+void csv_import_assistant_finish (GtkAssistant *gtkassistant, gpointer user_data);
+void csv_import_assistant_cancel (GtkAssistant *gtkassistant, gpointer user_data);
+void csv_import_assistant_close (GtkAssistant *gtkassistant, gpointer user_data);
+
+void csv_import_assistant_start_page_prepare (GtkAssistant *gtkassistant, gpointer user_data);
+void csv_import_assistant_account_page_prepare (GtkAssistant *gtkassistant, gpointer user_data);
+void csv_import_assistant_file_page_prepare (GtkAssistant *assistant, gpointer user_data);
+void csv_import_assistant_finish_page_prepare (GtkAssistant *assistant, gpointer user_data);
+void csv_import_assistant_summary_page_prepare (GtkAssistant *assistant, gpointer user_data);
+
+void csv_import_sep_cb (GtkWidget *radio, gpointer user_data );
+void csv_import_hrows_cb (GtkWidget *spin, gpointer user_data );
+
+void csv_import_file_chooser_confirm_cb (GtkWidget *button, CsvImportInfo *info);
+
+static gchar *gnc_input_dialog (GtkWidget *parent, const gchar *title, const gchar *msg, const gchar *default_input);
+
+static const gchar *finish_tree_string = N_(
+            "The accounts will be imported from the file '%s' when you click 'Apply'.\n\n"
+            "You can also go back and verify your selections by clicking on 'Back'"
+            " or 'Cancel' to Abort Import.\n");
+
+static const gchar *new_book_finish_tree_string = N_(
+            "The accounts will be imported from the file '%s' when you click 'Apply'.\n\n"
+            "You can also go back and verify your selections by clicking on 'Back'"
+            " or 'Cancel' to Abort Import.\n\n"
+            "If this is your initial import into a new file, you will first see "
+            "a dialog for setting book options, since these can affect how "
+            "imported data are converted to GnuCash transactions. If this is an "
+            "existing file, the dialog will not be shown.\n");
+
+/* Escape '_' in string */
+static gchar *mnemonic_escape (const gchar *source);
+static gchar *mnemonic_escape (const gchar *source)
+{
+    const guchar *p;
+    gchar *dest;
+    gchar *q;
+
+    g_return_val_if_fail (source != NULL, NULL);
+
+    p = (guchar *) source;
+    q = dest = g_malloc (strlen (source) * 2 + 1);
+
+    while (*p)
+    {
+        switch (*p)
+        {
+        case '_':
+            *q++ = '_';
+            *q++ = '_';
+            break;
+        default:
+            *q++ = *p;
+            break;
+        }
+        p++;
+    }
+    *q = 0;
+    return dest;
+}
+
+/*************************************************************************/
+
+/**************************************************
+ * csv_file_chooser_confirm_cb
+ *
+ * call back for ok button in file chooser widget
+ **************************************************/
+void
+csv_import_file_chooser_confirm_cb (GtkWidget *button, CsvImportInfo *info)
+{
+    GtkAssistant *assistant = GTK_ASSISTANT(info->window);
+    gint num = gtk_assistant_get_current_page (assistant);
+    GtkWidget *page = gtk_assistant_get_nth_page (assistant, num);
+
+    gchar *file_name;
+    csv_import_result res;
+
+    gtk_assistant_set_page_complete (assistant, page, FALSE);
+
+    file_name = gtk_file_chooser_get_filename ( GTK_FILE_CHOOSER(info->file_chooser ));
+
+    if (file_name)
+    {
+        gchar *filepath = gnc_uri_get_path ( file_name );
+        gchar *filedir = g_path_get_dirname( filepath );
+        info->starting_dir = g_strdup(filedir);
+        g_free ( filedir );
+        g_free ( filepath );
+
+        info->file_name = g_strdup(file_name);
+
+        // generate preview
+        gtk_list_store_clear (info->store);
+        res = csv_import_read_file (info->file_name, info->regexp->str, info->store, 1 );
+        if (res == RESULT_OPEN_FAILED)
+            gnc_error_dialog (info->window, _("The input file can not be opened."));
+        else if (res == RESULT_OK)
+            gtk_assistant_set_page_complete (assistant, page, TRUE);
+        else if (res == MATCH_FOUND)
+            gtk_assistant_set_page_complete (assistant, page, TRUE);
+    }
+    g_free(file_name);
+
+    DEBUG("file_name selected is %s", info->file_name);
+    DEBUG("starting directory is %s", info->starting_dir);
+
+    /* Step to next page if page is complete */
+    if(gtk_assistant_get_page_complete(assistant, page))
+        gtk_assistant_set_current_page (assistant, num + 1);
+
+}
+
+
+/*******************************************************
+ * csv_import_hrows_cb
+ *
+ * call back for the start row / number of header rows
+ *******************************************************/
+void csv_import_hrows_cb (GtkWidget *spin, gpointer user_data )
+{
+    CsvImportInfo *info = user_data;
+
+    GtkTreeIter iter;
+    gboolean valid;
+    int num_rows;
+
+    /* Get number of rows for header */
+    info->header_rows = gtk_spin_button_get_value_as_int (GTK_SPIN_BUTTON(spin));
+
+    /* Get number of rows displayed */
+    num_rows = gtk_tree_model_iter_n_children(GTK_TREE_MODEL(info->store), NULL);
+
+    /* Modify background color for header rows */
+    if (info->header_rows == 0)
+    {
+        valid = gtk_tree_model_iter_nth_child(GTK_TREE_MODEL(info->store), &iter, NULL, 0 );
+        if (valid)
+            gtk_list_store_set (info->store, &iter, ROW_COLOR, NULL, -1);
+    }
+    else
+    {
+        if (info->header_rows - 1 < num_rows)
+        {
+            valid = gtk_tree_model_iter_nth_child(GTK_TREE_MODEL(info->store), &iter, NULL, info->header_rows - 1 );
+            if (valid)
+                gtk_list_store_set (info->store, &iter, ROW_COLOR, "pink", -1);
+            valid = gtk_tree_model_iter_next (GTK_TREE_MODEL(info->store), &iter);
+            if (valid)
+                gtk_list_store_set (info->store, &iter, ROW_COLOR, NULL, -1);
+        }
+    }
+}
+
+
+/*******************************************************
+ * csv_import_sep_cb
+ *
+ * call back for type of separartor required
+ *******************************************************/
+void csv_import_sep_cb (GtkWidget *radio, gpointer user_data )
+{
+    CsvImportInfo *info = user_data;
+    const gchar *name;
+    gchar *temp;
+
+    if (!gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(radio)))
+    {
+        LEAVE("1st callback of pair. Defer to 2nd callback.");
+        return;
+    }
+
+    name = gtk_buildable_get_name(GTK_BUILDABLE(radio));
+
+    if (g_strcmp0(name, g_strdup("radio_semi")) == 0)
+        g_string_assign (info->regexp, "^(?<type>[^;]*);(?<full_name>[^;]*);(?<name>[^;]*);(?<code>[^;]*);?(?<description>[^;]*);?(?<color>[^;]*);?(?<notes>[^;]*);?(?<commoditym>[^;]*);?(?<commodityn>[^;]*);?(?<hidden>[^;]*);?(?<tax>[^;]*);?(?<place_holder>[^;]*)$");
+
+    if (g_strcmp0(name, g_strdup("radio_comma")) == 0)
+        g_string_assign (info->regexp, "^(?<type>[^,]*),(?<full_name>[^,]*),(?<name>[^,]*),(?<code>[^,]*),?(?<description>[^,]*),?(?<color>[^,]*),?(?<notes>[^,]*),?(?<commoditym>[^,]*),?(?<commodityn>[^,]*),?(?<hidden>[^,]*),?(?<tax>[^,]*),?(?<place_holder>[^,]*)$");
+
+    if (g_strcmp0(name, g_strdup("radio_semiq")) == 0)
+        g_string_assign (info->regexp, "^((?<type>[^\";]*)|\"(?<type>[^\"]*)\");((?<full_name>[^\";]*)|\"(?<full_name>[^\"]*)\");((?<name>[^\";]*)|\"(?<name>[^\"]*)\");((?<code>[^\";]*)|\"(?<code>[^\"]*)\");((?<description>[^\";]*)|\"(?<description>[^\"]*)\");((?<color>[^\";]*)|\"(?<color>[^\"]*)\");((?<notes>[^\";]*)|\"(?<notes>[^\"]*)\");((?<commoditym>[^\";]*)|\"(?<commoditym>[^\"]*)\");((?<commodityn>[^\";]*)|\"(?<commodityn>[^\"]*)\");((?<hidden>[^\";]*)|\"(?<hidden>[^\"]*)\");((?<tax>[^\";]*)|\"(?<tax>[^\"]*)\");((?<place_holder>[^\";]*)|\"(?<place_holder>[^\"]*)\")$");
+
+    if (g_strcmp0(name, g_strdup("radio_commaq")) == 0)
+        g_string_assign (info->regexp, "^((?<type>[^\",]*)|\"(?<type>[^\"]*)\"),((?<full_name>[^\",]*)|\"(?<full_name>[^\"]*)\"),((?<name>[^\",]*)|\"(?<name>[^\"]*)\"),((?<code>[^\",]*)|\"(?<code>[^\"]*)\"),((?<description>[^\",]*)|\"(?<description>[^\"]*)\"),((?<color>[^\",]*)|\"(?<color>[^\"]*)\"),((?<notes>[^\",]*)|\"(?<notes>[^\"]*)\"),((?<commoditym>[^\",]*)|\"(?<commoditym>[^\"]*)\"),((?<commodityn>[^\",]*)|\"(?<commodityn>[^\"]*)\"),((?<hidden>[^\",]*)|\"(?<hidden>[^\"]*)\"),((?<tax>[^\",]*)|\"(?<tax>[^\"]*)\"),((?<place_holder>[^\",]*)|\"(?<place_holder>[^\"]*)\")$");
+
+    if (g_strcmp0(name, g_strdup("radio_custom")) == 0)
+    {
+        temp = gnc_input_dialog (0, _("Adjust regular expression used for import"), _("This regular expression is used to parse the import file. Modify according to your needs.\n"), info->regexp->str);
+        if (temp)
+        {
+            g_string_assign (info->regexp, temp);
+            g_free (temp);
+        }
+    }
+
+    /* Generate preview */
+    gtk_list_store_clear (info->store);
+
+    if (csv_import_read_file (info->file_name, info->regexp->str, info->store, 11 ) == MATCH_FOUND)
+        gtk_widget_set_sensitive (info->header_row_spin, TRUE);
+    else
+        gtk_widget_set_sensitive (info->header_row_spin, FALSE);
+
+    /* Reset Header spin to 0 */
+    gtk_spin_button_set_value( GTK_SPIN_BUTTON(info->header_row_spin), 0 );
+}
+
+
+/*******************************************************
+ * load_settings
+ *
+ * load the default settings for the assistant
+ *******************************************************/
+static
+void load_settings (CsvImportInfo *info)
+{
+    info->header_rows = 0;
+    info->error = "";
+    info->starting_dir = NULL;
+    info->file_name = NULL;
+    info->error = "";
+
+    /* The default directory for the user to select files. */
+    info->starting_dir = gnc_get_default_directory(GNC_PREFS_GROUP);
+}
+
+
+/* =============================================================== */
+
+
+/********************************************************************\
+ * gnc_input_dialog                                                 *
+ *   simple convenience dialog to get a single value from the user  *
+ *   user may choose between "Ok" and "Cancel"                      *
+ *                                                                  *
+ * NOTE: This function does not return until the dialog is closed   *
+ *                                                                  *
+ * Args:   parent  - the parent window or NULL                      *
+ *         title   - the title of the dialog                        *
+ *         msg     - the message to display                         *
+ *         default_input - will be displayed as default input       *
+ * Return: the input (text) the user entered, if pressed "Ok"       *
+ *         NULL, if pressed "Cancel"                                *
+\********************************************************************/
+static gchar *
+gnc_input_dialog (GtkWidget *parent, const gchar *title, const gchar *msg, const gchar *default_input)
+{
+    GtkWidget *dialog, *label, *content_area;
+    gint result;
+    GtkWidget *view;
+    GtkTextBuffer *buffer;
+    gchar *user_input;
+    GtkTextIter start, end;
+
+    /* Create the widgets */
+    dialog = gtk_dialog_new_with_buttons (title, GTK_WINDOW (parent),
+                                          GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT,
+                                          GTK_STOCK_OK, GTK_RESPONSE_ACCEPT,
+                                          GTK_STOCK_CANCEL, GTK_RESPONSE_REJECT,
+                                          NULL);
+
+    content_area = gtk_dialog_get_content_area (GTK_DIALOG (dialog));
+
+    // add a label
+    label = gtk_label_new (msg);
+    gtk_container_add (GTK_CONTAINER (content_area), label);
+
+    // add a textview
+    view = gtk_text_view_new ();
+    gtk_text_view_set_wrap_mode (GTK_TEXT_VIEW (view), GTK_WRAP_WORD_CHAR);
+    buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (view));
+    gtk_text_buffer_set_text (buffer, default_input, -1);
+    gtk_container_add (GTK_CONTAINER (content_area), view);
+
+    // run the dialog
+    gtk_widget_show_all (dialog);
+    result = gtk_dialog_run (GTK_DIALOG (dialog));
+
+    if (result == GTK_RESPONSE_REJECT)
+        user_input = 0;
+    else
+    {
+        gtk_text_buffer_get_start_iter (buffer, &start);
+        gtk_text_buffer_get_end_iter (buffer, &end);
+        user_input = gtk_text_buffer_get_text (buffer,
+                                               &start, &end, FALSE);
+    }
+
+    gtk_widget_destroy (dialog);
+
+    return user_input;
+}
+
+
+/* =============================================================== */
+
+
+/*******************************************************
+ * Assistant page prepare functions
+ *******************************************************/
+void
+csv_import_assistant_start_page_prepare (GtkAssistant *assistant,
+        gpointer user_data)
+{
+    gint num = gtk_assistant_get_current_page (assistant);
+    GtkWidget *page = gtk_assistant_get_nth_page (assistant, num);
+
+    /* Enable the Assistant Buttons */
+    gtk_assistant_set_page_complete (assistant, page, TRUE);
+}
+
+
+void
+csv_import_assistant_file_page_prepare (GtkAssistant *assistant,
+                                        gpointer user_data)
+{
+    CsvImportInfo *info = user_data;
+    gint num = gtk_assistant_get_current_page (assistant);
+    GtkWidget *page = gtk_assistant_get_nth_page (assistant, num);
+
+    /* Set the default directory */
+    if (info->starting_dir)
+        gtk_file_chooser_set_current_folder(GTK_FILE_CHOOSER(info->file_chooser), info->starting_dir);
+
+    /* Disable the Forward Assistant Button */
+    gtk_assistant_set_page_complete (assistant, page, FALSE);
+}
+
+
+void
+csv_import_assistant_account_page_prepare (GtkAssistant *assistant,
+        gpointer user_data)
+{
+    CsvImportInfo *info = user_data;
+
+    gtk_list_store_clear (info->store);
+
+    if (csv_import_read_file (info->file_name, info->regexp->str, info->store, 11 ) == MATCH_FOUND)
+        gtk_widget_set_sensitive (info->header_row_spin, TRUE);
+    else
+        gtk_widget_set_sensitive (info->header_row_spin, FALSE);
+}
+
+
+void
+csv_import_assistant_finish_page_prepare (GtkAssistant *assistant,
+        gpointer user_data)
+{
+    CsvImportInfo *info = user_data;
+    gint num = gtk_assistant_get_current_page (assistant);
+    GtkWidget *page = gtk_assistant_get_nth_page (assistant, num);
+    gchar *text;
+
+    /* Set Finish page text */
+    /* Before creating accounts, if this is a new book, tell user they can
+     * specify book options, since they affect how transactions are created */
+    if (info->new_book)
+    {
+        text = g_strdup_printf (gettext (new_book_finish_tree_string), info->file_name);
+    }
+    else
+    {
+        text = g_strdup_printf (gettext (finish_tree_string), info->file_name);
+    }
+    gtk_label_set_text (GTK_LABEL(info->finish_label), text);
+    g_free(text);
+
+    /* Save the Window size and directory */
+    gnc_set_default_directory(GNC_PREFS_GROUP, info->starting_dir);
+
+    /* Enable the Assistant Buttons */
+    gtk_assistant_set_page_complete (assistant, page, TRUE);
+}
+
+
+void
+csv_import_assistant_summary_page_prepare (GtkAssistant *assistant,
+        gpointer user_data)
+{
+    CsvImportInfo *info = user_data;
+    gchar *text, *errtext, *mtext;
+
+    /* Before creating accounts, if this is a new book, let user specify
+     * book options, since they affect how transactions are created */
+    if (info->new_book)
+        info->new_book = gnc_new_book_option_display();
+
+    if (!g_strcmp0(info->error, "") == 0)
+    {
+        GtkTextBuffer *buffer;
+
+        buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (info->summary_error_view));
+        text = g_strdup_printf(gettext ("Import completed but with errors!\n\nThe number of Accounts added was %u and "
+                                        "updated was %u.\n\nSee below for errors..." ), info->num_new, info->num_updates );
+        errtext = g_strdup_printf ( "%s", info->error);
+        gtk_text_buffer_set_text (buffer, errtext, -1);
+        g_free(errtext);
+        g_free(info->error);
+    }
+    else
+        text = g_strdup_printf(gettext ("Import completed successfully!\n\nThe number of Accounts added was %u and "
+                                        "updated was %u.\n" ), info->num_new, info->num_updates );
+
+    mtext = g_strdup_printf("<span size=\"medium\"><b>%s</b></span>", text);
+    gtk_label_set_markup(GTK_LABEL(info->summary_label), mtext);
+
+    g_free(text);
+    g_free(mtext);
+}
+
+
+void
+csv_import_assistant_prepare (GtkAssistant *assistant, GtkWidget *page,
+                              gpointer user_data)
+{
+    gint currentpage = gtk_assistant_get_current_page(assistant);
+
+    switch (currentpage)
+    {
+    case 0:
+        /* Current page is Import Start page */
+        csv_import_assistant_start_page_prepare (assistant, user_data);
+        break;
+    case 1:
+        /* Current page is File select page */
+        csv_import_assistant_file_page_prepare (assistant, user_data);
+        break;
+    case 2:
+        /* Current page is Account page */
+        csv_import_assistant_account_page_prepare (assistant, user_data);
+        break;
+    case 3:
+        /* Current page is Finish page */
+        csv_import_assistant_finish_page_prepare (assistant, user_data);
+        break;
+    case 4:
+        /* Current page is Summary page */
+        csv_import_assistant_summary_page_prepare (assistant, user_data);
+        break;
+    }
+}
+
+
+/*******************************************************
+ * Assistant call back functions
+ *******************************************************/
+static void
+csv_import_assistant_destroy_cb (GtkObject *object, gpointer user_data)
+{
+    CsvImportInfo *info = user_data;
+    gnc_unregister_gui_component_by_data (ASSISTANT_CSV_IMPORT_CM_CLASS, info);
+    g_free (info);
+}
+
+void
+csv_import_assistant_cancel (GtkAssistant *assistant, gpointer user_data)
+{
+    CsvImportInfo *info = user_data;
+    gnc_close_gui_component_by_data (ASSISTANT_CSV_IMPORT_CM_CLASS, info);
+}
+
+void
+csv_import_assistant_close (GtkAssistant *assistant, gpointer user_data)
+{
+    CsvImportInfo *info = user_data;
+    gnc_close_gui_component_by_data (ASSISTANT_CSV_IMPORT_CM_CLASS, info);
+}
+
+void
+csv_import_assistant_finish (GtkAssistant *assistant, gpointer user_data)
+{
+    CsvImportInfo *info = user_data;
+
+    gtk_list_store_clear (info->store);
+    csv_import_read_file (info->file_name, info->regexp->str, info->store, 0 );
+    csv_account_import (info);
+}
+
+static void
+csv_import_close_handler (gpointer user_data)
+{
+    CsvImportInfo *info = user_data;
+
+    g_free(info->starting_dir);
+    g_free(info->file_name);
+    g_string_free(info->regexp, TRUE);
+
+    gnc_save_window_size(GNC_PREFS_GROUP, GTK_WINDOW(info->window));
+    gtk_widget_destroy (info->window);
+}
+
+/*******************************************************
+ * Create the Assistant
+ *******************************************************/
+static GtkWidget *
+csv_import_assistant_create (CsvImportInfo *info)
+{
+    GtkBuilder *builder;
+    GtkWidget *window;
+    GtkWidget *box, *h_box;
+    GtkWidget *button;
+    GtkCellRenderer *renderer;
+    GtkTreeViewColumn *column;
+
+    builder = gtk_builder_new();
+    gnc_builder_add_from_file  (builder , "assistant-csv-account-import.glade", "num_hrows_adj");
+    gnc_builder_add_from_file  (builder , "assistant-csv-account-import.glade", "CSV Account Import Assistant");
+    window = GTK_WIDGET(gtk_builder_get_object (builder, "CSV Account Import Assistant"));
+    info->window = window;
+
+    /* Set the assistant colors */
+    gnc_assistant_set_colors (GTK_ASSISTANT (info->window));
+
+    /* Load default settings */
+    load_settings (info);
+
+    /* Enable buttons on all page. */
+    gtk_assistant_set_page_complete (GTK_ASSISTANT (window),
+                                     GTK_WIDGET(gtk_builder_get_object(builder, "start_page")),
+                                     TRUE);
+    gtk_assistant_set_page_complete (GTK_ASSISTANT (window),
+                                     GTK_WIDGET(gtk_builder_get_object(builder, "file_page")),
+                                     FALSE);
+    gtk_assistant_set_page_complete (GTK_ASSISTANT (window),
+                                     GTK_WIDGET(gtk_builder_get_object(builder, "import_tree_page")),
+                                     TRUE);
+    gtk_assistant_set_page_complete (GTK_ASSISTANT (window),
+                                     GTK_WIDGET(gtk_builder_get_object(builder, "end_page")),
+                                     FALSE);
+    gtk_assistant_set_page_complete (GTK_ASSISTANT (window),
+                                     GTK_WIDGET(gtk_builder_get_object(builder, "summary_page")),
+                                     TRUE);
+
+    /* Start Page */
+
+    /* File chooser Page */
+    info->file_chooser = gtk_file_chooser_widget_new (GTK_FILE_CHOOSER_ACTION_OPEN);
+    g_signal_connect (G_OBJECT (info->file_chooser), "file-activated",
+                      G_CALLBACK (csv_import_file_chooser_confirm_cb), info);
+    button = gtk_button_new_from_stock(GTK_STOCK_OK);
+    gtk_widget_set_size_request (button, 100, -1);
+    gtk_widget_show (button);
+    h_box = gtk_hbox_new(TRUE, 0);
+    gtk_box_pack_start(GTK_BOX(h_box), button, FALSE, FALSE, 0);
+    gtk_file_chooser_set_extra_widget (GTK_FILE_CHOOSER(info->file_chooser), h_box);
+    g_signal_connect (G_OBJECT (button), "clicked",
+                      G_CALLBACK (csv_import_file_chooser_confirm_cb), info);
+
+    box = GTK_WIDGET(gtk_builder_get_object(builder, "file_page"));
+    gtk_box_pack_start (GTK_BOX (box), info->file_chooser, TRUE, TRUE, 6);
+    gtk_widget_show (info->file_chooser);
+
+    /* Account Tree Page */
+    info->header_row_spin = GTK_WIDGET(gtk_builder_get_object (builder, "num_hrows"));
+    info->tree_view = GTK_WIDGET(gtk_builder_get_object (builder, "treeview"));
+
+    info->regexp = g_string_new ( "^(?<type>[^;]*);(?<full_name>[^;]*);(?<name>[^;]*);(?<code>[^;]*);?(?<description>[^;]*);?(?<color>[^;]*);?(?<notes>[^;]*);?(?<commoditym>[^;]*);?(?<commodityn>[^;]*);?(?<hidden>[^;]*);?(?<tax>[^;]*);?(?<place_holder>[^;]*)$");
+
+    /* create model and bind to view */
+    info->store = gtk_list_store_new (N_COLUMNS,
+                                      G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING,
+                                      G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING);
+    gtk_tree_view_set_model( GTK_TREE_VIEW(info->tree_view), GTK_TREE_MODEL(info->store) );
+#define CREATE_COLUMN(description,column_id) \
+  renderer = gtk_cell_renderer_text_new (); \
+  column = gtk_tree_view_column_new_with_attributes (mnemonic_escape(_(description)), renderer, "text", column_id, NULL); \
+  gtk_tree_view_column_add_attribute(column, renderer, "background", ROW_COLOR); \
+  gtk_tree_view_column_set_resizable (column, TRUE); \
+  gtk_tree_view_append_column (GTK_TREE_VIEW (info->tree_view), column);
+    CREATE_COLUMN ("type", TYPE);
+    CREATE_COLUMN ("full_name", FULL_NAME);
+    CREATE_COLUMN ("name", NAME);
+    CREATE_COLUMN ("code", CODE);
+    CREATE_COLUMN ("description", DESCRIPTION);
+    CREATE_COLUMN ("color", COLOR);
+    CREATE_COLUMN ("notes", NOTES);
+    CREATE_COLUMN ("commoditym", COMMODITYM);
+    CREATE_COLUMN ("commodityn", COMMODITYN);
+    CREATE_COLUMN ("hidden", HIDDEN);
+    CREATE_COLUMN ("tax", TAX);
+    CREATE_COLUMN ("place_holder", PLACE_HOLDER);
+
+    /* Finish Page */
+    info->finish_label = GTK_WIDGET(gtk_builder_get_object(builder, "end_page"));
+    /* Summary Page */
+    info->summary_label = GTK_WIDGET(gtk_builder_get_object(builder, "summary_label"));
+    info->summary_error_view = GTK_WIDGET(gtk_builder_get_object(builder, "summary_error_view"));
+
+    g_signal_connect (G_OBJECT(window), "destroy",
+                      G_CALLBACK (csv_import_assistant_destroy_cb), info);
+
+    gnc_restore_window_size (GNC_PREFS_GROUP, GTK_WINDOW(info->window));
+
+    gtk_builder_connect_signals(builder, info);
+    g_object_unref(G_OBJECT(builder));
+    return window;
+}
+
+
+/********************************************************************\
+ * gnc_file_csv_account_import                                      *
+ * opens up a assistant to import accounts.                         *
+ *                                                                  *
+ * Args:   import_type                                              *
+ * Return: nothing                                                  *
+\********************************************************************/
+void
+gnc_file_csv_account_import(void)
+{
+    CsvImportInfo *info;
+
+    info = g_new0 (CsvImportInfo, 1);
+
+    /* In order to trigger a book options display on the creation of a new book,
+     * we need to detect when we are dealing with a new book. */
+    info->new_book = gnc_is_new_book();
+
+    csv_import_assistant_create (info);
+
+    gnc_register_gui_component (ASSISTANT_CSV_IMPORT_CM_CLASS,
+                                NULL, csv_import_close_handler,
+                                info);
+
+    gtk_widget_show_all (info->window);
+
+    gnc_window_adjust_for_screen (GTK_WINDOW(info->window));
+}

Copied: gnucash/trunk/src/import-export/csv-imp/assistant-csv-account-import.glade (from rev 23566, gnucash/trunk/src/import-export/csv-import/assistant-csv-account-import.glade)
===================================================================
--- gnucash/trunk/src/import-export/csv-imp/assistant-csv-account-import.glade	                        (rev 0)
+++ gnucash/trunk/src/import-export/csv-imp/assistant-csv-account-import.glade	2013-12-15 17:21:20 UTC (rev 23567)
@@ -0,0 +1,382 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<interface>
+  <requires lib="gtk+" version="2.16"/>
+  <!-- interface-naming-policy project-wide -->
+  <object class="GtkAssistant" id="CSV Account Import Assistant">
+    <property name="can_focus">False</property>
+    <property name="border_width">12</property>
+    <property name="title" translatable="yes">CSV Import Assistant</property>
+    <property name="default_width">400</property>
+    <property name="default_height">500</property>
+    <signal name="close" handler="csv_import_assistant_close" swapped="no"/>
+    <signal name="apply" handler="csv_import_assistant_finish" swapped="no"/>
+    <signal name="prepare" handler="csv_import_assistant_prepare" swapped="no"/>
+    <signal name="cancel" handler="csv_import_assistant_cancel" swapped="no"/>
+    <child>
+      <object class="GtkVBox" id="start_page">
+        <property name="visible">True</property>
+        <property name="can_focus">False</property>
+        <property name="border_width">12</property>
+        <child>
+          <object class="GtkLabel" id="start_label">
+            <property name="visible">True</property>
+            <property name="can_focus">False</property>
+            <property name="label" translatable="yes">
+This assistant will help you import Accounts from a file.
+
+The file must be in the same format as that exported as this is a fixed format import. If the account is missing, based on the full account name, it will be added as long as the security / currency specified exists. If the account exists, then four fields will be updated. These are code, description, notes and color.
+
+Click on 'Forward' to proceed or 'Cancel' to Abort Import.
+</property>
+            <property name="justify">center</property>
+            <property name="wrap">True</property>
+          </object>
+          <packing>
+            <property name="expand">False</property>
+            <property name="fill">False</property>
+            <property name="position">0</property>
+          </packing>
+        </child>
+      </object>
+      <packing>
+        <property name="page_type">intro</property>
+        <property name="title" translatable="yes">Import Account Assistant</property>
+        <property name="complete">True</property>
+      </packing>
+    </child>
+    <child>
+      <object class="GtkVBox" id="file_page">
+        <property name="visible">True</property>
+        <property name="can_focus">False</property>
+        <property name="border_width">12</property>
+        <child>
+          <object class="GtkLabel" id="label4">
+            <property name="visible">True</property>
+            <property name="can_focus">False</property>
+            <property name="label" translatable="yes">
+Enter file name and location for the Import...
+</property>
+            <property name="wrap">True</property>
+          </object>
+          <packing>
+            <property name="expand">False</property>
+            <property name="fill">False</property>
+            <property name="position">0</property>
+          </packing>
+        </child>
+        <child>
+          <placeholder/>
+        </child>
+      </object>
+      <packing>
+        <property name="title" translatable="yes">Choose File to Import</property>
+      </packing>
+    </child>
+    <child>
+      <object class="GtkVBox" id="import_tree_page">
+        <property name="visible">True</property>
+        <property name="can_focus">False</property>
+        <property name="border_width">12</property>
+        <child>
+          <object class="GtkHBox" id="hbox1">
+            <property name="visible">True</property>
+            <property name="can_focus">False</property>
+            <child>
+              <object class="GtkLabel" id="label3">
+                <property name="visible">True</property>
+                <property name="can_focus">False</property>
+                <property name="xpad">6</property>
+                <property name="label" translatable="yes">Number of rows for the Header</property>
+              </object>
+              <packing>
+                <property name="expand">False</property>
+                <property name="fill">False</property>
+                <property name="position">0</property>
+              </packing>
+            </child>
+            <child>
+              <object class="GtkSpinButton" id="num_hrows">
+                <property name="visible">True</property>
+                <property name="can_focus">True</property>
+                <property name="editable">False</property>
+                <property name="invisible_char">&#x25CF;</property>
+                <property name="invisible_char_set">True</property>
+                <property name="primary_icon_activatable">False</property>
+                <property name="secondary_icon_activatable">False</property>
+                <property name="primary_icon_sensitive">True</property>
+                <property name="secondary_icon_sensitive">True</property>
+                <property name="adjustment">num_hrows_adj</property>
+                <signal name="value-changed" handler="csv_import_hrows_cb" swapped="no"/>
+              </object>
+              <packing>
+                <property name="expand">False</property>
+                <property name="fill">False</property>
+                <property name="position">1</property>
+              </packing>
+            </child>
+            <child>
+              <placeholder/>
+            </child>
+          </object>
+          <packing>
+            <property name="expand">False</property>
+            <property name="fill">False</property>
+            <property name="position">0</property>
+          </packing>
+        </child>
+        <child>
+          <object class="GtkFrame" id="separator_frame">
+            <property name="visible">True</property>
+            <property name="can_focus">False</property>
+            <property name="label_xalign">0</property>
+            <property name="shadow_type">in</property>
+            <child>
+              <object class="GtkTable" id="table4">
+                <property name="visible">True</property>
+                <property name="can_focus">False</property>
+                <property name="border_width">12</property>
+                <property name="n_rows">4</property>
+                <property name="n_columns">4</property>
+                <child>
+                  <object class="GtkRadioButton" id="radio_semi">
+                    <property name="label" translatable="yes">Semicolon Separated</property>
+                    <property name="visible">True</property>
+                    <property name="can_focus">True</property>
+                    <property name="receives_default">False</property>
+                    <property name="use_action_appearance">False</property>
+                    <property name="active">True</property>
+                    <property name="draw_indicator">True</property>
+                    <signal name="toggled" handler="csv_import_sep_cb" swapped="no"/>
+                  </object>
+                </child>
+                <child>
+                  <object class="GtkRadioButton" id="radio_semiq">
+                    <property name="label" translatable="yes">Semicolon Separated with Quotes</property>
+                    <property name="visible">True</property>
+                    <property name="can_focus">True</property>
+                    <property name="receives_default">False</property>
+                    <property name="use_action_appearance">False</property>
+                    <property name="draw_indicator">True</property>
+                    <property name="group">radio_semi</property>
+                    <signal name="toggled" handler="csv_import_sep_cb" swapped="no"/>
+                  </object>
+                  <packing>
+                    <property name="left_attach">2</property>
+                    <property name="right_attach">3</property>
+                  </packing>
+                </child>
+                <child>
+                  <object class="GtkRadioButton" id="radio_comma">
+                    <property name="label" translatable="yes">Comma Separated</property>
+                    <property name="visible">True</property>
+                    <property name="can_focus">True</property>
+                    <property name="receives_default">False</property>
+                    <property name="use_action_appearance">False</property>
+                    <property name="draw_indicator">True</property>
+                    <property name="group">radio_semi</property>
+                    <signal name="toggled" handler="csv_import_sep_cb" swapped="no"/>
+                  </object>
+                  <packing>
+                    <property name="top_attach">1</property>
+                    <property name="bottom_attach">2</property>
+                  </packing>
+                </child>
+                <child>
+                  <object class="GtkRadioButton" id="radio_commaq">
+                    <property name="label" translatable="yes">Comma Separated with Quotes</property>
+                    <property name="visible">True</property>
+                    <property name="can_focus">True</property>
+                    <property name="receives_default">False</property>
+                    <property name="use_action_appearance">False</property>
+                    <property name="draw_indicator">True</property>
+                    <property name="group">radio_semi</property>
+                    <signal name="toggled" handler="csv_import_sep_cb" swapped="no"/>
+                  </object>
+                  <packing>
+                    <property name="left_attach">2</property>
+                    <property name="right_attach">3</property>
+                    <property name="top_attach">1</property>
+                    <property name="bottom_attach">2</property>
+                  </packing>
+                </child>
+                <child>
+                  <object class="GtkRadioButton" id="radio_custom">
+                    <property name="label" translatable="yes">Custom regular Expression</property>
+                    <property name="visible">True</property>
+                    <property name="can_focus">True</property>
+                    <property name="receives_default">False</property>
+                    <property name="use_action_appearance">False</property>
+                    <property name="draw_indicator">True</property>
+                    <property name="group">radio_semi</property>
+                    <signal name="toggled" handler="csv_import_sep_cb" swapped="no"/>
+                  </object>
+                  <packing>
+                    <property name="top_attach">2</property>
+                    <property name="bottom_attach">3</property>
+                  </packing>
+                </child>
+                <child>
+                  <placeholder/>
+                </child>
+                <child>
+                  <placeholder/>
+                </child>
+                <child>
+                  <placeholder/>
+                </child>
+                <child>
+                  <placeholder/>
+                </child>
+                <child>
+                  <placeholder/>
+                </child>
+                <child>
+                  <placeholder/>
+                </child>
+                <child>
+                  <placeholder/>
+                </child>
+                <child>
+                  <placeholder/>
+                </child>
+                <child>
+                  <placeholder/>
+                </child>
+                <child>
+                  <placeholder/>
+                </child>
+                <child>
+                  <placeholder/>
+                </child>
+              </object>
+            </child>
+            <child type="label">
+              <object class="GtkLabel" id="label6">
+                <property name="visible">True</property>
+                <property name="can_focus">False</property>
+                <property name="label" translatable="yes">Select Separator Type</property>
+                <property name="use_markup">True</property>
+              </object>
+            </child>
+          </object>
+          <packing>
+            <property name="expand">False</property>
+            <property name="fill">False</property>
+            <property name="padding">7</property>
+            <property name="position">1</property>
+          </packing>
+        </child>
+        <child>
+          <object class="GtkFrame" id="preview_frame">
+            <property name="visible">True</property>
+            <property name="can_focus">False</property>
+            <property name="label_xalign">0</property>
+            <property name="shadow_type">in</property>
+            <child>
+              <object class="GtkScrolledWindow" id="scroll_window">
+                <property name="visible">True</property>
+                <property name="can_focus">True</property>
+                <property name="border_width">6</property>
+                <property name="hscrollbar_policy">automatic</property>
+                <property name="vscrollbar_policy">automatic</property>
+                <child>
+                  <object class="GtkTreeView" id="treeview">
+                    <property name="visible">True</property>
+                    <property name="can_focus">True</property>
+                  </object>
+                </child>
+              </object>
+            </child>
+            <child type="label">
+              <object class="GtkLabel" id="label8">
+                <property name="visible">True</property>
+                <property name="can_focus">False</property>
+                <property name="label" translatable="yes">Preview</property>
+                <property name="use_markup">True</property>
+              </object>
+            </child>
+          </object>
+          <packing>
+            <property name="expand">True</property>
+            <property name="fill">True</property>
+            <property name="position">2</property>
+          </packing>
+        </child>
+      </object>
+      <packing>
+        <property name="page_type">progress</property>
+        <property name="title" translatable="yes">Import Account Preview, first 10 rows only</property>
+        <property name="complete">True</property>
+      </packing>
+    </child>
+    <child>
+      <object class="GtkLabel" id="end_page">
+        <property name="visible">True</property>
+        <property name="can_focus">False</property>
+        <property name="label" translatable="yes">Press Apply to create export file.
+Cancel to abort.</property>
+        <property name="wrap">True</property>
+      </object>
+      <packing>
+        <property name="page_type">confirm</property>
+        <property name="title" translatable="yes">Import Accounts Now</property>
+      </packing>
+    </child>
+    <child>
+      <object class="GtkVBox" id="summary_page">
+        <property name="visible">True</property>
+        <property name="can_focus">False</property>
+        <property name="border_width">12</property>
+        <child>
+          <object class="GtkLabel" id="summary_label">
+            <property name="visible">True</property>
+            <property name="can_focus">False</property>
+            <property name="label" translatable="yes">label</property>
+            <property name="use_markup">True</property>
+          </object>
+          <packing>
+            <property name="expand">True</property>
+            <property name="fill">True</property>
+            <property name="position">0</property>
+          </packing>
+        </child>
+        <child>
+          <object class="GtkScrolledWindow" id="summary_error_scrolledwindow">
+            <property name="visible">True</property>
+            <property name="can_focus">False</property>
+            <property name="border_width">1</property>
+            <property name="hscrollbar_policy">automatic</property>
+            <property name="vscrollbar_policy">automatic</property>
+            <property name="shadow_type">etched-in</property>
+            <child>
+              <object class="GtkTextView" id="summary_error_view">
+                <property name="visible">True</property>
+                <property name="can_focus">False</property>
+                <property name="left_margin">2</property>
+                <property name="right_margin">2</property>
+              </object>
+            </child>
+          </object>
+          <packing>
+            <property name="expand">True</property>
+            <property name="fill">True</property>
+            <property name="position">1</property>
+          </packing>
+        </child>
+        <child>
+          <placeholder/>
+        </child>
+      </object>
+      <packing>
+        <property name="page_type">summary</property>
+        <property name="title" translatable="yes">Import Summary</property>
+        <property name="complete">True</property>
+      </packing>
+    </child>
+  </object>
+  <object class="GtkAdjustment" id="num_hrows_adj">
+    <property name="upper">100</property>
+    <property name="step_increment">1</property>
+    <property name="page_increment">10</property>
+  </object>
+</interface>

Copied: gnucash/trunk/src/import-export/csv-imp/assistant-csv-account-import.h (from rev 23566, gnucash/trunk/src/import-export/csv-import/assistant-csv-account-import.h)
===================================================================
--- gnucash/trunk/src/import-export/csv-imp/assistant-csv-account-import.h	                        (rev 0)
+++ gnucash/trunk/src/import-export/csv-imp/assistant-csv-account-import.h	2013-12-15 17:21:20 UTC (rev 23567)
@@ -0,0 +1,69 @@
+/*******************************************************************\
+ * assistant-csv-account-import.h -- An assistant for importing     *
+ *                                         Accounts from a file.    *
+ *                                                                  *
+ * Copyright (C) 2012 Robert Fewell                                 *
+ *                                                                  *
+ * This program is free software; you can redistribute it and/or    *
+ * modify it under the terms of the GNU General Public License as   *
+ * published by the Free Software Foundation; either version 2 of   *
+ * the License, or (at your option) any later version.              *
+ *                                                                  *
+ * This program is distributed in the hope that it will be useful,  *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of   *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the    *
+ * GNU General Public License for more details.                     *
+ *                                                                  *
+ * You should have received a copy of the GNU General Public License*
+ * along with this program; if not, contact:                        *
+ *                                                                  *
+ * Free Software Foundation           Voice:  +1-617-542-5942       *
+ * 51 Franklin Street, Fifth Floor    Fax:    +1-617-542-2652       *
+ * Boston, MA  02110-1301,  USA       gnu at gnu.org                   *
+\********************************************************************/
+/** @file assistant-csv-account-import.h
+    @brief CSV Import Assistant
+    @author Copyright (c) 2011 Robert Fewell
+*/
+#ifndef GNC_ASSISTANT_CSV_IMPORT_H
+#define GNC_ASSISTANT_CSV_IMPORT_H
+
+
+// Account tree model
+enum tree_import_model_columns
+{
+    TYPE, FULL_NAME, NAME, CODE, DESCRIPTION, COLOR,
+    NOTES, COMMODITYM, COMMODITYN, HIDDEN, TAX, PLACE_HOLDER, ROW_COLOR,
+    N_COLUMNS
+};
+
+typedef struct
+{
+    GtkWidget    *window;
+    GtkWidget    *assistant;
+
+    GtkWidget    *file_chooser;
+    GtkWidget    *tree_view;
+    GtkListStore *store;
+    GString      *regexp;
+    GtkWidget    *header_row_spin;
+    GtkWidget    *finish_label;
+    GtkWidget    *summary_label;
+    GtkWidget    *summary_error_view;
+
+    gchar        *starting_dir;
+    gchar        *file_name;
+    gchar        *error;
+
+    int           header_rows;
+    int           num_new;
+    int           num_updates;
+    gboolean      new_book; /**< Are we importing into a new book?; if yes, call book options */
+} CsvImportInfo;
+
+
+/** The gnc_file_csv_account_import() will let the user import
+ *  accounts from a delimited file.
+ */
+void gnc_file_csv_account_import (void);
+#endif

Copied: gnucash/trunk/src/import-export/csv-imp/assistant-csv-trans-import.c (from rev 23566, gnucash/trunk/src/import-export/csv-import/assistant-csv-trans-import.c)
===================================================================
--- gnucash/trunk/src/import-export/csv-imp/assistant-csv-trans-import.c	                        (rev 0)
+++ gnucash/trunk/src/import-export/csv-imp/assistant-csv-trans-import.c	2013-12-15 17:21:20 UTC (rev 23567)
@@ -0,0 +1,1853 @@
+/*******************************************************************\
+ * assistant-csv-trans-import.c -- An assistant for importing       *
+ *                                     Transactions from a file.    *
+ *                                                                  *
+ * Copyright (C) 2012 Robert Fewell                                 *
+ * Copyright (c) 2007 Benny Sperisen <lasindi at gmail.com>            *
+ *                                                                  *
+ * This program is free software; you can redistribute it and/or    *
+ * modify it under the terms of the GNU General Public License as   *
+ * published by the Free Software Foundation; either version 2 of   *
+ * the License, or (at your option) any later version.              *
+ *                                                                  *
+ * This program is distributed in the hope that it will be useful,  *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of   *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the    *
+ * GNU General Public License for more details.                     *
+ *                                                                  *
+ * You should have received a copy of the GNU General Public License*
+ * along with this program; if not, contact:                        *
+ *                                                                  *
+ * Free Software Foundation           Voice:  +1-617-542-5942       *
+ * 51 Franklin Street, Fifth Floor    Fax:    +1-617-542-2652       *
+ * Boston, MA  02110-1301,  USA       gnu at gnu.org                   *
+\********************************************************************/
+/** @file assistant-csv-trans-import.c
+    @brief CSV Import Assistant
+    @author Copyright (c) 2012 Robert Fewell
+*/
+#include "config.h"
+
+#include <gtk/gtk.h>
+#include <glib/gi18n.h>
+
+#include "gnc-ui.h"
+#include "gnc-uri-utils.h"
+#include "gnc-ui-util.h"
+#include "dialog-utils.h"
+
+#include "gnc-component-manager.h"
+
+#include "assistant-utils.h"
+#include "assistant-csv-trans-import.h"
+
+#include "import-account-matcher.h"
+#include "import-main-matcher.h"
+
+#include "gnc-csv-model.h"
+#include "gnc-csv-gnumeric-popup.h"
+#include <goffice/gtk/go-charmap-sel.h>
+
+#define MIN_COL_WIDTH 70
+#define GNC_PREFS_GROUP "dialogs.import.csv"
+#define ASSISTANT_CSV_IMPORT_TRANS_CM_CLASS "assistant-csv-trans-import"
+
+/* This static indicates the debugging module that this .o belongs to.  */
+static QofLogModule log_module = GNC_MOD_ASSISTANT;
+
+/** Enumeration for separator checkbutton types. These are the
+ * different types of checkbuttons that the user can click to
+ * configure separators in a delimited file. */
+enum SEP_BUTTON_TYPES {SEP_SPACE, SEP_TAB, SEP_COMMA, SEP_COLON, SEP_SEMICOLON, SEP_HYPHEN,
+                       SEP_NUM_OF_TYPES
+                      };
+
+typedef struct
+{
+
+    GtkWidget       *window;
+
+    GtkWidget       *file_chooser;                  /**< The widget for the file chooser */
+    gchar           *starting_dir;                  /**< The starting directory for import file */
+    gchar           *file_name;                     /**< The import file name */
+
+    GtkWidget       *check_label;                   /**< The widget for the check label */
+    GtkWidget       *check_butt;                    /**< The widget for the check label button */
+    GtkWidget       *start_row_spin;                /**< The widget for the start row spinner */
+    GtkWidget       *end_row_spin;                  /**< The widget for the end row spinner */
+    int              start_row;                     /**< The start row */
+    int              end_row;                       /**< The end row */
+
+    GncCsvParseData *parse_data;                    /**< The actual data we are previewing */
+    GOCharmapSel    *encselector;                   /**< The widget for selecting the encoding */
+    GtkCheckButton  *sep_buttons[SEP_NUM_OF_TYPES]; /**< Checkbuttons for common separators */
+    GtkCheckButton  *custom_cbutton;                /**< The checkbutton for a custom separator */
+    GtkEntry        *custom_entry;                  /**< The entry for custom separators */
+    GtkComboBoxText *date_format_combo;             /**< The Combo Text widget for selecting the date format */
+    GtkComboBoxText *currency_format_combo;         /**< The Combo Text widget for selecting the currency format */
+    GtkTreeView     *treeview;                      /**< The treeview containing the data */
+    GtkTreeView     *ctreeview;                     /**< The treeview containing the column types */
+    GtkLabel        *instructions_label;            /**< The instructions label */
+    GtkImage        *instructions_image;            /**< The instructions image */
+    gboolean         encoding_selected_called;      /**< Before encoding_selected is first called, this is FALSE.
+                                                       * (See description of encoding_selected.) */
+    gboolean         not_empty;                     /**< FALSE initially, true after the first type gnc_csv_preview_update_assist is called. */
+    gboolean         previewing_errors;             /**< TRUE if the dialog is displaying
+                                                       * error lines, instead of all the file data. */
+    int              code_encoding_calls;           /**< Normally this is 0. If the computer
+                                                       * changes encselector, this is set to
+                                                       * 2. encoding_selected is called twice,
+                                                       * each time decrementing this by 1. */
+    gboolean         approved;                      /**< This is FALSE until the user clicks "OK". */
+    GtkWidget      **treeview_buttons;              /**< This array contains the header buttons in treeview */
+    int              num_of_rows;                   /**< The number of rows in the store */
+    int              longest_line;                  /**< The length of the longest row */
+    int              fixed_context_col;             /**< The number of the column whose the user has clicked */
+    int              fixed_context_dx;              /**< The horizontal coordinate of the pixel in the header of the column
+                                                       * the user has clicked */
+
+    GtkWidget           *account_page;              /**< The widget for the account page, to be packed with the account matcher */
+    GtkWidget           *account_label;             /**< The account page label at bottom of page */
+    AccountPickerDialog *account_picker;            /**< The AccountPickerDialog structure */
+    gboolean             account_page_step;         /**< Allows for auto stepping the account page if we match online id */
+
+    GNCImportMainMatcher *gnc_csv_importer_gui;     /**< The GNCImportMainMatcher structure */
+    GtkWidget            *match_page;               /**< The widget for the matcher page, to be packed with the transaction matcher */
+    GtkWidget            *match_label;              /**< The match label at the bottom of the page */
+    GtkWidget            *help_button;              /**< The widget for the help button on the matcher page */
+    GtkWidget            *cancel_button;            /**< The widget for the new cancel button when going back is blocked */
+    gboolean              match_parse_run;          /**< This is set after the first run */
+
+    GtkWidget            *summary_label;            /**< The summary text */
+
+    gboolean              new_book;                 /**< Are we importing into a new book?; if yes, call book options */
+
+} CsvImportTrans;
+
+
+/*************************************************************************/
+
+void csv_import_trans_assistant_prepare (GtkAssistant  *assistant, GtkWidget *page, gpointer user_data);
+void csv_import_trans_assistant_finish (GtkAssistant *gtkassistant, gpointer user_data);
+void csv_import_trans_assistant_cancel (GtkAssistant *gtkassistant, gpointer user_data);
+void csv_import_trans_assistant_close (GtkAssistant *gtkassistant, gpointer user_data);
+
+void csv_import_trans_assistant_start_page_prepare (GtkAssistant *gtkassistant, gpointer user_data);
+void csv_import_trans_assistant_file_page_prepare (GtkAssistant *assistant, gpointer user_data);
+void csv_import_trans_assistant_preview_page_prepare (GtkAssistant *gtkassistant, gpointer user_data);
+void csv_import_trans_assistant_account_page_prepare (GtkAssistant *assistant, gpointer user_data);
+void csv_import_trans_assistant_doc_page_prepare (GtkAssistant *assistant, gpointer user_data);
+void csv_import_trans_assistant_match_page_prepare (GtkAssistant *assistant, gpointer user_data);
+void csv_import_trans_assistant_finish_page_prepare (GtkAssistant *assistant, gpointer user_data);
+void csv_import_trans_assistant_summary_page_prepare (GtkAssistant *assistant, gpointer user_data);
+
+void csv_import_trans_srow_cb (GtkWidget *spin, gpointer user_data );
+void csv_import_trans_erow_cb (GtkWidget *spin, gpointer user_data );
+void csv_import_trans_auto_cb (GtkWidget *cb, gpointer user_data );
+void csv_import_trans_file_chooser_confirm_cb (GtkWidget *button, CsvImportTrans *info);
+
+static void gnc_csv_preview_update_assist(CsvImportTrans* info);
+gboolean preview_settings_valid (CsvImportTrans *info);
+
+/*************************************************************************/
+
+/**************************************************
+ * csv_import_trans_file_chooser_confirm_cb
+ *
+ * call back for ok button in file chooser widget
+ **************************************************/
+void
+csv_import_trans_file_chooser_confirm_cb (GtkWidget *button, CsvImportTrans *info)
+{
+    GtkAssistant *assistant = GTK_ASSISTANT(info->window);
+    gint num = gtk_assistant_get_current_page (assistant);
+    GtkWidget *page = gtk_assistant_get_nth_page (assistant, num);
+    GError* error;
+    gchar *file_name;
+    GncCsvParseData* parse_data;
+
+    gtk_assistant_set_page_complete (assistant, page, FALSE);
+
+    file_name = gtk_file_chooser_get_filename ( GTK_FILE_CHOOSER(info->file_chooser ));
+
+    if (file_name)
+    {
+        gchar *filepath = gnc_uri_get_path ( file_name );
+        gchar *filedir = g_path_get_dirname( filepath );
+        info->starting_dir = g_strdup(filedir);
+        g_free ( filedir );
+        g_free ( filepath );
+
+        info->file_name = g_strdup(file_name);
+        error = NULL;
+        /* Load the file into parse_data. */
+        parse_data = gnc_csv_new_parse_data();
+        if (gnc_csv_load_file(parse_data, file_name, &error))
+        {
+            /* If we couldn't load the file ... */
+            gnc_error_dialog(NULL, "%s", error->message);
+            if (error->code == GNC_CSV_FILE_OPEN_ERR)
+            {
+                gnc_csv_parse_data_free(parse_data);
+                return;
+            }
+            /* If we couldn't guess the encoding, we are content with just
+             * displaying an error message and move on with a blank
+             * display. */
+        }
+        else
+        {
+            /* Parse the data. */
+            if (gnc_csv_parse(parse_data, TRUE, &error))
+            {
+                /* If we couldn't parse the data ... */
+                gnc_error_dialog(NULL, "%s", error->message);
+                gnc_csv_parse_data_free(parse_data);
+            }
+            else
+            {
+                info->parse_data = parse_data;
+                info->previewing_errors = FALSE; /* We're looking at all the data. */
+                info->approved = FALSE; /* This is FALSE until the user clicks "OK". */
+                gtk_assistant_set_page_complete (assistant, page, TRUE);
+            }
+        }
+    }
+    g_free(file_name);
+
+    DEBUG("file_name selected is %s", info->file_name);
+    DEBUG("starting directory is %s", info->starting_dir);
+
+    /* Step to next page if page is complete */
+    if(gtk_assistant_get_page_complete(assistant, page))
+        gtk_assistant_set_current_page (assistant, num + 1);
+}
+
+
+/**************************************************
+ * row_selection_update
+ *
+ * refresh the start and end row highlighting
+ **************************************************/
+static
+void row_selection_update (CsvImportTrans* info)
+{
+    GtkListStore *store;
+    GtkTreeIter iter;
+    gboolean valid;
+    int i;
+
+    store = GTK_LIST_STORE( gtk_tree_view_get_model(info->treeview));
+
+    for ( i = 0; i <= info->start_row; i++)
+    {
+        /* Modify background color of rows less than start row */
+        if (info->start_row == i)
+        {
+            valid = gtk_tree_model_iter_nth_child(GTK_TREE_MODEL(store), &iter, NULL, i );
+            if (valid)
+                gtk_list_store_set (store, &iter, 0, NULL, -1);
+        }
+        else
+        {
+            valid = gtk_tree_model_iter_nth_child(GTK_TREE_MODEL(store), &iter, NULL, i );
+            if (valid)
+                gtk_list_store_set (store, &iter, 0, "pink", -1);
+            valid = gtk_tree_model_iter_next (GTK_TREE_MODEL(store), &iter);
+            if (valid)
+                gtk_list_store_set (store, &iter, 0, NULL, -1);
+        }
+
+    }
+
+    for ( i = info->num_of_rows - 1; i >= info->end_row; i--)
+    {
+        /* Modify background color of rows more than end row */
+        if ( i == info->end_row )
+        {
+            valid = gtk_tree_model_iter_nth_child(GTK_TREE_MODEL(store), &iter, NULL, i );
+            if (valid)
+                gtk_list_store_set (store, &iter, 0, NULL, -1);
+        }
+        else
+        {
+            valid = gtk_tree_model_iter_nth_child(GTK_TREE_MODEL(store), &iter, NULL, i );
+            if (valid)
+                gtk_list_store_set (store, &iter, 0, "pink", -1);
+            valid = gtk_tree_model_iter_nth_child(GTK_TREE_MODEL(store), &iter, NULL, i - 1 );
+            if (valid)
+                gtk_list_store_set (store, &iter, 0, NULL, -1);
+        }
+    }
+}
+
+
+/*******************************************************
+ * csv_import_trans_srow_cb
+ *
+ * call back for import start row
+ *******************************************************/
+void csv_import_trans_srow_cb (GtkWidget *spin, gpointer user_data )
+{
+    CsvImportTrans *info = user_data;
+    GtkAdjustment *adj;
+
+    /* Get number of rows for header */
+    info->start_row = gtk_spin_button_get_value_as_int (GTK_SPIN_BUTTON(spin)) - 1;
+
+    info->parse_data->start_row = info->start_row;
+
+    adj = gtk_spin_button_get_adjustment(GTK_SPIN_BUTTON(info->end_row_spin));
+    gtk_adjustment_set_lower(adj, info->start_row + 1 );
+
+    /* Refresh the row highlighting */
+    row_selection_update (info);
+}
+
+
+/*******************************************************
+ * csv_import_trans_erow_cb
+ *
+ * call back for import end row
+ *******************************************************/
+void csv_import_trans_erow_cb (GtkWidget *spin, gpointer user_data )
+{
+    CsvImportTrans *info = user_data;
+    GtkAdjustment *adj;
+
+    /* Get number of rows for header */
+    info->end_row = gtk_spin_button_get_value_as_int (GTK_SPIN_BUTTON(spin)) - 1;
+
+    info->parse_data->end_row = info->end_row + 1;
+
+    adj = gtk_spin_button_get_adjustment(GTK_SPIN_BUTTON(info->start_row_spin));
+    gtk_adjustment_set_upper(adj, info->end_row + 1 );
+
+    /* Refresh the row highlighting */
+    row_selection_update (info);
+}
+
+
+/*******************************************************
+ * csv_import_trans_auto_cb
+ *
+ * call back for auto create account / Skip Errors
+ *******************************************************/
+void csv_import_trans_auto_cb (GtkWidget *cb, gpointer user_data )
+{
+    CsvImportTrans *info = user_data;
+
+    if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(cb)))
+    {
+        if (info->previewing_errors == TRUE)
+            info->approved = TRUE;
+        else
+            info->account_picker->auto_create = TRUE;
+    }
+    else
+    {
+        if (info->previewing_errors == TRUE)
+            info->approved = FALSE;
+        else
+            info->account_picker->auto_create = FALSE;
+    }
+}
+
+
+/** Returns the cell renderer from a column in the preview's treeview.
+ * @param info The display of the data being imported
+ * @param col The number of the column whose cell renderer is being retrieved
+ * @return The cell renderer of column number col
+ */
+static GtkCellRenderer* gnc_csv_preview_get_cell_renderer(CsvImportTrans* info, int col)
+{
+    GList* renderers = gtk_cell_layout_get_cells(GTK_CELL_LAYOUT(gtk_tree_view_get_column(info->treeview, col)));
+
+    GtkCellRenderer* cell = GTK_CELL_RENDERER(renderers->data);
+    g_list_free(renderers);
+    return cell;
+}
+
+
+/** Event handler for separator changes. This function is called
+ * whenever one of the widgets for configuring the separators (the
+ * separator checkbuttons or the custom separator entry) is
+ * changed.
+ * @param widget The widget that was changed
+ * @param info The data that is being configured
+ */
+static void sep_button_clicked(GtkWidget* widget, CsvImportTrans* info)
+{
+    int i;
+    char* stock_separator_characters[] = {" ", "\t", ",", ":", ";", "-"};
+    GSList* checked_separators = NULL;
+    GError* error;
+
+    /* Add the corresponding characters to checked_separators for each
+     * button that is checked. */
+    for (i = 0; i < SEP_NUM_OF_TYPES; i++)
+    {
+        if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(info->sep_buttons[i])))
+            checked_separators = g_slist_append(checked_separators, stock_separator_characters[i]);
+    }
+
+    /* Add the custom separator if the user checked its button. */
+    if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(info->custom_cbutton)))
+    {
+        char* custom_sep = (char*)gtk_entry_get_text(info->custom_entry);
+        if (custom_sep[0] != '\0') /* Don't add a blank separator (bad things will happen!). */
+            checked_separators = g_slist_append(checked_separators, custom_sep);
+    }
+
+    /* Set the parse options using the checked_separators list. */
+    stf_parse_options_csv_set_separators(info->parse_data->options, NULL, checked_separators);
+    g_slist_free(checked_separators);
+
+    /* Parse the data using the new options. We don't want to reguess
+     * the column types because we want to leave the user's
+     * configurations in tact. */
+    if (gnc_csv_parse(info->parse_data, FALSE, &error))
+    {
+        /* Warn the user there was a problem and try to undo what caused
+         * the error. (This will cause a reparsing and ideally a usable
+         * configuration.) */
+        gnc_error_dialog(NULL, "Error in parsing");
+        /* If the user changed the custom separator, erase that custom separator. */
+        if (widget == GTK_WIDGET(info->custom_entry))
+        {
+            gtk_entry_set_text(GTK_ENTRY(widget), "");
+        }
+        /* If the user checked a checkbutton, toggle that checkbutton back. */
+        else
+        {
+            gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widget),
+                                         !gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget)));
+        }
+        return;
+    }
+
+    /* If we parsed successfully, redisplay the data. */
+    gnc_csv_preview_update_assist(info);
+
+    /* Refresh the row highlighting */
+    row_selection_update(info);
+}
+
+
+/** Event handler for clicking one of the format type radio
+ * buttons. This occurs if the format (Fixed-Width or CSV) is changed.
+ * @param csv_button The "Separated" radio button
+ * @param info The display of the data being imported
+ */
+static void separated_or_fixed_selected(GtkToggleButton* csv_button, CsvImportTrans* info)
+{
+    GError* error = NULL;
+    /* Set the parsing type correctly. */
+    if (gtk_toggle_button_get_active(csv_button)) /* If we're in CSV mode ... */
+    {
+        stf_parse_options_set_type(info->parse_data->options, PARSE_TYPE_CSV);
+    }
+    else /* If we're in fixed-width mode ... */
+    {
+        stf_parse_options_set_type(info->parse_data->options, PARSE_TYPE_FIXED);
+    }
+
+    /* Reparse the data. */
+    if (gnc_csv_parse(info->parse_data, FALSE, &error))
+    {
+        /* Show an error dialog explaining the problem. */
+        gnc_error_dialog(NULL, "%s", error->message);
+        return;
+    }
+
+    /* Show the new data. */
+    gnc_csv_preview_update_assist(info);
+
+    /* Refresh the row highlighting */
+    row_selection_update(info);
+}
+
+
+/** Event handler for a new encoding. This is called when the user
+ * selects a new encoding; the data is reparsed and shown to the
+ * user.
+ * @param selector The widget the user uses to select a new encoding
+ * @param encoding The encoding that the user selected
+ * @param info The display of the data being imported
+ */
+static void encoding_selected(GOCharmapSel* selector, const char* encoding,
+                              CsvImportTrans* info)
+{
+    /* This gets called twice everytime a new encoding is selected. The
+     * second call actually passes the correct data; thus, we only do
+     * something the second time this is called. */
+
+    /* Prevent code-caused calls of this function from having an impact. */
+    if (info->code_encoding_calls > 0)
+    {
+        info->code_encoding_calls--;
+        return;
+    }
+
+    /* If this is the second time the function is called ... */
+    if (info->encoding_selected_called)
+    {
+        const char* previous_encoding = info->parse_data->encoding;
+        GError* error = NULL;
+        /* Try converting the new encoding and reparsing. */
+        if (gnc_csv_convert_encoding(info->parse_data, encoding, &error) ||
+                gnc_csv_parse(info->parse_data, FALSE, &error))
+        {
+            /* If it fails, change back to the old encoding. */
+            gnc_error_dialog(NULL, "%s", _("Invalid encoding selected"));
+            info->encoding_selected_called = FALSE;
+            go_charmap_sel_set_encoding(selector, previous_encoding);
+            return;
+        }
+
+        gnc_csv_preview_update_assist(info);
+        info->encoding_selected_called = FALSE;
+    }
+    else /* If this is the first call of the function ... */
+    {
+        info->encoding_selected_called = TRUE; /* ... set the flag and wait for the next call. */
+    }
+}
+
+
+/** Event handler for selecting a new date format.
+ * @param format_selector The combo box for selecting date formats
+ * @param info The display of the data being imported
+ */
+static void date_format_selected(GtkComboBoxText* format_selector, CsvImportTrans* info)
+{
+    info->parse_data->date_format = gtk_combo_box_get_active(GTK_COMBO_BOX(format_selector));
+}
+
+
+/** Event handler for selecting a new currency format.
+ * @param currency_selector The combo box for selecting currency formats
+ * @param info The display of the data being imported
+ */
+static void currency_format_selected(GtkComboBoxText* currency_selector, CsvImportTrans* info)
+{
+    info->parse_data->currency_format = gtk_combo_box_get_active(GTK_COMBO_BOX(currency_selector));
+}
+
+
+/*======================================================================*/
+/*================== Beginning of Gnumeric Code ========================*/
+
+/* The following is code copied from Gnumeric 1.7.8 licensed under the
+ * GNU General Public License version 2 and/or version 3. It is from the file
+ * gnumeric/src/dialogs/dialog-stf-fixed-page.c, and it has been
+ * modified slightly to work within GnuCash. */
+
+/*
+ * Copyright 2001 Almer S. Tigelaar <almer at gnome.org>
+ * Copyright 2003 Morten Welinder <terra at gnome.org>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+enum
+{
+    CONTEXT_STF_IMPORT_MERGE_LEFT = 1,
+    CONTEXT_STF_IMPORT_MERGE_RIGHT = 2,
+    CONTEXT_STF_IMPORT_SPLIT = 3,
+    CONTEXT_STF_IMPORT_WIDEN = 4,
+    CONTEXT_STF_IMPORT_NARROW = 5
+};
+
+static GnumericPopupMenuElement const popup_elements[] =
+{
+    {
+        N_("Merge with column on _left"), GTK_STOCK_REMOVE,
+        0, 1 << CONTEXT_STF_IMPORT_MERGE_LEFT, CONTEXT_STF_IMPORT_MERGE_LEFT
+    },
+    {
+        N_("Merge with column on _right"), GTK_STOCK_REMOVE,
+        0, 1 << CONTEXT_STF_IMPORT_MERGE_RIGHT, CONTEXT_STF_IMPORT_MERGE_RIGHT
+    },
+    { "", NULL, 0, 0, 0 },
+    {
+        N_("_Split this column"), NULL,
+        0, 1 << CONTEXT_STF_IMPORT_SPLIT, CONTEXT_STF_IMPORT_SPLIT
+    },
+    { "", NULL, 0, 0, 0 },
+    {
+        N_("_Widen this column"), GTK_STOCK_GO_FORWARD,
+        0, 1 << CONTEXT_STF_IMPORT_WIDEN, CONTEXT_STF_IMPORT_WIDEN
+    },
+    {
+        N_("_Narrow this column"), GTK_STOCK_GO_BACK,
+        0, 1 << CONTEXT_STF_IMPORT_NARROW, CONTEXT_STF_IMPORT_NARROW
+    },
+    { NULL, NULL, 0, 0, 0 },
+};
+
+static gboolean
+make_new_column (CsvImportTrans* info, int col, int dx, gboolean test_only)
+{
+    PangoLayout *layout;
+    PangoFontDescription *font_desc;
+    int charindex, width;
+    GtkCellRenderer *cell =	gnc_csv_preview_get_cell_renderer(info, col);
+    int colstart, colend;
+    GError* error = NULL;
+
+    colstart = (col == 0)
+               ? 0
+               : stf_parse_options_fixed_splitpositions_nth (info->parse_data->options, col - 1);
+    colend = stf_parse_options_fixed_splitpositions_nth (info->parse_data->options, col);
+
+    g_object_get (G_OBJECT (cell), "font_desc", &font_desc, NULL);
+    layout = gtk_widget_create_pango_layout (GTK_WIDGET (info->treeview), "x");
+    pango_layout_set_font_description (layout, font_desc);
+    pango_layout_get_pixel_size (layout, &width, NULL);
+    if (width < 1) width = 1;
+    charindex = colstart + (dx + width / 2) / width;
+    g_object_unref (layout);
+    pango_font_description_free (font_desc);
+
+    if (charindex <= colstart || (colend != -1 && charindex >= colend))
+        return FALSE;
+
+    if (!test_only)
+    {
+        stf_parse_options_fixed_splitpositions_add (info->parse_data->options, charindex);
+        if (gnc_csv_parse(info->parse_data, FALSE, &error))
+        {
+            gnc_error_dialog(NULL, "%s", error->message);
+            return FALSE;
+        }
+        gnc_csv_preview_update_assist (info);
+    }
+
+    return TRUE;
+}
+
+static gboolean
+widen_column (CsvImportTrans* info, int col, gboolean test_only)
+{
+    int colcount = stf_parse_options_fixed_splitpositions_count (info->parse_data->options);
+    int nextstart, nextnextstart;
+    GError* error = NULL;
+
+    if (col >= colcount - 1)
+        return FALSE;
+
+    nextstart = stf_parse_options_fixed_splitpositions_nth (info->parse_data->options, col);
+
+    nextnextstart = (col == colcount - 2)
+                    ? info->longest_line
+                    : stf_parse_options_fixed_splitpositions_nth (info->parse_data->options, col + 1);
+
+    if (nextstart + 1 >= nextnextstart)
+        return FALSE;
+
+    if (!test_only)
+    {
+        stf_parse_options_fixed_splitpositions_remove (info->parse_data->options, nextstart);
+        stf_parse_options_fixed_splitpositions_add (info->parse_data->options, nextstart + 1);
+        if (gnc_csv_parse(info->parse_data, FALSE, &error))
+        {
+            gnc_error_dialog(NULL, "%s", error->message);
+            return FALSE;
+        }
+        gnc_csv_preview_update_assist (info);
+    }
+    return TRUE;
+}
+
+static gboolean
+narrow_column (CsvImportTrans* info, int col, gboolean test_only)
+{
+    int colcount = stf_parse_options_fixed_splitpositions_count (info->parse_data->options);
+    int thisstart, nextstart;
+    GError* error = NULL;
+
+    if (col >= colcount - 1)
+        return FALSE;
+
+    thisstart = (col == 0)
+                ? 0
+                : stf_parse_options_fixed_splitpositions_nth (info->parse_data->options, col - 1);
+    nextstart = stf_parse_options_fixed_splitpositions_nth (info->parse_data->options, col);
+
+    if (nextstart - 1 <= thisstart)
+        return FALSE;
+
+    if (!test_only)
+    {
+        stf_parse_options_fixed_splitpositions_remove (info->parse_data->options, nextstart);
+        stf_parse_options_fixed_splitpositions_add (info->parse_data->options, nextstart - 1);
+        if (gnc_csv_parse(info->parse_data, FALSE, &error))
+        {
+            gnc_error_dialog(NULL, "%s", error->message);
+            return FALSE;
+        }
+        gnc_csv_preview_update_assist (info);
+    }
+    return TRUE;
+}
+
+static gboolean
+delete_column (CsvImportTrans* info, int col, gboolean test_only)
+{
+    GError* error = NULL;
+    int colcount = stf_parse_options_fixed_splitpositions_count (info->parse_data->options);
+    if (col < 0 || col >= colcount - 1)
+        return FALSE;
+
+    if (!test_only)
+    {
+        int nextstart = stf_parse_options_fixed_splitpositions_nth (info->parse_data->options, col);
+        stf_parse_options_fixed_splitpositions_remove (info->parse_data->options, nextstart);
+        if (gnc_csv_parse(info->parse_data, FALSE, &error))
+        {
+            gnc_error_dialog(NULL, "%s", error->message);
+            return FALSE;
+        }
+        gnc_csv_preview_update_assist (info);
+    }
+    return TRUE;
+}
+
+static void
+select_column (CsvImportTrans* info, int col)
+{
+    int colcount = stf_parse_options_fixed_splitpositions_count (info->parse_data->options);
+    GtkTreeViewColumn *column;
+
+    if (col < 0 || col >= colcount)
+        return;
+
+    column = gtk_tree_view_get_column (info->treeview, col);
+    gtk_widget_grab_focus (column->button);
+}
+
+static gboolean
+fixed_context_menu_handler (GnumericPopupMenuElement const *element,
+                            gpointer user_data)
+{
+    CsvImportTrans* info = user_data;
+    int col = info->fixed_context_col;
+
+    switch (element->index)
+    {
+    case CONTEXT_STF_IMPORT_MERGE_LEFT:
+        delete_column (info, col - 1, FALSE);
+        break;
+    case CONTEXT_STF_IMPORT_MERGE_RIGHT:
+        delete_column (info, col, FALSE);
+        break;
+    case CONTEXT_STF_IMPORT_SPLIT:
+        make_new_column (info, col, info->fixed_context_dx, FALSE);
+        break;
+    case CONTEXT_STF_IMPORT_WIDEN:
+        widen_column (info, col, FALSE);
+        break;
+    case CONTEXT_STF_IMPORT_NARROW:
+        narrow_column (info, col, FALSE);
+        break;
+    default:
+        ; /* Nothing */
+    }
+    return TRUE;
+}
+
+static void
+fixed_context_menu (CsvImportTrans* info, GdkEventButton *event,
+                    int col, int dx)
+{
+    int sensitivity_filter = 0;
+
+    info->fixed_context_col = col;
+    info->fixed_context_dx = dx;
+
+    if (!delete_column (info, col - 1, TRUE))
+        sensitivity_filter |= (1 << CONTEXT_STF_IMPORT_MERGE_LEFT);
+    if (!delete_column (info, col, TRUE))
+        sensitivity_filter |= (1 << CONTEXT_STF_IMPORT_MERGE_RIGHT);
+    if (!make_new_column (info, col, dx, TRUE))
+        sensitivity_filter |= (1 << CONTEXT_STF_IMPORT_SPLIT);
+    if (!widen_column (info, col, TRUE))
+        sensitivity_filter |= (1 << CONTEXT_STF_IMPORT_WIDEN);
+    if (!narrow_column (info, col, TRUE))
+        sensitivity_filter |= (1 << CONTEXT_STF_IMPORT_NARROW);
+
+    select_column (info, col);
+    gnumeric_create_popup_menu (popup_elements, &fixed_context_menu_handler,
+                                info, 0,
+                                sensitivity_filter, event);
+}
+
+/*===================== End of Gnumeric Code ===========================*/
+/*======================================================================*/
+
+
+/** Event handler for the data treeview being resized. When the data
+ * treeview is resized, the column types treeview's columns are also resized to
+ * match.
+ * @param widget The data treeview
+ * @param allocation The size of the data treeview
+ * @param info The display of the data being imported
+ */
+static void treeview_resized(GtkWidget* widget, GtkAllocation* allocation, CsvImportTrans* info)
+{
+    /* ncols is the number of columns in the data. */
+    int i, ncols = info->parse_data->column_types->len;
+
+    /* Go through each column except for the last. (We don't want to set
+     * the width of the last column because the user won't be able to
+     * shrink the dialog back if it's expanded.) */
+
+    for (i = 0; i < ncols - 1; i++)
+    {
+        gint col_width; /* The width of the column in info->treeview. */
+        GtkTreeViewColumn* pcol;
+        GtkTreeViewColumn* ccol; /* The corresponding column in info->ctreeview. */
+
+        /* Get the width. */
+        col_width = gtk_tree_view_column_get_width(gtk_tree_view_get_column(info->treeview, i));
+        /* Set the minumum width for a column so that drop down selector can be seen. */
+        if (col_width < MIN_COL_WIDTH)
+        {
+            col_width = MIN_COL_WIDTH;
+        }
+        pcol = gtk_tree_view_get_column(info->treeview, i);
+        gtk_tree_view_column_set_min_width(pcol, col_width);
+        /* Set ccol's width the same. */
+        ccol = gtk_tree_view_get_column(info->ctreeview, i);
+        gtk_tree_view_column_set_min_width(ccol, col_width);
+        gtk_tree_view_column_set_max_width(ccol, col_width);
+    }
+}
+
+
+/** Event handler for the user selecting a new column type. When the
+ * user selects a new column type, that column's text must be changed
+ * to that selection, and any other columns containing that selection
+ * must be changed to "None" because we don't allow duplicates.
+ * @param renderer The renderer of the column the user changed
+ * @param path There is only 1 row in info->ctreeview, so this is always 0.
+ * @param new_text The text the user selected
+ * @param info The display of the data being imported
+ */
+static void column_type_changed(GtkCellRenderer* renderer, gchar* path,
+                                GtkTreeIter* new_text_iter, CsvImportTrans* info)
+{
+    /* ncols is the number of columns in the data. */
+    int i, ncols = info->parse_data->column_types->len;
+    /* store has the actual strings that appear in info->ctreeview. */
+    GtkTreeModel* store = gtk_tree_view_get_model(info->ctreeview);
+    GtkTreeModel* model;
+    gint textColumn;
+    GtkTreeIter iter;
+    gchar* new_text;
+
+    /* Get the new text */
+    g_object_get(renderer, "model", &model, "text-column", &textColumn, NULL);
+    gtk_tree_model_get(model, new_text_iter, textColumn, &new_text, -1);
+
+    /* Get an iterator for the first (and only) row. */
+    gtk_tree_model_get_iter_first(store, &iter);
+
+    /* Go through each column. */
+    for (i = 0; i < ncols; i++)
+    {
+        /* We need all this stuff so that we can find out whether or not
+         * this was the column that was changed. */
+        GtkCellRenderer* col_renderer; /* The renderer for this column. */
+        /* The column in the treeview we are looking at */
+        GtkTreeViewColumn* col = gtk_tree_view_get_column(info->ctreeview, i);
+        /* The list of renderers for col */
+        GList* rend_list = gtk_cell_layout_get_cells(GTK_CELL_LAYOUT(col));
+        /* rend_list has only one entry, which we put in col_renderer. */
+        col_renderer = rend_list->data;
+        g_list_free(rend_list);
+
+        /* If this is not the column that was changed ... */
+        if (col_renderer != renderer)
+        {
+            /* The string that appears in the column */
+            gchar* contents = NULL;
+            /* Get the type string. (store is arranged so that every two
+             * columns is a pair of the model used for the combobox and the
+             * string that appears, so that store looks like:
+             * model 0, string 0, model 1, string 1, ..., model ncols, string ncols. */
+            gtk_tree_model_get(store, &iter, 2 * i + 1, &contents, -1);
+            /* If this column has the same string that the user selected ... */
+            if (!g_strcmp0(contents, new_text))
+            {
+                /* ... set this column to the "None" type. (We can't allow duplicate types.) */
+                gtk_list_store_set(GTK_LIST_STORE(store), &iter, 2 * i + 1,
+                                   _(gnc_csv_column_type_strs[GNC_CSV_NONE]), -1);
+            }
+            g_free(contents);
+        }
+        else /* If this is the column that was changed ... */
+        {
+            /* Set the text for this column to what the user selected. (See
+             * comment above "Get the type string. ..." for why we set
+             * column 2*i+1 in store.) */
+            gtk_list_store_set(GTK_LIST_STORE(store), &iter, 2 * i + 1, new_text, -1);
+        }
+    }
+}
+
+
+/** Event handler for clicking on column headers. This function is
+ * called whenever the user clicks on column headers in
+ * preview->treeview to modify columns when in fixed-width mode.
+ * @param button The button at the top of a column of the treeview
+ * @param event The event that happened (where the user clicked)
+ * @param info The data being configured
+ */
+static void header_button_press_handler(GtkWidget* button, GdkEventButton* event,
+                                        CsvImportTrans* info)
+{
+    /* col is the number of the column that was clicked, and offset is
+       to correct for the indentation of button. */
+    int i, col = 0, offset = GTK_BIN(button)->child->allocation.x - button->allocation.x,
+           ncols = info->parse_data->column_types->len;
+    /* Find the column that was clicked. */
+    for (i = 0; i < ncols; i++)
+    {
+        if (info->treeview_buttons[i] == button)
+        {
+            col = i;
+            break;
+        }
+    }
+
+    /* Don't let the user affect the last column if it has error messages. */
+    if (info->parse_data->orig_max_row < ncols && ncols - col == 1)
+    {
+        return;
+    }
+
+    /* Double clicks can split columns. */
+    if (event->type == GDK_2BUTTON_PRESS && event->button == 1)
+    {
+        make_new_column(info, col, (int)event->x - offset, FALSE);
+    }
+    /* Right clicking brings up a context menu. */
+    else if (event->type == GDK_BUTTON_PRESS && event->button == 3)
+    {
+        fixed_context_menu(info, event, col, (int)event->x - offset);
+    }
+}
+
+
+/* Test for the required minimum number of coloumns selected and
+ * a valid date format.
+ * Returns TRUE if we do or FALSE if we don't.
+ *
+ * @param info The data being previewed
+ */
+gboolean preview_settings_valid (CsvImportTrans* info)
+{
+    /* Shorten the column_types identifier. */
+    GArray* column_types = info->parse_data->column_types;
+    int i, ncols = column_types->len; /* ncols is the number of columns in the data. */
+    int weight = 0;
+    gboolean valid = TRUE;
+    /* store contains the actual strings appearing in the column types treeview. */
+    GtkTreeModel* store = gtk_tree_view_get_model(info->ctreeview);
+    /* datastore contains the actual strings appearing in the preview treeview. */
+    GtkTreeModel* datastore = gtk_tree_view_get_model(info->treeview);
+    GtkTreeIter iter, iter2;
+    /* Get an iterator for the first (and only) row. */
+    gtk_tree_model_get_iter_first(store, &iter);
+
+    /* Get an iterator for the first required row in the data store. */
+    gtk_tree_model_iter_nth_child(GTK_TREE_MODEL(datastore), &iter2, NULL, info->start_row );
+
+    /* Go through each of the columns. */
+    for (i = 0; i < ncols; i++)
+    {
+        int type; /* The column type contained in this column. */
+        gchar* contents = NULL; /* The column type string in this column. */
+        gchar* prevstr = NULL; /* The string in this column from datastore. */
+        gchar* accstr = NULL; /* The string in this column from datastore. */
+        /* Get the type string first. (store is arranged so that every two
+         * columns is a pair of the model used for the combobox and the
+         * string that appears, so that store looks like:
+         * model 0, string 0, model 1, string 1, ..., model ncols, string ncols. */
+        gtk_tree_model_get(store, &iter, 2 * i + 1, &contents, -1);
+
+        /* Go through each column type until ... */
+        for (type = 0; type < GNC_CSV_NUM_COL_TYPES; type++)
+        {
+            /* ... we find one that matches with what's in the column. */
+            if (!g_strcmp0(contents, _(gnc_csv_column_type_strs[type])))
+            {
+                /* Set the column_types array appropriately and quit. */
+                column_types->data[i] = type;
+
+                switch (type)
+                {
+                case GNC_CSV_DATE:
+                    weight = weight + 1000;
+                    gtk_tree_model_get(datastore, &iter2, i + 1, &prevstr, -1);
+
+                    if (parse_date(prevstr, info->parse_data->date_format) == -1)
+                        valid = FALSE;
+                    break;
+
+                case GNC_CSV_DESCRIPTION:
+                case GNC_CSV_NOTES:
+                    weight = weight + 100;
+                    break;
+
+                case GNC_CSV_BALANCE:
+                case GNC_CSV_DEPOSIT:
+                case GNC_CSV_WITHDRAWAL:
+                    weight = weight + 10;
+                    break;
+
+                case GNC_CSV_NUM:
+                    weight = weight + 1;
+                    break;
+                case GNC_CSV_ACCOUNT:
+                    weight = weight + 1;
+                    gtk_tree_model_get(datastore, &iter2, i + 1, &accstr, -1);
+                    info->account_picker->account_online_id_value = strdup(accstr);
+                    break;
+                }
+                break;
+            }
+        }
+        /* Free the type string created by gtk_tree_model_get() */
+        g_free(contents);
+        g_free(prevstr);
+        g_free(accstr);
+    }
+    if (weight < 1109 || valid == FALSE)
+        return FALSE;
+    else
+        return TRUE;
+}
+
+
+/* Loads the preview's data into its data treeview. not_empty is TRUE
+ * when the data treeview already contains data, FALSE otherwise
+ * (e.g. the first time this function is called on a preview).
+ * @param info The data being previewed
+ */
+static void gnc_csv_preview_update_assist(CsvImportTrans* info)
+{
+    /* store has the data from the file being imported. cstores is an
+     * array of stores that hold the combo box entries for each
+     * column. ctstore contains both pointers to models in cstore and
+     * the actual text that appears in info->ctreeview. */
+    GtkListStore *store, **cstores, *ctstore;
+    GtkTreeIter iter;
+    GtkTreeSelection *selection;
+    /* ncols is the number of columns in the file data. */
+    int i, j, ncols = info->parse_data->column_types->len,
+              max_str_len = info->parse_data->file_str.end - info->parse_data->file_str.begin;
+
+    /* store contains only strings. */
+    GType* types = g_new(GType, 2 * ncols);
+    for (i = 0; i <  ncols + 1; i++)
+        types[i] = G_TYPE_STRING;
+    store = gtk_list_store_newv(ncols + 1, types);
+
+    /* ctstore is arranged as follows:
+     * model 0, text 0, model 1, text 1, ..., model ncols, text ncols. */
+    for (i = 0; i < 2 * ncols; i += 2)
+    {
+        types[i] = GTK_TYPE_TREE_MODEL;
+        types[i+1] = G_TYPE_STRING;
+    }
+    ctstore = gtk_list_store_newv(2 * ncols, types);
+
+    g_free(types);
+
+    /* Each element in cstores is a single column model. */
+    cstores = g_new(GtkListStore*, ncols);
+    for (i = 0; i < ncols; i++)
+    {
+        cstores[i] = gtk_list_store_new(1, G_TYPE_STRING);
+        /* Add all of the possible entries to the combo box. */
+        for (j = 0; j < GNC_CSV_NUM_COL_TYPES; j++)
+        {
+            gtk_list_store_append(cstores[i], &iter);
+            gtk_list_store_set(cstores[i], &iter, 0, _(gnc_csv_column_type_strs[j]), -1);
+        }
+    }
+
+    if (info->not_empty)
+    {
+        GList *tv_columns, *tv_columns_begin, *ctv_columns, *ctv_columns_begin;
+        tv_columns = tv_columns_begin = gtk_tree_view_get_columns(info->treeview);
+        ctv_columns = ctv_columns_begin = gtk_tree_view_get_columns(info->ctreeview);
+        /* Clear out exisiting columns in info->treeview. */
+        while (tv_columns != NULL)
+        {
+            gtk_tree_view_remove_column(info->treeview, GTK_TREE_VIEW_COLUMN(tv_columns->data));
+            tv_columns = g_list_next(tv_columns);
+        }
+        /* Do the same in info->ctreeview. */
+        while (ctv_columns != NULL)
+        {
+            gtk_tree_view_remove_column(info->ctreeview, GTK_TREE_VIEW_COLUMN(ctv_columns->data));
+            ctv_columns = g_list_next(ctv_columns);
+        }
+        g_list_free(tv_columns_begin);
+        g_list_free(ctv_columns_begin);
+        g_free(info->treeview_buttons);
+    }
+
+    /* Fill the data treeview with data from the file. */
+    /* Also, update the longest line value within the following loop (whichever is executed). */
+    info->longest_line = 0;
+    if (info->previewing_errors) /* If we are showing only errors ... */
+    {
+        /* ... only pick rows that are in info->error_lines. */
+        GList* error_lines = info->parse_data->error_lines;
+        while (error_lines != NULL)
+        {
+            int this_line_length = 0;
+            i = GPOINTER_TO_INT(error_lines->data);
+            gtk_list_store_append(store, &iter);
+
+            /* Row Color column */
+            gtk_list_store_set (store, &iter, 0, NULL, -1);
+
+            for (j = 0; j < ((GPtrArray*)(info->parse_data->orig_lines->pdata[i]))->len; j++)
+            {
+                /* Add this cell's length to the row's length and set the value of the list store. */
+                gchar* cell_string = (gchar*)((GPtrArray*)(info->parse_data->orig_lines->pdata[i]))->pdata[j];
+                this_line_length += g_utf8_strlen(cell_string, max_str_len);
+                gtk_list_store_set(store, &iter, j + 1, cell_string, -1);
+            }
+
+            if (this_line_length > info->longest_line)
+                info->longest_line = this_line_length;
+
+            error_lines = g_list_next(error_lines);
+        }
+    }
+    else /* Otherwise, put in all of the data. */
+    {
+        for (i = 0; i < info->parse_data->orig_lines->len; i++)
+        {
+            int this_line_length = 0;
+            gtk_list_store_append(store, &iter);
+
+            /* Row Color column */
+            gtk_list_store_set (store, &iter, 0, NULL, -1);
+
+            for (j = 0; j < ((GPtrArray*)(info->parse_data->orig_lines->pdata[i]))->len; j++)
+            {
+                /* Add this cell's length to the row's length and set the value of the list store. */
+                gchar* cell_string = (gchar*)((GPtrArray*)(info->parse_data->orig_lines->pdata[i]))->pdata[j];
+                this_line_length += g_utf8_strlen(cell_string, max_str_len);
+                gtk_list_store_set(store, &iter, j + 1, cell_string, -1);
+            }
+
+            if (this_line_length > info->longest_line)
+                info->longest_line = this_line_length;
+
+            /* Set the number of rows in the store */
+            info->num_of_rows = i + 1;
+        }
+    }
+
+    /* Set all the column types to what's in the parse data. */
+    gtk_list_store_append(ctstore, &iter);
+    gtk_list_store_set(ctstore, &iter, 0, NULL, -1); /* Dummy Column to match row color */
+    for (i = 0; i < ncols; i++)
+    {
+        gtk_list_store_set(ctstore, &iter, 2 * i, cstores[i], 2 * i + 1,
+                           _(gnc_csv_column_type_strs[(int)(info->parse_data->column_types->data[i])]),
+                           -1);
+    }
+
+    info->treeview_buttons = g_new(GtkWidget*, ncols);
+    /* Insert columns into the data and column type treeviews. */
+    for (i = 0; i < ncols ; i++)
+    {
+        GtkTreeViewColumn* col; /* The column we add to info->treeview. */
+        /* Create renderers for the data treeview (renderer) and the
+         * column type treeview (crenderer). */
+        GtkCellRenderer* renderer = gtk_cell_renderer_text_new(),
+                         *crenderer = gtk_cell_renderer_combo_new();
+        /* We want a monospace font for the data in case of fixed-width data. */
+        g_object_set(G_OBJECT(renderer), "family", "monospace", NULL);
+        /* We are using cstores for the combo box entries, and we don't
+         * want the user to be able to manually enter their own column
+         * types. */
+        g_object_set(G_OBJECT(crenderer), "model", cstores[i], "text-column", 0,
+                     "editable", TRUE, "has-entry", FALSE, NULL);
+        g_signal_connect(G_OBJECT(crenderer), "changed",
+                         G_CALLBACK(column_type_changed), (gpointer)info);
+
+        /* Add a single column for the treeview. */
+        col = gtk_tree_view_column_new_with_attributes("", renderer, "text", i + 1, NULL);
+
+        /* Add the Color column 0 to the renderer */
+        gtk_tree_view_column_add_attribute(col, renderer, "background", 0);
+
+        gtk_tree_view_insert_column(info->treeview, col, -1);
+        /* Enable resizing of the columns. */
+        gtk_tree_view_column_set_resizable(col, TRUE);
+        /* Use the alternating model and text entries from ctstore in
+         * info->ctreeview. */
+        gtk_tree_view_insert_column_with_attributes(info->ctreeview,
+                -1, "", crenderer, "model", 2 * i,
+                "text", 2 * i + 1, NULL);
+
+        /* We need to allow clicking on the column headers for fixed-width
+         * column splitting and merging. */
+        g_object_set(G_OBJECT(col), "clickable", TRUE, NULL);
+        g_signal_connect(G_OBJECT(col->button), "button_press_event",
+                         G_CALLBACK(header_button_press_handler), (gpointer)info);
+        info->treeview_buttons[i] = col->button;
+    }
+
+    /* Set the treeviews to use the models. */
+    gtk_tree_view_set_model(info->treeview, GTK_TREE_MODEL(store));
+    gtk_tree_view_set_model(info->ctreeview, GTK_TREE_MODEL(ctstore));
+
+    /* Select the header row */
+    gtk_tree_model_get_iter_first(GTK_TREE_MODEL(ctstore), &iter);
+    selection = gtk_tree_view_get_selection (info->ctreeview);
+    gtk_tree_selection_select_iter ( selection, &iter);
+
+    /* Free the memory for the stores. */
+    g_object_unref(GTK_TREE_MODEL(store));
+    g_object_unref(GTK_TREE_MODEL(ctstore));
+    for (i = 0; i < ncols; i++)
+        g_object_unref(GTK_TREE_MODEL(cstores[i]));
+
+    /* Make the things actually appear. */
+    gtk_widget_show_all(GTK_WIDGET(info->treeview));
+    gtk_widget_show_all(GTK_WIDGET(info->ctreeview));
+
+    /* Set the encoding selector to the right encoding. */
+    info->code_encoding_calls = 2;
+    go_charmap_sel_set_encoding(info->encselector, info->parse_data->encoding);
+
+    /* Set the date format to what's in the combo box (since we don't
+     * necessarily know if this will always be the same). */
+    info->parse_data->date_format = gtk_combo_box_get_active(GTK_COMBO_BOX(info->date_format_combo));
+
+    /* It's now been filled with some stuff. */
+    info->not_empty = TRUE;
+}
+
+
+/*******************************************************
+ * load_settings
+ *
+ * load the default settings for the assistant
+ *******************************************************/
+static
+void load_settings (CsvImportTrans *info)
+{
+    info->start_row = 0;
+    info->start_row = 0;
+    info->account_page_step = TRUE;
+    info->match_parse_run = FALSE;
+    info->file_name = NULL;
+    info->starting_dir = NULL;
+
+    /* The default directory for the user to select files. */
+    info->starting_dir = gnc_get_default_directory(GNC_PREFS_GROUP);
+}
+
+/*======================================================================*/
+/*======================================================================*/
+
+/*******************************************************
+ * Assistant page prepare functions
+ *******************************************************/
+void
+csv_import_trans_assistant_start_page_prepare (GtkAssistant *assistant,
+        gpointer user_data)
+{
+    gint num = gtk_assistant_get_current_page (assistant);
+    GtkWidget *page = gtk_assistant_get_nth_page (assistant, num);
+
+    /* Enable the Assistant Buttons */
+    gtk_assistant_set_page_complete (assistant, page, TRUE);
+}
+
+
+void
+csv_import_trans_assistant_file_page_prepare (GtkAssistant *assistant,
+        gpointer user_data)
+{
+    CsvImportTrans *info = user_data;
+    gint num = gtk_assistant_get_current_page (assistant);
+    GtkWidget *page = gtk_assistant_get_nth_page (assistant, num);
+
+    info->account_picker->auto_create = TRUE; /* Step over account page if we find matching online id */
+    info->previewing_errors = FALSE;          /* We're looking at all the data. */
+    info->approved = FALSE;                   /* This is FALSE until the user clicks "OK". */
+
+    /* Set the default directory */
+    if (info->starting_dir)
+        gtk_file_chooser_set_current_folder(GTK_FILE_CHOOSER(info->file_chooser), info->starting_dir);
+
+    /* Disable the Forward Assistant Button */
+    gtk_assistant_set_page_complete (assistant, page, FALSE);
+}
+
+
+void
+csv_import_trans_assistant_preview_page_prepare (GtkAssistant *assistant,
+        gpointer user_data)
+{
+    CsvImportTrans *info = user_data;
+    GtkAdjustment *adj;
+
+    g_signal_connect(G_OBJECT(info->treeview), "size-allocate",
+                     G_CALLBACK(treeview_resized), (gpointer)info);
+
+    if (info->previewing_errors == TRUE)
+    {
+        gchar* name;
+        GtkIconSize size;
+
+        /* Block going back */
+        gtk_assistant_commit (GTK_ASSISTANT(info->window));
+
+        gtk_image_get_stock(info->instructions_image, &name, &size);
+        gtk_image_set_from_stock(info->instructions_image, GTK_STOCK_DIALOG_ERROR, size);
+        gtk_label_set_text(info->instructions_label,
+                           _("The rows displayed below had errors which are in the last column. You can attempt to correct them by changing the configuration."));
+        gtk_widget_show(GTK_WIDGET(info->instructions_image));
+        gtk_widget_show(GTK_WIDGET(info->instructions_label));
+
+        /* Set spin buttons not sensative */
+        gtk_widget_set_sensitive (info->start_row_spin, FALSE);
+        gtk_widget_set_sensitive (info->end_row_spin, FALSE);
+
+        /* Set check button label */
+        gtk_label_set_text(GTK_LABEL(info->check_label), _("Skip Errors"));
+        gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON(info->check_butt), FALSE);
+    }
+
+    /* Load the data into the treeview. */
+    gnc_csv_preview_update_assist(info);
+
+    /* Set the upper limit of spin button to number of rows */
+    adj = gtk_spin_button_get_adjustment(GTK_SPIN_BUTTON(info->end_row_spin));
+    if (gtk_adjustment_get_upper(adj) != info->num_of_rows)
+    {
+        gtk_spin_button_set_value (GTK_SPIN_BUTTON(info->end_row_spin), info->num_of_rows);
+        gtk_adjustment_set_upper(adj, info->num_of_rows);
+    }
+
+    /* Update the row selection highlight */
+    row_selection_update(info);
+}
+
+
+void
+csv_import_trans_assistant_account_page_prepare (GtkAssistant *assistant,
+        gpointer user_data)
+{
+    CsvImportTrans *info = user_data;
+    gint num = gtk_assistant_get_current_page (assistant);
+    GtkWidget *page = gtk_assistant_get_nth_page (assistant, num);
+    gchar *text, *mtext;
+    Account * account = NULL;
+
+    if (!preview_settings_valid(info) && (info->approved == FALSE))
+    {
+        text = g_strdup_printf(gettext ("There are problems with the import settings!\nThe date format could be wrong "
+                                        "or there are not enough columns set..."));
+        mtext = g_strdup_printf("<span size=\"medium\" color=\"red\"><b>%s</b></span>", text);
+        gtk_label_set_markup(GTK_LABEL(info->account_label), mtext);
+        g_free(mtext);
+        g_free(text);
+
+        gtk_widget_set_sensitive (info->account_page, FALSE);
+    }
+    else
+    {
+        text = g_strdup_printf(gettext ("To Change the account, double click on the required account, click Forward to proceed."));
+        mtext = g_strdup_printf("<span size=\"medium\" color=\"red\"><b>%s</b></span>", text);
+        gtk_label_set_markup(GTK_LABEL(info->account_label), mtext );
+        g_free(mtext);
+        g_free(text);
+
+        gtk_widget_set_sensitive (info->account_page, TRUE);
+
+        /* Let the user select an account to put the transactions in. */
+        account = gnc_import_account_assist_update (info->account_picker);
+
+        /* If we have a valid account and auto_create is TRUE, move on to matcher */
+        if (!(account == NULL) && (info->account_picker->auto_create == TRUE))
+            gtk_assistant_set_current_page (assistant, num + 1);
+    }
+
+    /* Enable the Forward Assistant Button */
+    if (account == NULL)
+        gtk_assistant_set_page_complete (assistant, page, FALSE);
+    else
+        gtk_assistant_set_page_complete (assistant, page, TRUE);
+}
+
+
+void
+csv_import_trans_assistant_doc_page_prepare (GtkAssistant *assistant,
+        gpointer user_data)
+{
+    CsvImportTrans *info = user_data;
+
+    /* Block going back */
+    gtk_assistant_commit (GTK_ASSISTANT(info->window));
+
+    if ( info->match_parse_run == FALSE)
+    {
+        /* Add the Cancel button for the matcher */
+        info->cancel_button = gtk_button_new_with_mnemonic (_("_Cancel"));
+        gtk_assistant_add_action_widget (assistant, info->cancel_button);
+        g_signal_connect(info->cancel_button, "clicked",
+                         G_CALLBACK(csv_import_trans_assistant_cancel), info);
+        gtk_widget_show(GTK_WIDGET(info->cancel_button));
+    }
+}
+
+
+void
+csv_import_trans_assistant_match_page_prepare (GtkAssistant *assistant,
+        gpointer user_data)
+{
+    CsvImportTrans *info = user_data;
+    gint num = gtk_assistant_get_current_page (assistant);
+    GtkWidget *page = gtk_assistant_get_nth_page (assistant, num);
+    gchar *text, *mtext;
+
+    /* Block going back */
+    gtk_assistant_commit (GTK_ASSISTANT(info->window));
+
+    /* Before creating transactions, if this is a new book, let user specify
+     * book options, since they affect how transactions are created */
+    if (info->new_book)
+        info->new_book = gnc_new_book_option_display();
+
+    /* Create transactions from the parsed data, first time with FALSE
+       Subsequent times with TRUE */
+    if ( info->match_parse_run == FALSE)
+    {
+        gnc_csv_parse_to_trans(info->parse_data, info->account_picker->retAccount, FALSE);
+    }
+    else
+        gnc_csv_parse_to_trans(info->parse_data, info->account_picker->retAccount, TRUE);
+    info->match_parse_run = TRUE;
+
+    /* if there are errors, we jump back to preview to correct */
+    if (!(info->parse_data->error_lines == NULL) && (info->approved == FALSE) )
+    {
+        info->previewing_errors = TRUE; /* We're looking at errors. */
+        gtk_assistant_set_current_page (assistant, 2);
+    }
+
+    if ((info->parse_data->error_lines == NULL) || (info->approved == TRUE) )
+    {
+        GList* transactions; /* A list of the transactions we create */
+
+        text =  _("Double click on rows to change, then click on Apply to Import");
+        mtext = g_strdup_printf("<span size=\"medium\" color=\"red\"><b>%s</b></span>", text);
+        gtk_label_set_markup(GTK_LABEL(info->match_label), mtext);
+        g_free(mtext);
+
+        if (info->gnc_csv_importer_gui == NULL)
+        {
+            /* Create the genereic transaction importer GUI. */
+            info->gnc_csv_importer_gui = gnc_gen_trans_assist_new (info->match_page, NULL, FALSE, 42);
+
+            /* Add the help button for the matcher */
+            info->help_button = gtk_button_new_with_mnemonic (_("_Help"));
+            gtk_assistant_add_action_widget (assistant, info->help_button);
+            g_signal_connect(info->help_button, "clicked",
+                             G_CALLBACK(on_matcher_help_clicked), info->gnc_csv_importer_gui);
+            gtk_widget_show(GTK_WIDGET(info->help_button));
+
+            /* Get the list of the transactions that were created. */
+            transactions = info->parse_data->transactions;
+            /* Copy all of the transactions to the importer GUI. */
+            while (transactions != NULL)
+            {
+                GncCsvTransLine* trans_line = transactions->data;
+                gnc_gen_trans_list_add_trans(info->gnc_csv_importer_gui, trans_line->trans);
+                transactions = g_list_next(transactions);
+            }
+            g_list_free(transactions);
+        }
+    }
+    /* Enable the Forward Assistant Button */
+    gtk_assistant_set_page_complete (assistant, page, TRUE);
+}
+
+
+void
+csv_import_trans_assistant_summary_page_prepare (GtkAssistant *assistant,
+        gpointer user_data)
+{
+    CsvImportTrans *info = user_data;
+    gchar *text, *mtext;
+
+    /* Save the Window size and directory */
+    gnc_set_default_directory(GNC_PREFS_GROUP, info->starting_dir);
+
+    /* Remove the added button */
+    gtk_assistant_remove_action_widget (assistant, info->help_button);
+    gtk_assistant_remove_action_widget (assistant, info->cancel_button);
+
+    text = g_strdup_printf(gettext ("The transactions were imported from the file '%s'."), info->file_name);
+    mtext = g_strdup_printf("<span size=\"medium\"><b>%s</b></span>", text);
+    gtk_label_set_markup(GTK_LABEL(info->summary_label), mtext);
+    g_free(text);
+    g_free(mtext);
+}
+
+
+void
+csv_import_trans_assistant_prepare (GtkAssistant *assistant, GtkWidget *page,
+                                    gpointer user_data)
+{
+    gint currentpage = gtk_assistant_get_current_page(assistant);
+
+    switch (currentpage)
+    {
+    case 0:
+        /* Current page is Import Start page */
+        csv_import_trans_assistant_start_page_prepare (assistant, user_data);
+        break;
+    case 1:
+        /* Current page is File select page */
+        csv_import_trans_assistant_file_page_prepare (assistant, user_data);
+        break;
+    case 2:
+        /* Current page is Preview page */
+        csv_import_trans_assistant_preview_page_prepare (assistant, user_data);
+        break;
+    case 3:
+        /* Current page is Account page */
+        csv_import_trans_assistant_account_page_prepare (assistant, user_data);
+        break;
+    case 4:
+        /* Current page is Transaction Doc page */
+        csv_import_trans_assistant_doc_page_prepare (assistant, user_data);
+        break;
+    case 5:
+        /* Current page is Match page */
+        csv_import_trans_assistant_match_page_prepare (assistant, user_data);
+        break;
+    case 6:
+        /* Current page is Summary page */
+        csv_import_trans_assistant_summary_page_prepare (assistant, user_data);
+        break;
+    }
+}
+
+
+/*******************************************************
+ * Assistant call back functions
+ *******************************************************/
+static void
+csv_import_trans_assistant_destroy_cb (GtkObject *object, gpointer user_data)
+{
+    CsvImportTrans *info = user_data;
+    gnc_unregister_gui_component_by_data (ASSISTANT_CSV_IMPORT_TRANS_CM_CLASS, info);
+    g_free (info);
+}
+
+void
+csv_import_trans_assistant_cancel (GtkAssistant *assistant, gpointer user_data)
+{
+    CsvImportTrans *info = user_data;
+    gnc_close_gui_component_by_data (ASSISTANT_CSV_IMPORT_TRANS_CM_CLASS, info);
+}
+
+void
+csv_import_trans_assistant_close (GtkAssistant *assistant, gpointer user_data)
+{
+    CsvImportTrans *info = user_data;
+    gnc_close_gui_component_by_data (ASSISTANT_CSV_IMPORT_TRANS_CM_CLASS, info);
+}
+
+void
+csv_import_trans_assistant_finish (GtkAssistant *assistant, gpointer user_data)
+{
+    CsvImportTrans *info = user_data;
+
+    /* Start the import */
+    if (info->parse_data->transactions != NULL)
+        gnc_gen_trans_assist_start(info->gnc_csv_importer_gui);
+    else
+        gnc_gen_trans_list_delete(info->gnc_csv_importer_gui);
+}
+
+static void
+csv_import_trans_close_handler (gpointer user_data)
+{
+    CsvImportTrans *info = user_data;
+
+    g_free(info->file_name);
+    g_free(info->starting_dir);
+
+    /* Free the memory we allocated. */
+    if (!(info->parse_data == NULL))
+        gnc_csv_parse_data_free(info->parse_data);
+
+    if (!(info->account_picker == NULL))
+        info->account_picker = NULL;
+
+    if (!(info->gnc_csv_importer_gui == NULL))
+        info->gnc_csv_importer_gui = NULL;
+
+    gnc_save_window_size(GNC_PREFS_GROUP, GTK_WINDOW(info->window));
+    gtk_widget_destroy (info->window);
+}
+
+/*******************************************************
+ * Create the Assistant
+ *******************************************************/
+static GtkWidget *
+csv_import_trans_assistant_create (CsvImportTrans *info)
+{
+    GtkBuilder *builder;
+    GtkWidget *window;
+    GtkWidget *box;
+    GtkWidget *button, *csv_button, *h_box;
+
+    builder = gtk_builder_new();
+    gnc_builder_add_from_file  (builder , "assistant-csv-trans-import.glade", "start_row_adj");
+    gnc_builder_add_from_file  (builder , "assistant-csv-trans-import.glade", "end_row_adj");
+    gnc_builder_add_from_file  (builder , "assistant-csv-trans-import.glade", "CSV Transaction Assistant");
+    window = GTK_WIDGET(gtk_builder_get_object (builder, "CSV Transaction Assistant"));
+    info->window = window;
+
+    /* Set the assistant colors */
+    gnc_assistant_set_colors (GTK_ASSISTANT (info->window));
+
+    /* Load default settings */
+    load_settings (info);
+
+    /* Enable buttons on all page. */
+    gtk_assistant_set_page_complete (GTK_ASSISTANT (window),
+                                     GTK_WIDGET(gtk_builder_get_object(builder, "start_page")),
+                                     TRUE);
+    gtk_assistant_set_page_complete (GTK_ASSISTANT (window),
+                                     GTK_WIDGET(gtk_builder_get_object(builder, "file_page")),
+                                     FALSE);
+    gtk_assistant_set_page_complete (GTK_ASSISTANT (window),
+                                     GTK_WIDGET(gtk_builder_get_object(builder, "preview_page")),
+                                     TRUE);
+    gtk_assistant_set_page_complete (GTK_ASSISTANT (window),
+                                     GTK_WIDGET(gtk_builder_get_object(builder, "account_page")),
+                                     FALSE);
+    gtk_assistant_set_page_complete (GTK_ASSISTANT (window),
+                                     GTK_WIDGET(gtk_builder_get_object(builder, "doc_page")),
+                                     TRUE);
+    gtk_assistant_set_page_complete (GTK_ASSISTANT (window),
+                                     GTK_WIDGET(gtk_builder_get_object(builder, "match_page")),
+                                     FALSE);
+    gtk_assistant_set_page_complete (GTK_ASSISTANT (window),
+                                     GTK_WIDGET(gtk_builder_get_object(builder, "summary_page")),
+                                     TRUE);
+
+    /* Start Page */
+
+    /* File chooser Page */
+    info->file_chooser = gtk_file_chooser_widget_new (GTK_FILE_CHOOSER_ACTION_OPEN);
+    g_signal_connect (G_OBJECT (info->file_chooser), "file-activated",
+                      G_CALLBACK (csv_import_trans_file_chooser_confirm_cb), info);
+    button = gtk_button_new_from_stock(GTK_STOCK_OK);
+    gtk_widget_set_size_request (button, 100, -1);
+    gtk_widget_show (button);
+    h_box = gtk_hbox_new(TRUE, 0);
+    gtk_box_pack_start(GTK_BOX(h_box), button, FALSE, FALSE, 0);
+    gtk_file_chooser_set_extra_widget (GTK_FILE_CHOOSER(info->file_chooser), h_box);
+    g_signal_connect (G_OBJECT (button), "clicked",
+                      G_CALLBACK (csv_import_trans_file_chooser_confirm_cb), info);
+
+    box = GTK_WIDGET(gtk_builder_get_object(builder, "file_page"));
+    gtk_box_pack_start (GTK_BOX (box), info->file_chooser, TRUE, TRUE, 6);
+    gtk_widget_show (info->file_chooser);
+
+    /* Preview Settings Page */
+    {
+        char* sep_button_names[] = {"space_cbutton",
+                                    "tab_cbutton",
+                                    "comma_cbutton",
+                                    "colon_cbutton",
+                                    "semicolon_cbutton",
+                                    "hyphen_cbutton"
+                                   };
+        GtkContainer *date_format_container, *currency_format_container;
+        int i;
+
+        /* The table containing info->encselector and the separator configuration widgets */
+        GtkTable* enctable;
+
+        info->start_row_spin = GTK_WIDGET(gtk_builder_get_object (builder, "start_row"));
+        info->end_row_spin = GTK_WIDGET(gtk_builder_get_object (builder, "end_row"));
+        info->check_label = GTK_WIDGET(gtk_builder_get_object (builder, "check_label"));
+        info->check_butt = GTK_WIDGET(gtk_builder_get_object (builder, "check_butt"));
+
+        info->encselector = GO_CHARMAP_SEL(go_charmap_sel_new(GO_CHARMAP_SEL_TO_UTF8));
+        /* Connect the selector to the encoding_selected event handler. */
+        g_signal_connect(G_OBJECT(info->encselector), "charmap_changed",
+                         G_CALLBACK(encoding_selected), (gpointer)info);
+
+        /* Load the separator buttons from the glade builder file into the
+         * info->sep_buttons array. */
+        for (i = 0; i < SEP_NUM_OF_TYPES; i++)
+        {
+            info->sep_buttons[i]
+                = (GtkCheckButton*)GTK_WIDGET(gtk_builder_get_object (builder, sep_button_names[i]));
+            /* Connect them to the sep_button_clicked event handler. */
+            g_signal_connect(G_OBJECT(info->sep_buttons[i]), "toggled",
+                             G_CALLBACK(sep_button_clicked), (gpointer)info);
+        }
+
+        /* Load and connect the custom separator checkbutton in the same way
+         * as the other separator buttons. */
+        info->custom_cbutton
+            = (GtkCheckButton*)GTK_WIDGET(gtk_builder_get_object (builder, "custom_cbutton"));
+        g_signal_connect(G_OBJECT(info->custom_cbutton), "clicked",
+                         G_CALLBACK(sep_button_clicked), (gpointer)info);
+
+        /* Load the entry for the custom separator entry. Connect it to the
+         * sep_button_clicked event handler as well. */
+        info->custom_entry = (GtkEntry*)GTK_WIDGET(gtk_builder_get_object (builder, "custom_entry"));
+        g_signal_connect(G_OBJECT(info->custom_entry), "changed",
+                         G_CALLBACK(sep_button_clicked), (gpointer)info);
+
+        /* Get the table from the Glade builder file. */
+        enctable = GTK_TABLE(gtk_builder_get_object (builder, "enctable"));
+        /* Put the selector in at the top. */
+        gtk_table_attach_defaults(enctable, GTK_WIDGET(info->encselector), 1, 2, 0, 1);
+        /* Show the table in all its glory. */
+        gtk_widget_show_all(GTK_WIDGET(enctable));
+
+        /* The instructions label and image */
+        info->instructions_label = GTK_LABEL(gtk_builder_get_object (builder, "instructions_label"));
+        info->instructions_image = GTK_IMAGE(gtk_builder_get_object (builder, "instructions_image"));
+
+        /* Add in the date format combo box and hook it up to an event handler. */
+        info->date_format_combo = GTK_COMBO_BOX_TEXT(gtk_combo_box_text_new());
+        for (i = 0; i < num_date_formats; i++)
+        {
+            gtk_combo_box_text_append_text(info->date_format_combo, _(date_format_user[i]));
+        }
+        gtk_combo_box_set_active(GTK_COMBO_BOX(info->date_format_combo), 0);
+        g_signal_connect(G_OBJECT(info->date_format_combo), "changed",
+                         G_CALLBACK(date_format_selected), (gpointer)info);
+
+        /* Add it to the assistant. */
+        date_format_container = GTK_CONTAINER(gtk_builder_get_object (builder, "date_format_container"));
+        gtk_container_add(date_format_container, GTK_WIDGET(info->date_format_combo));
+        gtk_widget_show_all(GTK_WIDGET(date_format_container));
+
+        /* Add in the currency format combo box and hook it up to an event handler. */
+        info->currency_format_combo = GTK_COMBO_BOX_TEXT(gtk_combo_box_text_new());
+        for (i = 0; i < num_currency_formats; i++)
+        {
+            gtk_combo_box_text_append_text(info->currency_format_combo, _(currency_format_user[i]));
+        }
+        /* Default will the locale */
+        gtk_combo_box_set_active(GTK_COMBO_BOX(info->currency_format_combo), 0);
+        g_signal_connect(G_OBJECT(info->currency_format_combo), "changed",
+                         G_CALLBACK(currency_format_selected), (gpointer)info);
+
+        /* Add it to the assistant. */
+        currency_format_container = GTK_CONTAINER(gtk_builder_get_object (builder, "currency_format_container"));
+        gtk_container_add(currency_format_container, GTK_WIDGET(info->currency_format_combo));
+        gtk_widget_show_all(GTK_WIDGET(currency_format_container));
+
+        /* Connect the CSV/Fixed-Width radio button event handler. */
+        csv_button = GTK_WIDGET(gtk_builder_get_object (builder, "csv_button"));
+        g_signal_connect(csv_button, "toggled",
+                         G_CALLBACK(separated_or_fixed_selected), (gpointer)info);
+
+        /* Load the data treeview and connect it to its resizing event handler. */
+        info->treeview = (GtkTreeView*)GTK_WIDGET(gtk_builder_get_object (builder, "treeview"));
+
+        /* Load the column type treeview. */
+        info->ctreeview = (GtkTreeView*)GTK_WIDGET(gtk_builder_get_object (builder, "ctreeview"));
+
+        /* This is TRUE only after encoding_selected is called, so we must
+         * set it initially to FALSE. */
+        info->encoding_selected_called = FALSE;
+
+        /* It is empty at first. */
+        info->not_empty = FALSE;
+    }
+
+    /* Account page */
+    /* Initialise the Account Picker and add to the Assistant */
+    info->account_page  = GTK_WIDGET(gtk_builder_get_object (builder, "account_page"));
+    info->account_picker = gnc_import_account_assist_setup(info->account_page);
+    info->account_label = GTK_WIDGET(gtk_builder_get_object (builder, "account_label"));
+
+    /* Matcher page */
+    info->match_page  = GTK_WIDGET(gtk_builder_get_object (builder, "match_page"));
+    info->match_label = GTK_WIDGET(gtk_builder_get_object (builder, "match_label"));
+
+    /* Summary Page */
+    info->summary_label = GTK_WIDGET(gtk_builder_get_object(builder, "summary_label"));
+
+    g_signal_connect (G_OBJECT(window), "destroy",
+                      G_CALLBACK (csv_import_trans_assistant_destroy_cb), info);
+
+    gnc_restore_window_size (GNC_PREFS_GROUP, GTK_WINDOW(info->window));
+
+    gtk_builder_connect_signals(builder, info);
+    g_object_unref(G_OBJECT(builder));
+    return window;
+}
+
+
+/********************************************************************\
+ * gnc_file_csv_trans_import                                        *
+ * opens up a assistant to import accounts.                         *
+ *                                                                  *
+ * Args:   import_type                                              *
+ * Return: nothing                                                  *
+\********************************************************************/
+void
+gnc_file_csv_trans_import(void)
+{
+    CsvImportTrans *info;
+
+    info = g_new0 (CsvImportTrans, 1);
+
+    /* In order to trigger a book options display on the creation of a new book,
+     * we need to detect when we are dealing with a new book. */
+    info->new_book = gnc_is_new_book();
+
+    csv_import_trans_assistant_create (info);
+
+    gnc_register_gui_component (ASSISTANT_CSV_IMPORT_TRANS_CM_CLASS,
+                                NULL, csv_import_trans_close_handler,
+                                info);
+
+    gtk_widget_show_all (info->window);
+
+    gnc_window_adjust_for_screen (GTK_WINDOW(info->window));
+}

Copied: gnucash/trunk/src/import-export/csv-imp/assistant-csv-trans-import.glade (from rev 23566, gnucash/trunk/src/import-export/csv-import/assistant-csv-trans-import.glade)
===================================================================
--- gnucash/trunk/src/import-export/csv-imp/assistant-csv-trans-import.glade	                        (rev 0)
+++ gnucash/trunk/src/import-export/csv-imp/assistant-csv-trans-import.glade	2013-12-15 17:21:20 UTC (rev 23567)
@@ -0,0 +1,865 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<interface>
+  <requires lib="gtk+" version="2.16"/>
+  <!-- interface-naming-policy project-wide -->
+  <object class="GtkAssistant" id="CSV Transaction Assistant">
+    <property name="can_focus">False</property>
+    <property name="border_width">12</property>
+    <property name="title" translatable="yes">CSV Transaction Import</property>
+    <property name="default_width">400</property>
+    <property name="default_height">500</property>
+    <signal name="close" handler="csv_import_trans_assistant_close" swapped="no"/>
+    <signal name="apply" handler="csv_import_trans_assistant_finish" swapped="no"/>
+    <signal name="prepare" handler="csv_import_trans_assistant_prepare" swapped="no"/>
+    <signal name="cancel" handler="csv_import_trans_assistant_cancel" swapped="no"/>
+    <child>
+      <object class="GtkLabel" id="start_page">
+        <property name="visible">True</property>
+        <property name="can_focus">False</property>
+        <property name="label" translatable="yes">This assistant will help you import a delimited file containing a list of transactions.
+
+All transactions imported will be associated to one account for each import and if you select the account column, the account in the first row will be used for all rows.
+
+Various options exist for specifying the delimiter as well as a fixed width option. With the fixed width option, double click on the bar above the displayed rows to set the column width.
+
+There is an option for specifying the start and end row which can be used if you have some header text or multiple accounts in the same file.</property>
+        <property name="wrap">True</property>
+      </object>
+      <packing>
+        <property name="page_type">intro</property>
+        <property name="title" translatable="yes">Transaction Import Assistant</property>
+        <property name="complete">True</property>
+      </packing>
+    </child>
+    <child>
+      <object class="GtkVBox" id="file_page">
+        <property name="visible">True</property>
+        <property name="can_focus">False</property>
+        <property name="border_width">12</property>
+        <child>
+          <object class="GtkLabel" id="label7">
+            <property name="visible">True</property>
+            <property name="can_focus">False</property>
+            <property name="label" translatable="yes">
+Select location and file name for the Import, then click 'OK'...
+</property>
+            <property name="wrap">True</property>
+          </object>
+          <packing>
+            <property name="expand">False</property>
+            <property name="fill">False</property>
+            <property name="position">0</property>
+          </packing>
+        </child>
+        <child>
+          <placeholder/>
+        </child>
+      </object>
+      <packing>
+        <property name="title" translatable="yes">Select File for Import</property>
+      </packing>
+    </child>
+    <child>
+      <object class="GtkVBox" id="preview_page">
+        <property name="visible">True</property>
+        <property name="can_focus">False</property>
+        <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+        <property name="border_width">12</property>
+        <property name="spacing">2</property>
+        <child>
+          <object class="GtkHBox" id="hbox1">
+            <property name="visible">True</property>
+            <property name="can_focus">False</property>
+            <property name="spacing">12</property>
+            <child>
+              <object class="GtkVBox" id="vbox1">
+                <property name="visible">True</property>
+                <property name="can_focus">False</property>
+                <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+                <child>
+                  <object class="GtkHBox" id="hbox6">
+                    <property name="visible">True</property>
+                    <property name="can_focus">False</property>
+                    <child>
+                      <object class="GtkLabel" id="label9">
+                        <property name="visible">True</property>
+                        <property name="can_focus">False</property>
+                        <property name="label" translatable="yes">Start import on row </property>
+                      </object>
+                      <packing>
+                        <property name="expand">False</property>
+                        <property name="fill">False</property>
+                        <property name="position">0</property>
+                      </packing>
+                    </child>
+                    <child>
+                      <object class="GtkSpinButton" id="start_row">
+                        <property name="visible">True</property>
+                        <property name="can_focus">True</property>
+                        <property name="editable">False</property>
+                        <property name="invisible_char">&#x25CF;</property>
+                        <property name="invisible_char_set">True</property>
+                        <property name="primary_icon_activatable">False</property>
+                        <property name="secondary_icon_activatable">False</property>
+                        <property name="primary_icon_sensitive">True</property>
+                        <property name="secondary_icon_sensitive">True</property>
+                        <property name="adjustment">start_row_adj</property>
+                        <signal name="value-changed" handler="csv_import_trans_srow_cb" swapped="no"/>
+                      </object>
+                      <packing>
+                        <property name="expand">False</property>
+                        <property name="fill">False</property>
+                        <property name="position">1</property>
+                      </packing>
+                    </child>
+                    <child>
+                      <object class="GtkLabel" id="label10">
+                        <property name="visible">True</property>
+                        <property name="can_focus">False</property>
+                        <property name="label" translatable="yes"> and stop on row </property>
+                      </object>
+                      <packing>
+                        <property name="expand">False</property>
+                        <property name="fill">False</property>
+                        <property name="position">2</property>
+                      </packing>
+                    </child>
+                    <child>
+                      <object class="GtkSpinButton" id="end_row">
+                        <property name="visible">True</property>
+                        <property name="can_focus">True</property>
+                        <property name="editable">False</property>
+                        <property name="invisible_char">&#x25CF;</property>
+                        <property name="invisible_char_set">True</property>
+                        <property name="primary_icon_activatable">False</property>
+                        <property name="secondary_icon_activatable">False</property>
+                        <property name="primary_icon_sensitive">True</property>
+                        <property name="secondary_icon_sensitive">True</property>
+                        <property name="adjustment">end_row_adj</property>
+                        <signal name="value-changed" handler="csv_import_trans_erow_cb" swapped="no"/>
+                      </object>
+                      <packing>
+                        <property name="expand">False</property>
+                        <property name="fill">False</property>
+                        <property name="position">3</property>
+                      </packing>
+                    </child>
+                  </object>
+                  <packing>
+                    <property name="expand">False</property>
+                    <property name="fill">False</property>
+                    <property name="position">0</property>
+                  </packing>
+                </child>
+                <child>
+                  <object class="GtkHSeparator" id="hseparator7">
+                    <property name="visible">True</property>
+                    <property name="can_focus">False</property>
+                  </object>
+                  <packing>
+                    <property name="expand">False</property>
+                    <property name="fill">True</property>
+                    <property name="padding">8</property>
+                    <property name="position">1</property>
+                  </packing>
+                </child>
+                <child>
+                  <object class="GtkHBox" id="hbox4">
+                    <property name="visible">True</property>
+                    <property name="can_focus">False</property>
+                    <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+                    <child>
+                      <object class="GtkLabel" id="label1">
+                        <property name="visible">True</property>
+                        <property name="can_focus">False</property>
+                        <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+                        <property name="label" translatable="yes">Data type: </property>
+                      </object>
+                      <packing>
+                        <property name="expand">False</property>
+                        <property name="fill">True</property>
+                        <property name="position">0</property>
+                      </packing>
+                    </child>
+                    <child>
+                      <object class="GtkRadioButton" id="csv_button">
+                        <property name="label" translatable="yes">Separated</property>
+                        <property name="visible">True</property>
+                        <property name="can_focus">True</property>
+                        <property name="receives_default">False</property>
+                        <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+                        <property name="use_action_appearance">False</property>
+                        <property name="active">True</property>
+                        <property name="draw_indicator">True</property>
+                      </object>
+                      <packing>
+                        <property name="expand">False</property>
+                        <property name="fill">True</property>
+                        <property name="position">1</property>
+                      </packing>
+                    </child>
+                    <child>
+                      <object class="GtkRadioButton" id="radiobutton2">
+                        <property name="label" translatable="yes">Fixed-Width</property>
+                        <property name="visible">True</property>
+                        <property name="can_focus">True</property>
+                        <property name="receives_default">False</property>
+                        <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+                        <property name="use_action_appearance">False</property>
+                        <property name="draw_indicator">True</property>
+                        <property name="group">csv_button</property>
+                      </object>
+                      <packing>
+                        <property name="expand">False</property>
+                        <property name="fill">True</property>
+                        <property name="position">2</property>
+                      </packing>
+                    </child>
+                  </object>
+                  <packing>
+                    <property name="expand">False</property>
+                    <property name="fill">True</property>
+                    <property name="position">2</property>
+                  </packing>
+                </child>
+                <child>
+                  <object class="GtkHSeparator" id="hseparator6">
+                    <property name="visible">True</property>
+                    <property name="can_focus">False</property>
+                    <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+                  </object>
+                  <packing>
+                    <property name="expand">False</property>
+                    <property name="fill">False</property>
+                    <property name="padding">10</property>
+                    <property name="position">3</property>
+                  </packing>
+                </child>
+                <child>
+                  <object class="GtkHBox" id="hbox7">
+                    <property name="visible">True</property>
+                    <property name="can_focus">False</property>
+                    <child>
+                      <object class="GtkFrame" id="frame2">
+                        <property name="visible">True</property>
+                        <property name="can_focus">False</property>
+                        <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+                        <property name="label_xalign">0</property>
+                        <property name="shadow_type">none</property>
+                        <child>
+                          <object class="GtkAlignment" id="date_format_container">
+                            <property name="visible">True</property>
+                            <property name="can_focus">False</property>
+                            <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+                            <property name="left_padding">12</property>
+                            <child>
+                              <placeholder/>
+                            </child>
+                          </object>
+                        </child>
+                        <child type="label">
+                          <object class="GtkLabel" id="label4">
+                            <property name="visible">True</property>
+                            <property name="can_focus">False</property>
+                            <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+                            <property name="label" translatable="yes">Date Format</property>
+                            <property name="use_markup">True</property>
+                          </object>
+                        </child>
+                      </object>
+                      <packing>
+                        <property name="expand">False</property>
+                        <property name="fill">False</property>
+                        <property name="position">0</property>
+                      </packing>
+                    </child>
+                    <child>
+                      <object class="GtkFrame" id="frame3">
+                        <property name="visible">True</property>
+                        <property name="can_focus">False</property>
+                        <property name="label_xalign">0</property>
+                        <property name="shadow_type">none</property>
+                        <child>
+                          <object class="GtkAlignment" id="currency_format_container">
+                            <property name="visible">True</property>
+                            <property name="can_focus">False</property>
+                            <property name="left_padding">12</property>
+                            <child>
+                              <placeholder/>
+                            </child>
+                          </object>
+                        </child>
+                        <child type="label">
+                          <object class="GtkLabel" id="label2">
+                            <property name="visible">True</property>
+                            <property name="can_focus">False</property>
+                            <property name="label" translatable="yes">Currency format</property>
+                            <property name="use_markup">True</property>
+                          </object>
+                        </child>
+                      </object>
+                      <packing>
+                        <property name="expand">True</property>
+                        <property name="fill">True</property>
+                        <property name="position">1</property>
+                      </packing>
+                    </child>
+                  </object>
+                  <packing>
+                    <property name="expand">False</property>
+                    <property name="fill">False</property>
+                    <property name="position">4</property>
+                  </packing>
+                </child>
+                <child>
+                  <object class="GtkHSeparator" id="hseparator3">
+                    <property name="visible">True</property>
+                    <property name="can_focus">False</property>
+                    <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+                  </object>
+                  <packing>
+                    <property name="expand">False</property>
+                    <property name="fill">False</property>
+                    <property name="padding">10</property>
+                    <property name="position">5</property>
+                  </packing>
+                </child>
+              </object>
+              <packing>
+                <property name="expand">False</property>
+                <property name="fill">False</property>
+                <property name="position">0</property>
+              </packing>
+            </child>
+            <child>
+              <object class="GtkVBox" id="vbox3">
+                <property name="visible">True</property>
+                <property name="can_focus">False</property>
+                <child>
+                  <object class="GtkHBox" id="hbox2">
+                    <property name="visible">True</property>
+                    <property name="can_focus">False</property>
+                    <child>
+                      <object class="GtkTable" id="enctable">
+                        <property name="visible">True</property>
+                        <property name="can_focus">False</property>
+                        <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+                        <child>
+                          <object class="GtkLabel" id="label3">
+                            <property name="visible">True</property>
+                            <property name="can_focus">False</property>
+                            <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+                            <property name="label" translatable="yes">Encoding: </property>
+                          </object>
+                          <packing>
+                            <property name="x_options">GTK_FILL</property>
+                            <property name="y_options">GTK_FILL</property>
+                          </packing>
+                        </child>
+                      </object>
+                      <packing>
+                        <property name="expand">True</property>
+                        <property name="fill">True</property>
+                        <property name="position">0</property>
+                      </packing>
+                    </child>
+                  </object>
+                  <packing>
+                    <property name="expand">False</property>
+                    <property name="fill">False</property>
+                    <property name="position">0</property>
+                  </packing>
+                </child>
+                <child>
+                  <object class="GtkHSeparator" id="hseparator1">
+                    <property name="visible">True</property>
+                    <property name="can_focus">False</property>
+                  </object>
+                  <packing>
+                    <property name="expand">False</property>
+                    <property name="fill">True</property>
+                    <property name="padding">5</property>
+                    <property name="position">1</property>
+                  </packing>
+                </child>
+                <child>
+                  <object class="GtkFrame" id="frame1">
+                    <property name="visible">True</property>
+                    <property name="can_focus">False</property>
+                    <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+                    <property name="label_xalign">0</property>
+                    <property name="shadow_type">none</property>
+                    <child>
+                      <object class="GtkAlignment" id="alignment1">
+                        <property name="visible">True</property>
+                        <property name="can_focus">False</property>
+                        <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+                        <property name="left_padding">12</property>
+                        <child>
+                          <object class="GtkTable" id="table1">
+                            <property name="visible">True</property>
+                            <property name="can_focus">False</property>
+                            <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+                            <property name="n_rows">3</property>
+                            <property name="n_columns">3</property>
+                            <property name="column_spacing">3</property>
+                            <property name="row_spacing">3</property>
+                            <property name="homogeneous">True</property>
+                            <child>
+                              <object class="GtkCheckButton" id="space_cbutton">
+                                <property name="label" translatable="yes">Space</property>
+                                <property name="visible">True</property>
+                                <property name="can_focus">True</property>
+                                <property name="receives_default">False</property>
+                                <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+                                <property name="use_action_appearance">False</property>
+                                <property name="draw_indicator">True</property>
+                              </object>
+                              <packing>
+                                <property name="x_options">GTK_FILL</property>
+                                <property name="y_options">GTK_FILL</property>
+                              </packing>
+                            </child>
+                            <child>
+                              <object class="GtkCheckButton" id="tab_cbutton">
+                                <property name="label" translatable="yes">Tab</property>
+                                <property name="visible">True</property>
+                                <property name="can_focus">True</property>
+                                <property name="receives_default">False</property>
+                                <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+                                <property name="use_action_appearance">False</property>
+                                <property name="draw_indicator">True</property>
+                              </object>
+                              <packing>
+                                <property name="left_attach">1</property>
+                                <property name="right_attach">2</property>
+                                <property name="x_options">GTK_FILL</property>
+                                <property name="y_options">GTK_FILL</property>
+                              </packing>
+                            </child>
+                            <child>
+                              <object class="GtkCheckButton" id="comma_cbutton">
+                                <property name="label" translatable="yes">Comma (,)</property>
+                                <property name="visible">True</property>
+                                <property name="can_focus">True</property>
+                                <property name="receives_default">False</property>
+                                <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+                                <property name="use_action_appearance">False</property>
+                                <property name="active">True</property>
+                                <property name="draw_indicator">True</property>
+                              </object>
+                              <packing>
+                                <property name="left_attach">2</property>
+                                <property name="right_attach">3</property>
+                                <property name="x_options">GTK_FILL</property>
+                                <property name="y_options">GTK_FILL</property>
+                              </packing>
+                            </child>
+                            <child>
+                              <object class="GtkCheckButton" id="colon_cbutton">
+                                <property name="label" translatable="yes">Colon (:)</property>
+                                <property name="visible">True</property>
+                                <property name="can_focus">True</property>
+                                <property name="receives_default">False</property>
+                                <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+                                <property name="use_action_appearance">False</property>
+                                <property name="draw_indicator">True</property>
+                              </object>
+                              <packing>
+                                <property name="top_attach">1</property>
+                                <property name="bottom_attach">2</property>
+                                <property name="x_options">GTK_FILL</property>
+                                <property name="y_options">GTK_FILL</property>
+                              </packing>
+                            </child>
+                            <child>
+                              <object class="GtkCheckButton" id="semicolon_cbutton">
+                                <property name="label" translatable="yes">Semicolon (;)</property>
+                                <property name="visible">True</property>
+                                <property name="can_focus">True</property>
+                                <property name="receives_default">False</property>
+                                <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+                                <property name="use_action_appearance">False</property>
+                                <property name="draw_indicator">True</property>
+                              </object>
+                              <packing>
+                                <property name="left_attach">1</property>
+                                <property name="right_attach">2</property>
+                                <property name="top_attach">1</property>
+                                <property name="bottom_attach">2</property>
+                                <property name="x_options">GTK_FILL</property>
+                                <property name="y_options">GTK_FILL</property>
+                              </packing>
+                            </child>
+                            <child>
+                              <object class="GtkCheckButton" id="hyphen_cbutton">
+                                <property name="label" translatable="yes">Hyphen (-)</property>
+                                <property name="visible">True</property>
+                                <property name="can_focus">True</property>
+                                <property name="receives_default">False</property>
+                                <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+                                <property name="use_action_appearance">False</property>
+                                <property name="draw_indicator">True</property>
+                              </object>
+                              <packing>
+                                <property name="left_attach">2</property>
+                                <property name="right_attach">3</property>
+                                <property name="top_attach">1</property>
+                                <property name="bottom_attach">2</property>
+                                <property name="x_options">GTK_FILL</property>
+                                <property name="y_options">GTK_FILL</property>
+                              </packing>
+                            </child>
+                            <child>
+                              <object class="GtkCheckButton" id="custom_cbutton">
+                                <property name="label" translatable="yes">Custom</property>
+                                <property name="visible">True</property>
+                                <property name="can_focus">True</property>
+                                <property name="receives_default">False</property>
+                                <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+                                <property name="use_action_appearance">False</property>
+                                <property name="draw_indicator">True</property>
+                              </object>
+                              <packing>
+                                <property name="top_attach">2</property>
+                                <property name="bottom_attach">3</property>
+                                <property name="x_options">GTK_FILL</property>
+                                <property name="y_options">GTK_FILL</property>
+                              </packing>
+                            </child>
+                            <child>
+                              <object class="GtkEntry" id="custom_entry">
+                                <property name="visible">True</property>
+                                <property name="can_focus">True</property>
+                                <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+                                <property name="invisible_char">&#x25CF;</property>
+                                <property name="invisible_char_set">True</property>
+                                <property name="primary_icon_activatable">False</property>
+                                <property name="secondary_icon_activatable">False</property>
+                                <property name="primary_icon_sensitive">True</property>
+                                <property name="secondary_icon_sensitive">True</property>
+                              </object>
+                              <packing>
+                                <property name="left_attach">1</property>
+                                <property name="right_attach">3</property>
+                                <property name="top_attach">2</property>
+                                <property name="bottom_attach">3</property>
+                                <property name="x_options">GTK_FILL</property>
+                                <property name="y_options">GTK_FILL</property>
+                              </packing>
+                            </child>
+                          </object>
+                        </child>
+                      </object>
+                    </child>
+                    <child type="label">
+                      <object class="GtkLabel" id="label5">
+                        <property name="visible">True</property>
+                        <property name="can_focus">False</property>
+                        <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+                        <property name="label" translatable="yes">Separators</property>
+                        <property name="use_markup">True</property>
+                      </object>
+                    </child>
+                  </object>
+                  <packing>
+                    <property name="expand">False</property>
+                    <property name="fill">False</property>
+                    <property name="position">2</property>
+                  </packing>
+                </child>
+                <child>
+                  <object class="GtkHSeparator" id="hseparator2">
+                    <property name="visible">True</property>
+                    <property name="can_focus">False</property>
+                  </object>
+                  <packing>
+                    <property name="expand">False</property>
+                    <property name="fill">True</property>
+                    <property name="padding">6</property>
+                    <property name="position">3</property>
+                  </packing>
+                </child>
+              </object>
+              <packing>
+                <property name="expand">False</property>
+                <property name="fill">False</property>
+                <property name="position">1</property>
+              </packing>
+            </child>
+          </object>
+          <packing>
+            <property name="expand">False</property>
+            <property name="fill">False</property>
+            <property name="position">0</property>
+          </packing>
+        </child>
+        <child>
+          <object class="GtkHBox" id="hbox3">
+            <property name="visible">True</property>
+            <property name="can_focus">False</property>
+            <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+            <child>
+              <object class="GtkImage" id="instructions_image">
+                <property name="visible">True</property>
+                <property name="can_focus">False</property>
+                <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+                <property name="stock">gtk-dialog-info</property>
+              </object>
+              <packing>
+                <property name="expand">False</property>
+                <property name="fill">True</property>
+                <property name="padding">2</property>
+                <property name="position">0</property>
+              </packing>
+            </child>
+            <child>
+              <object class="GtkLabel" id="instructions_label">
+                <property name="visible">True</property>
+                <property name="can_focus">False</property>
+                <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+                <property name="xalign">0</property>
+                <property name="label" translatable="yes">Select the type of each column below.</property>
+              </object>
+              <packing>
+                <property name="expand">True</property>
+                <property name="fill">True</property>
+                <property name="position">1</property>
+              </packing>
+            </child>
+          </object>
+          <packing>
+            <property name="expand">False</property>
+            <property name="fill">False</property>
+            <property name="position">1</property>
+          </packing>
+        </child>
+        <child>
+          <object class="GtkScrolledWindow" id="scrolledwindow1">
+            <property name="visible">True</property>
+            <property name="can_focus">True</property>
+            <property name="hscrollbar_policy">automatic</property>
+            <property name="vscrollbar_policy">automatic</property>
+            <child>
+              <object class="GtkViewport" id="viewport1">
+                <property name="visible">True</property>
+                <property name="can_focus">False</property>
+                <child>
+                  <object class="GtkVBox" id="vbox2">
+                    <property name="visible">True</property>
+                    <property name="can_focus">False</property>
+                    <child>
+                      <object class="GtkTreeView" id="ctreeview">
+                        <property name="visible">True</property>
+                        <property name="can_focus">True</property>
+                        <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+                        <property name="headers_visible">False</property>
+                        <property name="enable_grid_lines">both</property>
+                      </object>
+                      <packing>
+                        <property name="expand">False</property>
+                        <property name="fill">True</property>
+                        <property name="position">0</property>
+                      </packing>
+                    </child>
+                    <child>
+                      <object class="GtkTreeView" id="treeview">
+                        <property name="visible">True</property>
+                        <property name="can_focus">True</property>
+                        <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+                        <property name="enable_grid_lines">both</property>
+                      </object>
+                      <packing>
+                        <property name="expand">True</property>
+                        <property name="fill">True</property>
+                        <property name="position">1</property>
+                      </packing>
+                    </child>
+                  </object>
+                </child>
+              </object>
+            </child>
+          </object>
+          <packing>
+            <property name="expand">True</property>
+            <property name="fill">True</property>
+            <property name="position">2</property>
+          </packing>
+        </child>
+        <child>
+          <object class="GtkHBox" id="hbox5">
+            <property name="visible">True</property>
+            <property name="can_focus">False</property>
+            <child>
+              <object class="GtkCheckButton" id="check_butt">
+                <property name="visible">True</property>
+                <property name="can_focus">True</property>
+                <property name="receives_default">False</property>
+                <property name="use_action_appearance">False</property>
+                <property name="xalign">1</property>
+                <property name="image_position">right</property>
+                <property name="active">True</property>
+                <property name="draw_indicator">True</property>
+                <signal name="toggled" handler="csv_import_trans_auto_cb" swapped="no"/>
+              </object>
+              <packing>
+                <property name="expand">False</property>
+                <property name="fill">False</property>
+                <property name="pack_type">end</property>
+                <property name="position">0</property>
+              </packing>
+            </child>
+            <child>
+              <object class="GtkLabel" id="check_label">
+                <property name="visible">True</property>
+                <property name="can_focus">False</property>
+                <property name="xpad">5</property>
+                <property name="label" translatable="yes">Step over Account Page if Setup</property>
+              </object>
+              <packing>
+                <property name="expand">False</property>
+                <property name="fill">False</property>
+                <property name="pack_type">end</property>
+                <property name="position">1</property>
+              </packing>
+            </child>
+          </object>
+          <packing>
+            <property name="expand">False</property>
+            <property name="fill">False</property>
+            <property name="pack_type">end</property>
+            <property name="position">3</property>
+          </packing>
+        </child>
+      </object>
+      <packing>
+        <property name="title" translatable="yes">Preview Settings</property>
+      </packing>
+    </child>
+    <child>
+      <object class="GtkVBox" id="account_page">
+        <property name="visible">True</property>
+        <property name="can_focus">False</property>
+        <property name="border_width">12</property>
+        <child>
+          <placeholder/>
+        </child>
+        <child>
+          <placeholder/>
+        </child>
+        <child>
+          <object class="GtkLabel" id="account_label">
+            <property name="visible">True</property>
+            <property name="can_focus">False</property>
+            <property name="label" translatable="yes">Error text.</property>
+            <property name="justify">center</property>
+          </object>
+          <packing>
+            <property name="expand">False</property>
+            <property name="fill">False</property>
+            <property name="pack_type">end</property>
+            <property name="position">2</property>
+          </packing>
+        </child>
+      </object>
+      <packing>
+        <property name="title" translatable="yes">Account Selection</property>
+      </packing>
+    </child>
+    <child>
+      <object class="GtkVBox" id="doc_page">
+        <property name="visible">True</property>
+        <property name="can_focus">False</property>
+        <child>
+          <object class="GtkLabel" id="label8">
+            <property name="visible">True</property>
+            <property name="can_focus">False</property>
+            <property name="label" translatable="yes">On the following page you will be able to associate each transaction to a category.
+
+If this is the first time importing, you will find that all lines may need to be associated. On subsequent imports, the importer will try to associate the transactions based on previous imports.
+
+If this is your initial import into a new file, you will first see a dialog for setting book options, since these can affect how imported data are converted to GnuCash transactions. If this is an existing file, the dialog will not be shown.
+
+The confidence of a correct association is displayed as a colored bar.
+
+More information can be displayed by using the help button.</property>
+            <property name="wrap">True</property>
+          </object>
+          <packing>
+            <property name="expand">True</property>
+            <property name="fill">True</property>
+            <property name="position">0</property>
+          </packing>
+        </child>
+      </object>
+      <packing>
+        <property name="page_type">progress</property>
+        <property name="title" translatable="yes">Transaction Information</property>
+        <property name="complete">True</property>
+      </packing>
+    </child>
+    <child>
+      <object class="GtkVBox" id="match_page">
+        <property name="visible">True</property>
+        <property name="can_focus">False</property>
+        <property name="border_width">12</property>
+        <child>
+          <object class="GtkLabel" id="match_label">
+            <property name="visible">True</property>
+            <property name="can_focus">False</property>
+            <property name="label" translatable="yes">label</property>
+          </object>
+          <packing>
+            <property name="expand">False</property>
+            <property name="fill">False</property>
+            <property name="pack_type">end</property>
+            <property name="position">0</property>
+          </packing>
+        </child>
+      </object>
+      <packing>
+        <property name="page_type">confirm</property>
+        <property name="title" translatable="yes">Match Transactions</property>
+      </packing>
+    </child>
+    <child>
+      <object class="GtkVBox" id="summary_page">
+        <property name="visible">True</property>
+        <property name="can_focus">False</property>
+        <property name="border_width">12</property>
+        <child>
+          <object class="GtkLabel" id="summary_label">
+            <property name="visible">True</property>
+            <property name="can_focus">False</property>
+            <property name="label" translatable="yes">label</property>
+            <property name="use_markup">True</property>
+          </object>
+          <packing>
+            <property name="expand">True</property>
+            <property name="fill">True</property>
+            <property name="position">0</property>
+          </packing>
+        </child>
+      </object>
+      <packing>
+        <property name="page_type">summary</property>
+        <property name="title" translatable="yes">Import Summary</property>
+        <property name="complete">True</property>
+      </packing>
+    </child>
+  </object>
+  <object class="GtkAdjustment" id="end_row_adj">
+    <property name="lower">1</property>
+    <property name="upper">100</property>
+    <property name="value">100</property>
+    <property name="step_increment">1</property>
+    <property name="page_increment">10</property>
+  </object>
+  <object class="GtkAdjustment" id="start_row_adj">
+    <property name="lower">1</property>
+    <property name="upper">100</property>
+    <property name="value">1</property>
+    <property name="step_increment">1</property>
+    <property name="page_increment">10</property>
+  </object>
+</interface>

Copied: gnucash/trunk/src/import-export/csv-imp/assistant-csv-trans-import.h (from rev 23566, gnucash/trunk/src/import-export/csv-import/assistant-csv-trans-import.h)
===================================================================
--- gnucash/trunk/src/import-export/csv-imp/assistant-csv-trans-import.h	                        (rev 0)
+++ gnucash/trunk/src/import-export/csv-imp/assistant-csv-trans-import.h	2013-12-15 17:21:20 UTC (rev 23567)
@@ -0,0 +1,36 @@
+/*******************************************************************\
+ * assistant-csv-trans-import.h -- An assistant for importing       *
+ *                                     Transactions from a file.    *
+ *                                                                  *
+ * Copyright (C) 2012 Robert Fewell                                 *
+ *                                                                  *
+ * This program is free software; you can redistribute it and/or    *
+ * modify it under the terms of the GNU General Public License as   *
+ * published by the Free Software Foundation; either version 2 of   *
+ * the License, or (at your option) any later version.              *
+ *                                                                  *
+ * This program is distributed in the hope that it will be useful,  *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of   *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the    *
+ * GNU General Public License for more details.                     *
+ *                                                                  *
+ * You should have received a copy of the GNU General Public License*
+ * along with this program; if not, contact:                        *
+ *                                                                  *
+ * Free Software Foundation           Voice:  +1-617-542-5942       *
+ * 51 Franklin Street, Fifth Floor    Fax:    +1-617-542-2652       *
+ * Boston, MA  02110-1301,  USA       gnu at gnu.org                   *
+\********************************************************************/
+/** @file assistant-csv-trans-import.h
+    @brief CSV Import Assistant
+    @author Copyright (c) 2011 Robert Fewell
+*/
+#ifndef GNC_ASSISTANT_CSV_IMPORT_TRANS_H
+#define GNC_ASSISTANT_CSV_IMPORT_TRANS_H
+
+
+/** The gnc_file_csv_trans_import() will let the user import thte
+ *  account tree or transactions to a delimited file.
+ */
+void gnc_file_csv_trans_import (void);
+#endif

Copied: gnucash/trunk/src/import-export/csv-imp/csv-account-import.c (from rev 23566, gnucash/trunk/src/import-export/csv-import/csv-account-import.c)
===================================================================
--- gnucash/trunk/src/import-export/csv-imp/csv-account-import.c	                        (rev 0)
+++ gnucash/trunk/src/import-export/csv-imp/csv-account-import.c	2013-12-15 17:21:20 UTC (rev 23567)
@@ -0,0 +1,348 @@
+/*******************************************************************\
+ * csv-account-import.c -- Account importing from file              *
+ *                                                                  *
+ * Copyright (C) 2012 Robert Fewell                                 *
+ *                                                                  *
+ * Based on code from bi_import written by Sebastian Held  and      *
+ * Mike Evans.                                                      *
+ *                                                                  *
+ * This program is free software; you can redistribute it and/or    *
+ * modify it under the terms of the GNU General Public License as   *
+ * published by the Free Software Foundation; either version 2 of   *
+ * the License, or (at your option) any later version.              *
+ *                                                                  *
+ * This program is distributed in the hope that it will be useful,  *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of   *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the    *
+ * GNU General Public License for more details.                     *
+ *                                                                  *
+ * You should have received a copy of the GNU General Public License*
+ * along with this program; if not, contact:                        *
+ *                                                                  *
+ * Free Software Foundation           Voice:  +1-617-542-5942       *
+ * 51 Franklin Street, Fifth Floor    Fax:    +1-617-542-2652       *
+ * Boston, MA  02110-1301,  USA       gnu at gnu.org                   *
+\********************************************************************/
+
+#include "config.h"
+
+#include <glib.h>
+#include <glib/gi18n.h>
+#include <glib/gstdio.h>
+
+#include "gnc-ui-util.h"
+#include <regex.h>
+#include "Account.h"
+#include "gnc-component-manager.h"
+#include "csv-account-import.h"
+
+/* This static indicates the debugging module that this .o belongs to.  */
+static QofLogModule log_module = GNC_MOD_ASSISTANT;
+
+/* This helper macro takes a regexp match and fills the model */
+#define FILL_IN_HELPER(match_name,column) \
+            temp = g_match_info_fetch_named (match_info, match_name); \
+            if (temp) \
+            { \
+		g_strstrip( temp ); \
+                gtk_list_store_set (store, &iter, column, temp, -1); \
+                g_free (temp); \
+            }
+
+
+/*******************************************************
+ * csv_import_read_file
+ *
+ * Parse the file for a correctly formatted file
+ *******************************************************/
+csv_import_result
+csv_import_read_file (const gchar *filename, const gchar *parser_regexp,
+                      GtkListStore *store, guint max_rows )
+{
+    FILE       *f;
+    char       *line;
+    gchar      *line_utf8, *temp;
+    GMatchInfo *match_info;
+    GError     *err;
+    GRegex     *regexpat;
+    int         row = 0;
+    gboolean match_found = FALSE;
+
+    // model
+    GtkTreeIter iter;
+
+    f = g_fopen (filename, "rt");
+    if (!f)
+    {
+        //gnc_error_dialog( 0, _("File %s cannot be opened."), filename );
+        return RESULT_OPEN_FAILED;
+    }
+
+    // compile the regular expression and check for errors
+    err = NULL;
+    regexpat =
+        g_regex_new (parser_regexp, G_REGEX_EXTENDED | G_REGEX_OPTIMIZE | G_REGEX_DUPNAMES, 0, &err);
+    if (err != NULL)
+    {
+        GtkWidget *dialog;
+        gchar *errmsg;
+
+        errmsg = g_strdup_printf (_("Error in regular expression '%s':\n%s"),
+                                  parser_regexp, err->message);
+        g_error_free (err);
+        err = NULL;
+
+        dialog = gtk_message_dialog_new (NULL,
+                                         GTK_DIALOG_MODAL,
+                                         GTK_MESSAGE_ERROR,
+                                         GTK_BUTTONS_OK, "%s", errmsg);
+        gtk_dialog_run (GTK_DIALOG (dialog));
+        gtk_widget_destroy (dialog);
+        g_free (errmsg);
+        errmsg = 0;
+
+        fclose (f);
+        return RESULT_ERROR_IN_REGEXP;
+    }
+
+    // start the import
+#define buffer_size 1000
+    line = g_malloc0 (buffer_size);
+    while (!feof (f))
+    {
+        int l;
+        row++;
+        if (row == max_rows)
+            break;
+        // read one line
+        if (!fgets (line, buffer_size, f))
+            break;			// eof
+        // now strip the '\n' from the end of the line
+        l = strlen (line);
+        if ((l > 0) && (line[l - 1] == '\n'))
+            line[l - 1] = 0;
+
+        // convert line from locale into utf8
+        line_utf8 = g_locale_to_utf8 (line, -1, NULL, NULL, NULL);
+
+        // parse the line
+        match_info = NULL;	// it seems, that in contrast to documentation, match_info is not always set -> g_match_info_free will segfault
+        if (g_regex_match (regexpat, line_utf8, 0, &match_info))
+        {
+            match_found = TRUE;
+            // fill in the values
+            gtk_list_store_append (store, &iter);
+            FILL_IN_HELPER ("type", TYPE);
+            FILL_IN_HELPER ("full_name", FULL_NAME);
+            FILL_IN_HELPER ("name", NAME);
+            FILL_IN_HELPER ("code", CODE);
+            FILL_IN_HELPER ("description", DESCRIPTION);
+            FILL_IN_HELPER ("color", COLOR);
+            FILL_IN_HELPER ("notes", NOTES);
+            FILL_IN_HELPER ("commoditym", COMMODITYM);
+            FILL_IN_HELPER ("commodityn", COMMODITYN);
+            FILL_IN_HELPER ("hidden", HIDDEN);
+            FILL_IN_HELPER ("tax", TAX);
+            FILL_IN_HELPER ("place_holder", PLACE_HOLDER);
+            gtk_list_store_set (store, &iter, ROW_COLOR, NULL, -1);
+        }
+
+        g_match_info_free (match_info);
+        match_info = 0;
+        g_free (line_utf8);
+        line_utf8 = 0;
+    }
+    g_free (line);
+    line = 0;
+
+    g_regex_unref (regexpat);
+    regexpat = 0;
+    fclose (f);
+    if (match_found == TRUE)
+        return MATCH_FOUND;
+    else
+        return RESULT_OK;
+}
+
+
+/*******************************************************
+ * csv_account_import
+ *
+ * Parse the liststore for account updates
+ *******************************************************/
+void
+csv_account_import (CsvImportInfo *info)
+{
+    QofBook       *book;
+    Account       *acc, *parent, *root;
+    gboolean       valid;
+    GdkColor       testcolor;
+    GtkTreeIter    iter;
+    gchar         *type, *full_name, *name, *code, *description, *color;
+    gchar         *notes, *commoditym, *commodityn, *hidden, *tax, *place_holder;
+    int            row;
+
+    ENTER("");
+    book = gnc_get_current_book();
+    root = gnc_book_get_root_account(book);
+
+    info->num_new = 0;
+    info->num_updates = 0;
+
+    /* Move to the first valid entry in store */
+    row = info->header_rows;
+    valid = gtk_tree_model_iter_nth_child(GTK_TREE_MODEL(info->store), &iter, NULL, row );
+    while (valid)
+    {
+        /* Walk through the list, reading each row */
+        gtk_tree_model_get (GTK_TREE_MODEL (info->store), &iter,
+                            TYPE, &type,
+                            FULL_NAME, &full_name,
+                            NAME, &name,
+                            CODE, &code,
+                            DESCRIPTION, &description,
+                            COLOR, &color,
+                            NOTES, &notes,
+                            COMMODITYM, &commoditym,
+                            COMMODITYN, &commodityn,
+                            HIDDEN, &hidden,
+                            TAX, &tax,
+                            PLACE_HOLDER, &place_holder, -1);
+
+        /* See if we can find the account by full name */
+        acc = gnc_account_lookup_by_full_name(root, full_name);
+
+        DEBUG("Row is %u and full name is %s", row, full_name);
+        if (acc == NULL)
+        {
+            /* Account does not exist, Lets try and add it */
+            if (g_strrstr(full_name, name) != NULL)
+            {
+                gint string_position;
+                gnc_commodity *commodity;
+                gnc_commodity_table *table;
+                gchar *full_parent;
+
+                /* Get full name of parent account, allow for separator */
+                string_position = strlen(full_name) - strlen(name) - 1;
+
+                if (string_position == -1)
+                    full_parent = g_strdup(full_name);
+                else
+                    full_parent = g_strndup(full_name, string_position);
+
+                parent = gnc_account_lookup_by_full_name(root, full_parent);
+                g_free (full_parent);
+
+                if (parent == NULL && string_position != -1)
+                {
+                    gchar *text = g_strdup_printf( gettext("Row %u, path to account %s not found, added as top level\n"), row + 1, name );
+                    info->error = g_strconcat(info->error, text, NULL);
+                    g_free(text);
+                    PINFO("Unable to import Row %u for account %s, path not found!", row, name);
+                }
+
+                if (parent == NULL)
+                    parent = root;
+
+                /* Do we have a valid commodity */
+                table = gnc_commodity_table_get_table (book);
+                commodity = gnc_commodity_table_lookup( table, commodityn, commoditym);
+
+                if (commodity)
+                {
+                    DEBUG("We have a valid commodity and will add account %s", full_name);
+                    info->num_new =  info->num_new + 1;
+                    gnc_suspend_gui_refresh ();
+                    acc = xaccMallocAccount (book);
+                    xaccAccountBeginEdit (acc);
+                    xaccAccountSetName (acc, name);
+                    xaccAccountSetType(acc, xaccAccountStringToEnum (type));
+
+                    if (!g_strcmp0(notes, "") == 0)
+                        xaccAccountSetNotes (acc, notes);
+                    if (!g_strcmp0(description, "") == 0)
+                        xaccAccountSetDescription (acc, description);
+                    if (!g_strcmp0(code, "") == 0)
+                        xaccAccountSetCode (acc, code);
+
+                    if (!g_strcmp0(color, "") == 0)
+                    {
+                        if (gdk_color_parse(color, &testcolor))
+                            xaccAccountSetColor (acc, color);
+                    }
+
+                    if (g_strcmp0(hidden, "T") == 0)
+                        xaccAccountSetHidden (acc, TRUE);
+                    if (g_strcmp0(place_holder, "T") == 0)
+                        xaccAccountSetPlaceholder (acc, TRUE);
+
+                    xaccAccountSetCommodity(acc, commodity);
+                    xaccAccountBeginEdit (parent);
+                    gnc_account_append_child (parent, acc);
+                    xaccAccountCommitEdit (parent);
+                    xaccAccountCommitEdit (acc);
+                    gnc_resume_gui_refresh ();
+                }
+                else
+                {
+                    gchar *err_string = g_strdup_printf( gettext("Row %u, commodity %s / %s not found\n"), row + 1,
+                                                         commoditym, commodityn);
+                    info->error = g_strconcat(info->error, err_string, NULL);
+                    g_free(err_string);
+                    PINFO("Unable to import Row %u for account %s, commodity!", row, full_name);
+                }
+            }
+            else
+            {
+                gchar *err_string = g_strdup_printf( gettext("Row %u, account %s not in %s\n"), row + 1, name, full_name);
+                info->error = g_strconcat(info->error, err_string, NULL);
+                g_free(err_string);
+                PINFO("Unable to import Row %u for account %s, name!", row, full_name);
+            }
+        }
+        else
+        {
+            /* Lets try and update the color, notes, description, code entries */
+            DEBUG("Existing account, will try and update account %s", full_name);
+            info->num_updates = info->num_updates + 1;
+            if (!g_strcmp0(color, "") == 0)
+            {
+                if (gdk_color_parse(color, &testcolor))
+                    xaccAccountSetColor (acc, color);
+            }
+
+            if (!g_strcmp0(notes, "") == 0)
+            {
+                /* Check for multiple lines */
+                gchar **parts;
+                parts = g_strsplit(notes, "\\n", -1);
+                notes = g_strjoinv("\n", parts);
+                g_strfreev(parts);
+            }
+            xaccAccountSetNotes (acc, notes);
+
+            if (!g_strcmp0(description, "") == 0)
+                xaccAccountSetDescription (acc, description);
+            if (!g_strcmp0(code, "") == 0)
+                xaccAccountSetCode (acc, code);
+        }
+        valid = gtk_tree_model_iter_next (GTK_TREE_MODEL (info->store), &iter);
+        row++;
+
+        /* free resources */
+        g_free (type);
+        g_free (full_name);
+        g_free (name);
+        g_free (code);
+        g_free (description);
+        g_free (color);
+        g_free (notes);
+        g_free (commoditym);
+        g_free (commodityn);
+        g_free (hidden);
+        g_free (tax);
+        g_free (place_holder);
+    }
+    LEAVE("");
+}

Copied: gnucash/trunk/src/import-export/csv-imp/csv-account-import.h (from rev 23566, gnucash/trunk/src/import-export/csv-import/csv-account-import.h)
===================================================================
--- gnucash/trunk/src/import-export/csv-imp/csv-account-import.h	                        (rev 0)
+++ gnucash/trunk/src/import-export/csv-imp/csv-account-import.h	2013-12-15 17:21:20 UTC (rev 23567)
@@ -0,0 +1,50 @@
+/*******************************************************************\
+ * csv-account-import.h -- Account importing from file              *
+ *                                                                  *
+ * Copyright (C) 2012 Robert Fewell                                 *
+ *                                                                  *
+ * Based on code from bi_import written by Sebastian Held  and      *
+ * Mike Evans.                                                      *
+ *                                                                  *
+ * This program is free software; you can redistribute it and/or    *
+ * modify it under the terms of the GNU General Public License as   *
+ * published by the Free Software Foundation; either version 2 of   *
+ * the License, or (at your option) any later version.              *
+ *                                                                  *
+ * This program is distributed in the hope that it will be useful,  *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of   *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the    *
+ * GNU General Public License for more details.                     *
+ *                                                                  *
+ * You should have received a copy of the GNU General Public License*
+ * along with this program; if not, contact:                        *
+ *                                                                  *
+ * Free Software Foundation           Voice:  +1-617-542-5942       *
+ * 51 Franklin Street, Fifth Floor    Fax:    +1-617-542-2652       *
+ * Boston, MA  02110-1301,  USA       gnu at gnu.org                   *
+\********************************************************************/
+
+#ifndef CSV_ACCOUNT_IMPORT_H
+#define CSV_ACCOUNT_IMPORT_H
+
+#include <glib.h>
+#include <gtk/gtk.h>
+
+#include "assistant-csv-account-import.h"
+
+enum _csv_import_result
+{
+    RESULT_OK,
+    RESULT_OPEN_FAILED,
+    RESULT_ERROR_IN_REGEXP,
+    MATCH_FOUND,
+};
+typedef enum _csv_import_result csv_import_result;
+
+csv_import_result
+csv_import_read_file (const gchar *filename, const gchar *parser_regexp, GtkListStore *store, guint max_rows );
+
+void csv_account_import(CsvImportInfo *info);
+
+#endif /* CSV_ACCOUNT_IMPORT_H */
+

Copied: gnucash/trunk/src/import-export/csv-imp/gnc-csv-gnumeric-popup.c (from rev 23566, gnucash/trunk/src/import-export/csv-import/gnc-csv-gnumeric-popup.c)
===================================================================
--- gnucash/trunk/src/import-export/csv-imp/gnc-csv-gnumeric-popup.c	                        (rev 0)
+++ gnucash/trunk/src/import-export/csv-imp/gnc-csv-gnumeric-popup.c	2013-12-15 17:21:20 UTC (rev 23567)
@@ -0,0 +1,195 @@
+/* The following is code copied from Gnumeric 1.7.8 licensed under the
+ * GNU General Public License version 2 and/or version 3. It is from the file
+ * gnumeric/src/gui-util.c, and it has been modified slightly to work
+ * within GnuCash. */
+
+/* Miguel de Icaza is not sure specifically who from the Gnumeric
+ * community is the copyright owner of the code below, so, on his
+ * recommendation, here is the full list of Gnumeric authors.
+ *
+ * Miguel de Icaza, creator.
+ * Jody Goldberg, maintainer.
+ * Harald Ashburner, Options pricers
+ * Sean Atkinson, functions and X-Base importing.
+ * Michel Berkelaar, Simplex algorithm for Solver (LP Solve).
+ * Jean Brefort, Core charting engine.
+ * Grandma Chema Celorio, Tester and sheet copy.
+ * Frank Chiulli, OLE support.
+ * Kenneth Christiansen, i18n, misc stuff.
+ * Zbigniew Chyla, plugin system, i18n.
+ * J.H.M. Dassen (Ray), debian packaging.
+ * Jeroen Dirks, Simplex algorithm for Solver (LP Solve).
+ * Tom Dyas, plugin support.
+ * Gergo Erdi, Gnumeric hacker.
+ * John Gotts, rpm packaging.
+ * Andreas J. Guelzow, Gnumeric hacker.
+ * Jon K. Hellan, Gnumeric hacker.
+ * Ross Ihaka, special functions.
+ * Jukka-Pekka Iivonen, numerous functions and tools.
+ * Jakub Jelinek, Gnumeric hacker.
+ * Chris Lahey, number format engine.
+ * Adrian Likins, documentation, debugging.
+ * Takashi Matsuda, original text plugin.
+ * Michael Meeks, Excel and OLE2 importing.
+ * Lutz Muller, SheetObject improvements.
+ * Emmanuel Pacaud, Many plot types for charting engine.
+ * Federico M. Quintero, canvas support.
+ * Mark Probst, Guile support.
+ * Rasca, HTML, troff, LaTeX exporters.
+ * Vincent Renardias, original CSV support, French localization.
+ * Ariel Rios, Guile support.
+ * Uwe Steinmann, Paradox Importer.
+ * Arturo Tena, OLE support.
+ * Almer S. Tigelaar, Gnumeric hacker.
+ * Bruno Unna, Excel bits.
+ * Daniel Veillard, XML support.
+ * Vladimir Vuksan, financial functions.
+ * Morten Welinder, Gnumeric hacker and leak plugging demi-god.
+ */
+
+#include "gnc-csv-gnumeric-popup.h"
+
+#include <glib/gi18n.h>
+
+static void
+popup_item_activate (GtkWidget *item, gpointer *user_data)
+{
+    GnumericPopupMenuElement const *elem =
+        g_object_get_data (G_OBJECT (item), "descriptor");
+    GnumericPopupMenuHandler handler =
+        g_object_get_data (G_OBJECT (item), "handler");
+
+    g_return_if_fail (elem != NULL);
+    g_return_if_fail (handler != NULL);
+
+    if (handler (elem, user_data))
+        gtk_widget_destroy (gtk_widget_get_toplevel (item));
+}
+
+static void
+gnumeric_create_popup_menu_list (GSList *elements,
+                                 GnumericPopupMenuHandler handler,
+                                 gpointer user_data,
+                                 int display_filter,
+                                 int sensitive_filter,
+                                 GdkEventButton *event)
+{
+    GtkWidget *menu, *item;
+    char const *trans;
+
+    menu = gtk_menu_new ();
+
+    for (; elements != NULL ; elements = elements->next)
+    {
+        GnumericPopupMenuElement const *element = elements->data;
+        char const * const name = element->name;
+        char const * const pix_name = element->pixmap;
+
+        item = NULL;
+
+        if (element->display_filter != 0 &&
+                !(element->display_filter & display_filter))
+            continue;
+
+        if (name != NULL && *name != '\0')
+        {
+            trans = _(name);
+            item = gtk_image_menu_item_new_with_mnemonic (trans);
+            if (element->sensitive_filter != 0 &&
+                    (element->sensitive_filter & sensitive_filter))
+                gtk_widget_set_sensitive (GTK_WIDGET (item), FALSE);
+            if (pix_name != NULL)
+            {
+                GtkWidget *image = gtk_image_new_from_stock (pix_name,
+                                   GTK_ICON_SIZE_MENU);
+                gtk_widget_show (image);
+                gtk_image_menu_item_set_image (
+                    GTK_IMAGE_MENU_ITEM (item),
+                    image);
+            }
+        }
+        else
+        {
+            /* separator */
+            item = gtk_menu_item_new ();
+            gtk_widget_set_sensitive (item, FALSE);
+        }
+
+        if (element->index != 0)
+        {
+            g_signal_connect (G_OBJECT (item),
+                              "activate",
+                              G_CALLBACK (&popup_item_activate), user_data);
+            g_object_set_data (
+                G_OBJECT (item), "descriptor", (gpointer)(element));
+            g_object_set_data (
+                G_OBJECT (item), "handler", (gpointer)handler);
+        }
+
+        gtk_widget_show (item);
+        gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);
+    }
+
+    gnumeric_popup_menu (GTK_MENU (menu), event);
+}
+
+void
+gnumeric_create_popup_menu (GnumericPopupMenuElement const *elements,
+                            GnumericPopupMenuHandler handler,
+                            gpointer user_data,
+                            int display_filter, int sensitive_filter,
+                            GdkEventButton *event)
+{
+    int i;
+    GSList *tmp = NULL;
+
+    for (i = 0; elements [i].name != NULL; i++)
+        tmp = g_slist_prepend (tmp, (gpointer)(elements + i));
+
+    tmp = g_slist_reverse (tmp);
+    gnumeric_create_popup_menu_list (tmp, handler, user_data,
+                                     display_filter, sensitive_filter, event);
+    g_slist_free (tmp);
+}
+
+static void
+kill_popup_menu (GtkWidget *widget, GtkMenu *menu)
+{
+    g_return_if_fail (menu != NULL);
+    g_return_if_fail (GTK_IS_MENU (menu));
+
+    g_object_unref (G_OBJECT (menu));
+}
+
+/**
+ * gnumeric_popup_menu :
+ * @menu : #GtkMenu
+ * @event : #GdkEventButton optionally NULL
+ *
+ * Bring up a popup and if @event is non-NULL ensure that the popup is on the
+ * right screen.
+ **/
+void
+gnumeric_popup_menu (GtkMenu *menu, GdkEventButton *event)
+{
+    g_return_if_fail (menu != NULL);
+    g_return_if_fail (GTK_IS_MENU (menu));
+
+    g_object_ref_sink (menu);
+
+    if (event)
+        gtk_menu_set_screen (menu,
+                             gdk_drawable_get_screen (event->window));
+
+    g_signal_connect (G_OBJECT (menu),
+                      "hide",
+                      G_CALLBACK (kill_popup_menu), menu);
+
+    /* Do NOT pass the button used to create the menu.
+     * instead pass 0.  Otherwise bringing up a menu with
+     * the right button will disable clicking on the menu with the left.
+     */
+    gtk_menu_popup (menu, NULL, NULL, NULL, NULL, 0,
+                    (event != NULL) ? event->time
+                    : gtk_get_current_event_time());
+}

Copied: gnucash/trunk/src/import-export/csv-imp/gnc-csv-gnumeric-popup.h (from rev 23566, gnucash/trunk/src/import-export/csv-import/gnc-csv-gnumeric-popup.h)
===================================================================
--- gnucash/trunk/src/import-export/csv-imp/gnc-csv-gnumeric-popup.h	                        (rev 0)
+++ gnucash/trunk/src/import-export/csv-imp/gnc-csv-gnumeric-popup.h	2013-12-15 17:21:20 UTC (rev 23567)
@@ -0,0 +1,79 @@
+/* The following is code copied from Gnumeric 1.7.8 licensed under the
+ * GNU General Public License version 2 and/or version 3. It is from the file
+ * gnumeric/src/gui-util.h, and it has been modified slightly to work
+ * within GnuCash. */
+
+/* Miguel de Icaza is not sure specifically who from the Gnumeric
+ * community is the copyright owner of the code below, so, on his
+ * recommendation, here is the full list of Gnumeric authors.
+ *
+ * Miguel de Icaza, creator.
+ * Jody Goldberg, maintainer.
+ * Harald Ashburner, Options pricers
+ * Sean Atkinson, functions and X-Base importing.
+ * Michel Berkelaar, Simplex algorithm for Solver (LP Solve).
+ * Jean Brefort, Core charting engine.
+ * Grandma Chema Celorio, Tester and sheet copy.
+ * Frank Chiulli, OLE support.
+ * Kenneth Christiansen, i18n, misc stuff.
+ * Zbigniew Chyla, plugin system, i18n.
+ * J.H.M. Dassen (Ray), debian packaging.
+ * Jeroen Dirks, Simplex algorithm for Solver (LP Solve).
+ * Tom Dyas, plugin support.
+ * Gergo Erdi, Gnumeric hacker.
+ * John Gotts, rpm packaging.
+ * Andreas J. Guelzow, Gnumeric hacker.
+ * Jon K. Hellan, Gnumeric hacker.
+ * Ross Ihaka, special functions.
+ * Jukka-Pekka Iivonen, numerous functions and tools.
+ * Jakub Jelinek, Gnumeric hacker.
+ * Chris Lahey, number format engine.
+ * Adrian Likins, documentation, debugging.
+ * Takashi Matsuda, original text plugin.
+ * Michael Meeks, Excel and OLE2 importing.
+ * Lutz Muller, SheetObject improvements.
+ * Emmanuel Pacaud, Many plot types for charting engine.
+ * Federico M. Quintero, canvas support.
+ * Mark Probst, Guile support.
+ * Rasca, HTML, troff, LaTeX exporters.
+ * Vincent Renardias, original CSV support, French localization.
+ * Ariel Rios, Guile support.
+ * Uwe Steinmann, Paradox Importer.
+ * Arturo Tena, OLE support.
+ * Almer S. Tigelaar, Gnumeric hacker.
+ * Bruno Unna, Excel bits.
+ * Daniel Veillard, XML support.
+ * Vladimir Vuksan, financial functions.
+ * Morten Welinder, Gnumeric hacker and leak plugging demi-god.
+ */
+
+#ifndef GNC_CSV_GNUMERIC_POPUP
+#define GNC_CSV_GNUMERIC_POPUP
+
+#include <gtk/gtk.h>
+
+typedef struct
+{
+    char const *name;
+    char const *pixmap;
+    int display_filter;
+    int sensitive_filter;
+
+    int index;
+} GnumericPopupMenuElement;
+
+typedef gboolean (*GnumericPopupMenuHandler) (GnumericPopupMenuElement const *e,
+        gpointer user_data);
+
+/* Use this on menus that are popped up */
+void gnumeric_popup_menu (GtkMenu *menu, GdkEventButton *event);
+
+void gnumeric_create_popup_menu (GnumericPopupMenuElement const *elements,
+                                 GnumericPopupMenuHandler handler,
+                                 gpointer user_data,
+                                 int display_filter,
+                                 int sensitive_filter,
+                                 GdkEventButton *event);
+
+
+#endif

Copied: gnucash/trunk/src/import-export/csv-imp/gnc-csv-model.c (from rev 23566, gnucash/trunk/src/import-export/csv-import/gnc-csv-model.c)
===================================================================
--- gnucash/trunk/src/import-export/csv-imp/gnc-csv-model.c	                        (rev 0)
+++ gnucash/trunk/src/import-export/csv-imp/gnc-csv-model.c	2013-12-15 17:21:20 UTC (rev 23567)
@@ -0,0 +1,1268 @@
+#include "gnc-csv-model.h"
+
+
+#include <glib/gi18n.h>
+
+#include <goffice/goffice-features.h>
+#if (GO_VERSION_EPOCH == 0) && (GO_VERSION_MAJOR == 7) && (GO_VERSION_MINOR == 8)
+/* For libgoffice-0.7.8, disable its internal inclusion of <regutf8.h>
+   so to avoid clashing symbol definitions with <regex.h> */
+# define GO_REGUTF8_H
+#endif
+#include <goffice/utils/go-glib-extras.h>
+
+#include "gnc-ui-util.h"
+#include "engine-helpers.h"
+
+#include <string.h>
+
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <regex.h>
+#include <unistd.h>
+#include <fcntl.h>
+#include <stdlib.h>
+#include <math.h>
+
+G_GNUC_UNUSED static QofLogModule log_module = GNC_MOD_IMPORT;
+
+const int num_date_formats = 5;
+const gchar* date_format_user[] = {N_("y-m-d"),
+                                   N_("d-m-y"),
+                                   N_("m-d-y"),
+                                   N_("d-m"),
+                                   N_("m-d")
+                                  };
+
+const int num_currency_formats = 3;
+const gchar* currency_format_user[] = {N_("Locale"),
+                                       N_("Period: 123,456.78"),
+                                       N_("Comma: 123.456,78")
+                                      };
+
+/* This array contains all of the different strings for different column types. */
+gchar* gnc_csv_column_type_strs[GNC_CSV_NUM_COL_TYPES] = {N_("None"),
+                                                          N_("Date"),
+                                                          N_("Num"),
+                                                          N_("Description"),
+                                                          N_("Notes"),
+                                                          N_("Account"),
+                                                          N_("Deposit"),
+                                                          N_("Withdrawal"),
+                                                          N_("Balance")
+                                                         };
+
+/** A set of sensible defaults for parsing CSV files.
+ * @return StfParseOptions_t* for parsing a file with comma separators
+ */
+static StfParseOptions_t* default_parse_options(void)
+{
+    StfParseOptions_t* options = stf_parse_options_new();
+    stf_parse_options_set_type(options, PARSE_TYPE_CSV);
+    stf_parse_options_csv_set_separators(options, ",", NULL);
+    return options;
+}
+
+/** Parses a string into a date, given a format. The format must
+ * include the year. This function should only be called by
+ * parse_date.
+ * @param date_str The string containing a date being parsed
+ * @param format An index specifying a format in date_format_user
+ * @return The parsed value of date_str on success or -1 on failure
+ */
+static time64 parse_date_with_year(const char* date_str, int format)
+{
+    time64 rawtime; /* The integer time */
+    struct tm retvalue, test_retvalue; /* The time in a broken-down structure */
+
+    int i, j, mem_length, orig_year = -1, orig_month = -1, orig_day = -1;
+
+    /* Buffer for containing individual parts (e.g. year, month, day) of a date */
+    char date_segment[5];
+
+    /* The compiled regular expression */
+    regex_t preg = {0};
+
+    /* An array containing indices specifying the matched substrings in date_str */
+    regmatch_t pmatch[4] = { {0}, {0}, {0}, {0} };
+
+    /* The regular expression for parsing dates */
+    const char* regex = "^ *([0-9]+) *[-/.'] *([0-9]+) *[-/.'] *([0-9]+).*$|^ *([0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]).*$";
+
+    /* We get our matches using the regular expression. */
+    regcomp(&preg, regex, REG_EXTENDED);
+    regexec(&preg, date_str, 4, pmatch, 0);
+    regfree(&preg);
+
+    /* If there wasn't a match, there was an error. */
+    if (pmatch[0].rm_eo == 0)
+        return -1;
+
+    /* If this is a string without separators ... */
+    if (pmatch[1].rm_so == -1)
+    {
+        /* ... we will fill in the indices based on the user's selection. */
+        int k = 0; /* k traverses date_str by keeping track of where separators "should" be. */
+        j = 1; /* j traverses pmatch. */
+        for (i = 0; date_format_user[format][i]; i++)
+        {
+            char segment_type = date_format_user[format][i];
+            /* Only do something if this is a meaningful character */
+            if (segment_type == 'y' || segment_type == 'm' || segment_type == 'd')
+            {
+                pmatch[j].rm_so = k;
+                switch (segment_type)
+                {
+                case 'm':
+                case 'd':
+                    k += 2;
+                    break;
+
+                case 'y':
+                    k += 4;
+                    break;
+                }
+
+                pmatch[j].rm_eo = k;
+                j++;
+            }
+        }
+    }
+
+    /* Put some sane values in retvalue by using the current time for
+     * the non-year-month-day parts of the date. */
+    gnc_time (&rawtime);
+    gnc_localtime_r (&rawtime, &retvalue);
+
+    /* j traverses pmatch (index 0 contains the entire string, so we
+     * start at index 1 for the first meaningful match). */
+    j = 1;
+    /* Go through the date format and interpret the matches in order of
+     * the sections in the date format. */
+    for (i = 0; date_format_user[format][i]; i++)
+    {
+        char segment_type = date_format_user[format][i];
+        /* Only do something if this is a meaningful character */
+        if (segment_type == 'y' || segment_type == 'm' || segment_type == 'd')
+        {
+            /* Copy the matching substring into date_segment so that we can
+             * convert it into an integer. */
+            mem_length = pmatch[j].rm_eo - pmatch[j].rm_so;
+            memcpy(date_segment, date_str + pmatch[j].rm_so, mem_length);
+            date_segment[mem_length] = '\0';
+
+            /* Set the appropriate member of retvalue. Save the original
+             * values so that we can check if the change when we use gnc_mktime
+             * below. */
+            switch (segment_type)
+            {
+            case 'y':
+                retvalue.tm_year = atoi(date_segment);
+
+                /* Handle two-digit years. */
+                if (retvalue.tm_year < 100)
+                {
+                    /* We allow two-digit years in the range 1969 - 2068. */
+                    if (retvalue.tm_year < 69)
+                        retvalue.tm_year += 100;
+                }
+                else
+                    retvalue.tm_year -= 1900;
+                orig_year = retvalue.tm_year;
+                break;
+
+            case 'm':
+                orig_month = retvalue.tm_mon = atoi(date_segment) - 1;
+                break;
+
+            case 'd':
+                orig_day = retvalue.tm_mday = atoi(date_segment);
+                break;
+            }
+            j++;
+        }
+    }
+    /* Convert back to an integer. If gnc_mktime leaves retvalue unchanged,
+     * everything is okay; otherwise, an error has occurred. */
+    /* We have to use a "test" date value to account for changes in
+     * daylight savings time, which can cause a date change with gnc_mktime
+     * near midnight, causing the code to incorrectly think a date is
+     * incorrect. */
+    test_retvalue = retvalue;
+    gnc_mktime (&test_retvalue);
+    retvalue.tm_isdst = test_retvalue.tm_isdst;
+    rawtime = gnc_mktime (&retvalue);
+    if (retvalue.tm_mday == orig_day &&
+            retvalue.tm_mon == orig_month &&
+            retvalue.tm_year == orig_year)
+    {
+        return rawtime;
+    }
+    else
+    {
+        return -1;
+    }
+}
+
+/** Parses a string into a date, given a format. The format cannot
+ * include the year. This function should only be called by
+ * parse_date.
+ * @param date_str The string containing a date being parsed
+ * @param format An index specifying a format in date_format_user
+ * @return The parsed value of date_str on success or -1 on failure
+ */
+static time64 parse_date_without_year(const char* date_str, int format)
+{
+    time64 rawtime; /* The integer time */
+    struct tm retvalue, test_retvalue; /* The time in a broken-down structure */
+
+    int i, j, mem_length, orig_year = -1, orig_month = -1, orig_day = -1;
+
+    /* Buffer for containing individual parts (e.g. year, month, day) of a date */
+    gchar* date_segment;
+
+    /* The compiled regular expression */
+    regex_t preg = {0};
+
+    /* An array containing indices specifying the matched substrings in date_str */
+    regmatch_t pmatch[3] = { {0}, {0}, {0} };
+
+    /* The regular expression for parsing dates */
+    const char* regex = "^ *([0-9]+) *[-/.'] *([0-9]+).*$";
+
+    /* We get our matches using the regular expression. */
+    regcomp(&preg, regex, REG_EXTENDED);
+    regexec(&preg, date_str, 3, pmatch, 0);
+    regfree(&preg);
+
+    /* If there wasn't a match, there was an error. */
+    if (pmatch[0].rm_eo == 0)
+        return -1;
+
+    /* Put some sane values in retvalue by using the current time for
+     * the non-year-month-day parts of the date. */
+    gnc_time (&rawtime);
+    gnc_localtime_r (&rawtime, &retvalue);
+    orig_year = retvalue.tm_year;
+
+    /* j traverses pmatch (index 0 contains the entire string, so we
+     * start at index 1 for the first meaningful match). */
+    j = 1;
+    /* Go through the date format and interpret the matches in order of
+     * the sections in the date format. */
+    for (i = 0; date_format_user[format][i]; i++)
+    {
+        char segment_type = date_format_user[format][i];
+        /* Only do something if this is a meaningful character */
+        if (segment_type == 'm' || segment_type == 'd')
+        {
+            /* Copy the matching substring into date_segment so that we can
+             * convert it into an integer. */
+            mem_length = pmatch[j].rm_eo - pmatch[j].rm_so;
+            date_segment = g_new(gchar, mem_length);
+            memcpy(date_segment, date_str + pmatch[j].rm_so, mem_length);
+            date_segment[mem_length] = '\0';
+
+            /* Set the appropriate member of retvalue. Save the original
+             * values so that we can check if the change when we use gnc_mktime
+             * below. */
+            switch (segment_type)
+            {
+            case 'm':
+                orig_month = retvalue.tm_mon = atoi(date_segment) - 1;
+                break;
+
+            case 'd':
+                orig_day = retvalue.tm_mday = atoi(date_segment);
+                break;
+            }
+            g_free(date_segment);
+            j++;
+        }
+    }
+    /* Convert back to an integer. If gnc_mktime leaves retvalue unchanged,
+     * everything is okay; otherwise, an error has occurred. */
+    /* We have to use a "test" date value to account for changes in
+     * daylight savings time, which can cause a date change with gnc_mktime
+     * near midnight, causing the code to incorrectly think a date is
+     * incorrect. */
+    test_retvalue = retvalue;
+    gnc_mktime (&test_retvalue);
+    retvalue.tm_isdst = test_retvalue.tm_isdst;
+    rawtime = gnc_mktime (&retvalue);
+    if (retvalue.tm_mday == orig_day &&
+            retvalue.tm_mon == orig_month &&
+            retvalue.tm_year == orig_year)
+    {
+        return rawtime;
+    }
+    else
+    {
+        return -1;
+    }
+}
+
+/** Parses a string into a date, given a format. This function
+ * requires only knowing the order in which the year, month and day
+ * appear. For example, 01-02-2003 will be parsed the same way as
+ * 01/02/2003.
+ * @param date_str The string containing a date being parsed
+ * @param format An index specifying a format in date_format_user
+ * @return The parsed value of date_str on success or -1 on failure
+ */
+time64 parse_date(const char* date_str, int format)
+{
+    if (strchr(date_format_user[format], 'y'))
+        return parse_date_with_year(date_str, format);
+    else
+        return parse_date_without_year(date_str, format);
+}
+
+/** Constructor for GncCsvParseData.
+ * @return Pointer to a new GncCSvParseData
+ */
+GncCsvParseData* gnc_csv_new_parse_data(void)
+{
+    GncCsvParseData* parse_data = g_new(GncCsvParseData, 1);
+    parse_data->encoding = "UTF-8";
+    /* All of the data pointers are initially NULL. This is so that, if
+     * gnc_csv_parse_data_free is called before all of the data is
+     * initialized, only the data that needs to be freed is freed. */
+    parse_data->raw_str.begin = parse_data->raw_str.end
+                                = parse_data->file_str.begin = parse_data->file_str.end = NULL;
+    parse_data->orig_lines = NULL;
+    parse_data->orig_row_lengths = NULL;
+    parse_data->column_types = NULL;
+    parse_data->error_lines = parse_data->transactions = NULL;
+    parse_data->options = default_parse_options();
+    parse_data->date_format = -1;
+    parse_data->currency_format = 0;
+    parse_data->chunk = g_string_chunk_new(100 * 1024);
+    parse_data->start_row = 0;
+    parse_data->end_row = 1000;
+    return parse_data;
+}
+
+/** Destructor for GncCsvParseData.
+ * @param parse_data Parse data whose memory will be freed
+ */
+void gnc_csv_parse_data_free(GncCsvParseData* parse_data)
+{
+    /* All non-NULL pointers have been initialized and must be freed. */
+
+    if (parse_data->raw_mapping != NULL)
+    {
+        g_mapped_file_unref(parse_data->raw_mapping);
+    }
+
+    if (parse_data->file_str.begin != NULL)
+        g_free(parse_data->file_str.begin);
+
+    if (parse_data->orig_lines != NULL)
+        stf_parse_general_free(parse_data->orig_lines);
+
+    if (parse_data->orig_row_lengths != NULL)
+        g_array_free(parse_data->orig_row_lengths, FALSE);
+
+    if (parse_data->options != NULL)
+        stf_parse_options_free(parse_data->options);
+
+    if (parse_data->column_types != NULL)
+        g_array_free(parse_data->column_types, TRUE);
+
+    if (parse_data->error_lines != NULL)
+        g_list_free(parse_data->error_lines);
+
+    if (parse_data->transactions != NULL)
+    {
+        GList* transactions = parse_data->transactions;
+        /* We have to free the GncCsvTransLine's that are at each node in
+         * the list before freeing the entire list. */
+        do
+        {
+            g_free(transactions->data);
+            transactions = g_list_next(transactions);
+        }
+        while (transactions != NULL);
+        g_list_free(parse_data->transactions);
+    }
+
+    g_free(parse_data->chunk);
+    g_free(parse_data);
+}
+
+/** Converts raw file data using a new encoding. This function must be
+ * called after gnc_csv_load_file only if gnc_csv_load_file guessed
+ * the wrong encoding.
+ * @param parse_data Data that is being parsed
+ * @param encoding Encoding that data should be translated using
+ * @param error Will point to an error on failure
+ * @return 0 on success, 1 on failure
+ */
+int gnc_csv_convert_encoding(GncCsvParseData* parse_data, const char* encoding,
+                             GError** error)
+{
+    gsize bytes_read, bytes_written;
+
+    /* If parse_data->file_str has already been initialized it must be
+     * freed first. (This should always be the case, since
+     * gnc_csv_load_file should always be called before this
+     * function.) */
+    if (parse_data->file_str.begin != NULL)
+        g_free(parse_data->file_str.begin);
+
+    /* Do the actual translation to UTF-8. */
+    parse_data->file_str.begin = g_convert(parse_data->raw_str.begin,
+                                           parse_data->raw_str.end - parse_data->raw_str.begin,
+                                           "UTF-8", encoding, &bytes_read, &bytes_written,
+                                           error);
+    /* Handle errors that occur. */
+    if (parse_data->file_str.begin == NULL)
+        return 1;
+
+    /* On success, save the ending pointer of the translated data and
+     * the encoding type and return 0. */
+    parse_data->file_str.end = parse_data->file_str.begin + bytes_written;
+    parse_data->encoding = (gchar*)encoding;
+    return 0;
+}
+
+/** Loads a file into a GncCsvParseData. This is the first function
+ * that must be called after createing a new GncCsvParseData. If this
+ * fails because the file couldn't be opened, no more functions can be
+ * called on the parse data until this succeeds (or until it fails
+ * because of an encoding guess error). If it fails because the
+ * encoding could not be guessed, gnc_csv_convert_encoding must be
+ * called until it succeeds.
+ * @param parse_data Data that is being parsed
+ * @param filename Name of the file that should be opened
+ * @param error Will contain an error if there is a failure
+ * @return 0 on success, 1 on failure
+ */
+int gnc_csv_load_file(GncCsvParseData* parse_data, const char* filename,
+                      GError** error)
+{
+    const char* guess_enc = NULL;
+
+    /* Get the raw data first and handle an error if one occurs. */
+    parse_data->raw_mapping = g_mapped_file_new(filename, FALSE, error);
+    if (parse_data->raw_mapping == NULL)
+    {
+        /* TODO Handle file opening errors more specifically,
+         * e.g. inexistent file versus no read permission. */
+        parse_data->raw_str.begin = NULL;
+        g_clear_error (error);
+        g_set_error(error, 0, GNC_CSV_FILE_OPEN_ERR, "%s", _("File opening failed."));
+        return 1;
+    }
+
+    /* Copy the mapping's contents into parse-data->raw_str. */
+    parse_data->raw_str.begin = g_mapped_file_get_contents(parse_data->raw_mapping);
+    parse_data->raw_str.end = parse_data->raw_str.begin + g_mapped_file_get_length(parse_data->raw_mapping);
+
+    /* Make a guess at the encoding of the data. */
+    if (!g_mapped_file_get_length(parse_data->raw_mapping) == 0)
+        guess_enc = go_guess_encoding((const char*)(parse_data->raw_str.begin),
+                                      (size_t)(parse_data->raw_str.end - parse_data->raw_str.begin),
+                                      "UTF-8", NULL);
+    if (guess_enc == NULL)
+    {
+        g_set_error(error, 0, GNC_CSV_ENCODING_ERR, "%s", _("Unknown encoding."));
+        return 1;
+    }
+    /* Convert using the guessed encoding into parse_data->file_str and
+     * handle any errors that occur. */
+    gnc_csv_convert_encoding(parse_data, guess_enc, error);
+    if (parse_data->file_str.begin == NULL)
+    {
+        g_set_error(error, 0, GNC_CSV_ENCODING_ERR, "%s", _("Unknown encoding."));
+        return 1;
+    }
+    else
+        return 0;
+}
+
+/** Parses a file into cells. This requires having an encoding that
+ * works (see gnc_csv_convert_encoding). parse_data->options should be
+ * set according to how the user wants before calling this
+ * function. (Note: this function must be called with guessColTypes as
+ * TRUE before it is ever called with it as FALSE.) (Note: if
+ * guessColTypes is TRUE, all the column types will be GNC_CSV_NONE
+ * right now.)
+ * @param parse_data Data that is being parsed
+ * @param guessColTypes TRUE to guess what the types of columns are based on the cell contents
+ * @param error Will contain an error if there is a failure
+ * @return 0 on success, 1 on failure
+ */
+int gnc_csv_parse(GncCsvParseData* parse_data, gboolean guessColTypes, GError** error)
+{
+    /* max_cols is the number of columns in the row with the most columns. */
+    int i, max_cols = 0;
+
+    if (parse_data->orig_lines != NULL)
+    {
+        stf_parse_general_free(parse_data->orig_lines);
+    }
+
+    /* If everything is fine ... */
+    if (parse_data->file_str.begin != NULL)
+    {
+        /* Do the actual parsing. */
+        parse_data->orig_lines = stf_parse_general(parse_data->options, parse_data->chunk,
+                                 parse_data->file_str.begin,
+                                 parse_data->file_str.end);
+    }
+    /* If we couldn't get the encoding right, we just want an empty array. */
+    else
+    {
+        parse_data->orig_lines = g_ptr_array_new();
+    }
+
+    /* Record the original row lengths of parse_data->orig_lines. */
+    if (parse_data->orig_row_lengths != NULL)
+        g_array_free(parse_data->orig_row_lengths, FALSE);
+
+    parse_data->orig_row_lengths =
+        g_array_sized_new(FALSE, FALSE, sizeof(int), parse_data->orig_lines->len);
+
+    g_array_set_size(parse_data->orig_row_lengths, parse_data->orig_lines->len);
+    parse_data->orig_max_row = 0;
+    for (i = 0; i < parse_data->orig_lines->len; i++)
+    {
+        int length = ((GPtrArray*)parse_data->orig_lines->pdata[i])->len;
+        parse_data->orig_row_lengths->data[i] = length;
+        if (length > parse_data->orig_max_row)
+            parse_data->orig_max_row = length;
+    }
+
+    /* If it failed, generate an error. */
+    if (parse_data->orig_lines == NULL)
+    {
+        g_set_error(error, 0, 0, "Parsing failed.");
+        return 1;
+    }
+
+    /* Now that we have data, let's set max_cols. */
+    for (i = 0; i < parse_data->orig_lines->len; i++)
+    {
+        if (max_cols < ((GPtrArray*)(parse_data->orig_lines->pdata[i]))->len)
+            max_cols = ((GPtrArray*)(parse_data->orig_lines->pdata[i]))->len;
+    }
+
+    if (guessColTypes)
+    {
+        /* Free parse_data->column_types if it's already been created. */
+        if (parse_data->column_types != NULL)
+            g_array_free(parse_data->column_types, TRUE);
+
+        /* Create parse_data->column_types and fill it with guesses based
+         * on the contents of each column. */
+        parse_data->column_types = g_array_sized_new(FALSE, FALSE, sizeof(int),
+                                   max_cols);
+        g_array_set_size(parse_data->column_types, max_cols);
+        /* TODO Make it actually guess. */
+        for (i = 0; i < parse_data->column_types->len; i++)
+        {
+            parse_data->column_types->data[i] = GNC_CSV_NONE;
+        }
+    }
+    else
+    {
+        /* If we don't need to guess column types, we will simply set any
+         * new columns that are created that didn't exist before to "None"
+         * since we don't want gibberish to appear. Note:
+         * parse_data->column_types should have already been
+         * initialized, so we don't check for it being NULL. */
+        int i = parse_data->column_types->len;
+        g_array_set_size(parse_data->column_types, max_cols);
+        for (; i < parse_data->column_types->len; i++)
+        {
+            parse_data->column_types->data[i] = GNC_CSV_NONE;
+        }
+    }
+
+    return 0;
+}
+
+/** A struct containing TransProperties that all describe a single transaction. */
+typedef struct
+{
+    int date_format; /**< The format for parsing dates */
+    int currency_format; /**< The format for currency */
+    Account* account; /**< The account the transaction belongs to */
+    GList* properties; /**< List of TransProperties */
+} TransPropertyList;
+
+/** A struct encapsulating a property of a transaction. */
+typedef struct
+{
+    int type; /**< A value from the GncCsvColumnType enum except
+             * GNC_CSV_NONE and GNC_CSV_NUM_COL_TYPES */
+    void* value; /**< Pointer to the data that will be used to configure a transaction */
+    TransPropertyList* list; /**< The list the property belongs to */
+} TransProperty;
+
+/** Constructor for TransProperty.
+ * @param type The type of the new property (see TransProperty.type for possible values)
+ */
+static TransProperty* trans_property_new(int type, TransPropertyList* list)
+{
+    TransProperty* prop = g_new(TransProperty, 1);
+    prop->type = type;
+    prop->list = list;
+    prop->value = NULL;
+    return prop;
+}
+
+/** Destructor for TransProperty.
+ * @param prop The property to be freed
+ */
+static void trans_property_free(TransProperty* prop)
+{
+    switch (prop->type)
+    {
+        /* The types for "Date" and "Balance" (time64 and gnc_numeric,
+         * respectively) are typically not pointed to, we have to free
+         * them, unlike types like char* ("Description"). */
+    case GNC_CSV_DATE:
+    case GNC_CSV_BALANCE:
+    case GNC_CSV_DEPOSIT:
+    case GNC_CSV_WITHDRAWAL:
+        if (prop->value != NULL)
+            g_free(prop->value);
+        break;
+    }
+    g_free(prop);
+}
+
+/** Sets the value of the property by parsing str. Note: this should
+ * only be called once on an instance of TransProperty, as calling it
+ * more than once can cause memory leaks.
+ * @param prop The property being set
+ * @param str The string to be parsed
+ * @return TRUE on success, FALSE on failure
+ */
+static gboolean trans_property_set(TransProperty* prop, char* str)
+{
+    char *endptr, *possible_currency_symbol, *str_dupe;
+    gnc_numeric val;
+    switch (prop->type)
+    {
+    case GNC_CSV_DATE:
+        prop->value = g_new(time64, 1);
+        *((time64*)(prop->value)) = parse_date(str, prop->list->date_format);
+        return *((time64*)(prop->value)) != -1;
+
+    case GNC_CSV_DESCRIPTION:
+    case GNC_CSV_NOTES:
+    case GNC_CSV_NUM:
+        prop->value = g_strdup(str);
+        return TRUE;
+
+    case GNC_CSV_BALANCE:
+    case GNC_CSV_DEPOSIT:
+    case GNC_CSV_WITHDRAWAL:
+        str_dupe = g_strdup(str); /* First, we make a copy so we can't mess up real data. */
+
+        /* Go through str_dupe looking for currency symbols. */
+        for (possible_currency_symbol = str_dupe; *possible_currency_symbol;
+                possible_currency_symbol = g_utf8_next_char(possible_currency_symbol))
+        {
+            if (g_unichar_type(g_utf8_get_char(possible_currency_symbol)) == G_UNICODE_CURRENCY_SYMBOL)
+            {
+                /* If we find a currency symbol, save the position just ahead
+                 * of the currency symbol (next_symbol), and find the null
+                 * terminator of the string (last_symbol). */
+                char *next_symbol = g_utf8_next_char(possible_currency_symbol), *last_symbol = next_symbol;
+                while (*last_symbol)
+                    last_symbol = g_utf8_next_char(last_symbol);
+
+                /* Move all of the string (including the null byte, which is
+                 * why we have +1 in the size parameter) following the
+                 * currency symbol back one character, thereby overwriting the
+                 * currency symbol. */
+                memmove(possible_currency_symbol, next_symbol, last_symbol - next_symbol + 1);
+                break;
+            }
+        }
+
+        /* Currency format */
+        switch (prop->list->currency_format)
+        {
+        case 0:
+            /* Currancy locale */
+            if (!(xaccParseAmount(str_dupe, TRUE, &val, &endptr)))
+            {
+                g_free(str_dupe);
+                return FALSE;
+            }
+            break;
+        case 1:
+            /* Currancy decimal period */
+            if (!(xaccParseAmountExtended(str_dupe, TRUE, '-', '.', ',', "\003\003", "$+", &val, &endptr)))
+            {
+                g_free(str_dupe);
+                return FALSE;
+            }
+            break;
+        case 2:
+            /* Currancy decimal comma */
+            if (!(xaccParseAmountExtended(str_dupe, TRUE, '-', ',', '.', "\003\003", "$+", &val, &endptr)))
+            {
+                g_free(str_dupe);
+                return FALSE;
+            }
+            break;
+        }
+
+        prop->value = g_new(gnc_numeric, 1);
+        *((gnc_numeric*)(prop->value)) = val;
+        g_free(str_dupe);
+        return TRUE;
+
+    }
+    return FALSE; /* We should never actually get here. */
+}
+
+/** Constructor for TransPropertyList.
+ * @param account The account with which transactions should be built
+ * @param date_format An index from date_format_user for how date properties should be parsed
+ * @return A pointer to a new TransPropertyList
+ */
+static TransPropertyList* trans_property_list_new(Account* account, int date_format, int currency_format)
+{
+    TransPropertyList* list = g_new(TransPropertyList, 1);
+    list->account = account;
+    list->date_format = date_format;
+    list->currency_format = currency_format;
+    list->properties = NULL;
+    return list;
+}
+
+/** Destructor for TransPropertyList.
+ * @param list The list to be freed
+ */
+static void trans_property_list_free(TransPropertyList* list)
+{
+    /* Free all of the properties in this list before freeeing the list itself. */
+    GList* properties_begin = list->properties;
+    while (list->properties != NULL)
+    {
+        trans_property_free((TransProperty*)(list->properties->data));
+        list->properties = g_list_next(list->properties);
+    }
+    g_list_free(properties_begin);
+    g_free(list);
+}
+
+/** Adds a property to the list it's linked with.
+ * (The TransPropertyList is not passed as a parameter because the property is
+ * associated with a list when it's constructed.)
+ * @param property The property to be added to its list
+ */
+static void trans_property_list_add(TransProperty* property)
+{
+    property->list->properties = g_list_append(property->list->properties, property);
+}
+
+/** Adds a split to a transaction.
+ * @param trans The transaction to add a split to
+ * @param account The account used for the split
+ * @param book The book where the split should be stored
+ * @param amount The amount of the split
+ */
+static void trans_add_split(Transaction* trans, Account* account, QofBook* book,
+                            gnc_numeric amount, const char *num)
+{
+    Split* split = xaccMallocSplit(book);
+    xaccSplitSetAccount(split, account);
+    xaccSplitSetParent(split, trans);
+    xaccSplitSetAmount(split, amount);
+    xaccSplitSetValue(split, amount);
+    /* set tran-num and/or split-action per book option */
+    gnc_set_num_action(trans, split, num, NULL);
+}
+
+/** Tests a TransPropertyList for having enough essential properties.
+ * Essential properties are "Date" and one of the following: "Balance", "Deposit", or
+ * "Withdrawal".
+ * @param list The list we are checking
+ * @param error Contains an error message on failure
+ * @return TRUE if there are enough essentials; FALSE otherwise
+ */
+static gboolean trans_property_list_verify_essentials(TransPropertyList* list, gchar** error)
+{
+    int i;
+    /* possible_errors lists the ways in which a list can fail this test. */
+    enum PossibleErrorTypes {NO_DATE, NO_AMOUNT, NUM_OF_POSSIBLE_ERRORS};
+    gchar* possible_errors[NUM_OF_POSSIBLE_ERRORS] =
+    {
+        N_("No date column."),
+        N_("No balance, deposit, or withdrawal column.")
+    };
+    int possible_error_lengths[NUM_OF_POSSIBLE_ERRORS] = {0};
+    GList *properties_begin = list->properties, *errors_list = NULL;
+
+    /* Go through each of the properties and erase possible errors. */
+    while (list->properties)
+    {
+        switch (((TransProperty*)(list->properties->data))->type)
+        {
+        case GNC_CSV_DATE:
+            possible_errors[NO_DATE] = NULL;
+            break;
+
+        case GNC_CSV_BALANCE:
+        case GNC_CSV_DEPOSIT:
+        case GNC_CSV_WITHDRAWAL:
+            possible_errors[NO_AMOUNT] = NULL;
+            break;
+        }
+        list->properties = g_list_next(list->properties);
+    }
+    list->properties = properties_begin;
+
+    /* Accumulate a list of the actual errors. */
+    for (i = 0; i < NUM_OF_POSSIBLE_ERRORS; i++)
+    {
+        if (possible_errors[i] != NULL)
+        {
+            errors_list = g_list_append(errors_list, GINT_TO_POINTER(i));
+            /* Since we added an error, we want to also store its length for
+             * when we construct the full error string. */
+            possible_error_lengths[i] = strlen(_(possible_errors[i]));
+        }
+    }
+
+    /* If there are no errors, we can quit now. */
+    if (errors_list == NULL)
+        return TRUE;
+    else
+    {
+        /* full_error_size is the full length of the error message. */
+        int full_error_size = 0, string_length = 0;
+        GList* errors_list_begin = errors_list;
+        gchar *error_message, *error_message_begin;
+
+        /* Find the value for full_error_size. */
+        while (errors_list)
+        {
+            /* We add an extra 1 to account for spaces in between messages. */
+            full_error_size += possible_error_lengths[GPOINTER_TO_INT(errors_list->data)] + 1;
+            errors_list = g_list_next(errors_list);
+        }
+        errors_list = errors_list_begin;
+
+        /* Append the error messages one after another. */
+        error_message = error_message_begin = g_new(gchar, full_error_size);
+        while (errors_list)
+        {
+            i = GPOINTER_TO_INT(errors_list->data);
+            string_length = possible_error_lengths[i];
+
+            /* Copy the error message and put a space after it. */
+            strncpy(error_message, _(possible_errors[i]), string_length);
+            error_message += string_length;
+            *error_message = ' ';
+            error_message++;
+
+            errors_list = g_list_next(errors_list);
+        }
+        *error_message = '\0'; /* Replace the last space with the null byte. */
+        g_list_free(errors_list_begin);
+
+        *error = error_message_begin;
+        return FALSE;
+    }
+}
+
+/** Create a Transaction from a TransPropertyList.
+ * @param list The list of properties
+ * @param error Contains an error on failure
+ * @return On success, a GncCsvTransLine; on failure, the trans pointer is NULL
+ */
+static GncCsvTransLine* trans_property_list_to_trans(TransPropertyList* list, gchar** error)
+{
+    GncCsvTransLine* trans_line = g_new(GncCsvTransLine, 1);
+    GList* properties_begin = list->properties;
+    QofBook* book = gnc_account_get_book(list->account);
+    gnc_commodity* currency = xaccAccountGetCommodity(list->account);
+    gnc_numeric amount = double_to_gnc_numeric(0.0, xaccAccountGetCommoditySCU(list->account),
+                         GNC_HOW_RND_ROUND_HALF_UP);
+    gchar *num = NULL;
+
+    /* This flag is set to TRUE if we can use the "Deposit" or "Withdrawal" column. */
+    gboolean amount_set = FALSE;
+
+    /* The balance is 0 by default. */
+    trans_line->balance_set = FALSE;
+    trans_line->balance = amount;
+    trans_line->num = NULL;
+
+    /* We make the line_no -1 just to mark that it hasn't been set. We
+     * may get rid of line_no soon anyway, so it's not particularly
+     * important. */
+    trans_line->line_no = -1;
+
+    /* Make sure this is a transaction with all the columns we need. */
+    if (!trans_property_list_verify_essentials(list, error))
+    {
+        g_free(trans_line);
+        return NULL;
+    }
+
+    trans_line->trans = xaccMallocTransaction(book);
+    xaccTransBeginEdit(trans_line->trans);
+    xaccTransSetCurrency(trans_line->trans, currency);
+
+    /* Go through each of the properties and edit the transaction accordingly. */
+    list->properties = properties_begin;
+    while (list->properties != NULL)
+    {
+        TransProperty* prop = (TransProperty*)(list->properties->data);
+        switch (prop->type)
+        {
+        case GNC_CSV_DATE:
+            xaccTransSetDatePostedSecsNormalized(trans_line->trans, *((time64*)(prop->value)));
+            break;
+
+        case GNC_CSV_DESCRIPTION:
+            xaccTransSetDescription(trans_line->trans, (char*)(prop->value));
+            break;
+
+        case GNC_CSV_NOTES:
+            xaccTransSetNotes(trans_line->trans, (char*)(prop->value));
+            break;
+
+        case GNC_CSV_NUM:
+            /* the 'num' is saved and passed to 'trans_add_split' below where
+             * 'gnc_set_num_action' is used to set tran-num and/or split-action
+             * per book option */
+            num = g_strdup ((char*)(prop->value));
+            /* the 'num' is also saved and used in 'gnc_csv_parse_to_trans' when
+             * it calls 'trans_add_split' after deleting the splits added below
+             * when a balance is used by the user */
+            trans_line->num = g_strdup ((char*)(prop->value));
+            break;
+
+        case GNC_CSV_DEPOSIT: /* Add deposits to the existing amount. */
+            if (prop->value != NULL)
+            {
+                amount = gnc_numeric_add(*((gnc_numeric*)(prop->value)),
+                                         amount,
+                                         xaccAccountGetCommoditySCU(list->account),
+                                         GNC_HOW_RND_ROUND_HALF_UP);
+                amount_set = TRUE;
+                /* We will use the "Deposit" and "Withdrawal" columns in preference to "Balance". */
+                trans_line->balance_set = FALSE;
+            }
+            break;
+
+        case GNC_CSV_WITHDRAWAL: /* Withdrawals are just negative deposits. */
+            if (prop->value != NULL)
+            {
+                amount = gnc_numeric_add(gnc_numeric_neg(*((gnc_numeric*)(prop->value))),
+                                         amount,
+                                         xaccAccountGetCommoditySCU(list->account),
+                                         GNC_HOW_RND_ROUND_HALF_UP);
+                amount_set = TRUE;
+                /* We will use the "Deposit" and "Withdrawal" columns in preference to "Balance". */
+                trans_line->balance_set = FALSE;
+            }
+            break;
+
+        case GNC_CSV_BALANCE: /* The balance gets stored in a separate field in trans_line. */
+            /* We will use the "Deposit" and "Withdrawal" columns in preference to "Balance". */
+            if (!amount_set && prop->value != NULL)
+            {
+                /* This gets put into the actual transaction at the end of gnc_csv_parse_to_trans. */
+                trans_line->balance = *((gnc_numeric*)(prop->value));
+                trans_line->balance_set = TRUE;
+            }
+            break;
+        }
+        list->properties = g_list_next(list->properties);
+    }
+
+    /* Add a split with the cumulative amount value. */
+    trans_add_split(trans_line->trans, list->account, book, amount, num);
+    if (num)
+        g_free(num);
+
+    return trans_line;
+}
+
+/** Creates a list of transactions from parsed data. Transactions that
+ * could be created from rows are placed in parse_data->transactions;
+ * rows that fail are placed in parse_data->error_lines. (Note: there
+ * is no way for this function to "fail," i.e. it only returns 0, so
+ * it may be changed to a void function in the future.)
+ * @param parse_data Data that is being parsed
+ * @param account Account with which transactions are created
+ * @param redo_errors TRUE to convert only error data, FALSE for all data
+ * @return 0 on success, 1 on failure
+ */
+int gnc_csv_parse_to_trans(GncCsvParseData* parse_data, Account* account,
+                           gboolean redo_errors)
+{
+    gboolean hasBalanceColumn;
+    int i, j, max_cols = 0;
+    GArray* column_types = parse_data->column_types;
+    GList *error_lines = NULL, *begin_error_lines = NULL;
+
+    /* last_transaction points to the last element in
+     * parse_data->transactions, or NULL if it's empty. */
+    GList* last_transaction = NULL;
+
+    /* Free parse_data->error_lines and parse_data->transactions if they
+     * already exist. */
+    if (redo_errors) /* If we're redoing errors, we save freeing until the end. */
+    {
+        begin_error_lines = error_lines = parse_data->error_lines;
+    }
+    else
+    {
+        if (parse_data->error_lines != NULL)
+        {
+            g_list_free(parse_data->error_lines);
+        }
+        if (parse_data->transactions != NULL)
+        {
+            g_list_free(parse_data->transactions);
+        }
+    }
+    parse_data->error_lines = NULL;
+
+    if (redo_errors) /* If we're looking only at error data ... */
+    {
+        if (parse_data->transactions == NULL)
+        {
+            last_transaction = NULL;
+        }
+        else
+        {
+            /* Move last_transaction to the end. */
+            last_transaction = parse_data->transactions;
+            while (g_list_next(last_transaction) != NULL)
+            {
+                last_transaction = g_list_next(last_transaction);
+            }
+        }
+        /* ... we use only the lines in error_lines. */
+        if (error_lines == NULL)
+            i = parse_data->orig_lines->len; /* Don't go into the for loop. */
+        else
+            i = GPOINTER_TO_INT(error_lines->data);
+    }
+    else /* Otherwise, we look at all the data. */
+    {
+        /* The following while-loop effectively behaves like the following for-loop:
+         * for(i = 0; i < parse_data->orig_lines->len; i++). */
+        i = parse_data->start_row;
+        last_transaction = NULL;
+    }
+
+    /* set parse_data->end_row to number of lines */
+    if (parse_data->end_row > parse_data->orig_lines->len)
+        parse_data->end_row = parse_data->orig_lines->len;
+
+    while (i < parse_data->end_row)
+    {
+        GPtrArray* line = parse_data->orig_lines->pdata[i];
+        /* This flag is TRUE if there are any errors in this row. */
+        gboolean errors = FALSE;
+        gchar* error_message = NULL;
+        TransPropertyList* list = trans_property_list_new(account, parse_data->date_format, parse_data->currency_format );
+        GncCsvTransLine* trans_line = NULL;
+
+        for (j = 0; j < line->len; j++)
+        {
+            /* We do nothing in "None" or "Account" columns. */
+            if ((column_types->data[j] != GNC_CSV_NONE) && (column_types->data[j] != GNC_CSV_ACCOUNT))
+            {
+                /* Affect the transaction appropriately. */
+                TransProperty* property = trans_property_new(column_types->data[j], list);
+                gboolean succeeded = trans_property_set(property, line->pdata[j]);
+
+                /* TODO Maybe move error handling to within TransPropertyList functions? */
+                if (succeeded)
+                {
+                    trans_property_list_add(property);
+                }
+                else
+                {
+                    errors = TRUE;
+                    error_message = g_strdup_printf(_("%s column could not be understood."),
+                                                    _(gnc_csv_column_type_strs[property->type]));
+                    trans_property_free(property);
+                    break;
+                }
+            }
+        }
+
+        /* If we had success, add the transaction to parse_data->transaction. */
+        if (!errors)
+        {
+            trans_line = trans_property_list_to_trans(list, &error_message);
+            errors = trans_line == NULL;
+        }
+
+        trans_property_list_free(list);
+
+        /* If there were errors, add this line to parse_data->error_lines. */
+        if (errors)
+        {
+            parse_data->error_lines = g_list_append(parse_data->error_lines,
+                                                    GINT_TO_POINTER(i));
+            /* If there's already an error message, we need to replace it. */
+            if (line->len > (int)(parse_data->orig_row_lengths->data[i]))
+            {
+                g_free(line->pdata[line->len - 1]);
+                line->pdata[line->len - 1] = error_message;
+            }
+            else
+            {
+                /* Put the error message at the end of the line. */
+                g_ptr_array_add(line, error_message);
+            }
+        }
+        else
+        {
+            /* If all went well, add this transaction to the list. */
+            trans_line->line_no = i;
+
+            /* We keep the transactions sorted by date. We start at the end
+             * of the list and go backward, simply because the file itself
+             * is probably also sorted by date (but we need to handle the
+             * exception anyway). */
+
+            /* If we can just put it at the end, do so and increment last_transaction. */
+            if (last_transaction == NULL ||
+                    xaccTransGetDate(((GncCsvTransLine*)(last_transaction->data))->trans) <= xaccTransGetDate(trans_line->trans))
+            {
+                parse_data->transactions = g_list_append(parse_data->transactions, trans_line);
+                /* If this is the first transaction, we need to get last_transaction on track. */
+                if (last_transaction == NULL)
+                    last_transaction = parse_data->transactions;
+                else /* Otherwise, we can just continue. */
+                    last_transaction = g_list_next(last_transaction);
+            }
+            /* Otherwise, search backward for the correct spot. */
+            else
+            {
+                GList* insertion_spot = last_transaction;
+                while (insertion_spot != NULL &&
+                        xaccTransGetDate(((GncCsvTransLine*)(insertion_spot->data))->trans) > xaccTransGetDate(trans_line->trans))
+                {
+                    insertion_spot = g_list_previous(insertion_spot);
+                }
+                /* Move insertion_spot one location forward since we have to
+                 * use the g_list_insert_before function. */
+                if (insertion_spot == NULL) /* We need to handle the case of inserting at the beginning of the list. */
+                    insertion_spot = parse_data->transactions;
+                else
+                    insertion_spot = g_list_next(insertion_spot);
+
+                parse_data->transactions = g_list_insert_before(parse_data->transactions, insertion_spot, trans_line);
+            }
+        }
+
+        /* Increment to the next row. */
+        if (redo_errors)
+        {
+            /* Move to the next error line in the list. */
+            error_lines = g_list_next(error_lines);
+            if (error_lines == NULL)
+                i = parse_data->orig_lines->len; /* Don't continue the for loop. */
+            else
+                i = GPOINTER_TO_INT(error_lines->data);
+        }
+        else
+        {
+            i++;
+        }
+    }
+
+    /* If we have a balance column, set the appropriate amounts on the transactions. */
+    hasBalanceColumn = FALSE;
+    for (i = 0; i < parse_data->column_types->len; i++)
+    {
+        if (parse_data->column_types->data[i] == GNC_CSV_BALANCE)
+        {
+            hasBalanceColumn = TRUE;
+            break;
+        }
+    }
+
+    if (hasBalanceColumn)
+    {
+        GList* transactions = parse_data->transactions;
+
+        /* balance_offset is how much the balance currently in the account
+         * differs from what it will be after the transactions are
+         * imported. This will be sum of all the previous transactions for
+         * any given transaction. */
+        gnc_numeric balance_offset = double_to_gnc_numeric(0.0,
+                                     xaccAccountGetCommoditySCU(account),
+                                     GNC_HOW_RND_ROUND_HALF_UP);
+        while (transactions != NULL)
+        {
+            GncCsvTransLine* trans_line = (GncCsvTransLine*)transactions->data;
+            if (trans_line->balance_set)
+            {
+                time64 date = xaccTransGetDate(trans_line->trans);
+                /* Find what the balance should be by adding the offset to the actual balance. */
+                gnc_numeric existing_balance = gnc_numeric_add(balance_offset,
+                                               xaccAccountGetBalanceAsOfDate(account, date),
+                                               xaccAccountGetCommoditySCU(account),
+                                               GNC_HOW_RND_ROUND_HALF_UP);
+
+                /* The amount of the transaction is the difference between the new and existing balance. */
+                gnc_numeric amount = gnc_numeric_sub(trans_line->balance,
+                                                     existing_balance,
+                                                     xaccAccountGetCommoditySCU(account),
+                                                     GNC_HOW_RND_ROUND_HALF_UP);
+
+                SplitList* splits = xaccTransGetSplitList(trans_line->trans);
+                while (splits)
+                {
+                    SplitList* next_splits = g_list_next(splits);
+                    xaccSplitDestroy((Split*)splits->data);
+                    splits = next_splits;
+                }
+
+                trans_add_split(trans_line->trans, account,
+                                gnc_account_get_book(account), amount, trans_line->num);
+                if (trans_line->num)
+                    g_free(trans_line->num);
+
+                /* This new transaction needs to be added to the balance offset. */
+                balance_offset = gnc_numeric_add(balance_offset,
+                                                 amount,
+                                                 xaccAccountGetCommoditySCU(account),
+                                                 GNC_HOW_RND_ROUND_HALF_UP);
+            }
+            transactions = g_list_next(transactions);
+        }
+    }
+
+    if (redo_errors) /* Now that we're at the end, we do the freeing. */
+    {
+        g_list_free(begin_error_lines);
+    }
+
+    /* We need to resize parse_data->column_types since errors may have added columns. */
+    for (i = 0; i < parse_data->orig_lines->len; i++)
+    {
+        if (max_cols < ((GPtrArray*)(parse_data->orig_lines->pdata[i]))->len)
+            max_cols = ((GPtrArray*)(parse_data->orig_lines->pdata[i]))->len;
+    }
+    i = parse_data->column_types->len;
+    parse_data->column_types = g_array_set_size(parse_data->column_types, max_cols);
+    for (; i < max_cols; i++)
+    {
+        parse_data->column_types->data[i] = GNC_CSV_NONE;
+    }
+
+    return 0;
+}

Copied: gnucash/trunk/src/import-export/csv-imp/gnc-csv-model.h (from rev 23566, gnucash/trunk/src/import-export/csv-import/gnc-csv-model.h)
===================================================================
--- gnucash/trunk/src/import-export/csv-imp/gnc-csv-model.h	                        (rev 0)
+++ gnucash/trunk/src/import-export/csv-imp/gnc-csv-model.h	2013-12-15 17:21:20 UTC (rev 23567)
@@ -0,0 +1,136 @@
+/********************************************************************\
+ * This program is free software; you can redistribute it and/or    *
+ * modify it under the terms of the GNU General Public License as   *
+ * published by the Free Software Foundation; either version 2 of   *
+ * the License, or (at your option) any later version.              *
+ *                                                                  *
+ * This program is distributed in the hope that it will be useful,  *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of   *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the    *
+ * GNU General Public License for more details.                     *
+ *                                                                  *
+ * You should have received a copy of the GNU General Public License*
+ * along with this program; if not, contact:                        *
+ *                                                                  *
+ * Free Software Foundation           Voice:  +1-617-542-5942       *
+ * 51 Franklin Street, Fifth Floor    Fax:    +1-617-542-2652       *
+ * Boston, MA  02110-1301,  USA       gnu at gnu.org                   *
+\********************************************************************/
+
+/** @file
+     @brief CSV import GUI
+     *
+     gnc-csv-model.h
+     @author Copyright (c) 2007 Benny Sperisen <lasindi at gmail.com>
+ */
+
+#ifndef GNC_CSV_MODEL_H
+#define GNC_CSV_MODEL_H
+
+#include "config.h"
+
+#include "Account.h"
+#include "Transaction.h"
+
+#include "stf/stf-parse.h"
+
+/** Enumeration for column types. These are the different types of
+ * columns that can exist in a CSV/Fixed-Width file. There should be
+ * no two columns with the same type except for the GNC_CSV_NONE
+ * type. */
+enum GncCsvColumnType {GNC_CSV_NONE,
+                       GNC_CSV_DATE,
+                       GNC_CSV_NUM,
+                       GNC_CSV_DESCRIPTION,
+                       GNC_CSV_NOTES,
+                       GNC_CSV_ACCOUNT,
+                       GNC_CSV_DEPOSIT,
+                       GNC_CSV_WITHDRAWAL,
+                       GNC_CSV_BALANCE,
+                       GNC_CSV_NUM_COL_TYPES
+                      };
+
+/** Enumeration for error types. These are the different types of
+ * errors that various functions used for the CSV/Fixed-Width importer
+ * can have. */
+enum GncCsvErrorType {GNC_CSV_FILE_OPEN_ERR,
+                      GNC_CSV_ENCODING_ERR
+                     };
+
+/** Struct for containing a string. This struct simply contains
+ * pointers to the beginning and end of a string. We need this because
+ * the STF code that gnc_csv_parse calls requires these pointers. */
+typedef struct
+{
+    char* begin;
+    char* end;
+} GncCsvStr;
+
+/* TODO We now sort transactions by date, not line number, so we
+ * should probably get rid of this struct and uses of it. */
+
+/** Struct pairing a transaction with a line number. This struct is
+ * used to keep the transactions in order. When rows are separated
+ * into "valid" and "error" lists (in case some of the rows have cells
+ * that are unparseable), we want the user to still be able to
+ * "correct" the error list. If we keep the line numbers of valid
+ * transactions, we can then put transactions created from the newly
+ * corrected rows into the right places. */
+typedef struct
+{
+    int line_no;
+    Transaction* trans;
+    gnc_numeric balance; /**< The (supposed) balance after this transaction takes place */
+    gboolean balance_set; /**< TRUE if balance has been set from user data, FALSE otherwise */
+    gchar *num; /**< Saves the 'num'for use if balance has been set from user data */
+} GncCsvTransLine;
+
+/* A set of currency formats that the user sees. */
+extern const int num_currency_formats;
+extern const gchar* currency_format_user[];
+
+/* A set of date formats that the user sees. */
+extern const int num_date_formats;
+extern const gchar* date_format_user[];
+
+/* This array contains all of the different strings for different column types. */
+extern gchar* gnc_csv_column_type_strs[];
+
+/** Struct containing data for parsing a CSV/Fixed-Width file. */
+typedef struct
+{
+    gchar* encoding;
+    GMappedFile* raw_mapping;   /**< The mapping containing raw_str */
+    GncCsvStr raw_str;          /**< Untouched data from the file as a string */
+    GncCsvStr file_str;         /**< raw_str translated into UTF-8 */
+    GPtrArray* orig_lines;      /**< file_str parsed into a two-dimensional array of strings */
+    GArray* orig_row_lengths;   /**< The lengths of rows in orig_lines
+                                      before error messages are appended */
+    int orig_max_row;           /**< Holds the maximum value in orig_row_lengths */
+    GStringChunk* chunk;        /**< A chunk of memory in which the contents of orig_lines is stored */
+    StfParseOptions_t* options; /**< Options controlling how file_str should be parsed */
+    GArray* column_types;       /**< Array of values from the GncCsvColumnType enumeration */
+    GList* error_lines;         /**< List of row numbers in orig_lines that have errors */
+    GList* transactions;        /**< List of GncCsvTransLine*s created using orig_lines and column_types */
+    int date_format;            /**< The format of the text in the date columns from date_format_internal. */
+    int start_row;              /**< The start row to generate transactions from. */
+    int end_row;                /**< The end row to generate transactions from. */
+    int currency_format;        /**< The currency format, 0 for locale, 1 for comma dec and 2 for period */
+} GncCsvParseData;
+
+GncCsvParseData* gnc_csv_new_parse_data(void);
+
+void gnc_csv_parse_data_free(GncCsvParseData* parse_data);
+
+int gnc_csv_load_file(GncCsvParseData* parse_data, const char* filename,
+                      GError** error);
+
+int gnc_csv_convert_encoding(GncCsvParseData* parse_data, const char* encoding, GError** error);
+
+int gnc_csv_parse(GncCsvParseData* parse_data, gboolean guessColTypes, GError** error);
+
+int gnc_csv_parse_to_trans(GncCsvParseData* parse_data, Account* account, gboolean redo_errors);
+
+time64 parse_date(const char* date_str, int format);
+
+#endif

Copied: gnucash/trunk/src/import-export/csv-imp/gnc-plugin-csv-import-ui.xml (from rev 23566, gnucash/trunk/src/import-export/csv-import/gnc-plugin-csv-import-ui.xml)
===================================================================
--- gnucash/trunk/src/import-export/csv-imp/gnc-plugin-csv-import-ui.xml	                        (rev 0)
+++ gnucash/trunk/src/import-export/csv-imp/gnc-plugin-csv-import-ui.xml	2013-12-15 17:21:20 UTC (rev 23567)
@@ -0,0 +1,12 @@
+<ui>
+  <menubar>
+    <menu name="File" action="FileAction">
+      <menu name="FileImport" action="FileImportAction">
+      	<placeholder name="FileImportPlaceholder">
+      	   <menuitem name="FileCsvImportAccounts" action="CsvImportAccountAction"/>
+      	   <menuitem name="FileCsvImportTrans" action="CsvImportTransAction"/>
+      	</placeholder>
+      </menu>
+    </menu>
+  </menubar>
+</ui>

Copied: gnucash/trunk/src/import-export/csv-imp/gnc-plugin-csv-import.c (from rev 23566, gnucash/trunk/src/import-export/csv-import/gnc-plugin-csv-import.c)
===================================================================
--- gnucash/trunk/src/import-export/csv-imp/gnc-plugin-csv-import.c	                        (rev 0)
+++ gnucash/trunk/src/import-export/csv-imp/gnc-plugin-csv-import.c	2013-12-15 17:21:20 UTC (rev 23567)
@@ -0,0 +1,169 @@
+/*
+ * gnc-plugin-csv-import.c -- csv import plugin
+ * Copyright (C) 2011 Robert Fewell
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, contact:
+ *
+ * Free Software Foundation           Voice:  +1-617-542-5942
+ * 51 Franklin Street, Fifth Floor    Fax:    +1-617-542-2652
+ * Boston, MA  02110-1301,  USA       gnu at gnu.org
+ */
+
+#include "config.h"
+
+#include <gtk/gtk.h>
+#include <glib/gi18n.h>
+
+#include "gnc-plugin-csv-import.h"
+#include "gnc-plugin-manager.h"
+
+#include "assistant-csv-account-import.h"
+#include "assistant-csv-trans-import.h"
+
+static void gnc_plugin_csv_import_class_init (GncPluginCsvImportClass *klass);
+static void gnc_plugin_csv_import_init (GncPluginCsvImport *plugin);
+static void gnc_plugin_csv_import_finalize (GObject *object);
+
+/* Command callbacks */
+static void gnc_plugin_csv_import_tree_cmd (GtkAction *action, GncMainWindowActionData *data);
+static void gnc_plugin_csv_import_trans_cmd (GtkAction *action, GncMainWindowActionData *data);
+
+#define PLUGIN_ACTIONS_NAME "gnc-plugin-csv-import-actions"
+#define PLUGIN_UI_FILENAME  "gnc-plugin-csv-import-ui.xml"
+
+static GtkActionEntry gnc_plugin_actions [] =
+{
+    {
+        "CsvImportAccountAction", GTK_STOCK_CONVERT, N_("Import _Accounts from CSV..."), NULL,
+        N_("Import Accounts from a CSV file"),
+        G_CALLBACK (gnc_plugin_csv_import_tree_cmd)
+    },
+    {
+        "CsvImportTransAction", GTK_STOCK_CONVERT, N_("Import _Transactions from CSV..."), NULL,
+        N_("Import Transactions from a CSV file"),
+        G_CALLBACK (gnc_plugin_csv_import_trans_cmd)
+    },
+};
+static guint gnc_plugin_n_actions = G_N_ELEMENTS (gnc_plugin_actions);
+
+typedef struct GncPluginCsvImportPrivate
+{
+    gpointer dummy;
+} GncPluginCsvImportPrivate;
+
+#define GNC_PLUGIN_CSV_IMPORT_GET_PRIVATE(o)  \
+   (G_TYPE_INSTANCE_GET_PRIVATE ((o), GNC_TYPE_PLUGIN_CSV_IMPORT, GncPluginCsvImportPrivate))
+
+static GObjectClass *parent_class = NULL;
+
+GType
+gnc_plugin_csv_import_get_type (void)
+{
+    static GType gnc_plugin_csv_import_type = 0;
+
+    if (gnc_plugin_csv_import_type == 0)
+    {
+        static const GTypeInfo our_info =
+        {
+            sizeof (GncPluginCsvImportClass),
+            NULL,		/* base_init */
+            NULL,		/* base_finalize */
+            (GClassInitFunc) gnc_plugin_csv_import_class_init,
+            NULL,		/* class_finalize */
+            NULL,		/* class_data */
+            sizeof (GncPluginCsvImport),
+            0,		/* n_preallocs */
+            (GInstanceInitFunc) gnc_plugin_csv_import_init,
+        };
+
+        gnc_plugin_csv_import_type = g_type_register_static (GNC_TYPE_PLUGIN,
+                                     "GncPluginCsvImport",
+                                     &our_info, 0);
+    }
+
+    return gnc_plugin_csv_import_type;
+}
+
+GncPlugin *
+gnc_plugin_csv_import_new (void)
+{
+    return GNC_PLUGIN (g_object_new (GNC_TYPE_PLUGIN_CSV_IMPORT, NULL));
+}
+
+static void
+gnc_plugin_csv_import_class_init (GncPluginCsvImportClass *klass)
+{
+    GObjectClass *object_class = G_OBJECT_CLASS (klass);
+    GncPluginClass *plugin_class = GNC_PLUGIN_CLASS (klass);
+
+    parent_class = g_type_class_peek_parent (klass);
+
+    object_class->finalize = gnc_plugin_csv_import_finalize;
+
+    /* plugin info */
+    plugin_class->plugin_name  = GNC_PLUGIN_CSV_IMPORT_NAME;
+
+    /* widget addition/removal */
+    plugin_class->actions_name = PLUGIN_ACTIONS_NAME;
+    plugin_class->actions      = gnc_plugin_actions;
+    plugin_class->n_actions    = gnc_plugin_n_actions;
+    plugin_class->ui_filename  = PLUGIN_UI_FILENAME;
+
+    g_type_class_add_private(klass, sizeof(GncPluginCsvImportPrivate));
+}
+
+static void
+gnc_plugin_csv_import_init (GncPluginCsvImport *plugin)
+{
+}
+
+static void
+gnc_plugin_csv_import_finalize (GObject *object)
+{
+    g_return_if_fail (GNC_IS_PLUGIN_CSV_IMPORT (object));
+
+    G_OBJECT_CLASS (parent_class)->finalize (object);
+}
+
+/************************************************************
+ *              Plugin Function Implementation              *
+ ************************************************************/
+
+/************************************************************
+ *                    Command Callbacks                     *
+ ************************************************************/
+static void
+gnc_plugin_csv_import_tree_cmd (GtkAction *action,
+                                GncMainWindowActionData *data)
+{
+    gnc_file_csv_account_import ();
+}
+
+static void
+gnc_plugin_csv_import_trans_cmd (GtkAction *action,
+                                 GncMainWindowActionData *data)
+{
+    gnc_file_csv_trans_import ();
+}
+
+/************************************************************
+ *                    Plugin Bootstrapping                   *
+ ************************************************************/
+void
+gnc_plugin_csv_import_create_plugin (void)
+{
+    GncPlugin *plugin = gnc_plugin_csv_import_new ();
+
+    gnc_plugin_manager_add_plugin (gnc_plugin_manager_get (), plugin);
+}

Copied: gnucash/trunk/src/import-export/csv-imp/gnc-plugin-csv-import.h (from rev 23566, gnucash/trunk/src/import-export/csv-import/gnc-plugin-csv-import.h)
===================================================================
--- gnucash/trunk/src/import-export/csv-imp/gnc-plugin-csv-import.h	                        (rev 0)
+++ gnucash/trunk/src/import-export/csv-imp/gnc-plugin-csv-import.h	2013-12-15 17:21:20 UTC (rev 23567)
@@ -0,0 +1,62 @@
+/*
+ * gnc-plugin-csv-import.h -- csv import plugin
+ * Copyright (C) 2011 Robert Fewell
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, contact:
+ *
+ * Free Software Foundation           Voice:  +1-617-542-5942
+ * 51 Franklin Street, Fifth Floor    Fax:    +1-617-542-2652
+ * Boston, MA  02110-1301,  USA       gnu at gnu.org
+ */
+
+#ifndef __GNC_PLUGIN_CSV_IMPORT_H
+#define __GNC_PLUGIN_CSV_IMPORT_H
+
+#include <gtk/gtk.h>
+
+#include "gnc-plugin.h"
+
+G_BEGIN_DECLS
+
+/* type macros */
+#define GNC_TYPE_PLUGIN_CSV_IMPORT            (gnc_plugin_csv_import_get_type ())
+#define GNC_PLUGIN_CSV_IMPORT(obj)            (G_TYPE_CHECK_INSTANCE_CAST ((obj), GNC_TYPE_PLUGIN_CSV_IMPORT, GncPluginCsvImport))
+#define GNC_PLUGIN_CSV_IMPORT_CLASS(klass)    (G_TYPE_CHECK_CLASS_CAST ((klass), GNC_TYPE_PLUGIN_CSV_IMPORT, GncPluginCsvImportClass))
+#define GNC_IS_PLUGIN_CSV_IMPORT(obj)         (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GNC_TYPE_PLUGIN_CSV_IMPORT))
+#define GNC_IS_PLUGIN_CSV_IMPORT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GNC_TYPE_PLUGIN_CSV_IMPORT))
+#define GNC_PLUGIN_CSV_IMPORT_GET_CLASS(obj)  (G_TYPE_INSTANCE_GET_CLASS ((obj), GNC_TYPE_PLUGIN_CSV_IMPORT, GncPluginCsvImportClass))
+
+#define GNC_PLUGIN_CSV_IMPORT_NAME "gnc-plugin-csv-import"
+
+/* typedefs & structures */
+typedef struct
+{
+    GncPlugin gnc_plugin;
+} GncPluginCsvImport;
+
+typedef struct
+{
+    GncPluginClass gnc_plugin;
+} GncPluginCsvImportClass;
+
+/* function prototypes */
+GType      gnc_plugin_csv_import_get_type (void);
+
+GncPlugin *gnc_plugin_csv_import_new      (void);
+
+void       gnc_plugin_csv_import_create_plugin (void);
+
+G_END_DECLS
+
+#endif /* __GNC_PLUGIN_CSV_IMPORT_H */

Copied: gnucash/trunk/src/import-export/csv-imp/gncmod-csv-import.c (from rev 23566, gnucash/trunk/src/import-export/csv-import/gncmod-csv-import.c)
===================================================================
--- gnucash/trunk/src/import-export/csv-imp/gncmod-csv-import.c	                        (rev 0)
+++ gnucash/trunk/src/import-export/csv-imp/gncmod-csv-import.c	2013-12-15 17:21:20 UTC (rev 23567)
@@ -0,0 +1,90 @@
+/********************************************************************\
+ * This program is free software; you can redistribute it and/or    *
+ * modify it under the terms of the GNU General Public License as   *
+ * published by the Free Software Foundation; either version 2 of   *
+ * the License, or (at your option) any later version.              *
+ *                                                                  *
+ * This program is distributed in the hope that it will be useful,  *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of   *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the    *
+ * GNU General Public License for more details.                     *
+ *                                                                  *
+ * You should have received a copy of the GNU General Public License*
+ * along with this program; if not, contact:                        *
+ *                                                                  *
+ * Free Software Foundation           Voice:  +1-617-542-5942       *
+ * 51 Franklin Street, Fifth Floor    Fax:    +1-617-542-2652       *
+ * Boston, MA  02110-1301,  USA       gnu at gnu.org                   *
+\********************************************************************/
+/** @addtogroup Import_Export
+    @{ */
+/**@internal
+ at file gncmod-csv-import.c
+ at brief module definition/initialization for the csv importer
+ at author Copyright (c) 2012 Robert Fewell
+*/
+#include "config.h"
+
+#include <gmodule.h>
+
+#include "gnc-module.h"
+#include "gnc-module-api.h"
+#include "gnc-plugin-csv-import.h"
+
+GNC_MODULE_API_DECL(libgncmod_csv_import)
+
+/* version of the gnc module system interface we require */
+int libgncmod_csv_import_gnc_module_system_interface = 0;
+
+/* module versioning uses libtool semantics. */
+int libgncmod_csv_import_gnc_module_current  = 0;
+int libgncmod_csv_import_gnc_module_revision = 0;
+int libgncmod_csv_import_gnc_module_age      = 0;
+
+//static GNCModule bus_core;
+//static GNCModule file;
+
+char *
+libgncmod_csv_import_gnc_module_path(void)
+{
+    return g_strdup("gnucash/import-export/csv-import");
+}
+
+char *
+libgncmod_csv_import_gnc_module_description(void)
+{
+    return g_strdup("Gnome GUI and C code for CSV importer.");
+}
+
+int
+libgncmod_csv_import_gnc_module_init(int refcount)
+{
+    if (!gnc_module_load("gnucash/engine", 0))
+    {
+        return FALSE;
+    }
+    if (!gnc_module_load("gnucash/app-utils", 0))
+    {
+        return FALSE;
+    }
+    if (!gnc_module_load("gnucash/gnome-utils", 0))
+    {
+        return FALSE;
+    }
+    if (!gnc_module_load("gnucash/import-export", 0))
+    {
+        return FALSE;
+    }
+
+    /* Add menu items with C callbacks */
+    gnc_plugin_csv_import_create_plugin();
+
+    return TRUE;
+}
+
+int
+libgncmod_csv_import_gnc_module_end(int refcount)
+{
+    return TRUE;
+}
+/** @}*/

Copied: gnucash/trunk/src/import-export/csv-imp/gschemas/Makefile.am (from rev 23566, gnucash/trunk/src/import-export/csv-import/gschemas/Makefile.am)
===================================================================
--- gnucash/trunk/src/import-export/csv-imp/gschemas/Makefile.am	                        (rev 0)
+++ gnucash/trunk/src/import-export/csv-imp/gschemas/Makefile.am	2013-12-15 17:21:20 UTC (rev 23567)
@@ -0,0 +1,10 @@
+ at INTLTOOL_XML_NOMERGE_RULE@
+
+gschema_in_files = \
+  org.gnucash.dialogs.import.csv.gschema.xml.in
+
+gsettings_SCHEMAS = $(gschema_in_files:.gschema.xml.in=.gschema.xml)
+
+ at GSETTINGS_RULES@
+
+CLEANFILES = $(gsettings_SCHEMAS)

Copied: gnucash/trunk/src/import-export/csv-imp/gschemas/org.gnucash.dialogs.import.csv.gschema.xml.in.in (from rev 23566, gnucash/trunk/src/import-export/csv-import/gschemas/org.gnucash.dialogs.import.csv.gschema.xml.in.in)
===================================================================
--- gnucash/trunk/src/import-export/csv-imp/gschemas/org.gnucash.dialogs.import.csv.gschema.xml.in.in	                        (rev 0)
+++ gnucash/trunk/src/import-export/csv-imp/gschemas/org.gnucash.dialogs.import.csv.gschema.xml.in.in	2013-12-15 17:21:20 UTC (rev 23567)
@@ -0,0 +1,16 @@
+<schemalist gettext-domain="@GETTEXT_PACKAGE@">
+  <schema id="org.gnucash.dialogs.import.csv" path="/org/gnucash/dialogs/import/csv/">
+    <key name="last-geometry" type="(iiii)">
+      <default>(-1,-1,-1,-1)</default>
+      <summary>Last window position and size</summary>
+      <description>This setting describes the size and position of the window when it was last closed.
+        The numbers are the X and Y coordinates of the top left corner of the window
+        followed by the width and height of the window.</description>
+    </key>
+    <key name="last-path" type="s">
+      <default>''</default>
+      <summary>Last pathname used</summary>
+      <description>This field contains the last pathname used by this window. It will be used as the initial filename/pathname the next time this window is opened.</description>
+    </key>
+  </schema>
+</schemalist>

Deleted: gnucash/trunk/src/import-export/csv-import/Makefile.am
===================================================================
--- gnucash/trunk/src/import-export/csv-import/Makefile.am	2013-12-15 17:20:10 UTC (rev 23566)
+++ gnucash/trunk/src/import-export/csv-import/Makefile.am	2013-12-15 17:21:20 UTC (rev 23567)
@@ -1,64 +0,0 @@
-SUBDIRS = . gschemas
-
-pkglib_LTLIBRARIES=libgncmod-csv-import.la
-
-libgncmod_csv_import_la_SOURCES = \
-  gncmod-csv-import.c \
-  assistant-csv-account-import.c \
-  assistant-csv-trans-import.c \
-  gnc-plugin-csv-import.c \
-  csv-account-import.c \
-  gnc-csv-model.c \
-  gnc-csv-gnumeric-popup.c
-
-noinst_HEADERS = \
-  assistant-csv-account-import.h \
-  assistant-csv-trans-import.h \
-  gnc-plugin-csv-import.h \
-  csv-account-import.h \
-  gnc-csv-model.h \
-  gnc-csv-gnumeric-popup.h
-
-libgncmod_csv_import_la_LDFLAGS = -avoid-version
-
-libgncmod_csv_import_la_LIBADD = \
-  ${top_builddir}/src/import-export/libgncmod-generic-import.la \
-  ${top_builddir}/src/gnome-utils/libgncmod-gnome-utils.la \
-  ${top_builddir}/src/app-utils/libgncmod-app-utils.la \
-  ${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}/lib/stf/libgnc-stf.la \
-  ${top_builddir}/lib/libc/libc-missing.la \
-  ${top_builddir}/src/libqof/qof/libgnc-qof.la \
-  ${GOFFICE_LIBS} \
-  ${GLIB_LIBS}
-
-AM_CPPFLAGS = \
-  -I${top_srcdir}/src \
-  -I${top_srcdir}/src/core-utils \
-  -I${top_srcdir}/src/engine \
-  -I${top_srcdir}/src/gnc-module \
-  -I${top_srcdir}/src/app-utils \
-  -I${top_srcdir}/src/gnome \
-  -I${top_srcdir}/src/gnome-utils \
-  -I${top_srcdir}/src/import-export \
-  -I${top_srcdir}/src/libqof/qof \
-  -I${top_srcdir}/lib/libc \
-  -I${top_srcdir}/lib \
-  ${GUILE_CFLAGS} \
-  ${GLIB_CFLAGS} \
-  $(GOFFICE_CFLAGS)
-
-uidir = $(GNC_UI_DIR)
-ui_DATA = \
-	gnc-plugin-csv-import-ui.xml
-
-gtkbuilderdir = ${GNC_GTKBUILDER_DIR}
-gtkbuilder_DATA = \
-	assistant-csv-account-import.glade \
-	assistant-csv-trans-import.glade
-
-EXTRA_DIST = $(ui_DATA) $(gtkbuilder_DATA)
-
-AM_CPPFLAGS += -DG_LOG_DOMAIN=\"gnc.import.csv\"

Deleted: gnucash/trunk/src/import-export/csv-import/assistant-csv-account-import.c
===================================================================
--- gnucash/trunk/src/import-export/csv-import/assistant-csv-account-import.c	2013-12-15 17:20:10 UTC (rev 23566)
+++ gnucash/trunk/src/import-export/csv-import/assistant-csv-account-import.c	2013-12-15 17:21:20 UTC (rev 23567)
@@ -1,681 +0,0 @@
-/*******************************************************************\
- * assistant-csv-account-import.c -- An assistant for importing     *
- *                                         Accounts from a file.    *
- *                                                                  *
- * Copyright (C) 2012 Robert Fewell                                 *
- *                                                                  *
- * This program is free software; you can redistribute it and/or    *
- * modify it under the terms of the GNU General Public License as   *
- * published by the Free Software Foundation; either version 2 of   *
- * the License, or (at your option) any later version.              *
- *                                                                  *
- * This program is distributed in the hope that it will be useful,  *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of   *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the    *
- * GNU General Public License for more details.                     *
- *                                                                  *
- * You should have received a copy of the GNU General Public License*
- * along with this program; if not, contact:                        *
- *                                                                  *
- * Free Software Foundation           Voice:  +1-617-542-5942       *
- * 51 Franklin Street, Fifth Floor    Fax:    +1-617-542-2652       *
- * Boston, MA  02110-1301,  USA       gnu at gnu.org                   *
-\********************************************************************/
-/** @file assistant-csv-account-import.c
-    @brief CSV Import Assistant
-    @author Copyright (c) 2012 Robert Fewell
-*/
-#include "config.h"
-
-#include <gtk/gtk.h>
-#include <glib/gi18n.h>
-
-#include "dialog-utils.h"
-#include "gnc-ui.h"
-#include "gnc-uri-utils.h"
-#include "gnc-ui-util.h"
-
-#include "gnc-component-manager.h"
-
-#include "assistant-utils.h"
-#include "assistant-csv-account-import.h"
-#include "csv-account-import.h"
-
-#define GNC_PREFS_GROUP "dialogs.import.csv"
-#define ASSISTANT_CSV_IMPORT_CM_CLASS "assistant-csv-account-import"
-
-/* This static indicates the debugging module that this .o belongs to.  */
-static QofLogModule log_module = GNC_MOD_ASSISTANT;
-
-/*************************************************************************/
-
-void csv_import_assistant_prepare (GtkAssistant  *assistant, GtkWidget *page, gpointer user_data);
-void csv_import_assistant_finish (GtkAssistant *gtkassistant, gpointer user_data);
-void csv_import_assistant_cancel (GtkAssistant *gtkassistant, gpointer user_data);
-void csv_import_assistant_close (GtkAssistant *gtkassistant, gpointer user_data);
-
-void csv_import_assistant_start_page_prepare (GtkAssistant *gtkassistant, gpointer user_data);
-void csv_import_assistant_account_page_prepare (GtkAssistant *gtkassistant, gpointer user_data);
-void csv_import_assistant_file_page_prepare (GtkAssistant *assistant, gpointer user_data);
-void csv_import_assistant_finish_page_prepare (GtkAssistant *assistant, gpointer user_data);
-void csv_import_assistant_summary_page_prepare (GtkAssistant *assistant, gpointer user_data);
-
-void csv_import_sep_cb (GtkWidget *radio, gpointer user_data );
-void csv_import_hrows_cb (GtkWidget *spin, gpointer user_data );
-
-void csv_import_file_chooser_confirm_cb (GtkWidget *button, CsvImportInfo *info);
-
-static gchar *gnc_input_dialog (GtkWidget *parent, const gchar *title, const gchar *msg, const gchar *default_input);
-
-static const gchar *finish_tree_string = N_(
-            "The accounts will be imported from the file '%s' when you click 'Apply'.\n\n"
-            "You can also go back and verify your selections by clicking on 'Back'"
-            " or 'Cancel' to Abort Import.\n");
-
-static const gchar *new_book_finish_tree_string = N_(
-            "The accounts will be imported from the file '%s' when you click 'Apply'.\n\n"
-            "You can also go back and verify your selections by clicking on 'Back'"
-            " or 'Cancel' to Abort Import.\n\n"
-            "If this is your initial import into a new file, you will first see "
-            "a dialog for setting book options, since these can affect how "
-            "imported data are converted to GnuCash transactions. If this is an "
-            "existing file, the dialog will not be shown.\n");
-
-/* Escape '_' in string */
-static gchar *mnemonic_escape (const gchar *source);
-static gchar *mnemonic_escape (const gchar *source)
-{
-    const guchar *p;
-    gchar *dest;
-    gchar *q;
-
-    g_return_val_if_fail (source != NULL, NULL);
-
-    p = (guchar *) source;
-    q = dest = g_malloc (strlen (source) * 2 + 1);
-
-    while (*p)
-    {
-        switch (*p)
-        {
-        case '_':
-            *q++ = '_';
-            *q++ = '_';
-            break;
-        default:
-            *q++ = *p;
-            break;
-        }
-        p++;
-    }
-    *q = 0;
-    return dest;
-}
-
-/*************************************************************************/
-
-/**************************************************
- * csv_file_chooser_confirm_cb
- *
- * call back for ok button in file chooser widget
- **************************************************/
-void
-csv_import_file_chooser_confirm_cb (GtkWidget *button, CsvImportInfo *info)
-{
-    GtkAssistant *assistant = GTK_ASSISTANT(info->window);
-    gint num = gtk_assistant_get_current_page (assistant);
-    GtkWidget *page = gtk_assistant_get_nth_page (assistant, num);
-
-    gchar *file_name;
-    csv_import_result res;
-
-    gtk_assistant_set_page_complete (assistant, page, FALSE);
-
-    file_name = gtk_file_chooser_get_filename ( GTK_FILE_CHOOSER(info->file_chooser ));
-
-    if (file_name)
-    {
-        gchar *filepath = gnc_uri_get_path ( file_name );
-        gchar *filedir = g_path_get_dirname( filepath );
-        info->starting_dir = g_strdup(filedir);
-        g_free ( filedir );
-        g_free ( filepath );
-
-        info->file_name = g_strdup(file_name);
-
-        // generate preview
-        gtk_list_store_clear (info->store);
-        res = csv_import_read_file (info->file_name, info->regexp->str, info->store, 1 );
-        if (res == RESULT_OPEN_FAILED)
-            gnc_error_dialog (info->window, _("The input file can not be opened."));
-        else if (res == RESULT_OK)
-            gtk_assistant_set_page_complete (assistant, page, TRUE);
-        else if (res == MATCH_FOUND)
-            gtk_assistant_set_page_complete (assistant, page, TRUE);
-    }
-    g_free(file_name);
-
-    DEBUG("file_name selected is %s", info->file_name);
-    DEBUG("starting directory is %s", info->starting_dir);
-
-    /* Step to next page if page is complete */
-    if(gtk_assistant_get_page_complete(assistant, page))
-        gtk_assistant_set_current_page (assistant, num + 1);
-
-}
-
-
-/*******************************************************
- * csv_import_hrows_cb
- *
- * call back for the start row / number of header rows
- *******************************************************/
-void csv_import_hrows_cb (GtkWidget *spin, gpointer user_data )
-{
-    CsvImportInfo *info = user_data;
-
-    GtkTreeIter iter;
-    gboolean valid;
-    int num_rows;
-
-    /* Get number of rows for header */
-    info->header_rows = gtk_spin_button_get_value_as_int (GTK_SPIN_BUTTON(spin));
-
-    /* Get number of rows displayed */
-    num_rows = gtk_tree_model_iter_n_children(GTK_TREE_MODEL(info->store), NULL);
-
-    /* Modify background color for header rows */
-    if (info->header_rows == 0)
-    {
-        valid = gtk_tree_model_iter_nth_child(GTK_TREE_MODEL(info->store), &iter, NULL, 0 );
-        if (valid)
-            gtk_list_store_set (info->store, &iter, ROW_COLOR, NULL, -1);
-    }
-    else
-    {
-        if (info->header_rows - 1 < num_rows)
-        {
-            valid = gtk_tree_model_iter_nth_child(GTK_TREE_MODEL(info->store), &iter, NULL, info->header_rows - 1 );
-            if (valid)
-                gtk_list_store_set (info->store, &iter, ROW_COLOR, "pink", -1);
-            valid = gtk_tree_model_iter_next (GTK_TREE_MODEL(info->store), &iter);
-            if (valid)
-                gtk_list_store_set (info->store, &iter, ROW_COLOR, NULL, -1);
-        }
-    }
-}
-
-
-/*******************************************************
- * csv_import_sep_cb
- *
- * call back for type of separartor required
- *******************************************************/
-void csv_import_sep_cb (GtkWidget *radio, gpointer user_data )
-{
-    CsvImportInfo *info = user_data;
-    const gchar *name;
-    gchar *temp;
-
-    if (!gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(radio)))
-    {
-        LEAVE("1st callback of pair. Defer to 2nd callback.");
-        return;
-    }
-
-    name = gtk_buildable_get_name(GTK_BUILDABLE(radio));
-
-    if (g_strcmp0(name, g_strdup("radio_semi")) == 0)
-        g_string_assign (info->regexp, "^(?<type>[^;]*);(?<full_name>[^;]*);(?<name>[^;]*);(?<code>[^;]*);?(?<description>[^;]*);?(?<color>[^;]*);?(?<notes>[^;]*);?(?<commoditym>[^;]*);?(?<commodityn>[^;]*);?(?<hidden>[^;]*);?(?<tax>[^;]*);?(?<place_holder>[^;]*)$");
-
-    if (g_strcmp0(name, g_strdup("radio_comma")) == 0)
-        g_string_assign (info->regexp, "^(?<type>[^,]*),(?<full_name>[^,]*),(?<name>[^,]*),(?<code>[^,]*),?(?<description>[^,]*),?(?<color>[^,]*),?(?<notes>[^,]*),?(?<commoditym>[^,]*),?(?<commodityn>[^,]*),?(?<hidden>[^,]*),?(?<tax>[^,]*),?(?<place_holder>[^,]*)$");
-
-    if (g_strcmp0(name, g_strdup("radio_semiq")) == 0)
-        g_string_assign (info->regexp, "^((?<type>[^\";]*)|\"(?<type>[^\"]*)\");((?<full_name>[^\";]*)|\"(?<full_name>[^\"]*)\");((?<name>[^\";]*)|\"(?<name>[^\"]*)\");((?<code>[^\";]*)|\"(?<code>[^\"]*)\");((?<description>[^\";]*)|\"(?<description>[^\"]*)\");((?<color>[^\";]*)|\"(?<color>[^\"]*)\");((?<notes>[^\";]*)|\"(?<notes>[^\"]*)\");((?<commoditym>[^\";]*)|\"(?<commoditym>[^\"]*)\");((?<commodityn>[^\";]*)|\"(?<commodityn>[^\"]*)\");((?<hidden>[^\";]*)|\"(?<hidden>[^\"]*)\");((?<tax>[^\";]*)|\"(?<tax>[^\"]*)\");((?<place_holder>[^\";]*)|\"(?<place_holder>[^\"]*)\")$");
-
-    if (g_strcmp0(name, g_strdup("radio_commaq")) == 0)
-        g_string_assign (info->regexp, "^((?<type>[^\",]*)|\"(?<type>[^\"]*)\"),((?<full_name>[^\",]*)|\"(?<full_name>[^\"]*)\"),((?<name>[^\",]*)|\"(?<name>[^\"]*)\"),((?<code>[^\",]*)|\"(?<code>[^\"]*)\"),((?<description>[^\",]*)|\"(?<description>[^\"]*)\"),((?<color>[^\",]*)|\"(?<color>[^\"]*)\"),((?<notes>[^\",]*)|\"(?<notes>[^\"]*)\"),((?<commoditym>[^\",]*)|\"(?<commoditym>[^\"]*)\"),((?<commodityn>[^\",]*)|\"(?<commodityn>[^\"]*)\"),((?<hidden>[^\",]*)|\"(?<hidden>[^\"]*)\"),((?<tax>[^\",]*)|\"(?<tax>[^\"]*)\"),((?<place_holder>[^\",]*)|\"(?<place_holder>[^\"]*)\")$");
-
-    if (g_strcmp0(name, g_strdup("radio_custom")) == 0)
-    {
-        temp = gnc_input_dialog (0, _("Adjust regular expression used for import"), _("This regular expression is used to parse the import file. Modify according to your needs.\n"), info->regexp->str);
-        if (temp)
-        {
-            g_string_assign (info->regexp, temp);
-            g_free (temp);
-        }
-    }
-
-    /* Generate preview */
-    gtk_list_store_clear (info->store);
-
-    if (csv_import_read_file (info->file_name, info->regexp->str, info->store, 11 ) == MATCH_FOUND)
-        gtk_widget_set_sensitive (info->header_row_spin, TRUE);
-    else
-        gtk_widget_set_sensitive (info->header_row_spin, FALSE);
-
-    /* Reset Header spin to 0 */
-    gtk_spin_button_set_value( GTK_SPIN_BUTTON(info->header_row_spin), 0 );
-}
-
-
-/*******************************************************
- * load_settings
- *
- * load the default settings for the assistant
- *******************************************************/
-static
-void load_settings (CsvImportInfo *info)
-{
-    info->header_rows = 0;
-    info->error = "";
-    info->starting_dir = NULL;
-    info->file_name = NULL;
-    info->error = "";
-
-    /* The default directory for the user to select files. */
-    info->starting_dir = gnc_get_default_directory(GNC_PREFS_GROUP);
-}
-
-
-/* =============================================================== */
-
-
-/********************************************************************\
- * gnc_input_dialog                                                 *
- *   simple convenience dialog to get a single value from the user  *
- *   user may choose between "Ok" and "Cancel"                      *
- *                                                                  *
- * NOTE: This function does not return until the dialog is closed   *
- *                                                                  *
- * Args:   parent  - the parent window or NULL                      *
- *         title   - the title of the dialog                        *
- *         msg     - the message to display                         *
- *         default_input - will be displayed as default input       *
- * Return: the input (text) the user entered, if pressed "Ok"       *
- *         NULL, if pressed "Cancel"                                *
-\********************************************************************/
-static gchar *
-gnc_input_dialog (GtkWidget *parent, const gchar *title, const gchar *msg, const gchar *default_input)
-{
-    GtkWidget *dialog, *label, *content_area;
-    gint result;
-    GtkWidget *view;
-    GtkTextBuffer *buffer;
-    gchar *user_input;
-    GtkTextIter start, end;
-
-    /* Create the widgets */
-    dialog = gtk_dialog_new_with_buttons (title, GTK_WINDOW (parent),
-                                          GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT,
-                                          GTK_STOCK_OK, GTK_RESPONSE_ACCEPT,
-                                          GTK_STOCK_CANCEL, GTK_RESPONSE_REJECT,
-                                          NULL);
-
-    content_area = gtk_dialog_get_content_area (GTK_DIALOG (dialog));
-
-    // add a label
-    label = gtk_label_new (msg);
-    gtk_container_add (GTK_CONTAINER (content_area), label);
-
-    // add a textview
-    view = gtk_text_view_new ();
-    gtk_text_view_set_wrap_mode (GTK_TEXT_VIEW (view), GTK_WRAP_WORD_CHAR);
-    buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (view));
-    gtk_text_buffer_set_text (buffer, default_input, -1);
-    gtk_container_add (GTK_CONTAINER (content_area), view);
-
-    // run the dialog
-    gtk_widget_show_all (dialog);
-    result = gtk_dialog_run (GTK_DIALOG (dialog));
-
-    if (result == GTK_RESPONSE_REJECT)
-        user_input = 0;
-    else
-    {
-        gtk_text_buffer_get_start_iter (buffer, &start);
-        gtk_text_buffer_get_end_iter (buffer, &end);
-        user_input = gtk_text_buffer_get_text (buffer,
-                                               &start, &end, FALSE);
-    }
-
-    gtk_widget_destroy (dialog);
-
-    return user_input;
-}
-
-
-/* =============================================================== */
-
-
-/*******************************************************
- * Assistant page prepare functions
- *******************************************************/
-void
-csv_import_assistant_start_page_prepare (GtkAssistant *assistant,
-        gpointer user_data)
-{
-    gint num = gtk_assistant_get_current_page (assistant);
-    GtkWidget *page = gtk_assistant_get_nth_page (assistant, num);
-
-    /* Enable the Assistant Buttons */
-    gtk_assistant_set_page_complete (assistant, page, TRUE);
-}
-
-
-void
-csv_import_assistant_file_page_prepare (GtkAssistant *assistant,
-                                        gpointer user_data)
-{
-    CsvImportInfo *info = user_data;
-    gint num = gtk_assistant_get_current_page (assistant);
-    GtkWidget *page = gtk_assistant_get_nth_page (assistant, num);
-
-    /* Set the default directory */
-    if (info->starting_dir)
-        gtk_file_chooser_set_current_folder(GTK_FILE_CHOOSER(info->file_chooser), info->starting_dir);
-
-    /* Disable the Forward Assistant Button */
-    gtk_assistant_set_page_complete (assistant, page, FALSE);
-}
-
-
-void
-csv_import_assistant_account_page_prepare (GtkAssistant *assistant,
-        gpointer user_data)
-{
-    CsvImportInfo *info = user_data;
-
-    gtk_list_store_clear (info->store);
-
-    if (csv_import_read_file (info->file_name, info->regexp->str, info->store, 11 ) == MATCH_FOUND)
-        gtk_widget_set_sensitive (info->header_row_spin, TRUE);
-    else
-        gtk_widget_set_sensitive (info->header_row_spin, FALSE);
-}
-
-
-void
-csv_import_assistant_finish_page_prepare (GtkAssistant *assistant,
-        gpointer user_data)
-{
-    CsvImportInfo *info = user_data;
-    gint num = gtk_assistant_get_current_page (assistant);
-    GtkWidget *page = gtk_assistant_get_nth_page (assistant, num);
-    gchar *text;
-
-    /* Set Finish page text */
-    /* Before creating accounts, if this is a new book, tell user they can
-     * specify book options, since they affect how transactions are created */
-    if (info->new_book)
-    {
-        text = g_strdup_printf (gettext (new_book_finish_tree_string), info->file_name);
-    }
-    else
-    {
-        text = g_strdup_printf (gettext (finish_tree_string), info->file_name);
-    }
-    gtk_label_set_text (GTK_LABEL(info->finish_label), text);
-    g_free(text);
-
-    /* Save the Window size and directory */
-    gnc_set_default_directory(GNC_PREFS_GROUP, info->starting_dir);
-
-    /* Enable the Assistant Buttons */
-    gtk_assistant_set_page_complete (assistant, page, TRUE);
-}
-
-
-void
-csv_import_assistant_summary_page_prepare (GtkAssistant *assistant,
-        gpointer user_data)
-{
-    CsvImportInfo *info = user_data;
-    gchar *text, *errtext, *mtext;
-
-    /* Before creating accounts, if this is a new book, let user specify
-     * book options, since they affect how transactions are created */
-    if (info->new_book)
-        info->new_book = gnc_new_book_option_display();
-
-    if (!g_strcmp0(info->error, "") == 0)
-    {
-        GtkTextBuffer *buffer;
-
-        buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (info->summary_error_view));
-        text = g_strdup_printf(gettext ("Import completed but with errors!\n\nThe number of Accounts added was %u and "
-                                        "updated was %u.\n\nSee below for errors..." ), info->num_new, info->num_updates );
-        errtext = g_strdup_printf ( "%s", info->error);
-        gtk_text_buffer_set_text (buffer, errtext, -1);
-        g_free(errtext);
-        g_free(info->error);
-    }
-    else
-        text = g_strdup_printf(gettext ("Import completed successfully!\n\nThe number of Accounts added was %u and "
-                                        "updated was %u.\n" ), info->num_new, info->num_updates );
-
-    mtext = g_strdup_printf("<span size=\"medium\"><b>%s</b></span>", text);
-    gtk_label_set_markup(GTK_LABEL(info->summary_label), mtext);
-
-    g_free(text);
-    g_free(mtext);
-}
-
-
-void
-csv_import_assistant_prepare (GtkAssistant *assistant, GtkWidget *page,
-                              gpointer user_data)
-{
-    gint currentpage = gtk_assistant_get_current_page(assistant);
-
-    switch (currentpage)
-    {
-    case 0:
-        /* Current page is Import Start page */
-        csv_import_assistant_start_page_prepare (assistant, user_data);
-        break;
-    case 1:
-        /* Current page is File select page */
-        csv_import_assistant_file_page_prepare (assistant, user_data);
-        break;
-    case 2:
-        /* Current page is Account page */
-        csv_import_assistant_account_page_prepare (assistant, user_data);
-        break;
-    case 3:
-        /* Current page is Finish page */
-        csv_import_assistant_finish_page_prepare (assistant, user_data);
-        break;
-    case 4:
-        /* Current page is Summary page */
-        csv_import_assistant_summary_page_prepare (assistant, user_data);
-        break;
-    }
-}
-
-
-/*******************************************************
- * Assistant call back functions
- *******************************************************/
-static void
-csv_import_assistant_destroy_cb (GtkObject *object, gpointer user_data)
-{
-    CsvImportInfo *info = user_data;
-    gnc_unregister_gui_component_by_data (ASSISTANT_CSV_IMPORT_CM_CLASS, info);
-    g_free (info);
-}
-
-void
-csv_import_assistant_cancel (GtkAssistant *assistant, gpointer user_data)
-{
-    CsvImportInfo *info = user_data;
-    gnc_close_gui_component_by_data (ASSISTANT_CSV_IMPORT_CM_CLASS, info);
-}
-
-void
-csv_import_assistant_close (GtkAssistant *assistant, gpointer user_data)
-{
-    CsvImportInfo *info = user_data;
-    gnc_close_gui_component_by_data (ASSISTANT_CSV_IMPORT_CM_CLASS, info);
-}
-
-void
-csv_import_assistant_finish (GtkAssistant *assistant, gpointer user_data)
-{
-    CsvImportInfo *info = user_data;
-
-    gtk_list_store_clear (info->store);
-    csv_import_read_file (info->file_name, info->regexp->str, info->store, 0 );
-    csv_account_import (info);
-}
-
-static void
-csv_import_close_handler (gpointer user_data)
-{
-    CsvImportInfo *info = user_data;
-
-    g_free(info->starting_dir);
-    g_free(info->file_name);
-    g_string_free(info->regexp, TRUE);
-
-    gnc_save_window_size(GNC_PREFS_GROUP, GTK_WINDOW(info->window));
-    gtk_widget_destroy (info->window);
-}
-
-/*******************************************************
- * Create the Assistant
- *******************************************************/
-static GtkWidget *
-csv_import_assistant_create (CsvImportInfo *info)
-{
-    GtkBuilder *builder;
-    GtkWidget *window;
-    GtkWidget *box, *h_box;
-    GtkWidget *button;
-    GtkCellRenderer *renderer;
-    GtkTreeViewColumn *column;
-
-    builder = gtk_builder_new();
-    gnc_builder_add_from_file  (builder , "assistant-csv-account-import.glade", "num_hrows_adj");
-    gnc_builder_add_from_file  (builder , "assistant-csv-account-import.glade", "CSV Account Import Assistant");
-    window = GTK_WIDGET(gtk_builder_get_object (builder, "CSV Account Import Assistant"));
-    info->window = window;
-
-    /* Set the assistant colors */
-    gnc_assistant_set_colors (GTK_ASSISTANT (info->window));
-
-    /* Load default settings */
-    load_settings (info);
-
-    /* Enable buttons on all page. */
-    gtk_assistant_set_page_complete (GTK_ASSISTANT (window),
-                                     GTK_WIDGET(gtk_builder_get_object(builder, "start_page")),
-                                     TRUE);
-    gtk_assistant_set_page_complete (GTK_ASSISTANT (window),
-                                     GTK_WIDGET(gtk_builder_get_object(builder, "file_page")),
-                                     FALSE);
-    gtk_assistant_set_page_complete (GTK_ASSISTANT (window),
-                                     GTK_WIDGET(gtk_builder_get_object(builder, "import_tree_page")),
-                                     TRUE);
-    gtk_assistant_set_page_complete (GTK_ASSISTANT (window),
-                                     GTK_WIDGET(gtk_builder_get_object(builder, "end_page")),
-                                     FALSE);
-    gtk_assistant_set_page_complete (GTK_ASSISTANT (window),
-                                     GTK_WIDGET(gtk_builder_get_object(builder, "summary_page")),
-                                     TRUE);
-
-    /* Start Page */
-
-    /* File chooser Page */
-    info->file_chooser = gtk_file_chooser_widget_new (GTK_FILE_CHOOSER_ACTION_OPEN);
-    g_signal_connect (G_OBJECT (info->file_chooser), "file-activated",
-                      G_CALLBACK (csv_import_file_chooser_confirm_cb), info);
-    button = gtk_button_new_from_stock(GTK_STOCK_OK);
-    gtk_widget_set_size_request (button, 100, -1);
-    gtk_widget_show (button);
-    h_box = gtk_hbox_new(TRUE, 0);
-    gtk_box_pack_start(GTK_BOX(h_box), button, FALSE, FALSE, 0);
-    gtk_file_chooser_set_extra_widget (GTK_FILE_CHOOSER(info->file_chooser), h_box);
-    g_signal_connect (G_OBJECT (button), "clicked",
-                      G_CALLBACK (csv_import_file_chooser_confirm_cb), info);
-
-    box = GTK_WIDGET(gtk_builder_get_object(builder, "file_page"));
-    gtk_box_pack_start (GTK_BOX (box), info->file_chooser, TRUE, TRUE, 6);
-    gtk_widget_show (info->file_chooser);
-
-    /* Account Tree Page */
-    info->header_row_spin = GTK_WIDGET(gtk_builder_get_object (builder, "num_hrows"));
-    info->tree_view = GTK_WIDGET(gtk_builder_get_object (builder, "treeview"));
-
-    info->regexp = g_string_new ( "^(?<type>[^;]*);(?<full_name>[^;]*);(?<name>[^;]*);(?<code>[^;]*);?(?<description>[^;]*);?(?<color>[^;]*);?(?<notes>[^;]*);?(?<commoditym>[^;]*);?(?<commodityn>[^;]*);?(?<hidden>[^;]*);?(?<tax>[^;]*);?(?<place_holder>[^;]*)$");
-
-    /* create model and bind to view */
-    info->store = gtk_list_store_new (N_COLUMNS,
-                                      G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING,
-                                      G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING);
-    gtk_tree_view_set_model( GTK_TREE_VIEW(info->tree_view), GTK_TREE_MODEL(info->store) );
-#define CREATE_COLUMN(description,column_id) \
-  renderer = gtk_cell_renderer_text_new (); \
-  column = gtk_tree_view_column_new_with_attributes (mnemonic_escape(_(description)), renderer, "text", column_id, NULL); \
-  gtk_tree_view_column_add_attribute(column, renderer, "background", ROW_COLOR); \
-  gtk_tree_view_column_set_resizable (column, TRUE); \
-  gtk_tree_view_append_column (GTK_TREE_VIEW (info->tree_view), column);
-    CREATE_COLUMN ("type", TYPE);
-    CREATE_COLUMN ("full_name", FULL_NAME);
-    CREATE_COLUMN ("name", NAME);
-    CREATE_COLUMN ("code", CODE);
-    CREATE_COLUMN ("description", DESCRIPTION);
-    CREATE_COLUMN ("color", COLOR);
-    CREATE_COLUMN ("notes", NOTES);
-    CREATE_COLUMN ("commoditym", COMMODITYM);
-    CREATE_COLUMN ("commodityn", COMMODITYN);
-    CREATE_COLUMN ("hidden", HIDDEN);
-    CREATE_COLUMN ("tax", TAX);
-    CREATE_COLUMN ("place_holder", PLACE_HOLDER);
-
-    /* Finish Page */
-    info->finish_label = GTK_WIDGET(gtk_builder_get_object(builder, "end_page"));
-    /* Summary Page */
-    info->summary_label = GTK_WIDGET(gtk_builder_get_object(builder, "summary_label"));
-    info->summary_error_view = GTK_WIDGET(gtk_builder_get_object(builder, "summary_error_view"));
-
-    g_signal_connect (G_OBJECT(window), "destroy",
-                      G_CALLBACK (csv_import_assistant_destroy_cb), info);
-
-    gnc_restore_window_size (GNC_PREFS_GROUP, GTK_WINDOW(info->window));
-
-    gtk_builder_connect_signals(builder, info);
-    g_object_unref(G_OBJECT(builder));
-    return window;
-}
-
-
-/********************************************************************\
- * gnc_file_csv_account_import                                      *
- * opens up a assistant to import accounts.                         *
- *                                                                  *
- * Args:   import_type                                              *
- * Return: nothing                                                  *
-\********************************************************************/
-void
-gnc_file_csv_account_import(void)
-{
-    CsvImportInfo *info;
-
-    info = g_new0 (CsvImportInfo, 1);
-
-    /* In order to trigger a book options display on the creation of a new book,
-     * we need to detect when we are dealing with a new book. */
-    info->new_book = gnc_is_new_book();
-
-    csv_import_assistant_create (info);
-
-    gnc_register_gui_component (ASSISTANT_CSV_IMPORT_CM_CLASS,
-                                NULL, csv_import_close_handler,
-                                info);
-
-    gtk_widget_show_all (info->window);
-
-    gnc_window_adjust_for_screen (GTK_WINDOW(info->window));
-}

Deleted: gnucash/trunk/src/import-export/csv-import/assistant-csv-account-import.glade
===================================================================
--- gnucash/trunk/src/import-export/csv-import/assistant-csv-account-import.glade	2013-12-15 17:20:10 UTC (rev 23566)
+++ gnucash/trunk/src/import-export/csv-import/assistant-csv-account-import.glade	2013-12-15 17:21:20 UTC (rev 23567)
@@ -1,382 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<interface>
-  <requires lib="gtk+" version="2.16"/>
-  <!-- interface-naming-policy project-wide -->
-  <object class="GtkAssistant" id="CSV Account Import Assistant">
-    <property name="can_focus">False</property>
-    <property name="border_width">12</property>
-    <property name="title" translatable="yes">CSV Import Assistant</property>
-    <property name="default_width">400</property>
-    <property name="default_height">500</property>
-    <signal name="close" handler="csv_import_assistant_close" swapped="no"/>
-    <signal name="apply" handler="csv_import_assistant_finish" swapped="no"/>
-    <signal name="prepare" handler="csv_import_assistant_prepare" swapped="no"/>
-    <signal name="cancel" handler="csv_import_assistant_cancel" swapped="no"/>
-    <child>
-      <object class="GtkVBox" id="start_page">
-        <property name="visible">True</property>
-        <property name="can_focus">False</property>
-        <property name="border_width">12</property>
-        <child>
-          <object class="GtkLabel" id="start_label">
-            <property name="visible">True</property>
-            <property name="can_focus">False</property>
-            <property name="label" translatable="yes">
-This assistant will help you import Accounts from a file.
-
-The file must be in the same format as that exported as this is a fixed format import. If the account is missing, based on the full account name, it will be added as long as the security / currency specified exists. If the account exists, then four fields will be updated. These are code, description, notes and color.
-
-Click on 'Forward' to proceed or 'Cancel' to Abort Import.
-</property>
-            <property name="justify">center</property>
-            <property name="wrap">True</property>
-          </object>
-          <packing>
-            <property name="expand">False</property>
-            <property name="fill">False</property>
-            <property name="position">0</property>
-          </packing>
-        </child>
-      </object>
-      <packing>
-        <property name="page_type">intro</property>
-        <property name="title" translatable="yes">Import Account Assistant</property>
-        <property name="complete">True</property>
-      </packing>
-    </child>
-    <child>
-      <object class="GtkVBox" id="file_page">
-        <property name="visible">True</property>
-        <property name="can_focus">False</property>
-        <property name="border_width">12</property>
-        <child>
-          <object class="GtkLabel" id="label4">
-            <property name="visible">True</property>
-            <property name="can_focus">False</property>
-            <property name="label" translatable="yes">
-Enter file name and location for the Import...
-</property>
-            <property name="wrap">True</property>
-          </object>
-          <packing>
-            <property name="expand">False</property>
-            <property name="fill">False</property>
-            <property name="position">0</property>
-          </packing>
-        </child>
-        <child>
-          <placeholder/>
-        </child>
-      </object>
-      <packing>
-        <property name="title" translatable="yes">Choose File to Import</property>
-      </packing>
-    </child>
-    <child>
-      <object class="GtkVBox" id="import_tree_page">
-        <property name="visible">True</property>
-        <property name="can_focus">False</property>
-        <property name="border_width">12</property>
-        <child>
-          <object class="GtkHBox" id="hbox1">
-            <property name="visible">True</property>
-            <property name="can_focus">False</property>
-            <child>
-              <object class="GtkLabel" id="label3">
-                <property name="visible">True</property>
-                <property name="can_focus">False</property>
-                <property name="xpad">6</property>
-                <property name="label" translatable="yes">Number of rows for the Header</property>
-              </object>
-              <packing>
-                <property name="expand">False</property>
-                <property name="fill">False</property>
-                <property name="position">0</property>
-              </packing>
-            </child>
-            <child>
-              <object class="GtkSpinButton" id="num_hrows">
-                <property name="visible">True</property>
-                <property name="can_focus">True</property>
-                <property name="editable">False</property>
-                <property name="invisible_char">&#x25CF;</property>
-                <property name="invisible_char_set">True</property>
-                <property name="primary_icon_activatable">False</property>
-                <property name="secondary_icon_activatable">False</property>
-                <property name="primary_icon_sensitive">True</property>
-                <property name="secondary_icon_sensitive">True</property>
-                <property name="adjustment">num_hrows_adj</property>
-                <signal name="value-changed" handler="csv_import_hrows_cb" swapped="no"/>
-              </object>
-              <packing>
-                <property name="expand">False</property>
-                <property name="fill">False</property>
-                <property name="position">1</property>
-              </packing>
-            </child>
-            <child>
-              <placeholder/>
-            </child>
-          </object>
-          <packing>
-            <property name="expand">False</property>
-            <property name="fill">False</property>
-            <property name="position">0</property>
-          </packing>
-        </child>
-        <child>
-          <object class="GtkFrame" id="separator_frame">
-            <property name="visible">True</property>
-            <property name="can_focus">False</property>
-            <property name="label_xalign">0</property>
-            <property name="shadow_type">in</property>
-            <child>
-              <object class="GtkTable" id="table4">
-                <property name="visible">True</property>
-                <property name="can_focus">False</property>
-                <property name="border_width">12</property>
-                <property name="n_rows">4</property>
-                <property name="n_columns">4</property>
-                <child>
-                  <object class="GtkRadioButton" id="radio_semi">
-                    <property name="label" translatable="yes">Semicolon Separated</property>
-                    <property name="visible">True</property>
-                    <property name="can_focus">True</property>
-                    <property name="receives_default">False</property>
-                    <property name="use_action_appearance">False</property>
-                    <property name="active">True</property>
-                    <property name="draw_indicator">True</property>
-                    <signal name="toggled" handler="csv_import_sep_cb" swapped="no"/>
-                  </object>
-                </child>
-                <child>
-                  <object class="GtkRadioButton" id="radio_semiq">
-                    <property name="label" translatable="yes">Semicolon Separated with Quotes</property>
-                    <property name="visible">True</property>
-                    <property name="can_focus">True</property>
-                    <property name="receives_default">False</property>
-                    <property name="use_action_appearance">False</property>
-                    <property name="draw_indicator">True</property>
-                    <property name="group">radio_semi</property>
-                    <signal name="toggled" handler="csv_import_sep_cb" swapped="no"/>
-                  </object>
-                  <packing>
-                    <property name="left_attach">2</property>
-                    <property name="right_attach">3</property>
-                  </packing>
-                </child>
-                <child>
-                  <object class="GtkRadioButton" id="radio_comma">
-                    <property name="label" translatable="yes">Comma Separated</property>
-                    <property name="visible">True</property>
-                    <property name="can_focus">True</property>
-                    <property name="receives_default">False</property>
-                    <property name="use_action_appearance">False</property>
-                    <property name="draw_indicator">True</property>
-                    <property name="group">radio_semi</property>
-                    <signal name="toggled" handler="csv_import_sep_cb" swapped="no"/>
-                  </object>
-                  <packing>
-                    <property name="top_attach">1</property>
-                    <property name="bottom_attach">2</property>
-                  </packing>
-                </child>
-                <child>
-                  <object class="GtkRadioButton" id="radio_commaq">
-                    <property name="label" translatable="yes">Comma Separated with Quotes</property>
-                    <property name="visible">True</property>
-                    <property name="can_focus">True</property>
-                    <property name="receives_default">False</property>
-                    <property name="use_action_appearance">False</property>
-                    <property name="draw_indicator">True</property>
-                    <property name="group">radio_semi</property>
-                    <signal name="toggled" handler="csv_import_sep_cb" swapped="no"/>
-                  </object>
-                  <packing>
-                    <property name="left_attach">2</property>
-                    <property name="right_attach">3</property>
-                    <property name="top_attach">1</property>
-                    <property name="bottom_attach">2</property>
-                  </packing>
-                </child>
-                <child>
-                  <object class="GtkRadioButton" id="radio_custom">
-                    <property name="label" translatable="yes">Custom regular Expression</property>
-                    <property name="visible">True</property>
-                    <property name="can_focus">True</property>
-                    <property name="receives_default">False</property>
-                    <property name="use_action_appearance">False</property>
-                    <property name="draw_indicator">True</property>
-                    <property name="group">radio_semi</property>
-                    <signal name="toggled" handler="csv_import_sep_cb" swapped="no"/>
-                  </object>
-                  <packing>
-                    <property name="top_attach">2</property>
-                    <property name="bottom_attach">3</property>
-                  </packing>
-                </child>
-                <child>
-                  <placeholder/>
-                </child>
-                <child>
-                  <placeholder/>
-                </child>
-                <child>
-                  <placeholder/>
-                </child>
-                <child>
-                  <placeholder/>
-                </child>
-                <child>
-                  <placeholder/>
-                </child>
-                <child>
-                  <placeholder/>
-                </child>
-                <child>
-                  <placeholder/>
-                </child>
-                <child>
-                  <placeholder/>
-                </child>
-                <child>
-                  <placeholder/>
-                </child>
-                <child>
-                  <placeholder/>
-                </child>
-                <child>
-                  <placeholder/>
-                </child>
-              </object>
-            </child>
-            <child type="label">
-              <object class="GtkLabel" id="label6">
-                <property name="visible">True</property>
-                <property name="can_focus">False</property>
-                <property name="label" translatable="yes">Select Separator Type</property>
-                <property name="use_markup">True</property>
-              </object>
-            </child>
-          </object>
-          <packing>
-            <property name="expand">False</property>
-            <property name="fill">False</property>
-            <property name="padding">7</property>
-            <property name="position">1</property>
-          </packing>
-        </child>
-        <child>
-          <object class="GtkFrame" id="preview_frame">
-            <property name="visible">True</property>
-            <property name="can_focus">False</property>
-            <property name="label_xalign">0</property>
-            <property name="shadow_type">in</property>
-            <child>
-              <object class="GtkScrolledWindow" id="scroll_window">
-                <property name="visible">True</property>
-                <property name="can_focus">True</property>
-                <property name="border_width">6</property>
-                <property name="hscrollbar_policy">automatic</property>
-                <property name="vscrollbar_policy">automatic</property>
-                <child>
-                  <object class="GtkTreeView" id="treeview">
-                    <property name="visible">True</property>
-                    <property name="can_focus">True</property>
-                  </object>
-                </child>
-              </object>
-            </child>
-            <child type="label">
-              <object class="GtkLabel" id="label8">
-                <property name="visible">True</property>
-                <property name="can_focus">False</property>
-                <property name="label" translatable="yes">Preview</property>
-                <property name="use_markup">True</property>
-              </object>
-            </child>
-          </object>
-          <packing>
-            <property name="expand">True</property>
-            <property name="fill">True</property>
-            <property name="position">2</property>
-          </packing>
-        </child>
-      </object>
-      <packing>
-        <property name="page_type">progress</property>
-        <property name="title" translatable="yes">Import Account Preview, first 10 rows only</property>
-        <property name="complete">True</property>
-      </packing>
-    </child>
-    <child>
-      <object class="GtkLabel" id="end_page">
-        <property name="visible">True</property>
-        <property name="can_focus">False</property>
-        <property name="label" translatable="yes">Press Apply to create export file.
-Cancel to abort.</property>
-        <property name="wrap">True</property>
-      </object>
-      <packing>
-        <property name="page_type">confirm</property>
-        <property name="title" translatable="yes">Import Accounts Now</property>
-      </packing>
-    </child>
-    <child>
-      <object class="GtkVBox" id="summary_page">
-        <property name="visible">True</property>
-        <property name="can_focus">False</property>
-        <property name="border_width">12</property>
-        <child>
-          <object class="GtkLabel" id="summary_label">
-            <property name="visible">True</property>
-            <property name="can_focus">False</property>
-            <property name="label" translatable="yes">label</property>
-            <property name="use_markup">True</property>
-          </object>
-          <packing>
-            <property name="expand">True</property>
-            <property name="fill">True</property>
-            <property name="position">0</property>
-          </packing>
-        </child>
-        <child>
-          <object class="GtkScrolledWindow" id="summary_error_scrolledwindow">
-            <property name="visible">True</property>
-            <property name="can_focus">False</property>
-            <property name="border_width">1</property>
-            <property name="hscrollbar_policy">automatic</property>
-            <property name="vscrollbar_policy">automatic</property>
-            <property name="shadow_type">etched-in</property>
-            <child>
-              <object class="GtkTextView" id="summary_error_view">
-                <property name="visible">True</property>
-                <property name="can_focus">False</property>
-                <property name="left_margin">2</property>
-                <property name="right_margin">2</property>
-              </object>
-            </child>
-          </object>
-          <packing>
-            <property name="expand">True</property>
-            <property name="fill">True</property>
-            <property name="position">1</property>
-          </packing>
-        </child>
-        <child>
-          <placeholder/>
-        </child>
-      </object>
-      <packing>
-        <property name="page_type">summary</property>
-        <property name="title" translatable="yes">Import Summary</property>
-        <property name="complete">True</property>
-      </packing>
-    </child>
-  </object>
-  <object class="GtkAdjustment" id="num_hrows_adj">
-    <property name="upper">100</property>
-    <property name="step_increment">1</property>
-    <property name="page_increment">10</property>
-  </object>
-</interface>

Deleted: gnucash/trunk/src/import-export/csv-import/assistant-csv-account-import.h
===================================================================
--- gnucash/trunk/src/import-export/csv-import/assistant-csv-account-import.h	2013-12-15 17:20:10 UTC (rev 23566)
+++ gnucash/trunk/src/import-export/csv-import/assistant-csv-account-import.h	2013-12-15 17:21:20 UTC (rev 23567)
@@ -1,69 +0,0 @@
-/*******************************************************************\
- * assistant-csv-account-import.h -- An assistant for importing     *
- *                                         Accounts from a file.    *
- *                                                                  *
- * Copyright (C) 2012 Robert Fewell                                 *
- *                                                                  *
- * This program is free software; you can redistribute it and/or    *
- * modify it under the terms of the GNU General Public License as   *
- * published by the Free Software Foundation; either version 2 of   *
- * the License, or (at your option) any later version.              *
- *                                                                  *
- * This program is distributed in the hope that it will be useful,  *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of   *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the    *
- * GNU General Public License for more details.                     *
- *                                                                  *
- * You should have received a copy of the GNU General Public License*
- * along with this program; if not, contact:                        *
- *                                                                  *
- * Free Software Foundation           Voice:  +1-617-542-5942       *
- * 51 Franklin Street, Fifth Floor    Fax:    +1-617-542-2652       *
- * Boston, MA  02110-1301,  USA       gnu at gnu.org                   *
-\********************************************************************/
-/** @file assistant-csv-account-import.h
-    @brief CSV Import Assistant
-    @author Copyright (c) 2011 Robert Fewell
-*/
-#ifndef GNC_ASSISTANT_CSV_IMPORT_H
-#define GNC_ASSISTANT_CSV_IMPORT_H
-
-
-// Account tree model
-enum tree_import_model_columns
-{
-    TYPE, FULL_NAME, NAME, CODE, DESCRIPTION, COLOR,
-    NOTES, COMMODITYM, COMMODITYN, HIDDEN, TAX, PLACE_HOLDER, ROW_COLOR,
-    N_COLUMNS
-};
-
-typedef struct
-{
-    GtkWidget    *window;
-    GtkWidget    *assistant;
-
-    GtkWidget    *file_chooser;
-    GtkWidget    *tree_view;
-    GtkListStore *store;
-    GString      *regexp;
-    GtkWidget    *header_row_spin;
-    GtkWidget    *finish_label;
-    GtkWidget    *summary_label;
-    GtkWidget    *summary_error_view;
-
-    gchar        *starting_dir;
-    gchar        *file_name;
-    gchar        *error;
-
-    int           header_rows;
-    int           num_new;
-    int           num_updates;
-    gboolean      new_book; /**< Are we importing into a new book?; if yes, call book options */
-} CsvImportInfo;
-
-
-/** The gnc_file_csv_account_import() will let the user import
- *  accounts from a delimited file.
- */
-void gnc_file_csv_account_import (void);
-#endif

Deleted: gnucash/trunk/src/import-export/csv-import/assistant-csv-trans-import.c
===================================================================
--- gnucash/trunk/src/import-export/csv-import/assistant-csv-trans-import.c	2013-12-15 17:20:10 UTC (rev 23566)
+++ gnucash/trunk/src/import-export/csv-import/assistant-csv-trans-import.c	2013-12-15 17:21:20 UTC (rev 23567)
@@ -1,1853 +0,0 @@
-/*******************************************************************\
- * assistant-csv-trans-import.c -- An assistant for importing       *
- *                                     Transactions from a file.    *
- *                                                                  *
- * Copyright (C) 2012 Robert Fewell                                 *
- * Copyright (c) 2007 Benny Sperisen <lasindi at gmail.com>            *
- *                                                                  *
- * This program is free software; you can redistribute it and/or    *
- * modify it under the terms of the GNU General Public License as   *
- * published by the Free Software Foundation; either version 2 of   *
- * the License, or (at your option) any later version.              *
- *                                                                  *
- * This program is distributed in the hope that it will be useful,  *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of   *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the    *
- * GNU General Public License for more details.                     *
- *                                                                  *
- * You should have received a copy of the GNU General Public License*
- * along with this program; if not, contact:                        *
- *                                                                  *
- * Free Software Foundation           Voice:  +1-617-542-5942       *
- * 51 Franklin Street, Fifth Floor    Fax:    +1-617-542-2652       *
- * Boston, MA  02110-1301,  USA       gnu at gnu.org                   *
-\********************************************************************/
-/** @file assistant-csv-trans-import.c
-    @brief CSV Import Assistant
-    @author Copyright (c) 2012 Robert Fewell
-*/
-#include "config.h"
-
-#include <gtk/gtk.h>
-#include <glib/gi18n.h>
-
-#include "gnc-ui.h"
-#include "gnc-uri-utils.h"
-#include "gnc-ui-util.h"
-#include "dialog-utils.h"
-
-#include "gnc-component-manager.h"
-
-#include "assistant-utils.h"
-#include "assistant-csv-trans-import.h"
-
-#include "import-account-matcher.h"
-#include "import-main-matcher.h"
-
-#include "gnc-csv-model.h"
-#include "gnc-csv-gnumeric-popup.h"
-#include <goffice/gtk/go-charmap-sel.h>
-
-#define MIN_COL_WIDTH 70
-#define GNC_PREFS_GROUP "dialogs.import.csv"
-#define ASSISTANT_CSV_IMPORT_TRANS_CM_CLASS "assistant-csv-trans-import"
-
-/* This static indicates the debugging module that this .o belongs to.  */
-static QofLogModule log_module = GNC_MOD_ASSISTANT;
-
-/** Enumeration for separator checkbutton types. These are the
- * different types of checkbuttons that the user can click to
- * configure separators in a delimited file. */
-enum SEP_BUTTON_TYPES {SEP_SPACE, SEP_TAB, SEP_COMMA, SEP_COLON, SEP_SEMICOLON, SEP_HYPHEN,
-                       SEP_NUM_OF_TYPES
-                      };
-
-typedef struct
-{
-
-    GtkWidget       *window;
-
-    GtkWidget       *file_chooser;                  /**< The widget for the file chooser */
-    gchar           *starting_dir;                  /**< The starting directory for import file */
-    gchar           *file_name;                     /**< The import file name */
-
-    GtkWidget       *check_label;                   /**< The widget for the check label */
-    GtkWidget       *check_butt;                    /**< The widget for the check label button */
-    GtkWidget       *start_row_spin;                /**< The widget for the start row spinner */
-    GtkWidget       *end_row_spin;                  /**< The widget for the end row spinner */
-    int              start_row;                     /**< The start row */
-    int              end_row;                       /**< The end row */
-
-    GncCsvParseData *parse_data;                    /**< The actual data we are previewing */
-    GOCharmapSel    *encselector;                   /**< The widget for selecting the encoding */
-    GtkCheckButton  *sep_buttons[SEP_NUM_OF_TYPES]; /**< Checkbuttons for common separators */
-    GtkCheckButton  *custom_cbutton;                /**< The checkbutton for a custom separator */
-    GtkEntry        *custom_entry;                  /**< The entry for custom separators */
-    GtkComboBoxText *date_format_combo;             /**< The Combo Text widget for selecting the date format */
-    GtkComboBoxText *currency_format_combo;         /**< The Combo Text widget for selecting the currency format */
-    GtkTreeView     *treeview;                      /**< The treeview containing the data */
-    GtkTreeView     *ctreeview;                     /**< The treeview containing the column types */
-    GtkLabel        *instructions_label;            /**< The instructions label */
-    GtkImage        *instructions_image;            /**< The instructions image */
-    gboolean         encoding_selected_called;      /**< Before encoding_selected is first called, this is FALSE.
-                                                       * (See description of encoding_selected.) */
-    gboolean         not_empty;                     /**< FALSE initially, true after the first type gnc_csv_preview_update_assist is called. */
-    gboolean         previewing_errors;             /**< TRUE if the dialog is displaying
-                                                       * error lines, instead of all the file data. */
-    int              code_encoding_calls;           /**< Normally this is 0. If the computer
-                                                       * changes encselector, this is set to
-                                                       * 2. encoding_selected is called twice,
-                                                       * each time decrementing this by 1. */
-    gboolean         approved;                      /**< This is FALSE until the user clicks "OK". */
-    GtkWidget      **treeview_buttons;              /**< This array contains the header buttons in treeview */
-    int              num_of_rows;                   /**< The number of rows in the store */
-    int              longest_line;                  /**< The length of the longest row */
-    int              fixed_context_col;             /**< The number of the column whose the user has clicked */
-    int              fixed_context_dx;              /**< The horizontal coordinate of the pixel in the header of the column
-                                                       * the user has clicked */
-
-    GtkWidget           *account_page;              /**< The widget for the account page, to be packed with the account matcher */
-    GtkWidget           *account_label;             /**< The account page label at bottom of page */
-    AccountPickerDialog *account_picker;            /**< The AccountPickerDialog structure */
-    gboolean             account_page_step;         /**< Allows for auto stepping the account page if we match online id */
-
-    GNCImportMainMatcher *gnc_csv_importer_gui;     /**< The GNCImportMainMatcher structure */
-    GtkWidget            *match_page;               /**< The widget for the matcher page, to be packed with the transaction matcher */
-    GtkWidget            *match_label;              /**< The match label at the bottom of the page */
-    GtkWidget            *help_button;              /**< The widget for the help button on the matcher page */
-    GtkWidget            *cancel_button;            /**< The widget for the new cancel button when going back is blocked */
-    gboolean              match_parse_run;          /**< This is set after the first run */
-
-    GtkWidget            *summary_label;            /**< The summary text */
-
-    gboolean              new_book;                 /**< Are we importing into a new book?; if yes, call book options */
-
-} CsvImportTrans;
-
-
-/*************************************************************************/
-
-void csv_import_trans_assistant_prepare (GtkAssistant  *assistant, GtkWidget *page, gpointer user_data);
-void csv_import_trans_assistant_finish (GtkAssistant *gtkassistant, gpointer user_data);
-void csv_import_trans_assistant_cancel (GtkAssistant *gtkassistant, gpointer user_data);
-void csv_import_trans_assistant_close (GtkAssistant *gtkassistant, gpointer user_data);
-
-void csv_import_trans_assistant_start_page_prepare (GtkAssistant *gtkassistant, gpointer user_data);
-void csv_import_trans_assistant_file_page_prepare (GtkAssistant *assistant, gpointer user_data);
-void csv_import_trans_assistant_preview_page_prepare (GtkAssistant *gtkassistant, gpointer user_data);
-void csv_import_trans_assistant_account_page_prepare (GtkAssistant *assistant, gpointer user_data);
-void csv_import_trans_assistant_doc_page_prepare (GtkAssistant *assistant, gpointer user_data);
-void csv_import_trans_assistant_match_page_prepare (GtkAssistant *assistant, gpointer user_data);
-void csv_import_trans_assistant_finish_page_prepare (GtkAssistant *assistant, gpointer user_data);
-void csv_import_trans_assistant_summary_page_prepare (GtkAssistant *assistant, gpointer user_data);
-
-void csv_import_trans_srow_cb (GtkWidget *spin, gpointer user_data );
-void csv_import_trans_erow_cb (GtkWidget *spin, gpointer user_data );
-void csv_import_trans_auto_cb (GtkWidget *cb, gpointer user_data );
-void csv_import_trans_file_chooser_confirm_cb (GtkWidget *button, CsvImportTrans *info);
-
-static void gnc_csv_preview_update_assist(CsvImportTrans* info);
-gboolean preview_settings_valid (CsvImportTrans *info);
-
-/*************************************************************************/
-
-/**************************************************
- * csv_import_trans_file_chooser_confirm_cb
- *
- * call back for ok button in file chooser widget
- **************************************************/
-void
-csv_import_trans_file_chooser_confirm_cb (GtkWidget *button, CsvImportTrans *info)
-{
-    GtkAssistant *assistant = GTK_ASSISTANT(info->window);
-    gint num = gtk_assistant_get_current_page (assistant);
-    GtkWidget *page = gtk_assistant_get_nth_page (assistant, num);
-    GError* error;
-    gchar *file_name;
-    GncCsvParseData* parse_data;
-
-    gtk_assistant_set_page_complete (assistant, page, FALSE);
-
-    file_name = gtk_file_chooser_get_filename ( GTK_FILE_CHOOSER(info->file_chooser ));
-
-    if (file_name)
-    {
-        gchar *filepath = gnc_uri_get_path ( file_name );
-        gchar *filedir = g_path_get_dirname( filepath );
-        info->starting_dir = g_strdup(filedir);
-        g_free ( filedir );
-        g_free ( filepath );
-
-        info->file_name = g_strdup(file_name);
-        error = NULL;
-        /* Load the file into parse_data. */
-        parse_data = gnc_csv_new_parse_data();
-        if (gnc_csv_load_file(parse_data, file_name, &error))
-        {
-            /* If we couldn't load the file ... */
-            gnc_error_dialog(NULL, "%s", error->message);
-            if (error->code == GNC_CSV_FILE_OPEN_ERR)
-            {
-                gnc_csv_parse_data_free(parse_data);
-                return;
-            }
-            /* If we couldn't guess the encoding, we are content with just
-             * displaying an error message and move on with a blank
-             * display. */
-        }
-        else
-        {
-            /* Parse the data. */
-            if (gnc_csv_parse(parse_data, TRUE, &error))
-            {
-                /* If we couldn't parse the data ... */
-                gnc_error_dialog(NULL, "%s", error->message);
-                gnc_csv_parse_data_free(parse_data);
-            }
-            else
-            {
-                info->parse_data = parse_data;
-                info->previewing_errors = FALSE; /* We're looking at all the data. */
-                info->approved = FALSE; /* This is FALSE until the user clicks "OK". */
-                gtk_assistant_set_page_complete (assistant, page, TRUE);
-            }
-        }
-    }
-    g_free(file_name);
-
-    DEBUG("file_name selected is %s", info->file_name);
-    DEBUG("starting directory is %s", info->starting_dir);
-
-    /* Step to next page if page is complete */
-    if(gtk_assistant_get_page_complete(assistant, page))
-        gtk_assistant_set_current_page (assistant, num + 1);
-}
-
-
-/**************************************************
- * row_selection_update
- *
- * refresh the start and end row highlighting
- **************************************************/
-static
-void row_selection_update (CsvImportTrans* info)
-{
-    GtkListStore *store;
-    GtkTreeIter iter;
-    gboolean valid;
-    int i;
-
-    store = GTK_LIST_STORE( gtk_tree_view_get_model(info->treeview));
-
-    for ( i = 0; i <= info->start_row; i++)
-    {
-        /* Modify background color of rows less than start row */
-        if (info->start_row == i)
-        {
-            valid = gtk_tree_model_iter_nth_child(GTK_TREE_MODEL(store), &iter, NULL, i );
-            if (valid)
-                gtk_list_store_set (store, &iter, 0, NULL, -1);
-        }
-        else
-        {
-            valid = gtk_tree_model_iter_nth_child(GTK_TREE_MODEL(store), &iter, NULL, i );
-            if (valid)
-                gtk_list_store_set (store, &iter, 0, "pink", -1);
-            valid = gtk_tree_model_iter_next (GTK_TREE_MODEL(store), &iter);
-            if (valid)
-                gtk_list_store_set (store, &iter, 0, NULL, -1);
-        }
-
-    }
-
-    for ( i = info->num_of_rows - 1; i >= info->end_row; i--)
-    {
-        /* Modify background color of rows more than end row */
-        if ( i == info->end_row )
-        {
-            valid = gtk_tree_model_iter_nth_child(GTK_TREE_MODEL(store), &iter, NULL, i );
-            if (valid)
-                gtk_list_store_set (store, &iter, 0, NULL, -1);
-        }
-        else
-        {
-            valid = gtk_tree_model_iter_nth_child(GTK_TREE_MODEL(store), &iter, NULL, i );
-            if (valid)
-                gtk_list_store_set (store, &iter, 0, "pink", -1);
-            valid = gtk_tree_model_iter_nth_child(GTK_TREE_MODEL(store), &iter, NULL, i - 1 );
-            if (valid)
-                gtk_list_store_set (store, &iter, 0, NULL, -1);
-        }
-    }
-}
-
-
-/*******************************************************
- * csv_import_trans_srow_cb
- *
- * call back for import start row
- *******************************************************/
-void csv_import_trans_srow_cb (GtkWidget *spin, gpointer user_data )
-{
-    CsvImportTrans *info = user_data;
-    GtkAdjustment *adj;
-
-    /* Get number of rows for header */
-    info->start_row = gtk_spin_button_get_value_as_int (GTK_SPIN_BUTTON(spin)) - 1;
-
-    info->parse_data->start_row = info->start_row;
-
-    adj = gtk_spin_button_get_adjustment(GTK_SPIN_BUTTON(info->end_row_spin));
-    gtk_adjustment_set_lower(adj, info->start_row + 1 );
-
-    /* Refresh the row highlighting */
-    row_selection_update (info);
-}
-
-
-/*******************************************************
- * csv_import_trans_erow_cb
- *
- * call back for import end row
- *******************************************************/
-void csv_import_trans_erow_cb (GtkWidget *spin, gpointer user_data )
-{
-    CsvImportTrans *info = user_data;
-    GtkAdjustment *adj;
-
-    /* Get number of rows for header */
-    info->end_row = gtk_spin_button_get_value_as_int (GTK_SPIN_BUTTON(spin)) - 1;
-
-    info->parse_data->end_row = info->end_row + 1;
-
-    adj = gtk_spin_button_get_adjustment(GTK_SPIN_BUTTON(info->start_row_spin));
-    gtk_adjustment_set_upper(adj, info->end_row + 1 );
-
-    /* Refresh the row highlighting */
-    row_selection_update (info);
-}
-
-
-/*******************************************************
- * csv_import_trans_auto_cb
- *
- * call back for auto create account / Skip Errors
- *******************************************************/
-void csv_import_trans_auto_cb (GtkWidget *cb, gpointer user_data )
-{
-    CsvImportTrans *info = user_data;
-
-    if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(cb)))
-    {
-        if (info->previewing_errors == TRUE)
-            info->approved = TRUE;
-        else
-            info->account_picker->auto_create = TRUE;
-    }
-    else
-    {
-        if (info->previewing_errors == TRUE)
-            info->approved = FALSE;
-        else
-            info->account_picker->auto_create = FALSE;
-    }
-}
-
-
-/** Returns the cell renderer from a column in the preview's treeview.
- * @param info The display of the data being imported
- * @param col The number of the column whose cell renderer is being retrieved
- * @return The cell renderer of column number col
- */
-static GtkCellRenderer* gnc_csv_preview_get_cell_renderer(CsvImportTrans* info, int col)
-{
-    GList* renderers = gtk_cell_layout_get_cells(GTK_CELL_LAYOUT(gtk_tree_view_get_column(info->treeview, col)));
-
-    GtkCellRenderer* cell = GTK_CELL_RENDERER(renderers->data);
-    g_list_free(renderers);
-    return cell;
-}
-
-
-/** Event handler for separator changes. This function is called
- * whenever one of the widgets for configuring the separators (the
- * separator checkbuttons or the custom separator entry) is
- * changed.
- * @param widget The widget that was changed
- * @param info The data that is being configured
- */
-static void sep_button_clicked(GtkWidget* widget, CsvImportTrans* info)
-{
-    int i;
-    char* stock_separator_characters[] = {" ", "\t", ",", ":", ";", "-"};
-    GSList* checked_separators = NULL;
-    GError* error;
-
-    /* Add the corresponding characters to checked_separators for each
-     * button that is checked. */
-    for (i = 0; i < SEP_NUM_OF_TYPES; i++)
-    {
-        if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(info->sep_buttons[i])))
-            checked_separators = g_slist_append(checked_separators, stock_separator_characters[i]);
-    }
-
-    /* Add the custom separator if the user checked its button. */
-    if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(info->custom_cbutton)))
-    {
-        char* custom_sep = (char*)gtk_entry_get_text(info->custom_entry);
-        if (custom_sep[0] != '\0') /* Don't add a blank separator (bad things will happen!). */
-            checked_separators = g_slist_append(checked_separators, custom_sep);
-    }
-
-    /* Set the parse options using the checked_separators list. */
-    stf_parse_options_csv_set_separators(info->parse_data->options, NULL, checked_separators);
-    g_slist_free(checked_separators);
-
-    /* Parse the data using the new options. We don't want to reguess
-     * the column types because we want to leave the user's
-     * configurations in tact. */
-    if (gnc_csv_parse(info->parse_data, FALSE, &error))
-    {
-        /* Warn the user there was a problem and try to undo what caused
-         * the error. (This will cause a reparsing and ideally a usable
-         * configuration.) */
-        gnc_error_dialog(NULL, "Error in parsing");
-        /* If the user changed the custom separator, erase that custom separator. */
-        if (widget == GTK_WIDGET(info->custom_entry))
-        {
-            gtk_entry_set_text(GTK_ENTRY(widget), "");
-        }
-        /* If the user checked a checkbutton, toggle that checkbutton back. */
-        else
-        {
-            gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widget),
-                                         !gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget)));
-        }
-        return;
-    }
-
-    /* If we parsed successfully, redisplay the data. */
-    gnc_csv_preview_update_assist(info);
-
-    /* Refresh the row highlighting */
-    row_selection_update(info);
-}
-
-
-/** Event handler for clicking one of the format type radio
- * buttons. This occurs if the format (Fixed-Width or CSV) is changed.
- * @param csv_button The "Separated" radio button
- * @param info The display of the data being imported
- */
-static void separated_or_fixed_selected(GtkToggleButton* csv_button, CsvImportTrans* info)
-{
-    GError* error = NULL;
-    /* Set the parsing type correctly. */
-    if (gtk_toggle_button_get_active(csv_button)) /* If we're in CSV mode ... */
-    {
-        stf_parse_options_set_type(info->parse_data->options, PARSE_TYPE_CSV);
-    }
-    else /* If we're in fixed-width mode ... */
-    {
-        stf_parse_options_set_type(info->parse_data->options, PARSE_TYPE_FIXED);
-    }
-
-    /* Reparse the data. */
-    if (gnc_csv_parse(info->parse_data, FALSE, &error))
-    {
-        /* Show an error dialog explaining the problem. */
-        gnc_error_dialog(NULL, "%s", error->message);
-        return;
-    }
-
-    /* Show the new data. */
-    gnc_csv_preview_update_assist(info);
-
-    /* Refresh the row highlighting */
-    row_selection_update(info);
-}
-
-
-/** Event handler for a new encoding. This is called when the user
- * selects a new encoding; the data is reparsed and shown to the
- * user.
- * @param selector The widget the user uses to select a new encoding
- * @param encoding The encoding that the user selected
- * @param info The display of the data being imported
- */
-static void encoding_selected(GOCharmapSel* selector, const char* encoding,
-                              CsvImportTrans* info)
-{
-    /* This gets called twice everytime a new encoding is selected. The
-     * second call actually passes the correct data; thus, we only do
-     * something the second time this is called. */
-
-    /* Prevent code-caused calls of this function from having an impact. */
-    if (info->code_encoding_calls > 0)
-    {
-        info->code_encoding_calls--;
-        return;
-    }
-
-    /* If this is the second time the function is called ... */
-    if (info->encoding_selected_called)
-    {
-        const char* previous_encoding = info->parse_data->encoding;
-        GError* error = NULL;
-        /* Try converting the new encoding and reparsing. */
-        if (gnc_csv_convert_encoding(info->parse_data, encoding, &error) ||
-                gnc_csv_parse(info->parse_data, FALSE, &error))
-        {
-            /* If it fails, change back to the old encoding. */
-            gnc_error_dialog(NULL, "%s", _("Invalid encoding selected"));
-            info->encoding_selected_called = FALSE;
-            go_charmap_sel_set_encoding(selector, previous_encoding);
-            return;
-        }
-
-        gnc_csv_preview_update_assist(info);
-        info->encoding_selected_called = FALSE;
-    }
-    else /* If this is the first call of the function ... */
-    {
-        info->encoding_selected_called = TRUE; /* ... set the flag and wait for the next call. */
-    }
-}
-
-
-/** Event handler for selecting a new date format.
- * @param format_selector The combo box for selecting date formats
- * @param info The display of the data being imported
- */
-static void date_format_selected(GtkComboBoxText* format_selector, CsvImportTrans* info)
-{
-    info->parse_data->date_format = gtk_combo_box_get_active(GTK_COMBO_BOX(format_selector));
-}
-
-
-/** Event handler for selecting a new currency format.
- * @param currency_selector The combo box for selecting currency formats
- * @param info The display of the data being imported
- */
-static void currency_format_selected(GtkComboBoxText* currency_selector, CsvImportTrans* info)
-{
-    info->parse_data->currency_format = gtk_combo_box_get_active(GTK_COMBO_BOX(currency_selector));
-}
-
-
-/*======================================================================*/
-/*================== Beginning of Gnumeric Code ========================*/
-
-/* The following is code copied from Gnumeric 1.7.8 licensed under the
- * GNU General Public License version 2 and/or version 3. It is from the file
- * gnumeric/src/dialogs/dialog-stf-fixed-page.c, and it has been
- * modified slightly to work within GnuCash. */
-
-/*
- * Copyright 2001 Almer S. Tigelaar <almer at gnome.org>
- * Copyright 2003 Morten Welinder <terra at gnome.org>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- */
-
-enum
-{
-    CONTEXT_STF_IMPORT_MERGE_LEFT = 1,
-    CONTEXT_STF_IMPORT_MERGE_RIGHT = 2,
-    CONTEXT_STF_IMPORT_SPLIT = 3,
-    CONTEXT_STF_IMPORT_WIDEN = 4,
-    CONTEXT_STF_IMPORT_NARROW = 5
-};
-
-static GnumericPopupMenuElement const popup_elements[] =
-{
-    {
-        N_("Merge with column on _left"), GTK_STOCK_REMOVE,
-        0, 1 << CONTEXT_STF_IMPORT_MERGE_LEFT, CONTEXT_STF_IMPORT_MERGE_LEFT
-    },
-    {
-        N_("Merge with column on _right"), GTK_STOCK_REMOVE,
-        0, 1 << CONTEXT_STF_IMPORT_MERGE_RIGHT, CONTEXT_STF_IMPORT_MERGE_RIGHT
-    },
-    { "", NULL, 0, 0, 0 },
-    {
-        N_("_Split this column"), NULL,
-        0, 1 << CONTEXT_STF_IMPORT_SPLIT, CONTEXT_STF_IMPORT_SPLIT
-    },
-    { "", NULL, 0, 0, 0 },
-    {
-        N_("_Widen this column"), GTK_STOCK_GO_FORWARD,
-        0, 1 << CONTEXT_STF_IMPORT_WIDEN, CONTEXT_STF_IMPORT_WIDEN
-    },
-    {
-        N_("_Narrow this column"), GTK_STOCK_GO_BACK,
-        0, 1 << CONTEXT_STF_IMPORT_NARROW, CONTEXT_STF_IMPORT_NARROW
-    },
-    { NULL, NULL, 0, 0, 0 },
-};
-
-static gboolean
-make_new_column (CsvImportTrans* info, int col, int dx, gboolean test_only)
-{
-    PangoLayout *layout;
-    PangoFontDescription *font_desc;
-    int charindex, width;
-    GtkCellRenderer *cell =	gnc_csv_preview_get_cell_renderer(info, col);
-    int colstart, colend;
-    GError* error = NULL;
-
-    colstart = (col == 0)
-               ? 0
-               : stf_parse_options_fixed_splitpositions_nth (info->parse_data->options, col - 1);
-    colend = stf_parse_options_fixed_splitpositions_nth (info->parse_data->options, col);
-
-    g_object_get (G_OBJECT (cell), "font_desc", &font_desc, NULL);
-    layout = gtk_widget_create_pango_layout (GTK_WIDGET (info->treeview), "x");
-    pango_layout_set_font_description (layout, font_desc);
-    pango_layout_get_pixel_size (layout, &width, NULL);
-    if (width < 1) width = 1;
-    charindex = colstart + (dx + width / 2) / width;
-    g_object_unref (layout);
-    pango_font_description_free (font_desc);
-
-    if (charindex <= colstart || (colend != -1 && charindex >= colend))
-        return FALSE;
-
-    if (!test_only)
-    {
-        stf_parse_options_fixed_splitpositions_add (info->parse_data->options, charindex);
-        if (gnc_csv_parse(info->parse_data, FALSE, &error))
-        {
-            gnc_error_dialog(NULL, "%s", error->message);
-            return FALSE;
-        }
-        gnc_csv_preview_update_assist (info);
-    }
-
-    return TRUE;
-}
-
-static gboolean
-widen_column (CsvImportTrans* info, int col, gboolean test_only)
-{
-    int colcount = stf_parse_options_fixed_splitpositions_count (info->parse_data->options);
-    int nextstart, nextnextstart;
-    GError* error = NULL;
-
-    if (col >= colcount - 1)
-        return FALSE;
-
-    nextstart = stf_parse_options_fixed_splitpositions_nth (info->parse_data->options, col);
-
-    nextnextstart = (col == colcount - 2)
-                    ? info->longest_line
-                    : stf_parse_options_fixed_splitpositions_nth (info->parse_data->options, col + 1);
-
-    if (nextstart + 1 >= nextnextstart)
-        return FALSE;
-
-    if (!test_only)
-    {
-        stf_parse_options_fixed_splitpositions_remove (info->parse_data->options, nextstart);
-        stf_parse_options_fixed_splitpositions_add (info->parse_data->options, nextstart + 1);
-        if (gnc_csv_parse(info->parse_data, FALSE, &error))
-        {
-            gnc_error_dialog(NULL, "%s", error->message);
-            return FALSE;
-        }
-        gnc_csv_preview_update_assist (info);
-    }
-    return TRUE;
-}
-
-static gboolean
-narrow_column (CsvImportTrans* info, int col, gboolean test_only)
-{
-    int colcount = stf_parse_options_fixed_splitpositions_count (info->parse_data->options);
-    int thisstart, nextstart;
-    GError* error = NULL;
-
-    if (col >= colcount - 1)
-        return FALSE;
-
-    thisstart = (col == 0)
-                ? 0
-                : stf_parse_options_fixed_splitpositions_nth (info->parse_data->options, col - 1);
-    nextstart = stf_parse_options_fixed_splitpositions_nth (info->parse_data->options, col);
-
-    if (nextstart - 1 <= thisstart)
-        return FALSE;
-
-    if (!test_only)
-    {
-        stf_parse_options_fixed_splitpositions_remove (info->parse_data->options, nextstart);
-        stf_parse_options_fixed_splitpositions_add (info->parse_data->options, nextstart - 1);
-        if (gnc_csv_parse(info->parse_data, FALSE, &error))
-        {
-            gnc_error_dialog(NULL, "%s", error->message);
-            return FALSE;
-        }
-        gnc_csv_preview_update_assist (info);
-    }
-    return TRUE;
-}
-
-static gboolean
-delete_column (CsvImportTrans* info, int col, gboolean test_only)
-{
-    GError* error = NULL;
-    int colcount = stf_parse_options_fixed_splitpositions_count (info->parse_data->options);
-    if (col < 0 || col >= colcount - 1)
-        return FALSE;
-
-    if (!test_only)
-    {
-        int nextstart = stf_parse_options_fixed_splitpositions_nth (info->parse_data->options, col);
-        stf_parse_options_fixed_splitpositions_remove (info->parse_data->options, nextstart);
-        if (gnc_csv_parse(info->parse_data, FALSE, &error))
-        {
-            gnc_error_dialog(NULL, "%s", error->message);
-            return FALSE;
-        }
-        gnc_csv_preview_update_assist (info);
-    }
-    return TRUE;
-}
-
-static void
-select_column (CsvImportTrans* info, int col)
-{
-    int colcount = stf_parse_options_fixed_splitpositions_count (info->parse_data->options);
-    GtkTreeViewColumn *column;
-
-    if (col < 0 || col >= colcount)
-        return;
-
-    column = gtk_tree_view_get_column (info->treeview, col);
-    gtk_widget_grab_focus (column->button);
-}
-
-static gboolean
-fixed_context_menu_handler (GnumericPopupMenuElement const *element,
-                            gpointer user_data)
-{
-    CsvImportTrans* info = user_data;
-    int col = info->fixed_context_col;
-
-    switch (element->index)
-    {
-    case CONTEXT_STF_IMPORT_MERGE_LEFT:
-        delete_column (info, col - 1, FALSE);
-        break;
-    case CONTEXT_STF_IMPORT_MERGE_RIGHT:
-        delete_column (info, col, FALSE);
-        break;
-    case CONTEXT_STF_IMPORT_SPLIT:
-        make_new_column (info, col, info->fixed_context_dx, FALSE);
-        break;
-    case CONTEXT_STF_IMPORT_WIDEN:
-        widen_column (info, col, FALSE);
-        break;
-    case CONTEXT_STF_IMPORT_NARROW:
-        narrow_column (info, col, FALSE);
-        break;
-    default:
-        ; /* Nothing */
-    }
-    return TRUE;
-}
-
-static void
-fixed_context_menu (CsvImportTrans* info, GdkEventButton *event,
-                    int col, int dx)
-{
-    int sensitivity_filter = 0;
-
-    info->fixed_context_col = col;
-    info->fixed_context_dx = dx;
-
-    if (!delete_column (info, col - 1, TRUE))
-        sensitivity_filter |= (1 << CONTEXT_STF_IMPORT_MERGE_LEFT);
-    if (!delete_column (info, col, TRUE))
-        sensitivity_filter |= (1 << CONTEXT_STF_IMPORT_MERGE_RIGHT);
-    if (!make_new_column (info, col, dx, TRUE))
-        sensitivity_filter |= (1 << CONTEXT_STF_IMPORT_SPLIT);
-    if (!widen_column (info, col, TRUE))
-        sensitivity_filter |= (1 << CONTEXT_STF_IMPORT_WIDEN);
-    if (!narrow_column (info, col, TRUE))
-        sensitivity_filter |= (1 << CONTEXT_STF_IMPORT_NARROW);
-
-    select_column (info, col);
-    gnumeric_create_popup_menu (popup_elements, &fixed_context_menu_handler,
-                                info, 0,
-                                sensitivity_filter, event);
-}
-
-/*===================== End of Gnumeric Code ===========================*/
-/*======================================================================*/
-
-
-/** Event handler for the data treeview being resized. When the data
- * treeview is resized, the column types treeview's columns are also resized to
- * match.
- * @param widget The data treeview
- * @param allocation The size of the data treeview
- * @param info The display of the data being imported
- */
-static void treeview_resized(GtkWidget* widget, GtkAllocation* allocation, CsvImportTrans* info)
-{
-    /* ncols is the number of columns in the data. */
-    int i, ncols = info->parse_data->column_types->len;
-
-    /* Go through each column except for the last. (We don't want to set
-     * the width of the last column because the user won't be able to
-     * shrink the dialog back if it's expanded.) */
-
-    for (i = 0; i < ncols - 1; i++)
-    {
-        gint col_width; /* The width of the column in info->treeview. */
-        GtkTreeViewColumn* pcol;
-        GtkTreeViewColumn* ccol; /* The corresponding column in info->ctreeview. */
-
-        /* Get the width. */
-        col_width = gtk_tree_view_column_get_width(gtk_tree_view_get_column(info->treeview, i));
-        /* Set the minumum width for a column so that drop down selector can be seen. */
-        if (col_width < MIN_COL_WIDTH)
-        {
-            col_width = MIN_COL_WIDTH;
-        }
-        pcol = gtk_tree_view_get_column(info->treeview, i);
-        gtk_tree_view_column_set_min_width(pcol, col_width);
-        /* Set ccol's width the same. */
-        ccol = gtk_tree_view_get_column(info->ctreeview, i);
-        gtk_tree_view_column_set_min_width(ccol, col_width);
-        gtk_tree_view_column_set_max_width(ccol, col_width);
-    }
-}
-
-
-/** Event handler for the user selecting a new column type. When the
- * user selects a new column type, that column's text must be changed
- * to that selection, and any other columns containing that selection
- * must be changed to "None" because we don't allow duplicates.
- * @param renderer The renderer of the column the user changed
- * @param path There is only 1 row in info->ctreeview, so this is always 0.
- * @param new_text The text the user selected
- * @param info The display of the data being imported
- */
-static void column_type_changed(GtkCellRenderer* renderer, gchar* path,
-                                GtkTreeIter* new_text_iter, CsvImportTrans* info)
-{
-    /* ncols is the number of columns in the data. */
-    int i, ncols = info->parse_data->column_types->len;
-    /* store has the actual strings that appear in info->ctreeview. */
-    GtkTreeModel* store = gtk_tree_view_get_model(info->ctreeview);
-    GtkTreeModel* model;
-    gint textColumn;
-    GtkTreeIter iter;
-    gchar* new_text;
-
-    /* Get the new text */
-    g_object_get(renderer, "model", &model, "text-column", &textColumn, NULL);
-    gtk_tree_model_get(model, new_text_iter, textColumn, &new_text, -1);
-
-    /* Get an iterator for the first (and only) row. */
-    gtk_tree_model_get_iter_first(store, &iter);
-
-    /* Go through each column. */
-    for (i = 0; i < ncols; i++)
-    {
-        /* We need all this stuff so that we can find out whether or not
-         * this was the column that was changed. */
-        GtkCellRenderer* col_renderer; /* The renderer for this column. */
-        /* The column in the treeview we are looking at */
-        GtkTreeViewColumn* col = gtk_tree_view_get_column(info->ctreeview, i);
-        /* The list of renderers for col */
-        GList* rend_list = gtk_cell_layout_get_cells(GTK_CELL_LAYOUT(col));
-        /* rend_list has only one entry, which we put in col_renderer. */
-        col_renderer = rend_list->data;
-        g_list_free(rend_list);
-
-        /* If this is not the column that was changed ... */
-        if (col_renderer != renderer)
-        {
-            /* The string that appears in the column */
-            gchar* contents = NULL;
-            /* Get the type string. (store is arranged so that every two
-             * columns is a pair of the model used for the combobox and the
-             * string that appears, so that store looks like:
-             * model 0, string 0, model 1, string 1, ..., model ncols, string ncols. */
-            gtk_tree_model_get(store, &iter, 2 * i + 1, &contents, -1);
-            /* If this column has the same string that the user selected ... */
-            if (!g_strcmp0(contents, new_text))
-            {
-                /* ... set this column to the "None" type. (We can't allow duplicate types.) */
-                gtk_list_store_set(GTK_LIST_STORE(store), &iter, 2 * i + 1,
-                                   _(gnc_csv_column_type_strs[GNC_CSV_NONE]), -1);
-            }
-            g_free(contents);
-        }
-        else /* If this is the column that was changed ... */
-        {
-            /* Set the text for this column to what the user selected. (See
-             * comment above "Get the type string. ..." for why we set
-             * column 2*i+1 in store.) */
-            gtk_list_store_set(GTK_LIST_STORE(store), &iter, 2 * i + 1, new_text, -1);
-        }
-    }
-}
-
-
-/** Event handler for clicking on column headers. This function is
- * called whenever the user clicks on column headers in
- * preview->treeview to modify columns when in fixed-width mode.
- * @param button The button at the top of a column of the treeview
- * @param event The event that happened (where the user clicked)
- * @param info The data being configured
- */
-static void header_button_press_handler(GtkWidget* button, GdkEventButton* event,
-                                        CsvImportTrans* info)
-{
-    /* col is the number of the column that was clicked, and offset is
-       to correct for the indentation of button. */
-    int i, col = 0, offset = GTK_BIN(button)->child->allocation.x - button->allocation.x,
-           ncols = info->parse_data->column_types->len;
-    /* Find the column that was clicked. */
-    for (i = 0; i < ncols; i++)
-    {
-        if (info->treeview_buttons[i] == button)
-        {
-            col = i;
-            break;
-        }
-    }
-
-    /* Don't let the user affect the last column if it has error messages. */
-    if (info->parse_data->orig_max_row < ncols && ncols - col == 1)
-    {
-        return;
-    }
-
-    /* Double clicks can split columns. */
-    if (event->type == GDK_2BUTTON_PRESS && event->button == 1)
-    {
-        make_new_column(info, col, (int)event->x - offset, FALSE);
-    }
-    /* Right clicking brings up a context menu. */
-    else if (event->type == GDK_BUTTON_PRESS && event->button == 3)
-    {
-        fixed_context_menu(info, event, col, (int)event->x - offset);
-    }
-}
-
-
-/* Test for the required minimum number of coloumns selected and
- * a valid date format.
- * Returns TRUE if we do or FALSE if we don't.
- *
- * @param info The data being previewed
- */
-gboolean preview_settings_valid (CsvImportTrans* info)
-{
-    /* Shorten the column_types identifier. */
-    GArray* column_types = info->parse_data->column_types;
-    int i, ncols = column_types->len; /* ncols is the number of columns in the data. */
-    int weight = 0;
-    gboolean valid = TRUE;
-    /* store contains the actual strings appearing in the column types treeview. */
-    GtkTreeModel* store = gtk_tree_view_get_model(info->ctreeview);
-    /* datastore contains the actual strings appearing in the preview treeview. */
-    GtkTreeModel* datastore = gtk_tree_view_get_model(info->treeview);
-    GtkTreeIter iter, iter2;
-    /* Get an iterator for the first (and only) row. */
-    gtk_tree_model_get_iter_first(store, &iter);
-
-    /* Get an iterator for the first required row in the data store. */
-    gtk_tree_model_iter_nth_child(GTK_TREE_MODEL(datastore), &iter2, NULL, info->start_row );
-
-    /* Go through each of the columns. */
-    for (i = 0; i < ncols; i++)
-    {
-        int type; /* The column type contained in this column. */
-        gchar* contents = NULL; /* The column type string in this column. */
-        gchar* prevstr = NULL; /* The string in this column from datastore. */
-        gchar* accstr = NULL; /* The string in this column from datastore. */
-        /* Get the type string first. (store is arranged so that every two
-         * columns is a pair of the model used for the combobox and the
-         * string that appears, so that store looks like:
-         * model 0, string 0, model 1, string 1, ..., model ncols, string ncols. */
-        gtk_tree_model_get(store, &iter, 2 * i + 1, &contents, -1);
-
-        /* Go through each column type until ... */
-        for (type = 0; type < GNC_CSV_NUM_COL_TYPES; type++)
-        {
-            /* ... we find one that matches with what's in the column. */
-            if (!g_strcmp0(contents, _(gnc_csv_column_type_strs[type])))
-            {
-                /* Set the column_types array appropriately and quit. */
-                column_types->data[i] = type;
-
-                switch (type)
-                {
-                case GNC_CSV_DATE:
-                    weight = weight + 1000;
-                    gtk_tree_model_get(datastore, &iter2, i + 1, &prevstr, -1);
-
-                    if (parse_date(prevstr, info->parse_data->date_format) == -1)
-                        valid = FALSE;
-                    break;
-
-                case GNC_CSV_DESCRIPTION:
-                case GNC_CSV_NOTES:
-                    weight = weight + 100;
-                    break;
-
-                case GNC_CSV_BALANCE:
-                case GNC_CSV_DEPOSIT:
-                case GNC_CSV_WITHDRAWAL:
-                    weight = weight + 10;
-                    break;
-
-                case GNC_CSV_NUM:
-                    weight = weight + 1;
-                    break;
-                case GNC_CSV_ACCOUNT:
-                    weight = weight + 1;
-                    gtk_tree_model_get(datastore, &iter2, i + 1, &accstr, -1);
-                    info->account_picker->account_online_id_value = strdup(accstr);
-                    break;
-                }
-                break;
-            }
-        }
-        /* Free the type string created by gtk_tree_model_get() */
-        g_free(contents);
-        g_free(prevstr);
-        g_free(accstr);
-    }
-    if (weight < 1109 || valid == FALSE)
-        return FALSE;
-    else
-        return TRUE;
-}
-
-
-/* Loads the preview's data into its data treeview. not_empty is TRUE
- * when the data treeview already contains data, FALSE otherwise
- * (e.g. the first time this function is called on a preview).
- * @param info The data being previewed
- */
-static void gnc_csv_preview_update_assist(CsvImportTrans* info)
-{
-    /* store has the data from the file being imported. cstores is an
-     * array of stores that hold the combo box entries for each
-     * column. ctstore contains both pointers to models in cstore and
-     * the actual text that appears in info->ctreeview. */
-    GtkListStore *store, **cstores, *ctstore;
-    GtkTreeIter iter;
-    GtkTreeSelection *selection;
-    /* ncols is the number of columns in the file data. */
-    int i, j, ncols = info->parse_data->column_types->len,
-              max_str_len = info->parse_data->file_str.end - info->parse_data->file_str.begin;
-
-    /* store contains only strings. */
-    GType* types = g_new(GType, 2 * ncols);
-    for (i = 0; i <  ncols + 1; i++)
-        types[i] = G_TYPE_STRING;
-    store = gtk_list_store_newv(ncols + 1, types);
-
-    /* ctstore is arranged as follows:
-     * model 0, text 0, model 1, text 1, ..., model ncols, text ncols. */
-    for (i = 0; i < 2 * ncols; i += 2)
-    {
-        types[i] = GTK_TYPE_TREE_MODEL;
-        types[i+1] = G_TYPE_STRING;
-    }
-    ctstore = gtk_list_store_newv(2 * ncols, types);
-
-    g_free(types);
-
-    /* Each element in cstores is a single column model. */
-    cstores = g_new(GtkListStore*, ncols);
-    for (i = 0; i < ncols; i++)
-    {
-        cstores[i] = gtk_list_store_new(1, G_TYPE_STRING);
-        /* Add all of the possible entries to the combo box. */
-        for (j = 0; j < GNC_CSV_NUM_COL_TYPES; j++)
-        {
-            gtk_list_store_append(cstores[i], &iter);
-            gtk_list_store_set(cstores[i], &iter, 0, _(gnc_csv_column_type_strs[j]), -1);
-        }
-    }
-
-    if (info->not_empty)
-    {
-        GList *tv_columns, *tv_columns_begin, *ctv_columns, *ctv_columns_begin;
-        tv_columns = tv_columns_begin = gtk_tree_view_get_columns(info->treeview);
-        ctv_columns = ctv_columns_begin = gtk_tree_view_get_columns(info->ctreeview);
-        /* Clear out exisiting columns in info->treeview. */
-        while (tv_columns != NULL)
-        {
-            gtk_tree_view_remove_column(info->treeview, GTK_TREE_VIEW_COLUMN(tv_columns->data));
-            tv_columns = g_list_next(tv_columns);
-        }
-        /* Do the same in info->ctreeview. */
-        while (ctv_columns != NULL)
-        {
-            gtk_tree_view_remove_column(info->ctreeview, GTK_TREE_VIEW_COLUMN(ctv_columns->data));
-            ctv_columns = g_list_next(ctv_columns);
-        }
-        g_list_free(tv_columns_begin);
-        g_list_free(ctv_columns_begin);
-        g_free(info->treeview_buttons);
-    }
-
-    /* Fill the data treeview with data from the file. */
-    /* Also, update the longest line value within the following loop (whichever is executed). */
-    info->longest_line = 0;
-    if (info->previewing_errors) /* If we are showing only errors ... */
-    {
-        /* ... only pick rows that are in info->error_lines. */
-        GList* error_lines = info->parse_data->error_lines;
-        while (error_lines != NULL)
-        {
-            int this_line_length = 0;
-            i = GPOINTER_TO_INT(error_lines->data);
-            gtk_list_store_append(store, &iter);
-
-            /* Row Color column */
-            gtk_list_store_set (store, &iter, 0, NULL, -1);
-
-            for (j = 0; j < ((GPtrArray*)(info->parse_data->orig_lines->pdata[i]))->len; j++)
-            {
-                /* Add this cell's length to the row's length and set the value of the list store. */
-                gchar* cell_string = (gchar*)((GPtrArray*)(info->parse_data->orig_lines->pdata[i]))->pdata[j];
-                this_line_length += g_utf8_strlen(cell_string, max_str_len);
-                gtk_list_store_set(store, &iter, j + 1, cell_string, -1);
-            }
-
-            if (this_line_length > info->longest_line)
-                info->longest_line = this_line_length;
-
-            error_lines = g_list_next(error_lines);
-        }
-    }
-    else /* Otherwise, put in all of the data. */
-    {
-        for (i = 0; i < info->parse_data->orig_lines->len; i++)
-        {
-            int this_line_length = 0;
-            gtk_list_store_append(store, &iter);
-
-            /* Row Color column */
-            gtk_list_store_set (store, &iter, 0, NULL, -1);
-
-            for (j = 0; j < ((GPtrArray*)(info->parse_data->orig_lines->pdata[i]))->len; j++)
-            {
-                /* Add this cell's length to the row's length and set the value of the list store. */
-                gchar* cell_string = (gchar*)((GPtrArray*)(info->parse_data->orig_lines->pdata[i]))->pdata[j];
-                this_line_length += g_utf8_strlen(cell_string, max_str_len);
-                gtk_list_store_set(store, &iter, j + 1, cell_string, -1);
-            }
-
-            if (this_line_length > info->longest_line)
-                info->longest_line = this_line_length;
-
-            /* Set the number of rows in the store */
-            info->num_of_rows = i + 1;
-        }
-    }
-
-    /* Set all the column types to what's in the parse data. */
-    gtk_list_store_append(ctstore, &iter);
-    gtk_list_store_set(ctstore, &iter, 0, NULL, -1); /* Dummy Column to match row color */
-    for (i = 0; i < ncols; i++)
-    {
-        gtk_list_store_set(ctstore, &iter, 2 * i, cstores[i], 2 * i + 1,
-                           _(gnc_csv_column_type_strs[(int)(info->parse_data->column_types->data[i])]),
-                           -1);
-    }
-
-    info->treeview_buttons = g_new(GtkWidget*, ncols);
-    /* Insert columns into the data and column type treeviews. */
-    for (i = 0; i < ncols ; i++)
-    {
-        GtkTreeViewColumn* col; /* The column we add to info->treeview. */
-        /* Create renderers for the data treeview (renderer) and the
-         * column type treeview (crenderer). */
-        GtkCellRenderer* renderer = gtk_cell_renderer_text_new(),
-                         *crenderer = gtk_cell_renderer_combo_new();
-        /* We want a monospace font for the data in case of fixed-width data. */
-        g_object_set(G_OBJECT(renderer), "family", "monospace", NULL);
-        /* We are using cstores for the combo box entries, and we don't
-         * want the user to be able to manually enter their own column
-         * types. */
-        g_object_set(G_OBJECT(crenderer), "model", cstores[i], "text-column", 0,
-                     "editable", TRUE, "has-entry", FALSE, NULL);
-        g_signal_connect(G_OBJECT(crenderer), "changed",
-                         G_CALLBACK(column_type_changed), (gpointer)info);
-
-        /* Add a single column for the treeview. */
-        col = gtk_tree_view_column_new_with_attributes("", renderer, "text", i + 1, NULL);
-
-        /* Add the Color column 0 to the renderer */
-        gtk_tree_view_column_add_attribute(col, renderer, "background", 0);
-
-        gtk_tree_view_insert_column(info->treeview, col, -1);
-        /* Enable resizing of the columns. */
-        gtk_tree_view_column_set_resizable(col, TRUE);
-        /* Use the alternating model and text entries from ctstore in
-         * info->ctreeview. */
-        gtk_tree_view_insert_column_with_attributes(info->ctreeview,
-                -1, "", crenderer, "model", 2 * i,
-                "text", 2 * i + 1, NULL);
-
-        /* We need to allow clicking on the column headers for fixed-width
-         * column splitting and merging. */
-        g_object_set(G_OBJECT(col), "clickable", TRUE, NULL);
-        g_signal_connect(G_OBJECT(col->button), "button_press_event",
-                         G_CALLBACK(header_button_press_handler), (gpointer)info);
-        info->treeview_buttons[i] = col->button;
-    }
-
-    /* Set the treeviews to use the models. */
-    gtk_tree_view_set_model(info->treeview, GTK_TREE_MODEL(store));
-    gtk_tree_view_set_model(info->ctreeview, GTK_TREE_MODEL(ctstore));
-
-    /* Select the header row */
-    gtk_tree_model_get_iter_first(GTK_TREE_MODEL(ctstore), &iter);
-    selection = gtk_tree_view_get_selection (info->ctreeview);
-    gtk_tree_selection_select_iter ( selection, &iter);
-
-    /* Free the memory for the stores. */
-    g_object_unref(GTK_TREE_MODEL(store));
-    g_object_unref(GTK_TREE_MODEL(ctstore));
-    for (i = 0; i < ncols; i++)
-        g_object_unref(GTK_TREE_MODEL(cstores[i]));
-
-    /* Make the things actually appear. */
-    gtk_widget_show_all(GTK_WIDGET(info->treeview));
-    gtk_widget_show_all(GTK_WIDGET(info->ctreeview));
-
-    /* Set the encoding selector to the right encoding. */
-    info->code_encoding_calls = 2;
-    go_charmap_sel_set_encoding(info->encselector, info->parse_data->encoding);
-
-    /* Set the date format to what's in the combo box (since we don't
-     * necessarily know if this will always be the same). */
-    info->parse_data->date_format = gtk_combo_box_get_active(GTK_COMBO_BOX(info->date_format_combo));
-
-    /* It's now been filled with some stuff. */
-    info->not_empty = TRUE;
-}
-
-
-/*******************************************************
- * load_settings
- *
- * load the default settings for the assistant
- *******************************************************/
-static
-void load_settings (CsvImportTrans *info)
-{
-    info->start_row = 0;
-    info->start_row = 0;
-    info->account_page_step = TRUE;
-    info->match_parse_run = FALSE;
-    info->file_name = NULL;
-    info->starting_dir = NULL;
-
-    /* The default directory for the user to select files. */
-    info->starting_dir = gnc_get_default_directory(GNC_PREFS_GROUP);
-}
-
-/*======================================================================*/
-/*======================================================================*/
-
-/*******************************************************
- * Assistant page prepare functions
- *******************************************************/
-void
-csv_import_trans_assistant_start_page_prepare (GtkAssistant *assistant,
-        gpointer user_data)
-{
-    gint num = gtk_assistant_get_current_page (assistant);
-    GtkWidget *page = gtk_assistant_get_nth_page (assistant, num);
-
-    /* Enable the Assistant Buttons */
-    gtk_assistant_set_page_complete (assistant, page, TRUE);
-}
-
-
-void
-csv_import_trans_assistant_file_page_prepare (GtkAssistant *assistant,
-        gpointer user_data)
-{
-    CsvImportTrans *info = user_data;
-    gint num = gtk_assistant_get_current_page (assistant);
-    GtkWidget *page = gtk_assistant_get_nth_page (assistant, num);
-
-    info->account_picker->auto_create = TRUE; /* Step over account page if we find matching online id */
-    info->previewing_errors = FALSE;          /* We're looking at all the data. */
-    info->approved = FALSE;                   /* This is FALSE until the user clicks "OK". */
-
-    /* Set the default directory */
-    if (info->starting_dir)
-        gtk_file_chooser_set_current_folder(GTK_FILE_CHOOSER(info->file_chooser), info->starting_dir);
-
-    /* Disable the Forward Assistant Button */
-    gtk_assistant_set_page_complete (assistant, page, FALSE);
-}
-
-
-void
-csv_import_trans_assistant_preview_page_prepare (GtkAssistant *assistant,
-        gpointer user_data)
-{
-    CsvImportTrans *info = user_data;
-    GtkAdjustment *adj;
-
-    g_signal_connect(G_OBJECT(info->treeview), "size-allocate",
-                     G_CALLBACK(treeview_resized), (gpointer)info);
-
-    if (info->previewing_errors == TRUE)
-    {
-        gchar* name;
-        GtkIconSize size;
-
-        /* Block going back */
-        gtk_assistant_commit (GTK_ASSISTANT(info->window));
-
-        gtk_image_get_stock(info->instructions_image, &name, &size);
-        gtk_image_set_from_stock(info->instructions_image, GTK_STOCK_DIALOG_ERROR, size);
-        gtk_label_set_text(info->instructions_label,
-                           _("The rows displayed below had errors which are in the last column. You can attempt to correct them by changing the configuration."));
-        gtk_widget_show(GTK_WIDGET(info->instructions_image));
-        gtk_widget_show(GTK_WIDGET(info->instructions_label));
-
-        /* Set spin buttons not sensative */
-        gtk_widget_set_sensitive (info->start_row_spin, FALSE);
-        gtk_widget_set_sensitive (info->end_row_spin, FALSE);
-
-        /* Set check button label */
-        gtk_label_set_text(GTK_LABEL(info->check_label), _("Skip Errors"));
-        gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON(info->check_butt), FALSE);
-    }
-
-    /* Load the data into the treeview. */
-    gnc_csv_preview_update_assist(info);
-
-    /* Set the upper limit of spin button to number of rows */
-    adj = gtk_spin_button_get_adjustment(GTK_SPIN_BUTTON(info->end_row_spin));
-    if (gtk_adjustment_get_upper(adj) != info->num_of_rows)
-    {
-        gtk_spin_button_set_value (GTK_SPIN_BUTTON(info->end_row_spin), info->num_of_rows);
-        gtk_adjustment_set_upper(adj, info->num_of_rows);
-    }
-
-    /* Update the row selection highlight */
-    row_selection_update(info);
-}
-
-
-void
-csv_import_trans_assistant_account_page_prepare (GtkAssistant *assistant,
-        gpointer user_data)
-{
-    CsvImportTrans *info = user_data;
-    gint num = gtk_assistant_get_current_page (assistant);
-    GtkWidget *page = gtk_assistant_get_nth_page (assistant, num);
-    gchar *text, *mtext;
-    Account * account = NULL;
-
-    if (!preview_settings_valid(info) && (info->approved == FALSE))
-    {
-        text = g_strdup_printf(gettext ("There are problems with the import settings!\nThe date format could be wrong "
-                                        "or there are not enough columns set..."));
-        mtext = g_strdup_printf("<span size=\"medium\" color=\"red\"><b>%s</b></span>", text);
-        gtk_label_set_markup(GTK_LABEL(info->account_label), mtext);
-        g_free(mtext);
-        g_free(text);
-
-        gtk_widget_set_sensitive (info->account_page, FALSE);
-    }
-    else
-    {
-        text = g_strdup_printf(gettext ("To Change the account, double click on the required account, click Forward to proceed."));
-        mtext = g_strdup_printf("<span size=\"medium\" color=\"red\"><b>%s</b></span>", text);
-        gtk_label_set_markup(GTK_LABEL(info->account_label), mtext );
-        g_free(mtext);
-        g_free(text);
-
-        gtk_widget_set_sensitive (info->account_page, TRUE);
-
-        /* Let the user select an account to put the transactions in. */
-        account = gnc_import_account_assist_update (info->account_picker);
-
-        /* If we have a valid account and auto_create is TRUE, move on to matcher */
-        if (!(account == NULL) && (info->account_picker->auto_create == TRUE))
-            gtk_assistant_set_current_page (assistant, num + 1);
-    }
-
-    /* Enable the Forward Assistant Button */
-    if (account == NULL)
-        gtk_assistant_set_page_complete (assistant, page, FALSE);
-    else
-        gtk_assistant_set_page_complete (assistant, page, TRUE);
-}
-
-
-void
-csv_import_trans_assistant_doc_page_prepare (GtkAssistant *assistant,
-        gpointer user_data)
-{
-    CsvImportTrans *info = user_data;
-
-    /* Block going back */
-    gtk_assistant_commit (GTK_ASSISTANT(info->window));
-
-    if ( info->match_parse_run == FALSE)
-    {
-        /* Add the Cancel button for the matcher */
-        info->cancel_button = gtk_button_new_with_mnemonic (_("_Cancel"));
-        gtk_assistant_add_action_widget (assistant, info->cancel_button);
-        g_signal_connect(info->cancel_button, "clicked",
-                         G_CALLBACK(csv_import_trans_assistant_cancel), info);
-        gtk_widget_show(GTK_WIDGET(info->cancel_button));
-    }
-}
-
-
-void
-csv_import_trans_assistant_match_page_prepare (GtkAssistant *assistant,
-        gpointer user_data)
-{
-    CsvImportTrans *info = user_data;
-    gint num = gtk_assistant_get_current_page (assistant);
-    GtkWidget *page = gtk_assistant_get_nth_page (assistant, num);
-    gchar *text, *mtext;
-
-    /* Block going back */
-    gtk_assistant_commit (GTK_ASSISTANT(info->window));
-
-    /* Before creating transactions, if this is a new book, let user specify
-     * book options, since they affect how transactions are created */
-    if (info->new_book)
-        info->new_book = gnc_new_book_option_display();
-
-    /* Create transactions from the parsed data, first time with FALSE
-       Subsequent times with TRUE */
-    if ( info->match_parse_run == FALSE)
-    {
-        gnc_csv_parse_to_trans(info->parse_data, info->account_picker->retAccount, FALSE);
-    }
-    else
-        gnc_csv_parse_to_trans(info->parse_data, info->account_picker->retAccount, TRUE);
-    info->match_parse_run = TRUE;
-
-    /* if there are errors, we jump back to preview to correct */
-    if (!(info->parse_data->error_lines == NULL) && (info->approved == FALSE) )
-    {
-        info->previewing_errors = TRUE; /* We're looking at errors. */
-        gtk_assistant_set_current_page (assistant, 2);
-    }
-
-    if ((info->parse_data->error_lines == NULL) || (info->approved == TRUE) )
-    {
-        GList* transactions; /* A list of the transactions we create */
-
-        text =  _("Double click on rows to change, then click on Apply to Import");
-        mtext = g_strdup_printf("<span size=\"medium\" color=\"red\"><b>%s</b></span>", text);
-        gtk_label_set_markup(GTK_LABEL(info->match_label), mtext);
-        g_free(mtext);
-
-        if (info->gnc_csv_importer_gui == NULL)
-        {
-            /* Create the genereic transaction importer GUI. */
-            info->gnc_csv_importer_gui = gnc_gen_trans_assist_new (info->match_page, NULL, FALSE, 42);
-
-            /* Add the help button for the matcher */
-            info->help_button = gtk_button_new_with_mnemonic (_("_Help"));
-            gtk_assistant_add_action_widget (assistant, info->help_button);
-            g_signal_connect(info->help_button, "clicked",
-                             G_CALLBACK(on_matcher_help_clicked), info->gnc_csv_importer_gui);
-            gtk_widget_show(GTK_WIDGET(info->help_button));
-
-            /* Get the list of the transactions that were created. */
-            transactions = info->parse_data->transactions;
-            /* Copy all of the transactions to the importer GUI. */
-            while (transactions != NULL)
-            {
-                GncCsvTransLine* trans_line = transactions->data;
-                gnc_gen_trans_list_add_trans(info->gnc_csv_importer_gui, trans_line->trans);
-                transactions = g_list_next(transactions);
-            }
-            g_list_free(transactions);
-        }
-    }
-    /* Enable the Forward Assistant Button */
-    gtk_assistant_set_page_complete (assistant, page, TRUE);
-}
-
-
-void
-csv_import_trans_assistant_summary_page_prepare (GtkAssistant *assistant,
-        gpointer user_data)
-{
-    CsvImportTrans *info = user_data;
-    gchar *text, *mtext;
-
-    /* Save the Window size and directory */
-    gnc_set_default_directory(GNC_PREFS_GROUP, info->starting_dir);
-
-    /* Remove the added button */
-    gtk_assistant_remove_action_widget (assistant, info->help_button);
-    gtk_assistant_remove_action_widget (assistant, info->cancel_button);
-
-    text = g_strdup_printf(gettext ("The transactions were imported from the file '%s'."), info->file_name);
-    mtext = g_strdup_printf("<span size=\"medium\"><b>%s</b></span>", text);
-    gtk_label_set_markup(GTK_LABEL(info->summary_label), mtext);
-    g_free(text);
-    g_free(mtext);
-}
-
-
-void
-csv_import_trans_assistant_prepare (GtkAssistant *assistant, GtkWidget *page,
-                                    gpointer user_data)
-{
-    gint currentpage = gtk_assistant_get_current_page(assistant);
-
-    switch (currentpage)
-    {
-    case 0:
-        /* Current page is Import Start page */
-        csv_import_trans_assistant_start_page_prepare (assistant, user_data);
-        break;
-    case 1:
-        /* Current page is File select page */
-        csv_import_trans_assistant_file_page_prepare (assistant, user_data);
-        break;
-    case 2:
-        /* Current page is Preview page */
-        csv_import_trans_assistant_preview_page_prepare (assistant, user_data);
-        break;
-    case 3:
-        /* Current page is Account page */
-        csv_import_trans_assistant_account_page_prepare (assistant, user_data);
-        break;
-    case 4:
-        /* Current page is Transaction Doc page */
-        csv_import_trans_assistant_doc_page_prepare (assistant, user_data);
-        break;
-    case 5:
-        /* Current page is Match page */
-        csv_import_trans_assistant_match_page_prepare (assistant, user_data);
-        break;
-    case 6:
-        /* Current page is Summary page */
-        csv_import_trans_assistant_summary_page_prepare (assistant, user_data);
-        break;
-    }
-}
-
-
-/*******************************************************
- * Assistant call back functions
- *******************************************************/
-static void
-csv_import_trans_assistant_destroy_cb (GtkObject *object, gpointer user_data)
-{
-    CsvImportTrans *info = user_data;
-    gnc_unregister_gui_component_by_data (ASSISTANT_CSV_IMPORT_TRANS_CM_CLASS, info);
-    g_free (info);
-}
-
-void
-csv_import_trans_assistant_cancel (GtkAssistant *assistant, gpointer user_data)
-{
-    CsvImportTrans *info = user_data;
-    gnc_close_gui_component_by_data (ASSISTANT_CSV_IMPORT_TRANS_CM_CLASS, info);
-}
-
-void
-csv_import_trans_assistant_close (GtkAssistant *assistant, gpointer user_data)
-{
-    CsvImportTrans *info = user_data;
-    gnc_close_gui_component_by_data (ASSISTANT_CSV_IMPORT_TRANS_CM_CLASS, info);
-}
-
-void
-csv_import_trans_assistant_finish (GtkAssistant *assistant, gpointer user_data)
-{
-    CsvImportTrans *info = user_data;
-
-    /* Start the import */
-    if (info->parse_data->transactions != NULL)
-        gnc_gen_trans_assist_start(info->gnc_csv_importer_gui);
-    else
-        gnc_gen_trans_list_delete(info->gnc_csv_importer_gui);
-}
-
-static void
-csv_import_trans_close_handler (gpointer user_data)
-{
-    CsvImportTrans *info = user_data;
-
-    g_free(info->file_name);
-    g_free(info->starting_dir);
-
-    /* Free the memory we allocated. */
-    if (!(info->parse_data == NULL))
-        gnc_csv_parse_data_free(info->parse_data);
-
-    if (!(info->account_picker == NULL))
-        info->account_picker = NULL;
-
-    if (!(info->gnc_csv_importer_gui == NULL))
-        info->gnc_csv_importer_gui = NULL;
-
-    gnc_save_window_size(GNC_PREFS_GROUP, GTK_WINDOW(info->window));
-    gtk_widget_destroy (info->window);
-}
-
-/*******************************************************
- * Create the Assistant
- *******************************************************/
-static GtkWidget *
-csv_import_trans_assistant_create (CsvImportTrans *info)
-{
-    GtkBuilder *builder;
-    GtkWidget *window;
-    GtkWidget *box;
-    GtkWidget *button, *csv_button, *h_box;
-
-    builder = gtk_builder_new();
-    gnc_builder_add_from_file  (builder , "assistant-csv-trans-import.glade", "start_row_adj");
-    gnc_builder_add_from_file  (builder , "assistant-csv-trans-import.glade", "end_row_adj");
-    gnc_builder_add_from_file  (builder , "assistant-csv-trans-import.glade", "CSV Transaction Assistant");
-    window = GTK_WIDGET(gtk_builder_get_object (builder, "CSV Transaction Assistant"));
-    info->window = window;
-
-    /* Set the assistant colors */
-    gnc_assistant_set_colors (GTK_ASSISTANT (info->window));
-
-    /* Load default settings */
-    load_settings (info);
-
-    /* Enable buttons on all page. */
-    gtk_assistant_set_page_complete (GTK_ASSISTANT (window),
-                                     GTK_WIDGET(gtk_builder_get_object(builder, "start_page")),
-                                     TRUE);
-    gtk_assistant_set_page_complete (GTK_ASSISTANT (window),
-                                     GTK_WIDGET(gtk_builder_get_object(builder, "file_page")),
-                                     FALSE);
-    gtk_assistant_set_page_complete (GTK_ASSISTANT (window),
-                                     GTK_WIDGET(gtk_builder_get_object(builder, "preview_page")),
-                                     TRUE);
-    gtk_assistant_set_page_complete (GTK_ASSISTANT (window),
-                                     GTK_WIDGET(gtk_builder_get_object(builder, "account_page")),
-                                     FALSE);
-    gtk_assistant_set_page_complete (GTK_ASSISTANT (window),
-                                     GTK_WIDGET(gtk_builder_get_object(builder, "doc_page")),
-                                     TRUE);
-    gtk_assistant_set_page_complete (GTK_ASSISTANT (window),
-                                     GTK_WIDGET(gtk_builder_get_object(builder, "match_page")),
-                                     FALSE);
-    gtk_assistant_set_page_complete (GTK_ASSISTANT (window),
-                                     GTK_WIDGET(gtk_builder_get_object(builder, "summary_page")),
-                                     TRUE);
-
-    /* Start Page */
-
-    /* File chooser Page */
-    info->file_chooser = gtk_file_chooser_widget_new (GTK_FILE_CHOOSER_ACTION_OPEN);
-    g_signal_connect (G_OBJECT (info->file_chooser), "file-activated",
-                      G_CALLBACK (csv_import_trans_file_chooser_confirm_cb), info);
-    button = gtk_button_new_from_stock(GTK_STOCK_OK);
-    gtk_widget_set_size_request (button, 100, -1);
-    gtk_widget_show (button);
-    h_box = gtk_hbox_new(TRUE, 0);
-    gtk_box_pack_start(GTK_BOX(h_box), button, FALSE, FALSE, 0);
-    gtk_file_chooser_set_extra_widget (GTK_FILE_CHOOSER(info->file_chooser), h_box);
-    g_signal_connect (G_OBJECT (button), "clicked",
-                      G_CALLBACK (csv_import_trans_file_chooser_confirm_cb), info);
-
-    box = GTK_WIDGET(gtk_builder_get_object(builder, "file_page"));
-    gtk_box_pack_start (GTK_BOX (box), info->file_chooser, TRUE, TRUE, 6);
-    gtk_widget_show (info->file_chooser);
-
-    /* Preview Settings Page */
-    {
-        char* sep_button_names[] = {"space_cbutton",
-                                    "tab_cbutton",
-                                    "comma_cbutton",
-                                    "colon_cbutton",
-                                    "semicolon_cbutton",
-                                    "hyphen_cbutton"
-                                   };
-        GtkContainer *date_format_container, *currency_format_container;
-        int i;
-
-        /* The table containing info->encselector and the separator configuration widgets */
-        GtkTable* enctable;
-
-        info->start_row_spin = GTK_WIDGET(gtk_builder_get_object (builder, "start_row"));
-        info->end_row_spin = GTK_WIDGET(gtk_builder_get_object (builder, "end_row"));
-        info->check_label = GTK_WIDGET(gtk_builder_get_object (builder, "check_label"));
-        info->check_butt = GTK_WIDGET(gtk_builder_get_object (builder, "check_butt"));
-
-        info->encselector = GO_CHARMAP_SEL(go_charmap_sel_new(GO_CHARMAP_SEL_TO_UTF8));
-        /* Connect the selector to the encoding_selected event handler. */
-        g_signal_connect(G_OBJECT(info->encselector), "charmap_changed",
-                         G_CALLBACK(encoding_selected), (gpointer)info);
-
-        /* Load the separator buttons from the glade builder file into the
-         * info->sep_buttons array. */
-        for (i = 0; i < SEP_NUM_OF_TYPES; i++)
-        {
-            info->sep_buttons[i]
-                = (GtkCheckButton*)GTK_WIDGET(gtk_builder_get_object (builder, sep_button_names[i]));
-            /* Connect them to the sep_button_clicked event handler. */
-            g_signal_connect(G_OBJECT(info->sep_buttons[i]), "toggled",
-                             G_CALLBACK(sep_button_clicked), (gpointer)info);
-        }
-
-        /* Load and connect the custom separator checkbutton in the same way
-         * as the other separator buttons. */
-        info->custom_cbutton
-            = (GtkCheckButton*)GTK_WIDGET(gtk_builder_get_object (builder, "custom_cbutton"));
-        g_signal_connect(G_OBJECT(info->custom_cbutton), "clicked",
-                         G_CALLBACK(sep_button_clicked), (gpointer)info);
-
-        /* Load the entry for the custom separator entry. Connect it to the
-         * sep_button_clicked event handler as well. */
-        info->custom_entry = (GtkEntry*)GTK_WIDGET(gtk_builder_get_object (builder, "custom_entry"));
-        g_signal_connect(G_OBJECT(info->custom_entry), "changed",
-                         G_CALLBACK(sep_button_clicked), (gpointer)info);
-
-        /* Get the table from the Glade builder file. */
-        enctable = GTK_TABLE(gtk_builder_get_object (builder, "enctable"));
-        /* Put the selector in at the top. */
-        gtk_table_attach_defaults(enctable, GTK_WIDGET(info->encselector), 1, 2, 0, 1);
-        /* Show the table in all its glory. */
-        gtk_widget_show_all(GTK_WIDGET(enctable));
-
-        /* The instructions label and image */
-        info->instructions_label = GTK_LABEL(gtk_builder_get_object (builder, "instructions_label"));
-        info->instructions_image = GTK_IMAGE(gtk_builder_get_object (builder, "instructions_image"));
-
-        /* Add in the date format combo box and hook it up to an event handler. */
-        info->date_format_combo = GTK_COMBO_BOX_TEXT(gtk_combo_box_text_new());
-        for (i = 0; i < num_date_formats; i++)
-        {
-            gtk_combo_box_text_append_text(info->date_format_combo, _(date_format_user[i]));
-        }
-        gtk_combo_box_set_active(GTK_COMBO_BOX(info->date_format_combo), 0);
-        g_signal_connect(G_OBJECT(info->date_format_combo), "changed",
-                         G_CALLBACK(date_format_selected), (gpointer)info);
-
-        /* Add it to the assistant. */
-        date_format_container = GTK_CONTAINER(gtk_builder_get_object (builder, "date_format_container"));
-        gtk_container_add(date_format_container, GTK_WIDGET(info->date_format_combo));
-        gtk_widget_show_all(GTK_WIDGET(date_format_container));
-
-        /* Add in the currency format combo box and hook it up to an event handler. */
-        info->currency_format_combo = GTK_COMBO_BOX_TEXT(gtk_combo_box_text_new());
-        for (i = 0; i < num_currency_formats; i++)
-        {
-            gtk_combo_box_text_append_text(info->currency_format_combo, _(currency_format_user[i]));
-        }
-        /* Default will the locale */
-        gtk_combo_box_set_active(GTK_COMBO_BOX(info->currency_format_combo), 0);
-        g_signal_connect(G_OBJECT(info->currency_format_combo), "changed",
-                         G_CALLBACK(currency_format_selected), (gpointer)info);
-
-        /* Add it to the assistant. */
-        currency_format_container = GTK_CONTAINER(gtk_builder_get_object (builder, "currency_format_container"));
-        gtk_container_add(currency_format_container, GTK_WIDGET(info->currency_format_combo));
-        gtk_widget_show_all(GTK_WIDGET(currency_format_container));
-
-        /* Connect the CSV/Fixed-Width radio button event handler. */
-        csv_button = GTK_WIDGET(gtk_builder_get_object (builder, "csv_button"));
-        g_signal_connect(csv_button, "toggled",
-                         G_CALLBACK(separated_or_fixed_selected), (gpointer)info);
-
-        /* Load the data treeview and connect it to its resizing event handler. */
-        info->treeview = (GtkTreeView*)GTK_WIDGET(gtk_builder_get_object (builder, "treeview"));
-
-        /* Load the column type treeview. */
-        info->ctreeview = (GtkTreeView*)GTK_WIDGET(gtk_builder_get_object (builder, "ctreeview"));
-
-        /* This is TRUE only after encoding_selected is called, so we must
-         * set it initially to FALSE. */
-        info->encoding_selected_called = FALSE;
-
-        /* It is empty at first. */
-        info->not_empty = FALSE;
-    }
-
-    /* Account page */
-    /* Initialise the Account Picker and add to the Assistant */
-    info->account_page  = GTK_WIDGET(gtk_builder_get_object (builder, "account_page"));
-    info->account_picker = gnc_import_account_assist_setup(info->account_page);
-    info->account_label = GTK_WIDGET(gtk_builder_get_object (builder, "account_label"));
-
-    /* Matcher page */
-    info->match_page  = GTK_WIDGET(gtk_builder_get_object (builder, "match_page"));
-    info->match_label = GTK_WIDGET(gtk_builder_get_object (builder, "match_label"));
-
-    /* Summary Page */
-    info->summary_label = GTK_WIDGET(gtk_builder_get_object(builder, "summary_label"));
-
-    g_signal_connect (G_OBJECT(window), "destroy",
-                      G_CALLBACK (csv_import_trans_assistant_destroy_cb), info);
-
-    gnc_restore_window_size (GNC_PREFS_GROUP, GTK_WINDOW(info->window));
-
-    gtk_builder_connect_signals(builder, info);
-    g_object_unref(G_OBJECT(builder));
-    return window;
-}
-
-
-/********************************************************************\
- * gnc_file_csv_trans_import                                        *
- * opens up a assistant to import accounts.                         *
- *                                                                  *
- * Args:   import_type                                              *
- * Return: nothing                                                  *
-\********************************************************************/
-void
-gnc_file_csv_trans_import(void)
-{
-    CsvImportTrans *info;
-
-    info = g_new0 (CsvImportTrans, 1);
-
-    /* In order to trigger a book options display on the creation of a new book,
-     * we need to detect when we are dealing with a new book. */
-    info->new_book = gnc_is_new_book();
-
-    csv_import_trans_assistant_create (info);
-
-    gnc_register_gui_component (ASSISTANT_CSV_IMPORT_TRANS_CM_CLASS,
-                                NULL, csv_import_trans_close_handler,
-                                info);
-
-    gtk_widget_show_all (info->window);
-
-    gnc_window_adjust_for_screen (GTK_WINDOW(info->window));
-}

Deleted: gnucash/trunk/src/import-export/csv-import/assistant-csv-trans-import.glade
===================================================================
--- gnucash/trunk/src/import-export/csv-import/assistant-csv-trans-import.glade	2013-12-15 17:20:10 UTC (rev 23566)
+++ gnucash/trunk/src/import-export/csv-import/assistant-csv-trans-import.glade	2013-12-15 17:21:20 UTC (rev 23567)
@@ -1,865 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<interface>
-  <requires lib="gtk+" version="2.16"/>
-  <!-- interface-naming-policy project-wide -->
-  <object class="GtkAssistant" id="CSV Transaction Assistant">
-    <property name="can_focus">False</property>
-    <property name="border_width">12</property>
-    <property name="title" translatable="yes">CSV Transaction Import</property>
-    <property name="default_width">400</property>
-    <property name="default_height">500</property>
-    <signal name="close" handler="csv_import_trans_assistant_close" swapped="no"/>
-    <signal name="apply" handler="csv_import_trans_assistant_finish" swapped="no"/>
-    <signal name="prepare" handler="csv_import_trans_assistant_prepare" swapped="no"/>
-    <signal name="cancel" handler="csv_import_trans_assistant_cancel" swapped="no"/>
-    <child>
-      <object class="GtkLabel" id="start_page">
-        <property name="visible">True</property>
-        <property name="can_focus">False</property>
-        <property name="label" translatable="yes">This assistant will help you import a delimited file containing a list of transactions.
-
-All transactions imported will be associated to one account for each import and if you select the account column, the account in the first row will be used for all rows.
-
-Various options exist for specifying the delimiter as well as a fixed width option. With the fixed width option, double click on the bar above the displayed rows to set the column width.
-
-There is an option for specifying the start and end row which can be used if you have some header text or multiple accounts in the same file.</property>
-        <property name="wrap">True</property>
-      </object>
-      <packing>
-        <property name="page_type">intro</property>
-        <property name="title" translatable="yes">Transaction Import Assistant</property>
-        <property name="complete">True</property>
-      </packing>
-    </child>
-    <child>
-      <object class="GtkVBox" id="file_page">
-        <property name="visible">True</property>
-        <property name="can_focus">False</property>
-        <property name="border_width">12</property>
-        <child>
-          <object class="GtkLabel" id="label7">
-            <property name="visible">True</property>
-            <property name="can_focus">False</property>
-            <property name="label" translatable="yes">
-Select location and file name for the Import, then click 'OK'...
-</property>
-            <property name="wrap">True</property>
-          </object>
-          <packing>
-            <property name="expand">False</property>
-            <property name="fill">False</property>
-            <property name="position">0</property>
-          </packing>
-        </child>
-        <child>
-          <placeholder/>
-        </child>
-      </object>
-      <packing>
-        <property name="title" translatable="yes">Select File for Import</property>
-      </packing>
-    </child>
-    <child>
-      <object class="GtkVBox" id="preview_page">
-        <property name="visible">True</property>
-        <property name="can_focus">False</property>
-        <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
-        <property name="border_width">12</property>
-        <property name="spacing">2</property>
-        <child>
-          <object class="GtkHBox" id="hbox1">
-            <property name="visible">True</property>
-            <property name="can_focus">False</property>
-            <property name="spacing">12</property>
-            <child>
-              <object class="GtkVBox" id="vbox1">
-                <property name="visible">True</property>
-                <property name="can_focus">False</property>
-                <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
-                <child>
-                  <object class="GtkHBox" id="hbox6">
-                    <property name="visible">True</property>
-                    <property name="can_focus">False</property>
-                    <child>
-                      <object class="GtkLabel" id="label9">
-                        <property name="visible">True</property>
-                        <property name="can_focus">False</property>
-                        <property name="label" translatable="yes">Start import on row </property>
-                      </object>
-                      <packing>
-                        <property name="expand">False</property>
-                        <property name="fill">False</property>
-                        <property name="position">0</property>
-                      </packing>
-                    </child>
-                    <child>
-                      <object class="GtkSpinButton" id="start_row">
-                        <property name="visible">True</property>
-                        <property name="can_focus">True</property>
-                        <property name="editable">False</property>
-                        <property name="invisible_char">&#x25CF;</property>
-                        <property name="invisible_char_set">True</property>
-                        <property name="primary_icon_activatable">False</property>
-                        <property name="secondary_icon_activatable">False</property>
-                        <property name="primary_icon_sensitive">True</property>
-                        <property name="secondary_icon_sensitive">True</property>
-                        <property name="adjustment">start_row_adj</property>
-                        <signal name="value-changed" handler="csv_import_trans_srow_cb" swapped="no"/>
-                      </object>
-                      <packing>
-                        <property name="expand">False</property>
-                        <property name="fill">False</property>
-                        <property name="position">1</property>
-                      </packing>
-                    </child>
-                    <child>
-                      <object class="GtkLabel" id="label10">
-                        <property name="visible">True</property>
-                        <property name="can_focus">False</property>
-                        <property name="label" translatable="yes"> and stop on row </property>
-                      </object>
-                      <packing>
-                        <property name="expand">False</property>
-                        <property name="fill">False</property>
-                        <property name="position">2</property>
-                      </packing>
-                    </child>
-                    <child>
-                      <object class="GtkSpinButton" id="end_row">
-                        <property name="visible">True</property>
-                        <property name="can_focus">True</property>
-                        <property name="editable">False</property>
-                        <property name="invisible_char">&#x25CF;</property>
-                        <property name="invisible_char_set">True</property>
-                        <property name="primary_icon_activatable">False</property>
-                        <property name="secondary_icon_activatable">False</property>
-                        <property name="primary_icon_sensitive">True</property>
-                        <property name="secondary_icon_sensitive">True</property>
-                        <property name="adjustment">end_row_adj</property>
-                        <signal name="value-changed" handler="csv_import_trans_erow_cb" swapped="no"/>
-                      </object>
-                      <packing>
-                        <property name="expand">False</property>
-                        <property name="fill">False</property>
-                        <property name="position">3</property>
-                      </packing>
-                    </child>
-                  </object>
-                  <packing>
-                    <property name="expand">False</property>
-                    <property name="fill">False</property>
-                    <property name="position">0</property>
-                  </packing>
-                </child>
-                <child>
-                  <object class="GtkHSeparator" id="hseparator7">
-                    <property name="visible">True</property>
-                    <property name="can_focus">False</property>
-                  </object>
-                  <packing>
-                    <property name="expand">False</property>
-                    <property name="fill">True</property>
-                    <property name="padding">8</property>
-                    <property name="position">1</property>
-                  </packing>
-                </child>
-                <child>
-                  <object class="GtkHBox" id="hbox4">
-                    <property name="visible">True</property>
-                    <property name="can_focus">False</property>
-                    <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
-                    <child>
-                      <object class="GtkLabel" id="label1">
-                        <property name="visible">True</property>
-                        <property name="can_focus">False</property>
-                        <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
-                        <property name="label" translatable="yes">Data type: </property>
-                      </object>
-                      <packing>
-                        <property name="expand">False</property>
-                        <property name="fill">True</property>
-                        <property name="position">0</property>
-                      </packing>
-                    </child>
-                    <child>
-                      <object class="GtkRadioButton" id="csv_button">
-                        <property name="label" translatable="yes">Separated</property>
-                        <property name="visible">True</property>
-                        <property name="can_focus">True</property>
-                        <property name="receives_default">False</property>
-                        <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
-                        <property name="use_action_appearance">False</property>
-                        <property name="active">True</property>
-                        <property name="draw_indicator">True</property>
-                      </object>
-                      <packing>
-                        <property name="expand">False</property>
-                        <property name="fill">True</property>
-                        <property name="position">1</property>
-                      </packing>
-                    </child>
-                    <child>
-                      <object class="GtkRadioButton" id="radiobutton2">
-                        <property name="label" translatable="yes">Fixed-Width</property>
-                        <property name="visible">True</property>
-                        <property name="can_focus">True</property>
-                        <property name="receives_default">False</property>
-                        <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
-                        <property name="use_action_appearance">False</property>
-                        <property name="draw_indicator">True</property>
-                        <property name="group">csv_button</property>
-                      </object>
-                      <packing>
-                        <property name="expand">False</property>
-                        <property name="fill">True</property>
-                        <property name="position">2</property>
-                      </packing>
-                    </child>
-                  </object>
-                  <packing>
-                    <property name="expand">False</property>
-                    <property name="fill">True</property>
-                    <property name="position">2</property>
-                  </packing>
-                </child>
-                <child>
-                  <object class="GtkHSeparator" id="hseparator6">
-                    <property name="visible">True</property>
-                    <property name="can_focus">False</property>
-                    <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
-                  </object>
-                  <packing>
-                    <property name="expand">False</property>
-                    <property name="fill">False</property>
-                    <property name="padding">10</property>
-                    <property name="position">3</property>
-                  </packing>
-                </child>
-                <child>
-                  <object class="GtkHBox" id="hbox7">
-                    <property name="visible">True</property>
-                    <property name="can_focus">False</property>
-                    <child>
-                      <object class="GtkFrame" id="frame2">
-                        <property name="visible">True</property>
-                        <property name="can_focus">False</property>
-                        <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
-                        <property name="label_xalign">0</property>
-                        <property name="shadow_type">none</property>
-                        <child>
-                          <object class="GtkAlignment" id="date_format_container">
-                            <property name="visible">True</property>
-                            <property name="can_focus">False</property>
-                            <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
-                            <property name="left_padding">12</property>
-                            <child>
-                              <placeholder/>
-                            </child>
-                          </object>
-                        </child>
-                        <child type="label">
-                          <object class="GtkLabel" id="label4">
-                            <property name="visible">True</property>
-                            <property name="can_focus">False</property>
-                            <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
-                            <property name="label" translatable="yes">Date Format</property>
-                            <property name="use_markup">True</property>
-                          </object>
-                        </child>
-                      </object>
-                      <packing>
-                        <property name="expand">False</property>
-                        <property name="fill">False</property>
-                        <property name="position">0</property>
-                      </packing>
-                    </child>
-                    <child>
-                      <object class="GtkFrame" id="frame3">
-                        <property name="visible">True</property>
-                        <property name="can_focus">False</property>
-                        <property name="label_xalign">0</property>
-                        <property name="shadow_type">none</property>
-                        <child>
-                          <object class="GtkAlignment" id="currency_format_container">
-                            <property name="visible">True</property>
-                            <property name="can_focus">False</property>
-                            <property name="left_padding">12</property>
-                            <child>
-                              <placeholder/>
-                            </child>
-                          </object>
-                        </child>
-                        <child type="label">
-                          <object class="GtkLabel" id="label2">
-                            <property name="visible">True</property>
-                            <property name="can_focus">False</property>
-                            <property name="label" translatable="yes">Currency format</property>
-                            <property name="use_markup">True</property>
-                          </object>
-                        </child>
-                      </object>
-                      <packing>
-                        <property name="expand">True</property>
-                        <property name="fill">True</property>
-                        <property name="position">1</property>
-                      </packing>
-                    </child>
-                  </object>
-                  <packing>
-                    <property name="expand">False</property>
-                    <property name="fill">False</property>
-                    <property name="position">4</property>
-                  </packing>
-                </child>
-                <child>
-                  <object class="GtkHSeparator" id="hseparator3">
-                    <property name="visible">True</property>
-                    <property name="can_focus">False</property>
-                    <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
-                  </object>
-                  <packing>
-                    <property name="expand">False</property>
-                    <property name="fill">False</property>
-                    <property name="padding">10</property>
-                    <property name="position">5</property>
-                  </packing>
-                </child>
-              </object>
-              <packing>
-                <property name="expand">False</property>
-                <property name="fill">False</property>
-                <property name="position">0</property>
-              </packing>
-            </child>
-            <child>
-              <object class="GtkVBox" id="vbox3">
-                <property name="visible">True</property>
-                <property name="can_focus">False</property>
-                <child>
-                  <object class="GtkHBox" id="hbox2">
-                    <property name="visible">True</property>
-                    <property name="can_focus">False</property>
-                    <child>
-                      <object class="GtkTable" id="enctable">
-                        <property name="visible">True</property>
-                        <property name="can_focus">False</property>
-                        <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
-                        <child>
-                          <object class="GtkLabel" id="label3">
-                            <property name="visible">True</property>
-                            <property name="can_focus">False</property>
-                            <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
-                            <property name="label" translatable="yes">Encoding: </property>
-                          </object>
-                          <packing>
-                            <property name="x_options">GTK_FILL</property>
-                            <property name="y_options">GTK_FILL</property>
-                          </packing>
-                        </child>
-                      </object>
-                      <packing>
-                        <property name="expand">True</property>
-                        <property name="fill">True</property>
-                        <property name="position">0</property>
-                      </packing>
-                    </child>
-                  </object>
-                  <packing>
-                    <property name="expand">False</property>
-                    <property name="fill">False</property>
-                    <property name="position">0</property>
-                  </packing>
-                </child>
-                <child>
-                  <object class="GtkHSeparator" id="hseparator1">
-                    <property name="visible">True</property>
-                    <property name="can_focus">False</property>
-                  </object>
-                  <packing>
-                    <property name="expand">False</property>
-                    <property name="fill">True</property>
-                    <property name="padding">5</property>
-                    <property name="position">1</property>
-                  </packing>
-                </child>
-                <child>
-                  <object class="GtkFrame" id="frame1">
-                    <property name="visible">True</property>
-                    <property name="can_focus">False</property>
-                    <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
-                    <property name="label_xalign">0</property>
-                    <property name="shadow_type">none</property>
-                    <child>
-                      <object class="GtkAlignment" id="alignment1">
-                        <property name="visible">True</property>
-                        <property name="can_focus">False</property>
-                        <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
-                        <property name="left_padding">12</property>
-                        <child>
-                          <object class="GtkTable" id="table1">
-                            <property name="visible">True</property>
-                            <property name="can_focus">False</property>
-                            <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
-                            <property name="n_rows">3</property>
-                            <property name="n_columns">3</property>
-                            <property name="column_spacing">3</property>
-                            <property name="row_spacing">3</property>
-                            <property name="homogeneous">True</property>
-                            <child>
-                              <object class="GtkCheckButton" id="space_cbutton">
-                                <property name="label" translatable="yes">Space</property>
-                                <property name="visible">True</property>
-                                <property name="can_focus">True</property>
-                                <property name="receives_default">False</property>
-                                <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
-                                <property name="use_action_appearance">False</property>
-                                <property name="draw_indicator">True</property>
-                              </object>
-                              <packing>
-                                <property name="x_options">GTK_FILL</property>
-                                <property name="y_options">GTK_FILL</property>
-                              </packing>
-                            </child>
-                            <child>
-                              <object class="GtkCheckButton" id="tab_cbutton">
-                                <property name="label" translatable="yes">Tab</property>
-                                <property name="visible">True</property>
-                                <property name="can_focus">True</property>
-                                <property name="receives_default">False</property>
-                                <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
-                                <property name="use_action_appearance">False</property>
-                                <property name="draw_indicator">True</property>
-                              </object>
-                              <packing>
-                                <property name="left_attach">1</property>
-                                <property name="right_attach">2</property>
-                                <property name="x_options">GTK_FILL</property>
-                                <property name="y_options">GTK_FILL</property>
-                              </packing>
-                            </child>
-                            <child>
-                              <object class="GtkCheckButton" id="comma_cbutton">
-                                <property name="label" translatable="yes">Comma (,)</property>
-                                <property name="visible">True</property>
-                                <property name="can_focus">True</property>
-                                <property name="receives_default">False</property>
-                                <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
-                                <property name="use_action_appearance">False</property>
-                                <property name="active">True</property>
-                                <property name="draw_indicator">True</property>
-                              </object>
-                              <packing>
-                                <property name="left_attach">2</property>
-                                <property name="right_attach">3</property>
-                                <property name="x_options">GTK_FILL</property>
-                                <property name="y_options">GTK_FILL</property>
-                              </packing>
-                            </child>
-                            <child>
-                              <object class="GtkCheckButton" id="colon_cbutton">
-                                <property name="label" translatable="yes">Colon (:)</property>
-                                <property name="visible">True</property>
-                                <property name="can_focus">True</property>
-                                <property name="receives_default">False</property>
-                                <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
-                                <property name="use_action_appearance">False</property>
-                                <property name="draw_indicator">True</property>
-                              </object>
-                              <packing>
-                                <property name="top_attach">1</property>
-                                <property name="bottom_attach">2</property>
-                                <property name="x_options">GTK_FILL</property>
-                                <property name="y_options">GTK_FILL</property>
-                              </packing>
-                            </child>
-                            <child>
-                              <object class="GtkCheckButton" id="semicolon_cbutton">
-                                <property name="label" translatable="yes">Semicolon (;)</property>
-                                <property name="visible">True</property>
-                                <property name="can_focus">True</property>
-                                <property name="receives_default">False</property>
-                                <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
-                                <property name="use_action_appearance">False</property>
-                                <property name="draw_indicator">True</property>
-                              </object>
-                              <packing>
-                                <property name="left_attach">1</property>
-                                <property name="right_attach">2</property>
-                                <property name="top_attach">1</property>
-                                <property name="bottom_attach">2</property>
-                                <property name="x_options">GTK_FILL</property>
-                                <property name="y_options">GTK_FILL</property>
-                              </packing>
-                            </child>
-                            <child>
-                              <object class="GtkCheckButton" id="hyphen_cbutton">
-                                <property name="label" translatable="yes">Hyphen (-)</property>
-                                <property name="visible">True</property>
-                                <property name="can_focus">True</property>
-                                <property name="receives_default">False</property>
-                                <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
-                                <property name="use_action_appearance">False</property>
-                                <property name="draw_indicator">True</property>
-                              </object>
-                              <packing>
-                                <property name="left_attach">2</property>
-                                <property name="right_attach">3</property>
-                                <property name="top_attach">1</property>
-                                <property name="bottom_attach">2</property>
-                                <property name="x_options">GTK_FILL</property>
-                                <property name="y_options">GTK_FILL</property>
-                              </packing>
-                            </child>
-                            <child>
-                              <object class="GtkCheckButton" id="custom_cbutton">
-                                <property name="label" translatable="yes">Custom</property>
-                                <property name="visible">True</property>
-                                <property name="can_focus">True</property>
-                                <property name="receives_default">False</property>
-                                <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
-                                <property name="use_action_appearance">False</property>
-                                <property name="draw_indicator">True</property>
-                              </object>
-                              <packing>
-                                <property name="top_attach">2</property>
-                                <property name="bottom_attach">3</property>
-                                <property name="x_options">GTK_FILL</property>
-                                <property name="y_options">GTK_FILL</property>
-                              </packing>
-                            </child>
-                            <child>
-                              <object class="GtkEntry" id="custom_entry">
-                                <property name="visible">True</property>
-                                <property name="can_focus">True</property>
-                                <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
-                                <property name="invisible_char">&#x25CF;</property>
-                                <property name="invisible_char_set">True</property>
-                                <property name="primary_icon_activatable">False</property>
-                                <property name="secondary_icon_activatable">False</property>
-                                <property name="primary_icon_sensitive">True</property>
-                                <property name="secondary_icon_sensitive">True</property>
-                              </object>
-                              <packing>
-                                <property name="left_attach">1</property>
-                                <property name="right_attach">3</property>
-                                <property name="top_attach">2</property>
-                                <property name="bottom_attach">3</property>
-                                <property name="x_options">GTK_FILL</property>
-                                <property name="y_options">GTK_FILL</property>
-                              </packing>
-                            </child>
-                          </object>
-                        </child>
-                      </object>
-                    </child>
-                    <child type="label">
-                      <object class="GtkLabel" id="label5">
-                        <property name="visible">True</property>
-                        <property name="can_focus">False</property>
-                        <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
-                        <property name="label" translatable="yes">Separators</property>
-                        <property name="use_markup">True</property>
-                      </object>
-                    </child>
-                  </object>
-                  <packing>
-                    <property name="expand">False</property>
-                    <property name="fill">False</property>
-                    <property name="position">2</property>
-                  </packing>
-                </child>
-                <child>
-                  <object class="GtkHSeparator" id="hseparator2">
-                    <property name="visible">True</property>
-                    <property name="can_focus">False</property>
-                  </object>
-                  <packing>
-                    <property name="expand">False</property>
-                    <property name="fill">True</property>
-                    <property name="padding">6</property>
-                    <property name="position">3</property>
-                  </packing>
-                </child>
-              </object>
-              <packing>
-                <property name="expand">False</property>
-                <property name="fill">False</property>
-                <property name="position">1</property>
-              </packing>
-            </child>
-          </object>
-          <packing>
-            <property name="expand">False</property>
-            <property name="fill">False</property>
-            <property name="position">0</property>
-          </packing>
-        </child>
-        <child>
-          <object class="GtkHBox" id="hbox3">
-            <property name="visible">True</property>
-            <property name="can_focus">False</property>
-            <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
-            <child>
-              <object class="GtkImage" id="instructions_image">
-                <property name="visible">True</property>
-                <property name="can_focus">False</property>
-                <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
-                <property name="stock">gtk-dialog-info</property>
-              </object>
-              <packing>
-                <property name="expand">False</property>
-                <property name="fill">True</property>
-                <property name="padding">2</property>
-                <property name="position">0</property>
-              </packing>
-            </child>
-            <child>
-              <object class="GtkLabel" id="instructions_label">
-                <property name="visible">True</property>
-                <property name="can_focus">False</property>
-                <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
-                <property name="xalign">0</property>
-                <property name="label" translatable="yes">Select the type of each column below.</property>
-              </object>
-              <packing>
-                <property name="expand">True</property>
-                <property name="fill">True</property>
-                <property name="position">1</property>
-              </packing>
-            </child>
-          </object>
-          <packing>
-            <property name="expand">False</property>
-            <property name="fill">False</property>
-            <property name="position">1</property>
-          </packing>
-        </child>
-        <child>
-          <object class="GtkScrolledWindow" id="scrolledwindow1">
-            <property name="visible">True</property>
-            <property name="can_focus">True</property>
-            <property name="hscrollbar_policy">automatic</property>
-            <property name="vscrollbar_policy">automatic</property>
-            <child>
-              <object class="GtkViewport" id="viewport1">
-                <property name="visible">True</property>
-                <property name="can_focus">False</property>
-                <child>
-                  <object class="GtkVBox" id="vbox2">
-                    <property name="visible">True</property>
-                    <property name="can_focus">False</property>
-                    <child>
-                      <object class="GtkTreeView" id="ctreeview">
-                        <property name="visible">True</property>
-                        <property name="can_focus">True</property>
-                        <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
-                        <property name="headers_visible">False</property>
-                        <property name="enable_grid_lines">both</property>
-                      </object>
-                      <packing>
-                        <property name="expand">False</property>
-                        <property name="fill">True</property>
-                        <property name="position">0</property>
-                      </packing>
-                    </child>
-                    <child>
-                      <object class="GtkTreeView" id="treeview">
-                        <property name="visible">True</property>
-                        <property name="can_focus">True</property>
-                        <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
-                        <property name="enable_grid_lines">both</property>
-                      </object>
-                      <packing>
-                        <property name="expand">True</property>
-                        <property name="fill">True</property>
-                        <property name="position">1</property>
-                      </packing>
-                    </child>
-                  </object>
-                </child>
-              </object>
-            </child>
-          </object>
-          <packing>
-            <property name="expand">True</property>
-            <property name="fill">True</property>
-            <property name="position">2</property>
-          </packing>
-        </child>
-        <child>
-          <object class="GtkHBox" id="hbox5">
-            <property name="visible">True</property>
-            <property name="can_focus">False</property>
-            <child>
-              <object class="GtkCheckButton" id="check_butt">
-                <property name="visible">True</property>
-                <property name="can_focus">True</property>
-                <property name="receives_default">False</property>
-                <property name="use_action_appearance">False</property>
-                <property name="xalign">1</property>
-                <property name="image_position">right</property>
-                <property name="active">True</property>
-                <property name="draw_indicator">True</property>
-                <signal name="toggled" handler="csv_import_trans_auto_cb" swapped="no"/>
-              </object>
-              <packing>
-                <property name="expand">False</property>
-                <property name="fill">False</property>
-                <property name="pack_type">end</property>
-                <property name="position">0</property>
-              </packing>
-            </child>
-            <child>
-              <object class="GtkLabel" id="check_label">
-                <property name="visible">True</property>
-                <property name="can_focus">False</property>
-                <property name="xpad">5</property>
-                <property name="label" translatable="yes">Step over Account Page if Setup</property>
-              </object>
-              <packing>
-                <property name="expand">False</property>
-                <property name="fill">False</property>
-                <property name="pack_type">end</property>
-                <property name="position">1</property>
-              </packing>
-            </child>
-          </object>
-          <packing>
-            <property name="expand">False</property>
-            <property name="fill">False</property>
-            <property name="pack_type">end</property>
-            <property name="position">3</property>
-          </packing>
-        </child>
-      </object>
-      <packing>
-        <property name="title" translatable="yes">Preview Settings</property>
-      </packing>
-    </child>
-    <child>
-      <object class="GtkVBox" id="account_page">
-        <property name="visible">True</property>
-        <property name="can_focus">False</property>
-        <property name="border_width">12</property>
-        <child>
-          <placeholder/>
-        </child>
-        <child>
-          <placeholder/>
-        </child>
-        <child>
-          <object class="GtkLabel" id="account_label">
-            <property name="visible">True</property>
-            <property name="can_focus">False</property>
-            <property name="label" translatable="yes">Error text.</property>
-            <property name="justify">center</property>
-          </object>
-          <packing>
-            <property name="expand">False</property>
-            <property name="fill">False</property>
-            <property name="pack_type">end</property>
-            <property name="position">2</property>
-          </packing>
-        </child>
-      </object>
-      <packing>
-        <property name="title" translatable="yes">Account Selection</property>
-      </packing>
-    </child>
-    <child>
-      <object class="GtkVBox" id="doc_page">
-        <property name="visible">True</property>
-        <property name="can_focus">False</property>
-        <child>
-          <object class="GtkLabel" id="label8">
-            <property name="visible">True</property>
-            <property name="can_focus">False</property>
-            <property name="label" translatable="yes">On the following page you will be able to associate each transaction to a category.
-
-If this is the first time importing, you will find that all lines may need to be associated. On subsequent imports, the importer will try to associate the transactions based on previous imports.
-
-If this is your initial import into a new file, you will first see a dialog for setting book options, since these can affect how imported data are converted to GnuCash transactions. If this is an existing file, the dialog will not be shown.
-
-The confidence of a correct association is displayed as a colored bar.
-
-More information can be displayed by using the help button.</property>
-            <property name="wrap">True</property>
-          </object>
-          <packing>
-            <property name="expand">True</property>
-            <property name="fill">True</property>
-            <property name="position">0</property>
-          </packing>
-        </child>
-      </object>
-      <packing>
-        <property name="page_type">progress</property>
-        <property name="title" translatable="yes">Transaction Information</property>
-        <property name="complete">True</property>
-      </packing>
-    </child>
-    <child>
-      <object class="GtkVBox" id="match_page">
-        <property name="visible">True</property>
-        <property name="can_focus">False</property>
-        <property name="border_width">12</property>
-        <child>
-          <object class="GtkLabel" id="match_label">
-            <property name="visible">True</property>
-            <property name="can_focus">False</property>
-            <property name="label" translatable="yes">label</property>
-          </object>
-          <packing>
-            <property name="expand">False</property>
-            <property name="fill">False</property>
-            <property name="pack_type">end</property>
-            <property name="position">0</property>
-          </packing>
-        </child>
-      </object>
-      <packing>
-        <property name="page_type">confirm</property>
-        <property name="title" translatable="yes">Match Transactions</property>
-      </packing>
-    </child>
-    <child>
-      <object class="GtkVBox" id="summary_page">
-        <property name="visible">True</property>
-        <property name="can_focus">False</property>
-        <property name="border_width">12</property>
-        <child>
-          <object class="GtkLabel" id="summary_label">
-            <property name="visible">True</property>
-            <property name="can_focus">False</property>
-            <property name="label" translatable="yes">label</property>
-            <property name="use_markup">True</property>
-          </object>
-          <packing>
-            <property name="expand">True</property>
-            <property name="fill">True</property>
-            <property name="position">0</property>
-          </packing>
-        </child>
-      </object>
-      <packing>
-        <property name="page_type">summary</property>
-        <property name="title" translatable="yes">Import Summary</property>
-        <property name="complete">True</property>
-      </packing>
-    </child>
-  </object>
-  <object class="GtkAdjustment" id="end_row_adj">
-    <property name="lower">1</property>
-    <property name="upper">100</property>
-    <property name="value">100</property>
-    <property name="step_increment">1</property>
-    <property name="page_increment">10</property>
-  </object>
-  <object class="GtkAdjustment" id="start_row_adj">
-    <property name="lower">1</property>
-    <property name="upper">100</property>
-    <property name="value">1</property>
-    <property name="step_increment">1</property>
-    <property name="page_increment">10</property>
-  </object>
-</interface>

Deleted: gnucash/trunk/src/import-export/csv-import/assistant-csv-trans-import.h
===================================================================
--- gnucash/trunk/src/import-export/csv-import/assistant-csv-trans-import.h	2013-12-15 17:20:10 UTC (rev 23566)
+++ gnucash/trunk/src/import-export/csv-import/assistant-csv-trans-import.h	2013-12-15 17:21:20 UTC (rev 23567)
@@ -1,36 +0,0 @@
-/*******************************************************************\
- * assistant-csv-trans-import.h -- An assistant for importing       *
- *                                     Transactions from a file.    *
- *                                                                  *
- * Copyright (C) 2012 Robert Fewell                                 *
- *                                                                  *
- * This program is free software; you can redistribute it and/or    *
- * modify it under the terms of the GNU General Public License as   *
- * published by the Free Software Foundation; either version 2 of   *
- * the License, or (at your option) any later version.              *
- *                                                                  *
- * This program is distributed in the hope that it will be useful,  *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of   *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the    *
- * GNU General Public License for more details.                     *
- *                                                                  *
- * You should have received a copy of the GNU General Public License*
- * along with this program; if not, contact:                        *
- *                                                                  *
- * Free Software Foundation           Voice:  +1-617-542-5942       *
- * 51 Franklin Street, Fifth Floor    Fax:    +1-617-542-2652       *
- * Boston, MA  02110-1301,  USA       gnu at gnu.org                   *
-\********************************************************************/
-/** @file assistant-csv-trans-import.h
-    @brief CSV Import Assistant
-    @author Copyright (c) 2011 Robert Fewell
-*/
-#ifndef GNC_ASSISTANT_CSV_IMPORT_TRANS_H
-#define GNC_ASSISTANT_CSV_IMPORT_TRANS_H
-
-
-/** The gnc_file_csv_trans_import() will let the user import thte
- *  account tree or transactions to a delimited file.
- */
-void gnc_file_csv_trans_import (void);
-#endif

Deleted: gnucash/trunk/src/import-export/csv-import/csv-account-import.c
===================================================================
--- gnucash/trunk/src/import-export/csv-import/csv-account-import.c	2013-12-15 17:20:10 UTC (rev 23566)
+++ gnucash/trunk/src/import-export/csv-import/csv-account-import.c	2013-12-15 17:21:20 UTC (rev 23567)
@@ -1,348 +0,0 @@
-/*******************************************************************\
- * csv-account-import.c -- Account importing from file              *
- *                                                                  *
- * Copyright (C) 2012 Robert Fewell                                 *
- *                                                                  *
- * Based on code from bi_import written by Sebastian Held  and      *
- * Mike Evans.                                                      *
- *                                                                  *
- * This program is free software; you can redistribute it and/or    *
- * modify it under the terms of the GNU General Public License as   *
- * published by the Free Software Foundation; either version 2 of   *
- * the License, or (at your option) any later version.              *
- *                                                                  *
- * This program is distributed in the hope that it will be useful,  *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of   *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the    *
- * GNU General Public License for more details.                     *
- *                                                                  *
- * You should have received a copy of the GNU General Public License*
- * along with this program; if not, contact:                        *
- *                                                                  *
- * Free Software Foundation           Voice:  +1-617-542-5942       *
- * 51 Franklin Street, Fifth Floor    Fax:    +1-617-542-2652       *
- * Boston, MA  02110-1301,  USA       gnu at gnu.org                   *
-\********************************************************************/
-
-#include "config.h"
-
-#include <glib.h>
-#include <glib/gi18n.h>
-#include <glib/gstdio.h>
-
-#include "gnc-ui-util.h"
-#include <regex.h>
-#include "Account.h"
-#include "gnc-component-manager.h"
-#include "csv-account-import.h"
-
-/* This static indicates the debugging module that this .o belongs to.  */
-static QofLogModule log_module = GNC_MOD_ASSISTANT;
-
-/* This helper macro takes a regexp match and fills the model */
-#define FILL_IN_HELPER(match_name,column) \
-            temp = g_match_info_fetch_named (match_info, match_name); \
-            if (temp) \
-            { \
-		g_strstrip( temp ); \
-                gtk_list_store_set (store, &iter, column, temp, -1); \
-                g_free (temp); \
-            }
-
-
-/*******************************************************
- * csv_import_read_file
- *
- * Parse the file for a correctly formatted file
- *******************************************************/
-csv_import_result
-csv_import_read_file (const gchar *filename, const gchar *parser_regexp,
-                      GtkListStore *store, guint max_rows )
-{
-    FILE       *f;
-    char       *line;
-    gchar      *line_utf8, *temp;
-    GMatchInfo *match_info;
-    GError     *err;
-    GRegex     *regexpat;
-    int         row = 0;
-    gboolean match_found = FALSE;
-
-    // model
-    GtkTreeIter iter;
-
-    f = g_fopen (filename, "rt");
-    if (!f)
-    {
-        //gnc_error_dialog( 0, _("File %s cannot be opened."), filename );
-        return RESULT_OPEN_FAILED;
-    }
-
-    // compile the regular expression and check for errors
-    err = NULL;
-    regexpat =
-        g_regex_new (parser_regexp, G_REGEX_EXTENDED | G_REGEX_OPTIMIZE | G_REGEX_DUPNAMES, 0, &err);
-    if (err != NULL)
-    {
-        GtkWidget *dialog;
-        gchar *errmsg;
-
-        errmsg = g_strdup_printf (_("Error in regular expression '%s':\n%s"),
-                                  parser_regexp, err->message);
-        g_error_free (err);
-        err = NULL;
-
-        dialog = gtk_message_dialog_new (NULL,
-                                         GTK_DIALOG_MODAL,
-                                         GTK_MESSAGE_ERROR,
-                                         GTK_BUTTONS_OK, "%s", errmsg);
-        gtk_dialog_run (GTK_DIALOG (dialog));
-        gtk_widget_destroy (dialog);
-        g_free (errmsg);
-        errmsg = 0;
-
-        fclose (f);
-        return RESULT_ERROR_IN_REGEXP;
-    }
-
-    // start the import
-#define buffer_size 1000
-    line = g_malloc0 (buffer_size);
-    while (!feof (f))
-    {
-        int l;
-        row++;
-        if (row == max_rows)
-            break;
-        // read one line
-        if (!fgets (line, buffer_size, f))
-            break;			// eof
-        // now strip the '\n' from the end of the line
-        l = strlen (line);
-        if ((l > 0) && (line[l - 1] == '\n'))
-            line[l - 1] = 0;
-
-        // convert line from locale into utf8
-        line_utf8 = g_locale_to_utf8 (line, -1, NULL, NULL, NULL);
-
-        // parse the line
-        match_info = NULL;	// it seems, that in contrast to documentation, match_info is not always set -> g_match_info_free will segfault
-        if (g_regex_match (regexpat, line_utf8, 0, &match_info))
-        {
-            match_found = TRUE;
-            // fill in the values
-            gtk_list_store_append (store, &iter);
-            FILL_IN_HELPER ("type", TYPE);
-            FILL_IN_HELPER ("full_name", FULL_NAME);
-            FILL_IN_HELPER ("name", NAME);
-            FILL_IN_HELPER ("code", CODE);
-            FILL_IN_HELPER ("description", DESCRIPTION);
-            FILL_IN_HELPER ("color", COLOR);
-            FILL_IN_HELPER ("notes", NOTES);
-            FILL_IN_HELPER ("commoditym", COMMODITYM);
-            FILL_IN_HELPER ("commodityn", COMMODITYN);
-            FILL_IN_HELPER ("hidden", HIDDEN);
-            FILL_IN_HELPER ("tax", TAX);
-            FILL_IN_HELPER ("place_holder", PLACE_HOLDER);
-            gtk_list_store_set (store, &iter, ROW_COLOR, NULL, -1);
-        }
-
-        g_match_info_free (match_info);
-        match_info = 0;
-        g_free (line_utf8);
-        line_utf8 = 0;
-    }
-    g_free (line);
-    line = 0;
-
-    g_regex_unref (regexpat);
-    regexpat = 0;
-    fclose (f);
-    if (match_found == TRUE)
-        return MATCH_FOUND;
-    else
-        return RESULT_OK;
-}
-
-
-/*******************************************************
- * csv_account_import
- *
- * Parse the liststore for account updates
- *******************************************************/
-void
-csv_account_import (CsvImportInfo *info)
-{
-    QofBook       *book;
-    Account       *acc, *parent, *root;
-    gboolean       valid;
-    GdkColor       testcolor;
-    GtkTreeIter    iter;
-    gchar         *type, *full_name, *name, *code, *description, *color;
-    gchar         *notes, *commoditym, *commodityn, *hidden, *tax, *place_holder;
-    int            row;
-
-    ENTER("");
-    book = gnc_get_current_book();
-    root = gnc_book_get_root_account(book);
-
-    info->num_new = 0;
-    info->num_updates = 0;
-
-    /* Move to the first valid entry in store */
-    row = info->header_rows;
-    valid = gtk_tree_model_iter_nth_child(GTK_TREE_MODEL(info->store), &iter, NULL, row );
-    while (valid)
-    {
-        /* Walk through the list, reading each row */
-        gtk_tree_model_get (GTK_TREE_MODEL (info->store), &iter,
-                            TYPE, &type,
-                            FULL_NAME, &full_name,
-                            NAME, &name,
-                            CODE, &code,
-                            DESCRIPTION, &description,
-                            COLOR, &color,
-                            NOTES, &notes,
-                            COMMODITYM, &commoditym,
-                            COMMODITYN, &commodityn,
-                            HIDDEN, &hidden,
-                            TAX, &tax,
-                            PLACE_HOLDER, &place_holder, -1);
-
-        /* See if we can find the account by full name */
-        acc = gnc_account_lookup_by_full_name(root, full_name);
-
-        DEBUG("Row is %u and full name is %s", row, full_name);
-        if (acc == NULL)
-        {
-            /* Account does not exist, Lets try and add it */
-            if (g_strrstr(full_name, name) != NULL)
-            {
-                gint string_position;
-                gnc_commodity *commodity;
-                gnc_commodity_table *table;
-                gchar *full_parent;
-
-                /* Get full name of parent account, allow for separator */
-                string_position = strlen(full_name) - strlen(name) - 1;
-
-                if (string_position == -1)
-                    full_parent = g_strdup(full_name);
-                else
-                    full_parent = g_strndup(full_name, string_position);
-
-                parent = gnc_account_lookup_by_full_name(root, full_parent);
-                g_free (full_parent);
-
-                if (parent == NULL && string_position != -1)
-                {
-                    gchar *text = g_strdup_printf( gettext("Row %u, path to account %s not found, added as top level\n"), row + 1, name );
-                    info->error = g_strconcat(info->error, text, NULL);
-                    g_free(text);
-                    PINFO("Unable to import Row %u for account %s, path not found!", row, name);
-                }
-
-                if (parent == NULL)
-                    parent = root;
-
-                /* Do we have a valid commodity */
-                table = gnc_commodity_table_get_table (book);
-                commodity = gnc_commodity_table_lookup( table, commodityn, commoditym);
-
-                if (commodity)
-                {
-                    DEBUG("We have a valid commodity and will add account %s", full_name);
-                    info->num_new =  info->num_new + 1;
-                    gnc_suspend_gui_refresh ();
-                    acc = xaccMallocAccount (book);
-                    xaccAccountBeginEdit (acc);
-                    xaccAccountSetName (acc, name);
-                    xaccAccountSetType(acc, xaccAccountStringToEnum (type));
-
-                    if (!g_strcmp0(notes, "") == 0)
-                        xaccAccountSetNotes (acc, notes);
-                    if (!g_strcmp0(description, "") == 0)
-                        xaccAccountSetDescription (acc, description);
-                    if (!g_strcmp0(code, "") == 0)
-                        xaccAccountSetCode (acc, code);
-
-                    if (!g_strcmp0(color, "") == 0)
-                    {
-                        if (gdk_color_parse(color, &testcolor))
-                            xaccAccountSetColor (acc, color);
-                    }
-
-                    if (g_strcmp0(hidden, "T") == 0)
-                        xaccAccountSetHidden (acc, TRUE);
-                    if (g_strcmp0(place_holder, "T") == 0)
-                        xaccAccountSetPlaceholder (acc, TRUE);
-
-                    xaccAccountSetCommodity(acc, commodity);
-                    xaccAccountBeginEdit (parent);
-                    gnc_account_append_child (parent, acc);
-                    xaccAccountCommitEdit (parent);
-                    xaccAccountCommitEdit (acc);
-                    gnc_resume_gui_refresh ();
-                }
-                else
-                {
-                    gchar *err_string = g_strdup_printf( gettext("Row %u, commodity %s / %s not found\n"), row + 1,
-                                                         commoditym, commodityn);
-                    info->error = g_strconcat(info->error, err_string, NULL);
-                    g_free(err_string);
-                    PINFO("Unable to import Row %u for account %s, commodity!", row, full_name);
-                }
-            }
-            else
-            {
-                gchar *err_string = g_strdup_printf( gettext("Row %u, account %s not in %s\n"), row + 1, name, full_name);
-                info->error = g_strconcat(info->error, err_string, NULL);
-                g_free(err_string);
-                PINFO("Unable to import Row %u for account %s, name!", row, full_name);
-            }
-        }
-        else
-        {
-            /* Lets try and update the color, notes, description, code entries */
-            DEBUG("Existing account, will try and update account %s", full_name);
-            info->num_updates = info->num_updates + 1;
-            if (!g_strcmp0(color, "") == 0)
-            {
-                if (gdk_color_parse(color, &testcolor))
-                    xaccAccountSetColor (acc, color);
-            }
-
-            if (!g_strcmp0(notes, "") == 0)
-            {
-                /* Check for multiple lines */
-                gchar **parts;
-                parts = g_strsplit(notes, "\\n", -1);
-                notes = g_strjoinv("\n", parts);
-                g_strfreev(parts);
-            }
-            xaccAccountSetNotes (acc, notes);
-
-            if (!g_strcmp0(description, "") == 0)
-                xaccAccountSetDescription (acc, description);
-            if (!g_strcmp0(code, "") == 0)
-                xaccAccountSetCode (acc, code);
-        }
-        valid = gtk_tree_model_iter_next (GTK_TREE_MODEL (info->store), &iter);
-        row++;
-
-        /* free resources */
-        g_free (type);
-        g_free (full_name);
-        g_free (name);
-        g_free (code);
-        g_free (description);
-        g_free (color);
-        g_free (notes);
-        g_free (commoditym);
-        g_free (commodityn);
-        g_free (hidden);
-        g_free (tax);
-        g_free (place_holder);
-    }
-    LEAVE("");
-}

Deleted: gnucash/trunk/src/import-export/csv-import/csv-account-import.h
===================================================================
--- gnucash/trunk/src/import-export/csv-import/csv-account-import.h	2013-12-15 17:20:10 UTC (rev 23566)
+++ gnucash/trunk/src/import-export/csv-import/csv-account-import.h	2013-12-15 17:21:20 UTC (rev 23567)
@@ -1,50 +0,0 @@
-/*******************************************************************\
- * csv-account-import.h -- Account importing from file              *
- *                                                                  *
- * Copyright (C) 2012 Robert Fewell                                 *
- *                                                                  *
- * Based on code from bi_import written by Sebastian Held  and      *
- * Mike Evans.                                                      *
- *                                                                  *
- * This program is free software; you can redistribute it and/or    *
- * modify it under the terms of the GNU General Public License as   *
- * published by the Free Software Foundation; either version 2 of   *
- * the License, or (at your option) any later version.              *
- *                                                                  *
- * This program is distributed in the hope that it will be useful,  *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of   *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the    *
- * GNU General Public License for more details.                     *
- *                                                                  *
- * You should have received a copy of the GNU General Public License*
- * along with this program; if not, contact:                        *
- *                                                                  *
- * Free Software Foundation           Voice:  +1-617-542-5942       *
- * 51 Franklin Street, Fifth Floor    Fax:    +1-617-542-2652       *
- * Boston, MA  02110-1301,  USA       gnu at gnu.org                   *
-\********************************************************************/
-
-#ifndef CSV_ACCOUNT_IMPORT_H
-#define CSV_ACCOUNT_IMPORT_H
-
-#include <glib.h>
-#include <gtk/gtk.h>
-
-#include "assistant-csv-account-import.h"
-
-enum _csv_import_result
-{
-    RESULT_OK,
-    RESULT_OPEN_FAILED,
-    RESULT_ERROR_IN_REGEXP,
-    MATCH_FOUND,
-};
-typedef enum _csv_import_result csv_import_result;
-
-csv_import_result
-csv_import_read_file (const gchar *filename, const gchar *parser_regexp, GtkListStore *store, guint max_rows );
-
-void csv_account_import(CsvImportInfo *info);
-
-#endif /* CSV_ACCOUNT_IMPORT_H */
-

Deleted: gnucash/trunk/src/import-export/csv-import/gnc-csv-gnumeric-popup.c
===================================================================
--- gnucash/trunk/src/import-export/csv-import/gnc-csv-gnumeric-popup.c	2013-12-15 17:20:10 UTC (rev 23566)
+++ gnucash/trunk/src/import-export/csv-import/gnc-csv-gnumeric-popup.c	2013-12-15 17:21:20 UTC (rev 23567)
@@ -1,195 +0,0 @@
-/* The following is code copied from Gnumeric 1.7.8 licensed under the
- * GNU General Public License version 2 and/or version 3. It is from the file
- * gnumeric/src/gui-util.c, and it has been modified slightly to work
- * within GnuCash. */
-
-/* Miguel de Icaza is not sure specifically who from the Gnumeric
- * community is the copyright owner of the code below, so, on his
- * recommendation, here is the full list of Gnumeric authors.
- *
- * Miguel de Icaza, creator.
- * Jody Goldberg, maintainer.
- * Harald Ashburner, Options pricers
- * Sean Atkinson, functions and X-Base importing.
- * Michel Berkelaar, Simplex algorithm for Solver (LP Solve).
- * Jean Brefort, Core charting engine.
- * Grandma Chema Celorio, Tester and sheet copy.
- * Frank Chiulli, OLE support.
- * Kenneth Christiansen, i18n, misc stuff.
- * Zbigniew Chyla, plugin system, i18n.
- * J.H.M. Dassen (Ray), debian packaging.
- * Jeroen Dirks, Simplex algorithm for Solver (LP Solve).
- * Tom Dyas, plugin support.
- * Gergo Erdi, Gnumeric hacker.
- * John Gotts, rpm packaging.
- * Andreas J. Guelzow, Gnumeric hacker.
- * Jon K. Hellan, Gnumeric hacker.
- * Ross Ihaka, special functions.
- * Jukka-Pekka Iivonen, numerous functions and tools.
- * Jakub Jelinek, Gnumeric hacker.
- * Chris Lahey, number format engine.
- * Adrian Likins, documentation, debugging.
- * Takashi Matsuda, original text plugin.
- * Michael Meeks, Excel and OLE2 importing.
- * Lutz Muller, SheetObject improvements.
- * Emmanuel Pacaud, Many plot types for charting engine.
- * Federico M. Quintero, canvas support.
- * Mark Probst, Guile support.
- * Rasca, HTML, troff, LaTeX exporters.
- * Vincent Renardias, original CSV support, French localization.
- * Ariel Rios, Guile support.
- * Uwe Steinmann, Paradox Importer.
- * Arturo Tena, OLE support.
- * Almer S. Tigelaar, Gnumeric hacker.
- * Bruno Unna, Excel bits.
- * Daniel Veillard, XML support.
- * Vladimir Vuksan, financial functions.
- * Morten Welinder, Gnumeric hacker and leak plugging demi-god.
- */
-
-#include "gnc-csv-gnumeric-popup.h"
-
-#include <glib/gi18n.h>
-
-static void
-popup_item_activate (GtkWidget *item, gpointer *user_data)
-{
-    GnumericPopupMenuElement const *elem =
-        g_object_get_data (G_OBJECT (item), "descriptor");
-    GnumericPopupMenuHandler handler =
-        g_object_get_data (G_OBJECT (item), "handler");
-
-    g_return_if_fail (elem != NULL);
-    g_return_if_fail (handler != NULL);
-
-    if (handler (elem, user_data))
-        gtk_widget_destroy (gtk_widget_get_toplevel (item));
-}
-
-static void
-gnumeric_create_popup_menu_list (GSList *elements,
-                                 GnumericPopupMenuHandler handler,
-                                 gpointer user_data,
-                                 int display_filter,
-                                 int sensitive_filter,
-                                 GdkEventButton *event)
-{
-    GtkWidget *menu, *item;
-    char const *trans;
-
-    menu = gtk_menu_new ();
-
-    for (; elements != NULL ; elements = elements->next)
-    {
-        GnumericPopupMenuElement const *element = elements->data;
-        char const * const name = element->name;
-        char const * const pix_name = element->pixmap;
-
-        item = NULL;
-
-        if (element->display_filter != 0 &&
-                !(element->display_filter & display_filter))
-            continue;
-
-        if (name != NULL && *name != '\0')
-        {
-            trans = _(name);
-            item = gtk_image_menu_item_new_with_mnemonic (trans);
-            if (element->sensitive_filter != 0 &&
-                    (element->sensitive_filter & sensitive_filter))
-                gtk_widget_set_sensitive (GTK_WIDGET (item), FALSE);
-            if (pix_name != NULL)
-            {
-                GtkWidget *image = gtk_image_new_from_stock (pix_name,
-                                   GTK_ICON_SIZE_MENU);
-                gtk_widget_show (image);
-                gtk_image_menu_item_set_image (
-                    GTK_IMAGE_MENU_ITEM (item),
-                    image);
-            }
-        }
-        else
-        {
-            /* separator */
-            item = gtk_menu_item_new ();
-            gtk_widget_set_sensitive (item, FALSE);
-        }
-
-        if (element->index != 0)
-        {
-            g_signal_connect (G_OBJECT (item),
-                              "activate",
-                              G_CALLBACK (&popup_item_activate), user_data);
-            g_object_set_data (
-                G_OBJECT (item), "descriptor", (gpointer)(element));
-            g_object_set_data (
-                G_OBJECT (item), "handler", (gpointer)handler);
-        }
-
-        gtk_widget_show (item);
-        gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);
-    }
-
-    gnumeric_popup_menu (GTK_MENU (menu), event);
-}
-
-void
-gnumeric_create_popup_menu (GnumericPopupMenuElement const *elements,
-                            GnumericPopupMenuHandler handler,
-                            gpointer user_data,
-                            int display_filter, int sensitive_filter,
-                            GdkEventButton *event)
-{
-    int i;
-    GSList *tmp = NULL;
-
-    for (i = 0; elements [i].name != NULL; i++)
-        tmp = g_slist_prepend (tmp, (gpointer)(elements + i));
-
-    tmp = g_slist_reverse (tmp);
-    gnumeric_create_popup_menu_list (tmp, handler, user_data,
-                                     display_filter, sensitive_filter, event);
-    g_slist_free (tmp);
-}
-
-static void
-kill_popup_menu (GtkWidget *widget, GtkMenu *menu)
-{
-    g_return_if_fail (menu != NULL);
-    g_return_if_fail (GTK_IS_MENU (menu));
-
-    g_object_unref (G_OBJECT (menu));
-}
-
-/**
- * gnumeric_popup_menu :
- * @menu : #GtkMenu
- * @event : #GdkEventButton optionally NULL
- *
- * Bring up a popup and if @event is non-NULL ensure that the popup is on the
- * right screen.
- **/
-void
-gnumeric_popup_menu (GtkMenu *menu, GdkEventButton *event)
-{
-    g_return_if_fail (menu != NULL);
-    g_return_if_fail (GTK_IS_MENU (menu));
-
-    g_object_ref_sink (menu);
-
-    if (event)
-        gtk_menu_set_screen (menu,
-                             gdk_drawable_get_screen (event->window));
-
-    g_signal_connect (G_OBJECT (menu),
-                      "hide",
-                      G_CALLBACK (kill_popup_menu), menu);
-
-    /* Do NOT pass the button used to create the menu.
-     * instead pass 0.  Otherwise bringing up a menu with
-     * the right button will disable clicking on the menu with the left.
-     */
-    gtk_menu_popup (menu, NULL, NULL, NULL, NULL, 0,
-                    (event != NULL) ? event->time
-                    : gtk_get_current_event_time());
-}

Deleted: gnucash/trunk/src/import-export/csv-import/gnc-csv-gnumeric-popup.h
===================================================================
--- gnucash/trunk/src/import-export/csv-import/gnc-csv-gnumeric-popup.h	2013-12-15 17:20:10 UTC (rev 23566)
+++ gnucash/trunk/src/import-export/csv-import/gnc-csv-gnumeric-popup.h	2013-12-15 17:21:20 UTC (rev 23567)
@@ -1,79 +0,0 @@
-/* The following is code copied from Gnumeric 1.7.8 licensed under the
- * GNU General Public License version 2 and/or version 3. It is from the file
- * gnumeric/src/gui-util.h, and it has been modified slightly to work
- * within GnuCash. */
-
-/* Miguel de Icaza is not sure specifically who from the Gnumeric
- * community is the copyright owner of the code below, so, on his
- * recommendation, here is the full list of Gnumeric authors.
- *
- * Miguel de Icaza, creator.
- * Jody Goldberg, maintainer.
- * Harald Ashburner, Options pricers
- * Sean Atkinson, functions and X-Base importing.
- * Michel Berkelaar, Simplex algorithm for Solver (LP Solve).
- * Jean Brefort, Core charting engine.
- * Grandma Chema Celorio, Tester and sheet copy.
- * Frank Chiulli, OLE support.
- * Kenneth Christiansen, i18n, misc stuff.
- * Zbigniew Chyla, plugin system, i18n.
- * J.H.M. Dassen (Ray), debian packaging.
- * Jeroen Dirks, Simplex algorithm for Solver (LP Solve).
- * Tom Dyas, plugin support.
- * Gergo Erdi, Gnumeric hacker.
- * John Gotts, rpm packaging.
- * Andreas J. Guelzow, Gnumeric hacker.
- * Jon K. Hellan, Gnumeric hacker.
- * Ross Ihaka, special functions.
- * Jukka-Pekka Iivonen, numerous functions and tools.
- * Jakub Jelinek, Gnumeric hacker.
- * Chris Lahey, number format engine.
- * Adrian Likins, documentation, debugging.
- * Takashi Matsuda, original text plugin.
- * Michael Meeks, Excel and OLE2 importing.
- * Lutz Muller, SheetObject improvements.
- * Emmanuel Pacaud, Many plot types for charting engine.
- * Federico M. Quintero, canvas support.
- * Mark Probst, Guile support.
- * Rasca, HTML, troff, LaTeX exporters.
- * Vincent Renardias, original CSV support, French localization.
- * Ariel Rios, Guile support.
- * Uwe Steinmann, Paradox Importer.
- * Arturo Tena, OLE support.
- * Almer S. Tigelaar, Gnumeric hacker.
- * Bruno Unna, Excel bits.
- * Daniel Veillard, XML support.
- * Vladimir Vuksan, financial functions.
- * Morten Welinder, Gnumeric hacker and leak plugging demi-god.
- */
-
-#ifndef GNC_CSV_GNUMERIC_POPUP
-#define GNC_CSV_GNUMERIC_POPUP
-
-#include <gtk/gtk.h>
-
-typedef struct
-{
-    char const *name;
-    char const *pixmap;
-    int display_filter;
-    int sensitive_filter;
-
-    int index;
-} GnumericPopupMenuElement;
-
-typedef gboolean (*GnumericPopupMenuHandler) (GnumericPopupMenuElement const *e,
-        gpointer user_data);
-
-/* Use this on menus that are popped up */
-void gnumeric_popup_menu (GtkMenu *menu, GdkEventButton *event);
-
-void gnumeric_create_popup_menu (GnumericPopupMenuElement const *elements,
-                                 GnumericPopupMenuHandler handler,
-                                 gpointer user_data,
-                                 int display_filter,
-                                 int sensitive_filter,
-                                 GdkEventButton *event);
-
-
-#endif

Deleted: gnucash/trunk/src/import-export/csv-import/gnc-csv-model.c
===================================================================
--- gnucash/trunk/src/import-export/csv-import/gnc-csv-model.c	2013-12-15 17:20:10 UTC (rev 23566)
+++ gnucash/trunk/src/import-export/csv-import/gnc-csv-model.c	2013-12-15 17:21:20 UTC (rev 23567)
@@ -1,1268 +0,0 @@
-#include "gnc-csv-model.h"
-
-
-#include <glib/gi18n.h>
-
-#include <goffice/goffice-features.h>
-#if (GO_VERSION_EPOCH == 0) && (GO_VERSION_MAJOR == 7) && (GO_VERSION_MINOR == 8)
-/* For libgoffice-0.7.8, disable its internal inclusion of <regutf8.h>
-   so to avoid clashing symbol definitions with <regex.h> */
-# define GO_REGUTF8_H
-#endif
-#include <goffice/utils/go-glib-extras.h>
-
-#include "gnc-ui-util.h"
-#include "engine-helpers.h"
-
-#include <string.h>
-
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <regex.h>
-#include <unistd.h>
-#include <fcntl.h>
-#include <stdlib.h>
-#include <math.h>
-
-G_GNUC_UNUSED static QofLogModule log_module = GNC_MOD_IMPORT;
-
-const int num_date_formats = 5;
-const gchar* date_format_user[] = {N_("y-m-d"),
-                                   N_("d-m-y"),
-                                   N_("m-d-y"),
-                                   N_("d-m"),
-                                   N_("m-d")
-                                  };
-
-const int num_currency_formats = 3;
-const gchar* currency_format_user[] = {N_("Locale"),
-                                       N_("Period: 123,456.78"),
-                                       N_("Comma: 123.456,78")
-                                      };
-
-/* This array contains all of the different strings for different column types. */
-gchar* gnc_csv_column_type_strs[GNC_CSV_NUM_COL_TYPES] = {N_("None"),
-                                                          N_("Date"),
-                                                          N_("Num"),
-                                                          N_("Description"),
-                                                          N_("Notes"),
-                                                          N_("Account"),
-                                                          N_("Deposit"),
-                                                          N_("Withdrawal"),
-                                                          N_("Balance")
-                                                         };
-
-/** A set of sensible defaults for parsing CSV files.
- * @return StfParseOptions_t* for parsing a file with comma separators
- */
-static StfParseOptions_t* default_parse_options(void)
-{
-    StfParseOptions_t* options = stf_parse_options_new();
-    stf_parse_options_set_type(options, PARSE_TYPE_CSV);
-    stf_parse_options_csv_set_separators(options, ",", NULL);
-    return options;
-}
-
-/** Parses a string into a date, given a format. The format must
- * include the year. This function should only be called by
- * parse_date.
- * @param date_str The string containing a date being parsed
- * @param format An index specifying a format in date_format_user
- * @return The parsed value of date_str on success or -1 on failure
- */
-static time64 parse_date_with_year(const char* date_str, int format)
-{
-    time64 rawtime; /* The integer time */
-    struct tm retvalue, test_retvalue; /* The time in a broken-down structure */
-
-    int i, j, mem_length, orig_year = -1, orig_month = -1, orig_day = -1;
-
-    /* Buffer for containing individual parts (e.g. year, month, day) of a date */
-    char date_segment[5];
-
-    /* The compiled regular expression */
-    regex_t preg = {0};
-
-    /* An array containing indices specifying the matched substrings in date_str */
-    regmatch_t pmatch[4] = { {0}, {0}, {0}, {0} };
-
-    /* The regular expression for parsing dates */
-    const char* regex = "^ *([0-9]+) *[-/.'] *([0-9]+) *[-/.'] *([0-9]+).*$|^ *([0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]).*$";
-
-    /* We get our matches using the regular expression. */
-    regcomp(&preg, regex, REG_EXTENDED);
-    regexec(&preg, date_str, 4, pmatch, 0);
-    regfree(&preg);
-
-    /* If there wasn't a match, there was an error. */
-    if (pmatch[0].rm_eo == 0)
-        return -1;
-
-    /* If this is a string without separators ... */
-    if (pmatch[1].rm_so == -1)
-    {
-        /* ... we will fill in the indices based on the user's selection. */
-        int k = 0; /* k traverses date_str by keeping track of where separators "should" be. */
-        j = 1; /* j traverses pmatch. */
-        for (i = 0; date_format_user[format][i]; i++)
-        {
-            char segment_type = date_format_user[format][i];
-            /* Only do something if this is a meaningful character */
-            if (segment_type == 'y' || segment_type == 'm' || segment_type == 'd')
-            {
-                pmatch[j].rm_so = k;
-                switch (segment_type)
-                {
-                case 'm':
-                case 'd':
-                    k += 2;
-                    break;
-
-                case 'y':
-                    k += 4;
-                    break;
-                }
-
-                pmatch[j].rm_eo = k;
-                j++;
-            }
-        }
-    }
-
-    /* Put some sane values in retvalue by using the current time for
-     * the non-year-month-day parts of the date. */
-    gnc_time (&rawtime);
-    gnc_localtime_r (&rawtime, &retvalue);
-
-    /* j traverses pmatch (index 0 contains the entire string, so we
-     * start at index 1 for the first meaningful match). */
-    j = 1;
-    /* Go through the date format and interpret the matches in order of
-     * the sections in the date format. */
-    for (i = 0; date_format_user[format][i]; i++)
-    {
-        char segment_type = date_format_user[format][i];
-        /* Only do something if this is a meaningful character */
-        if (segment_type == 'y' || segment_type == 'm' || segment_type == 'd')
-        {
-            /* Copy the matching substring into date_segment so that we can
-             * convert it into an integer. */
-            mem_length = pmatch[j].rm_eo - pmatch[j].rm_so;
-            memcpy(date_segment, date_str + pmatch[j].rm_so, mem_length);
-            date_segment[mem_length] = '\0';
-
-            /* Set the appropriate member of retvalue. Save the original
-             * values so that we can check if the change when we use gnc_mktime
-             * below. */
-            switch (segment_type)
-            {
-            case 'y':
-                retvalue.tm_year = atoi(date_segment);
-
-                /* Handle two-digit years. */
-                if (retvalue.tm_year < 100)
-                {
-                    /* We allow two-digit years in the range 1969 - 2068. */
-                    if (retvalue.tm_year < 69)
-                        retvalue.tm_year += 100;
-                }
-                else
-                    retvalue.tm_year -= 1900;
-                orig_year = retvalue.tm_year;
-                break;
-
-            case 'm':
-                orig_month = retvalue.tm_mon = atoi(date_segment) - 1;
-                break;
-
-            case 'd':
-                orig_day = retvalue.tm_mday = atoi(date_segment);
-                break;
-            }
-            j++;
-        }
-    }
-    /* Convert back to an integer. If gnc_mktime leaves retvalue unchanged,
-     * everything is okay; otherwise, an error has occurred. */
-    /* We have to use a "test" date value to account for changes in
-     * daylight savings time, which can cause a date change with gnc_mktime
-     * near midnight, causing the code to incorrectly think a date is
-     * incorrect. */
-    test_retvalue = retvalue;
-    gnc_mktime (&test_retvalue);
-    retvalue.tm_isdst = test_retvalue.tm_isdst;
-    rawtime = gnc_mktime (&retvalue);
-    if (retvalue.tm_mday == orig_day &&
-            retvalue.tm_mon == orig_month &&
-            retvalue.tm_year == orig_year)
-    {
-        return rawtime;
-    }
-    else
-    {
-        return -1;
-    }
-}
-
-/** Parses a string into a date, given a format. The format cannot
- * include the year. This function should only be called by
- * parse_date.
- * @param date_str The string containing a date being parsed
- * @param format An index specifying a format in date_format_user
- * @return The parsed value of date_str on success or -1 on failure
- */
-static time64 parse_date_without_year(const char* date_str, int format)
-{
-    time64 rawtime; /* The integer time */
-    struct tm retvalue, test_retvalue; /* The time in a broken-down structure */
-
-    int i, j, mem_length, orig_year = -1, orig_month = -1, orig_day = -1;
-
-    /* Buffer for containing individual parts (e.g. year, month, day) of a date */
-    gchar* date_segment;
-
-    /* The compiled regular expression */
-    regex_t preg = {0};
-
-    /* An array containing indices specifying the matched substrings in date_str */
-    regmatch_t pmatch[3] = { {0}, {0}, {0} };
-
-    /* The regular expression for parsing dates */
-    const char* regex = "^ *([0-9]+) *[-/.'] *([0-9]+).*$";
-
-    /* We get our matches using the regular expression. */
-    regcomp(&preg, regex, REG_EXTENDED);
-    regexec(&preg, date_str, 3, pmatch, 0);
-    regfree(&preg);
-
-    /* If there wasn't a match, there was an error. */
-    if (pmatch[0].rm_eo == 0)
-        return -1;
-
-    /* Put some sane values in retvalue by using the current time for
-     * the non-year-month-day parts of the date. */
-    gnc_time (&rawtime);
-    gnc_localtime_r (&rawtime, &retvalue);
-    orig_year = retvalue.tm_year;
-
-    /* j traverses pmatch (index 0 contains the entire string, so we
-     * start at index 1 for the first meaningful match). */
-    j = 1;
-    /* Go through the date format and interpret the matches in order of
-     * the sections in the date format. */
-    for (i = 0; date_format_user[format][i]; i++)
-    {
-        char segment_type = date_format_user[format][i];
-        /* Only do something if this is a meaningful character */
-        if (segment_type == 'm' || segment_type == 'd')
-        {
-            /* Copy the matching substring into date_segment so that we can
-             * convert it into an integer. */
-            mem_length = pmatch[j].rm_eo - pmatch[j].rm_so;
-            date_segment = g_new(gchar, mem_length);
-            memcpy(date_segment, date_str + pmatch[j].rm_so, mem_length);
-            date_segment[mem_length] = '\0';
-
-            /* Set the appropriate member of retvalue. Save the original
-             * values so that we can check if the change when we use gnc_mktime
-             * below. */
-            switch (segment_type)
-            {
-            case 'm':
-                orig_month = retvalue.tm_mon = atoi(date_segment) - 1;
-                break;
-
-            case 'd':
-                orig_day = retvalue.tm_mday = atoi(date_segment);
-                break;
-            }
-            g_free(date_segment);
-            j++;
-        }
-    }
-    /* Convert back to an integer. If gnc_mktime leaves retvalue unchanged,
-     * everything is okay; otherwise, an error has occurred. */
-    /* We have to use a "test" date value to account for changes in
-     * daylight savings time, which can cause a date change with gnc_mktime
-     * near midnight, causing the code to incorrectly think a date is
-     * incorrect. */
-    test_retvalue = retvalue;
-    gnc_mktime (&test_retvalue);
-    retvalue.tm_isdst = test_retvalue.tm_isdst;
-    rawtime = gnc_mktime (&retvalue);
-    if (retvalue.tm_mday == orig_day &&
-            retvalue.tm_mon == orig_month &&
-            retvalue.tm_year == orig_year)
-    {
-        return rawtime;
-    }
-    else
-    {
-        return -1;
-    }
-}
-
-/** Parses a string into a date, given a format. This function
- * requires only knowing the order in which the year, month and day
- * appear. For example, 01-02-2003 will be parsed the same way as
- * 01/02/2003.
- * @param date_str The string containing a date being parsed
- * @param format An index specifying a format in date_format_user
- * @return The parsed value of date_str on success or -1 on failure
- */
-time64 parse_date(const char* date_str, int format)
-{
-    if (strchr(date_format_user[format], 'y'))
-        return parse_date_with_year(date_str, format);
-    else
-        return parse_date_without_year(date_str, format);
-}
-
-/** Constructor for GncCsvParseData.
- * @return Pointer to a new GncCSvParseData
- */
-GncCsvParseData* gnc_csv_new_parse_data(void)
-{
-    GncCsvParseData* parse_data = g_new(GncCsvParseData, 1);
-    parse_data->encoding = "UTF-8";
-    /* All of the data pointers are initially NULL. This is so that, if
-     * gnc_csv_parse_data_free is called before all of the data is
-     * initialized, only the data that needs to be freed is freed. */
-    parse_data->raw_str.begin = parse_data->raw_str.end
-                                = parse_data->file_str.begin = parse_data->file_str.end = NULL;
-    parse_data->orig_lines = NULL;
-    parse_data->orig_row_lengths = NULL;
-    parse_data->column_types = NULL;
-    parse_data->error_lines = parse_data->transactions = NULL;
-    parse_data->options = default_parse_options();
-    parse_data->date_format = -1;
-    parse_data->currency_format = 0;
-    parse_data->chunk = g_string_chunk_new(100 * 1024);
-    parse_data->start_row = 0;
-    parse_data->end_row = 1000;
-    return parse_data;
-}
-
-/** Destructor for GncCsvParseData.
- * @param parse_data Parse data whose memory will be freed
- */
-void gnc_csv_parse_data_free(GncCsvParseData* parse_data)
-{
-    /* All non-NULL pointers have been initialized and must be freed. */
-
-    if (parse_data->raw_mapping != NULL)
-    {
-        g_mapped_file_unref(parse_data->raw_mapping);
-    }
-
-    if (parse_data->file_str.begin != NULL)
-        g_free(parse_data->file_str.begin);
-
-    if (parse_data->orig_lines != NULL)
-        stf_parse_general_free(parse_data->orig_lines);
-
-    if (parse_data->orig_row_lengths != NULL)
-        g_array_free(parse_data->orig_row_lengths, FALSE);
-
-    if (parse_data->options != NULL)
-        stf_parse_options_free(parse_data->options);
-
-    if (parse_data->column_types != NULL)
-        g_array_free(parse_data->column_types, TRUE);
-
-    if (parse_data->error_lines != NULL)
-        g_list_free(parse_data->error_lines);
-
-    if (parse_data->transactions != NULL)
-    {
-        GList* transactions = parse_data->transactions;
-        /* We have to free the GncCsvTransLine's that are at each node in
-         * the list before freeing the entire list. */
-        do
-        {
-            g_free(transactions->data);
-            transactions = g_list_next(transactions);
-        }
-        while (transactions != NULL);
-        g_list_free(parse_data->transactions);
-    }
-
-    g_free(parse_data->chunk);
-    g_free(parse_data);
-}
-
-/** Converts raw file data using a new encoding. This function must be
- * called after gnc_csv_load_file only if gnc_csv_load_file guessed
- * the wrong encoding.
- * @param parse_data Data that is being parsed
- * @param encoding Encoding that data should be translated using
- * @param error Will point to an error on failure
- * @return 0 on success, 1 on failure
- */
-int gnc_csv_convert_encoding(GncCsvParseData* parse_data, const char* encoding,
-                             GError** error)
-{
-    gsize bytes_read, bytes_written;
-
-    /* If parse_data->file_str has already been initialized it must be
-     * freed first. (This should always be the case, since
-     * gnc_csv_load_file should always be called before this
-     * function.) */
-    if (parse_data->file_str.begin != NULL)
-        g_free(parse_data->file_str.begin);
-
-    /* Do the actual translation to UTF-8. */
-    parse_data->file_str.begin = g_convert(parse_data->raw_str.begin,
-                                           parse_data->raw_str.end - parse_data->raw_str.begin,
-                                           "UTF-8", encoding, &bytes_read, &bytes_written,
-                                           error);
-    /* Handle errors that occur. */
-    if (parse_data->file_str.begin == NULL)
-        return 1;
-
-    /* On success, save the ending pointer of the translated data and
-     * the encoding type and return 0. */
-    parse_data->file_str.end = parse_data->file_str.begin + bytes_written;
-    parse_data->encoding = (gchar*)encoding;
-    return 0;
-}
-
-/** Loads a file into a GncCsvParseData. This is the first function
- * that must be called after createing a new GncCsvParseData. If this
- * fails because the file couldn't be opened, no more functions can be
- * called on the parse data until this succeeds (or until it fails
- * because of an encoding guess error). If it fails because the
- * encoding could not be guessed, gnc_csv_convert_encoding must be
- * called until it succeeds.
- * @param parse_data Data that is being parsed
- * @param filename Name of the file that should be opened
- * @param error Will contain an error if there is a failure
- * @return 0 on success, 1 on failure
- */
-int gnc_csv_load_file(GncCsvParseData* parse_data, const char* filename,
-                      GError** error)
-{
-    const char* guess_enc = NULL;
-
-    /* Get the raw data first and handle an error if one occurs. */
-    parse_data->raw_mapping = g_mapped_file_new(filename, FALSE, error);
-    if (parse_data->raw_mapping == NULL)
-    {
-        /* TODO Handle file opening errors more specifically,
-         * e.g. inexistent file versus no read permission. */
-        parse_data->raw_str.begin = NULL;
-        g_clear_error (error);
-        g_set_error(error, 0, GNC_CSV_FILE_OPEN_ERR, "%s", _("File opening failed."));
-        return 1;
-    }
-
-    /* Copy the mapping's contents into parse-data->raw_str. */
-    parse_data->raw_str.begin = g_mapped_file_get_contents(parse_data->raw_mapping);
-    parse_data->raw_str.end = parse_data->raw_str.begin + g_mapped_file_get_length(parse_data->raw_mapping);
-
-    /* Make a guess at the encoding of the data. */
-    if (!g_mapped_file_get_length(parse_data->raw_mapping) == 0)
-        guess_enc = go_guess_encoding((const char*)(parse_data->raw_str.begin),
-                                      (size_t)(parse_data->raw_str.end - parse_data->raw_str.begin),
-                                      "UTF-8", NULL);
-    if (guess_enc == NULL)
-    {
-        g_set_error(error, 0, GNC_CSV_ENCODING_ERR, "%s", _("Unknown encoding."));
-        return 1;
-    }
-    /* Convert using the guessed encoding into parse_data->file_str and
-     * handle any errors that occur. */
-    gnc_csv_convert_encoding(parse_data, guess_enc, error);
-    if (parse_data->file_str.begin == NULL)
-    {
-        g_set_error(error, 0, GNC_CSV_ENCODING_ERR, "%s", _("Unknown encoding."));
-        return 1;
-    }
-    else
-        return 0;
-}
-
-/** Parses a file into cells. This requires having an encoding that
- * works (see gnc_csv_convert_encoding). parse_data->options should be
- * set according to how the user wants before calling this
- * function. (Note: this function must be called with guessColTypes as
- * TRUE before it is ever called with it as FALSE.) (Note: if
- * guessColTypes is TRUE, all the column types will be GNC_CSV_NONE
- * right now.)
- * @param parse_data Data that is being parsed
- * @param guessColTypes TRUE to guess what the types of columns are based on the cell contents
- * @param error Will contain an error if there is a failure
- * @return 0 on success, 1 on failure
- */
-int gnc_csv_parse(GncCsvParseData* parse_data, gboolean guessColTypes, GError** error)
-{
-    /* max_cols is the number of columns in the row with the most columns. */
-    int i, max_cols = 0;
-
-    if (parse_data->orig_lines != NULL)
-    {
-        stf_parse_general_free(parse_data->orig_lines);
-    }
-
-    /* If everything is fine ... */
-    if (parse_data->file_str.begin != NULL)
-    {
-        /* Do the actual parsing. */
-        parse_data->orig_lines = stf_parse_general(parse_data->options, parse_data->chunk,
-                                 parse_data->file_str.begin,
-                                 parse_data->file_str.end);
-    }
-    /* If we couldn't get the encoding right, we just want an empty array. */
-    else
-    {
-        parse_data->orig_lines = g_ptr_array_new();
-    }
-
-    /* Record the original row lengths of parse_data->orig_lines. */
-    if (parse_data->orig_row_lengths != NULL)
-        g_array_free(parse_data->orig_row_lengths, FALSE);
-
-    parse_data->orig_row_lengths =
-        g_array_sized_new(FALSE, FALSE, sizeof(int), parse_data->orig_lines->len);
-
-    g_array_set_size(parse_data->orig_row_lengths, parse_data->orig_lines->len);
-    parse_data->orig_max_row = 0;
-    for (i = 0; i < parse_data->orig_lines->len; i++)
-    {
-        int length = ((GPtrArray*)parse_data->orig_lines->pdata[i])->len;
-        parse_data->orig_row_lengths->data[i] = length;
-        if (length > parse_data->orig_max_row)
-            parse_data->orig_max_row = length;
-    }
-
-    /* If it failed, generate an error. */
-    if (parse_data->orig_lines == NULL)
-    {
-        g_set_error(error, 0, 0, "Parsing failed.");
-        return 1;
-    }
-
-    /* Now that we have data, let's set max_cols. */
-    for (i = 0; i < parse_data->orig_lines->len; i++)
-    {
-        if (max_cols < ((GPtrArray*)(parse_data->orig_lines->pdata[i]))->len)
-            max_cols = ((GPtrArray*)(parse_data->orig_lines->pdata[i]))->len;
-    }
-
-    if (guessColTypes)
-    {
-        /* Free parse_data->column_types if it's already been created. */
-        if (parse_data->column_types != NULL)
-            g_array_free(parse_data->column_types, TRUE);
-
-        /* Create parse_data->column_types and fill it with guesses based
-         * on the contents of each column. */
-        parse_data->column_types = g_array_sized_new(FALSE, FALSE, sizeof(int),
-                                   max_cols);
-        g_array_set_size(parse_data->column_types, max_cols);
-        /* TODO Make it actually guess. */
-        for (i = 0; i < parse_data->column_types->len; i++)
-        {
-            parse_data->column_types->data[i] = GNC_CSV_NONE;
-        }
-    }
-    else
-    {
-        /* If we don't need to guess column types, we will simply set any
-         * new columns that are created that didn't exist before to "None"
-         * since we don't want gibberish to appear. Note:
-         * parse_data->column_types should have already been
-         * initialized, so we don't check for it being NULL. */
-        int i = parse_data->column_types->len;
-        g_array_set_size(parse_data->column_types, max_cols);
-        for (; i < parse_data->column_types->len; i++)
-        {
-            parse_data->column_types->data[i] = GNC_CSV_NONE;
-        }
-    }
-
-    return 0;
-}
-
-/** A struct containing TransProperties that all describe a single transaction. */
-typedef struct
-{
-    int date_format; /**< The format for parsing dates */
-    int currency_format; /**< The format for currency */
-    Account* account; /**< The account the transaction belongs to */
-    GList* properties; /**< List of TransProperties */
-} TransPropertyList;
-
-/** A struct encapsulating a property of a transaction. */
-typedef struct
-{
-    int type; /**< A value from the GncCsvColumnType enum except
-             * GNC_CSV_NONE and GNC_CSV_NUM_COL_TYPES */
-    void* value; /**< Pointer to the data that will be used to configure a transaction */
-    TransPropertyList* list; /**< The list the property belongs to */
-} TransProperty;
-
-/** Constructor for TransProperty.
- * @param type The type of the new property (see TransProperty.type for possible values)
- */
-static TransProperty* trans_property_new(int type, TransPropertyList* list)
-{
-    TransProperty* prop = g_new(TransProperty, 1);
-    prop->type = type;
-    prop->list = list;
-    prop->value = NULL;
-    return prop;
-}
-
-/** Destructor for TransProperty.
- * @param prop The property to be freed
- */
-static void trans_property_free(TransProperty* prop)
-{
-    switch (prop->type)
-    {
-        /* The types for "Date" and "Balance" (time64 and gnc_numeric,
-         * respectively) are typically not pointed to, we have to free
-         * them, unlike types like char* ("Description"). */
-    case GNC_CSV_DATE:
-    case GNC_CSV_BALANCE:
-    case GNC_CSV_DEPOSIT:
-    case GNC_CSV_WITHDRAWAL:
-        if (prop->value != NULL)
-            g_free(prop->value);
-        break;
-    }
-    g_free(prop);
-}
-
-/** Sets the value of the property by parsing str. Note: this should
- * only be called once on an instance of TransProperty, as calling it
- * more than once can cause memory leaks.
- * @param prop The property being set
- * @param str The string to be parsed
- * @return TRUE on success, FALSE on failure
- */
-static gboolean trans_property_set(TransProperty* prop, char* str)
-{
-    char *endptr, *possible_currency_symbol, *str_dupe;
-    gnc_numeric val;
-    switch (prop->type)
-    {
-    case GNC_CSV_DATE:
-        prop->value = g_new(time64, 1);
-        *((time64*)(prop->value)) = parse_date(str, prop->list->date_format);
-        return *((time64*)(prop->value)) != -1;
-
-    case GNC_CSV_DESCRIPTION:
-    case GNC_CSV_NOTES:
-    case GNC_CSV_NUM:
-        prop->value = g_strdup(str);
-        return TRUE;
-
-    case GNC_CSV_BALANCE:
-    case GNC_CSV_DEPOSIT:
-    case GNC_CSV_WITHDRAWAL:
-        str_dupe = g_strdup(str); /* First, we make a copy so we can't mess up real data. */
-
-        /* Go through str_dupe looking for currency symbols. */
-        for (possible_currency_symbol = str_dupe; *possible_currency_symbol;
-                possible_currency_symbol = g_utf8_next_char(possible_currency_symbol))
-        {
-            if (g_unichar_type(g_utf8_get_char(possible_currency_symbol)) == G_UNICODE_CURRENCY_SYMBOL)
-            {
-                /* If we find a currency symbol, save the position just ahead
-                 * of the currency symbol (next_symbol), and find the null
-                 * terminator of the string (last_symbol). */
-                char *next_symbol = g_utf8_next_char(possible_currency_symbol), *last_symbol = next_symbol;
-                while (*last_symbol)
-                    last_symbol = g_utf8_next_char(last_symbol);
-
-                /* Move all of the string (including the null byte, which is
-                 * why we have +1 in the size parameter) following the
-                 * currency symbol back one character, thereby overwriting the
-                 * currency symbol. */
-                memmove(possible_currency_symbol, next_symbol, last_symbol - next_symbol + 1);
-                break;
-            }
-        }
-
-        /* Currency format */
-        switch (prop->list->currency_format)
-        {
-        case 0:
-            /* Currancy locale */
-            if (!(xaccParseAmount(str_dupe, TRUE, &val, &endptr)))
-            {
-                g_free(str_dupe);
-                return FALSE;
-            }
-            break;
-        case 1:
-            /* Currancy decimal period */
-            if (!(xaccParseAmountExtended(str_dupe, TRUE, '-', '.', ',', "\003\003", "$+", &val, &endptr)))
-            {
-                g_free(str_dupe);
-                return FALSE;
-            }
-            break;
-        case 2:
-            /* Currancy decimal comma */
-            if (!(xaccParseAmountExtended(str_dupe, TRUE, '-', ',', '.', "\003\003", "$+", &val, &endptr)))
-            {
-                g_free(str_dupe);
-                return FALSE;
-            }
-            break;
-        }
-
-        prop->value = g_new(gnc_numeric, 1);
-        *((gnc_numeric*)(prop->value)) = val;
-        g_free(str_dupe);
-        return TRUE;
-
-    }
-    return FALSE; /* We should never actually get here. */
-}
-
-/** Constructor for TransPropertyList.
- * @param account The account with which transactions should be built
- * @param date_format An index from date_format_user for how date properties should be parsed
- * @return A pointer to a new TransPropertyList
- */
-static TransPropertyList* trans_property_list_new(Account* account, int date_format, int currency_format)
-{
-    TransPropertyList* list = g_new(TransPropertyList, 1);
-    list->account = account;
-    list->date_format = date_format;
-    list->currency_format = currency_format;
-    list->properties = NULL;
-    return list;
-}
-
-/** Destructor for TransPropertyList.
- * @param list The list to be freed
- */
-static void trans_property_list_free(TransPropertyList* list)
-{
-    /* Free all of the properties in this list before freeeing the list itself. */
-    GList* properties_begin = list->properties;
-    while (list->properties != NULL)
-    {
-        trans_property_free((TransProperty*)(list->properties->data));
-        list->properties = g_list_next(list->properties);
-    }
-    g_list_free(properties_begin);
-    g_free(list);
-}
-
-/** Adds a property to the list it's linked with.
- * (The TransPropertyList is not passed as a parameter because the property is
- * associated with a list when it's constructed.)
- * @param property The property to be added to its list
- */
-static void trans_property_list_add(TransProperty* property)
-{
-    property->list->properties = g_list_append(property->list->properties, property);
-}
-
-/** Adds a split to a transaction.
- * @param trans The transaction to add a split to
- * @param account The account used for the split
- * @param book The book where the split should be stored
- * @param amount The amount of the split
- */
-static void trans_add_split(Transaction* trans, Account* account, QofBook* book,
-                            gnc_numeric amount, const char *num)
-{
-    Split* split = xaccMallocSplit(book);
-    xaccSplitSetAccount(split, account);
-    xaccSplitSetParent(split, trans);
-    xaccSplitSetAmount(split, amount);
-    xaccSplitSetValue(split, amount);
-    /* set tran-num and/or split-action per book option */
-    gnc_set_num_action(trans, split, num, NULL);
-}
-
-/** Tests a TransPropertyList for having enough essential properties.
- * Essential properties are "Date" and one of the following: "Balance", "Deposit", or
- * "Withdrawal".
- * @param list The list we are checking
- * @param error Contains an error message on failure
- * @return TRUE if there are enough essentials; FALSE otherwise
- */
-static gboolean trans_property_list_verify_essentials(TransPropertyList* list, gchar** error)
-{
-    int i;
-    /* possible_errors lists the ways in which a list can fail this test. */
-    enum PossibleErrorTypes {NO_DATE, NO_AMOUNT, NUM_OF_POSSIBLE_ERRORS};
-    gchar* possible_errors[NUM_OF_POSSIBLE_ERRORS] =
-    {
-        N_("No date column."),
-        N_("No balance, deposit, or withdrawal column.")
-    };
-    int possible_error_lengths[NUM_OF_POSSIBLE_ERRORS] = {0};
-    GList *properties_begin = list->properties, *errors_list = NULL;
-
-    /* Go through each of the properties and erase possible errors. */
-    while (list->properties)
-    {
-        switch (((TransProperty*)(list->properties->data))->type)
-        {
-        case GNC_CSV_DATE:
-            possible_errors[NO_DATE] = NULL;
-            break;
-
-        case GNC_CSV_BALANCE:
-        case GNC_CSV_DEPOSIT:
-        case GNC_CSV_WITHDRAWAL:
-            possible_errors[NO_AMOUNT] = NULL;
-            break;
-        }
-        list->properties = g_list_next(list->properties);
-    }
-    list->properties = properties_begin;
-
-    /* Accumulate a list of the actual errors. */
-    for (i = 0; i < NUM_OF_POSSIBLE_ERRORS; i++)
-    {
-        if (possible_errors[i] != NULL)
-        {
-            errors_list = g_list_append(errors_list, GINT_TO_POINTER(i));
-            /* Since we added an error, we want to also store its length for
-             * when we construct the full error string. */
-            possible_error_lengths[i] = strlen(_(possible_errors[i]));
-        }
-    }
-
-    /* If there are no errors, we can quit now. */
-    if (errors_list == NULL)
-        return TRUE;
-    else
-    {
-        /* full_error_size is the full length of the error message. */
-        int full_error_size = 0, string_length = 0;
-        GList* errors_list_begin = errors_list;
-        gchar *error_message, *error_message_begin;
-
-        /* Find the value for full_error_size. */
-        while (errors_list)
-        {
-            /* We add an extra 1 to account for spaces in between messages. */
-            full_error_size += possible_error_lengths[GPOINTER_TO_INT(errors_list->data)] + 1;
-            errors_list = g_list_next(errors_list);
-        }
-        errors_list = errors_list_begin;
-
-        /* Append the error messages one after another. */
-        error_message = error_message_begin = g_new(gchar, full_error_size);
-        while (errors_list)
-        {
-            i = GPOINTER_TO_INT(errors_list->data);
-            string_length = possible_error_lengths[i];
-
-            /* Copy the error message and put a space after it. */
-            strncpy(error_message, _(possible_errors[i]), string_length);
-            error_message += string_length;
-            *error_message = ' ';
-            error_message++;
-
-            errors_list = g_list_next(errors_list);
-        }
-        *error_message = '\0'; /* Replace the last space with the null byte. */
-        g_list_free(errors_list_begin);
-
-        *error = error_message_begin;
-        return FALSE;
-    }
-}
-
-/** Create a Transaction from a TransPropertyList.
- * @param list The list of properties
- * @param error Contains an error on failure
- * @return On success, a GncCsvTransLine; on failure, the trans pointer is NULL
- */
-static GncCsvTransLine* trans_property_list_to_trans(TransPropertyList* list, gchar** error)
-{
-    GncCsvTransLine* trans_line = g_new(GncCsvTransLine, 1);
-    GList* properties_begin = list->properties;
-    QofBook* book = gnc_account_get_book(list->account);
-    gnc_commodity* currency = xaccAccountGetCommodity(list->account);
-    gnc_numeric amount = double_to_gnc_numeric(0.0, xaccAccountGetCommoditySCU(list->account),
-                         GNC_HOW_RND_ROUND_HALF_UP);
-    gchar *num = NULL;
-
-    /* This flag is set to TRUE if we can use the "Deposit" or "Withdrawal" column. */
-    gboolean amount_set = FALSE;
-
-    /* The balance is 0 by default. */
-    trans_line->balance_set = FALSE;
-    trans_line->balance = amount;
-    trans_line->num = NULL;
-
-    /* We make the line_no -1 just to mark that it hasn't been set. We
-     * may get rid of line_no soon anyway, so it's not particularly
-     * important. */
-    trans_line->line_no = -1;
-
-    /* Make sure this is a transaction with all the columns we need. */
-    if (!trans_property_list_verify_essentials(list, error))
-    {
-        g_free(trans_line);
-        return NULL;
-    }
-
-    trans_line->trans = xaccMallocTransaction(book);
-    xaccTransBeginEdit(trans_line->trans);
-    xaccTransSetCurrency(trans_line->trans, currency);
-
-    /* Go through each of the properties and edit the transaction accordingly. */
-    list->properties = properties_begin;
-    while (list->properties != NULL)
-    {
-        TransProperty* prop = (TransProperty*)(list->properties->data);
-        switch (prop->type)
-        {
-        case GNC_CSV_DATE:
-            xaccTransSetDatePostedSecsNormalized(trans_line->trans, *((time64*)(prop->value)));
-            break;
-
-        case GNC_CSV_DESCRIPTION:
-            xaccTransSetDescription(trans_line->trans, (char*)(prop->value));
-            break;
-
-        case GNC_CSV_NOTES:
-            xaccTransSetNotes(trans_line->trans, (char*)(prop->value));
-            break;
-
-        case GNC_CSV_NUM:
-            /* the 'num' is saved and passed to 'trans_add_split' below where
-             * 'gnc_set_num_action' is used to set tran-num and/or split-action
-             * per book option */
-            num = g_strdup ((char*)(prop->value));
-            /* the 'num' is also saved and used in 'gnc_csv_parse_to_trans' when
-             * it calls 'trans_add_split' after deleting the splits added below
-             * when a balance is used by the user */
-            trans_line->num = g_strdup ((char*)(prop->value));
-            break;
-
-        case GNC_CSV_DEPOSIT: /* Add deposits to the existing amount. */
-            if (prop->value != NULL)
-            {
-                amount = gnc_numeric_add(*((gnc_numeric*)(prop->value)),
-                                         amount,
-                                         xaccAccountGetCommoditySCU(list->account),
-                                         GNC_HOW_RND_ROUND_HALF_UP);
-                amount_set = TRUE;
-                /* We will use the "Deposit" and "Withdrawal" columns in preference to "Balance". */
-                trans_line->balance_set = FALSE;
-            }
-            break;
-
-        case GNC_CSV_WITHDRAWAL: /* Withdrawals are just negative deposits. */
-            if (prop->value != NULL)
-            {
-                amount = gnc_numeric_add(gnc_numeric_neg(*((gnc_numeric*)(prop->value))),
-                                         amount,
-                                         xaccAccountGetCommoditySCU(list->account),
-                                         GNC_HOW_RND_ROUND_HALF_UP);
-                amount_set = TRUE;
-                /* We will use the "Deposit" and "Withdrawal" columns in preference to "Balance". */
-                trans_line->balance_set = FALSE;
-            }
-            break;
-
-        case GNC_CSV_BALANCE: /* The balance gets stored in a separate field in trans_line. */
-            /* We will use the "Deposit" and "Withdrawal" columns in preference to "Balance". */
-            if (!amount_set && prop->value != NULL)
-            {
-                /* This gets put into the actual transaction at the end of gnc_csv_parse_to_trans. */
-                trans_line->balance = *((gnc_numeric*)(prop->value));
-                trans_line->balance_set = TRUE;
-            }
-            break;
-        }
-        list->properties = g_list_next(list->properties);
-    }
-
-    /* Add a split with the cumulative amount value. */
-    trans_add_split(trans_line->trans, list->account, book, amount, num);
-    if (num)
-        g_free(num);
-
-    return trans_line;
-}
-
-/** Creates a list of transactions from parsed data. Transactions that
- * could be created from rows are placed in parse_data->transactions;
- * rows that fail are placed in parse_data->error_lines. (Note: there
- * is no way for this function to "fail," i.e. it only returns 0, so
- * it may be changed to a void function in the future.)
- * @param parse_data Data that is being parsed
- * @param account Account with which transactions are created
- * @param redo_errors TRUE to convert only error data, FALSE for all data
- * @return 0 on success, 1 on failure
- */
-int gnc_csv_parse_to_trans(GncCsvParseData* parse_data, Account* account,
-                           gboolean redo_errors)
-{
-    gboolean hasBalanceColumn;
-    int i, j, max_cols = 0;
-    GArray* column_types = parse_data->column_types;
-    GList *error_lines = NULL, *begin_error_lines = NULL;
-
-    /* last_transaction points to the last element in
-     * parse_data->transactions, or NULL if it's empty. */
-    GList* last_transaction = NULL;
-
-    /* Free parse_data->error_lines and parse_data->transactions if they
-     * already exist. */
-    if (redo_errors) /* If we're redoing errors, we save freeing until the end. */
-    {
-        begin_error_lines = error_lines = parse_data->error_lines;
-    }
-    else
-    {
-        if (parse_data->error_lines != NULL)
-        {
-            g_list_free(parse_data->error_lines);
-        }
-        if (parse_data->transactions != NULL)
-        {
-            g_list_free(parse_data->transactions);
-        }
-    }
-    parse_data->error_lines = NULL;
-
-    if (redo_errors) /* If we're looking only at error data ... */
-    {
-        if (parse_data->transactions == NULL)
-        {
-            last_transaction = NULL;
-        }
-        else
-        {
-            /* Move last_transaction to the end. */
-            last_transaction = parse_data->transactions;
-            while (g_list_next(last_transaction) != NULL)
-            {
-                last_transaction = g_list_next(last_transaction);
-            }
-        }
-        /* ... we use only the lines in error_lines. */
-        if (error_lines == NULL)
-            i = parse_data->orig_lines->len; /* Don't go into the for loop. */
-        else
-            i = GPOINTER_TO_INT(error_lines->data);
-    }
-    else /* Otherwise, we look at all the data. */
-    {
-        /* The following while-loop effectively behaves like the following for-loop:
-         * for(i = 0; i < parse_data->orig_lines->len; i++). */
-        i = parse_data->start_row;
-        last_transaction = NULL;
-    }
-
-    /* set parse_data->end_row to number of lines */
-    if (parse_data->end_row > parse_data->orig_lines->len)
-        parse_data->end_row = parse_data->orig_lines->len;
-
-    while (i < parse_data->end_row)
-    {
-        GPtrArray* line = parse_data->orig_lines->pdata[i];
-        /* This flag is TRUE if there are any errors in this row. */
-        gboolean errors = FALSE;
-        gchar* error_message = NULL;
-        TransPropertyList* list = trans_property_list_new(account, parse_data->date_format, parse_data->currency_format );
-        GncCsvTransLine* trans_line = NULL;
-
-        for (j = 0; j < line->len; j++)
-        {
-            /* We do nothing in "None" or "Account" columns. */
-            if ((column_types->data[j] != GNC_CSV_NONE) && (column_types->data[j] != GNC_CSV_ACCOUNT))
-            {
-                /* Affect the transaction appropriately. */
-                TransProperty* property = trans_property_new(column_types->data[j], list);
-                gboolean succeeded = trans_property_set(property, line->pdata[j]);
-
-                /* TODO Maybe move error handling to within TransPropertyList functions? */
-                if (succeeded)
-                {
-                    trans_property_list_add(property);
-                }
-                else
-                {
-                    errors = TRUE;
-                    error_message = g_strdup_printf(_("%s column could not be understood."),
-                                                    _(gnc_csv_column_type_strs[property->type]));
-                    trans_property_free(property);
-                    break;
-                }
-            }
-        }
-
-        /* If we had success, add the transaction to parse_data->transaction. */
-        if (!errors)
-        {
-            trans_line = trans_property_list_to_trans(list, &error_message);
-            errors = trans_line == NULL;
-        }
-
-        trans_property_list_free(list);
-
-        /* If there were errors, add this line to parse_data->error_lines. */
-        if (errors)
-        {
-            parse_data->error_lines = g_list_append(parse_data->error_lines,
-                                                    GINT_TO_POINTER(i));
-            /* If there's already an error message, we need to replace it. */
-            if (line->len > (int)(parse_data->orig_row_lengths->data[i]))
-            {
-                g_free(line->pdata[line->len - 1]);
-                line->pdata[line->len - 1] = error_message;
-            }
-            else
-            {
-                /* Put the error message at the end of the line. */
-                g_ptr_array_add(line, error_message);
-            }
-        }
-        else
-        {
-            /* If all went well, add this transaction to the list. */
-            trans_line->line_no = i;
-
-            /* We keep the transactions sorted by date. We start at the end
-             * of the list and go backward, simply because the file itself
-             * is probably also sorted by date (but we need to handle the
-             * exception anyway). */
-
-            /* If we can just put it at the end, do so and increment last_transaction. */
-            if (last_transaction == NULL ||
-                    xaccTransGetDate(((GncCsvTransLine*)(last_transaction->data))->trans) <= xaccTransGetDate(trans_line->trans))
-            {
-                parse_data->transactions = g_list_append(parse_data->transactions, trans_line);
-                /* If this is the first transaction, we need to get last_transaction on track. */
-                if (last_transaction == NULL)
-                    last_transaction = parse_data->transactions;
-                else /* Otherwise, we can just continue. */
-                    last_transaction = g_list_next(last_transaction);
-            }
-            /* Otherwise, search backward for the correct spot. */
-            else
-            {
-                GList* insertion_spot = last_transaction;
-                while (insertion_spot != NULL &&
-                        xaccTransGetDate(((GncCsvTransLine*)(insertion_spot->data))->trans) > xaccTransGetDate(trans_line->trans))
-                {
-                    insertion_spot = g_list_previous(insertion_spot);
-                }
-                /* Move insertion_spot one location forward since we have to
-                 * use the g_list_insert_before function. */
-                if (insertion_spot == NULL) /* We need to handle the case of inserting at the beginning of the list. */
-                    insertion_spot = parse_data->transactions;
-                else
-                    insertion_spot = g_list_next(insertion_spot);
-
-                parse_data->transactions = g_list_insert_before(parse_data->transactions, insertion_spot, trans_line);
-            }
-        }
-
-        /* Increment to the next row. */
-        if (redo_errors)
-        {
-            /* Move to the next error line in the list. */
-            error_lines = g_list_next(error_lines);
-            if (error_lines == NULL)
-                i = parse_data->orig_lines->len; /* Don't continue the for loop. */
-            else
-                i = GPOINTER_TO_INT(error_lines->data);
-        }
-        else
-        {
-            i++;
-        }
-    }
-
-    /* If we have a balance column, set the appropriate amounts on the transactions. */
-    hasBalanceColumn = FALSE;
-    for (i = 0; i < parse_data->column_types->len; i++)
-    {
-        if (parse_data->column_types->data[i] == GNC_CSV_BALANCE)
-        {
-            hasBalanceColumn = TRUE;
-            break;
-        }
-    }
-
-    if (hasBalanceColumn)
-    {
-        GList* transactions = parse_data->transactions;
-
-        /* balance_offset is how much the balance currently in the account
-         * differs from what it will be after the transactions are
-         * imported. This will be sum of all the previous transactions for
-         * any given transaction. */
-        gnc_numeric balance_offset = double_to_gnc_numeric(0.0,
-                                     xaccAccountGetCommoditySCU(account),
-                                     GNC_HOW_RND_ROUND_HALF_UP);
-        while (transactions != NULL)
-        {
-            GncCsvTransLine* trans_line = (GncCsvTransLine*)transactions->data;
-            if (trans_line->balance_set)
-            {
-                time64 date = xaccTransGetDate(trans_line->trans);
-                /* Find what the balance should be by adding the offset to the actual balance. */
-                gnc_numeric existing_balance = gnc_numeric_add(balance_offset,
-                                               xaccAccountGetBalanceAsOfDate(account, date),
-                                               xaccAccountGetCommoditySCU(account),
-                                               GNC_HOW_RND_ROUND_HALF_UP);
-
-                /* The amount of the transaction is the difference between the new and existing balance. */
-                gnc_numeric amount = gnc_numeric_sub(trans_line->balance,
-                                                     existing_balance,
-                                                     xaccAccountGetCommoditySCU(account),
-                                                     GNC_HOW_RND_ROUND_HALF_UP);
-
-                SplitList* splits = xaccTransGetSplitList(trans_line->trans);
-                while (splits)
-                {
-                    SplitList* next_splits = g_list_next(splits);
-                    xaccSplitDestroy((Split*)splits->data);
-                    splits = next_splits;
-                }
-
-                trans_add_split(trans_line->trans, account,
-                                gnc_account_get_book(account), amount, trans_line->num);
-                if (trans_line->num)
-                    g_free(trans_line->num);
-
-                /* This new transaction needs to be added to the balance offset. */
-                balance_offset = gnc_numeric_add(balance_offset,
-                                                 amount,
-                                                 xaccAccountGetCommoditySCU(account),
-                                                 GNC_HOW_RND_ROUND_HALF_UP);
-            }
-            transactions = g_list_next(transactions);
-        }
-    }
-
-    if (redo_errors) /* Now that we're at the end, we do the freeing. */
-    {
-        g_list_free(begin_error_lines);
-    }
-
-    /* We need to resize parse_data->column_types since errors may have added columns. */
-    for (i = 0; i < parse_data->orig_lines->len; i++)
-    {
-        if (max_cols < ((GPtrArray*)(parse_data->orig_lines->pdata[i]))->len)
-            max_cols = ((GPtrArray*)(parse_data->orig_lines->pdata[i]))->len;
-    }
-    i = parse_data->column_types->len;
-    parse_data->column_types = g_array_set_size(parse_data->column_types, max_cols);
-    for (; i < max_cols; i++)
-    {
-        parse_data->column_types->data[i] = GNC_CSV_NONE;
-    }
-
-    return 0;
-}

Deleted: gnucash/trunk/src/import-export/csv-import/gnc-csv-model.h
===================================================================
--- gnucash/trunk/src/import-export/csv-import/gnc-csv-model.h	2013-12-15 17:20:10 UTC (rev 23566)
+++ gnucash/trunk/src/import-export/csv-import/gnc-csv-model.h	2013-12-15 17:21:20 UTC (rev 23567)
@@ -1,136 +0,0 @@
-/********************************************************************\
- * This program is free software; you can redistribute it and/or    *
- * modify it under the terms of the GNU General Public License as   *
- * published by the Free Software Foundation; either version 2 of   *
- * the License, or (at your option) any later version.              *
- *                                                                  *
- * This program is distributed in the hope that it will be useful,  *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of   *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the    *
- * GNU General Public License for more details.                     *
- *                                                                  *
- * You should have received a copy of the GNU General Public License*
- * along with this program; if not, contact:                        *
- *                                                                  *
- * Free Software Foundation           Voice:  +1-617-542-5942       *
- * 51 Franklin Street, Fifth Floor    Fax:    +1-617-542-2652       *
- * Boston, MA  02110-1301,  USA       gnu at gnu.org                   *
-\********************************************************************/
-
-/** @file
-     @brief CSV import GUI
-     *
-     gnc-csv-model.h
-     @author Copyright (c) 2007 Benny Sperisen <lasindi at gmail.com>
- */
-
-#ifndef GNC_CSV_MODEL_H
-#define GNC_CSV_MODEL_H
-
-#include "config.h"
-
-#include "Account.h"
-#include "Transaction.h"
-
-#include "stf/stf-parse.h"
-
-/** Enumeration for column types. These are the different types of
- * columns that can exist in a CSV/Fixed-Width file. There should be
- * no two columns with the same type except for the GNC_CSV_NONE
- * type. */
-enum GncCsvColumnType {GNC_CSV_NONE,
-                       GNC_CSV_DATE,
-                       GNC_CSV_NUM,
-                       GNC_CSV_DESCRIPTION,
-                       GNC_CSV_NOTES,
-                       GNC_CSV_ACCOUNT,
-                       GNC_CSV_DEPOSIT,
-                       GNC_CSV_WITHDRAWAL,
-                       GNC_CSV_BALANCE,
-                       GNC_CSV_NUM_COL_TYPES
-                      };
-
-/** Enumeration for error types. These are the different types of
- * errors that various functions used for the CSV/Fixed-Width importer
- * can have. */
-enum GncCsvErrorType {GNC_CSV_FILE_OPEN_ERR,
-                      GNC_CSV_ENCODING_ERR
-                     };
-
-/** Struct for containing a string. This struct simply contains
- * pointers to the beginning and end of a string. We need this because
- * the STF code that gnc_csv_parse calls requires these pointers. */
-typedef struct
-{
-    char* begin;
-    char* end;
-} GncCsvStr;
-
-/* TODO We now sort transactions by date, not line number, so we
- * should probably get rid of this struct and uses of it. */
-
-/** Struct pairing a transaction with a line number. This struct is
- * used to keep the transactions in order. When rows are separated
- * into "valid" and "error" lists (in case some of the rows have cells
- * that are unparseable), we want the user to still be able to
- * "correct" the error list. If we keep the line numbers of valid
- * transactions, we can then put transactions created from the newly
- * corrected rows into the right places. */
-typedef struct
-{
-    int line_no;
-    Transaction* trans;
-    gnc_numeric balance; /**< The (supposed) balance after this transaction takes place */
-    gboolean balance_set; /**< TRUE if balance has been set from user data, FALSE otherwise */
-    gchar *num; /**< Saves the 'num'for use if balance has been set from user data */
-} GncCsvTransLine;
-
-/* A set of currency formats that the user sees. */
-extern const int num_currency_formats;
-extern const gchar* currency_format_user[];
-
-/* A set of date formats that the user sees. */
-extern const int num_date_formats;
-extern const gchar* date_format_user[];
-
-/* This array contains all of the different strings for different column types. */
-extern gchar* gnc_csv_column_type_strs[];
-
-/** Struct containing data for parsing a CSV/Fixed-Width file. */
-typedef struct
-{
-    gchar* encoding;
-    GMappedFile* raw_mapping;   /**< The mapping containing raw_str */
-    GncCsvStr raw_str;          /**< Untouched data from the file as a string */
-    GncCsvStr file_str;         /**< raw_str translated into UTF-8 */
-    GPtrArray* orig_lines;      /**< file_str parsed into a two-dimensional array of strings */
-    GArray* orig_row_lengths;   /**< The lengths of rows in orig_lines
-                                      before error messages are appended */
-    int orig_max_row;           /**< Holds the maximum value in orig_row_lengths */
-    GStringChunk* chunk;        /**< A chunk of memory in which the contents of orig_lines is stored */
-    StfParseOptions_t* options; /**< Options controlling how file_str should be parsed */
-    GArray* column_types;       /**< Array of values from the GncCsvColumnType enumeration */
-    GList* error_lines;         /**< List of row numbers in orig_lines that have errors */
-    GList* transactions;        /**< List of GncCsvTransLine*s created using orig_lines and column_types */
-    int date_format;            /**< The format of the text in the date columns from date_format_internal. */
-    int start_row;              /**< The start row to generate transactions from. */
-    int end_row;                /**< The end row to generate transactions from. */
-    int currency_format;        /**< The currency format, 0 for locale, 1 for comma dec and 2 for period */
-} GncCsvParseData;
-
-GncCsvParseData* gnc_csv_new_parse_data(void);
-
-void gnc_csv_parse_data_free(GncCsvParseData* parse_data);
-
-int gnc_csv_load_file(GncCsvParseData* parse_data, const char* filename,
-                      GError** error);
-
-int gnc_csv_convert_encoding(GncCsvParseData* parse_data, const char* encoding, GError** error);
-
-int gnc_csv_parse(GncCsvParseData* parse_data, gboolean guessColTypes, GError** error);
-
-int gnc_csv_parse_to_trans(GncCsvParseData* parse_data, Account* account, gboolean redo_errors);
-
-time64 parse_date(const char* date_str, int format);
-
-#endif

Deleted: gnucash/trunk/src/import-export/csv-import/gnc-plugin-csv-import-ui.xml
===================================================================
--- gnucash/trunk/src/import-export/csv-import/gnc-plugin-csv-import-ui.xml	2013-12-15 17:20:10 UTC (rev 23566)
+++ gnucash/trunk/src/import-export/csv-import/gnc-plugin-csv-import-ui.xml	2013-12-15 17:21:20 UTC (rev 23567)
@@ -1,12 +0,0 @@
-<ui>
-  <menubar>
-    <menu name="File" action="FileAction">
-      <menu name="FileImport" action="FileImportAction">
-      	<placeholder name="FileImportPlaceholder">
-      	   <menuitem name="FileCsvImportAccounts" action="CsvImportAccountAction"/>
-      	   <menuitem name="FileCsvImportTrans" action="CsvImportTransAction"/>
-      	</placeholder>
-      </menu>
-    </menu>
-  </menubar>
-</ui>

Deleted: gnucash/trunk/src/import-export/csv-import/gnc-plugin-csv-import.c
===================================================================
--- gnucash/trunk/src/import-export/csv-import/gnc-plugin-csv-import.c	2013-12-15 17:20:10 UTC (rev 23566)
+++ gnucash/trunk/src/import-export/csv-import/gnc-plugin-csv-import.c	2013-12-15 17:21:20 UTC (rev 23567)
@@ -1,169 +0,0 @@
-/*
- * gnc-plugin-csv-import.c -- csv import plugin
- * Copyright (C) 2011 Robert Fewell
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation; either version 2 of
- * the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, contact:
- *
- * Free Software Foundation           Voice:  +1-617-542-5942
- * 51 Franklin Street, Fifth Floor    Fax:    +1-617-542-2652
- * Boston, MA  02110-1301,  USA       gnu at gnu.org
- */
-
-#include "config.h"
-
-#include <gtk/gtk.h>
-#include <glib/gi18n.h>
-
-#include "gnc-plugin-csv-import.h"
-#include "gnc-plugin-manager.h"
-
-#include "assistant-csv-account-import.h"
-#include "assistant-csv-trans-import.h"
-
-static void gnc_plugin_csv_import_class_init (GncPluginCsvImportClass *klass);
-static void gnc_plugin_csv_import_init (GncPluginCsvImport *plugin);
-static void gnc_plugin_csv_import_finalize (GObject *object);
-
-/* Command callbacks */
-static void gnc_plugin_csv_import_tree_cmd (GtkAction *action, GncMainWindowActionData *data);
-static void gnc_plugin_csv_import_trans_cmd (GtkAction *action, GncMainWindowActionData *data);
-
-#define PLUGIN_ACTIONS_NAME "gnc-plugin-csv-import-actions"
-#define PLUGIN_UI_FILENAME  "gnc-plugin-csv-import-ui.xml"
-
-static GtkActionEntry gnc_plugin_actions [] =
-{
-    {
-        "CsvImportAccountAction", GTK_STOCK_CONVERT, N_("Import _Accounts from CSV..."), NULL,
-        N_("Import Accounts from a CSV file"),
-        G_CALLBACK (gnc_plugin_csv_import_tree_cmd)
-    },
-    {
-        "CsvImportTransAction", GTK_STOCK_CONVERT, N_("Import _Transactions from CSV..."), NULL,
-        N_("Import Transactions from a CSV file"),
-        G_CALLBACK (gnc_plugin_csv_import_trans_cmd)
-    },
-};
-static guint gnc_plugin_n_actions = G_N_ELEMENTS (gnc_plugin_actions);
-
-typedef struct GncPluginCsvImportPrivate
-{
-    gpointer dummy;
-} GncPluginCsvImportPrivate;
-
-#define GNC_PLUGIN_CSV_IMPORT_GET_PRIVATE(o)  \
-   (G_TYPE_INSTANCE_GET_PRIVATE ((o), GNC_TYPE_PLUGIN_CSV_IMPORT, GncPluginCsvImportPrivate))
-
-static GObjectClass *parent_class = NULL;
-
-GType
-gnc_plugin_csv_import_get_type (void)
-{
-    static GType gnc_plugin_csv_import_type = 0;
-
-    if (gnc_plugin_csv_import_type == 0)
-    {
-        static const GTypeInfo our_info =
-        {
-            sizeof (GncPluginCsvImportClass),
-            NULL,		/* base_init */
-            NULL,		/* base_finalize */
-            (GClassInitFunc) gnc_plugin_csv_import_class_init,
-            NULL,		/* class_finalize */
-            NULL,		/* class_data */
-            sizeof (GncPluginCsvImport),
-            0,		/* n_preallocs */
-            (GInstanceInitFunc) gnc_plugin_csv_import_init,
-        };
-
-        gnc_plugin_csv_import_type = g_type_register_static (GNC_TYPE_PLUGIN,
-                                     "GncPluginCsvImport",
-                                     &our_info, 0);
-    }
-
-    return gnc_plugin_csv_import_type;
-}
-
-GncPlugin *
-gnc_plugin_csv_import_new (void)
-{
-    return GNC_PLUGIN (g_object_new (GNC_TYPE_PLUGIN_CSV_IMPORT, NULL));
-}
-
-static void
-gnc_plugin_csv_import_class_init (GncPluginCsvImportClass *klass)
-{
-    GObjectClass *object_class = G_OBJECT_CLASS (klass);
-    GncPluginClass *plugin_class = GNC_PLUGIN_CLASS (klass);
-
-    parent_class = g_type_class_peek_parent (klass);
-
-    object_class->finalize = gnc_plugin_csv_import_finalize;
-
-    /* plugin info */
-    plugin_class->plugin_name  = GNC_PLUGIN_CSV_IMPORT_NAME;
-
-    /* widget addition/removal */
-    plugin_class->actions_name = PLUGIN_ACTIONS_NAME;
-    plugin_class->actions      = gnc_plugin_actions;
-    plugin_class->n_actions    = gnc_plugin_n_actions;
-    plugin_class->ui_filename  = PLUGIN_UI_FILENAME;
-
-    g_type_class_add_private(klass, sizeof(GncPluginCsvImportPrivate));
-}
-
-static void
-gnc_plugin_csv_import_init (GncPluginCsvImport *plugin)
-{
-}
-
-static void
-gnc_plugin_csv_import_finalize (GObject *object)
-{
-    g_return_if_fail (GNC_IS_PLUGIN_CSV_IMPORT (object));
-
-    G_OBJECT_CLASS (parent_class)->finalize (object);
-}
-
-/************************************************************
- *              Plugin Function Implementation              *
- ************************************************************/
-
-/************************************************************
- *                    Command Callbacks                     *
- ************************************************************/
-static void
-gnc_plugin_csv_import_tree_cmd (GtkAction *action,
-                                GncMainWindowActionData *data)
-{
-    gnc_file_csv_account_import ();
-}
-
-static void
-gnc_plugin_csv_import_trans_cmd (GtkAction *action,
-                                 GncMainWindowActionData *data)
-{
-    gnc_file_csv_trans_import ();
-}
-
-/************************************************************
- *                    Plugin Bootstrapping                   *
- ************************************************************/
-void
-gnc_plugin_csv_import_create_plugin (void)
-{
-    GncPlugin *plugin = gnc_plugin_csv_import_new ();
-
-    gnc_plugin_manager_add_plugin (gnc_plugin_manager_get (), plugin);
-}

Deleted: gnucash/trunk/src/import-export/csv-import/gnc-plugin-csv-import.h
===================================================================
--- gnucash/trunk/src/import-export/csv-import/gnc-plugin-csv-import.h	2013-12-15 17:20:10 UTC (rev 23566)
+++ gnucash/trunk/src/import-export/csv-import/gnc-plugin-csv-import.h	2013-12-15 17:21:20 UTC (rev 23567)
@@ -1,62 +0,0 @@
-/*
- * gnc-plugin-csv-import.h -- csv import plugin
- * Copyright (C) 2011 Robert Fewell
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation; either version 2 of
- * the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, contact:
- *
- * Free Software Foundation           Voice:  +1-617-542-5942
- * 51 Franklin Street, Fifth Floor    Fax:    +1-617-542-2652
- * Boston, MA  02110-1301,  USA       gnu at gnu.org
- */
-
-#ifndef __GNC_PLUGIN_CSV_IMPORT_H
-#define __GNC_PLUGIN_CSV_IMPORT_H
-
-#include <gtk/gtk.h>
-
-#include "gnc-plugin.h"
-
-G_BEGIN_DECLS
-
-/* type macros */
-#define GNC_TYPE_PLUGIN_CSV_IMPORT            (gnc_plugin_csv_import_get_type ())
-#define GNC_PLUGIN_CSV_IMPORT(obj)            (G_TYPE_CHECK_INSTANCE_CAST ((obj), GNC_TYPE_PLUGIN_CSV_IMPORT, GncPluginCsvImport))
-#define GNC_PLUGIN_CSV_IMPORT_CLASS(klass)    (G_TYPE_CHECK_CLASS_CAST ((klass), GNC_TYPE_PLUGIN_CSV_IMPORT, GncPluginCsvImportClass))
-#define GNC_IS_PLUGIN_CSV_IMPORT(obj)         (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GNC_TYPE_PLUGIN_CSV_IMPORT))
-#define GNC_IS_PLUGIN_CSV_IMPORT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GNC_TYPE_PLUGIN_CSV_IMPORT))
-#define GNC_PLUGIN_CSV_IMPORT_GET_CLASS(obj)  (G_TYPE_INSTANCE_GET_CLASS ((obj), GNC_TYPE_PLUGIN_CSV_IMPORT, GncPluginCsvImportClass))
-
-#define GNC_PLUGIN_CSV_IMPORT_NAME "gnc-plugin-csv-import"
-
-/* typedefs & structures */
-typedef struct
-{
-    GncPlugin gnc_plugin;
-} GncPluginCsvImport;
-
-typedef struct
-{
-    GncPluginClass gnc_plugin;
-} GncPluginCsvImportClass;
-
-/* function prototypes */
-GType      gnc_plugin_csv_import_get_type (void);
-
-GncPlugin *gnc_plugin_csv_import_new      (void);
-
-void       gnc_plugin_csv_import_create_plugin (void);
-
-G_END_DECLS
-
-#endif /* __GNC_PLUGIN_CSV_IMPORT_H */

Deleted: gnucash/trunk/src/import-export/csv-import/gncmod-csv-import.c
===================================================================
--- gnucash/trunk/src/import-export/csv-import/gncmod-csv-import.c	2013-12-15 17:20:10 UTC (rev 23566)
+++ gnucash/trunk/src/import-export/csv-import/gncmod-csv-import.c	2013-12-15 17:21:20 UTC (rev 23567)
@@ -1,90 +0,0 @@
-/********************************************************************\
- * This program is free software; you can redistribute it and/or    *
- * modify it under the terms of the GNU General Public License as   *
- * published by the Free Software Foundation; either version 2 of   *
- * the License, or (at your option) any later version.              *
- *                                                                  *
- * This program is distributed in the hope that it will be useful,  *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of   *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the    *
- * GNU General Public License for more details.                     *
- *                                                                  *
- * You should have received a copy of the GNU General Public License*
- * along with this program; if not, contact:                        *
- *                                                                  *
- * Free Software Foundation           Voice:  +1-617-542-5942       *
- * 51 Franklin Street, Fifth Floor    Fax:    +1-617-542-2652       *
- * Boston, MA  02110-1301,  USA       gnu at gnu.org                   *
-\********************************************************************/
-/** @addtogroup Import_Export
-    @{ */
-/**@internal
- at file gncmod-csv-import.c
- at brief module definition/initialization for the csv importer
- at author Copyright (c) 2012 Robert Fewell
-*/
-#include "config.h"
-
-#include <gmodule.h>
-
-#include "gnc-module.h"
-#include "gnc-module-api.h"
-#include "gnc-plugin-csv-import.h"
-
-GNC_MODULE_API_DECL(libgncmod_csv_import)
-
-/* version of the gnc module system interface we require */
-int libgncmod_csv_import_gnc_module_system_interface = 0;
-
-/* module versioning uses libtool semantics. */
-int libgncmod_csv_import_gnc_module_current  = 0;
-int libgncmod_csv_import_gnc_module_revision = 0;
-int libgncmod_csv_import_gnc_module_age      = 0;
-
-//static GNCModule bus_core;
-//static GNCModule file;
-
-char *
-libgncmod_csv_import_gnc_module_path(void)
-{
-    return g_strdup("gnucash/import-export/csv-import");
-}
-
-char *
-libgncmod_csv_import_gnc_module_description(void)
-{
-    return g_strdup("Gnome GUI and C code for CSV importer.");
-}
-
-int
-libgncmod_csv_import_gnc_module_init(int refcount)
-{
-    if (!gnc_module_load("gnucash/engine", 0))
-    {
-        return FALSE;
-    }
-    if (!gnc_module_load("gnucash/app-utils", 0))
-    {
-        return FALSE;
-    }
-    if (!gnc_module_load("gnucash/gnome-utils", 0))
-    {
-        return FALSE;
-    }
-    if (!gnc_module_load("gnucash/import-export", 0))
-    {
-        return FALSE;
-    }
-
-    /* Add menu items with C callbacks */
-    gnc_plugin_csv_import_create_plugin();
-
-    return TRUE;
-}
-
-int
-libgncmod_csv_import_gnc_module_end(int refcount)
-{
-    return TRUE;
-}
-/** @}*/

Deleted: gnucash/trunk/src/import-export/csv-import/gschemas/Makefile.am
===================================================================
--- gnucash/trunk/src/import-export/csv-import/gschemas/Makefile.am	2013-12-15 17:20:10 UTC (rev 23566)
+++ gnucash/trunk/src/import-export/csv-import/gschemas/Makefile.am	2013-12-15 17:21:20 UTC (rev 23567)
@@ -1,10 +0,0 @@
- at INTLTOOL_XML_NOMERGE_RULE@
-
-gschema_in_files = \
-  org.gnucash.dialogs.import.csv.gschema.xml.in
-
-gsettings_SCHEMAS = $(gschema_in_files:.gschema.xml.in=.gschema.xml)
-
- at GSETTINGS_RULES@
-
-CLEANFILES = $(gsettings_SCHEMAS)

Deleted: gnucash/trunk/src/import-export/csv-import/gschemas/org.gnucash.dialogs.import.csv.gschema.xml.in.in
===================================================================
--- gnucash/trunk/src/import-export/csv-import/gschemas/org.gnucash.dialogs.import.csv.gschema.xml.in.in	2013-12-15 17:20:10 UTC (rev 23566)
+++ gnucash/trunk/src/import-export/csv-import/gschemas/org.gnucash.dialogs.import.csv.gschema.xml.in.in	2013-12-15 17:21:20 UTC (rev 23567)
@@ -1,16 +0,0 @@
-<schemalist gettext-domain="@GETTEXT_PACKAGE@">
-  <schema id="org.gnucash.dialogs.import.csv" path="/org/gnucash/dialogs/import/csv/">
-    <key name="last-geometry" type="(iiii)">
-      <default>(-1,-1,-1,-1)</default>
-      <summary>Last window position and size</summary>
-      <description>This setting describes the size and position of the window when it was last closed.
-        The numbers are the X and Y coordinates of the top left corner of the window
-        followed by the width and height of the window.</description>
-    </key>
-    <key name="last-path" type="s">
-      <default>''</default>
-      <summary>Last pathname used</summary>
-      <description>This field contains the last pathname used by this window. It will be used as the initial filename/pathname the next time this window is opened.</description>
-    </key>
-  </schema>
-</schemalist>

Copied: gnucash/trunk/src/import-export/qif-imp/Makefile.am (from rev 23566, gnucash/trunk/src/import-export/qif-import/Makefile.am)
===================================================================
--- gnucash/trunk/src/import-export/qif-imp/Makefile.am	                        (rev 0)
+++ gnucash/trunk/src/import-export/qif-imp/Makefile.am	2013-12-15 17:21:20 UTC (rev 23567)
@@ -0,0 +1,108 @@
+SUBDIRS = . test gschemas
+
+pkglib_LTLIBRARIES=libgncmod-qif-import.la
+
+libgncmod_qif_import_la_SOURCES = \
+  dialog-account-picker.c \
+  assistant-qif-import.c \
+  gnc-plugin-qif-import.c \
+  gncmod-qif-import.c
+
+noinst_HEADERS = \
+  dialog-account-picker.h \
+  assistant-qif-import.h \
+  gnc-plugin-qif-import.h
+
+libgncmod_qif_import_la_LDFLAGS = -avoid-version
+
+libgncmod_qif_import_la_LIBADD = \
+  ${top_builddir}/src/import-export/libgncmod-generic-import.la \
+  ${top_builddir}/src/gnome/libgnc-gnome.la \
+  ${top_builddir}/src/gnome-utils/libgncmod-gnome-utils.la \
+  ${top_builddir}/src/app-utils/libgncmod-app-utils.la \
+  ${top_builddir}/src/core-utils/libgnc-core-utils.la \
+  ${top_builddir}/src/engine/libgncmod-engine.la \
+  ${top_builddir}/src/gnc-module/libgnc-module.la \
+  ${top_builddir}/src/libqof/qof/libgnc-qof.la \
+  ${GUILE_LIBS} \
+  ${GLIB_LIBS}
+
+
+gncscmmoddir = ${GNC_SHAREDIR}/guile-modules/gnucash/import-export
+gncscmmod_DATA = qif-import.scm 
+
+gncscmdir = ${GNC_SCM_INSTALL_DIR}/qif-import
+
+gncscm_DATA = \
+  qif-dialog-utils.scm \
+  qif-file.scm \
+  qif-guess-map.scm \
+  qif-import.scm \
+  qif-merge-groups.scm \
+  qif-objects.scm \
+  qif-parse.scm \
+  qif-to-gnc.scm \
+  qif-utils.scm
+
+gtkbuilderdir = ${GNC_GTKBUILDER_DIR}
+gtkbuilder_DATA = \
+   dialog-account-picker.glade \
+   assistant-qif-import.glade
+
+AM_CPPFLAGS = \
+  -I${top_srcdir}/src \
+  -I${top_builddir}/src \
+  -I${top_srcdir}/src/core-utils \
+  -I${top_srcdir}/src/engine \
+  -I${top_srcdir}/src/gnc-module \
+  -I${top_srcdir}/src/app-utils \
+  -I${top_srcdir}/src/gnome \
+  -I${top_srcdir}/src/gnome-utils \
+  -I${top_srcdir}/src/import-export \
+  -I${top_srcdir}/src/libqof/qof \
+  ${GUILE_CFLAGS} \
+  ${GLIB_CFLAGS} \
+  ${GTK_CFLAGS}
+
+uidir = $(GNC_UI_DIR)
+ui_DATA = \
+	gnc-plugin-qif-import-ui.xml
+
+EXTRA_DIST = \
+  ${gncscm_DATA} \
+  ${gtkbuilder_DATA} \
+  file-format.txt \
+  $(ui_DATA)
+
+CLEANFILES =
+
+if GNUCASH_SEPARATE_BUILDDIR
+SCM_FILE_LINKS = \
+  ${gncscm_DATA}
+endif
+
+noinst_DATA = .scm-links
+
+.scm-links: 
+	$(RM) -rf gnucash
+	mkdir -p  gnucash qif-import
+	mkdir -p  gnucash/import-export
+if GNUCASH_SEPARATE_BUILDDIR
+	for X in ${SCM_FILE_LINKS} ; do \
+	  $(LN_S) -f ${srcdir}/$$X . ; \
+	done
+endif
+	( cd gnucash/import-export; for A in $(gncscmmod_DATA) ; do $(LN_S) -f ../../$$A . ; done )
+	( cd qif-import; for A in $(gncscm_DATA) ; do $(LN_S) -f ../$$A . ; done )
+if ! OS_WIN32
+# Windows knows no "ln -s" but uses "cp": must copy every time (see bug #566567).
+	touch .scm-links
+endif
+
+clean-local:
+	$(RM) -rf gnucash qif-import
+
+CLEANFILES += .scm-links
+DISTCLEANFILES = ${SCM_FILE_LINKS}
+
+AM_CPPFLAGS += -DG_LOG_DOMAIN=\"gnc.import.qif.import\"

Copied: gnucash/trunk/src/import-export/qif-imp/assistant-qif-import.c (from rev 23566, gnucash/trunk/src/import-export/qif-import/assistant-qif-import.c)
===================================================================
--- gnucash/trunk/src/import-export/qif-imp/assistant-qif-import.c	                        (rev 0)
+++ gnucash/trunk/src/import-export/qif-imp/assistant-qif-import.c	2013-12-15 17:21:20 UTC (rev 23567)
@@ -0,0 +1,3644 @@
+/********************************************************************\
+ * assistant-qif-import.c -- window for importing QIF files         *
+ *                        (GnuCash)                                 *
+ * Copyright (C) 2000 Bill Gribble <grib at billgribble.com>           *
+ * Copyright (c) 2006 David Hampton <hampton at employees.org>         *
+ * Copyright (c) 2011 Robert Fewell                                 *
+ *                                                                  *
+ * This program is free software; you can redistribute it and/or    *
+ * modify it under the terms of the GNU General Public License as   *
+ * published by the Free Software Foundation; either version 2 of   *
+ * the License, or (at your option) any later version.              *
+ *                                                                  *
+ * This program is distributed in the hope that it will be useful,  *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of   *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the    *
+ * GNU General Public License for more details.                     *
+ *                                                                  *
+ * You should have received a copy of the GNU General Public License*
+ * along with this program; if not, contact:                        *
+ *                                                                  *
+ * Free Software Foundation           Voice:  +1-617-542-5942       *
+ * 51 Franklin Street, Fifth Floor    Fax:    +1-617-542-2652       *
+ * Boston, MA  02110-1301,  USA       gnu at gnu.org                   *
+\********************************************************************/
+
+#include "config.h"
+
+#include <gtk/gtk.h>
+#include <glib/gi18n.h>
+#include <glib/gstdio.h>
+#include <libguile.h>
+#include <sys/time.h>
+#include <unistd.h>
+
+#include "Account.h"
+#include "Transaction.h"
+#include "dialog-account-picker.h"
+#include "dialog-commodity.h"
+#include "dialog-progress.h"
+#include "dialog-utils.h"
+#include "dialog-file-access.h"
+#include "assistant-qif-import.h"
+#include "assistant-utils.h"
+#include "gnc-component-manager.h"
+#include "qof.h"
+#include "gnc-file.h"
+#include "gnc-gui-query.h"
+#include "gnc-guile-utils.h"
+#include "gnc-currency-edit.h"
+#include "gnc-ui-util.h"
+#include "gnc-gtk-utils.h"
+#include "gnc-main-window.h"
+#include "gnc-plugin-page-account-tree.h"
+#include "gnc-prefs.h"
+#include "gnc-ui.h"
+#include "guile-mappings.h"
+
+#include "swig-runtime.h"
+
+#define ASSISTANT_QIF_IMPORT_CM_CLASS "assistant-qif-import"
+#define GNC_PREFS_GROUP   "dialogs.import.qif"
+#define GNC_PREF_SHOW_DOC "show-doc"
+#define GNC_PREF_DEFAULT_TRANS_STATUS_CLEARED "default-status-cleared"
+#define GNC_PREF_DEFAULT_TRANS_STATUS_NOTCLEARED "default-status-notcleared"
+#define GNC_PREF_DEFAULT_TRANS_STATUS_RECONCILED "default-status-reconciled"
+
+#define PREV_ROW "prev_row"
+
+static QofLogModule log_module = GNC_MOD_ASSISTANT;
+
+enum filename_cols
+{
+    FILENAME_COL_INDEX = 0,
+    FILENAME_COL_NAME,
+    NUM_FILENAME_COLS
+};
+
+enum account_cols
+{
+    ACCOUNT_COL_INDEX = 0,
+    ACCOUNT_COL_QIF_NAME,
+    ACCOUNT_COL_GNC_NAME,
+    ACCOUNT_COL_NEW,
+    ACCOUNT_COL_ELLIPSIZE,
+    NUM_ACCOUNT_COLS
+};
+
+enum qif_trans_cols
+{
+    QIF_TRANS_COL_INDEX = 0,
+    QIF_TRANS_COL_DATE,
+    QIF_TRANS_COL_DESCRIPTION,
+    QIF_TRANS_COL_AMOUNT,
+    QIF_TRANS_COL_CHECKED,
+    NUM_QIF_TRANS_COLS
+};
+
+struct _qifimportwindow
+{
+    GtkWidget * window;
+    GtkWidget * assistant;
+
+    /* Widgets on the file selection page. */
+    GtkWidget * filename_entry;
+
+    /* File loading progress page. */
+    GtkWidget * load_pause;
+    GtkWidget * load_start;
+    GtkWidget * load_log;
+    GNCProgressDialog *load_progress;
+
+    /* Widgets on the default account page. */
+    GtkWidget * acct_entry;
+
+    /* Widgets on the date format page. */
+    GtkWidget * date_format_combo;
+
+    /* Widgets on the files loaded page. */
+    GtkWidget * selected_file_view;
+    GtkWidget * unload_file_btn;
+
+    /* Widgets on the account matching page. */
+    GtkWidget * acct_view;
+    GtkWidget * acct_view_count;
+    GtkWidget * acct_view_btn;
+
+    /* Widgets on the category matching page. */
+    GtkWidget * cat_view;
+    GtkWidget * cat_view_count;
+    GtkWidget * cat_view_btn;
+
+    /* Widgets on the memo matching page. */
+    GtkWidget * memo_view;
+    GtkWidget * memo_view_count;
+    GtkWidget * memo_view_btn;
+
+    /* Widgets on the currency & book options page. */
+    GtkWidget * currency_picker;
+    GtkWidget * book_option_label;
+    GtkWidget * book_option_message;
+
+    /* Widgets on the commodity page. */
+    gint        num_new_pages;
+
+    /* Conversion progress page. */
+    GtkWidget * convert_pause;
+    GtkWidget * convert_start;
+    GtkWidget * convert_log;
+    GNCProgressDialog *convert_progress;
+
+    /* Widgets on the duplicates page. */
+    GtkWidget * new_transaction_view;
+    GtkWidget * old_transaction_view;
+
+    /* Widgets on the summary page. */
+    GtkWidget * summary_text;
+
+    GList     * commodity_pages;
+
+    gboolean  show_doc_pages;
+    gboolean  ask_date_format;
+    gboolean  busy;
+    gboolean  load_stop;
+    gboolean  acct_tree_found;
+    gboolean  new_book;
+
+    SCM       imported_files;
+    SCM       selected_file;
+
+    SCM       acct_map_info;
+    SCM       acct_display_info;
+
+    SCM       cat_map_info;
+    SCM       cat_display_info;
+
+    SCM       memo_map_info;
+    SCM       memo_display_info;
+
+    SCM       gnc_acct_info;
+    SCM       security_hash;
+    SCM       security_prefs;
+    SCM       new_securities;
+    GList   * new_namespaces;
+    SCM       ticker_map;
+
+    SCM       imported_account_tree;
+    SCM       match_transactions;
+    SCM       transaction_status;
+    int       selected_transaction;
+};
+
+struct _qifassistantpage
+{
+    GtkWidget     *page;
+    GtkWidget     *namespace_combo;
+    GtkWidget     *name_entry;
+    GtkWidget     *mnemonic_entry;
+    gnc_commodity *commodity;
+    SCM            hash_key;
+};
+
+typedef struct _qifassistantpage QIFAssistantPage;
+
+static void gnc_ui_qif_import_assistant_destroy (GtkObject *object, gpointer user_data);
+static void gnc_ui_qif_import_assistant_close_handler (gpointer user_data );
+
+void gnc_ui_qif_import_cancel_cb (GtkAssistant *gtkassistant, gpointer user_data);
+void gnc_ui_qif_import_prepare_cb (GtkAssistant *assistant, GtkWidget *page, gpointer user_data);
+void gnc_ui_qif_import_finish_cb (GtkAssistant *gtkassistant, gpointer user_data);
+void gnc_ui_qif_import_close_cb (GtkAssistant *gtkassistant, gpointer user_data);
+
+void gnc_ui_qif_import_intro_prepare (GtkAssistant  *assistant, gpointer user_data);
+
+void gnc_ui_qif_import_load_file_prepare (GtkAssistant *assistant, gpointer user_data);
+void gnc_ui_qif_import_select_file_cb (GtkButton *button, gpointer user_data);
+
+void gnc_ui_qif_import_load_progress_prepare (GtkAssistant *assistant, gpointer user_data);
+void gnc_ui_qif_import_load_progress_pause_cb (GtkButton *button, gpointer user_data);
+void gnc_ui_qif_import_load_progress_start_cb (GtkButton * button, gpointer user_data);
+
+void gnc_ui_qif_import_date_format_prepare (GtkAssistant *assistant, gpointer user_data);
+void gnc_ui_qif_import_date_valid_cb (GtkWidget *widget, gpointer user_data);
+
+void gnc_ui_qif_import_account_prepare (GtkAssistant *assistant, gpointer user_data);
+void gnc_ui_qif_import_acct_valid_cb (GtkWidget *widget, gpointer user_data);
+
+void gnc_ui_qif_import_loaded_files_prepare (GtkAssistant *assistant, gpointer user_data);
+void gnc_ui_qif_import_load_another_cb (GtkButton *button, gpointer user_data);
+void gnc_ui_qif_import_unload_file_cb (GtkButton *button, gpointer user_data);
+
+static void update_file_page (QIFImportWindow * wind);
+
+void gnc_ui_qif_import_account_match_prepare (GtkAssistant *assistant, gpointer user_data);
+void gnc_ui_qif_import_account_doc_prepare (GtkAssistant *assistant, gpointer user_data);
+void gnc_ui_qif_import_account_rematch_cb (GtkButton *button, gpointer user_data);
+
+void gnc_ui_qif_import_catagory_match_prepare (GtkAssistant *assistant, gpointer user_data);
+void gnc_ui_qif_import_catagory_doc_prepare (GtkAssistant *assistant, gpointer user_data);
+void gnc_ui_qif_import_category_rematch_cb (GtkButton *button, gpointer user_data);
+
+void gnc_ui_qif_import_memo_match_prepare (GtkAssistant *assistant, gpointer user_data);
+void gnc_ui_qif_import_memo_doc_prepare (GtkAssistant *assistant, gpointer user_data);
+void gnc_ui_qif_import_memo_rematch_cb (GtkButton *button, gpointer user_data);
+
+void gnc_ui_qif_import_currency_prepare (GtkAssistant *assistant, gpointer user_data);
+
+void gnc_ui_qif_import_commodity_new_prepare (GtkAssistant *assistant, gpointer user_data);
+void gnc_ui_qif_import_commodity_doc_prepare (GtkAssistant *assistant, gpointer user_data);
+void gnc_ui_qif_import_comm_changed_cb (GtkWidget *widget, gpointer user_data);
+
+void gnc_ui_qif_import_convert_progress_prepare (GtkAssistant *assistant, gpointer user_data);
+void gnc_ui_qif_import_convert_progress_pause_cb (GtkButton * button, gpointer user_data);
+void gnc_ui_qif_import_convert_progress_start_cb(GtkButton * button, gpointer user_data);
+
+void gnc_ui_qif_import_duplicates_match_prepare (GtkAssistant *assistant, gpointer user_data);
+void gnc_ui_qif_import_duplicates_doc_prepare (GtkAssistant *assistant, gpointer user_data);
+
+void gnc_ui_qif_import_end_page_prepare (GtkAssistant *assistant, gpointer user_data);
+
+void gnc_ui_qif_import_summary_page_prepare (GtkAssistant *assistant, gpointer user_data);
+
+
+/****************************************************************
+ * update_account_picker_page
+ *
+ * Generic function to update an account_picker page.  This
+ * generalizes the code shared whenever any QIF -> GNC mapper is
+ * updating it's LIST STORE.  It asks the Scheme side to guess some account
+ * translations and then shows the account name and suggested
+ * translation in the Accounts page view (acount picker list).
+ ****************************************************************/
+static void
+update_account_picker_page(QIFImportWindow * wind, SCM make_display,
+                           GtkWidget *view, SCM map_info, SCM * display_info)
+{
+
+    SCM  get_qif_name = scm_c_eval_string("qif-map-entry:qif-name");
+    SCM  get_gnc_name = scm_c_eval_string("qif-map-entry:gnc-name");
+    SCM  get_new      = scm_c_eval_string("qif-map-entry:new-acct?");
+    SCM  accts_left;
+    gchar *qif_name = NULL;
+    gchar *gnc_name = NULL;
+    gboolean checked;
+    gint row = 0;
+    gint prev_row;
+    GtkListStore *store;
+    GtkTreeIter iter;
+    GtkTreePath *path;
+    GtkTreeSelection *selection;
+
+    store = GTK_LIST_STORE(gtk_tree_view_get_model(GTK_TREE_VIEW(view)));
+
+    /* now get the list of strings to display in the gtk_list_store widget */
+    accts_left = scm_call_3(make_display,
+                            wind->imported_files,
+                            map_info,
+                            wind->gnc_acct_info);
+
+    scm_gc_unprotect_object(*display_info);
+    *display_info = accts_left;
+    scm_gc_protect_object(*display_info);
+
+    /* clear the list */
+    gtk_list_store_clear(store);
+
+    while (!scm_is_null(accts_left))
+    {
+        qif_name = gnc_scm_call_1_to_string(get_qif_name, SCM_CAR(accts_left));
+        gnc_name = gnc_scm_call_1_to_string(get_gnc_name, SCM_CAR(accts_left));
+        checked  = (scm_call_1(get_new, SCM_CAR(accts_left)) == SCM_BOOL_T);
+
+        gtk_list_store_append(store, &iter);
+        gtk_list_store_set(store, &iter,
+                           ACCOUNT_COL_INDEX,     row++,
+                           ACCOUNT_COL_QIF_NAME,  qif_name,
+                           ACCOUNT_COL_GNC_NAME,  gnc_name,
+                           ACCOUNT_COL_NEW,       checked,
+                           ACCOUNT_COL_ELLIPSIZE, PANGO_ELLIPSIZE_START,
+                           -1);
+        accts_left = SCM_CDR(accts_left);
+        g_free (qif_name);
+        g_free (gnc_name);
+    }
+
+    /* move to the old selected row */
+    prev_row = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(store), PREV_ROW));
+    if (prev_row != -1)
+    {
+        selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(view));
+        path = gtk_tree_path_new_from_indices(prev_row, -1);
+        gtk_tree_selection_select_path(selection, path);
+        gtk_tree_path_free(path);
+    }
+    else
+    {
+        selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(view));
+        path = gtk_tree_path_new_from_indices( 0, -1);
+        gtk_tree_selection_select_path(selection, path);
+        gtk_tree_path_free(path);
+    }
+}
+
+
+/****************************************************************
+ * update_account_page
+ *
+ * update the QIF account -> GNC Account picker
+ ****************************************************************/
+static void
+update_account_page(QIFImportWindow * wind)
+{
+
+    SCM  make_account_display = scm_c_eval_string("qif-dialog:make-account-display");
+
+    update_account_picker_page(wind, make_account_display, wind->acct_view,
+                               wind->acct_map_info, &(wind->acct_display_info));
+}
+
+
+/****************************************************************
+ * update_category_page
+ *
+ * update the QIF category -> GNC Account picker
+ ****************************************************************/
+static void
+update_category_page(QIFImportWindow * wind)
+{
+    SCM  make_category_display = scm_c_eval_string("qif-dialog:make-category-display");
+
+    update_account_picker_page(wind, make_category_display, wind->cat_view,
+                               wind->cat_map_info, &(wind->cat_display_info));
+}
+
+
+/****************************************************************
+ * update_memo_page
+ *
+ * update the QIF memo -> GNC Account picker
+ ****************************************************************/
+static void
+update_memo_page(QIFImportWindow * wind)
+{
+    SCM  make_memo_display = scm_c_eval_string("qif-dialog:make-memo-display");
+
+    update_account_picker_page(wind, make_memo_display, wind->memo_view,
+                               wind->memo_map_info, &(wind->memo_display_info));
+}
+
+
+/****************************************************************
+ * gnc_ui_qif_import_commodity_destroy
+ *
+ * This function destroys any commodity pages.
+ ****************************************************************/
+static void
+gnc_ui_qif_import_commodity_destroy(QIFImportWindow * wind)
+{
+    GList              *pageptr;
+    GtkWidget          *gtkpage;
+    QIFAssistantPage   *page;
+
+    for (pageptr = wind->commodity_pages; pageptr; pageptr = pageptr->next)
+    {
+        gtkpage   = pageptr->data;
+        page      = g_object_get_data(G_OBJECT(gtkpage), "page_struct");
+
+        /* Unprotect the Scheme hash key. */
+        scm_gc_unprotect_object(page->hash_key);
+
+        /* Free the memory allocated for the page's struct. */
+        g_free(page);
+    }
+
+    /* Free the list of pages. */
+    g_list_free(wind->commodity_pages);
+    wind->commodity_pages = NULL;
+}
+
+
+/**********************************************
+ * gnc_ui_qif_import_assistant_destroy
+ * close the QIF Import assistant window
+ **********************************************/
+static void
+gnc_ui_qif_import_assistant_destroy(GtkObject *object, gpointer user_data)
+{
+    QIFImportWindow * wind = user_data;
+
+    /* Destroy the progress dialog helpers. */
+    gnc_progress_dialog_destroy(wind->load_progress);
+
+    /* Destroy any commodity pages. */
+    gnc_ui_qif_import_commodity_destroy(wind);
+
+    gnc_unregister_gui_component_by_data(ASSISTANT_QIF_IMPORT_CM_CLASS, wind);
+
+    gtk_widget_destroy(wind->window);
+
+    scm_gc_unprotect_object(wind->imported_files);
+    scm_gc_unprotect_object(wind->selected_file);
+    scm_gc_unprotect_object(wind->gnc_acct_info);
+    scm_gc_unprotect_object(wind->cat_display_info);
+    scm_gc_unprotect_object(wind->cat_map_info);
+    scm_gc_unprotect_object(wind->memo_display_info);
+    scm_gc_unprotect_object(wind->memo_map_info);
+    scm_gc_unprotect_object(wind->acct_display_info);
+    scm_gc_unprotect_object(wind->acct_map_info);
+    scm_gc_unprotect_object(wind->security_hash);
+    scm_gc_unprotect_object(wind->security_prefs);
+    scm_gc_unprotect_object(wind->new_securities);
+    scm_gc_unprotect_object(wind->ticker_map);
+    scm_gc_unprotect_object(wind->imported_account_tree);
+    scm_gc_unprotect_object(wind->match_transactions);
+
+    g_free(wind);
+}
+
+
+/****************************************************************
+ * gnc_ui_qif_import_select_loaded_file_cb
+ * callback when a file is clicked in the "loaded files" page
+ ****************************************************************/
+static void
+gnc_ui_qif_import_select_loaded_file_cb(GtkTreeSelection *selection,
+                                        gpointer          user_data)
+{
+    QIFImportWindow * wind = user_data;
+    GtkTreeModel *model;
+    GtkTreeIter iter;
+    gint row;
+    GtkWidget *button;
+
+    button = (wind->unload_file_btn);
+    if (gtk_tree_selection_get_selected(selection, &model, &iter))
+    {
+        gtk_tree_model_get(model, &iter, FILENAME_COL_INDEX, &row, -1);
+        if (scm_is_list(wind->imported_files) &&
+                (scm_ilength(wind->imported_files) > row))
+        {
+            scm_gc_unprotect_object(wind->selected_file);
+            wind->selected_file = scm_list_ref(wind->imported_files,
+                                               scm_from_int (row));
+            scm_gc_protect_object(wind->selected_file);
+            g_object_set(button, "sensitive", TRUE, (gchar*)NULL);
+        }
+    }
+    else
+    {
+        scm_gc_unprotect_object(wind->selected_file);
+        wind->selected_file = SCM_BOOL_F;
+        scm_gc_protect_object(wind->selected_file);
+        g_object_set(button, "sensitive", FALSE, (gchar*)NULL);
+    }
+}
+
+
+/****************************************************
+ * create_account_picker_view
+ ****************************************************/
+static void
+create_account_picker_view(GtkWidget *widget,
+                           const gchar *col_name,
+                           GCallback activate_cb,
+                           GCallback select_cb,
+                           gpointer user_data)
+{
+    GtkTreeView *view = GTK_TREE_VIEW(widget);
+    GtkTreeSelection *selection = gtk_tree_view_get_selection(view);
+    GtkListStore *store;
+    GtkCellRenderer *renderer;
+    GtkTreeViewColumn *column;
+
+    store = gtk_list_store_new(NUM_ACCOUNT_COLS, G_TYPE_INT, G_TYPE_STRING,
+                               G_TYPE_STRING, G_TYPE_BOOLEAN,
+                               PANGO_TYPE_ELLIPSIZE_MODE);
+    gtk_tree_view_set_model(view, GTK_TREE_MODEL(store));
+    g_object_unref(store);
+
+    renderer = gtk_cell_renderer_text_new();
+    column = gtk_tree_view_column_new_with_attributes(col_name,
+             renderer,
+             "text",
+             ACCOUNT_COL_QIF_NAME,
+             "ellipsize",
+             ACCOUNT_COL_ELLIPSIZE,
+             NULL);
+    g_object_set(column, "expand", TRUE, NULL);
+    gtk_tree_view_column_set_resizable(column, TRUE);
+    gtk_tree_view_append_column(view, column);
+
+    renderer = gtk_cell_renderer_text_new();
+    column = gtk_tree_view_column_new_with_attributes(_("GnuCash account name"),
+             renderer,
+             "text",
+             ACCOUNT_COL_GNC_NAME,
+             "ellipsize",
+             ACCOUNT_COL_ELLIPSIZE,
+             NULL);
+
+    g_object_set(column, "expand", TRUE, NULL);
+    gtk_tree_view_column_set_resizable(column, TRUE);
+    gtk_tree_view_append_column(view, column);
+
+    renderer = gtk_cell_renderer_toggle_new();
+    g_object_set(renderer, "activatable", FALSE, NULL);
+    column = gtk_tree_view_column_new_with_attributes(_("New?"),
+             renderer,
+             "active",
+             ACCOUNT_COL_NEW,
+             NULL);
+    gtk_tree_view_append_column(view, column);
+
+    g_object_set_data(G_OBJECT(store), PREV_ROW, GINT_TO_POINTER(-1));
+
+    /* Connect the signal handlers. */
+    g_signal_connect(view, "row-activated", G_CALLBACK(activate_cb), user_data);
+    g_signal_connect(selection, "changed", G_CALLBACK(select_cb), user_data);
+
+    /* Allow multiple rows to be selected. */
+    gtk_tree_selection_set_mode(selection, GTK_SELECTION_MULTIPLE);
+}
+
+
+/********************************************************************
+ * rematch_line
+ *
+ * This is a helper function for tree controls used by some assistant
+ * pages for mapping QIF values to GnuCash accounts. It processes
+ * the selected rows when a user tries to edit the account mappings.
+ * The account picker is displayed, and the chosen GnuCash account
+ * becomes the new mapping for each row.  Finally, the update_page
+ * function is called.
+ ********************************************************************/
+static void
+rematch_line(QIFImportWindow *wind, GtkTreeSelection *selection,
+             SCM display_info, SCM map_info,
+             void (*update_page)(QIFImportWindow *))
+{
+    SCM           get_qif_name = scm_c_eval_string("qif-map-entry:qif-name");
+    SCM           get_gnc_name = scm_c_eval_string("qif-map-entry:gnc-name");
+    SCM           set_gnc_name = scm_c_eval_string("qif-map-entry:set-gnc-name!");
+    SCM           map_entry;
+    SCM           gnc_name;
+    GList        *pathlist;
+    GList        *current;
+    GtkTreeModel *model;
+    GtkTreeIter   iter;
+    gint          row;
+
+    /* Get a list of selected rows. */
+    pathlist = gtk_tree_selection_get_selected_rows(selection, &model);
+    if (!pathlist)
+        return;
+
+    /*
+     * Update the first selected row.
+     */
+
+    /* Get the row number of the first selected row. */
+    if (!gtk_tree_model_get_iter(model, &iter, (GtkTreePath *) pathlist->data))
+        return;
+    gtk_tree_model_get(model, &iter, ACCOUNT_COL_INDEX, &row, -1);
+
+    /* Save the row number. */
+    g_object_set_data(G_OBJECT(model), PREV_ROW, GINT_TO_POINTER(row));
+    if (row == -1)
+        return;
+
+    /* Find the <qif-map-entry> corresponding to the selected row. */
+    map_entry = scm_list_ref(display_info, scm_from_int (row));
+
+    /* Call the account picker to update it. */
+    if (!qif_account_picker_dialog(wind, map_entry))
+        return;
+    gnc_name = scm_call_1(get_gnc_name, map_entry);
+
+    /* Update the mapping hash table. */
+    scm_hash_set_x(map_info, scm_call_1(get_qif_name, map_entry), map_entry);
+
+    /*
+     * Map all other selected rows to the same GnuCash account.
+     */
+    for (current = pathlist->next; current; current = current->next)
+    {
+        /* Get the row number. */
+        gtk_tree_model_get_iter(model, &iter, (GtkTreePath *) current->data);
+        gtk_tree_model_get(model, &iter, ACCOUNT_COL_INDEX, &row, -1);
+
+        /* Update the <qif-map-entry> for the selected row. */
+        map_entry = scm_list_ref(display_info, scm_from_int (row));
+        scm_call_2(set_gnc_name, map_entry, gnc_name);
+
+        /* Update the mapping hash table. */
+        scm_hash_set_x(map_info, scm_call_1(get_qif_name, map_entry), map_entry);
+    }
+
+    /* Free the path list. */
+    g_list_foreach(pathlist, (GFunc) gtk_tree_path_free, NULL);
+    g_list_free(pathlist);
+
+    /* Update the display. */
+    update_page(wind);
+}
+
+
+/********************************************************************
+ * gnc_ui_qif_import_account_activate_cb
+ *
+ * This handler is invoked when a row is double-clicked in the "Match
+ * QIF accounts to GnuCash accounts" page.
+ ********************************************************************/
+static void
+gnc_ui_qif_import_account_activate_cb(GtkTreeView *view, GtkTreePath *path,
+                                      GtkTreeViewColumn *column,
+                                      gpointer user_data)
+{
+    QIFImportWindow  *wind = user_data;
+
+    g_return_if_fail(wind);
+
+    rematch_line(wind, gtk_tree_view_get_selection(view),
+                 wind->acct_display_info, wind->acct_map_info,
+                 update_account_page);
+}
+
+
+/********************************************************************
+ * gnc_ui_qif_import_account_select_cb
+ *
+ * This handler is invoked when the selection of account matchings
+ * has changed.  It updates the selection count and enables/disables
+ * the "Change" button.
+ ********************************************************************/
+static void
+gnc_ui_qif_import_account_select_cb(GtkTreeSelection *selection,
+                                    gpointer user_data)
+{
+    QIFImportWindow  *wind = user_data;
+    gint              count = gtk_tree_selection_count_selected_rows(selection);
+    gchar            *count_str;
+
+    g_return_if_fail(wind);
+
+    /* Update the "items selected" count. */
+    if (wind->acct_view_count)
+    {
+        count_str = g_strdup_printf("%d", count);
+        gtk_label_set_text(GTK_LABEL(wind->acct_view_count), count_str);
+        g_free(count_str);
+    }
+
+    /* Enable/disable the Change button. */
+    if (wind->acct_view_btn)
+    {
+        if (count)
+            gtk_widget_set_sensitive(wind->acct_view_btn, TRUE);
+        else
+            gtk_widget_set_sensitive(wind->acct_view_btn, FALSE);
+    }
+}
+
+
+/********************************************************************
+ * gnc_ui_qif_import_category_activate_cb
+ *
+ * This handler is invoked when a row is double-clicked in the "Match
+ * QIF categories to GnuCash accounts" page.
+ ********************************************************************/
+static void
+gnc_ui_qif_import_category_activate_cb(GtkTreeView *view, GtkTreePath *path,
+                                       GtkTreeViewColumn *column,
+                                       gpointer user_data)
+{
+    QIFImportWindow *wind = user_data;
+    GtkTreeSelection *selection;
+
+    g_return_if_fail(view && wind);
+    selection = gtk_tree_view_get_selection(view);
+
+    rematch_line(wind, selection, wind->cat_display_info, wind->cat_map_info,
+                 update_category_page);
+}
+
+
+/********************************************************************
+ * gnc_ui_qif_import_category_select_cb
+ *
+ * This handler is invoked when the selection of category matchings
+ * has changed.  It updates the selection count and enables/disables
+ * the "Change" button.
+ ********************************************************************/
+static void
+gnc_ui_qif_import_category_select_cb(GtkTreeSelection *selection,
+                                     gpointer user_data)
+{
+    QIFImportWindow  *wind = user_data;
+    gint              count = gtk_tree_selection_count_selected_rows(selection);
+    gchar            *count_str;
+
+    g_return_if_fail(wind);
+
+    /* Update the "items selected" count. */
+    if (wind->cat_view_count)
+    {
+        count_str = g_strdup_printf("%d", count);
+        gtk_label_set_text(GTK_LABEL(wind->cat_view_count), count_str);
+        g_free(count_str);
+    }
+
+    /* Enable/disable the Change button. */
+    if (wind->cat_view_btn)
+    {
+        if (count)
+            gtk_widget_set_sensitive(wind->cat_view_btn, TRUE);
+        else
+            gtk_widget_set_sensitive(wind->cat_view_btn, FALSE);
+    }
+}
+
+
+/********************************************************************
+ *  gnc_ui_qif_import_memo_activate_cb
+ *
+ * This handler is invoked when a row is double-clicked in the "Match
+ * QIF payee/memo to GnuCash accounts" page.
+ ********************************************************************/
+static void
+gnc_ui_qif_import_memo_activate_cb(GtkTreeView *view, GtkTreePath *path,
+                                   GtkTreeViewColumn *column,
+                                   gpointer user_data)
+{
+    QIFImportWindow *wind = user_data;
+    GtkTreeSelection *selection;
+
+    g_return_if_fail(view && wind);
+    selection = gtk_tree_view_get_selection(view);
+
+    rematch_line(wind, selection, wind->memo_display_info, wind->memo_map_info,
+                 update_memo_page);
+}
+
+
+/********************************************************************
+ * gnc_ui_qif_import_memo_select_cb
+ *
+ * This handler is invoked when the selection of memo matchings
+ * has changed.  It updates the selection count and enables/disables
+ * the "Change" button.
+ ********************************************************************/
+static void
+gnc_ui_qif_import_memo_select_cb(GtkTreeSelection *selection,
+                                 gpointer user_data)
+{
+    QIFImportWindow  *wind = user_data;
+    gint              count = gtk_tree_selection_count_selected_rows(selection);
+    gchar            *count_str;
+
+    g_return_if_fail(wind);
+
+    /* Update the "items selected" count. */
+    if (wind->memo_view_count)
+    {
+        count_str = g_strdup_printf("%d", count);
+        gtk_label_set_text(GTK_LABEL(wind->memo_view_count), count_str);
+        g_free(count_str);
+    }
+
+    /* Enable/disable the Change button. */
+    if (wind->memo_view_btn)
+    {
+        if (count)
+            gtk_widget_set_sensitive(wind->memo_view_btn, TRUE);
+        else
+            gtk_widget_set_sensitive(wind->memo_view_btn, FALSE);
+    }
+}
+
+
+/*********************************************
+ * new_security_page
+ *********************************************/
+static QIFAssistantPage *
+new_security_page(SCM security_hash_key, gnc_commodity *comm, QIFImportWindow *wind )
+{
+
+    QIFAssistantPage *retval = g_new0(QIFAssistantPage, 1);
+    GtkListStore *store;
+    GtkWidget    *table;
+    GtkWidget    *label;
+    gchar        *title = NULL;
+    const char   *str;
+    GtkWidget    *page;
+    char         *name_tooltip =
+        _("Enter a name or short description, such as \"Red Hat Stock\".");
+    char         *mnemonic_tooltip =
+        _("Enter the ticker symbol or other well known abbreviation, such as"
+          " \"RHT\". If there isn't one, or you don't know it, create your own.");
+    char         *namespace_tooltip =
+        _("Select the exchange on which the symbol is traded, or select the"
+          " type of investment (such as FUND for mutual funds.) If you don't"
+          " see your exchange or an appropriate investment type, you can"
+          " enter a new one.");
+
+    /* Make the page widget. */
+    page = gtk_vbox_new( FALSE, 0 );
+    retval->page = page;
+    g_object_set_data(G_OBJECT(retval->page), "page_struct", retval);
+    page = retval->page;
+
+    /* Insert the new page */
+    gtk_assistant_insert_page (GTK_ASSISTANT(wind->window), page, 14);
+    gtk_assistant_set_page_type(GTK_ASSISTANT(wind->window), page, GTK_ASSISTANT_PAGE_PROGRESS );
+    gtk_assistant_set_page_complete (GTK_ASSISTANT (wind->window), page, TRUE);
+    gtk_assistant_update_buttons_state (GTK_ASSISTANT (wind->window));
+
+    /* Save the commodity and the hash table key. */
+    retval->commodity = comm;
+    retval->hash_key = security_hash_key;
+    scm_gc_protect_object(retval->hash_key);
+
+    /* Set the page title. */
+    str = gnc_commodity_get_mnemonic(comm);
+    str = str ? str : "";
+    title = _("Enter information about");
+    title =  g_strdup_printf("%s \"%s\"", title, str);
+    gtk_assistant_set_page_title(GTK_ASSISTANT(wind->window), page, title);
+    g_free(title);
+
+    /*
+     * Add all the widgets to the page.
+     */
+    table = gtk_table_new(3, 2, FALSE);
+    gtk_table_set_row_spacings(GTK_TABLE(table), 6);
+    gtk_table_set_col_spacings(GTK_TABLE(table), 12);
+
+    /* Name entry */
+    retval->name_entry = gtk_entry_new();
+    gtk_entry_set_text(GTK_ENTRY(retval->name_entry),
+                       gnc_commodity_get_fullname(comm));
+    label = gtk_label_new_with_mnemonic(_("_Name or description:"));
+    gtk_label_set_mnemonic_widget(GTK_LABEL(label), retval->name_entry);
+    gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5);
+
+    gtk_widget_set_tooltip_text(label, name_tooltip);
+    gtk_widget_set_tooltip_text(retval->name_entry, name_tooltip);
+
+    gtk_table_attach(GTK_TABLE(table), label, 0, 1, 0, 1,
+                     GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0);
+    gtk_table_attach_defaults(GTK_TABLE(table), retval->name_entry,
+                              1, 2, 0, 1);
+
+    g_signal_connect (retval->name_entry, "changed",
+                      G_CALLBACK (gnc_ui_qif_import_comm_changed_cb), wind);
+
+    /* Mnemonic entry */
+    retval->mnemonic_entry = gtk_entry_new();
+    gtk_entry_set_text(GTK_ENTRY(retval->mnemonic_entry),
+                       gnc_commodity_get_mnemonic(comm));
+    label = gtk_label_new_with_mnemonic(
+                _("_Ticker symbol or other abbreviation:"));
+    gtk_label_set_mnemonic_widget(GTK_LABEL(label), retval->mnemonic_entry);
+    gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5);
+
+    gtk_widget_set_tooltip_text(label, mnemonic_tooltip);
+    gtk_widget_set_tooltip_text(retval->mnemonic_entry, mnemonic_tooltip);
+
+    gtk_table_attach(GTK_TABLE(table), label, 0, 1, 1, 2,
+                     GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0);
+    gtk_table_attach_defaults(GTK_TABLE(table), retval->mnemonic_entry,
+                              1, 2, 1, 2);
+
+    g_signal_connect (retval->mnemonic_entry, "changed",
+                      G_CALLBACK (gnc_ui_qif_import_comm_changed_cb), wind);
+
+    /* Namespace entry */
+    store = gtk_list_store_new (1, G_TYPE_STRING);
+    retval->namespace_combo = gtk_combo_box_new_with_model_and_entry(GTK_TREE_MODEL(store));
+    g_object_unref(store);
+
+    /* Set the column for the text */
+    gtk_combo_box_set_entry_text_column (GTK_COMBO_BOX(retval->namespace_combo), 0);
+
+    gnc_cbwe_add_completion(GTK_COMBO_BOX(retval->namespace_combo));
+    label = gtk_label_new_with_mnemonic(
+                _("_Exchange or abbreviation type:"));
+    gtk_label_set_mnemonic_widget(GTK_LABEL(label), retval->namespace_combo);
+    gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5);
+
+    gtk_widget_set_tooltip_text(label, namespace_tooltip);
+    gtk_widget_set_tooltip_text(retval->namespace_combo, namespace_tooltip);
+
+    gtk_table_attach(GTK_TABLE(table), label, 0, 1, 2, 3,
+                     GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0);
+    gtk_table_attach_defaults(GTK_TABLE(table), retval->namespace_combo,
+                              1, 2, 2, 3);
+
+    gtk_container_set_border_width(GTK_CONTAINER(page), 12);
+
+    gtk_box_pack_start(GTK_BOX(page), table, FALSE, FALSE, 12);
+
+    return retval;
+}
+
+
+/********************************************************************
+ * prepare_security_pages
+ *
+ * Prepare the assistant page for each security.
+ ********************************************************************/
+static void
+prepare_security_pages(QIFImportWindow * wind)
+{
+    SCM   hash_ref  = scm_c_eval_string("hash-ref");
+    SCM   securities;
+    SCM   comm_ptr_token;
+
+    GList          * current;
+    gnc_commodity  * commodity;
+    QIFAssistantPage   * new_page;
+
+    /*
+     * Make assistant pages for each new QIF security.
+     */
+    gnc_set_busy_cursor(NULL, TRUE);
+    securities = wind->new_securities;
+    current = wind->commodity_pages;
+    while (!scm_is_null(securities) && (securities != SCM_BOOL_F))
+    {
+        if (current)
+        {
+            /* The page has already been made. */
+            current = current->next;
+        }
+        else
+        {
+            /* Get the GnuCash commodity corresponding to the new QIF security. */
+            comm_ptr_token = scm_call_2(hash_ref,
+                                        wind->security_hash,
+                                        SCM_CAR(securities));
+#define FUNC_NAME "new_security_page"
+            commodity = SWIG_MustGetPtr(comm_ptr_token,
+                                        SWIG_TypeQuery("_p_gnc_commodity"), 1, 0);
+#undef FUNC_NAME
+
+            /* Build a new security page. */
+            new_page = new_security_page(SCM_CAR(securities), commodity, wind);
+
+            /* Add it to the list of security pages. */
+            wind->commodity_pages = g_list_append(wind->commodity_pages,
+                                                  new_page->page);
+
+            gtk_widget_show_all(new_page->page);
+        }
+        wind->num_new_pages = wind->num_new_pages + 1;
+        securities = SCM_CDR(securities);
+    }
+    gnc_unset_busy_cursor(NULL);
+    PINFO("Number of New Security pages is %d", wind->num_new_pages);
+}
+
+
+/****************************************************************
+ * gnc_ui_qif_import_commodity_update
+ *
+ * This function updates the commodities based on the values for
+ * mnemonic, namespace, and name approved by the user.
+ ****************************************************************/
+static void
+gnc_ui_qif_import_commodity_update(QIFImportWindow * wind)
+{
+    GList              *pageptr;
+    GtkWidget          *gtkpage;
+    QIFAssistantPage   *page;
+    const gchar        *mnemonic = NULL;
+    gchar              *namespace = NULL;
+    const gchar        *fullname = NULL;
+    gnc_commodity      *tab_commodity;
+
+    for (pageptr = wind->commodity_pages; pageptr; pageptr = pageptr->next)
+    {
+        gtkpage   = pageptr->data;
+        page      = g_object_get_data(G_OBJECT(gtkpage), "page_struct");
+
+        /* Get any changes from the commodity page. */
+        mnemonic  = gtk_entry_get_text(GTK_ENTRY(page->mnemonic_entry));
+        namespace = gnc_ui_namespace_picker_ns(page->namespace_combo);
+        fullname  = gtk_entry_get_text(GTK_ENTRY(page->name_entry));
+
+        /* Update the commodity with the new values. */
+        gnc_commodity_set_namespace(page->commodity, namespace);
+        gnc_commodity_set_fullname(page->commodity, fullname);
+        gnc_commodity_set_mnemonic(page->commodity, mnemonic);
+
+        /* Add the commodity to the commodity table (if it isn't a duplicate). */
+        tab_commodity = gnc_commodity_table_lookup(gnc_get_current_commodities(),
+                        namespace, mnemonic);
+        if (!tab_commodity || tab_commodity == page->commodity)
+            tab_commodity = gnc_commodity_table_insert(gnc_get_current_commodities(),
+                            page->commodity);
+
+        /* Update the security hash table. */
+        scm_hash_set_x(wind->security_hash,
+                       page->hash_key,
+                       SWIG_NewPointerObj(tab_commodity,
+                                          SWIG_TypeQuery("_p_gnc_commodity"), 0));
+
+        g_free(namespace);
+    }
+}
+
+
+/****************************************************************
+ * gnc_ui_qif_import_convert_undo
+ *
+ * This function launches the Scheme procedure that un-imports
+ * any imported accounts and transactions.
+ ****************************************************************/
+static void
+gnc_ui_qif_import_convert_undo(QIFImportWindow * wind)
+{
+    SCM undo = scm_c_eval_string("qif-import:qif-to-gnc-undo");
+
+    gnc_set_busy_cursor(NULL, TRUE);
+
+    /* Undo the conversion. */
+    scm_call_1(undo, wind->imported_account_tree);
+
+    /* There's no imported account tree any more. */
+    scm_gc_unprotect_object(wind->imported_account_tree);
+    wind->imported_account_tree = SCM_BOOL_F;
+    scm_gc_protect_object(wind->imported_account_tree);
+
+    /* Get rid of the list of matched transactions. */
+    scm_gc_unprotect_object(wind->match_transactions);
+    wind->match_transactions = SCM_BOOL_F;
+    scm_gc_protect_object(wind->match_transactions);
+
+    gnc_unset_busy_cursor(NULL);
+}
+
+
+/****************************************************************
+ * refresh_old_transactions
+ *
+ * This function launches the Scheme procedure that refreshes
+ * the old transactions.
+ ****************************************************************/
+static void
+refresh_old_transactions(QIFImportWindow * wind, int selection)
+{
+    SCM          possible_matches;
+    SCM          current_xtn;
+    SCM          selected;
+    Transaction  * gnc_xtn;
+    Split        * gnc_split;
+    const gchar  * amount_str;
+    int          rownum = 0;
+    GtkTreeView *view;
+    GtkListStore *store;
+    GtkTreeIter iter;
+
+    view = GTK_TREE_VIEW(wind->old_transaction_view);
+    store = GTK_LIST_STORE(gtk_tree_view_get_model(view));
+    gtk_list_store_clear(store);
+
+    if (wind->match_transactions != SCM_BOOL_F)
+    {
+        possible_matches = SCM_CDR(scm_list_ref(wind->match_transactions,
+                                                scm_from_int (wind->selected_transaction)));
+        scm_call_2(scm_c_eval_string("qif-import:refresh-match-selection"),
+                   possible_matches, scm_from_int (selection));
+
+        while (!scm_is_null(possible_matches))
+        {
+            current_xtn = SCM_CAR(possible_matches);
+#define FUNC_NAME "xaccTransCountSplits"
+            gnc_xtn     = SWIG_MustGetPtr(SCM_CAR(current_xtn),
+                                          SWIG_TypeQuery("_p_Transaction"), 1, 0);
+#undef FUNC_NAME
+            selected    = SCM_CDR(current_xtn);
+
+            if (xaccTransCountSplits(gnc_xtn) > 2)
+            {
+                amount_str = _("(split)");
+            }
+            else
+            {
+                gnc_split = xaccTransGetSplit(gnc_xtn, 0);
+                amount_str =
+                    xaccPrintAmount(gnc_numeric_abs(xaccSplitGetValue(gnc_split)),
+                                    gnc_account_print_info
+                                    (xaccSplitGetAccount(gnc_split), TRUE));
+            }
+
+            gtk_list_store_append(store, &iter);
+            gtk_list_store_set
+            (store, &iter,
+             QIF_TRANS_COL_INDEX, rownum++,
+             QIF_TRANS_COL_DATE, gnc_print_date(xaccTransRetDatePostedTS(gnc_xtn)),
+             QIF_TRANS_COL_DESCRIPTION, xaccTransGetDescription(gnc_xtn),
+             QIF_TRANS_COL_AMOUNT, amount_str,
+             QIF_TRANS_COL_CHECKED, selected != SCM_BOOL_F,
+             -1);
+
+            possible_matches = SCM_CDR(possible_matches);
+        }
+    }
+}
+
+
+/****************************************************************
+ * gnc_ui_qif_import_duplicate_new_select_cb
+ *
+ * This function is the call back for duplicate transactions.
+ ****************************************************************/
+static void
+gnc_ui_qif_import_duplicate_new_select_cb(GtkTreeSelection *selection,
+        QIFImportWindow  *wind)
+{
+    GtkTreeModel *model;
+    GtkTreeIter iter;
+
+    if (gtk_tree_selection_get_selected(selection, &model, &iter))
+        gtk_tree_model_get(model, &iter,
+                           QIF_TRANS_COL_INDEX, &wind->selected_transaction,
+                           -1);
+    refresh_old_transactions(wind, -1);
+}
+
+
+/****************************************************************
+ * reset_ignore_old_select
+ ****************************************************************/
+static gboolean
+reset_ignore_old_select(gboolean *ignore)
+{
+    *ignore = FALSE;
+    return FALSE;
+}
+
+
+/****************************************************************
+ * gnc_ui_qif_import_duplicate_old_select_cb
+ *
+ * This function is the call back for duplicate transactions.
+ ****************************************************************/
+static void
+gnc_ui_qif_import_duplicate_old_select_cb(GtkTreeSelection *selection,
+        QIFImportWindow  *wind)
+{
+    GtkTreeModel *model;
+    GtkTreeIter iter;
+    gint row;
+    static gboolean ignore_old_select = FALSE;
+
+    /* Get the current selection then clear it.  We're about to clear
+     * the entire list store and rebuild it so this prevents errors. */
+    if (!gtk_tree_selection_get_selected(selection, &model, &iter))
+        return;
+    gtk_tree_selection_unselect_all(selection);
+
+    /* Getting a weird double call the first time a line is clicked.
+     * Once via gtk_tree_view_button_press and then again via
+     * gtk_tree_view_grab_focus. */
+    if (ignore_old_select)
+        return;
+    ignore_old_select = TRUE;
+    g_idle_add((GSourceFunc)reset_ignore_old_select, &ignore_old_select);
+
+    /* Get the row the user clicked on and update the scheme
+     * code/rebuild the list store.  */
+    gtk_tree_model_get(model, &iter,
+                       QIF_TRANS_COL_INDEX, &row,
+                       -1);
+    refresh_old_transactions(wind, row);
+}
+
+
+/********************************************************************
+ * gnc_ui_qif_import_check_acct_tree
+ *
+ * Designed for use with gnc_main_window_foreach_page(), this
+ * function determines whether an account tab is open in the main
+ * window. The parameter user_data must point to a gboolean.
+ ********************************************************************/
+static void
+gnc_ui_qif_import_check_acct_tree(GncPluginPage *page, gpointer user_data)
+{
+    gboolean *found = user_data;
+
+    if (GNC_IS_PLUGIN_PAGE_ACCOUNT_TREE(page) && found)
+        *found = TRUE;
+}
+
+
+/****************************************************************
+ * do_cancel
+ *
+ * Clears out any imported data and shuts down the importer.
+ ****************************************************************/
+static void
+do_cancel(QIFImportWindow * wind)
+{
+    GList                *pageptr;
+    GtkWidget            *gtkpage;
+    QIFAssistantPage     *page;
+    gnc_commodity_table  *table;
+
+    gnc_set_busy_cursor(NULL, TRUE);
+
+    /* Remove any converted data. */
+    gnc_ui_qif_import_convert_undo(wind);
+
+    /* Remove any commodities created for assistant pages. */
+    for (pageptr = wind->commodity_pages; pageptr; pageptr = pageptr->next)
+    {
+        gtkpage   = pageptr->data;
+        page      = g_object_get_data(G_OBJECT(gtkpage), "page_struct");
+        gnc_commodity_destroy(page->commodity);
+    }
+
+    /* Remove any namespaces created by the user. */
+    table = gnc_get_current_commodities();
+    while (wind->new_namespaces)
+    {
+        gnc_commodity_table_delete_namespace(table, (gchar *) wind->new_namespaces->data);
+
+        /* Free the data and the list element. */
+        g_free(wind->new_namespaces->data);
+        wind->new_namespaces = g_list_delete_link(wind->new_namespaces,
+                               wind->new_namespaces);
+    }
+    gnc_unset_busy_cursor(NULL);
+
+    /* Destroy the assistant. */
+    gnc_close_gui_component_by_data(ASSISTANT_QIF_IMPORT_CM_CLASS, wind);
+}
+
+
+/****************************************************************
+ * cancel_timeout_cb
+ *
+ * This timer callback function waits until the busy flag
+ * has been cleared before acting to cancel the import.
+ ****************************************************************/
+static gboolean
+cancel_timeout_cb(gpointer data)
+{
+    QIFImportWindow *wind = data;
+
+    if (wind->busy)
+        /* Wait for timer to go off again. */
+        return TRUE;
+
+    /* The busy flag was lowered. Perform the cancel. */
+    do_cancel(wind);
+
+    /* Cancel the timer. */
+    return FALSE;
+}
+
+
+/****************************************************************
+ * gnc_ui_qif_import_cancel_cb
+ *
+ * Invoked when the "Cancel" button is clicked.
+ ****************************************************************/
+void
+gnc_ui_qif_import_cancel_cb(GtkAssistant *gtkassistant, gpointer user_data)
+{
+    QIFImportWindow  *wind = user_data;
+
+    if (wind->busy)
+    {
+        /* Cancel any long-running Scheme operation. */
+        scm_c_eval_string("(qif-import:cancel)");
+
+        /* Wait for the busy flag to be lowered. */
+        g_timeout_add(200, cancel_timeout_cb, user_data);
+    }
+    else
+        do_cancel(wind);
+}
+
+
+/****************************************************************
+ * gnc_ui_qif_import_close_cb
+ *
+ * Invoked when the "Close" button is clicked.
+ ****************************************************************/
+void
+gnc_ui_qif_import_close_cb(GtkAssistant *gtkassistant, gpointer user_data)
+{
+    QIFImportWindow  *wind = user_data;
+
+    /* If We did not have an account tree, lets save it */
+    if (!wind->acct_tree_found)
+    {
+        qof_book_mark_session_dirty(gnc_get_current_book());
+        gnc_ui_file_access_for_save_as();
+    }
+
+    gnc_close_gui_component_by_data( ASSISTANT_QIF_IMPORT_CM_CLASS, wind );
+}
+
+
+/****************************************************************
+ * gnc_ui_qif_import_assistant_get_mappings
+ *
+ * SCM get mappings.
+ ****************************************************************/
+SCM
+gnc_ui_qif_import_assistant_get_mappings(QIFImportWindow * w)
+{
+    return SCM_LIST3(w->acct_map_info,
+                     w->cat_map_info,
+                     w->memo_map_info);
+}
+
+
+/* ================================================================== */
+/*                                                                    */
+/*                         IMPORTER CREATION                          */
+/*                                                                    */
+/* ================================================================== */
+
+/********************************************************************
+ * get_preferences
+ *
+ * Get all user preferences related to QIF import.
+ ********************************************************************/
+static void
+get_preferences(QIFImportWindow *wind)
+{
+    gchar tmp_transaction_status = 'n';
+
+    g_return_if_fail(wind);
+
+    /* Get the user's preference for showing documentation pages. */
+    wind->show_doc_pages =
+        gnc_prefs_get_bool (GNC_PREFS_GROUP, GNC_PREF_SHOW_DOC);
+
+    /* Clear / Reconcile transaction if not specified in QIF file. */
+    if (gnc_prefs_get_bool (GNC_PREFS_GROUP, GNC_PREF_DEFAULT_TRANS_STATUS_CLEARED))
+        tmp_transaction_status = 'c';
+    else if (gnc_prefs_get_bool (GNC_PREFS_GROUP, GNC_PREF_DEFAULT_TRANS_STATUS_RECONCILED))
+        tmp_transaction_status = 'y';
+
+    wind->transaction_status = SCM_MAKE_CHAR(tmp_transaction_status);
+}
+
+
+/********************************************************************
+ * initialize_scheme
+ *
+ * Initialize all Scheme-controlled objects.
+ ********************************************************************/
+static void
+initialize_scheme(QIFImportWindow *wind)
+{
+    SCM  load_map_prefs;
+    SCM  mapping_info;
+    SCM  create_ticker_map;
+
+    g_return_if_fail(wind);
+
+    /* Initialize Scheme variables. */
+    wind->imported_files        = SCM_EOL;
+    wind->selected_file         = SCM_BOOL_F;
+    wind->gnc_acct_info         = SCM_BOOL_F;
+    wind->cat_display_info      = SCM_BOOL_F;
+    wind->cat_map_info          = SCM_BOOL_F;
+    wind->acct_display_info     = SCM_BOOL_F;
+    wind->acct_map_info         = SCM_BOOL_F;
+    wind->memo_display_info     = SCM_BOOL_F;
+    wind->memo_map_info         = SCM_BOOL_F;
+    wind->security_hash         = SCM_BOOL_F;
+    wind->security_prefs        = SCM_BOOL_F;
+    wind->new_securities        = SCM_BOOL_F;
+    wind->ticker_map            = SCM_BOOL_F;
+    wind->imported_account_tree = SCM_BOOL_F;
+    wind->match_transactions    = SCM_BOOL_F;
+
+    /* Get the saved state of mappings from Quicken accounts and
+     * categories to GnuCash accounts. */
+    load_map_prefs = scm_c_eval_string("qif-import:load-map-prefs");
+    mapping_info = scm_call_0(load_map_prefs); /* <- gets/creates session/book */
+    wind->gnc_acct_info         = scm_list_ref(mapping_info, scm_from_int (0));
+    wind->acct_map_info         = scm_list_ref(mapping_info, scm_from_int (1));
+    wind->cat_map_info          = scm_list_ref(mapping_info, scm_from_int (2));
+    wind->memo_map_info         = scm_list_ref(mapping_info, scm_from_int (3));
+    wind->security_hash         = scm_list_ref(mapping_info, scm_from_int (4));
+    wind->security_prefs        = scm_list_ref(mapping_info, scm_from_int (5));
+
+    /* Get the initial ticker map. */
+    create_ticker_map = scm_c_eval_string("make-ticker-map");
+    wind->ticker_map            = scm_call_0(create_ticker_map);
+
+    /* Protect our data from garbage collection. */
+    scm_gc_protect_object(wind->imported_files);
+    scm_gc_protect_object(wind->selected_file);
+    scm_gc_protect_object(wind->gnc_acct_info);
+    scm_gc_protect_object(wind->cat_display_info);
+    scm_gc_protect_object(wind->cat_map_info);
+    scm_gc_protect_object(wind->memo_display_info);
+    scm_gc_protect_object(wind->memo_map_info);
+    scm_gc_protect_object(wind->acct_display_info);
+    scm_gc_protect_object(wind->acct_map_info);
+    scm_gc_protect_object(wind->security_hash);
+    scm_gc_protect_object(wind->security_prefs);
+    scm_gc_protect_object(wind->new_securities);
+    scm_gc_protect_object(wind->ticker_map);
+    scm_gc_protect_object(wind->imported_account_tree);
+    scm_gc_protect_object(wind->match_transactions);
+}
+
+
+/*****************************************
+ * Page 0 - Intro Page Page
+ ****************************************/
+
+/********************************************************************
+ * gnc_ui_qif_import_intro_prepare
+ *
+ * Prepare the intro page for display.
+ ********************************************************************/
+void
+gnc_ui_qif_import_intro_prepare (GtkAssistant  *assistant, gpointer user_data)
+{
+    QIFImportWindow   *wind = user_data;
+    SCM unload = scm_c_eval_string("qif-dialog:unload-qif-file");
+    SCM files_list;
+
+    /* Set load stop to FALSE */
+    wind->load_stop = FALSE;
+
+    files_list = scm_call_2(unload, wind->selected_file, wind->imported_files);
+
+    scm_gc_unprotect_object(wind->imported_files);
+    wind->imported_files = files_list;
+    scm_gc_protect_object(wind->imported_files);
+
+    scm_gc_unprotect_object(wind->selected_file);
+    wind->selected_file = SCM_BOOL_F;
+    scm_gc_protect_object(wind->selected_file);
+}
+
+
+/*****************************************
+ * Page 1 - Load File Page Procedures
+ ****************************************/
+
+/********************************************************************
+ * gnc_ui_qif_import_load_file_complete
+ *
+ * Do we have a file to load.
+ ********************************************************************/
+static gboolean
+gnc_ui_qif_import_load_file_complete (GtkAssistant  *assistant,
+                                      gpointer user_data)
+{
+    QIFImportWindow * wind = user_data;
+    const gchar * path_to_load;
+
+    /* Get the file name. */
+    path_to_load = gtk_entry_get_text(GTK_ENTRY(wind->filename_entry));
+
+    /* Validate the chosen filename. */
+    if (strlen(path_to_load) == 0)
+        gnc_error_dialog(wind->window, "%s", _("Please select a file to load."));
+    else if (g_access(path_to_load, R_OK) < 0)
+        gnc_error_dialog(wind->window, "%s",
+                         _("File not found or read permission denied. "
+                           "Please select another file."));
+    else
+    {
+        SCM qif_file_loaded = scm_c_eval_string("qif-dialog:qif-file-loaded?");
+
+        /* See if the file is already loaded. */
+        if (scm_call_2(qif_file_loaded,
+                       scm_from_locale_string(path_to_load ? path_to_load : ""),
+                       wind->imported_files) == SCM_BOOL_T)
+            gnc_error_dialog(wind->window, "%s",
+                             _("That QIF file is already loaded. "
+                               "Please select another file."));
+        else
+        {
+            /* Passed all checks; proceed to the next page. */
+            return TRUE;
+        }
+    }
+
+    /* Stay on this page. */
+    return FALSE;
+}
+
+
+/********************************************************************
+ * gnc_ui_qif_import_load_file_prepare
+ *
+ * Prepare the load file page for display.
+ ********************************************************************/
+void
+gnc_ui_qif_import_load_file_prepare (GtkAssistant  *assistant, gpointer user_data)
+{
+
+    gint num = gtk_assistant_get_current_page (assistant);
+    GtkWidget *page = gtk_assistant_get_nth_page (assistant, num);
+
+    /* Disable the Assistant Forward Button */
+    gtk_assistant_set_page_complete (assistant, page, FALSE);
+}
+
+
+/********************************************************************
+ * gnc_ui_qif_import_select_file_cb
+ *
+ * invoked when the "select file" button is clicked
+ * this is just to pick a file name and reset-to-defaults all the
+ * fields describing how to parse the file.
+ ********************************************************************/
+void
+gnc_ui_qif_import_select_file_cb(GtkButton * button,
+                                 gpointer user_data)
+{
+    QIFImportWindow * wind = user_data;
+
+    GtkAssistant *assistant = GTK_ASSISTANT(wind->window);
+    gint num = gtk_assistant_get_current_page (assistant);
+    GtkWidget *page = gtk_assistant_get_nth_page (assistant, num);
+
+    GtkFileFilter *filter;
+    char * new_file_name;
+    char *file_name, *default_dir;
+
+    /* Default to whatever's already present */
+    default_dir = gnc_get_default_directory(GNC_PREFS_GROUP);
+
+    filter = gtk_file_filter_new();
+    gtk_file_filter_set_name(filter, "*.qif");
+    gtk_file_filter_add_pattern(filter, "*.[Qq][Ii][Ff]");
+    new_file_name = gnc_file_dialog(_("Select QIF File"),
+                                    g_list_prepend (NULL, filter),
+                                    default_dir,
+                                    GNC_FILE_DIALOG_IMPORT);
+
+    /* Insure valid data, and something that can be freed. */
+    if (new_file_name == NULL)
+    {
+        file_name = g_strdup(default_dir);
+    }
+    else if (!g_path_is_absolute(new_file_name))
+    {
+        file_name = g_build_filename(default_dir, new_file_name, NULL);
+        g_free(new_file_name);
+    }
+    else
+    {
+        file_name = new_file_name;
+        /* Update the working directory */
+        g_free(default_dir);
+        default_dir = g_path_get_dirname(file_name);
+        gnc_set_default_directory(GNC_PREFS_GROUP, default_dir);
+    }
+    g_free(default_dir);
+
+    /* set the filename entry for what was selected */
+    gtk_entry_set_text(GTK_ENTRY(wind->filename_entry), file_name);
+    g_free(file_name);
+
+    gtk_assistant_set_page_complete (assistant, page,
+                                     gnc_ui_qif_import_load_file_complete (assistant, user_data));
+}
+
+
+/*****************************************
+ * Page 2 - Load Progress Page Procedures
+ ****************************************/
+
+/********************************************************************
+ * gnc_ui_qif_import_load_progress_pause_cb
+ *
+ * Invoked when the "Pause" button is clicked.
+ ********************************************************************/
+void
+gnc_ui_qif_import_load_progress_pause_cb(GtkButton * button,
+        gpointer user_data)
+{
+    QIFImportWindow *wind = user_data;
+    SCM toggle_pause      = scm_c_eval_string("qif-import:toggle-pause");
+    SCM progress;
+
+    if (!wind->busy)
+        return;
+
+    /* Create SCM for the progress helper. */
+    progress = SWIG_NewPointerObj(wind->load_progress,
+                                  SWIG_TypeQuery("_p__GNCProgressDialog"),
+                                  0);
+
+    /* Pause (or resume) the currently running operation. */
+    scm_call_1(toggle_pause, progress);
+
+    /* Swap the button label between pause and resume. */
+    if (strcmp(gtk_button_get_label(button), _("_Resume")))
+    {
+        gtk_button_set_use_stock(button, FALSE);
+        gtk_button_set_use_underline(button, TRUE);
+        gtk_button_set_label(button, _("_Resume"));
+    }
+    else
+    {
+        gtk_button_set_use_stock(button, TRUE);
+        gtk_button_set_use_underline(button, FALSE);
+        gtk_button_set_label(button, "gtk-media-pause");
+    }
+}
+
+
+/********************************************************************
+ * gnc_ui_qif_import_load_progress_start_cb
+ *
+ * Invoked when the "Start" button is clicked.
+ ********************************************************************/
+void
+gnc_ui_qif_import_load_progress_start_cb(GtkButton * button,
+        gpointer user_data)
+{
+    QIFImportWindow   *wind = user_data;
+    gint num = gtk_assistant_get_current_page (GTK_ASSISTANT(wind->window));
+    GtkWidget *page = gtk_assistant_get_nth_page (GTK_ASSISTANT(wind->window), num);
+
+    const gchar * path_to_load;
+
+    SCM make_qif_file   = scm_c_eval_string("make-qif-file");
+    SCM qif_file_load   = scm_c_eval_string("qif-file:read-file");
+    SCM qif_file_parse  = scm_c_eval_string("qif-file:parse-fields");
+    SCM unload_qif_file = scm_c_eval_string("qif-dialog:unload-qif-file");
+    SCM parse_results   = scm_c_eval_string("qif-file:parse-fields-results");
+    SCM scm_qiffile;
+    SCM imported_files = SCM_EOL;
+    SCM load_return, parse_return;
+    SCM progress;
+
+    /* Raise the busy flag so the assistant can't be canceled unexpectedly. */
+    wind->busy = TRUE;
+    gtk_widget_set_sensitive(wind->load_pause, TRUE);
+
+    /* Get the file name. */
+    path_to_load = gtk_entry_get_text(GTK_ENTRY(wind->filename_entry));
+
+    /* Create the <qif-file> object. */
+    scm_qiffile          = scm_call_0(make_qif_file);
+    scm_gc_unprotect_object(wind->selected_file);
+    wind->selected_file  = scm_qiffile;
+    scm_gc_protect_object(wind->selected_file);
+    imported_files       = scm_cons(scm_qiffile, wind->imported_files);
+
+    /* Create SCM for the progress helper. */
+    progress = SWIG_NewPointerObj(wind->load_progress,
+                                  SWIG_TypeQuery("_p__GNCProgressDialog"),
+                                  0);
+
+    /* Clear any previous pause or cancel state. */
+    scm_c_eval_string("(qif-import:reset-cancel-pause)");
+
+    /*
+     * Load the file.
+     *
+     * The loader returns:
+     *  success:   ()
+     *  failure:   (#f error-message)
+     *  warning:   (#t error-message)
+     *  cancel:    #t
+     *  exception: #f
+     */
+
+    /* This step will fill 70% of the bar. */
+    gnc_progress_dialog_push(wind->load_progress, 0.7);
+    load_return = scm_call_4(qif_file_load,
+                             SCM_CAR(imported_files),
+                             scm_from_locale_string(path_to_load ? path_to_load : ""),
+                             wind->ticker_map,
+                             progress);
+    gnc_progress_dialog_pop(wind->load_progress);
+    if (load_return == SCM_BOOL_T)
+    {
+        /* Canceled by the user. */
+
+        /* Disable the pause button. */
+        gtk_widget_set_sensitive(wind->load_pause, FALSE);
+
+        /* Inform the user. */
+        gnc_progress_dialog_set_sub(wind->load_progress, _("Canceled"));
+
+        wind->busy = FALSE;
+        wind->load_stop = TRUE;
+    }
+    else if (load_return == SCM_BOOL_F || !scm_is_list(load_return))
+    {
+        /* A bug was detected. */
+
+        /* Disable the pause button. */
+        gtk_widget_set_sensitive(wind->load_pause, FALSE);
+
+        /* Inform the user. */
+        gnc_progress_dialog_append_log(wind->load_progress,
+                                       _( "An error occurred while loading the QIF file."));
+        gnc_progress_dialog_set_sub(wind->load_progress, _("Failed"));
+        gnc_progress_dialog_reset_value(wind->load_progress);
+        gnc_error_dialog(wind->window, "%s",
+                         _( "An error occurred while loading the QIF file."));
+        /* FIXME: How should we request that the user report this problem? */
+
+        wind->busy = FALSE;
+        wind->load_stop = TRUE;
+    }
+    else if (!scm_is_null(load_return))
+    {
+        if (SCM_CAR(load_return) == SCM_BOOL_F)
+        {
+            imported_files = scm_call_2(unload_qif_file, scm_qiffile, imported_files);
+            scm_gc_unprotect_object(wind->imported_files);
+            wind->imported_files = imported_files;
+            scm_gc_protect_object(wind->imported_files);
+
+            gnc_progress_dialog_set_sub(wind->load_progress, _("Failed"));
+            gnc_progress_dialog_reset_value(wind->load_progress);
+
+            gtk_widget_set_sensitive(wind->load_pause, FALSE);
+            wind->busy = FALSE;
+            wind->load_stop = TRUE;
+        }
+    }
+
+    /*
+     * Parse the fields.
+     *
+     * The parser returns:
+     *   success:   ()
+     *   failure:   (#f . ((type . error) ...))
+     *   warning:   (#t . ((type . error) ...))
+     *   cancel:    #t
+     *   exception: #f
+     */
+
+    /* This step will fill the remainder of the bar. */
+    gnc_progress_dialog_push(wind->load_progress, 1);
+    parse_return = scm_call_2(qif_file_parse, SCM_CAR(imported_files), progress);
+    gnc_progress_dialog_pop(wind->load_progress);
+    wind->ask_date_format = FALSE;
+    if (parse_return == SCM_BOOL_T)
+    {
+        /* Canceled by the user. */
+
+        /* Disable the pause button. */
+        gtk_widget_set_sensitive(wind->load_pause, FALSE);
+
+        /* Unload the file. */
+        gnc_progress_dialog_set_sub(wind->load_progress, _("Cleaning up"));
+        imported_files = scm_call_2(unload_qif_file, scm_qiffile, imported_files);
+
+        /* Inform the user. */
+        gnc_progress_dialog_set_sub(wind->load_progress, _("Canceled"));
+
+        wind->busy = FALSE;
+        wind->load_stop = TRUE;
+    }
+    else if (parse_return == SCM_BOOL_F || !scm_is_list(parse_return))
+    {
+        /* A bug was detected. */
+
+        /* Disable the pause button. */
+        gtk_widget_set_sensitive(wind->load_pause, FALSE);
+
+        /* Unload the file. */
+        gnc_progress_dialog_set_sub(wind->load_progress, _("Cleaning up"));
+        imported_files = scm_call_2(unload_qif_file, scm_qiffile, imported_files);
+
+        /* Inform the user. */
+        gnc_progress_dialog_append_log(wind->load_progress,
+                                       _( "A bug was detected while parsing the QIF file."));
+        gnc_progress_dialog_set_sub(wind->load_progress, _("Failed"));
+        gnc_progress_dialog_reset_value(wind->load_progress);
+        gnc_error_dialog(wind->window, "%s",
+                         _( "A bug was detected while parsing the QIF file."));
+        /* FIXME: How should we request that the user report this problem? */
+
+        wind->busy = FALSE;
+        wind->load_stop = TRUE;
+    }
+    else if (!scm_is_null(parse_return))
+    {
+        /* Are there only warnings? */
+        if (SCM_CAR(parse_return) == SCM_BOOL_T)
+        {
+            SCM date_formats;
+
+            /* A warning means that (potentially) the date format is
+             * ambiguous.  So search the results for the "date" type and if
+             * it's found, set up the format selector page. */
+            if ((date_formats = scm_call_2(parse_results,
+                                           SCM_CDR(parse_return),
+                                           scm_from_locale_symbol ("date"))) != SCM_BOOL_F)
+            {
+                GtkComboBox *combo_box;
+                GtkTreeModel *model;
+                GtkTreeIter iter;
+
+                /* Block the date call back */
+                g_signal_handlers_block_by_func( wind->date_format_combo, gnc_ui_qif_import_date_valid_cb, wind );
+
+                /* Clear the date format combo box. */
+                combo_box = GTK_COMBO_BOX(wind->date_format_combo);
+                model = gtk_combo_box_get_model(combo_box);
+                gtk_list_store_clear(GTK_LIST_STORE(model));
+
+                gtk_combo_box_set_active(GTK_COMBO_BOX(wind->date_format_combo), -1);
+
+                /* Add the formats for the user to select from. */
+                while (scm_is_list(date_formats) && !scm_is_null(date_formats))
+                {
+                    gtk_list_store_append(GTK_LIST_STORE(model), &iter);
+                    gtk_list_store_set (GTK_LIST_STORE(model), &iter, 0, gnc_scm_symbol_to_locale_string(SCM_CAR(date_formats)), -1);
+
+                    date_formats = SCM_CDR(date_formats);
+                }
+
+                /* Unblock the date call back */
+                g_signal_handlers_unblock_by_func( wind->date_format_combo, gnc_ui_qif_import_date_valid_cb, wind );
+
+                wind->ask_date_format = TRUE;
+            }
+        }
+        else
+        {
+            /* Parsing failed. */
+            imported_files = scm_call_2(unload_qif_file, scm_qiffile, imported_files);
+            gnc_progress_dialog_set_sub(wind->load_progress, _("Failed"));
+            gnc_progress_dialog_reset_value(wind->load_progress);
+
+            gtk_widget_set_sensitive(wind->load_pause, FALSE);
+            wind->busy = FALSE;
+            wind->load_stop = TRUE;
+        }
+    }
+
+    /* Enable the assistant Forward button */
+    gtk_assistant_set_page_complete (GTK_ASSISTANT(wind->window), page, TRUE);
+
+    /* Set Pause and Start buttons */
+    gtk_widget_set_sensitive(wind->load_pause, FALSE);
+    gtk_widget_set_sensitive(wind->load_start, FALSE);
+
+    if (wind->load_stop == FALSE)
+    {
+        /* The file was loaded successfully. */
+        gnc_progress_dialog_set_sub(wind->load_progress, _("Loading completed"));
+        gnc_progress_dialog_set_value(wind->load_progress, 1);
+
+        scm_gc_unprotect_object(wind->imported_files);
+        wind->imported_files = imported_files;
+        scm_gc_protect_object(wind->imported_files);
+
+        gtk_widget_set_sensitive(wind->load_pause, FALSE);
+        wind->busy = FALSE;
+
+        /* Auto step to next page */
+        gtk_assistant_set_current_page (GTK_ASSISTANT(wind->window), num + 1);
+    }
+}
+
+
+/********************************************************************
+ * gnc_ui_qif_import_load_progress_prepare
+ *
+ * Prepare the file loading progress page for display.
+ ********************************************************************/
+void
+gnc_ui_qif_import_load_progress_prepare (GtkAssistant  *assistant, gpointer user_data)
+{
+    QIFImportWindow   *wind = user_data;
+    gint num = gtk_assistant_get_current_page (assistant);
+    GtkWidget *page = gtk_assistant_get_nth_page (assistant, num);
+
+    /* Reset the progress display. */
+    gnc_progress_dialog_set_primary(wind->load_progress, "");
+    gnc_progress_dialog_set_secondary(wind->load_progress,
+                                      _("When you press the Start Button, GnuCash will load your QIF file. If there are no errors or warnings, you will automatically proceed to the next step. Otherwise, the details will be shown below for your review."));
+    gnc_progress_dialog_set_sub(wind->load_progress, " ");
+    gnc_progress_dialog_reset_value(wind->load_progress);
+    gnc_progress_dialog_reset_log(wind->load_progress);
+
+    /* Set Pause and Start buttons */
+    gtk_widget_set_sensitive(wind->load_pause, FALSE);
+    gtk_widget_set_sensitive(wind->load_start, TRUE);
+
+    /* Disable the assistant Forward button */
+    gtk_assistant_set_page_complete (assistant, page, FALSE);
+}
+
+
+/*****************************************
+ * Page 3 - Date format Page Procedures
+ ****************************************/
+
+/********************************************************************
+ * gnc_ui_qif_import_date_format_prepare
+ *
+ * Determine if we need the date page and what is next page.
+ ********************************************************************/
+void
+gnc_ui_qif_import_date_format_prepare (GtkAssistant  *assistant, gpointer user_data)
+
+{
+    QIFImportWindow *wind = user_data;
+    gint num = gtk_assistant_get_current_page (assistant);
+
+    if (wind->ask_date_format)
+    {
+        /* We need to get a date format, so stay here. */
+    }
+    else
+    {
+        /* Skip ahead to the Account page. */
+        gtk_assistant_set_current_page (assistant, num + 1);
+    }
+}
+
+
+/********************************************************************
+ * gnc_ui_qif_import_date_valid_cb
+ *
+ * Reparse file with new date format.
+ ********************************************************************/
+void
+gnc_ui_qif_import_date_valid_cb (GtkWidget *widget, gpointer user_data)
+{
+    QIFImportWindow * wind = user_data;
+    GtkTreeModel *model;
+    GtkTreeIter iter;
+
+    GtkAssistant *assistant = GTK_ASSISTANT(wind->window);
+    gint num = gtk_assistant_get_current_page (assistant);
+    GtkWidget *page = gtk_assistant_get_nth_page (assistant, num);
+
+    SCM  reparse_dates   = scm_c_eval_string("qif-file:reparse-dates");
+    SCM  format_sym;
+    gchar *text;
+
+    /* Get the selected date format. */
+    model = gtk_combo_box_get_model(GTK_COMBO_BOX(wind->date_format_combo));
+    gtk_combo_box_get_active_iter (GTK_COMBO_BOX(wind->date_format_combo), &iter);
+    gtk_tree_model_get( model, &iter, 0, &text, -1 );
+
+    if (!text)
+    {
+        g_critical("QIF import: BUG DETECTED in gnc_ui_qif_import_date_valid_cb. Format is NULL.");
+    }
+    format_sym = scm_from_locale_symbol (text);
+    g_free(text);
+
+    /* Reparse the dates using the selected format. */
+    scm_call_2(reparse_dates, wind->selected_file, format_sym);
+
+    gtk_assistant_set_page_complete (assistant, page, TRUE);
+}
+
+
+/******************************************
+ * Page 4 - Account Setup Page Procedures
+ ******************************************/
+
+/********************************************************************
+ * gnc_ui_qif_import_account_prepare
+ *
+ * Do we need to specify an account.
+ ********************************************************************/
+void
+gnc_ui_qif_import_account_prepare (GtkAssistant  *assistant, gpointer user_data)
+{
+    QIFImportWindow * wind = user_data;
+    gint num = gtk_assistant_get_current_page (assistant);
+
+    SCM  check_from_acct = scm_c_eval_string("qif-file:check-from-acct");
+
+    /* Determine the next page to display. */
+    if (scm_call_1(check_from_acct, wind->selected_file) != SCM_BOOL_T)
+    {
+        /* There is an account name missing. Ask the user to provide one. */
+        SCM default_acct = scm_c_eval_string("qif-file:path-to-accountname");
+        gchar * default_acctname = NULL;
+
+        default_acctname = gnc_scm_call_1_to_string(default_acct, wind->selected_file);
+        gtk_entry_set_text(GTK_ENTRY(wind->acct_entry), default_acctname);
+        g_free (default_acctname);
+    }
+    else
+    {
+        /* Skip ahead to the "loaded files" page. */
+        gtk_assistant_set_current_page (assistant, num + 1);
+    }
+}
+
+
+/********************************************************************
+ * gnc_ui_qif_import_acct_valid_cb
+ *
+ * Invoked when the "next" button is clicked on the default acct page.
+ ********************************************************************/
+void
+gnc_ui_qif_import_acct_valid_cb(GtkWidget * widget,
+                                gpointer user_data)
+{
+    QIFImportWindow * wind = user_data;
+
+    GtkAssistant *assistant = GTK_ASSISTANT(wind->window);
+    gint num = gtk_assistant_get_current_page (assistant);
+    GtkWidget *page = gtk_assistant_get_nth_page (assistant, num);
+
+    const gchar * acct_name = gtk_entry_get_text(GTK_ENTRY(wind->acct_entry));
+
+    if (!acct_name || acct_name[0] == 0)
+    {
+        /* Disable the assistant Forward Button */
+        gtk_assistant_set_page_complete (assistant, page, FALSE);
+    }
+    else
+    {
+        /* Enable the assistant Forward Button */
+        gtk_assistant_set_page_complete (assistant, page, TRUE);
+    }
+}
+
+
+/*****************************************
+ * Page 5 - Loaded Files Page Procedures
+ ****************************************/
+
+/********************************************************************
+ * gnc_ui_qif_import_loaded_files_prepare
+ *
+ * Get the loaded files page ready for viewing
+ ********************************************************************/
+void
+gnc_ui_qif_import_loaded_files_prepare (GtkAssistant *assistant,
+                                        gpointer user_data)
+{
+    QIFImportWindow * wind = user_data;
+
+    gint num = gtk_assistant_get_current_page (assistant);
+    GtkWidget *page = gtk_assistant_get_nth_page (assistant, num);
+
+    const gchar * acct_name = gtk_entry_get_text(GTK_ENTRY(wind->acct_entry));
+    SCM    fix_default = scm_c_eval_string("qif-import:fix-from-acct");
+    SCM    scm_name;
+
+    scm_name = scm_from_utf8_string(acct_name ? acct_name : "");
+    scm_call_2(fix_default, wind->selected_file, scm_name);
+
+    /* Enable the assistant Forward Button */
+    gtk_assistant_set_page_complete (assistant, page, TRUE);
+
+    update_file_page(wind);
+}
+
+
+/********************************************************************
+ * gnc_ui_qif_import_load_another_cb
+ * Invoked when the "load another" button is clicked on the loaded
+ * files page.
+ ********************************************************************/
+void
+gnc_ui_qif_import_load_another_cb(GtkButton * button,
+                                  gpointer user_data)
+{
+    QIFImportWindow * wind = user_data;
+    GtkAssistant *assistant = GTK_ASSISTANT(wind->window);
+
+    gtk_assistant_set_current_page (assistant, 1);
+}
+
+
+/********************************************************************
+ * gnc_ui_qif_import_unload_cb
+ * Invoked when the "unload" button is clicked on the loaded files
+ * page.
+ ********************************************************************/
+void
+gnc_ui_qif_import_unload_file_cb(GtkButton * button,
+                                 gpointer user_data)
+{
+    QIFImportWindow * wind = user_data;
+
+    SCM unload_qif_file = scm_c_eval_string("qif-dialog:unload-qif-file");
+    SCM imported_files;
+
+    if (wind->selected_file != SCM_BOOL_F)
+    {
+        imported_files =
+            scm_call_2(unload_qif_file, wind->selected_file, wind->imported_files);
+
+        scm_gc_unprotect_object(wind->imported_files);
+        wind->imported_files = imported_files;
+        scm_gc_protect_object(wind->imported_files);
+
+        scm_gc_unprotect_object(wind->selected_file);
+        wind->selected_file = SCM_BOOL_F;
+        scm_gc_protect_object(wind->selected_file);
+
+        update_file_page(wind);
+    }
+}
+
+
+/********************************************************************
+ * update_file_page
+ *
+ * Update the list of loaded files.
+ ********************************************************************/
+static void
+update_file_page(QIFImportWindow * wind)
+{
+    SCM       loaded_file_list = wind->imported_files;
+    SCM       qif_file_path;
+    int       row = 0;
+    GtkTreeView *view;
+    GtkListStore *store;
+    GtkTreeIter iter;
+    GtkTreePath *path;
+    GtkTreeRowReference *reference = NULL;
+
+    /* clear the list */
+    view = GTK_TREE_VIEW(wind->selected_file_view);
+    store = GTK_LIST_STORE(gtk_tree_view_get_model(view));
+    gtk_list_store_clear(store);
+    qif_file_path = scm_c_eval_string("qif-file:path");
+
+    while (!scm_is_null(loaded_file_list))
+    {
+        gchar *row_text    = NULL;
+        SCM    scm_qiffile = SCM_BOOL_F;
+
+        scm_qiffile = SCM_CAR(loaded_file_list);
+        row_text = gnc_scm_call_1_to_string(qif_file_path, scm_qiffile);
+
+        gtk_list_store_append(store, &iter);
+        gtk_list_store_set(store, &iter,
+                           FILENAME_COL_INDEX, row++,
+                           FILENAME_COL_NAME, row_text,
+                           -1);
+        g_free (row_text);
+
+        if (scm_qiffile == wind->selected_file)
+        {
+            path = gtk_tree_model_get_path(GTK_TREE_MODEL(store), &iter);
+            reference = gtk_tree_row_reference_new(GTK_TREE_MODEL(store), path);
+            gtk_tree_path_free(path);
+        }
+        loaded_file_list = SCM_CDR(loaded_file_list);
+    }
+
+    if (reference)
+    {
+        GtkTreeSelection* selection = gtk_tree_view_get_selection(view);
+        path = gtk_tree_row_reference_get_path(reference);
+        if (path)
+        {
+            gtk_tree_selection_select_path(selection, path);
+            gtk_tree_path_free(path);
+        }
+        gtk_tree_row_reference_free(reference);
+    }
+}
+
+
+/**********************************************
+ * Page 6 - Account Doc. Page Procedures
+ **********************************************/
+
+/********************************************************************
+ * gnc_ui_qif_import_account_doc_prepare
+ ********************************************************************/
+void
+gnc_ui_qif_import_account_doc_prepare (GtkAssistant *assistant,
+                                       gpointer user_data)
+{
+    QIFImportWindow * wind = user_data;
+    gint num = gtk_assistant_get_current_page (assistant);
+    GtkWidget *page = gtk_assistant_get_nth_page (assistant, num);
+    gint total = gtk_assistant_get_n_pages (assistant);
+    gtk_assistant_update_buttons_state (assistant);
+
+    PINFO("Total Number of Assistant Pages is %d", gtk_assistant_get_n_pages (assistant));
+
+    /* Enable the Assistant Forward Button */
+    gtk_assistant_set_page_complete (assistant, page, TRUE);
+
+    /* Jump to Summary page if load_stop TRUE */
+    if (wind->load_stop)
+        gtk_assistant_set_current_page (assistant, total - 1 );
+
+    /* Jump over doc page if show_doc_pages FALSE */
+    if (!wind->show_doc_pages)
+        gtk_assistant_set_current_page (assistant, num + 1 );
+}
+
+
+/******************************************
+ * Page 7 - Account Match Page Procedures
+ ******************************************/
+
+/********************************************************************
+ * gnc_ui_qif_import_account_match_prepare
+ *
+ * Get the matching pages ready for viewing.
+ ********************************************************************/
+void
+gnc_ui_qif_import_account_match_prepare(GtkAssistant *assistant,
+                                        gpointer user_data)
+{
+    QIFImportWindow * wind = user_data;
+    gint num = gtk_assistant_get_current_page (assistant);
+    GtkWidget *page = gtk_assistant_get_nth_page (assistant, num);
+
+    /* Prepare the matching pages. */
+    gnc_set_busy_cursor(NULL, TRUE);
+    update_account_page(wind);
+    update_category_page(wind);
+    update_memo_page(wind);
+    gnc_unset_busy_cursor(NULL);
+
+    /* Enable the Assistant Forward Button */
+    gtk_assistant_set_page_complete (assistant, page, TRUE);
+}
+
+
+/****************************************************************
+ * gnc_ui_qif_import_account_rematch_cb
+ *
+ * This handler is invoked when the user clicks the "Change
+ * GnuCash account" button on the account mapping page. This
+ * button is an alternative to double-clicking a row.
+ ****************************************************************/
+void
+gnc_ui_qif_import_account_rematch_cb(GtkButton *button, gpointer user_data)
+{
+    QIFImportWindow  *wind = user_data;
+
+    g_return_if_fail(wind);
+
+    rematch_line(wind,
+                 gtk_tree_view_get_selection(GTK_TREE_VIEW(wind->acct_view)),
+                 wind->acct_display_info,
+                 wind->acct_map_info,
+                 update_account_page);
+}
+
+
+/*******************************************
+ * Page 8 - Catagory Doc. Page Procedures
+ *******************************************/
+
+/********************************************************************
+ * gnc_ui_qif_import_catagory_doc_prepare
+ ********************************************************************/
+void
+gnc_ui_qif_import_catagory_doc_prepare (GtkAssistant *assistant,
+                                        gpointer user_data)
+{
+    QIFImportWindow * wind = user_data;
+    gint num = gtk_assistant_get_current_page (assistant);
+    GtkWidget *page = gtk_assistant_get_nth_page (assistant, num);
+    gint total = gtk_assistant_get_n_pages (assistant);
+    gtk_assistant_update_buttons_state (assistant);
+
+    PINFO("Total Number of Assistant Pages is %d", gtk_assistant_get_n_pages (assistant));
+
+    /* Enable the Assistant Forward Button */
+    gtk_assistant_set_page_complete (assistant, page, TRUE);
+
+    /* Jump to Summary page if load_stop TRUE */
+    if (wind->load_stop)
+        gtk_assistant_set_current_page (assistant, total - 1 );
+
+    /* Jump over doc page if show_doc_pages FALSE */
+    if (!wind->show_doc_pages)
+        gtk_assistant_set_current_page (assistant, num + 1 );
+
+    /* If there are no category mappings, jump the doc page. */
+    if (scm_is_list(wind->cat_display_info) && scm_is_null(wind->cat_display_info))
+        gtk_assistant_set_current_page (assistant, num + 1);
+}
+
+
+/******************************************
+ * Page 9 - Catagory Match Page Procedures
+ ******************************************/
+
+/****************************************************************
+ * gnc_ui_qif_import_catagory_match_prepare
+ *
+ * Find the next page to show, depending on whether there are
+ * category or payee/memo mappings to be dealt with.
+ ****************************************************************/
+void
+gnc_ui_qif_import_catagory_match_prepare(GtkAssistant *assistant,
+        gpointer user_data)
+{
+    QIFImportWindow * wind = user_data;
+    gint num = gtk_assistant_get_current_page (assistant);
+    GtkWidget *page = gtk_assistant_get_nth_page (assistant, num);
+
+    /* Enable the Assistant Forward Button */
+    gtk_assistant_set_page_complete (assistant, page, TRUE);
+
+    /* If there are no category mappings, jump this step. */
+    if (scm_is_list(wind->cat_display_info) && scm_is_null(wind->cat_display_info))
+        gtk_assistant_set_current_page (assistant, num + 1);
+}
+
+
+/****************************************************************
+ * gnc_ui_qif_import_category_rematch_cb
+ *
+ * This handler is invoked when the user clicks the "Change
+ * GnuCash account" button on the category mapping page. This
+ * button is an alternative to double-clicking a row.
+ ****************************************************************/
+void
+gnc_ui_qif_import_category_rematch_cb(GtkButton *button, gpointer user_data)
+{
+    QIFImportWindow  *wind = user_data;
+
+    g_return_if_fail(wind);
+
+    rematch_line(wind,
+                 gtk_tree_view_get_selection(GTK_TREE_VIEW(wind->cat_view)),
+                 wind->cat_display_info,
+                 wind->cat_map_info,
+                 update_category_page);
+}
+
+
+/****************************************
+ * Page 10 - Memo Doc. Page Procedures
+ ****************************************/
+
+/********************************************************************
+ * gnc_ui_qif_import_memo_doc_prepare
+ ********************************************************************/
+void
+gnc_ui_qif_import_memo_doc_prepare (GtkAssistant *assistant,
+                                    gpointer user_data)
+{
+    QIFImportWindow * wind = user_data;
+    gint num = gtk_assistant_get_current_page (assistant);
+    GtkWidget *page = gtk_assistant_get_nth_page (assistant, num);
+    gint total = gtk_assistant_get_n_pages (assistant);
+    gtk_assistant_update_buttons_state (assistant);
+
+    PINFO("Total Number of Assistant Pages is %d", gtk_assistant_get_n_pages (assistant));
+
+    /* Enable the Assistant Forward Button */
+    gtk_assistant_set_page_complete (assistant, page, TRUE);
+
+    /* Jump to Summary page if load_stop TRUE */
+    if (wind->load_stop)
+        gtk_assistant_set_current_page (assistant, total - 1 );
+
+    /* Jump over doc page if show_doc_pages FALSE */
+    if (!wind->show_doc_pages)
+        gtk_assistant_set_current_page (assistant, num + 1 );
+
+    /* If there are no memo mappings, jump the doc page. */
+    if (scm_is_list(wind->memo_display_info) && scm_is_null(wind->memo_display_info))
+        gtk_assistant_set_current_page (assistant, num + 1);
+}
+
+
+/****************************************
+ * Page 11 - Memo Match Page Procedures
+ ****************************************/
+
+/****************************************************************
+ * gnc_ui_qif_import_memo_match_prepare
+ *
+ * Find the next page to show, depending on whether there are
+ * category or payee/memo mappings to be dealt with.
+ ****************************************************************/
+void
+gnc_ui_qif_import_memo_match_prepare (GtkAssistant *assistant,
+                                      gpointer user_data)
+{
+    QIFImportWindow * wind = user_data;
+    gint num = gtk_assistant_get_current_page (assistant);
+    GtkWidget *page = gtk_assistant_get_nth_page (assistant, num);
+
+    /* Enable the Assistant Forward Button */
+    gtk_assistant_set_page_complete (assistant, page, TRUE);
+
+    /* If there are no memo mappings, jump this step. */
+    if (scm_is_list(wind->memo_display_info) && scm_is_null(wind->memo_display_info))
+        gtk_assistant_set_current_page (assistant, num + 1);
+}
+
+
+/****************************************************************
+ * gnc_ui_qif_import_memo_rematch_cb
+ *
+ * This handler is invoked when the user clicks the "Change
+ * GnuCash account" button on the memo mapping page. This
+ * button is an alternative to double-clicking a row.
+ ****************************************************************/
+void
+gnc_ui_qif_import_memo_rematch_cb(GtkButton *button, gpointer user_data)
+{
+    QIFImportWindow  *wind = user_data;
+
+    g_return_if_fail(wind);
+
+    rematch_line(wind,
+                 gtk_tree_view_get_selection(GTK_TREE_VIEW(wind->memo_view)),
+                 wind->memo_display_info,
+                 wind->memo_map_info,
+                 update_memo_page);
+}
+
+
+/*****************************************
+ * Page 12  - Currency Page Procedures
+ ****************************************/
+
+/****************************************************************
+ * gnc_ui_qif_import_currency_prepare
+ *
+ * Find the next page to show, depending on whether there are
+ * category or payee/memo mappings to be dealt with.
+ ****************************************************************/
+void
+gnc_ui_qif_import_currency_prepare(GtkAssistant *assistant,
+                                   gpointer user_data)
+{
+    gint num = gtk_assistant_get_current_page (assistant);
+    GtkWidget *page = gtk_assistant_get_nth_page (assistant, num);
+    QIFImportWindow  *wind = user_data;
+
+    g_return_if_fail(wind);
+
+    /* Only display Book Option data if new book */
+    if (wind->new_book)
+    {
+        gtk_assistant_set_page_title (assistant, page,
+                                      _("Choose the QIF file currency and select Book Options"));
+        gtk_widget_show (wind->book_option_label);
+        gtk_widget_show (wind->book_option_message);
+    }
+    else
+    {
+        gtk_assistant_set_page_title (assistant, page,
+                                      _("Choose the QIF file currency"));
+        gtk_widget_hide (wind->book_option_label);
+        gtk_widget_hide (wind->book_option_message);
+    }
+
+    /* Enable the Assistant Forward Button */
+    gtk_assistant_set_page_complete (assistant, page, TRUE);
+}
+
+
+/**************************************************
+ * Page 13 - Commodity Doc. Page Procedures
+ **************************************************/
+
+/****************************************************************
+ * gnc_ui_qif_import_new_securities
+ *
+ * This function creates or updates the list of QIF securities
+ * for which no corresponding GnuCash commodity existed prior to
+ * import. If there are any such securities, TRUE is returned.
+ * Otherwise, FALSE is returned.
+ ****************************************************************/
+static gboolean
+gnc_ui_qif_import_new_securities(QIFImportWindow * wind)
+{
+    SCM updates;
+    SCM update_securities = scm_c_eval_string("qif-import:update-security-hash");
+
+    /* Get a list of any new QIF securities since the previous call. */
+    updates = scm_call_4(update_securities,
+                         wind->security_hash,
+                         wind->ticker_map,
+                         wind->acct_map_info,
+                         wind->security_prefs);
+    if (updates != SCM_BOOL_F)
+    {
+        /* A list of new QIF securities was returned. Save it. */
+        scm_gc_unprotect_object(wind->new_securities);
+        if (wind->new_securities != SCM_BOOL_F)
+            /* There is an existing list, so append the new list. */
+            wind->new_securities = scm_append(scm_list_2(wind->new_securities,
+                                              updates));
+        else
+            wind->new_securities = updates;
+        scm_gc_protect_object(wind->new_securities);
+
+        return TRUE;
+    }
+
+    if (wind->new_securities != SCM_BOOL_F)
+        return TRUE;
+
+    return FALSE;
+}
+
+
+/********************************************************************
+ * gnc_ui_qif_import_commodity_doc_prepare
+ ********************************************************************/
+void
+gnc_ui_qif_import_commodity_doc_prepare (GtkAssistant *assistant,
+        gpointer user_data)
+{
+    QIFImportWindow * wind = user_data;
+    gint num = gtk_assistant_get_current_page (assistant);
+    GtkWidget *page = gtk_assistant_get_nth_page (assistant, num);
+    gint total = gtk_assistant_get_n_pages (assistant);
+    gtk_assistant_update_buttons_state (assistant);
+
+    PINFO("Total Number of Assistant Pages is %d", gtk_assistant_get_n_pages (assistant));
+
+    /* Enable the Assistant Forward Button */
+    gtk_assistant_set_page_complete (assistant, page, TRUE);
+
+    /* Jump to Summary page if load_stop TRUE */
+    if (wind->load_stop)
+        gtk_assistant_set_current_page (assistant, total - 1 );
+
+    /* If there are new securities, prepare the security pages. */
+    if (gnc_ui_qif_import_new_securities(wind))
+        prepare_security_pages(wind);
+    else
+        /* If there are no securities, jump the doc page */
+        gtk_assistant_set_current_page (assistant, num + 1 );
+
+    /* Jump over doc page if show_doc_pages FALSE */
+    if (!wind->show_doc_pages)
+        gtk_assistant_set_current_page (assistant, num + 1 );
+}
+
+
+/********************************************
+ * Page xx - Commodity New Pages Procedures
+ ********************************************/
+
+/********************************************
+ * gnc_ui_qif_import_commodity_new_prepare
+ *******************************************/
+void
+gnc_ui_qif_import_commodity_new_prepare (GtkAssistant *assistant,
+        gpointer user_data)
+{
+    gint num = gtk_assistant_get_current_page (assistant);
+    GtkWidget *page = gtk_assistant_get_nth_page (assistant, num);
+
+    QIFAssistantPage    *qpage = g_object_get_data(G_OBJECT(page), "page_struct");
+    const gchar         *ns;
+
+    g_return_if_fail (qpage != NULL);
+
+    /* Get any entered namespace. */
+    ns = gtk_entry_get_text( GTK_ENTRY( gtk_bin_get_child( GTK_BIN( GTK_COMBO_BOX(qpage->namespace_combo)))));
+
+    /* Update the namespaces available to select. */
+    if (!ns || !ns[0])
+        gnc_ui_update_namespace_picker(
+            qpage->namespace_combo,
+            gnc_commodity_get_namespace(qpage->commodity),
+            DIAG_COMM_ALL);
+    else
+        gnc_ui_update_namespace_picker(qpage->namespace_combo, ns, DIAG_COMM_ALL);
+}
+
+
+/*********************************
+ * gnc_ui_qif_import_comm_valid
+ ********************************/
+static gboolean
+gnc_ui_qif_import_comm_valid (GtkAssistant *assistant,
+                              gpointer user_data)
+{
+    QIFImportWindow *wind = user_data;
+    gint num = gtk_assistant_get_current_page (GTK_ASSISTANT(wind->window));
+    GtkWidget *page = gtk_assistant_get_nth_page (assistant, num);
+    QIFAssistantPage    *qpage = g_object_get_data(G_OBJECT(page), "page_struct");
+
+    QofBook                 *book;
+    gnc_commodity_table     *table;
+    gnc_commodity_namespace *newns;
+
+    gchar       *namespace = gnc_ui_namespace_picker_ns(qpage->namespace_combo);
+    const gchar *name      = gtk_entry_get_text(GTK_ENTRY(qpage->name_entry));
+    const gchar *mnemonic  = gtk_entry_get_text(GTK_ENTRY(qpage->mnemonic_entry));
+
+    if (!name || (name[0] == 0))
+    {
+        gnc_warning_dialog(wind->window, "%s",
+                           _("Enter a name or short description, such as \"Red Hat Stock\"."));
+        g_free(namespace);
+        return FALSE;
+    }
+    else if (!mnemonic || (mnemonic[0] == 0))
+    {
+        gnc_warning_dialog(wind->window, "%s",
+                           _("Enter the ticker symbol or other well known abbreviation, such as"
+                             " \"RHT\". If there isn't one, or you don't know it, create your own."));
+        g_free(namespace);
+        return FALSE;
+    }
+    else if (!namespace || (namespace[0] == 0))
+    {
+        gnc_warning_dialog(wind->window, "%s",
+                           _("Select the exchange on which the symbol is traded, or select the"
+                             " type of investment (such as FUND for mutual funds.) If you don't"
+                             " see your exchange or an appropriate investment type, you can"
+                             " enter a new one."));
+        if (namespace)
+            g_free(namespace);
+        return FALSE;
+    }
+
+    /* FIXME: Should check whether a commodity with this namespace and
+     *        mnemonic already exists. If so, ask the user whether to use
+     *        the existing one, or go back and change what they've entered.
+     */
+
+    book = gnc_get_current_book();
+    table = gnc_commodity_table_get_table(book);
+    if (gnc_commodity_namespace_is_iso(namespace) &&
+            !gnc_commodity_table_lookup(table, namespace, mnemonic))
+    {
+        gnc_warning_dialog(wind->window, "%s",
+                           _("You must enter an existing national "
+                             "currency or enter a different type."));
+
+        g_free(namespace);
+        return FALSE;
+    }
+
+    /* Is the namespace a new one? */
+    if (!gnc_commodity_table_has_namespace(table, namespace))
+    {
+        /* Register it so that it will appear as an option on other pages. */
+        newns = gnc_commodity_table_add_namespace(table, namespace, book);
+
+        /* Remember it so it can be removed if the import gets canceled. */
+        if (newns)
+            wind->new_namespaces = g_list_prepend(wind->new_namespaces, namespace);
+        else
+        {
+            g_warning("QIF import: Couldn't create namespace %s", namespace);
+            g_free(namespace);
+        }
+    }
+    else
+        g_free(namespace);
+
+    return TRUE;
+}
+
+
+/*************************************
+ * gnc_ui_qif_import_comm_changed_cb
+ ************************************/
+void
+gnc_ui_qif_import_comm_changed_cb (GtkWidget *widget, gpointer user_data)
+{
+    QIFImportWindow *wind = user_data;
+    GtkAssistant *assistant = GTK_ASSISTANT(wind->window);
+    gint num = gtk_assistant_get_current_page (assistant);
+    GtkWidget *page = gtk_assistant_get_nth_page (assistant, num);
+
+    gtk_assistant_set_page_complete (assistant, page, gnc_ui_qif_import_comm_valid (assistant, user_data));
+}
+
+
+/**********************************************
+ * Page 14 - Convert progress Page Procedures
+ *********************************************/
+
+/********************************************************************
+ * gnc_ui_qif_import_convert_progress_pause_cb
+ *
+ * Invoked when the "Pause" button is clicked.
+ ********************************************************************/
+void
+gnc_ui_qif_import_convert_progress_pause_cb(GtkButton * button,
+        gpointer user_data)
+{
+    QIFImportWindow *wind = user_data;
+    SCM toggle_pause      = scm_c_eval_string("qif-import:toggle-pause");
+    SCM progress;
+
+    if (!wind->busy)
+        return;
+
+    /* Create SCM for the progress helper. */
+    progress = SWIG_NewPointerObj(wind->convert_progress,
+                                  SWIG_TypeQuery("_p__GNCProgressDialog"),
+                                  0);
+
+    /* Pause (or resume) the currently running operation. */
+    scm_call_1(toggle_pause, progress);
+
+    /* Swap the button label between pause and resume. */
+    if (strcmp(gtk_button_get_label(button), _("_Resume")))
+    {
+        gtk_button_set_use_stock(button, FALSE);
+        gtk_button_set_use_underline(button, TRUE);
+        gtk_button_set_label(button, _("_Resume"));
+    }
+    else
+    {
+        gtk_button_set_use_stock(button, TRUE);
+        gtk_button_set_use_underline(button, FALSE);
+        gtk_button_set_label(button, "gtk-media-pause");
+    }
+}
+
+
+/********************************************************************
+ * gnc_ui_qif_import_convert_progress_start_cb
+ *
+ * Invoked when the "Start" button is clicked.
+ ********************************************************************/
+void
+gnc_ui_qif_import_convert_progress_start_cb(GtkButton * button,
+        gpointer user_data)
+{
+    QIFImportWindow   *wind = user_data;
+    gint num = gtk_assistant_get_current_page (GTK_ASSISTANT(wind->window));
+    GtkWidget *page = gtk_assistant_get_nth_page (GTK_ASSISTANT(wind->window), num);
+
+    SCM qif_to_gnc      = scm_c_eval_string("qif-import:qif-to-gnc");
+    SCM find_duplicates = scm_c_eval_string("gnc:account-tree-find-duplicates");
+    SCM retval;
+
+    /* SCM for the progress dialog. */
+    SCM progress = SWIG_NewPointerObj(wind->convert_progress,
+                                      SWIG_TypeQuery("_p__GNCProgressDialog"),
+                                      0);
+
+    /* The default currency. */
+    const gchar *currname = gtk_entry_get_text( GTK_ENTRY( gtk_bin_get_child( GTK_BIN( GTK_COMBO_BOX(wind->currency_picker)))));
+
+    /* Raise the busy flag so the assistant can't be canceled unexpectedly. */
+    wind->busy = TRUE;
+    gtk_widget_set_sensitive(wind->convert_pause, TRUE);
+    gtk_widget_set_sensitive(wind->convert_start, FALSE);
+
+    /* Clear any previous pause or cancel state. */
+    scm_c_eval_string("(qif-import:reset-cancel-pause)");
+
+    /* Update the commodities. */
+    gnc_ui_qif_import_commodity_update(wind);
+
+    /*
+     * Convert the QIF data into GnuCash data.
+     *
+     * A Scheme function does all the work.  The return value is the
+     * root account of an account tree containing all the new accounts
+     * and transactions. Upon failure, #f is returned. If the user
+     * cancels, #t is returned.
+     */
+
+    /* This step will fill 70% of the bar. */
+    gnc_progress_dialog_push(wind->convert_progress, 0.7);
+    retval = scm_apply(qif_to_gnc,
+                       SCM_LIST8(wind->imported_files,
+                                 wind->acct_map_info,
+                                 wind->cat_map_info,
+                                 wind->memo_map_info,
+                                 wind->security_hash,
+                                 scm_from_utf8_string(currname ? currname : ""),
+                                 wind->transaction_status,
+                                 progress),
+                       SCM_EOL);
+    gnc_progress_dialog_pop(wind->convert_progress);
+
+    if (retval == SCM_BOOL_T)
+    {
+        /* Canceled by the user. */
+
+        /* Disable the pause button. */
+        gtk_widget_set_sensitive(wind->convert_pause, FALSE);
+
+        /* Remove any converted data. */
+        gnc_progress_dialog_set_sub(wind->convert_progress, _("Cleaning up"));
+        gnc_ui_qif_import_convert_undo(wind);
+
+        /* Inform the user. */
+        gnc_progress_dialog_set_sub(wind->convert_progress, _("Canceled"));
+        gnc_progress_dialog_reset_value(wind->convert_progress);
+
+        wind->busy = FALSE;
+        wind->load_stop = TRUE;
+    }
+    else if (retval == SCM_BOOL_F)
+    {
+        /* An bug was encountered during conversion. */
+
+        /* Disable the pause button. */
+        gtk_widget_set_sensitive(wind->convert_pause, FALSE);
+
+        /* Remove any converted data. */
+        gnc_progress_dialog_set_sub(wind->convert_progress, _("Cleaning up"));
+        gnc_ui_qif_import_convert_undo(wind);
+
+        /* Inform the user. */
+        gnc_progress_dialog_append_log(wind->convert_progress,
+                                       _( "A bug was detected while converting the QIF data."));
+        gnc_progress_dialog_set_sub(wind->convert_progress, _("Failed"));
+        gnc_progress_dialog_reset_value(wind->convert_progress);
+        gnc_error_dialog(wind->window, "%s",
+                         _( "A bug was detected while converting the QIF data."));
+        /* FIXME: How should we request that the user report this problem? */
+
+        wind->busy = FALSE;
+        wind->load_stop = TRUE;
+    }
+    else if (scm_is_symbol(retval))
+    {
+        /* An error was encountered during conversion. */
+
+        /* Disable the pause button. */
+        gtk_widget_set_sensitive(wind->convert_pause, FALSE);
+
+        /* Remove any converted data. */
+        gnc_progress_dialog_set_sub(wind->convert_progress, _("Cleaning up"));
+        gnc_ui_qif_import_convert_undo(wind);
+
+        /* Inform the user. */
+        gnc_progress_dialog_set_sub(wind->convert_progress, _("Failed"));
+        gnc_progress_dialog_reset_value(wind->convert_progress);
+
+        wind->busy = FALSE;
+        wind->load_stop = TRUE;
+    }
+
+    /* Save the imported account tree. */
+    scm_gc_unprotect_object(wind->imported_account_tree);
+    wind->imported_account_tree = retval;
+    scm_gc_protect_object(wind->imported_account_tree);
+
+    /*
+     * Detect potentially duplicated transactions.
+     */
+
+    /* This step will fill the remainder of the bar. */
+    gnc_progress_dialog_push(wind->convert_progress, 1);
+    retval = scm_call_3(find_duplicates,
+                        scm_c_eval_string("(gnc-get-current-root-account)"),
+                        wind->imported_account_tree, progress);
+    gnc_progress_dialog_pop(wind->convert_progress);
+
+    /* Save the results. */
+    scm_gc_unprotect_object(wind->match_transactions);
+    wind->match_transactions = retval;
+    scm_gc_protect_object(wind->match_transactions);
+
+    if (retval == SCM_BOOL_T)
+    {
+        /* Canceled by the user. */
+        gtk_widget_set_sensitive(wind->convert_pause, FALSE);
+        gnc_progress_dialog_set_sub(wind->convert_progress, _("Canceling"));
+        wind->busy = FALSE;
+        wind->load_stop = TRUE;
+    }
+    else if (retval == SCM_BOOL_F)
+    {
+        /* An error occurred during duplicate checking. */
+
+        /* Remove any converted data. */
+        gnc_progress_dialog_set_sub(wind->convert_progress, _("Cleaning up"));
+        gnc_ui_qif_import_convert_undo(wind);
+
+        /* Inform the user. */
+        gnc_progress_dialog_append_log(wind->convert_progress,
+                                       _( "A bug was detected while detecting duplicates."));
+        gnc_progress_dialog_set_sub(wind->convert_progress, _("Failed"));
+        gnc_progress_dialog_reset_value(wind->convert_progress);
+        gnc_error_dialog(wind->window, "%s",
+                         _( "A bug was detected while detecting duplicates."));
+        /* FIXME: How should we request that the user report this problem? */
+
+        gtk_widget_set_sensitive(wind->convert_pause, FALSE);
+        wind->busy = FALSE;
+        wind->load_stop = TRUE;
+    }
+
+    /* Enable the Assistant Forward Button */
+    gtk_assistant_set_page_complete (GTK_ASSISTANT(wind->window), page, TRUE);
+
+    /* Set Pause and Start buttons */
+    gtk_widget_set_sensitive(wind->convert_pause, FALSE);
+    gtk_widget_set_sensitive(wind->convert_start, FALSE);
+
+    if (wind->load_stop == FALSE)
+    {
+        /* The conversion completed successfully. */
+        gnc_progress_dialog_set_sub(wind->convert_progress,
+                                    _("Conversion completed"));
+        gnc_progress_dialog_set_value(wind->convert_progress, 1);
+
+        gtk_widget_set_sensitive(wind->convert_pause, FALSE);
+        wind->busy = FALSE;
+
+        /* If the log is empty, move on to the next page automatically. */
+        if (gtk_text_buffer_get_char_count(gtk_text_view_get_buffer(GTK_TEXT_VIEW(wind->convert_log))) == 0)
+            gtk_assistant_set_current_page (GTK_ASSISTANT(wind->window), num + 1);
+    }
+}
+
+
+/********************************************************************
+ * gnc_ui_qif_import_convert_progress_prepare
+ *
+ * Prepare the data conversion progress page for display.
+ ********************************************************************/
+void
+gnc_ui_qif_import_convert_progress_prepare(GtkAssistant *assistant,
+        gpointer user_data)
+{
+    QIFImportWindow   *wind = user_data;
+    gint num = gtk_assistant_get_current_page (assistant);
+    GtkWidget *page = gtk_assistant_get_nth_page (assistant, num);
+
+    /* Recompute assistant Buttons */
+    gtk_assistant_update_buttons_state( assistant );
+
+    /* Reset the progress display. */
+    gnc_progress_dialog_set_primary(wind->convert_progress, "");
+    gnc_progress_dialog_set_secondary(wind->convert_progress,
+                                      _("When you press the Start Button, GnuCash will import your QIF data. If there are no errors or warnings, you will automatically proceed to the next step. Otherwise, the details will be shown below for your review."));
+    gnc_progress_dialog_set_sub(wind->convert_progress, " ");
+    gnc_progress_dialog_reset_value(wind->convert_progress);
+    gnc_progress_dialog_reset_log(wind->convert_progress);
+
+    /* Set Pause and Start buttons */
+    gtk_widget_set_sensitive(wind->convert_pause, FALSE);
+    gtk_widget_set_sensitive(wind->convert_start, TRUE);
+
+    /* Disable the assistant Forward button */
+    gtk_assistant_set_page_complete (assistant, page, FALSE);
+
+    /* Before creating transactions, if this is a new book, let user specify
+     * book options, since they affect how transactions are created */
+    if (wind->new_book)
+        wind->new_book = gnc_new_book_option_display();
+}
+
+
+/*****************************************
+ * Page 15 - Match Doc. Page Procedures
+ *****************************************/
+
+/********************************************************************
+ * gnc_ui_qif_import_duplicates_doc_prepare
+ ********************************************************************/
+void
+gnc_ui_qif_import_duplicates_doc_prepare (GtkAssistant *assistant,
+        gpointer user_data)
+{
+    QIFImportWindow * wind = user_data;
+    gint num = gtk_assistant_get_current_page (assistant);
+    GtkWidget *page = gtk_assistant_get_nth_page (assistant, num);
+    gint total = gtk_assistant_get_n_pages (assistant);
+    gtk_assistant_update_buttons_state (assistant);
+
+    PINFO("Total Number of Assistant Pages is %d", gtk_assistant_get_n_pages (assistant));
+
+    /* Enable the Assistant Forward Button */
+    gtk_assistant_set_page_complete (assistant, page, TRUE);
+
+    /* Jump to Summary page if load_stop TRUE */
+    if (wind->load_stop)
+        gtk_assistant_set_current_page (assistant, total - 1 );
+
+    /* Jump over doc page if show_doc_pages FALSE */
+    if (!wind->show_doc_pages)
+        gtk_assistant_set_current_page (assistant, num + 1 );
+
+    /* Don't show doc page if there are no duplicates */
+    if (scm_is_null(wind->match_transactions))
+        gtk_assistant_set_current_page (assistant, num + 1 );
+}
+
+
+/**********************************************
+ * Page 16 - Match Duplicates Page Procedures
+ **********************************************/
+
+/********************************************************************
+ * gnc_ui_qif_import_duplicates_match_prepare
+ ********************************************************************/
+void
+gnc_ui_qif_import_duplicates_match_prepare (GtkAssistant *assistant,
+        gpointer user_data)
+{
+    QIFImportWindow * wind = user_data;
+    gint num = gtk_assistant_get_current_page (assistant);
+    GtkWidget *page = gtk_assistant_get_nth_page (assistant, num);
+
+    GtkTreeView      *view;
+    GtkListStore     *store;
+    SCM               duplicates;
+    SCM               current_xtn;
+    Transaction      *gnc_xtn;
+    Split            *gnc_split;
+    GtkTreeIter       iter;
+    GtkTreeSelection *selection;
+    GtkTreePath      *path;
+    const gchar      *amount_str;
+    int               rownum = 0;
+
+    if (!scm_is_null(wind->match_transactions))
+    {
+        view = GTK_TREE_VIEW(wind->new_transaction_view);
+        store = GTK_LIST_STORE(gtk_tree_view_get_model(view));
+        gtk_list_store_clear(store);
+
+        if (!scm_is_list(wind->match_transactions))
+            return;
+
+        /* Loop through the list of new, potentially duplicate transactions. */
+        duplicates = wind->match_transactions;
+        while (!scm_is_null(duplicates))
+        {
+            current_xtn = SCM_CAAR(duplicates);
+#define FUNC_NAME "xaccTransCountSplits"
+            gnc_xtn = SWIG_MustGetPtr(current_xtn,
+                                      SWIG_TypeQuery("_p_Transaction"), 1, 0);
+#undef FUNC_NAME
+            if (xaccTransCountSplits(gnc_xtn) > 2)
+                amount_str = _("(split)");
+            else
+            {
+                gnc_split = xaccTransGetSplit(gnc_xtn, 0);
+                amount_str =
+                    xaccPrintAmount(gnc_numeric_abs(xaccSplitGetValue(gnc_split)),
+                                    gnc_account_print_info
+                                    (xaccSplitGetAccount(gnc_split), TRUE));
+            }
+            gtk_list_store_append(store, &iter);
+            gtk_list_store_set
+            (store, &iter,
+             QIF_TRANS_COL_INDEX, rownum++,
+             QIF_TRANS_COL_DATE,
+             gnc_print_date(xaccTransRetDatePostedTS(gnc_xtn)),
+             QIF_TRANS_COL_DESCRIPTION, xaccTransGetDescription(gnc_xtn),
+             QIF_TRANS_COL_AMOUNT, amount_str,
+             -1);
+
+            duplicates = SCM_CDR(duplicates);
+        }
+        selection = gtk_tree_view_get_selection(view);
+        path = gtk_tree_path_new_from_indices(0, -1);
+        gtk_tree_selection_select_path(selection, path);
+        gtk_tree_path_free(path);
+    }
+    else
+        gtk_assistant_set_current_page (assistant, num + 1 );
+
+    /* Enable the Assistant Forward Button */
+    gtk_assistant_set_page_complete (assistant, page, TRUE);
+}
+
+
+/*************************************
+ * Page 17 - Apply Page Procedures
+ *************************************/
+
+/********************************************************************
+ * gnc_ui_qif_import_end_page_prepare
+ ********************************************************************/
+void
+gnc_ui_qif_import_end_page_prepare (GtkAssistant *assistant,
+                                    gpointer user_data)
+{
+    gint num = gtk_assistant_get_current_page (assistant);
+    GtkWidget *page = gtk_assistant_get_nth_page (assistant, num);
+
+    /* Enable the Assistant Forward Button */
+    gtk_assistant_set_page_complete (assistant, page, TRUE);
+}
+
+
+/********************************************************************
+ * gnc_ui_qif_import_finish_cb
+ *
+ * Invoked when the "Apply" button is clicked on the final page.
+ ********************************************************************/
+void
+gnc_ui_qif_import_finish_cb (GtkAssistant *gtkassistant,
+                             gpointer user_data)
+{
+    QIFImportWindow * wind = user_data;
+
+    SCM save_map_prefs = scm_c_eval_string("qif-import:save-map-prefs");
+    SCM cat_and_merge = scm_c_eval_string("gnc:account-tree-catenate-and-merge");
+    SCM prune_xtns = scm_c_eval_string("gnc:prune-matching-transactions");
+    SCM scm_result;
+
+    GncPluginPage *page;
+    gboolean acct_tree_found = FALSE;
+
+    gnc_suspend_gui_refresh();
+
+    /* Prune any imported transactions that were determined to be duplicates. */
+    if (wind->match_transactions != SCM_BOOL_F)
+        scm_call_1(prune_xtns, wind->match_transactions);
+
+    /* Merge the imported account tree with the existing one. */
+    if (wind->imported_account_tree != SCM_BOOL_F)
+        scm_call_2(cat_and_merge,
+                   scm_c_eval_string("(gnc-get-current-root-account)"),
+                   wind->imported_account_tree);
+
+    gnc_resume_gui_refresh();
+
+    /* Save the user's mapping preferences. */
+    scm_result = scm_apply(save_map_prefs,
+                           SCM_LIST5(wind->acct_map_info, wind->cat_map_info,
+                                     wind->memo_map_info, wind->security_hash,
+                                     wind->security_prefs),
+                           SCM_EOL);
+
+    if (scm_result == SCM_BOOL_F)
+        gnc_warning_dialog(wind->window, "%s",
+                           _("GnuCash was unable to save your mapping preferences."));
+
+    /* Open an account tab in the main window if one doesn't exist already. */
+    gnc_main_window_foreach_page(gnc_ui_qif_import_check_acct_tree,
+                                 &acct_tree_found);
+
+    wind->acct_tree_found = acct_tree_found;
+    if (!acct_tree_found)
+    {
+        page = gnc_plugin_page_account_tree_new();
+        gnc_main_window_open_page(NULL, page);
+    }
+}
+
+
+/***************************************
+ * Page 18 - Summary Page Procedures
+ ***************************************/
+
+/********************************************************************
+ * gnc_ui_qif_import_summary_page_prepare
+ ********************************************************************/
+void
+gnc_ui_qif_import_summary_page_prepare (GtkAssistant *assistant,
+                                        gpointer user_data)
+{
+    QIFImportWindow * wind = user_data;
+    gint num = gtk_assistant_get_current_page (assistant);
+    GtkWidget *page = gtk_assistant_get_nth_page (assistant, num);
+
+    gchar *text;
+
+    if (wind->load_stop)
+        text = g_strdup_printf(_("There was a problem with the import."));
+    else
+        text = g_strdup_printf(_("QIF Import Completed."));
+
+    gtk_label_set_markup(GTK_LABEL(wind->summary_text), g_strdup_printf("<span size=\"large\"><b>%s</b></span>", text));
+
+    g_free(text);
+
+    /* Enable the Assistant Forward Button */
+    gtk_assistant_set_page_complete (assistant, page, TRUE);
+}
+
+
+/********************************************************************
+ * Prepare callback for assistant pages.
+ ********************************************************************/
+void gnc_ui_qif_import_prepare_cb (GtkAssistant  *assistant, GtkWidget *page,
+                                   gpointer user_data)
+{
+    gint currentpage = gtk_assistant_get_current_page(assistant);
+    GtkWidget *mypage = gtk_assistant_get_nth_page (assistant, currentpage);
+    const char *pagename = gtk_buildable_get_name(GTK_BUILDABLE(mypage));
+
+    PINFO("Builder Page Name is %s", gtk_buildable_get_name(GTK_BUILDABLE(mypage)));
+
+    if (!g_strcmp0 (pagename, "start_page"))
+    {
+        /* Current page is Intro page */
+        gnc_ui_qif_import_intro_prepare (assistant, user_data);
+    }
+    else if (!g_strcmp0 (pagename, "load_file_page"))
+    {
+        /* Current page is File Load */
+        gnc_ui_qif_import_load_file_prepare (assistant, user_data);
+    }
+    else if (!g_strcmp0 (pagename, "load_progress_page"))
+    {
+        /* Current page is Load Progress */
+        gnc_ui_qif_import_load_progress_prepare (assistant, user_data);
+    }
+    else if (!g_strcmp0 (pagename, "date_format_page"))
+    {
+        /* Current page is date page */
+        gnc_ui_qif_import_date_format_prepare (assistant, user_data);
+    }
+    else if (!g_strcmp0 (pagename, "account_name_page"))
+    {
+        /* Current page is account page */
+        gnc_ui_qif_import_account_prepare (assistant, user_data);
+    }
+    else if (!g_strcmp0 (pagename, "loaded_files_page"))
+    {
+        /* Current page is loaded files page */
+        gnc_ui_qif_import_loaded_files_prepare (assistant, user_data);
+    }
+    else if (!g_strcmp0 (pagename, "account_doc_page"))
+    {
+        /* Current page is  Account Doc. page */
+        gnc_ui_qif_import_account_doc_prepare (assistant, user_data);
+    }
+    else if (!g_strcmp0 (pagename, "account_match_page"))
+    {
+        /* Current page is Account Match page */
+        gnc_ui_qif_import_account_match_prepare (assistant, user_data);
+    }
+    else if (!g_strcmp0 (pagename, "category_doc_page"))
+    {
+        /* Current page is Catagory Doc. page */
+        gnc_ui_qif_import_catagory_doc_prepare (assistant, user_data);
+    }
+    else if (!g_strcmp0 (pagename, "category_match_page"))
+    {
+        /* Current page is Catagory Match page */
+        gnc_ui_qif_import_catagory_match_prepare (assistant, user_data);
+    }
+    else if (!g_strcmp0 (pagename, "memo_doc_page"))
+    {
+        /* Current page is Memo Doc. page */
+        gnc_ui_qif_import_memo_doc_prepare (assistant, user_data);
+    }
+    else if (!g_strcmp0 (pagename, "memo_match_page"))
+    {
+        /* Current page is Memo Match page */
+        gnc_ui_qif_import_memo_match_prepare (assistant, user_data);
+    }
+    else if (!g_strcmp0 (pagename, "currency_book_option_page"))
+    {
+        /* Current page is Currency page */
+        gnc_ui_qif_import_currency_prepare (assistant, user_data);
+    }
+    else if (!g_strcmp0 (pagename, "commodity_doc_page"))
+    {
+        /* Current page is Commodity Doc. page */
+        gnc_ui_qif_import_commodity_doc_prepare (assistant, user_data);
+    }
+    else if (!g_strcmp0 (pagename, "commodity_page"))
+    {
+        /* Current page is Commodity page */
+        /* gnc_ui_qif_import_commodity_prepare (assistant, user_data); */
+    }
+    else if (!g_strcmp0 (pagename, "convert_progress_page"))
+    {
+        /* Current page is Conversion progress page */
+        gnc_ui_qif_import_convert_progress_prepare (assistant, user_data);
+    }
+    else if (!g_strcmp0 (pagename, "duplicates_doc_page"))
+    {
+        /* Current page is Duplicates Doc page */
+        gnc_ui_qif_import_duplicates_doc_prepare (assistant, user_data);
+    }
+    else if (!g_strcmp0 (pagename, "duplicates_match_page"))
+    {
+        /* Current page is Duplicates Match page */
+        gnc_ui_qif_import_duplicates_match_prepare (assistant, user_data);
+    }
+    else if (!g_strcmp0 (pagename, "end_page"))
+    {
+        /* Current page is the end page */
+        gnc_ui_qif_import_end_page_prepare (assistant, user_data);
+    }
+    else if (!g_strcmp0 (pagename, "summary_page"))
+    {
+        /* Current page is the summary page */
+        gnc_ui_qif_import_summary_page_prepare (assistant, user_data);
+    }
+    else
+    {
+        /* Current page is a new commodity page */
+        gnc_ui_qif_import_commodity_new_prepare (assistant, user_data);
+    }
+}
+
+
+/********************************************************************
+ * get_assistant_widgets
+ *
+ * Get all builder-defined widgets that need to be actively managed.
+ ********************************************************************/
+static void
+get_assistant_widgets(QIFImportWindow *wind, GtkBuilder *builder)
+{
+    g_return_if_fail(wind);
+    g_return_if_fail(builder);
+
+    wind->window             = GTK_WIDGET(gtk_builder_get_object (builder, "QIF Import Assistant"));
+    wind->filename_entry     = GTK_WIDGET(gtk_builder_get_object (builder, "qif_filename_entry"));
+    wind->load_pause         = GTK_WIDGET(gtk_builder_get_object (builder, "load_progress_pause"));
+    wind->load_start         = GTK_WIDGET(gtk_builder_get_object (builder, "load_progress_start"));
+    wind->load_log           = GTK_WIDGET(gtk_builder_get_object (builder, "load_progress_log"));
+    wind->load_progress      = gnc_progress_dialog_custom(
+                                   GTK_LABEL(gtk_builder_get_object (builder, "load_progress_primary")),
+                                   GTK_LABEL(gtk_builder_get_object (builder, "load_progress_secondary")),
+                                   GTK_PROGRESS_BAR(gtk_builder_get_object (builder, "load_progress_bar")),
+                                   GTK_LABEL(gtk_builder_get_object (builder, "load_progress_sub")),
+                                   GTK_TEXT_VIEW(wind->load_log));
+    wind->acct_entry         = GTK_WIDGET(gtk_builder_get_object (builder, "qif_account_entry"));
+    wind->date_format_combo  = GTK_WIDGET(gtk_builder_get_object (builder, "date_format_combobox"));
+    wind->selected_file_view = GTK_WIDGET(gtk_builder_get_object (builder, "selected_file_view"));
+    wind->unload_file_btn    = GTK_WIDGET(gtk_builder_get_object (builder, "unload_file_button"));
+    wind->currency_picker    = GTK_WIDGET(gtk_builder_get_object (builder, "currency_comboboxentry"));
+    wind->book_option_label  = GTK_WIDGET(gtk_builder_get_object (builder, "book_option_label"));
+    wind->book_option_message = GTK_WIDGET(gtk_builder_get_object (builder, "book_option_message_label"));
+    wind->acct_view          = GTK_WIDGET(gtk_builder_get_object (builder, "account_page_view"));
+    wind->acct_view_count    = GTK_WIDGET(gtk_builder_get_object (builder, "account_page_count"));
+    wind->acct_view_btn      = GTK_WIDGET(gtk_builder_get_object (builder, "account_page_change"));
+    wind->cat_view           = GTK_WIDGET(gtk_builder_get_object (builder, "category_page_view"));
+    wind->cat_view_count     = GTK_WIDGET(gtk_builder_get_object (builder, "category_page_count"));
+    wind->cat_view_btn       = GTK_WIDGET(gtk_builder_get_object (builder, "category_page_change"));
+    wind->memo_view          = GTK_WIDGET(gtk_builder_get_object (builder, "memo_page_view"));
+    wind->memo_view_count    = GTK_WIDGET(gtk_builder_get_object (builder, "memo_page_count"));
+    wind->memo_view_btn      = GTK_WIDGET(gtk_builder_get_object (builder, "memo_page_change"));
+    wind->convert_pause      = GTK_WIDGET(gtk_builder_get_object (builder, "convert_progress_pause"));
+    wind->convert_start      = GTK_WIDGET(gtk_builder_get_object (builder, "convert_progress_start"));
+    wind->convert_log        = GTK_WIDGET(gtk_builder_get_object (builder, "convert_progress_log"));
+    wind->convert_progress   = gnc_progress_dialog_custom(
+                                   GTK_LABEL(gtk_builder_get_object (builder, "convert_progress_primary")),
+                                   GTK_LABEL(gtk_builder_get_object (builder, "convert_progress_secondary")),
+                                   GTK_PROGRESS_BAR(gtk_builder_get_object (builder, "convert_progress_bar")),
+                                   GTK_LABEL(gtk_builder_get_object (builder, "convert_progress_sub")),
+                                   GTK_TEXT_VIEW(wind->convert_log));
+    wind->summary_text       = GTK_WIDGET(gtk_builder_get_object (builder, "summary_page"));
+
+    wind->new_transaction_view =
+        GTK_WIDGET(gtk_builder_get_object (builder, "new_transaction_view"));
+    wind->old_transaction_view =
+        GTK_WIDGET(gtk_builder_get_object (builder, "old_transaction_view"));
+
+    gnc_assistant_set_colors (GTK_ASSISTANT (wind->window));
+}
+
+
+/********************************************************************
+ * build_views
+ *
+ * Build the details of all GtkTreeView widgets.
+ ********************************************************************/
+static void
+build_views(QIFImportWindow *wind)
+{
+    GtkTreeView *view;
+    GtkListStore *store;
+    GtkCellRenderer *renderer;
+    GtkTreeViewColumn *column;
+    GtkTreeSelection *selection;
+
+    g_return_if_fail(wind);
+
+    /* Set up the selected file view */
+    view = GTK_TREE_VIEW(wind->selected_file_view);
+    store = gtk_list_store_new(NUM_FILENAME_COLS, G_TYPE_INT, G_TYPE_STRING);
+    gtk_tree_view_set_model(view, GTK_TREE_MODEL(store));
+    g_object_unref(store);
+
+    renderer = gtk_cell_renderer_text_new();
+    column = gtk_tree_view_column_new_with_attributes("unused",
+             renderer,
+             "text",
+             FILENAME_COL_NAME,
+             NULL);
+    gtk_tree_view_append_column(view, column);
+
+    selection = gtk_tree_view_get_selection(view);
+    g_signal_connect(selection, "changed",
+                     G_CALLBACK(gnc_ui_qif_import_select_loaded_file_cb),
+                     wind);
+
+    /* Set up the QIF account to GnuCash account matcher. */
+    create_account_picker_view(wind->acct_view, _("QIF account name"),
+                               G_CALLBACK(gnc_ui_qif_import_account_activate_cb),
+                               G_CALLBACK(gnc_ui_qif_import_account_select_cb),
+                               wind);
+
+    /* Set up the QIF category to GnuCash account matcher. */
+    create_account_picker_view(wind->cat_view,  _("QIF category name"),
+                               G_CALLBACK(gnc_ui_qif_import_category_activate_cb),
+                               G_CALLBACK(gnc_ui_qif_import_category_select_cb),
+                               wind);
+
+    /* Set up the QIF payee/memo to GnuCash account matcher. */
+    create_account_picker_view(wind->memo_view, _("QIF payee/memo"),
+                               G_CALLBACK(gnc_ui_qif_import_memo_activate_cb),
+                               G_CALLBACK(gnc_ui_qif_import_memo_select_cb),
+                               wind);
+
+    /* Set up the new transaction view */
+    view = GTK_TREE_VIEW(wind->new_transaction_view);
+    store = gtk_list_store_new(NUM_QIF_TRANS_COLS, G_TYPE_INT, G_TYPE_STRING,
+                               G_TYPE_STRING, G_TYPE_STRING, G_TYPE_BOOLEAN);
+    gtk_tree_view_set_model(view, GTK_TREE_MODEL(store));
+    g_object_unref(store);
+
+    renderer = gtk_cell_renderer_text_new();
+    column = gtk_tree_view_column_new_with_attributes(_("Date"),
+             renderer,
+             "text",
+             QIF_TRANS_COL_DATE,
+             NULL);
+    gtk_tree_view_append_column(view, column);
+
+    renderer = gtk_cell_renderer_text_new();
+    column = gtk_tree_view_column_new_with_attributes(_("Description"),
+             renderer,
+             "text",
+             QIF_TRANS_COL_DESCRIPTION,
+             NULL);
+    gtk_tree_view_append_column(view, column);
+    gtk_tree_view_column_set_expand(column, TRUE);
+
+    renderer = gtk_cell_renderer_text_new();
+    column = gtk_tree_view_column_new_with_attributes(_("Amount"),
+             renderer,
+             "text",
+             QIF_TRANS_COL_AMOUNT,
+             NULL);
+    gtk_tree_view_append_column(view, column);
+
+    selection = gtk_tree_view_get_selection(view);
+    g_signal_connect(selection, "changed",
+                     G_CALLBACK(gnc_ui_qif_import_duplicate_new_select_cb),
+                     wind);
+
+    /* Set up the old transaction view */
+    view = GTK_TREE_VIEW(wind->old_transaction_view);
+    store = gtk_list_store_new(NUM_QIF_TRANS_COLS, G_TYPE_INT, G_TYPE_STRING,
+                               G_TYPE_STRING, G_TYPE_STRING, G_TYPE_BOOLEAN);
+    gtk_tree_view_set_model(view, GTK_TREE_MODEL(store));
+    g_object_unref(store);
+
+    renderer = gtk_cell_renderer_text_new();
+    column = gtk_tree_view_column_new_with_attributes(_("Date"),
+             renderer,
+             "text",
+             QIF_TRANS_COL_DATE,
+             NULL);
+    gtk_tree_view_append_column(view, column);
+
+    renderer = gtk_cell_renderer_text_new();
+    column = gtk_tree_view_column_new_with_attributes(_("Description"),
+             renderer,
+             "text",
+             QIF_TRANS_COL_DESCRIPTION,
+             NULL);
+    gtk_tree_view_append_column(view, column);
+    gtk_tree_view_column_set_expand(column, TRUE);
+
+    renderer = gtk_cell_renderer_text_new();
+    column = gtk_tree_view_column_new_with_attributes(_("Amount"),
+             renderer,
+             "text",
+             QIF_TRANS_COL_AMOUNT,
+             NULL);
+    gtk_tree_view_append_column(view, column);
+
+    renderer = gtk_cell_renderer_toggle_new();
+    column = gtk_tree_view_column_new_with_attributes(_("Match?"),
+             renderer,
+             "active",
+             QIF_TRANS_COL_CHECKED,
+             NULL);
+    gtk_tree_view_append_column(view, column);
+
+    selection = gtk_tree_view_get_selection(view);
+    g_signal_connect(selection, "changed",
+                     G_CALLBACK(gnc_ui_qif_import_duplicate_old_select_cb),
+                     wind);
+}
+
+
+/********************************************************************
+ * gnc_ui_qif_import_assistant_make
+ *
+ * Build a new QIF import assistant.
+ ********************************************************************/
+static GtkWidget *
+gnc_ui_qif_import_assistant_make(QIFImportWindow *qif_win)
+{
+    GtkBuilder        *builder;
+    GtkWidget         *box;
+
+    builder = gtk_builder_new();
+    gnc_builder_add_from_file (builder, "assistant-qif-import.glade", "currency_liststore");
+    gnc_builder_add_from_file (builder, "assistant-qif-import.glade", "date_format_liststore");
+    gnc_builder_add_from_file (builder, "assistant-qif-import.glade", "QIF Import Assistant");
+
+    qif_win->new_namespaces       = NULL;
+    qif_win->selected_transaction = 0;
+    qif_win->busy                 = FALSE;
+    /* In order to include a book options display on the creation of a new book,
+     * we need to detect when we are dealing with a new book. */
+    qif_win->new_book = gnc_is_new_book();
+
+    /* Get all user preferences related to QIF importing. */
+    get_preferences(qif_win);
+
+    /* Set up the Scheme side of things. Note that if a session/book did not
+     * exist prior to this function, it is created within scheme function
+     * "qif-import:load-map-prefs", so we need to have set the flag previously */
+    initialize_scheme(qif_win);
+
+    /* Get all interesting builder-defined widgets. */
+    get_assistant_widgets(qif_win, builder);
+
+    /* Make this window stay on top */
+    gtk_window_set_transient_for (GTK_WINDOW (qif_win->window),
+				  GTK_WINDOW (gnc_ui_get_toplevel ()));
+
+    /* Build the details of all GtkTreeView widgets. */
+    build_views(qif_win);
+
+    /* Currency Page */
+    /* Set a default currency for new accounts */
+    qif_win->currency_picker = gnc_currency_edit_new();
+    gnc_currency_edit_set_currency (GNC_CURRENCY_EDIT(qif_win->currency_picker), gnc_default_currency());
+    gtk_widget_show (qif_win->currency_picker);
+    box = GTK_WIDGET(gtk_builder_get_object (builder, "currency_picker_hbox"));
+    gtk_box_pack_start(GTK_BOX(box), qif_win->currency_picker, TRUE, TRUE, 0);
+
+    gnc_restore_window_size (GNC_PREFS_GROUP, GTK_WINDOW(qif_win->window));
+
+    g_signal_connect( qif_win->window, "destroy",
+                      G_CALLBACK(gnc_ui_qif_import_assistant_destroy), qif_win );
+
+    gtk_builder_connect_signals(builder, qif_win);
+
+    g_object_unref(G_OBJECT(builder));
+
+    gtk_widget_show_all(qif_win->window);
+    gtk_window_present(GTK_WINDOW(qif_win->window));
+
+    return qif_win->window;
+}
+
+
+/********************************************
+ * gnc_ui_qif_import_assistant_close_handler
+ ********************************************/
+static void
+gnc_ui_qif_import_assistant_close_handler( gpointer user_data )
+{
+    QIFImportWindow *qif_win = user_data;
+
+    gnc_save_window_size(GNC_PREFS_GROUP, GTK_WINDOW(qif_win->window));
+    gtk_widget_destroy( qif_win->window );
+}
+
+
+/********************************************
+ * gnc_file_qif_import
+ ********************************************/
+void
+gnc_file_qif_import(void)
+{
+    QIFImportWindow *qif_win;
+    gint component_id;
+
+    qif_win = g_new0 (QIFImportWindow, 1);
+
+    /* pop up the QIF File Import dialog box */
+    gnc_ui_qif_import_assistant_make(qif_win);
+
+    component_id = gnc_register_gui_component (ASSISTANT_QIF_IMPORT_CM_CLASS,
+                   NULL, gnc_ui_qif_import_assistant_close_handler,
+                   qif_win);
+
+    gnc_gui_component_watch_entity_type (component_id,
+                                         GNC_ID_ACCOUNT,
+                                         QOF_EVENT_MODIFY | QOF_EVENT_DESTROY);
+
+    gtk_widget_show_all (qif_win->window);
+
+    gnc_window_adjust_for_screen (GTK_WINDOW(qif_win->window));
+}

Copied: gnucash/trunk/src/import-export/qif-imp/assistant-qif-import.glade (from rev 23566, gnucash/trunk/src/import-export/qif-import/assistant-qif-import.glade)
===================================================================
--- gnucash/trunk/src/import-export/qif-imp/assistant-qif-import.glade	                        (rev 0)
+++ gnucash/trunk/src/import-export/qif-imp/assistant-qif-import.glade	2013-12-15 17:21:20 UTC (rev 23567)
@@ -0,0 +1,1331 @@
+<?xml version="1.0"?>
+<interface>
+  <requires lib="gtk+" version="2.16"/>
+  <!-- interface-naming-policy project-wide -->
+  <object class="GtkAssistant" id="QIF Import Assistant">
+    <property name="can_focus">False</property>
+    <property name="border_width">12</property>
+    <property name="title" translatable="yes">QIF Import Assistant</property>
+    <signal name="close" handler="gnc_ui_qif_import_close_cb" swapped="no"/>
+    <signal name="apply" handler="gnc_ui_qif_import_finish_cb" swapped="no"/>
+    <signal name="cancel" handler="gnc_ui_qif_import_cancel_cb" swapped="no"/>
+    <signal name="prepare" handler="gnc_ui_qif_import_prepare_cb" swapped="no"/>
+    <child>
+      <object class="GtkLabel" id="start_page">
+        <property name="visible">True</property>
+        <property name="can_focus">False</property>
+        <property name="label" translatable="yes">GnuCash can import financial data from QIF (Quicken Interchange Format) files written by Quicken/QuickBooks, MS Money, Moneydance, and many other programs. 
+
+The import process has several steps. Your GnuCash accounts will not be changed until you click "Apply" at the end of the process. 
+
+Click "Forward" to start loading your QIF data, or "Cancel" to abort the process. </property>
+        <property name="wrap">True</property>
+      </object>
+      <packing>
+        <property name="page_type">intro</property>
+        <property name="title" translatable="yes">Import QIF files</property>
+        <property name="complete">True</property>
+      </packing>
+    </child>
+    <child>
+      <object class="GtkVBox" id="load_file_page">
+        <property name="visible">True</property>
+        <property name="can_focus">False</property>
+        <property name="border_width">12</property>
+        <child>
+          <object class="GtkLabel" id="label822">
+            <property name="visible">True</property>
+            <property name="can_focus">False</property>
+            <property name="label" translatable="yes">Please select a file to load. When you click "Forward", the file will be loaded and analyzed. You may need to answer some questions about the account(s) in the file.
+
+You will have the opportunity to load as many files as you wish, so don't worry if your data is in multiple files. 
+</property>
+            <property name="wrap">True</property>
+          </object>
+          <packing>
+            <property name="expand">False</property>
+            <property name="fill">False</property>
+            <property name="padding">5</property>
+            <property name="position">0</property>
+          </packing>
+        </child>
+        <child>
+          <object class="GtkHBox" id="hbox69">
+            <property name="visible">True</property>
+            <property name="can_focus">False</property>
+            <child>
+              <object class="GtkEntry" id="qif_filename_entry">
+                <property name="visible">True</property>
+                <property name="can_focus">True</property>
+                <property name="can_default">True</property>
+                <property name="has_default">True</property>
+                <property name="editable">False</property>
+                <property name="invisible_char">&#x25CF;</property>
+                <property name="invisible_char_set">True</property>
+                <property name="primary_icon_activatable">False</property>
+                <property name="secondary_icon_activatable">False</property>
+                <property name="primary_icon_sensitive">True</property>
+                <property name="secondary_icon_sensitive">True</property>
+              </object>
+              <packing>
+                <property name="expand">True</property>
+                <property name="fill">True</property>
+                <property name="position">0</property>
+              </packing>
+            </child>
+            <child>
+              <object class="GtkButton" id="button71">
+                <property name="label" translatable="yes">_Select...</property>
+                <property name="visible">True</property>
+                <property name="can_focus">True</property>
+                <property name="receives_default">True</property>
+                <property name="use_action_appearance">False</property>
+                <property name="use_underline">True</property>
+                <signal name="clicked" handler="gnc_ui_qif_import_select_file_cb" swapped="no"/>
+              </object>
+              <packing>
+                <property name="expand">False</property>
+                <property name="fill">False</property>
+                <property name="padding">3</property>
+                <property name="position">1</property>
+              </packing>
+            </child>
+          </object>
+          <packing>
+            <property name="expand">False</property>
+            <property name="fill">False</property>
+            <property name="position">1</property>
+          </packing>
+        </child>
+      </object>
+      <packing>
+        <property name="page_type">content</property>
+        <property name="title" translatable="yes">Select a QIF file to load</property>
+      </packing>
+    </child>
+    <child>
+      <object class="GtkVBox" id="load_progress_page">
+        <property name="visible">True</property>
+        <property name="can_focus">False</property>
+        <property name="border_width">12</property>
+        <property name="spacing">12</property>
+        <child>
+          <object class="GtkLabel" id="load_progress_primary">
+            <property name="visible">True</property>
+            <property name="can_focus">False</property>
+            <property name="label"><span weight="bold" size="larger">Primary text</span></property>
+            <property name="use_markup">True</property>
+            <property name="wrap">True</property>
+          </object>
+          <packing>
+            <property name="expand">False</property>
+            <property name="fill">False</property>
+            <property name="position">0</property>
+          </packing>
+        </child>
+        <child>
+          <object class="GtkLabel" id="load_progress_secondary">
+            <property name="visible">True</property>
+            <property name="can_focus">False</property>
+            <property name="label">Secondary text.</property>
+            <property name="wrap">True</property>
+          </object>
+          <packing>
+            <property name="expand">False</property>
+            <property name="fill">False</property>
+            <property name="position">1</property>
+          </packing>
+        </child>
+        <child>
+          <object class="GtkVBox" id="load_progress_vbox1">
+            <property name="visible">True</property>
+            <property name="can_focus">False</property>
+            <child>
+              <object class="GtkProgressBar" id="load_progress_bar">
+                <property name="visible">True</property>
+                <property name="can_focus">False</property>
+                <property name="pulse_step">0.10000000149</property>
+              </object>
+              <packing>
+                <property name="expand">False</property>
+                <property name="fill">False</property>
+                <property name="position">0</property>
+              </packing>
+            </child>
+            <child>
+              <object class="GtkLabel" id="load_progress_sub">
+                <property name="visible">True</property>
+                <property name="can_focus">False</property>
+                <property name="xalign">0</property>
+                <property name="label"><span style="italic">Sub-operation text</span></property>
+                <property name="use_markup">True</property>
+                <property name="wrap">True</property>
+              </object>
+              <packing>
+                <property name="expand">False</property>
+                <property name="fill">False</property>
+                <property name="position">1</property>
+              </packing>
+            </child>
+            <child>
+              <object class="GtkHButtonBox" id="load_progress_hbuttonbox1">
+                <property name="visible">True</property>
+                <property name="can_focus">False</property>
+                <property name="layout_style">end</property>
+                <child>
+                  <object class="GtkButton" id="load_progress_start">
+                    <property name="label" translatable="yes">_Start</property>
+                    <property name="visible">True</property>
+                    <property name="can_focus">True</property>
+                    <property name="receives_default">True</property>
+                    <property name="use_action_appearance">False</property>
+                    <property name="use_underline">True</property>
+                    <signal name="clicked" handler="gnc_ui_qif_import_load_progress_start_cb" swapped="no"/>
+                  </object>
+                  <packing>
+                    <property name="expand">False</property>
+                    <property name="fill">False</property>
+                    <property name="position">0</property>
+                  </packing>
+                </child>
+                <child>
+                  <object class="GtkButton" id="load_progress_pause">
+                    <property name="label">gtk-media-pause</property>
+                    <property name="visible">True</property>
+                    <property name="can_focus">True</property>
+                    <property name="can_default">True</property>
+                    <property name="receives_default">True</property>
+                    <property name="use_action_appearance">False</property>
+                    <property name="use_stock">True</property>
+                    <signal name="clicked" handler="gnc_ui_qif_import_load_progress_pause_cb" swapped="no"/>
+                  </object>
+                  <packing>
+                    <property name="expand">False</property>
+                    <property name="fill">False</property>
+                    <property name="position">1</property>
+                  </packing>
+                </child>
+              </object>
+              <packing>
+                <property name="expand">False</property>
+                <property name="fill">False</property>
+                <property name="position">2</property>
+              </packing>
+            </child>
+          </object>
+          <packing>
+            <property name="expand">False</property>
+            <property name="fill">False</property>
+            <property name="padding">6</property>
+            <property name="position">2</property>
+          </packing>
+        </child>
+        <child>
+          <object class="GtkScrolledWindow" id="scrolledwindow25">
+            <property name="visible">True</property>
+            <property name="can_focus">True</property>
+            <property name="hscrollbar_policy">automatic</property>
+            <property name="vscrollbar_policy">automatic</property>
+            <property name="shadow_type">in</property>
+            <child>
+              <object class="GtkTextView" id="load_progress_log">
+                <property name="visible">True</property>
+                <property name="can_focus">True</property>
+                <property name="editable">False</property>
+                <property name="wrap_mode">word</property>
+                <property name="cursor_visible">False</property>
+                <property name="accepts_tab">False</property>
+              </object>
+            </child>
+          </object>
+          <packing>
+            <property name="expand">True</property>
+            <property name="fill">True</property>
+            <property name="position">3</property>
+          </packing>
+        </child>
+      </object>
+      <packing>
+        <property name="page_type">content</property>
+        <property name="title" translatable="yes">Load QIF files</property>
+      </packing>
+    </child>
+    <child>
+      <object class="GtkVBox" id="date_format_page">
+        <property name="visible">True</property>
+        <property name="can_focus">False</property>
+        <property name="border_width">12</property>
+        <child>
+          <object class="GtkLabel" id="label841">
+            <property name="visible">True</property>
+            <property name="can_focus">False</property>
+            <property name="label" translatable="yes">The QIF file format does not specify which order the day, month, and year components of a date are printed. In most cases, it is possible to automatically determine which format is in use in a particular file. However, in the file you have just imported there exist more than one possible format that fits the data. 
+
+Please select a date format for the file. QIF files created by European software are likely  to be in "d-m-y" or day-month-year format, where US QIF files are likely to be "m-d-y" or month-day-year. 
+</property>
+            <property name="wrap">True</property>
+          </object>
+          <packing>
+            <property name="expand">False</property>
+            <property name="fill">False</property>
+            <property name="position">0</property>
+          </packing>
+        </child>
+        <child>
+          <object class="GtkComboBox" id="date_format_combobox">
+            <property name="visible">True</property>
+            <property name="can_focus">False</property>
+            <property name="model">date_format_liststore</property>
+            <signal name="changed" handler="gnc_ui_qif_import_date_valid_cb" swapped="no"/>
+            <child>
+              <object class="GtkCellRendererText" id="cellrenderertext1"/>
+              <attributes>
+                <attribute name="text">0</attribute>
+              </attributes>
+            </child>
+          </object>
+          <packing>
+            <property name="expand">False</property>
+            <property name="fill">False</property>
+            <property name="position">1</property>
+          </packing>
+        </child>
+        <child>
+          <object class="GtkLabel" id="label847713">
+            <property name="visible">True</property>
+            <property name="can_focus">False</property>
+            <property name="label" translatable="yes">Click "Back" to cancel the loading of this file and choose another.</property>
+            <property name="justify">center</property>
+            <property name="wrap">True</property>
+          </object>
+          <packing>
+            <property name="expand">False</property>
+            <property name="fill">False</property>
+            <property name="pack_type">end</property>
+            <property name="position">2</property>
+          </packing>
+        </child>
+      </object>
+      <packing>
+        <property name="page_type">content</property>
+        <property name="title" translatable="yes">Set a date format for this QIF file</property>
+      </packing>
+    </child>
+    <child>
+      <object class="GtkVBox" id="account_name_page">
+        <property name="visible">True</property>
+        <property name="can_focus">False</property>
+        <property name="border_width">12</property>
+        <child>
+          <object class="GtkLabel" id="label823">
+            <property name="visible">True</property>
+            <property name="can_focus">False</property>
+            <property name="label" translatable="yes">The QIF file that you just loaded appears to contain transactions for just one account, but the file does not specify a name for that account. 
+
+Please enter a name for the account. If the file was exported from another accounting program, you should use the same account name that was used in that program.
+</property>
+            <property name="wrap">True</property>
+          </object>
+          <packing>
+            <property name="expand">False</property>
+            <property name="fill">False</property>
+            <property name="padding">4</property>
+            <property name="position">0</property>
+          </packing>
+        </child>
+        <child>
+          <object class="GtkHBox" id="hbox70">
+            <property name="visible">True</property>
+            <property name="can_focus">False</property>
+            <child>
+              <object class="GtkLabel" id="label824">
+                <property name="visible">True</property>
+                <property name="can_focus">False</property>
+                <property name="xalign">1</property>
+                <property name="label" translatable="yes">Account name:</property>
+                <property name="justify">center</property>
+              </object>
+              <packing>
+                <property name="expand">False</property>
+                <property name="fill">False</property>
+                <property name="padding">4</property>
+                <property name="position">0</property>
+              </packing>
+            </child>
+            <child>
+              <object class="GtkEntry" id="qif_account_entry">
+                <property name="visible">True</property>
+                <property name="can_focus">True</property>
+                <property name="invisible_char">&#x25CF;</property>
+                <property name="invisible_char_set">True</property>
+                <property name="primary_icon_activatable">False</property>
+                <property name="secondary_icon_activatable">False</property>
+                <property name="primary_icon_sensitive">True</property>
+                <property name="secondary_icon_sensitive">True</property>
+                <signal name="changed" handler="gnc_ui_qif_import_acct_valid_cb" swapped="no"/>
+              </object>
+              <packing>
+                <property name="expand">True</property>
+                <property name="fill">True</property>
+                <property name="position">1</property>
+              </packing>
+            </child>
+          </object>
+          <packing>
+            <property name="expand">False</property>
+            <property name="fill">False</property>
+            <property name="position">1</property>
+          </packing>
+        </child>
+        <child>
+          <object class="GtkLabel" id="label847714">
+            <property name="visible">True</property>
+            <property name="can_focus">False</property>
+            <property name="label" translatable="yes">Click "Back" to cancel the loading of this file and choose another.</property>
+            <property name="justify">center</property>
+          </object>
+          <packing>
+            <property name="expand">False</property>
+            <property name="fill">False</property>
+            <property name="pack_type">end</property>
+            <property name="position">2</property>
+          </packing>
+        </child>
+      </object>
+      <packing>
+        <property name="page_type">content</property>
+        <property name="title" translatable="yes">Set the default QIF account name</property>
+        <property name="complete">True</property>
+      </packing>
+    </child>
+    <child>
+      <object class="GtkVBox" id="loaded_files_page">
+        <property name="visible">True</property>
+        <property name="can_focus">False</property>
+        <property name="border_width">12</property>
+        <property name="spacing">4</property>
+        <child>
+          <object class="GtkScrolledWindow" id="scrolledwindow26">
+            <property name="visible">True</property>
+            <property name="can_focus">True</property>
+            <property name="hscrollbar_policy">automatic</property>
+            <property name="vscrollbar_policy">automatic</property>
+            <property name="shadow_type">in</property>
+            <child>
+              <object class="GtkTreeView" id="selected_file_view">
+                <property name="visible">True</property>
+                <property name="can_focus">True</property>
+                <property name="headers_visible">False</property>
+                <property name="rules_hint">True</property>
+              </object>
+            </child>
+          </object>
+          <packing>
+            <property name="expand">True</property>
+            <property name="fill">True</property>
+            <property name="position">0</property>
+          </packing>
+        </child>
+        <child>
+          <object class="GtkLabel" id="label816">
+            <property name="visible">True</property>
+            <property name="can_focus">False</property>
+            <property name="label" translatable="yes">Click "Load another file" if you have more data to import at this time. Do this if you have saved your accounts to separate QIF files.
+
+Click "Forward" to finish loading files and move to the next step of the QIF import process. </property>
+            <property name="wrap">True</property>
+          </object>
+          <packing>
+            <property name="expand">False</property>
+            <property name="fill">False</property>
+            <property name="padding">3</property>
+            <property name="position">1</property>
+          </packing>
+        </child>
+        <child>
+          <object class="GtkHButtonBox" id="hbox68">
+            <property name="visible">True</property>
+            <property name="can_focus">False</property>
+            <property name="layout_style">spread</property>
+            <child>
+              <object class="GtkButton" id="unload_file_button">
+                <property name="label" translatable="yes">_Unload selected file</property>
+                <property name="visible">True</property>
+                <property name="can_focus">True</property>
+                <property name="receives_default">True</property>
+                <property name="use_action_appearance">False</property>
+                <property name="use_underline">True</property>
+                <signal name="clicked" handler="gnc_ui_qif_import_unload_file_cb" swapped="no"/>
+              </object>
+              <packing>
+                <property name="expand">False</property>
+                <property name="fill">False</property>
+                <property name="position">0</property>
+              </packing>
+            </child>
+            <child>
+              <object class="GtkButton" id="button69">
+                <property name="label" translatable="yes">_Load another file</property>
+                <property name="visible">True</property>
+                <property name="can_focus">True</property>
+                <property name="receives_default">True</property>
+                <property name="use_action_appearance">False</property>
+                <property name="use_underline">True</property>
+                <signal name="clicked" handler="gnc_ui_qif_import_load_another_cb" swapped="no"/>
+              </object>
+              <packing>
+                <property name="expand">False</property>
+                <property name="fill">False</property>
+                <property name="position">1</property>
+              </packing>
+            </child>
+          </object>
+          <packing>
+            <property name="expand">False</property>
+            <property name="fill">False</property>
+            <property name="position">2</property>
+          </packing>
+        </child>
+      </object>
+      <packing>
+        <property name="title" translatable="yes">QIF files you have loaded</property>
+        <property name="complete">True</property>
+      </packing>
+    </child>
+    <child>
+      <object class="GtkVBox" id="account_doc_page">
+        <property name="visible">True</property>
+        <property name="can_focus">False</property>
+        <property name="border_width">12</property>
+        <child>
+          <object class="GtkLabel" id="label830">
+            <property name="visible">True</property>
+            <property name="can_focus">False</property>
+            <property name="label" translatable="yes">On the next page, the accounts in your QIF files and any stocks or mutual funds you own will be matched with GnuCash accounts. If a GnuCash account already exists with the same name, or a similar name and compatible type, that account will be used as a match; otherwise, GnuCash will create a new account with the same name and type as the QIF account. If you do not like the suggested GnuCash account, double-click to change it.
+
+Note that GnuCash will be creating many accounts that did not exist on your other personal finance program, including a separate account for each stock you own, separate accounts for the brokerage commissions, special "Equity" accounts (subaccounts of Retained Earnings, by default) which are the source of your opening balances, etc. All of these accounts will appear on the next page so you can change them if you want to, but it is safe to leave them alone.
+</property>
+            <property name="wrap">True</property>
+          </object>
+          <packing>
+            <property name="expand">False</property>
+            <property name="fill">False</property>
+            <property name="position">0</property>
+          </packing>
+        </child>
+      </object>
+      <packing>
+        <property name="page_type">content</property>
+        <property name="title" translatable="yes">Accounts and stock holdings</property>
+      </packing>
+    </child>
+    <child>
+      <object class="GtkVBox" id="account_match_page">
+        <property name="visible">True</property>
+        <property name="can_focus">False</property>
+        <property name="border_width">12</property>
+        <child>
+          <object class="GtkLabel" id="label7609">
+            <property name="visible">True</property>
+            <property name="can_focus">False</property>
+            <property name="xalign">0</property>
+            <property name="xpad">5</property>
+            <property name="label" translatable="yes">_Select the matchings you want to change:</property>
+            <property name="use_underline">True</property>
+            <property name="mnemonic_widget">account_page_view</property>
+          </object>
+          <packing>
+            <property name="expand">False</property>
+            <property name="fill">False</property>
+            <property name="padding">5</property>
+            <property name="position">0</property>
+          </packing>
+        </child>
+        <child>
+          <object class="GtkScrolledWindow" id="scrolledwindow11">
+            <property name="visible">True</property>
+            <property name="can_focus">True</property>
+            <property name="hscrollbar_policy">automatic</property>
+            <property name="vscrollbar_policy">automatic</property>
+            <property name="shadow_type">in</property>
+            <child>
+              <object class="GtkTreeView" id="account_page_view">
+                <property name="visible">True</property>
+                <property name="can_focus">True</property>
+                <property name="rules_hint">True</property>
+              </object>
+            </child>
+          </object>
+          <packing>
+            <property name="expand">True</property>
+            <property name="fill">True</property>
+            <property name="position">1</property>
+          </packing>
+        </child>
+        <child>
+          <object class="GtkHBox" id="hbox7609">
+            <property name="visible">True</property>
+            <property name="can_focus">False</property>
+            <child>
+              <object class="GtkLabel" id="label7610">
+                <property name="visible">True</property>
+                <property name="can_focus">False</property>
+                <property name="xalign">0</property>
+                <property name="label" translatable="yes">Matchings selected:</property>
+                <property name="wrap">True</property>
+              </object>
+              <packing>
+                <property name="expand">False</property>
+                <property name="fill">False</property>
+                <property name="position">0</property>
+              </packing>
+            </child>
+            <child>
+              <object class="GtkLabel" id="account_page_count">
+                <property name="visible">True</property>
+                <property name="can_focus">False</property>
+                <property name="xalign">0</property>
+                <property name="label">0</property>
+                <property name="wrap">True</property>
+              </object>
+              <packing>
+                <property name="expand">True</property>
+                <property name="fill">True</property>
+                <property name="padding">3</property>
+                <property name="position">1</property>
+              </packing>
+            </child>
+            <child>
+              <object class="GtkButton" id="account_page_change">
+                <property name="label" translatable="yes">Change GnuCash _Account...</property>
+                <property name="visible">True</property>
+                <property name="sensitive">False</property>
+                <property name="can_focus">True</property>
+                <property name="receives_default">True</property>
+                <property name="use_action_appearance">False</property>
+                <property name="use_underline">True</property>
+                <signal name="clicked" handler="gnc_ui_qif_import_account_rematch_cb" swapped="no"/>
+              </object>
+              <packing>
+                <property name="expand">False</property>
+                <property name="fill">False</property>
+                <property name="position">2</property>
+              </packing>
+            </child>
+          </object>
+          <packing>
+            <property name="expand">False</property>
+            <property name="fill">False</property>
+            <property name="position">2</property>
+          </packing>
+        </child>
+      </object>
+      <packing>
+        <property name="page_type">content</property>
+        <property name="title" translatable="yes">Match QIF accounts with GnuCash accounts</property>
+      </packing>
+    </child>
+    <child>
+      <object class="GtkVBox" id="category_doc_page">
+        <property name="visible">True</property>
+        <property name="can_focus">False</property>
+        <property name="border_width">12</property>
+        <child>
+          <object class="GtkLabel" id="label840">
+            <property name="visible">True</property>
+            <property name="can_focus">False</property>
+            <property name="label" translatable="yes">GnuCash uses separate Income and Expense accounts rather than categories to classify your transactions. Each of the categories in your QIF file will be converted to a GnuCash account. 
+
+On the next page, you will have an opportunity to look at the suggested matches between QIF categories and GnuCash accounts. You may change matches that you do not like by double-clicking on the line containing the category name.
+
+If you change your mind later, you can reorganize the account structure safely within GnuCash.</property>
+            <property name="wrap">True</property>
+          </object>
+          <packing>
+            <property name="expand">False</property>
+            <property name="fill">False</property>
+            <property name="position">0</property>
+          </packing>
+        </child>
+      </object>
+      <packing>
+        <property name="page_type">content</property>
+        <property name="title" translatable="yes">Income and Expense categories</property>
+      </packing>
+    </child>
+    <child>
+      <object class="GtkVBox" id="category_match_page">
+        <property name="visible">True</property>
+        <property name="can_focus">False</property>
+        <property name="border_width">12</property>
+        <child>
+          <object class="GtkLabel" id="label7611">
+            <property name="visible">True</property>
+            <property name="can_focus">False</property>
+            <property name="xalign">0</property>
+            <property name="xpad">5</property>
+            <property name="label" translatable="yes">_Select the matchings you want to change:</property>
+            <property name="use_underline">True</property>
+            <property name="mnemonic_widget">category_page_view</property>
+          </object>
+          <packing>
+            <property name="expand">False</property>
+            <property name="fill">False</property>
+            <property name="padding">5</property>
+            <property name="position">0</property>
+          </packing>
+        </child>
+        <child>
+          <object class="GtkScrolledWindow" id="scrolledwindow12">
+            <property name="visible">True</property>
+            <property name="can_focus">True</property>
+            <property name="hscrollbar_policy">automatic</property>
+            <property name="vscrollbar_policy">automatic</property>
+            <property name="shadow_type">in</property>
+            <child>
+              <object class="GtkTreeView" id="category_page_view">
+                <property name="visible">True</property>
+                <property name="can_focus">True</property>
+                <property name="rules_hint">True</property>
+              </object>
+            </child>
+          </object>
+          <packing>
+            <property name="expand">True</property>
+            <property name="fill">True</property>
+            <property name="position">1</property>
+          </packing>
+        </child>
+        <child>
+          <object class="GtkHBox" id="hbox7612">
+            <property name="visible">True</property>
+            <property name="can_focus">False</property>
+            <child>
+              <object class="GtkLabel" id="label7613">
+                <property name="visible">True</property>
+                <property name="can_focus">False</property>
+                <property name="xalign">0</property>
+                <property name="label" translatable="yes">Matchings selected:</property>
+                <property name="wrap">True</property>
+              </object>
+              <packing>
+                <property name="expand">False</property>
+                <property name="fill">False</property>
+                <property name="position">0</property>
+              </packing>
+            </child>
+            <child>
+              <object class="GtkLabel" id="category_page_count">
+                <property name="visible">True</property>
+                <property name="can_focus">False</property>
+                <property name="xalign">0</property>
+                <property name="label">0</property>
+                <property name="wrap">True</property>
+              </object>
+              <packing>
+                <property name="expand">True</property>
+                <property name="fill">True</property>
+                <property name="padding">3</property>
+                <property name="position">1</property>
+              </packing>
+            </child>
+            <child>
+              <object class="GtkButton" id="category_page_change">
+                <property name="label" translatable="yes">Change GnuCash _Account...</property>
+                <property name="visible">True</property>
+                <property name="sensitive">False</property>
+                <property name="can_focus">True</property>
+                <property name="receives_default">True</property>
+                <property name="use_action_appearance">False</property>
+                <property name="use_underline">True</property>
+                <signal name="clicked" handler="gnc_ui_qif_import_category_rematch_cb" swapped="no"/>
+              </object>
+              <packing>
+                <property name="expand">False</property>
+                <property name="fill">False</property>
+                <property name="position">2</property>
+              </packing>
+            </child>
+          </object>
+          <packing>
+            <property name="expand">False</property>
+            <property name="fill">False</property>
+            <property name="position">2</property>
+          </packing>
+        </child>
+      </object>
+      <packing>
+        <property name="page_type">content</property>
+        <property name="title" translatable="yes">Match QIF categories with GnuCash accounts</property>
+      </packing>
+    </child>
+    <child>
+      <object class="GtkVBox" id="memo_doc_page">
+        <property name="visible">True</property>
+        <property name="can_focus">False</property>
+        <property name="border_width">12</property>
+        <child>
+          <object class="GtkLabel" id="label847707">
+            <property name="visible">True</property>
+            <property name="can_focus">False</property>
+            <property name="label" translatable="yes">QIF files downloaded from banks and other financial institutions may not have information about Accounts and Categories which would allow them to be correctly assigned to GnuCash accounts. 
+
+In the following page, you will see the text that appears in the Payee and Memo fields of transactions with no QIF Account or Category. By default these transactions are assigned to the 'Unspecified' account in GnuCash. If you select a different account, it will be remembered for future QIF files. </property>
+            <property name="wrap">True</property>
+          </object>
+          <packing>
+            <property name="expand">False</property>
+            <property name="fill">False</property>
+            <property name="position">0</property>
+          </packing>
+        </child>
+      </object>
+      <packing>
+        <property name="page_type">content</property>
+        <property name="title" translatable="yes">Payees and memos</property>
+      </packing>
+    </child>
+    <child>
+      <object class="GtkVBox" id="memo_match_page">
+        <property name="visible">True</property>
+        <property name="can_focus">False</property>
+        <property name="border_width">12</property>
+        <child>
+          <object class="GtkLabel" id="label7614">
+            <property name="visible">True</property>
+            <property name="can_focus">False</property>
+            <property name="xalign">0</property>
+            <property name="xpad">5</property>
+            <property name="label" translatable="yes">_Select the matchings you want to change:</property>
+            <property name="use_underline">True</property>
+            <property name="mnemonic_widget">memo_page_view</property>
+          </object>
+          <packing>
+            <property name="expand">False</property>
+            <property name="fill">False</property>
+            <property name="padding">5</property>
+            <property name="position">0</property>
+          </packing>
+        </child>
+        <child>
+          <object class="GtkScrolledWindow" id="scrolledwindow1">
+            <property name="visible">True</property>
+            <property name="can_focus">True</property>
+            <property name="hscrollbar_policy">automatic</property>
+            <property name="vscrollbar_policy">automatic</property>
+            <property name="shadow_type">in</property>
+            <child>
+              <object class="GtkTreeView" id="memo_page_view">
+                <property name="visible">True</property>
+                <property name="can_focus">True</property>
+                <property name="rules_hint">True</property>
+              </object>
+            </child>
+          </object>
+          <packing>
+            <property name="expand">True</property>
+            <property name="fill">True</property>
+            <property name="position">1</property>
+          </packing>
+        </child>
+        <child>
+          <object class="GtkHBox" id="hbox7615">
+            <property name="visible">True</property>
+            <property name="can_focus">False</property>
+            <child>
+              <object class="GtkLabel" id="label7616">
+                <property name="visible">True</property>
+                <property name="can_focus">False</property>
+                <property name="xalign">0</property>
+                <property name="label" translatable="yes">Matchings selected:</property>
+                <property name="wrap">True</property>
+              </object>
+              <packing>
+                <property name="expand">False</property>
+                <property name="fill">False</property>
+                <property name="position">0</property>
+              </packing>
+            </child>
+            <child>
+              <object class="GtkLabel" id="memo_page_count">
+                <property name="visible">True</property>
+                <property name="can_focus">False</property>
+                <property name="xalign">0</property>
+                <property name="label">0</property>
+                <property name="wrap">True</property>
+              </object>
+              <packing>
+                <property name="expand">True</property>
+                <property name="fill">True</property>
+                <property name="padding">3</property>
+                <property name="position">1</property>
+              </packing>
+            </child>
+            <child>
+              <object class="GtkButton" id="memo_page_change">
+                <property name="label" translatable="yes">Change GnuCash _Account...</property>
+                <property name="visible">True</property>
+                <property name="sensitive">False</property>
+                <property name="can_focus">True</property>
+                <property name="receives_default">True</property>
+                <property name="use_action_appearance">False</property>
+                <property name="use_underline">True</property>
+                <signal name="clicked" handler="gnc_ui_qif_import_memo_rematch_cb" swapped="no"/>
+              </object>
+              <packing>
+                <property name="expand">False</property>
+                <property name="fill">False</property>
+                <property name="position">2</property>
+              </packing>
+            </child>
+          </object>
+          <packing>
+            <property name="expand">False</property>
+            <property name="fill">False</property>
+            <property name="position">2</property>
+          </packing>
+        </child>
+      </object>
+      <packing>
+        <property name="page_type">content</property>
+        <property name="title" translatable="yes">Match payees/memos to GnuCash accounts</property>
+      </packing>
+    </child>
+    <child>
+      <object class="GtkVBox" id="currency_book_option_page">
+        <property name="visible">True</property>
+        <property name="can_focus">False</property>
+        <property name="border_width">12</property>
+        <child>
+          <object class="GtkLabel" id="label831">
+            <property name="visible">True</property>
+            <property name="can_focus">False</property>
+            <property name="yalign">0</property>
+            <property name="label" translatable="yes">The QIF importer cannot currently handle multi-currency QIF files. All the accounts you are importing must be denominated in the same currency.
+</property>
+            <property name="justify">center</property>
+            <property name="wrap">True</property>
+          </object>
+          <packing>
+            <property name="expand">False</property>
+            <property name="fill">False</property>
+            <property name="position">0</property>
+          </packing>
+        </child>
+        <child>
+          <object class="GtkLabel" id="label832">
+            <property name="visible">True</property>
+            <property name="can_focus">False</property>
+            <property name="xalign">0</property>
+            <property name="yalign">0</property>
+            <property name="xpad">4</property>
+            <property name="label" translatable="yes">_Select the currency to use for all imported transactions:</property>
+            <property name="use_underline">True</property>
+          </object>
+          <packing>
+            <property name="expand">False</property>
+            <property name="fill">False</property>
+            <property name="padding">5</property>
+            <property name="position">1</property>
+          </packing>
+        </child>
+        <child>
+          <object class="GtkHBox" id="currency_picker_hbox">
+            <property name="visible">True</property>
+            <property name="can_focus">False</property>
+            <child>
+              <placeholder/>
+            </child>
+          </object>
+          <packing>
+            <property name="expand">False</property>
+            <property name="fill">False</property>
+            <property name="position">2</property>
+          </packing>
+        </child>
+        <child>
+          <object class="GtkLabel" id="book_option_label">
+            <property name="visible">True</property>
+            <property name="can_focus">False</property>
+            <property name="label" translatable="yes"><b>Book Options</b></property>
+            <property name="use_markup">True</property>
+          </object>
+          <packing>
+            <property name="expand">False</property>
+            <property name="fill">False</property>
+            <property name="position">3</property>
+          </packing>
+        </child>
+        <child>
+          <object class="GtkLabel" id="book_option_message_label">
+            <property name="visible">True</property>
+            <property name="can_focus">False</property>
+            <property name="label" translatable="yes">Since you are creating a new file, you will next see a dialog for setting book options. These can affect how GnuCash imports transactions. If you come back to this page without cancelling and starting over, the dialog for setting book options will not be shown a second time when you go forward. You can access it directly from the menu via File->Properties.</property>
+            <property name="wrap">True</property>
+          </object>
+          <packing>
+            <property name="expand">False</property>
+            <property name="fill">False</property>
+            <property name="position">4</property>
+          </packing>
+        </child>
+      </object>
+      <packing>
+        <property name="title" translatable="yes">Choose the QIF file currency and select Book Options</property>
+      </packing>
+    </child>
+    <child>
+      <object class="GtkVBox" id="commodity_doc_page">
+        <property name="visible">True</property>
+        <property name="can_focus">False</property>
+        <property name="border_width">12</property>
+        <child>
+          <object class="GtkLabel" id="label833">
+            <property name="visible">True</property>
+            <property name="can_focus">False</property>
+            <property name="label" translatable="yes">In the following pages you will be asked to provide information about stocks, mutual funds, and other investments that appear in the QIF file(s) you are importing. GnuCash needs some additional details about these investments that the QIF format does not provide. 
+
+Each stock, mutual fund, or other investment must have a name and an abbreviation, such as a stock symbol. Because some unrelated investments have the same abbreviation, you also need to indicate what type of abbreviation you have entered. For example, you could select the exchange that assigned the symbol (NASDAQ, NYSE, etc.), or select an investment type.
+
+If you don't see your exchange listed, or none of the available choices are appropriate, you can enter a new one.</property>
+            <property name="wrap">True</property>
+          </object>
+          <packing>
+            <property name="expand">False</property>
+            <property name="fill">False</property>
+            <property name="position">0</property>
+          </packing>
+        </child>
+      </object>
+      <packing>
+        <property name="page_type">content</property>
+        <property name="title" translatable="yes">Tradable commodities</property>
+      </packing>
+    </child>
+    <child>
+      <object class="GtkVBox" id="convert_content_page">
+        <property name="visible">True</property>
+        <property name="can_focus">False</property>
+        <property name="border_width">12</property>
+        <property name="spacing">12</property>
+        <child>
+          <object class="GtkLabel" id="convert_progress_primary">
+            <property name="visible">True</property>
+            <property name="can_focus">False</property>
+            <property name="label"><span weight="bold" size="larger">Primary text</span></property>
+            <property name="use_markup">True</property>
+            <property name="wrap">True</property>
+          </object>
+          <packing>
+            <property name="expand">False</property>
+            <property name="fill">False</property>
+            <property name="position">0</property>
+          </packing>
+        </child>
+        <child>
+          <object class="GtkLabel" id="convert_progress_secondary">
+            <property name="visible">True</property>
+            <property name="can_focus">False</property>
+            <property name="label">Secondary text.</property>
+            <property name="wrap">True</property>
+          </object>
+          <packing>
+            <property name="expand">False</property>
+            <property name="fill">False</property>
+            <property name="position">1</property>
+          </packing>
+        </child>
+        <child>
+          <object class="GtkVBox" id="convert_progress_vbox1">
+            <property name="visible">True</property>
+            <property name="can_focus">False</property>
+            <child>
+              <object class="GtkProgressBar" id="convert_progress_bar">
+                <property name="visible">True</property>
+                <property name="can_focus">False</property>
+                <property name="pulse_step">0.10000000149</property>
+              </object>
+              <packing>
+                <property name="expand">False</property>
+                <property name="fill">False</property>
+                <property name="position">0</property>
+              </packing>
+            </child>
+            <child>
+              <object class="GtkLabel" id="convert_progress_sub">
+                <property name="visible">True</property>
+                <property name="can_focus">False</property>
+                <property name="xalign">0</property>
+                <property name="label"><span style="italic">Sub-operation text</span></property>
+                <property name="use_markup">True</property>
+                <property name="wrap">True</property>
+              </object>
+              <packing>
+                <property name="expand">False</property>
+                <property name="fill">False</property>
+                <property name="position">1</property>
+              </packing>
+            </child>
+            <child>
+              <object class="GtkHButtonBox" id="convert_progress_hbuttonbox1">
+                <property name="visible">True</property>
+                <property name="can_focus">False</property>
+                <property name="layout_style">end</property>
+                <child>
+                  <object class="GtkButton" id="convert_progress_start">
+                    <property name="label" translatable="yes">_Start Import</property>
+                    <property name="visible">True</property>
+                    <property name="can_focus">True</property>
+                    <property name="receives_default">True</property>
+                    <property name="use_action_appearance">False</property>
+                    <property name="use_underline">True</property>
+                    <signal name="clicked" handler="gnc_ui_qif_import_convert_progress_start_cb" swapped="no"/>
+                  </object>
+                  <packing>
+                    <property name="expand">False</property>
+                    <property name="fill">False</property>
+                    <property name="position">0</property>
+                  </packing>
+                </child>
+                <child>
+                  <object class="GtkButton" id="convert_progress_pause">
+                    <property name="label">gtk-media-pause</property>
+                    <property name="visible">True</property>
+                    <property name="can_focus">True</property>
+                    <property name="can_default">True</property>
+                    <property name="receives_default">True</property>
+                    <property name="use_action_appearance">False</property>
+                    <property name="use_stock">True</property>
+                    <signal name="clicked" handler="gnc_ui_qif_import_convert_progress_pause_cb" swapped="no"/>
+                  </object>
+                  <packing>
+                    <property name="expand">False</property>
+                    <property name="fill">False</property>
+                    <property name="position">1</property>
+                  </packing>
+                </child>
+              </object>
+              <packing>
+                <property name="expand">False</property>
+                <property name="fill">False</property>
+                <property name="position">2</property>
+              </packing>
+            </child>
+          </object>
+          <packing>
+            <property name="expand">False</property>
+            <property name="fill">False</property>
+            <property name="padding">6</property>
+            <property name="position">2</property>
+          </packing>
+        </child>
+        <child>
+          <object class="GtkScrolledWindow" id="scrolledwindow2">
+            <property name="visible">True</property>
+            <property name="can_focus">True</property>
+            <property name="hscrollbar_policy">automatic</property>
+            <property name="vscrollbar_policy">automatic</property>
+            <property name="shadow_type">in</property>
+            <child>
+              <object class="GtkTextView" id="convert_progress_log">
+                <property name="visible">True</property>
+                <property name="can_focus">True</property>
+                <property name="editable">False</property>
+                <property name="wrap_mode">word</property>
+                <property name="cursor_visible">False</property>
+                <property name="accepts_tab">False</property>
+              </object>
+            </child>
+          </object>
+          <packing>
+            <property name="expand">True</property>
+            <property name="fill">True</property>
+            <property name="position">3</property>
+          </packing>
+        </child>
+      </object>
+      <packing>
+        <property name="title" translatable="yes">QIF Import</property>
+      </packing>
+    </child>
+    <child>
+      <object class="GtkVBox" id="duplicates_doc_page">
+        <property name="visible">True</property>
+        <property name="can_focus">False</property>
+        <property name="border_width">5</property>
+        <child>
+          <object class="GtkLabel" id="label847694">
+            <property name="visible">True</property>
+            <property name="can_focus">False</property>
+            <property name="label" translatable="yes">
+If you are importing a QIF file from a bank or other financial institution, some of the transactions may already exist in your GnuCash accounts. To avoid duplication, GnuCash has tried to identify matches and needs your help to review them.
+
+On the next page you will be shown a list of imported transactions. As you select each one, a list of possible matches will be shown below it. If you find a correct match, click on it. Your selection will be confirmed by a check mark in the "Match?" column.
+
+Click "Forward" to review the possible matches.</property>
+            <property name="wrap">True</property>
+          </object>
+          <packing>
+            <property name="expand">False</property>
+            <property name="fill">False</property>
+            <property name="position">0</property>
+          </packing>
+        </child>
+      </object>
+      <packing>
+        <property name="page_type">content</property>
+        <property name="title" translatable="yes">Match existing transactions</property>
+      </packing>
+    </child>
+    <child>
+      <object class="GtkVBox" id="duplicates_match_page">
+        <property name="visible">True</property>
+        <property name="can_focus">False</property>
+        <property name="border_width">12</property>
+        <child>
+          <object class="GtkVBox" id="vbox94">
+            <property name="visible">True</property>
+            <property name="can_focus">False</property>
+            <property name="spacing">2</property>
+            <child>
+              <object class="GtkFrame" id="frame45">
+                <property name="visible">True</property>
+                <property name="can_focus">False</property>
+                <property name="label_xalign">0</property>
+                <property name="shadow_type">none</property>
+                <child>
+                  <object class="GtkScrolledWindow" id="scrolledwindow22">
+                    <property name="visible">True</property>
+                    <property name="can_focus">True</property>
+                    <property name="hscrollbar_policy">automatic</property>
+                    <property name="vscrollbar_policy">automatic</property>
+                    <property name="shadow_type">in</property>
+                    <child>
+                      <object class="GtkTreeView" id="new_transaction_view">
+                        <property name="visible">True</property>
+                        <property name="can_focus">True</property>
+                        <property name="rules_hint">True</property>
+                      </object>
+                    </child>
+                  </object>
+                </child>
+                <child type="label">
+                  <object class="GtkLabel" id="label847716">
+                    <property name="visible">True</property>
+                    <property name="can_focus">False</property>
+                    <property name="label" translatable="yes">_Imported transactions needing review:</property>
+                    <property name="use_underline">True</property>
+                    <property name="mnemonic_widget">new_transaction_view</property>
+                  </object>
+                </child>
+              </object>
+              <packing>
+                <property name="expand">True</property>
+                <property name="fill">True</property>
+                <property name="position">0</property>
+              </packing>
+            </child>
+            <child>
+              <object class="GtkFrame" id="frame46">
+                <property name="visible">True</property>
+                <property name="can_focus">False</property>
+                <property name="label_xalign">0</property>
+                <property name="shadow_type">none</property>
+                <child>
+                  <object class="GtkScrolledWindow" id="scrolledwindow23">
+                    <property name="visible">True</property>
+                    <property name="can_focus">True</property>
+                    <property name="hscrollbar_policy">automatic</property>
+                    <property name="vscrollbar_policy">automatic</property>
+                    <property name="shadow_type">in</property>
+                    <child>
+                      <object class="GtkTreeView" id="old_transaction_view">
+                        <property name="visible">True</property>
+                        <property name="can_focus">True</property>
+                        <property name="rules_hint">True</property>
+                      </object>
+                    </child>
+                  </object>
+                </child>
+                <child type="label">
+                  <object class="GtkLabel" id="label847717">
+                    <property name="visible">True</property>
+                    <property name="can_focus">False</property>
+                    <property name="label" translatable="yes">_Possible matches for the selected transaction:</property>
+                    <property name="use_underline">True</property>
+                    <property name="mnemonic_widget">old_transaction_view</property>
+                  </object>
+                </child>
+              </object>
+              <packing>
+                <property name="expand">True</property>
+                <property name="fill">True</property>
+                <property name="position">1</property>
+              </packing>
+            </child>
+          </object>
+          <packing>
+            <property name="expand">True</property>
+            <property name="fill">True</property>
+            <property name="position">0</property>
+          </packing>
+        </child>
+      </object>
+      <packing>
+        <property name="page_type">content</property>
+        <property name="title" translatable="yes">Select possible duplicates</property>
+      </packing>
+    </child>
+    <child>
+      <object class="GtkLabel" id="end_page">
+        <property name="visible">True</property>
+        <property name="can_focus">False</property>
+        <property name="label" translatable="yes">Click "Apply" to import data from the staging area and update your GnuCash accounts. The account and category matching information you have entered will be saved and used for defaults the next time you use the QIF import facility. 
+
+Click "Back" to review your account and category matchings, to change currency and security settings for new accounts, or to add more files to the staging area.
+
+Click "Cancel" to abort the QIF import process.</property>
+        <property name="wrap">True</property>
+      </object>
+      <packing>
+        <property name="page_type">confirm</property>
+        <property name="title" translatable="yes">Update your GnuCash accounts</property>
+      </packing>
+    </child>
+    <child>
+      <object class="GtkLabel" id="summary_page">
+        <property name="visible">True</property>
+        <property name="can_focus">False</property>
+        <property name="label" translatable="yes">Summary Text</property>
+        <property name="use_markup">True</property>
+      </object>
+      <packing>
+        <property name="page_type">summary</property>
+        <property name="title" translatable="yes">Qif Import Summary</property>
+        <property name="complete">True</property>
+      </packing>
+    </child>
+  </object>
+  <object class="GtkListStore" id="currency_liststore">
+    <columns>
+      <!-- column-name item -->
+      <column type="gchararray"/>
+    </columns>
+    <data>
+      <row>
+        <col id="0" translatable="yes">Dummy</col>
+      </row>
+    </data>
+  </object>
+  <object class="GtkListStore" id="date_format_liststore">
+    <columns>
+      <!-- column-name item -->
+      <column type="gchararray"/>
+    </columns>
+    <data>
+      <row>
+        <col id="0" translatable="yes">Dummy</col>
+      </row>
+    </data>
+  </object>
+</interface>

Copied: gnucash/trunk/src/import-export/qif-imp/assistant-qif-import.h (from rev 23566, gnucash/trunk/src/import-export/qif-import/assistant-qif-import.h)
===================================================================
--- gnucash/trunk/src/import-export/qif-imp/assistant-qif-import.h	                        (rev 0)
+++ gnucash/trunk/src/import-export/qif-imp/assistant-qif-import.h	2013-12-15 17:21:20 UTC (rev 23567)
@@ -0,0 +1,45 @@
+/********************************************************************\
+ * assistant-qif-import.h -- window for import of QIF data          *
+ *                       (GnuCash)                                  *
+ * Copyright (C) 2000 Bill Gribble <grib at billgribble.com>           *
+ * Copyright (c) 2011 Robert Fewell                                 *
+ *                                                                  *
+ * This program is free software; you can redistribute it and/or    *
+ * modify it under the terms of the GNU General Public License as   *
+ * published by the Free Software Foundation; either version 2 of   *
+ * the License, or (at your option) any later version.              *
+ *                                                                  *
+ * This program is distributed in the hope that it will be useful,  *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of   *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the    *
+ * GNU General Public License for more details.                     *
+ *                                                                  *
+ * You should have received a copy of the GNU General Public License*
+ * along with this program; if not, contact:                        *
+ *                                                                  *
+ * Free Software Foundation           Voice:  +1-617-542-5942       *
+ * 51 Franklin Street, Fifth Floor    Fax:    +1-617-542-2652       *
+ * Boston, MA  02110-1301,  USA       gnu at gnu.org                   *
+\********************************************************************/
+
+#ifndef ASSISTANT_QIF_IMPORT_H
+#define ASSISTANT_QIF_IMPORT_H
+
+#include <libguile.h>
+#include <gtk/gtk.h>
+
+/* QIF Import Windows ***********************************************/
+
+typedef struct _qifimportwindow QIFImportWindow;
+
+SCM               gnc_ui_qif_import_assistant_get_mappings(QIFImportWindow * w);
+
+/* The gnc_file_qif_import() routine will pop up a standard file
+ *     selection dialogue asking the user to pick a QIF file. If one
+ *     is selected then the QIF file is opened and read. It's contents
+ *     are merged into the existing session (if any). The current
+ *     session continues to remain open for editing. */
+void              gnc_file_qif_import (void);
+void              gnc_ui_qif_import_create_plugin(void);
+
+#endif

Copied: gnucash/trunk/src/import-export/qif-imp/dialog-account-picker.c (from rev 23566, gnucash/trunk/src/import-export/qif-import/dialog-account-picker.c)
===================================================================
--- gnucash/trunk/src/import-export/qif-imp/dialog-account-picker.c	                        (rev 0)
+++ gnucash/trunk/src/import-export/qif-imp/dialog-account-picker.c	2013-12-15 17:21:20 UTC (rev 23567)
@@ -0,0 +1,424 @@
+/********************************************************************\
+ * dialog-account-picker.c -- window for picking a Gnucash account  *
+ * from the QIF importer.                                           *
+ * Copyright (C) 2000-2001 Bill Gribble <grib at billgribble.com>      *
+ * Copyright (c) 2006 David Hampton <hampton at employees.org>         *
+ *                                                                  *
+ * This program is free software; you can redistribute it and/or    *
+ * modify it under the terms of the GNU General Public License as   *
+ * published by the Free Software Foundation; either version 2 of   *
+ * the License, or (at your option) any later version.              *
+ *                                                                  *
+ * This program is distributed in the hope that it will be useful,  *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of   *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the    *
+ * GNU General Public License for more details.                     *
+ *                                                                  *
+ * You should have received a copy of the GNU General Public License*
+ * along with this program; if not, contact:                        *
+ *                                                                  *
+ * Free Software Foundation           Voice:  +1-617-542-5942       *
+ * 51 Franklin Street, Fifth Floor    Fax:    +1-617-542-2652       *
+ * Boston, MA  02110-1301,  USA       gnu at gnu.org                   *
+\********************************************************************/
+
+#include "config.h"
+
+#include <gtk/gtk.h>
+#include <glib/gi18n.h>
+#include <stdio.h>
+#include <libguile.h>
+
+#include "dialog-account-picker.h"
+#include "dialog-utils.h"
+#include "assistant-qif-import.h"
+#include "gnc-gui-query.h"
+#include "gnc-ui-util.h"
+#include "guile-mappings.h"
+#include "gnc-guile-utils.h"
+#include "gnc-ui.h" /* for GNC_RESPONSE_NEW */
+
+enum account_cols
+{
+    ACCOUNT_COL_NAME = 0,
+    ACCOUNT_COL_FULLNAME,
+    ACCOUNT_COL_CHECK,
+    NUM_ACCOUNT_COLS
+};
+
+struct _accountpickerdialog
+{
+    GtkWidget       * dialog;
+    GtkTreeView     * treeview;
+    QIFImportWindow * qif_wind;
+    SCM             map_entry;
+    gchar           * selected_name;
+};
+
+void gnc_ui_qif_account_picker_new_cb (GtkButton * w, gpointer user_data);
+
+/****************************************************************
+ * acct_tree_add_accts
+ *
+ * Given a Scheme list of accounts, this function populates a
+ * GtkTreeStore from them. If the search_name and reference
+ * parameters are provided, and an account is found whose full
+ * name matches search_name, then a GtkTreeRowReference* will be
+ * returned in the reference parameter.
+ ****************************************************************/
+static void
+acct_tree_add_accts(SCM accts,
+                    GtkTreeStore *store,
+                    GtkTreeIter *parent,
+                    const char *base_name,
+                    const char *search_name,
+                    GtkTreeRowReference **reference)
+{
+    GtkTreeIter  iter;
+    char         * compname;
+    char         * acctname;
+    gboolean     leafnode;
+    SCM          current;
+    gboolean     checked;
+
+    while (!scm_is_null(accts))
+    {
+        current = SCM_CAR(accts);
+
+        if (scm_is_null(current))
+        {
+            g_critical("QIF import: BUG DETECTED in acct_tree_add_accts!");
+            accts = SCM_CDR(accts);
+            continue;
+        }
+
+        if (scm_is_string(SCM_CAR(current)))
+            compname = gnc_scm_to_utf8_string (SCM_CAR(current));
+        else
+            compname = g_strdup("");
+
+        if (!scm_is_null(SCM_CADDR(current)))
+        {
+            leafnode = FALSE;
+        }
+        else
+        {
+            leafnode = TRUE;
+        }
+
+        /* compute full name */
+        if (base_name && *base_name)
+        {
+            acctname = g_strjoin(gnc_get_account_separator_string(),
+                                 base_name, compname, (char *)NULL);
+        }
+        else
+        {
+            acctname = g_strdup(compname);
+        }
+
+        checked = (SCM_CADR(current) == SCM_BOOL_T);
+
+        gtk_tree_store_append(store, &iter, parent);
+        gtk_tree_store_set(store, &iter,
+                           ACCOUNT_COL_NAME, compname,
+                           ACCOUNT_COL_FULLNAME, acctname,
+                           ACCOUNT_COL_CHECK, checked,
+                           -1);
+
+        if (reference && !*reference &&
+                search_name && (g_utf8_collate(search_name, acctname) == 0))
+        {
+            GtkTreePath *path = gtk_tree_model_get_path(GTK_TREE_MODEL(store), &iter);
+            *reference = gtk_tree_row_reference_new(GTK_TREE_MODEL(store), path);
+            gtk_tree_path_free(path);
+        }
+
+        if (!leafnode)
+        {
+            acct_tree_add_accts(SCM_CADDR(current), store, &iter, acctname,
+                                search_name, reference);
+        }
+
+        g_free(acctname);
+        g_free(compname);
+
+        accts = SCM_CDR(accts);
+    }
+}
+
+
+/****************************************************************
+ * build_acct_tree
+ *
+ * This function refreshes the contents of the account tree.
+ ****************************************************************/
+static void
+build_acct_tree(QIFAccountPickerDialog * picker, QIFImportWindow * import)
+{
+    SCM  get_accts = scm_c_eval_string("qif-import:get-all-accts");
+    SCM  acct_tree;
+    GtkTreeStore *store;
+    GtkTreePath *path;
+    GtkTreeSelection* selection;
+    GtkTreeRowReference *reference = NULL;
+    gchar *name_to_select;
+
+    g_return_if_fail(picker && import);
+
+    /* Get an account tree with all existing and to-be-imported accounts. */
+    acct_tree = scm_call_1(get_accts,
+                           gnc_ui_qif_import_assistant_get_mappings(import));
+
+    /* Rebuild the store.
+     * NOTE: It is necessary to save a copy of the name to select, because
+     *       when the store is cleared, everything becomes unselected. */
+    name_to_select = g_strdup(picker->selected_name);
+    store = GTK_TREE_STORE(gtk_tree_view_get_model(picker->treeview));
+    gtk_tree_store_clear(store);
+    acct_tree_add_accts(acct_tree, store, NULL, NULL, name_to_select, &reference);
+    g_free(name_to_select);
+
+    /* Select and display the indicated account (if it was found). */
+    if (reference)
+    {
+        selection = gtk_tree_view_get_selection(picker->treeview);
+        path = gtk_tree_row_reference_get_path(reference);
+        if (path)
+        {
+            gtk_tree_view_expand_to_path(picker->treeview, path);
+            gtk_tree_selection_select_path(selection, path);
+            gtk_tree_path_free(path);
+        }
+        gtk_tree_row_reference_free(reference);
+    }
+}
+
+
+/****************************************************************
+ * gnc_ui_qif_account_picker_new_cb
+ *
+ * This handler is invoked when the user wishes to create a new
+ * account.
+ ****************************************************************/
+void
+gnc_ui_qif_account_picker_new_cb(GtkButton * w, gpointer user_data)
+{
+    QIFAccountPickerDialog * wind = user_data;
+    SCM name_setter = scm_c_eval_string("qif-map-entry:set-gnc-name!");
+    const gchar *name;
+    int response;
+    gchar *fullname;
+    GtkWidget *dlg, *entry;
+
+    /* Create a dialog to get the new account name. */
+    dlg = gtk_message_dialog_new(GTK_WINDOW(wind->dialog),
+                                 GTK_DIALOG_DESTROY_WITH_PARENT,
+                                 GTK_MESSAGE_QUESTION,
+                                 GTK_BUTTONS_OK_CANCEL,
+                                 "%s", _("Enter a name for the account"));
+    gtk_dialog_set_default_response(GTK_DIALOG(dlg), GTK_RESPONSE_OK);
+    entry = gtk_entry_new();
+    gtk_entry_set_activates_default(GTK_ENTRY(entry), TRUE);
+    gtk_entry_set_max_length(GTK_ENTRY(entry), 250);
+    gtk_widget_show(entry);
+    gtk_container_add(GTK_CONTAINER(GTK_DIALOG(dlg)->vbox), entry);
+
+    /* Run the dialog to get the new account name. */
+    response = gtk_dialog_run(GTK_DIALOG(dlg));
+    name = gtk_entry_get_text(GTK_ENTRY(entry));
+
+    /* Did the user enter a name and click OK? */
+    if (response == GTK_RESPONSE_OK && name && *name)
+    {
+        /* If an account is selected, this will be a new subaccount. */
+        if (wind->selected_name && *(wind->selected_name))
+            /* We have the short name; determine the full name. */
+            fullname = g_strjoin(gnc_get_account_separator_string(),
+                                 wind->selected_name, name, (char *)NULL);
+        else
+            fullname = g_strdup(name);
+
+        /* Save the full name and update the map entry. */
+        g_free(wind->selected_name);
+        wind->selected_name = fullname;
+        scm_call_2(name_setter, wind->map_entry, scm_from_utf8_string(fullname));
+    }
+    gtk_widget_destroy(dlg);
+
+    /* Refresh the tree display and give it the focus. */
+    build_acct_tree(wind, wind->qif_wind);
+    gtk_widget_grab_focus(GTK_WIDGET(wind->treeview));
+}
+
+
+/****************************************************************
+ * gnc_ui_qif_account_picker_changed_cb
+ *
+ ****************************************************************/
+static void
+gnc_ui_qif_account_picker_changed_cb(GtkTreeSelection *selection,
+                                     gpointer          user_data)
+{
+    QIFAccountPickerDialog * wind = user_data;
+    SCM name_setter = scm_c_eval_string("qif-map-entry:set-gnc-name!");
+    GtkTreeModel *model;
+    GtkTreeIter iter;
+
+    g_free(wind->selected_name);
+    if (gtk_tree_selection_get_selected(selection, &model, &iter))
+    {
+        gtk_tree_model_get(model, &iter,
+                           ACCOUNT_COL_FULLNAME, &wind->selected_name,
+                           -1);
+        scm_call_2(name_setter, wind->map_entry,
+                   wind->selected_name ? scm_from_utf8_string(wind->selected_name) : SCM_BOOL_F);
+    }
+    else
+    {
+        wind->selected_name = NULL;
+    }
+}
+
+
+/****************************************************************
+ * gnc_ui_qif_account_picker_row_activated_cb
+ *
+ ****************************************************************/
+static void
+gnc_ui_qif_account_picker_row_activated_cb(GtkTreeView *view,
+        GtkTreePath *path,
+        GtkTreeViewColumn *column,
+        gpointer user_data)
+{
+    QIFAccountPickerDialog *wind = user_data;
+    g_return_if_fail(wind);
+
+    gtk_dialog_response(GTK_DIALOG(wind->dialog), GTK_RESPONSE_OK);
+}
+
+
+/****************************************************************
+ * gnc_ui_qif_account_picker_map_cb
+ *
+ ****************************************************************/
+static int
+gnc_ui_qif_account_picker_map_cb(GtkWidget * w, gpointer user_data)
+{
+    QIFAccountPickerDialog * wind = user_data;
+
+    /* update the tree display with all the existing accounts plus all
+     * the ones the QIF importer thinks it will be creating.  this will
+     * also select the map_entry line. */
+    build_acct_tree(wind, wind->qif_wind);
+    return FALSE;
+}
+
+
+/****************************************************************
+ * qif_account_picker_dialog
+ *
+ * Select an account from the ones that the engine knows about,
+ * plus those that will be created by the QIF import.  If the
+ * user clicks OK, map_entry is changed and TRUE is returned.
+ * If the clicks Cancel instead, FALSE is returned. Modal.
+ ****************************************************************/
+gboolean
+qif_account_picker_dialog(QIFImportWindow * qif_wind, SCM map_entry)
+{
+    QIFAccountPickerDialog * wind;
+    SCM gnc_name     = scm_c_eval_string("qif-map-entry:gnc-name");
+    SCM set_gnc_name = scm_c_eval_string("qif-map-entry:set-gnc-name!");
+    SCM orig_acct    = scm_call_1(gnc_name, map_entry);
+    int response;
+    GtkBuilder *builder;
+    GtkWidget *button;
+
+    wind = g_new0(QIFAccountPickerDialog, 1);
+
+    /* Save the map entry. */
+    wind->map_entry = map_entry;
+    scm_gc_protect_object(wind->map_entry);
+
+    /* Set the initial account to be selected. */
+    if (scm_is_string(orig_acct))
+        wind->selected_name = gnc_scm_to_utf8_string (orig_acct);
+
+    builder = gtk_builder_new();
+    gnc_builder_add_from_file (builder, "dialog-account-picker.glade", "QIF Import Account Picker");
+
+    /* Connect all the signals */
+    gtk_builder_connect_signals (builder, wind);
+
+    wind->dialog     = GTK_WIDGET(gtk_builder_get_object (builder, "QIF Import Account Picker"));
+    wind->treeview   = GTK_TREE_VIEW(gtk_builder_get_object (builder, "account_tree"));
+    wind->qif_wind   = qif_wind;
+
+    {
+        GtkTreeStore *store;
+        GtkCellRenderer *renderer;
+        GtkTreeViewColumn *column;
+        GtkTreeSelection *selection;
+
+        store = gtk_tree_store_new(NUM_ACCOUNT_COLS, G_TYPE_STRING, G_TYPE_STRING,
+                                   G_TYPE_BOOLEAN);
+        gtk_tree_view_set_model(wind->treeview, GTK_TREE_MODEL(store));
+        g_object_unref(store);
+
+        renderer = gtk_cell_renderer_text_new();
+        column = gtk_tree_view_column_new_with_attributes(_("Account"),
+                 renderer,
+                 "text",
+                 ACCOUNT_COL_NAME,
+                 NULL);
+        g_object_set(column, "expand", TRUE, NULL);
+        gtk_tree_view_append_column(wind->treeview, column);
+
+        renderer = gtk_cell_renderer_toggle_new();
+        g_object_set(renderer, "activatable", FALSE, NULL);
+        column = gtk_tree_view_column_new_with_attributes(_("New?"),
+                 renderer,
+                 "active",
+                 ACCOUNT_COL_CHECK,
+                 NULL);
+        gtk_tree_view_append_column(wind->treeview, column);
+
+        selection = gtk_tree_view_get_selection(wind->treeview);
+        g_signal_connect(selection, "changed",
+                         G_CALLBACK(gnc_ui_qif_account_picker_changed_cb), wind);
+        g_signal_connect(wind->treeview, "row-activated",
+                         G_CALLBACK(gnc_ui_qif_account_picker_row_activated_cb),
+                         wind);
+    }
+
+    g_signal_connect_after(wind->dialog, "map",
+                           G_CALLBACK(gnc_ui_qif_account_picker_map_cb),
+                           wind);
+
+    button =  GTK_WIDGET(gtk_builder_get_object (builder, "newbutton"));
+    gtk_button_set_use_stock(GTK_BUTTON(button), TRUE);
+
+    /* this is to get the checkmarks set up right.. it will get called
+     * again after the window is mapped. */
+    build_acct_tree(wind, wind->qif_wind);
+
+    do
+    {
+        response = gtk_dialog_run(GTK_DIALOG(wind->dialog));
+    }
+    while (response == GNC_RESPONSE_NEW);
+    gtk_widget_destroy(wind->dialog);
+    g_object_unref(G_OBJECT(builder));
+
+    scm_gc_unprotect_object(wind->map_entry);
+    g_free(wind->selected_name);
+    g_free(wind);
+
+    if (response == GTK_RESPONSE_OK)
+        return TRUE;
+
+    /* Restore the original mapping. */
+    scm_call_2(set_gnc_name, map_entry, orig_acct);
+
+    return FALSE;
+}

Copied: gnucash/trunk/src/import-export/qif-imp/dialog-account-picker.glade (from rev 23566, gnucash/trunk/src/import-export/qif-import/dialog-account-picker.glade)
===================================================================
--- gnucash/trunk/src/import-export/qif-imp/dialog-account-picker.glade	                        (rev 0)
+++ gnucash/trunk/src/import-export/qif-imp/dialog-account-picker.glade	2013-12-15 17:21:20 UTC (rev 23567)
@@ -0,0 +1,315 @@
+<?xml version="1.0"?>
+<interface>
+  <requires lib="gtk+" version="2.16"/>
+  <!-- interface-naming-policy project-wide -->
+  <object class="GtkWindow" id="Preferences">
+    <property name="visible">True</property>
+    <property name="can_focus">False</property>
+    <property name="title" translatable="yes">Preferences</property>
+    <child>
+      <object class="GtkTable" id="prefs_table">
+        <property name="visible">True</property>
+        <property name="can_focus">False</property>
+        <property name="n_rows">7</property>
+        <property name="n_columns">4</property>
+        <child>
+          <object class="GtkLabel" id="label847718">
+            <property name="visible">True</property>
+            <property name="can_focus">False</property>
+            <property name="xalign">0</property>
+            <property name="label" translatable="yes"><b>QIF Import</b></property>
+            <property name="use_markup">True</property>
+          </object>
+          <packing>
+            <property name="x_options">GTK_FILL</property>
+            <property name="y_options"></property>
+          </packing>
+        </child>
+        <child>
+          <object class="GtkCheckButton" id="pref/dialogs.import.qif/show-doc">
+            <property name="label" translatable="yes">_Show documentation</property>
+            <property name="visible">True</property>
+            <property name="can_focus">True</property>
+            <property name="receives_default">False</property>
+            <property name="has_tooltip">True</property>
+            <property name="tooltip_markup">Show some documentation-only pages in QIF Import assistant.</property>
+            <property name="tooltip_text" translatable="yes">Show some documentation-only pages in QIF Import assistant.</property>
+            <property name="use_action_appearance">False</property>
+            <property name="use_underline">True</property>
+            <property name="draw_indicator">True</property>
+          </object>
+          <packing>
+            <property name="right_attach">4</property>
+            <property name="top_attach">1</property>
+            <property name="bottom_attach">2</property>
+            <property name="x_options">GTK_FILL</property>
+            <property name="y_options"></property>
+            <property name="x_padding">12</property>
+          </packing>
+        </child>
+        <child>
+          <object class="GtkRadioButton" id="pref/dialogs.import.qif/default-status-reconciled">
+            <property name="label" translatable="yes">_Reconciled</property>
+            <property name="visible">True</property>
+            <property name="can_focus">True</property>
+            <property name="receives_default">False</property>
+            <property name="has_tooltip">True</property>
+            <property name="tooltip_markup">When the status is not specified in a QIF file, the transactions are marked as reconciled.</property>
+            <property name="tooltip_text" translatable="yes">When the status is not specified in a QIF file, the transactions are marked as reconciled.</property>
+            <property name="use_action_appearance">False</property>
+            <property name="use_underline">True</property>
+            <property name="active">True</property>
+            <property name="draw_indicator">True</property>
+          </object>
+          <packing>
+            <property name="top_attach">6</property>
+            <property name="bottom_attach">7</property>
+            <property name="x_options">GTK_FILL</property>
+            <property name="y_options"></property>
+            <property name="x_padding">12</property>
+          </packing>
+        </child>
+        <child>
+          <object class="GtkRadioButton" id="pref/dialogs.import.qif/default-status-cleared">
+            <property name="label" translatable="yes">_Cleared</property>
+            <property name="visible">True</property>
+            <property name="can_focus">True</property>
+            <property name="receives_default">False</property>
+            <property name="has_tooltip">True</property>
+            <property name="tooltip_markup">When the status is not specified in a QIF file, the transactions are marked as cleared.</property>
+            <property name="tooltip_text" translatable="yes">When the status is not specified in a QIF file, the transactions are marked as cleared.</property>
+            <property name="use_action_appearance">False</property>
+            <property name="use_underline">True</property>
+            <property name="draw_indicator">True</property>
+            <property name="group">pref/dialogs.import.qif/default-status-reconciled</property>
+          </object>
+          <packing>
+            <property name="top_attach">5</property>
+            <property name="bottom_attach">6</property>
+            <property name="x_options">GTK_FILL</property>
+            <property name="y_options"></property>
+            <property name="x_padding">12</property>
+          </packing>
+        </child>
+        <child>
+          <object class="GtkRadioButton" id="pref/dialogs.import.qif/default-status-notcleared">
+            <property name="label" translatable="yes">_Not cleared</property>
+            <property name="visible">True</property>
+            <property name="can_focus">True</property>
+            <property name="receives_default">True</property>
+            <property name="has_tooltip">True</property>
+            <property name="tooltip_markup">When the status is not specified in a QIF file, the transactions are marked as not cleared.</property>
+            <property name="tooltip_text" translatable="yes">When the status is not specified in a QIF file, the transactions are marked as not cleared.</property>
+            <property name="use_action_appearance">False</property>
+            <property name="use_underline">True</property>
+            <property name="draw_indicator">True</property>
+            <property name="group">pref/dialogs.import.qif/default-status-reconciled</property>
+          </object>
+          <packing>
+            <property name="top_attach">4</property>
+            <property name="bottom_attach">5</property>
+            <property name="x_options">GTK_FILL</property>
+            <property name="y_options"></property>
+            <property name="x_padding">12</property>
+          </packing>
+        </child>
+        <child>
+          <object class="GtkLabel" id="qif_default_transation_status">
+            <property name="visible">True</property>
+            <property name="can_focus">False</property>
+            <property name="xalign">0</property>
+            <property name="xpad">16</property>
+            <property name="ypad">5</property>
+            <property name="label" translatable="yes">Default transaction status (overridden by the status given by the QIF file)</property>
+          </object>
+          <packing>
+            <property name="right_attach">4</property>
+            <property name="top_attach">2</property>
+            <property name="bottom_attach">3</property>
+            <property name="x_options">GTK_FILL</property>
+            <property name="y_options"></property>
+          </packing>
+        </child>
+        <child>
+          <placeholder/>
+        </child>
+        <child>
+          <placeholder/>
+        </child>
+        <child>
+          <placeholder/>
+        </child>
+        <child>
+          <placeholder/>
+        </child>
+        <child>
+          <placeholder/>
+        </child>
+        <child>
+          <placeholder/>
+        </child>
+        <child>
+          <placeholder/>
+        </child>
+        <child>
+          <placeholder/>
+        </child>
+        <child>
+          <placeholder/>
+        </child>
+        <child>
+          <placeholder/>
+        </child>
+        <child>
+          <placeholder/>
+        </child>
+        <child>
+          <placeholder/>
+        </child>
+        <child>
+          <placeholder/>
+        </child>
+        <child>
+          <placeholder/>
+        </child>
+        <child>
+          <placeholder/>
+        </child>
+        <child>
+          <placeholder/>
+        </child>
+      </object>
+    </child>
+  </object>
+  <object class="GtkDialog" id="QIF Import Account Picker">
+    <property name="visible">True</property>
+    <property name="can_focus">False</property>
+    <property name="title" translatable="yes">Select Account</property>
+    <property name="default_width">300</property>
+    <property name="default_height">400</property>
+    <property name="type_hint">dialog</property>
+    <child internal-child="vbox">
+      <object class="GtkVBox" id="dialog-vbox1">
+        <property name="visible">True</property>
+        <property name="can_focus">False</property>
+        <property name="spacing">8</property>
+        <child internal-child="action_area">
+          <object class="GtkHButtonBox" id="dialog-action_area1">
+            <property name="visible">True</property>
+            <property name="can_focus">False</property>
+            <property name="layout_style">end</property>
+            <child>
+              <object class="GtkButton" id="newbutton">
+                <property name="label">gnc-new-account</property>
+                <property name="visible">True</property>
+                <property name="can_focus">True</property>
+                <property name="can_default">True</property>
+                <property name="receives_default">True</property>
+                <property name="use_action_appearance">False</property>
+                <property name="use_underline">True</property>
+                <signal name="clicked" handler="gnc_ui_qif_account_picker_new_cb" swapped="no"/>
+              </object>
+              <packing>
+                <property name="expand">False</property>
+                <property name="fill">False</property>
+                <property name="position">0</property>
+              </packing>
+            </child>
+            <child>
+              <object class="GtkButton" id="cancelbutton">
+                <property name="label">gtk-cancel</property>
+                <property name="visible">True</property>
+                <property name="can_focus">True</property>
+                <property name="can_default">True</property>
+                <property name="receives_default">True</property>
+                <property name="use_action_appearance">False</property>
+                <property name="use_stock">True</property>
+              </object>
+              <packing>
+                <property name="expand">False</property>
+                <property name="fill">False</property>
+                <property name="position">1</property>
+              </packing>
+            </child>
+            <child>
+              <object class="GtkButton" id="okbutton">
+                <property name="label">gtk-ok</property>
+                <property name="visible">True</property>
+                <property name="can_focus">True</property>
+                <property name="can_default">True</property>
+                <property name="receives_default">True</property>
+                <property name="use_action_appearance">False</property>
+                <property name="use_stock">True</property>
+              </object>
+              <packing>
+                <property name="expand">False</property>
+                <property name="fill">False</property>
+                <property name="position">2</property>
+              </packing>
+            </child>
+          </object>
+          <packing>
+            <property name="expand">False</property>
+            <property name="fill">False</property>
+            <property name="pack_type">end</property>
+            <property name="position">0</property>
+          </packing>
+        </child>
+        <child>
+          <object class="GtkVBox" id="vbox2">
+            <property name="visible">True</property>
+            <property name="can_focus">False</property>
+            <child>
+              <object class="GtkLabel" id="label1">
+                <property name="visible">True</property>
+                <property name="can_focus">False</property>
+                <property name="xalign">0</property>
+                <property name="xpad">5</property>
+                <property name="label" translatable="yes">_Select or add a GnuCash account:</property>
+                <property name="use_underline">True</property>
+                <property name="mnemonic_widget">account_tree</property>
+              </object>
+              <packing>
+                <property name="expand">False</property>
+                <property name="fill">False</property>
+                <property name="padding">5</property>
+                <property name="position">0</property>
+              </packing>
+            </child>
+            <child>
+              <object class="GtkScrolledWindow" id="scrolledwindow24">
+                <property name="visible">True</property>
+                <property name="can_focus">True</property>
+                <property name="hscrollbar_policy">automatic</property>
+                <property name="vscrollbar_policy">automatic</property>
+                <property name="shadow_type">in</property>
+                <child>
+                  <object class="GtkTreeView" id="account_tree">
+                    <property name="visible">True</property>
+                    <property name="can_focus">True</property>
+                    <property name="rules_hint">True</property>
+                  </object>
+                </child>
+              </object>
+              <packing>
+                <property name="expand">True</property>
+                <property name="fill">True</property>
+                <property name="position">1</property>
+              </packing>
+            </child>
+          </object>
+          <packing>
+            <property name="expand">True</property>
+            <property name="fill">True</property>
+            <property name="position">2</property>
+          </packing>
+        </child>
+      </object>
+    </child>
+    <action-widgets>
+      <action-widget response="1">newbutton</action-widget>
+      <action-widget response="-6">cancelbutton</action-widget>
+      <action-widget response="-5">okbutton</action-widget>
+    </action-widgets>
+  </object>
+</interface>

Copied: gnucash/trunk/src/import-export/qif-imp/dialog-account-picker.h (from rev 23566, gnucash/trunk/src/import-export/qif-import/dialog-account-picker.h)
===================================================================
--- gnucash/trunk/src/import-export/qif-imp/dialog-account-picker.h	                        (rev 0)
+++ gnucash/trunk/src/import-export/qif-imp/dialog-account-picker.h	2013-12-15 17:21:20 UTC (rev 23567)
@@ -0,0 +1,35 @@
+/********************************************************************\
+ * dialog-account-picker.h -- window for picking a GNUcash account  *
+ *                       (GnuCash)                                  *
+ * Copyright (C) 2000 Bill Gribble <grib at billgribble.com>           *
+ *                                                                  *
+ * This program is free software; you can redistribute it and/or    *
+ * modify it under the terms of the GNU General Public License as   *
+ * published by the Free Software Foundation; either version 2 of   *
+ * the License, or (at your option) any later version.              *
+ *                                                                  *
+ * This program is distributed in the hope that it will be useful,  *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of   *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the    *
+ * GNU General Public License for more details.                     *
+ *                                                                  *
+ * You should have received a copy of the GNU General Public License*
+ * along with this program; if not, contact:                        *
+ *                                                                  *
+ * Free Software Foundation           Voice:  +1-617-542-5942       *
+ * 51 Franklin Street, Fifth Floor    Fax:    +1-617-542-2652       *
+ * Boston, MA  02110-1301,  USA       gnu at gnu.org                   *
+\********************************************************************/
+
+#ifndef DIALOG_ACCOUNT_PICKER_H
+#define DIALOG_ACCOUNT_PICKER_H
+
+#include <libguile.h>
+
+#include "assistant-qif-import.h"
+
+gboolean qif_account_picker_dialog(QIFImportWindow * wind, SCM initial_sel);
+
+typedef struct _accountpickerdialog QIFAccountPickerDialog;
+
+#endif

Copied: gnucash/trunk/src/import-export/qif-imp/file-format.txt (from rev 23566, gnucash/trunk/src/import-export/qif-import/file-format.txt)
===================================================================
--- gnucash/trunk/src/import-export/qif-imp/file-format.txt	                        (rev 0)
+++ gnucash/trunk/src/import-export/qif-imp/file-format.txt	2013-12-15 17:21:20 UTC (rev 23567)
@@ -0,0 +1,410 @@
+QIF file format
+---------------
+The QIF is an old and rather broken file format defined by Intuit
+for exporting Quicken data.  It is 'broken' because the format
+is ambiguous in many places, non-standard between different releases
+and applications, and even varies subtly from country to country (in
+particular, the way dates and amounts are represented), and fails
+to define important data (such as the currency denomination, or the
+exchange rates when transferring between accounts marked in different
+currencies).  Importing a QIF file can require significant manual
+intervention by the user in order to get the data straight.
+
+
+Extensions
+----------
+TEF -- Time and Expense Format (see below)
+
+QFX -- also known as 'Web Connect' --  very similar, and is the
+       'new' standard for on-line bank statement downloads.
+       (??? or is it just 'ofx in a file' ???)
+
+
+Type of account identifiers
+----------------------------
+!Type:Bank     Bank account
+!Type:Bill     ??? (bill presentment ???)
+!Type:Cash     Cash account
+!Type:CCard    Credit Card account
+!Type:Invoice  ??? (invoice presentment ???)
+!Type:Invst    Investment account
+!Type:Oth A    Asset account
+!Type:Oth S    Asset account (German)
+!Type:Oth L    Liability account
+!Type:Tax      ???
+
+!Account         Account list or which account applies to following
+                 transactions
+
+!Type:Cat        Category list
+!Type:Class      Class list
+!Type:Memorized  Memorized transaction list
+
+Note that !Account is used both to be a header for account information,
+and to be a header for a list of transactions.
+
+Also note that international versions of Quicken and MS Money often
+translate the Type: tags into the local language.  But not always.
+
+
+Account Information Format
+--------------------------
+The below typically follow an !Account identifier, and provide account
+data.
+
+Letter Definition
+N      Name
+T      Type of account
+D      Description
+L      Credit limit (only for credit card accounts)
+/      Statement balance date
+$      Statement balance amount
+^      End of entry
+
+
+Category Information Format
+---------------------------
+N      Category name:subcategory name
+D      Description
+T      Tax related if included, not tax related if omitted
+I      Income category
+E      Expense category (if category type is unspecified,
+       assumes expense type)
+B      Budget amount (optional, only appears in a Budget QIF file)
+R      Tax schedule information
+^      End of entry
+
+
+Class Information Format
+------------------------
+N      Class name
+D      Description
+^      End of entry
+
+
+Memorized Transaction Format
+----------------------------
+KC     Check transaction
+KD     Deposit transaction
+KP     Payment transaction
+KI     Investment transaction
+KE     Electronic payee transaction
+T      Amount
+C      Cleared status
+P      Payee
+M      Memo
+A      Address
+L      Category or Transfer/Class
+S      Category/class in split
+E      Memo in split
+$      Dollar amount of split
+1      Amortization: First payment date
+2      Amortization: Total years for loan
+3      Amortization: Number of payments already made
+4      Amortization: Number of periods per year
+5      Amortization: Interest rate
+6      Amortization: Current loan balance
+7      Amortization: Original loan amount
+^      End of entry
+
+Note that the K* entries must be the *last* entries in the transaction.
+All fields are optional.  If this is an amortization record, then all
+seven amortization fields much be present.
+
+
+Investment transaction format
+-----------------------------
+Letter Definition
+D      Date (optional)
+N      Action
+Y      Security
+I      Price
+Q      Quantity (# of shares or split ratio)
+C      Cleared status
+P      first line text for transfers/reminders
+M      Memo
+O      Commission
+L      Account for transfer
+       (category/class or transfer/class)
+       (For MiscIncX or MiscExpX actions, this will be
+       category/class|transfer/class or |transfer/class)
+T      Amount of transaction
+U      Amount of transaction (higher possible value than T)
+$      Amount transferred
+^      End of entry
+
+Note that numbers for investment transactions are positive in most
+cases.  The importation process automatically takes care of negating
+the values for Actions that move funds out of an account (for example:
+sales, expenses and transfers).
+
+Be aware that GnuCash's file format stores the share quantity and the
+total value of the transaction.  Prices are not stored.
+
+
+Non-investment transaction format
+---------------------------------
+Letter Definition
+D      Date
+T      Amount
+U      Transaction amount (higher possible value than T)
+C      Cleared status
+N      Number (check or reference number)
+P      Payee/description
+M      Memo
+A      Address (up to 5 lines; 6th line is an optional message)
+L      Category (category/class or transfer/class)
+
+S      Category in split (category/class or transfer/class)
+E      Memo in split
+$      Dollar amount of split
+%      Percentage of split if percentages are used
+F      Reimbursable business expense flag
+X      Small Business extensions
+^      End of entry
+
+Note that S,E and $ lines are repeated as needed for splits.
+
+
+Time and Expense Format
+-----------------------
+The following QIF extension added by Iambic Software
+to handle time and expense tracking.  This is used in particular
+by handhelds (Palm and WinCE).  TEF is claimed to be a superset
+of the QIF format.
+
+TEF Files begin with the header:
+#TEF VERSION X.YYY
+Documented below is version 1.01
+
+#      Any line beginning with # is a comment and not parsed
+B      City
+F      Reported
+H      Report #
+J      Attendees
+K      Reimbursable
+R      Receipt
+U      Begin Odometer
+V      End Odometer
+W      Private
+X      Exchange Rate
+Z      User
+
+1      Client
+2      Project
+3      Activity
+4      Expense Type
+5      Account
+6      Vehicle
+7      Currency
+8      Task
+9      (not used)
+0      (not used)
+
+@      Billing Code
+!      Tax Amount
+%      Uses Splits
+(      SalesTaxRate1
+)      SalesTaxRate2
+=      Flat Fee Amount
+\      Status1
+/      Status2
+&      Status3
+<      Status4
+>      Status5
+?      Keyword: TIME, EXPENSE, CLIENT, PROJECT, ACTIVITY, TYPE,
+       TASK, VEHICLE, PAYEE, CURRENCY. If absent, entry is
+       assumed EXPENSE type as compatible with QIF
+
+*      Duration hh:mm:ss
+
++      Timer On
+[      Start time
+]      End Time
+{      TimerLastStoppedAt
+}      (not used)
+|      Notes
+
+
+When importing type CLIENT, PROJECT, ACTIVITY, TYPE, TASK, VEHICLE,
+PAYEE, CURRENCY the following are used:
+
+N      Name
+C      Code
+R      Rate
+L      Link
+W      Private
+
+
+=====================================================================
+General Notes
+=====================================================================
+
+Dates
+-----
+Dates in US QIF files are usually in the format MM/DD/YY, although
+four-digit years are not uncommon.  Dates sometimes occur without the
+slash separator, or using other separators in place of the slash,
+commonly '-' and '.'.  US Quicken seems to be using the ' to indicate
+post-2000 two-digit years (such as 01/01'00 for Jan 1 2000).  Some
+banks appear to be using a completely undifferentiated numeric string
+formateed YYYYMMDD in downloaded QIF files.
+
+European QIF files may have dates in the DD/MM/YY format.
+
+
+Monetary Amounts
+----------------
+These typically occur in either US or European format:
+
+10,000.00  Ten Thousand Dollars (US format)
+10.000,00  Ten Thousand Francs  (European format)
+
+An apostrophe is also used in some cases:
+
+10'000.00  Ten Thousand Dollars (Quicken 4)
+10'000,00  Ten Thousand Francs  (unconfirmed)
+
+Within a given QIF file, the usage of a particular numeric format
+appears to be consistent within a particular field but may be
+different from one field to another.  For example, the Share Amount
+field can be in European format but the Split Amount in US.  No
+radix-point is required and no limit on decimal places is evident, so
+it's possible to see the number "1,000" meaning "1 franc per share"
+"1,000" meaning "one thousand shares" in the same transaction (!).
+
+
+Investment Actions
+------------------
+The N line of investment transactions specifies the "action" of the
+transaction. Although not a complete list, possible values include
+the following:
+
+QIF N Line    Notes
+============  =====
+Aktab         Same as ShrsOut.
+AktSplit      Same as StkSplit.
+Aktzu         Same as ShrsIn.
+Buy           Buy shares.
+BuyX          Buy shares. Used with an L line.
+Cash          Miscellaneous cash transaction. Used with an L line.
+CGMid         Mid-term capital gains.
+CGMidX        Mid-term capital gains. For use with an L line.
+CGLong        Long-term capital gains.
+CGLongX       Long-term capital gains. For use with an L line.
+CGShort       Short-term capital gains.
+CGShortX      Short-term capital gains. For use with an L line.
+ContribX      Same as XIn. Used for tax-advantaged accounts.
+CvrShrt       Buy shares to cover a short sale.
+CvrShrtX      Buy shares to cover a short sale. Used with an L line.
+Div           Dividend received.
+DivX          Dividend received. For use with an L line.
+Errinerg      Same as Reminder.
+Exercise      Exercise an option.
+ExercisX      Exercise an option. For use with an L line.
+Expire        Mark an option as expired. (Uses D, N, Y & M lines)
+Grant         Receive a grant of stock options.
+Int           Same as IntInc.
+IntX          Same as IntIncX.
+IntInc        Interest received.
+IntIncX       Interest received. For use with an L line.
+K.gewsp       Same as CGShort. (German)
+K.gewspX      Same as CGShortX. (German)
+Kapgew        Same as CGLong. Kapitalgewinnsteuer.(German)
+KapgewX       Same as CGLongX. Kapitalgewinnsteuer. (German)
+Kauf          Same as Buy. (German)
+KaufX         Same as BuyX. (German)
+MargInt       Margin interest paid.
+MargIntX      Margin interest paid. For use with an L line.
+MiscExp       Miscellaneous expense.
+MiscExpX      Miscellaneous expense. For use with an L line.
+MiscInc       Miscellaneous income.
+MiscIncX      Miscellaneous income. For use with an L line.
+ReinvDiv      Reinvested dividend.
+ReinvInt      Reinvested interest.
+ReinvLG       Reinvested long-term capital gains.
+Reinvkur      Same as ReinvLG.
+Reinvksp      Same as ReinvSh.
+ReinvMd       Reinvested mid-term capital gains.
+ReinvSG       Same as ReinvSh.
+ReinvSh       Reinvested short-term capital gains.
+Reinvzin      Same as ReinvDiv.
+Reminder      Reminder. (Uses D, N, C & M lines)
+RtrnCap       Return of capital.
+RtrnCapX      Return of capital. For use with an L line.
+Sell          Sell shares.
+SellX         Sell shares. For use with an L line.
+ShtSell       Short sale.
+ShrsIn        Deposit shares.
+ShrsOut       Withdraw shares.
+StkSplit      Stock split.
+Verkauf       Same as Sell. (German)
+VerkaufX      Same as SellX. (German)
+Vest          Mark options as vested. (Uses N, Y, Q, C & M lines)
+WithDrwX      Same as XOut. Used for tax-advantaged accounts.
+XIn           Transfer cash from another account.
+XOut          Transfer cash to another account.
+
+
+Category/Transfer/Class line
+----------------------------
+The "L" line of most transactions specifies the category, transfer
+account, and class (if any) of the transaction.  Square brackets
+surrounding the contents mean the transaction is a transfer to the
+named account.  A forward slash separates the category/account from
+the class.  So overall, the format is one of the following:
+
+   LCategory of transaction
+   L[Transfer account]
+   LCategory of transaction/Class of transaction
+   L[Transfer account]/Class of transaction
+
+In stock transactions, if the 'N' field (action) is MiscIncX or
+MiscExpX, there can be *two* account/class pairs on the L line, with
+the second guaranteed to be a transfer.  I believe they are
+separated by a '|', like so:
+
+   D01/01/2000
+   NMiscExpX
+   T1000.00
+   Lexpense category/expense class|[Transfer account]/transfer class
+
+
+Cleared Status line
+-------------------
+The "C" line of specifies the cleared status. The second character
+in the line, if present, may be any of:
+
+* Cleared
+c Cleared
+X Reconciled
+R Reconciled
+? Budgeted
+! Budgeted
+
+
+=====================================================================
+Sample Files
+=====================================================================
+
+Investment Transactions
+-----------------------
+!Account
+NAssets:Investments:Mutual Fund
+TInvst
+D10/30/2006
+Q0.9
+T500
+PPurchase
+NBuyX
+L[Assets:Investments:Mutual Fund:Cash]
+YFOO
+^
+D11/28/2006
+Q0.897
+T100
+PSale
+NSellX
+L[Assets:Investments:Mutual Fund:Cash]
+YFOO
+^

Copied: gnucash/trunk/src/import-export/qif-imp/gnc-plugin-qif-import-ui.xml (from rev 23566, gnucash/trunk/src/import-export/qif-import/gnc-plugin-qif-import-ui.xml)
===================================================================
--- gnucash/trunk/src/import-export/qif-imp/gnc-plugin-qif-import-ui.xml	                        (rev 0)
+++ gnucash/trunk/src/import-export/qif-imp/gnc-plugin-qif-import-ui.xml	2013-12-15 17:21:20 UTC (rev 23567)
@@ -0,0 +1,12 @@
+<ui>
+  <menubar>
+    <menu name="File" action="FileAction">
+      <menu name="FileImport" action="FileImportAction">
+      	<placeholder name="FileImportPlaceholder">
+      	   <menuitem name="FileQIFImport" action="QIFImportAction"/>
+      	   <!-- menuitem name="FileQIFTestDruid" action="QIFTestDruid"/ -->
+      	</placeholder>
+      </menu>
+    </menu>
+  </menubar>
+</ui>

Copied: gnucash/trunk/src/import-export/qif-imp/gnc-plugin-qif-import.c (from rev 23566, gnucash/trunk/src/import-export/qif-import/gnc-plugin-qif-import.c)
===================================================================
--- gnucash/trunk/src/import-export/qif-imp/gnc-plugin-qif-import.c	                        (rev 0)
+++ gnucash/trunk/src/import-export/qif-imp/gnc-plugin-qif-import.c	2013-12-15 17:21:20 UTC (rev 23567)
@@ -0,0 +1,163 @@
+/********************************************************************\
+ * gnc-plugin-qif-import.c -- window for importing QIF files        *
+ *                        (GnuCash)                                 *
+ * Copyright (C) 2003 Jan Arne Petersen <jpetersen at uni-bonn.de>     *
+ *                                                                  *
+ * This program is free software; you can redistribute it and/or    *
+ * modify it under the terms of the GNU General Public License as   *
+ * published by the Free Software Foundation; either version 2 of   *
+ * the License, or (at your option) any later version.              *
+ *                                                                  *
+ * This program is distributed in the hope that it will be useful,  *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of   *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the    *
+ * GNU General Public License for more details.                     *
+ *                                                                  *
+ * You should have received a copy of the GNU General Public License*
+ * along with this program; if not, contact:                        *
+ *                                                                  *
+ * Free Software Foundation           Voice:  +1-617-542-5942       *
+ * 51 Franklin Street, Fifth Floor    Fax:    +1-617-542-2652       *
+ * Boston, MA  02110-1301,  USA       gnu at gnu.org                   *
+\********************************************************************/
+
+#include "config.h"
+
+#include <gtk/gtk.h>
+#include <glib/gi18n.h>
+
+#include "dialog-preferences.h"
+#include "assistant-qif-import.h"
+#include "gnc-plugin-manager.h"
+#include "gnc-plugin-qif-import.h"
+
+static void gnc_plugin_qif_import_class_init (GncPluginQifImportClass *klass);
+static void gnc_plugin_qif_import_init (GncPluginQifImport *plugin);
+static void gnc_plugin_qif_import_finalize (GObject *object);
+
+/* Command callbacks */
+static void gnc_plugin_qif_import_cmd_new_qif_import (GtkAction *action, GncMainWindowActionData *data);
+
+#define PLUGIN_ACTIONS_NAME "gnc-plugin-qif-import-actions"
+#define PLUGIN_UI_FILENAME  "gnc-plugin-qif-import-ui.xml"
+
+static GtkActionEntry gnc_plugin_actions [] =
+{
+    {
+        "QIFImportAction", GTK_STOCK_CONVERT, N_("Import _QIF..."), NULL,
+        N_("Import a Quicken QIF file"),
+        G_CALLBACK (gnc_plugin_qif_import_cmd_new_qif_import)
+    },
+};
+static guint gnc_plugin_n_actions = G_N_ELEMENTS (gnc_plugin_actions);
+
+typedef struct GncPluginQifImportPrivate
+{
+    gpointer dummy;
+} GncPluginQifImportPrivate;
+
+#define GNC_PLUGIN_QIF_IMPORT_GET_PRIVATE(o)  \
+   (G_TYPE_INSTANCE_GET_PRIVATE ((o), GNC_TYPE_PLUGIN_QIF_IMPORT, GncPluginQifImportPrivate))
+
+static GObjectClass *parent_class = NULL;
+
+GType
+gnc_plugin_qif_import_get_type (void)
+{
+    static GType gnc_plugin_qif_import_type = 0;
+
+    if (gnc_plugin_qif_import_type == 0)
+    {
+        static const GTypeInfo our_info =
+        {
+            sizeof (GncPluginQifImportClass),
+            NULL,		/* base_init */
+            NULL,		/* base_finalize */
+            (GClassInitFunc) gnc_plugin_qif_import_class_init,
+            NULL,		/* class_finalize */
+            NULL,		/* class_data */
+            sizeof (GncPluginQifImport),
+            0,		/* n_preallocs */
+            (GInstanceInitFunc) gnc_plugin_qif_import_init,
+        };
+
+        gnc_plugin_qif_import_type = g_type_register_static (GNC_TYPE_PLUGIN,
+                                     "GncPluginQifImport",
+                                     &our_info, 0);
+    }
+
+    return gnc_plugin_qif_import_type;
+}
+
+GncPlugin *
+gnc_plugin_qif_import_new (void)
+{
+    return GNC_PLUGIN (g_object_new (GNC_TYPE_PLUGIN_QIF_IMPORT, NULL));
+}
+
+static void
+gnc_plugin_qif_import_class_init (GncPluginQifImportClass *klass)
+{
+    GObjectClass *object_class = G_OBJECT_CLASS (klass);
+    GncPluginClass *plugin_class = GNC_PLUGIN_CLASS (klass);
+
+    parent_class = g_type_class_peek_parent (klass);
+
+    object_class->finalize = gnc_plugin_qif_import_finalize;
+
+    /* plugin info */
+    plugin_class->plugin_name  = GNC_PLUGIN_QIF_IMPORT_NAME;
+
+    /* widget addition/removal */
+    plugin_class->actions_name = PLUGIN_ACTIONS_NAME;
+    plugin_class->actions      = gnc_plugin_actions;
+    plugin_class->n_actions    = gnc_plugin_n_actions;
+    plugin_class->ui_filename  = PLUGIN_UI_FILENAME;
+
+    g_type_class_add_private(klass, sizeof(GncPluginQifImportPrivate));
+}
+
+static void
+gnc_plugin_qif_import_init (GncPluginQifImport *plugin)
+{
+}
+
+static void
+gnc_plugin_qif_import_finalize (GObject *object)
+{
+    g_return_if_fail (GNC_IS_PLUGIN_QIF_IMPORT (object));
+
+    G_OBJECT_CLASS (parent_class)->finalize (object);
+}
+
+/************************************************************
+ *              Plugin Function Implementation              *
+ ************************************************************/
+
+/************************************************************
+ *                    Command Callbacks                     *
+ ************************************************************/
+
+static void
+gnc_plugin_qif_import_cmd_new_qif_import (GtkAction *action,
+        GncMainWindowActionData *data)
+{
+    gnc_file_qif_import();
+}
+
+
+/************************************************************
+ *                    Plugin Bootstrapping                   *
+ ************************************************************/
+
+void
+gnc_plugin_qif_import_create_plugin (void)
+{
+    GncPlugin *plugin = gnc_plugin_qif_import_new ();
+    gnc_plugin_manager_add_plugin (gnc_plugin_manager_get (), plugin);
+
+    /* Add to preferences under Online Banking */
+    /* The parameters are; glade file, items to add from glade file - last being the dialog, preference tab name */
+    gnc_preferences_add_to_page ("dialog-account-picker.glade", "prefs_table",
+                                 _("Online Banking"));
+}

Copied: gnucash/trunk/src/import-export/qif-imp/gnc-plugin-qif-import.h (from rev 23566, gnucash/trunk/src/import-export/qif-import/gnc-plugin-qif-import.h)
===================================================================
--- gnucash/trunk/src/import-export/qif-imp/gnc-plugin-qif-import.h	                        (rev 0)
+++ gnucash/trunk/src/import-export/qif-imp/gnc-plugin-qif-import.h	2013-12-15 17:21:20 UTC (rev 23567)
@@ -0,0 +1,63 @@
+/********************************************************************\
+ * gnc-plugin-qif-import.c -- window for importing QIF files        *
+ *                        (GnuCash)                                 *
+ * Copyright (C) 2003 Jan Arne Petersen <jpetersen at uni-bonn.de>     *
+ *                                                                  *
+ * This program is free software; you can redistribute it and/or    *
+ * modify it under the terms of the GNU General Public License as   *
+ * published by the Free Software Foundation; either version 2 of   *
+ * the License, or (at your option) any later version.              *
+ *                                                                  *
+ * This program is distributed in the hope that it will be useful,  *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of   *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the    *
+ * GNU General Public License for more details.                     *
+ *                                                                  *
+ * You should have received a copy of the GNU General Public License*
+ * along with this program; if not, contact:                        *
+ *                                                                  *
+ * Free Software Foundation           Voice:  +1-617-542-5942       *
+ * 51 Franklin Street, Fifth Floor    Fax:    +1-617-542-2652       *
+ * Boston, MA  02110-1301,  USA       gnu at gnu.org                   *
+\********************************************************************/
+
+#ifndef __GNC_PLUGIN_QIF_IMPORT_H
+#define __GNC_PLUGIN_QIF_IMPORT_H
+
+#include <gtk/gtk.h>
+
+#include "gnc-plugin.h"
+
+G_BEGIN_DECLS
+
+/* type macros */
+#define GNC_TYPE_PLUGIN_QIF_IMPORT            (gnc_plugin_qif_import_get_type ())
+#define GNC_PLUGIN_QIF_IMPORT(obj)            (G_TYPE_CHECK_INSTANCE_CAST ((obj), GNC_TYPE_PLUGIN_QIF_IMPORT, GncPluginQifImport))
+#define GNC_PLUGIN_QIF_IMPORT_CLASS(klass)    (G_TYPE_CHECK_CLASS_CAST ((klass), GNC_TYPE_PLUGIN_QIF_IMPORT, GncPluginQifImportClass))
+#define GNC_IS_PLUGIN_QIF_IMPORT(obj)         (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GNC_TYPE_PLUGIN_QIF_IMPORT))
+#define GNC_IS_PLUGIN_QIF_IMPORT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GNC_TYPE_PLUGIN_QIF_IMPORT))
+#define GNC_PLUGIN_QIF_IMPORT_GET_CLASS(obj)  (G_TYPE_INSTANCE_GET_CLASS ((obj), GNC_TYPE_PLUGIN_QIF_IMPORT, GncPluginQifImportClass))
+
+#define GNC_PLUGIN_QIF_IMPORT_NAME "gnc-plugin-qif-import"
+
+/* typedefs & structures */
+typedef struct
+{
+    GncPlugin gnc_plugin;
+} GncPluginQifImport;
+
+typedef struct
+{
+    GncPluginClass gnc_plugin;
+} GncPluginQifImportClass;
+
+/* function prototypes */
+GType      gnc_plugin_qif_import_get_type (void);
+
+GncPlugin *gnc_plugin_qif_import_new      (void);
+
+void       gnc_plugin_qif_import_create_plugin (void);
+
+G_END_DECLS
+
+#endif /* __GNC_PLUGIN_QIF_IMPORT_H */

Copied: gnucash/trunk/src/import-export/qif-imp/gncmod-qif-import.c (from rev 23566, gnucash/trunk/src/import-export/qif-import/gncmod-qif-import.c)
===================================================================
--- gnucash/trunk/src/import-export/qif-imp/gncmod-qif-import.c	                        (rev 0)
+++ gnucash/trunk/src/import-export/qif-imp/gncmod-qif-import.c	2013-12-15 17:21:20 UTC (rev 23567)
@@ -0,0 +1,80 @@
+/*********************************************************************
+ * gncmod-qif-import.c
+ * module definition/initialization for old QIF importer (deprecated)
+ *
+ * Copyright (c) 2001 Linux Developers Group, Inc.
+ *********************************************************************/
+
+#include "config.h"
+#include <gmodule.h>
+#include <libguile.h>
+
+#include "gnc-module.h"
+#include "gnc-module-api.h"
+#include "assistant-qif-import.h"
+#include "dialog-new-user.h"
+
+#include "gnc-plugin-qif-import.h"
+
+GNC_MODULE_API_DECL(libgncmod_qif_import)
+
+/* version of the gnc module system interface we require */
+int libgncmod_qif_import_gnc_module_system_interface = 0;
+
+/* module versioning uses libtool semantics. */
+int libgncmod_qif_import_gnc_module_current  = 0;
+int libgncmod_qif_import_gnc_module_revision = 0;
+int libgncmod_qif_import_gnc_module_age      = 0;
+
+
+char *
+libgncmod_qif_import_gnc_module_path(void)
+{
+    return g_strdup("gnucash/import-export/qif-import");
+}
+
+char *
+libgncmod_qif_import_gnc_module_description(void)
+{
+    return g_strdup("Gnome GUI and Scheme code for QIF importer");
+}
+
+int
+libgncmod_qif_import_gnc_module_init(int refcount)
+{
+    if (!gnc_module_load("gnucash/engine", 0))
+    {
+        return FALSE;
+    }
+
+    if (!gnc_module_load("gnucash/app-utils", 0))
+    {
+        return FALSE;
+    }
+
+    if (!gnc_module_load("gnucash/gnome-utils", 0))
+    {
+        return FALSE;
+    }
+
+    /* If the recount == 0 then register the qif-import-assistant for the new-user
+     * dialog.
+     */
+    if (refcount == 0)
+    {
+        gnc_new_user_dialog_register_qif_assistant
+        ((void (*)())gnc_file_qif_import);
+    }
+
+    scm_c_eval_string("(use-modules (gnucash import-export qif-import))");
+
+    gnc_plugin_qif_import_create_plugin();
+
+    return TRUE;
+}
+
+int
+libgncmod_qif_import_gnc_module_end(int refcount)
+{
+    return TRUE;
+}

Copied: gnucash/trunk/src/import-export/qif-imp/gschemas/Makefile.am (from rev 23566, gnucash/trunk/src/import-export/qif-import/gschemas/Makefile.am)
===================================================================
--- gnucash/trunk/src/import-export/qif-imp/gschemas/Makefile.am	                        (rev 0)
+++ gnucash/trunk/src/import-export/qif-imp/gschemas/Makefile.am	2013-12-15 17:21:20 UTC (rev 23567)
@@ -0,0 +1,10 @@
+ at INTLTOOL_XML_NOMERGE_RULE@
+
+gschema_in_files = \
+  org.gnucash.dialogs.import.qif.gschema.xml.in
+
+gsettings_SCHEMAS = $(gschema_in_files:.gschema.xml.in=.gschema.xml)
+
+ at GSETTINGS_RULES@
+
+CLEANFILES = $(gsettings_SCHEMAS)

Copied: gnucash/trunk/src/import-export/qif-imp/gschemas/org.gnucash.dialogs.import.qif.gschema.xml.in.in (from rev 23566, gnucash/trunk/src/import-export/qif-import/gschemas/org.gnucash.dialogs.import.qif.gschema.xml.in.in)
===================================================================
--- gnucash/trunk/src/import-export/qif-imp/gschemas/org.gnucash.dialogs.import.qif.gschema.xml.in.in	                        (rev 0)
+++ gnucash/trunk/src/import-export/qif-imp/gschemas/org.gnucash.dialogs.import.qif.gschema.xml.in.in	2013-12-15 17:21:20 UTC (rev 23567)
@@ -0,0 +1,36 @@
+<schemalist gettext-domain="@GETTEXT_PACKAGE@">
+  <schema id="org.gnucash.dialogs.import.qif" path="/org/gnucash/dialogs/import/qif/">
+    <key name="default-status-notcleared" type="b">
+      <default>true</default>
+      <summary>Default QIF transaction status</summary>
+      <description>Default status for QIF transaction when not specified in QIF file.</description>
+    </key>
+    <key name="default-status-cleared" type="b">
+      <default>false</default>
+      <summary>Default QIF transaction status</summary>
+      <description>Default status for QIF transaction when not specified in QIF file.</description>
+    </key>
+    <key name="default-status-reconciled" type="b">
+      <default>false</default>
+      <summary>When the status is not specified in a QIF file, the transactions are marked as reconciled.</summary>
+      <description>Default status for QIF transaction when not specified in QIF file.</description>
+    </key>
+    <key name="last-geometry" type="(iiii)">
+      <default>(-1,-1,-1,-1)</default>
+      <summary>Last window position and size</summary>
+      <description>This setting describes the size and position of the window when it was last closed.
+        The numbers are the X and Y coordinates of the top left corner of the window
+        followed by the width and height of the window.</description>
+    </key>
+    <key name="last-path" type="s">
+      <default>''</default>
+      <summary>Last pathname used</summary>
+      <description>This field contains the last pathname used by this window. It will be used as the initial filename/pathname the next time this window is opened.</description>
+    </key>
+    <key name="show-doc" type="b">
+      <default>true</default>
+      <summary>Show documentation</summary>
+      <description>Show some documentation-only pages in QIF Import assistant.</description>
+    </key>
+  </schema>
+</schemalist>

Copied: gnucash/trunk/src/import-export/qif-imp/qif-dialog-utils.scm (from rev 23566, gnucash/trunk/src/import-export/qif-import/qif-dialog-utils.scm)
===================================================================
--- gnucash/trunk/src/import-export/qif-imp/qif-dialog-utils.scm	                        (rev 0)
+++ gnucash/trunk/src/import-export/qif-imp/qif-dialog-utils.scm	2013-12-15 17:21:20 UTC (rev 23567)
@@ -0,0 +1,903 @@
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;;  qif-dialog-utils.scm
+;;;  build qif->gnc account maps and put them in a displayable
+;;;  form.
+;;;
+;;;  Bill Gribble <grib at billgribble.com> 20 Feb 2000
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+
+(define (default-stock-acct brokerage security)
+  (string-append brokerage (gnc-get-account-separator-string) security))
+
+(define (default-dividend-acct brokerage security)
+  (string-append (_ "Income") (gnc-get-account-separator-string)
+                 (_ "Dividends") (gnc-get-account-separator-string)
+                 brokerage (gnc-get-account-separator-string)
+                 security))
+
+(define (default-interest-acct brokerage security)
+  (string-append (_ "Income") (gnc-get-account-separator-string)
+                 (_ "Interest") (gnc-get-account-separator-string)
+                 brokerage
+                 (if (string=? security "")
+                  ""
+                  (string-append (gnc-get-account-separator-string)
+                                  security))))
+
+(define (default-capital-return-acct brokerage security)
+  (string-append (_ "Income") (gnc-get-account-separator-string)
+                 (_ "Cap Return") (gnc-get-account-separator-string)
+                 brokerage (gnc-get-account-separator-string)
+                 security))
+
+(define (default-cglong-acct brokerage security)
+  (string-append (_ "Income") (gnc-get-account-separator-string)
+                 (_ "Cap. gain (long)") (gnc-get-account-separator-string)
+                 brokerage (gnc-get-account-separator-string)
+                 security))
+
+(define (default-cgmid-acct brokerage security)
+  (string-append (_ "Income") (gnc-get-account-separator-string)
+                 (_ "Cap. gain (mid)") (gnc-get-account-separator-string)
+                 brokerage (gnc-get-account-separator-string)
+                 security))
+
+(define (default-cgshort-acct brokerage security)
+  (string-append (_ "Income") (gnc-get-account-separator-string)
+                 (_ "Cap. gain (short)") (gnc-get-account-separator-string)
+                 brokerage (gnc-get-account-separator-string)
+                 security))
+
+(define (default-equity-holding security)
+  (string-append (_ "Equity") (gnc-get-account-separator-string)
+                 (_ "Retained Earnings")))
+
+(define (default-equity-account)
+  (string-append (_ "Equity") (gnc-get-account-separator-string)
+                 (_ "Retained Earnings")))
+
+(define (default-commission-acct brokerage)
+  (string-append (_ "Expenses") (gnc-get-account-separator-string)
+                 (_ "Commissions") (gnc-get-account-separator-string)
+                 brokerage))
+
+(define (default-margin-interest-acct brokerage)
+  (string-append (_ "Expenses") (gnc-get-account-separator-string)
+                 (_ "Margin Interest") (gnc-get-account-separator-string)
+                 brokerage))
+
+(define (default-unspec-acct)
+  (_ "Unspecified"))
+
+;; The following investment actions implicitly specify
+;; the two accounts involved in the transaction.
+(define qif-import:actions-implicit
+  (list 'buy 'cglong 'cgmid 'cgshort 'div 'intinc 'margint 'reinvdiv
+        'reinvint 'reinvlg 'reinvmd 'reinvsg 'reinvsh 'reminder
+        'rtrncap 'sell 'shrsin 'shrsout 'stksplit))
+
+
+(define (qif-import:gnc-account-exists map-entry acct-list)
+  (let ((retval #f))
+    (for-each
+     (lambda (acct)
+       (if (string=? (qif-map-entry:gnc-name map-entry)
+                     (cadr acct))
+           (set! retval #t)))
+     acct-list)
+    retval))
+
+;; the account-display is a 3-columned list of accounts in the QIF
+;; import dialog (the "Account" page of the notebook).  Column 1 is
+;; the account name in the QIF file, column 2 is the number of QIF
+;; xtns with that account name, and column 3 is the guess for the
+;; translation.  Sorted on # transactions, then alpha.
+
+(define (qif-dialog:make-account-display qif-files acct-hash gnc-acct-info)
+  ;; first, clear the "display" flags in the acct-hash and set up the
+  ;; new-file? flags.  If there's nothing to show any more, don't.
+  (hash-fold
+   (lambda (k v p)
+     (qif-map-entry:set-display?! v #f)
+     #f)
+   #f acct-hash)
+
+  (let ((retval '()))
+    ;; we want to make two passes here.  The first pass picks the
+    ;; explicit Account descriptions out of each file.  These are the
+    ;; best sources of info because we will have types and so on for
+    ;; them.  The second pass picks out account-style L fields and
+    ;; investment security names from the transactions.  Hopefully
+    ;; we'll have most of the accounts already located by that point.
+    ;; Otherwise, we have to guess them.
+
+    ;; acct-hash hashes the qif name to a <qif-map-entry> object.
+    ;; guess-acct returns one.
+    (for-each
+     (lambda (file)
+       ;; first, get the explicit account references.
+       (for-each
+        (lambda (acct)
+          (let ((entry (hash-ref acct-hash (qif-acct:name acct))))
+            (if (not entry)
+                (set! entry
+                      (qif-import:guess-acct (qif-acct:name acct)
+                                             (qif-acct:type acct)
+                                             gnc-acct-info)))
+            (qif-map-entry:set-description! entry (qif-acct:description acct))
+            (hash-set! acct-hash (qif-acct:name acct) entry)))
+        (qif-file:accounts file)))
+     qif-files)
+
+    ;; now make the second pass through the files, looking at the
+    ;; transactions.  Hopefully the accounts are all there already.
+    ;; stock accounts can have both a category/account and another
+    ;; account ref from the security name.
+    (for-each
+     (lambda (file)
+       (for-each
+        (lambda (xtn)
+          (let ((stock-acct (qif-xtn:security-name xtn))
+                (action (qif-xtn:action xtn))
+                (from-acct (qif-xtn:from-acct xtn))
+                (qif-account #f)
+                (qif-account-types #f)
+                (entry #f))
+
+            (if (and stock-acct action)
+                ;; stock transactions are weird.  there can be several
+                ;; accounts associated with stock xtns: the security,
+                ;; the brokerage, a dividend account, a long-term CG
+                ;; account, a short-term CG account, an interest
+                ;; account.  Make sure all of the right ones get stuck
+                ;; in the map.
+                (begin
+                  ;; first: figure out what the near-end account is.
+                  ;; it's generally the security account, but could be
+                  ;; an interest, dividend, or CG account.
+                  (case action
+                    ((buy buyx sell sellx reinvint reinvdiv reinvsh reinvsg
+                          reinvlg reinvmd shrsin shrsout stksplit)
+                     (set! qif-account
+                           (default-stock-acct from-acct stock-acct))
+                     (set! qif-account-types (list GNC-STOCK-TYPE
+                                                   GNC-MUTUAL-TYPE)))
+                    ((div cgshort cgmid cglong intinc miscinc miscexp
+                          margint rtrncap xin xout)
+                     (set! qif-account from-acct)
+                     (set! qif-account-types (list GNC-BANK-TYPE
+                                                   GNC-CCARD-TYPE
+                                                   GNC-CASH-TYPE
+                                                   GNC-ASSET-TYPE
+                                                   GNC-LIABILITY-TYPE
+                                                   GNC-RECEIVABLE-TYPE
+                                                   GNC-PAYABLE-TYPE)))
+
+                    ((divx cgshortx cgmidx cglongx intincx margintx rtrncapx)
+                     (set! qif-account
+                           (and (qif-split:category-is-account?
+                                  (car (qif-xtn:splits xtn)))
+                                (qif-split:category
+                                  (car (qif-xtn:splits xtn)))))
+                     (set! qif-account-types (list GNC-BANK-TYPE
+                                                   GNC-CCARD-TYPE
+                                                   GNC-CASH-TYPE
+                                                   GNC-ASSET-TYPE
+                                                   GNC-LIABILITY-TYPE
+                                                   GNC-RECEIVABLE-TYPE
+                                                   GNC-PAYABLE-TYPE)))
+                    ((miscincx miscexpx)
+                     (set! qif-account
+                           (qif-split:miscx-category
+                            (car (qif-xtn:splits xtn))))
+                     (set! qif-account-types (list GNC-BANK-TYPE
+                                                   GNC-CCARD-TYPE
+                                                   GNC-CASH-TYPE
+                                                   GNC-ASSET-TYPE
+                                                   GNC-LIABILITY-TYPE
+                                                   GNC-RECEIVABLE-TYPE
+                                                   GNC-PAYABLE-TYPE))))
+
+                  ;; now reference the near-end account
+                  (if qif-account
+                      (begin
+                        (set! entry (hash-ref acct-hash qif-account))
+                        (if (not entry)
+                            (set! entry
+                                  (qif-import:guess-acct qif-account
+                                                         qif-account-types
+                                                         gnc-acct-info)))
+                        (qif-map-entry:set-display?! entry #t)
+                        (hash-set! acct-hash qif-account entry)))
+
+                  ;; now figure out the other end of the transaction.
+                  ;; the far end will be the brokerage for buy, sell,
+                  ;; etc, or the "L"-referenced account for buyx,
+                  ;; sellx, etc, or an equity account for ShrsIn/ShrsOut
+
+                  ;; miscintx and miscexpx are very, very "special"
+                  ;; cases ... I'm not sure this is right.
+                  ;; the L line looks like :
+                  ;; LCategory/class [Account]/class
+                  ;; so I assume near-acct is Account and far acct
+                  ;; is Category.  This matches the intincx/divx
+                  ;; behavior.
+
+                  (set! qif-account #f)
+                  (case action
+                    ((buy sell)
+                     (set! qif-account from-acct)
+                     (set! qif-account-types (list GNC-BANK-TYPE
+                                                   GNC-CCARD-TYPE
+                                                   GNC-CASH-TYPE
+                                                   GNC-ASSET-TYPE
+                                                   GNC-LIABILITY-TYPE
+                                                   GNC-RECEIVABLE-TYPE
+                                                   GNC-PAYABLE-TYPE)))
+                    ((buyx sellx xin xout)
+                     (set! qif-account
+                           (and (qif-split:category-is-account?
+                                  (car (qif-xtn:splits xtn)))
+                                (qif-split:category
+                                  (car (qif-xtn:splits xtn)))))
+                     (set! qif-account-types (list GNC-BANK-TYPE
+                                                   GNC-CCARD-TYPE
+                                                   GNC-CASH-TYPE
+                                                   GNC-ASSET-TYPE
+                                                   GNC-LIABILITY-TYPE
+                                                   GNC-RECEIVABLE-TYPE
+                                                   GNC-PAYABLE-TYPE)))
+
+                    ((stksplit)
+                     (set! qif-account
+                           (default-stock-acct from-acct stock-acct))
+                     (set! qif-account-types (list GNC-STOCK-TYPE
+                                                   GNC-MUTUAL-TYPE
+                                                   GNC-ASSET-TYPE
+                                                   GNC-LIABILITY-TYPE
+                                                   GNC-RECEIVABLE-TYPE
+                                                   GNC-PAYABLE-TYPE)))
+                    ((cgshort cgshortx reinvsg reinvsh)
+                     (set! qif-account
+                           (default-cgshort-acct from-acct stock-acct))
+                     (set! qif-account-types (list GNC-INCOME-TYPE)))
+
+                    ((cgmid cgmidx reinvmd)
+                     (set! qif-account
+                           (default-cgmid-acct from-acct stock-acct))
+                     (set! qif-account-types (list GNC-INCOME-TYPE)))
+
+                    ((cglong cglongx reinvlg)
+                     (set! qif-account
+                           (default-cglong-acct from-acct stock-acct))
+                     (set! qif-account-types (list GNC-INCOME-TYPE)))
+
+                    ((intinc intincx reinvint)
+                     (set! qif-account
+                           (default-interest-acct from-acct stock-acct))
+                     (set! qif-account-types (list GNC-INCOME-TYPE)))
+
+                    ((div divx reinvdiv)
+                     (set! qif-account
+                           (default-dividend-acct from-acct stock-acct))
+                     (set! qif-account-types (list GNC-INCOME-TYPE)))
+
+                    ((rtrncap rtrncapx)
+                     (set! qif-account
+                           (default-capital-return-acct from-acct stock-acct))
+                     (set! qif-account-types (list GNC-INCOME-TYPE)))
+
+                    ((shrsin shrsout)
+                     (set! qif-account
+                           (default-equity-holding stock-acct))
+                     (set! qif-account-types (list GNC-EQUITY-TYPE)))
+
+                    ((margint margintx)
+                     (set! qif-account
+                           (default-margin-interest-acct from-acct))
+                     (set! qif-account-types (list GNC-EXPENSE-TYPE)))
+
+                    ((miscinc miscexp miscincx miscexpx)
+                     ;; these reference a category on the other end
+                     (set! qif-account #f)))
+
+                  ;; now reference the far-end account
+                  (if qif-account
+                      (begin
+                        (set! entry (hash-ref acct-hash qif-account))
+                        (if (not entry)
+                            (set! entry (qif-import:guess-acct
+                                         qif-account qif-account-types
+                                         gnc-acct-info)))
+                        (qif-map-entry:set-display?! entry #t)
+                        (hash-set! acct-hash qif-account entry)))
+
+                  ;; if there's a commission, reference the
+                  ;; commission account
+                  (if (qif-xtn:commission xtn)
+                      (begin
+                        (set! qif-account
+                              (default-commission-acct from-acct))
+                        (set! entry
+                              (hash-ref acct-hash qif-account))
+                        (if (not entry)
+                            (set! entry
+                                  (qif-import:guess-acct
+                                   qif-account
+                                   (list GNC-EXPENSE-TYPE)
+                                   gnc-acct-info)))
+                        (qif-map-entry:set-display?! entry #t)
+                          (hash-set! acct-hash qif-account entry))))
+
+                ;; non-stock transactions.  these are a bit easier.
+                ;; the near-end account (from) is always in the
+                ;; transaction, and the far end(s) are in the splits.
+                (begin
+                  (set! entry (hash-ref acct-hash from-acct))
+                  (if (not entry)
+                      (set! entry (qif-import:guess-acct
+                                   from-acct
+                                   (list GNC-BANK-TYPE
+                                         GNC-CCARD-TYPE
+                                         GNC-CASH-TYPE
+                                         GNC-ASSET-TYPE
+                                         GNC-LIABILITY-TYPE
+                                         GNC-RECEIVABLE-TYPE
+                                         GNC-PAYABLE-TYPE)
+                                   gnc-acct-info)))
+                  (qif-map-entry:set-display?! entry #t)
+                  (hash-set! acct-hash from-acct entry)
+
+                  ;; iterate over the splits doing the same thing.
+                  (for-each
+                   (lambda (split)
+                     (let ((xtn-is-acct (qif-split:category-is-account? split))
+                           (xtn-acct #f)
+                           (entry #f))
+                       (if xtn-is-acct
+                           (begin
+                             (set! xtn-acct (qif-split:category split))
+                             (set! entry (hash-ref acct-hash xtn-acct))
+                             (if (not entry)
+                                 (set! entry
+                                       (qif-import:guess-acct
+                                        xtn-acct
+                                        (list GNC-BANK-TYPE
+                                              GNC-CCARD-TYPE
+                                              GNC-CASH-TYPE
+                                              GNC-ASSET-TYPE
+                                              GNC-LIABILITY-TYPE
+                                              GNC-RECEIVABLE-TYPE
+                                              GNC-PAYABLE-TYPE)
+                                        gnc-acct-info)))
+                             (qif-map-entry:set-display?! entry #t)
+                             (hash-set! acct-hash xtn-acct entry)))))
+                   (qif-xtn:splits xtn))))))
+        (qif-file:xtns file)))
+     qif-files)
+
+    ;; now that the hash table is filled, make the display list
+    (hash-fold
+     (lambda (k v p)
+       (if (qif-map-entry:display? v)
+           (begin
+             (qif-map-entry:set-new-acct?!
+              v (not (qif-import:gnc-account-exists v gnc-acct-info)))
+             (set! retval (cons v retval))))
+       #f)
+     #f acct-hash)
+
+    ;; sort by number of transactions with that account so the
+    ;; most important are at the top
+    (set! retval
+          (sort retval
+                (lambda (a b)
+                  (string<? (qif-map-entry:qif-name a)
+                            (qif-map-entry:qif-name b)))))
+    retval))
+
+
+;; the category display is similar to the Account display.
+;; QIF category name, xtn count, then GNUcash account.
+
+(define (qif-dialog:make-category-display qif-files cat-hash gnc-acct-info)
+  ;; first, clear the "display" flags in the cat-hash.  If there's
+  ;; nothing to show any more, don't.
+  (hash-fold
+   (lambda (k v p)
+     (qif-map-entry:set-display?! v #f)
+     #f)
+   #f cat-hash)
+
+  (let ((retval '())
+        (entry #f))
+    ;; get the Cat entries from each file
+    (for-each
+     (lambda (file)
+       (for-each
+        (lambda (cat)
+          (set! entry (hash-ref cat-hash (qif-cat:name cat)))
+          (if (not entry)
+              (set! entry
+                    (qif-import:guess-acct (qif-cat:name cat)
+                                           (if (qif-cat:expense-cat cat)
+                                               (list GNC-EXPENSE-TYPE
+                                                     GNC-INCOME-TYPE)
+                                               (list GNC-INCOME-TYPE
+                                                     GNC-EXPENSE-TYPE))
+                                           gnc-acct-info)))
+          (qif-map-entry:set-description!
+           entry (qif-cat:description cat))
+          (hash-set! cat-hash (qif-cat:name cat) entry))
+        (qif-file:cats file)))
+     qif-files)
+
+    ;; now look at every transaction and increment the count
+    ;; in the account slot if the string matches, or make a
+    ;; new hash reference if not.
+    (for-each
+     (lambda (qif-file)
+       (for-each
+        (lambda (xtn)
+          (let ((action (qif-xtn:action xtn)))
+            ;; Many types of investment transactions implicitly use the
+            ;; brokerage account or a known offshoot. There is no need
+            ;; to consider a category mapping for these.
+            (if (not (and action
+                          (memv action qif-import:actions-implicit)))
+                ;; iterate over the splits
+                (for-each
+                 (lambda (split)
+                   (let ((xtn-is-acct (qif-split:category-is-account? split))
+                         (xtn-cat #f)
+                         (entry #f))
+                     (if (not xtn-is-acct)
+                         (begin
+                           (set! xtn-cat (qif-split:category split))
+                           (set! entry (hash-ref cat-hash xtn-cat))
+                           ;; NOTE: It would be more robust and efficient if the
+                           ;; three "make display" routines below were combined:
+                           ;;   make-account-display
+                           ;;   make-category-display
+                           ;;   make-memo-display
+                           ;;
+                           ;; This would also require adjusting several callback
+                           ;; functions that reference these procedures from C.
+                           ;;
+                           ;; Until then, the maintainer of this code must make
+                           ;; sure that the logic used in the "if" below matches
+                           ;; the criteria for making memo/payee mappings (seen
+                           ;; in make-memo-display).
+
+                           ;; Add an entry if there isn't one already and either
+                           ;;  (a) the category is non-blank, or
+                           ;;  (b) no memo/payee mapping can be applied
+                           (if (and (not entry)
+                                    (or (not (and (string? xtn-cat)
+                                                  (string=? xtn-cat "")))
+                                        (and (or (not (qif-split:memo split))
+                                                 (equal? (qif-split:memo split) ""))
+                                             (or (> (length (qif-xtn:splits xtn)) 1)
+                                                 (not (qif-xtn:payee xtn))
+                                                 (equal? (qif-xtn:payee xtn) "")))))
+                               (set! entry
+                                     (qif-import:guess-acct
+                                      xtn-cat
+                                      (if (gnc-numeric-positive-p
+                                           (qif-split:amount split))
+                                          (list GNC-INCOME-TYPE
+                                                GNC-EXPENSE-TYPE)
+                                          (list GNC-EXPENSE-TYPE
+                                                GNC-INCOME-TYPE))
+                                      gnc-acct-info)))
+                           (if entry
+                               (begin
+                                 (qif-map-entry:set-display?! entry #t)
+                                 (hash-set! cat-hash xtn-cat entry)))))))
+                 (qif-xtn:splits xtn)))))
+        (qif-file:xtns qif-file)))
+     qif-files)
+
+    ;; now that the hash table is filled, make the display list
+    (hash-fold
+     (lambda (k v p)
+       (if (qif-map-entry:display? v)
+           (begin
+             (qif-map-entry:set-new-acct?!
+              v (not (qif-import:gnc-account-exists v gnc-acct-info)))
+             (set! retval (cons v retval))))
+       #f)
+     #f cat-hash)
+
+    ;; sort by qif account name
+    (set! retval (sort retval
+                       (lambda (a b)
+                         (string<? (qif-map-entry:qif-name a)
+                                   (qif-map-entry:qif-name b)))))
+    retval))
+
+;; this one's like the other display builders, it just looks at the
+;; payee and memo too.
+
+(define (qif-dialog:make-memo-display qif-files memo-hash gnc-acct-info)
+  (let ((retval '()))
+    ;; clear the display flags for existing items
+    (hash-fold
+     (lambda (k v p)
+       (qif-map-entry:set-display?! v #f)
+       #f)
+     #f memo-hash)
+
+    ;; iterate over every imported transaction.  If there's no
+    ;; category in the transaction, look at the payee to get a clue.
+    ;; of there's no payee, look at the split memo.
+    (for-each
+     (lambda (file)
+       (for-each
+        (lambda (xtn)
+          (let ((payee (qif-xtn:payee xtn))
+                (action (qif-xtn:action xtn))
+                (splits (qif-xtn:splits xtn)))
+            ;; Many types of investment transactions implicitly use the
+            ;; brokerage account or a known offshoot. There is no need
+            ;; to consider a memo/payee mapping for these.
+            (if (not (and action
+                          (memv action qif-import:actions-implicit)))
+                (for-each
+                 (lambda (split)
+                   (let ((cat (qif-split:category split))
+                         (memo (qif-split:memo split))
+                         (key-string #f))
+                     ;; for each split: if there's a category, do nothing.
+                     ;; if there's a payee, use that as the
+                     ;; key otherwise, use the split memo.
+                     (cond ((and cat
+                                 (or (not (string? cat))
+                                     (not (string=? cat ""))))
+                            (set! key-string #f))
+                           ((and payee (= (length splits) 1))
+                            (set! key-string payee))
+                           (memo
+                            (set! key-string memo)))
+
+                     (if key-string
+                         (let ((entry (hash-ref memo-hash key-string)))
+                           (if (not entry)
+                               (begin
+                                 (set! entry (make-qif-map-entry))
+                                 (qif-map-entry:set-qif-name! entry key-string)
+                                 (qif-map-entry:set-gnc-name!
+                                  entry (default-unspec-acct))
+                                 (qif-map-entry:set-allowed-types!
+                                  entry
+                                  (if (gnc-numeric-positive-p
+                                       (qif-split:amount split))
+                                      (list GNC-INCOME-TYPE GNC-EXPENSE-TYPE
+                                            GNC-BANK-TYPE GNC-CCARD-TYPE
+                                            GNC-LIABILITY-TYPE GNC-ASSET-TYPE
+                                            GNC-RECEIVABLE-TYPE GNC-PAYABLE-TYPE
+                                            GNC-STOCK-TYPE GNC-MUTUAL-TYPE)
+                                      (list GNC-EXPENSE-TYPE GNC-INCOME-TYPE
+                                            GNC-BANK-TYPE GNC-CCARD-TYPE
+                                            GNC-LIABILITY-TYPE GNC-ASSET-TYPE
+                                            GNC-RECEIVABLE-TYPE GNC-PAYABLE-TYPE
+                                            GNC-STOCK-TYPE GNC-MUTUAL-TYPE)))))
+                           (qif-map-entry:set-display?! entry #t)
+                           (hash-set! memo-hash key-string entry)))))
+                 splits))))
+        (qif-file:xtns file)))
+     qif-files)
+
+    ;; build display list
+    (hash-fold
+     (lambda (k v p)
+       (if (qif-map-entry:display? v)
+           (begin
+             (qif-map-entry:set-new-acct?!
+              v (not (qif-import:gnc-account-exists v gnc-acct-info)))
+             (set! retval (cons v retval))))
+       #f)
+     #f memo-hash)
+
+    ;; sort by qif memo/payee name
+    (set! retval (sort retval
+                       (lambda (a b)
+                         (string<? (qif-map-entry:qif-name a)
+                                   (qif-map-entry:qif-name b)))))
+    retval))
+
+
+(define (qif-dialog:qif-file-loaded? filename list-of-files)
+  (let ((status (map
+                 (lambda (file)
+                   (string=? filename (qif-file:path file)))
+                 list-of-files)))
+    (if (memq #t status)
+        #t
+        #f)))
+
+(define (qif-dialog:unload-qif-file oldfile list-of-files)
+  (delq oldfile list-of-files))
+
+(define (qif-import:any-new-accts? hash-table)
+  (let ((retval #f))
+    (for-each
+     (lambda (bin)
+       (for-each
+        (lambda (elt)
+          (if (and (qif-map-entry:new-acct? (cdr elt))
+                   (qif-map-entry:display? (cdr elt)))
+              (set! retval #t)))
+        bin))
+     (vector->list hash-table))
+    retval))
+
+(define (qif-import:fix-from-acct qif-file new-acct-name)
+  (for-each
+   (lambda (xtn)
+     (if (not (qif-xtn:from-acct xtn))
+         (qif-xtn:set-from-acct! xtn new-acct-name)))
+   (qif-file:xtns qif-file)))
+
+
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;  qif-import:get-account-name
+;;
+;;  Given an account name, return the rightmost subaccount.
+;;  For example, given the account name "foo:bar", "bar" is
+;;  returned (assuming the account separator is ":").
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+
+(define (qif-import:get-account-name fullname)
+  (let* ((sep (gnc-get-account-separator-string))
+         (last-sep (gnc:string-rcontains fullname sep)))
+    (if last-sep
+        (substring fullname (+ last-sep (string-length sep)))
+        fullname)))
+
+
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;  qif-dialog:default-namespace
+;;
+;;  Given a security's QIF symbol and type, along with all
+;;  previously seen security mapping preferences, return a
+;;  default namespace.
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+(define (qif-dialog:default-namespace qif-symbol qif-type prefs)
+
+  ;; Guess a namespace based on the symbol alone.
+  (define (guess-by-symbol s)
+    (if (string? s)
+      (let ((l (string-length s))
+            (d (string-index s #\.))
+            (pref-match
+              (if (list? prefs)
+                  (find (lambda (elt)
+                          ;; Does the symbol match, and is the namespace
+                          ;; compatible with the QIF type?
+                          (and (string=? s (caddr elt))
+                               (not (and (string? qif-type)
+                                         (string=? GNC_COMMODITY_NS_MUTUAL
+                                                   (cadr elt))
+                                         (or (string-ci=? qif-type "stock")
+                                             (string-ci=? qif-type "etf"))))))
+                        prefs)
+                   #f)))
+        (cond
+          ;; If a preferences match was found, use its namespace.
+          (pref-match
+           (cadr pref-match))
+
+          ;; Guess NYSE for symbols of 1-3 characters.
+          ((< l 4)
+           GNC_COMMODITY_NS_NYSE)
+
+          ;; Guess NYSE for symbols of 1-3 characters
+          ;; followed by a dot and 1-2 characters.
+          ((and d
+                (< l 7)
+                (< 0 d 4)
+                (<= 2 (- l d) 3))
+           GNC_COMMODITY_NS_NYSE)
+
+          ;; Guess NASDAQ for symbols of 4 characters.
+          ((= l 4)
+           GNC_COMMODITY_NS_NASDAQ)
+
+          ;; Otherwise it's probably a fund.
+          (else
+           GNC_COMMODITY_NS_MUTUAL)))
+      ;; There's no symbol. Default to a fund.
+      GNC_COMMODITY_NS_MUTUAL))
+
+  ;; Was a QIF type given?
+  (if (string? qif-type)
+     ;; Yes. We might be able to definitely determine the namespace.
+     (cond
+       ;; Mutual fund
+       ((string-ci=? qif-type "mutual fund")
+        GNC_COMMODITY_NS_MUTUAL)
+
+       ;; Index
+       ((string-ci=? qif-type "index")
+        ;; This QIF type must be wrong; indexes aren't tradable!
+        GNC_COMMODITY_NS_MUTUAL)
+
+       (else
+        (guess-by-symbol qif-symbol)))
+
+     ;; No QIF type was given, so guess a
+     ;; default namespace by symbol alone.
+     (guess-by-symbol qif-symbol)))
+
+
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;  qif-import:update-security-hash
+;;
+;;  For each QIF security in acct-hash, find a matching
+;;  GnuCash security or create a new one, then add it to the
+;;  security-hash table. Return a list of security-hash keys
+;;  for all newly created GnuCash securities, or #f if none.
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+
+(define (qif-import:update-security-hash security-hash ticker-map
+                                         acct-hash sec-prefs)
+  (let ((names '()))
+    (hash-fold
+     (lambda (qif-name map-entry p)
+       (let ((security-name (qif-import:get-account-name qif-name)))
+         ;; Is this account going to be imported, is it security-denominated,
+         ;; and is the security not already in the security hash table?
+         (if (and
+              security-name
+              (qif-map-entry:display? map-entry)
+              (or (memv GNC-STOCK-TYPE
+                        (qif-map-entry:allowed-types map-entry))
+                  (memv GNC-MUTUAL-TYPE
+                        (qif-map-entry:allowed-types map-entry)))
+              (not (hash-ref security-hash security-name)))
+             (let ((existing-gnc-acct
+                     (gnc-account-lookup-by-full-name
+                      (gnc-get-current-root-account)
+                      (qif-map-entry:gnc-name map-entry)))
+                   (book (gnc-account-get-book (gnc-get-current-root-account))))
+               ;; Are we importing to an existing, security-denominated account?
+               (if (and (not (null? existing-gnc-acct))
+                        (memv (xaccAccountGetType existing-gnc-acct)
+                              (list GNC-STOCK-TYPE GNC-MUTUAL-TYPE)))
+                   ;; Yes, so that security is the one to use. Add it
+                   ;; to the security hash table.
+                   (let ((commodity
+                          (xaccAccountGetCommodity existing-gnc-acct)))
+                     (hash-set! security-hash security-name commodity))
+
+                   ;; Otherwise, since we can't definitively match this QIF
+                   ;; security to a GnuCash security, create a new one with
+                   ;; some (hopefully) intelligent defaults.
+                   (let* ((qif-symbol
+                            (qif-ticker-map:lookup-symbol ticker-map
+                                                          security-name))
+                          (qif-type
+                            (qif-ticker-map:lookup-type ticker-map
+                                                        security-name))
+                          (namespace (qif-dialog:default-namespace qif-symbol
+                                                                   qif-type
+                                                                   sec-prefs)))
+
+                     ;; If no symbol has been provided, default to the name.
+                     (if (not qif-symbol)
+                         (set! qif-symbol security-name))
+
+                     ;; Create the new security and add it to the hash table.
+                     (hash-set! security-hash
+                                security-name
+                                (gnc-commodity-new book
+                                                   security-name
+                                                   namespace
+                                                   qif-symbol
+                                                   ""
+                                                   100000))
+
+                     ;; Add the hash key to the list to be returned.
+                     (set! names (cons security-name names))))))
+         #f))
+     #f acct-hash)
+
+    (if (not (null? names))
+        (sort names string<?)
+        #f)))
+
+;; this is used within the dialog to get a list of all the new
+;; accounts the importer thinks it's going to make.  Passed to the
+;; account picker.
+;;
+;; returned is a tree-structured list of all the old and new accounts
+;; like so : (name new? children).  trees are sorted alphabetically.
+;; This should probably change but it's beeter than no sort at all.
+
+(define (qif-import:get-all-accts extra-maps)
+  (define (cvt-to-tree path new?)
+    (if (null? path)
+        '()
+        (list (car path) new?
+              (if (null? (cdr path)) '()
+                  (list (cvt-to-tree (cdr path) new?))))))
+
+  (define (merge-into-tree tree path new?)
+    (if (null? path)
+        tree
+        (if (null? tree)
+            (list (cvt-to-tree path new?))
+            (let ((newtree '()))
+              (let loop ((tree-elt (car tree))
+                         (tree-left (cdr tree)))
+                (if (string=? (car path) (car tree-elt))
+                    (let ((old-children (caddr tree-elt)))
+                      (set! newtree
+                            (cons (list (car path)
+                                        (and new? (cadr tree-elt))
+                                        (merge-into-tree
+                                         old-children (cdr path) new?))
+                                  (append newtree tree-left))))
+                    (begin
+                      (set! newtree (cons tree-elt newtree))
+                      (if (not (null? tree-left))
+                          (loop (car tree-left) (cdr tree-left))
+                          (set! newtree (cons (cvt-to-tree path new?)
+                                              newtree))))))
+              (sort newtree (lambda (a b) (string<? (car a) (car b))))))))
+
+
+  (let ((accts '())
+        (acct-tree '())
+        (sep (gnc-get-account-separator-string)))
+
+    ;; get the new accounts from the account map
+    (for-each
+     (lambda (acctmap)
+       (if acctmap
+           (hash-fold
+            (lambda (k v p)
+              (if (qif-map-entry:display? v)
+                  (set! accts
+                        (cons
+                         (cons (gnc:substring-split (qif-map-entry:gnc-name v)
+                                                    sep)
+                               (qif-map-entry:new-acct? v))
+                         accts)))
+              #f)
+            #f acctmap)))
+     extra-maps)
+
+    ;; get the old accounts from the current account group
+    (for-each
+     (lambda (acct)
+       (set! accts
+             (cons
+              (cons (gnc:substring-split (gnc-account-get-full-name acct) sep)
+                    #f)
+              accts)))
+     (gnc-account-get-descendants-sorted (gnc-get-current-root-account)))
+
+    ;; now build a tree structure
+    (for-each
+     (lambda (acct)
+       (set! acct-tree
+             (merge-into-tree acct-tree (car acct) (cdr acct))))
+     accts)
+
+    ;; we're done
+    acct-tree))
+
+(define (qif-import:refresh-match-selection matches item)
+  (if (> item -1)
+      (let ((i 0))
+        (for-each
+         (lambda (match)
+           (if (= i item)
+               (if (cdr match)
+                   (set-cdr! match #f)
+                   (set-cdr! match #t))
+               (set-cdr! match #f))
+           (set! i (+ 1 i)))
+         matches))))

Copied: gnucash/trunk/src/import-export/qif-imp/qif-file.scm (from rev 23566, gnucash/trunk/src/import-export/qif-import/qif-file.scm)
===================================================================
--- gnucash/trunk/src/import-export/qif-imp/qif-file.scm	                        (rev 0)
+++ gnucash/trunk/src/import-export/qif-imp/qif-file.scm	2013-12-15 17:21:20 UTC (rev 23567)
@@ -0,0 +1,1018 @@
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;;  qif-file.scm
+;;;
+;;;  Read a QIF file into a <qif-file> object.
+;;;
+;;;  Bill Gribble <grib at billgribble.com> 20 Feb 2000
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+
+(use-modules (gnucash core-utils))
+(use-modules (gnucash printf))
+(use-modules (ice-9 regex))
+(use-modules (srfi srfi-13))
+(use-modules (ice-9 rdelim))
+
+(define qif-bad-numeric-rexp
+  (make-regexp "^\\.\\.\\."))
+
+(define (not-bad-numeric-string? input)
+  (let ((match (regexp-exec qif-bad-numeric-rexp input)))
+    (if match #f #t)))
+
+
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;  qif-file:read-file
+;;
+;;  Suck in all the lines. Don't do any string interpretation,
+;;  just store the fields "raw".
+;;
+;;  The return value will be:
+;;    success:   ()
+;;    failure:   (#f error-message)
+;;    warning:   (#t error-message)
+;;    cancel:    #t
+;;    exception: #f
+;;
+;; FIXME: This function really should be able to return multiple
+;;        errors and warnings rather than a single one.
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+
+(define (qif-file:read-file self path ticker-map progress-dialog)
+
+  ;; This procedure does all the work. We'll define it, then call it safely.
+  (define (private-read)
+    (let ((qstate-type #f)
+          (current-xtn #f)
+          (current-split #f)
+          (current-account-name #f)
+          (last-seen-account-name #f)
+          (default-split #f)
+          (first-xtn #f)
+          (ignore-accounts #f)
+          (private-retval '())
+          (line-num 0)
+          (line #f)
+          (tag #f)
+          (value #f)
+          (abort-read #f)
+          (delimiters (string #\cr #\nl))
+          (file-stats #f)
+          (file-size 0)
+          (bytes-read 0))
+
+      ;; This procedure simplifies handling of warnings.
+      (define (mywarn . args)
+        (let ((str (gnc:list-display-to-string
+                     (append (list (_ "Line") " " line-num ": ") args))))
+          (set! private-retval (list #t str))
+          (qif-import:log progress-dialog "qif-file:read-file" str)))
+
+
+      ;; This procedure simplifies handling of failures
+      (define (myfail . args)
+        (let ((str (gnc:list-display-to-string
+                         (append (list (_ "Line") " " line-num ": ") args))))
+          (set! private-retval (list #f str))
+          (qif-import:log progress-dialog "qif-file:read-file"
+                          (string-append str "\n" (_ "Read aborted.")))
+          (set! abort-read #t)))
+
+
+      (qif-file:set-path! self path)
+      (if (not (access? path R_OK))
+          ;; A UTF-8 encoded path won't succeed on some systems, such as
+          ;; Windows XP. Try encoding the path according to the locale.
+          (set! path (gnc-locale-from-utf8 path)))
+      (set! file-stats (stat path))
+      (set! file-size (stat:size file-stats))
+
+
+      (if progress-dialog
+          (gnc-progress-dialog-set-sub progress-dialog
+                                       (string-append (_ "Reading") " " path)))
+
+      (with-input-from-file path
+        (lambda ()
+          ;; loop over lines
+          (let line-loop ()
+            (set! line (read-delimited delimiters))
+            (set! line-num (+ 1 line-num))
+            (if (and (not (eof-object? line))
+                     (not (string=? line "")))
+                (begin
+                  ;; Add to the bytes-read tally.
+                  (set! bytes-read
+                        (+ bytes-read 1 (string-length line)))
+
+                  ;; Pick the 1-char tag off from the remainder of the line.
+                  (set! tag (string-ref line 0))
+                  (set! value (substring line 1))
+
+                  ;; If the line doesn't conform to UTF-8, try a default
+                  ;; character set conversion based on the locale. If that
+                  ;; fails, remove any invalid characters.
+                  (if (not (gnc-utf8? value))
+                      (let ((converted-value (gnc-locale-to-utf8 value)))
+                        (if (or (string=? converted-value "")
+                                (not (gnc-utf8? converted-value)))
+                            (begin
+                              (set! value (gnc-utf8-strip-invalid-strdup value))
+                              (mywarn
+                               (_ "Some characters have been discarded.")
+                               " " (_"Converted to: ") value))
+                            (begin
+                              (mywarn
+                               (_ "Some characters have been converted according to your locale.")
+                               " " (_"Converted to: ") converted-value)
+                              (set! value converted-value)))))
+
+                  (if (eq? tag #\!)
+                      ;; The "!" tag has the highest precedence and is used
+                      ;; to switch between different sections of the file.
+                      (let ((old-qstate qstate-type))
+                        (set! qstate-type (qif-parse:parse-bang-field value))
+                        (case qstate-type
+                          ;; Transaction list for a particular account
+                          ((type:bank type:cash type:ccard type:invst type:port
+                            #{type:oth a}#  #{type:oth l}# #{type:oth s}#)
+                           (if ignore-accounts
+                               (set! current-account-name
+                                     last-seen-account-name))
+                           (set! ignore-accounts #f)
+                           (set! current-xtn (make-qif-xtn))
+                           (set! default-split (make-qif-split))
+                           (set! first-xtn #t))
+
+                          ;; Class list
+                          ((type:class)
+                           (set! current-xtn (make-qif-class)))
+
+                          ;; Category list
+                          ((type:cat)
+                           (set! current-xtn (make-qif-cat)))
+
+                          ;; Account list
+                          ((account)
+                           (set! current-xtn (make-qif-acct)))
+
+                          ;; Security list
+                          ((type:security)
+                           (set! current-xtn (make-qif-stock-symbol)))
+
+                          ;; Memorized transaction list
+                          ((type:memorized)
+                           ;; Not supported. We really should warn the user.
+                           #f)
+
+                          ;; Security price list
+                          ((type:prices)
+                           ;; Not supported. We really should warn the user.
+                           #f)
+
+                          ((option:autoswitch)
+                           (set! ignore-accounts #t))
+
+                          ((clear:autoswitch)
+                           (set! ignore-accounts #f))
+
+                          (else
+                           ;; Ignore any other "option:" identifiers and
+                           ;; just return to the previously known !type
+                           (if (string-match "^option:"
+                                             (symbol->string qstate-type))
+                               (begin
+                                 (mywarn (_ "Ignoring unknown option") " '"
+                                         qstate-type "'")
+                                 (set! qstate-type old-qstate))))))
+
+
+                      ;; It's not a "!" tag, so the meaning depends on what
+                      ;; type of section we are currently working on.
+                      (case qstate-type
+
+                        ;;;;;;;;;;;;;;;;;;;;;;
+                        ;; Transaction list ;;
+                        ;;;;;;;;;;;;;;;;;;;;;;
+
+                        ((type:bank type:cash type:ccard type:invst type:port
+                          #{type:oth a}#  #{type:oth l}# #{type:oth s}#)
+                         (case tag
+                           ;; D : transaction date
+                           ((#\D)
+                            (qif-xtn:set-date! current-xtn value))
+
+                           ;; T : total amount
+                           ((#\T)
+                            (if (and default-split
+                                    (not-bad-numeric-string? value))
+                                (qif-split:set-amount! default-split value)))
+
+                           ;; P : payee
+                           ((#\P)
+                            (qif-xtn:set-payee! current-xtn value))
+
+                           ;; A : address
+                           ;; multiple "A" lines are appended together with
+                           ;; newlines; some Quicken files have a lot of
+                           ;; A lines.
+                           ((#\A)
+                            (qif-xtn:set-address!
+                             current-xtn
+                             (let ((current (qif-xtn:address current-xtn)))
+                               (if (not (string? current))
+                                   (set! current ""))
+                               (string-append current "\n" value))))
+
+                           ;; N : For transactions involving a security, this
+                           ;; is the investment action. For all others,  this
+                           ;; is a check number or transaction number.
+                           ((#\N)
+                            (if (or (eq? qstate-type 'type:invst)
+                                    (eq? qstate-type 'type:port))
+                                (qif-xtn:set-action! current-xtn value)
+                                (qif-xtn:set-number! current-xtn value)))
+
+                           ;; C : cleared flag
+                           ((#\C)
+                            (qif-xtn:set-cleared! current-xtn value))
+
+                           ;; M : memo
+                           ((#\M)
+                            (if default-split
+                                (qif-split:set-memo! default-split value)))
+
+                           ;; I : share price (stock transactions)
+                           ((#\I)
+                            (qif-xtn:set-share-price! current-xtn value))
+
+                           ;; Q : number of shares (stock transactions)
+                           ((#\Q)
+                            (qif-xtn:set-num-shares! current-xtn value))
+
+                           ;; Y : name of security (stock transactions)
+                           ((#\Y)
+                            (qif-xtn:set-security-name! current-xtn value))
+
+                           ;; O : commission (stock transactions)
+                           ((#\O)
+                            (qif-xtn:set-commission! current-xtn value))
+
+                           ;; L : category
+                           ((#\L)
+                            (if default-split
+                                (qif-split:set-category! default-split value)))
+
+                           ;; S : split category
+                           ;; At this point we are ignoring the default-split
+                           ;; completely, but save it for later -- we need it
+                           ;; to determine whether to reverse the split values.
+                           ((#\S)
+                            (set! current-split (make-qif-split))
+                            (if default-split
+                                (qif-xtn:set-default-split! current-xtn
+                                                            default-split))
+                            (set! default-split #f)
+                            (qif-split:set-category! current-split value)
+                            (qif-xtn:set-splits!
+                               current-xtn
+                               (cons current-split
+                                     (qif-xtn:splits current-xtn))))
+
+                           ;; E : split memo
+                           ((#\E)
+                            (if current-split
+                                (qif-split:set-memo! current-split value)))
+
+                           ;; $ : split amount (if there are splits)
+                           ((#\$)
+                            (if (and current-split
+                                     (not-bad-numeric-string? value))
+                                (qif-split:set-amount! current-split value)))
+
+                           ;; ^ : end-of-record
+                           ((#\^)
+                            (if (null? (qif-xtn:splits current-xtn))
+                                (qif-xtn:set-splits! current-xtn
+                                                     (list default-split)))
+                            (if first-xtn
+                                (let ((opening-balance-payee
+                                       (qif-file:process-opening-balance-xtn
+                                        self current-account-name current-xtn
+                                        qstate-type)))
+                                  (if (not current-account-name)
+                                      (set! current-account-name
+                                            opening-balance-payee))
+                                  (set! first-xtn #f)))
+
+                            (if (and (or (eq? qstate-type 'type:invst)
+                                         (eq? qstate-type 'type:port))
+                                     (not (qif-xtn:security-name current-xtn)))
+                                (qif-xtn:set-security-name! current-xtn ""))
+
+                            (qif-xtn:set-from-acct! current-xtn
+                                                    current-account-name)
+
+                            (if (qif-xtn:date current-xtn)
+                                (qif-file:add-xtn! self current-xtn)
+                                ;; The date is missing! Warn the user.
+                                (mywarn (_ "Date required.") " "
+                                        (_ "Discarding this transaction.")))
+
+                            ;;(write current-xtn) (newline)
+                            (set! current-xtn (make-qif-xtn))
+                            (set! current-split #f)
+                            (set! default-split (make-qif-split)))))
+
+
+                        ;;;;;;;;;;;;;;;;
+                        ;; Class list ;;
+                        ;;;;;;;;;;;;;;;;
+
+                        ((type:class)
+                         (case tag
+                           ;; N : name
+                           ((#\N)
+                            (qif-class:set-name! current-xtn value))
+
+                           ;; D : description
+                           ((#\D)
+                            (qif-class:set-description! current-xtn value))
+
+                           ;; R : tax copy designator (ignored for now)
+                           ((#\R)
+                            #t)
+
+                           ;; end-of-record
+                           ((#\^)
+                            (qif-file:add-class! self current-xtn)
+                            (set! current-xtn (make-qif-class)))
+
+                           (else
+                            (mywarn (_ "Ignoring class line") ": " line))))
+
+
+                        ;;;;;;;;;;;;;;;;;;
+                        ;; Account List ;;
+                        ;;;;;;;;;;;;;;;;;;
+
+                        ((account)
+                         (case tag
+                           ((#\N)
+                            (qif-acct:set-name! current-xtn value)
+                            (set! last-seen-account-name value))
+                           ((#\D)
+                            (qif-acct:set-description! current-xtn value))
+                           ((#\T)
+                            (qif-acct:set-type! current-xtn value))
+                           ((#\L)
+                            (qif-acct:set-limit! current-xtn value))
+                           ((#\B)
+                            (qif-acct:set-budget! current-xtn value))
+                           ((#\^)
+                            (if (not ignore-accounts)
+                                (set! current-account-name
+                                      (qif-acct:name current-xtn)))
+                            (qif-file:add-account! self current-xtn)
+                            (set! current-xtn (make-qif-acct)))))
+
+
+                        ;;;;;;;;;;;;;;;;;;;
+                        ;; Category list ;;
+                        ;;;;;;;;;;;;;;;;;;;
+
+                        ((type:cat)
+                         (case tag
+                           ;; N : category name
+                           ((#\N)
+                            (qif-cat:set-name! current-xtn value))
+
+                           ;; D : category description
+                           ((#\D)
+                            (qif-cat:set-description! current-xtn value))
+
+                           ;; T : is this a taxable category?
+                           ((#\T)
+                            (qif-cat:set-taxable! current-xtn #t))
+
+                           ;; E : is this an expense category?
+                           ((#\E)
+                            (qif-cat:set-expense-cat! current-xtn #t))
+
+                           ;; I : is this an income category?
+                           ((#\I)
+                            (qif-cat:set-income-cat! current-xtn #t))
+
+                           ;; R : tax form/line designator
+                           ((#\R)
+                            (qif-cat:set-tax-class! current-xtn value))
+
+                           ;; B : budget amount.  not really supported.
+                           ((#\B)
+                            (qif-cat:set-budget-amt! current-xtn value))
+
+                           ;; end-of-record
+                           ((#\^)
+                            (qif-file:add-cat! self current-xtn)
+                            (set! current-xtn (make-qif-cat)))
+
+                           (else
+                            (mywarn (_ "Ignoring category line") ": " line))))
+
+
+                        ;;;;;;;;;;;;;;;;;;;
+                        ;; Security list ;;
+                        ;;;;;;;;;;;;;;;;;;;
+
+                        ((type:security)
+                         (case tag
+                           ;; N : stock name
+                           ((#\N)
+                            (qif-stock-symbol:set-name! current-xtn value))
+
+                           ;; S : ticker symbol
+                           ((#\S)
+                            (qif-stock-symbol:set-symbol! current-xtn value))
+
+                           ;; T : type
+                           ((#\T)
+                            (qif-stock-symbol:set-type! current-xtn value))
+
+                           ;; G : asset class (ignored)
+                           ((#\G)
+                            #t)
+
+                           ;; end-of-record
+                           ((#\^)
+                            (qif-ticker-map:add-ticker! ticker-map current-xtn)
+                            (set! current-xtn (make-qif-stock-symbol)))
+
+                           (else
+                            (mywarn (_ "Ignoring security line") ": " line))))
+
+
+                        ;; trying to sneak one by, eh?
+                        (else
+                          (if (and (not qstate-type)
+                                   (not (string=? (string-trim line) "")))
+                              (myfail
+                                (_ "File does not appear to be in QIF format")
+                                ": " line)))))
+
+                  ;; Report the progress.
+                  (if (and progress-dialog
+                           (zero? (remainder line-num 32)))
+                      (begin
+                        (gnc-progress-dialog-set-value progress-dialog
+                                                       (/ bytes-read file-size))
+                        (qif-import:check-pause progress-dialog)
+                        (if qif-import:canceled
+                            (begin
+                              (set! private-retval #t)
+                              (set! abort-read #t)))))
+
+                  ;; This is if we read a normal (non-null, non-eof) line...
+                  (if (not abort-read)
+                      (line-loop)))
+
+                ;; ...and this is if we read a null or eof line.
+                (if (and (not abort-read)
+                         (not (eof-object? line)))
+                    (line-loop))))))
+
+      ;; Reverse the transaction list so xtns are in the same order that
+      ;; they appeared in the file.  This is important in a few cases.
+      (qif-file:set-xtns! self (reverse (qif-file:xtns self)))
+
+      private-retval))
+
+
+  (gnc:backtrace-if-exception
+    (lambda ()
+      (let ((retval #f))
+        ;; Safely read the file.
+        (set! retval (gnc:backtrace-if-exception private-read))
+
+        ;; Fill the progress dialog.
+        (if (and progress-dialog
+                 (list? retval))
+          (gnc-progress-dialog-set-value progress-dialog 1))
+
+        retval))))
+
+
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;  qif-file:process-opening-balance-xtn
+;;
+;;  This gets called for the first transaction after a !Type: tag.
+;;
+;;  If the first transaction after a !Type: tag has a payee of
+;;  "Opening Balance", we have to massage the transaction a little.
+;;  The meaning of an OB transaction is "transfer from Equity to the
+;;  account specified in the L line." idiomatically, ms-money and some
+;;  others use this transaction instead of an Account record to
+;;  specify "this" account (the from-account for all following
+;;  transactions), so we have to allow for that.
+;;
+;;  Even if the payee isn't "Opening Balance", we know that if there's
+;;  no default from-account by this time, we need to set one.  In that
+;;  case, we set the default account based on the file name.
+;;
+;;  If we DO know the account already, and this is a tranfer to it,
+;;  it's also an opening balance regardless of the payee.
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+
+(define (qif-file:process-opening-balance-xtn self acct-name xtn type)
+  (let ((payee (qif-xtn:payee xtn))
+        (category (qif-split:category (car (qif-xtn:splits xtn))))
+        (cat-is-acct? (qif-split:category-is-account?
+                       (car (qif-xtn:splits xtn))))
+        (security (qif-xtn:security-name xtn)))
+    (if (or (and (not acct-name)
+                 (not security)
+                 payee (string? payee)
+                 (string=? (string-remove-trailing-space payee)
+                           "Opening Balance")
+                 cat-is-acct?)
+            (and acct-name (string? acct-name)
+                 (string=? acct-name category)
+                 (not security)))
+        ;; this is an explicit "Opening Balance" transaction.  we need
+        ;; to change the category to point to the equity account that
+        ;; the opening balance comes from.
+        (begin
+          (qif-split:set-category-private! (car (qif-xtn:splits xtn))
+                                           (default-equity-account))
+          (qif-split:set-category-is-account?! (car (qif-xtn:splits xtn)) #t)
+          (set! acct-name category)))
+    acct-name))
+
+;; return #t if all xtns have a non-#f from-acct otherwise, we will
+;; need to ask for an explicit account.
+(define (qif-file:check-from-acct self)
+  (let ((retval #t))
+    (for-each
+     (lambda (xtn)
+       (if (not (qif-xtn:from-acct xtn))
+           (set! retval #f)))
+     (qif-file:xtns self))
+    retval))
+
+;; if the date format was ambiguous, this will get called to reparse.
+(define (qif-file:reparse-dates self new-format)
+  (check-and-parse-field
+   qif-xtn:date qif-xtn:set-date! equal?
+   qif-parse:check-date-format (list new-format)
+   qif-parse:parse-date/format
+   (qif-file:xtns self)
+   qif-parse:print-date
+   'error-on-ambiguity (lambda (t e) e) 'date
+   (lambda (fraction) #t)))
+
+
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;  qif-file:parse-fields
+;;
+;;  Take a previously-read qif file and convert fields from
+;;  strings to the appropriate type.
+;;
+;;  The return value will be:
+;;    success:   ()
+;;    failure:   (#f . ((type . error) ...))
+;;    warning:   (#t . ((type . error) ...))
+;;    cancel:    #t
+;;    exception: #f
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+
+(define (qif-file:parse-fields self progress-dialog)
+
+  ;; This procedure does all the work. We'll define it, then call it safely.
+  (define (private-parse)
+   (let ((error #f)
+         (update-count 0)
+         (all-ok #f))
+
+     ;; This procedure sets a suboperation name.
+     (define (set-sub str)
+       (if progress-dialog
+           (gnc-progress-dialog-set-sub progress-dialog str))
+       #t)
+
+
+     ;; This procedure sets a suboperation weight.
+     (define (start-sub weight)
+       (if progress-dialog
+           (gnc-progress-dialog-push progress-dialog weight))
+       #t)
+
+
+     ;; This procedure finishes a suboperation.
+     (define (finish-sub)
+       (if progress-dialog
+           (gnc-progress-dialog-pop-full progress-dialog))
+       #t)
+
+
+     ;; This procedure handles progress reporting, pause, and cancel.
+     (define (update-progress fraction)
+       (set! update-count (+ 1 update-count))
+       (if (and progress-dialog
+                (zero? (remainder update-count 32)))
+           (begin
+             (gnc-progress-dialog-set-value progress-dialog fraction)
+             (qif-import:check-pause progress-dialog)
+             (if qif-import:canceled
+                 (throw 'cancel)))))
+
+
+     ;; This procedure is the generic error handler for parsing.
+     (define (add-error t e)
+       ;; Log the error message.
+       (if (string? e)
+           (qif-import:log progress-dialog
+                           "qif-file:parse-fields"
+                           (string-append (case t
+                                            ((date) (_ "Transaction date"))
+                                            ((split-amounts) (_ "Transaction amount"))
+                                            ((share-price) (_ "Share price"))
+                                            ((num-shares) (_ "Share quantity"))
+                                            ((action) (_ "Investment action"))
+                                            ((cleared) (_ "Reconciliation status"))
+                                            ((commission) (_ "Commission"))
+                                            ((acct-type) (_ "Account type"))
+                                            ((tax-class) (_ "Tax class"))
+                                            ((budget-amt) (_ "Category budget amount"))
+                                            ((budget) (_ "Account budget amount"))
+                                            ((limit) (_ "Credit limit"))
+                                            (else (symbol->string t)))
+                                          ": " e)))
+       ;; Save the error condition.
+       (if (not error)
+           (set! error (list (cons t e)))
+           (set! error (cons (cons t e) error))))
+
+
+     (and
+      ;;
+      ;; Fields of categories.
+      ;;
+      (set-sub (_ "Parsing categories"))
+      ;; The category tasks will be 5% of the overall parsing effort.
+      (start-sub 0.05)
+
+      ;; Tax classes; assume this is 50% of the category parsing effort.
+      (start-sub 0.5)
+      (check-and-parse-field
+       qif-cat:tax-class qif-cat:set-tax-class! gnc-numeric-equal
+       qif-parse:check-number-format '(decimal comma)
+       qif-parse:parse-number/format (qif-file:cats self)
+       qif-parse:print-number
+       'guess-on-ambiguity add-error 'tax-class
+       update-progress)
+      (finish-sub)
+
+      ;; Budget amounts; this is the last task for category parsing.
+      (start-sub 1)
+      (check-and-parse-field
+       qif-cat:budget-amt qif-cat:set-budget-amt! gnc-numeric-equal
+       qif-parse:check-number-format '(decimal comma)
+       qif-parse:parse-number/format (qif-file:cats self)
+       qif-parse:print-number
+       'guess-on-ambiguity add-error 'budget-amt
+       update-progress)
+      (finish-sub)
+
+      (finish-sub)
+
+
+      ;;
+      ;; Fields of accounts
+      ;;
+      (set-sub (_ "Parsing accounts"))
+      ;; The account tasks will be 5% of the overall parsing effort.
+      (start-sub 0.05)
+
+      ;; Account limits; assume this is 20% of the account parsing effort.
+      (start-sub 0.2)
+      (check-and-parse-field
+       qif-acct:limit qif-acct:set-limit! gnc-numeric-equal
+       qif-parse:check-number-format '(decimal comma)
+       qif-parse:parse-number/format (qif-file:accounts self)
+       qif-parse:print-number
+       'guess-on-ambiguity add-error 'limit
+       update-progress)
+      (finish-sub)
+
+      ;; Budget amounts; assume this is 20% of the account parsing effort.
+      (start-sub 0.2)
+      (check-and-parse-field
+       qif-acct:budget qif-acct:set-budget! gnc-numeric-equal
+       qif-parse:check-number-format '(decimal comma)
+       qif-parse:parse-number/format (qif-file:accounts self)
+       qif-parse:print-number
+       'guess-on-ambiguity add-error 'budget
+       update-progress)
+      (finish-sub)
+
+      ;; Account types; this is the last task for account parsing.
+      (start-sub 1)
+      (parse-field
+       qif-acct:type qif-acct:set-type!
+       qif-parse:parse-acct-type (qif-file:accounts self)
+       add-error 'acct-type
+       update-progress)
+      (finish-sub)
+
+      (finish-sub)
+
+
+      ;;
+      ;; fields of transactions
+      ;;
+      (set-sub (_ "Parsing transactions"))
+      ;; Transaction parsing takes up the rest of the overall parsing effort.
+      (start-sub 1)
+
+      ;; Dates; assume this is 15% of the transaction effort.
+      (start-sub 0.15)
+      (check-and-parse-field
+       qif-xtn:date qif-xtn:set-date! equal?
+       qif-parse:check-date-format '(m-d-y d-m-y y-m-d y-d-m)
+       qif-parse:parse-date/format
+       (qif-file:xtns self)
+       qif-parse:print-date
+       'error-on-ambiguity add-error 'date
+       update-progress)
+      (finish-sub)
+
+      ;; Clear flags; assume this is 5% of the transaction effort.
+      (start-sub 0.05)
+      (parse-field
+       qif-xtn:cleared qif-xtn:set-cleared!
+       qif-parse:parse-cleared-field (qif-file:xtns self)
+       add-error 'cleared
+       update-progress)
+      (finish-sub)
+
+      ;; Investment actions; assume this is 10% of the transaction effort.
+      (start-sub 0.1)
+      (parse-field
+       qif-xtn:action qif-xtn:set-action!
+       qif-parse:parse-action-field (qif-file:xtns self)
+       add-error 'action
+       update-progress)
+      (finish-sub)
+
+      ;; Share prices; assume this is 10% of the transaction effort.
+      (start-sub 0.1)
+      (check-and-parse-field
+       qif-xtn:share-price qif-xtn:set-share-price! gnc-numeric-equal
+       qif-parse:check-number-format '(decimal comma)
+       qif-parse:parse-number/format (qif-file:xtns self)
+       qif-parse:print-number
+       'guess-on-ambiguity add-error 'share-price
+       update-progress)
+      (finish-sub)
+
+      ;; Share quantities; assume this is 10% of the transaction effort.
+      (start-sub 0.1)
+      (check-and-parse-field
+       qif-xtn:num-shares qif-xtn:set-num-shares! gnc-numeric-equal
+       qif-parse:check-number-format '(decimal comma)
+       qif-parse:parse-number/format (qif-file:xtns self)
+       qif-parse:print-number
+       'guess-on-ambiguity add-error 'num-shares
+       update-progress)
+      (finish-sub)
+
+      ;; Commissions; assume this is 10% of the transaction effort.
+      (start-sub 0.1)
+      (check-and-parse-field
+       qif-xtn:commission qif-xtn:set-commission! gnc-numeric-equal
+       qif-parse:check-number-format '(decimal comma)
+       qif-parse:parse-number/format (qif-file:xtns self)
+       qif-parse:print-number
+       'guess-on-ambiguity add-error 'commission
+       update-progress)
+      (finish-sub)
+
+      ;; Splits; this is the rest of the transaction effort.
+      (start-sub 1)
+      ;; this one's a little tricky... it checks and sets all the
+      ;; split amounts for the transaction together.
+      (check-and-parse-field
+       qif-xtn:split-amounts qif-xtn:set-split-amounts! gnc-numeric-equal
+       qif-parse:check-number-formats '(decimal comma)
+       qif-parse:parse-numbers/format (qif-file:xtns self)
+       qif-parse:print-numbers
+       'guess-on-ambiguity add-error 'split-amounts
+       update-progress)
+      (finish-sub)
+
+      (finish-sub)
+
+
+      (begin
+        (set! all-ok #t)
+        #t))
+
+     ;; Determine what to return.
+     (cond (qif-import:canceled
+            #t)
+           (error
+            (cons all-ok error))
+           (else '()))))
+
+
+  ;; Safely read the file and return the result.
+  (gnc:backtrace-if-exception
+    (lambda () (catch 'cancel private-parse (lambda (key . args) #t)))))
+
+
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;  parse-field
+;;
+;;  A simplified version of check-and-parse-field which just
+;;  calls the parser on every instance of the field in the set
+;;  of objects.
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+
+(define (parse-field getter setter parser objects errorproc errortype reporter)
+  (let ((work-to-do (length objects))
+        (work-done 0)
+        (unparsed #f))
+    (for-each
+     (lambda (obj)
+       (set! unparsed (getter obj))
+       (if (and unparsed (string? unparsed))
+           (setter obj (parser unparsed errorproc errortype)))
+       (set! work-done (+ 1 work-done))
+       (reporter (/ work-done work-to-do)))
+     objects))
+  #t)
+
+
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;  check-and-parse-field
+;;
+;;  This is a semi-generic routine to apply a format check and
+;;  parsing routine to fields that can have multiple possible
+;;  formats.  In this case, any amount field cam be decimal or
+;;  comma radix and the date field can be any of several possible
+;;  types.
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+
+(define (check-and-parse-field getter setter equiv-thunk checker
+                               formats parser objects printer
+                               on-error errorproc errortype
+                               reporter)
+  (let* ((do-parsing #f)
+         (retval #t)
+         (format #f)
+         (len (length objects))
+         (work-to-do (* len 2))
+         (work-done 0))
+
+    ;; first find the right format for the field
+    ;; loop over objects.  If the formats list ever gets down
+    ;; to 1 element, we can stop right there.
+    (if (not (null? objects))
+        (let loop ((current (car objects))
+                   (rest (cdr objects)))
+          (let ((val (getter current)))
+            (if val
+                (begin
+                  (set! do-parsing #t)
+                  (set! formats (checker val formats))))
+            (set! work-done (+ 1 work-done))
+            (reporter (/ work-done work-to-do)))
+          (if (and (not (null? formats))
+                   ;; (not (null? (cdr formats)))
+                   (not (null? rest)))
+              (loop (car rest) (cdr rest)))))
+
+    ;; if there's nothing left in formats, there's no format that will
+    ;; fit all the values for a given field.  We have to give up at
+    ;; that point.
+
+    ;; If there are multiple items in formats, we look at the on-error
+    ;; arg.  If it's 'guess-on-ambiguity, we take the default (first)
+    ;; item in the list.  This is not super great.  if it's
+    ;; 'fail-on-ambiguity (or anything else, actually) we return the
+    ;; list of acceptable formats.
+
+    (cond
+     ((or (not formats)
+          (null? formats))
+      ;; Data was not in any of the supplied formats.
+      (errorproc errortype (_ "Unrecognized or inconsistent format."))
+      (set! retval #f)
+      (set! do-parsing #f))
+
+     ((and (not (null? (cdr formats))) do-parsing)
+      ;; There are multiple formats that fit.  If they all produce the
+      ;; same interpretation for every data point in the set, then
+      ;; just ignore the format ambiguity.  Otherwise, it's really an
+      ;; error.  ATM since there's no way to correct the error let's
+      ;; just leave it be.
+      (if (or (eq? on-error 'guess-on-ambiguity)
+              (all-formats-equivalent? getter parser equiv-thunk formats
+                                       objects printer errorproc errortype))
+          (set! format (car formats))
+          (begin
+            (errorproc errortype formats)
+            (set! do-parsing #f)
+            ;; NOTE: It seems like this ought to be (set! retval #f) instead,
+            ;;       but that would stop all parsing dead in its tracks. Not
+            ;;       sure that this can happen to anything other than dates,
+            ;;       and those will get reparsed anyway.
+            (set! retval #t))))
+     (else
+      (set! format (car formats))))
+
+    ;; do-parsing is false if there were no objects with non-#f values
+    ;; in the field, or the data format is ambiguous and
+    ;; 'fail-on-ambiguity was passed.  We would have had to look at
+    ;; all of them once, but at least not twice.
+    (if do-parsing
+        (for-each
+          (lambda (current)
+            (let ((val (getter current))
+                  (parsed #f))
+              (if val
+                  (begin
+                    (set! parsed (parser val format))
+                    (if parsed
+                        (setter current parsed)
+                        (begin
+                          (set! retval #f)
+                          (errorproc errortype
+                           (_ "Parsing failed.")))))))
+            (set! work-done (+ 1 work-done))
+            (reporter (/ work-done work-to-do)))
+         objects))
+
+    (if retval
+        (reporter 1))
+
+    retval))
+
+
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;  all-formats-equivalent?
+;;
+;;  This predicate checks for the off chance that even though
+;;  there are multiple possible interpretations they are all the
+;;  same. (i.e. the numbers "1000 2000 3000 4000" could be
+;;  interpreted as decimal or comma radix, but who cares?  The
+;;  values will be the same).
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+
+(define (all-formats-equivalent? getter parser equiv-thunk formats objects
+                                 printer errorproc errortype)
+  (let ((all-ok #t))
+    (let obj-loop ((objlist objects))
+      (let* ((unparsed (getter (car objlist)))
+             (parsed #f))
+        (if (string? unparsed)
+            (begin
+              ;; Parse using the first format in the list.
+              (set! parsed (parser unparsed (car formats)))
+              ;; For each remaining format, see if the result is the same.
+              (for-each
+               (lambda (fmt)
+                 (let ((this-parsed (parser unparsed fmt)))
+                   (if (not (equiv-thunk parsed this-parsed))
+                       (begin
+                         (set! all-ok #f)
+                         (if (not (eq? errortype 'date))
+                             (errorproc errortype
+                                        (gnc:list-display-to-string (list
+                              (_ "Parse ambiguity between formats") " "
+                              formats "\n"
+                              (sprintf #f (_ "Value '%s' could be %s or %s.")
+                                       parsed
+                                       (printer parsed)
+                                       (printer this-parsed))))))))))
+               (cdr formats))))
+        (if (and all-ok (not (null? (cdr objlist))))
+            (obj-loop (cdr objlist)))))
+    all-ok))
+
+
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;  qif-file:parse-fields-results
+;;
+;;  Take the results from qif-file:parse fields and find the
+;;  first result for a particular type of parse.
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+
+(define (qif-file:parse-fields-results results type)
+  (define (test-results results)
+    (if (null? results) #f
+        (let* ((this-res (car results))
+               (this-type (car this-res)))
+          (if (eq? this-type type)
+              (cdr this-res)
+              (test-results (cdr results))))))
+
+  (if results (test-results results) #f))

Copied: gnucash/trunk/src/import-export/qif-imp/qif-guess-map.scm (from rev 23566, gnucash/trunk/src/import-export/qif-import/qif-guess-map.scm)
===================================================================
--- gnucash/trunk/src/import-export/qif-imp/qif-guess-map.scm	                        (rev 0)
+++ gnucash/trunk/src/import-export/qif-imp/qif-guess-map.scm	2013-12-15 17:21:20 UTC (rev 23567)
@@ -0,0 +1,456 @@
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;;  qif-guess-map.scm
+;;;  guess (or load from prefs) mappings from QIF cats/accts to gnc
+;;;
+;;;  Bill Gribble <grib at billgribble.com> 20 Feb 2000
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+
+(use-modules (srfi srfi-13))
+
+(define GNC-BANK-TYPE 0)
+(define GNC-CASH-TYPE 1)
+(define GNC-ASSET-TYPE 2)
+(define GNC-LIABILITY-TYPE 4)
+(define GNC-CCARD-TYPE 3)
+(define GNC-STOCK-TYPE 5)
+(define GNC-MUTUAL-TYPE 6)
+(define GNC-INCOME-TYPE 8)
+(define GNC-EXPENSE-TYPE 9)
+(define GNC-EQUITY-TYPE 10)
+(define GNC-RECEIVABLE-TYPE 11)
+(define GNC-PAYABLE-TYPE 12)
+
+
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;  qif-import:load-map-prefs
+;;
+;;  Load the saved mappings file, and make a table of all the
+;;  accounts with their full names and pointers for later
+;;  guessing of a mapping.
+;;
+;;  We'll be returning a list with the following members:
+;;   - a list of all the known gnucash accounts in
+;;     (shortname fullname Account*) format
+;;   - a hash of QIF account name to gnucash account info
+;;   - a hash of QIF category to gnucash account info
+;;   - a hash of QIF memo/payee to gnucash account info
+;;     (older saved prefs may not have this one)
+;;   - a hash of QIF security name to gnc-commodity*
+;;   - a list of all previously saved security mappings
+;;     (older saved prefs may not have this one)
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+
+(define (qif-import:load-map-prefs)
+
+  ;; This procedure builds a list of all descendants of an existing
+  ;; GnuCash account. Each member of the list is itself a list with
+  ;; the form: (shortname fullname Account*)
+  (define (extract-all-account-info an-account root-name)
+    (if (null? an-account)
+        '()
+        (let ((children-list (gnc-account-get-children-sorted an-account))
+              (names '()))
+
+          ;; Recursively walk the account tree.
+          (for-each
+           (lambda (child-acct)
+             (let* ((name (xaccAccountGetName child-acct))
+                    (fullname
+                     (if (string? root-name)
+                         (string-append root-name
+                                        (gnc-get-account-separator-string)
+                                        name)
+                         name)))
+               (set! names
+                     (append (cons (list name fullname child-acct)
+                                   (extract-all-account-info child-acct fullname))
+                             names))))
+           children-list)
+          names)))
+
+  (define (safe-read)
+    (false-if-exception
+     (read)))
+
+  (let* ((pref-filename (gnc-build-dotgnucash-path "qif-accounts-map"))
+         (results '()))
+
+    ;; Get the user's saved mappings.
+    (if (access? pref-filename R_OK)
+        ;; We have access to the mapping file (qif-accounts-map).
+        (with-input-from-file pref-filename
+          (lambda ()
+            (let ((qif-account-list #f)
+                  (qif-cat-list #f)
+                  (qif-memo-list #f)
+                  (qif-security-list #f)
+                  (qif-account-hash #f)
+                  (qif-cat-hash #f)
+                  (qif-memo-hash #f)
+                  (qif-security-hash #f)
+                  (saved-sep #f))
+
+              ;; Read the mapping file.
+              (set! qif-account-list (safe-read))
+              (set! qif-cat-list (safe-read))
+              (set! qif-memo-list (safe-read))
+              (set! qif-security-list (safe-read))
+              (set! saved-sep (safe-read))
+
+              ;; Convert the separator to a string if necessary.
+              ;; It was a character prior to 2.2.6.
+              (if (char? saved-sep)
+                  (set! saved-sep (string saved-sep)))
+
+              ;; Process the QIF account mapping.
+              (if (not (list? qif-account-list))
+                  (set! qif-account-hash (make-hash-table 20))
+                  (set! qif-account-hash
+                        (qif-import:read-map qif-account-list
+                                             saved-sep)))
+
+              ;; Process the QIF category mapping.
+              (if (not (list? qif-cat-list))
+                  (set! qif-cat-hash (make-hash-table 20))
+                  (set! qif-cat-hash (qif-import:read-map qif-cat-list
+                                                          saved-sep)))
+
+              ;; Process the QIF payee/memo mapping.
+              (if (not (list? qif-memo-list))
+                  (set! qif-memo-hash (make-hash-table 20))
+                  (set! qif-memo-hash (qif-import:read-map qif-memo-list
+                                                           saved-sep)))
+
+              ;; Process the QIF security mapping.
+              (if (not (list? qif-security-list))
+                  (set! qif-security-hash (make-hash-table 20))
+                  (set! qif-security-hash (qif-import:read-securities
+                                           qif-security-list)))
+
+              ;; Put all the mappings together in a list.
+              (set! results (list qif-account-hash
+                                  qif-cat-hash
+                                  qif-memo-hash
+                                  qif-security-hash
+                                  qif-security-list)))))
+
+        ;; Otherwise, we can't get any saved mappings. Use empty tables.
+        (set! results (list (make-hash-table 20)
+                            (make-hash-table 20)
+                            (make-hash-table 20)
+                            (make-hash-table 20)
+                            '())))
+
+    ;; Build the list of all known account names.
+    (let* ((all-accounts (gnc-get-current-root-account))
+           (all-account-info (extract-all-account-info all-accounts #f)))
+      (set! results (cons all-account-info results)))
+
+    results))
+
+
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;  qif-import:write-map
+;;
+;;  Writes out a mapping hash table, setting the number of
+;;  transactions to 0 along the way to prevent the creation
+;;  of bogus accounts if you have funny stuff in your map.
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+
+(define (qif-import:write-map hashtab)
+  (let ((table '()))
+    (hash-fold
+     (lambda (key value p)
+       (set! table (cons (cons key (simple-obj-to-list value)) table))
+       #f) #f hashtab)
+    (write table)))
+
+(define (qif-import:read-map tablist tab-sep)
+  (let* ((table (make-hash-table 20))
+         (sep (gnc-get-account-separator-string))
+         (changed-sep? (and (string? tab-sep) (not (string=? tab-sep sep)))))
+
+    (for-each
+     (lambda (entry)
+       (let ((key (car entry))
+             (value (simple-obj-from-list (cdr entry) <qif-map-entry>)))
+
+         ;; If the account separator has changed, fix the account name.
+         (if changed-sep?
+           (let ((acct-name (qif-map-entry:gnc-name value)))
+             (if (string? acct-name)
+                 (qif-map-entry:set-gnc-name! value
+                                              (gnc:substring-replace acct-name
+                                                                     tab-sep  
+                                                                     sep)))))
+
+         (qif-map-entry:set-display?! value #f)
+         (hash-set! table key value)))
+     tablist)
+    table))
+
+
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;  qif-import:read-securities
+;;
+;;  This procedure examines a list of previously seen security
+;;  mappings and returns a hash table pairing QIF security names
+;;  with existing GnuCash commodities.
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+
+(define (qif-import:read-securities security-list)
+  (let ((table (make-hash-table 20)))
+    (for-each
+     (lambda (entry)
+       (if (and (list? entry)
+                (= 3 (length entry)))
+           ;; The saved information about each security mapping is a
+           ;; list of three items: the QIF name, and the GnuCash
+           ;; namespace and mnemonic (symbol) to which it maps.
+           ;; Example: ("McDonald's" "NYSE" "MCD")
+           (let ((commodity (gnc-commodity-table-lookup
+                              (gnc-commodity-table-get-table
+                                (gnc-get-current-book))
+                              (cadr entry)
+                              (caddr entry))))
+             (if (and commodity (not (null? commodity)))
+                 ;; There is an existing GnuCash commodity for this
+                 ;; combination of namespace and symbol.
+                 (hash-set! table (car entry) commodity)))))
+     security-list)
+    table))
+
+
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;  qif-import:write-securities
+;;
+;;  This procedure writes a mapping QIF security names to
+;;  GnuCash commodity namespaces and mnemonics (symbols).
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+
+(define (qif-import:write-securities security-hash security-prefs)
+  (let ((table '()))
+    ;; For each security that has been paired with an existing
+    ;; GnuCash commodity, create a list containing the QIF name
+    ;; and the commodity's namespace and mnemonic (symbol).
+    (hash-fold
+      (lambda (key value p)
+        ;;FIXME: we used to type-check the values, like:
+        ;; (gw:wcp-is-of-type? <gnc:commodity*> value)
+        (if (and value #t)
+            (set! table (cons (list key
+                                   (gnc-commodity-get-namespace value)
+                                   (gnc-commodity-get-mnemonic value))
+                              table))
+            (gnc:warn "qif-import:write-securities:"
+                      " something funny in hash table."))
+        #f)
+      #f security-hash)
+
+    ;; Add on the rest of the saved security mapping preferences.
+    (for-each
+      (lambda (m)
+        (if (not (hash-ref security-hash (car m)))
+            (set! table (cons m table))))
+      security-prefs)
+
+    ;; Write out the mappings.
+    (write table)))
+
+
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;  qif-import:save-map-prefs
+;;
+;;  This procedure saves all the user's mapping preferences to a
+;;  file.  This only gets called when the user clicks the Apply
+;;  button in the druid, so any new mappings will be lost if the
+;;  user cancels the import instead.
+;;
+;;  Returns #t upon success or #f on failure.
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+
+(define (qif-import:save-map-prefs acct-map cat-map memo-map
+                                   security-map security-prefs)
+
+  ;; This procedure does all the work. We'll define it, then call it safely.
+  (define (private-save)
+    (with-output-to-file (gnc-build-dotgnucash-path "qif-accounts-map")
+      (lambda ()
+        (display ";;; qif-accounts-map")
+        (newline)
+        (display ";;; Automatically generated by GnuCash. DO NOT EDIT.")
+        (newline)
+        (display ";;; (Unless you really, really want to.)")
+        (newline)
+        (display ";;; Map QIF accounts to GnuCash accounts")
+        (newline)
+        (qif-import:write-map acct-map)
+        (newline)
+
+        (display ";;; Map QIF categories to GnuCash accounts")
+        (newline)
+        (qif-import:write-map cat-map)
+        (newline)
+
+        (display ";;; Map QIF payee/memo to GnuCash accounts")
+        (newline)
+        (qif-import:write-map memo-map)
+        (newline)
+
+        (display ";;; Map QIF security names to GnuCash commodities")
+        (newline)
+        (qif-import:write-securities security-map security-prefs)
+        (newline)
+
+        (display ";;; GnuCash separator used in these mappings")
+        (newline)
+        (write (gnc-get-account-separator-string))
+        (newline)))
+    #t)
+
+  ;; Safely save the file.
+  (gnc:backtrace-if-exception private-save))
+
+
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;  here's where we do all the guessing.  We really want to find the
+;;  match in the hash table, but failing that we guess intelligently
+;;  and then (failing that) not so intelligently. called in the
+;;  dialog routines to rebuild the category and account map pages.
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+
+
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;  guess-acct
+;;
+;;  find an existing gnc acct of the right type and name, or
+;;  specify a type and name for a new one.
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+
+(define (qif-import:guess-acct acct-name allowed-types gnc-acct-info)
+  ;; see if there's a saved mapping in the hash table or an
+  ;; existing gnucash account with a name that could reasonably
+  ;; be said to be the same name (i.e. ABC Bank == abc bank)
+  (let* ((mapped-gnc-acct
+          (qif-import:find-similar-acct acct-name allowed-types
+                                        gnc-acct-info))
+         (retval (make-qif-map-entry)))
+
+    ;; set fields needed for any return value
+    (qif-map-entry:set-qif-name! retval acct-name)
+    (qif-map-entry:set-allowed-types! retval allowed-types)
+
+    (if mapped-gnc-acct
+        ;; ok, we've found an existing account that
+        ;; seems to work OK name-wise.
+        (begin
+          (qif-map-entry:set-gnc-name! retval (car mapped-gnc-acct))
+          (qif-map-entry:set-allowed-types! retval
+                                            (cadr mapped-gnc-acct))
+          (qif-map-entry:set-new-acct?! retval #f))
+        ;; we haven't found a match, so by default just create a new
+        ;; one.  Try to put the new account in a similar place in
+        ;; the hierarchy if there is one.
+        (let ((new-acct-info
+               (qif-import:find-new-acct acct-name allowed-types
+                                         gnc-acct-info)))
+          (qif-map-entry:set-gnc-name! retval (car new-acct-info))
+          (qif-map-entry:set-allowed-types! retval (cadr new-acct-info))
+          (qif-map-entry:set-new-acct?! retval #t)))
+    retval))
+
+
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;  qif-import:find-similar-acct
+;;
+;;  guess a translation from QIF info
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+
+(define (qif-import:find-similar-acct qif-acct-name allowed-types
+                                      gnc-acct-info)
+  (let* ((same-type-accts '())
+         (matching-name-accts '())
+         (retval #f))
+    (for-each
+     (lambda (gnc-acct)
+       ;; check against allowed-types
+       (let ((acct-matches? #f))
+         (for-each
+          (lambda (type)
+            (if (= type (xaccAccountGetType (caddr gnc-acct)))
+                (set! acct-matches? #t)))
+          allowed-types)
+         (if acct-matches?
+             (set! same-type-accts (cons gnc-acct same-type-accts)))))
+     gnc-acct-info)
+
+    ;; now find one in the same-type-list with a similar name.
+    (for-each
+     (lambda (gnc-acct)
+       (if (qif-import:possibly-matching-name?
+            qif-acct-name gnc-acct)
+           (set! matching-name-accts
+                 (cons gnc-acct matching-name-accts))))
+     same-type-accts)
+
+    ;; now we have either nothing, something, or too much :)
+    ;; return the full-name of the first name-matching account
+    (if (not (null? matching-name-accts))
+        (set! retval (list
+                      (cadr (car matching-name-accts))
+                      (list (xaccAccountGetType
+                             (caddr (car matching-name-accts))))))
+        #f)
+    retval))
+
+
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;  qif-import:possibly-matching-name?
+;;
+;;  try various normalizations and permutations of the names
+;;  to see if they could be the same.
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+
+(define (qif-import:possibly-matching-name? qif-acct-name gnc-acct)
+  (or
+   ;; the QIF acct is the same name as the short name of the
+   ;; gnc acct [ignoring case] (likely)
+   (string=? (string-downcase  qif-acct-name)
+             (string-downcase (car gnc-acct)))
+
+   ;; the QIF acct is the same name as the long name of the
+   ;; gnc acct [ignoring case] (not so likely)
+   (string=? (string-downcase qif-acct-name)
+             (string-downcase (cadr gnc-acct)))
+
+   ;; the QIF name is a substring of the gnc full name.
+   ;; this happens if you have the same tree but a different
+   ;; top-level structure. (i.e. expenses:tax vs. QIF tax)
+   (and (> (string-length qif-acct-name) 0)
+        (string-contains (string-downcase (cadr gnc-acct))
+                         (string-downcase qif-acct-name)))))
+
+
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;  qif-import:find-new-acct
+;;
+;;  Come up with a logical name for a new account based on
+;;  the Quicken name and type of the account
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+
+(define (qif-import:find-new-acct qif-acct allowed-types gnc-acct-info)
+  (cond ((and (string? qif-acct)
+              (string=? qif-acct (default-equity-account)))
+         (let ((existing-equity
+                (qif-import:find-similar-acct (default-equity-account)
+                                              (list GNC-EQUITY-TYPE)
+                                              gnc-acct-info)))
+           (if existing-equity
+               existing-equity
+               (list (default-equity-account) (list GNC-EQUITY-TYPE)))))
+        ((and (string? qif-acct)
+              (not (string=? qif-acct "")))
+         (list qif-acct allowed-types))
+        (#t
+         (list (default-unspec-acct) allowed-types))))
+

Copied: gnucash/trunk/src/import-export/qif-imp/qif-import.scm (from rev 23566, gnucash/trunk/src/import-export/qif-import/qif-import.scm)
===================================================================
--- gnucash/trunk/src/import-export/qif-imp/qif-import.scm	                        (rev 0)
+++ gnucash/trunk/src/import-export/qif-imp/qif-import.scm	2013-12-15 17:21:20 UTC (rev 23567)
@@ -0,0 +1,81 @@
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;;  qif-import.scm
+;;;  virtual loader for QIF import facility
+;;;
+;;;  Bill Gribble <grib at billgribble.com> 20 Feb 2000
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+
+(define-module (gnucash import-export qif-import))
+(use-modules (gnucash main)) ;; FIXME: delete after we finish modularizing.
+
+;; We do this initialization here because src/gnome isn't a real module.
+;; Note: Guile 2 needs to find the symbols from the extension at compile time already
+(cond-expand
+  (guile-2
+    (eval-when
+      (compile load eval expand)
+      (load-extension "libgnc-gnome" "scm_init_sw_gnome_module")))
+  (else
+    (load-extension "libgnc-gnome" "scm_init_sw_gnome_module")))
+
+(use-modules (sw_gnome))
+
+(use-modules (gnucash gnc-module))
+(use-modules (ice-9 regex))
+(use-modules (srfi srfi-1))
+
+(debug-enable 'debug)
+(debug-enable 'backtrace)
+
+(gnc:module-load "gnucash/engine" 0)
+(gnc:module-load "gnucash/app-utils" 0)
+(gnc:module-load "gnucash/gnome-utils" 0)
+
+(load-from-path "qif-import/qif-objects.scm")      ;; class definitions
+(load-from-path "qif-import/qif-parse.scm")        ;; string-to-value
+(load-from-path "qif-import/qif-utils.scm")
+(load-from-path "qif-import/qif-file.scm")         ;; actual file reading
+(load-from-path "qif-import/qif-dialog-utils.scm") ;; build displays
+(load-from-path "qif-import/qif-guess-map.scm")    ;; build acct mappings
+(load-from-path "qif-import/qif-to-gnc.scm")       ;; conv QIF xtns to GNC
+(load-from-path "qif-import/qif-merge-groups.scm") ;; merge into user's acct
+
+(export make-qif-file)
+(export make-ticker-map)
+(export qif-import:get-all-accts)
+(export qif-import:fix-from-acct)
+(export qif-import:any-new-accts?)
+(export qif-import:update-security-hash)
+(export qif-import:refresh-match-selection)
+(export qif-import:save-map-prefs)
+(export qif-import:load-map-prefs)
+(export qif-import:qif-to-gnc)
+(export qif-import:qif-to-gnc-undo)
+(export qif-import:reset-cancel-pause)
+(export qif-import:cancel)
+(export qif-import:toggle-pause)
+
+(export qif-map-entry:gnc-name)
+(export qif-map-entry:set-gnc-name!)
+(export qif-map-entry:clone)
+(export qif-map-entry:qif-name)
+(export qif-map-entry:new-acct?)
+
+(export qif-file:read-file)
+(export qif-file:parse-fields)
+(export qif-file:parse-fields-results)
+(export qif-file:check-from-acct)
+(export qif-file:reparse-dates)
+(export qif-file:check-from-acct)
+(export qif-file:path-to-accountname)
+(export qif-file:path)
+
+(export qif-dialog:qif-file-loaded?)
+(export qif-dialog:unload-qif-file)
+(export qif-dialog:make-account-display)
+(export qif-dialog:make-category-display)
+(export qif-dialog:make-memo-display)
+
+(export gnc:account-tree-find-duplicates)
+(export gnc:account-tree-catenate-and-merge)
+(export gnc:prune-matching-transactions)

Copied: gnucash/trunk/src/import-export/qif-imp/qif-merge-groups.scm (from rev 23566, gnucash/trunk/src/import-export/qif-import/qif-merge-groups.scm)
===================================================================
--- gnucash/trunk/src/import-export/qif-imp/qif-merge-groups.scm	                        (rev 0)
+++ gnucash/trunk/src/import-export/qif-imp/qif-merge-groups.scm	2013-12-15 17:21:20 UTC (rev 23567)
@@ -0,0 +1,265 @@
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;;  qif-merge-groups.scm
+;;;  eliminate duplicate xtns in a new (imported) account group
+;;;
+;;;  Copyright 2001 Bill Gribble <grib at billgribble.com>
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;  gnc:account-tree-get-transactions
+;;
+;;  Given an account tree, this procedure returns a list of all
+;;  transactions whose splits only use accounts in the tree.
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+(define (gnc:account-tree-get-transactions root)
+  (let ((accounts (gnc-account-get-descendants-sorted root)))
+    (if (null? accounts)
+        '()
+        (let ((query (qof-query-create-for-splits))
+              (xtns #f))
+
+          (qof-query-set-book query (gnc-account-get-book root))
+
+          ;; we want to find all transactions with every split inside the
+          ;; account group.
+          (xaccQueryAddAccountMatch query accounts
+                                    QOF-GUID-MATCH-ANY QOF-QUERY-AND)
+
+          (set! xtns (xaccQueryGetTransactions query QUERY-TXN-MATCH-ALL))
+
+          ;; lose the query
+          (qof-query-destroy query)
+          xtns))))
+
+
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;  gnc:account-tree-find-duplicates
+;;
+;;  Given two account trees, old-root and new-root, a search is
+;;  performed to determine, for each transaction in new-root,
+;;  whether there are any transactions in old-root that may be
+;;  duplicated by it.
+;;
+;;  The search results are returned in an association list, with
+;;  new-root transactions as the keys. The value associated with
+;;  each key is a second association list of possibly duplicated
+;;  transactions in the old-root, taking the form:
+;;  ( (old-xtn . #f) (old-xtn . #f) (old-xtn . #f) ... )
+;;
+;;  The druid can then ask the user for a final determination,
+;;  and change #f to #t where duplication is found.
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+
+(define (gnc:account-tree-find-duplicates old-root new-root progress-dialog)
+
+  ;; This procedure does all the work. We'll define it, then call it safely.
+  (define (private-find)
+
+    ;; Given a list of accounts, this predicate returns true if any
+    ;; of those accounts are involved in a transaction.
+    (define (has-any-xtns? acctlist)
+      (if (null? acctlist)
+          #f
+          (let ((splits (xaccAccountGetSplitList (car acctlist))))
+            (if (null? splits)
+                (has-any-xtns? (cdr acctlist))
+                #t))))
+
+
+    (let ((old-accounts (gnc-account-get-descendants-sorted old-root)))
+      (if (has-any-xtns? old-accounts)
+          ;; Get all the transactions in the new tree, then iterate over them
+          ;; trying to find matches in the old tree.  If there are matches,
+          ;; push the matches onto a list.
+          (let* ((new-xtns (gnc:account-tree-get-transactions new-root))
+                 (work-to-do (length new-xtns))
+                 (work-done 0)
+                 (matches '()))
+
+            ;; This procedure handles progress reporting, pause, and cancel.
+            (define (update-progress)
+              (set! work-done (+ 1 work-done))
+              (if (and progress-dialog
+                       (zero? (remainder work-done 8)))
+                  (begin
+                    (gnc-progress-dialog-set-value progress-dialog
+                                                   (/ work-done work-to-do))
+                    (qif-import:check-pause progress-dialog)
+                    (if qif-import:canceled
+                        (throw 'cancel)))))
+
+
+            (if progress-dialog
+                (gnc-progress-dialog-set-sub progress-dialog
+                                         (_ "Finding duplicate transactions")))
+
+            ;; For each transaction in the new account tree, build a query
+            ;; that matches possibly duplicate transactions in the old tree.
+            (for-each
+              (lambda (xtn)
+                (let ((query (qof-query-create-for-splits))
+                      (num-splits 0))
+                  (qof-query-set-book query (gnc-account-get-book old-root))
+
+                  ;; First, we only want to find only transactions
+                  ;; from accounts in the old tree.
+                  (xaccQueryAddAccountMatch query
+                                            old-accounts
+                                            QOF-GUID-MATCH-ANY QOF-QUERY-AND)
+
+                  ;; The date should be close to the same.. +/- a week.
+                  (let ((date (gnc-transaction-get-date-posted xtn)))
+                    (xaccQueryAddDateMatchTS query #t
+                                             (decdate date WeekDelta) #t
+                                             (incdate date WeekDelta)
+                                             QOF-QUERY-AND))
+
+                  ;; For each split in the new transaction, add a
+                  ;; term that can match on its properties.
+                  (let ((q-splits (qof-query-create-for-splits)))
+                    (for-each
+                      (lambda (split)
+                        (set! num-splits (+ num-splits 1))
+                        (let ((sq (qof-query-create-for-splits)))
+                          (qof-query-set-book sq (gnc-account-get-book old-root))
+
+                          ;; Require a match on the account name. If the name
+                          ;; doesn't exist in the old tree (indicating a new
+                          ;; account), the match will be NULL and the query
+                          ;; won't find anything.  Optimize this later.
+                          (xaccQueryAddSingleAccountMatch
+                            sq
+                            (gnc-account-lookup-by-full-name old-root
+                              (gnc-account-get-full-name
+                                (xaccSplitGetAccount split)))
+                            QOF-QUERY-AND)
+
+                          ;; Require the value of the split in the new tree
+                          ;; to match the the value of the split in the old
+                          ;; tree.  We should really check for fuzziness.
+                          (xaccQueryAddValueMatch sq
+                                                  (xaccSplitGetValue split)
+                                                  QOF-NUMERIC-MATCH-ANY
+                                                  QOF-COMPARE-EQUAL
+                                                  QOF-QUERY-AND)
+
+                          ;; Now merge into the split query.  Reminder: q-splits
+                          ;; must be merged with an OR. Otherwise, nothing will
+                          ;; match. (For example, something can be equal to 4 or
+                          ;; to -4, but not both.)
+                          (let ((q-new (qof-query-merge q-splits
+                                                        sq
+                                                        QOF-QUERY-OR)))
+                            (qof-query-destroy q-splits)
+                            (qof-query-destroy sq)
+                            (set! q-splits q-new))))
+                      (xaccTransGetSplitList xtn))
+
+                    ;; Now q-splits will find every split that is the same as
+                    ;; any one split of the new-root transaction.  Merge it in.
+                    (let ((q-new (qof-query-merge query
+                                                  q-splits
+                                                  QOF-QUERY-AND)))
+                      (qof-query-destroy query)
+                      (qof-query-destroy q-splits)
+                      (set! query q-new)))
+
+                  ;; Now that we have built a query that finds matching splits
+                  ;; in the old tree, run it and build a list of transactions
+                  ;; from the results.
+                  ;;
+                  ;; If the transaction from the new tree has more than two
+                  ;; splits, then we'll assume that it fully reflects what
+                  ;; occurred, and only consider transactions in the old tree
+                  ;; that match with every single split.
+                  ;;
+                  ;; All other new transactions could be incomplete, so we'll
+                  ;; consider transactions from the old tree to be possible
+                  ;; duplicates even if only one split matches.
+                  ;;
+                  ;; For more information, see bug 481528.
+                  (let ((old-xtns (xaccQueryGetTransactions
+                                    query
+                                    (if (> num-splits 2)
+                                        QUERY-TXN-MATCH-ALL
+                                        QUERY-TXN-MATCH-ANY))))
+
+                    ;; Turn the resulting list of possibly duplicated
+                    ;; transactions into an association list.
+                    (set! old-xtns (map
+                                     (lambda (elt)
+                                       (cons elt #f)) old-xtns))
+
+                    ;; If anything matched the query, add it to our "matches"
+                    ;; association list, keyed by the new-root transaction.
+                    (if (not (null? old-xtns))
+                        (set! matches (cons (cons xtn old-xtns) matches))))
+
+                  (qof-query-destroy query))
+                (update-progress))
+              new-xtns)
+
+            ;; Finished.
+            (if progress-dialog
+                (gnc-progress-dialog-set-value progress-dialog 1))
+
+            ;; Return the matches.
+            matches)
+
+          ;; Since there are either no accounts or no transactions in the old
+          ;; tree, duplicate checking is unnecessary.
+          (begin
+            ;; Finished.
+            (if progress-dialog
+                (gnc-progress-dialog-set-value progress-dialog 1))
+
+            ;; Return an empty list.
+            '()))))
+
+  ;; Safely do the work and return the result.
+  (gnc:backtrace-if-exception
+    (lambda () (catch 'cancel private-find (lambda (key . args) #t)))))
+
+
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;  gnc:prune-matching-transactions
+;;
+;;  The parameter, match-list, is an association list of the form
+;;  returned by gnc:account-tree-find-duplicates. This procedure
+;;  looks through the list and discards any transaction that has
+;;  been definitively determined to be a duplicate of one of the
+;;  possible matches.
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+
+(define (gnc:prune-matching-transactions match-list)
+  (for-each
+   (lambda (match)
+     (let ((new-xtn (car match))
+           (matches (cdr match))
+           (do-delete #f))
+       (for-each
+        (lambda (old)
+          (if (cdr old)
+              (set! do-delete #t)))
+        matches)
+       (if do-delete
+           (begin
+             (xaccTransBeginEdit new-xtn)
+             (xaccTransDestroy new-xtn)
+             (xaccTransCommitEdit new-xtn)))))
+   match-list))
+
+
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;  gnc:account-tree-catenate-and-merge
+;;
+;;  The procedure moves the entire contents of one account tree,
+;;  new-root, to a second account tree, old-root, and merges any
+;;  duplicated accounts.
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+(define (gnc:account-tree-catenate-and-merge old-root new-root)
+  ;; stuff the new accounts into the old account tree and merge the accounts
+  (gnc-account-join-children old-root new-root)
+  (xaccAccountBeginEdit new-root)
+  (xaccAccountDestroy new-root)
+  (gnc-account-merge-children old-root))

Copied: gnucash/trunk/src/import-export/qif-imp/qif-objects.scm (from rev 23566, gnucash/trunk/src/import-export/qif-import/qif-objects.scm)
===================================================================
--- gnucash/trunk/src/import-export/qif-imp/qif-objects.scm	                        (rev 0)
+++ gnucash/trunk/src/import-export/qif-imp/qif-objects.scm	2013-12-15 17:21:20 UTC (rev 23567)
@@ -0,0 +1,690 @@
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;;  qif-objects.scm
+;;;  representations for parts of an imported Quicken file.  
+;;;
+;;;  Bill Gribble <grib at billgribble.com> 20 Feb 2000 
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+
+
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;  qif-file class 
+;;  xtns         : list of <qif-xtn>  
+;;  accounts     : list of <qif-acct>  
+;;  cats         : list of <qif-cat>  
+;;  classes      : list of <qif-class>  
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+
+(define <qif-file>
+  (make-simple-class 
+   'qif-file 
+   '(path                 ;; where file was loaded 
+     y2k-threshold
+     xtns                
+     accounts 
+     cats
+     classes)))
+
+(define qif-file?
+  (record-predicate <qif-file>))
+
+(define qif-file:path 
+  (simple-obj-getter <qif-file> 'path))
+
+(define qif-file:set-path! 
+  (simple-obj-setter <qif-file> 'path))
+
+(define qif-file:y2k-threshold 
+  (simple-obj-getter <qif-file> 'y2k-threshold))
+
+(define qif-file:set-y2k-threshold!
+  (simple-obj-setter <qif-file> 'y2k-threshold))
+
+(define qif-file:cats 
+  (simple-obj-getter <qif-file> 'cats))
+
+(define qif-file:set-cats!
+  (simple-obj-setter <qif-file> 'cats))
+
+(define qif-file:classes 
+  (simple-obj-getter <qif-file> 'classes))
+
+(define qif-file:set-classes!
+  (simple-obj-setter <qif-file> 'classes))
+
+(define qif-file:xtns 
+  (simple-obj-getter <qif-file> 'xtns))
+
+(define qif-file:set-xtns!
+  (simple-obj-setter <qif-file> 'xtns))
+
+(define qif-file:accounts 
+  (simple-obj-getter <qif-file> 'accounts))
+
+(define qif-file:set-accounts!
+  (simple-obj-setter <qif-file> 'accounts))
+
+(define (make-qif-file) 
+  (let ((self (make-simple-obj <qif-file>)))
+    (qif-file:set-y2k-threshold! self 50)
+    (qif-file:set-xtns! self '())
+    (qif-file:set-accounts! self '())
+    (qif-file:set-cats! self '())
+    (qif-file:set-classes! self '())
+    self))
+
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;  qif-split class 
+;;  this is for bank/ccard accounts only. 
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+
+(define <qif-split>
+  (make-simple-class 
+   'qif-split
+   '(category class memo amount category-is-account? matching-cleared mark
+              miscx-category miscx-is-account? miscx-class)))
+
+(define qif-split:category 
+  (simple-obj-getter <qif-split> 'category))
+
+(define qif-split:set-category-private!
+  (simple-obj-setter <qif-split> 'category))
+
+(define (qif-split:set-category! self value)
+  (let* ((cat-info 
+          (qif-split:parse-category self value))
+         (cat-name (list-ref cat-info 0))
+         (is-account? (list-ref cat-info 1))
+         (class-name (list-ref cat-info 2))
+         (miscx-name (list-ref cat-info 3))
+         (miscx-is-account? (list-ref cat-info 4))
+         (miscx-class (list-ref cat-info 5)))
+    (qif-split:set-category-private! self cat-name)
+    (qif-split:set-class! self class-name)
+    (qif-split:set-category-is-account?! self is-account?)
+    (qif-split:set-miscx-category! self miscx-name)
+    (qif-split:set-miscx-is-account?! self miscx-is-account?)
+    (qif-split:set-miscx-class! self miscx-class)))
+    
+(define qif-split:class 
+  (simple-obj-getter <qif-split> 'class))
+
+(define qif-split:set-class!
+  (simple-obj-setter <qif-split> 'class))
+
+(define qif-split:memo 
+  (simple-obj-getter <qif-split> 'memo))
+
+(define qif-split:set-memo! 
+  (simple-obj-setter <qif-split> 'memo))
+
+(define qif-split:amount 
+  (simple-obj-getter <qif-split> 'amount))
+
+(define qif-split:set-amount! 
+  (simple-obj-setter <qif-split> 'amount))
+
+(define qif-split:mark 
+  (simple-obj-getter <qif-split> 'mark))
+
+(define qif-split:set-mark! 
+  (simple-obj-setter <qif-split> 'mark))
+
+(define qif-split:matching-cleared 
+  (simple-obj-getter <qif-split> 'matching-cleared))
+
+(define qif-split:set-matching-cleared! 
+  (simple-obj-setter <qif-split> 'matching-cleared))
+
+(define qif-split:category-is-account? 
+  (simple-obj-getter <qif-split> 'category-is-account?))
+
+(define qif-split:set-category-is-account?! 
+  (simple-obj-setter <qif-split> 'category-is-account?))
+
+(define qif-split:miscx-is-account? 
+  (simple-obj-getter <qif-split> 'miscx-is-account?))
+
+(define qif-split:set-miscx-is-account?!
+  (simple-obj-setter <qif-split> 'miscx-is-account?))
+
+(define qif-split:miscx-category 
+  (simple-obj-getter <qif-split> 'miscx-category))
+
+(define qif-split:set-miscx-category!
+  (simple-obj-setter <qif-split> 'miscx-category))
+
+(define qif-split:miscx-class 
+  (simple-obj-getter <qif-split> 'miscx-class))
+
+(define qif-split:set-miscx-class!
+  (simple-obj-setter <qif-split> 'miscx-class))
+
+(define (make-qif-split)
+  (let ((self (make-simple-obj <qif-split>)))
+    (qif-split:set-category! self "")
+    self))
+
+
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;  qif-xtn class 
+;;  [D] date       : parsed. 
+;;  [P] payee      : string 
+;;  [N] number (check number, sell, or buy)
+;;  [C] cleared    : parsed (x/X/*) ;
+;;  [T] amount     : parsed, units are currency of dest account
+;;  [I] share price : parsed
+;;  [Q] number of shares
+;;  [Y] name of security 
+;;  [O] commission (parsed)
+;;  [L] category   : string 
+;;  [S]/[E]/[$] splits : a list of <qif-split>
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+
+(define <qif-xtn>
+  (make-simple-class 
+   'qif-xtn
+   '(date payee address number action cleared  
+          from-acct share-price num-shares security-name commission 
+          default-split splits mark)))
+
+(define qif-xtn?
+  (record-predicate <qif-xtn>))
+
+(define qif-xtn:date
+  (simple-obj-getter <qif-xtn> 'date))
+
+(define qif-xtn:set-date! 
+  (simple-obj-setter <qif-xtn> 'date))
+
+(define qif-xtn:payee
+  (simple-obj-getter <qif-xtn> 'payee))
+
+(define qif-xtn:set-payee! 
+  (simple-obj-setter <qif-xtn> 'payee))
+
+(define qif-xtn:address
+  (simple-obj-getter <qif-xtn> 'address))
+
+(define qif-xtn:set-address! 
+  (simple-obj-setter <qif-xtn> 'address))
+
+(define qif-xtn:number
+  (simple-obj-getter <qif-xtn> 'number))
+
+(define qif-xtn:set-number! 
+  (simple-obj-setter <qif-xtn> 'number))
+
+(define qif-xtn:action
+  (simple-obj-getter <qif-xtn> 'action))
+
+(define qif-xtn:set-action! 
+  (simple-obj-setter <qif-xtn> 'action))
+
+(define qif-xtn:cleared
+  (simple-obj-getter <qif-xtn> 'cleared))
+
+(define qif-xtn:set-cleared! 
+  (simple-obj-setter <qif-xtn> 'cleared))
+
+(define qif-xtn:from-acct
+  (simple-obj-getter <qif-xtn> 'from-acct))
+
+(define qif-xtn:set-from-acct! 
+  (simple-obj-setter <qif-xtn> 'from-acct))
+
+(define qif-xtn:share-price
+  (simple-obj-getter <qif-xtn> 'share-price))
+
+(define qif-xtn:set-share-price! 
+  (simple-obj-setter <qif-xtn> 'share-price))
+
+(define qif-xtn:num-shares
+  (simple-obj-getter <qif-xtn> 'num-shares))
+
+(define qif-xtn:set-num-shares! 
+  (simple-obj-setter <qif-xtn> 'num-shares))
+
+(define qif-xtn:security-name
+  (simple-obj-getter <qif-xtn> 'security-name))
+
+(define qif-xtn:set-security-name! 
+  (simple-obj-setter <qif-xtn> 'security-name))
+
+(define qif-xtn:commission
+  (simple-obj-getter <qif-xtn> 'commission))
+
+(define qif-xtn:set-commission! 
+  (simple-obj-setter <qif-xtn> 'commission))
+
+(define qif-xtn:default-split
+  (simple-obj-getter <qif-xtn> 'default-split))
+
+(define qif-xtn:set-default-split! 
+  (simple-obj-setter <qif-xtn> 'default-split))
+
+(define qif-xtn:splits
+  (simple-obj-getter <qif-xtn> 'splits))
+
+(define qif-xtn:set-splits! 
+  (simple-obj-setter <qif-xtn> 'splits))
+
+(define qif-xtn:mark
+  (simple-obj-getter <qif-xtn> 'mark))
+
+(define qif-xtn:set-mark! 
+  (simple-obj-setter <qif-xtn> 'mark))
+
+(define (make-qif-xtn)
+  (let ((self (make-simple-obj <qif-xtn>)))
+    (qif-xtn:set-mark! self #f)
+    (qif-xtn:set-splits! self '())
+    self))
+
+(define (qif-xtn:print self)
+  (simple-obj-print self))
+
+
+(define (qif-xtn:split-amounts self)
+  (let ((def-spl (qif-xtn:default-split self))
+	(spl-lst (qif-xtn:splits self)))
+    (map
+     (lambda (split)
+       (qif-split:amount split))
+     (if def-spl (cons def-spl spl-lst) spl-lst))))
+
+(define (qif-xtn:set-split-amounts! self amounts)
+  (define (set-amounts neg? amounts)
+    (map 
+     (lambda (split amount)
+       (qif-split:set-amount! split (if neg? (gnc-numeric-neg amount) amount)))
+     (qif-xtn:splits self) amounts))
+
+  (define (need-neg amounts)
+    (let ((sum (gnc-numeric-zero)))
+      (for-each
+       (lambda (amt)
+	 (set! sum (gnc-numeric-add sum amt 0 GNC-DENOM-LCD)))
+       amounts)
+      (gnc-numeric-zero-p sum)))
+
+  (let ((def-spl (qif-xtn:default-split self)))
+    (if def-spl
+	(set-amounts (need-neg amounts) (cdr amounts))
+	(set-amounts #f amounts))))
+
+
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;  <qif-acct>
+;;  [N] name         : string 
+;;  [T] type         : string 
+;;  [D] description  : string 
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+
+(define <qif-acct>
+  (make-simple-class 
+   'qif-acct
+   '(name type description limit budget)))
+
+(define qif-acct:name
+  (simple-obj-getter <qif-acct> 'name))
+
+(define qif-acct:set-name! 
+  (simple-obj-setter <qif-acct> 'name))
+
+(define qif-acct:type
+  (simple-obj-getter <qif-acct> 'type))
+
+(define qif-acct:set-type! 
+  (simple-obj-setter <qif-acct> 'type))
+
+(define qif-acct:description
+  (simple-obj-getter <qif-acct> 'description))
+
+(define qif-acct:set-description! 
+  (simple-obj-setter <qif-acct> 'description))
+
+(define qif-acct:limit
+  (simple-obj-getter <qif-acct> 'limit))
+
+(define qif-acct:set-limit! 
+  (simple-obj-setter <qif-acct> 'limit))
+
+(define qif-acct:budget
+  (simple-obj-getter <qif-acct> 'budget))
+
+(define qif-acct:set-budget! 
+  (simple-obj-setter <qif-acct> 'budget))
+
+(define (make-qif-acct)
+  (let ((retval (make-simple-obj <qif-acct>)))
+    (qif-acct:set-type! retval "Bank")
+    (qif-acct:set-name! retval "Default Account")
+    retval))
+
+(define qif-acct? 
+  (record-predicate <qif-acct>))
+
+(define (qif-acct:print self)
+  (simple-obj-print self))
+
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;  <qif-class>
+;;  [N] name         : string 
+;;  [D] description  : string 
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+
+(define <qif-class>
+  (make-simple-class
+   'qif-class
+   '(name description)))
+
+(define qif-class:name
+  (simple-obj-getter <qif-class> 'name))
+
+(define qif-class:set-name! 
+  (simple-obj-setter <qif-class> 'name))
+
+(define qif-class:description
+  (simple-obj-getter <qif-class> 'description))
+
+(define qif-class:set-description! 
+  (simple-obj-setter <qif-class> 'description))
+
+(define (qif-class:print self)
+  (simple-obj-print self))
+
+(define (make-qif-class)
+  (make-simple-obj <qif-class>))
+
+(define qif-class? 
+  (record-predicate <qif-class>))
+
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;  <qif-cat> : a "Cat" or category transaction
+;;  [N] name         : string 
+;;  [D] description  : string 
+;;  [T] taxable      : boolean 
+;;  [E] expense?     : boolean
+;;  [I] income?      : boolean 
+;;  [R] tax rate     : number 
+;;  [B] budget amt   : number 
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+
+
+(define <qif-cat>
+  (make-simple-class 
+   'qif-cat
+   '(name description taxable expense-cat income-cat tax-class budget-amt)))
+
+(define qif-cat:name
+  (simple-obj-getter <qif-cat> 'name))
+
+(define qif-cat:set-name! 
+  (simple-obj-setter <qif-cat> 'name))
+
+(define qif-cat:description
+  (simple-obj-getter <qif-cat> 'description))
+
+(define qif-cat:set-description! 
+  (simple-obj-setter <qif-cat> 'description))
+
+(define qif-cat:taxable
+  (simple-obj-getter <qif-cat> 'taxable))
+
+(define qif-cat:set-taxable! 
+  (simple-obj-setter <qif-cat> 'taxable))
+
+(define qif-cat:expense-cat
+  (simple-obj-getter <qif-cat> 'expense-cat))
+
+(define qif-cat:set-expense-cat! 
+  (simple-obj-setter <qif-cat> 'expense-cat))
+
+(define qif-cat:income-cat
+  (simple-obj-getter <qif-cat> 'income-cat))
+
+(define qif-cat:set-income-cat! 
+  (simple-obj-setter <qif-cat> 'income-cat))
+
+(define qif-cat:tax-class
+  (simple-obj-getter <qif-cat> 'tax-class))
+
+(define qif-cat:set-tax-class! 
+  (simple-obj-setter <qif-cat> 'tax-class))
+
+(define qif-cat:budget-amt
+  (simple-obj-getter <qif-cat> 'budget-amt))
+
+(define qif-cat:set-budget-amt! 
+  (simple-obj-setter <qif-cat> 'budget-amt))
+
+(define (make-qif-cat) 
+  (make-simple-obj <qif-cat>))
+
+(define qif-cat? 
+  (record-predicate <qif-cat>))
+
+(define (qif-cat:print self)
+  (simple-obj-print self))
+
+(define (qif-file:add-xtn! self xtn)
+  (qif-file:set-xtns! self 
+                      (cons xtn (qif-file:xtns self))))
+
+(define (qif-file:add-cat! self cat)
+  (qif-file:set-cats! self 
+                      (cons cat (qif-file:cats self))))
+
+(define (qif-file:add-class! self class)
+  (qif-file:set-classes! self 
+                         (cons class (qif-file:classes self))))
+
+(define (qif-file:add-account! self account)
+  (qif-file:set-accounts! self 
+                          (cons account (qif-file:accounts self))))
+
+
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;  munge the QIF filename to create a simple default account name 
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+
+(define (qif-file:path-to-accountname self)
+  (let ((namestring (qif-file:path self)))
+    (if (and (string? namestring)
+             (> (string-length namestring) 0))
+        (begin 
+          (set! namestring 
+                (substring namestring 
+                           (let ((last-slash (string-rindex namestring #\/)))
+                             (if last-slash 
+                                 (+ 1 last-slash) 
+                                 0))
+                           (let ((last-dot (string-rindex namestring #\.)))
+                             (if last-dot 
+                                 last-dot 
+                                 (string-length namestring)))))
+          (set! namestring (string-replace-char! namestring #\- #\space))
+          (set! namestring (string-replace-char! namestring #\_ #\space))
+          namestring)
+        "QIF Import")))
+
+
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;; qif-map-entry class
+;; information for mapping a QIF account/category name to a
+;; gnucash name.
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+
+(define <qif-map-entry>
+  (make-simple-class
+   'qif-map-entry
+   '(qif-name       ;; set while parsing file 
+     allowed-types  ;; set while parsing file 
+     description    ;; from QIF acct, if there is one 
+     gnc-name       ;; set from guess-map 
+     new-acct?      ;; set from guess-map
+     display?)))    ;; set when non-zero transactions 
+
+(define (make-qif-map-entry)
+  (make-simple-obj <qif-map-entry>))
+
+(define (qif-map-entry:clone orig)
+  (let ((me (make-qif-map-entry)))
+    (qif-map-entry:set-qif-name! me (qif-map-entry:qif-name orig))
+    (qif-map-entry:set-allowed-types! me (qif-map-entry:allowed-types orig))
+    (qif-map-entry:set-description! me (qif-map-entry:description orig))
+    (qif-map-entry:set-gnc-name! me (qif-map-entry:gnc-name orig))
+    (qif-map-entry:set-new-acct?! me (qif-map-entry:new-acct? orig))
+    (qif-map-entry:set-display?! me (qif-map-entry:display? orig))
+    me))
+
+(define (qif-map-entry:allowed-parent-types self) 
+  (let ((types-list (reverse (qif-map-entry:allowed-types self))))
+    (define (add-types . rest)
+      (for-each 
+       (lambda (t)
+         (if (not (memv t types-list))
+             (set! types-list (cons t types-list))))
+       rest))
+    
+    (for-each 
+     (lambda (t)
+       (cond 
+        ((memv t (list GNC-BANK-TYPE GNC-CASH-TYPE GNC-CCARD-TYPE 
+                       GNC-STOCK-TYPE GNC-MUTUAL-TYPE
+                       GNC-ASSET-TYPE GNC-LIABILITY-TYPE
+                       GNC-RECEIVABLE-TYPE GNC-PAYABLE-TYPE))
+         (add-types GNC-BANK-TYPE GNC-CASH-TYPE GNC-CCARD-TYPE 
+                    GNC-STOCK-TYPE GNC-MUTUAL-TYPE
+                    GNC-ASSET-TYPE GNC-LIABILITY-TYPE
+                    GNC-RECEIVABLE-TYPE GNC-PAYABLE-TYPE))
+        ((memv t (list GNC-INCOME-TYPE GNC-EXPENSE-TYPE))
+         (add-types GNC-INCOME-TYPE GNC-EXPENSE-TYPE))
+        (#t
+         (add-types t))))
+     (qif-map-entry:allowed-types self))
+    (reverse types-list)))
+
+
+(define qif-map-entry:qif-name
+  (simple-obj-getter <qif-map-entry> 'qif-name))
+
+(define qif-map-entry:set-qif-name!
+  (simple-obj-setter <qif-map-entry> 'qif-name))
+
+(define qif-map-entry:allowed-types
+  (simple-obj-getter <qif-map-entry> 'allowed-types))
+
+(define qif-map-entry:set-allowed-types!
+  (simple-obj-setter <qif-map-entry> 'allowed-types))
+
+(define qif-map-entry:description
+  (simple-obj-getter <qif-map-entry> 'description))
+
+(define qif-map-entry:set-description!
+  (simple-obj-setter <qif-map-entry> 'description))
+
+(define qif-map-entry:gnc-name
+  (simple-obj-getter <qif-map-entry> 'gnc-name))
+
+(define qif-map-entry:set-gnc-name!
+  (simple-obj-setter <qif-map-entry> 'gnc-name))
+
+(define qif-map-entry:new-acct?
+  (simple-obj-getter <qif-map-entry> 'new-acct?))
+
+(define qif-map-entry:set-new-acct?!
+  (simple-obj-setter <qif-map-entry> 'new-acct?))
+
+(define qif-map-entry:display?
+  (simple-obj-getter <qif-map-entry> 'display?))
+
+(define qif-map-entry:set-display?!
+  (simple-obj-setter <qif-map-entry> 'display?))
+
+
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;  <qif-stock-symbol>
+;;  [N] stock name     : string 
+;;  [S] ticker symbol  : string 
+;;  [T] type           : string 
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+
+(define <qif-stock-symbol>
+  (make-simple-class
+   'qif-stock-symbol
+   '(name symbol type)))
+
+(define qif-stock-symbol:name
+  (simple-obj-getter <qif-stock-symbol> 'name))
+
+(define qif-stock-symbol:set-name! 
+  (simple-obj-setter <qif-stock-symbol> 'name))
+
+(define qif-stock-symbol:symbol
+  (simple-obj-getter <qif-stock-symbol> 'symbol))
+
+(define qif-stock-symbol:set-symbol! 
+  (simple-obj-setter <qif-stock-symbol> 'symbol))
+
+(define qif-stock-symbol:type
+  (simple-obj-getter <qif-stock-symbol> 'type))
+
+(define qif-stock-symbol:set-type! 
+  (simple-obj-setter <qif-stock-symbol> 'type))
+
+(define (qif-stock-symbol:print self)
+  (simple-obj-print self))
+
+(define (make-qif-stock-symbol)
+  (let ((retval (make-simple-obj <qif-stock-symbol>)))
+    (qif-stock-symbol:set-name! retval "")
+    (qif-stock-symbol:set-symbol! retval "")
+    (qif-stock-symbol:set-type! retval "")
+    retval))
+
+(define <qif-ticker-map>
+  (make-simple-class
+   'qif-ticker-map
+   '(stocks)))
+
+(define qif-ticker-map:ticker-map
+  (simple-obj-getter <qif-ticker-map> 'stocks))
+
+(define qif-ticker-map:set-ticker-map!
+  (simple-obj-setter <qif-ticker-map> 'stocks))
+
+(define (make-ticker-map) 
+  (let ((self (make-simple-obj <qif-ticker-map>)))
+    (qif-ticker-map:set-ticker-map! self '())
+    self))
+
+(define (qif-ticker-map:add-ticker! ticker-map stock-symbol)
+  (qif-ticker-map:set-ticker-map!
+   ticker-map
+   (cons stock-symbol (qif-ticker-map:ticker-map ticker-map))))
+
+(define (qif-ticker-map:lookup-symbol ticker-map name)
+  (let ((retval #f))
+    (for-each 
+     (lambda (symbol)
+       (if (string=? name (qif-stock-symbol:name symbol))
+	   (begin
+	     (set! retval (qif-stock-symbol:symbol symbol))
+	     (if (and (string? retval) (string=? retval ""))
+		 (set! retval #f)))))
+     (qif-ticker-map:ticker-map ticker-map))
+    retval))
+
+(define (qif-ticker-map:lookup-type ticker-map name)
+  (let ((retval #f))
+    (for-each 
+     (lambda (symbol)
+       (if (string=? name (qif-stock-symbol:name symbol))
+	   (begin
+	     (set! retval (qif-stock-symbol:type symbol))
+	     (if (and (string? retval) (string=? retval ""))
+		 (set! retval #f)))))
+     (qif-ticker-map:ticker-map ticker-map))
+    retval))
+

Copied: gnucash/trunk/src/import-export/qif-imp/qif-parse.scm (from rev 23566, gnucash/trunk/src/import-export/qif-import/qif-parse.scm)
===================================================================
--- gnucash/trunk/src/import-export/qif-imp/qif-parse.scm	                        (rev 0)
+++ gnucash/trunk/src/import-export/qif-imp/qif-parse.scm	2013-12-15 17:21:20 UTC (rev 23567)
@@ -0,0 +1,640 @@
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;;  qif-parse.scm
+;;;  routines to parse values and dates in QIF files.
+;;;
+;;;  Bill Gribble <grib at billgribble.com> 20 Feb 2000
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+
+(use-modules (gnucash printf))
+
+(define qif-category-compiled-rexp
+  (make-regexp "^ *(\\[)?([^]/|]*)(]?)(/?)([^|]*)(\\|(\\[)?([^]/]*)(]?)(/?)(.*))? *$"))
+
+(define qif-date-compiled-rexp
+  (make-regexp "^ *([0-9]+) *[-/.'] *([0-9]+) *[-/.'] *([0-9]+).*$|^ *([0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]).*$"))
+
+(define qif-date-mdy-compiled-rexp
+  (make-regexp "([0-9][0-9])([0-9][0-9])([0-9][0-9][0-9][0-9])"))
+
+(define qif-date-ymd-compiled-rexp
+  (make-regexp "([0-9][0-9][0-9][0-9])([0-9][0-9])([0-9][0-9])"))
+
+(define decimal-radix-regexp
+  (make-regexp
+   "^ *[$]?[+-]?[$]?[0-9]+[+-]?$|^ *[$]?[+-]?[$]?[0-9]?[0-9]?[0-9]?([,'][0-9][0-9][0-9])*(\\.[0-9]*)?[+-]? *$|^ *[$]?[+-]?[$]?[0-9]+\\.[0-9]*[+-]? *$"))
+
+(define comma-radix-regexp
+  (make-regexp
+   "^ *[$]?[+-]?[$]?[0-9]+[+-]?$|^ *[$]?[+-]?[$]?[0-9]?[0-9]?[0-9]?([\\.'][0-9][0-9][0-9])*(,[0-9]*)?[+-]? *$|^ *[$]?[+-]?[$]?[0-9]+,[0-9]*[+-]? *$"))
+
+(define integer-regexp (make-regexp "^[$]?[+-]?[$]?[0-9]+[+-]? *$"))
+
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;  qif-split:parse-category
+;;  this one just gets nastier and nastier.
+;;  ATM we return a list of 6 elements:
+;;    parsed category name (without [] if it was an account name)
+;;    bool stating if it was an account name
+;;    class of account or #f
+;;    string representing the "miscx category" if any
+;;    bool if miscx category is an account
+;;    class of miscx cat or #f
+;;  gosh, I love regular expressions.
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+
+(define (qif-split:parse-category self value)
+  (let ((match (regexp-exec qif-category-compiled-rexp value)))
+    (if match
+        (let ((rv
+               (list (match:substring match 2)
+                     (if (and (match:substring match 1)
+                              (match:substring match 3))
+                         #t #f)
+                     (if (match:substring match 4)
+                         (match:substring match 5)
+                         #f)
+                     ;; miscx category name
+                     (if (match:substring match 6)
+                         (match:substring match 8)
+                         #f)
+                     ;; is it an account?
+                     (if (and (match:substring match 7)
+                              (match:substring match 9))
+                         #t #f)
+                     (if (match:substring match 10)
+                         (match:substring match 11)
+                         #f))))
+          rv)
+        (begin
+          ;; Parsing failed. Bug detected!
+          (gnc:warn "qif-split:parse-category: can't parse [" value "].")
+          (throw 'bug
+                 "qif-split:parse-category"
+                 "Can't parse account or category ~A."
+                 (list value)
+                 #f)))))
+
+
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;  qif-parse:fix-year
+;;  this is where we handle y2k fixes etc.  input is a string
+;;  containing the year ("00", "2000", and "19100" all mean the same
+;;  thing). output is an integer representing the year in the C.E.
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+
+(define (qif-parse:fix-year year-string y2k-threshold)
+  (let ((fixed-string #f)
+        (post-read-value #f)
+        (y2k-fixed-value #f))
+
+    ;; quicken prints 2000 as "' 0" for at least some versions.
+    ;; thanks dave p for reporting this.
+    (if (eq? (string-ref year-string 0) #\')
+        (begin
+          (gnc:warn "qif-file:fix-year: found weird QIF Y2K year ["
+                    year-string "].")
+          (set! fixed-string
+                (substring year-string 2 (string-length year-string))))
+        (set! fixed-string year-string))
+
+    ;; now the string should just have a number in it plus some
+    ;; optional trailing space.
+    (set! post-read-value
+          (with-input-from-string fixed-string
+            (lambda () (read))))
+
+    (cond
+     ;; 2-digit numbers less than the window size are interpreted to
+     ;; be post-2000.
+     ((and (integer? post-read-value)
+           (< post-read-value y2k-threshold))
+      (set! y2k-fixed-value (+ 2000 post-read-value)))
+
+     ;; there's a common bug in printing post-2000 dates that
+     ;; prints 2000 as 19100 etc.
+     ((and (integer? post-read-value)
+           (> post-read-value 19000))
+      (set! y2k-fixed-value (+ 1900 (- post-read-value 19000))))
+
+     ;; normal dates represented in unix years (i.e. year-1900, so
+     ;; 2000 => 100.)  We also want to allow full year specifications,
+     ;; (i.e. 1999, 2001, etc) and there's a point at which you can't
+     ;; determine which is which.  this should eventually be another
+     ;; field in the qif-file struct but not yet.  mktime in scheme
+     ;; doesn't deal with dates before December 14, 1901, at least for
+     ;; now, so let's give ourselves until at least 3802 before this
+     ;; does the wrong thing.
+     ((and (integer? post-read-value)
+           (< post-read-value 1902))
+      (set! y2k-fixed-value (+ 1900 post-read-value)))
+
+     ;; this is a normal, 4-digit year spec (1999, 2000, etc).
+     ((integer? post-read-value)
+      (set! y2k-fixed-value post-read-value))
+
+     ;; No idea what the string represents.  Maybe a new bug in Quicken!
+     (#t
+      (gnc:warn "qif-file:fix-year: ay caramba! What is this? ["
+                year-string "].")))
+
+    y2k-fixed-value))
+
+
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;  parse-acct-type : set the type of the account, using gnucash
+;;  conventions.
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+
+(define (qif-parse:parse-acct-type read-value errorproc errortype)
+  (let ((mangled-string
+         (string-downcase! (string-remove-trailing-space
+                            (string-remove-leading-space read-value)))))
+    (cond
+     ((string=? mangled-string "bank")
+      (list GNC-BANK-TYPE))
+     ((string=? mangled-string "port")
+      (list GNC-BANK-TYPE))
+     ((string=? mangled-string "cash")
+      (list GNC-CASH-TYPE))
+     ((string=? mangled-string "ccard")
+      (list GNC-CCARD-TYPE))
+     ((string=? mangled-string "invst") ;; these are brokerage accounts.
+      (list GNC-BANK-TYPE))
+     ((string=? mangled-string "401(k)/403(b)")
+      (list GNC-BANK-TYPE))
+     ((string=? mangled-string "oth a")
+      (list GNC-ASSET-TYPE GNC-BANK-TYPE GNC-CASH-TYPE))
+     ((string=? mangled-string "oth l")
+      (list GNC-LIABILITY-TYPE GNC-CCARD-TYPE))
+     ((string=? mangled-string "oth s") ;; German asset account
+      (list GNC-ASSET-TYPE GNC-BANK-TYPE GNC-CASH-TYPE))
+     ((string=? mangled-string "mutual")
+      (list GNC-BANK-TYPE))
+     (#t
+      (errorproc errortype
+                 (sprintf #f (_ "Unrecognized account type '%s'. Defaulting to Bank.")
+                          read-value))
+      (list GNC-BANK-TYPE)))))
+
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;  parse-bang-field : the bang fields switch the parse context
+;;  for the qif file.
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+
+(define (qif-parse:parse-bang-field read-value)
+  (let ((bang-field (string-downcase!
+                     (string-remove-trailing-space read-value))))
+;; The QIF files output by the WWW site of Credit Lyonnais
+;; begin by:   !type bank
+;; instead of: !Type:bank
+    (if (>= (string-length bang-field) 5)
+        (if (string=? (substring bang-field 0 5) "type ")
+            (string-set! bang-field 4 #\:)))
+
+    (string->symbol bang-field)))
+
+
+(define (qif-parse:parse-action-field read-value errorproc errortype)
+  (if read-value
+      (let ((action-symbol (string-to-canonical-symbol read-value)))
+        (case action-symbol
+          ;; buy
+          ((buy cvrshrt kauf)
+           'buy)
+          ((buyx cvrshrtx kaufx)
+           'buyx)
+          ((cglong kapgew) ;; Kapitalgewinnsteuer
+           'cglong)
+          ((cglongx kapgewx)
+           'cglongx)
+          ((cgmid) ;; Kapitalgewinnsteuer
+           'cgmid)
+          ((cgmidx)
+           'cgmidx)
+          ((cgshort k.gewsp)
+           'cgshort)
+          ((cgshortx k.gewspx)
+           'cgshortx)
+          ((div)   ;; dividende
+           'div)
+          ((divx)
+           'divx)
+;          ((exercise)
+;           'exercise)
+;          ((exercisx)
+;           'exercisx)
+;          ((expire)
+;           'expire)
+;          ((grant)
+;           'grant)
+          ((int intinc) ;; zinsen
+           'intinc)
+          ((intx intincx)
+           'intincx)
+          ((margint)
+           'margint)
+          ((margintx)
+           'margintx)
+          ((miscexp)
+           'miscexp)
+          ((miscexpx)
+           'miscexpx)
+          ((miscinc cash)
+           'miscinc)
+          ((miscincx)
+           'miscincx)
+          ((reinvdiv)
+           'reinvdiv)
+          ((reinvint reinvzin)
+           'reinvint)
+          ((reinvlg reinvkur)
+           'reinvlg)
+          ((reinvmd)
+           'reinvmd)
+          ((reinvsg reinvksp)
+           'reinvsg)
+          ((reinvsh)
+           'reinvsh)
+          ((reminder erinnerg)
+           'reminder)
+          ((rtrncap)
+           'rtrncap)
+          ((rtrncapx)
+           'rtrncapx)
+          ((sell shtsell verkauf)  ;; verkaufen
+           'sell)
+          ((sellx shtsellx verkaufx)
+           'sellx)
+          ((shrsin aktzu)
+           'shrsin)
+          ((shrsout aktab)
+           'shrsout)
+          ((stksplit aktsplit)
+           'stksplit)
+          ((xin contribx)
+           'xin)
+          ((xout withdrwx)
+           'xout)
+;          ((vest)
+;           'vest)
+          (else
+           (errorproc errortype
+                      (sprintf #f (_ "Unrecognized action '%s'.") read-value))
+           #f)))
+      #f))
+
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;  parse-cleared-field : In a "C" (cleared status) QIF line,
+;;  * or C means cleared, X or R means reconciled, and ! or ?
+;;  mean some budget related stuff I don't understand.
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+
+(define (qif-parse:parse-cleared-field read-value errorproc errortype)
+  (if (and (string? read-value)
+           (not (string-null? read-value)))
+      (let ((secondchar (string-ref read-value 0)))
+        (case secondchar
+          ;; Reconciled is the most likely, especially for large imports,
+          ;; so check that first. Also allow for lowercase.
+          ((#\X #\x #\R #\r)
+           'reconciled)
+          ((#\* #\C #\c)
+           'cleared)
+          ((#\? #\!)
+           'budgeted)
+          (else
+            (errorproc errortype
+                       (sprintf #f (_ "Unrecognized status '%s'. Defaulting to uncleared.")
+                                read-value))
+            #f)))
+      #f))
+
+
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;  parse-check-date-format
+;;  given a match-triple (matches in spaces 1, 2, 3) and a
+;;  list of possible date formats, return the list of formats
+;;  that this date string could actually be.
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+(define (parse-check-date-format match possible-formats)
+  (let ((date-parts (list (match:substring match 1)
+                          (match:substring match 2)
+                          (match:substring match 3)))
+        (numeric-date-parts '())
+        (retval '()))
+
+    ;;(define (print-list l)
+    ;;  (for-each (lambda (x) (display x) (display " ")) l))
+
+    ;;(for-each (lambda (x) (if (list? x) (print-list x) (display x)))
+    ;;      (list "parsing: " date-parts " in " possible-formats "\n"))
+
+    ;; get the strings into numbers (but keep the strings around)
+    (set! numeric-date-parts
+          (map (lambda (elt)
+                 (with-input-from-string elt
+                   (lambda () (read))))
+               date-parts))
+
+    (let ((possibilities possible-formats)
+          (n1 (car numeric-date-parts))
+          (n2 (cadr numeric-date-parts))
+          (n3 (caddr numeric-date-parts))
+          (s1 (car date-parts))
+          (s3 (caddr date-parts)))
+
+      ;; filter the possibilities to eliminate (hopefully)
+      ;; all but one
+      (if (or (not (number? n1)) (> n1 12))
+          (set! possibilities (delq 'm-d-y possibilities)))
+      (if (or (not (number? n1)) (> n1 31))
+          (set! possibilities (delq 'd-m-y possibilities)))
+      (if (or (not (number? n1)) (< n1 1))
+          (set! possibilities (delq 'd-m-y possibilities)))
+      (if (or (not (number? n1)) (< n1 1))
+          (set! possibilities (delq 'm-d-y possibilities)))
+
+      (if (or (not (number? n2)) (> n2 12))
+          (begin
+            (set! possibilities (delq 'd-m-y possibilities))
+            (set! possibilities (delq 'y-m-d possibilities))))
+
+      (if (or (not (number? n2)) (> n2 31))
+          (begin
+            (set! possibilities (delq 'm-d-y possibilities))
+            (set! possibilities (delq 'y-d-m possibilities))))
+
+      (if (or (not (number? n3)) (> n3 12))
+          (set! possibilities (delq 'y-d-m possibilities)))
+      (if (or (not (number? n3)) (> n3 31))
+          (set! possibilities (delq 'y-m-d possibilities)))
+
+      (if (or (not (number? n3)) (< n3 1))
+          (set! possibilities (delq 'y-m-d possibilities)))
+      (if (or (not (number? n3)) (< n3 1))
+          (set! possibilities (delq 'y-d-m possibilities)))
+
+      ;; If we've got a 4-character year, make sure the date
+      ;; is after 1930.  Don't check the high value (perhaps
+      ;; we should?).
+      (if (= (string-length s1) 4)
+          (if (or (not (number? n1)) (< n1 1930))
+              (begin
+                (set! possibilities (delq 'y-m-d possibilities))
+                (set! possibilities (delq 'y-d-m possibilities)))))
+      (if (= (string-length s3) 4)
+          (if (or (not (number? n3)) (< n3 1930))
+              (begin
+                (set! possibilities (delq 'm-d-y possibilities))
+                (set! possibilities (delq 'd-m-y possibilities)))))
+
+      (set! retval possibilities))
+    retval))
+
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;  qif-parse:check-date-format
+;;  given a list of possible date formats, return a pruned list
+;;  of possibilities.
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+(define (qif-parse:check-date-format date-string possible-formats)
+  (let ((retval '()))
+    (if (or (not (string? date-string))
+            (not (> (string-length date-string) 0)))
+        (set! retval possible-formats))
+    (let ((match (regexp-exec qif-date-compiled-rexp date-string)))
+      (if match
+          (if (match:substring match 1)
+              (set! retval (parse-check-date-format match possible-formats))
+
+              ;; Uh oh -- this is a string XXXXXXXX; we don't know which
+              ;; way to test..  So test both YYYYxxxx and xxxxYYYY,
+              ;; and let the parser verify the year is valid.
+              (let* ((new-date-string (match:substring match 4))
+                     (date-ymd (regexp-exec qif-date-ymd-compiled-rexp
+                                            new-date-string))
+                     (date-mdy (regexp-exec qif-date-mdy-compiled-rexp
+                                               new-date-string))
+                     (res1 '())
+                     (res2 '()))
+                (if (or (memq 'y-d-m possible-formats)
+                        (memq 'y-m-d possible-formats))
+                    (set! res1 (parse-check-date-format date-ymd possible-formats)))
+                (if (or (memq 'd-m-y possible-formats)
+                        (memq 'm-d-y possible-formats))
+                    (set! res2 (parse-check-date-format date-mdy possible-formats)))
+
+                (set! retval (append res1 res2))))))
+    retval))
+
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;  qif-parse:parse-date/format
+;;  given a date-string and a format, convert the string to a
+;;  date and return a list of day, month, year
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+
+(define (qif-parse:parse-date/format date-string format)
+  (let ((date-parts '())
+        (numeric-date-parts '())
+        (retval #f)
+
+        (match (regexp-exec qif-date-compiled-rexp date-string)))
+    (if match
+        (if (match:substring match 1)
+             (set! date-parts (list (match:substring match 1)
+                                    (match:substring match 2)
+                                    (match:substring match 3)))
+             ;; This is of the form XXXXXXXX; split the string based on
+             ;; whether the format is YYYYxxxx or xxxxYYYY
+             (let ((date-str (match:substring match 4)))
+               (case format
+                 ((d-m-y m-d-y)
+                  (let ((m (regexp-exec qif-date-mdy-compiled-rexp date-str)))
+                    (set! date-parts (list (match:substring m 1)
+                                           (match:substring m 2)
+                                           (match:substring m 3)))))
+                 ((y-m-d y-d-m)
+                  (let ((m (regexp-exec qif-date-ymd-compiled-rexp date-str)))
+                    (set! date-parts (list (match:substring m 1)
+                                           (match:substring m 2)
+                                           (match:substring m 3)))))
+                 ))))
+
+    ;; get the strings into numbers (but keep the strings around)
+    (set! numeric-date-parts
+          (map (lambda (elt)
+                 (with-input-from-string elt
+                   (lambda () (read))))
+               date-parts))
+
+    ;; if the date parts list doesn't have 3 parts, we're in trouble
+    (if (not (eq? 3 (length date-parts)))
+        (gnc:warn "qif-parse:parse-date/format: can't interpret date ["
+                  date-string "]\nDate parts: " date-parts)
+        (case format
+          ((d-m-y)
+           (let ((d (car numeric-date-parts))
+                 (m (cadr numeric-date-parts))
+                 (y (qif-parse:fix-year (caddr date-parts) 50)))
+             (if (and (integer? d) (integer? m) (integer? y)
+                      (<= m 12) (<= d 31))
+                 (set! retval (list d m y))
+                 (gnc:warn "qif-parse:parse-date/format: "
+                           "format is d/m/y, but date is ["
+                           date-string "]."))))
+
+          ((m-d-y)
+           (let ((m (car numeric-date-parts))
+                 (d (cadr numeric-date-parts))
+                 (y (qif-parse:fix-year (caddr date-parts) 50)))
+             (if (and (integer? d) (integer? m) (integer? y)
+                      (<= m 12) (<= d 31))
+                 (set! retval (list d m y))
+                 (gnc:warn "qif-parse:parse-date/format: "
+                           "format is m/d/y, but date is ["
+                           date-string "]."))))
+
+          ((y-m-d)
+           (let ((y (qif-parse:fix-year (car date-parts) 50))
+                 (m (cadr numeric-date-parts))
+                 (d (caddr numeric-date-parts)))
+             (if (and (integer? d) (integer? m) (integer? y)
+                      (<= m 12) (<= d 31))
+                 (set! retval (list d m y))
+                 (gnc:warn "qif-parse:parse-date/format: "
+                           "format is y/m/d, but date is ["
+                           date-string "]."))))
+
+          ((y-d-m)
+           (let ((y (qif-parse:fix-year (car date-parts) 50))
+                 (d (cadr numeric-date-parts))
+                 (m (caddr numeric-date-parts)))
+             (if (and (integer? d) (integer? m) (integer? y)
+                      (<= m 12) (<= d 31))
+                 (set! retval (list d m y))
+                 (gnc:warn "qif-parse:parse-date/format: "
+                           "format is y/d/m, but date is ["
+                           date-string "]."))))))
+    retval))
+
+
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;  number format predicates
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+
+(define (value-is-decimal-radix? value)
+  (if (regexp-exec decimal-radix-regexp value)
+      #t #f))
+
+(define (value-is-comma-radix? value)
+  (if (regexp-exec comma-radix-regexp value)
+      #t #f))
+
+(define (value-is-integer? value)
+  (if (regexp-exec integer-regexp value)
+      #t #f))
+
+
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;  qif-parse:check-number-format
+;;  given a list of possible number formats, return a pruned list
+;;  of possibilities.
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+
+(define (qif-parse:check-number-format value-string possible-formats)
+  (let ((retval possible-formats))
+    (if (not (value-is-decimal-radix? value-string))
+        (set! retval (delq 'decimal retval)))
+    (if (not (value-is-comma-radix? value-string))
+        (set! retval (delq 'comma retval)))
+    (if (not (value-is-integer? value-string))
+        (set! retval (delq 'integer retval)))
+    retval))
+
+
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;  qif-parse:parse-number/format
+;;  assuming we know what the format is, parse the string.
+;;  returns a gnc-numeric; the denominator is set so as to exactly
+;;  represent the number
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+
+(define (qif-parse:parse-number/format value-string format)
+  (let ((minus-index (string-index value-string #\-))
+        (filtered-string (gnc:string-delete-chars value-string "$'+-")))
+    (case format
+      ((decimal)
+       (let* ((read-string (string-remove-char filtered-string #\,))
+              (read-val (with-input-from-string read-string
+                                                (lambda () (read)))))
+         (if (number? read-val)
+             (double-to-gnc-numeric
+              (if minus-index (- 0.0 read-val) (+ 0.0 read-val))
+              GNC-DENOM-AUTO
+              (logior (GNC-DENOM-SIGFIGS
+                       (string-length (string-remove-char read-string #\.)))
+                      GNC-RND-ROUND))
+             (gnc-numeric-zero))))
+      ((comma)
+       (let* ((read-string (gnc:string-replace-char
+                              (string-remove-char filtered-string #\.)
+                              #\, #\.))
+              (read-val (with-input-from-string read-string
+                                                (lambda () (read)))))
+         (if (number? read-val)
+             (double-to-gnc-numeric
+              (if minus-index (- 0.0 read-val) (+ 0.0 read-val))
+              GNC-DENOM-AUTO
+              (logior (GNC-DENOM-SIGFIGS
+                       (string-length (string-remove-char read-string #\.)))
+                      GNC-RND-ROUND))
+             (gnc-numeric-zero))))
+      ((integer)
+       (let ((read-val (with-input-from-string filtered-string
+                                               (lambda () (read)))))
+         (if (number? read-val)
+             (double-to-gnc-numeric
+              (if minus-index (- 0.0 read-val) (+ 0.0 read-val))
+              1 GNC-RND-ROUND)
+             (gnc-numeric-zero)))))))
+
+(define (qif-parse:check-number-formats amt-strings formats)
+  (let ((retval formats))
+    (for-each
+     (lambda (amt)
+       (if amt
+           (set! retval (qif-parse:check-number-format amt retval))))
+     amt-strings)
+    retval))
+
+(define (qif-parse:parse-numbers/format amt-strings format)
+  (let* ((all-ok #t)
+         (tmp #f)
+         (parsed
+          (map
+           (lambda (amt)
+             (if amt
+                 (begin
+                   (set! tmp (qif-parse:parse-number/format amt format))
+                   (if (not tmp)
+                       (set! all-ok #f))
+                   tmp)
+                 (gnc-numeric-zero)))
+           amt-strings)))
+    (if all-ok parsed #f)))
+
+(define (qif-parse:print-date date-list)
+  (let ((tm (localtime (current-time))))
+    (set-tm:mday tm (car date-list))
+    (set-tm:mon tm (- (cadr date-list) 1))
+    (set-tm:year tm (- (caddr date-list) 1900))
+    (strftime "%a %B %d %Y" tm)))
+
+(define (qif-parse:print-number num)
+  (with-output-to-string
+    (lambda ()
+      (write num))))
+
+(define (qif-parse:print-numbers num)
+  (with-output-to-string
+    (lambda ()
+      (write num))))

Copied: gnucash/trunk/src/import-export/qif-imp/qif-to-gnc.scm (from rev 23566, gnucash/trunk/src/import-export/qif-import/qif-to-gnc.scm)
===================================================================
--- gnucash/trunk/src/import-export/qif-imp/qif-to-gnc.scm	                        (rev 0)
+++ gnucash/trunk/src/import-export/qif-imp/qif-to-gnc.scm	2013-12-15 17:21:20 UTC (rev 23567)
@@ -0,0 +1,1231 @@
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;;  qif-to-gnc.scm
+;;;  this is where QIF transactions are transformed into a
+;;;  Gnucash account tree.
+;;;
+;;;  Copyright 2000-2001 Bill Gribble <grib at billgribble.com>
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+
+(use-modules (srfi srfi-13))
+(use-modules (gnucash printf))
+
+
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;  qif-import:find-or-make-acct
+;;
+;;  Given a colon-separated account path, return an Account* to
+;;  an existing or new account.
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+
+(define (qif-import:find-or-make-acct acct-info check-types? commodity
+				      check-commodity? default-currency
+                                      gnc-acct-hash old-root new-root)
+  (let* ((sep (gnc-get-account-separator-string))
+         (gnc-name (qif-map-entry:gnc-name acct-info))
+         (existing-account (hash-ref gnc-acct-hash gnc-name))
+         (same-gnc-account
+          (gnc-account-lookup-by-full-name old-root gnc-name))
+         (allowed-types
+          (qif-map-entry:allowed-types acct-info))
+         (make-new-acct #f)
+         (incompatible-acct #f))
+
+    (define (compatible? account)
+      (let ((acc-type (xaccAccountGetType account))
+            (acc-commodity (xaccAccountGetCommodity account)))
+        (and
+         (if check-types?
+             (and (list? allowed-types)
+                  (memv acc-type allowed-types))
+             #t)
+	 (if check-commodity?
+	     (gnc-commodity-equiv acc-commodity commodity)
+	     #t))))
+
+    (define (make-unique-name-variant long-name short-name)
+      (if (not (null? (gnc-account-lookup-by-full-name old-root long-name)))
+          (let loop ((count 2))
+            (let* ((test-name
+                    (string-append long-name (sprintf #f " %a" count)))
+                   (test-acct
+                    (gnc-account-lookup-by-full-name old-root test-name)))
+              (if (and (not (null? test-acct)) (not (compatible? test-acct)))
+                  (loop (+ 1 count))
+                  (string-append short-name (sprintf #f " %a" count)))))
+          short-name))
+
+    ;; If a GnuCash account already exists in the old root with the same
+    ;; name, that doesn't necessarily mean we can use it. The type and
+    ;; commodity must be  compatible.
+    (if (and same-gnc-account (not (null? same-gnc-account)))
+        (if (compatible? same-gnc-account)
+            (begin
+              ;; The existing GnuCash account is compatible, so we
+              ;; can use it. Make sure we use the same type.
+              (set! make-new-acct #f)
+              (set! incompatible-acct #f)
+              (set! allowed-types
+                    (list (xaccAccountGetType same-gnc-account))))
+            (begin
+              ;; There's an existing, incompatible account with that name,
+              ;; so we have to make a new account with different properties
+              ;; and a slightly different name.
+              (set! make-new-acct #t)
+              (set! incompatible-acct #t)))
+        (begin
+          ;; Otherwise, there's no existing account with the same name.
+          (set! make-new-acct #t)
+          (set! incompatible-acct #f)))
+
+    ;; here, existing-account means a previously *created* account
+    ;; (possibly a new account, possibly a copy of an existing gnucash
+    ;; acct)
+    (if (and (and existing-account (not (null? existing-account)))
+             (compatible? existing-account))
+        existing-account
+        (let ((new-acct (xaccMallocAccount (gnc-get-current-book)))
+              (parent-acct #f)
+              (parent-name #f)
+              (acct-name #f)
+              (last-sep #f))
+
+          ;; This procedure returns a default account type.  This could
+          ;; be smarter, but at least it won't allow security account
+          ;; types to be used on currency-denominated accounts.
+          (define (default-account-type allowed-types currency?)
+            (if (or (not allowed-types)
+                    (null? allowed-types))
+                ;; None of the allowed types are compatible.
+                ;; Bug detected!
+                (throw 'bug
+                       "qif-import:find-or-make-acct"
+                       "No valid account types allowed for account ~A."
+                       (list acct-name)
+                       #f)
+                (if (memv (car allowed-types) (list GNC-STOCK-TYPE
+                                                    GNC-MUTUAL-TYPE))
+                    ;; The type is incompatible with a currency.
+                    (if currency?
+                      (default-account-type (cdr allowed-types)
+                                            currency?)
+                      (car allowed-types))
+                    ;; The type is compatible with a currency.
+                    (if currency?
+                      (car allowed-types)
+                      (default-account-type (cdr allowed-types)
+                                            currency?)))))
+
+          (set! last-sep (gnc:string-rcontains gnc-name sep))
+
+          (xaccAccountBeginEdit new-acct)
+
+          ;; if this is a copy of an existing gnc account, copy the
+          ;; account properties.  For incompatible existing accts,
+          ;; we'll do something different later.
+          (if (and same-gnc-account (not (null? same-gnc-account)))
+              (begin
+                (xaccAccountSetName
+                 new-acct (xaccAccountGetName same-gnc-account))
+                (xaccAccountSetDescription
+                 new-acct (xaccAccountGetDescription same-gnc-account))
+                (xaccAccountSetType
+                 new-acct (xaccAccountGetType same-gnc-account))
+                (xaccAccountSetCommodity
+                 new-acct (xaccAccountGetCommodity same-gnc-account))
+                (xaccAccountSetNotes
+                 new-acct (xaccAccountGetNotes same-gnc-account))
+                (xaccAccountSetColor
+                 new-acct (xaccAccountGetColor same-gnc-account))
+                (xaccAccountSetCode
+                 new-acct (xaccAccountGetCode same-gnc-account))))
+
+          ;; If this is a nested account foo:bar:baz, make sure
+          ;; that foo:bar and foo exist also.
+          (if last-sep
+              (begin
+                (set! parent-name (substring gnc-name 0 last-sep))
+                (set! acct-name (substring gnc-name (+ (string-length sep)
+                                                       last-sep))))
+              (set! acct-name gnc-name))
+
+          ;; If this is a completely new account (as opposed to a copy
+          ;; of an existing account), use the parameters passed in.
+          (if make-new-acct
+              (begin
+                ;; Set the name, description, and commodity.
+                (xaccAccountSetName new-acct acct-name)
+                (if (qif-map-entry:description acct-info)
+                    (xaccAccountSetDescription
+                     new-acct (qif-map-entry:description acct-info)))
+                (xaccAccountSetCommodity new-acct commodity)
+
+                ;; If there was an existing, incompatible account with
+                ;; the same name, set the new account name to be unique,
+                ;; and set a description that hints at what's happened.
+                (if incompatible-acct
+                    (let ((new-name (make-unique-name-variant
+                                     gnc-name acct-name)))
+                      (xaccAccountSetName new-acct new-name)
+                      (xaccAccountSetDescription
+                       new-acct
+                       (_ "QIF import: Name conflict with another account."))))
+
+                ;; Set the account type.
+                (xaccAccountSetType new-acct
+                                    (default-account-type
+                                      (qif-map-entry:allowed-types acct-info)
+                                      (gnc-commodity-is-currency commodity)))))
+          (xaccAccountCommitEdit new-acct)
+
+          ;; If a parent account is needed, find or make it.
+          (if last-sep
+              (let ((pinfo (make-qif-map-entry)))
+                (qif-map-entry:set-qif-name! pinfo parent-name)
+                (qif-map-entry:set-gnc-name! pinfo parent-name)
+                (qif-map-entry:set-allowed-types!
+                 acct-info (list (xaccAccountGetType new-acct)))
+                (qif-map-entry:set-allowed-types!
+                 pinfo (qif-map-entry:allowed-parent-types acct-info))
+
+                (set! parent-acct (qif-import:find-or-make-acct
+                                   pinfo #t default-currency #f default-currency
+                                   gnc-acct-hash old-root new-root))))
+          (if (and parent-acct (not (null? parent-acct)))
+              (gnc-account-append-child parent-acct new-acct)
+              (gnc-account-append-child new-root new-acct))
+
+          (hash-set! gnc-acct-hash gnc-name new-acct)
+          new-acct))))
+
+
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;; qif-import:qif-to-gnc
+;;
+;; This is the top-level of the back end conversion from QIF
+;; to GnuCash. All the account mappings and so on should be
+;; done before this is called.
+;;
+;; This procedure returns:
+;;   success: the root of the imported tree
+;;   failure: a symbol indicating the reason
+;;   cancel:  #t
+;;   bug:     #f
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+
+(define (qif-import:qif-to-gnc qif-files-list
+                               qif-acct-map qif-cat-map
+                               qif-memo-map stock-map
+                               default-currency-name
+                               transaction-status-pref
+                               progress-dialog)
+
+  ;; This procedure does all the work. We'll define it, then call it safely.
+  (define (private-convert)
+    (let* ((old-root (gnc-get-current-root-account))
+           (new-root (xaccMallocAccount (gnc-get-current-book)))
+           (gnc-acct-hash (make-hash-table 20))
+           (sep (gnc-get-account-separator-string))
+           (default-currency
+             (gnc-commodity-table-find-full
+              (gnc-commodity-table-get-table (gnc-get-current-book))
+              GNC_COMMODITY_NS_CURRENCY default-currency-name))
+           (sorted-accounts-list '())
+           (markable-xtns '())
+           (sorted-qif-files-list (sort qif-files-list
+                                        (lambda (a b)
+                                          (> (length (qif-file:xtns a))
+                                             (length (qif-file:xtns b))))))
+           (work-to-do 0)
+           (work-done 0))
+
+      ;; This procedure handles progress reporting, pause, and cancel.
+      (define (update-progress)
+        (set! work-done (+ 1 work-done))
+        (if (and progress-dialog
+                 (zero? (remainder work-done 8)))
+            (begin
+              (gnc-progress-dialog-set-value progress-dialog
+                                             (/ work-done work-to-do))
+              (qif-import:check-pause progress-dialog)
+              (if qif-import:canceled
+                  (throw 'cancel)))))
+
+
+      (if progress-dialog
+          (gnc-progress-dialog-set-sub progress-dialog
+                                      (_ "Preparing to convert your QIF data")))
+
+      ;; Build a list of all accounts to create for the import tree.
+      ;; We need to iterate over the account, category, and payee/memo
+      ;; mappings to build the list.
+      (hash-fold
+       (lambda (k v p)
+         (if (qif-map-entry:display? v)
+             (set! sorted-accounts-list
+                   (cons v sorted-accounts-list)))
+         #t)
+       #t qif-acct-map)
+
+      (hash-fold
+       (lambda (k v p)
+         (if (qif-map-entry:display? v)
+             (set! sorted-accounts-list
+                   (cons v sorted-accounts-list)))
+         #t)
+       #t qif-cat-map)
+
+      (hash-fold
+       (lambda (k v p)
+         (if (qif-map-entry:display? v)
+             (set! sorted-accounts-list
+                   (cons v sorted-accounts-list)))
+         #t)
+       #t qif-memo-map)
+      (set! work-to-do (length sorted-accounts-list))
+
+      ;; Before trying to mark transactions, prune down the list to
+      ;; those that are transfers between QIF accounts.
+      (for-each
+       (lambda (qif-file)
+         (for-each
+          (lambda (xtn)
+            (set! work-to-do (+ 1 work-to-do))
+            (let splitloop ((splits (qif-xtn:splits xtn)))
+              (if (qif-split:category-is-account? (car splits))
+                  (begin
+                    (set! markable-xtns (cons xtn markable-xtns))
+                    (set! work-to-do (+ 1 work-to-do)))
+                  (if (not (null? (cdr splits)))
+                      (splitloop (cdr splits))))))
+          (qif-file:xtns qif-file)))
+       qif-files-list)
+
+
+      ;; Build a local account tree to hold converted transactions.
+      (if progress-dialog
+          (gnc-progress-dialog-set-sub progress-dialog
+                                       (_ "Creating accounts")))
+
+      ;; Sort the account list on the depth of the account path.  If a
+      ;; short part is explicitly mentioned, make sure it gets created
+      ;; before the deeper path that would create the parent accounts
+      ;; without enough information about their type.
+      (set! sorted-accounts-list
+            (sort sorted-accounts-list
+                  (lambda (a b)
+                    (< (gnc:substring-count (qif-map-entry:gnc-name a)
+                                            sep)
+                       (gnc:substring-count (qif-map-entry:gnc-name b)
+                                            sep)))))
+
+      ;; Make all the accounts.
+      (for-each
+       (lambda (acctinfo)
+         (let* ((security
+                 (and stock-map
+                      (hash-ref stock-map
+                                (qif-import:get-account-name
+                                 (qif-map-entry:qif-name acctinfo)))))
+                (ok-types (qif-map-entry:allowed-types acctinfo))
+                (equity? (memv GNC-EQUITY-TYPE ok-types))
+                (stock? (or (memv GNC-STOCK-TYPE ok-types)
+                            (memv GNC-MUTUAL-TYPE ok-types))))
+
+           (update-progress)
+           (cond ((and equity? security)  ;; a "retained holdings" acct
+                  (qif-import:find-or-make-acct acctinfo #f
+                                                security #t
+                                                default-currency
+                                                gnc-acct-hash
+                                                old-root new-root))
+                 ((and security (or stock?
+                                    (gnc-commodity-is-currency security)))
+                  (qif-import:find-or-make-acct
+                   acctinfo #f security #t default-currency
+                   gnc-acct-hash old-root new-root))
+                 (#t
+                  (qif-import:find-or-make-acct
+                   acctinfo #f default-currency #t default-currency
+                   gnc-acct-hash old-root new-root)))))
+       sorted-accounts-list)
+
+      ;; Run through the markable transactions marking any
+      ;; duplicates.  marked transactions/splits won't get imported.
+      (if progress-dialog
+          (gnc-progress-dialog-set-sub progress-dialog
+                                    (_ "Matching transfers between accounts")))
+      (if (> (length markable-xtns) 1)
+          (let xloop ((xtn (car markable-xtns))
+                      (rest (cdr markable-xtns)))
+            ;; Update the progress.
+            (update-progress)
+
+            (if (not (qif-xtn:mark xtn))
+                (qif-import:mark-matching-xtns xtn rest))
+            (if (not (null? (cdr rest)))
+                (xloop (car rest) (cdr rest)))))
+
+      ;; Iterate over files. Going in the sort order by number of
+      ;; transactions should give us a small speed advantage.
+      (for-each
+       (lambda (qif-file)
+         (if progress-dialog
+             (gnc-progress-dialog-set-sub progress-dialog
+                                          (string-append (_ "Converting") " "
+                                                     (qif-file:path qif-file))))
+         (for-each
+          (lambda (xtn)
+            ;; Update the progress.
+            (update-progress)
+
+            (if (not (qif-xtn:mark xtn))
+                ;; Convert into a GnuCash transaction.
+                (let ((gnc-xtn (xaccMallocTransaction
+                                (gnc-get-current-book))))
+                  (xaccTransBeginEdit gnc-xtn)
+
+                  ;; All accounts & splits are required to be in the
+                  ;; user-specified currency. Use it for the txn too.
+                  (xaccTransSetCurrency gnc-xtn default-currency)
+
+                  ;; Build the transaction.
+                  (qif-import:qif-xtn-to-gnc-xtn xtn qif-file gnc-xtn
+                                                 gnc-acct-hash
+                                                 qif-acct-map
+                                                 qif-cat-map
+                                                 qif-memo-map
+                                                 transaction-status-pref
+                                                 progress-dialog)
+
+                  ;; rebalance and commit everything
+                  (xaccTransCommitEdit gnc-xtn))))
+          (qif-file:xtns qif-file)))
+       sorted-qif-files-list)
+
+      ;; Finished.
+      (if progress-dialog
+          (gnc-progress-dialog-set-value progress-dialog 1))
+
+      new-root))
+
+  ;; Safely convert the files and return the result.
+  (gnc:backtrace-if-exception
+    (lambda ()
+      (catch 'cancel
+             (lambda ()
+               (catch 'bad-date private-convert (lambda (key . args) key)))
+             (lambda (key . args) #t)))))
+
+
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;; qif-import:qif-xtn-to-gnc-xtn
+;; translate a single transaction to a set of gnucash splits and
+;; a gnucash transaction structure.
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+
+(define (qif-import:qif-xtn-to-gnc-xtn qif-xtn qif-file gnc-xtn
+                                       gnc-acct-hash
+                                       qif-acct-map qif-cat-map qif-memo-map
+                                       transaction-status-pref
+                                       progress-dialog)
+  (let ((splits (qif-xtn:splits qif-xtn))
+        (gnc-near-split (xaccMallocSplit (gnc-get-current-book)))
+        (near-split-total (gnc-numeric-zero))
+        (near-acct-info #f)
+        (near-acct-name #f)
+        (near-acct #f)
+        (qif-payee (qif-xtn:payee qif-xtn))
+        (qif-number (qif-xtn:number qif-xtn))
+        (qif-action (qif-xtn:action qif-xtn))
+        (qif-security (qif-xtn:security-name qif-xtn))
+        (qif-default-split (qif-xtn:default-split qif-xtn))
+        (qif-memo #f)
+        (qif-date (qif-xtn:date qif-xtn))
+        (qif-from-acct (qif-xtn:from-acct qif-xtn))
+        (qif-cleared (qif-xtn:cleared qif-xtn))
+        (n- (lambda (n) (gnc-numeric-neg n)))
+        (nsub (lambda (a b) (gnc-numeric-sub a b 0 GNC-DENOM-LCD)))
+        (n+ (lambda (a b) (gnc-numeric-add a b 0 GNC-DENOM-LCD)))
+        (n* (lambda (a b) (gnc-numeric-mul a b 0 GNC-DENOM-REDUCE)))
+        (n/ (lambda (a b) (gnc-numeric-div a b 0 GNC-DENOM-REDUCE))))
+
+    ;; Set properties of the whole transaction.
+
+    ;; Set the transaction date.
+    (cond
+      ((not qif-date)
+        (qif-import:log progress-dialog
+                        "qif-import:qif-xtn-to-gnc-xtn"
+                        (_ "Missing transaction date."))
+        (throw 'bad-date
+               "qif-import:qif-xtn-to-gnc-xtn"
+               "Missing transaction date."
+               #f
+               #f))
+      ((< (list-ref qif-date 2) 1970)
+        (qif-import:log progress-dialog
+                        "qif-import:qif-xtn-to-gnc-xtn"
+                        (_ "Dates earlier than 1970 are not supported."))
+        (throw 'bad-date
+               "qif-import:qif-xtn-to-gnc-xtn"
+               "Invalid transaction year (~A)."
+               (list (list-ref qif-date 2))
+               #f))
+      (else
+        (apply xaccTransSetDate gnc-xtn (qif-xtn:date qif-xtn))))
+
+    ;; fixme: bug #105
+    (if qif-payee
+        (xaccTransSetDescription gnc-xtn qif-payee))
+    (if qif-number
+        ;; Use function that will set either tran-num or split-action per
+        ;; book option.
+        (gnc-set-num-action gnc-xtn gnc-near-split qif-number #f))
+
+    ;; Look for the transaction memo (QIF "M" line). When a default split
+    ;; exists, the memo can be found there. Otherwise, it will be in the
+    ;; first member of the splits list.
+    (if qif-default-split
+       (set! qif-memo (qif-split:memo qif-default-split))
+       (set! qif-memo (qif-split:memo (car (qif-xtn:splits qif-xtn)))))
+    (if qif-memo
+	  (if (or (not qif-payee)
+	          (equal? qif-payee ""))
+	      (xaccTransSetDescription gnc-xtn qif-memo)
+	      ;; Use the memo for the transaction notes. Previously this went to
+	      ;; the debit/credit lines. See bug 495219 for more information.
+	      (xaccTransSetNotes gnc-xtn qif-memo)))
+
+    ;; Look for the transaction status (QIF "C" line). When it exists, apply
+    ;; the cleared (c) or reconciled (y) status to the split. Otherwise, apply
+    ;; user preference.
+    (if (eq? qif-cleared 'cleared)
+        (xaccSplitSetReconcile gnc-near-split #\c)
+        (if (eq? qif-cleared 'reconciled)
+            (xaccSplitSetReconcile gnc-near-split #\y)
+            ;; Apply user preference by default.
+            (xaccSplitSetReconcile gnc-near-split transaction-status-pref)))
+
+    (if (not qif-security)
+        (begin
+          ;; NON-STOCK TRANSACTIONS: the near account is the current
+          ;; bank-account or the default associated with the file.
+          ;; the far account is the one associated with the split
+          ;; category.
+          (set! near-acct-info (hash-ref qif-acct-map qif-from-acct))
+          (set! near-acct-name (qif-map-entry:gnc-name near-acct-info))
+          (set! near-acct (hash-ref gnc-acct-hash near-acct-name))
+
+          ;; iterate over QIF splits.  Each split defines one "far
+          ;; end" for the transaction.
+          (for-each
+           (lambda (qif-split)
+             (if (not (qif-split:mark qif-split))
+                 (let ((gnc-far-split (xaccMallocSplit
+                                       (gnc-get-current-book)))
+                       (far-acct-info #f)
+                       (far-acct-name #f)
+                       (far-acct #f)
+                       (split-amt (qif-split:amount qif-split))
+                       ;; For split transactions, get this split's memo.
+                       (memo
+                         (if qif-default-split
+                             (qif-split:memo qif-split) #f))
+                       (cat (qif-split:category qif-split)))
+
+                   (if (not split-amt) (set! split-amt (gnc-numeric-zero)))
+                   ;; fill the splits in (near first).  This handles
+                   ;; files in multiple currencies by pulling the
+                   ;; currency value from the file import.
+                   (set! near-split-total (n+ near-split-total split-amt))
+                   (xaccSplitSetValue gnc-far-split (n- split-amt))
+                   (xaccSplitSetAmount gnc-far-split (n- split-amt))
+
+                   (if memo (xaccSplitSetMemo gnc-far-split memo))
+
+                   ;; figure out what the far acct is
+                   (cond
+                    ;; If the category is an account, use the account mapping.
+                    ((and (not (string=? cat ""))
+                          (qif-split:category-is-account? qif-split))
+                     (set! far-acct-info (hash-ref qif-acct-map cat)))
+
+                    ;; Otherwise, if it isn't empty, use the category mapping.
+                    ((not (string=? cat ""))
+                     (set! far-acct-info (hash-ref qif-cat-map cat)))
+
+                    ;; Otherwise, for non-split QIF transactions, try a payee
+                    ;; mapping, and if that doesn't work, try mapping the
+                    ;; transaction memo. For split transactions, map the memo
+                    ;; for this particular split line. If all else fails, use
+                    ;; the default category mapping (the Unspecified account,
+                    ;; unless the user has changed it).
+                    (#t
+                     (set! far-acct-info
+                           (if (= (length splits) 1)
+                               (or (and (string? qif-payee)
+                                        (not (string=? qif-payee ""))
+                                        (hash-ref qif-memo-map qif-payee))
+                                   (and (string? qif-memo)
+                                        (not (string=? qif-memo ""))
+                                        (hash-ref qif-memo-map qif-memo)))
+                               (and (string? memo)
+                                    (not (string=? memo ""))
+                                    (hash-ref qif-memo-map memo))))
+                     (if (not far-acct-info)
+                         (set! far-acct-info (hash-ref qif-cat-map cat)))))
+
+                   (set! far-acct-name (qif-map-entry:gnc-name far-acct-info))
+                   (set! far-acct (hash-ref gnc-acct-hash far-acct-name))
+
+                   ;; set the reconcile status.
+                   (let ((cleared (qif-split:matching-cleared qif-split)))
+                     (if (eq? 'cleared cleared)
+                         (xaccSplitSetReconcile gnc-far-split #\c))
+                     (if (eq? 'reconciled cleared)
+                         (xaccSplitSetReconcile gnc-far-split #\y)))
+
+                   ;; finally, plug the split into the account
+                   (xaccSplitSetAccount gnc-far-split far-acct)
+                   (xaccSplitSetParent gnc-far-split gnc-xtn))))
+           splits)
+
+          ;; the value of the near split is the total of the far splits.
+          (xaccSplitSetValue gnc-near-split near-split-total)
+          (xaccSplitSetAmount gnc-near-split near-split-total)
+          (xaccSplitSetParent gnc-near-split gnc-xtn)
+          (xaccSplitSetAccount gnc-near-split near-acct))
+
+        ;; STOCK TRANSACTIONS: the near/far accounts depend on the
+        ;; "action" encoded in the Number field.  It's generally the
+        ;; security account (for buys, sells, and reinvests) but can
+        ;; also be an interest, dividend, or SG/LG account.
+        (let* ((share-price (qif-xtn:share-price qif-xtn))
+               (num-shares (qif-xtn:num-shares qif-xtn))
+               (split-amt #f)
+               (xtn-amt (qif-split:amount (car (qif-xtn:splits qif-xtn))))
+               (qif-accts #f)
+               (qif-near-acct #f)
+               (qif-far-acct #f)
+               (qif-commission-acct #f)
+               (far-acct-info #f)
+               (far-acct-name #f)
+               (far-acct #f)
+               (commission-acct #f)
+               (commission-amt (qif-xtn:commission qif-xtn))
+               (commission-split #f)
+               (gnc-far-split (xaccMallocSplit (gnc-get-current-book))))
+
+          (if (not num-shares) (set! num-shares (gnc-numeric-zero)))
+
+          ;; Determine the extended price of all shares without commission.
+          (if xtn-amt
+              ;; Adjust for commission (if any).
+              (if commission-amt
+                  (case qif-action
+                    ((sell sellx shrsout)
+                     (set! split-amt (n+ xtn-amt commission-amt)))
+                    (else
+                     (set! split-amt (nsub xtn-amt commission-amt))))
+                  (set! split-amt xtn-amt))
+              ;; There's no grand total available.
+              (if share-price
+                  ;; Use the given share price, despite possible rounding.
+                  (set! split-amt (n* num-shares share-price))
+                  (set! split-amt (gnc-numeric-zero))))
+
+          ;; Determine the share price.
+          (if (not share-price)
+              (set! share-price (gnc-numeric-zero))
+              (if (and xtn-amt (not (gnc-numeric-zero-p num-shares)))
+                  ;; There's a share price but it could be imprecise
+                  ;; enough to cause rounding. We can compute a better
+                  ;; share price ourselves. For more information, see
+                  ;; bug 373584.
+                  (set! share-price (n/ split-amt num-shares))))
+
+          ;; I don't think this should ever happen, but I want
+          ;; to keep this check just in case.
+          (if (> (length splits) 1)
+              (gnc:warn "qif-import:qif-xtn-to-gnc-xtn: "
+                        "splits in stock transaction!"))
+
+          (set! qif-accts
+                (qif-split:accounts-affected (car (qif-xtn:splits qif-xtn))
+                                             qif-xtn))
+
+          (set! qif-near-acct (car qif-accts))
+          (set! qif-far-acct (cadr qif-accts))
+          (set! qif-commission-acct (caddr qif-accts))
+
+          ;; Translate the QIF account names into GnuCash accounts.
+          (if (and qif-near-acct qif-far-acct)
+              (begin
+                ;; Determine the near account.
+                (set! near-acct-info
+                      (or (hash-ref qif-acct-map qif-near-acct)
+                          (hash-ref qif-cat-map qif-near-acct)))
+                (set! near-acct-name (qif-map-entry:gnc-name near-acct-info))
+                (set! near-acct (hash-ref gnc-acct-hash near-acct-name))
+
+                ;; Determine the far account.
+                (if (or (not (string? qif-far-acct))
+                        (string=? qif-far-acct ""))
+                    ;; No far account name is specified, so try a
+                    ;; payee or memo mapping to get a default.
+                    (set! far-acct-info
+                          (or (hash-ref qif-memo-map (qif-xtn:payee qif-xtn))
+                              (hash-ref qif-memo-map
+                                        (qif-split:memo
+                                          (car (qif-xtn:splits qif-xtn)))))))
+                (if (not far-acct-info)
+                    (set! far-acct-info
+                          (or (hash-ref qif-acct-map qif-far-acct)
+                              (hash-ref qif-cat-map qif-far-acct))))
+                (set! far-acct-name (qif-map-entry:gnc-name far-acct-info))
+                (set! far-acct (hash-ref gnc-acct-hash far-acct-name))))
+
+          ;; the amounts and signs: are shares going in or out?
+          ;; are amounts currency or shares?
+          (case qif-action
+            ((buy buyx reinvint reinvdiv reinvsg reinvsh reinvmd reinvlg)
+             (if (not share-price) (set! share-price (gnc-numeric-zero)))
+             (xaccSplitSetAmount gnc-near-split num-shares)
+             (xaccSplitSetValue gnc-near-split split-amt)
+             (xaccSplitSetValue gnc-far-split (n- xtn-amt))
+             (xaccSplitSetAmount gnc-far-split (n- xtn-amt)))
+
+            ((sell sellx)
+             (if (not share-price) (set! share-price (gnc-numeric-zero)))
+             (xaccSplitSetAmount gnc-near-split (n- num-shares))
+             (xaccSplitSetValue gnc-near-split (n- split-amt))
+             (xaccSplitSetValue gnc-far-split xtn-amt)
+             (xaccSplitSetAmount gnc-far-split xtn-amt))
+
+            ((cgshort cgshortx cgmid cgmidx cglong cglongx intinc intincx
+                      div divx miscinc miscincx xin rtrncap rtrncapx)
+             (xaccSplitSetValue gnc-near-split xtn-amt)
+             (xaccSplitSetAmount gnc-near-split xtn-amt)
+             (xaccSplitSetValue gnc-far-split (n- xtn-amt))
+             (xaccSplitSetAmount gnc-far-split (n- xtn-amt)))
+
+            ((xout miscexp miscexpx margint margintx)
+             (xaccSplitSetValue gnc-near-split (n- xtn-amt))
+             (xaccSplitSetAmount gnc-near-split (n- xtn-amt))
+             (xaccSplitSetValue gnc-far-split  xtn-amt)
+             (xaccSplitSetAmount gnc-far-split  xtn-amt))
+
+            ((shrsin)
+             ;; getting rid of the old equity-acct-per-stock trick.
+             ;; you must now have a cash/basis value for the stock.
+             (xaccSplitSetAmount gnc-near-split num-shares)
+             (xaccSplitSetValue gnc-near-split split-amt)
+             (xaccSplitSetValue gnc-far-split (n- xtn-amt))
+             (xaccSplitSetAmount gnc-far-split (n- xtn-amt)))
+
+            ((shrsout)
+             ;; shrsout is like shrsin
+             (xaccSplitSetAmount gnc-near-split (n- num-shares))
+             (xaccSplitSetValue gnc-near-split (n- split-amt))
+             (xaccSplitSetValue gnc-far-split xtn-amt)
+             (xaccSplitSetAmount gnc-far-split xtn-amt))
+
+            ;; stock splits: QIF just specifies the split ratio, not
+            ;; the number of shares in and out, so we have to fetch
+            ;; the number of shares from the security account
+
+            ;; FIXME : this could be wrong.  Make sure the
+            ;; share-amount is at the correct time.
+            ((stksplit)
+             (let* ((splitratio (n/ num-shares (gnc-numeric-create 10 1)))
+                    (in-shares
+                     (xaccAccountGetBalance near-acct))
+                    (out-shares (n* in-shares splitratio)))
+               (xaccSplitSetAmount gnc-near-split out-shares)
+               (xaccSplitSetAmount gnc-far-split (n- in-shares))
+               (xaccSplitSetValue gnc-near-split (n- split-amt))
+               (xaccSplitSetValue gnc-far-split split-amt))))
+
+          (let ((cleared (qif-split:matching-cleared
+                          (car (qif-xtn:splits qif-xtn)))))
+            (if (eq? 'cleared cleared)
+                (xaccSplitSetReconcile gnc-far-split #\c))
+            (if (eq? 'reconciled cleared)
+                (xaccSplitSetReconcile gnc-far-split #\y)))
+
+          (if qif-commission-acct
+              (let* ((commission-acct-info
+                      (or (hash-ref qif-acct-map qif-commission-acct)
+                          (hash-ref qif-cat-map qif-commission-acct)))
+                     (commission-acct-name
+                      (and commission-acct-info
+                           (qif-map-entry:gnc-name commission-acct-info))))
+                (if commission-acct-name
+                    (set! commission-acct
+                          (hash-ref gnc-acct-hash commission-acct-name)))))
+
+          (if (and commission-amt commission-acct)
+              (begin
+                (set! commission-split (xaccMallocSplit
+                                        (gnc-get-current-book)))
+                (xaccSplitSetValue commission-split commission-amt)
+                (xaccSplitSetAmount commission-split commission-amt)))
+
+          (if (and qif-near-acct qif-far-acct)
+              (begin
+                (xaccSplitSetParent gnc-near-split gnc-xtn)
+                (xaccSplitSetAccount gnc-near-split near-acct)
+
+                (xaccSplitSetParent gnc-far-split gnc-xtn)
+                (xaccSplitSetAccount gnc-far-split far-acct)
+
+                (if commission-split
+                    (begin
+                      (xaccSplitSetParent commission-split gnc-xtn)
+                      (xaccSplitSetAccount commission-split
+                                           commission-acct)))))))
+
+    ;; QIF indicates a void transaction by starting the payee with "**VOID**".
+    (if (and (string? qif-payee)
+             (string-prefix? "**VOID**" qif-payee))
+        (xaccTransVoid gnc-xtn "QIF"))
+
+    ;; return the modified transaction (though it's ignored).
+    gnc-xtn))
+
+
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;  qif-import:mark-matching-xtns
+;;  find transactions that are the "opposite half" of xtn and
+;;  mark them so they won't be imported.
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+
+(define (qif-import:mark-matching-xtns xtn candidate-xtns)
+  (let splitloop ((splits-left (qif-xtn:splits xtn)))
+
+    ;; splits-left starts out as all the splits of this transaction.
+    ;; if multiple splits match up with a single split on the other
+    ;; end, we may remove more than one split from splits-left with
+    ;; each call to mark-some-splits.
+    (if (not (null? splits-left))
+        (if (and (not (qif-split:mark (car splits-left)))
+                 (qif-split:category-is-account? (car splits-left)))
+            (set! splits-left
+                  (qif-import:mark-some-splits
+                   splits-left xtn candidate-xtns))
+            (set! splits-left (cdr splits-left))))
+
+    (if (not (null? splits-left))
+        (splitloop splits-left))))
+
+
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;; qif-import:mark-some-splits
+;; find split(s) matching elements of splits and mark them so they
+;; don't get imported.
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+
+(define (qif-import:mark-some-splits splits xtn candidate-xtns)
+  (let* ((n- (lambda (n) (gnc-numeric-neg n)))
+         (nsub (lambda (a b) (gnc-numeric-sub a b 0 GNC-DENOM-LCD)))
+         (n+ (lambda (a b) (gnc-numeric-add a b 0 GNC-DENOM-LCD)))
+         (n* (lambda (a b) (gnc-numeric-mul a b 0 GNC-DENOM-REDUCE)))
+         (n/ (lambda (a b) (gnc-numeric-div a b 0 GNC-DENOM-REDUCE)))
+         (split (car splits))
+         (near-acct-name #f)
+         (far-acct-name #f)
+         (date (qif-xtn:date xtn))
+         (amount (n- (qif-split:amount split)))
+         (group-amount #f)
+         (security-name (qif-xtn:security-name xtn))
+         (action (qif-xtn:action xtn))
+         (bank-xtn? (not security-name))
+         (different-acct-splits '())
+         (same-acct-splits '())
+         (how #f)
+         (done #f))
+
+    (if bank-xtn?
+        (begin
+          (set! near-acct-name (qif-xtn:from-acct xtn))
+          (set! far-acct-name (qif-split:category split))
+          (set! group-amount (gnc-numeric-zero))
+
+          ;; group-amount is the sum of all the splits in this xtn
+          ;; going to the same account as 'split'.  We might be able
+          ;; to match this whole group to a single matching opposite
+          ;; split.
+          (for-each
+           (lambda (s)
+             (if (and (qif-split:category-is-account? s)
+                      (string=? far-acct-name (qif-split:category s)))
+                 (begin
+                   (set! same-acct-splits
+                         (cons s same-acct-splits))
+                   (set! group-amount (nsub group-amount (qif-split:amount s))))
+                 (set! different-acct-splits
+                       (cons s different-acct-splits))))
+           splits)
+
+          (set! same-acct-splits (reverse same-acct-splits))
+          (set! different-acct-splits (reverse different-acct-splits)))
+
+        ;; stock transactions.  they can't have splits as far as I can
+        ;; tell, so the 'different-acct-splits' is always '()
+        (let ((qif-accts
+               (qif-split:accounts-affected split xtn)))
+          (set! near-acct-name (car qif-accts))
+          (set! far-acct-name (cadr qif-accts))
+          (set! same-acct-splits (list split))
+          (if action
+              ;; we need to do some special massaging to get
+              ;; transactions to match up.  Quicken thinks the near
+              ;; and far accounts are different than we do.
+              (case action
+                ((intincx divx cglongx cgmidx cgshortx rtrncapx margintx
+                          sellx)
+                 (set! amount (n- amount))
+                 (set! near-acct-name (qif-xtn:from-acct xtn))
+                 (set! far-acct-name (qif-split:category split)))
+                ((miscincx miscexpx)
+                 (set! amount (n- amount))
+                 (set! near-acct-name (qif-xtn:from-acct xtn))
+                 (set! far-acct-name (qif-split:miscx-category split)))
+                ((buyx)
+                 (set! near-acct-name (qif-xtn:from-acct xtn))
+                 (set! far-acct-name (qif-split:category split)))
+                ((xout)
+                 (set! amount (n- amount)))))))
+
+    ;; this is the grind loop.  Go over every unmarked transaction in
+    ;; the candidate-xtns list.
+    (let xtn-loop ((xtns candidate-xtns))
+      (if (and (not (qif-xtn:mark (car xtns)))
+               (string=? (qif-xtn:from-acct (car xtns)) far-acct-name))
+          (begin
+            (set! how
+                  (qif-import:xtn-has-matches? (car xtns) near-acct-name
+                                               date amount group-amount))
+            (if how
+                (begin
+                  (qif-import:merge-and-mark-xtns xtn same-acct-splits
+                                                  (car xtns) how)
+                  (set! done #t)))))
+      ;; iterate with the next transaction
+      (if (and (not done)
+               (not (null? (cdr xtns))))
+          (xtn-loop (cdr xtns))))
+
+    ;; return the rest of the splits to iterate on
+    (if (not how)
+        (cdr splits)
+        (case (car how)
+          ((one-to-one many-to-one)
+           (cdr splits))
+          ((one-to-many)
+           different-acct-splits)))))
+
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;  qif-import:xtn-has-matches?
+;;  check for one-to-one, many-to-one, one-to-many split matches.
+;;  returns either #f (no match) or a cons cell with the car being one
+;;  of 'one-to-one 'one-to-many 'many-to-one, the cdr being a list of
+;;  splits that were part of the matching group.
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+
+(define (qif-import:xtn-has-matches? xtn acct-name date amount group-amt)
+  (let ((same-acct-splits '())
+        (this-group-amt (gnc-numeric-zero))
+        (how #f)
+        (date-matches
+         (let ((self-date (qif-xtn:date xtn)))
+           (and (pair? self-date)
+                (pair? date)
+                (eq? (length self-date) 3)
+                (eq? (length date) 3)
+                (= (car self-date) (car date))
+                (= (cadr self-date) (cadr date))
+                (= (caddr self-date) (caddr date)))))
+        (n- (lambda (n) (gnc-numeric-neg n)))
+        (nsub (lambda (a b) (gnc-numeric-sub a b 0 GNC-DENOM-LCD)))
+        (n+ (lambda (a b) (gnc-numeric-add a b 0 GNC-DENOM-LCD)))
+        (n* (lambda (a b) (gnc-numeric-mul a b 0 GNC-DENOM-REDUCE)))
+        (n/ (lambda (a b) (gnc-numeric-div a b 0 GNC-DENOM-REDUCE))))
+
+    (if date-matches
+        (begin
+          ;; calculate a group total for splits going to acct-name
+          (let split-loop ((splits-left (qif-xtn:splits xtn)))
+            (let ((split (car splits-left)))
+              ;; does the account match up?
+              (if (and (qif-split:category-is-account? split)
+                       (string? acct-name)
+                       (string=? (qif-split:category split) acct-name))
+                  ;; if so, get the amount
+                  (let ((this-amt (qif-split:amount split))
+                        (stock-xtn (qif-xtn:security-name xtn))
+                        (action (qif-xtn:action xtn)))
+                    ;; need to change the sign of the amount for some
+                    ;; stock transactions (buy/sell both positive in
+                    ;; QIF)
+                    (if (and stock-xtn action)
+                        (case action
+                          ((xout sellx intincx divx cglongx cgshortx
+                                 miscincx miscexpx)
+                           (set! this-amt (n- this-amt)))))
+
+                    ;; we might be done if this-amt is either equal
+                    ;; to the split amount or the group amount.
+                    (cond
+                     ((gnc-numeric-equal this-amt amount)
+                      (set! how
+                            (cons 'one-to-one (list split))))
+                     ((and group-amt (gnc-numeric-equal this-amt group-amt))
+                      (set! how
+                            (cons 'one-to-many (list split))))
+                     (#t
+                      (set! same-acct-splits (cons split same-acct-splits))
+                      (set! this-group-amt
+                            (n+ this-group-amt this-amt))))))
+
+              ;; if 'how' is non-#f, we are ready to return.
+              (if (and (not how)
+                       (not (null? (cdr splits-left))))
+                  (split-loop (cdr splits-left)))))
+
+          ;; now we're out of the loop.  if 'how' isn't set,
+          ;; we can still have a many-to-one match.
+          (if (and (not how)
+                   (gnc-numeric-equal this-group-amt amount))
+              (set! how (cons 'many-to-one same-acct-splits)))))
+
+    ;; we're all done.  'how' either is #f or a
+    ;; cons of the way-it-matched and a list of the matching
+    ;; splits.
+    how))
+
+
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;  (qif-split:accounts-affected split xtn)
+;;  Get the near and far ends of a split, returned as a list
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+
+(define (qif-split:accounts-affected split xtn)
+  (let ((near-acct-name #f)
+        (far-acct-name #f)
+        (commission-acct-name #f)
+        (security (qif-xtn:security-name xtn))
+        (action (qif-xtn:action xtn))
+        (from-acct (qif-xtn:from-acct xtn)))
+
+    ;; for non-security transactions, the near account is the
+    ;; acct in which the xtn is, and the far is the account
+    ;; linked by the category line.
+
+    (if (not security)
+        ;; non-security transactions
+        (begin
+          (set! near-acct-name from-acct)
+          (set! far-acct-name (qif-split:category split)))
+
+        ;; security transactions : the near end is either the
+        ;; brokerage, the stock, or the category
+        (begin
+          (case action
+            ((buy buyx sell sellx reinvint reinvdiv reinvsg reinvsh
+                  reinvlg reinvmd shrsin shrsout stksplit)
+             (set! near-acct-name (default-stock-acct from-acct security)))
+            ((div cgshort cglong cgmid intinc miscinc miscexp
+                  rtrncap margint xin xout)
+             (set! near-acct-name from-acct))
+            ((divx cgshortx cglongx cgmidx intincx rtrncapx margintx)
+             (set! near-acct-name
+                   (qif-split:category (car (qif-xtn:splits xtn)))))
+            ((miscincx miscexpx)
+             (set! near-acct-name
+                   (qif-split:miscx-category (car (qif-xtn:splits xtn))))))
+
+          ;; the far split: where is the money coming from?
+          ;; Either the brokerage account, the category,
+          ;; or an external account
+          (case action
+            ((buy sell)
+             (set! far-acct-name from-acct))
+            ((buyx sellx miscinc miscincx miscexp miscexpx xin xout)
+             (set! far-acct-name
+                   (qif-split:category (car (qif-xtn:splits xtn)))))
+            ((stksplit)
+             (set! far-acct-name (default-stock-acct from-acct security)))
+            ((cgshort cgshortx reinvsg reinvsh)
+             (set! far-acct-name
+                   (default-cgshort-acct from-acct security)))
+            ((cglong cglongx reinvlg)
+             (set! far-acct-name
+                   (default-cglong-acct from-acct security)))
+            ((cgmid cgmidx reinvmd)
+             (set! far-acct-name
+                   (default-cgmid-acct from-acct security)))
+            ((intinc intincx reinvint)
+             (set! far-acct-name
+                   (default-interest-acct from-acct security)))
+            ((margint margintx)
+             (set! far-acct-name
+                   (default-margin-interest-acct from-acct)))
+            ((rtrncap rtrncapx)
+             (set! far-acct-name
+                   (default-capital-return-acct from-acct security)))
+            ((div divx reinvdiv)
+             (set! far-acct-name
+                   (default-dividend-acct from-acct security)))
+            ((shrsin shrsout)
+             (set! far-acct-name
+                   (default-equity-holding security))))
+
+          ;; the commission account, if it exists
+          (if (qif-xtn:commission xtn)
+              (set! commission-acct-name
+                    (default-commission-acct from-acct)))))
+
+    (list near-acct-name far-acct-name commission-acct-name)))
+
+
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;; qif-import:merge-and-mark-xtns
+;; we know that the splits match.  Pick one to mark and
+;; merge the information into the other one.
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+
+(define (qif-import:merge-and-mark-xtns xtn splits other-xtn how)
+  ;; merge transaction fields
+  (let ((action (qif-xtn:action xtn))
+        (o-action (qif-xtn:action other-xtn))
+        (security (qif-xtn:security-name xtn))
+        (o-security (qif-xtn:security-name other-xtn))
+        (split (car splits))
+        (match-type (car how))
+        (match-splits (cdr how)))
+    (case match-type
+      ;; many-to-one: the other-xtn has several splits that total
+      ;; in amount to 'split'.  We want to preserve the multi-split
+      ;; transaction.
+      ((many-to-one)
+       (qif-xtn:mark-split xtn split)
+       (qif-import:merge-xtn-info xtn other-xtn)
+       (for-each
+        (lambda (s)
+          (qif-split:set-matching-cleared! s (qif-xtn:cleared xtn)))
+        match-splits))
+
+      ;; one-to-many: 'split' is just one of a set of splits in xtn
+      ;; that total up to the split in match-splits.
+      ((one-to-many)
+       (qif-xtn:mark-split other-xtn (car match-splits))
+       (qif-import:merge-xtn-info other-xtn xtn)
+       (for-each
+        (lambda (s)
+          (qif-split:set-matching-cleared!
+           s (qif-xtn:cleared other-xtn)))
+        splits))
+
+      ;; otherwise: one-to-one, a normal single split match.
+      (else
+       (cond
+        ;; If one transaction has more splits than the other, mark the
+        ;; one with less splits, regardless of all other conditions.
+        ;; Otherwise, QIF split transactions will become mangled. For
+        ;; more information, see bug 114724.
+        ((< (length (qif-xtn:splits xtn))
+            (length (qif-xtn:splits other-xtn)))
+               (qif-xtn:mark-split xtn split)
+               (qif-import:merge-xtn-info xtn other-xtn)
+               (qif-split:set-matching-cleared!
+                (car match-splits) (qif-xtn:cleared xtn)))
+
+        ((> (length (qif-xtn:splits xtn))
+            (length (qif-xtn:splits other-xtn)))
+               (qif-xtn:mark-split other-xtn (car match-splits))
+               (qif-import:merge-xtn-info other-xtn xtn)
+               (qif-split:set-matching-cleared!
+                split (qif-xtn:cleared other-xtn)))
+
+        ;; this is a transfer involving a security xtn.  Let the
+        ;; security xtn dominate the way it's handled.
+        ((and (not action) o-action o-security)
+         (qif-xtn:mark-split xtn split)
+         (qif-import:merge-xtn-info xtn other-xtn)
+         (qif-split:set-matching-cleared!
+          (car match-splits) (qif-xtn:cleared xtn)))
+
+        ((and action (not o-action) security)
+         (qif-xtn:mark-split other-xtn (car match-splits))
+         (qif-import:merge-xtn-info other-xtn xtn)
+         (qif-split:set-matching-cleared!
+          split (qif-xtn:cleared other-xtn)))
+
+        ;; this is a security transaction from one brokerage to another
+        ;; or within a brokerage.  The "foox" xtn has the most
+        ;; information about what went on, so use it.
+        ((and action o-action o-security)
+         (case o-action
+           ((buyx sellx cgshortx cgmidx cglongx intincx divx
+                  margintx rtrncapx miscincx miscexpx)
+            (qif-xtn:mark-split xtn split)
+            (qif-import:merge-xtn-info xtn other-xtn)
+            (qif-split:set-matching-cleared!
+             (car match-splits) (qif-xtn:cleared xtn)))
+
+           (else
+            (qif-xtn:mark-split other-xtn (car match-splits))
+            (qif-import:merge-xtn-info other-xtn xtn)
+            (qif-split:set-matching-cleared!
+             split (qif-xtn:cleared other-xtn)))))
+
+        ;; Otherwise, this is a normal no-frills split match.
+        (#t
+          (qif-xtn:mark-split other-xtn (car match-splits))
+          (qif-import:merge-xtn-info other-xtn xtn)
+          (qif-split:set-matching-cleared!
+           split (qif-xtn:cleared other-xtn))))))))
+
+
+(define (qif-import:merge-xtn-info from-xtn to-xtn)
+  (if (and (qif-xtn:payee from-xtn)
+           (not (qif-xtn:payee to-xtn)))
+      (qif-xtn:set-payee! to-xtn (qif-xtn:payee from-xtn)))
+  (if (and (qif-xtn:address from-xtn)
+           (not (qif-xtn:address to-xtn)))
+      (qif-xtn:set-address! to-xtn (qif-xtn:address from-xtn)))
+  (if (and (qif-xtn:number from-xtn)
+           (not (qif-xtn:number to-xtn)))
+      (qif-xtn:set-number! to-xtn (qif-xtn:number from-xtn))))
+
+
+(define (qif-xtn:mark-split xtn split)
+  (qif-split:set-mark! split #t)
+  (let ((all-marked #t))
+    (let loop ((splits (qif-xtn:splits xtn)))
+      (if (not (qif-split:mark (car splits)))
+          (set! all-marked #f)
+          (if (not (null? (cdr splits)))
+              (loop (cdr splits)))))
+    (if all-marked
+        (qif-xtn:set-mark! xtn #t))))
+
+
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;  qif-import:qif-to-gnc-undo
+;;
+;;  Cancel the import by removing all newly created accounts,
+;;  splits, and transactions.
+;;
+;;  NOTE: Any new commodities should be destroyed by the druid.
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+(define (qif-import:qif-to-gnc-undo root)
+  (if root
+    (let ((txns (gnc:account-tree-get-transactions root)))
+      ;; Destroy all the transactions and their splits.
+      (for-each (lambda (elt) (xaccTransDestroy elt)) txns)
+
+      ;; Destroy the accounts
+      (xaccAccountBeginEdit root)
+      (xaccAccountDestroy root))))

Copied: gnucash/trunk/src/import-export/qif-imp/qif-utils.scm (from rev 23566, gnucash/trunk/src/import-export/qif-import/qif-utils.scm)
===================================================================
--- gnucash/trunk/src/import-export/qif-imp/qif-utils.scm	                        (rev 0)
+++ gnucash/trunk/src/import-export/qif-imp/qif-utils.scm	2013-12-15 17:21:20 UTC (rev 23567)
@@ -0,0 +1,100 @@
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;;  qif-utils.scm
+;;;  string munging and other utility routines 
+;;;
+;;;  Bill Gribble <grib at billgribble.com> 20 Feb 2000 
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+
+(use-modules (ice-9 regex))
+
+(define qif-import:paused #f)
+(define qif-import:canceled #f)
+
+(define (simple-filter pred list)
+  (let ((retval '()))
+    (map (lambda (elt)
+           (if (pred elt)
+               (set! retval (cons elt retval))))
+         list)
+    (reverse retval)))
+
+(define remove-trailing-space-rexp 
+  (make-regexp "^(.*[^ ]+) *$"))
+
+(define remove-leading-space-rexp 
+  (make-regexp "^ *([^ ].*)$"))
+
+(define (string-remove-trailing-space str)
+  (let ((match (regexp-exec remove-trailing-space-rexp str)))
+    (if match
+        (string-copy (match:substring match 1))
+        "")))
+
+(define (string-remove-leading-space str)
+  (let ((match (regexp-exec remove-leading-space-rexp str)))
+    (if match 
+        (string-copy (match:substring match 1))
+        "")))
+
+(define (string-remove-char str char)
+  (let ((rexpstr 
+         (case char  
+           ((#\.) "\\.")
+           ((#\^) "\\^")
+           ((#\$) "\\$")
+           ((#\*) "\\*")
+           ((#\+) "\\+")
+           ((#\\) "\\\\")
+           ((#\?) "\\?")
+           (else 
+             (make-string 1 char)))))
+    (regexp-substitute/global #f rexpstr str 'pre 'post)))
+
+
+(define (string-char-count str char)
+  (length (simple-filter (lambda (elt) (eq? elt char))
+                         (string->list str))))
+
+
+(define (string-replace-char! str old new)
+  (let ((rexpstr 
+         (if (not (eq? old #\.))
+             (make-string 1 old)
+             "\\."))
+        (newstr (make-string 1 new)))
+    (regexp-substitute/global #f rexpstr str 'pre newstr 'post)))
+
+(define (string-to-canonical-symbol str)
+  (string->symbol 
+   (string-downcase
+    (string-remove-leading-space
+     (string-remove-trailing-space str)))))
+
+
+(define (qif-import:log progress-dialog proc str)
+  (if progress-dialog
+      (gnc-progress-dialog-append-log progress-dialog (string-append str "\n"))
+      (gnc:warn proc ": " str)))
+
+(define (qif-import:reset-cancel-pause)
+  (set! qif-import:paused #f)
+  (set! qif-import:canceled #f))
+
+(define (qif-import:cancel)
+  (set! qif-import:canceled #t))
+
+(define (qif-import:toggle-pause progress-dialog)
+  (if qif-import:paused
+      (begin
+        (set! qif-import:paused #f)
+        (if progress-dialog
+            (gnc-progress-dialog-resume progress-dialog)))
+      (begin
+        (set! qif-import:paused #t)
+        (if progress-dialog
+            (gnc-progress-dialog-pause progress-dialog)))))
+
+(define (qif-import:check-pause progress-dialog)
+  (while (and qif-import:paused (not qif-import:canceled))
+    (gnc-progress-dialog-update progress-dialog)))
+

Copied: gnucash/trunk/src/import-export/qif-imp/test/Makefile.am (from rev 23566, gnucash/trunk/src/import-export/qif-import/test/Makefile.am)
===================================================================
--- gnucash/trunk/src/import-export/qif-imp/test/Makefile.am	                        (rev 0)
+++ gnucash/trunk/src/import-export/qif-imp/test/Makefile.am	2013-12-15 17:21:20 UTC (rev 23567)
@@ -0,0 +1,17 @@
+TESTS=test-link
+
+check_PROGRAMS=test-link
+
+test_link_SOURCES = \
+  test-link.c
+
+test_link_LDADD=../libgncmod-qif-import.la \
+  ${top_builddir}/src/register/ledger-core/libgncmod-ledger-core.la \
+  ${top_builddir}/src/libqof/qof/libgnc-qof.la \
+  ${top_builddir}/src/core-utils/libgnc-core-utils.la \
+  ${top_builddir}/src/gnome/libgnc-gnome.la \
+  ${top_builddir}/src/engine/libgncmod-engine.la \
+  ${top_builddir}/src/gnome-utils/libgncmod-gnome-utils.la \
+  ${top_builddir}/src/app-utils/libgncmod-app-utils.la \
+  ${LIBXML2_LIBS}
+

Copied: gnucash/trunk/src/import-export/qif-imp/test/test-link.c (from rev 23566, gnucash/trunk/src/import-export/qif-import/test/test-link.c)
===================================================================
--- gnucash/trunk/src/import-export/qif-imp/test/test-link.c	                        (rev 0)
+++ gnucash/trunk/src/import-export/qif-imp/test/test-link.c	2013-12-15 17:21:20 UTC (rev 23567)
@@ -0,0 +1,6 @@
+int
+main(int argc, char ** argv)
+{
+    return 0;
+}
+

Deleted: gnucash/trunk/src/import-export/qif-import/Makefile.am
===================================================================
--- gnucash/trunk/src/import-export/qif-import/Makefile.am	2013-12-15 17:20:10 UTC (rev 23566)
+++ gnucash/trunk/src/import-export/qif-import/Makefile.am	2013-12-15 17:21:20 UTC (rev 23567)
@@ -1,108 +0,0 @@
-SUBDIRS = . test gschemas
-
-pkglib_LTLIBRARIES=libgncmod-qif-import.la
-
-libgncmod_qif_import_la_SOURCES = \
-  dialog-account-picker.c \
-  assistant-qif-import.c \
-  gnc-plugin-qif-import.c \
-  gncmod-qif-import.c
-
-noinst_HEADERS = \
-  dialog-account-picker.h \
-  assistant-qif-import.h \
-  gnc-plugin-qif-import.h
-
-libgncmod_qif_import_la_LDFLAGS = -avoid-version
-
-libgncmod_qif_import_la_LIBADD = \
-  ${top_builddir}/src/import-export/libgncmod-generic-import.la \
-  ${top_builddir}/src/gnome/libgnc-gnome.la \
-  ${top_builddir}/src/gnome-utils/libgncmod-gnome-utils.la \
-  ${top_builddir}/src/app-utils/libgncmod-app-utils.la \
-  ${top_builddir}/src/core-utils/libgnc-core-utils.la \
-  ${top_builddir}/src/engine/libgncmod-engine.la \
-  ${top_builddir}/src/gnc-module/libgnc-module.la \
-  ${top_builddir}/src/libqof/qof/libgnc-qof.la \
-  ${GUILE_LIBS} \
-  ${GLIB_LIBS}
-
-
-gncscmmoddir = ${GNC_SHAREDIR}/guile-modules/gnucash/import-export
-gncscmmod_DATA = qif-import.scm 
-
-gncscmdir = ${GNC_SCM_INSTALL_DIR}/qif-import
-
-gncscm_DATA = \
-  qif-dialog-utils.scm \
-  qif-file.scm \
-  qif-guess-map.scm \
-  qif-import.scm \
-  qif-merge-groups.scm \
-  qif-objects.scm \
-  qif-parse.scm \
-  qif-to-gnc.scm \
-  qif-utils.scm
-
-gtkbuilderdir = ${GNC_GTKBUILDER_DIR}
-gtkbuilder_DATA = \
-   dialog-account-picker.glade \
-   assistant-qif-import.glade
-
-AM_CPPFLAGS = \
-  -I${top_srcdir}/src \
-  -I${top_builddir}/src \
-  -I${top_srcdir}/src/core-utils \
-  -I${top_srcdir}/src/engine \
-  -I${top_srcdir}/src/gnc-module \
-  -I${top_srcdir}/src/app-utils \
-  -I${top_srcdir}/src/gnome \
-  -I${top_srcdir}/src/gnome-utils \
-  -I${top_srcdir}/src/import-export \
-  -I${top_srcdir}/src/libqof/qof \
-  ${GUILE_CFLAGS} \
-  ${GLIB_CFLAGS} \
-  ${GTK_CFLAGS}
-
-uidir = $(GNC_UI_DIR)
-ui_DATA = \
-	gnc-plugin-qif-import-ui.xml
-
-EXTRA_DIST = \
-  ${gncscm_DATA} \
-  ${gtkbuilder_DATA} \
-  file-format.txt \
-  $(ui_DATA)
-
-CLEANFILES =
-
-if GNUCASH_SEPARATE_BUILDDIR
-SCM_FILE_LINKS = \
-  ${gncscm_DATA}
-endif
-
-noinst_DATA = .scm-links
-
-.scm-links: 
-	$(RM) -rf gnucash
-	mkdir -p  gnucash qif-import
-	mkdir -p  gnucash/import-export
-if GNUCASH_SEPARATE_BUILDDIR
-	for X in ${SCM_FILE_LINKS} ; do \
-	  $(LN_S) -f ${srcdir}/$$X . ; \
-	done
-endif
-	( cd gnucash/import-export; for A in $(gncscmmod_DATA) ; do $(LN_S) -f ../../$$A . ; done )
-	( cd qif-import; for A in $(gncscm_DATA) ; do $(LN_S) -f ../$$A . ; done )
-if ! OS_WIN32
-# Windows knows no "ln -s" but uses "cp": must copy every time (see bug #566567).
-	touch .scm-links
-endif
-
-clean-local:
-	$(RM) -rf gnucash qif-import
-
-CLEANFILES += .scm-links
-DISTCLEANFILES = ${SCM_FILE_LINKS}
-
-AM_CPPFLAGS += -DG_LOG_DOMAIN=\"gnc.import.qif.import\"

Deleted: gnucash/trunk/src/import-export/qif-import/assistant-qif-import.c
===================================================================
--- gnucash/trunk/src/import-export/qif-import/assistant-qif-import.c	2013-12-15 17:20:10 UTC (rev 23566)
+++ gnucash/trunk/src/import-export/qif-import/assistant-qif-import.c	2013-12-15 17:21:20 UTC (rev 23567)
@@ -1,3644 +0,0 @@
-/********************************************************************\
- * assistant-qif-import.c -- window for importing QIF files         *
- *                        (GnuCash)                                 *
- * Copyright (C) 2000 Bill Gribble <grib at billgribble.com>           *
- * Copyright (c) 2006 David Hampton <hampton at employees.org>         *
- * Copyright (c) 2011 Robert Fewell                                 *
- *                                                                  *
- * This program is free software; you can redistribute it and/or    *
- * modify it under the terms of the GNU General Public License as   *
- * published by the Free Software Foundation; either version 2 of   *
- * the License, or (at your option) any later version.              *
- *                                                                  *
- * This program is distributed in the hope that it will be useful,  *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of   *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the    *
- * GNU General Public License for more details.                     *
- *                                                                  *
- * You should have received a copy of the GNU General Public License*
- * along with this program; if not, contact:                        *
- *                                                                  *
- * Free Software Foundation           Voice:  +1-617-542-5942       *
- * 51 Franklin Street, Fifth Floor    Fax:    +1-617-542-2652       *
- * Boston, MA  02110-1301,  USA       gnu at gnu.org                   *
-\********************************************************************/
-
-#include "config.h"
-
-#include <gtk/gtk.h>
-#include <glib/gi18n.h>
-#include <glib/gstdio.h>
-#include <libguile.h>
-#include <sys/time.h>
-#include <unistd.h>
-
-#include "Account.h"
-#include "Transaction.h"
-#include "dialog-account-picker.h"
-#include "dialog-commodity.h"
-#include "dialog-progress.h"
-#include "dialog-utils.h"
-#include "dialog-file-access.h"
-#include "assistant-qif-import.h"
-#include "assistant-utils.h"
-#include "gnc-component-manager.h"
-#include "qof.h"
-#include "gnc-file.h"
-#include "gnc-gui-query.h"
-#include "gnc-guile-utils.h"
-#include "gnc-currency-edit.h"
-#include "gnc-ui-util.h"
-#include "gnc-gtk-utils.h"
-#include "gnc-main-window.h"
-#include "gnc-plugin-page-account-tree.h"
-#include "gnc-prefs.h"
-#include "gnc-ui.h"
-#include "guile-mappings.h"
-
-#include "swig-runtime.h"
-
-#define ASSISTANT_QIF_IMPORT_CM_CLASS "assistant-qif-import"
-#define GNC_PREFS_GROUP   "dialogs.import.qif"
-#define GNC_PREF_SHOW_DOC "show-doc"
-#define GNC_PREF_DEFAULT_TRANS_STATUS_CLEARED "default-status-cleared"
-#define GNC_PREF_DEFAULT_TRANS_STATUS_NOTCLEARED "default-status-notcleared"
-#define GNC_PREF_DEFAULT_TRANS_STATUS_RECONCILED "default-status-reconciled"
-
-#define PREV_ROW "prev_row"
-
-static QofLogModule log_module = GNC_MOD_ASSISTANT;
-
-enum filename_cols
-{
-    FILENAME_COL_INDEX = 0,
-    FILENAME_COL_NAME,
-    NUM_FILENAME_COLS
-};
-
-enum account_cols
-{
-    ACCOUNT_COL_INDEX = 0,
-    ACCOUNT_COL_QIF_NAME,
-    ACCOUNT_COL_GNC_NAME,
-    ACCOUNT_COL_NEW,
-    ACCOUNT_COL_ELLIPSIZE,
-    NUM_ACCOUNT_COLS
-};
-
-enum qif_trans_cols
-{
-    QIF_TRANS_COL_INDEX = 0,
-    QIF_TRANS_COL_DATE,
-    QIF_TRANS_COL_DESCRIPTION,
-    QIF_TRANS_COL_AMOUNT,
-    QIF_TRANS_COL_CHECKED,
-    NUM_QIF_TRANS_COLS
-};
-
-struct _qifimportwindow
-{
-    GtkWidget * window;
-    GtkWidget * assistant;
-
-    /* Widgets on the file selection page. */
-    GtkWidget * filename_entry;
-
-    /* File loading progress page. */
-    GtkWidget * load_pause;
-    GtkWidget * load_start;
-    GtkWidget * load_log;
-    GNCProgressDialog *load_progress;
-
-    /* Widgets on the default account page. */
-    GtkWidget * acct_entry;
-
-    /* Widgets on the date format page. */
-    GtkWidget * date_format_combo;
-
-    /* Widgets on the files loaded page. */
-    GtkWidget * selected_file_view;
-    GtkWidget * unload_file_btn;
-
-    /* Widgets on the account matching page. */
-    GtkWidget * acct_view;
-    GtkWidget * acct_view_count;
-    GtkWidget * acct_view_btn;
-
-    /* Widgets on the category matching page. */
-    GtkWidget * cat_view;
-    GtkWidget * cat_view_count;
-    GtkWidget * cat_view_btn;
-
-    /* Widgets on the memo matching page. */
-    GtkWidget * memo_view;
-    GtkWidget * memo_view_count;
-    GtkWidget * memo_view_btn;
-
-    /* Widgets on the currency & book options page. */
-    GtkWidget * currency_picker;
-    GtkWidget * book_option_label;
-    GtkWidget * book_option_message;
-
-    /* Widgets on the commodity page. */
-    gint        num_new_pages;
-
-    /* Conversion progress page. */
-    GtkWidget * convert_pause;
-    GtkWidget * convert_start;
-    GtkWidget * convert_log;
-    GNCProgressDialog *convert_progress;
-
-    /* Widgets on the duplicates page. */
-    GtkWidget * new_transaction_view;
-    GtkWidget * old_transaction_view;
-
-    /* Widgets on the summary page. */
-    GtkWidget * summary_text;
-
-    GList     * commodity_pages;
-
-    gboolean  show_doc_pages;
-    gboolean  ask_date_format;
-    gboolean  busy;
-    gboolean  load_stop;
-    gboolean  acct_tree_found;
-    gboolean  new_book;
-
-    SCM       imported_files;
-    SCM       selected_file;
-
-    SCM       acct_map_info;
-    SCM       acct_display_info;
-
-    SCM       cat_map_info;
-    SCM       cat_display_info;
-
-    SCM       memo_map_info;
-    SCM       memo_display_info;
-
-    SCM       gnc_acct_info;
-    SCM       security_hash;
-    SCM       security_prefs;
-    SCM       new_securities;
-    GList   * new_namespaces;
-    SCM       ticker_map;
-
-    SCM       imported_account_tree;
-    SCM       match_transactions;
-    SCM       transaction_status;
-    int       selected_transaction;
-};
-
-struct _qifassistantpage
-{
-    GtkWidget     *page;
-    GtkWidget     *namespace_combo;
-    GtkWidget     *name_entry;
-    GtkWidget     *mnemonic_entry;
-    gnc_commodity *commodity;
-    SCM            hash_key;
-};
-
-typedef struct _qifassistantpage QIFAssistantPage;
-
-static void gnc_ui_qif_import_assistant_destroy (GtkObject *object, gpointer user_data);
-static void gnc_ui_qif_import_assistant_close_handler (gpointer user_data );
-
-void gnc_ui_qif_import_cancel_cb (GtkAssistant *gtkassistant, gpointer user_data);
-void gnc_ui_qif_import_prepare_cb (GtkAssistant *assistant, GtkWidget *page, gpointer user_data);
-void gnc_ui_qif_import_finish_cb (GtkAssistant *gtkassistant, gpointer user_data);
-void gnc_ui_qif_import_close_cb (GtkAssistant *gtkassistant, gpointer user_data);
-
-void gnc_ui_qif_import_intro_prepare (GtkAssistant  *assistant, gpointer user_data);
-
-void gnc_ui_qif_import_load_file_prepare (GtkAssistant *assistant, gpointer user_data);
-void gnc_ui_qif_import_select_file_cb (GtkButton *button, gpointer user_data);
-
-void gnc_ui_qif_import_load_progress_prepare (GtkAssistant *assistant, gpointer user_data);
-void gnc_ui_qif_import_load_progress_pause_cb (GtkButton *button, gpointer user_data);
-void gnc_ui_qif_import_load_progress_start_cb (GtkButton * button, gpointer user_data);
-
-void gnc_ui_qif_import_date_format_prepare (GtkAssistant *assistant, gpointer user_data);
-void gnc_ui_qif_import_date_valid_cb (GtkWidget *widget, gpointer user_data);
-
-void gnc_ui_qif_import_account_prepare (GtkAssistant *assistant, gpointer user_data);
-void gnc_ui_qif_import_acct_valid_cb (GtkWidget *widget, gpointer user_data);
-
-void gnc_ui_qif_import_loaded_files_prepare (GtkAssistant *assistant, gpointer user_data);
-void gnc_ui_qif_import_load_another_cb (GtkButton *button, gpointer user_data);
-void gnc_ui_qif_import_unload_file_cb (GtkButton *button, gpointer user_data);
-
-static void update_file_page (QIFImportWindow * wind);
-
-void gnc_ui_qif_import_account_match_prepare (GtkAssistant *assistant, gpointer user_data);
-void gnc_ui_qif_import_account_doc_prepare (GtkAssistant *assistant, gpointer user_data);
-void gnc_ui_qif_import_account_rematch_cb (GtkButton *button, gpointer user_data);
-
-void gnc_ui_qif_import_catagory_match_prepare (GtkAssistant *assistant, gpointer user_data);
-void gnc_ui_qif_import_catagory_doc_prepare (GtkAssistant *assistant, gpointer user_data);
-void gnc_ui_qif_import_category_rematch_cb (GtkButton *button, gpointer user_data);
-
-void gnc_ui_qif_import_memo_match_prepare (GtkAssistant *assistant, gpointer user_data);
-void gnc_ui_qif_import_memo_doc_prepare (GtkAssistant *assistant, gpointer user_data);
-void gnc_ui_qif_import_memo_rematch_cb (GtkButton *button, gpointer user_data);
-
-void gnc_ui_qif_import_currency_prepare (GtkAssistant *assistant, gpointer user_data);
-
-void gnc_ui_qif_import_commodity_new_prepare (GtkAssistant *assistant, gpointer user_data);
-void gnc_ui_qif_import_commodity_doc_prepare (GtkAssistant *assistant, gpointer user_data);
-void gnc_ui_qif_import_comm_changed_cb (GtkWidget *widget, gpointer user_data);
-
-void gnc_ui_qif_import_convert_progress_prepare (GtkAssistant *assistant, gpointer user_data);
-void gnc_ui_qif_import_convert_progress_pause_cb (GtkButton * button, gpointer user_data);
-void gnc_ui_qif_import_convert_progress_start_cb(GtkButton * button, gpointer user_data);
-
-void gnc_ui_qif_import_duplicates_match_prepare (GtkAssistant *assistant, gpointer user_data);
-void gnc_ui_qif_import_duplicates_doc_prepare (GtkAssistant *assistant, gpointer user_data);
-
-void gnc_ui_qif_import_end_page_prepare (GtkAssistant *assistant, gpointer user_data);
-
-void gnc_ui_qif_import_summary_page_prepare (GtkAssistant *assistant, gpointer user_data);
-
-
-/****************************************************************
- * update_account_picker_page
- *
- * Generic function to update an account_picker page.  This
- * generalizes the code shared whenever any QIF -> GNC mapper is
- * updating it's LIST STORE.  It asks the Scheme side to guess some account
- * translations and then shows the account name and suggested
- * translation in the Accounts page view (acount picker list).
- ****************************************************************/
-static void
-update_account_picker_page(QIFImportWindow * wind, SCM make_display,
-                           GtkWidget *view, SCM map_info, SCM * display_info)
-{
-
-    SCM  get_qif_name = scm_c_eval_string("qif-map-entry:qif-name");
-    SCM  get_gnc_name = scm_c_eval_string("qif-map-entry:gnc-name");
-    SCM  get_new      = scm_c_eval_string("qif-map-entry:new-acct?");
-    SCM  accts_left;
-    gchar *qif_name = NULL;
-    gchar *gnc_name = NULL;
-    gboolean checked;
-    gint row = 0;
-    gint prev_row;
-    GtkListStore *store;
-    GtkTreeIter iter;
-    GtkTreePath *path;
-    GtkTreeSelection *selection;
-
-    store = GTK_LIST_STORE(gtk_tree_view_get_model(GTK_TREE_VIEW(view)));
-
-    /* now get the list of strings to display in the gtk_list_store widget */
-    accts_left = scm_call_3(make_display,
-                            wind->imported_files,
-                            map_info,
-                            wind->gnc_acct_info);
-
-    scm_gc_unprotect_object(*display_info);
-    *display_info = accts_left;
-    scm_gc_protect_object(*display_info);
-
-    /* clear the list */
-    gtk_list_store_clear(store);
-
-    while (!scm_is_null(accts_left))
-    {
-        qif_name = gnc_scm_call_1_to_string(get_qif_name, SCM_CAR(accts_left));
-        gnc_name = gnc_scm_call_1_to_string(get_gnc_name, SCM_CAR(accts_left));
-        checked  = (scm_call_1(get_new, SCM_CAR(accts_left)) == SCM_BOOL_T);
-
-        gtk_list_store_append(store, &iter);
-        gtk_list_store_set(store, &iter,
-                           ACCOUNT_COL_INDEX,     row++,
-                           ACCOUNT_COL_QIF_NAME,  qif_name,
-                           ACCOUNT_COL_GNC_NAME,  gnc_name,
-                           ACCOUNT_COL_NEW,       checked,
-                           ACCOUNT_COL_ELLIPSIZE, PANGO_ELLIPSIZE_START,
-                           -1);
-        accts_left = SCM_CDR(accts_left);
-        g_free (qif_name);
-        g_free (gnc_name);
-    }
-
-    /* move to the old selected row */
-    prev_row = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(store), PREV_ROW));
-    if (prev_row != -1)
-    {
-        selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(view));
-        path = gtk_tree_path_new_from_indices(prev_row, -1);
-        gtk_tree_selection_select_path(selection, path);
-        gtk_tree_path_free(path);
-    }
-    else
-    {
-        selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(view));
-        path = gtk_tree_path_new_from_indices( 0, -1);
-        gtk_tree_selection_select_path(selection, path);
-        gtk_tree_path_free(path);
-    }
-}
-
-
-/****************************************************************
- * update_account_page
- *
- * update the QIF account -> GNC Account picker
- ****************************************************************/
-static void
-update_account_page(QIFImportWindow * wind)
-{
-
-    SCM  make_account_display = scm_c_eval_string("qif-dialog:make-account-display");
-
-    update_account_picker_page(wind, make_account_display, wind->acct_view,
-                               wind->acct_map_info, &(wind->acct_display_info));
-}
-
-
-/****************************************************************
- * update_category_page
- *
- * update the QIF category -> GNC Account picker
- ****************************************************************/
-static void
-update_category_page(QIFImportWindow * wind)
-{
-    SCM  make_category_display = scm_c_eval_string("qif-dialog:make-category-display");
-
-    update_account_picker_page(wind, make_category_display, wind->cat_view,
-                               wind->cat_map_info, &(wind->cat_display_info));
-}
-
-
-/****************************************************************
- * update_memo_page
- *
- * update the QIF memo -> GNC Account picker
- ****************************************************************/
-static void
-update_memo_page(QIFImportWindow * wind)
-{
-    SCM  make_memo_display = scm_c_eval_string("qif-dialog:make-memo-display");
-
-    update_account_picker_page(wind, make_memo_display, wind->memo_view,
-                               wind->memo_map_info, &(wind->memo_display_info));
-}
-
-
-/****************************************************************
- * gnc_ui_qif_import_commodity_destroy
- *
- * This function destroys any commodity pages.
- ****************************************************************/
-static void
-gnc_ui_qif_import_commodity_destroy(QIFImportWindow * wind)
-{
-    GList              *pageptr;
-    GtkWidget          *gtkpage;
-    QIFAssistantPage   *page;
-
-    for (pageptr = wind->commodity_pages; pageptr; pageptr = pageptr->next)
-    {
-        gtkpage   = pageptr->data;
-        page      = g_object_get_data(G_OBJECT(gtkpage), "page_struct");
-
-        /* Unprotect the Scheme hash key. */
-        scm_gc_unprotect_object(page->hash_key);
-
-        /* Free the memory allocated for the page's struct. */
-        g_free(page);
-    }
-
-    /* Free the list of pages. */
-    g_list_free(wind->commodity_pages);
-    wind->commodity_pages = NULL;
-}
-
-
-/**********************************************
- * gnc_ui_qif_import_assistant_destroy
- * close the QIF Import assistant window
- **********************************************/
-static void
-gnc_ui_qif_import_assistant_destroy(GtkObject *object, gpointer user_data)
-{
-    QIFImportWindow * wind = user_data;
-
-    /* Destroy the progress dialog helpers. */
-    gnc_progress_dialog_destroy(wind->load_progress);
-
-    /* Destroy any commodity pages. */
-    gnc_ui_qif_import_commodity_destroy(wind);
-
-    gnc_unregister_gui_component_by_data(ASSISTANT_QIF_IMPORT_CM_CLASS, wind);
-
-    gtk_widget_destroy(wind->window);
-
-    scm_gc_unprotect_object(wind->imported_files);
-    scm_gc_unprotect_object(wind->selected_file);
-    scm_gc_unprotect_object(wind->gnc_acct_info);
-    scm_gc_unprotect_object(wind->cat_display_info);
-    scm_gc_unprotect_object(wind->cat_map_info);
-    scm_gc_unprotect_object(wind->memo_display_info);
-    scm_gc_unprotect_object(wind->memo_map_info);
-    scm_gc_unprotect_object(wind->acct_display_info);
-    scm_gc_unprotect_object(wind->acct_map_info);
-    scm_gc_unprotect_object(wind->security_hash);
-    scm_gc_unprotect_object(wind->security_prefs);
-    scm_gc_unprotect_object(wind->new_securities);
-    scm_gc_unprotect_object(wind->ticker_map);
-    scm_gc_unprotect_object(wind->imported_account_tree);
-    scm_gc_unprotect_object(wind->match_transactions);
-
-    g_free(wind);
-}
-
-
-/****************************************************************
- * gnc_ui_qif_import_select_loaded_file_cb
- * callback when a file is clicked in the "loaded files" page
- ****************************************************************/
-static void
-gnc_ui_qif_import_select_loaded_file_cb(GtkTreeSelection *selection,
-                                        gpointer          user_data)
-{
-    QIFImportWindow * wind = user_data;
-    GtkTreeModel *model;
-    GtkTreeIter iter;
-    gint row;
-    GtkWidget *button;
-
-    button = (wind->unload_file_btn);
-    if (gtk_tree_selection_get_selected(selection, &model, &iter))
-    {
-        gtk_tree_model_get(model, &iter, FILENAME_COL_INDEX, &row, -1);
-        if (scm_is_list(wind->imported_files) &&
-                (scm_ilength(wind->imported_files) > row))
-        {
-            scm_gc_unprotect_object(wind->selected_file);
-            wind->selected_file = scm_list_ref(wind->imported_files,
-                                               scm_from_int (row));
-            scm_gc_protect_object(wind->selected_file);
-            g_object_set(button, "sensitive", TRUE, (gchar*)NULL);
-        }
-    }
-    else
-    {
-        scm_gc_unprotect_object(wind->selected_file);
-        wind->selected_file = SCM_BOOL_F;
-        scm_gc_protect_object(wind->selected_file);
-        g_object_set(button, "sensitive", FALSE, (gchar*)NULL);
-    }
-}
-
-
-/****************************************************
- * create_account_picker_view
- ****************************************************/
-static void
-create_account_picker_view(GtkWidget *widget,
-                           const gchar *col_name,
-                           GCallback activate_cb,
-                           GCallback select_cb,
-                           gpointer user_data)
-{
-    GtkTreeView *view = GTK_TREE_VIEW(widget);
-    GtkTreeSelection *selection = gtk_tree_view_get_selection(view);
-    GtkListStore *store;
-    GtkCellRenderer *renderer;
-    GtkTreeViewColumn *column;
-
-    store = gtk_list_store_new(NUM_ACCOUNT_COLS, G_TYPE_INT, G_TYPE_STRING,
-                               G_TYPE_STRING, G_TYPE_BOOLEAN,
-                               PANGO_TYPE_ELLIPSIZE_MODE);
-    gtk_tree_view_set_model(view, GTK_TREE_MODEL(store));
-    g_object_unref(store);
-
-    renderer = gtk_cell_renderer_text_new();
-    column = gtk_tree_view_column_new_with_attributes(col_name,
-             renderer,
-             "text",
-             ACCOUNT_COL_QIF_NAME,
-             "ellipsize",
-             ACCOUNT_COL_ELLIPSIZE,
-             NULL);
-    g_object_set(column, "expand", TRUE, NULL);
-    gtk_tree_view_column_set_resizable(column, TRUE);
-    gtk_tree_view_append_column(view, column);
-
-    renderer = gtk_cell_renderer_text_new();
-    column = gtk_tree_view_column_new_with_attributes(_("GnuCash account name"),
-             renderer,
-             "text",
-             ACCOUNT_COL_GNC_NAME,
-             "ellipsize",
-             ACCOUNT_COL_ELLIPSIZE,
-             NULL);
-
-    g_object_set(column, "expand", TRUE, NULL);
-    gtk_tree_view_column_set_resizable(column, TRUE);
-    gtk_tree_view_append_column(view, column);
-
-    renderer = gtk_cell_renderer_toggle_new();
-    g_object_set(renderer, "activatable", FALSE, NULL);
-    column = gtk_tree_view_column_new_with_attributes(_("New?"),
-             renderer,
-             "active",
-             ACCOUNT_COL_NEW,
-             NULL);
-    gtk_tree_view_append_column(view, column);
-
-    g_object_set_data(G_OBJECT(store), PREV_ROW, GINT_TO_POINTER(-1));
-
-    /* Connect the signal handlers. */
-    g_signal_connect(view, "row-activated", G_CALLBACK(activate_cb), user_data);
-    g_signal_connect(selection, "changed", G_CALLBACK(select_cb), user_data);
-
-    /* Allow multiple rows to be selected. */
-    gtk_tree_selection_set_mode(selection, GTK_SELECTION_MULTIPLE);
-}
-
-
-/********************************************************************
- * rematch_line
- *
- * This is a helper function for tree controls used by some assistant
- * pages for mapping QIF values to GnuCash accounts. It processes
- * the selected rows when a user tries to edit the account mappings.
- * The account picker is displayed, and the chosen GnuCash account
- * becomes the new mapping for each row.  Finally, the update_page
- * function is called.
- ********************************************************************/
-static void
-rematch_line(QIFImportWindow *wind, GtkTreeSelection *selection,
-             SCM display_info, SCM map_info,
-             void (*update_page)(QIFImportWindow *))
-{
-    SCM           get_qif_name = scm_c_eval_string("qif-map-entry:qif-name");
-    SCM           get_gnc_name = scm_c_eval_string("qif-map-entry:gnc-name");
-    SCM           set_gnc_name = scm_c_eval_string("qif-map-entry:set-gnc-name!");
-    SCM           map_entry;
-    SCM           gnc_name;
-    GList        *pathlist;
-    GList        *current;
-    GtkTreeModel *model;
-    GtkTreeIter   iter;
-    gint          row;
-
-    /* Get a list of selected rows. */
-    pathlist = gtk_tree_selection_get_selected_rows(selection, &model);
-    if (!pathlist)
-        return;
-
-    /*
-     * Update the first selected row.
-     */
-
-    /* Get the row number of the first selected row. */
-    if (!gtk_tree_model_get_iter(model, &iter, (GtkTreePath *) pathlist->data))
-        return;
-    gtk_tree_model_get(model, &iter, ACCOUNT_COL_INDEX, &row, -1);
-
-    /* Save the row number. */
-    g_object_set_data(G_OBJECT(model), PREV_ROW, GINT_TO_POINTER(row));
-    if (row == -1)
-        return;
-
-    /* Find the <qif-map-entry> corresponding to the selected row. */
-    map_entry = scm_list_ref(display_info, scm_from_int (row));
-
-    /* Call the account picker to update it. */
-    if (!qif_account_picker_dialog(wind, map_entry))
-        return;
-    gnc_name = scm_call_1(get_gnc_name, map_entry);
-
-    /* Update the mapping hash table. */
-    scm_hash_set_x(map_info, scm_call_1(get_qif_name, map_entry), map_entry);
-
-    /*
-     * Map all other selected rows to the same GnuCash account.
-     */
-    for (current = pathlist->next; current; current = current->next)
-    {
-        /* Get the row number. */
-        gtk_tree_model_get_iter(model, &iter, (GtkTreePath *) current->data);
-        gtk_tree_model_get(model, &iter, ACCOUNT_COL_INDEX, &row, -1);
-
-        /* Update the <qif-map-entry> for the selected row. */
-        map_entry = scm_list_ref(display_info, scm_from_int (row));
-        scm_call_2(set_gnc_name, map_entry, gnc_name);
-
-        /* Update the mapping hash table. */
-        scm_hash_set_x(map_info, scm_call_1(get_qif_name, map_entry), map_entry);
-    }
-
-    /* Free the path list. */
-    g_list_foreach(pathlist, (GFunc) gtk_tree_path_free, NULL);
-    g_list_free(pathlist);
-
-    /* Update the display. */
-    update_page(wind);
-}
-
-
-/********************************************************************
- * gnc_ui_qif_import_account_activate_cb
- *
- * This handler is invoked when a row is double-clicked in the "Match
- * QIF accounts to GnuCash accounts" page.
- ********************************************************************/
-static void
-gnc_ui_qif_import_account_activate_cb(GtkTreeView *view, GtkTreePath *path,
-                                      GtkTreeViewColumn *column,
-                                      gpointer user_data)
-{
-    QIFImportWindow  *wind = user_data;
-
-    g_return_if_fail(wind);
-
-    rematch_line(wind, gtk_tree_view_get_selection(view),
-                 wind->acct_display_info, wind->acct_map_info,
-                 update_account_page);
-}
-
-
-/********************************************************************
- * gnc_ui_qif_import_account_select_cb
- *
- * This handler is invoked when the selection of account matchings
- * has changed.  It updates the selection count and enables/disables
- * the "Change" button.
- ********************************************************************/
-static void
-gnc_ui_qif_import_account_select_cb(GtkTreeSelection *selection,
-                                    gpointer user_data)
-{
-    QIFImportWindow  *wind = user_data;
-    gint              count = gtk_tree_selection_count_selected_rows(selection);
-    gchar            *count_str;
-
-    g_return_if_fail(wind);
-
-    /* Update the "items selected" count. */
-    if (wind->acct_view_count)
-    {
-        count_str = g_strdup_printf("%d", count);
-        gtk_label_set_text(GTK_LABEL(wind->acct_view_count), count_str);
-        g_free(count_str);
-    }
-
-    /* Enable/disable the Change button. */
-    if (wind->acct_view_btn)
-    {
-        if (count)
-            gtk_widget_set_sensitive(wind->acct_view_btn, TRUE);
-        else
-            gtk_widget_set_sensitive(wind->acct_view_btn, FALSE);
-    }
-}
-
-
-/********************************************************************
- * gnc_ui_qif_import_category_activate_cb
- *
- * This handler is invoked when a row is double-clicked in the "Match
- * QIF categories to GnuCash accounts" page.
- ********************************************************************/
-static void
-gnc_ui_qif_import_category_activate_cb(GtkTreeView *view, GtkTreePath *path,
-                                       GtkTreeViewColumn *column,
-                                       gpointer user_data)
-{
-    QIFImportWindow *wind = user_data;
-    GtkTreeSelection *selection;
-
-    g_return_if_fail(view && wind);
-    selection = gtk_tree_view_get_selection(view);
-
-    rematch_line(wind, selection, wind->cat_display_info, wind->cat_map_info,
-                 update_category_page);
-}
-
-
-/********************************************************************
- * gnc_ui_qif_import_category_select_cb
- *
- * This handler is invoked when the selection of category matchings
- * has changed.  It updates the selection count and enables/disables
- * the "Change" button.
- ********************************************************************/
-static void
-gnc_ui_qif_import_category_select_cb(GtkTreeSelection *selection,
-                                     gpointer user_data)
-{
-    QIFImportWindow  *wind = user_data;
-    gint              count = gtk_tree_selection_count_selected_rows(selection);
-    gchar            *count_str;
-
-    g_return_if_fail(wind);
-
-    /* Update the "items selected" count. */
-    if (wind->cat_view_count)
-    {
-        count_str = g_strdup_printf("%d", count);
-        gtk_label_set_text(GTK_LABEL(wind->cat_view_count), count_str);
-        g_free(count_str);
-    }
-
-    /* Enable/disable the Change button. */
-    if (wind->cat_view_btn)
-    {
-        if (count)
-            gtk_widget_set_sensitive(wind->cat_view_btn, TRUE);
-        else
-            gtk_widget_set_sensitive(wind->cat_view_btn, FALSE);
-    }
-}
-
-
-/********************************************************************
- *  gnc_ui_qif_import_memo_activate_cb
- *
- * This handler is invoked when a row is double-clicked in the "Match
- * QIF payee/memo to GnuCash accounts" page.
- ********************************************************************/
-static void
-gnc_ui_qif_import_memo_activate_cb(GtkTreeView *view, GtkTreePath *path,
-                                   GtkTreeViewColumn *column,
-                                   gpointer user_data)
-{
-    QIFImportWindow *wind = user_data;
-    GtkTreeSelection *selection;
-
-    g_return_if_fail(view && wind);
-    selection = gtk_tree_view_get_selection(view);
-
-    rematch_line(wind, selection, wind->memo_display_info, wind->memo_map_info,
-                 update_memo_page);
-}
-
-
-/********************************************************************
- * gnc_ui_qif_import_memo_select_cb
- *
- * This handler is invoked when the selection of memo matchings
- * has changed.  It updates the selection count and enables/disables
- * the "Change" button.
- ********************************************************************/
-static void
-gnc_ui_qif_import_memo_select_cb(GtkTreeSelection *selection,
-                                 gpointer user_data)
-{
-    QIFImportWindow  *wind = user_data;
-    gint              count = gtk_tree_selection_count_selected_rows(selection);
-    gchar            *count_str;
-
-    g_return_if_fail(wind);
-
-    /* Update the "items selected" count. */
-    if (wind->memo_view_count)
-    {
-        count_str = g_strdup_printf("%d", count);
-        gtk_label_set_text(GTK_LABEL(wind->memo_view_count), count_str);
-        g_free(count_str);
-    }
-
-    /* Enable/disable the Change button. */
-    if (wind->memo_view_btn)
-    {
-        if (count)
-            gtk_widget_set_sensitive(wind->memo_view_btn, TRUE);
-        else
-            gtk_widget_set_sensitive(wind->memo_view_btn, FALSE);
-    }
-}
-
-
-/*********************************************
- * new_security_page
- *********************************************/
-static QIFAssistantPage *
-new_security_page(SCM security_hash_key, gnc_commodity *comm, QIFImportWindow *wind )
-{
-
-    QIFAssistantPage *retval = g_new0(QIFAssistantPage, 1);
-    GtkListStore *store;
-    GtkWidget    *table;
-    GtkWidget    *label;
-    gchar        *title = NULL;
-    const char   *str;
-    GtkWidget    *page;
-    char         *name_tooltip =
-        _("Enter a name or short description, such as \"Red Hat Stock\".");
-    char         *mnemonic_tooltip =
-        _("Enter the ticker symbol or other well known abbreviation, such as"
-          " \"RHT\". If there isn't one, or you don't know it, create your own.");
-    char         *namespace_tooltip =
-        _("Select the exchange on which the symbol is traded, or select the"
-          " type of investment (such as FUND for mutual funds.) If you don't"
-          " see your exchange or an appropriate investment type, you can"
-          " enter a new one.");
-
-    /* Make the page widget. */
-    page = gtk_vbox_new( FALSE, 0 );
-    retval->page = page;
-    g_object_set_data(G_OBJECT(retval->page), "page_struct", retval);
-    page = retval->page;
-
-    /* Insert the new page */
-    gtk_assistant_insert_page (GTK_ASSISTANT(wind->window), page, 14);
-    gtk_assistant_set_page_type(GTK_ASSISTANT(wind->window), page, GTK_ASSISTANT_PAGE_PROGRESS );
-    gtk_assistant_set_page_complete (GTK_ASSISTANT (wind->window), page, TRUE);
-    gtk_assistant_update_buttons_state (GTK_ASSISTANT (wind->window));
-
-    /* Save the commodity and the hash table key. */
-    retval->commodity = comm;
-    retval->hash_key = security_hash_key;
-    scm_gc_protect_object(retval->hash_key);
-
-    /* Set the page title. */
-    str = gnc_commodity_get_mnemonic(comm);
-    str = str ? str : "";
-    title = _("Enter information about");
-    title =  g_strdup_printf("%s \"%s\"", title, str);
-    gtk_assistant_set_page_title(GTK_ASSISTANT(wind->window), page, title);
-    g_free(title);
-
-    /*
-     * Add all the widgets to the page.
-     */
-    table = gtk_table_new(3, 2, FALSE);
-    gtk_table_set_row_spacings(GTK_TABLE(table), 6);
-    gtk_table_set_col_spacings(GTK_TABLE(table), 12);
-
-    /* Name entry */
-    retval->name_entry = gtk_entry_new();
-    gtk_entry_set_text(GTK_ENTRY(retval->name_entry),
-                       gnc_commodity_get_fullname(comm));
-    label = gtk_label_new_with_mnemonic(_("_Name or description:"));
-    gtk_label_set_mnemonic_widget(GTK_LABEL(label), retval->name_entry);
-    gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5);
-
-    gtk_widget_set_tooltip_text(label, name_tooltip);
-    gtk_widget_set_tooltip_text(retval->name_entry, name_tooltip);
-
-    gtk_table_attach(GTK_TABLE(table), label, 0, 1, 0, 1,
-                     GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0);
-    gtk_table_attach_defaults(GTK_TABLE(table), retval->name_entry,
-                              1, 2, 0, 1);
-
-    g_signal_connect (retval->name_entry, "changed",
-                      G_CALLBACK (gnc_ui_qif_import_comm_changed_cb), wind);
-
-    /* Mnemonic entry */
-    retval->mnemonic_entry = gtk_entry_new();
-    gtk_entry_set_text(GTK_ENTRY(retval->mnemonic_entry),
-                       gnc_commodity_get_mnemonic(comm));
-    label = gtk_label_new_with_mnemonic(
-                _("_Ticker symbol or other abbreviation:"));
-    gtk_label_set_mnemonic_widget(GTK_LABEL(label), retval->mnemonic_entry);
-    gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5);
-
-    gtk_widget_set_tooltip_text(label, mnemonic_tooltip);
-    gtk_widget_set_tooltip_text(retval->mnemonic_entry, mnemonic_tooltip);
-
-    gtk_table_attach(GTK_TABLE(table), label, 0, 1, 1, 2,
-                     GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0);
-    gtk_table_attach_defaults(GTK_TABLE(table), retval->mnemonic_entry,
-                              1, 2, 1, 2);
-
-    g_signal_connect (retval->mnemonic_entry, "changed",
-                      G_CALLBACK (gnc_ui_qif_import_comm_changed_cb), wind);
-
-    /* Namespace entry */
-    store = gtk_list_store_new (1, G_TYPE_STRING);
-    retval->namespace_combo = gtk_combo_box_new_with_model_and_entry(GTK_TREE_MODEL(store));
-    g_object_unref(store);
-
-    /* Set the column for the text */
-    gtk_combo_box_set_entry_text_column (GTK_COMBO_BOX(retval->namespace_combo), 0);
-
-    gnc_cbwe_add_completion(GTK_COMBO_BOX(retval->namespace_combo));
-    label = gtk_label_new_with_mnemonic(
-                _("_Exchange or abbreviation type:"));
-    gtk_label_set_mnemonic_widget(GTK_LABEL(label), retval->namespace_combo);
-    gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5);
-
-    gtk_widget_set_tooltip_text(label, namespace_tooltip);
-    gtk_widget_set_tooltip_text(retval->namespace_combo, namespace_tooltip);
-
-    gtk_table_attach(GTK_TABLE(table), label, 0, 1, 2, 3,
-                     GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0);
-    gtk_table_attach_defaults(GTK_TABLE(table), retval->namespace_combo,
-                              1, 2, 2, 3);
-
-    gtk_container_set_border_width(GTK_CONTAINER(page), 12);
-
-    gtk_box_pack_start(GTK_BOX(page), table, FALSE, FALSE, 12);
-
-    return retval;
-}
-
-
-/********************************************************************
- * prepare_security_pages
- *
- * Prepare the assistant page for each security.
- ********************************************************************/
-static void
-prepare_security_pages(QIFImportWindow * wind)
-{
-    SCM   hash_ref  = scm_c_eval_string("hash-ref");
-    SCM   securities;
-    SCM   comm_ptr_token;
-
-    GList          * current;
-    gnc_commodity  * commodity;
-    QIFAssistantPage   * new_page;
-
-    /*
-     * Make assistant pages for each new QIF security.
-     */
-    gnc_set_busy_cursor(NULL, TRUE);
-    securities = wind->new_securities;
-    current = wind->commodity_pages;
-    while (!scm_is_null(securities) && (securities != SCM_BOOL_F))
-    {
-        if (current)
-        {
-            /* The page has already been made. */
-            current = current->next;
-        }
-        else
-        {
-            /* Get the GnuCash commodity corresponding to the new QIF security. */
-            comm_ptr_token = scm_call_2(hash_ref,
-                                        wind->security_hash,
-                                        SCM_CAR(securities));
-#define FUNC_NAME "new_security_page"
-            commodity = SWIG_MustGetPtr(comm_ptr_token,
-                                        SWIG_TypeQuery("_p_gnc_commodity"), 1, 0);
-#undef FUNC_NAME
-
-            /* Build a new security page. */
-            new_page = new_security_page(SCM_CAR(securities), commodity, wind);
-
-            /* Add it to the list of security pages. */
-            wind->commodity_pages = g_list_append(wind->commodity_pages,
-                                                  new_page->page);
-
-            gtk_widget_show_all(new_page->page);
-        }
-        wind->num_new_pages = wind->num_new_pages + 1;
-        securities = SCM_CDR(securities);
-    }
-    gnc_unset_busy_cursor(NULL);
-    PINFO("Number of New Security pages is %d", wind->num_new_pages);
-}
-
-
-/****************************************************************
- * gnc_ui_qif_import_commodity_update
- *
- * This function updates the commodities based on the values for
- * mnemonic, namespace, and name approved by the user.
- ****************************************************************/
-static void
-gnc_ui_qif_import_commodity_update(QIFImportWindow * wind)
-{
-    GList              *pageptr;
-    GtkWidget          *gtkpage;
-    QIFAssistantPage   *page;
-    const gchar        *mnemonic = NULL;
-    gchar              *namespace = NULL;
-    const gchar        *fullname = NULL;
-    gnc_commodity      *tab_commodity;
-
-    for (pageptr = wind->commodity_pages; pageptr; pageptr = pageptr->next)
-    {
-        gtkpage   = pageptr->data;
-        page      = g_object_get_data(G_OBJECT(gtkpage), "page_struct");
-
-        /* Get any changes from the commodity page. */
-        mnemonic  = gtk_entry_get_text(GTK_ENTRY(page->mnemonic_entry));
-        namespace = gnc_ui_namespace_picker_ns(page->namespace_combo);
-        fullname  = gtk_entry_get_text(GTK_ENTRY(page->name_entry));
-
-        /* Update the commodity with the new values. */
-        gnc_commodity_set_namespace(page->commodity, namespace);
-        gnc_commodity_set_fullname(page->commodity, fullname);
-        gnc_commodity_set_mnemonic(page->commodity, mnemonic);
-
-        /* Add the commodity to the commodity table (if it isn't a duplicate). */
-        tab_commodity = gnc_commodity_table_lookup(gnc_get_current_commodities(),
-                        namespace, mnemonic);
-        if (!tab_commodity || tab_commodity == page->commodity)
-            tab_commodity = gnc_commodity_table_insert(gnc_get_current_commodities(),
-                            page->commodity);
-
-        /* Update the security hash table. */
-        scm_hash_set_x(wind->security_hash,
-                       page->hash_key,
-                       SWIG_NewPointerObj(tab_commodity,
-                                          SWIG_TypeQuery("_p_gnc_commodity"), 0));
-
-        g_free(namespace);
-    }
-}
-
-
-/****************************************************************
- * gnc_ui_qif_import_convert_undo
- *
- * This function launches the Scheme procedure that un-imports
- * any imported accounts and transactions.
- ****************************************************************/
-static void
-gnc_ui_qif_import_convert_undo(QIFImportWindow * wind)
-{
-    SCM undo = scm_c_eval_string("qif-import:qif-to-gnc-undo");
-
-    gnc_set_busy_cursor(NULL, TRUE);
-
-    /* Undo the conversion. */
-    scm_call_1(undo, wind->imported_account_tree);
-
-    /* There's no imported account tree any more. */
-    scm_gc_unprotect_object(wind->imported_account_tree);
-    wind->imported_account_tree = SCM_BOOL_F;
-    scm_gc_protect_object(wind->imported_account_tree);
-
-    /* Get rid of the list of matched transactions. */
-    scm_gc_unprotect_object(wind->match_transactions);
-    wind->match_transactions = SCM_BOOL_F;
-    scm_gc_protect_object(wind->match_transactions);
-
-    gnc_unset_busy_cursor(NULL);
-}
-
-
-/****************************************************************
- * refresh_old_transactions
- *
- * This function launches the Scheme procedure that refreshes
- * the old transactions.
- ****************************************************************/
-static void
-refresh_old_transactions(QIFImportWindow * wind, int selection)
-{
-    SCM          possible_matches;
-    SCM          current_xtn;
-    SCM          selected;
-    Transaction  * gnc_xtn;
-    Split        * gnc_split;
-    const gchar  * amount_str;
-    int          rownum = 0;
-    GtkTreeView *view;
-    GtkListStore *store;
-    GtkTreeIter iter;
-
-    view = GTK_TREE_VIEW(wind->old_transaction_view);
-    store = GTK_LIST_STORE(gtk_tree_view_get_model(view));
-    gtk_list_store_clear(store);
-
-    if (wind->match_transactions != SCM_BOOL_F)
-    {
-        possible_matches = SCM_CDR(scm_list_ref(wind->match_transactions,
-                                                scm_from_int (wind->selected_transaction)));
-        scm_call_2(scm_c_eval_string("qif-import:refresh-match-selection"),
-                   possible_matches, scm_from_int (selection));
-
-        while (!scm_is_null(possible_matches))
-        {
-            current_xtn = SCM_CAR(possible_matches);
-#define FUNC_NAME "xaccTransCountSplits"
-            gnc_xtn     = SWIG_MustGetPtr(SCM_CAR(current_xtn),
-                                          SWIG_TypeQuery("_p_Transaction"), 1, 0);
-#undef FUNC_NAME
-            selected    = SCM_CDR(current_xtn);
-
-            if (xaccTransCountSplits(gnc_xtn) > 2)
-            {
-                amount_str = _("(split)");
-            }
-            else
-            {
-                gnc_split = xaccTransGetSplit(gnc_xtn, 0);
-                amount_str =
-                    xaccPrintAmount(gnc_numeric_abs(xaccSplitGetValue(gnc_split)),
-                                    gnc_account_print_info
-                                    (xaccSplitGetAccount(gnc_split), TRUE));
-            }
-
-            gtk_list_store_append(store, &iter);
-            gtk_list_store_set
-            (store, &iter,
-             QIF_TRANS_COL_INDEX, rownum++,
-             QIF_TRANS_COL_DATE, gnc_print_date(xaccTransRetDatePostedTS(gnc_xtn)),
-             QIF_TRANS_COL_DESCRIPTION, xaccTransGetDescription(gnc_xtn),
-             QIF_TRANS_COL_AMOUNT, amount_str,
-             QIF_TRANS_COL_CHECKED, selected != SCM_BOOL_F,
-             -1);
-
-            possible_matches = SCM_CDR(possible_matches);
-        }
-    }
-}
-
-
-/****************************************************************
- * gnc_ui_qif_import_duplicate_new_select_cb
- *
- * This function is the call back for duplicate transactions.
- ****************************************************************/
-static void
-gnc_ui_qif_import_duplicate_new_select_cb(GtkTreeSelection *selection,
-        QIFImportWindow  *wind)
-{
-    GtkTreeModel *model;
-    GtkTreeIter iter;
-
-    if (gtk_tree_selection_get_selected(selection, &model, &iter))
-        gtk_tree_model_get(model, &iter,
-                           QIF_TRANS_COL_INDEX, &wind->selected_transaction,
-                           -1);
-    refresh_old_transactions(wind, -1);
-}
-
-
-/****************************************************************
- * reset_ignore_old_select
- ****************************************************************/
-static gboolean
-reset_ignore_old_select(gboolean *ignore)
-{
-    *ignore = FALSE;
-    return FALSE;
-}
-
-
-/****************************************************************
- * gnc_ui_qif_import_duplicate_old_select_cb
- *
- * This function is the call back for duplicate transactions.
- ****************************************************************/
-static void
-gnc_ui_qif_import_duplicate_old_select_cb(GtkTreeSelection *selection,
-        QIFImportWindow  *wind)
-{
-    GtkTreeModel *model;
-    GtkTreeIter iter;
-    gint row;
-    static gboolean ignore_old_select = FALSE;
-
-    /* Get the current selection then clear it.  We're about to clear
-     * the entire list store and rebuild it so this prevents errors. */
-    if (!gtk_tree_selection_get_selected(selection, &model, &iter))
-        return;
-    gtk_tree_selection_unselect_all(selection);
-
-    /* Getting a weird double call the first time a line is clicked.
-     * Once via gtk_tree_view_button_press and then again via
-     * gtk_tree_view_grab_focus. */
-    if (ignore_old_select)
-        return;
-    ignore_old_select = TRUE;
-    g_idle_add((GSourceFunc)reset_ignore_old_select, &ignore_old_select);
-
-    /* Get the row the user clicked on and update the scheme
-     * code/rebuild the list store.  */
-    gtk_tree_model_get(model, &iter,
-                       QIF_TRANS_COL_INDEX, &row,
-                       -1);
-    refresh_old_transactions(wind, row);
-}
-
-
-/********************************************************************
- * gnc_ui_qif_import_check_acct_tree
- *
- * Designed for use with gnc_main_window_foreach_page(), this
- * function determines whether an account tab is open in the main
- * window. The parameter user_data must point to a gboolean.
- ********************************************************************/
-static void
-gnc_ui_qif_import_check_acct_tree(GncPluginPage *page, gpointer user_data)
-{
-    gboolean *found = user_data;
-
-    if (GNC_IS_PLUGIN_PAGE_ACCOUNT_TREE(page) && found)
-        *found = TRUE;
-}
-
-
-/****************************************************************
- * do_cancel
- *
- * Clears out any imported data and shuts down the importer.
- ****************************************************************/
-static void
-do_cancel(QIFImportWindow * wind)
-{
-    GList                *pageptr;
-    GtkWidget            *gtkpage;
-    QIFAssistantPage     *page;
-    gnc_commodity_table  *table;
-
-    gnc_set_busy_cursor(NULL, TRUE);
-
-    /* Remove any converted data. */
-    gnc_ui_qif_import_convert_undo(wind);
-
-    /* Remove any commodities created for assistant pages. */
-    for (pageptr = wind->commodity_pages; pageptr; pageptr = pageptr->next)
-    {
-        gtkpage   = pageptr->data;
-        page      = g_object_get_data(G_OBJECT(gtkpage), "page_struct");
-        gnc_commodity_destroy(page->commodity);
-    }
-
-    /* Remove any namespaces created by the user. */
-    table = gnc_get_current_commodities();
-    while (wind->new_namespaces)
-    {
-        gnc_commodity_table_delete_namespace(table, (gchar *) wind->new_namespaces->data);
-
-        /* Free the data and the list element. */
-        g_free(wind->new_namespaces->data);
-        wind->new_namespaces = g_list_delete_link(wind->new_namespaces,
-                               wind->new_namespaces);
-    }
-    gnc_unset_busy_cursor(NULL);
-
-    /* Destroy the assistant. */
-    gnc_close_gui_component_by_data(ASSISTANT_QIF_IMPORT_CM_CLASS, wind);
-}
-
-
-/****************************************************************
- * cancel_timeout_cb
- *
- * This timer callback function waits until the busy flag
- * has been cleared before acting to cancel the import.
- ****************************************************************/
-static gboolean
-cancel_timeout_cb(gpointer data)
-{
-    QIFImportWindow *wind = data;
-
-    if (wind->busy)
-        /* Wait for timer to go off again. */
-        return TRUE;
-
-    /* The busy flag was lowered. Perform the cancel. */
-    do_cancel(wind);
-
-    /* Cancel the timer. */
-    return FALSE;
-}
-
-
-/****************************************************************
- * gnc_ui_qif_import_cancel_cb
- *
- * Invoked when the "Cancel" button is clicked.
- ****************************************************************/
-void
-gnc_ui_qif_import_cancel_cb(GtkAssistant *gtkassistant, gpointer user_data)
-{
-    QIFImportWindow  *wind = user_data;
-
-    if (wind->busy)
-    {
-        /* Cancel any long-running Scheme operation. */
-        scm_c_eval_string("(qif-import:cancel)");
-
-        /* Wait for the busy flag to be lowered. */
-        g_timeout_add(200, cancel_timeout_cb, user_data);
-    }
-    else
-        do_cancel(wind);
-}
-
-
-/****************************************************************
- * gnc_ui_qif_import_close_cb
- *
- * Invoked when the "Close" button is clicked.
- ****************************************************************/
-void
-gnc_ui_qif_import_close_cb(GtkAssistant *gtkassistant, gpointer user_data)
-{
-    QIFImportWindow  *wind = user_data;
-
-    /* If We did not have an account tree, lets save it */
-    if (!wind->acct_tree_found)
-    {
-        qof_book_mark_session_dirty(gnc_get_current_book());
-        gnc_ui_file_access_for_save_as();
-    }
-
-    gnc_close_gui_component_by_data( ASSISTANT_QIF_IMPORT_CM_CLASS, wind );
-}
-
-
-/****************************************************************
- * gnc_ui_qif_import_assistant_get_mappings
- *
- * SCM get mappings.
- ****************************************************************/
-SCM
-gnc_ui_qif_import_assistant_get_mappings(QIFImportWindow * w)
-{
-    return SCM_LIST3(w->acct_map_info,
-                     w->cat_map_info,
-                     w->memo_map_info);
-}
-
-
-/* ================================================================== */
-/*                                                                    */
-/*                         IMPORTER CREATION                          */
-/*                                                                    */
-/* ================================================================== */
-
-/********************************************************************
- * get_preferences
- *
- * Get all user preferences related to QIF import.
- ********************************************************************/
-static void
-get_preferences(QIFImportWindow *wind)
-{
-    gchar tmp_transaction_status = 'n';
-
-    g_return_if_fail(wind);
-
-    /* Get the user's preference for showing documentation pages. */
-    wind->show_doc_pages =
-        gnc_prefs_get_bool (GNC_PREFS_GROUP, GNC_PREF_SHOW_DOC);
-
-    /* Clear / Reconcile transaction if not specified in QIF file. */
-    if (gnc_prefs_get_bool (GNC_PREFS_GROUP, GNC_PREF_DEFAULT_TRANS_STATUS_CLEARED))
-        tmp_transaction_status = 'c';
-    else if (gnc_prefs_get_bool (GNC_PREFS_GROUP, GNC_PREF_DEFAULT_TRANS_STATUS_RECONCILED))
-        tmp_transaction_status = 'y';
-
-    wind->transaction_status = SCM_MAKE_CHAR(tmp_transaction_status);
-}
-
-
-/********************************************************************
- * initialize_scheme
- *
- * Initialize all Scheme-controlled objects.
- ********************************************************************/
-static void
-initialize_scheme(QIFImportWindow *wind)
-{
-    SCM  load_map_prefs;
-    SCM  mapping_info;
-    SCM  create_ticker_map;
-
-    g_return_if_fail(wind);
-
-    /* Initialize Scheme variables. */
-    wind->imported_files        = SCM_EOL;
-    wind->selected_file         = SCM_BOOL_F;
-    wind->gnc_acct_info         = SCM_BOOL_F;
-    wind->cat_display_info      = SCM_BOOL_F;
-    wind->cat_map_info          = SCM_BOOL_F;
-    wind->acct_display_info     = SCM_BOOL_F;
-    wind->acct_map_info         = SCM_BOOL_F;
-    wind->memo_display_info     = SCM_BOOL_F;
-    wind->memo_map_info         = SCM_BOOL_F;
-    wind->security_hash         = SCM_BOOL_F;
-    wind->security_prefs        = SCM_BOOL_F;
-    wind->new_securities        = SCM_BOOL_F;
-    wind->ticker_map            = SCM_BOOL_F;
-    wind->imported_account_tree = SCM_BOOL_F;
-    wind->match_transactions    = SCM_BOOL_F;
-
-    /* Get the saved state of mappings from Quicken accounts and
-     * categories to GnuCash accounts. */
-    load_map_prefs = scm_c_eval_string("qif-import:load-map-prefs");
-    mapping_info = scm_call_0(load_map_prefs); /* <- gets/creates session/book */
-    wind->gnc_acct_info         = scm_list_ref(mapping_info, scm_from_int (0));
-    wind->acct_map_info         = scm_list_ref(mapping_info, scm_from_int (1));
-    wind->cat_map_info          = scm_list_ref(mapping_info, scm_from_int (2));
-    wind->memo_map_info         = scm_list_ref(mapping_info, scm_from_int (3));
-    wind->security_hash         = scm_list_ref(mapping_info, scm_from_int (4));
-    wind->security_prefs        = scm_list_ref(mapping_info, scm_from_int (5));
-
-    /* Get the initial ticker map. */
-    create_ticker_map = scm_c_eval_string("make-ticker-map");
-    wind->ticker_map            = scm_call_0(create_ticker_map);
-
-    /* Protect our data from garbage collection. */
-    scm_gc_protect_object(wind->imported_files);
-    scm_gc_protect_object(wind->selected_file);
-    scm_gc_protect_object(wind->gnc_acct_info);
-    scm_gc_protect_object(wind->cat_display_info);
-    scm_gc_protect_object(wind->cat_map_info);
-    scm_gc_protect_object(wind->memo_display_info);
-    scm_gc_protect_object(wind->memo_map_info);
-    scm_gc_protect_object(wind->acct_display_info);
-    scm_gc_protect_object(wind->acct_map_info);
-    scm_gc_protect_object(wind->security_hash);
-    scm_gc_protect_object(wind->security_prefs);
-    scm_gc_protect_object(wind->new_securities);
-    scm_gc_protect_object(wind->ticker_map);
-    scm_gc_protect_object(wind->imported_account_tree);
-    scm_gc_protect_object(wind->match_transactions);
-}
-
-
-/*****************************************
- * Page 0 - Intro Page Page
- ****************************************/
-
-/********************************************************************
- * gnc_ui_qif_import_intro_prepare
- *
- * Prepare the intro page for display.
- ********************************************************************/
-void
-gnc_ui_qif_import_intro_prepare (GtkAssistant  *assistant, gpointer user_data)
-{
-    QIFImportWindow   *wind = user_data;
-    SCM unload = scm_c_eval_string("qif-dialog:unload-qif-file");
-    SCM files_list;
-
-    /* Set load stop to FALSE */
-    wind->load_stop = FALSE;
-
-    files_list = scm_call_2(unload, wind->selected_file, wind->imported_files);
-
-    scm_gc_unprotect_object(wind->imported_files);
-    wind->imported_files = files_list;
-    scm_gc_protect_object(wind->imported_files);
-
-    scm_gc_unprotect_object(wind->selected_file);
-    wind->selected_file = SCM_BOOL_F;
-    scm_gc_protect_object(wind->selected_file);
-}
-
-
-/*****************************************
- * Page 1 - Load File Page Procedures
- ****************************************/
-
-/********************************************************************
- * gnc_ui_qif_import_load_file_complete
- *
- * Do we have a file to load.
- ********************************************************************/
-static gboolean
-gnc_ui_qif_import_load_file_complete (GtkAssistant  *assistant,
-                                      gpointer user_data)
-{
-    QIFImportWindow * wind = user_data;
-    const gchar * path_to_load;
-
-    /* Get the file name. */
-    path_to_load = gtk_entry_get_text(GTK_ENTRY(wind->filename_entry));
-
-    /* Validate the chosen filename. */
-    if (strlen(path_to_load) == 0)
-        gnc_error_dialog(wind->window, "%s", _("Please select a file to load."));
-    else if (g_access(path_to_load, R_OK) < 0)
-        gnc_error_dialog(wind->window, "%s",
-                         _("File not found or read permission denied. "
-                           "Please select another file."));
-    else
-    {
-        SCM qif_file_loaded = scm_c_eval_string("qif-dialog:qif-file-loaded?");
-
-        /* See if the file is already loaded. */
-        if (scm_call_2(qif_file_loaded,
-                       scm_from_locale_string(path_to_load ? path_to_load : ""),
-                       wind->imported_files) == SCM_BOOL_T)
-            gnc_error_dialog(wind->window, "%s",
-                             _("That QIF file is already loaded. "
-                               "Please select another file."));
-        else
-        {
-            /* Passed all checks; proceed to the next page. */
-            return TRUE;
-        }
-    }
-
-    /* Stay on this page. */
-    return FALSE;
-}
-
-
-/********************************************************************
- * gnc_ui_qif_import_load_file_prepare
- *
- * Prepare the load file page for display.
- ********************************************************************/
-void
-gnc_ui_qif_import_load_file_prepare (GtkAssistant  *assistant, gpointer user_data)
-{
-
-    gint num = gtk_assistant_get_current_page (assistant);
-    GtkWidget *page = gtk_assistant_get_nth_page (assistant, num);
-
-    /* Disable the Assistant Forward Button */
-    gtk_assistant_set_page_complete (assistant, page, FALSE);
-}
-
-
-/********************************************************************
- * gnc_ui_qif_import_select_file_cb
- *
- * invoked when the "select file" button is clicked
- * this is just to pick a file name and reset-to-defaults all the
- * fields describing how to parse the file.
- ********************************************************************/
-void
-gnc_ui_qif_import_select_file_cb(GtkButton * button,
-                                 gpointer user_data)
-{
-    QIFImportWindow * wind = user_data;
-
-    GtkAssistant *assistant = GTK_ASSISTANT(wind->window);
-    gint num = gtk_assistant_get_current_page (assistant);
-    GtkWidget *page = gtk_assistant_get_nth_page (assistant, num);
-
-    GtkFileFilter *filter;
-    char * new_file_name;
-    char *file_name, *default_dir;
-
-    /* Default to whatever's already present */
-    default_dir = gnc_get_default_directory(GNC_PREFS_GROUP);
-
-    filter = gtk_file_filter_new();
-    gtk_file_filter_set_name(filter, "*.qif");
-    gtk_file_filter_add_pattern(filter, "*.[Qq][Ii][Ff]");
-    new_file_name = gnc_file_dialog(_("Select QIF File"),
-                                    g_list_prepend (NULL, filter),
-                                    default_dir,
-                                    GNC_FILE_DIALOG_IMPORT);
-
-    /* Insure valid data, and something that can be freed. */
-    if (new_file_name == NULL)
-    {
-        file_name = g_strdup(default_dir);
-    }
-    else if (!g_path_is_absolute(new_file_name))
-    {
-        file_name = g_build_filename(default_dir, new_file_name, NULL);
-        g_free(new_file_name);
-    }
-    else
-    {
-        file_name = new_file_name;
-        /* Update the working directory */
-        g_free(default_dir);
-        default_dir = g_path_get_dirname(file_name);
-        gnc_set_default_directory(GNC_PREFS_GROUP, default_dir);
-    }
-    g_free(default_dir);
-
-    /* set the filename entry for what was selected */
-    gtk_entry_set_text(GTK_ENTRY(wind->filename_entry), file_name);
-    g_free(file_name);
-
-    gtk_assistant_set_page_complete (assistant, page,
-                                     gnc_ui_qif_import_load_file_complete (assistant, user_data));
-}
-
-
-/*****************************************
- * Page 2 - Load Progress Page Procedures
- ****************************************/
-
-/********************************************************************
- * gnc_ui_qif_import_load_progress_pause_cb
- *
- * Invoked when the "Pause" button is clicked.
- ********************************************************************/
-void
-gnc_ui_qif_import_load_progress_pause_cb(GtkButton * button,
-        gpointer user_data)
-{
-    QIFImportWindow *wind = user_data;
-    SCM toggle_pause      = scm_c_eval_string("qif-import:toggle-pause");
-    SCM progress;
-
-    if (!wind->busy)
-        return;
-
-    /* Create SCM for the progress helper. */
-    progress = SWIG_NewPointerObj(wind->load_progress,
-                                  SWIG_TypeQuery("_p__GNCProgressDialog"),
-                                  0);
-
-    /* Pause (or resume) the currently running operation. */
-    scm_call_1(toggle_pause, progress);
-
-    /* Swap the button label between pause and resume. */
-    if (strcmp(gtk_button_get_label(button), _("_Resume")))
-    {
-        gtk_button_set_use_stock(button, FALSE);
-        gtk_button_set_use_underline(button, TRUE);
-        gtk_button_set_label(button, _("_Resume"));
-    }
-    else
-    {
-        gtk_button_set_use_stock(button, TRUE);
-        gtk_button_set_use_underline(button, FALSE);
-        gtk_button_set_label(button, "gtk-media-pause");
-    }
-}
-
-
-/********************************************************************
- * gnc_ui_qif_import_load_progress_start_cb
- *
- * Invoked when the "Start" button is clicked.
- ********************************************************************/
-void
-gnc_ui_qif_import_load_progress_start_cb(GtkButton * button,
-        gpointer user_data)
-{
-    QIFImportWindow   *wind = user_data;
-    gint num = gtk_assistant_get_current_page (GTK_ASSISTANT(wind->window));
-    GtkWidget *page = gtk_assistant_get_nth_page (GTK_ASSISTANT(wind->window), num);
-
-    const gchar * path_to_load;
-
-    SCM make_qif_file   = scm_c_eval_string("make-qif-file");
-    SCM qif_file_load   = scm_c_eval_string("qif-file:read-file");
-    SCM qif_file_parse  = scm_c_eval_string("qif-file:parse-fields");
-    SCM unload_qif_file = scm_c_eval_string("qif-dialog:unload-qif-file");
-    SCM parse_results   = scm_c_eval_string("qif-file:parse-fields-results");
-    SCM scm_qiffile;
-    SCM imported_files = SCM_EOL;
-    SCM load_return, parse_return;
-    SCM progress;
-
-    /* Raise the busy flag so the assistant can't be canceled unexpectedly. */
-    wind->busy = TRUE;
-    gtk_widget_set_sensitive(wind->load_pause, TRUE);
-
-    /* Get the file name. */
-    path_to_load = gtk_entry_get_text(GTK_ENTRY(wind->filename_entry));
-
-    /* Create the <qif-file> object. */
-    scm_qiffile          = scm_call_0(make_qif_file);
-    scm_gc_unprotect_object(wind->selected_file);
-    wind->selected_file  = scm_qiffile;
-    scm_gc_protect_object(wind->selected_file);
-    imported_files       = scm_cons(scm_qiffile, wind->imported_files);
-
-    /* Create SCM for the progress helper. */
-    progress = SWIG_NewPointerObj(wind->load_progress,
-                                  SWIG_TypeQuery("_p__GNCProgressDialog"),
-                                  0);
-
-    /* Clear any previous pause or cancel state. */
-    scm_c_eval_string("(qif-import:reset-cancel-pause)");
-
-    /*
-     * Load the file.
-     *
-     * The loader returns:
-     *  success:   ()
-     *  failure:   (#f error-message)
-     *  warning:   (#t error-message)
-     *  cancel:    #t
-     *  exception: #f
-     */
-
-    /* This step will fill 70% of the bar. */
-    gnc_progress_dialog_push(wind->load_progress, 0.7);
-    load_return = scm_call_4(qif_file_load,
-                             SCM_CAR(imported_files),
-                             scm_from_locale_string(path_to_load ? path_to_load : ""),
-                             wind->ticker_map,
-                             progress);
-    gnc_progress_dialog_pop(wind->load_progress);
-    if (load_return == SCM_BOOL_T)
-    {
-        /* Canceled by the user. */
-
-        /* Disable the pause button. */
-        gtk_widget_set_sensitive(wind->load_pause, FALSE);
-
-        /* Inform the user. */
-        gnc_progress_dialog_set_sub(wind->load_progress, _("Canceled"));
-
-        wind->busy = FALSE;
-        wind->load_stop = TRUE;
-    }
-    else if (load_return == SCM_BOOL_F || !scm_is_list(load_return))
-    {
-        /* A bug was detected. */
-
-        /* Disable the pause button. */
-        gtk_widget_set_sensitive(wind->load_pause, FALSE);
-
-        /* Inform the user. */
-        gnc_progress_dialog_append_log(wind->load_progress,
-                                       _( "An error occurred while loading the QIF file."));
-        gnc_progress_dialog_set_sub(wind->load_progress, _("Failed"));
-        gnc_progress_dialog_reset_value(wind->load_progress);
-        gnc_error_dialog(wind->window, "%s",
-                         _( "An error occurred while loading the QIF file."));
-        /* FIXME: How should we request that the user report this problem? */
-
-        wind->busy = FALSE;
-        wind->load_stop = TRUE;
-    }
-    else if (!scm_is_null(load_return))
-    {
-        if (SCM_CAR(load_return) == SCM_BOOL_F)
-        {
-            imported_files = scm_call_2(unload_qif_file, scm_qiffile, imported_files);
-            scm_gc_unprotect_object(wind->imported_files);
-            wind->imported_files = imported_files;
-            scm_gc_protect_object(wind->imported_files);
-
-            gnc_progress_dialog_set_sub(wind->load_progress, _("Failed"));
-            gnc_progress_dialog_reset_value(wind->load_progress);
-
-            gtk_widget_set_sensitive(wind->load_pause, FALSE);
-            wind->busy = FALSE;
-            wind->load_stop = TRUE;
-        }
-    }
-
-    /*
-     * Parse the fields.
-     *
-     * The parser returns:
-     *   success:   ()
-     *   failure:   (#f . ((type . error) ...))
-     *   warning:   (#t . ((type . error) ...))
-     *   cancel:    #t
-     *   exception: #f
-     */
-
-    /* This step will fill the remainder of the bar. */
-    gnc_progress_dialog_push(wind->load_progress, 1);
-    parse_return = scm_call_2(qif_file_parse, SCM_CAR(imported_files), progress);
-    gnc_progress_dialog_pop(wind->load_progress);
-    wind->ask_date_format = FALSE;
-    if (parse_return == SCM_BOOL_T)
-    {
-        /* Canceled by the user. */
-
-        /* Disable the pause button. */
-        gtk_widget_set_sensitive(wind->load_pause, FALSE);
-
-        /* Unload the file. */
-        gnc_progress_dialog_set_sub(wind->load_progress, _("Cleaning up"));
-        imported_files = scm_call_2(unload_qif_file, scm_qiffile, imported_files);
-
-        /* Inform the user. */
-        gnc_progress_dialog_set_sub(wind->load_progress, _("Canceled"));
-
-        wind->busy = FALSE;
-        wind->load_stop = TRUE;
-    }
-    else if (parse_return == SCM_BOOL_F || !scm_is_list(parse_return))
-    {
-        /* A bug was detected. */
-
-        /* Disable the pause button. */
-        gtk_widget_set_sensitive(wind->load_pause, FALSE);
-
-        /* Unload the file. */
-        gnc_progress_dialog_set_sub(wind->load_progress, _("Cleaning up"));
-        imported_files = scm_call_2(unload_qif_file, scm_qiffile, imported_files);
-
-        /* Inform the user. */
-        gnc_progress_dialog_append_log(wind->load_progress,
-                                       _( "A bug was detected while parsing the QIF file."));
-        gnc_progress_dialog_set_sub(wind->load_progress, _("Failed"));
-        gnc_progress_dialog_reset_value(wind->load_progress);
-        gnc_error_dialog(wind->window, "%s",
-                         _( "A bug was detected while parsing the QIF file."));
-        /* FIXME: How should we request that the user report this problem? */
-
-        wind->busy = FALSE;
-        wind->load_stop = TRUE;
-    }
-    else if (!scm_is_null(parse_return))
-    {
-        /* Are there only warnings? */
-        if (SCM_CAR(parse_return) == SCM_BOOL_T)
-        {
-            SCM date_formats;
-
-            /* A warning means that (potentially) the date format is
-             * ambiguous.  So search the results for the "date" type and if
-             * it's found, set up the format selector page. */
-            if ((date_formats = scm_call_2(parse_results,
-                                           SCM_CDR(parse_return),
-                                           scm_from_locale_symbol ("date"))) != SCM_BOOL_F)
-            {
-                GtkComboBox *combo_box;
-                GtkTreeModel *model;
-                GtkTreeIter iter;
-
-                /* Block the date call back */
-                g_signal_handlers_block_by_func( wind->date_format_combo, gnc_ui_qif_import_date_valid_cb, wind );
-
-                /* Clear the date format combo box. */
-                combo_box = GTK_COMBO_BOX(wind->date_format_combo);
-                model = gtk_combo_box_get_model(combo_box);
-                gtk_list_store_clear(GTK_LIST_STORE(model));
-
-                gtk_combo_box_set_active(GTK_COMBO_BOX(wind->date_format_combo), -1);
-
-                /* Add the formats for the user to select from. */
-                while (scm_is_list(date_formats) && !scm_is_null(date_formats))
-                {
-                    gtk_list_store_append(GTK_LIST_STORE(model), &iter);
-                    gtk_list_store_set (GTK_LIST_STORE(model), &iter, 0, gnc_scm_symbol_to_locale_string(SCM_CAR(date_formats)), -1);
-
-                    date_formats = SCM_CDR(date_formats);
-                }
-
-                /* Unblock the date call back */
-                g_signal_handlers_unblock_by_func( wind->date_format_combo, gnc_ui_qif_import_date_valid_cb, wind );
-
-                wind->ask_date_format = TRUE;
-            }
-        }
-        else
-        {
-            /* Parsing failed. */
-            imported_files = scm_call_2(unload_qif_file, scm_qiffile, imported_files);
-            gnc_progress_dialog_set_sub(wind->load_progress, _("Failed"));
-            gnc_progress_dialog_reset_value(wind->load_progress);
-
-            gtk_widget_set_sensitive(wind->load_pause, FALSE);
-            wind->busy = FALSE;
-            wind->load_stop = TRUE;
-        }
-    }
-
-    /* Enable the assistant Forward button */
-    gtk_assistant_set_page_complete (GTK_ASSISTANT(wind->window), page, TRUE);
-
-    /* Set Pause and Start buttons */
-    gtk_widget_set_sensitive(wind->load_pause, FALSE);
-    gtk_widget_set_sensitive(wind->load_start, FALSE);
-
-    if (wind->load_stop == FALSE)
-    {
-        /* The file was loaded successfully. */
-        gnc_progress_dialog_set_sub(wind->load_progress, _("Loading completed"));
-        gnc_progress_dialog_set_value(wind->load_progress, 1);
-
-        scm_gc_unprotect_object(wind->imported_files);
-        wind->imported_files = imported_files;
-        scm_gc_protect_object(wind->imported_files);
-
-        gtk_widget_set_sensitive(wind->load_pause, FALSE);
-        wind->busy = FALSE;
-
-        /* Auto step to next page */
-        gtk_assistant_set_current_page (GTK_ASSISTANT(wind->window), num + 1);
-    }
-}
-
-
-/********************************************************************
- * gnc_ui_qif_import_load_progress_prepare
- *
- * Prepare the file loading progress page for display.
- ********************************************************************/
-void
-gnc_ui_qif_import_load_progress_prepare (GtkAssistant  *assistant, gpointer user_data)
-{
-    QIFImportWindow   *wind = user_data;
-    gint num = gtk_assistant_get_current_page (assistant);
-    GtkWidget *page = gtk_assistant_get_nth_page (assistant, num);
-
-    /* Reset the progress display. */
-    gnc_progress_dialog_set_primary(wind->load_progress, "");
-    gnc_progress_dialog_set_secondary(wind->load_progress,
-                                      _("When you press the Start Button, GnuCash will load your QIF file. If there are no errors or warnings, you will automatically proceed to the next step. Otherwise, the details will be shown below for your review."));
-    gnc_progress_dialog_set_sub(wind->load_progress, " ");
-    gnc_progress_dialog_reset_value(wind->load_progress);
-    gnc_progress_dialog_reset_log(wind->load_progress);
-
-    /* Set Pause and Start buttons */
-    gtk_widget_set_sensitive(wind->load_pause, FALSE);
-    gtk_widget_set_sensitive(wind->load_start, TRUE);
-
-    /* Disable the assistant Forward button */
-    gtk_assistant_set_page_complete (assistant, page, FALSE);
-}
-
-
-/*****************************************
- * Page 3 - Date format Page Procedures
- ****************************************/
-
-/********************************************************************
- * gnc_ui_qif_import_date_format_prepare
- *
- * Determine if we need the date page and what is next page.
- ********************************************************************/
-void
-gnc_ui_qif_import_date_format_prepare (GtkAssistant  *assistant, gpointer user_data)
-
-{
-    QIFImportWindow *wind = user_data;
-    gint num = gtk_assistant_get_current_page (assistant);
-
-    if (wind->ask_date_format)
-    {
-        /* We need to get a date format, so stay here. */
-    }
-    else
-    {
-        /* Skip ahead to the Account page. */
-        gtk_assistant_set_current_page (assistant, num + 1);
-    }
-}
-
-
-/********************************************************************
- * gnc_ui_qif_import_date_valid_cb
- *
- * Reparse file with new date format.
- ********************************************************************/
-void
-gnc_ui_qif_import_date_valid_cb (GtkWidget *widget, gpointer user_data)
-{
-    QIFImportWindow * wind = user_data;
-    GtkTreeModel *model;
-    GtkTreeIter iter;
-
-    GtkAssistant *assistant = GTK_ASSISTANT(wind->window);
-    gint num = gtk_assistant_get_current_page (assistant);
-    GtkWidget *page = gtk_assistant_get_nth_page (assistant, num);
-
-    SCM  reparse_dates   = scm_c_eval_string("qif-file:reparse-dates");
-    SCM  format_sym;
-    gchar *text;
-
-    /* Get the selected date format. */
-    model = gtk_combo_box_get_model(GTK_COMBO_BOX(wind->date_format_combo));
-    gtk_combo_box_get_active_iter (GTK_COMBO_BOX(wind->date_format_combo), &iter);
-    gtk_tree_model_get( model, &iter, 0, &text, -1 );
-
-    if (!text)
-    {
-        g_critical("QIF import: BUG DETECTED in gnc_ui_qif_import_date_valid_cb. Format is NULL.");
-    }
-    format_sym = scm_from_locale_symbol (text);
-    g_free(text);
-
-    /* Reparse the dates using the selected format. */
-    scm_call_2(reparse_dates, wind->selected_file, format_sym);
-
-    gtk_assistant_set_page_complete (assistant, page, TRUE);
-}
-
-
-/******************************************
- * Page 4 - Account Setup Page Procedures
- ******************************************/
-
-/********************************************************************
- * gnc_ui_qif_import_account_prepare
- *
- * Do we need to specify an account.
- ********************************************************************/
-void
-gnc_ui_qif_import_account_prepare (GtkAssistant  *assistant, gpointer user_data)
-{
-    QIFImportWindow * wind = user_data;
-    gint num = gtk_assistant_get_current_page (assistant);
-
-    SCM  check_from_acct = scm_c_eval_string("qif-file:check-from-acct");
-
-    /* Determine the next page to display. */
-    if (scm_call_1(check_from_acct, wind->selected_file) != SCM_BOOL_T)
-    {
-        /* There is an account name missing. Ask the user to provide one. */
-        SCM default_acct = scm_c_eval_string("qif-file:path-to-accountname");
-        gchar * default_acctname = NULL;
-
-        default_acctname = gnc_scm_call_1_to_string(default_acct, wind->selected_file);
-        gtk_entry_set_text(GTK_ENTRY(wind->acct_entry), default_acctname);
-        g_free (default_acctname);
-    }
-    else
-    {
-        /* Skip ahead to the "loaded files" page. */
-        gtk_assistant_set_current_page (assistant, num + 1);
-    }
-}
-
-
-/********************************************************************
- * gnc_ui_qif_import_acct_valid_cb
- *
- * Invoked when the "next" button is clicked on the default acct page.
- ********************************************************************/
-void
-gnc_ui_qif_import_acct_valid_cb(GtkWidget * widget,
-                                gpointer user_data)
-{
-    QIFImportWindow * wind = user_data;
-
-    GtkAssistant *assistant = GTK_ASSISTANT(wind->window);
-    gint num = gtk_assistant_get_current_page (assistant);
-    GtkWidget *page = gtk_assistant_get_nth_page (assistant, num);
-
-    const gchar * acct_name = gtk_entry_get_text(GTK_ENTRY(wind->acct_entry));
-
-    if (!acct_name || acct_name[0] == 0)
-    {
-        /* Disable the assistant Forward Button */
-        gtk_assistant_set_page_complete (assistant, page, FALSE);
-    }
-    else
-    {
-        /* Enable the assistant Forward Button */
-        gtk_assistant_set_page_complete (assistant, page, TRUE);
-    }
-}
-
-
-/*****************************************
- * Page 5 - Loaded Files Page Procedures
- ****************************************/
-
-/********************************************************************
- * gnc_ui_qif_import_loaded_files_prepare
- *
- * Get the loaded files page ready for viewing
- ********************************************************************/
-void
-gnc_ui_qif_import_loaded_files_prepare (GtkAssistant *assistant,
-                                        gpointer user_data)
-{
-    QIFImportWindow * wind = user_data;
-
-    gint num = gtk_assistant_get_current_page (assistant);
-    GtkWidget *page = gtk_assistant_get_nth_page (assistant, num);
-
-    const gchar * acct_name = gtk_entry_get_text(GTK_ENTRY(wind->acct_entry));
-    SCM    fix_default = scm_c_eval_string("qif-import:fix-from-acct");
-    SCM    scm_name;
-
-    scm_name = scm_from_utf8_string(acct_name ? acct_name : "");
-    scm_call_2(fix_default, wind->selected_file, scm_name);
-
-    /* Enable the assistant Forward Button */
-    gtk_assistant_set_page_complete (assistant, page, TRUE);
-
-    update_file_page(wind);
-}
-
-
-/********************************************************************
- * gnc_ui_qif_import_load_another_cb
- * Invoked when the "load another" button is clicked on the loaded
- * files page.
- ********************************************************************/
-void
-gnc_ui_qif_import_load_another_cb(GtkButton * button,
-                                  gpointer user_data)
-{
-    QIFImportWindow * wind = user_data;
-    GtkAssistant *assistant = GTK_ASSISTANT(wind->window);
-
-    gtk_assistant_set_current_page (assistant, 1);
-}
-
-
-/********************************************************************
- * gnc_ui_qif_import_unload_cb
- * Invoked when the "unload" button is clicked on the loaded files
- * page.
- ********************************************************************/
-void
-gnc_ui_qif_import_unload_file_cb(GtkButton * button,
-                                 gpointer user_data)
-{
-    QIFImportWindow * wind = user_data;
-
-    SCM unload_qif_file = scm_c_eval_string("qif-dialog:unload-qif-file");
-    SCM imported_files;
-
-    if (wind->selected_file != SCM_BOOL_F)
-    {
-        imported_files =
-            scm_call_2(unload_qif_file, wind->selected_file, wind->imported_files);
-
-        scm_gc_unprotect_object(wind->imported_files);
-        wind->imported_files = imported_files;
-        scm_gc_protect_object(wind->imported_files);
-
-        scm_gc_unprotect_object(wind->selected_file);
-        wind->selected_file = SCM_BOOL_F;
-        scm_gc_protect_object(wind->selected_file);
-
-        update_file_page(wind);
-    }
-}
-
-
-/********************************************************************
- * update_file_page
- *
- * Update the list of loaded files.
- ********************************************************************/
-static void
-update_file_page(QIFImportWindow * wind)
-{
-    SCM       loaded_file_list = wind->imported_files;
-    SCM       qif_file_path;
-    int       row = 0;
-    GtkTreeView *view;
-    GtkListStore *store;
-    GtkTreeIter iter;
-    GtkTreePath *path;
-    GtkTreeRowReference *reference = NULL;
-
-    /* clear the list */
-    view = GTK_TREE_VIEW(wind->selected_file_view);
-    store = GTK_LIST_STORE(gtk_tree_view_get_model(view));
-    gtk_list_store_clear(store);
-    qif_file_path = scm_c_eval_string("qif-file:path");
-
-    while (!scm_is_null(loaded_file_list))
-    {
-        gchar *row_text    = NULL;
-        SCM    scm_qiffile = SCM_BOOL_F;
-
-        scm_qiffile = SCM_CAR(loaded_file_list);
-        row_text = gnc_scm_call_1_to_string(qif_file_path, scm_qiffile);
-
-        gtk_list_store_append(store, &iter);
-        gtk_list_store_set(store, &iter,
-                           FILENAME_COL_INDEX, row++,
-                           FILENAME_COL_NAME, row_text,
-                           -1);
-        g_free (row_text);
-
-        if (scm_qiffile == wind->selected_file)
-        {
-            path = gtk_tree_model_get_path(GTK_TREE_MODEL(store), &iter);
-            reference = gtk_tree_row_reference_new(GTK_TREE_MODEL(store), path);
-            gtk_tree_path_free(path);
-        }
-        loaded_file_list = SCM_CDR(loaded_file_list);
-    }
-
-    if (reference)
-    {
-        GtkTreeSelection* selection = gtk_tree_view_get_selection(view);
-        path = gtk_tree_row_reference_get_path(reference);
-        if (path)
-        {
-            gtk_tree_selection_select_path(selection, path);
-            gtk_tree_path_free(path);
-        }
-        gtk_tree_row_reference_free(reference);
-    }
-}
-
-
-/**********************************************
- * Page 6 - Account Doc. Page Procedures
- **********************************************/
-
-/********************************************************************
- * gnc_ui_qif_import_account_doc_prepare
- ********************************************************************/
-void
-gnc_ui_qif_import_account_doc_prepare (GtkAssistant *assistant,
-                                       gpointer user_data)
-{
-    QIFImportWindow * wind = user_data;
-    gint num = gtk_assistant_get_current_page (assistant);
-    GtkWidget *page = gtk_assistant_get_nth_page (assistant, num);
-    gint total = gtk_assistant_get_n_pages (assistant);
-    gtk_assistant_update_buttons_state (assistant);
-
-    PINFO("Total Number of Assistant Pages is %d", gtk_assistant_get_n_pages (assistant));
-
-    /* Enable the Assistant Forward Button */
-    gtk_assistant_set_page_complete (assistant, page, TRUE);
-
-    /* Jump to Summary page if load_stop TRUE */
-    if (wind->load_stop)
-        gtk_assistant_set_current_page (assistant, total - 1 );
-
-    /* Jump over doc page if show_doc_pages FALSE */
-    if (!wind->show_doc_pages)
-        gtk_assistant_set_current_page (assistant, num + 1 );
-}
-
-
-/******************************************
- * Page 7 - Account Match Page Procedures
- ******************************************/
-
-/********************************************************************
- * gnc_ui_qif_import_account_match_prepare
- *
- * Get the matching pages ready for viewing.
- ********************************************************************/
-void
-gnc_ui_qif_import_account_match_prepare(GtkAssistant *assistant,
-                                        gpointer user_data)
-{
-    QIFImportWindow * wind = user_data;
-    gint num = gtk_assistant_get_current_page (assistant);
-    GtkWidget *page = gtk_assistant_get_nth_page (assistant, num);
-
-    /* Prepare the matching pages. */
-    gnc_set_busy_cursor(NULL, TRUE);
-    update_account_page(wind);
-    update_category_page(wind);
-    update_memo_page(wind);
-    gnc_unset_busy_cursor(NULL);
-
-    /* Enable the Assistant Forward Button */
-    gtk_assistant_set_page_complete (assistant, page, TRUE);
-}
-
-
-/****************************************************************
- * gnc_ui_qif_import_account_rematch_cb
- *
- * This handler is invoked when the user clicks the "Change
- * GnuCash account" button on the account mapping page. This
- * button is an alternative to double-clicking a row.
- ****************************************************************/
-void
-gnc_ui_qif_import_account_rematch_cb(GtkButton *button, gpointer user_data)
-{
-    QIFImportWindow  *wind = user_data;
-
-    g_return_if_fail(wind);
-
-    rematch_line(wind,
-                 gtk_tree_view_get_selection(GTK_TREE_VIEW(wind->acct_view)),
-                 wind->acct_display_info,
-                 wind->acct_map_info,
-                 update_account_page);
-}
-
-
-/*******************************************
- * Page 8 - Catagory Doc. Page Procedures
- *******************************************/
-
-/********************************************************************
- * gnc_ui_qif_import_catagory_doc_prepare
- ********************************************************************/
-void
-gnc_ui_qif_import_catagory_doc_prepare (GtkAssistant *assistant,
-                                        gpointer user_data)
-{
-    QIFImportWindow * wind = user_data;
-    gint num = gtk_assistant_get_current_page (assistant);
-    GtkWidget *page = gtk_assistant_get_nth_page (assistant, num);
-    gint total = gtk_assistant_get_n_pages (assistant);
-    gtk_assistant_update_buttons_state (assistant);
-
-    PINFO("Total Number of Assistant Pages is %d", gtk_assistant_get_n_pages (assistant));
-
-    /* Enable the Assistant Forward Button */
-    gtk_assistant_set_page_complete (assistant, page, TRUE);
-
-    /* Jump to Summary page if load_stop TRUE */
-    if (wind->load_stop)
-        gtk_assistant_set_current_page (assistant, total - 1 );
-
-    /* Jump over doc page if show_doc_pages FALSE */
-    if (!wind->show_doc_pages)
-        gtk_assistant_set_current_page (assistant, num + 1 );
-
-    /* If there are no category mappings, jump the doc page. */
-    if (scm_is_list(wind->cat_display_info) && scm_is_null(wind->cat_display_info))
-        gtk_assistant_set_current_page (assistant, num + 1);
-}
-
-
-/******************************************
- * Page 9 - Catagory Match Page Procedures
- ******************************************/
-
-/****************************************************************
- * gnc_ui_qif_import_catagory_match_prepare
- *
- * Find the next page to show, depending on whether there are
- * category or payee/memo mappings to be dealt with.
- ****************************************************************/
-void
-gnc_ui_qif_import_catagory_match_prepare(GtkAssistant *assistant,
-        gpointer user_data)
-{
-    QIFImportWindow * wind = user_data;
-    gint num = gtk_assistant_get_current_page (assistant);
-    GtkWidget *page = gtk_assistant_get_nth_page (assistant, num);
-
-    /* Enable the Assistant Forward Button */
-    gtk_assistant_set_page_complete (assistant, page, TRUE);
-
-    /* If there are no category mappings, jump this step. */
-    if (scm_is_list(wind->cat_display_info) && scm_is_null(wind->cat_display_info))
-        gtk_assistant_set_current_page (assistant, num + 1);
-}
-
-
-/****************************************************************
- * gnc_ui_qif_import_category_rematch_cb
- *
- * This handler is invoked when the user clicks the "Change
- * GnuCash account" button on the category mapping page. This
- * button is an alternative to double-clicking a row.
- ****************************************************************/
-void
-gnc_ui_qif_import_category_rematch_cb(GtkButton *button, gpointer user_data)
-{
-    QIFImportWindow  *wind = user_data;
-
-    g_return_if_fail(wind);
-
-    rematch_line(wind,
-                 gtk_tree_view_get_selection(GTK_TREE_VIEW(wind->cat_view)),
-                 wind->cat_display_info,
-                 wind->cat_map_info,
-                 update_category_page);
-}
-
-
-/****************************************
- * Page 10 - Memo Doc. Page Procedures
- ****************************************/
-
-/********************************************************************
- * gnc_ui_qif_import_memo_doc_prepare
- ********************************************************************/
-void
-gnc_ui_qif_import_memo_doc_prepare (GtkAssistant *assistant,
-                                    gpointer user_data)
-{
-    QIFImportWindow * wind = user_data;
-    gint num = gtk_assistant_get_current_page (assistant);
-    GtkWidget *page = gtk_assistant_get_nth_page (assistant, num);
-    gint total = gtk_assistant_get_n_pages (assistant);
-    gtk_assistant_update_buttons_state (assistant);
-
-    PINFO("Total Number of Assistant Pages is %d", gtk_assistant_get_n_pages (assistant));
-
-    /* Enable the Assistant Forward Button */
-    gtk_assistant_set_page_complete (assistant, page, TRUE);
-
-    /* Jump to Summary page if load_stop TRUE */
-    if (wind->load_stop)
-        gtk_assistant_set_current_page (assistant, total - 1 );
-
-    /* Jump over doc page if show_doc_pages FALSE */
-    if (!wind->show_doc_pages)
-        gtk_assistant_set_current_page (assistant, num + 1 );
-
-    /* If there are no memo mappings, jump the doc page. */
-    if (scm_is_list(wind->memo_display_info) && scm_is_null(wind->memo_display_info))
-        gtk_assistant_set_current_page (assistant, num + 1);
-}
-
-
-/****************************************
- * Page 11 - Memo Match Page Procedures
- ****************************************/
-
-/****************************************************************
- * gnc_ui_qif_import_memo_match_prepare
- *
- * Find the next page to show, depending on whether there are
- * category or payee/memo mappings to be dealt with.
- ****************************************************************/
-void
-gnc_ui_qif_import_memo_match_prepare (GtkAssistant *assistant,
-                                      gpointer user_data)
-{
-    QIFImportWindow * wind = user_data;
-    gint num = gtk_assistant_get_current_page (assistant);
-    GtkWidget *page = gtk_assistant_get_nth_page (assistant, num);
-
-    /* Enable the Assistant Forward Button */
-    gtk_assistant_set_page_complete (assistant, page, TRUE);
-
-    /* If there are no memo mappings, jump this step. */
-    if (scm_is_list(wind->memo_display_info) && scm_is_null(wind->memo_display_info))
-        gtk_assistant_set_current_page (assistant, num + 1);
-}
-
-
-/****************************************************************
- * gnc_ui_qif_import_memo_rematch_cb
- *
- * This handler is invoked when the user clicks the "Change
- * GnuCash account" button on the memo mapping page. This
- * button is an alternative to double-clicking a row.
- ****************************************************************/
-void
-gnc_ui_qif_import_memo_rematch_cb(GtkButton *button, gpointer user_data)
-{
-    QIFImportWindow  *wind = user_data;
-
-    g_return_if_fail(wind);
-
-    rematch_line(wind,
-                 gtk_tree_view_get_selection(GTK_TREE_VIEW(wind->memo_view)),
-                 wind->memo_display_info,
-                 wind->memo_map_info,
-                 update_memo_page);
-}
-
-
-/*****************************************
- * Page 12  - Currency Page Procedures
- ****************************************/
-
-/****************************************************************
- * gnc_ui_qif_import_currency_prepare
- *
- * Find the next page to show, depending on whether there are
- * category or payee/memo mappings to be dealt with.
- ****************************************************************/
-void
-gnc_ui_qif_import_currency_prepare(GtkAssistant *assistant,
-                                   gpointer user_data)
-{
-    gint num = gtk_assistant_get_current_page (assistant);
-    GtkWidget *page = gtk_assistant_get_nth_page (assistant, num);
-    QIFImportWindow  *wind = user_data;
-
-    g_return_if_fail(wind);
-
-    /* Only display Book Option data if new book */
-    if (wind->new_book)
-    {
-        gtk_assistant_set_page_title (assistant, page,
-                                      _("Choose the QIF file currency and select Book Options"));
-        gtk_widget_show (wind->book_option_label);
-        gtk_widget_show (wind->book_option_message);
-    }
-    else
-    {
-        gtk_assistant_set_page_title (assistant, page,
-                                      _("Choose the QIF file currency"));
-        gtk_widget_hide (wind->book_option_label);
-        gtk_widget_hide (wind->book_option_message);
-    }
-
-    /* Enable the Assistant Forward Button */
-    gtk_assistant_set_page_complete (assistant, page, TRUE);
-}
-
-
-/**************************************************
- * Page 13 - Commodity Doc. Page Procedures
- **************************************************/
-
-/****************************************************************
- * gnc_ui_qif_import_new_securities
- *
- * This function creates or updates the list of QIF securities
- * for which no corresponding GnuCash commodity existed prior to
- * import. If there are any such securities, TRUE is returned.
- * Otherwise, FALSE is returned.
- ****************************************************************/
-static gboolean
-gnc_ui_qif_import_new_securities(QIFImportWindow * wind)
-{
-    SCM updates;
-    SCM update_securities = scm_c_eval_string("qif-import:update-security-hash");
-
-    /* Get a list of any new QIF securities since the previous call. */
-    updates = scm_call_4(update_securities,
-                         wind->security_hash,
-                         wind->ticker_map,
-                         wind->acct_map_info,
-                         wind->security_prefs);
-    if (updates != SCM_BOOL_F)
-    {
-        /* A list of new QIF securities was returned. Save it. */
-        scm_gc_unprotect_object(wind->new_securities);
-        if (wind->new_securities != SCM_BOOL_F)
-            /* There is an existing list, so append the new list. */
-            wind->new_securities = scm_append(scm_list_2(wind->new_securities,
-                                              updates));
-        else
-            wind->new_securities = updates;
-        scm_gc_protect_object(wind->new_securities);
-
-        return TRUE;
-    }
-
-    if (wind->new_securities != SCM_BOOL_F)
-        return TRUE;
-
-    return FALSE;
-}
-
-
-/********************************************************************
- * gnc_ui_qif_import_commodity_doc_prepare
- ********************************************************************/
-void
-gnc_ui_qif_import_commodity_doc_prepare (GtkAssistant *assistant,
-        gpointer user_data)
-{
-    QIFImportWindow * wind = user_data;
-    gint num = gtk_assistant_get_current_page (assistant);
-    GtkWidget *page = gtk_assistant_get_nth_page (assistant, num);
-    gint total = gtk_assistant_get_n_pages (assistant);
-    gtk_assistant_update_buttons_state (assistant);
-
-    PINFO("Total Number of Assistant Pages is %d", gtk_assistant_get_n_pages (assistant));
-
-    /* Enable the Assistant Forward Button */
-    gtk_assistant_set_page_complete (assistant, page, TRUE);
-
-    /* Jump to Summary page if load_stop TRUE */
-    if (wind->load_stop)
-        gtk_assistant_set_current_page (assistant, total - 1 );
-
-    /* If there are new securities, prepare the security pages. */
-    if (gnc_ui_qif_import_new_securities(wind))
-        prepare_security_pages(wind);
-    else
-        /* If there are no securities, jump the doc page */
-        gtk_assistant_set_current_page (assistant, num + 1 );
-
-    /* Jump over doc page if show_doc_pages FALSE */
-    if (!wind->show_doc_pages)
-        gtk_assistant_set_current_page (assistant, num + 1 );
-}
-
-
-/********************************************
- * Page xx - Commodity New Pages Procedures
- ********************************************/
-
-/********************************************
- * gnc_ui_qif_import_commodity_new_prepare
- *******************************************/
-void
-gnc_ui_qif_import_commodity_new_prepare (GtkAssistant *assistant,
-        gpointer user_data)
-{
-    gint num = gtk_assistant_get_current_page (assistant);
-    GtkWidget *page = gtk_assistant_get_nth_page (assistant, num);
-
-    QIFAssistantPage    *qpage = g_object_get_data(G_OBJECT(page), "page_struct");
-    const gchar         *ns;
-
-    g_return_if_fail (qpage != NULL);
-
-    /* Get any entered namespace. */
-    ns = gtk_entry_get_text( GTK_ENTRY( gtk_bin_get_child( GTK_BIN( GTK_COMBO_BOX(qpage->namespace_combo)))));
-
-    /* Update the namespaces available to select. */
-    if (!ns || !ns[0])
-        gnc_ui_update_namespace_picker(
-            qpage->namespace_combo,
-            gnc_commodity_get_namespace(qpage->commodity),
-            DIAG_COMM_ALL);
-    else
-        gnc_ui_update_namespace_picker(qpage->namespace_combo, ns, DIAG_COMM_ALL);
-}
-
-
-/*********************************
- * gnc_ui_qif_import_comm_valid
- ********************************/
-static gboolean
-gnc_ui_qif_import_comm_valid (GtkAssistant *assistant,
-                              gpointer user_data)
-{
-    QIFImportWindow *wind = user_data;
-    gint num = gtk_assistant_get_current_page (GTK_ASSISTANT(wind->window));
-    GtkWidget *page = gtk_assistant_get_nth_page (assistant, num);
-    QIFAssistantPage    *qpage = g_object_get_data(G_OBJECT(page), "page_struct");
-
-    QofBook                 *book;
-    gnc_commodity_table     *table;
-    gnc_commodity_namespace *newns;
-
-    gchar       *namespace = gnc_ui_namespace_picker_ns(qpage->namespace_combo);
-    const gchar *name      = gtk_entry_get_text(GTK_ENTRY(qpage->name_entry));
-    const gchar *mnemonic  = gtk_entry_get_text(GTK_ENTRY(qpage->mnemonic_entry));
-
-    if (!name || (name[0] == 0))
-    {
-        gnc_warning_dialog(wind->window, "%s",
-                           _("Enter a name or short description, such as \"Red Hat Stock\"."));
-        g_free(namespace);
-        return FALSE;
-    }
-    else if (!mnemonic || (mnemonic[0] == 0))
-    {
-        gnc_warning_dialog(wind->window, "%s",
-                           _("Enter the ticker symbol or other well known abbreviation, such as"
-                             " \"RHT\". If there isn't one, or you don't know it, create your own."));
-        g_free(namespace);
-        return FALSE;
-    }
-    else if (!namespace || (namespace[0] == 0))
-    {
-        gnc_warning_dialog(wind->window, "%s",
-                           _("Select the exchange on which the symbol is traded, or select the"
-                             " type of investment (such as FUND for mutual funds.) If you don't"
-                             " see your exchange or an appropriate investment type, you can"
-                             " enter a new one."));
-        if (namespace)
-            g_free(namespace);
-        return FALSE;
-    }
-
-    /* FIXME: Should check whether a commodity with this namespace and
-     *        mnemonic already exists. If so, ask the user whether to use
-     *        the existing one, or go back and change what they've entered.
-     */
-
-    book = gnc_get_current_book();
-    table = gnc_commodity_table_get_table(book);
-    if (gnc_commodity_namespace_is_iso(namespace) &&
-            !gnc_commodity_table_lookup(table, namespace, mnemonic))
-    {
-        gnc_warning_dialog(wind->window, "%s",
-                           _("You must enter an existing national "
-                             "currency or enter a different type."));
-
-        g_free(namespace);
-        return FALSE;
-    }
-
-    /* Is the namespace a new one? */
-    if (!gnc_commodity_table_has_namespace(table, namespace))
-    {
-        /* Register it so that it will appear as an option on other pages. */
-        newns = gnc_commodity_table_add_namespace(table, namespace, book);
-
-        /* Remember it so it can be removed if the import gets canceled. */
-        if (newns)
-            wind->new_namespaces = g_list_prepend(wind->new_namespaces, namespace);
-        else
-        {
-            g_warning("QIF import: Couldn't create namespace %s", namespace);
-            g_free(namespace);
-        }
-    }
-    else
-        g_free(namespace);
-
-    return TRUE;
-}
-
-
-/*************************************
- * gnc_ui_qif_import_comm_changed_cb
- ************************************/
-void
-gnc_ui_qif_import_comm_changed_cb (GtkWidget *widget, gpointer user_data)
-{
-    QIFImportWindow *wind = user_data;
-    GtkAssistant *assistant = GTK_ASSISTANT(wind->window);
-    gint num = gtk_assistant_get_current_page (assistant);
-    GtkWidget *page = gtk_assistant_get_nth_page (assistant, num);
-
-    gtk_assistant_set_page_complete (assistant, page, gnc_ui_qif_import_comm_valid (assistant, user_data));
-}
-
-
-/**********************************************
- * Page 14 - Convert progress Page Procedures
- *********************************************/
-
-/********************************************************************
- * gnc_ui_qif_import_convert_progress_pause_cb
- *
- * Invoked when the "Pause" button is clicked.
- ********************************************************************/
-void
-gnc_ui_qif_import_convert_progress_pause_cb(GtkButton * button,
-        gpointer user_data)
-{
-    QIFImportWindow *wind = user_data;
-    SCM toggle_pause      = scm_c_eval_string("qif-import:toggle-pause");
-    SCM progress;
-
-    if (!wind->busy)
-        return;
-
-    /* Create SCM for the progress helper. */
-    progress = SWIG_NewPointerObj(wind->convert_progress,
-                                  SWIG_TypeQuery("_p__GNCProgressDialog"),
-                                  0);
-
-    /* Pause (or resume) the currently running operation. */
-    scm_call_1(toggle_pause, progress);
-
-    /* Swap the button label between pause and resume. */
-    if (strcmp(gtk_button_get_label(button), _("_Resume")))
-    {
-        gtk_button_set_use_stock(button, FALSE);
-        gtk_button_set_use_underline(button, TRUE);
-        gtk_button_set_label(button, _("_Resume"));
-    }
-    else
-    {
-        gtk_button_set_use_stock(button, TRUE);
-        gtk_button_set_use_underline(button, FALSE);
-        gtk_button_set_label(button, "gtk-media-pause");
-    }
-}
-
-
-/********************************************************************
- * gnc_ui_qif_import_convert_progress_start_cb
- *
- * Invoked when the "Start" button is clicked.
- ********************************************************************/
-void
-gnc_ui_qif_import_convert_progress_start_cb(GtkButton * button,
-        gpointer user_data)
-{
-    QIFImportWindow   *wind = user_data;
-    gint num = gtk_assistant_get_current_page (GTK_ASSISTANT(wind->window));
-    GtkWidget *page = gtk_assistant_get_nth_page (GTK_ASSISTANT(wind->window), num);
-
-    SCM qif_to_gnc      = scm_c_eval_string("qif-import:qif-to-gnc");
-    SCM find_duplicates = scm_c_eval_string("gnc:account-tree-find-duplicates");
-    SCM retval;
-
-    /* SCM for the progress dialog. */
-    SCM progress = SWIG_NewPointerObj(wind->convert_progress,
-                                      SWIG_TypeQuery("_p__GNCProgressDialog"),
-                                      0);
-
-    /* The default currency. */
-    const gchar *currname = gtk_entry_get_text( GTK_ENTRY( gtk_bin_get_child( GTK_BIN( GTK_COMBO_BOX(wind->currency_picker)))));
-
-    /* Raise the busy flag so the assistant can't be canceled unexpectedly. */
-    wind->busy = TRUE;
-    gtk_widget_set_sensitive(wind->convert_pause, TRUE);
-    gtk_widget_set_sensitive(wind->convert_start, FALSE);
-
-    /* Clear any previous pause or cancel state. */
-    scm_c_eval_string("(qif-import:reset-cancel-pause)");
-
-    /* Update the commodities. */
-    gnc_ui_qif_import_commodity_update(wind);
-
-    /*
-     * Convert the QIF data into GnuCash data.
-     *
-     * A Scheme function does all the work.  The return value is the
-     * root account of an account tree containing all the new accounts
-     * and transactions. Upon failure, #f is returned. If the user
-     * cancels, #t is returned.
-     */
-
-    /* This step will fill 70% of the bar. */
-    gnc_progress_dialog_push(wind->convert_progress, 0.7);
-    retval = scm_apply(qif_to_gnc,
-                       SCM_LIST8(wind->imported_files,
-                                 wind->acct_map_info,
-                                 wind->cat_map_info,
-                                 wind->memo_map_info,
-                                 wind->security_hash,
-                                 scm_from_utf8_string(currname ? currname : ""),
-                                 wind->transaction_status,
-                                 progress),
-                       SCM_EOL);
-    gnc_progress_dialog_pop(wind->convert_progress);
-
-    if (retval == SCM_BOOL_T)
-    {
-        /* Canceled by the user. */
-
-        /* Disable the pause button. */
-        gtk_widget_set_sensitive(wind->convert_pause, FALSE);
-
-        /* Remove any converted data. */
-        gnc_progress_dialog_set_sub(wind->convert_progress, _("Cleaning up"));
-        gnc_ui_qif_import_convert_undo(wind);
-
-        /* Inform the user. */
-        gnc_progress_dialog_set_sub(wind->convert_progress, _("Canceled"));
-        gnc_progress_dialog_reset_value(wind->convert_progress);
-
-        wind->busy = FALSE;
-        wind->load_stop = TRUE;
-    }
-    else if (retval == SCM_BOOL_F)
-    {
-        /* An bug was encountered during conversion. */
-
-        /* Disable the pause button. */
-        gtk_widget_set_sensitive(wind->convert_pause, FALSE);
-
-        /* Remove any converted data. */
-        gnc_progress_dialog_set_sub(wind->convert_progress, _("Cleaning up"));
-        gnc_ui_qif_import_convert_undo(wind);
-
-        /* Inform the user. */
-        gnc_progress_dialog_append_log(wind->convert_progress,
-                                       _( "A bug was detected while converting the QIF data."));
-        gnc_progress_dialog_set_sub(wind->convert_progress, _("Failed"));
-        gnc_progress_dialog_reset_value(wind->convert_progress);
-        gnc_error_dialog(wind->window, "%s",
-                         _( "A bug was detected while converting the QIF data."));
-        /* FIXME: How should we request that the user report this problem? */
-
-        wind->busy = FALSE;
-        wind->load_stop = TRUE;
-    }
-    else if (scm_is_symbol(retval))
-    {
-        /* An error was encountered during conversion. */
-
-        /* Disable the pause button. */
-        gtk_widget_set_sensitive(wind->convert_pause, FALSE);
-
-        /* Remove any converted data. */
-        gnc_progress_dialog_set_sub(wind->convert_progress, _("Cleaning up"));
-        gnc_ui_qif_import_convert_undo(wind);
-
-        /* Inform the user. */
-        gnc_progress_dialog_set_sub(wind->convert_progress, _("Failed"));
-        gnc_progress_dialog_reset_value(wind->convert_progress);
-
-        wind->busy = FALSE;
-        wind->load_stop = TRUE;
-    }
-
-    /* Save the imported account tree. */
-    scm_gc_unprotect_object(wind->imported_account_tree);
-    wind->imported_account_tree = retval;
-    scm_gc_protect_object(wind->imported_account_tree);
-
-    /*
-     * Detect potentially duplicated transactions.
-     */
-
-    /* This step will fill the remainder of the bar. */
-    gnc_progress_dialog_push(wind->convert_progress, 1);
-    retval = scm_call_3(find_duplicates,
-                        scm_c_eval_string("(gnc-get-current-root-account)"),
-                        wind->imported_account_tree, progress);
-    gnc_progress_dialog_pop(wind->convert_progress);
-
-    /* Save the results. */
-    scm_gc_unprotect_object(wind->match_transactions);
-    wind->match_transactions = retval;
-    scm_gc_protect_object(wind->match_transactions);
-
-    if (retval == SCM_BOOL_T)
-    {
-        /* Canceled by the user. */
-        gtk_widget_set_sensitive(wind->convert_pause, FALSE);
-        gnc_progress_dialog_set_sub(wind->convert_progress, _("Canceling"));
-        wind->busy = FALSE;
-        wind->load_stop = TRUE;
-    }
-    else if (retval == SCM_BOOL_F)
-    {
-        /* An error occurred during duplicate checking. */
-
-        /* Remove any converted data. */
-        gnc_progress_dialog_set_sub(wind->convert_progress, _("Cleaning up"));
-        gnc_ui_qif_import_convert_undo(wind);
-
-        /* Inform the user. */
-        gnc_progress_dialog_append_log(wind->convert_progress,
-                                       _( "A bug was detected while detecting duplicates."));
-        gnc_progress_dialog_set_sub(wind->convert_progress, _("Failed"));
-        gnc_progress_dialog_reset_value(wind->convert_progress);
-        gnc_error_dialog(wind->window, "%s",
-                         _( "A bug was detected while detecting duplicates."));
-        /* FIXME: How should we request that the user report this problem? */
-
-        gtk_widget_set_sensitive(wind->convert_pause, FALSE);
-        wind->busy = FALSE;
-        wind->load_stop = TRUE;
-    }
-
-    /* Enable the Assistant Forward Button */
-    gtk_assistant_set_page_complete (GTK_ASSISTANT(wind->window), page, TRUE);
-
-    /* Set Pause and Start buttons */
-    gtk_widget_set_sensitive(wind->convert_pause, FALSE);
-    gtk_widget_set_sensitive(wind->convert_start, FALSE);
-
-    if (wind->load_stop == FALSE)
-    {
-        /* The conversion completed successfully. */
-        gnc_progress_dialog_set_sub(wind->convert_progress,
-                                    _("Conversion completed"));
-        gnc_progress_dialog_set_value(wind->convert_progress, 1);
-
-        gtk_widget_set_sensitive(wind->convert_pause, FALSE);
-        wind->busy = FALSE;
-
-        /* If the log is empty, move on to the next page automatically. */
-        if (gtk_text_buffer_get_char_count(gtk_text_view_get_buffer(GTK_TEXT_VIEW(wind->convert_log))) == 0)
-            gtk_assistant_set_current_page (GTK_ASSISTANT(wind->window), num + 1);
-    }
-}
-
-
-/********************************************************************
- * gnc_ui_qif_import_convert_progress_prepare
- *
- * Prepare the data conversion progress page for display.
- ********************************************************************/
-void
-gnc_ui_qif_import_convert_progress_prepare(GtkAssistant *assistant,
-        gpointer user_data)
-{
-    QIFImportWindow   *wind = user_data;
-    gint num = gtk_assistant_get_current_page (assistant);
-    GtkWidget *page = gtk_assistant_get_nth_page (assistant, num);
-
-    /* Recompute assistant Buttons */
-    gtk_assistant_update_buttons_state( assistant );
-
-    /* Reset the progress display. */
-    gnc_progress_dialog_set_primary(wind->convert_progress, "");
-    gnc_progress_dialog_set_secondary(wind->convert_progress,
-                                      _("When you press the Start Button, GnuCash will import your QIF data. If there are no errors or warnings, you will automatically proceed to the next step. Otherwise, the details will be shown below for your review."));
-    gnc_progress_dialog_set_sub(wind->convert_progress, " ");
-    gnc_progress_dialog_reset_value(wind->convert_progress);
-    gnc_progress_dialog_reset_log(wind->convert_progress);
-
-    /* Set Pause and Start buttons */
-    gtk_widget_set_sensitive(wind->convert_pause, FALSE);
-    gtk_widget_set_sensitive(wind->convert_start, TRUE);
-
-    /* Disable the assistant Forward button */
-    gtk_assistant_set_page_complete (assistant, page, FALSE);
-
-    /* Before creating transactions, if this is a new book, let user specify
-     * book options, since they affect how transactions are created */
-    if (wind->new_book)
-        wind->new_book = gnc_new_book_option_display();
-}
-
-
-/*****************************************
- * Page 15 - Match Doc. Page Procedures
- *****************************************/
-
-/********************************************************************
- * gnc_ui_qif_import_duplicates_doc_prepare
- ********************************************************************/
-void
-gnc_ui_qif_import_duplicates_doc_prepare (GtkAssistant *assistant,
-        gpointer user_data)
-{
-    QIFImportWindow * wind = user_data;
-    gint num = gtk_assistant_get_current_page (assistant);
-    GtkWidget *page = gtk_assistant_get_nth_page (assistant, num);
-    gint total = gtk_assistant_get_n_pages (assistant);
-    gtk_assistant_update_buttons_state (assistant);
-
-    PINFO("Total Number of Assistant Pages is %d", gtk_assistant_get_n_pages (assistant));
-
-    /* Enable the Assistant Forward Button */
-    gtk_assistant_set_page_complete (assistant, page, TRUE);
-
-    /* Jump to Summary page if load_stop TRUE */
-    if (wind->load_stop)
-        gtk_assistant_set_current_page (assistant, total - 1 );
-
-    /* Jump over doc page if show_doc_pages FALSE */
-    if (!wind->show_doc_pages)
-        gtk_assistant_set_current_page (assistant, num + 1 );
-
-    /* Don't show doc page if there are no duplicates */
-    if (scm_is_null(wind->match_transactions))
-        gtk_assistant_set_current_page (assistant, num + 1 );
-}
-
-
-/**********************************************
- * Page 16 - Match Duplicates Page Procedures
- **********************************************/
-
-/********************************************************************
- * gnc_ui_qif_import_duplicates_match_prepare
- ********************************************************************/
-void
-gnc_ui_qif_import_duplicates_match_prepare (GtkAssistant *assistant,
-        gpointer user_data)
-{
-    QIFImportWindow * wind = user_data;
-    gint num = gtk_assistant_get_current_page (assistant);
-    GtkWidget *page = gtk_assistant_get_nth_page (assistant, num);
-
-    GtkTreeView      *view;
-    GtkListStore     *store;
-    SCM               duplicates;
-    SCM               current_xtn;
-    Transaction      *gnc_xtn;
-    Split            *gnc_split;
-    GtkTreeIter       iter;
-    GtkTreeSelection *selection;
-    GtkTreePath      *path;
-    const gchar      *amount_str;
-    int               rownum = 0;
-
-    if (!scm_is_null(wind->match_transactions))
-    {
-        view = GTK_TREE_VIEW(wind->new_transaction_view);
-        store = GTK_LIST_STORE(gtk_tree_view_get_model(view));
-        gtk_list_store_clear(store);
-
-        if (!scm_is_list(wind->match_transactions))
-            return;
-
-        /* Loop through the list of new, potentially duplicate transactions. */
-        duplicates = wind->match_transactions;
-        while (!scm_is_null(duplicates))
-        {
-            current_xtn = SCM_CAAR(duplicates);
-#define FUNC_NAME "xaccTransCountSplits"
-            gnc_xtn = SWIG_MustGetPtr(current_xtn,
-                                      SWIG_TypeQuery("_p_Transaction"), 1, 0);
-#undef FUNC_NAME
-            if (xaccTransCountSplits(gnc_xtn) > 2)
-                amount_str = _("(split)");
-            else
-            {
-                gnc_split = xaccTransGetSplit(gnc_xtn, 0);
-                amount_str =
-                    xaccPrintAmount(gnc_numeric_abs(xaccSplitGetValue(gnc_split)),
-                                    gnc_account_print_info
-                                    (xaccSplitGetAccount(gnc_split), TRUE));
-            }
-            gtk_list_store_append(store, &iter);
-            gtk_list_store_set
-            (store, &iter,
-             QIF_TRANS_COL_INDEX, rownum++,
-             QIF_TRANS_COL_DATE,
-             gnc_print_date(xaccTransRetDatePostedTS(gnc_xtn)),
-             QIF_TRANS_COL_DESCRIPTION, xaccTransGetDescription(gnc_xtn),
-             QIF_TRANS_COL_AMOUNT, amount_str,
-             -1);
-
-            duplicates = SCM_CDR(duplicates);
-        }
-        selection = gtk_tree_view_get_selection(view);
-        path = gtk_tree_path_new_from_indices(0, -1);
-        gtk_tree_selection_select_path(selection, path);
-        gtk_tree_path_free(path);
-    }
-    else
-        gtk_assistant_set_current_page (assistant, num + 1 );
-
-    /* Enable the Assistant Forward Button */
-    gtk_assistant_set_page_complete (assistant, page, TRUE);
-}
-
-
-/*************************************
- * Page 17 - Apply Page Procedures
- *************************************/
-
-/********************************************************************
- * gnc_ui_qif_import_end_page_prepare
- ********************************************************************/
-void
-gnc_ui_qif_import_end_page_prepare (GtkAssistant *assistant,
-                                    gpointer user_data)
-{
-    gint num = gtk_assistant_get_current_page (assistant);
-    GtkWidget *page = gtk_assistant_get_nth_page (assistant, num);
-
-    /* Enable the Assistant Forward Button */
-    gtk_assistant_set_page_complete (assistant, page, TRUE);
-}
-
-
-/********************************************************************
- * gnc_ui_qif_import_finish_cb
- *
- * Invoked when the "Apply" button is clicked on the final page.
- ********************************************************************/
-void
-gnc_ui_qif_import_finish_cb (GtkAssistant *gtkassistant,
-                             gpointer user_data)
-{
-    QIFImportWindow * wind = user_data;
-
-    SCM save_map_prefs = scm_c_eval_string("qif-import:save-map-prefs");
-    SCM cat_and_merge = scm_c_eval_string("gnc:account-tree-catenate-and-merge");
-    SCM prune_xtns = scm_c_eval_string("gnc:prune-matching-transactions");
-    SCM scm_result;
-
-    GncPluginPage *page;
-    gboolean acct_tree_found = FALSE;
-
-    gnc_suspend_gui_refresh();
-
-    /* Prune any imported transactions that were determined to be duplicates. */
-    if (wind->match_transactions != SCM_BOOL_F)
-        scm_call_1(prune_xtns, wind->match_transactions);
-
-    /* Merge the imported account tree with the existing one. */
-    if (wind->imported_account_tree != SCM_BOOL_F)
-        scm_call_2(cat_and_merge,
-                   scm_c_eval_string("(gnc-get-current-root-account)"),
-                   wind->imported_account_tree);
-
-    gnc_resume_gui_refresh();
-
-    /* Save the user's mapping preferences. */
-    scm_result = scm_apply(save_map_prefs,
-                           SCM_LIST5(wind->acct_map_info, wind->cat_map_info,
-                                     wind->memo_map_info, wind->security_hash,
-                                     wind->security_prefs),
-                           SCM_EOL);
-
-    if (scm_result == SCM_BOOL_F)
-        gnc_warning_dialog(wind->window, "%s",
-                           _("GnuCash was unable to save your mapping preferences."));
-
-    /* Open an account tab in the main window if one doesn't exist already. */
-    gnc_main_window_foreach_page(gnc_ui_qif_import_check_acct_tree,
-                                 &acct_tree_found);
-
-    wind->acct_tree_found = acct_tree_found;
-    if (!acct_tree_found)
-    {
-        page = gnc_plugin_page_account_tree_new();
-        gnc_main_window_open_page(NULL, page);
-    }
-}
-
-
-/***************************************
- * Page 18 - Summary Page Procedures
- ***************************************/
-
-/********************************************************************
- * gnc_ui_qif_import_summary_page_prepare
- ********************************************************************/
-void
-gnc_ui_qif_import_summary_page_prepare (GtkAssistant *assistant,
-                                        gpointer user_data)
-{
-    QIFImportWindow * wind = user_data;
-    gint num = gtk_assistant_get_current_page (assistant);
-    GtkWidget *page = gtk_assistant_get_nth_page (assistant, num);
-
-    gchar *text;
-
-    if (wind->load_stop)
-        text = g_strdup_printf(_("There was a problem with the import."));
-    else
-        text = g_strdup_printf(_("QIF Import Completed."));
-
-    gtk_label_set_markup(GTK_LABEL(wind->summary_text), g_strdup_printf("<span size=\"large\"><b>%s</b></span>", text));
-
-    g_free(text);
-
-    /* Enable the Assistant Forward Button */
-    gtk_assistant_set_page_complete (assistant, page, TRUE);
-}
-
-
-/********************************************************************
- * Prepare callback for assistant pages.
- ********************************************************************/
-void gnc_ui_qif_import_prepare_cb (GtkAssistant  *assistant, GtkWidget *page,
-                                   gpointer user_data)
-{
-    gint currentpage = gtk_assistant_get_current_page(assistant);
-    GtkWidget *mypage = gtk_assistant_get_nth_page (assistant, currentpage);
-    const char *pagename = gtk_buildable_get_name(GTK_BUILDABLE(mypage));
-
-    PINFO("Builder Page Name is %s", gtk_buildable_get_name(GTK_BUILDABLE(mypage)));
-
-    if (!g_strcmp0 (pagename, "start_page"))
-    {
-        /* Current page is Intro page */
-        gnc_ui_qif_import_intro_prepare (assistant, user_data);
-    }
-    else if (!g_strcmp0 (pagename, "load_file_page"))
-    {
-        /* Current page is File Load */
-        gnc_ui_qif_import_load_file_prepare (assistant, user_data);
-    }
-    else if (!g_strcmp0 (pagename, "load_progress_page"))
-    {
-        /* Current page is Load Progress */
-        gnc_ui_qif_import_load_progress_prepare (assistant, user_data);
-    }
-    else if (!g_strcmp0 (pagename, "date_format_page"))
-    {
-        /* Current page is date page */
-        gnc_ui_qif_import_date_format_prepare (assistant, user_data);
-    }
-    else if (!g_strcmp0 (pagename, "account_name_page"))
-    {
-        /* Current page is account page */
-        gnc_ui_qif_import_account_prepare (assistant, user_data);
-    }
-    else if (!g_strcmp0 (pagename, "loaded_files_page"))
-    {
-        /* Current page is loaded files page */
-        gnc_ui_qif_import_loaded_files_prepare (assistant, user_data);
-    }
-    else if (!g_strcmp0 (pagename, "account_doc_page"))
-    {
-        /* Current page is  Account Doc. page */
-        gnc_ui_qif_import_account_doc_prepare (assistant, user_data);
-    }
-    else if (!g_strcmp0 (pagename, "account_match_page"))
-    {
-        /* Current page is Account Match page */
-        gnc_ui_qif_import_account_match_prepare (assistant, user_data);
-    }
-    else if (!g_strcmp0 (pagename, "category_doc_page"))
-    {
-        /* Current page is Catagory Doc. page */
-        gnc_ui_qif_import_catagory_doc_prepare (assistant, user_data);
-    }
-    else if (!g_strcmp0 (pagename, "category_match_page"))
-    {
-        /* Current page is Catagory Match page */
-        gnc_ui_qif_import_catagory_match_prepare (assistant, user_data);
-    }
-    else if (!g_strcmp0 (pagename, "memo_doc_page"))
-    {
-        /* Current page is Memo Doc. page */
-        gnc_ui_qif_import_memo_doc_prepare (assistant, user_data);
-    }
-    else if (!g_strcmp0 (pagename, "memo_match_page"))
-    {
-        /* Current page is Memo Match page */
-        gnc_ui_qif_import_memo_match_prepare (assistant, user_data);
-    }
-    else if (!g_strcmp0 (pagename, "currency_book_option_page"))
-    {
-        /* Current page is Currency page */
-        gnc_ui_qif_import_currency_prepare (assistant, user_data);
-    }
-    else if (!g_strcmp0 (pagename, "commodity_doc_page"))
-    {
-        /* Current page is Commodity Doc. page */
-        gnc_ui_qif_import_commodity_doc_prepare (assistant, user_data);
-    }
-    else if (!g_strcmp0 (pagename, "commodity_page"))
-    {
-        /* Current page is Commodity page */
-        /* gnc_ui_qif_import_commodity_prepare (assistant, user_data); */
-    }
-    else if (!g_strcmp0 (pagename, "convert_progress_page"))
-    {
-        /* Current page is Conversion progress page */
-        gnc_ui_qif_import_convert_progress_prepare (assistant, user_data);
-    }
-    else if (!g_strcmp0 (pagename, "duplicates_doc_page"))
-    {
-        /* Current page is Duplicates Doc page */
-        gnc_ui_qif_import_duplicates_doc_prepare (assistant, user_data);
-    }
-    else if (!g_strcmp0 (pagename, "duplicates_match_page"))
-    {
-        /* Current page is Duplicates Match page */
-        gnc_ui_qif_import_duplicates_match_prepare (assistant, user_data);
-    }
-    else if (!g_strcmp0 (pagename, "end_page"))
-    {
-        /* Current page is the end page */
-        gnc_ui_qif_import_end_page_prepare (assistant, user_data);
-    }
-    else if (!g_strcmp0 (pagename, "summary_page"))
-    {
-        /* Current page is the summary page */
-        gnc_ui_qif_import_summary_page_prepare (assistant, user_data);
-    }
-    else
-    {
-        /* Current page is a new commodity page */
-        gnc_ui_qif_import_commodity_new_prepare (assistant, user_data);
-    }
-}
-
-
-/********************************************************************
- * get_assistant_widgets
- *
- * Get all builder-defined widgets that need to be actively managed.
- ********************************************************************/
-static void
-get_assistant_widgets(QIFImportWindow *wind, GtkBuilder *builder)
-{
-    g_return_if_fail(wind);
-    g_return_if_fail(builder);
-
-    wind->window             = GTK_WIDGET(gtk_builder_get_object (builder, "QIF Import Assistant"));
-    wind->filename_entry     = GTK_WIDGET(gtk_builder_get_object (builder, "qif_filename_entry"));
-    wind->load_pause         = GTK_WIDGET(gtk_builder_get_object (builder, "load_progress_pause"));
-    wind->load_start         = GTK_WIDGET(gtk_builder_get_object (builder, "load_progress_start"));
-    wind->load_log           = GTK_WIDGET(gtk_builder_get_object (builder, "load_progress_log"));
-    wind->load_progress      = gnc_progress_dialog_custom(
-                                   GTK_LABEL(gtk_builder_get_object (builder, "load_progress_primary")),
-                                   GTK_LABEL(gtk_builder_get_object (builder, "load_progress_secondary")),
-                                   GTK_PROGRESS_BAR(gtk_builder_get_object (builder, "load_progress_bar")),
-                                   GTK_LABEL(gtk_builder_get_object (builder, "load_progress_sub")),
-                                   GTK_TEXT_VIEW(wind->load_log));
-    wind->acct_entry         = GTK_WIDGET(gtk_builder_get_object (builder, "qif_account_entry"));
-    wind->date_format_combo  = GTK_WIDGET(gtk_builder_get_object (builder, "date_format_combobox"));
-    wind->selected_file_view = GTK_WIDGET(gtk_builder_get_object (builder, "selected_file_view"));
-    wind->unload_file_btn    = GTK_WIDGET(gtk_builder_get_object (builder, "unload_file_button"));
-    wind->currency_picker    = GTK_WIDGET(gtk_builder_get_object (builder, "currency_comboboxentry"));
-    wind->book_option_label  = GTK_WIDGET(gtk_builder_get_object (builder, "book_option_label"));
-    wind->book_option_message = GTK_WIDGET(gtk_builder_get_object (builder, "book_option_message_label"));
-    wind->acct_view          = GTK_WIDGET(gtk_builder_get_object (builder, "account_page_view"));
-    wind->acct_view_count    = GTK_WIDGET(gtk_builder_get_object (builder, "account_page_count"));
-    wind->acct_view_btn      = GTK_WIDGET(gtk_builder_get_object (builder, "account_page_change"));
-    wind->cat_view           = GTK_WIDGET(gtk_builder_get_object (builder, "category_page_view"));
-    wind->cat_view_count     = GTK_WIDGET(gtk_builder_get_object (builder, "category_page_count"));
-    wind->cat_view_btn       = GTK_WIDGET(gtk_builder_get_object (builder, "category_page_change"));
-    wind->memo_view          = GTK_WIDGET(gtk_builder_get_object (builder, "memo_page_view"));
-    wind->memo_view_count    = GTK_WIDGET(gtk_builder_get_object (builder, "memo_page_count"));
-    wind->memo_view_btn      = GTK_WIDGET(gtk_builder_get_object (builder, "memo_page_change"));
-    wind->convert_pause      = GTK_WIDGET(gtk_builder_get_object (builder, "convert_progress_pause"));
-    wind->convert_start      = GTK_WIDGET(gtk_builder_get_object (builder, "convert_progress_start"));
-    wind->convert_log        = GTK_WIDGET(gtk_builder_get_object (builder, "convert_progress_log"));
-    wind->convert_progress   = gnc_progress_dialog_custom(
-                                   GTK_LABEL(gtk_builder_get_object (builder, "convert_progress_primary")),
-                                   GTK_LABEL(gtk_builder_get_object (builder, "convert_progress_secondary")),
-                                   GTK_PROGRESS_BAR(gtk_builder_get_object (builder, "convert_progress_bar")),
-                                   GTK_LABEL(gtk_builder_get_object (builder, "convert_progress_sub")),
-                                   GTK_TEXT_VIEW(wind->convert_log));
-    wind->summary_text       = GTK_WIDGET(gtk_builder_get_object (builder, "summary_page"));
-
-    wind->new_transaction_view =
-        GTK_WIDGET(gtk_builder_get_object (builder, "new_transaction_view"));
-    wind->old_transaction_view =
-        GTK_WIDGET(gtk_builder_get_object (builder, "old_transaction_view"));
-
-    gnc_assistant_set_colors (GTK_ASSISTANT (wind->window));
-}
-
-
-/********************************************************************
- * build_views
- *
- * Build the details of all GtkTreeView widgets.
- ********************************************************************/
-static void
-build_views(QIFImportWindow *wind)
-{
-    GtkTreeView *view;
-    GtkListStore *store;
-    GtkCellRenderer *renderer;
-    GtkTreeViewColumn *column;
-    GtkTreeSelection *selection;
-
-    g_return_if_fail(wind);
-
-    /* Set up the selected file view */
-    view = GTK_TREE_VIEW(wind->selected_file_view);
-    store = gtk_list_store_new(NUM_FILENAME_COLS, G_TYPE_INT, G_TYPE_STRING);
-    gtk_tree_view_set_model(view, GTK_TREE_MODEL(store));
-    g_object_unref(store);
-
-    renderer = gtk_cell_renderer_text_new();
-    column = gtk_tree_view_column_new_with_attributes("unused",
-             renderer,
-             "text",
-             FILENAME_COL_NAME,
-             NULL);
-    gtk_tree_view_append_column(view, column);
-
-    selection = gtk_tree_view_get_selection(view);
-    g_signal_connect(selection, "changed",
-                     G_CALLBACK(gnc_ui_qif_import_select_loaded_file_cb),
-                     wind);
-
-    /* Set up the QIF account to GnuCash account matcher. */
-    create_account_picker_view(wind->acct_view, _("QIF account name"),
-                               G_CALLBACK(gnc_ui_qif_import_account_activate_cb),
-                               G_CALLBACK(gnc_ui_qif_import_account_select_cb),
-                               wind);
-
-    /* Set up the QIF category to GnuCash account matcher. */
-    create_account_picker_view(wind->cat_view,  _("QIF category name"),
-                               G_CALLBACK(gnc_ui_qif_import_category_activate_cb),
-                               G_CALLBACK(gnc_ui_qif_import_category_select_cb),
-                               wind);
-
-    /* Set up the QIF payee/memo to GnuCash account matcher. */
-    create_account_picker_view(wind->memo_view, _("QIF payee/memo"),
-                               G_CALLBACK(gnc_ui_qif_import_memo_activate_cb),
-                               G_CALLBACK(gnc_ui_qif_import_memo_select_cb),
-                               wind);
-
-    /* Set up the new transaction view */
-    view = GTK_TREE_VIEW(wind->new_transaction_view);
-    store = gtk_list_store_new(NUM_QIF_TRANS_COLS, G_TYPE_INT, G_TYPE_STRING,
-                               G_TYPE_STRING, G_TYPE_STRING, G_TYPE_BOOLEAN);
-    gtk_tree_view_set_model(view, GTK_TREE_MODEL(store));
-    g_object_unref(store);
-
-    renderer = gtk_cell_renderer_text_new();
-    column = gtk_tree_view_column_new_with_attributes(_("Date"),
-             renderer,
-             "text",
-             QIF_TRANS_COL_DATE,
-             NULL);
-    gtk_tree_view_append_column(view, column);
-
-    renderer = gtk_cell_renderer_text_new();
-    column = gtk_tree_view_column_new_with_attributes(_("Description"),
-             renderer,
-             "text",
-             QIF_TRANS_COL_DESCRIPTION,
-             NULL);
-    gtk_tree_view_append_column(view, column);
-    gtk_tree_view_column_set_expand(column, TRUE);
-
-    renderer = gtk_cell_renderer_text_new();
-    column = gtk_tree_view_column_new_with_attributes(_("Amount"),
-             renderer,
-             "text",
-             QIF_TRANS_COL_AMOUNT,
-             NULL);
-    gtk_tree_view_append_column(view, column);
-
-    selection = gtk_tree_view_get_selection(view);
-    g_signal_connect(selection, "changed",
-                     G_CALLBACK(gnc_ui_qif_import_duplicate_new_select_cb),
-                     wind);
-
-    /* Set up the old transaction view */
-    view = GTK_TREE_VIEW(wind->old_transaction_view);
-    store = gtk_list_store_new(NUM_QIF_TRANS_COLS, G_TYPE_INT, G_TYPE_STRING,
-                               G_TYPE_STRING, G_TYPE_STRING, G_TYPE_BOOLEAN);
-    gtk_tree_view_set_model(view, GTK_TREE_MODEL(store));
-    g_object_unref(store);
-
-    renderer = gtk_cell_renderer_text_new();
-    column = gtk_tree_view_column_new_with_attributes(_("Date"),
-             renderer,
-             "text",
-             QIF_TRANS_COL_DATE,
-             NULL);
-    gtk_tree_view_append_column(view, column);
-
-    renderer = gtk_cell_renderer_text_new();
-    column = gtk_tree_view_column_new_with_attributes(_("Description"),
-             renderer,
-             "text",
-             QIF_TRANS_COL_DESCRIPTION,
-             NULL);
-    gtk_tree_view_append_column(view, column);
-    gtk_tree_view_column_set_expand(column, TRUE);
-
-    renderer = gtk_cell_renderer_text_new();
-    column = gtk_tree_view_column_new_with_attributes(_("Amount"),
-             renderer,
-             "text",
-             QIF_TRANS_COL_AMOUNT,
-             NULL);
-    gtk_tree_view_append_column(view, column);
-
-    renderer = gtk_cell_renderer_toggle_new();
-    column = gtk_tree_view_column_new_with_attributes(_("Match?"),
-             renderer,
-             "active",
-             QIF_TRANS_COL_CHECKED,
-             NULL);
-    gtk_tree_view_append_column(view, column);
-
-    selection = gtk_tree_view_get_selection(view);
-    g_signal_connect(selection, "changed",
-                     G_CALLBACK(gnc_ui_qif_import_duplicate_old_select_cb),
-                     wind);
-}
-
-
-/********************************************************************
- * gnc_ui_qif_import_assistant_make
- *
- * Build a new QIF import assistant.
- ********************************************************************/
-static GtkWidget *
-gnc_ui_qif_import_assistant_make(QIFImportWindow *qif_win)
-{
-    GtkBuilder        *builder;
-    GtkWidget         *box;
-
-    builder = gtk_builder_new();
-    gnc_builder_add_from_file (builder, "assistant-qif-import.glade", "currency_liststore");
-    gnc_builder_add_from_file (builder, "assistant-qif-import.glade", "date_format_liststore");
-    gnc_builder_add_from_file (builder, "assistant-qif-import.glade", "QIF Import Assistant");
-
-    qif_win->new_namespaces       = NULL;
-    qif_win->selected_transaction = 0;
-    qif_win->busy                 = FALSE;
-    /* In order to include a book options display on the creation of a new book,
-     * we need to detect when we are dealing with a new book. */
-    qif_win->new_book = gnc_is_new_book();
-
-    /* Get all user preferences related to QIF importing. */
-    get_preferences(qif_win);
-
-    /* Set up the Scheme side of things. Note that if a session/book did not
-     * exist prior to this function, it is created within scheme function
-     * "qif-import:load-map-prefs", so we need to have set the flag previously */
-    initialize_scheme(qif_win);
-
-    /* Get all interesting builder-defined widgets. */
-    get_assistant_widgets(qif_win, builder);
-
-    /* Make this window stay on top */
-    gtk_window_set_transient_for (GTK_WINDOW (qif_win->window),
-				  GTK_WINDOW (gnc_ui_get_toplevel ()));
-
-    /* Build the details of all GtkTreeView widgets. */
-    build_views(qif_win);
-
-    /* Currency Page */
-    /* Set a default currency for new accounts */
-    qif_win->currency_picker = gnc_currency_edit_new();
-    gnc_currency_edit_set_currency (GNC_CURRENCY_EDIT(qif_win->currency_picker), gnc_default_currency());
-    gtk_widget_show (qif_win->currency_picker);
-    box = GTK_WIDGET(gtk_builder_get_object (builder, "currency_picker_hbox"));
-    gtk_box_pack_start(GTK_BOX(box), qif_win->currency_picker, TRUE, TRUE, 0);
-
-    gnc_restore_window_size (GNC_PREFS_GROUP, GTK_WINDOW(qif_win->window));
-
-    g_signal_connect( qif_win->window, "destroy",
-                      G_CALLBACK(gnc_ui_qif_import_assistant_destroy), qif_win );
-
-    gtk_builder_connect_signals(builder, qif_win);
-
-    g_object_unref(G_OBJECT(builder));
-
-    gtk_widget_show_all(qif_win->window);
-    gtk_window_present(GTK_WINDOW(qif_win->window));
-
-    return qif_win->window;
-}
-
-
-/********************************************
- * gnc_ui_qif_import_assistant_close_handler
- ********************************************/
-static void
-gnc_ui_qif_import_assistant_close_handler( gpointer user_data )
-{
-    QIFImportWindow *qif_win = user_data;
-
-    gnc_save_window_size(GNC_PREFS_GROUP, GTK_WINDOW(qif_win->window));
-    gtk_widget_destroy( qif_win->window );
-}
-
-
-/********************************************
- * gnc_file_qif_import
- ********************************************/
-void
-gnc_file_qif_import(void)
-{
-    QIFImportWindow *qif_win;
-    gint component_id;
-
-    qif_win = g_new0 (QIFImportWindow, 1);
-
-    /* pop up the QIF File Import dialog box */
-    gnc_ui_qif_import_assistant_make(qif_win);
-
-    component_id = gnc_register_gui_component (ASSISTANT_QIF_IMPORT_CM_CLASS,
-                   NULL, gnc_ui_qif_import_assistant_close_handler,
-                   qif_win);
-
-    gnc_gui_component_watch_entity_type (component_id,
-                                         GNC_ID_ACCOUNT,
-                                         QOF_EVENT_MODIFY | QOF_EVENT_DESTROY);
-
-    gtk_widget_show_all (qif_win->window);
-
-    gnc_window_adjust_for_screen (GTK_WINDOW(qif_win->window));
-}

Deleted: gnucash/trunk/src/import-export/qif-import/assistant-qif-import.glade
===================================================================
--- gnucash/trunk/src/import-export/qif-import/assistant-qif-import.glade	2013-12-15 17:20:10 UTC (rev 23566)
+++ gnucash/trunk/src/import-export/qif-import/assistant-qif-import.glade	2013-12-15 17:21:20 UTC (rev 23567)
@@ -1,1331 +0,0 @@
-<?xml version="1.0"?>
-<interface>
-  <requires lib="gtk+" version="2.16"/>
-  <!-- interface-naming-policy project-wide -->
-  <object class="GtkAssistant" id="QIF Import Assistant">
-    <property name="can_focus">False</property>
-    <property name="border_width">12</property>
-    <property name="title" translatable="yes">QIF Import Assistant</property>
-    <signal name="close" handler="gnc_ui_qif_import_close_cb" swapped="no"/>
-    <signal name="apply" handler="gnc_ui_qif_import_finish_cb" swapped="no"/>
-    <signal name="cancel" handler="gnc_ui_qif_import_cancel_cb" swapped="no"/>
-    <signal name="prepare" handler="gnc_ui_qif_import_prepare_cb" swapped="no"/>
-    <child>
-      <object class="GtkLabel" id="start_page">
-        <property name="visible">True</property>
-        <property name="can_focus">False</property>
-        <property name="label" translatable="yes">GnuCash can import financial data from QIF (Quicken Interchange Format) files written by Quicken/QuickBooks, MS Money, Moneydance, and many other programs. 
-
-The import process has several steps. Your GnuCash accounts will not be changed until you click "Apply" at the end of the process. 
-
-Click "Forward" to start loading your QIF data, or "Cancel" to abort the process. </property>
-        <property name="wrap">True</property>
-      </object>
-      <packing>
-        <property name="page_type">intro</property>
-        <property name="title" translatable="yes">Import QIF files</property>
-        <property name="complete">True</property>
-      </packing>
-    </child>
-    <child>
-      <object class="GtkVBox" id="load_file_page">
-        <property name="visible">True</property>
-        <property name="can_focus">False</property>
-        <property name="border_width">12</property>
-        <child>
-          <object class="GtkLabel" id="label822">
-            <property name="visible">True</property>
-            <property name="can_focus">False</property>
-            <property name="label" translatable="yes">Please select a file to load. When you click "Forward", the file will be loaded and analyzed. You may need to answer some questions about the account(s) in the file.
-
-You will have the opportunity to load as many files as you wish, so don't worry if your data is in multiple files. 
-</property>
-            <property name="wrap">True</property>
-          </object>
-          <packing>
-            <property name="expand">False</property>
-            <property name="fill">False</property>
-            <property name="padding">5</property>
-            <property name="position">0</property>
-          </packing>
-        </child>
-        <child>
-          <object class="GtkHBox" id="hbox69">
-            <property name="visible">True</property>
-            <property name="can_focus">False</property>
-            <child>
-              <object class="GtkEntry" id="qif_filename_entry">
-                <property name="visible">True</property>
-                <property name="can_focus">True</property>
-                <property name="can_default">True</property>
-                <property name="has_default">True</property>
-                <property name="editable">False</property>
-                <property name="invisible_char">&#x25CF;</property>
-                <property name="invisible_char_set">True</property>
-                <property name="primary_icon_activatable">False</property>
-                <property name="secondary_icon_activatable">False</property>
-                <property name="primary_icon_sensitive">True</property>
-                <property name="secondary_icon_sensitive">True</property>
-              </object>
-              <packing>
-                <property name="expand">True</property>
-                <property name="fill">True</property>
-                <property name="position">0</property>
-              </packing>
-            </child>
-            <child>
-              <object class="GtkButton" id="button71">
-                <property name="label" translatable="yes">_Select...</property>
-                <property name="visible">True</property>
-                <property name="can_focus">True</property>
-                <property name="receives_default">True</property>
-                <property name="use_action_appearance">False</property>
-                <property name="use_underline">True</property>
-                <signal name="clicked" handler="gnc_ui_qif_import_select_file_cb" swapped="no"/>
-              </object>
-              <packing>
-                <property name="expand">False</property>
-                <property name="fill">False</property>
-                <property name="padding">3</property>
-                <property name="position">1</property>
-              </packing>
-            </child>
-          </object>
-          <packing>
-            <property name="expand">False</property>
-            <property name="fill">False</property>
-            <property name="position">1</property>
-          </packing>
-        </child>
-      </object>
-      <packing>
-        <property name="page_type">content</property>
-        <property name="title" translatable="yes">Select a QIF file to load</property>
-      </packing>
-    </child>
-    <child>
-      <object class="GtkVBox" id="load_progress_page">
-        <property name="visible">True</property>
-        <property name="can_focus">False</property>
-        <property name="border_width">12</property>
-        <property name="spacing">12</property>
-        <child>
-          <object class="GtkLabel" id="load_progress_primary">
-            <property name="visible">True</property>
-            <property name="can_focus">False</property>
-            <property name="label"><span weight="bold" size="larger">Primary text</span></property>
-            <property name="use_markup">True</property>
-            <property name="wrap">True</property>
-          </object>
-          <packing>
-            <property name="expand">False</property>
-            <property name="fill">False</property>
-            <property name="position">0</property>
-          </packing>
-        </child>
-        <child>
-          <object class="GtkLabel" id="load_progress_secondary">
-            <property name="visible">True</property>
-            <property name="can_focus">False</property>
-            <property name="label">Secondary text.</property>
-            <property name="wrap">True</property>
-          </object>
-          <packing>
-            <property name="expand">False</property>
-            <property name="fill">False</property>
-            <property name="position">1</property>
-          </packing>
-        </child>
-        <child>
-          <object class="GtkVBox" id="load_progress_vbox1">
-            <property name="visible">True</property>
-            <property name="can_focus">False</property>
-            <child>
-              <object class="GtkProgressBar" id="load_progress_bar">
-                <property name="visible">True</property>
-                <property name="can_focus">False</property>
-                <property name="pulse_step">0.10000000149</property>
-              </object>
-              <packing>
-                <property name="expand">False</property>
-                <property name="fill">False</property>
-                <property name="position">0</property>
-              </packing>
-            </child>
-            <child>
-              <object class="GtkLabel" id="load_progress_sub">
-                <property name="visible">True</property>
-                <property name="can_focus">False</property>
-                <property name="xalign">0</property>
-                <property name="label"><span style="italic">Sub-operation text</span></property>
-                <property name="use_markup">True</property>
-                <property name="wrap">True</property>
-              </object>
-              <packing>
-                <property name="expand">False</property>
-                <property name="fill">False</property>
-                <property name="position">1</property>
-              </packing>
-            </child>
-            <child>
-              <object class="GtkHButtonBox" id="load_progress_hbuttonbox1">
-                <property name="visible">True</property>
-                <property name="can_focus">False</property>
-                <property name="layout_style">end</property>
-                <child>
-                  <object class="GtkButton" id="load_progress_start">
-                    <property name="label" translatable="yes">_Start</property>
-                    <property name="visible">True</property>
-                    <property name="can_focus">True</property>
-                    <property name="receives_default">True</property>
-                    <property name="use_action_appearance">False</property>
-                    <property name="use_underline">True</property>
-                    <signal name="clicked" handler="gnc_ui_qif_import_load_progress_start_cb" swapped="no"/>
-                  </object>
-                  <packing>
-                    <property name="expand">False</property>
-                    <property name="fill">False</property>
-                    <property name="position">0</property>
-                  </packing>
-                </child>
-                <child>
-                  <object class="GtkButton" id="load_progress_pause">
-                    <property name="label">gtk-media-pause</property>
-                    <property name="visible">True</property>
-                    <property name="can_focus">True</property>
-                    <property name="can_default">True</property>
-                    <property name="receives_default">True</property>
-                    <property name="use_action_appearance">False</property>
-                    <property name="use_stock">True</property>
-                    <signal name="clicked" handler="gnc_ui_qif_import_load_progress_pause_cb" swapped="no"/>
-                  </object>
-                  <packing>
-                    <property name="expand">False</property>
-                    <property name="fill">False</property>
-                    <property name="position">1</property>
-                  </packing>
-                </child>
-              </object>
-              <packing>
-                <property name="expand">False</property>
-                <property name="fill">False</property>
-                <property name="position">2</property>
-              </packing>
-            </child>
-          </object>
-          <packing>
-            <property name="expand">False</property>
-            <property name="fill">False</property>
-            <property name="padding">6</property>
-            <property name="position">2</property>
-          </packing>
-        </child>
-        <child>
-          <object class="GtkScrolledWindow" id="scrolledwindow25">
-            <property name="visible">True</property>
-            <property name="can_focus">True</property>
-            <property name="hscrollbar_policy">automatic</property>
-            <property name="vscrollbar_policy">automatic</property>
-            <property name="shadow_type">in</property>
-            <child>
-              <object class="GtkTextView" id="load_progress_log">
-                <property name="visible">True</property>
-                <property name="can_focus">True</property>
-                <property name="editable">False</property>
-                <property name="wrap_mode">word</property>
-                <property name="cursor_visible">False</property>
-                <property name="accepts_tab">False</property>
-              </object>
-            </child>
-          </object>
-          <packing>
-            <property name="expand">True</property>
-            <property name="fill">True</property>
-            <property name="position">3</property>
-          </packing>
-        </child>
-      </object>
-      <packing>
-        <property name="page_type">content</property>
-        <property name="title" translatable="yes">Load QIF files</property>
-      </packing>
-    </child>
-    <child>
-      <object class="GtkVBox" id="date_format_page">
-        <property name="visible">True</property>
-        <property name="can_focus">False</property>
-        <property name="border_width">12</property>
-        <child>
-          <object class="GtkLabel" id="label841">
-            <property name="visible">True</property>
-            <property name="can_focus">False</property>
-            <property name="label" translatable="yes">The QIF file format does not specify which order the day, month, and year components of a date are printed. In most cases, it is possible to automatically determine which format is in use in a particular file. However, in the file you have just imported there exist more than one possible format that fits the data. 
-
-Please select a date format for the file. QIF files created by European software are likely  to be in "d-m-y" or day-month-year format, where US QIF files are likely to be "m-d-y" or month-day-year. 
-</property>
-            <property name="wrap">True</property>
-          </object>
-          <packing>
-            <property name="expand">False</property>
-            <property name="fill">False</property>
-            <property name="position">0</property>
-          </packing>
-        </child>
-        <child>
-          <object class="GtkComboBox" id="date_format_combobox">
-            <property name="visible">True</property>
-            <property name="can_focus">False</property>
-            <property name="model">date_format_liststore</property>
-            <signal name="changed" handler="gnc_ui_qif_import_date_valid_cb" swapped="no"/>
-            <child>
-              <object class="GtkCellRendererText" id="cellrenderertext1"/>
-              <attributes>
-                <attribute name="text">0</attribute>
-              </attributes>
-            </child>
-          </object>
-          <packing>
-            <property name="expand">False</property>
-            <property name="fill">False</property>
-            <property name="position">1</property>
-          </packing>
-        </child>
-        <child>
-          <object class="GtkLabel" id="label847713">
-            <property name="visible">True</property>
-            <property name="can_focus">False</property>
-            <property name="label" translatable="yes">Click "Back" to cancel the loading of this file and choose another.</property>
-            <property name="justify">center</property>
-            <property name="wrap">True</property>
-          </object>
-          <packing>
-            <property name="expand">False</property>
-            <property name="fill">False</property>
-            <property name="pack_type">end</property>
-            <property name="position">2</property>
-          </packing>
-        </child>
-      </object>
-      <packing>
-        <property name="page_type">content</property>
-        <property name="title" translatable="yes">Set a date format for this QIF file</property>
-      </packing>
-    </child>
-    <child>
-      <object class="GtkVBox" id="account_name_page">
-        <property name="visible">True</property>
-        <property name="can_focus">False</property>
-        <property name="border_width">12</property>
-        <child>
-          <object class="GtkLabel" id="label823">
-            <property name="visible">True</property>
-            <property name="can_focus">False</property>
-            <property name="label" translatable="yes">The QIF file that you just loaded appears to contain transactions for just one account, but the file does not specify a name for that account. 
-
-Please enter a name for the account. If the file was exported from another accounting program, you should use the same account name that was used in that program.
-</property>
-            <property name="wrap">True</property>
-          </object>
-          <packing>
-            <property name="expand">False</property>
-            <property name="fill">False</property>
-            <property name="padding">4</property>
-            <property name="position">0</property>
-          </packing>
-        </child>
-        <child>
-          <object class="GtkHBox" id="hbox70">
-            <property name="visible">True</property>
-            <property name="can_focus">False</property>
-            <child>
-              <object class="GtkLabel" id="label824">
-                <property name="visible">True</property>
-                <property name="can_focus">False</property>
-                <property name="xalign">1</property>
-                <property name="label" translatable="yes">Account name:</property>
-                <property name="justify">center</property>
-              </object>
-              <packing>
-                <property name="expand">False</property>
-                <property name="fill">False</property>
-                <property name="padding">4</property>
-                <property name="position">0</property>
-              </packing>
-            </child>
-            <child>
-              <object class="GtkEntry" id="qif_account_entry">
-                <property name="visible">True</property>
-                <property name="can_focus">True</property>
-                <property name="invisible_char">&#x25CF;</property>
-                <property name="invisible_char_set">True</property>
-                <property name="primary_icon_activatable">False</property>
-                <property name="secondary_icon_activatable">False</property>
-                <property name="primary_icon_sensitive">True</property>
-                <property name="secondary_icon_sensitive">True</property>
-                <signal name="changed" handler="gnc_ui_qif_import_acct_valid_cb" swapped="no"/>
-              </object>
-              <packing>
-                <property name="expand">True</property>
-                <property name="fill">True</property>
-                <property name="position">1</property>
-              </packing>
-            </child>
-          </object>
-          <packing>
-            <property name="expand">False</property>
-            <property name="fill">False</property>
-            <property name="position">1</property>
-          </packing>
-        </child>
-        <child>
-          <object class="GtkLabel" id="label847714">
-            <property name="visible">True</property>
-            <property name="can_focus">False</property>
-            <property name="label" translatable="yes">Click "Back" to cancel the loading of this file and choose another.</property>
-            <property name="justify">center</property>
-          </object>
-          <packing>
-            <property name="expand">False</property>
-            <property name="fill">False</property>
-            <property name="pack_type">end</property>
-            <property name="position">2</property>
-          </packing>
-        </child>
-      </object>
-      <packing>
-        <property name="page_type">content</property>
-        <property name="title" translatable="yes">Set the default QIF account name</property>
-        <property name="complete">True</property>
-      </packing>
-    </child>
-    <child>
-      <object class="GtkVBox" id="loaded_files_page">
-        <property name="visible">True</property>
-        <property name="can_focus">False</property>
-        <property name="border_width">12</property>
-        <property name="spacing">4</property>
-        <child>
-          <object class="GtkScrolledWindow" id="scrolledwindow26">
-            <property name="visible">True</property>
-            <property name="can_focus">True</property>
-            <property name="hscrollbar_policy">automatic</property>
-            <property name="vscrollbar_policy">automatic</property>
-            <property name="shadow_type">in</property>
-            <child>
-              <object class="GtkTreeView" id="selected_file_view">
-                <property name="visible">True</property>
-                <property name="can_focus">True</property>
-                <property name="headers_visible">False</property>
-                <property name="rules_hint">True</property>
-              </object>
-            </child>
-          </object>
-          <packing>
-            <property name="expand">True</property>
-            <property name="fill">True</property>
-            <property name="position">0</property>
-          </packing>
-        </child>
-        <child>
-          <object class="GtkLabel" id="label816">
-            <property name="visible">True</property>
-            <property name="can_focus">False</property>
-            <property name="label" translatable="yes">Click "Load another file" if you have more data to import at this time. Do this if you have saved your accounts to separate QIF files.
-
-Click "Forward" to finish loading files and move to the next step of the QIF import process. </property>
-            <property name="wrap">True</property>
-          </object>
-          <packing>
-            <property name="expand">False</property>
-            <property name="fill">False</property>
-            <property name="padding">3</property>
-            <property name="position">1</property>
-          </packing>
-        </child>
-        <child>
-          <object class="GtkHButtonBox" id="hbox68">
-            <property name="visible">True</property>
-            <property name="can_focus">False</property>
-            <property name="layout_style">spread</property>
-            <child>
-              <object class="GtkButton" id="unload_file_button">
-                <property name="label" translatable="yes">_Unload selected file</property>
-                <property name="visible">True</property>
-                <property name="can_focus">True</property>
-                <property name="receives_default">True</property>
-                <property name="use_action_appearance">False</property>
-                <property name="use_underline">True</property>
-                <signal name="clicked" handler="gnc_ui_qif_import_unload_file_cb" swapped="no"/>
-              </object>
-              <packing>
-                <property name="expand">False</property>
-                <property name="fill">False</property>
-                <property name="position">0</property>
-              </packing>
-            </child>
-            <child>
-              <object class="GtkButton" id="button69">
-                <property name="label" translatable="yes">_Load another file</property>
-                <property name="visible">True</property>
-                <property name="can_focus">True</property>
-                <property name="receives_default">True</property>
-                <property name="use_action_appearance">False</property>
-                <property name="use_underline">True</property>
-                <signal name="clicked" handler="gnc_ui_qif_import_load_another_cb" swapped="no"/>
-              </object>
-              <packing>
-                <property name="expand">False</property>
-                <property name="fill">False</property>
-                <property name="position">1</property>
-              </packing>
-            </child>
-          </object>
-          <packing>
-            <property name="expand">False</property>
-            <property name="fill">False</property>
-            <property name="position">2</property>
-          </packing>
-        </child>
-      </object>
-      <packing>
-        <property name="title" translatable="yes">QIF files you have loaded</property>
-        <property name="complete">True</property>
-      </packing>
-    </child>
-    <child>
-      <object class="GtkVBox" id="account_doc_page">
-        <property name="visible">True</property>
-        <property name="can_focus">False</property>
-        <property name="border_width">12</property>
-        <child>
-          <object class="GtkLabel" id="label830">
-            <property name="visible">True</property>
-            <property name="can_focus">False</property>
-            <property name="label" translatable="yes">On the next page, the accounts in your QIF files and any stocks or mutual funds you own will be matched with GnuCash accounts. If a GnuCash account already exists with the same name, or a similar name and compatible type, that account will be used as a match; otherwise, GnuCash will create a new account with the same name and type as the QIF account. If you do not like the suggested GnuCash account, double-click to change it.
-
-Note that GnuCash will be creating many accounts that did not exist on your other personal finance program, including a separate account for each stock you own, separate accounts for the brokerage commissions, special "Equity" accounts (subaccounts of Retained Earnings, by default) which are the source of your opening balances, etc. All of these accounts will appear on the next page so you can change them if you want to, but it is safe to leave them alone.
-</property>
-            <property name="wrap">True</property>
-          </object>
-          <packing>
-            <property name="expand">False</property>
-            <property name="fill">False</property>
-            <property name="position">0</property>
-          </packing>
-        </child>
-      </object>
-      <packing>
-        <property name="page_type">content</property>
-        <property name="title" translatable="yes">Accounts and stock holdings</property>
-      </packing>
-    </child>
-    <child>
-      <object class="GtkVBox" id="account_match_page">
-        <property name="visible">True</property>
-        <property name="can_focus">False</property>
-        <property name="border_width">12</property>
-        <child>
-          <object class="GtkLabel" id="label7609">
-            <property name="visible">True</property>
-            <property name="can_focus">False</property>
-            <property name="xalign">0</property>
-            <property name="xpad">5</property>
-            <property name="label" translatable="yes">_Select the matchings you want to change:</property>
-            <property name="use_underline">True</property>
-            <property name="mnemonic_widget">account_page_view</property>
-          </object>
-          <packing>
-            <property name="expand">False</property>
-            <property name="fill">False</property>
-            <property name="padding">5</property>
-            <property name="position">0</property>
-          </packing>
-        </child>
-        <child>
-          <object class="GtkScrolledWindow" id="scrolledwindow11">
-            <property name="visible">True</property>
-            <property name="can_focus">True</property>
-            <property name="hscrollbar_policy">automatic</property>
-            <property name="vscrollbar_policy">automatic</property>
-            <property name="shadow_type">in</property>
-            <child>
-              <object class="GtkTreeView" id="account_page_view">
-                <property name="visible">True</property>
-                <property name="can_focus">True</property>
-                <property name="rules_hint">True</property>
-              </object>
-            </child>
-          </object>
-          <packing>
-            <property name="expand">True</property>
-            <property name="fill">True</property>
-            <property name="position">1</property>
-          </packing>
-        </child>
-        <child>
-          <object class="GtkHBox" id="hbox7609">
-            <property name="visible">True</property>
-            <property name="can_focus">False</property>
-            <child>
-              <object class="GtkLabel" id="label7610">
-                <property name="visible">True</property>
-                <property name="can_focus">False</property>
-                <property name="xalign">0</property>
-                <property name="label" translatable="yes">Matchings selected:</property>
-                <property name="wrap">True</property>
-              </object>
-              <packing>
-                <property name="expand">False</property>
-                <property name="fill">False</property>
-                <property name="position">0</property>
-              </packing>
-            </child>
-            <child>
-              <object class="GtkLabel" id="account_page_count">
-                <property name="visible">True</property>
-                <property name="can_focus">False</property>
-                <property name="xalign">0</property>
-                <property name="label">0</property>
-                <property name="wrap">True</property>
-              </object>
-              <packing>
-                <property name="expand">True</property>
-                <property name="fill">True</property>
-                <property name="padding">3</property>
-                <property name="position">1</property>
-              </packing>
-            </child>
-            <child>
-              <object class="GtkButton" id="account_page_change">
-                <property name="label" translatable="yes">Change GnuCash _Account...</property>
-                <property name="visible">True</property>
-                <property name="sensitive">False</property>
-                <property name="can_focus">True</property>
-                <property name="receives_default">True</property>
-                <property name="use_action_appearance">False</property>
-                <property name="use_underline">True</property>
-                <signal name="clicked" handler="gnc_ui_qif_import_account_rematch_cb" swapped="no"/>
-              </object>
-              <packing>
-                <property name="expand">False</property>
-                <property name="fill">False</property>
-                <property name="position">2</property>
-              </packing>
-            </child>
-          </object>
-          <packing>
-            <property name="expand">False</property>
-            <property name="fill">False</property>
-            <property name="position">2</property>
-          </packing>
-        </child>
-      </object>
-      <packing>
-        <property name="page_type">content</property>
-        <property name="title" translatable="yes">Match QIF accounts with GnuCash accounts</property>
-      </packing>
-    </child>
-    <child>
-      <object class="GtkVBox" id="category_doc_page">
-        <property name="visible">True</property>
-        <property name="can_focus">False</property>
-        <property name="border_width">12</property>
-        <child>
-          <object class="GtkLabel" id="label840">
-            <property name="visible">True</property>
-            <property name="can_focus">False</property>
-            <property name="label" translatable="yes">GnuCash uses separate Income and Expense accounts rather than categories to classify your transactions. Each of the categories in your QIF file will be converted to a GnuCash account. 
-
-On the next page, you will have an opportunity to look at the suggested matches between QIF categories and GnuCash accounts. You may change matches that you do not like by double-clicking on the line containing the category name.
-
-If you change your mind later, you can reorganize the account structure safely within GnuCash.</property>
-            <property name="wrap">True</property>
-          </object>
-          <packing>
-            <property name="expand">False</property>
-            <property name="fill">False</property>
-            <property name="position">0</property>
-          </packing>
-        </child>
-      </object>
-      <packing>
-        <property name="page_type">content</property>
-        <property name="title" translatable="yes">Income and Expense categories</property>
-      </packing>
-    </child>
-    <child>
-      <object class="GtkVBox" id="category_match_page">
-        <property name="visible">True</property>
-        <property name="can_focus">False</property>
-        <property name="border_width">12</property>
-        <child>
-          <object class="GtkLabel" id="label7611">
-            <property name="visible">True</property>
-            <property name="can_focus">False</property>
-            <property name="xalign">0</property>
-            <property name="xpad">5</property>
-            <property name="label" translatable="yes">_Select the matchings you want to change:</property>
-            <property name="use_underline">True</property>
-            <property name="mnemonic_widget">category_page_view</property>
-          </object>
-          <packing>
-            <property name="expand">False</property>
-            <property name="fill">False</property>
-            <property name="padding">5</property>
-            <property name="position">0</property>
-          </packing>
-        </child>
-        <child>
-          <object class="GtkScrolledWindow" id="scrolledwindow12">
-            <property name="visible">True</property>
-            <property name="can_focus">True</property>
-            <property name="hscrollbar_policy">automatic</property>
-            <property name="vscrollbar_policy">automatic</property>
-            <property name="shadow_type">in</property>
-            <child>
-              <object class="GtkTreeView" id="category_page_view">
-                <property name="visible">True</property>
-                <property name="can_focus">True</property>
-                <property name="rules_hint">True</property>
-              </object>
-            </child>
-          </object>
-          <packing>
-            <property name="expand">True</property>
-            <property name="fill">True</property>
-            <property name="position">1</property>
-          </packing>
-        </child>
-        <child>
-          <object class="GtkHBox" id="hbox7612">
-            <property name="visible">True</property>
-            <property name="can_focus">False</property>
-            <child>
-              <object class="GtkLabel" id="label7613">
-                <property name="visible">True</property>
-                <property name="can_focus">False</property>
-                <property name="xalign">0</property>
-                <property name="label" translatable="yes">Matchings selected:</property>
-                <property name="wrap">True</property>
-              </object>
-              <packing>
-                <property name="expand">False</property>
-                <property name="fill">False</property>
-                <property name="position">0</property>
-              </packing>
-            </child>
-            <child>
-              <object class="GtkLabel" id="category_page_count">
-                <property name="visible">True</property>
-                <property name="can_focus">False</property>
-                <property name="xalign">0</property>
-                <property name="label">0</property>
-                <property name="wrap">True</property>
-              </object>
-              <packing>
-                <property name="expand">True</property>
-                <property name="fill">True</property>
-                <property name="padding">3</property>
-                <property name="position">1</property>
-              </packing>
-            </child>
-            <child>
-              <object class="GtkButton" id="category_page_change">
-                <property name="label" translatable="yes">Change GnuCash _Account...</property>
-                <property name="visible">True</property>
-                <property name="sensitive">False</property>
-                <property name="can_focus">True</property>
-                <property name="receives_default">True</property>
-                <property name="use_action_appearance">False</property>
-                <property name="use_underline">True</property>
-                <signal name="clicked" handler="gnc_ui_qif_import_category_rematch_cb" swapped="no"/>
-              </object>
-              <packing>
-                <property name="expand">False</property>
-                <property name="fill">False</property>
-                <property name="position">2</property>
-              </packing>
-            </child>
-          </object>
-          <packing>
-            <property name="expand">False</property>
-            <property name="fill">False</property>
-            <property name="position">2</property>
-          </packing>
-        </child>
-      </object>
-      <packing>
-        <property name="page_type">content</property>
-        <property name="title" translatable="yes">Match QIF categories with GnuCash accounts</property>
-      </packing>
-    </child>
-    <child>
-      <object class="GtkVBox" id="memo_doc_page">
-        <property name="visible">True</property>
-        <property name="can_focus">False</property>
-        <property name="border_width">12</property>
-        <child>
-          <object class="GtkLabel" id="label847707">
-            <property name="visible">True</property>
-            <property name="can_focus">False</property>
-            <property name="label" translatable="yes">QIF files downloaded from banks and other financial institutions may not have information about Accounts and Categories which would allow them to be correctly assigned to GnuCash accounts. 
-
-In the following page, you will see the text that appears in the Payee and Memo fields of transactions with no QIF Account or Category. By default these transactions are assigned to the 'Unspecified' account in GnuCash. If you select a different account, it will be remembered for future QIF files. </property>
-            <property name="wrap">True</property>
-          </object>
-          <packing>
-            <property name="expand">False</property>
-            <property name="fill">False</property>
-            <property name="position">0</property>
-          </packing>
-        </child>
-      </object>
-      <packing>
-        <property name="page_type">content</property>
-        <property name="title" translatable="yes">Payees and memos</property>
-      </packing>
-    </child>
-    <child>
-      <object class="GtkVBox" id="memo_match_page">
-        <property name="visible">True</property>
-        <property name="can_focus">False</property>
-        <property name="border_width">12</property>
-        <child>
-          <object class="GtkLabel" id="label7614">
-            <property name="visible">True</property>
-            <property name="can_focus">False</property>
-            <property name="xalign">0</property>
-            <property name="xpad">5</property>
-            <property name="label" translatable="yes">_Select the matchings you want to change:</property>
-            <property name="use_underline">True</property>
-            <property name="mnemonic_widget">memo_page_view</property>
-          </object>
-          <packing>
-            <property name="expand">False</property>
-            <property name="fill">False</property>
-            <property name="padding">5</property>
-            <property name="position">0</property>
-          </packing>
-        </child>
-        <child>
-          <object class="GtkScrolledWindow" id="scrolledwindow1">
-            <property name="visible">True</property>
-            <property name="can_focus">True</property>
-            <property name="hscrollbar_policy">automatic</property>
-            <property name="vscrollbar_policy">automatic</property>
-            <property name="shadow_type">in</property>
-            <child>
-              <object class="GtkTreeView" id="memo_page_view">
-                <property name="visible">True</property>
-                <property name="can_focus">True</property>
-                <property name="rules_hint">True</property>
-              </object>
-            </child>
-          </object>
-          <packing>
-            <property name="expand">True</property>
-            <property name="fill">True</property>
-            <property name="position">1</property>
-          </packing>
-        </child>
-        <child>
-          <object class="GtkHBox" id="hbox7615">
-            <property name="visible">True</property>
-            <property name="can_focus">False</property>
-            <child>
-              <object class="GtkLabel" id="label7616">
-                <property name="visible">True</property>
-                <property name="can_focus">False</property>
-                <property name="xalign">0</property>
-                <property name="label" translatable="yes">Matchings selected:</property>
-                <property name="wrap">True</property>
-              </object>
-              <packing>
-                <property name="expand">False</property>
-                <property name="fill">False</property>
-                <property name="position">0</property>
-              </packing>
-            </child>
-            <child>
-              <object class="GtkLabel" id="memo_page_count">
-                <property name="visible">True</property>
-                <property name="can_focus">False</property>
-                <property name="xalign">0</property>
-                <property name="label">0</property>
-                <property name="wrap">True</property>
-              </object>
-              <packing>
-                <property name="expand">True</property>
-                <property name="fill">True</property>
-                <property name="padding">3</property>
-                <property name="position">1</property>
-              </packing>
-            </child>
-            <child>
-              <object class="GtkButton" id="memo_page_change">
-                <property name="label" translatable="yes">Change GnuCash _Account...</property>
-                <property name="visible">True</property>
-                <property name="sensitive">False</property>
-                <property name="can_focus">True</property>
-                <property name="receives_default">True</property>
-                <property name="use_action_appearance">False</property>
-                <property name="use_underline">True</property>
-                <signal name="clicked" handler="gnc_ui_qif_import_memo_rematch_cb" swapped="no"/>
-              </object>
-              <packing>
-                <property name="expand">False</property>
-                <property name="fill">False</property>
-                <property name="position">2</property>
-              </packing>
-            </child>
-          </object>
-          <packing>
-            <property name="expand">False</property>
-            <property name="fill">False</property>
-            <property name="position">2</property>
-          </packing>
-        </child>
-      </object>
-      <packing>
-        <property name="page_type">content</property>
-        <property name="title" translatable="yes">Match payees/memos to GnuCash accounts</property>
-      </packing>
-    </child>
-    <child>
-      <object class="GtkVBox" id="currency_book_option_page">
-        <property name="visible">True</property>
-        <property name="can_focus">False</property>
-        <property name="border_width">12</property>
-        <child>
-          <object class="GtkLabel" id="label831">
-            <property name="visible">True</property>
-            <property name="can_focus">False</property>
-            <property name="yalign">0</property>
-            <property name="label" translatable="yes">The QIF importer cannot currently handle multi-currency QIF files. All the accounts you are importing must be denominated in the same currency.
-</property>
-            <property name="justify">center</property>
-            <property name="wrap">True</property>
-          </object>
-          <packing>
-            <property name="expand">False</property>
-            <property name="fill">False</property>
-            <property name="position">0</property>
-          </packing>
-        </child>
-        <child>
-          <object class="GtkLabel" id="label832">
-            <property name="visible">True</property>
-            <property name="can_focus">False</property>
-            <property name="xalign">0</property>
-            <property name="yalign">0</property>
-            <property name="xpad">4</property>
-            <property name="label" translatable="yes">_Select the currency to use for all imported transactions:</property>
-            <property name="use_underline">True</property>
-          </object>
-          <packing>
-            <property name="expand">False</property>
-            <property name="fill">False</property>
-            <property name="padding">5</property>
-            <property name="position">1</property>
-          </packing>
-        </child>
-        <child>
-          <object class="GtkHBox" id="currency_picker_hbox">
-            <property name="visible">True</property>
-            <property name="can_focus">False</property>
-            <child>
-              <placeholder/>
-            </child>
-          </object>
-          <packing>
-            <property name="expand">False</property>
-            <property name="fill">False</property>
-            <property name="position">2</property>
-          </packing>
-        </child>
-        <child>
-          <object class="GtkLabel" id="book_option_label">
-            <property name="visible">True</property>
-            <property name="can_focus">False</property>
-            <property name="label" translatable="yes"><b>Book Options</b></property>
-            <property name="use_markup">True</property>
-          </object>
-          <packing>
-            <property name="expand">False</property>
-            <property name="fill">False</property>
-            <property name="position">3</property>
-          </packing>
-        </child>
-        <child>
-          <object class="GtkLabel" id="book_option_message_label">
-            <property name="visible">True</property>
-            <property name="can_focus">False</property>
-            <property name="label" translatable="yes">Since you are creating a new file, you will next see a dialog for setting book options. These can affect how GnuCash imports transactions. If you come back to this page without cancelling and starting over, the dialog for setting book options will not be shown a second time when you go forward. You can access it directly from the menu via File->Properties.</property>
-            <property name="wrap">True</property>
-          </object>
-          <packing>
-            <property name="expand">False</property>
-            <property name="fill">False</property>
-            <property name="position">4</property>
-          </packing>
-        </child>
-      </object>
-      <packing>
-        <property name="title" translatable="yes">Choose the QIF file currency and select Book Options</property>
-      </packing>
-    </child>
-    <child>
-      <object class="GtkVBox" id="commodity_doc_page">
-        <property name="visible">True</property>
-        <property name="can_focus">False</property>
-        <property name="border_width">12</property>
-        <child>
-          <object class="GtkLabel" id="label833">
-            <property name="visible">True</property>
-            <property name="can_focus">False</property>
-            <property name="label" translatable="yes">In the following pages you will be asked to provide information about stocks, mutual funds, and other investments that appear in the QIF file(s) you are importing. GnuCash needs some additional details about these investments that the QIF format does not provide. 
-
-Each stock, mutual fund, or other investment must have a name and an abbreviation, such as a stock symbol. Because some unrelated investments have the same abbreviation, you also need to indicate what type of abbreviation you have entered. For example, you could select the exchange that assigned the symbol (NASDAQ, NYSE, etc.), or select an investment type.
-
-If you don't see your exchange listed, or none of the available choices are appropriate, you can enter a new one.</property>
-            <property name="wrap">True</property>
-          </object>
-          <packing>
-            <property name="expand">False</property>
-            <property name="fill">False</property>
-            <property name="position">0</property>
-          </packing>
-        </child>
-      </object>
-      <packing>
-        <property name="page_type">content</property>
-        <property name="title" translatable="yes">Tradable commodities</property>
-      </packing>
-    </child>
-    <child>
-      <object class="GtkVBox" id="convert_content_page">
-        <property name="visible">True</property>
-        <property name="can_focus">False</property>
-        <property name="border_width">12</property>
-        <property name="spacing">12</property>
-        <child>
-          <object class="GtkLabel" id="convert_progress_primary">
-            <property name="visible">True</property>
-            <property name="can_focus">False</property>
-            <property name="label"><span weight="bold" size="larger">Primary text</span></property>
-            <property name="use_markup">True</property>
-            <property name="wrap">True</property>
-          </object>
-          <packing>
-            <property name="expand">False</property>
-            <property name="fill">False</property>
-            <property name="position">0</property>
-          </packing>
-        </child>
-        <child>
-          <object class="GtkLabel" id="convert_progress_secondary">
-            <property name="visible">True</property>
-            <property name="can_focus">False</property>
-            <property name="label">Secondary text.</property>
-            <property name="wrap">True</property>
-          </object>
-          <packing>
-            <property name="expand">False</property>
-            <property name="fill">False</property>
-            <property name="position">1</property>
-          </packing>
-        </child>
-        <child>
-          <object class="GtkVBox" id="convert_progress_vbox1">
-            <property name="visible">True</property>
-            <property name="can_focus">False</property>
-            <child>
-              <object class="GtkProgressBar" id="convert_progress_bar">
-                <property name="visible">True</property>
-                <property name="can_focus">False</property>
-                <property name="pulse_step">0.10000000149</property>
-              </object>
-              <packing>
-                <property name="expand">False</property>
-                <property name="fill">False</property>
-                <property name="position">0</property>
-              </packing>
-            </child>
-            <child>
-              <object class="GtkLabel" id="convert_progress_sub">
-                <property name="visible">True</property>
-                <property name="can_focus">False</property>
-                <property name="xalign">0</property>
-                <property name="label"><span style="italic">Sub-operation text</span></property>
-                <property name="use_markup">True</property>
-                <property name="wrap">True</property>
-              </object>
-              <packing>
-                <property name="expand">False</property>
-                <property name="fill">False</property>
-                <property name="position">1</property>
-              </packing>
-            </child>
-            <child>
-              <object class="GtkHButtonBox" id="convert_progress_hbuttonbox1">
-                <property name="visible">True</property>
-                <property name="can_focus">False</property>
-                <property name="layout_style">end</property>
-                <child>
-                  <object class="GtkButton" id="convert_progress_start">
-                    <property name="label" translatable="yes">_Start Import</property>
-                    <property name="visible">True</property>
-                    <property name="can_focus">True</property>
-                    <property name="receives_default">True</property>
-                    <property name="use_action_appearance">False</property>
-                    <property name="use_underline">True</property>
-                    <signal name="clicked" handler="gnc_ui_qif_import_convert_progress_start_cb" swapped="no"/>
-                  </object>
-                  <packing>
-                    <property name="expand">False</property>
-                    <property name="fill">False</property>
-                    <property name="position">0</property>
-                  </packing>
-                </child>
-                <child>
-                  <object class="GtkButton" id="convert_progress_pause">
-                    <property name="label">gtk-media-pause</property>
-                    <property name="visible">True</property>
-                    <property name="can_focus">True</property>
-                    <property name="can_default">True</property>
-                    <property name="receives_default">True</property>
-                    <property name="use_action_appearance">False</property>
-                    <property name="use_stock">True</property>
-                    <signal name="clicked" handler="gnc_ui_qif_import_convert_progress_pause_cb" swapped="no"/>
-                  </object>
-                  <packing>
-                    <property name="expand">False</property>
-                    <property name="fill">False</property>
-                    <property name="position">1</property>
-                  </packing>
-                </child>
-              </object>
-              <packing>
-                <property name="expand">False</property>
-                <property name="fill">False</property>
-                <property name="position">2</property>
-              </packing>
-            </child>
-          </object>
-          <packing>
-            <property name="expand">False</property>
-            <property name="fill">False</property>
-            <property name="padding">6</property>
-            <property name="position">2</property>
-          </packing>
-        </child>
-        <child>
-          <object class="GtkScrolledWindow" id="scrolledwindow2">
-            <property name="visible">True</property>
-            <property name="can_focus">True</property>
-            <property name="hscrollbar_policy">automatic</property>
-            <property name="vscrollbar_policy">automatic</property>
-            <property name="shadow_type">in</property>
-            <child>
-              <object class="GtkTextView" id="convert_progress_log">
-                <property name="visible">True</property>
-                <property name="can_focus">True</property>
-                <property name="editable">False</property>
-                <property name="wrap_mode">word</property>
-                <property name="cursor_visible">False</property>
-                <property name="accepts_tab">False</property>
-              </object>
-            </child>
-          </object>
-          <packing>
-            <property name="expand">True</property>
-            <property name="fill">True</property>
-            <property name="position">3</property>
-          </packing>
-        </child>
-      </object>
-      <packing>
-        <property name="title" translatable="yes">QIF Import</property>
-      </packing>
-    </child>
-    <child>
-      <object class="GtkVBox" id="duplicates_doc_page">
-        <property name="visible">True</property>
-        <property name="can_focus">False</property>
-        <property name="border_width">5</property>
-        <child>
-          <object class="GtkLabel" id="label847694">
-            <property name="visible">True</property>
-            <property name="can_focus">False</property>
-            <property name="label" translatable="yes">
-If you are importing a QIF file from a bank or other financial institution, some of the transactions may already exist in your GnuCash accounts. To avoid duplication, GnuCash has tried to identify matches and needs your help to review them.
-
-On the next page you will be shown a list of imported transactions. As you select each one, a list of possible matches will be shown below it. If you find a correct match, click on it. Your selection will be confirmed by a check mark in the "Match?" column.
-
-Click "Forward" to review the possible matches.</property>
-            <property name="wrap">True</property>
-          </object>
-          <packing>
-            <property name="expand">False</property>
-            <property name="fill">False</property>
-            <property name="position">0</property>
-          </packing>
-        </child>
-      </object>
-      <packing>
-        <property name="page_type">content</property>
-        <property name="title" translatable="yes">Match existing transactions</property>
-      </packing>
-    </child>
-    <child>
-      <object class="GtkVBox" id="duplicates_match_page">
-        <property name="visible">True</property>
-        <property name="can_focus">False</property>
-        <property name="border_width">12</property>
-        <child>
-          <object class="GtkVBox" id="vbox94">
-            <property name="visible">True</property>
-            <property name="can_focus">False</property>
-            <property name="spacing">2</property>
-            <child>
-              <object class="GtkFrame" id="frame45">
-                <property name="visible">True</property>
-                <property name="can_focus">False</property>
-                <property name="label_xalign">0</property>
-                <property name="shadow_type">none</property>
-                <child>
-                  <object class="GtkScrolledWindow" id="scrolledwindow22">
-                    <property name="visible">True</property>
-                    <property name="can_focus">True</property>
-                    <property name="hscrollbar_policy">automatic</property>
-                    <property name="vscrollbar_policy">automatic</property>
-                    <property name="shadow_type">in</property>
-                    <child>
-                      <object class="GtkTreeView" id="new_transaction_view">
-                        <property name="visible">True</property>
-                        <property name="can_focus">True</property>
-                        <property name="rules_hint">True</property>
-                      </object>
-                    </child>
-                  </object>
-                </child>
-                <child type="label">
-                  <object class="GtkLabel" id="label847716">
-                    <property name="visible">True</property>
-                    <property name="can_focus">False</property>
-                    <property name="label" translatable="yes">_Imported transactions needing review:</property>
-                    <property name="use_underline">True</property>
-                    <property name="mnemonic_widget">new_transaction_view</property>
-                  </object>
-                </child>
-              </object>
-              <packing>
-                <property name="expand">True</property>
-                <property name="fill">True</property>
-                <property name="position">0</property>
-              </packing>
-            </child>
-            <child>
-              <object class="GtkFrame" id="frame46">
-                <property name="visible">True</property>
-                <property name="can_focus">False</property>
-                <property name="label_xalign">0</property>
-                <property name="shadow_type">none</property>
-                <child>
-                  <object class="GtkScrolledWindow" id="scrolledwindow23">
-                    <property name="visible">True</property>
-                    <property name="can_focus">True</property>
-                    <property name="hscrollbar_policy">automatic</property>
-                    <property name="vscrollbar_policy">automatic</property>
-                    <property name="shadow_type">in</property>
-                    <child>
-                      <object class="GtkTreeView" id="old_transaction_view">
-                        <property name="visible">True</property>
-                        <property name="can_focus">True</property>
-                        <property name="rules_hint">True</property>
-                      </object>
-                    </child>
-                  </object>
-                </child>
-                <child type="label">
-                  <object class="GtkLabel" id="label847717">
-                    <property name="visible">True</property>
-                    <property name="can_focus">False</property>
-                    <property name="label" translatable="yes">_Possible matches for the selected transaction:</property>
-                    <property name="use_underline">True</property>
-                    <property name="mnemonic_widget">old_transaction_view</property>
-                  </object>
-                </child>
-              </object>
-              <packing>
-                <property name="expand">True</property>
-                <property name="fill">True</property>
-                <property name="position">1</property>
-              </packing>
-            </child>
-          </object>
-          <packing>
-            <property name="expand">True</property>
-            <property name="fill">True</property>
-            <property name="position">0</property>
-          </packing>
-        </child>
-      </object>
-      <packing>
-        <property name="page_type">content</property>
-        <property name="title" translatable="yes">Select possible duplicates</property>
-      </packing>
-    </child>
-    <child>
-      <object class="GtkLabel" id="end_page">
-        <property name="visible">True</property>
-        <property name="can_focus">False</property>
-        <property name="label" translatable="yes">Click "Apply" to import data from the staging area and update your GnuCash accounts. The account and category matching information you have entered will be saved and used for defaults the next time you use the QIF import facility. 
-
-Click "Back" to review your account and category matchings, to change currency and security settings for new accounts, or to add more files to the staging area.
-
-Click "Cancel" to abort the QIF import process.</property>
-        <property name="wrap">True</property>
-      </object>
-      <packing>
-        <property name="page_type">confirm</property>
-        <property name="title" translatable="yes">Update your GnuCash accounts</property>
-      </packing>
-    </child>
-    <child>
-      <object class="GtkLabel" id="summary_page">
-        <property name="visible">True</property>
-        <property name="can_focus">False</property>
-        <property name="label" translatable="yes">Summary Text</property>
-        <property name="use_markup">True</property>
-      </object>
-      <packing>
-        <property name="page_type">summary</property>
-        <property name="title" translatable="yes">Qif Import Summary</property>
-        <property name="complete">True</property>
-      </packing>
-    </child>
-  </object>
-  <object class="GtkListStore" id="currency_liststore">
-    <columns>
-      <!-- column-name item -->
-      <column type="gchararray"/>
-    </columns>
-    <data>
-      <row>
-        <col id="0" translatable="yes">Dummy</col>
-      </row>
-    </data>
-  </object>
-  <object class="GtkListStore" id="date_format_liststore">
-    <columns>
-      <!-- column-name item -->
-      <column type="gchararray"/>
-    </columns>
-    <data>
-      <row>
-        <col id="0" translatable="yes">Dummy</col>
-      </row>
-    </data>
-  </object>
-</interface>

Deleted: gnucash/trunk/src/import-export/qif-import/assistant-qif-import.h
===================================================================
--- gnucash/trunk/src/import-export/qif-import/assistant-qif-import.h	2013-12-15 17:20:10 UTC (rev 23566)
+++ gnucash/trunk/src/import-export/qif-import/assistant-qif-import.h	2013-12-15 17:21:20 UTC (rev 23567)
@@ -1,45 +0,0 @@
-/********************************************************************\
- * assistant-qif-import.h -- window for import of QIF data          *
- *                       (GnuCash)                                  *
- * Copyright (C) 2000 Bill Gribble <grib at billgribble.com>           *
- * Copyright (c) 2011 Robert Fewell                                 *
- *                                                                  *
- * This program is free software; you can redistribute it and/or    *
- * modify it under the terms of the GNU General Public License as   *
- * published by the Free Software Foundation; either version 2 of   *
- * the License, or (at your option) any later version.              *
- *                                                                  *
- * This program is distributed in the hope that it will be useful,  *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of   *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the    *
- * GNU General Public License for more details.                     *
- *                                                                  *
- * You should have received a copy of the GNU General Public License*
- * along with this program; if not, contact:                        *
- *                                                                  *
- * Free Software Foundation           Voice:  +1-617-542-5942       *
- * 51 Franklin Street, Fifth Floor    Fax:    +1-617-542-2652       *
- * Boston, MA  02110-1301,  USA       gnu at gnu.org                   *
-\********************************************************************/
-
-#ifndef ASSISTANT_QIF_IMPORT_H
-#define ASSISTANT_QIF_IMPORT_H
-
-#include <libguile.h>
-#include <gtk/gtk.h>
-
-/* QIF Import Windows ***********************************************/
-
-typedef struct _qifimportwindow QIFImportWindow;
-
-SCM               gnc_ui_qif_import_assistant_get_mappings(QIFImportWindow * w);
-
-/* The gnc_file_qif_import() routine will pop up a standard file
- *     selection dialogue asking the user to pick a QIF file. If one
- *     is selected then the QIF file is opened and read. It's contents
- *     are merged into the existing session (if any). The current
- *     session continues to remain open for editing. */
-void              gnc_file_qif_import (void);
-void              gnc_ui_qif_import_create_plugin(void);
-
-#endif

Deleted: gnucash/trunk/src/import-export/qif-import/dialog-account-picker.c
===================================================================
--- gnucash/trunk/src/import-export/qif-import/dialog-account-picker.c	2013-12-15 17:20:10 UTC (rev 23566)
+++ gnucash/trunk/src/import-export/qif-import/dialog-account-picker.c	2013-12-15 17:21:20 UTC (rev 23567)
@@ -1,424 +0,0 @@
-/********************************************************************\
- * dialog-account-picker.c -- window for picking a Gnucash account  *
- * from the QIF importer.                                           *
- * Copyright (C) 2000-2001 Bill Gribble <grib at billgribble.com>      *
- * Copyright (c) 2006 David Hampton <hampton at employees.org>         *
- *                                                                  *
- * This program is free software; you can redistribute it and/or    *
- * modify it under the terms of the GNU General Public License as   *
- * published by the Free Software Foundation; either version 2 of   *
- * the License, or (at your option) any later version.              *
- *                                                                  *
- * This program is distributed in the hope that it will be useful,  *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of   *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the    *
- * GNU General Public License for more details.                     *
- *                                                                  *
- * You should have received a copy of the GNU General Public License*
- * along with this program; if not, contact:                        *
- *                                                                  *
- * Free Software Foundation           Voice:  +1-617-542-5942       *
- * 51 Franklin Street, Fifth Floor    Fax:    +1-617-542-2652       *
- * Boston, MA  02110-1301,  USA       gnu at gnu.org                   *
-\********************************************************************/
-
-#include "config.h"
-
-#include <gtk/gtk.h>
-#include <glib/gi18n.h>
-#include <stdio.h>
-#include <libguile.h>
-
-#include "dialog-account-picker.h"
-#include "dialog-utils.h"
-#include "assistant-qif-import.h"
-#include "gnc-gui-query.h"
-#include "gnc-ui-util.h"
-#include "guile-mappings.h"
-#include "gnc-guile-utils.h"
-#include "gnc-ui.h" /* for GNC_RESPONSE_NEW */
-
-enum account_cols
-{
-    ACCOUNT_COL_NAME = 0,
-    ACCOUNT_COL_FULLNAME,
-    ACCOUNT_COL_CHECK,
-    NUM_ACCOUNT_COLS
-};
-
-struct _accountpickerdialog
-{
-    GtkWidget       * dialog;
-    GtkTreeView     * treeview;
-    QIFImportWindow * qif_wind;
-    SCM             map_entry;
-    gchar           * selected_name;
-};
-
-void gnc_ui_qif_account_picker_new_cb (GtkButton * w, gpointer user_data);
-
-/****************************************************************
- * acct_tree_add_accts
- *
- * Given a Scheme list of accounts, this function populates a
- * GtkTreeStore from them. If the search_name and reference
- * parameters are provided, and an account is found whose full
- * name matches search_name, then a GtkTreeRowReference* will be
- * returned in the reference parameter.
- ****************************************************************/
-static void
-acct_tree_add_accts(SCM accts,
-                    GtkTreeStore *store,
-                    GtkTreeIter *parent,
-                    const char *base_name,
-                    const char *search_name,
-                    GtkTreeRowReference **reference)
-{
-    GtkTreeIter  iter;
-    char         * compname;
-    char         * acctname;
-    gboolean     leafnode;
-    SCM          current;
-    gboolean     checked;
-
-    while (!scm_is_null(accts))
-    {
-        current = SCM_CAR(accts);
-
-        if (scm_is_null(current))
-        {
-            g_critical("QIF import: BUG DETECTED in acct_tree_add_accts!");
-            accts = SCM_CDR(accts);
-            continue;
-        }
-
-        if (scm_is_string(SCM_CAR(current)))
-            compname = gnc_scm_to_utf8_string (SCM_CAR(current));
-        else
-            compname = g_strdup("");
-
-        if (!scm_is_null(SCM_CADDR(current)))
-        {
-            leafnode = FALSE;
-        }
-        else
-        {
-            leafnode = TRUE;
-        }
-
-        /* compute full name */
-        if (base_name && *base_name)
-        {
-            acctname = g_strjoin(gnc_get_account_separator_string(),
-                                 base_name, compname, (char *)NULL);
-        }
-        else
-        {
-            acctname = g_strdup(compname);
-        }
-
-        checked = (SCM_CADR(current) == SCM_BOOL_T);
-
-        gtk_tree_store_append(store, &iter, parent);
-        gtk_tree_store_set(store, &iter,
-                           ACCOUNT_COL_NAME, compname,
-                           ACCOUNT_COL_FULLNAME, acctname,
-                           ACCOUNT_COL_CHECK, checked,
-                           -1);
-
-        if (reference && !*reference &&
-                search_name && (g_utf8_collate(search_name, acctname) == 0))
-        {
-            GtkTreePath *path = gtk_tree_model_get_path(GTK_TREE_MODEL(store), &iter);
-            *reference = gtk_tree_row_reference_new(GTK_TREE_MODEL(store), path);
-            gtk_tree_path_free(path);
-        }
-
-        if (!leafnode)
-        {
-            acct_tree_add_accts(SCM_CADDR(current), store, &iter, acctname,
-                                search_name, reference);
-        }
-
-        g_free(acctname);
-        g_free(compname);
-
-        accts = SCM_CDR(accts);
-    }
-}
-
-
-/****************************************************************
- * build_acct_tree
- *
- * This function refreshes the contents of the account tree.
- ****************************************************************/
-static void
-build_acct_tree(QIFAccountPickerDialog * picker, QIFImportWindow * import)
-{
-    SCM  get_accts = scm_c_eval_string("qif-import:get-all-accts");
-    SCM  acct_tree;
-    GtkTreeStore *store;
-    GtkTreePath *path;
-    GtkTreeSelection* selection;
-    GtkTreeRowReference *reference = NULL;
-    gchar *name_to_select;
-
-    g_return_if_fail(picker && import);
-
-    /* Get an account tree with all existing and to-be-imported accounts. */
-    acct_tree = scm_call_1(get_accts,
-                           gnc_ui_qif_import_assistant_get_mappings(import));
-
-    /* Rebuild the store.
-     * NOTE: It is necessary to save a copy of the name to select, because
-     *       when the store is cleared, everything becomes unselected. */
-    name_to_select = g_strdup(picker->selected_name);
-    store = GTK_TREE_STORE(gtk_tree_view_get_model(picker->treeview));
-    gtk_tree_store_clear(store);
-    acct_tree_add_accts(acct_tree, store, NULL, NULL, name_to_select, &reference);
-    g_free(name_to_select);
-
-    /* Select and display the indicated account (if it was found). */
-    if (reference)
-    {
-        selection = gtk_tree_view_get_selection(picker->treeview);
-        path = gtk_tree_row_reference_get_path(reference);
-        if (path)
-        {
-            gtk_tree_view_expand_to_path(picker->treeview, path);
-            gtk_tree_selection_select_path(selection, path);
-            gtk_tree_path_free(path);
-        }
-        gtk_tree_row_reference_free(reference);
-    }
-}
-
-
-/****************************************************************
- * gnc_ui_qif_account_picker_new_cb
- *
- * This handler is invoked when the user wishes to create a new
- * account.
- ****************************************************************/
-void
-gnc_ui_qif_account_picker_new_cb(GtkButton * w, gpointer user_data)
-{
-    QIFAccountPickerDialog * wind = user_data;
-    SCM name_setter = scm_c_eval_string("qif-map-entry:set-gnc-name!");
-    const gchar *name;
-    int response;
-    gchar *fullname;
-    GtkWidget *dlg, *entry;
-
-    /* Create a dialog to get the new account name. */
-    dlg = gtk_message_dialog_new(GTK_WINDOW(wind->dialog),
-                                 GTK_DIALOG_DESTROY_WITH_PARENT,
-                                 GTK_MESSAGE_QUESTION,
-                                 GTK_BUTTONS_OK_CANCEL,
-                                 "%s", _("Enter a name for the account"));
-    gtk_dialog_set_default_response(GTK_DIALOG(dlg), GTK_RESPONSE_OK);
-    entry = gtk_entry_new();
-    gtk_entry_set_activates_default(GTK_ENTRY(entry), TRUE);
-    gtk_entry_set_max_length(GTK_ENTRY(entry), 250);
-    gtk_widget_show(entry);
-    gtk_container_add(GTK_CONTAINER(GTK_DIALOG(dlg)->vbox), entry);
-
-    /* Run the dialog to get the new account name. */
-    response = gtk_dialog_run(GTK_DIALOG(dlg));
-    name = gtk_entry_get_text(GTK_ENTRY(entry));
-
-    /* Did the user enter a name and click OK? */
-    if (response == GTK_RESPONSE_OK && name && *name)
-    {
-        /* If an account is selected, this will be a new subaccount. */
-        if (wind->selected_name && *(wind->selected_name))
-            /* We have the short name; determine the full name. */
-            fullname = g_strjoin(gnc_get_account_separator_string(),
-                                 wind->selected_name, name, (char *)NULL);
-        else
-            fullname = g_strdup(name);
-
-        /* Save the full name and update the map entry. */
-        g_free(wind->selected_name);
-        wind->selected_name = fullname;
-        scm_call_2(name_setter, wind->map_entry, scm_from_utf8_string(fullname));
-    }
-    gtk_widget_destroy(dlg);
-
-    /* Refresh the tree display and give it the focus. */
-    build_acct_tree(wind, wind->qif_wind);
-    gtk_widget_grab_focus(GTK_WIDGET(wind->treeview));
-}
-
-
-/****************************************************************
- * gnc_ui_qif_account_picker_changed_cb
- *
- ****************************************************************/
-static void
-gnc_ui_qif_account_picker_changed_cb(GtkTreeSelection *selection,
-                                     gpointer          user_data)
-{
-    QIFAccountPickerDialog * wind = user_data;
-    SCM name_setter = scm_c_eval_string("qif-map-entry:set-gnc-name!");
-    GtkTreeModel *model;
-    GtkTreeIter iter;
-
-    g_free(wind->selected_name);
-    if (gtk_tree_selection_get_selected(selection, &model, &iter))
-    {
-        gtk_tree_model_get(model, &iter,
-                           ACCOUNT_COL_FULLNAME, &wind->selected_name,
-                           -1);
-        scm_call_2(name_setter, wind->map_entry,
-                   wind->selected_name ? scm_from_utf8_string(wind->selected_name) : SCM_BOOL_F);
-    }
-    else
-    {
-        wind->selected_name = NULL;
-    }
-}
-
-
-/****************************************************************
- * gnc_ui_qif_account_picker_row_activated_cb
- *
- ****************************************************************/
-static void
-gnc_ui_qif_account_picker_row_activated_cb(GtkTreeView *view,
-        GtkTreePath *path,
-        GtkTreeViewColumn *column,
-        gpointer user_data)
-{
-    QIFAccountPickerDialog *wind = user_data;
-    g_return_if_fail(wind);
-
-    gtk_dialog_response(GTK_DIALOG(wind->dialog), GTK_RESPONSE_OK);
-}
-
-
-/****************************************************************
- * gnc_ui_qif_account_picker_map_cb
- *
- ****************************************************************/
-static int
-gnc_ui_qif_account_picker_map_cb(GtkWidget * w, gpointer user_data)
-{
-    QIFAccountPickerDialog * wind = user_data;
-
-    /* update the tree display with all the existing accounts plus all
-     * the ones the QIF importer thinks it will be creating.  this will
-     * also select the map_entry line. */
-    build_acct_tree(wind, wind->qif_wind);
-    return FALSE;
-}
-
-
-/****************************************************************
- * qif_account_picker_dialog
- *
- * Select an account from the ones that the engine knows about,
- * plus those that will be created by the QIF import.  If the
- * user clicks OK, map_entry is changed and TRUE is returned.
- * If the clicks Cancel instead, FALSE is returned. Modal.
- ****************************************************************/
-gboolean
-qif_account_picker_dialog(QIFImportWindow * qif_wind, SCM map_entry)
-{
-    QIFAccountPickerDialog * wind;
-    SCM gnc_name     = scm_c_eval_string("qif-map-entry:gnc-name");
-    SCM set_gnc_name = scm_c_eval_string("qif-map-entry:set-gnc-name!");
-    SCM orig_acct    = scm_call_1(gnc_name, map_entry);
-    int response;
-    GtkBuilder *builder;
-    GtkWidget *button;
-
-    wind = g_new0(QIFAccountPickerDialog, 1);
-
-    /* Save the map entry. */
-    wind->map_entry = map_entry;
-    scm_gc_protect_object(wind->map_entry);
-
-    /* Set the initial account to be selected. */
-    if (scm_is_string(orig_acct))
-        wind->selected_name = gnc_scm_to_utf8_string (orig_acct);
-
-    builder = gtk_builder_new();
-    gnc_builder_add_from_file (builder, "dialog-account-picker.glade", "QIF Import Account Picker");
-
-    /* Connect all the signals */
-    gtk_builder_connect_signals (builder, wind);
-
-    wind->dialog     = GTK_WIDGET(gtk_builder_get_object (builder, "QIF Import Account Picker"));
-    wind->treeview   = GTK_TREE_VIEW(gtk_builder_get_object (builder, "account_tree"));
-    wind->qif_wind   = qif_wind;
-
-    {
-        GtkTreeStore *store;
-        GtkCellRenderer *renderer;
-        GtkTreeViewColumn *column;
-        GtkTreeSelection *selection;
-
-        store = gtk_tree_store_new(NUM_ACCOUNT_COLS, G_TYPE_STRING, G_TYPE_STRING,
-                                   G_TYPE_BOOLEAN);
-        gtk_tree_view_set_model(wind->treeview, GTK_TREE_MODEL(store));
-        g_object_unref(store);
-
-        renderer = gtk_cell_renderer_text_new();
-        column = gtk_tree_view_column_new_with_attributes(_("Account"),
-                 renderer,
-                 "text",
-                 ACCOUNT_COL_NAME,
-                 NULL);
-        g_object_set(column, "expand", TRUE, NULL);
-        gtk_tree_view_append_column(wind->treeview, column);
-
-        renderer = gtk_cell_renderer_toggle_new();
-        g_object_set(renderer, "activatable", FALSE, NULL);
-        column = gtk_tree_view_column_new_with_attributes(_("New?"),
-                 renderer,
-                 "active",
-                 ACCOUNT_COL_CHECK,
-                 NULL);
-        gtk_tree_view_append_column(wind->treeview, column);
-
-        selection = gtk_tree_view_get_selection(wind->treeview);
-        g_signal_connect(selection, "changed",
-                         G_CALLBACK(gnc_ui_qif_account_picker_changed_cb), wind);
-        g_signal_connect(wind->treeview, "row-activated",
-                         G_CALLBACK(gnc_ui_qif_account_picker_row_activated_cb),
-                         wind);
-    }
-
-    g_signal_connect_after(wind->dialog, "map",
-                           G_CALLBACK(gnc_ui_qif_account_picker_map_cb),
-                           wind);
-
-    button =  GTK_WIDGET(gtk_builder_get_object (builder, "newbutton"));
-    gtk_button_set_use_stock(GTK_BUTTON(button), TRUE);
-
-    /* this is to get the checkmarks set up right.. it will get called
-     * again after the window is mapped. */
-    build_acct_tree(wind, wind->qif_wind);
-
-    do
-    {
-        response = gtk_dialog_run(GTK_DIALOG(wind->dialog));
-    }
-    while (response == GNC_RESPONSE_NEW);
-    gtk_widget_destroy(wind->dialog);
-    g_object_unref(G_OBJECT(builder));
-
-    scm_gc_unprotect_object(wind->map_entry);
-    g_free(wind->selected_name);
-    g_free(wind);
-
-    if (response == GTK_RESPONSE_OK)
-        return TRUE;
-
-    /* Restore the original mapping. */
-    scm_call_2(set_gnc_name, map_entry, orig_acct);
-
-    return FALSE;
-}

Deleted: gnucash/trunk/src/import-export/qif-import/dialog-account-picker.glade
===================================================================
--- gnucash/trunk/src/import-export/qif-import/dialog-account-picker.glade	2013-12-15 17:20:10 UTC (rev 23566)
+++ gnucash/trunk/src/import-export/qif-import/dialog-account-picker.glade	2013-12-15 17:21:20 UTC (rev 23567)
@@ -1,315 +0,0 @@
-<?xml version="1.0"?>
-<interface>
-  <requires lib="gtk+" version="2.16"/>
-  <!-- interface-naming-policy project-wide -->
-  <object class="GtkWindow" id="Preferences">
-    <property name="visible">True</property>
-    <property name="can_focus">False</property>
-    <property name="title" translatable="yes">Preferences</property>
-    <child>
-      <object class="GtkTable" id="prefs_table">
-        <property name="visible">True</property>
-        <property name="can_focus">False</property>
-        <property name="n_rows">7</property>
-        <property name="n_columns">4</property>
-        <child>
-          <object class="GtkLabel" id="label847718">
-            <property name="visible">True</property>
-            <property name="can_focus">False</property>
-            <property name="xalign">0</property>
-            <property name="label" translatable="yes"><b>QIF Import</b></property>
-            <property name="use_markup">True</property>
-          </object>
-          <packing>
-            <property name="x_options">GTK_FILL</property>
-            <property name="y_options"></property>
-          </packing>
-        </child>
-        <child>
-          <object class="GtkCheckButton" id="pref/dialogs.import.qif/show-doc">
-            <property name="label" translatable="yes">_Show documentation</property>
-            <property name="visible">True</property>
-            <property name="can_focus">True</property>
-            <property name="receives_default">False</property>
-            <property name="has_tooltip">True</property>
-            <property name="tooltip_markup">Show some documentation-only pages in QIF Import assistant.</property>
-            <property name="tooltip_text" translatable="yes">Show some documentation-only pages in QIF Import assistant.</property>
-            <property name="use_action_appearance">False</property>
-            <property name="use_underline">True</property>
-            <property name="draw_indicator">True</property>
-          </object>
-          <packing>
-            <property name="right_attach">4</property>
-            <property name="top_attach">1</property>
-            <property name="bottom_attach">2</property>
-            <property name="x_options">GTK_FILL</property>
-            <property name="y_options"></property>
-            <property name="x_padding">12</property>
-          </packing>
-        </child>
-        <child>
-          <object class="GtkRadioButton" id="pref/dialogs.import.qif/default-status-reconciled">
-            <property name="label" translatable="yes">_Reconciled</property>
-            <property name="visible">True</property>
-            <property name="can_focus">True</property>
-            <property name="receives_default">False</property>
-            <property name="has_tooltip">True</property>
-            <property name="tooltip_markup">When the status is not specified in a QIF file, the transactions are marked as reconciled.</property>
-            <property name="tooltip_text" translatable="yes">When the status is not specified in a QIF file, the transactions are marked as reconciled.</property>
-            <property name="use_action_appearance">False</property>
-            <property name="use_underline">True</property>
-            <property name="active">True</property>
-            <property name="draw_indicator">True</property>
-          </object>
-          <packing>
-            <property name="top_attach">6</property>
-            <property name="bottom_attach">7</property>
-            <property name="x_options">GTK_FILL</property>
-            <property name="y_options"></property>
-            <property name="x_padding">12</property>
-          </packing>
-        </child>
-        <child>
-          <object class="GtkRadioButton" id="pref/dialogs.import.qif/default-status-cleared">
-            <property name="label" translatable="yes">_Cleared</property>
-            <property name="visible">True</property>
-            <property name="can_focus">True</property>
-            <property name="receives_default">False</property>
-            <property name="has_tooltip">True</property>
-            <property name="tooltip_markup">When the status is not specified in a QIF file, the transactions are marked as cleared.</property>
-            <property name="tooltip_text" translatable="yes">When the status is not specified in a QIF file, the transactions are marked as cleared.</property>
-            <property name="use_action_appearance">False</property>
-            <property name="use_underline">True</property>
-            <property name="draw_indicator">True</property>
-            <property name="group">pref/dialogs.import.qif/default-status-reconciled</property>
-          </object>
-          <packing>
-            <property name="top_attach">5</property>
-            <property name="bottom_attach">6</property>
-            <property name="x_options">GTK_FILL</property>
-            <property name="y_options"></property>
-            <property name="x_padding">12</property>
-          </packing>
-        </child>
-        <child>
-          <object class="GtkRadioButton" id="pref/dialogs.import.qif/default-status-notcleared">
-            <property name="label" translatable="yes">_Not cleared</property>
-            <property name="visible">True</property>
-            <property name="can_focus">True</property>
-            <property name="receives_default">True</property>
-            <property name="has_tooltip">True</property>
-            <property name="tooltip_markup">When the status is not specified in a QIF file, the transactions are marked as not cleared.</property>
-            <property name="tooltip_text" translatable="yes">When the status is not specified in a QIF file, the transactions are marked as not cleared.</property>
-            <property name="use_action_appearance">False</property>
-            <property name="use_underline">True</property>
-            <property name="draw_indicator">True</property>
-            <property name="group">pref/dialogs.import.qif/default-status-reconciled</property>
-          </object>
-          <packing>
-            <property name="top_attach">4</property>
-            <property name="bottom_attach">5</property>
-            <property name="x_options">GTK_FILL</property>
-            <property name="y_options"></property>
-            <property name="x_padding">12</property>
-          </packing>
-        </child>
-        <child>
-          <object class="GtkLabel" id="qif_default_transation_status">
-            <property name="visible">True</property>
-            <property name="can_focus">False</property>
-            <property name="xalign">0</property>
-            <property name="xpad">16</property>
-            <property name="ypad">5</property>
-            <property name="label" translatable="yes">Default transaction status (overridden by the status given by the QIF file)</property>
-          </object>
-          <packing>
-            <property name="right_attach">4</property>
-            <property name="top_attach">2</property>
-            <property name="bottom_attach">3</property>
-            <property name="x_options">GTK_FILL</property>
-            <property name="y_options"></property>
-          </packing>
-        </child>
-        <child>
-          <placeholder/>
-        </child>
-        <child>
-          <placeholder/>
-        </child>
-        <child>
-          <placeholder/>
-        </child>
-        <child>
-          <placeholder/>
-        </child>
-        <child>
-          <placeholder/>
-        </child>
-        <child>
-          <placeholder/>
-        </child>
-        <child>
-          <placeholder/>
-        </child>
-        <child>
-          <placeholder/>
-        </child>
-        <child>
-          <placeholder/>
-        </child>
-        <child>
-          <placeholder/>
-        </child>
-        <child>
-          <placeholder/>
-        </child>
-        <child>
-          <placeholder/>
-        </child>
-        <child>
-          <placeholder/>
-        </child>
-        <child>
-          <placeholder/>
-        </child>
-        <child>
-          <placeholder/>
-        </child>
-        <child>
-          <placeholder/>
-        </child>
-      </object>
-    </child>
-  </object>
-  <object class="GtkDialog" id="QIF Import Account Picker">
-    <property name="visible">True</property>
-    <property name="can_focus">False</property>
-    <property name="title" translatable="yes">Select Account</property>
-    <property name="default_width">300</property>
-    <property name="default_height">400</property>
-    <property name="type_hint">dialog</property>
-    <child internal-child="vbox">
-      <object class="GtkVBox" id="dialog-vbox1">
-        <property name="visible">True</property>
-        <property name="can_focus">False</property>
-        <property name="spacing">8</property>
-        <child internal-child="action_area">
-          <object class="GtkHButtonBox" id="dialog-action_area1">
-            <property name="visible">True</property>
-            <property name="can_focus">False</property>
-            <property name="layout_style">end</property>
-            <child>
-              <object class="GtkButton" id="newbutton">
-                <property name="label">gnc-new-account</property>
-                <property name="visible">True</property>
-                <property name="can_focus">True</property>
-                <property name="can_default">True</property>
-                <property name="receives_default">True</property>
-                <property name="use_action_appearance">False</property>
-                <property name="use_underline">True</property>
-                <signal name="clicked" handler="gnc_ui_qif_account_picker_new_cb" swapped="no"/>
-              </object>
-              <packing>
-                <property name="expand">False</property>
-                <property name="fill">False</property>
-                <property name="position">0</property>
-              </packing>
-            </child>
-            <child>
-              <object class="GtkButton" id="cancelbutton">
-                <property name="label">gtk-cancel</property>
-                <property name="visible">True</property>
-                <property name="can_focus">True</property>
-                <property name="can_default">True</property>
-                <property name="receives_default">True</property>
-                <property name="use_action_appearance">False</property>
-                <property name="use_stock">True</property>
-              </object>
-              <packing>
-                <property name="expand">False</property>
-                <property name="fill">False</property>
-                <property name="position">1</property>
-              </packing>
-            </child>
-            <child>
-              <object class="GtkButton" id="okbutton">
-                <property name="label">gtk-ok</property>
-                <property name="visible">True</property>
-                <property name="can_focus">True</property>
-                <property name="can_default">True</property>
-                <property name="receives_default">True</property>
-                <property name="use_action_appearance">False</property>
-                <property name="use_stock">True</property>
-              </object>
-              <packing>
-                <property name="expand">False</property>
-                <property name="fill">False</property>
-                <property name="position">2</property>
-              </packing>
-            </child>
-          </object>
-          <packing>
-            <property name="expand">False</property>
-            <property name="fill">False</property>
-            <property name="pack_type">end</property>
-            <property name="position">0</property>
-          </packing>
-        </child>
-        <child>
-          <object class="GtkVBox" id="vbox2">
-            <property name="visible">True</property>
-            <property name="can_focus">False</property>
-            <child>
-              <object class="GtkLabel" id="label1">
-                <property name="visible">True</property>
-                <property name="can_focus">False</property>
-                <property name="xalign">0</property>
-                <property name="xpad">5</property>
-                <property name="label" translatable="yes">_Select or add a GnuCash account:</property>
-                <property name="use_underline">True</property>
-                <property name="mnemonic_widget">account_tree</property>
-              </object>
-              <packing>
-                <property name="expand">False</property>
-                <property name="fill">False</property>
-                <property name="padding">5</property>
-                <property name="position">0</property>
-              </packing>
-            </child>
-            <child>
-              <object class="GtkScrolledWindow" id="scrolledwindow24">
-                <property name="visible">True</property>
-                <property name="can_focus">True</property>
-                <property name="hscrollbar_policy">automatic</property>
-                <property name="vscrollbar_policy">automatic</property>
-                <property name="shadow_type">in</property>
-                <child>
-                  <object class="GtkTreeView" id="account_tree">
-                    <property name="visible">True</property>
-                    <property name="can_focus">True</property>
-                    <property name="rules_hint">True</property>
-                  </object>
-                </child>
-              </object>
-              <packing>
-                <property name="expand">True</property>
-                <property name="fill">True</property>
-                <property name="position">1</property>
-              </packing>
-            </child>
-          </object>
-          <packing>
-            <property name="expand">True</property>
-            <property name="fill">True</property>
-            <property name="position">2</property>
-          </packing>
-        </child>
-      </object>
-    </child>
-    <action-widgets>
-      <action-widget response="1">newbutton</action-widget>
-      <action-widget response="-6">cancelbutton</action-widget>
-      <action-widget response="-5">okbutton</action-widget>
-    </action-widgets>
-  </object>
-</interface>

Deleted: gnucash/trunk/src/import-export/qif-import/dialog-account-picker.h
===================================================================
--- gnucash/trunk/src/import-export/qif-import/dialog-account-picker.h	2013-12-15 17:20:10 UTC (rev 23566)
+++ gnucash/trunk/src/import-export/qif-import/dialog-account-picker.h	2013-12-15 17:21:20 UTC (rev 23567)
@@ -1,35 +0,0 @@
-/********************************************************************\
- * dialog-account-picker.h -- window for picking a GNUcash account  *
- *                       (GnuCash)                                  *
- * Copyright (C) 2000 Bill Gribble <grib at billgribble.com>           *
- *                                                                  *
- * This program is free software; you can redistribute it and/or    *
- * modify it under the terms of the GNU General Public License as   *
- * published by the Free Software Foundation; either version 2 of   *
- * the License, or (at your option) any later version.              *
- *                                                                  *
- * This program is distributed in the hope that it will be useful,  *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of   *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the    *
- * GNU General Public License for more details.                     *
- *                                                                  *
- * You should have received a copy of the GNU General Public License*
- * along with this program; if not, contact:                        *
- *                                                                  *
- * Free Software Foundation           Voice:  +1-617-542-5942       *
- * 51 Franklin Street, Fifth Floor    Fax:    +1-617-542-2652       *
- * Boston, MA  02110-1301,  USA       gnu at gnu.org                   *
-\********************************************************************/
-
-#ifndef DIALOG_ACCOUNT_PICKER_H
-#define DIALOG_ACCOUNT_PICKER_H
-
-#include <libguile.h>
-
-#include "assistant-qif-import.h"
-
-gboolean qif_account_picker_dialog(QIFImportWindow * wind, SCM initial_sel);
-
-typedef struct _accountpickerdialog QIFAccountPickerDialog;
-
-#endif

Deleted: gnucash/trunk/src/import-export/qif-import/file-format.txt
===================================================================
--- gnucash/trunk/src/import-export/qif-import/file-format.txt	2013-12-15 17:20:10 UTC (rev 23566)
+++ gnucash/trunk/src/import-export/qif-import/file-format.txt	2013-12-15 17:21:20 UTC (rev 23567)
@@ -1,410 +0,0 @@
-QIF file format
----------------
-The QIF is an old and rather broken file format defined by Intuit
-for exporting Quicken data.  It is 'broken' because the format
-is ambiguous in many places, non-standard between different releases
-and applications, and even varies subtly from country to country (in
-particular, the way dates and amounts are represented), and fails
-to define important data (such as the currency denomination, or the
-exchange rates when transferring between accounts marked in different
-currencies).  Importing a QIF file can require significant manual
-intervention by the user in order to get the data straight.
-
-
-Extensions
-----------
-TEF -- Time and Expense Format (see below)
-
-QFX -- also known as 'Web Connect' --  very similar, and is the
-       'new' standard for on-line bank statement downloads.
-       (??? or is it just 'ofx in a file' ???)
-
-
-Type of account identifiers
-----------------------------
-!Type:Bank     Bank account
-!Type:Bill     ??? (bill presentment ???)
-!Type:Cash     Cash account
-!Type:CCard    Credit Card account
-!Type:Invoice  ??? (invoice presentment ???)
-!Type:Invst    Investment account
-!Type:Oth A    Asset account
-!Type:Oth S    Asset account (German)
-!Type:Oth L    Liability account
-!Type:Tax      ???
-
-!Account         Account list or which account applies to following
-                 transactions
-
-!Type:Cat        Category list
-!Type:Class      Class list
-!Type:Memorized  Memorized transaction list
-
-Note that !Account is used both to be a header for account information,
-and to be a header for a list of transactions.
-
-Also note that international versions of Quicken and MS Money often
-translate the Type: tags into the local language.  But not always.
-
-
-Account Information Format
---------------------------
-The below typically follow an !Account identifier, and provide account
-data.
-
-Letter Definition
-N      Name
-T      Type of account
-D      Description
-L      Credit limit (only for credit card accounts)
-/      Statement balance date
-$      Statement balance amount
-^      End of entry
-
-
-Category Information Format
----------------------------
-N      Category name:subcategory name
-D      Description
-T      Tax related if included, not tax related if omitted
-I      Income category
-E      Expense category (if category type is unspecified,
-       assumes expense type)
-B      Budget amount (optional, only appears in a Budget QIF file)
-R      Tax schedule information
-^      End of entry
-
-
-Class Information Format
-------------------------
-N      Class name
-D      Description
-^      End of entry
-
-
-Memorized Transaction Format
-----------------------------
-KC     Check transaction
-KD     Deposit transaction
-KP     Payment transaction
-KI     Investment transaction
-KE     Electronic payee transaction
-T      Amount
-C      Cleared status
-P      Payee
-M      Memo
-A      Address
-L      Category or Transfer/Class
-S      Category/class in split
-E      Memo in split
-$      Dollar amount of split
-1      Amortization: First payment date
-2      Amortization: Total years for loan
-3      Amortization: Number of payments already made
-4      Amortization: Number of periods per year
-5      Amortization: Interest rate
-6      Amortization: Current loan balance
-7      Amortization: Original loan amount
-^      End of entry
-
-Note that the K* entries must be the *last* entries in the transaction.
-All fields are optional.  If this is an amortization record, then all
-seven amortization fields much be present.
-
-
-Investment transaction format
------------------------------
-Letter Definition
-D      Date (optional)
-N      Action
-Y      Security
-I      Price
-Q      Quantity (# of shares or split ratio)
-C      Cleared status
-P      first line text for transfers/reminders
-M      Memo
-O      Commission
-L      Account for transfer
-       (category/class or transfer/class)
-       (For MiscIncX or MiscExpX actions, this will be
-       category/class|transfer/class or |transfer/class)
-T      Amount of transaction
-U      Amount of transaction (higher possible value than T)
-$      Amount transferred
-^      End of entry
-
-Note that numbers for investment transactions are positive in most
-cases.  The importation process automatically takes care of negating
-the values for Actions that move funds out of an account (for example:
-sales, expenses and transfers).
-
-Be aware that GnuCash's file format stores the share quantity and the
-total value of the transaction.  Prices are not stored.
-
-
-Non-investment transaction format
----------------------------------
-Letter Definition
-D      Date
-T      Amount
-U      Transaction amount (higher possible value than T)
-C      Cleared status
-N      Number (check or reference number)
-P      Payee/description
-M      Memo
-A      Address (up to 5 lines; 6th line is an optional message)
-L      Category (category/class or transfer/class)
-
-S      Category in split (category/class or transfer/class)
-E      Memo in split
-$      Dollar amount of split
-%      Percentage of split if percentages are used
-F      Reimbursable business expense flag
-X      Small Business extensions
-^      End of entry
-
-Note that S,E and $ lines are repeated as needed for splits.
-
-
-Time and Expense Format
------------------------
-The following QIF extension added by Iambic Software
-to handle time and expense tracking.  This is used in particular
-by handhelds (Palm and WinCE).  TEF is claimed to be a superset
-of the QIF format.
-
-TEF Files begin with the header:
-#TEF VERSION X.YYY
-Documented below is version 1.01
-
-#      Any line beginning with # is a comment and not parsed
-B      City
-F      Reported
-H      Report #
-J      Attendees
-K      Reimbursable
-R      Receipt
-U      Begin Odometer
-V      End Odometer
-W      Private
-X      Exchange Rate
-Z      User
-
-1      Client
-2      Project
-3      Activity
-4      Expense Type
-5      Account
-6      Vehicle
-7      Currency
-8      Task
-9      (not used)
-0      (not used)
-
-@      Billing Code
-!      Tax Amount
-%      Uses Splits
-(      SalesTaxRate1
-)      SalesTaxRate2
-=      Flat Fee Amount
-\      Status1
-/      Status2
-&      Status3
-<      Status4
->      Status5
-?      Keyword: TIME, EXPENSE, CLIENT, PROJECT, ACTIVITY, TYPE,
-       TASK, VEHICLE, PAYEE, CURRENCY. If absent, entry is
-       assumed EXPENSE type as compatible with QIF
-
-*      Duration hh:mm:ss
-
-+      Timer On
-[      Start time
-]      End Time
-{      TimerLastStoppedAt
-}      (not used)
-|      Notes
-
-
-When importing type CLIENT, PROJECT, ACTIVITY, TYPE, TASK, VEHICLE,
-PAYEE, CURRENCY the following are used:
-
-N      Name
-C      Code
-R      Rate
-L      Link
-W      Private
-
-
-=====================================================================
-General Notes
-=====================================================================
-
-Dates
------
-Dates in US QIF files are usually in the format MM/DD/YY, although
-four-digit years are not uncommon.  Dates sometimes occur without the
-slash separator, or using other separators in place of the slash,
-commonly '-' and '.'.  US Quicken seems to be using the ' to indicate
-post-2000 two-digit years (such as 01/01'00 for Jan 1 2000).  Some
-banks appear to be using a completely undifferentiated numeric string
-formateed YYYYMMDD in downloaded QIF files.
-
-European QIF files may have dates in the DD/MM/YY format.
-
-
-Monetary Amounts
-----------------
-These typically occur in either US or European format:
-
-10,000.00  Ten Thousand Dollars (US format)
-10.000,00  Ten Thousand Francs  (European format)
-
-An apostrophe is also used in some cases:
-
-10'000.00  Ten Thousand Dollars (Quicken 4)
-10'000,00  Ten Thousand Francs  (unconfirmed)
-
-Within a given QIF file, the usage of a particular numeric format
-appears to be consistent within a particular field but may be
-different from one field to another.  For example, the Share Amount
-field can be in European format but the Split Amount in US.  No
-radix-point is required and no limit on decimal places is evident, so
-it's possible to see the number "1,000" meaning "1 franc per share"
-"1,000" meaning "one thousand shares" in the same transaction (!).
-
-
-Investment Actions
-------------------
-The N line of investment transactions specifies the "action" of the
-transaction. Although not a complete list, possible values include
-the following:
-
-QIF N Line    Notes
-============  =====
-Aktab         Same as ShrsOut.
-AktSplit      Same as StkSplit.
-Aktzu         Same as ShrsIn.
-Buy           Buy shares.
-BuyX          Buy shares. Used with an L line.
-Cash          Miscellaneous cash transaction. Used with an L line.
-CGMid         Mid-term capital gains.
-CGMidX        Mid-term capital gains. For use with an L line.
-CGLong        Long-term capital gains.
-CGLongX       Long-term capital gains. For use with an L line.
-CGShort       Short-term capital gains.
-CGShortX      Short-term capital gains. For use with an L line.
-ContribX      Same as XIn. Used for tax-advantaged accounts.
-CvrShrt       Buy shares to cover a short sale.
-CvrShrtX      Buy shares to cover a short sale. Used with an L line.
-Div           Dividend received.
-DivX          Dividend received. For use with an L line.
-Errinerg      Same as Reminder.
-Exercise      Exercise an option.
-ExercisX      Exercise an option. For use with an L line.
-Expire        Mark an option as expired. (Uses D, N, Y & M lines)
-Grant         Receive a grant of stock options.
-Int           Same as IntInc.
-IntX          Same as IntIncX.
-IntInc        Interest received.
-IntIncX       Interest received. For use with an L line.
-K.gewsp       Same as CGShort. (German)
-K.gewspX      Same as CGShortX. (German)
-Kapgew        Same as CGLong. Kapitalgewinnsteuer.(German)
-KapgewX       Same as CGLongX. Kapitalgewinnsteuer. (German)
-Kauf          Same as Buy. (German)
-KaufX         Same as BuyX. (German)
-MargInt       Margin interest paid.
-MargIntX      Margin interest paid. For use with an L line.
-MiscExp       Miscellaneous expense.
-MiscExpX      Miscellaneous expense. For use with an L line.
-MiscInc       Miscellaneous income.
-MiscIncX      Miscellaneous income. For use with an L line.
-ReinvDiv      Reinvested dividend.
-ReinvInt      Reinvested interest.
-ReinvLG       Reinvested long-term capital gains.
-Reinvkur      Same as ReinvLG.
-Reinvksp      Same as ReinvSh.
-ReinvMd       Reinvested mid-term capital gains.
-ReinvSG       Same as ReinvSh.
-ReinvSh       Reinvested short-term capital gains.
-Reinvzin      Same as ReinvDiv.
-Reminder      Reminder. (Uses D, N, C & M lines)
-RtrnCap       Return of capital.
-RtrnCapX      Return of capital. For use with an L line.
-Sell          Sell shares.
-SellX         Sell shares. For use with an L line.
-ShtSell       Short sale.
-ShrsIn        Deposit shares.
-ShrsOut       Withdraw shares.
-StkSplit      Stock split.
-Verkauf       Same as Sell. (German)
-VerkaufX      Same as SellX. (German)
-Vest          Mark options as vested. (Uses N, Y, Q, C & M lines)
-WithDrwX      Same as XOut. Used for tax-advantaged accounts.
-XIn           Transfer cash from another account.
-XOut          Transfer cash to another account.
-
-
-Category/Transfer/Class line
-----------------------------
-The "L" line of most transactions specifies the category, transfer
-account, and class (if any) of the transaction.  Square brackets
-surrounding the contents mean the transaction is a transfer to the
-named account.  A forward slash separates the category/account from
-the class.  So overall, the format is one of the following:
-
-   LCategory of transaction
-   L[Transfer account]
-   LCategory of transaction/Class of transaction
-   L[Transfer account]/Class of transaction
-
-In stock transactions, if the 'N' field (action) is MiscIncX or
-MiscExpX, there can be *two* account/class pairs on the L line, with
-the second guaranteed to be a transfer.  I believe they are
-separated by a '|', like so:
-
-   D01/01/2000
-   NMiscExpX
-   T1000.00
-   Lexpense category/expense class|[Transfer account]/transfer class
-
-
-Cleared Status line
--------------------
-The "C" line of specifies the cleared status. The second character
-in the line, if present, may be any of:
-
-* Cleared
-c Cleared
-X Reconciled
-R Reconciled
-? Budgeted
-! Budgeted
-
-
-=====================================================================
-Sample Files
-=====================================================================
-
-Investment Transactions
------------------------
-!Account
-NAssets:Investments:Mutual Fund
-TInvst
-D10/30/2006
-Q0.9
-T500
-PPurchase
-NBuyX
-L[Assets:Investments:Mutual Fund:Cash]
-YFOO
-^
-D11/28/2006
-Q0.897
-T100
-PSale
-NSellX
-L[Assets:Investments:Mutual Fund:Cash]
-YFOO
-^

Deleted: gnucash/trunk/src/import-export/qif-import/gnc-plugin-qif-import-ui.xml
===================================================================
--- gnucash/trunk/src/import-export/qif-import/gnc-plugin-qif-import-ui.xml	2013-12-15 17:20:10 UTC (rev 23566)
+++ gnucash/trunk/src/import-export/qif-import/gnc-plugin-qif-import-ui.xml	2013-12-15 17:21:20 UTC (rev 23567)
@@ -1,12 +0,0 @@
-<ui>
-  <menubar>
-    <menu name="File" action="FileAction">
-      <menu name="FileImport" action="FileImportAction">
-      	<placeholder name="FileImportPlaceholder">
-      	   <menuitem name="FileQIFImport" action="QIFImportAction"/>
-      	   <!-- menuitem name="FileQIFTestDruid" action="QIFTestDruid"/ -->
-      	</placeholder>
-      </menu>
-    </menu>
-  </menubar>
-</ui>

Deleted: gnucash/trunk/src/import-export/qif-import/gnc-plugin-qif-import.c
===================================================================
--- gnucash/trunk/src/import-export/qif-import/gnc-plugin-qif-import.c	2013-12-15 17:20:10 UTC (rev 23566)
+++ gnucash/trunk/src/import-export/qif-import/gnc-plugin-qif-import.c	2013-12-15 17:21:20 UTC (rev 23567)
@@ -1,163 +0,0 @@
-/********************************************************************\
- * gnc-plugin-qif-import.c -- window for importing QIF files        *
- *                        (GnuCash)                                 *
- * Copyright (C) 2003 Jan Arne Petersen <jpetersen at uni-bonn.de>     *
- *                                                                  *
- * This program is free software; you can redistribute it and/or    *
- * modify it under the terms of the GNU General Public License as   *
- * published by the Free Software Foundation; either version 2 of   *
- * the License, or (at your option) any later version.              *
- *                                                                  *
- * This program is distributed in the hope that it will be useful,  *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of   *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the    *
- * GNU General Public License for more details.                     *
- *                                                                  *
- * You should have received a copy of the GNU General Public License*
- * along with this program; if not, contact:                        *
- *                                                                  *
- * Free Software Foundation           Voice:  +1-617-542-5942       *
- * 51 Franklin Street, Fifth Floor    Fax:    +1-617-542-2652       *
- * Boston, MA  02110-1301,  USA       gnu at gnu.org                   *
-\********************************************************************/
-
-#include "config.h"
-
-#include <gtk/gtk.h>
-#include <glib/gi18n.h>
-
-#include "dialog-preferences.h"
-#include "assistant-qif-import.h"
-#include "gnc-plugin-manager.h"
-#include "gnc-plugin-qif-import.h"
-
-static void gnc_plugin_qif_import_class_init (GncPluginQifImportClass *klass);
-static void gnc_plugin_qif_import_init (GncPluginQifImport *plugin);
-static void gnc_plugin_qif_import_finalize (GObject *object);
-
-/* Command callbacks */
-static void gnc_plugin_qif_import_cmd_new_qif_import (GtkAction *action, GncMainWindowActionData *data);
-
-#define PLUGIN_ACTIONS_NAME "gnc-plugin-qif-import-actions"
-#define PLUGIN_UI_FILENAME  "gnc-plugin-qif-import-ui.xml"
-
-static GtkActionEntry gnc_plugin_actions [] =
-{
-    {
-        "QIFImportAction", GTK_STOCK_CONVERT, N_("Import _QIF..."), NULL,
-        N_("Import a Quicken QIF file"),
-        G_CALLBACK (gnc_plugin_qif_import_cmd_new_qif_import)
-    },
-};
-static guint gnc_plugin_n_actions = G_N_ELEMENTS (gnc_plugin_actions);
-
-typedef struct GncPluginQifImportPrivate
-{
-    gpointer dummy;
-} GncPluginQifImportPrivate;
-
-#define GNC_PLUGIN_QIF_IMPORT_GET_PRIVATE(o)  \
-   (G_TYPE_INSTANCE_GET_PRIVATE ((o), GNC_TYPE_PLUGIN_QIF_IMPORT, GncPluginQifImportPrivate))
-
-static GObjectClass *parent_class = NULL;
-
-GType
-gnc_plugin_qif_import_get_type (void)
-{
-    static GType gnc_plugin_qif_import_type = 0;
-
-    if (gnc_plugin_qif_import_type == 0)
-    {
-        static const GTypeInfo our_info =
-        {
-            sizeof (GncPluginQifImportClass),
-            NULL,		/* base_init */
-            NULL,		/* base_finalize */
-            (GClassInitFunc) gnc_plugin_qif_import_class_init,
-            NULL,		/* class_finalize */
-            NULL,		/* class_data */
-            sizeof (GncPluginQifImport),
-            0,		/* n_preallocs */
-            (GInstanceInitFunc) gnc_plugin_qif_import_init,
-        };
-
-        gnc_plugin_qif_import_type = g_type_register_static (GNC_TYPE_PLUGIN,
-                                     "GncPluginQifImport",
-                                     &our_info, 0);
-    }
-
-    return gnc_plugin_qif_import_type;
-}
-
-GncPlugin *
-gnc_plugin_qif_import_new (void)
-{
-    return GNC_PLUGIN (g_object_new (GNC_TYPE_PLUGIN_QIF_IMPORT, NULL));
-}
-
-static void
-gnc_plugin_qif_import_class_init (GncPluginQifImportClass *klass)
-{
-    GObjectClass *object_class = G_OBJECT_CLASS (klass);
-    GncPluginClass *plugin_class = GNC_PLUGIN_CLASS (klass);
-
-    parent_class = g_type_class_peek_parent (klass);
-
-    object_class->finalize = gnc_plugin_qif_import_finalize;
-
-    /* plugin info */
-    plugin_class->plugin_name  = GNC_PLUGIN_QIF_IMPORT_NAME;
-
-    /* widget addition/removal */
-    plugin_class->actions_name = PLUGIN_ACTIONS_NAME;
-    plugin_class->actions      = gnc_plugin_actions;
-    plugin_class->n_actions    = gnc_plugin_n_actions;
-    plugin_class->ui_filename  = PLUGIN_UI_FILENAME;
-
-    g_type_class_add_private(klass, sizeof(GncPluginQifImportPrivate));
-}
-
-static void
-gnc_plugin_qif_import_init (GncPluginQifImport *plugin)
-{
-}
-
-static void
-gnc_plugin_qif_import_finalize (GObject *object)
-{
-    g_return_if_fail (GNC_IS_PLUGIN_QIF_IMPORT (object));
-
-    G_OBJECT_CLASS (parent_class)->finalize (object);
-}
-
-/************************************************************
- *              Plugin Function Implementation              *
- ************************************************************/
-
-/************************************************************
- *                    Command Callbacks                     *
- ************************************************************/
-
-static void
-gnc_plugin_qif_import_cmd_new_qif_import (GtkAction *action,
-        GncMainWindowActionData *data)
-{
-    gnc_file_qif_import();
-}
-
-
-/************************************************************
- *                    Plugin Bootstrapping                   *
- ************************************************************/
-
-void
-gnc_plugin_qif_import_create_plugin (void)
-{
-    GncPlugin *plugin = gnc_plugin_qif_import_new ();
-    gnc_plugin_manager_add_plugin (gnc_plugin_manager_get (), plugin);
-
-    /* Add to preferences under Online Banking */
-    /* The parameters are; glade file, items to add from glade file - last being the dialog, preference tab name */
-    gnc_preferences_add_to_page ("dialog-account-picker.glade", "prefs_table",
-                                 _("Online Banking"));
-}

Deleted: gnucash/trunk/src/import-export/qif-import/gnc-plugin-qif-import.h
===================================================================
--- gnucash/trunk/src/import-export/qif-import/gnc-plugin-qif-import.h	2013-12-15 17:20:10 UTC (rev 23566)
+++ gnucash/trunk/src/import-export/qif-import/gnc-plugin-qif-import.h	2013-12-15 17:21:20 UTC (rev 23567)
@@ -1,63 +0,0 @@
-/********************************************************************\
- * gnc-plugin-qif-import.c -- window for importing QIF files        *
- *                        (GnuCash)                                 *
- * Copyright (C) 2003 Jan Arne Petersen <jpetersen at uni-bonn.de>     *
- *                                                                  *
- * This program is free software; you can redistribute it and/or    *
- * modify it under the terms of the GNU General Public License as   *
- * published by the Free Software Foundation; either version 2 of   *
- * the License, or (at your option) any later version.              *
- *                                                                  *
- * This program is distributed in the hope that it will be useful,  *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of   *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the    *
- * GNU General Public License for more details.                     *
- *                                                                  *
- * You should have received a copy of the GNU General Public License*
- * along with this program; if not, contact:                        *
- *                                                                  *
- * Free Software Foundation           Voice:  +1-617-542-5942       *
- * 51 Franklin Street, Fifth Floor    Fax:    +1-617-542-2652       *
- * Boston, MA  02110-1301,  USA       gnu at gnu.org                   *
-\********************************************************************/
-
-#ifndef __GNC_PLUGIN_QIF_IMPORT_H
-#define __GNC_PLUGIN_QIF_IMPORT_H
-
-#include <gtk/gtk.h>
-
-#include "gnc-plugin.h"
-
-G_BEGIN_DECLS
-
-/* type macros */
-#define GNC_TYPE_PLUGIN_QIF_IMPORT            (gnc_plugin_qif_import_get_type ())
-#define GNC_PLUGIN_QIF_IMPORT(obj)            (G_TYPE_CHECK_INSTANCE_CAST ((obj), GNC_TYPE_PLUGIN_QIF_IMPORT, GncPluginQifImport))
-#define GNC_PLUGIN_QIF_IMPORT_CLASS(klass)    (G_TYPE_CHECK_CLASS_CAST ((klass), GNC_TYPE_PLUGIN_QIF_IMPORT, GncPluginQifImportClass))
-#define GNC_IS_PLUGIN_QIF_IMPORT(obj)         (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GNC_TYPE_PLUGIN_QIF_IMPORT))
-#define GNC_IS_PLUGIN_QIF_IMPORT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GNC_TYPE_PLUGIN_QIF_IMPORT))
-#define GNC_PLUGIN_QIF_IMPORT_GET_CLASS(obj)  (G_TYPE_INSTANCE_GET_CLASS ((obj), GNC_TYPE_PLUGIN_QIF_IMPORT, GncPluginQifImportClass))
-
-#define GNC_PLUGIN_QIF_IMPORT_NAME "gnc-plugin-qif-import"
-
-/* typedefs & structures */
-typedef struct
-{
-    GncPlugin gnc_plugin;
-} GncPluginQifImport;
-
-typedef struct
-{
-    GncPluginClass gnc_plugin;
-} GncPluginQifImportClass;
-
-/* function prototypes */
-GType      gnc_plugin_qif_import_get_type (void);
-
-GncPlugin *gnc_plugin_qif_import_new      (void);
-
-void       gnc_plugin_qif_import_create_plugin (void);
-
-G_END_DECLS
-
-#endif /* __GNC_PLUGIN_QIF_IMPORT_H */

Deleted: gnucash/trunk/src/import-export/qif-import/gncmod-qif-import.c
===================================================================
--- gnucash/trunk/src/import-export/qif-import/gncmod-qif-import.c	2013-12-15 17:20:10 UTC (rev 23566)
+++ gnucash/trunk/src/import-export/qif-import/gncmod-qif-import.c	2013-12-15 17:21:20 UTC (rev 23567)
@@ -1,80 +0,0 @@
-/*********************************************************************
- * gncmod-qif-import.c
- * module definition/initialization for old QIF importer (deprecated)
- *
- * Copyright (c) 2001 Linux Developers Group, Inc.
- *********************************************************************/
-
-#include "config.h"
-#include <gmodule.h>
-#include <libguile.h>
-
-#include "gnc-module.h"
-#include "gnc-module-api.h"
-#include "assistant-qif-import.h"
-#include "dialog-new-user.h"
-
-#include "gnc-plugin-qif-import.h"
-
-GNC_MODULE_API_DECL(libgncmod_qif_import)
-
-/* version of the gnc module system interface we require */
-int libgncmod_qif_import_gnc_module_system_interface = 0;
-
-/* module versioning uses libtool semantics. */
-int libgncmod_qif_import_gnc_module_current  = 0;
-int libgncmod_qif_import_gnc_module_revision = 0;
-int libgncmod_qif_import_gnc_module_age      = 0;
-
-
-char *
-libgncmod_qif_import_gnc_module_path(void)
-{
-    return g_strdup("gnucash/import-export/qif-import");
-}
-
-char *
-libgncmod_qif_import_gnc_module_description(void)
-{
-    return g_strdup("Gnome GUI and Scheme code for QIF importer");
-}
-
-int
-libgncmod_qif_import_gnc_module_init(int refcount)
-{
-    if (!gnc_module_load("gnucash/engine", 0))
-    {
-        return FALSE;
-    }
-
-    if (!gnc_module_load("gnucash/app-utils", 0))
-    {
-        return FALSE;
-    }
-
-    if (!gnc_module_load("gnucash/gnome-utils", 0))
-    {
-        return FALSE;
-    }
-
-    /* If the recount == 0 then register the qif-import-assistant for the new-user
-     * dialog.
-     */
-    if (refcount == 0)
-    {
-        gnc_new_user_dialog_register_qif_assistant
-        ((void (*)())gnc_file_qif_import);
-    }
-
-    scm_c_eval_string("(use-modules (gnucash import-export qif-import))");
-
-    gnc_plugin_qif_import_create_plugin();
-
-    return TRUE;
-}
-
-int
-libgncmod_qif_import_gnc_module_end(int refcount)
-{
-    return TRUE;
-}

Deleted: gnucash/trunk/src/import-export/qif-import/gschemas/Makefile.am
===================================================================
--- gnucash/trunk/src/import-export/qif-import/gschemas/Makefile.am	2013-12-15 17:20:10 UTC (rev 23566)
+++ gnucash/trunk/src/import-export/qif-import/gschemas/Makefile.am	2013-12-15 17:21:20 UTC (rev 23567)
@@ -1,10 +0,0 @@
- at INTLTOOL_XML_NOMERGE_RULE@
-
-gschema_in_files = \
-  org.gnucash.dialogs.import.qif.gschema.xml.in
-
-gsettings_SCHEMAS = $(gschema_in_files:.gschema.xml.in=.gschema.xml)
-
- at GSETTINGS_RULES@
-
-CLEANFILES = $(gsettings_SCHEMAS)

Deleted: gnucash/trunk/src/import-export/qif-import/gschemas/org.gnucash.dialogs.import.qif.gschema.xml.in.in
===================================================================
--- gnucash/trunk/src/import-export/qif-import/gschemas/org.gnucash.dialogs.import.qif.gschema.xml.in.in	2013-12-15 17:20:10 UTC (rev 23566)
+++ gnucash/trunk/src/import-export/qif-import/gschemas/org.gnucash.dialogs.import.qif.gschema.xml.in.in	2013-12-15 17:21:20 UTC (rev 23567)
@@ -1,36 +0,0 @@
-<schemalist gettext-domain="@GETTEXT_PACKAGE@">
-  <schema id="org.gnucash.dialogs.import.qif" path="/org/gnucash/dialogs/import/qif/">
-    <key name="default-status-notcleared" type="b">
-      <default>true</default>
-      <summary>Default QIF transaction status</summary>
-      <description>Default status for QIF transaction when not specified in QIF file.</description>
-    </key>
-    <key name="default-status-cleared" type="b">
-      <default>false</default>
-      <summary>Default QIF transaction status</summary>
-      <description>Default status for QIF transaction when not specified in QIF file.</description>
-    </key>
-    <key name="default-status-reconciled" type="b">
-      <default>false</default>
-      <summary>When the status is not specified in a QIF file, the transactions are marked as reconciled.</summary>
-      <description>Default status for QIF transaction when not specified in QIF file.</description>
-    </key>
-    <key name="last-geometry" type="(iiii)">
-      <default>(-1,-1,-1,-1)</default>
-      <summary>Last window position and size</summary>
-      <description>This setting describes the size and position of the window when it was last closed.
-        The numbers are the X and Y coordinates of the top left corner of the window
-        followed by the width and height of the window.</description>
-    </key>
-    <key name="last-path" type="s">
-      <default>''</default>
-      <summary>Last pathname used</summary>
-      <description>This field contains the last pathname used by this window. It will be used as the initial filename/pathname the next time this window is opened.</description>
-    </key>
-    <key name="show-doc" type="b">
-      <default>true</default>
-      <summary>Show documentation</summary>
-      <description>Show some documentation-only pages in QIF Import assistant.</description>
-    </key>
-  </schema>
-</schemalist>

Deleted: gnucash/trunk/src/import-export/qif-import/qif-dialog-utils.scm
===================================================================
--- gnucash/trunk/src/import-export/qif-import/qif-dialog-utils.scm	2013-12-15 17:20:10 UTC (rev 23566)
+++ gnucash/trunk/src/import-export/qif-import/qif-dialog-utils.scm	2013-12-15 17:21:20 UTC (rev 23567)
@@ -1,903 +0,0 @@
-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-;;;  qif-dialog-utils.scm
-;;;  build qif->gnc account maps and put them in a displayable
-;;;  form.
-;;;
-;;;  Bill Gribble <grib at billgribble.com> 20 Feb 2000
-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-
-(define (default-stock-acct brokerage security)
-  (string-append brokerage (gnc-get-account-separator-string) security))
-
-(define (default-dividend-acct brokerage security)
-  (string-append (_ "Income") (gnc-get-account-separator-string)
-                 (_ "Dividends") (gnc-get-account-separator-string)
-                 brokerage (gnc-get-account-separator-string)
-                 security))
-
-(define (default-interest-acct brokerage security)
-  (string-append (_ "Income") (gnc-get-account-separator-string)
-                 (_ "Interest") (gnc-get-account-separator-string)
-                 brokerage
-                 (if (string=? security "")
-                  ""
-                  (string-append (gnc-get-account-separator-string)
-                                  security))))
-
-(define (default-capital-return-acct brokerage security)
-  (string-append (_ "Income") (gnc-get-account-separator-string)
-                 (_ "Cap Return") (gnc-get-account-separator-string)
-                 brokerage (gnc-get-account-separator-string)
-                 security))
-
-(define (default-cglong-acct brokerage security)
-  (string-append (_ "Income") (gnc-get-account-separator-string)
-                 (_ "Cap. gain (long)") (gnc-get-account-separator-string)
-                 brokerage (gnc-get-account-separator-string)
-                 security))
-
-(define (default-cgmid-acct brokerage security)
-  (string-append (_ "Income") (gnc-get-account-separator-string)
-                 (_ "Cap. gain (mid)") (gnc-get-account-separator-string)
-                 brokerage (gnc-get-account-separator-string)
-                 security))
-
-(define (default-cgshort-acct brokerage security)
-  (string-append (_ "Income") (gnc-get-account-separator-string)
-                 (_ "Cap. gain (short)") (gnc-get-account-separator-string)
-                 brokerage (gnc-get-account-separator-string)
-                 security))
-
-(define (default-equity-holding security)
-  (string-append (_ "Equity") (gnc-get-account-separator-string)
-                 (_ "Retained Earnings")))
-
-(define (default-equity-account)
-  (string-append (_ "Equity") (gnc-get-account-separator-string)
-                 (_ "Retained Earnings")))
-
-(define (default-commission-acct brokerage)
-  (string-append (_ "Expenses") (gnc-get-account-separator-string)
-                 (_ "Commissions") (gnc-get-account-separator-string)
-                 brokerage))
-
-(define (default-margin-interest-acct brokerage)
-  (string-append (_ "Expenses") (gnc-get-account-separator-string)
-                 (_ "Margin Interest") (gnc-get-account-separator-string)
-                 brokerage))
-
-(define (default-unspec-acct)
-  (_ "Unspecified"))
-
-;; The following investment actions implicitly specify
-;; the two accounts involved in the transaction.
-(define qif-import:actions-implicit
-  (list 'buy 'cglong 'cgmid 'cgshort 'div 'intinc 'margint 'reinvdiv
-        'reinvint 'reinvlg 'reinvmd 'reinvsg 'reinvsh 'reminder
-        'rtrncap 'sell 'shrsin 'shrsout 'stksplit))
-
-
-(define (qif-import:gnc-account-exists map-entry acct-list)
-  (let ((retval #f))
-    (for-each
-     (lambda (acct)
-       (if (string=? (qif-map-entry:gnc-name map-entry)
-                     (cadr acct))
-           (set! retval #t)))
-     acct-list)
-    retval))
-
-;; the account-display is a 3-columned list of accounts in the QIF
-;; import dialog (the "Account" page of the notebook).  Column 1 is
-;; the account name in the QIF file, column 2 is the number of QIF
-;; xtns with that account name, and column 3 is the guess for the
-;; translation.  Sorted on # transactions, then alpha.
-
-(define (qif-dialog:make-account-display qif-files acct-hash gnc-acct-info)
-  ;; first, clear the "display" flags in the acct-hash and set up the
-  ;; new-file? flags.  If there's nothing to show any more, don't.
-  (hash-fold
-   (lambda (k v p)
-     (qif-map-entry:set-display?! v #f)
-     #f)
-   #f acct-hash)
-
-  (let ((retval '()))
-    ;; we want to make two passes here.  The first pass picks the
-    ;; explicit Account descriptions out of each file.  These are the
-    ;; best sources of info because we will have types and so on for
-    ;; them.  The second pass picks out account-style L fields and
-    ;; investment security names from the transactions.  Hopefully
-    ;; we'll have most of the accounts already located by that point.
-    ;; Otherwise, we have to guess them.
-
-    ;; acct-hash hashes the qif name to a <qif-map-entry> object.
-    ;; guess-acct returns one.
-    (for-each
-     (lambda (file)
-       ;; first, get the explicit account references.
-       (for-each
-        (lambda (acct)
-          (let ((entry (hash-ref acct-hash (qif-acct:name acct))))
-            (if (not entry)
-                (set! entry
-                      (qif-import:guess-acct (qif-acct:name acct)
-                                             (qif-acct:type acct)
-                                             gnc-acct-info)))
-            (qif-map-entry:set-description! entry (qif-acct:description acct))
-            (hash-set! acct-hash (qif-acct:name acct) entry)))
-        (qif-file:accounts file)))
-     qif-files)
-
-    ;; now make the second pass through the files, looking at the
-    ;; transactions.  Hopefully the accounts are all there already.
-    ;; stock accounts can have both a category/account and another
-    ;; account ref from the security name.
-    (for-each
-     (lambda (file)
-       (for-each
-        (lambda (xtn)
-          (let ((stock-acct (qif-xtn:security-name xtn))
-                (action (qif-xtn:action xtn))
-                (from-acct (qif-xtn:from-acct xtn))
-                (qif-account #f)
-                (qif-account-types #f)
-                (entry #f))
-
-            (if (and stock-acct action)
-                ;; stock transactions are weird.  there can be several
-                ;; accounts associated with stock xtns: the security,
-                ;; the brokerage, a dividend account, a long-term CG
-                ;; account, a short-term CG account, an interest
-                ;; account.  Make sure all of the right ones get stuck
-                ;; in the map.
-                (begin
-                  ;; first: figure out what the near-end account is.
-                  ;; it's generally the security account, but could be
-                  ;; an interest, dividend, or CG account.
-                  (case action
-                    ((buy buyx sell sellx reinvint reinvdiv reinvsh reinvsg
-                          reinvlg reinvmd shrsin shrsout stksplit)
-                     (set! qif-account
-                           (default-stock-acct from-acct stock-acct))
-                     (set! qif-account-types (list GNC-STOCK-TYPE
-                                                   GNC-MUTUAL-TYPE)))
-                    ((div cgshort cgmid cglong intinc miscinc miscexp
-                          margint rtrncap xin xout)
-                     (set! qif-account from-acct)
-                     (set! qif-account-types (list GNC-BANK-TYPE
-                                                   GNC-CCARD-TYPE
-                                                   GNC-CASH-TYPE
-                                                   GNC-ASSET-TYPE
-                                                   GNC-LIABILITY-TYPE
-                                                   GNC-RECEIVABLE-TYPE
-                                                   GNC-PAYABLE-TYPE)))
-
-                    ((divx cgshortx cgmidx cglongx intincx margintx rtrncapx)
-                     (set! qif-account
-                           (and (qif-split:category-is-account?
-                                  (car (qif-xtn:splits xtn)))
-                                (qif-split:category
-                                  (car (qif-xtn:splits xtn)))))
-                     (set! qif-account-types (list GNC-BANK-TYPE
-                                                   GNC-CCARD-TYPE
-                                                   GNC-CASH-TYPE
-                                                   GNC-ASSET-TYPE
-                                                   GNC-LIABILITY-TYPE
-                                                   GNC-RECEIVABLE-TYPE
-                                                   GNC-PAYABLE-TYPE)))
-                    ((miscincx miscexpx)
-                     (set! qif-account
-                           (qif-split:miscx-category
-                            (car (qif-xtn:splits xtn))))
-                     (set! qif-account-types (list GNC-BANK-TYPE
-                                                   GNC-CCARD-TYPE
-                                                   GNC-CASH-TYPE
-                                                   GNC-ASSET-TYPE
-                                                   GNC-LIABILITY-TYPE
-                                                   GNC-RECEIVABLE-TYPE
-                                                   GNC-PAYABLE-TYPE))))
-
-                  ;; now reference the near-end account
-                  (if qif-account
-                      (begin
-                        (set! entry (hash-ref acct-hash qif-account))
-                        (if (not entry)
-                            (set! entry
-                                  (qif-import:guess-acct qif-account
-                                                         qif-account-types
-                                                         gnc-acct-info)))
-                        (qif-map-entry:set-display?! entry #t)
-                        (hash-set! acct-hash qif-account entry)))
-
-                  ;; now figure out the other end of the transaction.
-                  ;; the far end will be the brokerage for buy, sell,
-                  ;; etc, or the "L"-referenced account for buyx,
-                  ;; sellx, etc, or an equity account for ShrsIn/ShrsOut
-
-                  ;; miscintx and miscexpx are very, very "special"
-                  ;; cases ... I'm not sure this is right.
-                  ;; the L line looks like :
-                  ;; LCategory/class [Account]/class
-                  ;; so I assume near-acct is Account and far acct
-                  ;; is Category.  This matches the intincx/divx
-                  ;; behavior.
-
-                  (set! qif-account #f)
-                  (case action
-                    ((buy sell)
-                     (set! qif-account from-acct)
-                     (set! qif-account-types (list GNC-BANK-TYPE
-                                                   GNC-CCARD-TYPE
-                                                   GNC-CASH-TYPE
-                                                   GNC-ASSET-TYPE
-                                                   GNC-LIABILITY-TYPE
-                                                   GNC-RECEIVABLE-TYPE
-                                                   GNC-PAYABLE-TYPE)))
-                    ((buyx sellx xin xout)
-                     (set! qif-account
-                           (and (qif-split:category-is-account?
-                                  (car (qif-xtn:splits xtn)))
-                                (qif-split:category
-                                  (car (qif-xtn:splits xtn)))))
-                     (set! qif-account-types (list GNC-BANK-TYPE
-                                                   GNC-CCARD-TYPE
-                                                   GNC-CASH-TYPE
-                                                   GNC-ASSET-TYPE
-                                                   GNC-LIABILITY-TYPE
-                                                   GNC-RECEIVABLE-TYPE
-                                                   GNC-PAYABLE-TYPE)))
-
-                    ((stksplit)
-                     (set! qif-account
-                           (default-stock-acct from-acct stock-acct))
-                     (set! qif-account-types (list GNC-STOCK-TYPE
-                                                   GNC-MUTUAL-TYPE
-                                                   GNC-ASSET-TYPE
-                                                   GNC-LIABILITY-TYPE
-                                                   GNC-RECEIVABLE-TYPE
-                                                   GNC-PAYABLE-TYPE)))
-                    ((cgshort cgshortx reinvsg reinvsh)
-                     (set! qif-account
-                           (default-cgshort-acct from-acct stock-acct))
-                     (set! qif-account-types (list GNC-INCOME-TYPE)))
-
-                    ((cgmid cgmidx reinvmd)
-                     (set! qif-account
-                           (default-cgmid-acct from-acct stock-acct))
-                     (set! qif-account-types (list GNC-INCOME-TYPE)))
-
-                    ((cglong cglongx reinvlg)
-                     (set! qif-account
-                           (default-cglong-acct from-acct stock-acct))
-                     (set! qif-account-types (list GNC-INCOME-TYPE)))
-
-                    ((intinc intincx reinvint)
-                     (set! qif-account
-                           (default-interest-acct from-acct stock-acct))
-                     (set! qif-account-types (list GNC-INCOME-TYPE)))
-
-                    ((div divx reinvdiv)
-                     (set! qif-account
-                           (default-dividend-acct from-acct stock-acct))
-                     (set! qif-account-types (list GNC-INCOME-TYPE)))
-
-                    ((rtrncap rtrncapx)
-                     (set! qif-account
-                           (default-capital-return-acct from-acct stock-acct))
-                     (set! qif-account-types (list GNC-INCOME-TYPE)))
-
-                    ((shrsin shrsout)
-                     (set! qif-account
-                           (default-equity-holding stock-acct))
-                     (set! qif-account-types (list GNC-EQUITY-TYPE)))
-
-                    ((margint margintx)
-                     (set! qif-account
-                           (default-margin-interest-acct from-acct))
-                     (set! qif-account-types (list GNC-EXPENSE-TYPE)))
-
-                    ((miscinc miscexp miscincx miscexpx)
-                     ;; these reference a category on the other end
-                     (set! qif-account #f)))
-
-                  ;; now reference the far-end account
-                  (if qif-account
-                      (begin
-                        (set! entry (hash-ref acct-hash qif-account))
-                        (if (not entry)
-                            (set! entry (qif-import:guess-acct
-                                         qif-account qif-account-types
-                                         gnc-acct-info)))
-                        (qif-map-entry:set-display?! entry #t)
-                        (hash-set! acct-hash qif-account entry)))
-
-                  ;; if there's a commission, reference the
-                  ;; commission account
-                  (if (qif-xtn:commission xtn)
-                      (begin
-                        (set! qif-account
-                              (default-commission-acct from-acct))
-                        (set! entry
-                              (hash-ref acct-hash qif-account))
-                        (if (not entry)
-                            (set! entry
-                                  (qif-import:guess-acct
-                                   qif-account
-                                   (list GNC-EXPENSE-TYPE)
-                                   gnc-acct-info)))
-                        (qif-map-entry:set-display?! entry #t)
-                          (hash-set! acct-hash qif-account entry))))
-
-                ;; non-stock transactions.  these are a bit easier.
-                ;; the near-end account (from) is always in the
-                ;; transaction, and the far end(s) are in the splits.
-                (begin
-                  (set! entry (hash-ref acct-hash from-acct))
-                  (if (not entry)
-                      (set! entry (qif-import:guess-acct
-                                   from-acct
-                                   (list GNC-BANK-TYPE
-                                         GNC-CCARD-TYPE
-                                         GNC-CASH-TYPE
-                                         GNC-ASSET-TYPE
-                                         GNC-LIABILITY-TYPE
-                                         GNC-RECEIVABLE-TYPE
-                                         GNC-PAYABLE-TYPE)
-                                   gnc-acct-info)))
-                  (qif-map-entry:set-display?! entry #t)
-                  (hash-set! acct-hash from-acct entry)
-
-                  ;; iterate over the splits doing the same thing.
-                  (for-each
-                   (lambda (split)
-                     (let ((xtn-is-acct (qif-split:category-is-account? split))
-                           (xtn-acct #f)
-                           (entry #f))
-                       (if xtn-is-acct
-                           (begin
-                             (set! xtn-acct (qif-split:category split))
-                             (set! entry (hash-ref acct-hash xtn-acct))
-                             (if (not entry)
-                                 (set! entry
-                                       (qif-import:guess-acct
-                                        xtn-acct
-                                        (list GNC-BANK-TYPE
-                                              GNC-CCARD-TYPE
-                                              GNC-CASH-TYPE
-                                              GNC-ASSET-TYPE
-                                              GNC-LIABILITY-TYPE
-                                              GNC-RECEIVABLE-TYPE
-                                              GNC-PAYABLE-TYPE)
-                                        gnc-acct-info)))
-                             (qif-map-entry:set-display?! entry #t)
-                             (hash-set! acct-hash xtn-acct entry)))))
-                   (qif-xtn:splits xtn))))))
-        (qif-file:xtns file)))
-     qif-files)
-
-    ;; now that the hash table is filled, make the display list
-    (hash-fold
-     (lambda (k v p)
-       (if (qif-map-entry:display? v)
-           (begin
-             (qif-map-entry:set-new-acct?!
-              v (not (qif-import:gnc-account-exists v gnc-acct-info)))
-             (set! retval (cons v retval))))
-       #f)
-     #f acct-hash)
-
-    ;; sort by number of transactions with that account so the
-    ;; most important are at the top
-    (set! retval
-          (sort retval
-                (lambda (a b)
-                  (string<? (qif-map-entry:qif-name a)
-                            (qif-map-entry:qif-name b)))))
-    retval))
-
-
-;; the category display is similar to the Account display.
-;; QIF category name, xtn count, then GNUcash account.
-
-(define (qif-dialog:make-category-display qif-files cat-hash gnc-acct-info)
-  ;; first, clear the "display" flags in the cat-hash.  If there's
-  ;; nothing to show any more, don't.
-  (hash-fold
-   (lambda (k v p)
-     (qif-map-entry:set-display?! v #f)
-     #f)
-   #f cat-hash)
-
-  (let ((retval '())
-        (entry #f))
-    ;; get the Cat entries from each file
-    (for-each
-     (lambda (file)
-       (for-each
-        (lambda (cat)
-          (set! entry (hash-ref cat-hash (qif-cat:name cat)))
-          (if (not entry)
-              (set! entry
-                    (qif-import:guess-acct (qif-cat:name cat)
-                                           (if (qif-cat:expense-cat cat)
-                                               (list GNC-EXPENSE-TYPE
-                                                     GNC-INCOME-TYPE)
-                                               (list GNC-INCOME-TYPE
-                                                     GNC-EXPENSE-TYPE))
-                                           gnc-acct-info)))
-          (qif-map-entry:set-description!
-           entry (qif-cat:description cat))
-          (hash-set! cat-hash (qif-cat:name cat) entry))
-        (qif-file:cats file)))
-     qif-files)
-
-    ;; now look at every transaction and increment the count
-    ;; in the account slot if the string matches, or make a
-    ;; new hash reference if not.
-    (for-each
-     (lambda (qif-file)
-       (for-each
-        (lambda (xtn)
-          (let ((action (qif-xtn:action xtn)))
-            ;; Many types of investment transactions implicitly use the
-            ;; brokerage account or a known offshoot. There is no need
-            ;; to consider a category mapping for these.
-            (if (not (and action
-                          (memv action qif-import:actions-implicit)))
-                ;; iterate over the splits
-                (for-each
-                 (lambda (split)
-                   (let ((xtn-is-acct (qif-split:category-is-account? split))
-                         (xtn-cat #f)
-                         (entry #f))
-                     (if (not xtn-is-acct)
-                         (begin
-                           (set! xtn-cat (qif-split:category split))
-                           (set! entry (hash-ref cat-hash xtn-cat))
-                           ;; NOTE: It would be more robust and efficient if the
-                           ;; three "make display" routines below were combined:
-                           ;;   make-account-display
-                           ;;   make-category-display
-                           ;;   make-memo-display
-                           ;;
-                           ;; This would also require adjusting several callback
-                           ;; functions that reference these procedures from C.
-                           ;;
-                           ;; Until then, the maintainer of this code must make
-                           ;; sure that the logic used in the "if" below matches
-                           ;; the criteria for making memo/payee mappings (seen
-                           ;; in make-memo-display).
-
-                           ;; Add an entry if there isn't one already and either
-                           ;;  (a) the category is non-blank, or
-                           ;;  (b) no memo/payee mapping can be applied
-                           (if (and (not entry)
-                                    (or (not (and (string? xtn-cat)
-                                                  (string=? xtn-cat "")))
-                                        (and (or (not (qif-split:memo split))
-                                                 (equal? (qif-split:memo split) ""))
-                                             (or (> (length (qif-xtn:splits xtn)) 1)
-                                                 (not (qif-xtn:payee xtn))
-                                                 (equal? (qif-xtn:payee xtn) "")))))
-                               (set! entry
-                                     (qif-import:guess-acct
-                                      xtn-cat
-                                      (if (gnc-numeric-positive-p
-                                           (qif-split:amount split))
-                                          (list GNC-INCOME-TYPE
-                                                GNC-EXPENSE-TYPE)
-                                          (list GNC-EXPENSE-TYPE
-                                                GNC-INCOME-TYPE))
-                                      gnc-acct-info)))
-                           (if entry
-                               (begin
-                                 (qif-map-entry:set-display?! entry #t)
-                                 (hash-set! cat-hash xtn-cat entry)))))))
-                 (qif-xtn:splits xtn)))))
-        (qif-file:xtns qif-file)))
-     qif-files)
-
-    ;; now that the hash table is filled, make the display list
-    (hash-fold
-     (lambda (k v p)
-       (if (qif-map-entry:display? v)
-           (begin
-             (qif-map-entry:set-new-acct?!
-              v (not (qif-import:gnc-account-exists v gnc-acct-info)))
-             (set! retval (cons v retval))))
-       #f)
-     #f cat-hash)
-
-    ;; sort by qif account name
-    (set! retval (sort retval
-                       (lambda (a b)
-                         (string<? (qif-map-entry:qif-name a)
-                                   (qif-map-entry:qif-name b)))))
-    retval))
-
-;; this one's like the other display builders, it just looks at the
-;; payee and memo too.
-
-(define (qif-dialog:make-memo-display qif-files memo-hash gnc-acct-info)
-  (let ((retval '()))
-    ;; clear the display flags for existing items
-    (hash-fold
-     (lambda (k v p)
-       (qif-map-entry:set-display?! v #f)
-       #f)
-     #f memo-hash)
-
-    ;; iterate over every imported transaction.  If there's no
-    ;; category in the transaction, look at the payee to get a clue.
-    ;; of there's no payee, look at the split memo.
-    (for-each
-     (lambda (file)
-       (for-each
-        (lambda (xtn)
-          (let ((payee (qif-xtn:payee xtn))
-                (action (qif-xtn:action xtn))
-                (splits (qif-xtn:splits xtn)))
-            ;; Many types of investment transactions implicitly use the
-            ;; brokerage account or a known offshoot. There is no need
-            ;; to consider a memo/payee mapping for these.
-            (if (not (and action
-                          (memv action qif-import:actions-implicit)))
-                (for-each
-                 (lambda (split)
-                   (let ((cat (qif-split:category split))
-                         (memo (qif-split:memo split))
-                         (key-string #f))
-                     ;; for each split: if there's a category, do nothing.
-                     ;; if there's a payee, use that as the
-                     ;; key otherwise, use the split memo.
-                     (cond ((and cat
-                                 (or (not (string? cat))
-                                     (not (string=? cat ""))))
-                            (set! key-string #f))
-                           ((and payee (= (length splits) 1))
-                            (set! key-string payee))
-                           (memo
-                            (set! key-string memo)))
-
-                     (if key-string
-                         (let ((entry (hash-ref memo-hash key-string)))
-                           (if (not entry)
-                               (begin
-                                 (set! entry (make-qif-map-entry))
-                                 (qif-map-entry:set-qif-name! entry key-string)
-                                 (qif-map-entry:set-gnc-name!
-                                  entry (default-unspec-acct))
-                                 (qif-map-entry:set-allowed-types!
-                                  entry
-                                  (if (gnc-numeric-positive-p
-                                       (qif-split:amount split))
-                                      (list GNC-INCOME-TYPE GNC-EXPENSE-TYPE
-                                            GNC-BANK-TYPE GNC-CCARD-TYPE
-                                            GNC-LIABILITY-TYPE GNC-ASSET-TYPE
-                                            GNC-RECEIVABLE-TYPE GNC-PAYABLE-TYPE
-                                            GNC-STOCK-TYPE GNC-MUTUAL-TYPE)
-                                      (list GNC-EXPENSE-TYPE GNC-INCOME-TYPE
-                                            GNC-BANK-TYPE GNC-CCARD-TYPE
-                                            GNC-LIABILITY-TYPE GNC-ASSET-TYPE
-                                            GNC-RECEIVABLE-TYPE GNC-PAYABLE-TYPE
-                                            GNC-STOCK-TYPE GNC-MUTUAL-TYPE)))))
-                           (qif-map-entry:set-display?! entry #t)
-                           (hash-set! memo-hash key-string entry)))))
-                 splits))))
-        (qif-file:xtns file)))
-     qif-files)
-
-    ;; build display list
-    (hash-fold
-     (lambda (k v p)
-       (if (qif-map-entry:display? v)
-           (begin
-             (qif-map-entry:set-new-acct?!
-              v (not (qif-import:gnc-account-exists v gnc-acct-info)))
-             (set! retval (cons v retval))))
-       #f)
-     #f memo-hash)
-
-    ;; sort by qif memo/payee name
-    (set! retval (sort retval
-                       (lambda (a b)
-                         (string<? (qif-map-entry:qif-name a)
-                                   (qif-map-entry:qif-name b)))))
-    retval))
-
-
-(define (qif-dialog:qif-file-loaded? filename list-of-files)
-  (let ((status (map
-                 (lambda (file)
-                   (string=? filename (qif-file:path file)))
-                 list-of-files)))
-    (if (memq #t status)
-        #t
-        #f)))
-
-(define (qif-dialog:unload-qif-file oldfile list-of-files)
-  (delq oldfile list-of-files))
-
-(define (qif-import:any-new-accts? hash-table)
-  (let ((retval #f))
-    (for-each
-     (lambda (bin)
-       (for-each
-        (lambda (elt)
-          (if (and (qif-map-entry:new-acct? (cdr elt))
-                   (qif-map-entry:display? (cdr elt)))
-              (set! retval #t)))
-        bin))
-     (vector->list hash-table))
-    retval))
-
-(define (qif-import:fix-from-acct qif-file new-acct-name)
-  (for-each
-   (lambda (xtn)
-     (if (not (qif-xtn:from-acct xtn))
-         (qif-xtn:set-from-acct! xtn new-acct-name)))
-   (qif-file:xtns qif-file)))
-
-
-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-;;  qif-import:get-account-name
-;;
-;;  Given an account name, return the rightmost subaccount.
-;;  For example, given the account name "foo:bar", "bar" is
-;;  returned (assuming the account separator is ":").
-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-
-(define (qif-import:get-account-name fullname)
-  (let* ((sep (gnc-get-account-separator-string))
-         (last-sep (gnc:string-rcontains fullname sep)))
-    (if last-sep
-        (substring fullname (+ last-sep (string-length sep)))
-        fullname)))
-
-
-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-;;  qif-dialog:default-namespace
-;;
-;;  Given a security's QIF symbol and type, along with all
-;;  previously seen security mapping preferences, return a
-;;  default namespace.
-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-(define (qif-dialog:default-namespace qif-symbol qif-type prefs)
-
-  ;; Guess a namespace based on the symbol alone.
-  (define (guess-by-symbol s)
-    (if (string? s)
-      (let ((l (string-length s))
-            (d (string-index s #\.))
-            (pref-match
-              (if (list? prefs)
-                  (find (lambda (elt)
-                          ;; Does the symbol match, and is the namespace
-                          ;; compatible with the QIF type?
-                          (and (string=? s (caddr elt))
-                               (not (and (string? qif-type)
-                                         (string=? GNC_COMMODITY_NS_MUTUAL
-                                                   (cadr elt))
-                                         (or (string-ci=? qif-type "stock")
-                                             (string-ci=? qif-type "etf"))))))
-                        prefs)
-                   #f)))
-        (cond
-          ;; If a preferences match was found, use its namespace.
-          (pref-match
-           (cadr pref-match))
-
-          ;; Guess NYSE for symbols of 1-3 characters.
-          ((< l 4)
-           GNC_COMMODITY_NS_NYSE)
-
-          ;; Guess NYSE for symbols of 1-3 characters
-          ;; followed by a dot and 1-2 characters.
-          ((and d
-                (< l 7)
-                (< 0 d 4)
-                (<= 2 (- l d) 3))
-           GNC_COMMODITY_NS_NYSE)
-
-          ;; Guess NASDAQ for symbols of 4 characters.
-          ((= l 4)
-           GNC_COMMODITY_NS_NASDAQ)
-
-          ;; Otherwise it's probably a fund.
-          (else
-           GNC_COMMODITY_NS_MUTUAL)))
-      ;; There's no symbol. Default to a fund.
-      GNC_COMMODITY_NS_MUTUAL))
-
-  ;; Was a QIF type given?
-  (if (string? qif-type)
-     ;; Yes. We might be able to definitely determine the namespace.
-     (cond
-       ;; Mutual fund
-       ((string-ci=? qif-type "mutual fund")
-        GNC_COMMODITY_NS_MUTUAL)
-
-       ;; Index
-       ((string-ci=? qif-type "index")
-        ;; This QIF type must be wrong; indexes aren't tradable!
-        GNC_COMMODITY_NS_MUTUAL)
-
-       (else
-        (guess-by-symbol qif-symbol)))
-
-     ;; No QIF type was given, so guess a
-     ;; default namespace by symbol alone.
-     (guess-by-symbol qif-symbol)))
-
-
-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-;;  qif-import:update-security-hash
-;;
-;;  For each QIF security in acct-hash, find a matching
-;;  GnuCash security or create a new one, then add it to the
-;;  security-hash table. Return a list of security-hash keys
-;;  for all newly created GnuCash securities, or #f if none.
-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-
-(define (qif-import:update-security-hash security-hash ticker-map
-                                         acct-hash sec-prefs)
-  (let ((names '()))
-    (hash-fold
-     (lambda (qif-name map-entry p)
-       (let ((security-name (qif-import:get-account-name qif-name)))
-         ;; Is this account going to be imported, is it security-denominated,
-         ;; and is the security not already in the security hash table?
-         (if (and
-              security-name
-              (qif-map-entry:display? map-entry)
-              (or (memv GNC-STOCK-TYPE
-                        (qif-map-entry:allowed-types map-entry))
-                  (memv GNC-MUTUAL-TYPE
-                        (qif-map-entry:allowed-types map-entry)))
-              (not (hash-ref security-hash security-name)))
-             (let ((existing-gnc-acct
-                     (gnc-account-lookup-by-full-name
-                      (gnc-get-current-root-account)
-                      (qif-map-entry:gnc-name map-entry)))
-                   (book (gnc-account-get-book (gnc-get-current-root-account))))
-               ;; Are we importing to an existing, security-denominated account?
-               (if (and (not (null? existing-gnc-acct))
-                        (memv (xaccAccountGetType existing-gnc-acct)
-                              (list GNC-STOCK-TYPE GNC-MUTUAL-TYPE)))
-                   ;; Yes, so that security is the one to use. Add it
-                   ;; to the security hash table.
-                   (let ((commodity
-                          (xaccAccountGetCommodity existing-gnc-acct)))
-                     (hash-set! security-hash security-name commodity))
-
-                   ;; Otherwise, since we can't definitively match this QIF
-                   ;; security to a GnuCash security, create a new one with
-                   ;; some (hopefully) intelligent defaults.
-                   (let* ((qif-symbol
-                            (qif-ticker-map:lookup-symbol ticker-map
-                                                          security-name))
-                          (qif-type
-                            (qif-ticker-map:lookup-type ticker-map
-                                                        security-name))
-                          (namespace (qif-dialog:default-namespace qif-symbol
-                                                                   qif-type
-                                                                   sec-prefs)))
-
-                     ;; If no symbol has been provided, default to the name.
-                     (if (not qif-symbol)
-                         (set! qif-symbol security-name))
-
-                     ;; Create the new security and add it to the hash table.
-                     (hash-set! security-hash
-                                security-name
-                                (gnc-commodity-new book
-                                                   security-name
-                                                   namespace
-                                                   qif-symbol
-                                                   ""
-                                                   100000))
-
-                     ;; Add the hash key to the list to be returned.
-                     (set! names (cons security-name names))))))
-         #f))
-     #f acct-hash)
-
-    (if (not (null? names))
-        (sort names string<?)
-        #f)))
-
-;; this is used within the dialog to get a list of all the new
-;; accounts the importer thinks it's going to make.  Passed to the
-;; account picker.
-;;
-;; returned is a tree-structured list of all the old and new accounts
-;; like so : (name new? children).  trees are sorted alphabetically.
-;; This should probably change but it's beeter than no sort at all.
-
-(define (qif-import:get-all-accts extra-maps)
-  (define (cvt-to-tree path new?)
-    (if (null? path)
-        '()
-        (list (car path) new?
-              (if (null? (cdr path)) '()
-                  (list (cvt-to-tree (cdr path) new?))))))
-
-  (define (merge-into-tree tree path new?)
-    (if (null? path)
-        tree
-        (if (null? tree)
-            (list (cvt-to-tree path new?))
-            (let ((newtree '()))
-              (let loop ((tree-elt (car tree))
-                         (tree-left (cdr tree)))
-                (if (string=? (car path) (car tree-elt))
-                    (let ((old-children (caddr tree-elt)))
-                      (set! newtree
-                            (cons (list (car path)
-                                        (and new? (cadr tree-elt))
-                                        (merge-into-tree
-                                         old-children (cdr path) new?))
-                                  (append newtree tree-left))))
-                    (begin
-                      (set! newtree (cons tree-elt newtree))
-                      (if (not (null? tree-left))
-                          (loop (car tree-left) (cdr tree-left))
-                          (set! newtree (cons (cvt-to-tree path new?)
-                                              newtree))))))
-              (sort newtree (lambda (a b) (string<? (car a) (car b))))))))
-
-
-  (let ((accts '())
-        (acct-tree '())
-        (sep (gnc-get-account-separator-string)))
-
-    ;; get the new accounts from the account map
-    (for-each
-     (lambda (acctmap)
-       (if acctmap
-           (hash-fold
-            (lambda (k v p)
-              (if (qif-map-entry:display? v)
-                  (set! accts
-                        (cons
-                         (cons (gnc:substring-split (qif-map-entry:gnc-name v)
-                                                    sep)
-                               (qif-map-entry:new-acct? v))
-                         accts)))
-              #f)
-            #f acctmap)))
-     extra-maps)
-
-    ;; get the old accounts from the current account group
-    (for-each
-     (lambda (acct)
-       (set! accts
-             (cons
-              (cons (gnc:substring-split (gnc-account-get-full-name acct) sep)
-                    #f)
-              accts)))
-     (gnc-account-get-descendants-sorted (gnc-get-current-root-account)))
-
-    ;; now build a tree structure
-    (for-each
-     (lambda (acct)
-       (set! acct-tree
-             (merge-into-tree acct-tree (car acct) (cdr acct))))
-     accts)
-
-    ;; we're done
-    acct-tree))
-
-(define (qif-import:refresh-match-selection matches item)
-  (if (> item -1)
-      (let ((i 0))
-        (for-each
-         (lambda (match)
-           (if (= i item)
-               (if (cdr match)
-                   (set-cdr! match #f)
-                   (set-cdr! match #t))
-               (set-cdr! match #f))
-           (set! i (+ 1 i)))
-         matches))))

Deleted: gnucash/trunk/src/import-export/qif-import/qif-file.scm
===================================================================
--- gnucash/trunk/src/import-export/qif-import/qif-file.scm	2013-12-15 17:20:10 UTC (rev 23566)
+++ gnucash/trunk/src/import-export/qif-import/qif-file.scm	2013-12-15 17:21:20 UTC (rev 23567)
@@ -1,1018 +0,0 @@
-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-;;;  qif-file.scm
-;;;
-;;;  Read a QIF file into a <qif-file> object.
-;;;
-;;;  Bill Gribble <grib at billgribble.com> 20 Feb 2000
-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-
-(use-modules (gnucash core-utils))
-(use-modules (gnucash printf))
-(use-modules (ice-9 regex))
-(use-modules (srfi srfi-13))
-(use-modules (ice-9 rdelim))
-
-(define qif-bad-numeric-rexp
-  (make-regexp "^\\.\\.\\."))
-
-(define (not-bad-numeric-string? input)
-  (let ((match (regexp-exec qif-bad-numeric-rexp input)))
-    (if match #f #t)))
-
-
-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-;;  qif-file:read-file
-;;
-;;  Suck in all the lines. Don't do any string interpretation,
-;;  just store the fields "raw".
-;;
-;;  The return value will be:
-;;    success:   ()
-;;    failure:   (#f error-message)
-;;    warning:   (#t error-message)
-;;    cancel:    #t
-;;    exception: #f
-;;
-;; FIXME: This function really should be able to return multiple
-;;        errors and warnings rather than a single one.
-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-
-(define (qif-file:read-file self path ticker-map progress-dialog)
-
-  ;; This procedure does all the work. We'll define it, then call it safely.
-  (define (private-read)
-    (let ((qstate-type #f)
-          (current-xtn #f)
-          (current-split #f)
-          (current-account-name #f)
-          (last-seen-account-name #f)
-          (default-split #f)
-          (first-xtn #f)
-          (ignore-accounts #f)
-          (private-retval '())
-          (line-num 0)
-          (line #f)
-          (tag #f)
-          (value #f)
-          (abort-read #f)
-          (delimiters (string #\cr #\nl))
-          (file-stats #f)
-          (file-size 0)
-          (bytes-read 0))
-
-      ;; This procedure simplifies handling of warnings.
-      (define (mywarn . args)
-        (let ((str (gnc:list-display-to-string
-                     (append (list (_ "Line") " " line-num ": ") args))))
-          (set! private-retval (list #t str))
-          (qif-import:log progress-dialog "qif-file:read-file" str)))
-
-
-      ;; This procedure simplifies handling of failures
-      (define (myfail . args)
-        (let ((str (gnc:list-display-to-string
-                         (append (list (_ "Line") " " line-num ": ") args))))
-          (set! private-retval (list #f str))
-          (qif-import:log progress-dialog "qif-file:read-file"
-                          (string-append str "\n" (_ "Read aborted.")))
-          (set! abort-read #t)))
-
-
-      (qif-file:set-path! self path)
-      (if (not (access? path R_OK))
-          ;; A UTF-8 encoded path won't succeed on some systems, such as
-          ;; Windows XP. Try encoding the path according to the locale.
-          (set! path (gnc-locale-from-utf8 path)))
-      (set! file-stats (stat path))
-      (set! file-size (stat:size file-stats))
-
-
-      (if progress-dialog
-          (gnc-progress-dialog-set-sub progress-dialog
-                                       (string-append (_ "Reading") " " path)))
-
-      (with-input-from-file path
-        (lambda ()
-          ;; loop over lines
-          (let line-loop ()
-            (set! line (read-delimited delimiters))
-            (set! line-num (+ 1 line-num))
-            (if (and (not (eof-object? line))
-                     (not (string=? line "")))
-                (begin
-                  ;; Add to the bytes-read tally.
-                  (set! bytes-read
-                        (+ bytes-read 1 (string-length line)))
-
-                  ;; Pick the 1-char tag off from the remainder of the line.
-                  (set! tag (string-ref line 0))
-                  (set! value (substring line 1))
-
-                  ;; If the line doesn't conform to UTF-8, try a default
-                  ;; character set conversion based on the locale. If that
-                  ;; fails, remove any invalid characters.
-                  (if (not (gnc-utf8? value))
-                      (let ((converted-value (gnc-locale-to-utf8 value)))
-                        (if (or (string=? converted-value "")
-                                (not (gnc-utf8? converted-value)))
-                            (begin
-                              (set! value (gnc-utf8-strip-invalid-strdup value))
-                              (mywarn
-                               (_ "Some characters have been discarded.")
-                               " " (_"Converted to: ") value))
-                            (begin
-                              (mywarn
-                               (_ "Some characters have been converted according to your locale.")
-                               " " (_"Converted to: ") converted-value)
-                              (set! value converted-value)))))
-
-                  (if (eq? tag #\!)
-                      ;; The "!" tag has the highest precedence and is used
-                      ;; to switch between different sections of the file.
-                      (let ((old-qstate qstate-type))
-                        (set! qstate-type (qif-parse:parse-bang-field value))
-                        (case qstate-type
-                          ;; Transaction list for a particular account
-                          ((type:bank type:cash type:ccard type:invst type:port
-                            #{type:oth a}#  #{type:oth l}# #{type:oth s}#)
-                           (if ignore-accounts
-                               (set! current-account-name
-                                     last-seen-account-name))
-                           (set! ignore-accounts #f)
-                           (set! current-xtn (make-qif-xtn))
-                           (set! default-split (make-qif-split))
-                           (set! first-xtn #t))
-
-                          ;; Class list
-                          ((type:class)
-                           (set! current-xtn (make-qif-class)))
-
-                          ;; Category list
-                          ((type:cat)
-                           (set! current-xtn (make-qif-cat)))
-
-                          ;; Account list
-                          ((account)
-                           (set! current-xtn (make-qif-acct)))
-
-                          ;; Security list
-                          ((type:security)
-                           (set! current-xtn (make-qif-stock-symbol)))
-
-                          ;; Memorized transaction list
-                          ((type:memorized)
-                           ;; Not supported. We really should warn the user.
-                           #f)
-
-                          ;; Security price list
-                          ((type:prices)
-                           ;; Not supported. We really should warn the user.
-                           #f)
-
-                          ((option:autoswitch)
-                           (set! ignore-accounts #t))
-
-                          ((clear:autoswitch)
-                           (set! ignore-accounts #f))
-
-                          (else
-                           ;; Ignore any other "option:" identifiers and
-                           ;; just return to the previously known !type
-                           (if (string-match "^option:"
-                                             (symbol->string qstate-type))
-                               (begin
-                                 (mywarn (_ "Ignoring unknown option") " '"
-                                         qstate-type "'")
-                                 (set! qstate-type old-qstate))))))
-
-
-                      ;; It's not a "!" tag, so the meaning depends on what
-                      ;; type of section we are currently working on.
-                      (case qstate-type
-
-                        ;;;;;;;;;;;;;;;;;;;;;;
-                        ;; Transaction list ;;
-                        ;;;;;;;;;;;;;;;;;;;;;;
-
-                        ((type:bank type:cash type:ccard type:invst type:port
-                          #{type:oth a}#  #{type:oth l}# #{type:oth s}#)
-                         (case tag
-                           ;; D : transaction date
-                           ((#\D)
-                            (qif-xtn:set-date! current-xtn value))
-
-                           ;; T : total amount
-                           ((#\T)
-                            (if (and default-split
-                                    (not-bad-numeric-string? value))
-                                (qif-split:set-amount! default-split value)))
-
-                           ;; P : payee
-                           ((#\P)
-                            (qif-xtn:set-payee! current-xtn value))
-
-                           ;; A : address
-                           ;; multiple "A" lines are appended together with
-                           ;; newlines; some Quicken files have a lot of
-                           ;; A lines.
-                           ((#\A)
-                            (qif-xtn:set-address!
-                             current-xtn
-                             (let ((current (qif-xtn:address current-xtn)))
-                               (if (not (string? current))
-                                   (set! current ""))
-                               (string-append current "\n" value))))
-
-                           ;; N : For transactions involving a security, this
-                           ;; is the investment action. For all others,  this
-                           ;; is a check number or transaction number.
-                           ((#\N)
-                            (if (or (eq? qstate-type 'type:invst)
-                                    (eq? qstate-type 'type:port))
-                                (qif-xtn:set-action! current-xtn value)
-                                (qif-xtn:set-number! current-xtn value)))
-
-                           ;; C : cleared flag
-                           ((#\C)
-                            (qif-xtn:set-cleared! current-xtn value))
-
-                           ;; M : memo
-                           ((#\M)
-                            (if default-split
-                                (qif-split:set-memo! default-split value)))
-
-                           ;; I : share price (stock transactions)
-                           ((#\I)
-                            (qif-xtn:set-share-price! current-xtn value))
-
-                           ;; Q : number of shares (stock transactions)
-                           ((#\Q)
-                            (qif-xtn:set-num-shares! current-xtn value))
-
-                           ;; Y : name of security (stock transactions)
-                           ((#\Y)
-                            (qif-xtn:set-security-name! current-xtn value))
-
-                           ;; O : commission (stock transactions)
-                           ((#\O)
-                            (qif-xtn:set-commission! current-xtn value))
-
-                           ;; L : category
-                           ((#\L)
-                            (if default-split
-                                (qif-split:set-category! default-split value)))
-
-                           ;; S : split category
-                           ;; At this point we are ignoring the default-split
-                           ;; completely, but save it for later -- we need it
-                           ;; to determine whether to reverse the split values.
-                           ((#\S)
-                            (set! current-split (make-qif-split))
-                            (if default-split
-                                (qif-xtn:set-default-split! current-xtn
-                                                            default-split))
-                            (set! default-split #f)
-                            (qif-split:set-category! current-split value)
-                            (qif-xtn:set-splits!
-                               current-xtn
-                               (cons current-split
-                                     (qif-xtn:splits current-xtn))))
-
-                           ;; E : split memo
-                           ((#\E)
-                            (if current-split
-                                (qif-split:set-memo! current-split value)))
-
-                           ;; $ : split amount (if there are splits)
-                           ((#\$)
-                            (if (and current-split
-                                     (not-bad-numeric-string? value))
-                                (qif-split:set-amount! current-split value)))
-
-                           ;; ^ : end-of-record
-                           ((#\^)
-                            (if (null? (qif-xtn:splits current-xtn))
-                                (qif-xtn:set-splits! current-xtn
-                                                     (list default-split)))
-                            (if first-xtn
-                                (let ((opening-balance-payee
-                                       (qif-file:process-opening-balance-xtn
-                                        self current-account-name current-xtn
-                                        qstate-type)))
-                                  (if (not current-account-name)
-                                      (set! current-account-name
-                                            opening-balance-payee))
-                                  (set! first-xtn #f)))
-
-                            (if (and (or (eq? qstate-type 'type:invst)
-                                         (eq? qstate-type 'type:port))
-                                     (not (qif-xtn:security-name current-xtn)))
-                                (qif-xtn:set-security-name! current-xtn ""))
-
-                            (qif-xtn:set-from-acct! current-xtn
-                                                    current-account-name)
-
-                            (if (qif-xtn:date current-xtn)
-                                (qif-file:add-xtn! self current-xtn)
-                                ;; The date is missing! Warn the user.
-                                (mywarn (_ "Date required.") " "
-                                        (_ "Discarding this transaction.")))
-
-                            ;;(write current-xtn) (newline)
-                            (set! current-xtn (make-qif-xtn))
-                            (set! current-split #f)
-                            (set! default-split (make-qif-split)))))
-
-
-                        ;;;;;;;;;;;;;;;;
-                        ;; Class list ;;
-                        ;;;;;;;;;;;;;;;;
-
-                        ((type:class)
-                         (case tag
-                           ;; N : name
-                           ((#\N)
-                            (qif-class:set-name! current-xtn value))
-
-                           ;; D : description
-                           ((#\D)
-                            (qif-class:set-description! current-xtn value))
-
-                           ;; R : tax copy designator (ignored for now)
-                           ((#\R)
-                            #t)
-
-                           ;; end-of-record
-                           ((#\^)
-                            (qif-file:add-class! self current-xtn)
-                            (set! current-xtn (make-qif-class)))
-
-                           (else
-                            (mywarn (_ "Ignoring class line") ": " line))))
-
-
-                        ;;;;;;;;;;;;;;;;;;
-                        ;; Account List ;;
-                        ;;;;;;;;;;;;;;;;;;
-
-                        ((account)
-                         (case tag
-                           ((#\N)
-                            (qif-acct:set-name! current-xtn value)
-                            (set! last-seen-account-name value))
-                           ((#\D)
-                            (qif-acct:set-description! current-xtn value))
-                           ((#\T)
-                            (qif-acct:set-type! current-xtn value))
-                           ((#\L)
-                            (qif-acct:set-limit! current-xtn value))
-                           ((#\B)
-                            (qif-acct:set-budget! current-xtn value))
-                           ((#\^)
-                            (if (not ignore-accounts)
-                                (set! current-account-name
-                                      (qif-acct:name current-xtn)))
-                            (qif-file:add-account! self current-xtn)
-                            (set! current-xtn (make-qif-acct)))))
-
-
-                        ;;;;;;;;;;;;;;;;;;;
-                        ;; Category list ;;
-                        ;;;;;;;;;;;;;;;;;;;
-
-                        ((type:cat)
-                         (case tag
-                           ;; N : category name
-                           ((#\N)
-                            (qif-cat:set-name! current-xtn value))
-
-                           ;; D : category description
-                           ((#\D)
-                            (qif-cat:set-description! current-xtn value))
-
-                           ;; T : is this a taxable category?
-                           ((#\T)
-                            (qif-cat:set-taxable! current-xtn #t))
-
-                           ;; E : is this an expense category?
-                           ((#\E)
-                            (qif-cat:set-expense-cat! current-xtn #t))
-
-                           ;; I : is this an income category?
-                           ((#\I)
-                            (qif-cat:set-income-cat! current-xtn #t))
-
-                           ;; R : tax form/line designator
-                           ((#\R)
-                            (qif-cat:set-tax-class! current-xtn value))
-
-                           ;; B : budget amount.  not really supported.
-                           ((#\B)
-                            (qif-cat:set-budget-amt! current-xtn value))
-
-                           ;; end-of-record
-                           ((#\^)
-                            (qif-file:add-cat! self current-xtn)
-                            (set! current-xtn (make-qif-cat)))
-
-                           (else
-                            (mywarn (_ "Ignoring category line") ": " line))))
-
-
-                        ;;;;;;;;;;;;;;;;;;;
-                        ;; Security list ;;
-                        ;;;;;;;;;;;;;;;;;;;
-
-                        ((type:security)
-                         (case tag
-                           ;; N : stock name
-                           ((#\N)
-                            (qif-stock-symbol:set-name! current-xtn value))
-
-                           ;; S : ticker symbol
-                           ((#\S)
-                            (qif-stock-symbol:set-symbol! current-xtn value))
-
-                           ;; T : type
-                           ((#\T)
-                            (qif-stock-symbol:set-type! current-xtn value))
-
-                           ;; G : asset class (ignored)
-                           ((#\G)
-                            #t)
-
-                           ;; end-of-record
-                           ((#\^)
-                            (qif-ticker-map:add-ticker! ticker-map current-xtn)
-                            (set! current-xtn (make-qif-stock-symbol)))
-
-                           (else
-                            (mywarn (_ "Ignoring security line") ": " line))))
-
-
-                        ;; trying to sneak one by, eh?
-                        (else
-                          (if (and (not qstate-type)
-                                   (not (string=? (string-trim line) "")))
-                              (myfail
-                                (_ "File does not appear to be in QIF format")
-                                ": " line)))))
-
-                  ;; Report the progress.
-                  (if (and progress-dialog
-                           (zero? (remainder line-num 32)))
-                      (begin
-                        (gnc-progress-dialog-set-value progress-dialog
-                                                       (/ bytes-read file-size))
-                        (qif-import:check-pause progress-dialog)
-                        (if qif-import:canceled
-                            (begin
-                              (set! private-retval #t)
-                              (set! abort-read #t)))))
-
-                  ;; This is if we read a normal (non-null, non-eof) line...
-                  (if (not abort-read)
-                      (line-loop)))
-
-                ;; ...and this is if we read a null or eof line.
-                (if (and (not abort-read)
-                         (not (eof-object? line)))
-                    (line-loop))))))
-
-      ;; Reverse the transaction list so xtns are in the same order that
-      ;; they appeared in the file.  This is important in a few cases.
-      (qif-file:set-xtns! self (reverse (qif-file:xtns self)))
-
-      private-retval))
-
-
-  (gnc:backtrace-if-exception
-    (lambda ()
-      (let ((retval #f))
-        ;; Safely read the file.
-        (set! retval (gnc:backtrace-if-exception private-read))
-
-        ;; Fill the progress dialog.
-        (if (and progress-dialog
-                 (list? retval))
-          (gnc-progress-dialog-set-value progress-dialog 1))
-
-        retval))))
-
-
-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-;;  qif-file:process-opening-balance-xtn
-;;
-;;  This gets called for the first transaction after a !Type: tag.
-;;
-;;  If the first transaction after a !Type: tag has a payee of
-;;  "Opening Balance", we have to massage the transaction a little.
-;;  The meaning of an OB transaction is "transfer from Equity to the
-;;  account specified in the L line." idiomatically, ms-money and some
-;;  others use this transaction instead of an Account record to
-;;  specify "this" account (the from-account for all following
-;;  transactions), so we have to allow for that.
-;;
-;;  Even if the payee isn't "Opening Balance", we know that if there's
-;;  no default from-account by this time, we need to set one.  In that
-;;  case, we set the default account based on the file name.
-;;
-;;  If we DO know the account already, and this is a tranfer to it,
-;;  it's also an opening balance regardless of the payee.
-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-
-(define (qif-file:process-opening-balance-xtn self acct-name xtn type)
-  (let ((payee (qif-xtn:payee xtn))
-        (category (qif-split:category (car (qif-xtn:splits xtn))))
-        (cat-is-acct? (qif-split:category-is-account?
-                       (car (qif-xtn:splits xtn))))
-        (security (qif-xtn:security-name xtn)))
-    (if (or (and (not acct-name)
-                 (not security)
-                 payee (string? payee)
-                 (string=? (string-remove-trailing-space payee)
-                           "Opening Balance")
-                 cat-is-acct?)
-            (and acct-name (string? acct-name)
-                 (string=? acct-name category)
-                 (not security)))
-        ;; this is an explicit "Opening Balance" transaction.  we need
-        ;; to change the category to point to the equity account that
-        ;; the opening balance comes from.
-        (begin
-          (qif-split:set-category-private! (car (qif-xtn:splits xtn))
-                                           (default-equity-account))
-          (qif-split:set-category-is-account?! (car (qif-xtn:splits xtn)) #t)
-          (set! acct-name category)))
-    acct-name))
-
-;; return #t if all xtns have a non-#f from-acct otherwise, we will
-;; need to ask for an explicit account.
-(define (qif-file:check-from-acct self)
-  (let ((retval #t))
-    (for-each
-     (lambda (xtn)
-       (if (not (qif-xtn:from-acct xtn))
-           (set! retval #f)))
-     (qif-file:xtns self))
-    retval))
-
-;; if the date format was ambiguous, this will get called to reparse.
-(define (qif-file:reparse-dates self new-format)
-  (check-and-parse-field
-   qif-xtn:date qif-xtn:set-date! equal?
-   qif-parse:check-date-format (list new-format)
-   qif-parse:parse-date/format
-   (qif-file:xtns self)
-   qif-parse:print-date
-   'error-on-ambiguity (lambda (t e) e) 'date
-   (lambda (fraction) #t)))
-
-
-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-;;  qif-file:parse-fields
-;;
-;;  Take a previously-read qif file and convert fields from
-;;  strings to the appropriate type.
-;;
-;;  The return value will be:
-;;    success:   ()
-;;    failure:   (#f . ((type . error) ...))
-;;    warning:   (#t . ((type . error) ...))
-;;    cancel:    #t
-;;    exception: #f
-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-
-(define (qif-file:parse-fields self progress-dialog)
-
-  ;; This procedure does all the work. We'll define it, then call it safely.
-  (define (private-parse)
-   (let ((error #f)
-         (update-count 0)
-         (all-ok #f))
-
-     ;; This procedure sets a suboperation name.
-     (define (set-sub str)
-       (if progress-dialog
-           (gnc-progress-dialog-set-sub progress-dialog str))
-       #t)
-
-
-     ;; This procedure sets a suboperation weight.
-     (define (start-sub weight)
-       (if progress-dialog
-           (gnc-progress-dialog-push progress-dialog weight))
-       #t)
-
-
-     ;; This procedure finishes a suboperation.
-     (define (finish-sub)
-       (if progress-dialog
-           (gnc-progress-dialog-pop-full progress-dialog))
-       #t)
-
-
-     ;; This procedure handles progress reporting, pause, and cancel.
-     (define (update-progress fraction)
-       (set! update-count (+ 1 update-count))
-       (if (and progress-dialog
-                (zero? (remainder update-count 32)))
-           (begin
-             (gnc-progress-dialog-set-value progress-dialog fraction)
-             (qif-import:check-pause progress-dialog)
-             (if qif-import:canceled
-                 (throw 'cancel)))))
-
-
-     ;; This procedure is the generic error handler for parsing.
-     (define (add-error t e)
-       ;; Log the error message.
-       (if (string? e)
-           (qif-import:log progress-dialog
-                           "qif-file:parse-fields"
-                           (string-append (case t
-                                            ((date) (_ "Transaction date"))
-                                            ((split-amounts) (_ "Transaction amount"))
-                                            ((share-price) (_ "Share price"))
-                                            ((num-shares) (_ "Share quantity"))
-                                            ((action) (_ "Investment action"))
-                                            ((cleared) (_ "Reconciliation status"))
-                                            ((commission) (_ "Commission"))
-                                            ((acct-type) (_ "Account type"))
-                                            ((tax-class) (_ "Tax class"))
-                                            ((budget-amt) (_ "Category budget amount"))
-                                            ((budget) (_ "Account budget amount"))
-                                            ((limit) (_ "Credit limit"))
-                                            (else (symbol->string t)))
-                                          ": " e)))
-       ;; Save the error condition.
-       (if (not error)
-           (set! error (list (cons t e)))
-           (set! error (cons (cons t e) error))))
-
-
-     (and
-      ;;
-      ;; Fields of categories.
-      ;;
-      (set-sub (_ "Parsing categories"))
-      ;; The category tasks will be 5% of the overall parsing effort.
-      (start-sub 0.05)
-
-      ;; Tax classes; assume this is 50% of the category parsing effort.
-      (start-sub 0.5)
-      (check-and-parse-field
-       qif-cat:tax-class qif-cat:set-tax-class! gnc-numeric-equal
-       qif-parse:check-number-format '(decimal comma)
-       qif-parse:parse-number/format (qif-file:cats self)
-       qif-parse:print-number
-       'guess-on-ambiguity add-error 'tax-class
-       update-progress)
-      (finish-sub)
-
-      ;; Budget amounts; this is the last task for category parsing.
-      (start-sub 1)
-      (check-and-parse-field
-       qif-cat:budget-amt qif-cat:set-budget-amt! gnc-numeric-equal
-       qif-parse:check-number-format '(decimal comma)
-       qif-parse:parse-number/format (qif-file:cats self)
-       qif-parse:print-number
-       'guess-on-ambiguity add-error 'budget-amt
-       update-progress)
-      (finish-sub)
-
-      (finish-sub)
-
-
-      ;;
-      ;; Fields of accounts
-      ;;
-      (set-sub (_ "Parsing accounts"))
-      ;; The account tasks will be 5% of the overall parsing effort.
-      (start-sub 0.05)
-
-      ;; Account limits; assume this is 20% of the account parsing effort.
-      (start-sub 0.2)
-      (check-and-parse-field
-       qif-acct:limit qif-acct:set-limit! gnc-numeric-equal
-       qif-parse:check-number-format '(decimal comma)
-       qif-parse:parse-number/format (qif-file:accounts self)
-       qif-parse:print-number
-       'guess-on-ambiguity add-error 'limit
-       update-progress)
-      (finish-sub)
-
-      ;; Budget amounts; assume this is 20% of the account parsing effort.
-      (start-sub 0.2)
-      (check-and-parse-field
-       qif-acct:budget qif-acct:set-budget! gnc-numeric-equal
-       qif-parse:check-number-format '(decimal comma)
-       qif-parse:parse-number/format (qif-file:accounts self)
-       qif-parse:print-number
-       'guess-on-ambiguity add-error 'budget
-       update-progress)
-      (finish-sub)
-
-      ;; Account types; this is the last task for account parsing.
-      (start-sub 1)
-      (parse-field
-       qif-acct:type qif-acct:set-type!
-       qif-parse:parse-acct-type (qif-file:accounts self)
-       add-error 'acct-type
-       update-progress)
-      (finish-sub)
-
-      (finish-sub)
-
-
-      ;;
-      ;; fields of transactions
-      ;;
-      (set-sub (_ "Parsing transactions"))
-      ;; Transaction parsing takes up the rest of the overall parsing effort.
-      (start-sub 1)
-
-      ;; Dates; assume this is 15% of the transaction effort.
-      (start-sub 0.15)
-      (check-and-parse-field
-       qif-xtn:date qif-xtn:set-date! equal?
-       qif-parse:check-date-format '(m-d-y d-m-y y-m-d y-d-m)
-       qif-parse:parse-date/format
-       (qif-file:xtns self)
-       qif-parse:print-date
-       'error-on-ambiguity add-error 'date
-       update-progress)
-      (finish-sub)
-
-      ;; Clear flags; assume this is 5% of the transaction effort.
-      (start-sub 0.05)
-      (parse-field
-       qif-xtn:cleared qif-xtn:set-cleared!
-       qif-parse:parse-cleared-field (qif-file:xtns self)
-       add-error 'cleared
-       update-progress)
-      (finish-sub)
-
-      ;; Investment actions; assume this is 10% of the transaction effort.
-      (start-sub 0.1)
-      (parse-field
-       qif-xtn:action qif-xtn:set-action!
-       qif-parse:parse-action-field (qif-file:xtns self)
-       add-error 'action
-       update-progress)
-      (finish-sub)
-
-      ;; Share prices; assume this is 10% of the transaction effort.
-      (start-sub 0.1)
-      (check-and-parse-field
-       qif-xtn:share-price qif-xtn:set-share-price! gnc-numeric-equal
-       qif-parse:check-number-format '(decimal comma)
-       qif-parse:parse-number/format (qif-file:xtns self)
-       qif-parse:print-number
-       'guess-on-ambiguity add-error 'share-price
-       update-progress)
-      (finish-sub)
-
-      ;; Share quantities; assume this is 10% of the transaction effort.
-      (start-sub 0.1)
-      (check-and-parse-field
-       qif-xtn:num-shares qif-xtn:set-num-shares! gnc-numeric-equal
-       qif-parse:check-number-format '(decimal comma)
-       qif-parse:parse-number/format (qif-file:xtns self)
-       qif-parse:print-number
-       'guess-on-ambiguity add-error 'num-shares
-       update-progress)
-      (finish-sub)
-
-      ;; Commissions; assume this is 10% of the transaction effort.
-      (start-sub 0.1)
-      (check-and-parse-field
-       qif-xtn:commission qif-xtn:set-commission! gnc-numeric-equal
-       qif-parse:check-number-format '(decimal comma)
-       qif-parse:parse-number/format (qif-file:xtns self)
-       qif-parse:print-number
-       'guess-on-ambiguity add-error 'commission
-       update-progress)
-      (finish-sub)
-
-      ;; Splits; this is the rest of the transaction effort.
-      (start-sub 1)
-      ;; this one's a little tricky... it checks and sets all the
-      ;; split amounts for the transaction together.
-      (check-and-parse-field
-       qif-xtn:split-amounts qif-xtn:set-split-amounts! gnc-numeric-equal
-       qif-parse:check-number-formats '(decimal comma)
-       qif-parse:parse-numbers/format (qif-file:xtns self)
-       qif-parse:print-numbers
-       'guess-on-ambiguity add-error 'split-amounts
-       update-progress)
-      (finish-sub)
-
-      (finish-sub)
-
-
-      (begin
-        (set! all-ok #t)
-        #t))
-
-     ;; Determine what to return.
-     (cond (qif-import:canceled
-            #t)
-           (error
-            (cons all-ok error))
-           (else '()))))
-
-
-  ;; Safely read the file and return the result.
-  (gnc:backtrace-if-exception
-    (lambda () (catch 'cancel private-parse (lambda (key . args) #t)))))
-
-
-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-;;  parse-field
-;;
-;;  A simplified version of check-and-parse-field which just
-;;  calls the parser on every instance of the field in the set
-;;  of objects.
-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-
-(define (parse-field getter setter parser objects errorproc errortype reporter)
-  (let ((work-to-do (length objects))
-        (work-done 0)
-        (unparsed #f))
-    (for-each
-     (lambda (obj)
-       (set! unparsed (getter obj))
-       (if (and unparsed (string? unparsed))
-           (setter obj (parser unparsed errorproc errortype)))
-       (set! work-done (+ 1 work-done))
-       (reporter (/ work-done work-to-do)))
-     objects))
-  #t)
-
-
-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-;;  check-and-parse-field
-;;
-;;  This is a semi-generic routine to apply a format check and
-;;  parsing routine to fields that can have multiple possible
-;;  formats.  In this case, any amount field cam be decimal or
-;;  comma radix and the date field can be any of several possible
-;;  types.
-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-
-(define (check-and-parse-field getter setter equiv-thunk checker
-                               formats parser objects printer
-                               on-error errorproc errortype
-                               reporter)
-  (let* ((do-parsing #f)
-         (retval #t)
-         (format #f)
-         (len (length objects))
-         (work-to-do (* len 2))
-         (work-done 0))
-
-    ;; first find the right format for the field
-    ;; loop over objects.  If the formats list ever gets down
-    ;; to 1 element, we can stop right there.
-    (if (not (null? objects))
-        (let loop ((current (car objects))
-                   (rest (cdr objects)))
-          (let ((val (getter current)))
-            (if val
-                (begin
-                  (set! do-parsing #t)
-                  (set! formats (checker val formats))))
-            (set! work-done (+ 1 work-done))
-            (reporter (/ work-done work-to-do)))
-          (if (and (not (null? formats))
-                   ;; (not (null? (cdr formats)))
-                   (not (null? rest)))
-              (loop (car rest) (cdr rest)))))
-
-    ;; if there's nothing left in formats, there's no format that will
-    ;; fit all the values for a given field.  We have to give up at
-    ;; that point.
-
-    ;; If there are multiple items in formats, we look at the on-error
-    ;; arg.  If it's 'guess-on-ambiguity, we take the default (first)
-    ;; item in the list.  This is not super great.  if it's
-    ;; 'fail-on-ambiguity (or anything else, actually) we return the
-    ;; list of acceptable formats.
-
-    (cond
-     ((or (not formats)
-          (null? formats))
-      ;; Data was not in any of the supplied formats.
-      (errorproc errortype (_ "Unrecognized or inconsistent format."))
-      (set! retval #f)
-      (set! do-parsing #f))
-
-     ((and (not (null? (cdr formats))) do-parsing)
-      ;; There are multiple formats that fit.  If they all produce the
-      ;; same interpretation for every data point in the set, then
-      ;; just ignore the format ambiguity.  Otherwise, it's really an
-      ;; error.  ATM since there's no way to correct the error let's
-      ;; just leave it be.
-      (if (or (eq? on-error 'guess-on-ambiguity)
-              (all-formats-equivalent? getter parser equiv-thunk formats
-                                       objects printer errorproc errortype))
-          (set! format (car formats))
-          (begin
-            (errorproc errortype formats)
-            (set! do-parsing #f)
-            ;; NOTE: It seems like this ought to be (set! retval #f) instead,
-            ;;       but that would stop all parsing dead in its tracks. Not
-            ;;       sure that this can happen to anything other than dates,
-            ;;       and those will get reparsed anyway.
-            (set! retval #t))))
-     (else
-      (set! format (car formats))))
-
-    ;; do-parsing is false if there were no objects with non-#f values
-    ;; in the field, or the data format is ambiguous and
-    ;; 'fail-on-ambiguity was passed.  We would have had to look at
-    ;; all of them once, but at least not twice.
-    (if do-parsing
-        (for-each
-          (lambda (current)
-            (let ((val (getter current))
-                  (parsed #f))
-              (if val
-                  (begin
-                    (set! parsed (parser val format))
-                    (if parsed
-                        (setter current parsed)
-                        (begin
-                          (set! retval #f)
-                          (errorproc errortype
-                           (_ "Parsing failed.")))))))
-            (set! work-done (+ 1 work-done))
-            (reporter (/ work-done work-to-do)))
-         objects))
-
-    (if retval
-        (reporter 1))
-
-    retval))
-
-
-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-;;  all-formats-equivalent?
-;;
-;;  This predicate checks for the off chance that even though
-;;  there are multiple possible interpretations they are all the
-;;  same. (i.e. the numbers "1000 2000 3000 4000" could be
-;;  interpreted as decimal or comma radix, but who cares?  The
-;;  values will be the same).
-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-
-(define (all-formats-equivalent? getter parser equiv-thunk formats objects
-                                 printer errorproc errortype)
-  (let ((all-ok #t))
-    (let obj-loop ((objlist objects))
-      (let* ((unparsed (getter (car objlist)))
-             (parsed #f))
-        (if (string? unparsed)
-            (begin
-              ;; Parse using the first format in the list.
-              (set! parsed (parser unparsed (car formats)))
-              ;; For each remaining format, see if the result is the same.
-              (for-each
-               (lambda (fmt)
-                 (let ((this-parsed (parser unparsed fmt)))
-                   (if (not (equiv-thunk parsed this-parsed))
-                       (begin
-                         (set! all-ok #f)
-                         (if (not (eq? errortype 'date))
-                             (errorproc errortype
-                                        (gnc:list-display-to-string (list
-                              (_ "Parse ambiguity between formats") " "
-                              formats "\n"
-                              (sprintf #f (_ "Value '%s' could be %s or %s.")
-                                       parsed
-                                       (printer parsed)
-                                       (printer this-parsed))))))))))
-               (cdr formats))))
-        (if (and all-ok (not (null? (cdr objlist))))
-            (obj-loop (cdr objlist)))))
-    all-ok))
-
-
-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-;;  qif-file:parse-fields-results
-;;
-;;  Take the results from qif-file:parse fields and find the
-;;  first result for a particular type of parse.
-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-
-(define (qif-file:parse-fields-results results type)
-  (define (test-results results)
-    (if (null? results) #f
-        (let* ((this-res (car results))
-               (this-type (car this-res)))
-          (if (eq? this-type type)
-              (cdr this-res)
-              (test-results (cdr results))))))
-
-  (if results (test-results results) #f))

Deleted: gnucash/trunk/src/import-export/qif-import/qif-guess-map.scm
===================================================================
--- gnucash/trunk/src/import-export/qif-import/qif-guess-map.scm	2013-12-15 17:20:10 UTC (rev 23566)
+++ gnucash/trunk/src/import-export/qif-import/qif-guess-map.scm	2013-12-15 17:21:20 UTC (rev 23567)
@@ -1,456 +0,0 @@
-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-;;;  qif-guess-map.scm
-;;;  guess (or load from prefs) mappings from QIF cats/accts to gnc
-;;;
-;;;  Bill Gribble <grib at billgribble.com> 20 Feb 2000
-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-
-(use-modules (srfi srfi-13))
-
-(define GNC-BANK-TYPE 0)
-(define GNC-CASH-TYPE 1)
-(define GNC-ASSET-TYPE 2)
-(define GNC-LIABILITY-TYPE 4)
-(define GNC-CCARD-TYPE 3)
-(define GNC-STOCK-TYPE 5)
-(define GNC-MUTUAL-TYPE 6)
-(define GNC-INCOME-TYPE 8)
-(define GNC-EXPENSE-TYPE 9)
-(define GNC-EQUITY-TYPE 10)
-(define GNC-RECEIVABLE-TYPE 11)
-(define GNC-PAYABLE-TYPE 12)
-
-
-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-;;  qif-import:load-map-prefs
-;;
-;;  Load the saved mappings file, and make a table of all the
-;;  accounts with their full names and pointers for later
-;;  guessing of a mapping.
-;;
-;;  We'll be returning a list with the following members:
-;;   - a list of all the known gnucash accounts in
-;;     (shortname fullname Account*) format
-;;   - a hash of QIF account name to gnucash account info
-;;   - a hash of QIF category to gnucash account info
-;;   - a hash of QIF memo/payee to gnucash account info
-;;     (older saved prefs may not have this one)
-;;   - a hash of QIF security name to gnc-commodity*
-;;   - a list of all previously saved security mappings
-;;     (older saved prefs may not have this one)
-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-
-(define (qif-import:load-map-prefs)
-
-  ;; This procedure builds a list of all descendants of an existing
-  ;; GnuCash account. Each member of the list is itself a list with
-  ;; the form: (shortname fullname Account*)
-  (define (extract-all-account-info an-account root-name)
-    (if (null? an-account)
-        '()
-        (let ((children-list (gnc-account-get-children-sorted an-account))
-              (names '()))
-
-          ;; Recursively walk the account tree.
-          (for-each
-           (lambda (child-acct)
-             (let* ((name (xaccAccountGetName child-acct))
-                    (fullname
-                     (if (string? root-name)
-                         (string-append root-name
-                                        (gnc-get-account-separator-string)
-                                        name)
-                         name)))
-               (set! names
-                     (append (cons (list name fullname child-acct)
-                                   (extract-all-account-info child-acct fullname))
-                             names))))
-           children-list)
-          names)))
-
-  (define (safe-read)
-    (false-if-exception
-     (read)))
-
-  (let* ((pref-filename (gnc-build-dotgnucash-path "qif-accounts-map"))
-         (results '()))
-
-    ;; Get the user's saved mappings.
-    (if (access? pref-filename R_OK)
-        ;; We have access to the mapping file (qif-accounts-map).
-        (with-input-from-file pref-filename
-          (lambda ()
-            (let ((qif-account-list #f)
-                  (qif-cat-list #f)
-                  (qif-memo-list #f)
-                  (qif-security-list #f)
-                  (qif-account-hash #f)
-                  (qif-cat-hash #f)
-                  (qif-memo-hash #f)
-                  (qif-security-hash #f)
-                  (saved-sep #f))
-
-              ;; Read the mapping file.
-              (set! qif-account-list (safe-read))
-              (set! qif-cat-list (safe-read))
-              (set! qif-memo-list (safe-read))
-              (set! qif-security-list (safe-read))
-              (set! saved-sep (safe-read))
-
-              ;; Convert the separator to a string if necessary.
-              ;; It was a character prior to 2.2.6.
-              (if (char? saved-sep)
-                  (set! saved-sep (string saved-sep)))
-
-              ;; Process the QIF account mapping.
-              (if (not (list? qif-account-list))
-                  (set! qif-account-hash (make-hash-table 20))
-                  (set! qif-account-hash
-                        (qif-import:read-map qif-account-list
-                                             saved-sep)))
-
-              ;; Process the QIF category mapping.
-              (if (not (list? qif-cat-list))
-                  (set! qif-cat-hash (make-hash-table 20))
-                  (set! qif-cat-hash (qif-import:read-map qif-cat-list
-                                                          saved-sep)))
-
-              ;; Process the QIF payee/memo mapping.
-              (if (not (list? qif-memo-list))
-                  (set! qif-memo-hash (make-hash-table 20))
-                  (set! qif-memo-hash (qif-import:read-map qif-memo-list
-                                                           saved-sep)))
-
-              ;; Process the QIF security mapping.
-              (if (not (list? qif-security-list))
-                  (set! qif-security-hash (make-hash-table 20))
-                  (set! qif-security-hash (qif-import:read-securities
-                                           qif-security-list)))
-
-              ;; Put all the mappings together in a list.
-              (set! results (list qif-account-hash
-                                  qif-cat-hash
-                                  qif-memo-hash
-                                  qif-security-hash
-                                  qif-security-list)))))
-
-        ;; Otherwise, we can't get any saved mappings. Use empty tables.
-        (set! results (list (make-hash-table 20)
-                            (make-hash-table 20)
-                            (make-hash-table 20)
-                            (make-hash-table 20)
-                            '())))
-
-    ;; Build the list of all known account names.
-    (let* ((all-accounts (gnc-get-current-root-account))
-           (all-account-info (extract-all-account-info all-accounts #f)))
-      (set! results (cons all-account-info results)))
-
-    results))
-
-
-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-;;  qif-import:write-map
-;;
-;;  Writes out a mapping hash table, setting the number of
-;;  transactions to 0 along the way to prevent the creation
-;;  of bogus accounts if you have funny stuff in your map.
-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-
-(define (qif-import:write-map hashtab)
-  (let ((table '()))
-    (hash-fold
-     (lambda (key value p)
-       (set! table (cons (cons key (simple-obj-to-list value)) table))
-       #f) #f hashtab)
-    (write table)))
-
-(define (qif-import:read-map tablist tab-sep)
-  (let* ((table (make-hash-table 20))
-         (sep (gnc-get-account-separator-string))
-         (changed-sep? (and (string? tab-sep) (not (string=? tab-sep sep)))))
-
-    (for-each
-     (lambda (entry)
-       (let ((key (car entry))
-             (value (simple-obj-from-list (cdr entry) <qif-map-entry>)))
-
-         ;; If the account separator has changed, fix the account name.
-         (if changed-sep?
-           (let ((acct-name (qif-map-entry:gnc-name value)))
-             (if (string? acct-name)
-                 (qif-map-entry:set-gnc-name! value
-                                              (gnc:substring-replace acct-name
-                                                                     tab-sep  
-                                                                     sep)))))
-
-         (qif-map-entry:set-display?! value #f)
-         (hash-set! table key value)))
-     tablist)
-    table))
-
-
-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-;;  qif-import:read-securities
-;;
-;;  This procedure examines a list of previously seen security
-;;  mappings and returns a hash table pairing QIF security names
-;;  with existing GnuCash commodities.
-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-
-(define (qif-import:read-securities security-list)
-  (let ((table (make-hash-table 20)))
-    (for-each
-     (lambda (entry)
-       (if (and (list? entry)
-                (= 3 (length entry)))
-           ;; The saved information about each security mapping is a
-           ;; list of three items: the QIF name, and the GnuCash
-           ;; namespace and mnemonic (symbol) to which it maps.
-           ;; Example: ("McDonald's" "NYSE" "MCD")
-           (let ((commodity (gnc-commodity-table-lookup
-                              (gnc-commodity-table-get-table
-                                (gnc-get-current-book))
-                              (cadr entry)
-                              (caddr entry))))
-             (if (and commodity (not (null? commodity)))
-                 ;; There is an existing GnuCash commodity for this
-                 ;; combination of namespace and symbol.
-                 (hash-set! table (car entry) commodity)))))
-     security-list)
-    table))
-
-
-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-;;  qif-import:write-securities
-;;
-;;  This procedure writes a mapping QIF security names to
-;;  GnuCash commodity namespaces and mnemonics (symbols).
-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-
-(define (qif-import:write-securities security-hash security-prefs)
-  (let ((table '()))
-    ;; For each security that has been paired with an existing
-    ;; GnuCash commodity, create a list containing the QIF name
-    ;; and the commodity's namespace and mnemonic (symbol).
-    (hash-fold
-      (lambda (key value p)
-        ;;FIXME: we used to type-check the values, like:
-        ;; (gw:wcp-is-of-type? <gnc:commodity*> value)
-        (if (and value #t)
-            (set! table (cons (list key
-                                   (gnc-commodity-get-namespace value)
-                                   (gnc-commodity-get-mnemonic value))
-                              table))
-            (gnc:warn "qif-import:write-securities:"
-                      " something funny in hash table."))
-        #f)
-      #f security-hash)
-
-    ;; Add on the rest of the saved security mapping preferences.
-    (for-each
-      (lambda (m)
-        (if (not (hash-ref security-hash (car m)))
-            (set! table (cons m table))))
-      security-prefs)
-
-    ;; Write out the mappings.
-    (write table)))
-
-
-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-;;  qif-import:save-map-prefs
-;;
-;;  This procedure saves all the user's mapping preferences to a
-;;  file.  This only gets called when the user clicks the Apply
-;;  button in the druid, so any new mappings will be lost if the
-;;  user cancels the import instead.
-;;
-;;  Returns #t upon success or #f on failure.
-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-
-(define (qif-import:save-map-prefs acct-map cat-map memo-map
-                                   security-map security-prefs)
-
-  ;; This procedure does all the work. We'll define it, then call it safely.
-  (define (private-save)
-    (with-output-to-file (gnc-build-dotgnucash-path "qif-accounts-map")
-      (lambda ()
-        (display ";;; qif-accounts-map")
-        (newline)
-        (display ";;; Automatically generated by GnuCash. DO NOT EDIT.")
-        (newline)
-        (display ";;; (Unless you really, really want to.)")
-        (newline)
-        (display ";;; Map QIF accounts to GnuCash accounts")
-        (newline)
-        (qif-import:write-map acct-map)
-        (newline)
-
-        (display ";;; Map QIF categories to GnuCash accounts")
-        (newline)
-        (qif-import:write-map cat-map)
-        (newline)
-
-        (display ";;; Map QIF payee/memo to GnuCash accounts")
-        (newline)
-        (qif-import:write-map memo-map)
-        (newline)
-
-        (display ";;; Map QIF security names to GnuCash commodities")
-        (newline)
-        (qif-import:write-securities security-map security-prefs)
-        (newline)
-
-        (display ";;; GnuCash separator used in these mappings")
-        (newline)
-        (write (gnc-get-account-separator-string))
-        (newline)))
-    #t)
-
-  ;; Safely save the file.
-  (gnc:backtrace-if-exception private-save))
-
-
-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-;;  here's where we do all the guessing.  We really want to find the
-;;  match in the hash table, but failing that we guess intelligently
-;;  and then (failing that) not so intelligently. called in the
-;;  dialog routines to rebuild the category and account map pages.
-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-
-
-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-;;  guess-acct
-;;
-;;  find an existing gnc acct of the right type and name, or
-;;  specify a type and name for a new one.
-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-
-(define (qif-import:guess-acct acct-name allowed-types gnc-acct-info)
-  ;; see if there's a saved mapping in the hash table or an
-  ;; existing gnucash account with a name that could reasonably
-  ;; be said to be the same name (i.e. ABC Bank == abc bank)
-  (let* ((mapped-gnc-acct
-          (qif-import:find-similar-acct acct-name allowed-types
-                                        gnc-acct-info))
-         (retval (make-qif-map-entry)))
-
-    ;; set fields needed for any return value
-    (qif-map-entry:set-qif-name! retval acct-name)
-    (qif-map-entry:set-allowed-types! retval allowed-types)
-
-    (if mapped-gnc-acct
-        ;; ok, we've found an existing account that
-        ;; seems to work OK name-wise.
-        (begin
-          (qif-map-entry:set-gnc-name! retval (car mapped-gnc-acct))
-          (qif-map-entry:set-allowed-types! retval
-                                            (cadr mapped-gnc-acct))
-          (qif-map-entry:set-new-acct?! retval #f))
-        ;; we haven't found a match, so by default just create a new
-        ;; one.  Try to put the new account in a similar place in
-        ;; the hierarchy if there is one.
-        (let ((new-acct-info
-               (qif-import:find-new-acct acct-name allowed-types
-                                         gnc-acct-info)))
-          (qif-map-entry:set-gnc-name! retval (car new-acct-info))
-          (qif-map-entry:set-allowed-types! retval (cadr new-acct-info))
-          (qif-map-entry:set-new-acct?! retval #t)))
-    retval))
-
-
-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-;;  qif-import:find-similar-acct
-;;
-;;  guess a translation from QIF info
-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-
-(define (qif-import:find-similar-acct qif-acct-name allowed-types
-                                      gnc-acct-info)
-  (let* ((same-type-accts '())
-         (matching-name-accts '())
-         (retval #f))
-    (for-each
-     (lambda (gnc-acct)
-       ;; check against allowed-types
-       (let ((acct-matches? #f))
-         (for-each
-          (lambda (type)
-            (if (= type (xaccAccountGetType (caddr gnc-acct)))
-                (set! acct-matches? #t)))
-          allowed-types)
-         (if acct-matches?
-             (set! same-type-accts (cons gnc-acct same-type-accts)))))
-     gnc-acct-info)
-
-    ;; now find one in the same-type-list with a similar name.
-    (for-each
-     (lambda (gnc-acct)
-       (if (qif-import:possibly-matching-name?
-            qif-acct-name gnc-acct)
-           (set! matching-name-accts
-                 (cons gnc-acct matching-name-accts))))
-     same-type-accts)
-
-    ;; now we have either nothing, something, or too much :)
-    ;; return the full-name of the first name-matching account
-    (if (not (null? matching-name-accts))
-        (set! retval (list
-                      (cadr (car matching-name-accts))
-                      (list (xaccAccountGetType
-                             (caddr (car matching-name-accts))))))
-        #f)
-    retval))
-
-
-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-;;  qif-import:possibly-matching-name?
-;;
-;;  try various normalizations and permutations of the names
-;;  to see if they could be the same.
-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-
-(define (qif-import:possibly-matching-name? qif-acct-name gnc-acct)
-  (or
-   ;; the QIF acct is the same name as the short name of the
-   ;; gnc acct [ignoring case] (likely)
-   (string=? (string-downcase  qif-acct-name)
-             (string-downcase (car gnc-acct)))
-
-   ;; the QIF acct is the same name as the long name of the
-   ;; gnc acct [ignoring case] (not so likely)
-   (string=? (string-downcase qif-acct-name)
-             (string-downcase (cadr gnc-acct)))
-
-   ;; the QIF name is a substring of the gnc full name.
-   ;; this happens if you have the same tree but a different
-   ;; top-level structure. (i.e. expenses:tax vs. QIF tax)
-   (and (> (string-length qif-acct-name) 0)
-        (string-contains (string-downcase (cadr gnc-acct))
-                         (string-downcase qif-acct-name)))))
-
-
-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-;;  qif-import:find-new-acct
-;;
-;;  Come up with a logical name for a new account based on
-;;  the Quicken name and type of the account
-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-
-(define (qif-import:find-new-acct qif-acct allowed-types gnc-acct-info)
-  (cond ((and (string? qif-acct)
-              (string=? qif-acct (default-equity-account)))
-         (let ((existing-equity
-                (qif-import:find-similar-acct (default-equity-account)
-                                              (list GNC-EQUITY-TYPE)
-                                              gnc-acct-info)))
-           (if existing-equity
-               existing-equity
-               (list (default-equity-account) (list GNC-EQUITY-TYPE)))))
-        ((and (string? qif-acct)
-              (not (string=? qif-acct "")))
-         (list qif-acct allowed-types))
-        (#t
-         (list (default-unspec-acct) allowed-types))))
-

Deleted: gnucash/trunk/src/import-export/qif-import/qif-import.scm
===================================================================
--- gnucash/trunk/src/import-export/qif-import/qif-import.scm	2013-12-15 17:20:10 UTC (rev 23566)
+++ gnucash/trunk/src/import-export/qif-import/qif-import.scm	2013-12-15 17:21:20 UTC (rev 23567)
@@ -1,81 +0,0 @@
-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-;;;  qif-import.scm
-;;;  virtual loader for QIF import facility
-;;;
-;;;  Bill Gribble <grib at billgribble.com> 20 Feb 2000
-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-
-(define-module (gnucash import-export qif-import))
-(use-modules (gnucash main)) ;; FIXME: delete after we finish modularizing.
-
-;; We do this initialization here because src/gnome isn't a real module.
-;; Note: Guile 2 needs to find the symbols from the extension at compile time already
-(cond-expand
-  (guile-2
-    (eval-when
-      (compile load eval expand)
-      (load-extension "libgnc-gnome" "scm_init_sw_gnome_module")))
-  (else
-    (load-extension "libgnc-gnome" "scm_init_sw_gnome_module")))
-
-(use-modules (sw_gnome))
-
-(use-modules (gnucash gnc-module))
-(use-modules (ice-9 regex))
-(use-modules (srfi srfi-1))
-
-(debug-enable 'debug)
-(debug-enable 'backtrace)
-
-(gnc:module-load "gnucash/engine" 0)
-(gnc:module-load "gnucash/app-utils" 0)
-(gnc:module-load "gnucash/gnome-utils" 0)
-
-(load-from-path "qif-import/qif-objects.scm")      ;; class definitions
-(load-from-path "qif-import/qif-parse.scm")        ;; string-to-value
-(load-from-path "qif-import/qif-utils.scm")
-(load-from-path "qif-import/qif-file.scm")         ;; actual file reading
-(load-from-path "qif-import/qif-dialog-utils.scm") ;; build displays
-(load-from-path "qif-import/qif-guess-map.scm")    ;; build acct mappings
-(load-from-path "qif-import/qif-to-gnc.scm")       ;; conv QIF xtns to GNC
-(load-from-path "qif-import/qif-merge-groups.scm") ;; merge into user's acct
-
-(export make-qif-file)
-(export make-ticker-map)
-(export qif-import:get-all-accts)
-(export qif-import:fix-from-acct)
-(export qif-import:any-new-accts?)
-(export qif-import:update-security-hash)
-(export qif-import:refresh-match-selection)
-(export qif-import:save-map-prefs)
-(export qif-import:load-map-prefs)
-(export qif-import:qif-to-gnc)
-(export qif-import:qif-to-gnc-undo)
-(export qif-import:reset-cancel-pause)
-(export qif-import:cancel)
-(export qif-import:toggle-pause)
-
-(export qif-map-entry:gnc-name)
-(export qif-map-entry:set-gnc-name!)
-(export qif-map-entry:clone)
-(export qif-map-entry:qif-name)
-(export qif-map-entry:new-acct?)
-
-(export qif-file:read-file)
-(export qif-file:parse-fields)
-(export qif-file:parse-fields-results)
-(export qif-file:check-from-acct)
-(export qif-file:reparse-dates)
-(export qif-file:check-from-acct)
-(export qif-file:path-to-accountname)
-(export qif-file:path)
-
-(export qif-dialog:qif-file-loaded?)
-(export qif-dialog:unload-qif-file)
-(export qif-dialog:make-account-display)
-(export qif-dialog:make-category-display)
-(export qif-dialog:make-memo-display)
-
-(export gnc:account-tree-find-duplicates)
-(export gnc:account-tree-catenate-and-merge)
-(export gnc:prune-matching-transactions)

Deleted: gnucash/trunk/src/import-export/qif-import/qif-merge-groups.scm
===================================================================
--- gnucash/trunk/src/import-export/qif-import/qif-merge-groups.scm	2013-12-15 17:20:10 UTC (rev 23566)
+++ gnucash/trunk/src/import-export/qif-import/qif-merge-groups.scm	2013-12-15 17:21:20 UTC (rev 23567)
@@ -1,265 +0,0 @@
-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-;;;  qif-merge-groups.scm
-;;;  eliminate duplicate xtns in a new (imported) account group
-;;;
-;;;  Copyright 2001 Bill Gribble <grib at billgribble.com>
-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-
-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-;;  gnc:account-tree-get-transactions
-;;
-;;  Given an account tree, this procedure returns a list of all
-;;  transactions whose splits only use accounts in the tree.
-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-(define (gnc:account-tree-get-transactions root)
-  (let ((accounts (gnc-account-get-descendants-sorted root)))
-    (if (null? accounts)
-        '()
-        (let ((query (qof-query-create-for-splits))
-              (xtns #f))
-
-          (qof-query-set-book query (gnc-account-get-book root))
-
-          ;; we want to find all transactions with every split inside the
-          ;; account group.
-          (xaccQueryAddAccountMatch query accounts
-                                    QOF-GUID-MATCH-ANY QOF-QUERY-AND)
-
-          (set! xtns (xaccQueryGetTransactions query QUERY-TXN-MATCH-ALL))
-
-          ;; lose the query
-          (qof-query-destroy query)
-          xtns))))
-
-
-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-;;  gnc:account-tree-find-duplicates
-;;
-;;  Given two account trees, old-root and new-root, a search is
-;;  performed to determine, for each transaction in new-root,
-;;  whether there are any transactions in old-root that may be
-;;  duplicated by it.
-;;
-;;  The search results are returned in an association list, with
-;;  new-root transactions as the keys. The value associated with
-;;  each key is a second association list of possibly duplicated
-;;  transactions in the old-root, taking the form:
-;;  ( (old-xtn . #f) (old-xtn . #f) (old-xtn . #f) ... )
-;;
-;;  The druid can then ask the user for a final determination,
-;;  and change #f to #t where duplication is found.
-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-
-(define (gnc:account-tree-find-duplicates old-root new-root progress-dialog)
-
-  ;; This procedure does all the work. We'll define it, then call it safely.
-  (define (private-find)
-
-    ;; Given a list of accounts, this predicate returns true if any
-    ;; of those accounts are involved in a transaction.
-    (define (has-any-xtns? acctlist)
-      (if (null? acctlist)
-          #f
-          (let ((splits (xaccAccountGetSplitList (car acctlist))))
-            (if (null? splits)
-                (has-any-xtns? (cdr acctlist))
-                #t))))
-
-
-    (let ((old-accounts (gnc-account-get-descendants-sorted old-root)))
-      (if (has-any-xtns? old-accounts)
-          ;; Get all the transactions in the new tree, then iterate over them
-          ;; trying to find matches in the old tree.  If there are matches,
-          ;; push the matches onto a list.
-          (let* ((new-xtns (gnc:account-tree-get-transactions new-root))
-                 (work-to-do (length new-xtns))
-                 (work-done 0)
-                 (matches '()))
-
-            ;; This procedure handles progress reporting, pause, and cancel.
-            (define (update-progress)
-              (set! work-done (+ 1 work-done))
-              (if (and progress-dialog
-                       (zero? (remainder work-done 8)))
-                  (begin
-                    (gnc-progress-dialog-set-value progress-dialog
-                                                   (/ work-done work-to-do))
-                    (qif-import:check-pause progress-dialog)
-                    (if qif-import:canceled
-                        (throw 'cancel)))))
-
-
-            (if progress-dialog
-                (gnc-progress-dialog-set-sub progress-dialog
-                                         (_ "Finding duplicate transactions")))
-
-            ;; For each transaction in the new account tree, build a query
-            ;; that matches possibly duplicate transactions in the old tree.
-            (for-each
-              (lambda (xtn)
-                (let ((query (qof-query-create-for-splits))
-                      (num-splits 0))
-                  (qof-query-set-book query (gnc-account-get-book old-root))
-
-                  ;; First, we only want to find only transactions
-                  ;; from accounts in the old tree.
-                  (xaccQueryAddAccountMatch query
-                                            old-accounts
-                                            QOF-GUID-MATCH-ANY QOF-QUERY-AND)
-
-                  ;; The date should be close to the same.. +/- a week.
-                  (let ((date (gnc-transaction-get-date-posted xtn)))
-                    (xaccQueryAddDateMatchTS query #t
-                                             (decdate date WeekDelta) #t
-                                             (incdate date WeekDelta)
-                                             QOF-QUERY-AND))
-
-                  ;; For each split in the new transaction, add a
-                  ;; term that can match on its properties.
-                  (let ((q-splits (qof-query-create-for-splits)))
-                    (for-each
-                      (lambda (split)
-                        (set! num-splits (+ num-splits 1))
-                        (let ((sq (qof-query-create-for-splits)))
-                          (qof-query-set-book sq (gnc-account-get-book old-root))
-
-                          ;; Require a match on the account name. If the name
-                          ;; doesn't exist in the old tree (indicating a new
-                          ;; account), the match will be NULL and the query
-                          ;; won't find anything.  Optimize this later.
-                          (xaccQueryAddSingleAccountMatch
-                            sq
-                            (gnc-account-lookup-by-full-name old-root
-                              (gnc-account-get-full-name
-                                (xaccSplitGetAccount split)))
-                            QOF-QUERY-AND)
-
-                          ;; Require the value of the split in the new tree
-                          ;; to match the the value of the split in the old
-                          ;; tree.  We should really check for fuzziness.
-                          (xaccQueryAddValueMatch sq
-                                                  (xaccSplitGetValue split)
-                                                  QOF-NUMERIC-MATCH-ANY
-                                                  QOF-COMPARE-EQUAL
-                                                  QOF-QUERY-AND)
-
-                          ;; Now merge into the split query.  Reminder: q-splits
-                          ;; must be merged with an OR. Otherwise, nothing will
-                          ;; match. (For example, something can be equal to 4 or
-                          ;; to -4, but not both.)
-                          (let ((q-new (qof-query-merge q-splits
-                                                        sq
-                                                        QOF-QUERY-OR)))
-                            (qof-query-destroy q-splits)
-                            (qof-query-destroy sq)
-                            (set! q-splits q-new))))
-                      (xaccTransGetSplitList xtn))
-
-                    ;; Now q-splits will find every split that is the same as
-                    ;; any one split of the new-root transaction.  Merge it in.
-                    (let ((q-new (qof-query-merge query
-                                                  q-splits
-                                                  QOF-QUERY-AND)))
-                      (qof-query-destroy query)
-                      (qof-query-destroy q-splits)
-                      (set! query q-new)))
-
-                  ;; Now that we have built a query that finds matching splits
-                  ;; in the old tree, run it and build a list of transactions
-                  ;; from the results.
-                  ;;
-                  ;; If the transaction from the new tree has more than two
-                  ;; splits, then we'll assume that it fully reflects what
-                  ;; occurred, and only consider transactions in the old tree
-                  ;; that match with every single split.
-                  ;;
-                  ;; All other new transactions could be incomplete, so we'll
-                  ;; consider transactions from the old tree to be possible
-                  ;; duplicates even if only one split matches.
-                  ;;
-                  ;; For more information, see bug 481528.
-                  (let ((old-xtns (xaccQueryGetTransactions
-                                    query
-                                    (if (> num-splits 2)
-                                        QUERY-TXN-MATCH-ALL
-                                        QUERY-TXN-MATCH-ANY))))
-
-                    ;; Turn the resulting list of possibly duplicated
-                    ;; transactions into an association list.
-                    (set! old-xtns (map
-                                     (lambda (elt)
-                                       (cons elt #f)) old-xtns))
-
-                    ;; If anything matched the query, add it to our "matches"
-                    ;; association list, keyed by the new-root transaction.
-                    (if (not (null? old-xtns))
-                        (set! matches (cons (cons xtn old-xtns) matches))))
-
-                  (qof-query-destroy query))
-                (update-progress))
-              new-xtns)
-
-            ;; Finished.
-            (if progress-dialog
-                (gnc-progress-dialog-set-value progress-dialog 1))
-
-            ;; Return the matches.
-            matches)
-
-          ;; Since there are either no accounts or no transactions in the old
-          ;; tree, duplicate checking is unnecessary.
-          (begin
-            ;; Finished.
-            (if progress-dialog
-                (gnc-progress-dialog-set-value progress-dialog 1))
-
-            ;; Return an empty list.
-            '()))))
-
-  ;; Safely do the work and return the result.
-  (gnc:backtrace-if-exception
-    (lambda () (catch 'cancel private-find (lambda (key . args) #t)))))
-
-
-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-;;  gnc:prune-matching-transactions
-;;
-;;  The parameter, match-list, is an association list of the form
-;;  returned by gnc:account-tree-find-duplicates. This procedure
-;;  looks through the list and discards any transaction that has
-;;  been definitively determined to be a duplicate of one of the
-;;  possible matches.
-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-
-(define (gnc:prune-matching-transactions match-list)
-  (for-each
-   (lambda (match)
-     (let ((new-xtn (car match))
-           (matches (cdr match))
-           (do-delete #f))
-       (for-each
-        (lambda (old)
-          (if (cdr old)
-              (set! do-delete #t)))
-        matches)
-       (if do-delete
-           (begin
-             (xaccTransBeginEdit new-xtn)
-             (xaccTransDestroy new-xtn)
-             (xaccTransCommitEdit new-xtn)))))
-   match-list))
-
-
-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-;;  gnc:account-tree-catenate-and-merge
-;;
-;;  The procedure moves the entire contents of one account tree,
-;;  new-root, to a second account tree, old-root, and merges any
-;;  duplicated accounts.
-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-(define (gnc:account-tree-catenate-and-merge old-root new-root)
-  ;; stuff the new accounts into the old account tree and merge the accounts
-  (gnc-account-join-children old-root new-root)
-  (xaccAccountBeginEdit new-root)
-  (xaccAccountDestroy new-root)
-  (gnc-account-merge-children old-root))

Deleted: gnucash/trunk/src/import-export/qif-import/qif-objects.scm
===================================================================
--- gnucash/trunk/src/import-export/qif-import/qif-objects.scm	2013-12-15 17:20:10 UTC (rev 23566)
+++ gnucash/trunk/src/import-export/qif-import/qif-objects.scm	2013-12-15 17:21:20 UTC (rev 23567)
@@ -1,690 +0,0 @@
-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-;;;  qif-objects.scm
-;;;  representations for parts of an imported Quicken file.  
-;;;
-;;;  Bill Gribble <grib at billgribble.com> 20 Feb 2000 
-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-
-
-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-;;  qif-file class 
-;;  xtns         : list of <qif-xtn>  
-;;  accounts     : list of <qif-acct>  
-;;  cats         : list of <qif-cat>  
-;;  classes      : list of <qif-class>  
-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-
-(define <qif-file>
-  (make-simple-class 
-   'qif-file 
-   '(path                 ;; where file was loaded 
-     y2k-threshold
-     xtns                
-     accounts 
-     cats
-     classes)))
-
-(define qif-file?
-  (record-predicate <qif-file>))
-
-(define qif-file:path 
-  (simple-obj-getter <qif-file> 'path))
-
-(define qif-file:set-path! 
-  (simple-obj-setter <qif-file> 'path))
-
-(define qif-file:y2k-threshold 
-  (simple-obj-getter <qif-file> 'y2k-threshold))
-
-(define qif-file:set-y2k-threshold!
-  (simple-obj-setter <qif-file> 'y2k-threshold))
-
-(define qif-file:cats 
-  (simple-obj-getter <qif-file> 'cats))
-
-(define qif-file:set-cats!
-  (simple-obj-setter <qif-file> 'cats))
-
-(define qif-file:classes 
-  (simple-obj-getter <qif-file> 'classes))
-
-(define qif-file:set-classes!
-  (simple-obj-setter <qif-file> 'classes))
-
-(define qif-file:xtns 
-  (simple-obj-getter <qif-file> 'xtns))
-
-(define qif-file:set-xtns!
-  (simple-obj-setter <qif-file> 'xtns))
-
-(define qif-file:accounts 
-  (simple-obj-getter <qif-file> 'accounts))
-
-(define qif-file:set-accounts!
-  (simple-obj-setter <qif-file> 'accounts))
-
-(define (make-qif-file) 
-  (let ((self (make-simple-obj <qif-file>)))
-    (qif-file:set-y2k-threshold! self 50)
-    (qif-file:set-xtns! self '())
-    (qif-file:set-accounts! self '())
-    (qif-file:set-cats! self '())
-    (qif-file:set-classes! self '())
-    self))
-
-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-;;  qif-split class 
-;;  this is for bank/ccard accounts only. 
-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-
-(define <qif-split>
-  (make-simple-class 
-   'qif-split
-   '(category class memo amount category-is-account? matching-cleared mark
-              miscx-category miscx-is-account? miscx-class)))
-
-(define qif-split:category 
-  (simple-obj-getter <qif-split> 'category))
-
-(define qif-split:set-category-private!
-  (simple-obj-setter <qif-split> 'category))
-
-(define (qif-split:set-category! self value)
-  (let* ((cat-info 
-          (qif-split:parse-category self value))
-         (cat-name (list-ref cat-info 0))
-         (is-account? (list-ref cat-info 1))
-         (class-name (list-ref cat-info 2))
-         (miscx-name (list-ref cat-info 3))
-         (miscx-is-account? (list-ref cat-info 4))
-         (miscx-class (list-ref cat-info 5)))
-    (qif-split:set-category-private! self cat-name)
-    (qif-split:set-class! self class-name)
-    (qif-split:set-category-is-account?! self is-account?)
-    (qif-split:set-miscx-category! self miscx-name)
-    (qif-split:set-miscx-is-account?! self miscx-is-account?)
-    (qif-split:set-miscx-class! self miscx-class)))
-    
-(define qif-split:class 
-  (simple-obj-getter <qif-split> 'class))
-
-(define qif-split:set-class!
-  (simple-obj-setter <qif-split> 'class))
-
-(define qif-split:memo 
-  (simple-obj-getter <qif-split> 'memo))
-
-(define qif-split:set-memo! 
-  (simple-obj-setter <qif-split> 'memo))
-
-(define qif-split:amount 
-  (simple-obj-getter <qif-split> 'amount))
-
-(define qif-split:set-amount! 
-  (simple-obj-setter <qif-split> 'amount))
-
-(define qif-split:mark 
-  (simple-obj-getter <qif-split> 'mark))
-
-(define qif-split:set-mark! 
-  (simple-obj-setter <qif-split> 'mark))
-
-(define qif-split:matching-cleared 
-  (simple-obj-getter <qif-split> 'matching-cleared))
-
-(define qif-split:set-matching-cleared! 
-  (simple-obj-setter <qif-split> 'matching-cleared))
-
-(define qif-split:category-is-account? 
-  (simple-obj-getter <qif-split> 'category-is-account?))
-
-(define qif-split:set-category-is-account?! 
-  (simple-obj-setter <qif-split> 'category-is-account?))
-
-(define qif-split:miscx-is-account? 
-  (simple-obj-getter <qif-split> 'miscx-is-account?))
-
-(define qif-split:set-miscx-is-account?!
-  (simple-obj-setter <qif-split> 'miscx-is-account?))
-
-(define qif-split:miscx-category 
-  (simple-obj-getter <qif-split> 'miscx-category))
-
-(define qif-split:set-miscx-category!
-  (simple-obj-setter <qif-split> 'miscx-category))
-
-(define qif-split:miscx-class 
-  (simple-obj-getter <qif-split> 'miscx-class))
-
-(define qif-split:set-miscx-class!
-  (simple-obj-setter <qif-split> 'miscx-class))
-
-(define (make-qif-split)
-  (let ((self (make-simple-obj <qif-split>)))
-    (qif-split:set-category! self "")
-    self))
-
-
-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-;;  qif-xtn class 
-;;  [D] date       : parsed. 
-;;  [P] payee      : string 
-;;  [N] number (check number, sell, or buy)
-;;  [C] cleared    : parsed (x/X/*) ;
-;;  [T] amount     : parsed, units are currency of dest account
-;;  [I] share price : parsed
-;;  [Q] number of shares
-;;  [Y] name of security 
-;;  [O] commission (parsed)
-;;  [L] category   : string 
-;;  [S]/[E]/[$] splits : a list of <qif-split>
-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-
-(define <qif-xtn>
-  (make-simple-class 
-   'qif-xtn
-   '(date payee address number action cleared  
-          from-acct share-price num-shares security-name commission 
-          default-split splits mark)))
-
-(define qif-xtn?
-  (record-predicate <qif-xtn>))
-
-(define qif-xtn:date
-  (simple-obj-getter <qif-xtn> 'date))
-
-(define qif-xtn:set-date! 
-  (simple-obj-setter <qif-xtn> 'date))
-
-(define qif-xtn:payee
-  (simple-obj-getter <qif-xtn> 'payee))
-
-(define qif-xtn:set-payee! 
-  (simple-obj-setter <qif-xtn> 'payee))
-
-(define qif-xtn:address
-  (simple-obj-getter <qif-xtn> 'address))
-
-(define qif-xtn:set-address! 
-  (simple-obj-setter <qif-xtn> 'address))
-
-(define qif-xtn:number
-  (simple-obj-getter <qif-xtn> 'number))
-
-(define qif-xtn:set-number! 
-  (simple-obj-setter <qif-xtn> 'number))
-
-(define qif-xtn:action
-  (simple-obj-getter <qif-xtn> 'action))
-
-(define qif-xtn:set-action! 
-  (simple-obj-setter <qif-xtn> 'action))
-
-(define qif-xtn:cleared
-  (simple-obj-getter <qif-xtn> 'cleared))
-
-(define qif-xtn:set-cleared! 
-  (simple-obj-setter <qif-xtn> 'cleared))
-
-(define qif-xtn:from-acct
-  (simple-obj-getter <qif-xtn> 'from-acct))
-
-(define qif-xtn:set-from-acct! 
-  (simple-obj-setter <qif-xtn> 'from-acct))
-
-(define qif-xtn:share-price
-  (simple-obj-getter <qif-xtn> 'share-price))
-
-(define qif-xtn:set-share-price! 
-  (simple-obj-setter <qif-xtn> 'share-price))
-
-(define qif-xtn:num-shares
-  (simple-obj-getter <qif-xtn> 'num-shares))
-
-(define qif-xtn:set-num-shares! 
-  (simple-obj-setter <qif-xtn> 'num-shares))
-
-(define qif-xtn:security-name
-  (simple-obj-getter <qif-xtn> 'security-name))
-
-(define qif-xtn:set-security-name! 
-  (simple-obj-setter <qif-xtn> 'security-name))
-
-(define qif-xtn:commission
-  (simple-obj-getter <qif-xtn> 'commission))
-
-(define qif-xtn:set-commission! 
-  (simple-obj-setter <qif-xtn> 'commission))
-
-(define qif-xtn:default-split
-  (simple-obj-getter <qif-xtn> 'default-split))
-
-(define qif-xtn:set-default-split! 
-  (simple-obj-setter <qif-xtn> 'default-split))
-
-(define qif-xtn:splits
-  (simple-obj-getter <qif-xtn> 'splits))
-
-(define qif-xtn:set-splits! 
-  (simple-obj-setter <qif-xtn> 'splits))
-
-(define qif-xtn:mark
-  (simple-obj-getter <qif-xtn> 'mark))
-
-(define qif-xtn:set-mark! 
-  (simple-obj-setter <qif-xtn> 'mark))
-
-(define (make-qif-xtn)
-  (let ((self (make-simple-obj <qif-xtn>)))
-    (qif-xtn:set-mark! self #f)
-    (qif-xtn:set-splits! self '())
-    self))
-
-(define (qif-xtn:print self)
-  (simple-obj-print self))
-
-
-(define (qif-xtn:split-amounts self)
-  (let ((def-spl (qif-xtn:default-split self))
-	(spl-lst (qif-xtn:splits self)))
-    (map
-     (lambda (split)
-       (qif-split:amount split))
-     (if def-spl (cons def-spl spl-lst) spl-lst))))
-
-(define (qif-xtn:set-split-amounts! self amounts)
-  (define (set-amounts neg? amounts)
-    (map 
-     (lambda (split amount)
-       (qif-split:set-amount! split (if neg? (gnc-numeric-neg amount) amount)))
-     (qif-xtn:splits self) amounts))
-
-  (define (need-neg amounts)
-    (let ((sum (gnc-numeric-zero)))
-      (for-each
-       (lambda (amt)
-	 (set! sum (gnc-numeric-add sum amt 0 GNC-DENOM-LCD)))
-       amounts)
-      (gnc-numeric-zero-p sum)))
-
-  (let ((def-spl (qif-xtn:default-split self)))
-    (if def-spl
-	(set-amounts (need-neg amounts) (cdr amounts))
-	(set-amounts #f amounts))))
-
-
-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-;;  <qif-acct>
-;;  [N] name         : string 
-;;  [T] type         : string 
-;;  [D] description  : string 
-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-
-(define <qif-acct>
-  (make-simple-class 
-   'qif-acct
-   '(name type description limit budget)))
-
-(define qif-acct:name
-  (simple-obj-getter <qif-acct> 'name))
-
-(define qif-acct:set-name! 
-  (simple-obj-setter <qif-acct> 'name))
-
-(define qif-acct:type
-  (simple-obj-getter <qif-acct> 'type))
-
-(define qif-acct:set-type! 
-  (simple-obj-setter <qif-acct> 'type))
-
-(define qif-acct:description
-  (simple-obj-getter <qif-acct> 'description))
-
-(define qif-acct:set-description! 
-  (simple-obj-setter <qif-acct> 'description))
-
-(define qif-acct:limit
-  (simple-obj-getter <qif-acct> 'limit))
-
-(define qif-acct:set-limit! 
-  (simple-obj-setter <qif-acct> 'limit))
-
-(define qif-acct:budget
-  (simple-obj-getter <qif-acct> 'budget))
-
-(define qif-acct:set-budget! 
-  (simple-obj-setter <qif-acct> 'budget))
-
-(define (make-qif-acct)
-  (let ((retval (make-simple-obj <qif-acct>)))
-    (qif-acct:set-type! retval "Bank")
-    (qif-acct:set-name! retval "Default Account")
-    retval))
-
-(define qif-acct? 
-  (record-predicate <qif-acct>))
-
-(define (qif-acct:print self)
-  (simple-obj-print self))
-
-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-;;  <qif-class>
-;;  [N] name         : string 
-;;  [D] description  : string 
-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-
-(define <qif-class>
-  (make-simple-class
-   'qif-class
-   '(name description)))
-
-(define qif-class:name
-  (simple-obj-getter <qif-class> 'name))
-
-(define qif-class:set-name! 
-  (simple-obj-setter <qif-class> 'name))
-
-(define qif-class:description
-  (simple-obj-getter <qif-class> 'description))
-
-(define qif-class:set-description! 
-  (simple-obj-setter <qif-class> 'description))
-
-(define (qif-class:print self)
-  (simple-obj-print self))
-
-(define (make-qif-class)
-  (make-simple-obj <qif-class>))
-
-(define qif-class? 
-  (record-predicate <qif-class>))
-
-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-;;  <qif-cat> : a "Cat" or category transaction
-;;  [N] name         : string 
-;;  [D] description  : string 
-;;  [T] taxable      : boolean 
-;;  [E] expense?     : boolean
-;;  [I] income?      : boolean 
-;;  [R] tax rate     : number 
-;;  [B] budget amt   : number 
-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-
-
-(define <qif-cat>
-  (make-simple-class 
-   'qif-cat
-   '(name description taxable expense-cat income-cat tax-class budget-amt)))
-
-(define qif-cat:name
-  (simple-obj-getter <qif-cat> 'name))
-
-(define qif-cat:set-name! 
-  (simple-obj-setter <qif-cat> 'name))
-
-(define qif-cat:description
-  (simple-obj-getter <qif-cat> 'description))
-
-(define qif-cat:set-description! 
-  (simple-obj-setter <qif-cat> 'description))
-
-(define qif-cat:taxable
-  (simple-obj-getter <qif-cat> 'taxable))
-
-(define qif-cat:set-taxable! 
-  (simple-obj-setter <qif-cat> 'taxable))
-
-(define qif-cat:expense-cat
-  (simple-obj-getter <qif-cat> 'expense-cat))
-
-(define qif-cat:set-expense-cat! 
-  (simple-obj-setter <qif-cat> 'expense-cat))
-
-(define qif-cat:income-cat
-  (simple-obj-getter <qif-cat> 'income-cat))
-
-(define qif-cat:set-income-cat! 
-  (simple-obj-setter <qif-cat> 'income-cat))
-
-(define qif-cat:tax-class
-  (simple-obj-getter <qif-cat> 'tax-class))
-
-(define qif-cat:set-tax-class! 
-  (simple-obj-setter <qif-cat> 'tax-class))
-
-(define qif-cat:budget-amt
-  (simple-obj-getter <qif-cat> 'budget-amt))
-
-(define qif-cat:set-budget-amt! 
-  (simple-obj-setter <qif-cat> 'budget-amt))
-
-(define (make-qif-cat) 
-  (make-simple-obj <qif-cat>))
-
-(define qif-cat? 
-  (record-predicate <qif-cat>))
-
-(define (qif-cat:print self)
-  (simple-obj-print self))
-
-(define (qif-file:add-xtn! self xtn)
-  (qif-file:set-xtns! self 
-                      (cons xtn (qif-file:xtns self))))
-
-(define (qif-file:add-cat! self cat)
-  (qif-file:set-cats! self 
-                      (cons cat (qif-file:cats self))))
-
-(define (qif-file:add-class! self class)
-  (qif-file:set-classes! self 
-                         (cons class (qif-file:classes self))))
-
-(define (qif-file:add-account! self account)
-  (qif-file:set-accounts! self 
-                          (cons account (qif-file:accounts self))))
-
-
-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-;;  munge the QIF filename to create a simple default account name 
-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-
-(define (qif-file:path-to-accountname self)
-  (let ((namestring (qif-file:path self)))
-    (if (and (string? namestring)
-             (> (string-length namestring) 0))
-        (begin 
-          (set! namestring 
-                (substring namestring 
-                           (let ((last-slash (string-rindex namestring #\/)))
-                             (if last-slash 
-                                 (+ 1 last-slash) 
-                                 0))
-                           (let ((last-dot (string-rindex namestring #\.)))
-                             (if last-dot 
-                                 last-dot 
-                                 (string-length namestring)))))
-          (set! namestring (string-replace-char! namestring #\- #\space))
-          (set! namestring (string-replace-char! namestring #\_ #\space))
-          namestring)
-        "QIF Import")))
-
-
-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-;; qif-map-entry class
-;; information for mapping a QIF account/category name to a
-;; gnucash name.
-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-
-(define <qif-map-entry>
-  (make-simple-class
-   'qif-map-entry
-   '(qif-name       ;; set while parsing file 
-     allowed-types  ;; set while parsing file 
-     description    ;; from QIF acct, if there is one 
-     gnc-name       ;; set from guess-map 
-     new-acct?      ;; set from guess-map
-     display?)))    ;; set when non-zero transactions 
-
-(define (make-qif-map-entry)
-  (make-simple-obj <qif-map-entry>))
-
-(define (qif-map-entry:clone orig)
-  (let ((me (make-qif-map-entry)))
-    (qif-map-entry:set-qif-name! me (qif-map-entry:qif-name orig))
-    (qif-map-entry:set-allowed-types! me (qif-map-entry:allowed-types orig))
-    (qif-map-entry:set-description! me (qif-map-entry:description orig))
-    (qif-map-entry:set-gnc-name! me (qif-map-entry:gnc-name orig))
-    (qif-map-entry:set-new-acct?! me (qif-map-entry:new-acct? orig))
-    (qif-map-entry:set-display?! me (qif-map-entry:display? orig))
-    me))
-
-(define (qif-map-entry:allowed-parent-types self) 
-  (let ((types-list (reverse (qif-map-entry:allowed-types self))))
-    (define (add-types . rest)
-      (for-each 
-       (lambda (t)
-         (if (not (memv t types-list))
-             (set! types-list (cons t types-list))))
-       rest))
-    
-    (for-each 
-     (lambda (t)
-       (cond 
-        ((memv t (list GNC-BANK-TYPE GNC-CASH-TYPE GNC-CCARD-TYPE 
-                       GNC-STOCK-TYPE GNC-MUTUAL-TYPE
-                       GNC-ASSET-TYPE GNC-LIABILITY-TYPE
-                       GNC-RECEIVABLE-TYPE GNC-PAYABLE-TYPE))
-         (add-types GNC-BANK-TYPE GNC-CASH-TYPE GNC-CCARD-TYPE 
-                    GNC-STOCK-TYPE GNC-MUTUAL-TYPE
-                    GNC-ASSET-TYPE GNC-LIABILITY-TYPE
-                    GNC-RECEIVABLE-TYPE GNC-PAYABLE-TYPE))
-        ((memv t (list GNC-INCOME-TYPE GNC-EXPENSE-TYPE))
-         (add-types GNC-INCOME-TYPE GNC-EXPENSE-TYPE))
-        (#t
-         (add-types t))))
-     (qif-map-entry:allowed-types self))
-    (reverse types-list)))
-
-
-(define qif-map-entry:qif-name
-  (simple-obj-getter <qif-map-entry> 'qif-name))
-
-(define qif-map-entry:set-qif-name!
-  (simple-obj-setter <qif-map-entry> 'qif-name))
-
-(define qif-map-entry:allowed-types
-  (simple-obj-getter <qif-map-entry> 'allowed-types))
-
-(define qif-map-entry:set-allowed-types!
-  (simple-obj-setter <qif-map-entry> 'allowed-types))
-
-(define qif-map-entry:description
-  (simple-obj-getter <qif-map-entry> 'description))
-
-(define qif-map-entry:set-description!
-  (simple-obj-setter <qif-map-entry> 'description))
-
-(define qif-map-entry:gnc-name
-  (simple-obj-getter <qif-map-entry> 'gnc-name))
-
-(define qif-map-entry:set-gnc-name!
-  (simple-obj-setter <qif-map-entry> 'gnc-name))
-
-(define qif-map-entry:new-acct?
-  (simple-obj-getter <qif-map-entry> 'new-acct?))
-
-(define qif-map-entry:set-new-acct?!
-  (simple-obj-setter <qif-map-entry> 'new-acct?))
-
-(define qif-map-entry:display?
-  (simple-obj-getter <qif-map-entry> 'display?))
-
-(define qif-map-entry:set-display?!
-  (simple-obj-setter <qif-map-entry> 'display?))
-
-
-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-;;  <qif-stock-symbol>
-;;  [N] stock name     : string 
-;;  [S] ticker symbol  : string 
-;;  [T] type           : string 
-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-
-(define <qif-stock-symbol>
-  (make-simple-class
-   'qif-stock-symbol
-   '(name symbol type)))
-
-(define qif-stock-symbol:name
-  (simple-obj-getter <qif-stock-symbol> 'name))
-
-(define qif-stock-symbol:set-name! 
-  (simple-obj-setter <qif-stock-symbol> 'name))
-
-(define qif-stock-symbol:symbol
-  (simple-obj-getter <qif-stock-symbol> 'symbol))
-
-(define qif-stock-symbol:set-symbol! 
-  (simple-obj-setter <qif-stock-symbol> 'symbol))
-
-(define qif-stock-symbol:type
-  (simple-obj-getter <qif-stock-symbol> 'type))
-
-(define qif-stock-symbol:set-type! 
-  (simple-obj-setter <qif-stock-symbol> 'type))
-
-(define (qif-stock-symbol:print self)
-  (simple-obj-print self))
-
-(define (make-qif-stock-symbol)
-  (let ((retval (make-simple-obj <qif-stock-symbol>)))
-    (qif-stock-symbol:set-name! retval "")
-    (qif-stock-symbol:set-symbol! retval "")
-    (qif-stock-symbol:set-type! retval "")
-    retval))
-
-(define <qif-ticker-map>
-  (make-simple-class
-   'qif-ticker-map
-   '(stocks)))
-
-(define qif-ticker-map:ticker-map
-  (simple-obj-getter <qif-ticker-map> 'stocks))
-
-(define qif-ticker-map:set-ticker-map!
-  (simple-obj-setter <qif-ticker-map> 'stocks))
-
-(define (make-ticker-map) 
-  (let ((self (make-simple-obj <qif-ticker-map>)))
-    (qif-ticker-map:set-ticker-map! self '())
-    self))
-
-(define (qif-ticker-map:add-ticker! ticker-map stock-symbol)
-  (qif-ticker-map:set-ticker-map!
-   ticker-map
-   (cons stock-symbol (qif-ticker-map:ticker-map ticker-map))))
-
-(define (qif-ticker-map:lookup-symbol ticker-map name)
-  (let ((retval #f))
-    (for-each 
-     (lambda (symbol)
-       (if (string=? name (qif-stock-symbol:name symbol))
-	   (begin
-	     (set! retval (qif-stock-symbol:symbol symbol))
-	     (if (and (string? retval) (string=? retval ""))
-		 (set! retval #f)))))
-     (qif-ticker-map:ticker-map ticker-map))
-    retval))
-
-(define (qif-ticker-map:lookup-type ticker-map name)
-  (let ((retval #f))
-    (for-each 
-     (lambda (symbol)
-       (if (string=? name (qif-stock-symbol:name symbol))
-	   (begin
-	     (set! retval (qif-stock-symbol:type symbol))
-	     (if (and (string? retval) (string=? retval ""))
-		 (set! retval #f)))))
-     (qif-ticker-map:ticker-map ticker-map))
-    retval))
-

Deleted: gnucash/trunk/src/import-export/qif-import/qif-parse.scm
===================================================================
--- gnucash/trunk/src/import-export/qif-import/qif-parse.scm	2013-12-15 17:20:10 UTC (rev 23566)
+++ gnucash/trunk/src/import-export/qif-import/qif-parse.scm	2013-12-15 17:21:20 UTC (rev 23567)
@@ -1,640 +0,0 @@
-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-;;;  qif-parse.scm
-;;;  routines to parse values and dates in QIF files.
-;;;
-;;;  Bill Gribble <grib at billgribble.com> 20 Feb 2000
-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-
-(use-modules (gnucash printf))
-
-(define qif-category-compiled-rexp
-  (make-regexp "^ *(\\[)?([^]/|]*)(]?)(/?)([^|]*)(\\|(\\[)?([^]/]*)(]?)(/?)(.*))? *$"))
-
-(define qif-date-compiled-rexp
-  (make-regexp "^ *([0-9]+) *[-/.'] *([0-9]+) *[-/.'] *([0-9]+).*$|^ *([0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]).*$"))
-
-(define qif-date-mdy-compiled-rexp
-  (make-regexp "([0-9][0-9])([0-9][0-9])([0-9][0-9][0-9][0-9])"))
-
-(define qif-date-ymd-compiled-rexp
-  (make-regexp "([0-9][0-9][0-9][0-9])([0-9][0-9])([0-9][0-9])"))
-
-(define decimal-radix-regexp
-  (make-regexp
-   "^ *[$]?[+-]?[$]?[0-9]+[+-]?$|^ *[$]?[+-]?[$]?[0-9]?[0-9]?[0-9]?([,'][0-9][0-9][0-9])*(\\.[0-9]*)?[+-]? *$|^ *[$]?[+-]?[$]?[0-9]+\\.[0-9]*[+-]? *$"))
-
-(define comma-radix-regexp
-  (make-regexp
-   "^ *[$]?[+-]?[$]?[0-9]+[+-]?$|^ *[$]?[+-]?[$]?[0-9]?[0-9]?[0-9]?([\\.'][0-9][0-9][0-9])*(,[0-9]*)?[+-]? *$|^ *[$]?[+-]?[$]?[0-9]+,[0-9]*[+-]? *$"))
-
-(define integer-regexp (make-regexp "^[$]?[+-]?[$]?[0-9]+[+-]? *$"))
-
-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-;;  qif-split:parse-category
-;;  this one just gets nastier and nastier.
-;;  ATM we return a list of 6 elements:
-;;    parsed category name (without [] if it was an account name)
-;;    bool stating if it was an account name
-;;    class of account or #f
-;;    string representing the "miscx category" if any
-;;    bool if miscx category is an account
-;;    class of miscx cat or #f
-;;  gosh, I love regular expressions.
-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-
-(define (qif-split:parse-category self value)
-  (let ((match (regexp-exec qif-category-compiled-rexp value)))
-    (if match
-        (let ((rv
-               (list (match:substring match 2)
-                     (if (and (match:substring match 1)
-                              (match:substring match 3))
-                         #t #f)
-                     (if (match:substring match 4)
-                         (match:substring match 5)
-                         #f)
-                     ;; miscx category name
-                     (if (match:substring match 6)
-                         (match:substring match 8)
-                         #f)
-                     ;; is it an account?
-                     (if (and (match:substring match 7)
-                              (match:substring match 9))
-                         #t #f)
-                     (if (match:substring match 10)
-                         (match:substring match 11)
-                         #f))))
-          rv)
-        (begin
-          ;; Parsing failed. Bug detected!
-          (gnc:warn "qif-split:parse-category: can't parse [" value "].")
-          (throw 'bug
-                 "qif-split:parse-category"
-                 "Can't parse account or category ~A."
-                 (list value)
-                 #f)))))
-
-
-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-;;  qif-parse:fix-year
-;;  this is where we handle y2k fixes etc.  input is a string
-;;  containing the year ("00", "2000", and "19100" all mean the same
-;;  thing). output is an integer representing the year in the C.E.
-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-
-(define (qif-parse:fix-year year-string y2k-threshold)
-  (let ((fixed-string #f)
-        (post-read-value #f)
-        (y2k-fixed-value #f))
-
-    ;; quicken prints 2000 as "' 0" for at least some versions.
-    ;; thanks dave p for reporting this.
-    (if (eq? (string-ref year-string 0) #\')
-        (begin
-          (gnc:warn "qif-file:fix-year: found weird QIF Y2K year ["
-                    year-string "].")
-          (set! fixed-string
-                (substring year-string 2 (string-length year-string))))
-        (set! fixed-string year-string))
-
-    ;; now the string should just have a number in it plus some
-    ;; optional trailing space.
-    (set! post-read-value
-          (with-input-from-string fixed-string
-            (lambda () (read))))
-
-    (cond
-     ;; 2-digit numbers less than the window size are interpreted to
-     ;; be post-2000.
-     ((and (integer? post-read-value)
-           (< post-read-value y2k-threshold))
-      (set! y2k-fixed-value (+ 2000 post-read-value)))
-
-     ;; there's a common bug in printing post-2000 dates that
-     ;; prints 2000 as 19100 etc.
-     ((and (integer? post-read-value)
-           (> post-read-value 19000))
-      (set! y2k-fixed-value (+ 1900 (- post-read-value 19000))))
-
-     ;; normal dates represented in unix years (i.e. year-1900, so
-     ;; 2000 => 100.)  We also want to allow full year specifications,
-     ;; (i.e. 1999, 2001, etc) and there's a point at which you can't
-     ;; determine which is which.  this should eventually be another
-     ;; field in the qif-file struct but not yet.  mktime in scheme
-     ;; doesn't deal with dates before December 14, 1901, at least for
-     ;; now, so let's give ourselves until at least 3802 before this
-     ;; does the wrong thing.
-     ((and (integer? post-read-value)
-           (< post-read-value 1902))
-      (set! y2k-fixed-value (+ 1900 post-read-value)))
-
-     ;; this is a normal, 4-digit year spec (1999, 2000, etc).
-     ((integer? post-read-value)
-      (set! y2k-fixed-value post-read-value))
-
-     ;; No idea what the string represents.  Maybe a new bug in Quicken!
-     (#t
-      (gnc:warn "qif-file:fix-year: ay caramba! What is this? ["
-                year-string "].")))
-
-    y2k-fixed-value))
-
-
-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-;;  parse-acct-type : set the type of the account, using gnucash
-;;  conventions.
-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-
-(define (qif-parse:parse-acct-type read-value errorproc errortype)
-  (let ((mangled-string
-         (string-downcase! (string-remove-trailing-space
-                            (string-remove-leading-space read-value)))))
-    (cond
-     ((string=? mangled-string "bank")
-      (list GNC-BANK-TYPE))
-     ((string=? mangled-string "port")
-      (list GNC-BANK-TYPE))
-     ((string=? mangled-string "cash")
-      (list GNC-CASH-TYPE))
-     ((string=? mangled-string "ccard")
-      (list GNC-CCARD-TYPE))
-     ((string=? mangled-string "invst") ;; these are brokerage accounts.
-      (list GNC-BANK-TYPE))
-     ((string=? mangled-string "401(k)/403(b)")
-      (list GNC-BANK-TYPE))
-     ((string=? mangled-string "oth a")
-      (list GNC-ASSET-TYPE GNC-BANK-TYPE GNC-CASH-TYPE))
-     ((string=? mangled-string "oth l")
-      (list GNC-LIABILITY-TYPE GNC-CCARD-TYPE))
-     ((string=? mangled-string "oth s") ;; German asset account
-      (list GNC-ASSET-TYPE GNC-BANK-TYPE GNC-CASH-TYPE))
-     ((string=? mangled-string "mutual")
-      (list GNC-BANK-TYPE))
-     (#t
-      (errorproc errortype
-                 (sprintf #f (_ "Unrecognized account type '%s'. Defaulting to Bank.")
-                          read-value))
-      (list GNC-BANK-TYPE)))))
-
-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-;;  parse-bang-field : the bang fields switch the parse context
-;;  for the qif file.
-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-
-(define (qif-parse:parse-bang-field read-value)
-  (let ((bang-field (string-downcase!
-                     (string-remove-trailing-space read-value))))
-;; The QIF files output by the WWW site of Credit Lyonnais
-;; begin by:   !type bank
-;; instead of: !Type:bank
-    (if (>= (string-length bang-field) 5)
-        (if (string=? (substring bang-field 0 5) "type ")
-            (string-set! bang-field 4 #\:)))
-
-    (string->symbol bang-field)))
-
-
-(define (qif-parse:parse-action-field read-value errorproc errortype)
-  (if read-value
-      (let ((action-symbol (string-to-canonical-symbol read-value)))
-        (case action-symbol
-          ;; buy
-          ((buy cvrshrt kauf)
-           'buy)
-          ((buyx cvrshrtx kaufx)
-           'buyx)
-          ((cglong kapgew) ;; Kapitalgewinnsteuer
-           'cglong)
-          ((cglongx kapgewx)
-           'cglongx)
-          ((cgmid) ;; Kapitalgewinnsteuer
-           'cgmid)
-          ((cgmidx)
-           'cgmidx)
-          ((cgshort k.gewsp)
-           'cgshort)
-          ((cgshortx k.gewspx)
-           'cgshortx)
-          ((div)   ;; dividende
-           'div)
-          ((divx)
-           'divx)
-;          ((exercise)
-;           'exercise)
-;          ((exercisx)
-;           'exercisx)
-;          ((expire)
-;           'expire)
-;          ((grant)
-;           'grant)
-          ((int intinc) ;; zinsen
-           'intinc)
-          ((intx intincx)
-           'intincx)
-          ((margint)
-           'margint)
-          ((margintx)
-           'margintx)
-          ((miscexp)
-           'miscexp)
-          ((miscexpx)
-           'miscexpx)
-          ((miscinc cash)
-           'miscinc)
-          ((miscincx)
-           'miscincx)
-          ((reinvdiv)
-           'reinvdiv)
-          ((reinvint reinvzin)
-           'reinvint)
-          ((reinvlg reinvkur)
-           'reinvlg)
-          ((reinvmd)
-           'reinvmd)
-          ((reinvsg reinvksp)
-           'reinvsg)
-          ((reinvsh)
-           'reinvsh)
-          ((reminder erinnerg)
-           'reminder)
-          ((rtrncap)
-           'rtrncap)
-          ((rtrncapx)
-           'rtrncapx)
-          ((sell shtsell verkauf)  ;; verkaufen
-           'sell)
-          ((sellx shtsellx verkaufx)
-           'sellx)
-          ((shrsin aktzu)
-           'shrsin)
-          ((shrsout aktab)
-           'shrsout)
-          ((stksplit aktsplit)
-           'stksplit)
-          ((xin contribx)
-           'xin)
-          ((xout withdrwx)
-           'xout)
-;          ((vest)
-;           'vest)
-          (else
-           (errorproc errortype
-                      (sprintf #f (_ "Unrecognized action '%s'.") read-value))
-           #f)))
-      #f))
-
-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-;;  parse-cleared-field : In a "C" (cleared status) QIF line,
-;;  * or C means cleared, X or R means reconciled, and ! or ?
-;;  mean some budget related stuff I don't understand.
-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-
-(define (qif-parse:parse-cleared-field read-value errorproc errortype)
-  (if (and (string? read-value)
-           (not (string-null? read-value)))
-      (let ((secondchar (string-ref read-value 0)))
-        (case secondchar
-          ;; Reconciled is the most likely, especially for large imports,
-          ;; so check that first. Also allow for lowercase.
-          ((#\X #\x #\R #\r)
-           'reconciled)
-          ((#\* #\C #\c)
-           'cleared)
-          ((#\? #\!)
-           'budgeted)
-          (else
-            (errorproc errortype
-                       (sprintf #f (_ "Unrecognized status '%s'. Defaulting to uncleared.")
-                                read-value))
-            #f)))
-      #f))
-
-
-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-;;  parse-check-date-format
-;;  given a match-triple (matches in spaces 1, 2, 3) and a
-;;  list of possible date formats, return the list of formats
-;;  that this date string could actually be.
-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-(define (parse-check-date-format match possible-formats)
-  (let ((date-parts (list (match:substring match 1)
-                          (match:substring match 2)
-                          (match:substring match 3)))
-        (numeric-date-parts '())
-        (retval '()))
-
-    ;;(define (print-list l)
-    ;;  (for-each (lambda (x) (display x) (display " ")) l))
-
-    ;;(for-each (lambda (x) (if (list? x) (print-list x) (display x)))
-    ;;      (list "parsing: " date-parts " in " possible-formats "\n"))
-
-    ;; get the strings into numbers (but keep the strings around)
-    (set! numeric-date-parts
-          (map (lambda (elt)
-                 (with-input-from-string elt
-                   (lambda () (read))))
-               date-parts))
-
-    (let ((possibilities possible-formats)
-          (n1 (car numeric-date-parts))
-          (n2 (cadr numeric-date-parts))
-          (n3 (caddr numeric-date-parts))
-          (s1 (car date-parts))
-          (s3 (caddr date-parts)))
-
-      ;; filter the possibilities to eliminate (hopefully)
-      ;; all but one
-      (if (or (not (number? n1)) (> n1 12))
-          (set! possibilities (delq 'm-d-y possibilities)))
-      (if (or (not (number? n1)) (> n1 31))
-          (set! possibilities (delq 'd-m-y possibilities)))
-      (if (or (not (number? n1)) (< n1 1))
-          (set! possibilities (delq 'd-m-y possibilities)))
-      (if (or (not (number? n1)) (< n1 1))
-          (set! possibilities (delq 'm-d-y possibilities)))
-
-      (if (or (not (number? n2)) (> n2 12))
-          (begin
-            (set! possibilities (delq 'd-m-y possibilities))
-            (set! possibilities (delq 'y-m-d possibilities))))
-
-      (if (or (not (number? n2)) (> n2 31))
-          (begin
-            (set! possibilities (delq 'm-d-y possibilities))
-            (set! possibilities (delq 'y-d-m possibilities))))
-
-      (if (or (not (number? n3)) (> n3 12))
-          (set! possibilities (delq 'y-d-m possibilities)))
-      (if (or (not (number? n3)) (> n3 31))
-          (set! possibilities (delq 'y-m-d possibilities)))
-
-      (if (or (not (number? n3)) (< n3 1))
-          (set! possibilities (delq 'y-m-d possibilities)))
-      (if (or (not (number? n3)) (< n3 1))
-          (set! possibilities (delq 'y-d-m possibilities)))
-
-      ;; If we've got a 4-character year, make sure the date
-      ;; is after 1930.  Don't check the high value (perhaps
-      ;; we should?).
-      (if (= (string-length s1) 4)
-          (if (or (not (number? n1)) (< n1 1930))
-              (begin
-                (set! possibilities (delq 'y-m-d possibilities))
-                (set! possibilities (delq 'y-d-m possibilities)))))
-      (if (= (string-length s3) 4)
-          (if (or (not (number? n3)) (< n3 1930))
-              (begin
-                (set! possibilities (delq 'm-d-y possibilities))
-                (set! possibilities (delq 'd-m-y possibilities)))))
-
-      (set! retval possibilities))
-    retval))
-
-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-;;  qif-parse:check-date-format
-;;  given a list of possible date formats, return a pruned list
-;;  of possibilities.
-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-(define (qif-parse:check-date-format date-string possible-formats)
-  (let ((retval '()))
-    (if (or (not (string? date-string))
-            (not (> (string-length date-string) 0)))
-        (set! retval possible-formats))
-    (let ((match (regexp-exec qif-date-compiled-rexp date-string)))
-      (if match
-          (if (match:substring match 1)
-              (set! retval (parse-check-date-format match possible-formats))
-
-              ;; Uh oh -- this is a string XXXXXXXX; we don't know which
-              ;; way to test..  So test both YYYYxxxx and xxxxYYYY,
-              ;; and let the parser verify the year is valid.
-              (let* ((new-date-string (match:substring match 4))
-                     (date-ymd (regexp-exec qif-date-ymd-compiled-rexp
-                                            new-date-string))
-                     (date-mdy (regexp-exec qif-date-mdy-compiled-rexp
-                                               new-date-string))
-                     (res1 '())
-                     (res2 '()))
-                (if (or (memq 'y-d-m possible-formats)
-                        (memq 'y-m-d possible-formats))
-                    (set! res1 (parse-check-date-format date-ymd possible-formats)))
-                (if (or (memq 'd-m-y possible-formats)
-                        (memq 'm-d-y possible-formats))
-                    (set! res2 (parse-check-date-format date-mdy possible-formats)))
-
-                (set! retval (append res1 res2))))))
-    retval))
-
-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-;;  qif-parse:parse-date/format
-;;  given a date-string and a format, convert the string to a
-;;  date and return a list of day, month, year
-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-
-(define (qif-parse:parse-date/format date-string format)
-  (let ((date-parts '())
-        (numeric-date-parts '())
-        (retval #f)
-
-        (match (regexp-exec qif-date-compiled-rexp date-string)))
-    (if match
-        (if (match:substring match 1)
-             (set! date-parts (list (match:substring match 1)
-                                    (match:substring match 2)
-                                    (match:substring match 3)))
-             ;; This is of the form XXXXXXXX; split the string based on
-             ;; whether the format is YYYYxxxx or xxxxYYYY
-             (let ((date-str (match:substring match 4)))
-               (case format
-                 ((d-m-y m-d-y)
-                  (let ((m (regexp-exec qif-date-mdy-compiled-rexp date-str)))
-                    (set! date-parts (list (match:substring m 1)
-                                           (match:substring m 2)
-                                           (match:substring m 3)))))
-                 ((y-m-d y-d-m)
-                  (let ((m (regexp-exec qif-date-ymd-compiled-rexp date-str)))
-                    (set! date-parts (list (match:substring m 1)
-                                           (match:substring m 2)
-                                           (match:substring m 3)))))
-                 ))))
-
-    ;; get the strings into numbers (but keep the strings around)
-    (set! numeric-date-parts
-          (map (lambda (elt)
-                 (with-input-from-string elt
-                   (lambda () (read))))
-               date-parts))
-
-    ;; if the date parts list doesn't have 3 parts, we're in trouble
-    (if (not (eq? 3 (length date-parts)))
-        (gnc:warn "qif-parse:parse-date/format: can't interpret date ["
-                  date-string "]\nDate parts: " date-parts)
-        (case format
-          ((d-m-y)
-           (let ((d (car numeric-date-parts))
-                 (m (cadr numeric-date-parts))
-                 (y (qif-parse:fix-year (caddr date-parts) 50)))
-             (if (and (integer? d) (integer? m) (integer? y)
-                      (<= m 12) (<= d 31))
-                 (set! retval (list d m y))
-                 (gnc:warn "qif-parse:parse-date/format: "
-                           "format is d/m/y, but date is ["
-                           date-string "]."))))
-
-          ((m-d-y)
-           (let ((m (car numeric-date-parts))
-                 (d (cadr numeric-date-parts))
-                 (y (qif-parse:fix-year (caddr date-parts) 50)))
-             (if (and (integer? d) (integer? m) (integer? y)
-                      (<= m 12) (<= d 31))
-                 (set! retval (list d m y))
-                 (gnc:warn "qif-parse:parse-date/format: "
-                           "format is m/d/y, but date is ["
-                           date-string "]."))))
-
-          ((y-m-d)
-           (let ((y (qif-parse:fix-year (car date-parts) 50))
-                 (m (cadr numeric-date-parts))
-                 (d (caddr numeric-date-parts)))
-             (if (and (integer? d) (integer? m) (integer? y)
-                      (<= m 12) (<= d 31))
-                 (set! retval (list d m y))
-                 (gnc:warn "qif-parse:parse-date/format: "
-                           "format is y/m/d, but date is ["
-                           date-string "]."))))
-
-          ((y-d-m)
-           (let ((y (qif-parse:fix-year (car date-parts) 50))
-                 (d (cadr numeric-date-parts))
-                 (m (caddr numeric-date-parts)))
-             (if (and (integer? d) (integer? m) (integer? y)
-                      (<= m 12) (<= d 31))
-                 (set! retval (list d m y))
-                 (gnc:warn "qif-parse:parse-date/format: "
-                           "format is y/d/m, but date is ["
-                           date-string "]."))))))
-    retval))
-
-
-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-;;  number format predicates
-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-
-(define (value-is-decimal-radix? value)
-  (if (regexp-exec decimal-radix-regexp value)
-      #t #f))
-
-(define (value-is-comma-radix? value)
-  (if (regexp-exec comma-radix-regexp value)
-      #t #f))
-
-(define (value-is-integer? value)
-  (if (regexp-exec integer-regexp value)
-      #t #f))
-
-
-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-;;  qif-parse:check-number-format
-;;  given a list of possible number formats, return a pruned list
-;;  of possibilities.
-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-
-(define (qif-parse:check-number-format value-string possible-formats)
-  (let ((retval possible-formats))
-    (if (not (value-is-decimal-radix? value-string))
-        (set! retval (delq 'decimal retval)))
-    (if (not (value-is-comma-radix? value-string))
-        (set! retval (delq 'comma retval)))
-    (if (not (value-is-integer? value-string))
-        (set! retval (delq 'integer retval)))
-    retval))
-
-
-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-;;  qif-parse:parse-number/format
-;;  assuming we know what the format is, parse the string.
-;;  returns a gnc-numeric; the denominator is set so as to exactly
-;;  represent the number
-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-
-(define (qif-parse:parse-number/format value-string format)
-  (let ((minus-index (string-index value-string #\-))
-        (filtered-string (gnc:string-delete-chars value-string "$'+-")))
-    (case format
-      ((decimal)
-       (let* ((read-string (string-remove-char filtered-string #\,))
-              (read-val (with-input-from-string read-string
-                                                (lambda () (read)))))
-         (if (number? read-val)
-             (double-to-gnc-numeric
-              (if minus-index (- 0.0 read-val) (+ 0.0 read-val))
-              GNC-DENOM-AUTO
-              (logior (GNC-DENOM-SIGFIGS
-                       (string-length (string-remove-char read-string #\.)))
-                      GNC-RND-ROUND))
-             (gnc-numeric-zero))))
-      ((comma)
-       (let* ((read-string (gnc:string-replace-char
-                              (string-remove-char filtered-string #\.)
-                              #\, #\.))
-              (read-val (with-input-from-string read-string
-                                                (lambda () (read)))))
-         (if (number? read-val)
-             (double-to-gnc-numeric
-              (if minus-index (- 0.0 read-val) (+ 0.0 read-val))
-              GNC-DENOM-AUTO
-              (logior (GNC-DENOM-SIGFIGS
-                       (string-length (string-remove-char read-string #\.)))
-                      GNC-RND-ROUND))
-             (gnc-numeric-zero))))
-      ((integer)
-       (let ((read-val (with-input-from-string filtered-string
-                                               (lambda () (read)))))
-         (if (number? read-val)
-             (double-to-gnc-numeric
-              (if minus-index (- 0.0 read-val) (+ 0.0 read-val))
-              1 GNC-RND-ROUND)
-             (gnc-numeric-zero)))))))
-
-(define (qif-parse:check-number-formats amt-strings formats)
-  (let ((retval formats))
-    (for-each
-     (lambda (amt)
-       (if amt
-           (set! retval (qif-parse:check-number-format amt retval))))
-     amt-strings)
-    retval))
-
-(define (qif-parse:parse-numbers/format amt-strings format)
-  (let* ((all-ok #t)
-         (tmp #f)
-         (parsed
-          (map
-           (lambda (amt)
-             (if amt
-                 (begin
-                   (set! tmp (qif-parse:parse-number/format amt format))
-                   (if (not tmp)
-                       (set! all-ok #f))
-                   tmp)
-                 (gnc-numeric-zero)))
-           amt-strings)))
-    (if all-ok parsed #f)))
-
-(define (qif-parse:print-date date-list)
-  (let ((tm (localtime (current-time))))
-    (set-tm:mday tm (car date-list))
-    (set-tm:mon tm (- (cadr date-list) 1))
-    (set-tm:year tm (- (caddr date-list) 1900))
-    (strftime "%a %B %d %Y" tm)))
-
-(define (qif-parse:print-number num)
-  (with-output-to-string
-    (lambda ()
-      (write num))))
-
-(define (qif-parse:print-numbers num)
-  (with-output-to-string
-    (lambda ()
-      (write num))))

Deleted: gnucash/trunk/src/import-export/qif-import/qif-to-gnc.scm
===================================================================
--- gnucash/trunk/src/import-export/qif-import/qif-to-gnc.scm	2013-12-15 17:20:10 UTC (rev 23566)
+++ gnucash/trunk/src/import-export/qif-import/qif-to-gnc.scm	2013-12-15 17:21:20 UTC (rev 23567)
@@ -1,1231 +0,0 @@
-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-;;;  qif-to-gnc.scm
-;;;  this is where QIF transactions are transformed into a
-;;;  Gnucash account tree.
-;;;
-;;;  Copyright 2000-2001 Bill Gribble <grib at billgribble.com>
-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-
-(use-modules (srfi srfi-13))
-(use-modules (gnucash printf))
-
-
-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-;;  qif-import:find-or-make-acct
-;;
-;;  Given a colon-separated account path, return an Account* to
-;;  an existing or new account.
-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-
-(define (qif-import:find-or-make-acct acct-info check-types? commodity
-				      check-commodity? default-currency
-                                      gnc-acct-hash old-root new-root)
-  (let* ((sep (gnc-get-account-separator-string))
-         (gnc-name (qif-map-entry:gnc-name acct-info))
-         (existing-account (hash-ref gnc-acct-hash gnc-name))
-         (same-gnc-account
-          (gnc-account-lookup-by-full-name old-root gnc-name))
-         (allowed-types
-          (qif-map-entry:allowed-types acct-info))
-         (make-new-acct #f)
-         (incompatible-acct #f))
-
-    (define (compatible? account)
-      (let ((acc-type (xaccAccountGetType account))
-            (acc-commodity (xaccAccountGetCommodity account)))
-        (and
-         (if check-types?
-             (and (list? allowed-types)
-                  (memv acc-type allowed-types))
-             #t)
-	 (if check-commodity?
-	     (gnc-commodity-equiv acc-commodity commodity)
-	     #t))))
-
-    (define (make-unique-name-variant long-name short-name)
-      (if (not (null? (gnc-account-lookup-by-full-name old-root long-name)))
-          (let loop ((count 2))
-            (let* ((test-name
-                    (string-append long-name (sprintf #f " %a" count)))
-                   (test-acct
-                    (gnc-account-lookup-by-full-name old-root test-name)))
-              (if (and (not (null? test-acct)) (not (compatible? test-acct)))
-                  (loop (+ 1 count))
-                  (string-append short-name (sprintf #f " %a" count)))))
-          short-name))
-
-    ;; If a GnuCash account already exists in the old root with the same
-    ;; name, that doesn't necessarily mean we can use it. The type and
-    ;; commodity must be  compatible.
-    (if (and same-gnc-account (not (null? same-gnc-account)))
-        (if (compatible? same-gnc-account)
-            (begin
-              ;; The existing GnuCash account is compatible, so we
-              ;; can use it. Make sure we use the same type.
-              (set! make-new-acct #f)
-              (set! incompatible-acct #f)
-              (set! allowed-types
-                    (list (xaccAccountGetType same-gnc-account))))
-            (begin
-              ;; There's an existing, incompatible account with that name,
-              ;; so we have to make a new account with different properties
-              ;; and a slightly different name.
-              (set! make-new-acct #t)
-              (set! incompatible-acct #t)))
-        (begin
-          ;; Otherwise, there's no existing account with the same name.
-          (set! make-new-acct #t)
-          (set! incompatible-acct #f)))
-
-    ;; here, existing-account means a previously *created* account
-    ;; (possibly a new account, possibly a copy of an existing gnucash
-    ;; acct)
-    (if (and (and existing-account (not (null? existing-account)))
-             (compatible? existing-account))
-        existing-account
-        (let ((new-acct (xaccMallocAccount (gnc-get-current-book)))
-              (parent-acct #f)
-              (parent-name #f)
-              (acct-name #f)
-              (last-sep #f))
-
-          ;; This procedure returns a default account type.  This could
-          ;; be smarter, but at least it won't allow security account
-          ;; types to be used on currency-denominated accounts.
-          (define (default-account-type allowed-types currency?)
-            (if (or (not allowed-types)
-                    (null? allowed-types))
-                ;; None of the allowed types are compatible.
-                ;; Bug detected!
-                (throw 'bug
-                       "qif-import:find-or-make-acct"
-                       "No valid account types allowed for account ~A."
-                       (list acct-name)
-                       #f)
-                (if (memv (car allowed-types) (list GNC-STOCK-TYPE
-                                                    GNC-MUTUAL-TYPE))
-                    ;; The type is incompatible with a currency.
-                    (if currency?
-                      (default-account-type (cdr allowed-types)
-                                            currency?)
-                      (car allowed-types))
-                    ;; The type is compatible with a currency.
-                    (if currency?
-                      (car allowed-types)
-                      (default-account-type (cdr allowed-types)
-                                            currency?)))))
-
-          (set! last-sep (gnc:string-rcontains gnc-name sep))
-
-          (xaccAccountBeginEdit new-acct)
-
-          ;; if this is a copy of an existing gnc account, copy the
-          ;; account properties.  For incompatible existing accts,
-          ;; we'll do something different later.
-          (if (and same-gnc-account (not (null? same-gnc-account)))
-              (begin
-                (xaccAccountSetName
-                 new-acct (xaccAccountGetName same-gnc-account))
-                (xaccAccountSetDescription
-                 new-acct (xaccAccountGetDescription same-gnc-account))
-                (xaccAccountSetType
-                 new-acct (xaccAccountGetType same-gnc-account))
-                (xaccAccountSetCommodity
-                 new-acct (xaccAccountGetCommodity same-gnc-account))
-                (xaccAccountSetNotes
-                 new-acct (xaccAccountGetNotes same-gnc-account))
-                (xaccAccountSetColor
-                 new-acct (xaccAccountGetColor same-gnc-account))
-                (xaccAccountSetCode
-                 new-acct (xaccAccountGetCode same-gnc-account))))
-
-          ;; If this is a nested account foo:bar:baz, make sure
-          ;; that foo:bar and foo exist also.
-          (if last-sep
-              (begin
-                (set! parent-name (substring gnc-name 0 last-sep))
-                (set! acct-name (substring gnc-name (+ (string-length sep)
-                                                       last-sep))))
-              (set! acct-name gnc-name))
-
-          ;; If this is a completely new account (as opposed to a copy
-          ;; of an existing account), use the parameters passed in.
-          (if make-new-acct
-              (begin
-                ;; Set the name, description, and commodity.
-                (xaccAccountSetName new-acct acct-name)
-                (if (qif-map-entry:description acct-info)
-                    (xaccAccountSetDescription
-                     new-acct (qif-map-entry:description acct-info)))
-                (xaccAccountSetCommodity new-acct commodity)
-
-                ;; If there was an existing, incompatible account with
-                ;; the same name, set the new account name to be unique,
-                ;; and set a description that hints at what's happened.
-                (if incompatible-acct
-                    (let ((new-name (make-unique-name-variant
-                                     gnc-name acct-name)))
-                      (xaccAccountSetName new-acct new-name)
-                      (xaccAccountSetDescription
-                       new-acct
-                       (_ "QIF import: Name conflict with another account."))))
-
-                ;; Set the account type.
-                (xaccAccountSetType new-acct
-                                    (default-account-type
-                                      (qif-map-entry:allowed-types acct-info)
-                                      (gnc-commodity-is-currency commodity)))))
-          (xaccAccountCommitEdit new-acct)
-
-          ;; If a parent account is needed, find or make it.
-          (if last-sep
-              (let ((pinfo (make-qif-map-entry)))
-                (qif-map-entry:set-qif-name! pinfo parent-name)
-                (qif-map-entry:set-gnc-name! pinfo parent-name)
-                (qif-map-entry:set-allowed-types!
-                 acct-info (list (xaccAccountGetType new-acct)))
-                (qif-map-entry:set-allowed-types!
-                 pinfo (qif-map-entry:allowed-parent-types acct-info))
-
-                (set! parent-acct (qif-import:find-or-make-acct
-                                   pinfo #t default-currency #f default-currency
-                                   gnc-acct-hash old-root new-root))))
-          (if (and parent-acct (not (null? parent-acct)))
-              (gnc-account-append-child parent-acct new-acct)
-              (gnc-account-append-child new-root new-acct))
-
-          (hash-set! gnc-acct-hash gnc-name new-acct)
-          new-acct))))
-
-
-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-;; qif-import:qif-to-gnc
-;;
-;; This is the top-level of the back end conversion from QIF
-;; to GnuCash. All the account mappings and so on should be
-;; done before this is called.
-;;
-;; This procedure returns:
-;;   success: the root of the imported tree
-;;   failure: a symbol indicating the reason
-;;   cancel:  #t
-;;   bug:     #f
-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-
-(define (qif-import:qif-to-gnc qif-files-list
-                               qif-acct-map qif-cat-map
-                               qif-memo-map stock-map
-                               default-currency-name
-                               transaction-status-pref
-                               progress-dialog)
-
-  ;; This procedure does all the work. We'll define it, then call it safely.
-  (define (private-convert)
-    (let* ((old-root (gnc-get-current-root-account))
-           (new-root (xaccMallocAccount (gnc-get-current-book)))
-           (gnc-acct-hash (make-hash-table 20))
-           (sep (gnc-get-account-separator-string))
-           (default-currency
-             (gnc-commodity-table-find-full
-              (gnc-commodity-table-get-table (gnc-get-current-book))
-              GNC_COMMODITY_NS_CURRENCY default-currency-name))
-           (sorted-accounts-list '())
-           (markable-xtns '())
-           (sorted-qif-files-list (sort qif-files-list
-                                        (lambda (a b)
-                                          (> (length (qif-file:xtns a))
-                                             (length (qif-file:xtns b))))))
-           (work-to-do 0)
-           (work-done 0))
-
-      ;; This procedure handles progress reporting, pause, and cancel.
-      (define (update-progress)
-        (set! work-done (+ 1 work-done))
-        (if (and progress-dialog
-                 (zero? (remainder work-done 8)))
-            (begin
-              (gnc-progress-dialog-set-value progress-dialog
-                                             (/ work-done work-to-do))
-              (qif-import:check-pause progress-dialog)
-              (if qif-import:canceled
-                  (throw 'cancel)))))
-
-
-      (if progress-dialog
-          (gnc-progress-dialog-set-sub progress-dialog
-                                      (_ "Preparing to convert your QIF data")))
-
-      ;; Build a list of all accounts to create for the import tree.
-      ;; We need to iterate over the account, category, and payee/memo
-      ;; mappings to build the list.
-      (hash-fold
-       (lambda (k v p)
-         (if (qif-map-entry:display? v)
-             (set! sorted-accounts-list
-                   (cons v sorted-accounts-list)))
-         #t)
-       #t qif-acct-map)
-
-      (hash-fold
-       (lambda (k v p)
-         (if (qif-map-entry:display? v)
-             (set! sorted-accounts-list
-                   (cons v sorted-accounts-list)))
-         #t)
-       #t qif-cat-map)
-
-      (hash-fold
-       (lambda (k v p)
-         (if (qif-map-entry:display? v)
-             (set! sorted-accounts-list
-                   (cons v sorted-accounts-list)))
-         #t)
-       #t qif-memo-map)
-      (set! work-to-do (length sorted-accounts-list))
-
-      ;; Before trying to mark transactions, prune down the list to
-      ;; those that are transfers between QIF accounts.
-      (for-each
-       (lambda (qif-file)
-         (for-each
-          (lambda (xtn)
-            (set! work-to-do (+ 1 work-to-do))
-            (let splitloop ((splits (qif-xtn:splits xtn)))
-              (if (qif-split:category-is-account? (car splits))
-                  (begin
-                    (set! markable-xtns (cons xtn markable-xtns))
-                    (set! work-to-do (+ 1 work-to-do)))
-                  (if (not (null? (cdr splits)))
-                      (splitloop (cdr splits))))))
-          (qif-file:xtns qif-file)))
-       qif-files-list)
-
-
-      ;; Build a local account tree to hold converted transactions.
-      (if progress-dialog
-          (gnc-progress-dialog-set-sub progress-dialog
-                                       (_ "Creating accounts")))
-
-      ;; Sort the account list on the depth of the account path.  If a
-      ;; short part is explicitly mentioned, make sure it gets created
-      ;; before the deeper path that would create the parent accounts
-      ;; without enough information about their type.
-      (set! sorted-accounts-list
-            (sort sorted-accounts-list
-                  (lambda (a b)
-                    (< (gnc:substring-count (qif-map-entry:gnc-name a)
-                                            sep)
-                       (gnc:substring-count (qif-map-entry:gnc-name b)
-                                            sep)))))
-
-      ;; Make all the accounts.
-      (for-each
-       (lambda (acctinfo)
-         (let* ((security
-                 (and stock-map
-                      (hash-ref stock-map
-                                (qif-import:get-account-name
-                                 (qif-map-entry:qif-name acctinfo)))))
-                (ok-types (qif-map-entry:allowed-types acctinfo))
-                (equity? (memv GNC-EQUITY-TYPE ok-types))
-                (stock? (or (memv GNC-STOCK-TYPE ok-types)
-                            (memv GNC-MUTUAL-TYPE ok-types))))
-
-           (update-progress)
-           (cond ((and equity? security)  ;; a "retained holdings" acct
-                  (qif-import:find-or-make-acct acctinfo #f
-                                                security #t
-                                                default-currency
-                                                gnc-acct-hash
-                                                old-root new-root))
-                 ((and security (or stock?
-                                    (gnc-commodity-is-currency security)))
-                  (qif-import:find-or-make-acct
-                   acctinfo #f security #t default-currency
-                   gnc-acct-hash old-root new-root))
-                 (#t
-                  (qif-import:find-or-make-acct
-                   acctinfo #f default-currency #t default-currency
-                   gnc-acct-hash old-root new-root)))))
-       sorted-accounts-list)
-
-      ;; Run through the markable transactions marking any
-      ;; duplicates.  marked transactions/splits won't get imported.
-      (if progress-dialog
-          (gnc-progress-dialog-set-sub progress-dialog
-                                    (_ "Matching transfers between accounts")))
-      (if (> (length markable-xtns) 1)
-          (let xloop ((xtn (car markable-xtns))
-                      (rest (cdr markable-xtns)))
-            ;; Update the progress.
-            (update-progress)
-
-            (if (not (qif-xtn:mark xtn))
-                (qif-import:mark-matching-xtns xtn rest))
-            (if (not (null? (cdr rest)))
-                (xloop (car rest) (cdr rest)))))
-
-      ;; Iterate over files. Going in the sort order by number of
-      ;; transactions should give us a small speed advantage.
-      (for-each
-       (lambda (qif-file)
-         (if progress-dialog
-             (gnc-progress-dialog-set-sub progress-dialog
-                                          (string-append (_ "Converting") " "
-                                                     (qif-file:path qif-file))))
-         (for-each
-          (lambda (xtn)
-            ;; Update the progress.
-            (update-progress)
-
-            (if (not (qif-xtn:mark xtn))
-                ;; Convert into a GnuCash transaction.
-                (let ((gnc-xtn (xaccMallocTransaction
-                                (gnc-get-current-book))))
-                  (xaccTransBeginEdit gnc-xtn)
-
-                  ;; All accounts & splits are required to be in the
-                  ;; user-specified currency. Use it for the txn too.
-                  (xaccTransSetCurrency gnc-xtn default-currency)
-
-                  ;; Build the transaction.
-                  (qif-import:qif-xtn-to-gnc-xtn xtn qif-file gnc-xtn
-                                                 gnc-acct-hash
-                                                 qif-acct-map
-                                                 qif-cat-map
-                                                 qif-memo-map
-                                                 transaction-status-pref
-                                                 progress-dialog)
-
-                  ;; rebalance and commit everything
-                  (xaccTransCommitEdit gnc-xtn))))
-          (qif-file:xtns qif-file)))
-       sorted-qif-files-list)
-
-      ;; Finished.
-      (if progress-dialog
-          (gnc-progress-dialog-set-value progress-dialog 1))
-
-      new-root))
-
-  ;; Safely convert the files and return the result.
-  (gnc:backtrace-if-exception
-    (lambda ()
-      (catch 'cancel
-             (lambda ()
-               (catch 'bad-date private-convert (lambda (key . args) key)))
-             (lambda (key . args) #t)))))
-
-
-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-;; qif-import:qif-xtn-to-gnc-xtn
-;; translate a single transaction to a set of gnucash splits and
-;; a gnucash transaction structure.
-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-
-(define (qif-import:qif-xtn-to-gnc-xtn qif-xtn qif-file gnc-xtn
-                                       gnc-acct-hash
-                                       qif-acct-map qif-cat-map qif-memo-map
-                                       transaction-status-pref
-                                       progress-dialog)
-  (let ((splits (qif-xtn:splits qif-xtn))
-        (gnc-near-split (xaccMallocSplit (gnc-get-current-book)))
-        (near-split-total (gnc-numeric-zero))
-        (near-acct-info #f)
-        (near-acct-name #f)
-        (near-acct #f)
-        (qif-payee (qif-xtn:payee qif-xtn))
-        (qif-number (qif-xtn:number qif-xtn))
-        (qif-action (qif-xtn:action qif-xtn))
-        (qif-security (qif-xtn:security-name qif-xtn))
-        (qif-default-split (qif-xtn:default-split qif-xtn))
-        (qif-memo #f)
-        (qif-date (qif-xtn:date qif-xtn))
-        (qif-from-acct (qif-xtn:from-acct qif-xtn))
-        (qif-cleared (qif-xtn:cleared qif-xtn))
-        (n- (lambda (n) (gnc-numeric-neg n)))
-        (nsub (lambda (a b) (gnc-numeric-sub a b 0 GNC-DENOM-LCD)))
-        (n+ (lambda (a b) (gnc-numeric-add a b 0 GNC-DENOM-LCD)))
-        (n* (lambda (a b) (gnc-numeric-mul a b 0 GNC-DENOM-REDUCE)))
-        (n/ (lambda (a b) (gnc-numeric-div a b 0 GNC-DENOM-REDUCE))))
-
-    ;; Set properties of the whole transaction.
-
-    ;; Set the transaction date.
-    (cond
-      ((not qif-date)
-        (qif-import:log progress-dialog
-                        "qif-import:qif-xtn-to-gnc-xtn"
-                        (_ "Missing transaction date."))
-        (throw 'bad-date
-               "qif-import:qif-xtn-to-gnc-xtn"
-               "Missing transaction date."
-               #f
-               #f))
-      ((< (list-ref qif-date 2) 1970)
-        (qif-import:log progress-dialog
-                        "qif-import:qif-xtn-to-gnc-xtn"
-                        (_ "Dates earlier than 1970 are not supported."))
-        (throw 'bad-date
-               "qif-import:qif-xtn-to-gnc-xtn"
-               "Invalid transaction year (~A)."
-               (list (list-ref qif-date 2))
-               #f))
-      (else
-        (apply xaccTransSetDate gnc-xtn (qif-xtn:date qif-xtn))))
-
-    ;; fixme: bug #105
-    (if qif-payee
-        (xaccTransSetDescription gnc-xtn qif-payee))
-    (if qif-number
-        ;; Use function that will set either tran-num or split-action per
-        ;; book option.
-        (gnc-set-num-action gnc-xtn gnc-near-split qif-number #f))
-
-    ;; Look for the transaction memo (QIF "M" line). When a default split
-    ;; exists, the memo can be found there. Otherwise, it will be in the
-    ;; first member of the splits list.
-    (if qif-default-split
-       (set! qif-memo (qif-split:memo qif-default-split))
-       (set! qif-memo (qif-split:memo (car (qif-xtn:splits qif-xtn)))))
-    (if qif-memo
-	  (if (or (not qif-payee)
-	          (equal? qif-payee ""))
-	      (xaccTransSetDescription gnc-xtn qif-memo)
-	      ;; Use the memo for the transaction notes. Previously this went to
-	      ;; the debit/credit lines. See bug 495219 for more information.
-	      (xaccTransSetNotes gnc-xtn qif-memo)))
-
-    ;; Look for the transaction status (QIF "C" line). When it exists, apply
-    ;; the cleared (c) or reconciled (y) status to the split. Otherwise, apply
-    ;; user preference.
-    (if (eq? qif-cleared 'cleared)
-        (xaccSplitSetReconcile gnc-near-split #\c)
-        (if (eq? qif-cleared 'reconciled)
-            (xaccSplitSetReconcile gnc-near-split #\y)
-            ;; Apply user preference by default.
-            (xaccSplitSetReconcile gnc-near-split transaction-status-pref)))
-
-    (if (not qif-security)
-        (begin
-          ;; NON-STOCK TRANSACTIONS: the near account is the current
-          ;; bank-account or the default associated with the file.
-          ;; the far account is the one associated with the split
-          ;; category.
-          (set! near-acct-info (hash-ref qif-acct-map qif-from-acct))
-          (set! near-acct-name (qif-map-entry:gnc-name near-acct-info))
-          (set! near-acct (hash-ref gnc-acct-hash near-acct-name))
-
-          ;; iterate over QIF splits.  Each split defines one "far
-          ;; end" for the transaction.
-          (for-each
-           (lambda (qif-split)
-             (if (not (qif-split:mark qif-split))
-                 (let ((gnc-far-split (xaccMallocSplit
-                                       (gnc-get-current-book)))
-                       (far-acct-info #f)
-                       (far-acct-name #f)
-                       (far-acct #f)
-                       (split-amt (qif-split:amount qif-split))
-                       ;; For split transactions, get this split's memo.
-                       (memo
-                         (if qif-default-split
-                             (qif-split:memo qif-split) #f))
-                       (cat (qif-split:category qif-split)))
-
-                   (if (not split-amt) (set! split-amt (gnc-numeric-zero)))
-                   ;; fill the splits in (near first).  This handles
-                   ;; files in multiple currencies by pulling the
-                   ;; currency value from the file import.
-                   (set! near-split-total (n+ near-split-total split-amt))
-                   (xaccSplitSetValue gnc-far-split (n- split-amt))
-                   (xaccSplitSetAmount gnc-far-split (n- split-amt))
-
-                   (if memo (xaccSplitSetMemo gnc-far-split memo))
-
-                   ;; figure out what the far acct is
-                   (cond
-                    ;; If the category is an account, use the account mapping.
-                    ((and (not (string=? cat ""))
-                          (qif-split:category-is-account? qif-split))
-                     (set! far-acct-info (hash-ref qif-acct-map cat)))
-
-                    ;; Otherwise, if it isn't empty, use the category mapping.
-                    ((not (string=? cat ""))
-                     (set! far-acct-info (hash-ref qif-cat-map cat)))
-
-                    ;; Otherwise, for non-split QIF transactions, try a payee
-                    ;; mapping, and if that doesn't work, try mapping the
-                    ;; transaction memo. For split transactions, map the memo
-                    ;; for this particular split line. If all else fails, use
-                    ;; the default category mapping (the Unspecified account,
-                    ;; unless the user has changed it).
-                    (#t
-                     (set! far-acct-info
-                           (if (= (length splits) 1)
-                               (or (and (string? qif-payee)
-                                        (not (string=? qif-payee ""))
-                                        (hash-ref qif-memo-map qif-payee))
-                                   (and (string? qif-memo)
-                                        (not (string=? qif-memo ""))
-                                        (hash-ref qif-memo-map qif-memo)))
-                               (and (string? memo)
-                                    (not (string=? memo ""))
-                                    (hash-ref qif-memo-map memo))))
-                     (if (not far-acct-info)
-                         (set! far-acct-info (hash-ref qif-cat-map cat)))))
-
-                   (set! far-acct-name (qif-map-entry:gnc-name far-acct-info))
-                   (set! far-acct (hash-ref gnc-acct-hash far-acct-name))
-
-                   ;; set the reconcile status.
-                   (let ((cleared (qif-split:matching-cleared qif-split)))
-                     (if (eq? 'cleared cleared)
-                         (xaccSplitSetReconcile gnc-far-split #\c))
-                     (if (eq? 'reconciled cleared)
-                         (xaccSplitSetReconcile gnc-far-split #\y)))
-
-                   ;; finally, plug the split into the account
-                   (xaccSplitSetAccount gnc-far-split far-acct)
-                   (xaccSplitSetParent gnc-far-split gnc-xtn))))
-           splits)
-
-          ;; the value of the near split is the total of the far splits.
-          (xaccSplitSetValue gnc-near-split near-split-total)
-          (xaccSplitSetAmount gnc-near-split near-split-total)
-          (xaccSplitSetParent gnc-near-split gnc-xtn)
-          (xaccSplitSetAccount gnc-near-split near-acct))
-
-        ;; STOCK TRANSACTIONS: the near/far accounts depend on the
-        ;; "action" encoded in the Number field.  It's generally the
-        ;; security account (for buys, sells, and reinvests) but can
-        ;; also be an interest, dividend, or SG/LG account.
-        (let* ((share-price (qif-xtn:share-price qif-xtn))
-               (num-shares (qif-xtn:num-shares qif-xtn))
-               (split-amt #f)
-               (xtn-amt (qif-split:amount (car (qif-xtn:splits qif-xtn))))
-               (qif-accts #f)
-               (qif-near-acct #f)
-               (qif-far-acct #f)
-               (qif-commission-acct #f)
-               (far-acct-info #f)
-               (far-acct-name #f)
-               (far-acct #f)
-               (commission-acct #f)
-               (commission-amt (qif-xtn:commission qif-xtn))
-               (commission-split #f)
-               (gnc-far-split (xaccMallocSplit (gnc-get-current-book))))
-
-          (if (not num-shares) (set! num-shares (gnc-numeric-zero)))
-
-          ;; Determine the extended price of all shares without commission.
-          (if xtn-amt
-              ;; Adjust for commission (if any).
-              (if commission-amt
-                  (case qif-action
-                    ((sell sellx shrsout)
-                     (set! split-amt (n+ xtn-amt commission-amt)))
-                    (else
-                     (set! split-amt (nsub xtn-amt commission-amt))))
-                  (set! split-amt xtn-amt))
-              ;; There's no grand total available.
-              (if share-price
-                  ;; Use the given share price, despite possible rounding.
-                  (set! split-amt (n* num-shares share-price))
-                  (set! split-amt (gnc-numeric-zero))))
-
-          ;; Determine the share price.
-          (if (not share-price)
-              (set! share-price (gnc-numeric-zero))
-              (if (and xtn-amt (not (gnc-numeric-zero-p num-shares)))
-                  ;; There's a share price but it could be imprecise
-                  ;; enough to cause rounding. We can compute a better
-                  ;; share price ourselves. For more information, see
-                  ;; bug 373584.
-                  (set! share-price (n/ split-amt num-shares))))
-
-          ;; I don't think this should ever happen, but I want
-          ;; to keep this check just in case.
-          (if (> (length splits) 1)
-              (gnc:warn "qif-import:qif-xtn-to-gnc-xtn: "
-                        "splits in stock transaction!"))
-
-          (set! qif-accts
-                (qif-split:accounts-affected (car (qif-xtn:splits qif-xtn))
-                                             qif-xtn))
-
-          (set! qif-near-acct (car qif-accts))
-          (set! qif-far-acct (cadr qif-accts))
-          (set! qif-commission-acct (caddr qif-accts))
-
-          ;; Translate the QIF account names into GnuCash accounts.
-          (if (and qif-near-acct qif-far-acct)
-              (begin
-                ;; Determine the near account.
-                (set! near-acct-info
-                      (or (hash-ref qif-acct-map qif-near-acct)
-                          (hash-ref qif-cat-map qif-near-acct)))
-                (set! near-acct-name (qif-map-entry:gnc-name near-acct-info))
-                (set! near-acct (hash-ref gnc-acct-hash near-acct-name))
-
-                ;; Determine the far account.
-                (if (or (not (string? qif-far-acct))
-                        (string=? qif-far-acct ""))
-                    ;; No far account name is specified, so try a
-                    ;; payee or memo mapping to get a default.
-                    (set! far-acct-info
-                          (or (hash-ref qif-memo-map (qif-xtn:payee qif-xtn))
-                              (hash-ref qif-memo-map
-                                        (qif-split:memo
-                                          (car (qif-xtn:splits qif-xtn)))))))
-                (if (not far-acct-info)
-                    (set! far-acct-info
-                          (or (hash-ref qif-acct-map qif-far-acct)
-                              (hash-ref qif-cat-map qif-far-acct))))
-                (set! far-acct-name (qif-map-entry:gnc-name far-acct-info))
-                (set! far-acct (hash-ref gnc-acct-hash far-acct-name))))
-
-          ;; the amounts and signs: are shares going in or out?
-          ;; are amounts currency or shares?
-          (case qif-action
-            ((buy buyx reinvint reinvdiv reinvsg reinvsh reinvmd reinvlg)
-             (if (not share-price) (set! share-price (gnc-numeric-zero)))
-             (xaccSplitSetAmount gnc-near-split num-shares)
-             (xaccSplitSetValue gnc-near-split split-amt)
-             (xaccSplitSetValue gnc-far-split (n- xtn-amt))
-             (xaccSplitSetAmount gnc-far-split (n- xtn-amt)))
-
-            ((sell sellx)
-             (if (not share-price) (set! share-price (gnc-numeric-zero)))
-             (xaccSplitSetAmount gnc-near-split (n- num-shares))
-             (xaccSplitSetValue gnc-near-split (n- split-amt))
-             (xaccSplitSetValue gnc-far-split xtn-amt)
-             (xaccSplitSetAmount gnc-far-split xtn-amt))
-
-            ((cgshort cgshortx cgmid cgmidx cglong cglongx intinc intincx
-                      div divx miscinc miscincx xin rtrncap rtrncapx)
-             (xaccSplitSetValue gnc-near-split xtn-amt)
-             (xaccSplitSetAmount gnc-near-split xtn-amt)
-             (xaccSplitSetValue gnc-far-split (n- xtn-amt))
-             (xaccSplitSetAmount gnc-far-split (n- xtn-amt)))
-
-            ((xout miscexp miscexpx margint margintx)
-             (xaccSplitSetValue gnc-near-split (n- xtn-amt))
-             (xaccSplitSetAmount gnc-near-split (n- xtn-amt))
-             (xaccSplitSetValue gnc-far-split  xtn-amt)
-             (xaccSplitSetAmount gnc-far-split  xtn-amt))
-
-            ((shrsin)
-             ;; getting rid of the old equity-acct-per-stock trick.
-             ;; you must now have a cash/basis value for the stock.
-             (xaccSplitSetAmount gnc-near-split num-shares)
-             (xaccSplitSetValue gnc-near-split split-amt)
-             (xaccSplitSetValue gnc-far-split (n- xtn-amt))
-             (xaccSplitSetAmount gnc-far-split (n- xtn-amt)))
-
-            ((shrsout)
-             ;; shrsout is like shrsin
-             (xaccSplitSetAmount gnc-near-split (n- num-shares))
-             (xaccSplitSetValue gnc-near-split (n- split-amt))
-             (xaccSplitSetValue gnc-far-split xtn-amt)
-             (xaccSplitSetAmount gnc-far-split xtn-amt))
-
-            ;; stock splits: QIF just specifies the split ratio, not
-            ;; the number of shares in and out, so we have to fetch
-            ;; the number of shares from the security account
-
-            ;; FIXME : this could be wrong.  Make sure the
-            ;; share-amount is at the correct time.
-            ((stksplit)
-             (let* ((splitratio (n/ num-shares (gnc-numeric-create 10 1)))
-                    (in-shares
-                     (xaccAccountGetBalance near-acct))
-                    (out-shares (n* in-shares splitratio)))
-               (xaccSplitSetAmount gnc-near-split out-shares)
-               (xaccSplitSetAmount gnc-far-split (n- in-shares))
-               (xaccSplitSetValue gnc-near-split (n- split-amt))
-               (xaccSplitSetValue gnc-far-split split-amt))))
-
-          (let ((cleared (qif-split:matching-cleared
-                          (car (qif-xtn:splits qif-xtn)))))
-            (if (eq? 'cleared cleared)
-                (xaccSplitSetReconcile gnc-far-split #\c))
-            (if (eq? 'reconciled cleared)
-                (xaccSplitSetReconcile gnc-far-split #\y)))
-
-          (if qif-commission-acct
-              (let* ((commission-acct-info
-                      (or (hash-ref qif-acct-map qif-commission-acct)
-                          (hash-ref qif-cat-map qif-commission-acct)))
-                     (commission-acct-name
-                      (and commission-acct-info
-                           (qif-map-entry:gnc-name commission-acct-info))))
-                (if commission-acct-name
-                    (set! commission-acct
-                          (hash-ref gnc-acct-hash commission-acct-name)))))
-
-          (if (and commission-amt commission-acct)
-              (begin
-                (set! commission-split (xaccMallocSplit
-                                        (gnc-get-current-book)))
-                (xaccSplitSetValue commission-split commission-amt)
-                (xaccSplitSetAmount commission-split commission-amt)))
-
-          (if (and qif-near-acct qif-far-acct)
-              (begin
-                (xaccSplitSetParent gnc-near-split gnc-xtn)
-                (xaccSplitSetAccount gnc-near-split near-acct)
-
-                (xaccSplitSetParent gnc-far-split gnc-xtn)
-                (xaccSplitSetAccount gnc-far-split far-acct)
-
-                (if commission-split
-                    (begin
-                      (xaccSplitSetParent commission-split gnc-xtn)
-                      (xaccSplitSetAccount commission-split
-                                           commission-acct)))))))
-
-    ;; QIF indicates a void transaction by starting the payee with "**VOID**".
-    (if (and (string? qif-payee)
-             (string-prefix? "**VOID**" qif-payee))
-        (xaccTransVoid gnc-xtn "QIF"))
-
-    ;; return the modified transaction (though it's ignored).
-    gnc-xtn))
-
-
-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-;;  qif-import:mark-matching-xtns
-;;  find transactions that are the "opposite half" of xtn and
-;;  mark them so they won't be imported.
-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-
-(define (qif-import:mark-matching-xtns xtn candidate-xtns)
-  (let splitloop ((splits-left (qif-xtn:splits xtn)))
-
-    ;; splits-left starts out as all the splits of this transaction.
-    ;; if multiple splits match up with a single split on the other
-    ;; end, we may remove more than one split from splits-left with
-    ;; each call to mark-some-splits.
-    (if (not (null? splits-left))
-        (if (and (not (qif-split:mark (car splits-left)))
-                 (qif-split:category-is-account? (car splits-left)))
-            (set! splits-left
-                  (qif-import:mark-some-splits
-                   splits-left xtn candidate-xtns))
-            (set! splits-left (cdr splits-left))))
-
-    (if (not (null? splits-left))
-        (splitloop splits-left))))
-
-
-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-;; qif-import:mark-some-splits
-;; find split(s) matching elements of splits and mark them so they
-;; don't get imported.
-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-
-(define (qif-import:mark-some-splits splits xtn candidate-xtns)
-  (let* ((n- (lambda (n) (gnc-numeric-neg n)))
-         (nsub (lambda (a b) (gnc-numeric-sub a b 0 GNC-DENOM-LCD)))
-         (n+ (lambda (a b) (gnc-numeric-add a b 0 GNC-DENOM-LCD)))
-         (n* (lambda (a b) (gnc-numeric-mul a b 0 GNC-DENOM-REDUCE)))
-         (n/ (lambda (a b) (gnc-numeric-div a b 0 GNC-DENOM-REDUCE)))
-         (split (car splits))
-         (near-acct-name #f)
-         (far-acct-name #f)
-         (date (qif-xtn:date xtn))
-         (amount (n- (qif-split:amount split)))
-         (group-amount #f)
-         (security-name (qif-xtn:security-name xtn))
-         (action (qif-xtn:action xtn))
-         (bank-xtn? (not security-name))
-         (different-acct-splits '())
-         (same-acct-splits '())
-         (how #f)
-         (done #f))
-
-    (if bank-xtn?
-        (begin
-          (set! near-acct-name (qif-xtn:from-acct xtn))
-          (set! far-acct-name (qif-split:category split))
-          (set! group-amount (gnc-numeric-zero))
-
-          ;; group-amount is the sum of all the splits in this xtn
-          ;; going to the same account as 'split'.  We might be able
-          ;; to match this whole group to a single matching opposite
-          ;; split.
-          (for-each
-           (lambda (s)
-             (if (and (qif-split:category-is-account? s)
-                      (string=? far-acct-name (qif-split:category s)))
-                 (begin
-                   (set! same-acct-splits
-                         (cons s same-acct-splits))
-                   (set! group-amount (nsub group-amount (qif-split:amount s))))
-                 (set! different-acct-splits
-                       (cons s different-acct-splits))))
-           splits)
-
-          (set! same-acct-splits (reverse same-acct-splits))
-          (set! different-acct-splits (reverse different-acct-splits)))
-
-        ;; stock transactions.  they can't have splits as far as I can
-        ;; tell, so the 'different-acct-splits' is always '()
-        (let ((qif-accts
-               (qif-split:accounts-affected split xtn)))
-          (set! near-acct-name (car qif-accts))
-          (set! far-acct-name (cadr qif-accts))
-          (set! same-acct-splits (list split))
-          (if action
-              ;; we need to do some special massaging to get
-              ;; transactions to match up.  Quicken thinks the near
-              ;; and far accounts are different than we do.
-              (case action
-                ((intincx divx cglongx cgmidx cgshortx rtrncapx margintx
-                          sellx)
-                 (set! amount (n- amount))
-                 (set! near-acct-name (qif-xtn:from-acct xtn))
-                 (set! far-acct-name (qif-split:category split)))
-                ((miscincx miscexpx)
-                 (set! amount (n- amount))
-                 (set! near-acct-name (qif-xtn:from-acct xtn))
-                 (set! far-acct-name (qif-split:miscx-category split)))
-                ((buyx)
-                 (set! near-acct-name (qif-xtn:from-acct xtn))
-                 (set! far-acct-name (qif-split:category split)))
-                ((xout)
-                 (set! amount (n- amount)))))))
-
-    ;; this is the grind loop.  Go over every unmarked transaction in
-    ;; the candidate-xtns list.
-    (let xtn-loop ((xtns candidate-xtns))
-      (if (and (not (qif-xtn:mark (car xtns)))
-               (string=? (qif-xtn:from-acct (car xtns)) far-acct-name))
-          (begin
-            (set! how
-                  (qif-import:xtn-has-matches? (car xtns) near-acct-name
-                                               date amount group-amount))
-            (if how
-                (begin
-                  (qif-import:merge-and-mark-xtns xtn same-acct-splits
-                                                  (car xtns) how)
-                  (set! done #t)))))
-      ;; iterate with the next transaction
-      (if (and (not done)
-               (not (null? (cdr xtns))))
-          (xtn-loop (cdr xtns))))
-
-    ;; return the rest of the splits to iterate on
-    (if (not how)
-        (cdr splits)
-        (case (car how)
-          ((one-to-one many-to-one)
-           (cdr splits))
-          ((one-to-many)
-           different-acct-splits)))))
-
-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-;;  qif-import:xtn-has-matches?
-;;  check for one-to-one, many-to-one, one-to-many split matches.
-;;  returns either #f (no match) or a cons cell with the car being one
-;;  of 'one-to-one 'one-to-many 'many-to-one, the cdr being a list of
-;;  splits that were part of the matching group.
-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-
-(define (qif-import:xtn-has-matches? xtn acct-name date amount group-amt)
-  (let ((same-acct-splits '())
-        (this-group-amt (gnc-numeric-zero))
-        (how #f)
-        (date-matches
-         (let ((self-date (qif-xtn:date xtn)))
-           (and (pair? self-date)
-                (pair? date)
-                (eq? (length self-date) 3)
-                (eq? (length date) 3)
-                (= (car self-date) (car date))
-                (= (cadr self-date) (cadr date))
-                (= (caddr self-date) (caddr date)))))
-        (n- (lambda (n) (gnc-numeric-neg n)))
-        (nsub (lambda (a b) (gnc-numeric-sub a b 0 GNC-DENOM-LCD)))
-        (n+ (lambda (a b) (gnc-numeric-add a b 0 GNC-DENOM-LCD)))
-        (n* (lambda (a b) (gnc-numeric-mul a b 0 GNC-DENOM-REDUCE)))
-        (n/ (lambda (a b) (gnc-numeric-div a b 0 GNC-DENOM-REDUCE))))
-
-    (if date-matches
-        (begin
-          ;; calculate a group total for splits going to acct-name
-          (let split-loop ((splits-left (qif-xtn:splits xtn)))
-            (let ((split (car splits-left)))
-              ;; does the account match up?
-              (if (and (qif-split:category-is-account? split)
-                       (string? acct-name)
-                       (string=? (qif-split:category split) acct-name))
-                  ;; if so, get the amount
-                  (let ((this-amt (qif-split:amount split))
-                        (stock-xtn (qif-xtn:security-name xtn))
-                        (action (qif-xtn:action xtn)))
-                    ;; need to change the sign of the amount for some
-                    ;; stock transactions (buy/sell both positive in
-                    ;; QIF)
-                    (if (and stock-xtn action)
-                        (case action
-                          ((xout sellx intincx divx cglongx cgshortx
-                                 miscincx miscexpx)
-                           (set! this-amt (n- this-amt)))))
-
-                    ;; we might be done if this-amt is either equal
-                    ;; to the split amount or the group amount.
-                    (cond
-                     ((gnc-numeric-equal this-amt amount)
-                      (set! how
-                            (cons 'one-to-one (list split))))
-                     ((and group-amt (gnc-numeric-equal this-amt group-amt))
-                      (set! how
-                            (cons 'one-to-many (list split))))
-                     (#t
-                      (set! same-acct-splits (cons split same-acct-splits))
-                      (set! this-group-amt
-                            (n+ this-group-amt this-amt))))))
-
-              ;; if 'how' is non-#f, we are ready to return.
-              (if (and (not how)
-                       (not (null? (cdr splits-left))))
-                  (split-loop (cdr splits-left)))))
-
-          ;; now we're out of the loop.  if 'how' isn't set,
-          ;; we can still have a many-to-one match.
-          (if (and (not how)
-                   (gnc-numeric-equal this-group-amt amount))
-              (set! how (cons 'many-to-one same-acct-splits)))))
-
-    ;; we're all done.  'how' either is #f or a
-    ;; cons of the way-it-matched and a list of the matching
-    ;; splits.
-    how))
-
-
-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-;;  (qif-split:accounts-affected split xtn)
-;;  Get the near and far ends of a split, returned as a list
-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-
-(define (qif-split:accounts-affected split xtn)
-  (let ((near-acct-name #f)
-        (far-acct-name #f)
-        (commission-acct-name #f)
-        (security (qif-xtn:security-name xtn))
-        (action (qif-xtn:action xtn))
-        (from-acct (qif-xtn:from-acct xtn)))
-
-    ;; for non-security transactions, the near account is the
-    ;; acct in which the xtn is, and the far is the account
-    ;; linked by the category line.
-
-    (if (not security)
-        ;; non-security transactions
-        (begin
-          (set! near-acct-name from-acct)
-          (set! far-acct-name (qif-split:category split)))
-
-        ;; security transactions : the near end is either the
-        ;; brokerage, the stock, or the category
-        (begin
-          (case action
-            ((buy buyx sell sellx reinvint reinvdiv reinvsg reinvsh
-                  reinvlg reinvmd shrsin shrsout stksplit)
-             (set! near-acct-name (default-stock-acct from-acct security)))
-            ((div cgshort cglong cgmid intinc miscinc miscexp
-                  rtrncap margint xin xout)
-             (set! near-acct-name from-acct))
-            ((divx cgshortx cglongx cgmidx intincx rtrncapx margintx)
-             (set! near-acct-name
-                   (qif-split:category (car (qif-xtn:splits xtn)))))
-            ((miscincx miscexpx)
-             (set! near-acct-name
-                   (qif-split:miscx-category (car (qif-xtn:splits xtn))))))
-
-          ;; the far split: where is the money coming from?
-          ;; Either the brokerage account, the category,
-          ;; or an external account
-          (case action
-            ((buy sell)
-             (set! far-acct-name from-acct))
-            ((buyx sellx miscinc miscincx miscexp miscexpx xin xout)
-             (set! far-acct-name
-                   (qif-split:category (car (qif-xtn:splits xtn)))))
-            ((stksplit)
-             (set! far-acct-name (default-stock-acct from-acct security)))
-            ((cgshort cgshortx reinvsg reinvsh)
-             (set! far-acct-name
-                   (default-cgshort-acct from-acct security)))
-            ((cglong cglongx reinvlg)
-             (set! far-acct-name
-                   (default-cglong-acct from-acct security)))
-            ((cgmid cgmidx reinvmd)
-             (set! far-acct-name
-                   (default-cgmid-acct from-acct security)))
-            ((intinc intincx reinvint)
-             (set! far-acct-name
-                   (default-interest-acct from-acct security)))
-            ((margint margintx)
-             (set! far-acct-name
-                   (default-margin-interest-acct from-acct)))
-            ((rtrncap rtrncapx)
-             (set! far-acct-name
-                   (default-capital-return-acct from-acct security)))
-            ((div divx reinvdiv)
-             (set! far-acct-name
-                   (default-dividend-acct from-acct security)))
-            ((shrsin shrsout)
-             (set! far-acct-name
-                   (default-equity-holding security))))
-
-          ;; the commission account, if it exists
-          (if (qif-xtn:commission xtn)
-              (set! commission-acct-name
-                    (default-commission-acct from-acct)))))
-
-    (list near-acct-name far-acct-name commission-acct-name)))
-
-
-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-;; qif-import:merge-and-mark-xtns
-;; we know that the splits match.  Pick one to mark and
-;; merge the information into the other one.
-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-
-(define (qif-import:merge-and-mark-xtns xtn splits other-xtn how)
-  ;; merge transaction fields
-  (let ((action (qif-xtn:action xtn))
-        (o-action (qif-xtn:action other-xtn))
-        (security (qif-xtn:security-name xtn))
-        (o-security (qif-xtn:security-name other-xtn))
-        (split (car splits))
-        (match-type (car how))
-        (match-splits (cdr how)))
-    (case match-type
-      ;; many-to-one: the other-xtn has several splits that total
-      ;; in amount to 'split'.  We want to preserve the multi-split
-      ;; transaction.
-      ((many-to-one)
-       (qif-xtn:mark-split xtn split)
-       (qif-import:merge-xtn-info xtn other-xtn)
-       (for-each
-        (lambda (s)
-          (qif-split:set-matching-cleared! s (qif-xtn:cleared xtn)))
-        match-splits))
-
-      ;; one-to-many: 'split' is just one of a set of splits in xtn
-      ;; that total up to the split in match-splits.
-      ((one-to-many)
-       (qif-xtn:mark-split other-xtn (car match-splits))
-       (qif-import:merge-xtn-info other-xtn xtn)
-       (for-each
-        (lambda (s)
-          (qif-split:set-matching-cleared!
-           s (qif-xtn:cleared other-xtn)))
-        splits))
-
-      ;; otherwise: one-to-one, a normal single split match.
-      (else
-       (cond
-        ;; If one transaction has more splits than the other, mark the
-        ;; one with less splits, regardless of all other conditions.
-        ;; Otherwise, QIF split transactions will become mangled. For
-        ;; more information, see bug 114724.
-        ((< (length (qif-xtn:splits xtn))
-            (length (qif-xtn:splits other-xtn)))
-               (qif-xtn:mark-split xtn split)
-               (qif-import:merge-xtn-info xtn other-xtn)
-               (qif-split:set-matching-cleared!
-                (car match-splits) (qif-xtn:cleared xtn)))
-
-        ((> (length (qif-xtn:splits xtn))
-            (length (qif-xtn:splits other-xtn)))
-               (qif-xtn:mark-split other-xtn (car match-splits))
-               (qif-import:merge-xtn-info other-xtn xtn)
-               (qif-split:set-matching-cleared!
-                split (qif-xtn:cleared other-xtn)))
-
-        ;; this is a transfer involving a security xtn.  Let the
-        ;; security xtn dominate the way it's handled.
-        ((and (not action) o-action o-security)
-         (qif-xtn:mark-split xtn split)
-         (qif-import:merge-xtn-info xtn other-xtn)
-         (qif-split:set-matching-cleared!
-          (car match-splits) (qif-xtn:cleared xtn)))
-
-        ((and action (not o-action) security)
-         (qif-xtn:mark-split other-xtn (car match-splits))
-         (qif-import:merge-xtn-info other-xtn xtn)
-         (qif-split:set-matching-cleared!
-          split (qif-xtn:cleared other-xtn)))
-
-        ;; this is a security transaction from one brokerage to another
-        ;; or within a brokerage.  The "foox" xtn has the most
-        ;; information about what went on, so use it.
-        ((and action o-action o-security)
-         (case o-action
-           ((buyx sellx cgshortx cgmidx cglongx intincx divx
-                  margintx rtrncapx miscincx miscexpx)
-            (qif-xtn:mark-split xtn split)
-            (qif-import:merge-xtn-info xtn other-xtn)
-            (qif-split:set-matching-cleared!
-             (car match-splits) (qif-xtn:cleared xtn)))
-
-           (else
-            (qif-xtn:mark-split other-xtn (car match-splits))
-            (qif-import:merge-xtn-info other-xtn xtn)
-            (qif-split:set-matching-cleared!
-             split (qif-xtn:cleared other-xtn)))))
-
-        ;; Otherwise, this is a normal no-frills split match.
-        (#t
-          (qif-xtn:mark-split other-xtn (car match-splits))
-          (qif-import:merge-xtn-info other-xtn xtn)
-          (qif-split:set-matching-cleared!
-           split (qif-xtn:cleared other-xtn))))))))
-
-
-(define (qif-import:merge-xtn-info from-xtn to-xtn)
-  (if (and (qif-xtn:payee from-xtn)
-           (not (qif-xtn:payee to-xtn)))
-      (qif-xtn:set-payee! to-xtn (qif-xtn:payee from-xtn)))
-  (if (and (qif-xtn:address from-xtn)
-           (not (qif-xtn:address to-xtn)))
-      (qif-xtn:set-address! to-xtn (qif-xtn:address from-xtn)))
-  (if (and (qif-xtn:number from-xtn)
-           (not (qif-xtn:number to-xtn)))
-      (qif-xtn:set-number! to-xtn (qif-xtn:number from-xtn))))
-
-
-(define (qif-xtn:mark-split xtn split)
-  (qif-split:set-mark! split #t)
-  (let ((all-marked #t))
-    (let loop ((splits (qif-xtn:splits xtn)))
-      (if (not (qif-split:mark (car splits)))
-          (set! all-marked #f)
-          (if (not (null? (cdr splits)))
-              (loop (cdr splits)))))
-    (if all-marked
-        (qif-xtn:set-mark! xtn #t))))
-
-
-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-;;  qif-import:qif-to-gnc-undo
-;;
-;;  Cancel the import by removing all newly created accounts,
-;;  splits, and transactions.
-;;
-;;  NOTE: Any new commodities should be destroyed by the druid.
-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-(define (qif-import:qif-to-gnc-undo root)
-  (if root
-    (let ((txns (gnc:account-tree-get-transactions root)))
-      ;; Destroy all the transactions and their splits.
-      (for-each (lambda (elt) (xaccTransDestroy elt)) txns)
-
-      ;; Destroy the accounts
-      (xaccAccountBeginEdit root)
-      (xaccAccountDestroy root))))

Deleted: gnucash/trunk/src/import-export/qif-import/qif-utils.scm
===================================================================
--- gnucash/trunk/src/import-export/qif-import/qif-utils.scm	2013-12-15 17:20:10 UTC (rev 23566)
+++ gnucash/trunk/src/import-export/qif-import/qif-utils.scm	2013-12-15 17:21:20 UTC (rev 23567)
@@ -1,100 +0,0 @@
-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-;;;  qif-utils.scm
-;;;  string munging and other utility routines 
-;;;
-;;;  Bill Gribble <grib at billgribble.com> 20 Feb 2000 
-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-
-(use-modules (ice-9 regex))
-
-(define qif-import:paused #f)
-(define qif-import:canceled #f)
-
-(define (simple-filter pred list)
-  (let ((retval '()))
-    (map (lambda (elt)
-           (if (pred elt)
-               (set! retval (cons elt retval))))
-         list)
-    (reverse retval)))
-
-(define remove-trailing-space-rexp 
-  (make-regexp "^(.*[^ ]+) *$"))
-
-(define remove-leading-space-rexp 
-  (make-regexp "^ *([^ ].*)$"))
-
-(define (string-remove-trailing-space str)
-  (let ((match (regexp-exec remove-trailing-space-rexp str)))
-    (if match
-        (string-copy (match:substring match 1))
-        "")))
-
-(define (string-remove-leading-space str)
-  (let ((match (regexp-exec remove-leading-space-rexp str)))
-    (if match 
-        (string-copy (match:substring match 1))
-        "")))
-
-(define (string-remove-char str char)
-  (let ((rexpstr 
-         (case char  
-           ((#\.) "\\.")
-           ((#\^) "\\^")
-           ((#\$) "\\$")
-           ((#\*) "\\*")
-           ((#\+) "\\+")
-           ((#\\) "\\\\")
-           ((#\?) "\\?")
-           (else 
-             (make-string 1 char)))))
-    (regexp-substitute/global #f rexpstr str 'pre 'post)))
-
-
-(define (string-char-count str char)
-  (length (simple-filter (lambda (elt) (eq? elt char))
-                         (string->list str))))
-
-
-(define (string-replace-char! str old new)
-  (let ((rexpstr 
-         (if (not (eq? old #\.))
-             (make-string 1 old)
-             "\\."))
-        (newstr (make-string 1 new)))
-    (regexp-substitute/global #f rexpstr str 'pre newstr 'post)))
-
-(define (string-to-canonical-symbol str)
-  (string->symbol 
-   (string-downcase
-    (string-remove-leading-space
-     (string-remove-trailing-space str)))))
-
-
-(define (qif-import:log progress-dialog proc str)
-  (if progress-dialog
-      (gnc-progress-dialog-append-log progress-dialog (string-append str "\n"))
-      (gnc:warn proc ": " str)))
-
-(define (qif-import:reset-cancel-pause)
-  (set! qif-import:paused #f)
-  (set! qif-import:canceled #f))
-
-(define (qif-import:cancel)
-  (set! qif-import:canceled #t))
-
-(define (qif-import:toggle-pause progress-dialog)
-  (if qif-import:paused
-      (begin
-        (set! qif-import:paused #f)
-        (if progress-dialog
-            (gnc-progress-dialog-resume progress-dialog)))
-      (begin
-        (set! qif-import:paused #t)
-        (if progress-dialog
-            (gnc-progress-dialog-pause progress-dialog)))))
-
-(define (qif-import:check-pause progress-dialog)
-  (while (and qif-import:paused (not qif-import:canceled))
-    (gnc-progress-dialog-update progress-dialog)))
-

Deleted: gnucash/trunk/src/import-export/qif-import/test/Makefile.am
===================================================================
--- gnucash/trunk/src/import-export/qif-import/test/Makefile.am	2013-12-15 17:20:10 UTC (rev 23566)
+++ gnucash/trunk/src/import-export/qif-import/test/Makefile.am	2013-12-15 17:21:20 UTC (rev 23567)
@@ -1,17 +0,0 @@
-TESTS=test-link
-
-check_PROGRAMS=test-link
-
-test_link_SOURCES = \
-  test-link.c
-
-test_link_LDADD=../libgncmod-qif-import.la \
-  ${top_builddir}/src/register/ledger-core/libgncmod-ledger-core.la \
-  ${top_builddir}/src/libqof/qof/libgnc-qof.la \
-  ${top_builddir}/src/core-utils/libgnc-core-utils.la \
-  ${top_builddir}/src/gnome/libgnc-gnome.la \
-  ${top_builddir}/src/engine/libgncmod-engine.la \
-  ${top_builddir}/src/gnome-utils/libgncmod-gnome-utils.la \
-  ${top_builddir}/src/app-utils/libgncmod-app-utils.la \
-  ${LIBXML2_LIBS}
-

Deleted: gnucash/trunk/src/import-export/qif-import/test/test-link.c
===================================================================
--- gnucash/trunk/src/import-export/qif-import/test/test-link.c	2013-12-15 17:20:10 UTC (rev 23566)
+++ gnucash/trunk/src/import-export/qif-import/test/test-link.c	2013-12-15 17:21:20 UTC (rev 23567)
@@ -1,6 +0,0 @@
-int
-main(int argc, char ** argv)
-{
-    return 0;
-}
-



More information about the gnucash-changes mailing list