installer: Add #:selection parameter to 'run-checkbox-tree-page'.

* gnu/installer/newt/page.scm (%none-selected): New variable.
(run-checkbox-tree-page): Add #:selection.
[fill-checkbox-tree]: Honor it.
This commit is contained in:
Ludovic Courtès 2019-04-28 21:43:35 +02:00
parent 0fe1692200
commit 7253c2b629
No known key found for this signature in database
GPG Key ID: 090B11993D9AEBB5
1 changed files with 15 additions and 7 deletions

View File

@ -437,10 +437,14 @@ error is raised if the MAX-SCALE-UPDATE limit is reached."
(lambda () (lambda ()
(destroy-form-and-pop form))))) (destroy-form-and-pop form)))))
(define %none-selected
(circular-list #f))
(define* (run-checkbox-tree-page #:key (define* (run-checkbox-tree-page #:key
info-text info-text
title title
items items
(selection %none-selected)
item->text item->text
(info-textbox-width 50) (info-textbox-width 50)
(checkbox-tree-height 10) (checkbox-tree-height 10)
@ -453,7 +457,8 @@ a checkbox list. The page contains vertically stacked from the top to the
bottom, an informative text set to INFO-TEXT, the checkbox list and two bottom, an informative text set to INFO-TEXT, the checkbox list and two
buttons, 'Ok' and 'Exit'. The page title's is set to TITLE. ITEMS are buttons, 'Ok' and 'Exit'. The page title's is set to TITLE. ITEMS are
converted to text using ITEM->TEXT before being displayed in the checkbox converted to text using ITEM->TEXT before being displayed in the checkbox
list. list. SELECTION is a list of Booleans of the same length as ITEMS that
specifies which items are initially checked.
INFO-TEXTBOX-WIDTH is the width of the textbox where INFO-TEXT will be INFO-TEXTBOX-WIDTH is the width of the textbox where INFO-TEXT will be
displayed. CHECKBOX-TREE-HEIGHT is the height of the checkbox list. displayed. CHECKBOX-TREE-HEIGHT is the height of the checkbox list.
@ -465,12 +470,15 @@ pressed.
This procedure returns the list of checked items in the checkbox list among This procedure returns the list of checked items in the checkbox list among
ITEMS when 'Ok' is pressed." ITEMS when 'Ok' is pressed."
(define (fill-checkbox-tree checkbox-tree items) (define (fill-checkbox-tree checkbox-tree items)
(map (map (lambda (item selected?)
(lambda (item) (let* ((item-text (item->text item))
(let* ((item-text (item->text item)) (key (add-entry-to-checkboxtree checkbox-tree item-text
(key (add-entry-to-checkboxtree checkbox-tree item-text 0))) (if selected?
(cons key item))) FLAG-SELECTED
items)) 0))))
(cons key item)))
items
selection))
(let* ((checkbox-tree (let* ((checkbox-tree
(make-checkboxtree -1 -1 (make-checkboxtree -1 -1