aboutsummaryrefslogtreecommitdiff
path: root/src/indicator-sus.c
diff options
context:
space:
mode:
authorTed Gould <ted@canonical.com>2009-08-17 09:05:04 -0500
committerTed Gould <ted@canonical.com>2009-08-17 09:05:04 -0500
commitb107a295f3baacfc3fbd9328cb94f43a0f993c58 (patch)
tree9ef4f9cf4d83c507fcca6e2f92c8857fbd16a4e5 /src/indicator-sus.c
parent76e386da015a29e46291fe66848d376e340eed7b (diff)
parent692f214823437c5ae15bbcd601b98cdae1d1af08 (diff)
downloadayatana-indicator-session-b107a295f3baacfc3fbd9328cb94f43a0f993c58.tar.gz
ayatana-indicator-session-b107a295f3baacfc3fbd9328cb94f43a0f993c58.tar.bz2
ayatana-indicator-session-b107a295f3baacfc3fbd9328cb94f43a0f993c58.zip
Merging in the branch getting the status icons working.
Diffstat (limited to 'src/indicator-sus.c')
-rw-r--r--src/indicator-sus.c59
1 files changed, 57 insertions, 2 deletions
diff --git a/src/indicator-sus.c b/src/indicator-sus.c
index e248e68..07efc86 100644
--- a/src/indicator-sus.c
+++ b/src/indicator-sus.c
@@ -39,6 +39,7 @@ static DbusmenuGtkClient * users_client = NULL;
static DbusmenuGtkClient * session_client = NULL;
static GtkMenu * main_menu = NULL;
+static GtkImage * status_image = NULL;
static GtkWidget * status_separator = NULL;
static GtkWidget * users_separator = NULL;
@@ -47,6 +48,7 @@ static GtkWidget * loading_item = NULL;
static DBusGConnection * connection = NULL;
static DBusGProxy * proxy = NULL;
+static DBusGProxy * status_proxy = NULL;
typedef enum {
STATUS_SECTION,
@@ -71,8 +73,10 @@ get_label (void)
GtkImage *
get_icon (void)
{
- GtkImage * image = GTK_IMAGE(gtk_image_new_from_icon_name("user-offline", GTK_ICON_SIZE_MENU));
- return image;
+ g_debug("Changing status icon: '%s'", "user-offline");
+ status_image = GTK_IMAGE(gtk_image_new_from_icon_name("user-offline", GTK_ICON_SIZE_MENU));
+ gtk_widget_show(GTK_WIDGET(status_image));
+ return status_image;
}
static void
@@ -178,6 +182,55 @@ status_menu_root_changed(DbusmenuGtkClient * client, DbusmenuMenuitem * newroot,
return;
}
+void
+status_icon_cb (DBusGProxy * proxy, char * icons, GError *error, gpointer userdata)
+{
+ g_return_if_fail(status_image != NULL);
+ g_return_if_fail(icons != NULL);
+ g_return_if_fail(icons[0] != '\0');
+
+ g_debug("Changing status icon: '%s'", icons);
+ gtk_image_set_from_icon_name(status_image, icons, GTK_ICON_SIZE_MENU);
+
+ return;
+}
+
+void
+status_icon_changed (DBusGProxy * proxy, gchar * icon, gpointer userdata)
+{
+ return status_icon_cb(proxy, icon, NULL, NULL);
+}
+
+
+static gboolean
+connect_to_status (gpointer userdata)
+{
+ if (status_proxy == NULL) {
+ GError * error = NULL;
+
+ DBusGConnection * sbus = dbus_g_bus_get(DBUS_BUS_SESSION, NULL);
+
+ status_proxy = dbus_g_proxy_new_for_name_owner(sbus,
+ INDICATOR_STATUS_DBUS_NAME,
+ INDICATOR_STATUS_SERVICE_DBUS_OBJECT,
+ INDICATOR_STATUS_SERVICE_DBUS_INTERFACE,
+ &error);
+
+ if (error != NULL) {
+ g_warning("Unable to get status proxy: %s", error->message);
+ g_error_free(error);
+ return FALSE;
+ }
+
+ dbus_g_proxy_add_signal(status_proxy, "StatusIconsChanged", G_TYPE_STRING, G_TYPE_INVALID);
+ dbus_g_proxy_connect_signal(status_proxy, "StatusIconsChanged", G_CALLBACK(status_icon_changed), NULL, NULL);
+ }
+
+ org_ayatana_indicator_status_service_status_icons_async(status_proxy, status_icon_cb, NULL);
+
+ return FALSE;
+}
+
static gboolean
build_status_menu (gpointer userdata)
{
@@ -208,6 +261,8 @@ build_status_menu (gpointer userdata)
gtk_menu_shell_append(GTK_MENU_SHELL(main_menu), status_separator);
gtk_widget_hide(status_separator); /* Should be default, I'm just being explicit. $(%*#$ hide already! */
+ g_idle_add(connect_to_status, NULL);
+
return FALSE;
}