From fa0e7590b6c39fbf217b7348699241b82a64689a Mon Sep 17 00:00:00 2001 From: Dave Peticolas Date: Tue, 29 Feb 2000 11:24:07 +0000 Subject: [PATCH] *** empty log message *** git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@2042 57a11ea4-9604-0410-9ed3-97b8803252fd --- po/de.po | 2 +- po/fr.po | 2 +- src/register/gnome/combocell-gnome.c | 3 + src/scm/options.scm | 42 ++++++++- src/scm/prefs.scm | 131 +++++++------------------- src/scm/report/average-balance.scm | 123 ++++++++++++------------ src/scm/report/hello-world.scm | 64 +++++++++---- src/scm/report/transaction-report.scm | 2 + 8 files changed, 189 insertions(+), 180 deletions(-) diff --git a/po/de.po b/po/de.po index f4993264e9..07e1c5751c 100644 --- a/po/de.po +++ b/po/de.po @@ -5,7 +5,7 @@ msgid "" msgstr "" "Project-Id-Version: gnucash 1.2.0\n" -"POT-Creation-Date: 2000-02-25 02:11-0800\n" +"POT-Creation-Date: 2000-02-29 02:59-0800\n" "PO-Revision-Date: 1999-08-24 20:03+0200\n" "Last-Translator: Jan-Uwe Finck \n" "Language-Team: LANGUAGE \n" diff --git a/po/fr.po b/po/fr.po index 336497f5ae..67a895d2b2 100644 --- a/po/fr.po +++ b/po/fr.po @@ -5,7 +5,7 @@ msgid "" msgstr "" "Project-Id-Version: gnucash 1.2.0\n" -"POT-Creation-Date: 2000-02-25 02:11-0800\n" +"POT-Creation-Date: 2000-02-29 02:59-0800\n" "PO-Revision-Date: 1999-08-24 19:15+0200\n" "Last-Translator: Yannick LE NY \n" "Language-Team: LANGUAGE \n" diff --git a/src/register/gnome/combocell-gnome.c b/src/register/gnome/combocell-gnome.c index 55fdb55e8b..9b1e94a9d2 100644 --- a/src/register/gnome/combocell-gnome.c +++ b/src/register/gnome/combocell-gnome.c @@ -800,7 +800,10 @@ leaveCombo (BasicCell *bcell, const char *value) if (find == NULL && ((box->ignore_string == NULL) || (safe_strcmp(value, box->ignore_string) != 0))) + { + xaccSetBasicCellValue(bcell, ""); return strdup(""); + } } return value; diff --git a/src/scm/options.scm b/src/scm/options.scm index f7d8135f33..969e8c3935 100644 --- a/src/scm/options.scm +++ b/src/scm/options.scm @@ -202,7 +202,7 @@ (define (multichoice-legal val p-vals) (cond ((null? p-vals) #f) ((eq? val (vector-ref (car p-vals) 0)) #t) - (else multichoice-legal (cdr p-vals)))) + (else (multichoice-legal val (cdr p-vals))))) (let* ((value default-value) (value->string (lambda () @@ -222,6 +222,46 @@ (list #f "multichoice-option: illegal choice"))) ok-values))) +;; list options use the option-data in the same way as multichoice +;; options. List options allow the user to select more than one option. +(define (gnc:make-list-option + section + name + sort-tag + documentation-string + default-value + ok-values) + + (define (legal-value? value legal-values) + (cond ((null? legal-values) #f) + ((eq? value (vector-ref (car legal-values) 0)) #t) + (else (legal-value? value (cdr legal-values))))) + + (define (list-legal values) + (cond ((null? values) #t) + (else + (and + (legal-value? (car values) ok-values) + (list-legal (cdr values)))))) + + (let* ((value default-value) + (value->string (lambda () + (string-append "'" (gnc:value->string value))))) + (gnc:make-option + section name sort-tag 'list documentation-string + (lambda () value) + (lambda (x) + (if (list-legal x) + (set! value x) + (gnc:error "Illegal list option set"))) + (lambda () default-value) + (gnc:restore-form-generator value->string) + (lambda (x) + (if (list-legal x) + (list #t x) + (list #f "list-option: illegal value"))) + ok-values))) + ;; number range options use the option-data as a list whose ;; elements are: (lower-bound upper-bound num-decimals step-size) (define (gnc:make-number-range-option diff --git a/src/scm/prefs.scm b/src/scm/prefs.scm index ffc25aa10f..58ff0a5dde 100644 --- a/src/scm/prefs.scm +++ b/src/scm/prefs.scm @@ -67,105 +67,38 @@ ;;;;;; Create default options and config vars -;; Account Types options - -(gnc:register-configuration-option - (gnc:make-simple-boolean-option - "Account Types" "Show bank accounts" - "a" "Show bank accounts in the account tree." #t)) - -(gnc:register-configuration-option - (gnc:make-simple-boolean-option - "Account Types" "Show cash accounts" - "b" "Show cash accounts in the account tree." #t)) - -(gnc:register-configuration-option - (gnc:make-simple-boolean-option - "Account Types" "Show credit accounts" - "c" "Show credit accounts in the account tree." #t)) - -(gnc:register-configuration-option - (gnc:make-simple-boolean-option - "Account Types" "Show asset accounts" - "d" "Show asset accounts in the account tree." #t)) - -(gnc:register-configuration-option - (gnc:make-simple-boolean-option - "Account Types" "Show liability accounts" - "e" "Show liability accounts in the account tree." #t)) - -(gnc:register-configuration-option - (gnc:make-simple-boolean-option - "Account Types" "Show stock accounts" - "f" "Show stock accounts in the account tree." #t)) - -(gnc:register-configuration-option - (gnc:make-simple-boolean-option - "Account Types" "Show mutual fund accounts" - "g" "Show mutual fund accounts in the account tree." #t)) - -(gnc:register-configuration-option - (gnc:make-simple-boolean-option - "Account Types" "Show currency accounts" - "h" "Show currency accounts in the account tree." #t)) - -(gnc:register-configuration-option - (gnc:make-simple-boolean-option - "Account Types" "Show income accounts" - "i" "Show income accounts in the account tree." #t)) - -(gnc:register-configuration-option - (gnc:make-simple-boolean-option - "Account Types" "Show expense accounts" - "j" "Show expense accounts in the account tree." #t)) - -(gnc:register-configuration-option - (gnc:make-simple-boolean-option - "Account Types" "Show equity accounts" - "k" "Show equity accounts in the account tree." #t)) - - -;; Account Fields options - -(gnc:register-configuration-option - (gnc:make-simple-boolean-option - "Account Fields" "Show account name" - "a" "Show the account name column in the account tree." #t)) - -(gnc:register-configuration-option - (gnc:make-simple-boolean-option - "Account Fields" "Show account type" - "b" "Show the account type column in the account tree." #f)) - -(gnc:register-configuration-option - (gnc:make-simple-boolean-option - "Account Fields" "Show account code" - "c" "Show the account code column in the account tree." #f)) - -(gnc:register-configuration-option - (gnc:make-simple-boolean-option - "Account Fields" "Show account description" - "d" "Show the account description column in the account tree." #t)) - -(gnc:register-configuration-option - (gnc:make-simple-boolean-option - "Account Fields" "Show account notes" - "e" "Show the account notes column in the account tree." #f)) - -(gnc:register-configuration-option - (gnc:make-simple-boolean-option - "Account Fields" "Show account currency" - "f" "Show the account currency column in the account tree." #f)) - -(gnc:register-configuration-option - (gnc:make-simple-boolean-option - "Account Fields" "Show account security" - "g" "Show the account security column in the account tree." #f)) - -(gnc:register-configuration-option - (gnc:make-simple-boolean-option - "Account Fields" "Show account balance" - "h" "Show the account balance column in the account tree." #t)) +;; Main Window options + +(gnc:register-configuration-option + (gnc:make-list-option + "Main Window" "Account types to display" + "a" "" + (list 'equity 'expense 'income 'currency 'mutual + 'stock 'liability 'asset 'credit 'cash 'bank) + (list #(bank "Bank" "") + #(cash "Cash" "") + #(credit "Credit" "") + #(asset "Asset" "") + #(liability "Liability" "") + #(stock "Stock" "") + #(mutual "Mutual Fund" "") + #(currency "Currency" "") + #(income "Income" "") + #(expense "Expense" "") + #(equity "Equity" "")))) + +(gnc:register-configuration-option + (gnc:make-list-option + "Main Window" "Account fields to display" + "b" "" + (list 'balance 'description) + (list #(type "Type" "") + #(code "Code" "") + #(description "Description" "") + #(notes "Notes" "") + #(currency "Currency" "") + #(security "Security" "") + #(balance "Balance" "")))) ;; International options diff --git a/src/scm/report/average-balance.scm b/src/scm/report/average-balance.scm index e895a241c9..7ec69eadf4 100644 --- a/src/scm/report/average-balance.scm +++ b/src/scm/report/average-balance.scm @@ -534,7 +534,7 @@ (gnc:init-query gncq) (if (null? accounts) - (set! report-lines + (set! rept-text (list "You have not selected an account.")) (begin ; Grab account names @@ -557,65 +557,66 @@ (map (lambda(acct) (gnc:query-add-account gncq acct)) accounts) - (set! tempstruct - (build-mystruct-instance - (define-mystruct - (gnc:acctnames-from-list accounts)))) - - (set! acctcurrency (gnc:account-get-currency (car accounts))) - - (set! report-lines - (gnc:convert-split-list (gnc:query-get-splits gncq))))) - - (gnc:free-query gncq) - - (display (length report-lines)) - (display " Splits\n") - - ; Set initial balances to zero - (map (lambda(an) (tempstruct 'put an 0)) - (gnc:acctnames-from-list accounts)) - - (dateloop begindate - enddate - (eval stepsize)) - (set! rept-data - (reduce-split-list - (dateloop begindate - enddate - (eval stepsize)) - report-lines zdate tempstruct)) - - (set! sum-data (get-averages rept-data)) - - - ;; Create HTML - (set! rept-text - (html-table - collist - (append rept-data - (list "

" sum-data)))) - - - ;; Do a plot - (if (not (equal? NoPlot (eval plotstr))) - (let* ((fn "/tmp/gncplot.dat") - (preplot (string-append - "set xdata time\n" - "set timefmt '%m/%d/%Y'\n" - "set pointsize 2\n" - "set title '" acctname "'\n" - "set ylabel '" acctcurrency "'\n" - "set xlabel 'Period Ending'\n" - ) - ) - ) - - (data-to-gpfile collist rept-data fn (eval plotstr)) - (system - (string-append "echo \"" preplot "plot '" fn "'" (eval plotstr) - "\"|gnuplot -persist " ))) - ) - (append prefix (list "Report for " acctname "

\n" ) + (set! tempstruct + (build-mystruct-instance + (define-mystruct + (gnc:acctnames-from-list accounts)))) + + (set! acctcurrency (gnc:account-get-currency (car accounts))) + + (set! report-lines + (gnc:convert-split-list (gnc:query-get-splits gncq))) + + (gnc:free-query gncq) + + (display (length report-lines)) + (display " Splits\n") + + ; Set initial balances to zero + (map (lambda(an) (tempstruct 'put an 0)) + (gnc:acctnames-from-list accounts)) + + (dateloop begindate + enddate + (eval stepsize)) + (set! rept-data + (reduce-split-list + (dateloop begindate + enddate + (eval stepsize)) + report-lines zdate tempstruct)) + + (set! sum-data (get-averages rept-data)) + + ;; Create HTML + (set! rept-text + (html-table + collist + (append rept-data + (list "



" sum-data)))) + + ;; Do a plot + (if (not (equal? NoPlot (eval plotstr))) + (let* ((fn "/tmp/gncplot.dat") + (preplot (string-append + "set xdata time\n" + "set timefmt '%m/%d/%Y'\n" + "set pointsize 2\n" + "set title '" acctname "'\n" + "set ylabel '" acctcurrency "'\n" + "set xlabel 'Period Ending'\n" + ))) + + (data-to-gpfile collist rept-data fn (eval plotstr)) + (system + (string-append "echo \"" preplot "plot '" + fn "'" (eval plotstr) + "\"|gnuplot -persist " )))) + )) + + (append prefix + (if (null? accounts) + () + (list "Report for " acctname "

\n")) (list rept-text) suffix))) ) diff --git a/src/scm/report/hello-world.scm b/src/scm/report/hello-world.scm index 98cff8a252..9793778ceb 100644 --- a/src/scm/report/hello-world.scm +++ b/src/scm/report/hello-world.scm @@ -14,12 +14,12 @@ (define (options-generator) ;; This will be the new set of options. - (define gnc:*dummy-options* (gnc:new-options)) + (define gnc:*hello-world-options* (gnc:new-options)) ;; This is just a helper function for making options. ;; See gnucash/src/scm/options.scm for details. - (define (gnc:register-dummy-option new-option) - (gnc:register-option gnc:*dummy-options* new-option)) + (define (gnc:register-hello-world-option new-option) + (gnc:register-option gnc:*hello-world-options* new-option)) ;; This is a boolean option. It is in Section 'Hello, World!' ;; and is named 'Boolean Option'. Its sorting key is 'a', @@ -28,7 +28,7 @@ ;; is #t (true). The phrase 'This is a boolean option' ;; will be displayed as help text when the user puts ;; the mouse pointer over the option. - (gnc:register-dummy-option + (gnc:register-hello-world-option (gnc:make-simple-boolean-option "Hello, World!" "Boolean Option" "a" "This is a boolean option." #t)) @@ -38,13 +38,13 @@ ;; symbols. The value 'first will be displayed as "First Option" ;; and have a help string of "Help for first option.". The default ;; value is 'third. - (gnc:register-dummy-option + (gnc:register-hello-world-option (gnc:make-multichoice-option "Hello, World!" "Multi Choice Option" "b" "This is a multi choice option." 'third - (list #(first "First Option" "Help for first option.") - #(second "Second Option" "Help for second option.") - #(third "Third Option" "Help for third option.") + (list #(first "First Option" "Help for first option") + #(second "Second Option" "Help for second option") + #(third "Third Option" "Help for third option") #(fourth "Fourth Options" "The fourth option rules!")))) ;; This is a string option. Users can type anything they want @@ -52,7 +52,7 @@ ;; in the same section as the option above. It will be shown ;; after the option above because its key is 'b' while the ;; other key is 'a'. - (gnc:register-dummy-option + (gnc:register-hello-world-option (gnc:make-string-option "Hello, World!" "String Option" "c" "This is a string option" "Hello, World")) @@ -63,7 +63,7 @@ ;; Unix time. The last option is false, so the user can only ;; select a date, not a time. The default value is the current ;; time. - (gnc:register-dummy-option + (gnc:register-hello-world-option (gnc:make-date-option "Hello, World!" "Just a Date Option" "d" "This is a date option" @@ -72,7 +72,7 @@ ;; This is another date option, but the user can also select ;; the time. - (gnc:register-dummy-option + (gnc:register-hello-world-option (gnc:make-date-option "Hello, World!" "Time and Date Option" "e" "This is a date option with time" @@ -86,7 +86,7 @@ ;; (#f) indicates the alpha value should be ignored. You can get ;; a color string from a color option with gnc:color-option->html, ;; which will scale the values appropriately according the range. - (gnc:register-dummy-option + (gnc:register-hello-world-option (gnc:make-color-option "Hello, World!" "Background Color" "f" "This is a color option" @@ -109,23 +109,36 @@ ;; the user is allowed to select more than one account. ;; The default value for this option is the currently ;; selected account in the main window, if any. - (gnc:register-dummy-option + (gnc:register-hello-world-option (gnc:make-account-list-option - "Hello, World!" "An account list option" + "Hello Again" "An account list option" "g" "This is an account list option" (lambda () (gnc:get-current-accounts)) #f #t)) + ;; This is a list option. The user can select one or (possibly) + ;; more values from a list. The list of acceptable values is + ;; the same format as a multichoice option. The value of the + ;; option is a list of symbols. + (gnc:register-hello-world-option + (gnc:make-list-option + "Hello Again" "A list option" + "h" "This is a list option" + (list 'good) + (list #(good "The Good" "Good option") + #(bad "The Bad" "Bad option") + #(ugly "The Ugly" "Ugly option")))) + ;; This option is for testing. When true, the report generates ;; an exception. - (gnc:register-dummy-option + (gnc:register-hello-world-option (gnc:make-simple-boolean-option "Testing" "Crash the report" "a" (string-append "This is for testing. " "Your reports probably shouldn't have an " "option like this.") #f)) - gnc:*dummy-options*) + gnc:*hello-world-options*) ;; This is a helper function to generate an html list of account names ;; given an account list option. @@ -141,6 +154,19 @@ (map (lambda (name) (list "

  • " name "
  • ")) names) "")))) + ;; This is a helper function to generate an html list for the list option. + (define (list-option-list list-op) + (let* ((values (gnc:option-value list-op)) + (names (map symbol->string values))) + (if (null? values) + "

    You have selected no values in the list option.

    " + (list "

    " + "The items selected in the list option are:" + "

    " + "
      " + (map (lambda (name) (list "
    • " name "
    • ")) names) + "
    ")))) + ;; Here's another helper function. You can guess what it does. (define (bold string) (string-append "" string "")) @@ -175,8 +201,10 @@ (colorop (gnc:lookup-option options "Hello, World!" "Background Color")) (account-list-op (gnc:lookup-option options - "Hello, World!" + "Hello Again" "An account list option")) + (list-op (gnc:lookup-option options + "Hello Again" "A list option")) (crash-op (gnc:lookup-option options "Testing" "Crash the report"))) (let ((time-string (strftime "%X" (localtime (current-time)))) @@ -245,6 +273,8 @@ "The date and time option is " (bold date-string2) "." "

    ") + (list-option-list list-op) + (account-list account-list-op) (list "

    " diff --git a/src/scm/report/transaction-report.scm b/src/scm/report/transaction-report.scm index dba8a1ab6a..00e6fa9b02 100644 --- a/src/scm/report/transaction-report.scm +++ b/src/scm/report/transaction-report.scm @@ -491,6 +491,8 @@ trep-options-generator ;; renderer (lambda (options) + (gnc:set-total-inflow! 0) + (gnc:set-total-outflow! 0) (let* ((begindate (gnc:lookup-option options "Report Options" "From")) (enddate (gnc:lookup-option options "Report Options" "To")) (tr-report-account-op (gnc:lookup-option options