Unverified Commit 0e8e963d authored by Ludovic Courtès's avatar Ludovic Courtès
Browse files

installer: User accounts can now have a "real name."

* gnu/installer/newt/user.scm (run-user-add-page): Add #:real-name.  Add
a label and entry for the real name and initialize the 'real-name' field
of the <user> record.
* gnu/installer/final.scm (create-user-database): Set the 'comment'
field of the <user-account> record.
parent 43c1c44a
......@@ -71,6 +71,7 @@ (define root?
(string=? "root" (user-name user)))
(sys:user-account (name (user-name user))
(comment (user-real-name user))
(group "users")
(uid (if root? 0 #f))
(home-directory
......
......@@ -29,14 +29,17 @@ (define-module (gnu installer newt user)
#:use-module (srfi srfi-26)
#:export (run-user-page))
(define* (run-user-add-page #:key (name "") (home-directory ""))
"Run a form to enter the user name, home directory, and password. Use NAME
and HOME-DIRECTORY as the initial values in the form."
(define* (run-user-add-page #:key (name "") (real-name "")
(home-directory ""))
"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))
(let* ((label-name
(make-label -1 -1 (pad-label (G_ "Name"))))
(label-real-name
(make-label -1 -1 (pad-label (G_ "Real name"))))
(label-home-directory
(make-label -1 -1 (pad-label (G_ "Home directory"))))
(label-password
......@@ -44,11 +47,13 @@ (define (pad-label label)
(entry-width 30)
(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))
(entry-password (make-entry -1 -1 entry-width
#:flags FLAG-PASSWORD))
(entry-grid (make-grid 3 4))
(entry-grid (make-grid 2 5))
(button-grid (make-grid 1 1))
(ok-button (make-button -1 -1 (G_ "OK")))
(grid (make-grid 1 2))
......@@ -59,10 +64,12 @@ (define (pad-label label)
(set-entry-grid-field 0 0 label-name)
(set-entry-grid-field 1 0 entry-name)
(set-entry-grid-field 0 1 label-home-directory)
(set-entry-grid-field 1 1 entry-home-directory)
(set-entry-grid-field 0 2 label-password)
(set-entry-grid-field 1 2 entry-password)
(set-entry-grid-field 0 1 label-real-name)
(set-entry-grid-field 1 1 entry-real-name)
(set-entry-grid-field 0 2 label-home-directory)
(set-entry-grid-field 1 2 entry-home-directory)
(set-entry-grid-field 0 3 label-password)
(set-entry-grid-field 1 3 entry-password)
(set-grid-field button-grid 0 0 GRID-ELEMENT-COMPONENT ok-button)
......@@ -70,11 +77,17 @@ (define (pad-label label)
entry-name
(lambda (component)
(set-entry-text entry-home-directory
(string-append "/home/" (entry-value entry-name)))))
(string-append "/home/" (entry-value entry-name)))
(when (string-null? (entry-value entry-real-name))
(set-entry-text entry-real-name
(string-titlecase (entry-value entry-name))))))
(add-components-to-form form
label-name label-home-directory label-password
entry-name entry-home-directory entry-password
label-name label-real-name
label-home-directory label-password
entry-name entry-real-name
entry-home-directory entry-password
ok-button)
(make-wrapped-grid-window (vertically-stacked-grid
......@@ -94,6 +107,7 @@ (define (pad-label label)
(cond
((components=? argument ok-button)
(let ((name (entry-value entry-name))
(real-name (entry-value entry-real-name))
(home-directory (entry-value entry-home-directory))
(password (entry-value entry-password)))
(if (or (string=? name "")
......@@ -103,12 +117,14 @@ (define (pad-label label)
(run-user-add-page))
(user
(name name)
(real-name real-name)
(home-directory home-directory)
(password
(confirm-password password
(lambda ()
(run-user-add-page
#:name name
#:real-name real-name
#:home-directory
home-directory)))))))))))
(lambda ()
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment