From 4df640b8710d9cfad20f018cb310ff95abefbbc4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ball=C3=B3=20Gy=C3=B6rgy?= Date: Sat, 18 Oct 2014 00:25:39 +0200 Subject: [PATCH 2/2] libend-session-dialog: Fall back to real name if user name is empty --- .../libend-session-dialog/flashback-inhibit-dialog.c | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/gnome-flashback/libend-session-dialog/flashback-inhibit-dialog.c b/gnome-flashback/libend-session-dialog/flashback-inhibit-dialog.c index 2942605..81b7877 100644 --- a/gnome-flashback/libend-session-dialog/flashback-inhibit-dialog.c +++ b/gnome-flashback/libend-session-dialog/flashback-inhibit-dialog.c @@ -304,6 +304,24 @@ model_is_empty (GtkTreeModel *model) return gtk_tree_model_iter_n_children (model, NULL) == 0; } +char * +get_user_name (void) +{ + char *name; + + name = g_locale_to_utf8 (g_get_real_name (), -1, NULL, NULL, NULL); + + if (name == NULL || name[0] == '\0' || g_strcmp0 (name, "Unknown") == 0) { + g_free (name); + name = g_locale_to_utf8 (g_get_user_name (), -1 , NULL, NULL, NULL); + } + + if (!name) + name = g_strdup (g_get_user_name ()); + + return name; +} + static void update_dialog_text (FlashbackInhibitDialog *dialog) { @@ -338,7 +356,7 @@ update_dialog_text (FlashbackInhibitDialog *dialog) tmp = ngettext ("%s will be logged out automatically in %d second.", "%s will be logged out automatically in %d seconds.", seconds); - description = g_strdup_printf (tmp, g_get_real_name (), seconds); + description = g_strdup_printf (tmp, get_user_name (), seconds); } } else if (dialog->priv->action == FLASHBACK_LOGOUT_ACTION_SHUTDOWN) { title = _("Power Off"); -- 2.1.2