New scheme function gnc_option_default_value.

This commit is contained in:
John Ralls 2019-11-02 11:06:49 -07:00
parent 3f576671aa
commit 12c5b94430
2 changed files with 13 additions and 1 deletions

View File

@ -240,6 +240,15 @@ wrap_unique_ptr(GncOptionDBPtr, GncOptionDB);
return GncOption_get_scm_value(&(db_opt->get()));
}
SCM gnc_option_default_value(const GncOptionDBPtr& optiondb,
const char* section, const char* name)
{
auto db_opt = optiondb->find_option(section, name);
if (!db_opt)
return SCM_BOOL_F;
return GncOption_get_scm_default_value(&(db_opt->get()));
}
void gnc_set_option(const GncOptionDBPtr& optiondb, const char* section,
const char* name, SCM new_value)
{

View File

@ -77,8 +77,10 @@
(multi-opt (gnc-register-multichoice-option option-db "foo" "bar" "baz"
"Phony Option" multichoice)))
(test-equal "plugh" (gnc-option-value option-db "foo" "bar"))
(gnc-set-option option-db "foo" "bar" "corge")
(test-equal "corge" (gnc-option-value option-db "foo" "bar")))
(test-equal "corge" (gnc-option-value option-db "foo" "bar"))
(test-equal "plugh" (gnc-option-default-value option-db "foo" "bar")))
(test-end "test-gnc-test-multichoice-option"))
(define (test-gnc-make-list-option)
@ -93,6 +95,7 @@
(test-equal "AvgBalPlot" (gnc-option-value option-db "foo" "bar"))
(gnc-set-option option-db "foo" "bar" "GLPlot")
(test-equal "GLPlot" (gnc-option-value option-db "foo" "bar"))
(test-equal "AvgBalPlot" (gnc-option-default-value option-db "foo" "bar")))
(test-end "test-gnc-test-list-option"))
(define (test-gnc-make-date-option)