| 1 | |
| 2 | |
| 3 | |
| 4 | |
| 5 | |
| 6 | |
| 7 | |
| 8 | |
| 9 | |
| 10 | |
| 11 | |
| 12 | |
| 13 | |
| 14 | |
| 15 | |
| 16 | |
| 17 | |
| 18 |
|
| 19 | (define-module (gnu installer newt timezone)
|
| 20 | #:use-module (gnu installer steps)
|
| 21 | #:use-module (gnu installer timezone)
|
| 22 | #:use-module (gnu installer newt page)
|
| 23 | #:use-module (guix i18n)
|
| 24 | #:use-module (srfi srfi-1)
|
| 25 | #:use-module (srfi srfi-26)
|
| 26 | #:use-module (srfi srfi-34)
|
| 27 | #:use-module (srfi srfi-35)
|
| 28 | #:use-module (ice-9 match)
|
| 29 | #:use-module (ice-9 receive)
|
| 30 | #:use-module (newt)
|
| 31 | #:export (run-timezone-page))
|
| 32 |
|
| 33 | |
| 34 | (define info-textbox-width (make-parameter 40))
|
| 35 |
|
| 36 | (define (fill-timezones listbox timezones)
|
| 37 | "Fill the given LISTBOX with TIMEZONES. Return an association list
|
| 38 | correlating listbox keys with timezones."
|
| 39 | (map (lambda (timezone)
|
| 40 | (let ((key (append-entry-to-listbox listbox timezone)))
|
| 41 | (cons key timezone)))
|
| 42 | timezones))
|
| 43 |
|
| 44 | (define (run-timezone-page zonetab)
|
| 45 | "Run a page displaying available timezones, grouped by regions. The user is
|
| 46 | invited to select a timezone. The selected timezone, under Posix format is
|
| 47 | returned."
|
| 48 | (define (all-but-last list)
|
| 49 | (reverse (cdr (reverse list))))
|
| 50 |
|
| 51 | (define (run-page timezone-tree)
|
| 52 | (define (loop path)
|
| 53 | |
| 54 | |
| 55 | |
| 56 | (let ((timezones (locate-children timezone-tree path)))
|
| 57 | (run-listbox-selection-page
|
| 58 | #:title (G_ "Timezone")
|
| 59 | #:info-text (G_ "Please select a timezone.")
|
| 60 | #:listbox-items timezones
|
| 61 | #:listbox-item->text (cut gettext <> "iso_3166-1")
|
| 62 | #:button-text (if (null? path)
|
| 63 | (G_ "Exit")
|
| 64 | (G_ "Back"))
|
| 65 | #:button-callback-procedure
|
| 66 | (if (null? path)
|
| 67 | (lambda _
|
| 68 | (abort-to-prompt 'installer-step 'abort))
|
| 69 | (lambda _
|
| 70 | (loop (all-but-last path))))
|
| 71 | #:listbox-callback-procedure
|
| 72 | (lambda (timezone)
|
| 73 | (let* ((timezone* (append path (list timezone)))
|
| 74 | (tz (timezone->posix-tz timezone*)))
|
| 75 | (if (timezone-has-child? timezone-tree timezone*)
|
| 76 | (loop timezone*)
|
| 77 | tz))))))
|
| 78 | (loop '()))
|
| 79 |
|
| 80 | (let ((timezone-tree (zonetab->timezone-tree zonetab)))
|
| 81 | (run-page timezone-tree)))
|