aboutsummaryrefslogtreecommitdiff
path: root/src/indicator-session.c
diff options
context:
space:
mode:
authorTed Gould <ted@gould.cx>2010-03-12 15:47:33 -0600
committerTed Gould <ted@gould.cx>2010-03-12 15:47:33 -0600
commit746636765323cb223ef84af13920a9620176eb4f (patch)
tree41bdd59674e6bec07d0fd5e46be4143eb5175f61 /src/indicator-session.c
parent802d6447947701b2578a29babd2357642b982645 (diff)
downloadayatana-indicator-session-746636765323cb223ef84af13920a9620176eb4f.tar.gz
ayatana-indicator-session-746636765323cb223ef84af13920a9620176eb4f.tar.bz2
ayatana-indicator-session-746636765323cb223ef84af13920a9620176eb4f.zip
Getting the icon, but only when we're connected.
Diffstat (limited to 'src/indicator-session.c')
-rw-r--r--src/indicator-session.c25
1 files changed, 25 insertions, 0 deletions
diff --git a/src/indicator-session.c b/src/indicator-session.c
index c23cd0b..6e259dc 100644
--- a/src/indicator-session.c
+++ b/src/indicator-session.c
@@ -35,6 +35,7 @@ with this program. If not, see <http://www.gnu.org/licenses/>.
#include "dbus-shared-names.h"
#include "dbusmenu-shared.h"
+#include "session-dbus-client.h"
#define INDICATOR_SESSION_TYPE (indicator_session_get_type ())
#define INDICATOR_SESSION(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), INDICATOR_SESSION_TYPE, IndicatorSession))
@@ -71,6 +72,7 @@ static GtkMenu * get_menu (IndicatorObject * io);
static gboolean build_menu_switch (DbusmenuMenuitem * newitem, DbusmenuMenuitem * parent, DbusmenuClient * client);
static gboolean new_user_item (DbusmenuMenuitem * newitem, DbusmenuMenuitem * parent, DbusmenuClient * client);
static void icon_changed (DBusGProxy * proxy, gchar * icon_name, gpointer user_data);
+static void service_connection_cb (IndicatorServiceManager * sm, gboolean connected, gpointer user_data);
static void indicator_session_class_init (IndicatorSessionClass *klass);
static void indicator_session_init (IndicatorSession *self);
@@ -103,6 +105,7 @@ indicator_session_init (IndicatorSession *self)
/* Now let's fire these guys up. */
self->service = indicator_service_manager_new_version(INDICATOR_SESSION_DBUS_NAME, INDICATOR_SESSION_DBUS_VERSION);
+ g_signal_connect(G_OBJECT(self->service), INDICATOR_SERVICE_MANAGER_SIGNAL_CONNECTION_CHANGE, G_CALLBACK(service_connection_cb), self);
self->status_image = GTK_IMAGE(gtk_image_new_from_icon_name("system-shutdown-panel", GTK_ICON_SIZE_MENU));
self->menu = dbusmenu_gtkmenu_new(INDICATOR_SESSION_DBUS_NAME, INDICATOR_SESSION_DBUS_OBJECT);
@@ -155,6 +158,28 @@ indicator_session_finalize (GObject *object)
return;
}
+static void
+icon_name_get_cb (DBusGProxy *proxy, char * OUT_name, GError *error, gpointer userdata)
+{
+ IndicatorSession * self = INDICATOR_SESSION(userdata);
+ gtk_image_set_from_icon_name(self->status_image, OUT_name, GTK_ICON_SIZE_MENU);
+ return;
+}
+
+static void
+service_connection_cb (IndicatorServiceManager * sm, gboolean connected, gpointer user_data)
+{
+ IndicatorSession * self = INDICATOR_SESSION(user_data);
+
+ if (connected) {
+ org_ayatana_indicator_session_service_get_icon_async(self->service_proxy, icon_name_get_cb, user_data);
+ } else {
+ gtk_image_set_from_icon_name(self->status_image, "system-shutdown-panel", GTK_ICON_SIZE_MENU);
+ }
+
+ return;
+}
+
static GtkLabel *
get_label (IndicatorObject * io)
{