aboutsummaryrefslogtreecommitdiff
path: root/gnu/installer/newt
diff options
context:
space:
mode:
authorJakub Kądziołka <kuba@kadziolka.net>2020-04-29 11:08:42 +0200
committerJakub Kądziołka <kuba@kadziolka.net>2020-04-29 11:08:42 +0200
commit4035c3e3525599c3aa958d498c5bc789a4adffc3 (patch)
treee55a02215fcdb635d0504fc129526bfbf66abd14 /gnu/installer/newt
parent492b82bd4d592276e65c4b9bfbe1b679a00ff09f (diff)
parent4f0f46e4af0e342d84c5ad448258702029601e4b (diff)
downloadguix-4035c3e3525599c3aa958d498c5bc789a4adffc3.tar
guix-4035c3e3525599c3aa958d498c5bc789a4adffc3.tar.gz
Merge branch 'master' into staging
Diffstat (limited to 'gnu/installer/newt')
-rw-r--r--gnu/installer/newt/keymap.scm111
-rw-r--r--gnu/installer/newt/page.scm4
-rw-r--r--gnu/installer/newt/parameters.scm57
-rw-r--r--gnu/installer/newt/user.scm4
4 files changed, 152 insertions, 24 deletions
diff --git a/gnu/installer/newt/keymap.scm b/gnu/installer/newt/keymap.scm
index 2908ba7f0e..1b3af2f158 100644
--- a/gnu/installer/newt/keymap.scm
+++ b/gnu/installer/newt/keymap.scm
@@ -1,6 +1,7 @@
;;; GNU Guix --- Functional package management for GNU
-;;; Copyright © 2018 Mathieu Othacehe <m.othacehe@gmail.com>
+;;; Copyright © 2018, 2020 Mathieu Othacehe <m.othacehe@gmail.com>
;;; Copyright © 2019 Ludovic Courtès <ludo@gnu.org>
+;;; Copyright © 2020 Florian Pelz <pelzflorian@pelzflorian.de>
;;;
;;; This file is part of GNU Guix.
;;;
@@ -33,20 +34,34 @@
#:export (run-keymap-page
keyboard-layout->configuration))
-(define (run-layout-page layouts layout->text)
+(define (run-layout-page layouts layout->text context)
(let ((title (G_ "Layout")))
(run-listbox-selection-page
#:title title
- #:info-text (G_ "Please choose your keyboard layout.")
+ #:info-text
+ (case context
+ ((param) (G_ "Please choose your keyboard layout. \
+It will only be used during the installation process. \
+Non-Latin layouts can be toggled with Alt+Shift."))
+ (else (G_ "Please choose your keyboard layout. \
+It will be used during the install process, and for the installed system. \
+Non-Latin layouts can be toggled with Alt+Shift. You can switch to a \
+different layout at any time from the parameters menu.")))
#:listbox-items layouts
#:listbox-item->text layout->text
#:sort-listbox-items? #f
- #:button-text (G_ "Exit")
+ #:button-text
+ (case context
+ ((param) (G_ "Continue"))
+ (else (G_ "Exit")))
#:button-callback-procedure
- (lambda _
- (raise
- (condition
- (&installer-step-abort)))))))
+ (case context
+ ((param) (const #t))
+ (else
+ (lambda _
+ (raise
+ (condition
+ (&installer-step-abort)))))))))
(define (run-variant-page variants variant->text)
(let ((title (G_ "Variant")))
@@ -89,21 +104,66 @@
(append (sort main layout<?)
(sort others layout<?)))))
+(define (add-empty-variant variants)
+ "Prepend #f to VARIANTS so the user has the option to select no variant.
+The resulting layout may be different from all other variants (e.g. for
+Azerbaijani)."
+ (cons #f variants))
+
(define (sort-variants variants)
"Sort VARIANTS list by putting the international variant ahead and return it."
(call-with-values
(lambda ()
(partition
(lambda (variant)
- (let ((name (x11-keymap-variant-name variant)))
- (string=? name "altgr-intl")))
+ (and variant
+ (let ((name (x11-keymap-variant-name variant)))
+ (string=? name "altgr-intl"))))
variants))
(cut append <> <>)))
-(define* (run-keymap-page layouts)
+(define %non-latin-layouts
+ ;; List of keyboard layouts marked as $nonlatin in xkeyboard-config.
+ ;; See comments in xkeyboard-config file /share/X11/xkb/rules/base.
+ ;; We ignore layouts that support Latin input: "kr"
+ '("am" "ara" "ben" "bd" "bg" "bt" "by" "cs" "deva" "ge" "gh"
+ "gr" "guj" "guru" "il" "in" "ir" "iku" "jp" "kan" "kh"
+ "la" "lao" "lk" "mk" "mm" "mn" "mv" "mal" "olck" "ori" "pk"
+ "ru" "scc" "sy" "syr" "tel" "th" "tj" "tam" "ua" "uz"
+ ;; The list from xkeyboard-config is incomplete. Add more layouts when
+ ;; noticed:
+ "et" "kz"))
+
+(define %non-latin-variants
+ '("cyrillic"))
+
+(define %latin-layout+variants
+ ;; These layout+variant combinations are Latin after all.
+ '(("ir" "ku")))
+
+(define (toggleable-latin-layout layout variant)
+ "If LAYOUT is a non-Latin layout, return a new combined layout,
+a variant, and options that allow the user to switch between the
+non-Latin and the Latin layout. Otherwise, return LAYOUT, VARIANT,
+and #f."
+ (if (and (not (equal? variant "latin"))
+ (not (member (list layout variant) %latin-layout+variants))
+ (or (member layout %non-latin-layouts)
+ (member variant %non-latin-variants)))
+ (let ((latin-layout (if (equal? variant "azerty") "fr" "us")))
+ (list
+ (string-append layout "," latin-layout)
+ ;; Comma to use variant only for non-Latin:
+ (and variant (string-append variant ","))
+ "grp:alt_shift_toggle"))
+ (list layout variant #f)))
+
+(define* (run-keymap-page layouts #:key (context #f))
"Run a page asking the user to select a keyboard layout and variant. LAYOUTS
-is a list of supported X11-KEYMAP-LAYOUT. Return a list of two elements, the
-names of the selected keyboard layout and variant."
+is a list of supported X11-KEYMAP-LAYOUT. For non-Latin keyboard layouts, a
+second layout and toggle options will be added automatically. Return a list
+of three elements, the names of the selected keyboard layout, variant and
+options."
(define keymap-steps
(list
(installer-step
@@ -114,7 +174,8 @@ names of the selected keyboard layout and variant."
(sort-layouts layouts)
(lambda (layout)
(gettext (x11-keymap-layout-description layout)
- "xkeyboard-config"))))))
+ "xkeyboard-config"))
+ context))))
;; Propose the user to select a variant among those supported by the
;; previously selected layout.
(installer-step
@@ -126,10 +187,14 @@ names of the selected keyboard layout and variant."
;; Return #f if the layout does not have any variant.
(and (not (null? variants))
(run-variant-page
- (sort-variants variants)
+ (sort-variants (add-empty-variant variants))
(lambda (variant)
- (gettext (x11-keymap-variant-description variant)
- "xkeyboard-config"))))))))))
+ (if variant
+ (gettext (x11-keymap-variant-description variant)
+ "xkeyboard-config")
+ ;; Text to opt for no variant at all:
+ (gettext (x11-keymap-layout-description layout)
+ "xkeyboard-config")))))))))))
(define (format-result result)
(let ((layout (x11-keymap-layout-name
@@ -138,14 +203,20 @@ names of the selected keyboard layout and variant."
(lambda (variant)
(gettext (x11-keymap-variant-name variant)
"xkeyboard-config")))))
- (list layout (or variant ""))))
+ (toggleable-latin-layout layout variant)))
(format-result
(run-installer-steps #:steps keymap-steps)))
(define (keyboard-layout->configuration keymap)
"Return the operating system configuration snippet to install KEYMAP."
(match keymap
- ((name "")
+ ((name #f "grp:alt_shift_toggle")
+ `((keyboard-layout (keyboard-layout ,name
+ #:options '("grp:alt_shift_toggle")))))
+ ((name #f _)
`((keyboard-layout (keyboard-layout ,name))))
- ((name variant)
+ ((name variant "grp:alt_shift_toggle")
+ `((keyboard-layout (keyboard-layout ,name ,variant
+ #:options '("grp:alt_shift_toggle")))))
+ ((name variant _)
`((keyboard-layout (keyboard-layout ,name ,variant))))))
diff --git a/gnu/installer/newt/page.scm b/gnu/installer/newt/page.scm
index 9031c7d4ba..1d6b9979b4 100644
--- a/gnu/installer/newt/page.scm
+++ b/gnu/installer/newt/page.scm
@@ -231,7 +231,7 @@ input box, such as FLAG-PASSWORD."
(add-component-callback
input-visible-cb
- (lambda (component)
+ (lambda ()
(set-entry-flags input-entry
FLAG-PASSWORD
FLAG-ROLE-TOGGLE)))
@@ -486,7 +486,7 @@ the current listbox item has to be selected by key."
;; do nothing.
(add-component-callback
listbox
- (lambda (component)
+ (lambda ()
(let* ((current-key (current-listbox-entry listbox))
(listbox-keys (map car keys))
(last-key (last-listbox-key))
diff --git a/gnu/installer/newt/parameters.scm b/gnu/installer/newt/parameters.scm
new file mode 100644
index 0000000000..95112b5780
--- /dev/null
+++ b/gnu/installer/newt/parameters.scm
@@ -0,0 +1,57 @@
+;;; GNU Guix --- Functional package management for GNU
+;;; Copyright © 2020 Mathieu Othacehe <m.othacehe@gmail.com>
+;;;
+;;; This file is part of GNU Guix.
+;;;
+;;; GNU Guix is free software; you can redistribute it and/or modify it
+;;; under the terms of the GNU General Public License as published by
+;;; the Free Software Foundation; either version 3 of the License, or (at
+;;; your option) any later version.
+;;;
+;;; GNU Guix is distributed in the hope that it will be useful, but
+;;; WITHOUT ANY WARRANTY; without even the implied warranty of
+;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+;;; GNU General Public License for more details.
+;;;
+;;; You should have received a copy of the GNU General Public License
+;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
+
+(define-module (gnu installer newt parameters)
+ #:use-module (gnu installer proxy)
+ #:use-module (gnu installer steps)
+ #:use-module (gnu installer newt page)
+ #:use-module (guix i18n)
+ #:use-module (ice-9 match)
+ #:use-module (newt)
+ #:export (run-parameters-page))
+
+(define (run-proxy-page)
+ (define proxy
+ (run-input-page (G_ "Please enter the HTTP proxy URL. If you enter an \
+empty string, proxy usage will be disabled.")
+ (G_ "HTTP proxy configuration")
+ #:allow-empty-input? #t))
+ (if (string=? proxy "")
+ (clear-http-proxy)
+ (set-http-proxy proxy)))
+
+(define (run-parameters-page keyboard-layout-selection)
+ "Run a parameters page allowing to change the keyboard layout"
+ (let* ((items
+ (list
+ (cons (G_ "Change keyboard layout") keyboard-layout-selection)
+ (cons (G_ "Configure HTTP proxy") run-proxy-page)))
+ (result
+ (run-listbox-selection-page
+ #:info-text (G_ "Please choose one of the following parameters or \
+press ‘Back’ to go back to the installation process.")
+ #:title (G_ "Installation parameters")
+ #:listbox-items items
+ #:listbox-item->text car
+ #:sort-listbox-items? #f
+ #:listbox-height 6
+ #:button-text (G_ "Back"))))
+ (match result
+ ((_ . proc)
+ (proc))
+ (_ #f))))
diff --git a/gnu/installer/newt/user.scm b/gnu/installer/newt/user.scm
index ad711d665a..58bb86bf96 100644
--- a/gnu/installer/newt/user.scm
+++ b/gnu/installer/newt/user.scm
@@ -89,7 +89,7 @@ REAL-NAME, and HOME-DIRECTORY as the initial values in the form."
(add-component-callback
entry-name
- (lambda (component)
+ (lambda ()
(set-entry-text entry-home-directory
(string-append "/home/" (entry-value entry-name)))
@@ -99,7 +99,7 @@ REAL-NAME, and HOME-DIRECTORY as the initial values in the form."
(add-component-callback
password-visible-cb
- (lambda (component)
+ (lambda ()
(set-entry-flags entry-password
FLAG-PASSWORD
FLAG-ROLE-TOGGLE)))