aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/dbus-shared-names.h1
-rw-r--r--src/indicator-sus.c5
-rw-r--r--src/status-service-dbus.c106
-rw-r--r--src/status-service-dbus.h5
-rw-r--r--src/status-service.c41
-rw-r--r--src/status-service.xml2
6 files changed, 143 insertions, 17 deletions
diff --git a/src/dbus-shared-names.h b/src/dbus-shared-names.h
index bd2f8ab..516755d 100644
--- a/src/dbus-shared-names.h
+++ b/src/dbus-shared-names.h
@@ -4,6 +4,7 @@
#define INDICATOR_STATUS_DBUS_NAME "org.ayatana.indicator.status"
#define INDICATOR_STATUS_DBUS_OBJECT "/org/ayatana/indicator/status"
+#define INDICATOR_STATUS_SERVICE_DBUS_OBJECT "/org/ayatana/indicator/status-service"
#define INDICATOR_USERS_DBUS_NAME "org.ayatana.indicator.users"
#define INDICATOR_USERS_DBUS_OBJECT "/org/ayatana/indicator/users"
diff --git a/src/indicator-sus.c b/src/indicator-sus.c
index 18b6c44..9d1c66c 100644
--- a/src/indicator-sus.c
+++ b/src/indicator-sus.c
@@ -41,7 +41,7 @@ static guint session_menu_pos_offset (void);
GtkLabel *
get_label (void)
{
- GtkLabel * returnval = GTK_LABEL(gtk_label_new("Ted Gould"));
+ GtkLabel * returnval = GTK_LABEL(gtk_label_new(g_get_user_name()));
gtk_widget_show(GTK_WIDGET(returnval));
return returnval;
}
@@ -49,7 +49,8 @@ get_label (void)
GtkImage *
get_icon (void)
{
- return NULL;
+ GtkImage * image = GTK_IMAGE(gtk_image_new_from_icon_name("user-offline", GTK_ICON_SIZE_MENU));
+ return image;
}
static void
diff --git a/src/status-service-dbus.c b/src/status-service-dbus.c
index 9ffc6aa..5d4ba0a 100644
--- a/src/status-service-dbus.c
+++ b/src/status-service-dbus.c
@@ -2,18 +2,41 @@
#include "config.h"
#endif
+#include <dbus/dbus-glib.h>
+
+#include "dbus-shared-names.h"
#include "status-service-dbus.h"
static void status_service_dbus_class_init (StatusServiceDbusClass *klass);
static void status_service_dbus_init (StatusServiceDbus *self);
static void status_service_dbus_dispose (GObject *object);
static void status_service_dbus_finalize (GObject *object);
-static void _status_service_server_watch (void);
-static void _status_service_server_status_icons (void);
-static void _status_service_server_pretty_user_name (void);
+static gboolean _status_service_server_watch (StatusServiceDbus * service, GError ** error);
+static gboolean _status_service_server_status_icons (StatusServiceDbus * service, GArray * array, GError ** error);
+static gboolean _status_service_server_pretty_user_name (StatusServiceDbus * service, gchar ** username, GError ** error);
#include "status-service-server.h"
+/* Private */
+typedef struct _StatusServiceDbusPrivate StatusServiceDbusPrivate;
+struct _StatusServiceDbusPrivate
+{
+ gchar * name;
+};
+
+#define STATUS_SERVICE_DBUS_GET_PRIVATE(o) \
+ (G_TYPE_INSTANCE_GET_PRIVATE ((o), STATUS_SERVICE_DBUS_TYPE, StatusServiceDbusPrivate))
+
+/* Signals */
+enum {
+ USER_CHANGED,
+ STATUS_ICONS_CHANGED,
+ LAST_SIGNAL
+};
+
+static guint signals[LAST_SIGNAL] = { 0 };
+
+/* GObject Boilerplate */
G_DEFINE_TYPE (StatusServiceDbus, status_service_dbus, G_TYPE_OBJECT);
static void
@@ -21,8 +44,46 @@ status_service_dbus_class_init (StatusServiceDbusClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
+ g_type_class_add_private (object_class, sizeof(StatusServiceDbusPrivate));
+
object_class->dispose = status_service_dbus_dispose;
object_class->finalize = status_service_dbus_finalize;
+
+ /**
+ StatusServiceDbus::user-changed:
+ @arg0: The #StatusServiceDbus object.
+ @arg1: The place to put the new user name
+
+ Signals that the user name has changed and gives the
+ new user name.
+ */
+ signals[USER_CHANGED] = g_signal_new("user-changed",
+ G_TYPE_FROM_CLASS(klass),
+ G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET(StatusServiceDbusClass, user_changed),
+ NULL, NULL,
+ g_cclosure_marshal_VOID__POINTER,
+ G_TYPE_NONE, 1, G_TYPE_POINTER);
+
+ /**
+ StatusServiceDbus::status-icons-changed:
+ @arg0: The #StatusServiceDbus object.
+ @arg1: The list of icon names representing the statuses in
+ the order they should be displayed. Left to right.
+
+ Signals that the user status set has changed and that
+ new icons may need to be loaded. The list of icons will
+ always be complete.
+ */
+ signals[STATUS_ICONS_CHANGED] = g_signal_new("status-icons-changed",
+ G_TYPE_FROM_CLASS(klass),
+ G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET(StatusServiceDbusClass, status_icons_changed),
+ NULL, NULL,
+ g_cclosure_marshal_VOID__POINTER,
+ G_TYPE_NONE, 1, G_TYPE_POINTER);
+
+ dbus_g_object_type_install_info(STATUS_SERVICE_DBUS_TYPE, &dbus_glib__status_service_server_object_info);
return;
}
@@ -31,6 +92,14 @@ static void
status_service_dbus_init (StatusServiceDbus *self)
{
+ DBusGConnection * connection = dbus_g_bus_get(DBUS_BUS_SESSION, NULL);
+ dbus_g_connection_register_g_object(connection,
+ INDICATOR_STATUS_SERVICE_DBUS_OBJECT,
+ G_OBJECT(self));
+
+ StatusServiceDbusPrivate * priv = STATUS_SERVICE_DBUS_GET_PRIVATE(self);
+ priv->name = "test";
+
return;
}
@@ -50,23 +119,34 @@ status_service_dbus_finalize (GObject *object)
return;
}
-static void
-_status_service_server_watch (void)
+static gboolean
+_status_service_server_watch (StatusServiceDbus * service, GError ** error)
{
- return;
+ return TRUE;
}
-static void
-_status_service_server_status_icons (void)
+static gboolean
+_status_service_server_status_icons (StatusServiceDbus * service, GArray * array, GError ** error)
{
- return;
+ return TRUE;
}
-static void
-_status_service_server_pretty_user_name (void)
+static gboolean
+_status_service_server_pretty_user_name (StatusServiceDbus * service, gchar ** username, GError ** error)
{
-
- return;
+ if (!IS_STATUS_SERVICE_DBUS(service)) {
+ g_warning("NO BAD EVIL!");
+ return FALSE;
+ }
+
+ StatusServiceDbusPrivate * priv = STATUS_SERVICE_DBUS_GET_PRIVATE(service);
+ if (priv->name == NULL) {
+ *username = g_strdup("");
+ } else {
+ *username = g_strdup(priv->name);
+ }
+
+ return TRUE;
}
diff --git a/src/status-service-dbus.h b/src/status-service-dbus.h
index 1805dc5..e320104 100644
--- a/src/status-service-dbus.h
+++ b/src/status-service-dbus.h
@@ -18,6 +18,11 @@ typedef struct _StatusServiceDbusClass StatusServiceDbusClass;
struct _StatusServiceDbusClass {
GObjectClass parent_class;
+
+ /* Signals */
+ gboolean (*user_changed) (StatusServiceDbus * self, gchar ** name, gpointer user_data);
+ gboolean (*status_icons_changed) (StatusServiceDbus * self, GArray ** icons, gpointer user_data);
+
};
struct _StatusServiceDbus {
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);
diff --git a/src/status-service.xml b/src/status-service.xml
index df10859..3807158 100644
--- a/src/status-service.xml
+++ b/src/status-service.xml
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<node name="/">
- <interface name="com.ubuntu.indicator.status">
+ <interface name="org.ayatana.indicator.status">
<!-- Methods -->
<method name="Watch">