mirror of https://github.com/Gnucash/gnucash
git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@5360 57a11ea4-9604-0410-9ed3-97b8803252fdzzzoldfeatures/g2-gog-integ
parent
d8972c4b64
commit
4450f4a025
@ -1,23 +0,0 @@
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
;;; commodity-import.scm
|
||||
;;; file-io hooks to convert old-style currency strings to
|
||||
;;; real gnucash commodities.
|
||||
;;;
|
||||
;;; Bill Gribble <grib@billgribble.com> 11 Aug 2000
|
||||
;;; $Id$
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
|
||||
(gnc:support "commodity-import.scm")
|
||||
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
;; import-old-currencies
|
||||
;; If there are old currencies in the account group, start the
|
||||
;; import wizard.
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
|
||||
(define (import-old-currencies from-filename)
|
||||
(if (gnc:commodity-table-has-namespace (gnc:engine-commodities)
|
||||
"GNC_LEGACY_CURRENCIES")
|
||||
(gnc:import-legacy-commodities from-filename)))
|
||||
|
||||
(gnc:hook-add-dangler gnc:*book-opened-hook* import-old-currencies)
|
||||
@ -1,150 +0,0 @@
|
||||
|
||||
Option order is relevant...
|
||||
|
||||
Startup looks like this:
|
||||
|
||||
load *gnc:startup-file*
|
||||
|
||||
may be overriden with --startup-file
|
||||
|
||||
default is --share-dir /gnucash/scm/startup.scm
|
||||
|
||||
sets up *gnc:load-path* (most other files respect this)
|
||||
default is '("$HOME/.gnucash/scm" "$prefix/usr/share/gnucash/scm::")
|
||||
and all the subdirectories of these directories.
|
||||
|
||||
may be overridden by --load-path
|
||||
the default path can be referenced as *gnc:load-path*
|
||||
you can indicate that subdirs should be scanned with a trailing ::
|
||||
i.e. --load-path '(append *gnc:load-path* (gnc:subdirs "/my/dir/"))'
|
||||
|
||||
--load-path=<>:/usr/lib/foo:.:
|
||||
|
||||
|
||||
load *gnc:config-dir* / config
|
||||
*gnc:config-dir* may be overriden with --config-dir
|
||||
|
||||
load $HOME/.gnucash/config.user or load $HOME/.gnucash/config.auto
|
||||
|
||||
|
||||
This means that all code can be overriden by either --startup-file and
|
||||
--load-path.
|
||||
|
||||
|
||||
This file is out of date. Recent implementation has surpassed its
|
||||
contents. It will be updated later...
|
||||
|
||||
|
||||
This directory should hold the UI independent parts of the
|
||||
configuration engine. In particular, this sub-system is concerned
|
||||
with support for command line options, help strings for these options,
|
||||
and general preferences. It is also concerned with integrating these
|
||||
things with the startup config file.
|
||||
|
||||
Current notes:
|
||||
|
||||
1) One goal is to make it really easy to add preference options, and
|
||||
to make sure that changes in one place propagate everywhere they're
|
||||
relevant. You should be able to enter the option description in
|
||||
one place, and then this information should be used to parse
|
||||
command line options, automatically extend the options the config
|
||||
file supports, generate the usage message, and annotate the config
|
||||
file.
|
||||
|
||||
I propose that each subdir in the gnucash tree be allowed to contain
|
||||
an ./prefs.def.scm file which will look like this:
|
||||
|
||||
(gnucash:describe-pref name value-name type description
|
||||
default-value
|
||||
arg-convert-func
|
||||
arg-verify-func)
|
||||
i.e.
|
||||
|
||||
(gnucash:describe-pref
|
||||
"ledger-height" "height" 'integer
|
||||
"The default height of a newly opened ledger in number of lines."
|
||||
12
|
||||
gnucash:prefs-handle-integer-arg
|
||||
#f)
|
||||
|
||||
At the C level, all these objects will be returned as the guile
|
||||
SCM type, but translating this to the relevant C type is
|
||||
completely straightforward (guile has a set of functions for
|
||||
this). In most cases, you'll know what the expected C type is,
|
||||
and just use the relevant guile function to get it, but if not,
|
||||
there are type query functions. There are also C level "foreach"
|
||||
and list stepping functions to handle any lists.
|
||||
|
||||
The option-definitions files will be used to determine the config
|
||||
system's initial configuration behavior.
|
||||
|
||||
|
||||
[ OUT OF DATE -- implementation in flux ]
|
||||
|
||||
The following functions for interaction with the config system will
|
||||
be available:
|
||||
|
||||
guile-level:
|
||||
(gnucash:preference-list) => list of prefs
|
||||
(gnucash:preference-exists?) => list of prefs
|
||||
(gnucash:preference-lookup-by-name name) => pref
|
||||
(gnucash:preference-get-name pref) => name
|
||||
(gnucash:preference-get-type pref) => type
|
||||
(gnucash:preference-get-value pref) => value
|
||||
(gnucash:preference-set-value! pref value) => <undefined>
|
||||
(gnucash:preference-get-documentation! pref) => documentation
|
||||
|
||||
c-level: There will be an equivalent set of functions for querying
|
||||
the state of the preference engine, and there will be some
|
||||
helper functions to make interactions with the scheme level less
|
||||
awkward.
|
||||
|
||||
There will also be a callback mechanism whereby the C level can
|
||||
register functions to be called whenever a given preference
|
||||
changes. This will allow us to keep guileisms out of code that
|
||||
we want to keep strictly C/C++ (this feature addresses one of
|
||||
Linas' primary concerns).
|
||||
|
||||
--name="value" on the command line will be handled identically to
|
||||
(gnucash:preference-set-value! name value) in a config file, and will
|
||||
|
||||
gnucash --help" will display a list of all options, their types, their
|
||||
default values, and their documentation strings, all gathered from
|
||||
the config files.
|
||||
|
||||
2) The config file will just be guile code, and the startup procedure
|
||||
should work as follows. (This approach needs to be substantially
|
||||
more sophisticated later to handle UI selected options vs. user
|
||||
config-file options more intelligently, but this will do for now.)
|
||||
|
||||
By default, gnucash (or whatever we call it) writes all automatically
|
||||
generated (by user interaction in the GUI or whatever) config info
|
||||
to a file ~/.gnucash/config.auto in the form of guile code. Then at
|
||||
startup, gnucash *first* tries to read ~/.gnucash/config.user. If it
|
||||
can't, it falls back to ~/.gnucash/config.auto, but only if
|
||||
~/.gnucash/config.user doesn't exist.
|
||||
|
||||
Normal users will only have a ~/.gnucash/config.auto file, and they'll
|
||||
be happy. Users who want to tweak things manually will be able to
|
||||
create an ~/.gnucash/config.user file and go nuts in there, loading
|
||||
~/.gnucash/config.auto whenever they feel like it (or not at all).
|
||||
|
||||
Justification for guile code as the config file format rather than
|
||||
something less complex:
|
||||
|
||||
Want a to run a particular set of functions on startup? Put
|
||||
|
||||
(gnc:load "config.auto")
|
||||
|
||||
(my-first-function)
|
||||
(my-second-function)
|
||||
...
|
||||
|
||||
Also this makes hook functions possible (essentially callbacks on
|
||||
certain events into user provided guile functions).
|
||||
|
||||
Unknown:
|
||||
|
||||
1) How does this scheme integrate with gtk's config rc file mechanism?
|
||||
I know we'll pass argc, argv off to gtk_init, but do we need to
|
||||
think about anything else?
|
||||
@ -1,87 +0,0 @@
|
||||
;; structure.scm -- Some functions to help build structures
|
||||
;;
|
||||
;; 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
|
||||
;; 59 Temple Place - Suite 330 Fax: +1-617-542-2652
|
||||
;; Boston, MA 02111-1307, USA gnu@gnu.org
|
||||
|
||||
;;; define-mystruct is used to build an association list that defines
|
||||
;;; the layout of a structure...
|
||||
(define (define-mystruct lst)
|
||||
(define alist '()) ;; Association list
|
||||
(define count 0) ;; Number of entries
|
||||
(define (add-item item)
|
||||
(set! alist (cons (cons item count) alist))
|
||||
(set! count (+ 1 count)))
|
||||
(add-item 'gensymid)
|
||||
(for-each add-item lst)
|
||||
alist)
|
||||
;;; Use as follows:
|
||||
;;; (define qif-split-structure (define-mystruct '(category memo
|
||||
;;; amount percent)))
|
||||
;;;
|
||||
|
||||
(define (build-mystruct-instance structinfo)
|
||||
;;; struct-instance is the vector for the data...
|
||||
(define struct-instance (make-vector (length structinfo) #f))
|
||||
(define (get-item field-id) ;;; Look up entry based on ID
|
||||
(let ((assocv (assoc field-id structinfo)))
|
||||
(if assocv
|
||||
(vector-ref struct-instance (cdr assocv))
|
||||
(begin
|
||||
(display (string-append "No such field as "
|
||||
(symbol->string field-id)
|
||||
" in "))
|
||||
(display structinfo)
|
||||
(newline)
|
||||
#f))))
|
||||
|
||||
|
||||
(define (set-item! field-id value) ;;; Plunk in new value
|
||||
(let ((assocv (assoc field-id structinfo)))
|
||||
(if assocv
|
||||
(vector-set! struct-instance (cdr assocv) value)
|
||||
#f)))
|
||||
|
||||
(define (actions action field . value) ;;; now, methods to be applied
|
||||
(cond
|
||||
((eq? action 'get)
|
||||
(let ((item (get-item field)))
|
||||
(if item
|
||||
(car item)
|
||||
#f)))
|
||||
((eq? action 'put)
|
||||
(set-item! field value))
|
||||
(else
|
||||
(list structinfo struct-instance))))
|
||||
(set-item! 'gensymid (list (gensym))) ;;; Attach a unique identifier
|
||||
actions)
|
||||
|
||||
;(if testing?
|
||||
; (begin
|
||||
; (display "Testing structur.scm - define-mystruct, build-mystruct-instance")
|
||||
; (newline)
|
||||
; (let* ((ms (define-mystruct '(f1 f2 f3)))
|
||||
; (mi (build-mystruct-instance ms)))
|
||||
; (mi 'put 'f1 122)
|
||||
; (mi 'put 'f3 "hello")
|
||||
; (display "Empty list entry:") (display (mi 'get 'f2)) (newline)
|
||||
; (display "and two that aren't (f1 f3):")
|
||||
; (display (list (mi 'get 'f1) (mi 'get 'f3))) (newline)
|
||||
; (display "Whole thang:")
|
||||
; (display (mi 'whole 'thang)) (newline)
|
||||
; (display "Overlay 'f3 with 42, add to 'f1 value")
|
||||
; (mi 'put 'f3 42)
|
||||
; (display (number->string (+ (mi 'get 'f1) (mi 'get 'f3)))) (newline))))
|
||||
@ -1,65 +0,0 @@
|
||||
;;; $Id$
|
||||
(define oklist #f)
|
||||
(define errorlist #f)
|
||||
(define errcount #f)
|
||||
|
||||
(define (initialize-testing)
|
||||
(set! oklist '())
|
||||
(set! errorlist '())
|
||||
(set! errcount 0))
|
||||
|
||||
(define (testing funname input expected actual)
|
||||
(define (lookup-set! lookuptable key value)
|
||||
(let
|
||||
((oldval (assoc key lookuptable)))
|
||||
(if oldval
|
||||
(set-cdr! oldval value)
|
||||
(set! lookuptable (cons (cons key value) lookuptable))))
|
||||
lookuptable)
|
||||
|
||||
(if testing?
|
||||
(begin
|
||||
(display (string-append "Test: (" funname " "))
|
||||
(display input)
|
||||
(display ")") (newline)
|
||||
(display "Expect: ") (display expected) (newline)
|
||||
(display "Got: ") (display actual) (newline)
|
||||
(let ((result (list funname input expected actual)))
|
||||
(if (equal? expected actual)
|
||||
(begin
|
||||
(display "OK")
|
||||
(set! oklist (lookup-set! oklist (list funname input) result)))
|
||||
(begin
|
||||
(display "ERROR!!!!!!!!!")
|
||||
(set! errorlist (lookup-set! errorlist
|
||||
(list funname input)
|
||||
(list expected result))))))
|
||||
(newline))))
|
||||
|
||||
(define (reportonerrors)
|
||||
(newline)
|
||||
(display "Error Analysis:") (newline)
|
||||
(display "---------------------------") (newline)
|
||||
(display "Number Passed:")
|
||||
(display (number->string (length (map car oklist)))) (newline)
|
||||
(display "Number Failed:")
|
||||
(display (number->string (length (map car errorlist)))) (newline)
|
||||
|
||||
(map
|
||||
(lambda (lst)
|
||||
(display "Error:") (newline)
|
||||
(let* ((key (car lst))
|
||||
(funname (car key))
|
||||
(input (cadr key))
|
||||
(value (cdr lst))
|
||||
(expected (car value))
|
||||
(actual (cadr value)))
|
||||
(display "-------------------------------------------") (newline)
|
||||
(display "Function:") (display funname) (newline)
|
||||
(display "Input:") (display input) (newline)
|
||||
(display "Expected result:") (display expected) (newline)
|
||||
(display "Actual result:") (display actual) (newline)
|
||||
(display "-------------------------------------------") (newline)
|
||||
))
|
||||
errorlist)
|
||||
(newline))
|
||||
Loading…
Reference in new issue