aboutsummaryrefslogtreecommitdiff
path: root/gnu
diff options
context:
space:
mode:
authorMathieu Othacehe <m.othacehe@gmail.com>2019-01-12 18:26:11 +0100
committerLudovic Courtès <ludo@gnu.org>2019-01-17 14:04:27 +0100
commitcb614af01146d9d4be40e705f71db4efcbe684e7 (patch)
tree694d5aa5d137a82f8ebface2778a13fba20dd38f /gnu
parent513914b59f0a89eb559f3c894d188a4cf98ecdc1 (diff)
downloadgnu-guix-cb614af01146d9d4be40e705f71db4efcbe684e7.tar
gnu-guix-cb614af01146d9d4be40e705f71db4efcbe684e7.tar.gz
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.
Diffstat (limited to 'gnu')
-rw-r--r--gnu/installer/newt/keymap.scm36
1 files changed, 31 insertions, 5 deletions
diff --git a/gnu/installer/newt/keymap.scm b/gnu/installer/newt/keymap.scm
index 55a0aa6bf9..6211af2bc5 100644
--- a/gnu/installer/newt/keymap.scm
+++ b/gnu/installer/newt/keymap.scm
@@ -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