From 82a2c8c680be1f63c982c7016dc7665773c8496e Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Thu, 6 Aug 2009 12:14:53 +0100 Subject: Status submenu --- src/status-service.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/status-service.c b/src/status-service.c index dbb597c..4e16788 100644 --- a/src/status-service.c +++ b/src/status-service.c @@ -39,6 +39,7 @@ static const gchar * status_icons[STATUS_PROVIDER_STATUS_LAST] = { static DbusmenuMenuitem * root_menuitem = NULL; +static DbusmenuMenuitem * status_menuitem = NULL; static GMainLoop * mainloop = NULL; /* A fun little function to actually lock the screen. If, @@ -98,6 +99,10 @@ build_menu (gpointer data) DbusmenuMenuitem * root = DBUSMENU_MENUITEM(data); g_return_val_if_fail(root != NULL, FALSE); + 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 +111,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]); } -- cgit v1.2.3 From aff047a23a15219933657f85311d858d6e458870 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Thu, 6 Aug 2009 12:27:39 +0100 Subject: Putting the user name in a menu label. --- src/status-service.c | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'src') diff --git a/src/status-service.c b/src/status-service.c index 4e16788..b804711 100644 --- a/src/status-service.c +++ b/src/status-service.c @@ -41,6 +41,7 @@ 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"; /* A fun little function to actually lock the screen. If, that's what you want, let's do it! */ @@ -99,6 +100,11 @@ 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); + status_menuitem = dbusmenu_menuitem_new(); dbusmenu_menuitem_property_set(status_menuitem, "label", "Status"); dbusmenu_menuitem_child_append(root, status_menuitem); -- cgit v1.2.3 From a253844a712ceb8f54cb3b6fa5b090ba0a216e19 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Thu, 6 Aug 2009 12:39:59 +0100 Subject: Something global to track all the DBus stuff. --- src/status-service.c | 3 +++ 1 file changed, 3 insertions(+) (limited to 'src') diff --git a/src/status-service.c b/src/status-service.c index b804711..1bd33e9 100644 --- a/src/status-service.c +++ b/src/status-service.c @@ -42,6 +42,7 @@ 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, that's what you want, let's do it! */ @@ -158,6 +159,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); -- cgit v1.2.3 From 8f96c69134921cad27e583d2c9197e48c5fbfa96 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Thu, 6 Aug 2009 12:56:12 +0100 Subject: Doing a registration and a connection to DBus --- src/status-service-dbus.c | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'src') diff --git a/src/status-service-dbus.c b/src/status-service-dbus.c index 9ffc6aa..5096bfe 100644 --- a/src/status-service-dbus.c +++ b/src/status-service-dbus.c @@ -2,6 +2,9 @@ #include "config.h" #endif +#include + +#include "dbus-shared-names.h" #include "status-service-dbus.h" static void status_service_dbus_class_init (StatusServiceDbusClass *klass); @@ -23,6 +26,8 @@ status_service_dbus_class_init (StatusServiceDbusClass *klass) object_class->dispose = status_service_dbus_dispose; object_class->finalize = status_service_dbus_finalize; + + dbus_g_object_type_install_info(STATUS_SERVICE_DBUS_TYPE, &dbus_glib__status_service_server_object_info); return; } @@ -31,6 +36,11 @@ 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_DBUS_OBJECT, + G_OBJECT(self)); + return; } -- cgit v1.2.3 From e988b52dbade0b020a5c58b13a67a43a17ac4293 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Thu, 6 Aug 2009 13:08:33 +0100 Subject: ayatana.org --- src/status-service.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') 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 @@ - + -- cgit v1.2.3 From 78afa2e5ac7a98282bae867b2b68612ad3a01cba Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Thu, 6 Aug 2009 15:22:47 +0100 Subject: Adding a couple of signals in here. --- src/status-service-dbus.c | 44 ++++++++++++++++++++++++++++++++++++++++++++ src/status-service-dbus.h | 5 +++++ 2 files changed, 49 insertions(+) (limited to 'src') diff --git a/src/status-service-dbus.c b/src/status-service-dbus.c index 5096bfe..24c164a 100644 --- a/src/status-service-dbus.c +++ b/src/status-service-dbus.c @@ -17,6 +17,16 @@ static void _status_service_server_pretty_user_name (void); #include "status-service-server.h" +/* 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 @@ -27,6 +37,40 @@ status_service_dbus_class_init (StatusServiceDbusClass *klass) 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; 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 { -- cgit v1.2.3 From 39ac4b97ba6657a1cf3151c211bf7367ecd17a02 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Thu, 6 Aug 2009 15:28:41 +0100 Subject: Getting a new object to remove an error. --- src/dbus-shared-names.h | 1 + src/status-service-dbus.c | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) (limited to 'src') 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/status-service-dbus.c b/src/status-service-dbus.c index 24c164a..d1ee662 100644 --- a/src/status-service-dbus.c +++ b/src/status-service-dbus.c @@ -82,7 +82,7 @@ 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_DBUS_OBJECT, + INDICATOR_STATUS_SERVICE_DBUS_OBJECT, G_OBJECT(self)); return; -- cgit v1.2.3 From 770f0349686e63af7d5ff01451e9d01eb62edbc4 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Thu, 6 Aug 2009 15:49:04 +0100 Subject: More and better prototypes --- src/status-service-dbus.c | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) (limited to 'src') diff --git a/src/status-service-dbus.c b/src/status-service-dbus.c index d1ee662..8dc8aea 100644 --- a/src/status-service-dbus.c +++ b/src/status-service-dbus.c @@ -11,9 +11,9 @@ 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" @@ -104,23 +104,23 @@ 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; + return TRUE; } -- cgit v1.2.3 From 5afcbe0b90e4005446087e49907f61ddcb9b900f Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Thu, 6 Aug 2009 16:17:40 +0100 Subject: Now we have privates. --- src/status-service-dbus.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'src') diff --git a/src/status-service-dbus.c b/src/status-service-dbus.c index 8dc8aea..d5a880a 100644 --- a/src/status-service-dbus.c +++ b/src/status-service-dbus.c @@ -17,6 +17,16 @@ static gboolean _status_service_server_pretty_user_name (StatusServiceDbus * ser #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, @@ -34,6 +44,8 @@ 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; @@ -85,6 +97,9 @@ status_service_dbus_init (StatusServiceDbus *self) INDICATOR_STATUS_SERVICE_DBUS_OBJECT, G_OBJECT(self)); + StatusServiceDbusPrivate * priv = STATUS_SERVICE_DBUS_GET_PRIVATE(self); + priv->name = NULL; + return; } -- cgit v1.2.3 From 04cc48ee124c9eb1668fa9b6447239855e781534 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Thu, 6 Aug 2009 17:49:49 +0100 Subject: Some dummy code to get a name --- src/status-service-dbus.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/status-service-dbus.c b/src/status-service-dbus.c index d5a880a..5d4ba0a 100644 --- a/src/status-service-dbus.c +++ b/src/status-service-dbus.c @@ -98,7 +98,7 @@ status_service_dbus_init (StatusServiceDbus *self) G_OBJECT(self)); StatusServiceDbusPrivate * priv = STATUS_SERVICE_DBUS_GET_PRIVATE(self); - priv->name = NULL; + priv->name = "test"; return; } @@ -136,6 +136,17 @@ _status_service_server_status_icons (StatusServiceDbus * service, GArray * array static gboolean _status_service_server_pretty_user_name (StatusServiceDbus * service, gchar ** username, GError ** error) { + 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; } -- cgit v1.2.3 From be90d5341e81d2fab644b9deddd121a5163c2ac6 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Fri, 7 Aug 2009 19:36:33 +0100 Subject: Using the user name --- src/indicator-sus.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/indicator-sus.c b/src/indicator-sus.c index 18b6c44..d1296e0 100644 --- a/src/indicator-sus.c +++ b/src/indicator-sus.c @@ -25,6 +25,7 @@ static GtkWidget * loading_item = NULL; static DBusGConnection * connection = NULL; static DBusGProxy * proxy = NULL; +static DBusGProxy * status_proxy = NULL; typedef enum { STATUS_SECTION, @@ -41,7 +42,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; } -- cgit v1.2.3 From 348bd323b895f5d1fd41a4b083e4b49b74717037 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Fri, 7 Aug 2009 19:37:37 +0100 Subject: Clean it up. --- src/indicator-sus.c | 1 - 1 file changed, 1 deletion(-) (limited to 'src') diff --git a/src/indicator-sus.c b/src/indicator-sus.c index d1296e0..4d8e176 100644 --- a/src/indicator-sus.c +++ b/src/indicator-sus.c @@ -25,7 +25,6 @@ static GtkWidget * loading_item = NULL; static DBusGConnection * connection = NULL; static DBusGProxy * proxy = NULL; -static DBusGProxy * status_proxy = NULL; typedef enum { STATUS_SECTION, -- cgit v1.2.3 From d109578b8a84e07678762906021234404e53a8bf Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Fri, 7 Aug 2009 20:19:44 +0100 Subject: Getting an image built for offline --- src/indicator-sus.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/indicator-sus.c b/src/indicator-sus.c index 4d8e176..9d1c66c 100644 --- a/src/indicator-sus.c +++ b/src/indicator-sus.c @@ -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 -- cgit v1.2.3 From 848e09b4d35f6609c4deaf1298c8b4360ed15a22 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Fri, 7 Aug 2009 21:39:52 +0100 Subject: Put the user's real name in the menu item. --- src/status-service.c | 35 ++++++++++++++++++++++++++++++----- 1 file changed, 30 insertions(+), 5 deletions(-) (limited to 'src') 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 +#include + #include #include @@ -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"); -- cgit v1.2.3