[options] Update stylesheets to use new API.

This commit is contained in:
John Ralls 2022-08-01 11:08:28 -07:00
parent 018d5d8d83
commit e79fe2f2d9
4 changed files with 133 additions and 220 deletions

View File

@ -112,21 +112,19 @@ td.highlight {
") ")
(define (css-options) (define (css-options)
(let ((options (gnc:new-options))) (let ((options (gnc-new-optiondb)))
(gnc:register-option (gnc-register-text-option options
options
(gnc:make-text-option
(N_ "General") (N_ "CSS") "a" (N_ "General") (N_ "CSS") "a"
(N_ "CSS code. This field specifies the CSS code for styling reports.") (N_ "CSS code. This field specifies the CSS code for styling reports.")
default-css)) default-css)
options)) options))
(define (css-renderer options doc) (define (css-renderer options doc)
(let* ((ssdoc (gnc:make-html-document)) (let* ((ssdoc (gnc:make-html-document))
(css (gnc:option-value (gnc:lookup-option options "General" "CSS"))) (css (gnc-optiondb-lookup-value options "General" "CSS"))
(report-css (or (gnc:html-document-style-text doc) "")) (report-css (or (gnc:html-document-style-text doc) ""))
(all-css (string-append css report-css)) (all-css (string-append css report-css))
(headline (or (gnc:html-document-headline doc) (headline (or (gnc:html-document-headline doc)

View File

@ -43,151 +43,120 @@
(use-modules (gnucash html)) (use-modules (gnucash html))
(define (easy-fancy-footer-options) (define (easy-fancy-footer-options)
(let* ((options (gnc:new-options)) (let* ((options (gnc-new-optiondb)))
(opt-register
(lambda (opt)
(gnc:register-option options opt))))
(opt-register (gnc-register-string-option options
(gnc:make-string-option
(N_ "General") (N_ "General")
(N_ "Preparer") "a" (N_ "Preparer") "a"
(N_ "Name of person preparing the report.") (N_ "Name of person preparing the report.")
"")) "")
(opt-register (gnc-register-string-option options
(gnc:make-string-option
(N_ "General") (N_ "General")
(N_ "Prepared for") "b" (N_ "Prepared for") "b"
(N_ "Name of organization or company prepared for.") (N_ "Name of organization or company prepared for.")
"")) "")
(opt-register (gnc-register-simple-boolean-option options
(gnc:make-simple-boolean-option
(N_ "General") (N_ "General")
(N_ "Show preparer info") "c" (N_ "Show preparer info") "c"
(N_ "Name of organization or company.") (N_ "Name of organization or company.")
#f)) #f)
(opt-register (gnc-register-simple-boolean-option options
(gnc:make-simple-boolean-option
(N_ "General") (N_ "General")
(N_ "Enable Links") "d" (N_ "Enable Links") "d"
(N_ "Enable hyperlinks in reports.") (N_ "Enable hyperlinks in reports.")
#t)) #t)
(opt-register (gnc-register-text-option options
(gnc:make-text-option
(N_ "General") (N_ "General")
(N_ "Footer") "e" (N_ "Footer") "e"
(N_ "String to be placed as a footer.") (N_ "String to be placed as a footer.")
"")) "")
(opt-register (gnc-register-pixmap-option options
(gnc:make-pixmap-option
(N_ "Images") (N_ "Images")
(N_ "Background Tile") "a" (N_ "Background tile for reports.") (N_ "Background Tile") "a" (N_ "Background tile for reports.")
"")) "")
(opt-register (gnc-register-pixmap-option options
(gnc:make-pixmap-option
(N_ "Images") (N_ "Images")
;;; Translators: Banner is an image like Logo. ;;; Translators: Banner is an image like Logo.
(N_ "Heading Banner") "b" (N_ "Banner for top of report.") (N_ "Heading Banner") "b" (N_ "Banner for top of report.")
"")) "")
(opt-register (gnc-register-multichoice-option options
(gnc:make-multichoice-option
(N_ "Images") (N_ "Images")
(N_ "Heading Alignment") "c" (N_ "Banner for top of report.") (N_ "Heading Alignment") "c" (N_ "Banner for top of report.")
'left "left"
(list (vector 'left (N_ "Left")) (list (vector 'left (N_ "Left"))
(vector 'center (N_ "Center")) (vector 'center (N_ "Center"))
(vector 'right (N_ "Right"))))) (vector 'right (N_ "Right"))))
(opt-register (gnc-register-pixmap-option options
(gnc:make-pixmap-option
(N_ "Images") (N_ "Images")
(N_ "Logo") "d" (N_ "Company logo image.") (N_ "Logo") "d" (N_ "Company logo image.")
"")) "")
(opt-register (gnc-register-color-option options
(gnc:make-color-option
(N_ "Colors") (N_ "Colors")
(N_ "Background Color") "a" (N_ "General background color for report.") (N_ "Background Color") "a" (N_ "General background color for report.")
(list #xff #xff #xff #xff) "ffffff")
255 #f))
(opt-register (gnc-register-color-option options
(gnc:make-color-option
(N_ "Colors") (N_ "Colors")
(N_ "Text Color") "b" (N_ "Normal body text color.") (N_ "Text Color") "b" (N_ "Normal body text color.")
(list #x00 #x00 #x00 #xff) "000000")
255 #f))
(opt-register (gnc-register-color-option options
(gnc:make-color-option
(N_ "Colors") (N_ "Colors")
(N_ "Link Color") "c" (N_ "Link text color.") (N_ "Link Color") "c" (N_ "Link text color.")
(list #xb2 #x22 #x22 #xff) "b22222")
255 #f))
(opt-register (gnc-register-color-option options
(gnc:make-color-option
(N_ "Colors") (N_ "Colors")
(N_ "Table Cell Color") "c" (N_ "Default background for table cells.") (N_ "Table Cell Color") "c" (N_ "Default background for table cells.")
(list #xff #xff #xff #xff) "ffffff")
255 #f))
(opt-register (gnc-register-color-option options
(gnc:make-color-option
(N_ "Colors") (N_ "Colors")
(N_ "Alternate Table Cell Color") "d" (N_ "Alternate Table Cell Color") "d"
(N_ "Default alternate background for table cells.") (N_ "Default alternate background for table cells.")
(list #xff #xff #xff #xff) "ffffff")
255 #f))
(opt-register (gnc-register-color-option options
(gnc:make-color-option
(N_ "Colors") (N_ "Colors")
(N_ "Subheading/Subtotal Cell Color") "e" (N_ "Subheading/Subtotal Cell Color") "e"
(N_ "Default color for subtotal rows.") (N_ "Default color for subtotal rows.")
(list #xee #xe8 #xaa #xff) "eee8aa")
255 #f))
(opt-register (gnc-register-color-option options
(gnc:make-color-option
(N_ "Colors") (N_ "Colors")
(N_ "Sub-subheading/total Cell Color") "f" (N_ "Sub-subheading/total Cell Color") "f"
(N_ "Color for subsubtotals.") (N_ "Color for subsubtotals.")
(list #xfa #xfa #xd2 #xff) "fafad2")
255 #f))
(opt-register (gnc-register-color-option options
(gnc:make-color-option
(N_ "Colors") (N_ "Colors")
(N_ "Grand Total Cell Color") "g" (N_ "Grand Total Cell Color") "g"
(N_ "Color for grand totals.") (N_ "Color for grand totals.")
(list #xff #xff #x00 #xff) "ffff00")
255 #f))
(opt-register (gnc-register-number-range-option options
(gnc:make-number-range-option
(N_ "Tables") (N_ "Tables")
(N_ "Table cell spacing") "a" (N_ "Space between table cells.") (N_ "Table cell spacing") "a" (N_ "Space between table cells.")
1 0 20 0 1)) 1 0 20 1)
(opt-register (gnc-register-number-range-option options
(gnc:make-number-range-option
(N_ "Tables") (N_ "Tables")
(N_ "Table cell padding") "b" (N_ "Space between table cell edge and content.") (N_ "Table cell padding") "b" (N_ "Space between table cell edge and content.")
1 0 20 0 1)) 1 0 20 1)
(opt-register (gnc-register-number-range-option options
(gnc:make-number-range-option
(N_ "Tables") (N_ "Tables")
(N_ "Table border width") "c" (N_ "Bevel depth on tables.") (N_ "Table border width") "c" (N_ "Bevel depth on tables.")
1 0 20 0 1)) 1 0 20 1)
(register-font-options options) (register-font-options options)
options)) options))
@ -196,12 +165,11 @@
(let* ((ssdoc (gnc:make-html-document)) (let* ((ssdoc (gnc:make-html-document))
(opt-val (opt-val
(lambda (section name) (lambda (section name)
(gnc:option-value (gnc-optiondb-lookup-value options section name)))
(gnc:lookup-option options section name))))
(color-val (color-val
(lambda (section name) (lambda (section name)
(gnc:color-option->html (gnc:color->html
(gnc:lookup-option options section name)))) (gnc-optiondb-lookup-value options section name))))
(preparer (opt-val "General" "Preparer")) (preparer (opt-val "General" "Preparer"))
(prepared-for (opt-val "General" "Prepared for")) (prepared-for (opt-val "General" "Prepared for"))
(show-preparer? (opt-val "General" "Show preparer info")) (show-preparer? (opt-val "General" "Show preparer info"))

View File

@ -43,198 +43,159 @@
(use-modules (gnucash html)) (use-modules (gnucash html))
(define (head-or-tail-options) (define (head-or-tail-options)
(let* ((options (gnc:new-options)) (let ((options (gnc-new-optiondb)))
(opt-register
(lambda (opt) (gnc-register-string-option options
(gnc:register-option options opt))))
(opt-register
(gnc:make-string-option
(N_ "General") (N_ "General")
(N_ "Preparer") "a" (N_ "Preparer") "a"
(N_ "Name of person preparing the report.") (N_ "Name of person preparing the report.")
"")) "")
(opt-register (gnc-register-string-option options
(gnc:make-string-option
(N_ "General") (N_ "General")
(N_ "Prepared for") "b" (N_ "Prepared for") "b"
(N_ "Name of organization or company prepared for.") (N_ "Name of organization or company prepared for.")
"")) "")
(opt-register (gnc-register-simple-boolean-option options
(gnc:make-simple-boolean-option
(N_ "General") (N_ "General")
(N_ "Show preparer info") "c" (N_ "Show preparer info") "c"
(N_ "Name of organization or company.") (N_ "Name of organization or company.")
#t)) #t)
(opt-register (gnc-register-simple-boolean-option options
(gnc:make-simple-boolean-option
(N_ "General") (N_ "General")
(N_ "Show receiver info") "d" (N_ "Show receiver info") "d"
(N_ "Name of organization or company the report is prepared for.") (N_ "Name of organization or company the report is prepared for.")
#t)) #t)
(opt-register (gnc-register-simple-boolean-option options
(gnc:make-simple-boolean-option
(N_ "General") (N_ "General")
(N_ "Show date") "e" (N_ "Show date") "e"
(N_ "The creation date for this report.") (N_ "The creation date for this report.")
#t)) #t)
(opt-register (gnc-register-simple-boolean-option options
(gnc:make-simple-boolean-option
(N_ "General") (N_ "General")
(N_ "Show time in addition to date") "f" (N_ "Show time in addition to date") "f"
(N_ "The creation time for this report can only be shown if the date is shown.") (N_ "The creation time for this report can only be shown if the date is shown.")
#t)) #t)
(opt-register (gnc-register-simple-boolean-option options
(gnc:make-simple-boolean-option
(N_ "General") (N_ "General")
(N_ "Show GnuCash Version") "g" (N_ "Show GnuCash Version") "g"
(N_ "Show the currently used GnuCash version.") (N_ "Show the currently used GnuCash version.")
#t)) #t)
(opt-register (gnc-register-simple-boolean-option options
(gnc:make-simple-boolean-option
(N_ "General") (N_ "General")
(N_ "Enable Links") "h" (N_ "Enable Links") "h"
(N_ "Enable hyperlinks in reports.") (N_ "Enable hyperlinks in reports.")
#t)) #t)
;; FIXME: put this in a more sensible tab like Text or Header/Footer ;; FIXME: put this in a more sensible tab like Text or Header/Footer
(opt-register (gnc-register-text-option options
(gnc:make-text-option
(N_ "General") (N_ "General")
(N_ "Additional Comments") "i" (N_ "Additional Comments") "i"
(N_ "String for additional report information.") (N_ "String for additional report information.")
"")) "")
(opt-register (gnc-register-simple-boolean-option options
(gnc:make-simple-boolean-option
(N_ "General") (N_ "General")
(N_ "Show preparer info at bottom") "j" (N_ "Show preparer info at bottom") "j"
(N_ "Per default the preparer info will be shown before the report data.") (N_ "Per default the preparer info will be shown before the report data.")
#f)) #f)
(opt-register (gnc-register-simple-boolean-option options
(gnc:make-simple-boolean-option
(N_ "General") (N_ "General")
(N_ "Show receiver info at bottom") "k" (N_ "Show receiver info at bottom") "k"
(N_ "Per default the receiver info will be shown before the report data.") (N_ "Per default the receiver info will be shown before the report data.")
#f)) #f)
(opt-register (gnc-register-simple-boolean-option options
(gnc:make-simple-boolean-option
(N_ "General") (N_ "General")
(N_ "Show date/time at bottom") "l" (N_ "Show date/time at bottom") "l"
(N_ "Per default the date/time info will be shown before the report data.") (N_ "Per default the date/time info will be shown before the report data.")
#f)) #f)
(opt-register (gnc-register-simple-boolean-option options
(gnc:make-simple-boolean-option
(N_ "General") (N_ "General")
(N_ "Show comments at bottom") "m" (N_ "Show comments at bottom") "m"
(N_ "Per default the additional comments text will be shown before the report data.") (N_ "Per default the additional comments text will be shown before the report data.")
#f)) #f)
(opt-register (gnc-register-simple-boolean-option options
(gnc:make-simple-boolean-option
(N_ "General") (N_ "General")
(N_ "Show GnuCash version at bottom") "m" (N_ "Show GnuCash version at bottom") "m"
(N_ "Per default the GnuCash version will be shown before the report data.") (N_ "Per default the GnuCash version will be shown before the report data.")
#f)) #f)
(opt-register (gnc-register-pixmap-option options
(gnc:make-pixmap-option
(N_ "Images") (N_ "Images")
(N_ "Background Tile") "a" (N_ "Background tile for reports.") (N_ "Background Tile") "a" (N_ "Background tile for reports.")
"")) "")
(opt-register (gnc-register-pixmap-option options
(gnc:make-pixmap-option
(N_ "Images") (N_ "Images")
;;; Translators: Banner is an image like Logo. ;;; Translators: Banner is an image like Logo.
(N_ "Heading Banner") "b" (N_ "Banner for top of report.") (N_ "Heading Banner") "b" (N_ "Banner for top of report.")
"")) "")
(opt-register (gnc-register-multichoice-option options
(gnc:make-multichoice-option
(N_ "Images") (N_ "Images")
(N_ "Heading Alignment") "c" (N_ "Banner for top of report.") (N_ "Heading Alignment") "c" (N_ "Banner for top of report.")
'left "left"
(list (vector 'left (N_ "Left")) (list (vector 'left (N_ "Left"))
(vector 'center (N_ "Center")) (vector 'center (N_ "Center"))
(vector 'right (N_ "Right"))))) (vector 'right (N_ "Right"))))
(opt-register (gnc-register-pixmap-option options
(gnc:make-pixmap-option
(N_ "Images") (N_ "Images")
(N_ "Logo") "d" (N_ "Company logo image.") (N_ "Logo") "d" (N_ "Company logo image.")
"")) "")
(opt-register (gnc-register-color-option options
(gnc:make-color-option
(N_ "Colors") (N_ "Colors")
(N_ "Background Color") "a" (N_ "General background color for report.") (N_ "Background Color") "a" (N_ "General background color for report.")
(list #xff #xff #xff #xff) "ffffff")
255 #f))
(opt-register (gnc-register-color-option options
(gnc:make-color-option
(N_ "Colors") (N_ "Colors")
(N_ "Text Color") "b" (N_ "Normal body text color.") (N_ "Text Color") "b" (N_ "Normal body text color.")
(list #x00 #x00 #x00 #xff) "000000")
255 #f))
(opt-register (gnc-register-color-option options
(gnc:make-color-option
(N_ "Colors") (N_ "Colors")
(N_ "Link Color") "c" (N_ "Link text color.") (N_ "Link Color") "c" (N_ "Link text color.")
(list #xb2 #x22 #x22 #xff) "b22222")
255 #f))
(opt-register (gnc-register-color-option options
(gnc:make-color-option
(N_ "Colors") (N_ "Colors")
(N_ "Table Cell Color") "c" (N_ "Default background for table cells.") (N_ "Table Cell Color") "c" (N_ "Default background for table cells.")
(list #xff #xff #xff #xff) "ffffff")
255 #f))
(opt-register (gnc-register-color-option options
(gnc:make-color-option
(N_ "Colors") (N_ "Colors")
(N_ "Alternate Table Cell Color") "d" (N_ "Alternate Table Cell Color") "d"
(N_ "Default alternate background for table cells.") (N_ "Default alternate background for table cells.")
(list #xff #xff #xff #xff) "ffffff")
255 #f))
(opt-register (gnc-register-color-option options
(gnc:make-color-option
(N_ "Colors") (N_ "Colors")
(N_ "Subheading/Subtotal Cell Color") "e" (N_ "Subheading/Subtotal Cell Color") "e"
(N_ "Default color for subtotal rows.") (N_ "Default color for subtotal rows.")
(list #xee #xe8 #xaa #xff) "eexe8xaa")
255 #f))
(opt-register (gnc-register-color-option options
(gnc:make-color-option
(N_ "Colors") (N_ "Colors")
(N_ "Sub-subheading/total Cell Color") "f" (N_ "Sub-subheading/total Cell Color") "f"
(N_ "Color for subsubtotals.") (N_ "Color for subsubtotals.")
(list #xfa #xfa #xd2 #xff) "fafad2")
255 #f))
(opt-register (gnc-register-color-option options
(gnc:make-color-option
(N_ "Colors") (N_ "Colors")
(N_ "Grand Total Cell Color") "g" (N_ "Grand Total Cell Color") "g"
(N_ "Color for grand totals.") (N_ "Color for grand totals.")
(list #xff #xff #x00 #xff) "ffff00")
255 #f))
(opt-register (gnc-register-number-range-option options
(gnc:make-number-range-option
(N_ "Tables") (N_ "Tables")
(N_ "Table cell spacing") "a" (N_ "Space between table cells.") (N_ "Table cell spacing") "a" (N_ "Space between table cells.")
1 0 20 0 1)) 1 0 20 1)
(opt-register (gnc-register-number-range-option options
(gnc:make-number-range-option
(N_ "Tables") (N_ "Tables")
(N_ "Table cell padding") "b" (N_ "Space between table cell edge and content.") (N_ "Table cell padding") "b" (N_ "Space between table cell edge and content.")
1 0 20 0 1)) 1 0 20 1)
(opt-register (gnc-register-number-range-option options
(gnc:make-number-range-option
(N_ "Tables") (N_ "Tables")
(N_ "Table border width") "c" (N_ "Bevel depth on tables.") (N_ "Table border width") "c" (N_ "Bevel depth on tables.")
1 0 20 0 1)) 1 0 20 1)
(register-font-options options) (register-font-options options)
options)) options))
@ -243,12 +204,11 @@
(let* ((ssdoc (gnc:make-html-document)) (let* ((ssdoc (gnc:make-html-document))
(opt-val (opt-val
(lambda (section name) (lambda (section name)
(gnc:option-value (gnc-optiondb-lookup-value options section name)))
(gnc:lookup-option options section name))))
(color-val (color-val
(lambda (section name) (lambda (section name)
(gnc:color-option->html (gnc:color->html
(gnc:lookup-option options section name)))) (gnc-optiondb-lookup-value options section name))))
(preparer (opt-val "General" "Preparer")) (preparer (opt-val "General" "Preparer"))
(prepared-for (opt-val "General" "Prepared for")) (prepared-for (opt-val "General" "Prepared for"))
(show-preparer? (opt-val "General" "Show preparer info")) (show-preparer? (opt-val "General" "Show preparer info"))

View File

@ -36,64 +36,51 @@
;; this should generally be the default style sheet for most reports. ;; this should generally be the default style sheet for most reports.
;; it's supposed to be lightweight and unobtrusive. ;; it's supposed to be lightweight and unobtrusive.
(define (plain-options) (define (plain-options)
(let* ((options (gnc:new-options)) (let* ((options (gnc-new-optiondb)))
(opt-register (gnc-register-color-option options
(lambda (opt)
(gnc:register-option options opt))))
(opt-register
(gnc:make-color-option
(N_ "General") (N_ "General")
(N_ "Background Color") "a" (N_ "Background color for reports.") (N_ "Background Color") "a" (N_ "Background color for reports.")
(list #xff #xff #xff #xff) "ffffff")
255 #f)) (gnc-register-pixmap-option options
(opt-register
(gnc:make-pixmap-option
(N_ "General") (N_ "General")
(N_ "Background Pixmap") "b" (N_ "Background tile for reports.") (N_ "Background Pixmap") "b" (N_ "Background tile for reports.")
"")) "")
(opt-register (gnc-register-simple-boolean-option options
(gnc:make-simple-boolean-option
(N_ "General") (N_ "General")
(N_ "Enable Links") "c" (N_ "Enable hyperlinks in reports.") (N_ "Enable Links") "c" (N_ "Enable hyperlinks in reports.")
#t)) #t)
(opt-register (gnc-register-color-option options
(gnc:make-color-option
(N_ "Colors") (N_ "Colors")
(N_ "Alternate Table Cell Color") "a" (N_ "Background color for alternate lines.") (N_ "Alternate Table Cell Color") "a" (N_ "Background color for alternate lines.")
(list #xff #xff #xff #xff) "ffffff")
255 #f)) (gnc-register-number-range-option options
(opt-register
(gnc:make-number-range-option
(N_ "Tables") (N_ "Tables")
(N_ "Table cell spacing") "a" (N_ "Space between table cells.") (N_ "Table cell spacing") "a" (N_ "Space between table cells.")
0 0 20 0 1)) 0 0 20 1)
(opt-register (gnc-register-number-range-option options
(gnc:make-number-range-option
(N_ "Tables") (N_ "Tables")
(N_ "Table cell padding") "b" (N_ "Space between table cell edge and content.") (N_ "Table cell padding") "b" (N_ "Space between table cell edge and content.")
4 0 20 0 1)) 4 0 20 1)
(opt-register (gnc-register-number-range-option options
(gnc:make-number-range-option
(N_ "Tables") (N_ "Tables")
(N_ "Table border width") "c" (N_ "Bevel depth on tables.") (N_ "Table border width") "c" (N_ "Bevel depth on tables.")
0 0 20 0 1)) 0 0 20 1)
(register-font-options options) (register-font-options options)
options)) options))
(define (plain-renderer options doc) (define (plain-renderer options doc)
(define (opt-val section name) (define (opt-val section name)
(gnc:option-value (gnc-optiondb-lookup-value options section name))
(gnc:lookup-option options section name)))
(let* ((ssdoc (gnc:make-html-document)) (let* ((ssdoc (gnc:make-html-document))
(bgcolor (bgcolor
(gnc:color-option->html (gnc:color->html
(gnc:lookup-option options "General" "Background Color"))) (gnc-optiondb-lookup-value options "General" "Background Color")))
(bgpixmap (opt-val "General" "Background Pixmap")) (bgpixmap (opt-val "General" "Background Pixmap"))
(links? (opt-val "General" "Enable Links")) (links? (opt-val "General" "Enable Links"))
(alternate-row-color (alternate-row-color
(gnc:color-option->html (gnc:color->html
(gnc:lookup-option options "Colors" "Alternate Table Cell Color"))) (gnc-optiondb-lookup-value options "Colors" "Alternate Table Cell Color")))
(spacing (opt-val "Tables" "Table cell spacing")) (spacing (opt-val "Tables" "Table cell spacing"))
(padding (opt-val "Tables" "Table cell padding")) (padding (opt-val "Tables" "Table cell padding"))
(border (opt-val "Tables" "Table border width"))) (border (opt-val "Tables" "Table border width")))