[gnome-initial-setup] um-utils: Sync up with gnome-control-center



commit 55d5a148c19cc599d73914da547be43352d162a5
Author: Michael Wood <michael g wood intel com>
Date:   Mon May 20 10:30:30 2013 +0100

    um-utils: Sync up with gnome-control-center
    
    gnome-control-center 11382d24 (Chris Cummins)
    gnome-control-center 2714908b (Robert Roth)
    
    https://bugzilla.gnome.org/show_bug.cgi?id=700702

 gnome-initial-setup/pages/account/um-utils.c |   28 ++++++++++++++++++++++---
 1 files changed, 24 insertions(+), 4 deletions(-)
---
diff --git a/gnome-initial-setup/pages/account/um-utils.c b/gnome-initial-setup/pages/account/um-utils.c
index 7d9fafe..0ee5920 100644
--- a/gnome-initial-setup/pages/account/um-utils.c
+++ b/gnome-initial-setup/pages/account/um-utils.c
@@ -81,11 +81,30 @@ is_username_used (const gchar *username)
 gboolean
 is_valid_name (const gchar *name)
 {
-        gboolean valid;
+        gboolean is_empty = TRUE;
+        const gchar *c;
 
-        valid = (strlen (name) > 0);
+        /* Valid names must contain:
+         *   1) at least one character.
+         *   2) at least one non-"space" character.
+         */
+        for (c = name; *c; c++) {
+                gunichar unichar;
 
-        return valid;
+                unichar = g_utf8_get_char_validated (c, -1);
+
+                /* Partial UTF-8 sequence or end of string */
+                if (unichar == (gunichar) -1 || unichar == (gunichar) -2)
+                        break;
+
+                /* Check for non-space character */
+                if (!g_unichar_isspace (unichar)) {
+                        is_empty = FALSE;
+                        break;
+                }
+        }
+
+        return !is_empty;
 }
 
 gboolean
@@ -136,7 +155,7 @@ is_valid_username (const gchar *username, gchar **tip)
                         *tip = g_strdup (_("The username cannot start with a '-'"));
                 }
                 else {
-                        *tip = g_strdup (_("The username must consist of:\n"
+                        *tip = g_strdup (_("The username must only consist of:\n"
                                           " \xe2\x9e\xa3 letters from the English alphabet\n"
                                           " \xe2\x9e\xa3 digits\n"
                                           " \xe2\x9e\xa3 any of the characters '.', '-' and '_'"));
@@ -307,6 +326,7 @@ generate_username_choices (const gchar  *name,
                 gtk_list_store_set (store, &iter, 0, item1->str, -1);
                 g_hash_table_insert (items, item1->str, item1->str);
         }
+
         /* if there's only one word, would be the same as item1 */
         if (nwords2 > 1) {
                 /* add other items */


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