diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/service.c | 19 |
1 files changed, 14 insertions, 5 deletions
diff --git a/src/service.c b/src/service.c index 445f1af..9fda2f1 100644 --- a/src/service.c +++ b/src/service.c @@ -295,12 +295,21 @@ get_user_label (const IndicatorSessionUser * user) { const char * c; - /* If blank or whitespace, use username instead */ - for (c = user->real_name; *c != '\0' && g_ascii_isspace (*c); c++); - if (*c == '\0') - return user->user_name; + /* if real_name exists and is printable, use it */ + c = user->real_name; + if ((c != NULL) && g_utf8_validate(c, -1, NULL)) + { + while (*c != '\0') + { + if (g_unichar_isgraph(g_utf8_get_char(c))) + return user->real_name; + + c = g_utf8_next_char(c); + } + } - return user->real_name; + /* otherwise, use this as a fallback */ + return user->user_name; } static const char * |