installer: Add password 'hide' checkbox.

* gnu/installer/newt/page.scm (run-input-page)[input-hide-checkbox?]: New
parameter adding a checkbox to toggle password hiding. By default, the
checkbox is active and the password is hence hided.
* gnu/installer/newt/partition.scm (prompt-luks-passwords): Enable the
previous parameter on both password input pages.
* gnu/installer/newt/user.scm (run-root-password-page): Enable the previous
parameter,
(confirm-password): ditto,
(run-user-add-page): add a checkbox to toggle password hiding.
This commit is contained in:
Mathieu Othacehe 2019-05-05 12:54:40 +02:00
parent d9ef50b3bc
commit 445bd4d5e5
No known key found for this signature in database
GPG Key ID: 8354763531769CA6
3 changed files with 47 additions and 18 deletions

View File

@ -75,6 +75,7 @@ this page to TITLE."
#:key #:key
(allow-empty-input? #f) (allow-empty-input? #f)
(default-text #f) (default-text #f)
(input-hide-checkbox? #f)
(input-field-width 40) (input-field-width 40)
(input-flags 0)) (input-flags 0))
"Run a page to prompt user for an input. The given TEXT will be displayed "Run a page to prompt user for an input. The given TEXT will be displayed
@ -86,22 +87,37 @@ input box, such as FLAG-PASSWORD."
(make-reflowed-textbox -1 -1 text (make-reflowed-textbox -1 -1 text
input-field-width input-field-width
#:flags FLAG-BORDER)) #:flags FLAG-BORDER))
(grid (make-grid 1 3)) (input-visible-cb
(make-checkbox -1 -1 (G_ "Hide") #\x "x "))
(input-flags* (if input-hide-checkbox?
(logior FLAG-PASSWORD input-flags)
input-flags))
(input-entry (make-entry -1 -1 20 (input-entry (make-entry -1 -1 20
#:flags input-flags)) #:flags input-flags*))
(ok-button (make-button -1 -1 (G_ "OK"))) (ok-button (make-button -1 -1 (G_ "OK")))
(grid (vertically-stacked-grid
GRID-ELEMENT-COMPONENT text-box
GRID-ELEMENT-SUBGRID
(apply
horizontal-stacked-grid
GRID-ELEMENT-COMPONENT input-entry
`(,@(if input-hide-checkbox?
(list GRID-ELEMENT-COMPONENT input-visible-cb)
'())))
GRID-ELEMENT-COMPONENT ok-button))
(form (make-form))) (form (make-form)))
(add-component-callback
input-visible-cb
(lambda (component)
(set-entry-flags input-entry
FLAG-PASSWORD
FLAG-ROLE-TOGGLE)))
(when default-text (when default-text
(set-entry-text input-entry default-text)) (set-entry-text input-entry default-text))
(set-grid-field grid 0 0 GRID-ELEMENT-COMPONENT text-box) (add-form-to-grid grid form #t)
(set-grid-field grid 0 1 GRID-ELEMENT-COMPONENT input-entry
#:pad-top 1)
(set-grid-field grid 0 2 GRID-ELEMENT-COMPONENT ok-button
#:pad-top 1)
(add-components-to-form form text-box input-entry ok-button)
(make-wrapped-grid-window grid title) (make-wrapped-grid-window grid title)
(let ((error-page (lambda () (let ((error-page (lambda ()
(run-error-page (G_ "Please enter a non empty input.") (run-error-page (G_ "Please enter a non empty input.")

View File

@ -155,21 +155,18 @@ USER-PARTITIONS list. Return this list with password fields filled-in."
(file-name (user-partition-file-name user-part)) (file-name (user-partition-file-name user-part))
(password-page (password-page
(lambda () (lambda ()
;; Note: Don't use FLAG-PASSWORD here because this is the
;; first bit of text that the user types in, so it's
;; probably safer if they can see that the keyboard layout
;; they chose is in effect.
(run-input-page (run-input-page
(format #f (G_ "Please enter the password for the \ (format #f (G_ "Please enter the password for the \
encryption of partition ~a (label: ~a).") file-name crypt-label) encryption of partition ~a (label: ~a).") file-name crypt-label)
(G_ "Password required")))) (G_ "Password required")
#:input-hide-checkbox? #t)))
(password-confirm-page (password-confirm-page
(lambda () (lambda ()
(run-input-page (run-input-page
(format #f (G_ "Please confirm the password for the \ (format #f (G_ "Please confirm the password for the \
encryption of partition ~a (label: ~a).") file-name crypt-label) encryption of partition ~a (label: ~a).") file-name crypt-label)
(G_ "Password confirmation required") (G_ "Password confirmation required")
#:input-flags FLAG-PASSWORD)))) #:input-hide-checkbox? #t))))
(if crypt-label (if crypt-label
(let loop () (let loop ()
(let ((password (password-page)) (let ((password (password-page))

View File

@ -51,9 +51,11 @@ REAL-NAME, and HOME-DIRECTORY as the initial values in the form."
#:initial-value real-name)) #:initial-value real-name))
(entry-home-directory (make-entry -1 -1 entry-width (entry-home-directory (make-entry -1 -1 entry-width
#:initial-value home-directory)) #:initial-value home-directory))
(password-visible-cb
(make-checkbox -1 -1 (G_ "Hide") #\x "x "))
(entry-password (make-entry -1 -1 entry-width (entry-password (make-entry -1 -1 entry-width
#:flags FLAG-PASSWORD)) #:flags FLAG-PASSWORD))
(entry-grid (make-grid 2 5)) (entry-grid (make-grid 3 5))
(button-grid (make-grid 1 1)) (button-grid (make-grid 1 1))
(ok-button (make-button -1 -1 (G_ "OK"))) (ok-button (make-button -1 -1 (G_ "OK")))
(grid (make-grid 1 2)) (grid (make-grid 1 2))
@ -71,6 +73,12 @@ REAL-NAME, and HOME-DIRECTORY as the initial values in the form."
(set-entry-grid-field 0 3 label-password) (set-entry-grid-field 0 3 label-password)
(set-entry-grid-field 1 3 entry-password) (set-entry-grid-field 1 3 entry-password)
(set-grid-field entry-grid
2 3
GRID-ELEMENT-COMPONENT
password-visible-cb
#:pad-left 1)
(set-grid-field button-grid 0 0 GRID-ELEMENT-COMPONENT ok-button) (set-grid-field button-grid 0 0 GRID-ELEMENT-COMPONENT ok-button)
(add-component-callback (add-component-callback
@ -83,11 +91,19 @@ REAL-NAME, and HOME-DIRECTORY as the initial values in the form."
(set-entry-text entry-real-name (set-entry-text entry-real-name
(string-titlecase (entry-value entry-name)))))) (string-titlecase (entry-value entry-name))))))
(add-component-callback
password-visible-cb
(lambda (component)
(set-entry-flags entry-password
FLAG-PASSWORD
FLAG-ROLE-TOGGLE)))
(add-components-to-form form (add-components-to-form form
label-name label-real-name label-name label-real-name
label-home-directory label-password label-home-directory label-password
entry-name entry-real-name entry-name entry-real-name
entry-home-directory entry-password entry-home-directory entry-password
password-visible-cb
ok-button) ok-button)
(make-wrapped-grid-window (vertically-stacked-grid (make-wrapped-grid-window (vertically-stacked-grid
@ -136,7 +152,7 @@ a thunk, if the confirmation doesn't match PASSWORD, and return its result."
(run-input-page (G_ "Please confirm the password.") (run-input-page (G_ "Please confirm the password.")
(G_ "Password confirmation required") (G_ "Password confirmation required")
#:allow-empty-input? #t #:allow-empty-input? #t
#:input-flags FLAG-PASSWORD)) #:input-hide-checkbox? #t))
(if (string=? password confirmation) (if (string=? password confirmation)
password password
@ -153,7 +169,7 @@ a thunk, if the confirmation doesn't match PASSWORD, and return its result."
(run-input-page (G_ "Please choose a password for the system \ (run-input-page (G_ "Please choose a password for the system \
administrator (\"root\").") administrator (\"root\").")
(G_ "System administrator password") (G_ "System administrator password")
#:input-flags FLAG-PASSWORD)) #:input-hide-checkbox? #t))
(confirm-password password run-root-password-page)) (confirm-password password run-root-password-page))