Created
July 26, 2022 15:41
-
-
Save christopherlam/04f4bd48b981ac87cefa0f48a8283c21 to your computer and use it in GitHub Desktop.
options change cb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
modified gnucash/report/report-core.scm | |
@@ -167,7 +167,7 @@ | |
;; A <report-template> represents one of the available report types. | |
(define-record-type <report-template> | |
(make-new-record-template version name report-guid parent-type options-generator | |
- options-cleanup-cb options-changed-cb | |
+ options-cleanup-cb options-changed-cb options-update-cb | |
renderer in-menu? menu-path menu-name | |
menu-tip export-types export-thunk) | |
report-template? | |
@@ -178,6 +178,7 @@ | |
(options-generator report-template-options-generator) | |
(options-cleanup-cb report-template-options-cleanup-cb) | |
(options-changed-cb report-template-options-changed-cb) | |
+ (options-update-cb report-template-options-update-cb) | |
(renderer report-template-renderer) | |
(in-menu? report-template-in-menu?) | |
(menu-path report-template-menu-path) | |
modified gnucash/report/reports/standard/balsheet-pnl.scm | |
@@ -318,6 +318,20 @@ also show overall period profit & loss.")) | |
options)) | |
+(define (options-update-cb options) | |
+ (define (get-option pagename optname) | |
+ (gnc:option-value (gnc:lookup-option options pagename optname))) | |
+ (let ((opt-commodities-common-currency | |
+ (get-option pagename-commodities optname-common-currency))) | |
+ (for-each | |
+ (lambda (optname) | |
+ (gnc-option-db-set-option-selectable-by-name | |
+ options pagename-commodities optname opt-commodities-common-currency)) | |
+ (list optname-report-commodity | |
+ optname-show-rates | |
+ optname-show-foreign | |
+ optname-price-source)))) | |
+ | |
(define* (add-multicolumn-acct-table | |
table title accountlist maxindent get-cell-monetary-fn cols-data #:key | |
(reverse-cols? #f) | |
@@ -1296,6 +1310,7 @@ also show overall period profit & loss.")) | |
'report-guid "065d5d5a77ba11e8b31e83ada73c5eea" | |
'menu-path (list gnc:menuname-experimental) | |
'options-generator (lambda () (multicol-report-options-generator 'balsheet)) | |
+ 'options-update-cb options-update-cb | |
'renderer (lambda (rpt) (multicol-report-renderer rpt 'balsheet))) | |
(gnc:define-report | |
modified libgnucash/app-utils/option-util.c | |
@@ -788,21 +788,15 @@ void | |
gnc_option_call_option_widget_changed_proc (GNCOption *option, | |
gboolean reset_changed) | |
{ | |
- SCM cb, value; | |
+ // instead of calling callback for 1 option, call callback for the | |
+ // whole optiondb: | |
- cb = gnc_option_widget_changed_proc_getter (option); | |
+ SCM options_update_db = scm_c_eval_string ("report-template-options-update-cb"); | |
- if (cb != SCM_UNDEFINED) | |
- { | |
- value = gnc_option_get_ui_value (option); | |
+ if (scm_is_procedure_p (options_update_db)) | |
+ scm_call_1 (options_update_db, optiondb); | |
- if (value != SCM_UNDEFINED) | |
- { | |
- scm_call_1 (cb, value); | |
- } | |
- } | |
- if (reset_changed) | |
- option->changed = FALSE; | |
+ // that's all | |
} | |
/********************************************************************\ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment