diff --git a/configure.in b/configure.in index e109341e80..f6f8907e3f 100644 --- a/configure.in +++ b/configure.in @@ -741,6 +741,7 @@ AC_OUTPUT( src/gnome-utils/test/Makefile src/guile/Makefile src/import-export/Makefile + src/import-export/binary-import/Makefile src/import-export/qif-import/Makefile src/import-export/qif-io-core/Makefile src/import-export/qif-io-core/test/Makefile diff --git a/src/gnome/Makefile.am b/src/gnome/Makefile.am index de735db73f..193838fd4b 100644 --- a/src/gnome/Makefile.am +++ b/src/gnome/Makefile.am @@ -23,7 +23,6 @@ libgncgnome_a_SOURCES = \ dialog-transfer.c \ dialog-userpass.c \ dialog-scheduledxaction.c \ - druid-commodity.c \ druid-hierarchy.c \ druid-stock-split.c \ file-history.c \ @@ -69,7 +68,6 @@ noinst_HEADERS = \ dialog-totd.h \ dialog-transfer.h \ dialog-scheduledxaction.h \ - druid-commodity.h \ druid-hierarchy.h \ file-utils.h \ gnc-network.h \ diff --git a/src/gnome/glade/commodity.glade b/src/gnome/glade/commodity.glade index 89210edb3a..22618a9f35 100644 --- a/src/gnome/glade/commodity.glade +++ b/src/gnome/glade/commodity.glade @@ -571,79 +571,6 @@ - - GtkWindow - New Commodity Format Druid - Import currency and stock information - GTK_WINDOW_TOPLEVEL - GTK_WIN_POS_NONE - False - False - True - True - - - GnomeDruid - commodity_druid - - - GnomeDruidPageStart - start_page - - cancel - gnc_ui_commodity_druid_cancel_cb - New_Commodity_Format_Druid - Fri, 11 Aug 2000 21:12:16 GMT - - Import currency and stock information - The file you are loading is from an older version of GnuCash. -Information about currencies, stocks, and mutual funds needs to -be updated for the new version. - -This dialog will prompt you for some additional information about -each currency, stock, and mutual fund that appear in your -accounts. After you have entered this information, you can -update your accounts for the new version of GnuCash. - -Hit "Cancel" now to stop loading the file. - 255,255,255 - 0,0,0 - 153,191,153 - 255,255,255 - 255,255,255 - - - - GnomeDruidPageFinish - finish_page - - finish - gnc_ui_commodity_druid_finish_cb - New_Commodity_Format_Druid - Fri, 11 Aug 2000 21:17:16 GMT - - - cancel - gnc_ui_commodity_druid_cancel_cb - New_Commodity_Format_Druid - Fri, 11 Aug 2000 21:17:46 GMT - - Update your accounts with the new information - Click "Finish" to update your accounts to use the new -information you have entered. - -Click "Cancel" to cancel the file-loading process. - -Click "Back" to review your currency selections. - 155,191,156 - 255,255,255 - 255,255,255 - 0,0,0 - 255,255,255 - - - - GnomeDialog Commodities Dialog diff --git a/src/import-export/Makefile.am b/src/import-export/Makefile.am index 55b31f0334..eecc2cc64d 100644 --- a/src/import-export/Makefile.am +++ b/src/import-export/Makefile.am @@ -1,4 +1,4 @@ -SUBDIRS = qif-import +SUBDIRS = binary-import qif-import # FIXME remove this when qif-io-core is finished -DIST_SUBDIRS = qif-import qif-io-core +DIST_SUBDIRS = binary-import qif-import qif-io-core diff --git a/src/import-export/binary-import/.cvsignore b/src/import-export/binary-import/.cvsignore new file mode 100644 index 0000000000..6e0fa37ea3 --- /dev/null +++ b/src/import-export/binary-import/.cvsignore @@ -0,0 +1,8 @@ +Makefile +Makefile.in +.deps +*.diff +.scm-links +gw-binary-import.c +gw-binary-import.h +gw-binary-import.html diff --git a/src/import-export/binary-import/Makefile.am b/src/import-export/binary-import/Makefile.am new file mode 100644 index 0000000000..dd5e2b1b6a --- /dev/null +++ b/src/import-export/binary-import/Makefile.am @@ -0,0 +1,90 @@ +SUBDIRS = . #test + +pkglib_LTLIBRARIES = libgncmod-binary-import.la + +CFLAGS = @CFLAGS@ ${GLIB_CFLAGS} + +#FIXME remove the following deps +# -I${top_srcdir}/src \ +# -I${top_srcdir}/src/gnome \ + +INCLUDES = \ + -I${top_srcdir}/src/gnc-module \ + -I${top_srcdir}/src/engine \ + -I${top_srcdir}/src/app-utils \ + -I${top_srcdir}/src/gnome-utils \ + -I${top_srcdir}/src \ + -I${top_srcdir}/src/gnome \ + ${GNOME_INCLUDEDIR} \ + ${GUILE_INCS} + +libgncmod_binary_import_la_SOURCES = \ + druid-commodity.c \ + gncmod-binary-import.c + +gncincludedir = ${GNC_INCLUDE_DIR} +gncinclude_HEADERS = \ + druid-commodity.h + +libgncmod_binary_import_la_LDFLAGS = -module + +libgncmod_binary_import_la_LIBADD = \ + -L${top_srcdir}/src/gnc-module \ + -L${top_srcdir}/src/gnc-module/.libs \ + -lgncmodule \ + -L${top_srcdir}/src/engine \ + -L${top_srcdir}/src/engine/.libs \ + -lgncmod-engine \ + -L${top_srcdir}/src/calculation \ + -L${top_srcdir}/src/calculation/.libs \ + -lgncmod-calculation \ + -L${top_srcdir}/src/app-utils \ + -L${top_srcdir}/src/app-utils/.libs \ + -lgncmod-app-utils \ + -L${top_srcdir}/src/gnome-utils \ + -L${top_srcdir}/src/gnome-utils/.libs \ + -lgncmod-gnome-utils \ + ${GNOMEUI_LIBS} \ + ${GNOME_LIBDIR} \ + ${GUILE_LIBS} \ + ${GLIB_LIBS} + +libgw_binary_import_la_SOURCES = gw-binary-import.c +libgw_binary_import_la_LDFLAGS = -module + +gncmoddir = ${GNC_SHAREDIR}/guile-modules/gnucash/import-export +gncmod_DATA = binary-import.scm + +gwmoddir = ${GNC_GWRAP_LIBDIR} +gwmod_LTLIBRARIES = libgw-binary-import.la +gwmod_DATA = gw-binary-import-spec.scm + +noinst_DATA = .scm-links + +gladedir = $(GNC_GLADE_DIR) +glade_DATA = binary-import.glade + +EXTRA_DIST = \ + ${gncmod_DATA} \ + ${gwmod_DATA} \ + ${glade_DATA} + +.scm-links: + rm -f gnucash g-wrapped + ln -sf . gnucash + ln -sf . g-wrapped + touch .scm-links + +gw-binary-import.c gw-binary-import.h: .scm-links gw-binary-import-spec.scm + FLAVOR=gnome guile -c \ + "(set! %load-path (cons \"${G_WRAP_MODULE_DIR}\" %load-path)) \ + (set! %load-path (cons \"${PWD}\" %load-path)) \ + (primitive-load \"./gw-binary-import-spec.scm\") \ + (gw:generate-module \"gw-binary-import\")" + +BUILT_SOURCES += gw-binary-import.c gw-binary-import.h +CLEANFILES += gw-binary-import.c gw-binary-import.h gw-binary-import.html \ + gnucash g-wrapped .scm-links + +EXTRA_DIST = \ + .cvsignore diff --git a/src/import-export/binary-import/binary-import.glade b/src/import-export/binary-import/binary-import.glade new file mode 100644 index 0000000000..87de18d91b --- /dev/null +++ b/src/import-export/binary-import/binary-import.glade @@ -0,0 +1,92 @@ + + + + + Glade + glade + + + + C + True + True + False + False + False + False + + + + GtkWindow + New Commodity Format Druid + Import currency and stock information + GTK_WINDOW_TOPLEVEL + GTK_WIN_POS_NONE + False + False + True + True + + + GnomeDruid + commodity_druid + + + GnomeDruidPageStart + start_page + + cancel + gnc_ui_commodity_druid_cancel_cb + New_Commodity_Format_Druid + Fri, 11 Aug 2000 21:12:16 GMT + + Import currency and stock information + The file you are loading is from an older version of GnuCash. +Information about currencies, stocks, and mutual funds needs to +be updated for the new version. + +This dialog will prompt you for some additional information about +each currency, stock, and mutual fund that appear in your +accounts. After you have entered this information, you can +update your accounts for the new version of GnuCash. + +Hit "Cancel" now to stop loading the file. + 255,255,255 + 0,0,0 + 153,191,153 + 255,255,255 + 255,255,255 + + + + GnomeDruidPageFinish + finish_page + + finish + gnc_ui_commodity_druid_finish_cb + New_Commodity_Format_Druid + Fri, 11 Aug 2000 21:17:16 GMT + + + cancel + gnc_ui_commodity_druid_cancel_cb + New_Commodity_Format_Druid + Fri, 11 Aug 2000 21:17:46 GMT + + Update your accounts with the new information + Click "Finish" to update your accounts to use the new +information you have entered. + +Click "Cancel" to cancel the file-loading process. + +Click "Back" to review your currency selections. + 155,191,156 + 255,255,255 + 255,255,255 + 0,0,0 + 255,255,255 + + + + + diff --git a/src/import-export/binary-import/binary-import.scm b/src/import-export/binary-import/binary-import.scm new file mode 100644 index 0000000000..093a5182b4 --- /dev/null +++ b/src/import-export/binary-import/binary-import.scm @@ -0,0 +1,6 @@ + +(define-module (gnucash import-export binary-import)) +(use-modules (g-wrapped gw-binary-import)) +(use-modules (gnucash app-utils)) + +(gnc:hook-add-dangler gnc:*book-opened-hook* gnc:import-legacy-commodities) diff --git a/src/gnome/druid-commodity.c b/src/import-export/binary-import/druid-commodity.c similarity index 99% rename from src/gnome/druid-commodity.c rename to src/import-export/binary-import/druid-commodity.c index 21c62f1609..03b9057929 100644 --- a/src/gnome/druid-commodity.c +++ b/src/import-export/binary-import/druid-commodity.c @@ -139,7 +139,8 @@ gnc_ui_commodity_druid_create(const char * filename) { GnomeDruidPage * back_page; GladeXML * xml; - xml = gnc_glade_xml_new ("commodity.glade", "New Commodity Format Druid"); + xml = gnc_glade_xml_new ("binary-import.glade", + "New Commodity Format Druid"); d->window = glade_xml_get_widget (xml, "New Commodity Format Druid"); dobj = GTK_OBJECT(d->window); diff --git a/src/gnome/druid-commodity.h b/src/import-export/binary-import/druid-commodity.h similarity index 100% rename from src/gnome/druid-commodity.h rename to src/import-export/binary-import/druid-commodity.h diff --git a/src/import-export/binary-import/gncmod-binary-import.c b/src/import-export/binary-import/gncmod-binary-import.c new file mode 100644 index 0000000000..432b21c507 --- /dev/null +++ b/src/import-export/binary-import/gncmod-binary-import.c @@ -0,0 +1,74 @@ +/********************************************************************* + * gncmod-binary-import.c + * module definition/initialization for importing gnucash binary files + * + * Copyright (c) 2001 Linux Developers Group, Inc. + *********************************************************************/ + +#include +#include +#include +#include +#include + +#include "gnc-module.h" +#include "gnc-module-api.h" + +/* version of the gnc module system interface we require */ +int gnc_module_system_interface = 0; + +/* module versioning uses libtool semantics. */ +int gnc_module_current = 0; +int gnc_module_revision = 0; +int gnc_module_age = 0; + +char * +gnc_module_path(void) { + return g_strdup("gnucash/import-export/binary-import"); +} + +char * +gnc_module_description(void) { + return g_strdup("Utilities importing GnuCash binary files"); +} + +static void +lmod(char * mn) +{ + char * form = g_strdup_printf("(use-modules %s)\n", mn); + gh_eval_str(form); + g_free(form); +} + +int +gnc_module_init(int refcount) { + if (refcount == 0) + { + /* load the engine (we depend on it) */ + if(!gnc_module_load("gnucash/engine", 0)) { + return FALSE; + } + + /* load the calculation module (we depend on it) */ + if(!gnc_module_load("gnucash/app-utils", 0)) { + return FALSE; + } + + /* load the calculation module (we depend on it) */ + if(!gnc_module_load("gnucash/gnome-utils", 0)) { + return FALSE; + } + + /* publish g-wrapped bindings */ + /* load the scheme code */ + lmod("(g-wrapped gw-binary-import)"); + lmod("(gnucash import-export binary-import)"); + } + + return TRUE; +} + +int +gnc_module_end(int refcount) { + return TRUE; +} diff --git a/src/import-export/binary-import/gw-binary-import-spec.scm b/src/import-export/binary-import/gw-binary-import-spec.scm new file mode 100644 index 0000000000..e1f0de80ca --- /dev/null +++ b/src/import-export/binary-import/gw-binary-import-spec.scm @@ -0,0 +1,48 @@ +(define-module (g-wrapped gw-app-utils-spec)) + +(use-modules (g-wrap)) + +(debug-set! maxdepth 100000) +(debug-set! stack 2000000) + +(let ((mod (gw:new-module "gw-binary-import"))) + (define (standard-c-call-gen result func-call-code) + (list (gw:result-get-c-name result) " = " func-call-code ";\n")) + + (define (add-standard-result-handlers! type c->scm-converter) + (define (standard-pre-handler result) + (let* ((ret-type-name (gw:result-get-proper-c-type-name result)) + (ret-var-name (gw:result-get-c-name result))) + (list "{\n" + " " ret-type-name " " ret-var-name ";\n"))) + + (gw:type-set-pre-call-result-ccodegen! type standard-pre-handler) + + (gw:type-set-post-call-result-ccodegen! + type + (lambda (result) + (let* ((scm-name (gw:result-get-scm-name result)) + (c-name (gw:result-get-c-name result))) + (list + (c->scm-converter scm-name c-name) + " }\n"))))) + + (gw:module-depends-on mod "gw-runtime") + + (gw:module-set-guile-module! mod '(g-wrapped gw-binary-import)) + + (gw:module-set-declarations-ccodegen! + mod + (lambda (client-only?) + (list + "#include \n" + ))) + + (gw:wrap-function + mod + 'gnc:import-legacy-commodities + ' + "gnc_import_legacy_commodities" + '((( gw:const) filename)) + "Launch the legacy-commodity import druid") +) diff --git a/src/scm/main.scm b/src/scm/main.scm index d89c53ea21..d2d920cade 100644 --- a/src/scm/main.scm +++ b/src/scm/main.scm @@ -149,6 +149,7 @@ (gnc:module-load "gnucash/register/ledger-core" 0) (gnc:module-load "gnucash/register/register-core" 0) (gnc:module-load "gnucash/register/register-gnome" 0) + (gnc:module-load "gnucash/import-export/binary-import" 0) (gnc:module-load "gnucash/import-export/qif-import" 0) (gnc:module-load "gnucash/report/report-system" 0) (gnc:module-load "gnucash/report/stylesheets" 0) @@ -169,8 +170,6 @@ (gnc:depend "price-quotes.scm") (gnc:depend "tip-of-the-day.scm") - (gnc:hook-add-dangler gnc:*book-opened-hook* gnc:import-legacy-commodities) - (if (not (gnc:handle-command-line-args)) (gnc:shutdown 1))