[gnome-flashback] libend-session-dialog: Fall back to real name if user name is empty



commit b144ad208375132a308705e55eacc6d6f7daad9e
Author: Balló György <ballogyor gmail com>
Date:   Sat Oct 18 00:25:39 2014 +0200

    libend-session-dialog: Fall back to real name if user name is empty

 .../flashback-inhibit-dialog.c                     |   20 +++++++++++++++++++-
 1 files changed, 19 insertions(+), 1 deletions(-)
---
diff --git a/gnome-flashback/libend-session-dialog/flashback-inhibit-dialog.c 
b/gnome-flashback/libend-session-dialog/flashback-inhibit-dialog.c
index c6d613f..64eefeb 100644
--- a/gnome-flashback/libend-session-dialog/flashback-inhibit-dialog.c
+++ b/gnome-flashback/libend-session-dialog/flashback-inhibit-dialog.c
@@ -295,6 +295,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)
 {
@@ -329,7 +347,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");


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