aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTed Gould <ted@canonical.com>2009-08-08 13:34:14 -0600
committerTed Gould <ted@canonical.com>2009-08-08 13:34:14 -0600
commiteca9ad1566786f790bdd2cc12d419b46ef72e334 (patch)
tree90601a603d19eb1347630e1acfb5142f682fa407
parent695fba351aea9d830525a495c8517e27bdeb1248 (diff)
parent74ac9091c44c933e14b6ef05f1177accc744ecf2 (diff)
downloadayatana-indicator-session-eca9ad1566786f790bdd2cc12d419b46ef72e334.tar.gz
ayatana-indicator-session-eca9ad1566786f790bdd2cc12d419b46ef72e334.tar.bz2
ayatana-indicator-session-eca9ad1566786f790bdd2cc12d419b46ef72e334.zip
Setting the icon from the status service.
-rw-r--r--debian/changelog6
-rw-r--r--src/dbus-shared-names.h2
-rw-r--r--src/indicator-sus.c58
-rw-r--r--src/status-service-dbus.c2
-rw-r--r--src/status-service.xml2
5 files changed, 64 insertions, 6 deletions
diff --git a/debian/changelog b/debian/changelog
index 001481a..e86841a 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,9 @@
+indicator-sus (0.1~ppa7~status3) UNRELEASED; urgency=low
+
+ * Setting the icon from the status service.
+
+ -- Ted Gould <ted@ubuntu.com> Sat, 08 Aug 2009 13:33:55 -0600
+
indicator-sus (0.1~ppa7~status2) karmic; urgency=low
* Moving the icons to a better, warmer, place.
diff --git a/src/dbus-shared-names.h b/src/dbus-shared-names.h
index 9c828b1..6eb261f 100644
--- a/src/dbus-shared-names.h
+++ b/src/dbus-shared-names.h
@@ -26,7 +26,7 @@ with this program. If not, see <http://www.gnu.org/licenses/>.
#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/statusservice"
+#define INDICATOR_STATUS_SERVICE_DBUS_INTERFACE "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 1ab810c..3e16e64 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,9 +73,9 @@ get_label (void)
GtkImage *
get_icon (void)
{
- GtkImage * image = GTK_IMAGE(gtk_image_new_from_icon_name("user-offline", GTK_ICON_SIZE_MENU));
- gtk_widget_show(GTK_WIDGET(image));
- return image;
+ 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
@@ -179,6 +181,54 @@ 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');
+
+ 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_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, "IconsChanged", G_TYPE_STRING, G_TYPE_INVALID);
+ dbus_g_proxy_connect_signal(status_proxy, "IconsChanged", G_CALLBACK(status_icon_changed), NULL, NULL);
+ }
+
+ org_ayatana_indicator_status_status_icons_async(status_proxy, status_icon_cb, NULL);
+
+ return FALSE;
+}
+
static gboolean
build_status_menu (gpointer userdata)
{
@@ -209,6 +259,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;
}
diff --git a/src/status-service-dbus.c b/src/status-service-dbus.c
index 09d2711..f93980f 100644
--- a/src/status-service-dbus.c
+++ b/src/status-service-dbus.c
@@ -116,7 +116,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_SERVICE_DBUS_OBJECT,
+ INDICATOR_STATUS_DBUS_OBJECT,
G_OBJECT(self));
StatusServiceDbusPrivate * priv = STATUS_SERVICE_DBUS_GET_PRIVATE(self);
diff --git a/src/status-service.xml b/src/status-service.xml
index ba1f79f..977b338 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="org.ayatana.indicator.status">
+ <interface name="org.ayatana.indicator.status.service">
<!-- Methods -->
<method name="Watch">