aboutsummaryrefslogtreecommitdiff
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
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.
-rw-r--r--debian/changelog6
-rw-r--r--src/status-service.c35
2 files changed, 36 insertions, 5 deletions
diff --git a/debian/changelog b/debian/changelog
index b922989..17d8164 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,9 @@
+indicator-sus (0.1~ppa4~statusshuffle2) UNRELEASED; urgency=low
+
+ * Better usage of the names.
+
+ -- Ted Gould <ted@ubuntu.com> Fri, 07 Aug 2009 21:42:19 +0100
+
indicator-sus (0.1~ppa4~statusshuffle1) karmic; urgency=low
* Merging in status shuffle branch to package it.
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");