diff options
Diffstat (limited to 'gnu/installer/newt')
-rw-r--r-- | gnu/installer/newt/ethernet.scm | 48 | ||||
-rw-r--r-- | gnu/installer/newt/menu.scm | 2 | ||||
-rw-r--r-- | gnu/installer/newt/network.scm | 56 | ||||
-rw-r--r-- | gnu/installer/newt/page.scm | 42 | ||||
-rw-r--r-- | gnu/installer/newt/partition.scm | 20 | ||||
-rw-r--r-- | gnu/installer/newt/user.scm | 40 |
6 files changed, 133 insertions, 75 deletions
diff --git a/gnu/installer/newt/ethernet.scm b/gnu/installer/newt/ethernet.scm index d1f357243b..ba5e222a37 100644 --- a/gnu/installer/newt/ethernet.scm +++ b/gnu/installer/newt/ethernet.scm @@ -1,5 +1,6 @@ ;;; GNU Guix --- Functional package management for GNU ;;; Copyright © 2018 Mathieu Othacehe <m.othacehe@gmail.com> +;;; Copyright © 2019 Ludovic Courtès <ludo@gnu.org> ;;; ;;; This file is part of GNU Guix. ;;; @@ -23,6 +24,7 @@ #:use-module (gnu installer newt page) #:use-module (guix i18n) #:use-module (ice-9 format) + #:use-module (ice-9 match) #:use-module (srfi srfi-34) #:use-module (srfi srfi-35) #:use-module (newt) @@ -58,24 +60,28 @@ connection is pending." service)) (define (run-ethernet-page) - (let ((services (ethernet-services))) - (if (null? services) - (begin - (run-error-page - (G_ "No ethernet service available, please try again.") - (G_ "No service")) - (raise - (condition - (&installer-step-abort)))) - (run-listbox-selection-page - #:info-text (G_ "Please select an ethernet network.") - #:title (G_ "Ethernet connection") - #:listbox-items services - #:listbox-item->text ethernet-service->text - #:button-text (G_ "Exit") - #:button-callback-procedure - (lambda _ - (raise - (condition - (&installer-step-abort)))) - #:listbox-callback-procedure connect-ethernet-service)))) + (match (ethernet-services) + (() + (run-error-page + (G_ "No ethernet service available, please try again.") + (G_ "No service")) + (raise + (condition + (&installer-step-abort)))) + ((service) + ;; Only one service is available so return it directly. + service) + ((services ...) + (run-listbox-selection-page + #:info-text (G_ "Please select an ethernet network.") + #:title (G_ "Ethernet connection") + #:listbox-items services + #:listbox-item->text ethernet-service->text + #:listbox-height (min (+ (length services) 2) 10) + #:button-text (G_ "Exit") + #:button-callback-procedure + (lambda _ + (raise + (condition + (&installer-step-abort)))) + #:listbox-callback-procedure connect-ethernet-service)))) diff --git a/gnu/installer/newt/menu.scm b/gnu/installer/newt/menu.scm index 161266a94a..e153d3d756 100644 --- a/gnu/installer/newt/menu.scm +++ b/gnu/installer/newt/menu.scm @@ -32,7 +32,7 @@ process from." steps)) (run-listbox-selection-page - #:info-text (G_ "Choose where you want to resume the install.\ + #:info-text (G_ "Choose where you want to resume the install. \ You can also abort the installation by pressing the Abort button.") #:title (G_ "Installation menu") #:listbox-items (steps->items steps) diff --git a/gnu/installer/newt/network.scm b/gnu/installer/newt/network.scm index cf27a8cca2..0a938db103 100644 --- a/gnu/installer/newt/network.scm +++ b/gnu/installer/newt/network.scm @@ -1,5 +1,6 @@ ;;; GNU Guix --- Functional package management for GNU ;;; Copyright © 2018 Mathieu Othacehe <m.othacehe@gmail.com> +;;; Copyright © 2019 Ludovic Courtès <ludo@gnu.org> ;;; ;;; This file is part of GNU Guix. ;;; @@ -28,6 +29,7 @@ #:use-module (srfi srfi-11) #:use-module (srfi srfi-34) #:use-module (srfi srfi-35) + #:use-module (ice-9 match) #:use-module (newt) #:export (run-network-page)) @@ -53,32 +55,38 @@ Internet and return the selected technology. For now, only technologies with (string=? type "wifi")))) (connman-technologies))) - (let ((items (technology-items))) - (if (null? items) - (case (choice-window - (G_ "Internet access") - (G_ "Continue") - (G_ "Exit") - (G_ "The install process requires Internet access but no \ + (match (technology-items) + (() + (case (choice-window + (G_ "Internet access") + (G_ "Continue") + (G_ "Exit") + (G_ "The install process requires Internet access but no \ network device were found. Do you want to continue anyway?")) - ((1) (raise - (condition - (&installer-step-break)))) - ((2) (raise - (condition - (&installer-step-abort))))) - (run-listbox-selection-page - #:info-text (G_ "The install process requires Internet access.\ + ((1) (raise + (condition + (&installer-step-break)))) + ((2) (raise + (condition + (&installer-step-abort)))))) + ((technology) + ;; Since there's only one technology available, skip the selection + ;; screen. + technology) + ((items ...) + (run-listbox-selection-page + #:info-text (G_ "The install process requires Internet access.\ Please select a network device.") - #:title (G_ "Internet access") - #:listbox-items items - #:listbox-item->text technology->text - #:button-text (G_ "Exit") - #:button-callback-procedure - (lambda _ - (raise - (condition - (&installer-step-abort)))))))) + #:title (G_ "Internet access") + #:listbox-items items + #:listbox-item->text technology->text + #:listbox-height (min (+ (length items) 2) 10) + #:button-text (G_ "Exit") + #:button-callback-procedure + (lambda _ + (raise + (condition + (&installer-step-abort)))))))) (define (find-technology-by-type technologies type) "Find and return a technology with the given TYPE in TECHNOLOGIES list." diff --git a/gnu/installer/newt/page.scm b/gnu/installer/newt/page.scm index 3173d54737..728721c08f 100644 --- a/gnu/installer/newt/page.scm +++ b/gnu/installer/newt/page.scm @@ -75,6 +75,7 @@ this page to TITLE." #:key (allow-empty-input? #f) (default-text #f) + (input-hide-checkbox? #f) (input-field-width 40) (input-flags 0)) "Run a page to prompt user for an input. The given TEXT will be displayed @@ -86,22 +87,38 @@ input box, such as FLAG-PASSWORD." (make-reflowed-textbox -1 -1 text input-field-width #: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 FLAG-SCROLL + input-flags) + input-flags)) (input-entry (make-entry -1 -1 20 - #:flags input-flags)) + #:flags input-flags*)) (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))) + (add-component-callback + input-visible-cb + (lambda (component) + (set-entry-flags input-entry + FLAG-PASSWORD + FLAG-ROLE-TOGGLE))) + (when default-text (set-entry-text input-entry default-text)) - (set-grid-field grid 0 0 GRID-ELEMENT-COMPONENT text-box) - (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) + (add-form-to-grid grid form #t) (make-wrapped-grid-window grid title) (let ((error-page (lambda () (run-error-page (G_ "Please enter a non empty input.") @@ -559,7 +576,12 @@ ITEMS when 'Ok' is pressed." '()))))) (form (make-form))) - (set-textbox-text file-textbox file-text) + (set-textbox-text file-textbox + (receive (_w _h text) + (reflow-text file-text + file-textbox-width + 0 0) + text)) (add-form-to-grid grid form #t) (make-wrapped-grid-window grid title) diff --git a/gnu/installer/newt/partition.scm b/gnu/installer/newt/partition.scm index 3fb6c5079e..cd9d46316a 100644 --- a/gnu/installer/newt/partition.scm +++ b/gnu/installer/newt/partition.scm @@ -49,6 +49,7 @@ #:title (G_ "Partition scheme") #:listbox-items items #:listbox-item->text cdr + #:listbox-height 4 #:sort-listbox-items? #f ;keep the 'root' option first #:button-text (G_ "Exit") #:button-callback-procedure button-exit-action))) @@ -78,6 +79,7 @@ DEVICES list." #:title (G_ "Disk") #:listbox-items (device-items) #:listbox-item->text cdr + #:listbox-height 10 #:button-text (G_ "Exit") #:button-callback-procedure button-exit-action)) (device (car result))) @@ -118,7 +120,7 @@ Be careful, all data on the disk will be lost.") (run-listbox-selection-page #:info-text (G_ "Please select the file-system type for this partition.") #:title (G_ "File-system type") - #:listbox-items '(ext4 btrfs fat32 swap) + #:listbox-items '(ext4 btrfs fat16 fat32 swap) #:listbox-item->text user-fs-type-name #:sort-listbox-items? #f #:button-text (G_ "Exit") @@ -153,21 +155,18 @@ USER-PARTITIONS list. Return this list with password fields filled-in." (file-name (user-partition-file-name user-part)) (password-page (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 (format #f (G_ "Please enter the password for the \ encryption of partition ~a (label: ~a).") file-name crypt-label) - (G_ "Password required")))) + (G_ "Password required") + #:input-hide-checkbox? #t))) (password-confirm-page (lambda () (run-input-page (format #f (G_ "Please confirm the password for the \ encryption of partition ~a (label: ~a).") file-name crypt-label) (G_ "Password confirmation required") - #:input-flags FLAG-PASSWORD)))) + #:input-hide-checkbox? #t)))) (if crypt-label (let loop () (let ((password (password-page)) @@ -732,8 +731,10 @@ by pressing the Exit button.~%~%"))) (result (run-listbox-selection-page #:info-text (G_ "Please select a partitioning method.") #:title (G_ "Partitioning method") + #:listbox-height (+ (length items) 2) #:listbox-items items #:listbox-item->text cdr + #:sort-listbox-items? #f #:button-text (G_ "Exit") #:button-callback-procedure button-exit-action)) (method (car result))) @@ -751,10 +752,7 @@ by pressing the Exit button.~%~%"))) (disk-commit disk) disk))) (scheme (symbol-append method '- (run-scheme-page))) - (user-partitions (append - (auto-partition disk #:scheme scheme) - (create-special-user-partitions - (disk-partitions disk))))) + (user-partitions (auto-partition! disk #:scheme scheme))) (run-disk-page (list disk) user-partitions #:guided? #t))) ((eq? method 'manual) diff --git a/gnu/installer/newt/user.scm b/gnu/installer/newt/user.scm index deab056e0c..dab805198f 100644 --- a/gnu/installer/newt/user.scm +++ b/gnu/installer/newt/user.scm @@ -19,6 +19,7 @@ (define-module (gnu installer newt user) #:use-module (gnu installer user) + #:use-module ((gnu installer steps) #:select (&installer-step-abort)) #:use-module (gnu installer newt page) #:use-module (gnu installer newt utils) #:use-module (guix i18n) @@ -27,6 +28,8 @@ #:use-module (ice-9 receive) #:use-module (srfi srfi-1) #:use-module (srfi srfi-26) + #:use-module (srfi srfi-34) + #:use-module (srfi srfi-35) #:export (run-user-page)) (define* (run-user-add-page #:key (name "") (real-name "") @@ -34,7 +37,7 @@ "Run a form to enter the user name, home directory, and password. Use NAME, REAL-NAME, and HOME-DIRECTORY as the initial values in the form." (define (pad-label label) - (string-pad-right label 20)) + (string-pad-right label 25)) (let* ((label-name (make-label -1 -1 (pad-label (G_ "Name")))) @@ -44,16 +47,19 @@ REAL-NAME, and HOME-DIRECTORY as the initial values in the form." (make-label -1 -1 (pad-label (G_ "Home directory")))) (label-password (make-label -1 -1 (pad-label (G_ "Password")))) - (entry-width 30) + (entry-width 35) (entry-name (make-entry -1 -1 entry-width #:initial-value name)) (entry-real-name (make-entry -1 -1 entry-width #:initial-value real-name)) (entry-home-directory (make-entry -1 -1 entry-width #:initial-value home-directory)) + (password-visible-cb + (make-checkbox -1 -1 (G_ "Hide") #\x "x ")) (entry-password (make-entry -1 -1 entry-width - #:flags FLAG-PASSWORD)) - (entry-grid (make-grid 2 5)) + #:flags (logior FLAG-PASSWORD + FLAG-SCROLL))) + (entry-grid (make-grid 3 5)) (button-grid (make-grid 1 1)) (ok-button (make-button -1 -1 (G_ "OK"))) (grid (make-grid 1 2)) @@ -71,6 +77,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 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) (add-component-callback @@ -83,11 +95,19 @@ REAL-NAME, and HOME-DIRECTORY as the initial values in the form." (set-entry-text entry-real-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 label-name label-real-name label-home-directory label-password entry-name entry-real-name entry-home-directory entry-password + password-visible-cb ok-button) (make-wrapped-grid-window (vertically-stacked-grid @@ -136,7 +156,7 @@ a thunk, if the confirmation doesn't match PASSWORD, and return its result." (run-input-page (G_ "Please confirm the password.") (G_ "Password confirmation required") #:allow-empty-input? #t - #:input-flags FLAG-PASSWORD)) + #:input-hide-checkbox? #t)) (if (string=? password confirmation) password @@ -153,7 +173,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 \ administrator (\"root\").") (G_ "System administrator password") - #:input-flags FLAG-PASSWORD)) + #:input-hide-checkbox? #t)) (confirm-password password run-root-password-page)) @@ -179,7 +199,7 @@ administrator (\"root\").") (list GRID-ELEMENT-COMPONENT del-button))))) (ok-button (make-button -1 -1 (G_ "OK"))) (exit-button (make-button -1 -1 (G_ "Exit"))) - (title "User creation") + (title (G_ "User creation")) (grid (vertically-stacked-grid GRID-ELEMENT-COMPONENT info-textbox @@ -231,7 +251,11 @@ administrator (\"root\").") (run-error-page (G_ "Please create at least one user.") (G_ "No user")) (run users)) - (reverse users))))) + (reverse users)) + ((components=? argument exit-button) + (raise + (condition + (&installer-step-abort))))))) (lambda () (destroy-form-and-pop form)))))) |