installer: keymap: Put English layout and international variant ahead.

* gnu/installer/newt/keymap.scm (sort-layouts): New procedure,
(sort-variants): new procedure,
(run-keymap-page): use the two procedures above to sort layouts and variants.
This commit is contained in:
Mathieu Othacehe 2019-01-12 18:26:11 +01:00 committed by Ludovic Courtès
parent 513914b59f
commit cb614af011
No known key found for this signature in database
GPG Key ID: 090B11993D9AEBB5
1 changed files with 31 additions and 5 deletions

View File

@ -24,6 +24,7 @@
#:use-module (guix records)
#:use-module (newt)
#:use-module (srfi srfi-1)
#:use-module (srfi srfi-26)
#:use-module (srfi srfi-34)
#:use-module (srfi srfi-35)
#:export (run-keymap-page))
@ -35,6 +36,7 @@
#:info-text (G_ "Please choose your keyboard layout.")
#:listbox-items layouts
#:listbox-item->text layout->text
#:sort-listbox-items? #f
#:button-text (G_ "Exit")
#:button-callback-procedure
(lambda _
@ -49,6 +51,7 @@
#:info-text (G_ "Please choose a variant for your keyboard layout.")
#:listbox-items variants
#:listbox-item->text variant->text
#:sort-listbox-items? #f
#:button-text (G_ "Back")
#:button-callback-procedure
(lambda _
@ -56,6 +59,28 @@
(condition
(&installer-step-abort)))))))
(define (sort-layouts layouts)
"Sort LAYOUTS list by putting the US layout ahead and return it."
(call-with-values
(lambda ()
(partition
(lambda (layout)
(let ((name (x11-keymap-layout-name layout)))
(string=? name "us")))
layouts))
(cut append <> <>)))
(define (sort-variants variants)
"Sort VARIANTS list by putting the internation variant ahead and return it."
(call-with-values
(lambda ()
(partition
(lambda (variant)
(let ((name (x11-keymap-variant-name variant)))
(string=? name "altgr-intl")))
variants))
(cut append <> <>)))
(define* (run-keymap-page layouts)
"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
@ -67,7 +92,7 @@ names of the selected keyboard layout and variant."
(compute
(lambda _
(run-layout-page
layouts
(sort-layouts layouts)
(lambda (layout)
(x11-keymap-layout-description layout))))))
;; Propose the user to select a variant among those supported by the
@ -80,10 +105,11 @@ names of the selected keyboard layout and variant."
(variants (x11-keymap-layout-variants layout)))
;; Return #f if the layout does not have any variant.
(and (not (null? variants))
(run-variant-page variants
(lambda (variant)
(x11-keymap-variant-description
variant))))))))))
(run-variant-page
(sort-variants variants)
(lambda (variant)
(x11-keymap-variant-description
variant))))))))))
(define (format-result result)
(let ((layout (x11-keymap-layout-name