aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorTed Gould <ted@canonical.com>2009-08-07 21:42:37 +0100
committerTed Gould <ted@canonical.com>2009-08-07 21:42:37 +0100
commitf6e4e6e588d1164798e9d9a27cab63893a817771 (patch)
treefdc9237189da1065703360d11a804536c875938e /src
parent7ddcb5fb48cf5ff6bc8ae8f8e2c98b249182e2bc (diff)
parent848e09b4d35f6609c4deaf1298c8b4360ed15a22 (diff)
downloadayatana-indicator-session-f6e4e6e588d1164798e9d9a27cab63893a817771.tar.gz
ayatana-indicator-session-f6e4e6e588d1164798e9d9a27cab63893a817771.tar.bz2
ayatana-indicator-session-f6e4e6e588d1164798e9d9a27cab63893a817771.zip
Better usage of the names.
Diffstat (limited to 'src')
-rw-r--r--src/status-service.c35
1 files changed, 30 insertions, 5 deletions
diff --git a/src/status-service.c b/src/status-service.c
index 1bd33e9..a9274ce 100644
--- a/src/status-service.c
+++ b/src/status-service.c
@@ -1,4 +1,7 @@
+#include <sys/types.h>
+#include <pwd.h>
+
#include <glib/gi18n.h>
#include <dbus/dbus-glib.h>
@@ -41,7 +44,6 @@ static const gchar * status_icons[STATUS_PROVIDER_STATUS_LAST] = {
static DbusmenuMenuitem * root_menuitem = NULL;
static DbusmenuMenuitem * status_menuitem = NULL;
static GMainLoop * mainloop = NULL;
-static gchar * whoami = "ted";
static StatusServiceDbus * dbus_interface = NULL;
/* A fun little function to actually lock the screen. If,
@@ -95,16 +97,39 @@ build_providers (gpointer data)
return FALSE;
}
+static void
+build_user_item (DbusmenuMenuitem * root)
+{
+ struct passwd * pwd = NULL;
+
+ pwd = getpwuid(getuid());
+
+ if (pwd != NULL && pwd->pw_gecos != NULL) {
+ gchar * name = g_strdup(pwd->pw_gecos);
+ gchar * walker = name;
+ while (*walker != '\0' && *walker != ',') { walker++; }
+ *walker = '\0';
+
+ DbusmenuMenuitem * useritem = dbusmenu_menuitem_new();
+ dbusmenu_menuitem_property_set(useritem, "label", name);
+ dbusmenu_menuitem_property_set(useritem, "sensitive", "false");
+ dbusmenu_menuitem_child_append(root, useritem);
+
+ g_free(name);
+ } else {
+ g_debug("PWD: %s", (pwd == NULL ? "(pwd null)" : (pwd->pw_gecos == NULL ? "(gecos null)" : pwd->pw_gecos)));
+ }
+
+ return;
+}
+
static gboolean
build_menu (gpointer data)
{
DbusmenuMenuitem * root = DBUSMENU_MENUITEM(data);
g_return_val_if_fail(root != NULL, FALSE);
- DbusmenuMenuitem * useritem = dbusmenu_menuitem_new();
- dbusmenu_menuitem_property_set(useritem, "label", whoami);
- dbusmenu_menuitem_property_set(useritem, "sensitive", "false");
- dbusmenu_menuitem_child_append(root, useritem);
+ build_user_item(root);
status_menuitem = dbusmenu_menuitem_new();
dbusmenu_menuitem_property_set(status_menuitem, "label", "Status");