guix-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


From: guix-commits
Subject: 10/12: installer: User accounts can now have a "real name."
Date: Sun, 28 Apr 2019 16:57:17 -0400 (EDT)

civodul pushed a commit to branch master
in repository guix.

commit 0e8e963d73e61c7666f9ec4efa98c1a277c72af9
Author: Ludovic Court├Ęs <address@hidden>
Date:   Sun Apr 28 22:28:51 2019 +0200

    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.
---
 gnu/installer/final.scm     |  1 +
 gnu/installer/newt/user.scm | 38 +++++++++++++++++++++++++++-----------
 2 files changed, 28 insertions(+), 11 deletions(-)

diff --git a/gnu/installer/final.scm b/gnu/installer/final.scm
index c41670c..855b640 100644
--- a/gnu/installer/final.scm
+++ b/gnu/installer/final.scm
@@ -71,6 +71,7 @@ USERS."
              (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
diff --git a/gnu/installer/newt/user.scm b/gnu/installer/newt/user.scm
index 617d2d0..7c646c1 100644
--- a/gnu/installer/newt/user.scm
+++ b/gnu/installer/newt/user.scm
@@ -29,14 +29,17 @@
   #: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 @@ and HOME-DIRECTORY as the initial values in the form."
          (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 @@ and HOME-DIRECTORY as the initial values in the form."
 
     (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 @@ and HOME-DIRECTORY as the initial values in the form."
      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 @@ and HOME-DIRECTORY as the initial values in the form."
               (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 @@ and HOME-DIRECTORY as the initial values in the form."
                         (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 ()



reply via email to

[Prev in Thread] Current Thread [Next in Thread]