Wrap app-file functions in that module.

Get rid of gnc:timepair-to-datestring and just use gnc:print-date instead.


git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@5405 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
Dave Peticolas
2001-09-21 20:02:55 +00:00
parent 85e41282fe
commit 0526bc3daa
23 changed files with 155 additions and 59 deletions

View File

@@ -33,22 +33,20 @@ libgncmod_app_file_la_LIBADD = \
${GUILE_LIBS} \
${GLIB_LIBS}
#libgw_app_file_la_SOURCES = gw-app-file.c
#libgw_app_file_la_LDFLAGS = -module
libgw_app_file_la_SOURCES = gw-app-file.c
libgw_app_file_la_LDFLAGS = -module
#gncmoddir = ${GNC_SHAREDIR}/guile-modules/gnucash
#gncmod_DATA = app-file.scm
#gwmoddir = ${GNC_GWRAP_LIBDIR}
#gwmod_LTLIBRARIES = libgw-app-file.la
#gwmod_DATA = gw-app-file-spec.scm
gwmoddir = ${GNC_GWRAP_LIBDIR}
gwmod_LTLIBRARIES = libgw-app-file.la
gwmod_DATA = gw-app-file-spec.scm
noinst_DATA = .scm-links
#EXTRA_DIST = \
# ${gncmod_DATA} \
# ${gncscm_DATA} \
# ${gwmod_DATA}
EXTRA_DIST = \
${gwmod_DATA}
.scm-links:
rm -f gnucash g-wrapped
@@ -56,14 +54,14 @@ noinst_DATA = .scm-links
ln -sf . g-wrapped
touch .scm-links
#gw-app-file.c gw-app-file.h: .scm-links gw-app-file-spec.scm
# FLAVOR=gnome guile -c \
# "(set! %load-path (cons \"${G_WRAP_MODULE_DIR}\" %load-path)) \
# (set! %load-path (cons \"${PWD}\" %load-path)) \
# (set! %load-path (cons \"${top_srcdir}/src/engine\" %load-path)) \
# (primitive-load \"./gw-app-file-spec.scm\") \
# (gw:generate-module \"gw-app-file\")"
gw-app-file.c gw-app-file.h: .scm-links gw-app-file-spec.scm
FLAVOR=gnome guile -c \
"(set! %load-path (cons \"${G_WRAP_MODULE_DIR}\" %load-path)) \
(set! %load-path (cons \"${PWD}\" %load-path)) \
(set! %load-path (cons \"${top_srcdir}/src/engine\" %load-path)) \
(primitive-load \"./gw-app-file-spec.scm\") \
(gw:generate-module \"gw-app-file\")"
#BUILT_SOURCES += gw-app-file.c gw-app-file.h
#CLEANFILES += gw-app-file.c gw-app-file.h gw-app-file.html \
# gnucash g-wrapped .scm-links
BUILT_SOURCES += gw-app-file.c gw-app-file.h
CLEANFILES += gw-app-file.c gw-app-file.h gw-app-file.html \
gnucash g-wrapped .scm-links

View File

@@ -53,6 +53,8 @@ gnc_module_init(int refcount) {
return FALSE;
}
lmod ("(g-wrapped gw-app-file)");
if (refcount == 0)
{
gnc_file_init ();

View File

@@ -0,0 +1,93 @@
;;; -*-scheme-*-
(use-modules (g-wrap))
(debug-set! maxdepth 100000)
(debug-set! stack 2000000)
(define-module (g-wrapped gw-app-file-spec)
:use-module (g-wrap))
(use-modules (g-wrapped gw-engine-spec))
(use-modules (g-wrapped gw-glib-spec))
(let ((mod (gw:new-module "gw-app-file")))
(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-depends-on mod "gw-engine")
(gw:module-depends-on mod "gw-glib")
(gw:module-set-guile-module! mod '(g-wrapped gw-app-file))
(gw:module-set-declarations-ccodegen!
mod
(lambda (client-only?)
(list
"#include <gnc-file.h>\n"
"#include <gnc-file-dialog.h>\n"
"#include <gnc-file-history.h>\n")))
(gw:wrap-function
mod
'gnc:file-query-save
'<gw:bool>
"gnc_file_query_save"
'()
"Query the user whether to save the current file, and save
if they say 'Yes'. The return is false if the user says 'Cancel'.")
(gw:wrap-function
mod
'gnc:file-quit
'<gw:void>
"gnc_file_quit"
'()
"Stop working with the current file.")
(gw:wrap-function
mod
'gnc:file-open-file
'<gw:bool>
"gnc_file_open_file"
'(((<gw:m-chars-caller-owned> gw:const) filename))
"Open filename.")
(gw:wrap-function
mod
'gnc:history-get-last
'(<gw:m-chars-callee-owned> gw:const)
"gnc_history_get_last"
'()
"Get the last file opened by the user.")
(gw:wrap-function
mod
'gnc:file-selection-dialog
'(<gw:m-chars-callee-owned> gw:const)
"gnc_file_dialog"
'(((<gw:m-chars-caller-owned> gw:const) title)
((<gw:m-chars-caller-owned> gw:const) filter)
((<gw:m-chars-caller-owned> gw:const) default))
"Lets the user select a file. Dialog has given title, filter,
or default name. Either filter, default, or both should be NULL.")
)

View File

@@ -169,7 +169,6 @@
(export NinetyDayDelta)
(export gnc:timepair-delta)
(export gnc:time-elapsed)
(export gnc:timepair-to-datestring)
(export gnc:timepair-start-day-time)
(export gnc:timepair-end-day-time)
(export gnc:timepair-previous-day)

View File

@@ -310,8 +310,6 @@
;; and be implemented PROPERLY rather than hackily
;;; Added from transaction-report.scm
(define gnc:timepair-to-datestring gnc:print-date)
;; given a timepair contains any time on a certain day (local time)
;; converts it to be midday that day.

View File

@@ -2384,6 +2384,21 @@ of having a parent transaction with which one is working...")
'<gnc:time-pair>
"timespecCanonicalDayTime" '((<gnc:time-pair> tp))
"Convert a timepair on a certain day (localtime) to\
the timepair representing midday on that day"))
the timepair representing midday on that day")
;; src/engine/gnc-engine-util.h
(gw:wrap-function
mod
'gnc:safe-strcmp
'<gw:int>
"safe_strcmp" '(((<gw:m-chars-caller-owned> gw:const) a)
((<gw:m-chars-caller-owned> gw:const) b))
"Do a string comparison - in the C case it handles NULLs as the earliest string\
but in this case it doesn't really matter as a NULL should never be passed to it
over the scheme interface.")
)

View File

@@ -683,14 +683,6 @@ gnc_ui_start_event_loop (void)
/* ============================================================== */
gboolean
gnucash_ui_open_file(const char name[])
{
return gnc_file_open_file (name);
}
/* ============================================================== */
/* gnc_configure_date_format_cb
* Callback called when options change - sets dateFormat to the current
* value on the scheme side and refreshes register windows

View File

@@ -30,7 +30,6 @@
gboolean gnucash_ui_is_running(void);
gboolean gnucash_ui_is_terminating(void);
int gnucash_ui_init(void);
gboolean gnucash_ui_open_file(const char * name);
GNCMainInfo * gnc_ui_get_data(void);
void gnc_ui_shutdown(void);

View File

@@ -36,6 +36,7 @@
(use-modules (gnucash gnc-module))
(gnc:module-load "gnucash/tax/us" 0)
(gnc:module-load "gnucash/report/report-system" 0)
(gnc:module-load "gnucash/app-file" 0)
(define (make-level-collector num-levels)
(let ((level-collector (make-vector num-levels)))

View File

@@ -317,11 +317,11 @@
(last earlierlist))))
;; (if earlier
;; (warn "earlier"
;; (gnc:timepair-to-datestring (first earlier))
;; (gnc:print-date (first earlier))
;; (gnc:numeric-to-double (second earlier))))
;; (if later
;; (warn "later"
;; (gnc:timepair-to-datestring (first later))
;; (gnc:print-date (first later))
;; (gnc:numeric-to-double (second later))))
(if (and earlier later)

View File

@@ -354,11 +354,11 @@ balance at a given time"))
(if do-intervals?
(sprintf #f
(_ "%s to %s")
(gnc:timepair-to-datestring from-date-tp)
(gnc:timepair-to-datestring to-date-tp))
(gnc:print-date from-date-tp)
(gnc:print-date to-date-tp))
(sprintf #f
(_ "Balance at %s")
(gnc:timepair-to-datestring to-date-tp)))
(gnc:print-date to-date-tp)))
(if show-total?
(let ((total (apply + (unzip1 combined))))
(sprintf

View File

@@ -134,8 +134,8 @@
gain-loss-accum)
(set! data-rows
(cons
(list (gnc:timepair-to-datestring interval-start)
(gnc:timepair-to-datestring interval-end)
(list (gnc:print-date interval-start)
(gnc:print-date interval-end)
(/ (stats-accum 'total #f)
(gnc:timepair-delta interval-start
interval-end))

View File

@@ -207,7 +207,7 @@
;;(gnc:warn "account names" liability-account-names)
(gnc:html-document-set-title!
doc (sprintf #f (_ "Balance sheet at %s")
(gnc:timepair-to-datestring to-date-tp)))
(gnc:print-date to-date-tp)))
(if (not (null? accounts))
;; Get all the balances for each account group.

View File

@@ -233,7 +233,7 @@ developing over time"))
;; created.
(date-string-list
(map (lambda (date-list-item)
(gnc:timepair-to-datestring
(gnc:print-date
(if do-intervals?
(car date-list-item)
date-list-item)))
@@ -348,8 +348,8 @@ developing over time"))
(if do-intervals?
(_ "%s to %s")
(_ "Balances %s to %s"))
(gnc:timepair-to-datestring from-date-tp)
(gnc:timepair-to-datestring to-date-tp)))
(gnc:print-date from-date-tp)
(gnc:print-date to-date-tp)))
(gnc:html-barchart-set-width! chart width)
(gnc:html-barchart-set-height! chart height)

View File

@@ -245,9 +245,9 @@
(date-string-list (map
(if inc-exp?
(lambda (date-list-item)
(gnc:timepair-to-datestring
(gnc:print-date
(car date-list-item)))
gnc:timepair-to-datestring)
gnc:print-date)
dates-list)))
(gnc:html-barchart-set-title!
@@ -255,8 +255,8 @@
(gnc:html-barchart-set-subtitle!
chart (sprintf #f
(_ "%s to %s")
(gnc:timepair-to-datestring from-date-tp)
(gnc:timepair-to-datestring to-date-tp)))
(gnc:print-date from-date-tp)
(gnc:print-date to-date-tp)))
(gnc:html-barchart-set-width! chart width)
(gnc:html-barchart-set-height! chart height)
(gnc:html-barchart-set-row-labels! chart date-string-list)

View File

@@ -159,8 +159,8 @@
optname-from-date))))
(report-title (sprintf #f
(_ "Profit and Loss - %s to %s")
(gnc:timepair-to-datestring from-date-tp)
(gnc:timepair-to-datestring to-date-tp)))
(gnc:print-date from-date-tp)
(gnc:print-date to-date-tp)))
(doc (gnc:make-html-document)))
(gnc:html-document-set-title!

View File

@@ -147,7 +147,7 @@
(gnc:html-document-set-title!
document (string-append
report-title
(sprintf #f " %s" (gnc:timepair-to-datestring to-date))))
(sprintf #f " %s" (gnc:print-date to-date))))
(gnc:debug "accounts" accounts)
(if (not (null? accounts))

View File

@@ -184,8 +184,8 @@
" - "
(sprintf #f
(_ "%s to %s")
(gnc:timepair-to-datestring from-date-tp)
(gnc:timepair-to-datestring to-date-tp))))
(gnc:print-date from-date-tp)
(gnc:print-date to-date-tp))))
(gnc:html-scatter-set-width! chart width)
(gnc:html-scatter-set-height! chart height)
(gnc:html-scatter-set-marker! chart
@@ -240,7 +240,7 @@
;; some output
;;(warn "data" (map (lambda (x) (list
;; (gnc:timepair-to-datestring (car x))
;; (gnc:print-date (car x))
;; (gnc:numeric-to-double (second x))))
;; data))

View File

@@ -132,7 +132,7 @@
(if (date-col column-vector)
(addto! row-contents
(if transaction-info?
(gnc:timepair-to-datestring
(gnc:print-date
(gnc:transaction-get-date-posted parent))
" ")))
(if (num-col column-vector)

View File

@@ -346,8 +346,7 @@
(if (used-date column-vector)
(addto! row-contents
(if transaction-row?
(gnc:timepair-to-datestring
(gnc:transaction-get-date-posted parent))
(gnc:print-date (gnc:transaction-get-date-posted parent))
" ")))
(if (used-num column-vector)
(addto! row-contents

View File

@@ -273,7 +273,7 @@
(gnc:html-markup-b prepared-for)
(gnc:html-markup-br)
(_ "Date: ")
(gnc:timepair-to-datestring
(gnc:print-date
(cons (current-time) 0)))
;; title only

View File

@@ -247,7 +247,7 @@ option like this.")
;; these are samples of different date options. for a simple
;; date with day, month, and year but no time you should use
;; gnc:print-date or gnc:timepair-to-datestring
;; gnc:print-date
(let ((time-string (strftime "%X" (localtime (current-time))))
(date-string (strftime "%x" (localtime (car date-val))))
(date-string2 (strftime "%x %X" (localtime (car date2-val))))

View File

@@ -245,7 +245,7 @@
(define (gnc:load-account-file)
(let ((file (gnc:account-file-to-load)))
(if file
(and (not (gnc:ui-open-file file))
(and (not (gnc:file-open-file file))
(gnc:hook-run-danglers gnc:*book-opened-hook* #f))
(gnc:hook-run-danglers gnc:*book-opened-hook* #f))))