[gnome-initial-setup/fix-blank-avatar] Change generated avatar for empty name
- From: Philip Chimento <pchimento src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-initial-setup/fix-blank-avatar] Change generated avatar for empty name
- Date: Thu, 8 Aug 2019 17:53:09 +0000 (UTC)
commit b4f07c05e34ad35c9f919ba74dda8a5c5790a10f
Author: Philip Chimento <philip endlessm com>
Date: Mon Aug 5 17:41:48 2019 -0700
Change generated avatar for empty name
The default generated avatar consisting of a white circle looks broken
at first sight. We special-case an empty name to be a neutral "bust in
silhouette" character on an orange background, to show that the circle
contains an avatar and hopefully make it seem more clickable.
gnome-initial-setup/pages/account/um-utils.c | 13 +++++++++----
1 file changed, 9 insertions(+), 4 deletions(-)
---
diff --git a/gnome-initial-setup/pages/account/um-utils.c b/gnome-initial-setup/pages/account/um-utils.c
index 5fd215e..7cd63bb 100644
--- a/gnome-initial-setup/pages/account/um-utils.c
+++ b/gnome-initial-setup/pages/account/um-utils.c
@@ -487,13 +487,18 @@ extract_initials_from_name (const gchar *name)
gchar *normalized;
gunichar unichar;
+ if (name == NULL || name[0] == '\0') {
+ g_string_free (initials, TRUE);
+ return g_strdup ("\U0001F464"); /* U+1F464 "bust in silhouette" */
+ }
+
p = g_utf8_strup (name, -1);
normalized = g_utf8_normalize (g_strstrip (p), -1, G_NORMALIZE_DEFAULT_COMPOSE);
g_clear_pointer (&p, g_free);
if (normalized == NULL) {
g_free (normalized);
-
- return NULL;
+ g_string_free (initials, TRUE);
+ return g_strdup ("\U0001F464"); /* U+1F464 "bust in silhouette" */
}
unichar = g_utf8_get_char (normalized);
@@ -547,12 +552,12 @@ get_color_for_name (const gchar *name)
{ 99, 69, 44 }
};
- GdkRGBA color = { 255, 255, 255, 1.0 };
+ GdkRGBA color = { 230, 97, 0, 1.0 }; /* Orange 4 */
guint hash;
gint number_of_colors;
gint idx;
- if (name == NULL || strlen (name) == 0)
+ if (name == NULL || name[0] == '\0')
return color;
hash = g_str_hash (name);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]