aboutsummaryrefslogtreecommitdiff
path: root/src/status-service.c
diff options
context:
space:
mode:
authorTed Gould <ted@canonical.com>2009-08-07 21:54:26 +0100
committerTed Gould <ted@canonical.com>2009-08-07 21:54:26 +0100
commita52ff08217de74771d2721b6e3a3707d43fbe780 (patch)
tree2dd8c1e9c43293900548fd823bfad28652c9dfd7 /src/status-service.c
parent9b7303cd469357b2d17cb87313d83d47ffc16470 (diff)
parent848e09b4d35f6609c4deaf1298c8b4360ed15a22 (diff)
downloadayatana-indicator-session-a52ff08217de74771d2721b6e3a3707d43fbe780.tar.gz
ayatana-indicator-session-a52ff08217de74771d2721b6e3a3707d43fbe780.tar.bz2
ayatana-indicator-session-a52ff08217de74771d2721b6e3a3707d43fbe780.zip
Merging the branch for better status service.
Diffstat (limited to 'src/status-service.c')
-rw-r--r--src/status-service.c41
1 files changed, 40 insertions, 1 deletions
diff --git a/src/status-service.c b/src/status-service.c
index dbb597c..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>
@@ -39,7 +42,9 @@ static const gchar * status_icons[STATUS_PROVIDER_STATUS_LAST] = {
static DbusmenuMenuitem * root_menuitem = NULL;
+static DbusmenuMenuitem * status_menuitem = NULL;
static GMainLoop * mainloop = NULL;
+static StatusServiceDbus * dbus_interface = NULL;
/* A fun little function to actually lock the screen. If,
that's what you want, let's do it! */
@@ -92,12 +97,44 @@ 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);
+ build_user_item(root);
+
+ status_menuitem = dbusmenu_menuitem_new();
+ dbusmenu_menuitem_property_set(status_menuitem, "label", "Status");
+ dbusmenu_menuitem_child_append(root, status_menuitem);
+
StatusProviderStatus i;
for (i = STATUS_PROVIDER_STATUS_ONLINE; i < STATUS_PROVIDER_STATUS_LAST; i++) {
DbusmenuMenuitem * mi = dbusmenu_menuitem_new();
@@ -106,7 +143,7 @@ build_menu (gpointer data)
dbusmenu_menuitem_property_set(mi, "icon", status_icons[i]);
g_signal_connect(G_OBJECT(mi), DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED, G_CALLBACK(status_menu_click), GINT_TO_POINTER(i));
- dbusmenu_menuitem_child_append(root, mi);
+ dbusmenu_menuitem_child_append(status_menuitem, mi);
g_debug("Built %s", status_strings[i]);
}
@@ -147,6 +184,8 @@ main (int argc, char ** argv)
g_idle_add(build_menu, root_menuitem);
+ dbus_interface = g_object_new(STATUS_SERVICE_DBUS_TYPE, NULL);
+
mainloop = g_main_loop_new(NULL, FALSE);
g_main_loop_run(mainloop);