mirror of
https://github.com/Gnucash/gnucash.git
synced 2025-02-25 18:55:30 -06:00
ADD-API: gnc:option-make-internal!, gnc:unregister-option
This commit adds 2 additional helper calls, primarily useful for derived reports. gnc:option-make-internal! will hide an existing option. e.g. a derived report can set the value for a Display/* option and hide it from the user. gnc:unregister-option will unregister option. This is primarily useful for derived options e.g. another report copies from transaction.scm and removes some options and recreates them with different parameters. For example, unregister existing option from section "Accounts" name "Accounts", and recreate with different parameters e.g. limited account types.
This commit is contained in:
parent
6004b55d16
commit
88b3446299
@ -104,7 +104,7 @@
|
||||
(export gnc:render-options-changed)
|
||||
(export gnc:options-make-end-date!)
|
||||
(export gnc:options-make-date-interval!)
|
||||
|
||||
(export gnc:option-make-internal!)
|
||||
(export gnc:make-number-range-option)
|
||||
(export gnc:make-number-plot-size-option)
|
||||
(export gnc:plot-size-option-value-type)
|
||||
@ -131,6 +131,7 @@
|
||||
(export gnc:new-options)
|
||||
|
||||
(export gnc:register-option)
|
||||
(export gnc:unregister-option)
|
||||
(export gnc:options-register-callback)
|
||||
(export gnc:options-register-c-callback)
|
||||
(export gnc:options-unregister-callback-id)
|
||||
|
@ -1764,6 +1764,16 @@
|
||||
new-option
|
||||
(lambda () (option-changed section name)))))
|
||||
|
||||
(define (unregister-option section name)
|
||||
(let* ((section-hash (hash-ref option-hash section)))
|
||||
(if (and section-hash
|
||||
(hash-ref section-hash name))
|
||||
(begin
|
||||
(hash-remove! section-hash name)
|
||||
(if (zero? (hash-count (const #t) section-hash))
|
||||
(hash-remove! option-hash section)))
|
||||
(gnc:error "options:unregister-option: no such option\n"))))
|
||||
|
||||
; Call (thunk option) for each option in the database
|
||||
(define (options-for-each thunk)
|
||||
(define (section-for-each section-hash thunk)
|
||||
@ -1899,6 +1909,7 @@
|
||||
(case key
|
||||
((lookup) lookup-option)
|
||||
((register-option) register-option)
|
||||
((unregister-option) unregister-option)
|
||||
((register-callback) register-callback)
|
||||
((unregister-callback-id) unregister-callback-id)
|
||||
((for-each) options-for-each)
|
||||
@ -1939,6 +1950,9 @@
|
||||
((options 'lookup) section name)
|
||||
#f))
|
||||
|
||||
(define (gnc:unregister-option options section name)
|
||||
((options 'unregister-option) section name))
|
||||
|
||||
(define (gnc:generate-restore-forms options options-string)
|
||||
((options 'generate-restore-forms) options-string))
|
||||
|
||||
@ -2103,3 +2117,11 @@
|
||||
)))
|
||||
(gnc:options-make-end-date! options pagename name-to
|
||||
(string-append sort-tag "b") info-to))
|
||||
|
||||
(define (gnc:option-make-internal! options section name)
|
||||
;; this function will hide the option specified
|
||||
;; the option functionality is unchanged
|
||||
(let ((opt (gnc:lookup-option options section name)))
|
||||
(if opt
|
||||
(vector-set! opt 3 'internal)
|
||||
(error "gnc:option-make-internal! cannot find section / name"))))
|
||||
|
Loading…
Reference in New Issue
Block a user