aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorTed Gould <ted@canonical.com>2009-07-24 16:15:09 -0500
committerTed Gould <ted@canonical.com>2009-07-24 16:15:09 -0500
commitec987aaf9598ffa43561e9f3ef9cb4bcf0d21218 (patch)
tree44ad7a940c43975184c84fb00194d7ed52115bb3 /src
parent030273f33da9c1ac7875d7319ffc6d78561719cf (diff)
downloadayatana-indicator-session-ec987aaf9598ffa43561e9f3ef9cb4bcf0d21218.tar.gz
ayatana-indicator-session-ec987aaf9598ffa43561e9f3ef9cb4bcf0d21218.tar.bz2
ayatana-indicator-session-ec987aaf9598ffa43561e9f3ef9cb4bcf0d21218.zip
Setting the visiblity of the menu items based on whether DKP reports that we have the functionality.
Diffstat (limited to 'src')
-rw-r--r--src/session-service.c31
1 files changed, 22 insertions, 9 deletions
diff --git a/src/session-service.c b/src/session-service.c
index 240f397..92e4184 100644
--- a/src/session-service.c
+++ b/src/session-service.c
@@ -21,6 +21,9 @@ static DBusGProxy * dkp_prop_proxy = NULL;
static DBusGProxyCall * suspend_call = NULL;
static DBusGProxyCall * hibernate_call = NULL;
+static DbusmenuMenuitem * hibernate_mi = NULL;
+static DbusmenuMenuitem * suspend_mi = NULL;
+
/* Let's put this machine to sleep, with some info on how
it should sleep. */
static void
@@ -40,6 +43,7 @@ sleep (DbusmenuMenuitem * mi, gpointer userdata)
return;
}
+/* A response to getting the suspend property */
static void
suspend_prop_cb (DBusGProxy * proxy, DBusGProxyCall * call, gpointer userdata)
{
@@ -55,10 +59,14 @@ suspend_prop_cb (DBusGProxy * proxy, DBusGProxyCall * call, gpointer userdata)
}
g_debug("Got Suspend: %s", g_value_get_boolean(&candoit) ? "true" : "false");
+ if (suspend_mi != NULL) {
+ dbusmenu_menuitem_property_set(suspend_mi, "visible", g_value_get_boolean(&candoit) ? "true" : "false");
+ }
return;
}
+/* Response to getting the hibernate property */
static void
hibernate_prop_cb (DBusGProxy * proxy, DBusGProxyCall * call, gpointer userdata)
{
@@ -74,6 +82,9 @@ hibernate_prop_cb (DBusGProxy * proxy, DBusGProxyCall * call, gpointer userdata)
}
g_debug("Got Hibernate: %s", g_value_get_boolean(&candoit) ? "true" : "false");
+ if (suspend_mi != NULL) {
+ dbusmenu_menuitem_property_set(hibernate_mi, "visible", g_value_get_boolean(&candoit) ? "true" : "false");
+ }
return;
}
@@ -197,15 +208,17 @@ create_items (DbusmenuMenuitem * root) {
dbusmenu_menuitem_child_append(root, mi);
g_signal_connect(G_OBJECT(mi), DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED, G_CALLBACK(show_dialog), "logout");
- mi = dbusmenu_menuitem_new();
- dbusmenu_menuitem_property_set(mi, "label", _("Suspend"));
- dbusmenu_menuitem_child_append(root, mi);
- g_signal_connect(G_OBJECT(mi), DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED, G_CALLBACK(sleep), "Suspend");
-
- mi = dbusmenu_menuitem_new();
- dbusmenu_menuitem_property_set(mi, "label", _("Hibernate"));
- dbusmenu_menuitem_child_append(root, mi);
- g_signal_connect(G_OBJECT(mi), DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED, G_CALLBACK(sleep), "Hibernate");
+ suspend_mi = dbusmenu_menuitem_new();
+ dbusmenu_menuitem_property_set(suspend_mi, "visible", "false");
+ dbusmenu_menuitem_property_set(suspend_mi, "label", _("Suspend"));
+ dbusmenu_menuitem_child_append(root, suspend_mi);
+ g_signal_connect(G_OBJECT(suspend_mi), DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED, G_CALLBACK(sleep), "Suspend");
+
+ hibernate_mi = dbusmenu_menuitem_new();
+ dbusmenu_menuitem_property_set(hibernate_mi, "visible", "false");
+ dbusmenu_menuitem_property_set(hibernate_mi, "label", _("Hibernate"));
+ dbusmenu_menuitem_child_append(root, hibernate_mi);
+ g_signal_connect(G_OBJECT(hibernate_mi), DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED, G_CALLBACK(sleep), "Hibernate");
mi = dbusmenu_menuitem_new();
dbusmenu_menuitem_property_set(mi, "label", _("Restart"));