Add import-export/binary-import module for importing legacy files.

git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@5385 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
Dave Peticolas
2001-09-18 23:45:29 +00:00
parent 54393d0a06
commit bae4ce8697
13 changed files with 324 additions and 80 deletions

View File

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

View File

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

View File

@@ -571,79 +571,6 @@
</widget>
</widget>
<widget>
<class>GtkWindow</class>
<name>New Commodity Format Druid</name>
<title>Import currency and stock information</title>
<type>GTK_WINDOW_TOPLEVEL</type>
<position>GTK_WIN_POS_NONE</position>
<modal>False</modal>
<allow_shrink>False</allow_shrink>
<allow_grow>True</allow_grow>
<auto_shrink>True</auto_shrink>
<widget>
<class>GnomeDruid</class>
<name>commodity_druid</name>
<widget>
<class>GnomeDruidPageStart</class>
<name>start_page</name>
<signal>
<name>cancel</name>
<handler>gnc_ui_commodity_druid_cancel_cb</handler>
<data>New_Commodity_Format_Druid</data>
<last_modification_time>Fri, 11 Aug 2000 21:12:16 GMT</last_modification_time>
</signal>
<title>Import currency and stock information </title>
<text>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 &quot;Cancel&quot; now to stop loading the file. </text>
<title_color>255,255,255</title_color>
<text_color>0,0,0</text_color>
<background_color>153,191,153</background_color>
<logo_background_color>255,255,255</logo_background_color>
<textbox_color>255,255,255</textbox_color>
</widget>
<widget>
<class>GnomeDruidPageFinish</class>
<name>finish_page</name>
<signal>
<name>finish</name>
<handler>gnc_ui_commodity_druid_finish_cb</handler>
<data>New_Commodity_Format_Druid</data>
<last_modification_time>Fri, 11 Aug 2000 21:17:16 GMT</last_modification_time>
</signal>
<signal>
<name>cancel</name>
<handler>gnc_ui_commodity_druid_cancel_cb</handler>
<data>New_Commodity_Format_Druid</data>
<last_modification_time>Fri, 11 Aug 2000 21:17:46 GMT</last_modification_time>
</signal>
<title>Update your accounts with the new information</title>
<text>Click &quot;Finish&quot; to update your accounts to use the new
information you have entered.
Click &quot;Cancel&quot; to cancel the file-loading process.
Click &quot;Back&quot; to review your currency selections.</text>
<background_color>155,191,156</background_color>
<logo_background_color>255,255,255</logo_background_color>
<textbox_color>255,255,255</textbox_color>
<text_color>0,0,0</text_color>
<title_color>255,255,255</title_color>
</widget>
</widget>
</widget>
<widget>
<class>GnomeDialog</class>
<name>Commodities Dialog</name>

View File

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

View File

@@ -0,0 +1,8 @@
Makefile
Makefile.in
.deps
*.diff
.scm-links
gw-binary-import.c
gw-binary-import.h
gw-binary-import.html

View File

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

View File

@@ -0,0 +1,92 @@
<?xml version="1.0"?>
<GTK-Interface>
<project>
<name>Glade</name>
<program_name>glade</program_name>
<directory></directory>
<source_directory></source_directory>
<pixmaps_directory></pixmaps_directory>
<language>C</language>
<gnome_support>True</gnome_support>
<gettext_support>True</gettext_support>
<output_main_file>False</output_main_file>
<output_support_files>False</output_support_files>
<output_build_files>False</output_build_files>
<backup_source_files>False</backup_source_files>
</project>
<widget>
<class>GtkWindow</class>
<name>New Commodity Format Druid</name>
<title>Import currency and stock information</title>
<type>GTK_WINDOW_TOPLEVEL</type>
<position>GTK_WIN_POS_NONE</position>
<modal>False</modal>
<allow_shrink>False</allow_shrink>
<allow_grow>True</allow_grow>
<auto_shrink>True</auto_shrink>
<widget>
<class>GnomeDruid</class>
<name>commodity_druid</name>
<widget>
<class>GnomeDruidPageStart</class>
<name>start_page</name>
<signal>
<name>cancel</name>
<handler>gnc_ui_commodity_druid_cancel_cb</handler>
<data>New_Commodity_Format_Druid</data>
<last_modification_time>Fri, 11 Aug 2000 21:12:16 GMT</last_modification_time>
</signal>
<title>Import currency and stock information </title>
<text>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 &quot;Cancel&quot; now to stop loading the file. </text>
<title_color>255,255,255</title_color>
<text_color>0,0,0</text_color>
<background_color>153,191,153</background_color>
<logo_background_color>255,255,255</logo_background_color>
<textbox_color>255,255,255</textbox_color>
</widget>
<widget>
<class>GnomeDruidPageFinish</class>
<name>finish_page</name>
<signal>
<name>finish</name>
<handler>gnc_ui_commodity_druid_finish_cb</handler>
<data>New_Commodity_Format_Druid</data>
<last_modification_time>Fri, 11 Aug 2000 21:17:16 GMT</last_modification_time>
</signal>
<signal>
<name>cancel</name>
<handler>gnc_ui_commodity_druid_cancel_cb</handler>
<data>New_Commodity_Format_Druid</data>
<last_modification_time>Fri, 11 Aug 2000 21:17:46 GMT</last_modification_time>
</signal>
<title>Update your accounts with the new information</title>
<text>Click &quot;Finish&quot; to update your accounts to use the new
information you have entered.
Click &quot;Cancel&quot; to cancel the file-loading process.
Click &quot;Back&quot; to review your currency selections.</text>
<background_color>155,191,156</background_color>
<logo_background_color>255,255,255</logo_background_color>
<textbox_color>255,255,255</textbox_color>
<text_color>0,0,0</text_color>
<title_color>255,255,255</title_color>
</widget>
</widget>
</widget>
</GTK-Interface>

View File

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

View File

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

View File

@@ -0,0 +1,74 @@
/*********************************************************************
* gncmod-binary-import.c
* module definition/initialization for importing gnucash binary files
*
* Copyright (c) 2001 Linux Developers Group, Inc.
*********************************************************************/
#include <stdio.h>
#include <guile/gh.h>
#include <glib.h>
#include <libguile/strports.h>
#include <libguile/modules.h>
#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;
}

View File

@@ -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 <druid-commodity.h>\n"
)))
(gw:wrap-function
mod
'gnc:import-legacy-commodities
'<gw:void>
"gnc_import_legacy_commodities"
'(((<gw:m-chars-caller-owned> gw:const) filename))
"Launch the legacy-commodity import druid")
)

View File

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