[gnome-control-center/T20818: 30/54] user-accounts: Rearrange choice of default usernames



commit d7129b31c50a1706a5593c79c18d9ed53ac875df
Author: Michael Catanzaro <mcatanzaro igalia com>
Date:   Mon May 16 14:00:01 2016 -0500

    user-accounts: Rearrange choice of default usernames
    
    Let's use the user's first name by default. Based on Juan's changes to
    gnome-initial-setup.
    https://phabricator.endlessm.com/T3597

 panels/user-accounts/um-utils.c |   55 +++++++++++++++++++--------------------
 1 files changed, 27 insertions(+), 28 deletions(-)
---
diff --git a/panels/user-accounts/um-utils.c b/panels/user-accounts/um-utils.c
index b54e233..6225189 100644
--- a/panels/user-accounts/um-utils.c
+++ b/panels/user-accounts/um-utils.c
@@ -570,7 +570,6 @@ generate_username_choices (const gchar  *name,
         words1 = g_strsplit_set (stripped_name, " ", -1);
         len = g_strv_length (words1);
 
-        /* The default item is a concatenation of all words without ? */
         item0 = g_string_sized_new (strlen (stripped_name));
 
         g_free (ascii_name);
@@ -665,24 +664,42 @@ generate_username_choices (const gchar  *name,
 
         items = g_hash_table_new (g_str_hash, g_str_equal);
 
-        in_use = is_username_used (item0->str);
-        if (!in_use && !g_ascii_isdigit (item0->str[0])) {
+        /* add the first word */
+        in_use = is_username_used (first_word->str);
+        if (!in_use && !g_ascii_isdigit (first_word->str[0]) &&
+            !g_hash_table_lookup (items, first_word->str)) {
                 gtk_list_store_append (store, &iter);
-                gtk_list_store_set (store, &iter, 0, item0->str, -1);
-                g_hash_table_insert (items, item0->str, item0->str);
+                gtk_list_store_set (store, &iter, 0, first_word->str, -1);
+                g_hash_table_insert (items, first_word->str, first_word->str);
         }
 
-        in_use = is_username_used (item1->str);
-        same_as_initial = (g_strcmp0 (item0->str, item1->str) == 0);
-        if (!same_as_initial && nwords2 > 0 && !in_use && !g_ascii_isdigit (item1->str[0])) {
+        /* add the last word */
+        in_use = is_username_used (last_word->str);
+        if (!in_use && !g_ascii_isdigit (last_word->str[0]) &&
+            !g_hash_table_lookup (items, last_word->str)) {
                 gtk_list_store_append (store, &iter);
-                gtk_list_store_set (store, &iter, 0, item1->str, -1);
-                g_hash_table_insert (items, item1->str, item1->str);
+                gtk_list_store_set (store, &iter, 0, last_word->str, -1);
+                g_hash_table_insert (items, last_word->str, last_word->str);
         }
 
         /* if there's only one word, would be the same as item1 */
         if (nwords2 > 1) {
                 /* add other items */
+                in_use = is_username_used (item0->str);
+                if (!in_use && !g_ascii_isdigit (item0->str[0])) {
+                        gtk_list_store_append (store, &iter);
+                        gtk_list_store_set (store, &iter, 0, item0->str, -1);
+                        g_hash_table_insert (items, item0->str, item0->str);
+                }
+
+                in_use = is_username_used (item1->str);
+                same_as_initial = (g_strcmp0 (item0->str, item1->str) == 0);
+                if (!same_as_initial && nwords2 > 0 && !in_use && !g_ascii_isdigit (item1->str[0])) {
+                        gtk_list_store_append (store, &iter);
+                        gtk_list_store_set (store, &iter, 0, item1->str, -1);
+                        g_hash_table_insert (items, item1->str, item1->str);
+                }
+
                 in_use = is_username_used (item2->str);
                 if (!in_use && !g_ascii_isdigit (item2->str[0]) &&
                     !g_hash_table_lookup (items, item2->str)) {
@@ -706,24 +723,6 @@ generate_username_choices (const gchar  *name,
                         gtk_list_store_set (store, &iter, 0, item4->str, -1);
                         g_hash_table_insert (items, item4->str, item4->str);
                 }
-
-                /* add the last word */
-                in_use = is_username_used (last_word->str);
-                if (!in_use && !g_ascii_isdigit (last_word->str[0]) &&
-                    !g_hash_table_lookup (items, last_word->str)) {
-                        gtk_list_store_append (store, &iter);
-                        gtk_list_store_set (store, &iter, 0, last_word->str, -1);
-                        g_hash_table_insert (items, last_word->str, last_word->str);
-                }
-
-                /* ...and the first one */
-                in_use = is_username_used (first_word->str);
-                if (!in_use && !g_ascii_isdigit (first_word->str[0]) &&
-                    !g_hash_table_lookup (items, first_word->str)) {
-                        gtk_list_store_append (store, &iter);
-                        gtk_list_store_set (store, &iter, 0, first_word->str, -1);
-                        g_hash_table_insert (items, first_word->str, first_word->str);
-                }
         }
 
         g_hash_table_destroy (items);


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