From 8ea0fde8939236cca0d11aa726fe5d98f6de6526 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Mon, 15 Mar 2010 13:10:43 -0500 Subject: Changing the define name to have room for more locdown keys --- src/session-service.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/session-service.c b/src/session-service.c index f6b666f..a64f701 100644 --- a/src/session-service.c +++ b/src/session-service.c @@ -56,8 +56,8 @@ with this program. If not, see . #define GUEST_SESSION_LAUNCHER "/usr/share/gdm/guest-session/guest-session-launch" -#define LOCKDOWN_DIR "/desktop/gnome/lockdown" -#define LOCKDOWN_KEY LOCKDOWN_DIR "/disable_user_switching" +#define LOCKDOWN_DIR "/desktop/gnome/lockdown" +#define LOCKDOWN_KEY_USER LOCKDOWN_DIR "/disable_user_switching" typedef struct _ActivateData ActivateData; struct _ActivateData @@ -103,7 +103,7 @@ lockdown_changed (GConfClient *client, if (!value || !key) return; - if (g_strcmp0 (key, LOCKDOWN_KEY) == 0) + if (g_strcmp0 (key, LOCKDOWN_KEY_USER) == 0) { if (switch_menuitem) { @@ -127,7 +127,7 @@ ensure_gconf_client (void) gconf_client = gconf_client_get_default (); notify_lockdown_id = gconf_client_notify_add (gconf_client, - LOCKDOWN_KEY, + LOCKDOWN_KEY_USER, lockdown_changed, NULL, NULL, @@ -484,7 +484,7 @@ rebuild_items (DbusmenuMenuitem *root, dbusmenu_menuitem_child_append (root, switch_menuitem); g_signal_connect (G_OBJECT (switch_menuitem), DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED, G_CALLBACK (activate_new_session), NULL); - if (gconf_client_get_bool (gconf_client, LOCKDOWN_KEY, NULL)) + if (gconf_client_get_bool (gconf_client, LOCKDOWN_KEY_USER, NULL)) { dbusmenu_menuitem_property_set_bool (switch_menuitem, DBUSMENU_MENUITEM_PROP_VISIBLE, FALSE); } -- cgit v1.2.3 From df71f47685081f5125fb12c7bb170d88538e9523 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Mon, 15 Mar 2010 13:28:19 -0500 Subject: Reacting to changes in the screensaver lockdown key. --- src/session-service.c | 43 +++++++++++++++++++++++++------------------ 1 file changed, 25 insertions(+), 18 deletions(-) (limited to 'src') diff --git a/src/session-service.c b/src/session-service.c index a64f701..7ebc00a 100644 --- a/src/session-service.c +++ b/src/session-service.c @@ -58,6 +58,7 @@ with this program. If not, see . #define LOCKDOWN_DIR "/desktop/gnome/lockdown" #define LOCKDOWN_KEY_USER LOCKDOWN_DIR "/disable_user_switching" +#define LOCKDOWN_KEY_SCREENSAVER LOCKDOWN_DIR "/disable_lock_screen" typedef struct _ActivateData ActivateData; struct _ActivateData @@ -97,26 +98,32 @@ lockdown_changed (GConfClient *client, GConfEntry *entry, gpointer user_data) { - GConfValue *value = gconf_entry_get_value (entry); - const gchar *key = gconf_entry_get_key (entry); + GConfValue *value = gconf_entry_get_value (entry); + const gchar *key = gconf_entry_get_key (entry); - if (!value || !key) - return; + if (value == NULL || key == NULL) { + return; + } - if (g_strcmp0 (key, LOCKDOWN_KEY_USER) == 0) - { - if (switch_menuitem) - { - if (gconf_value_get_bool (value)) - { - dbusmenu_menuitem_property_set_bool (switch_menuitem, DBUSMENU_MENUITEM_PROP_VISIBLE, FALSE); - } - else - { - dbusmenu_menuitem_property_set_bool (switch_menuitem, DBUSMENU_MENUITEM_PROP_VISIBLE, TRUE); - } - } - } + if (g_strcmp0 (key, LOCKDOWN_KEY_USER) == 0) { + if (switch_menuitem != NULL) { + if (gconf_value_get_bool (value)) { + dbusmenu_menuitem_property_set_bool (switch_menuitem, DBUSMENU_MENUITEM_PROP_VISIBLE, FALSE); + } else { + dbusmenu_menuitem_property_set_bool (switch_menuitem, DBUSMENU_MENUITEM_PROP_VISIBLE, TRUE); + } + } + } if (g_strcmp0 (key, LOCKDOWN_KEY_SCREENSAVER) == 0) { + if (lock_menuitem != NULL) { + if (gconf_value_get_bool (value)) { + dbusmenu_menuitem_property_set_bool (lock_menuitem, DBUSMENU_MENUITEM_PROP_VISIBLE, FALSE); + } else { + dbusmenu_menuitem_property_set_bool (lock_menuitem, DBUSMENU_MENUITEM_PROP_VISIBLE, TRUE); + } + } + } + + return; } static void -- cgit v1.2.3 From aa52289c19291ffa9bc4ed70f67d1f683cbf6381 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Mon, 15 Mar 2010 13:29:01 -0500 Subject: Embarassing 4 letter word to forget. Guess the compiler would add it back anyway though. --- src/session-service.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/session-service.c b/src/session-service.c index 7ebc00a..24623aa 100644 --- a/src/session-service.c +++ b/src/session-service.c @@ -113,7 +113,7 @@ lockdown_changed (GConfClient *client, dbusmenu_menuitem_property_set_bool (switch_menuitem, DBUSMENU_MENUITEM_PROP_VISIBLE, TRUE); } } - } if (g_strcmp0 (key, LOCKDOWN_KEY_SCREENSAVER) == 0) { + } else if (g_strcmp0 (key, LOCKDOWN_KEY_SCREENSAVER) == 0) { if (lock_menuitem != NULL) { if (gconf_value_get_bool (value)) { dbusmenu_menuitem_property_set_bool (lock_menuitem, DBUSMENU_MENUITEM_PROP_VISIBLE, FALSE); -- cgit v1.2.3 From da365cbe9598860cc4e74938ded3ad735a6db396 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Mon, 15 Mar 2010 14:11:55 -0500 Subject: Tracking the separator next to the lock item as well. --- src/session-service.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/session-service.c b/src/session-service.c index 24623aa..b976236 100644 --- a/src/session-service.c +++ b/src/session-service.c @@ -73,6 +73,7 @@ static UsersServiceDbus *dbus_interface = NULL; static SessionDbus *session_dbus = NULL; static DbusmenuMenuitem *lock_menuitem = NULL; +static DbusmenuMenuitem *lock_separator = NULL; static DbusmenuMenuitem *switch_menuitem = NULL; static DbusmenuMenuitem * root_menuitem = NULL; @@ -116,9 +117,11 @@ lockdown_changed (GConfClient *client, } else if (g_strcmp0 (key, LOCKDOWN_KEY_SCREENSAVER) == 0) { if (lock_menuitem != NULL) { if (gconf_value_get_bool (value)) { - dbusmenu_menuitem_property_set_bool (lock_menuitem, DBUSMENU_MENUITEM_PROP_VISIBLE, FALSE); + dbusmenu_menuitem_property_set_bool (lock_menuitem, DBUSMENU_MENUITEM_PROP_VISIBLE, FALSE); + dbusmenu_menuitem_property_set_bool (lock_separator, DBUSMENU_MENUITEM_PROP_VISIBLE, FALSE); } else { - dbusmenu_menuitem_property_set_bool (lock_menuitem, DBUSMENU_MENUITEM_PROP_VISIBLE, TRUE); + dbusmenu_menuitem_property_set_bool (lock_menuitem, DBUSMENU_MENUITEM_PROP_VISIBLE, TRUE); + dbusmenu_menuitem_property_set_bool (lock_separator, DBUSMENU_MENUITEM_PROP_VISIBLE, TRUE); } } } @@ -464,12 +467,14 @@ rebuild_items (DbusmenuMenuitem *root, } else { dbusmenu_menuitem_property_set_bool(lock_menuitem, DBUSMENU_MENUITEM_PROP_ENABLED, TRUE); } + lock_separator = NULL; if (can_activate == TRUE) { DbusmenuMenuitem * separator1 = dbusmenu_menuitem_new(); dbusmenu_menuitem_property_set(separator1, DBUSMENU_MENUITEM_PROP_TYPE, DBUSMENU_CLIENT_TYPES_SEPARATOR); dbusmenu_menuitem_child_append(root, separator1); + lock_separator = separator1; if (check_guest_session ()) { @@ -554,6 +559,9 @@ rebuild_items (DbusmenuMenuitem *root, DbusmenuMenuitem * separator = dbusmenu_menuitem_new(); dbusmenu_menuitem_property_set(separator, DBUSMENU_MENUITEM_PROP_TYPE, DBUSMENU_CLIENT_TYPES_SEPARATOR); dbusmenu_menuitem_child_append(root, separator); + if (lock_separator == NULL) { + lock_separator = separator; + } logout_mi = dbusmenu_menuitem_new(); if (supress_confirmations()) { -- cgit v1.2.3 From 065984db24fa4e8723d9dd5add9eec0e71d43ace Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Mon, 15 Mar 2010 14:45:48 -0500 Subject: Switching around the GConf notification setup to do an entire directory. --- src/session-service.c | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) (limited to 'src') diff --git a/src/session-service.c b/src/session-service.c index b976236..72a93eb 100644 --- a/src/session-service.c +++ b/src/session-service.c @@ -91,7 +91,6 @@ static DbusmenuMenuitem * restart_mi = NULL; static DbusmenuMenuitem * shutdown_mi = NULL; static GConfClient * gconf_client = NULL; -static guint notify_lockdown_id = 0; static void lockdown_changed (GConfClient *client, @@ -129,20 +128,17 @@ lockdown_changed (GConfClient *client, return; } +/* Ensures that we have a GConf client and if we build one + set up the signal handler. */ static void ensure_gconf_client (void) { - if (!gconf_client) - { - gconf_client = gconf_client_get_default (); - - notify_lockdown_id = gconf_client_notify_add (gconf_client, - LOCKDOWN_KEY_USER, - lockdown_changed, - NULL, - NULL, - NULL); - } + if (!gconf_client) { + gconf_client = gconf_client_get_default (); + gconf_client_add_dir(gconf_client, LOCKDOWN_DIR, GCONF_CLIENT_PRELOAD_ONELEVEL, NULL); + gconf_client_notify_add(gconf_client, LOCKDOWN_DIR, lockdown_changed, NULL, NULL, NULL); + } + return; } /* A return from the command to sleep the system. Make sure -- cgit v1.2.3 From 523c02493e72d1e99e23082e9b14af51fd54ae18 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Mon, 15 Mar 2010 15:21:26 -0500 Subject: Switching from hiding entries to just rebuilding the menus. --- src/session-service.c | 22 ++++------------------ 1 file changed, 4 insertions(+), 18 deletions(-) (limited to 'src') diff --git a/src/session-service.c b/src/session-service.c index 72a93eb..c0703bb 100644 --- a/src/session-service.c +++ b/src/session-service.c @@ -92,6 +92,8 @@ static DbusmenuMenuitem * shutdown_mi = NULL; static GConfClient * gconf_client = NULL; +static void rebuild_items (DbusmenuMenuitem *root, UsersServiceDbus *service); + static void lockdown_changed (GConfClient *client, guint cnxd_id, @@ -105,24 +107,8 @@ lockdown_changed (GConfClient *client, return; } - if (g_strcmp0 (key, LOCKDOWN_KEY_USER) == 0) { - if (switch_menuitem != NULL) { - if (gconf_value_get_bool (value)) { - dbusmenu_menuitem_property_set_bool (switch_menuitem, DBUSMENU_MENUITEM_PROP_VISIBLE, FALSE); - } else { - dbusmenu_menuitem_property_set_bool (switch_menuitem, DBUSMENU_MENUITEM_PROP_VISIBLE, TRUE); - } - } - } else if (g_strcmp0 (key, LOCKDOWN_KEY_SCREENSAVER) == 0) { - if (lock_menuitem != NULL) { - if (gconf_value_get_bool (value)) { - dbusmenu_menuitem_property_set_bool (lock_menuitem, DBUSMENU_MENUITEM_PROP_VISIBLE, FALSE); - dbusmenu_menuitem_property_set_bool (lock_separator, DBUSMENU_MENUITEM_PROP_VISIBLE, FALSE); - } else { - dbusmenu_menuitem_property_set_bool (lock_menuitem, DBUSMENU_MENUITEM_PROP_VISIBLE, TRUE); - dbusmenu_menuitem_property_set_bool (lock_separator, DBUSMENU_MENUITEM_PROP_VISIBLE, TRUE); - } - } + if (g_strcmp0 (key, LOCKDOWN_KEY_USER) == 0 || g_strcmp0 (key, LOCKDOWN_KEY_SCREENSAVER) == 0) { + rebuild_items(root_menuitem, dbus_interface); } return; -- cgit v1.2.3 From 29bd57b57fe4cf4e964fdecf034cb2ecb8cd04b1 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Mon, 15 Mar 2010 15:33:36 -0500 Subject: Changing the lockdown key to do all the switching instead of just the switch user item. --- src/session-service.c | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) (limited to 'src') diff --git a/src/session-service.c b/src/session-service.c index c0703bb..66d468f 100644 --- a/src/session-service.c +++ b/src/session-service.c @@ -434,7 +434,10 @@ rebuild_items (DbusmenuMenuitem *root, gboolean can_activate; GList *children; - can_activate = users_service_dbus_can_activate_session (service); + ensure_gconf_client (); + + can_activate = users_service_dbus_can_activate_session (service) && + !gconf_client_get_bool (gconf_client, LOCKDOWN_KEY_USER, NULL); children = dbusmenu_menuitem_take_children (root); g_list_foreach (children, (GFunc)g_object_unref, NULL); @@ -470,22 +473,12 @@ rebuild_items (DbusmenuMenuitem *root, if (check_new_session ()) { - ensure_gconf_client (); switch_menuitem = dbusmenu_menuitem_new (); dbusmenu_menuitem_property_set (switch_menuitem, DBUSMENU_MENUITEM_PROP_TYPE, MENU_SWITCH_TYPE); dbusmenu_menuitem_property_set (switch_menuitem, MENU_SWITCH_USER, g_get_user_name()); dbusmenu_menuitem_child_append (root, switch_menuitem); g_signal_connect (G_OBJECT (switch_menuitem), DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED, G_CALLBACK (activate_new_session), NULL); - - if (gconf_client_get_bool (gconf_client, LOCKDOWN_KEY_USER, NULL)) - { - dbusmenu_menuitem_property_set_bool (switch_menuitem, DBUSMENU_MENUITEM_PROP_VISIBLE, FALSE); - } - else - { - dbusmenu_menuitem_property_set_bool (switch_menuitem, DBUSMENU_MENUITEM_PROP_VISIBLE, TRUE); - } } GList * users = NULL; -- cgit v1.2.3 From c334ecccf05654c102b112cf7d76d2f38768924f Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Mon, 15 Mar 2010 15:36:48 -0500 Subject: Removing the lock separator as we don't need it anymore. --- src/session-service.c | 6 ------ 1 file changed, 6 deletions(-) (limited to 'src') diff --git a/src/session-service.c b/src/session-service.c index 66d468f..cadce43 100644 --- a/src/session-service.c +++ b/src/session-service.c @@ -73,7 +73,6 @@ static UsersServiceDbus *dbus_interface = NULL; static SessionDbus *session_dbus = NULL; static DbusmenuMenuitem *lock_menuitem = NULL; -static DbusmenuMenuitem *lock_separator = NULL; static DbusmenuMenuitem *switch_menuitem = NULL; static DbusmenuMenuitem * root_menuitem = NULL; @@ -452,14 +451,12 @@ rebuild_items (DbusmenuMenuitem *root, } else { dbusmenu_menuitem_property_set_bool(lock_menuitem, DBUSMENU_MENUITEM_PROP_ENABLED, TRUE); } - lock_separator = NULL; if (can_activate == TRUE) { DbusmenuMenuitem * separator1 = dbusmenu_menuitem_new(); dbusmenu_menuitem_property_set(separator1, DBUSMENU_MENUITEM_PROP_TYPE, DBUSMENU_CLIENT_TYPES_SEPARATOR); dbusmenu_menuitem_child_append(root, separator1); - lock_separator = separator1; if (check_guest_session ()) { @@ -534,9 +531,6 @@ rebuild_items (DbusmenuMenuitem *root, DbusmenuMenuitem * separator = dbusmenu_menuitem_new(); dbusmenu_menuitem_property_set(separator, DBUSMENU_MENUITEM_PROP_TYPE, DBUSMENU_CLIENT_TYPES_SEPARATOR); dbusmenu_menuitem_child_append(root, separator); - if (lock_separator == NULL) { - lock_separator = separator; - } logout_mi = dbusmenu_menuitem_new(); if (supress_confirmations()) { -- cgit v1.2.3 From bdba7e5c6a5081c599ade54e4798f9f1af0b536e Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Mon, 15 Mar 2010 15:52:17 -0500 Subject: Handling the locking of the screen in the rebuild function. --- src/session-service.c | 36 ++++++++++++++++++++++-------------- 1 file changed, 22 insertions(+), 14 deletions(-) (limited to 'src') diff --git a/src/session-service.c b/src/session-service.c index cadce43..53c305c 100644 --- a/src/session-service.c +++ b/src/session-service.c @@ -431,32 +431,38 @@ rebuild_items (DbusmenuMenuitem *root, GList *u; UserData *user; gboolean can_activate; + gboolean can_lockscreen; GList *children; ensure_gconf_client (); can_activate = users_service_dbus_can_activate_session (service) && !gconf_client_get_bool (gconf_client, LOCKDOWN_KEY_USER, NULL); + can_lockscreen = !gconf_client_get_bool (gconf_client, LOCKDOWN_KEY_SCREENSAVER, NULL); children = dbusmenu_menuitem_take_children (root); g_list_foreach (children, (GFunc)g_object_unref, NULL); g_list_free (children); - lock_menuitem = dbusmenu_menuitem_new(); - dbusmenu_menuitem_property_set(lock_menuitem, DBUSMENU_MENUITEM_PROP_LABEL, _("Lock Screen")); - g_signal_connect(G_OBJECT(lock_menuitem), DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED, G_CALLBACK(lock_screen), NULL); - dbusmenu_menuitem_child_append(root, lock_menuitem); - if (!will_lock_screen()) { - dbusmenu_menuitem_property_set_bool(lock_menuitem, DBUSMENU_MENUITEM_PROP_ENABLED, FALSE); - } else { - dbusmenu_menuitem_property_set_bool(lock_menuitem, DBUSMENU_MENUITEM_PROP_ENABLED, TRUE); + if (can_lockscreen) { + lock_menuitem = dbusmenu_menuitem_new(); + dbusmenu_menuitem_property_set(lock_menuitem, DBUSMENU_MENUITEM_PROP_LABEL, _("Lock Screen")); + g_signal_connect(G_OBJECT(lock_menuitem), DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED, G_CALLBACK(lock_screen), NULL); + dbusmenu_menuitem_child_append(root, lock_menuitem); + if (!will_lock_screen()) { + dbusmenu_menuitem_property_set_bool(lock_menuitem, DBUSMENU_MENUITEM_PROP_ENABLED, FALSE); + } else { + dbusmenu_menuitem_property_set_bool(lock_menuitem, DBUSMENU_MENUITEM_PROP_ENABLED, TRUE); + } } if (can_activate == TRUE) { - DbusmenuMenuitem * separator1 = dbusmenu_menuitem_new(); - dbusmenu_menuitem_property_set(separator1, DBUSMENU_MENUITEM_PROP_TYPE, DBUSMENU_CLIENT_TYPES_SEPARATOR); - dbusmenu_menuitem_child_append(root, separator1); + if (can_lockscreen) { + DbusmenuMenuitem * separator1 = dbusmenu_menuitem_new(); + dbusmenu_menuitem_property_set(separator1, DBUSMENU_MENUITEM_PROP_TYPE, DBUSMENU_CLIENT_TYPES_SEPARATOR); + dbusmenu_menuitem_child_append(root, separator1); + } if (check_guest_session ()) { @@ -528,9 +534,11 @@ rebuild_items (DbusmenuMenuitem *root, g_list_free(users); } - DbusmenuMenuitem * separator = dbusmenu_menuitem_new(); - dbusmenu_menuitem_property_set(separator, DBUSMENU_MENUITEM_PROP_TYPE, DBUSMENU_CLIENT_TYPES_SEPARATOR); - dbusmenu_menuitem_child_append(root, separator); + if (can_lockscreen || can_activate) { + DbusmenuMenuitem * separator = dbusmenu_menuitem_new(); + dbusmenu_menuitem_property_set(separator, DBUSMENU_MENUITEM_PROP_TYPE, DBUSMENU_CLIENT_TYPES_SEPARATOR); + dbusmenu_menuitem_child_append(root, separator); + } logout_mi = dbusmenu_menuitem_new(); if (supress_confirmations()) { -- cgit v1.2.3 From acc3a9675f035777b3b32335edb7854860bfb9ba Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Mon, 15 Mar 2010 16:00:43 -0500 Subject: Adding some comments to describe a long function. --- src/session-service.c | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'src') diff --git a/src/session-service.c b/src/session-service.c index 53c305c..3ee1f6c 100644 --- a/src/session-service.c +++ b/src/session-service.c @@ -434,16 +434,21 @@ rebuild_items (DbusmenuMenuitem *root, gboolean can_lockscreen; GList *children; + /* Make sure we have a valid GConf client, and build one + if needed */ ensure_gconf_client (); + /* Check to see which menu items we're allowed to have */ can_activate = users_service_dbus_can_activate_session (service) && !gconf_client_get_bool (gconf_client, LOCKDOWN_KEY_USER, NULL); can_lockscreen = !gconf_client_get_bool (gconf_client, LOCKDOWN_KEY_SCREENSAVER, NULL); + /* Remove the old menu items if that makes sense */ children = dbusmenu_menuitem_take_children (root); g_list_foreach (children, (GFunc)g_object_unref, NULL); g_list_free (children); + /* Lock screen item */ if (can_lockscreen) { lock_menuitem = dbusmenu_menuitem_new(); dbusmenu_menuitem_property_set(lock_menuitem, DBUSMENU_MENUITEM_PROP_LABEL, _("Lock Screen")); @@ -456,6 +461,7 @@ rebuild_items (DbusmenuMenuitem *root, } } + /* Build all of the user switching items */ if (can_activate == TRUE) { if (can_lockscreen) { @@ -534,12 +540,16 @@ rebuild_items (DbusmenuMenuitem *root, g_list_free(users); } + /* If there were a bunch of items before us, we need a + separator. */ if (can_lockscreen || can_activate) { DbusmenuMenuitem * separator = dbusmenu_menuitem_new(); dbusmenu_menuitem_property_set(separator, DBUSMENU_MENUITEM_PROP_TYPE, DBUSMENU_CLIENT_TYPES_SEPARATOR); dbusmenu_menuitem_child_append(root, separator); } + /* Start going through the session based items. */ + logout_mi = dbusmenu_menuitem_new(); if (supress_confirmations()) { dbusmenu_menuitem_property_set(logout_mi, DBUSMENU_MENUITEM_PROP_LABEL, _("Log Out")); -- cgit v1.2.3 From eb8756b0a8b55f904dd74103fa33d67b1da11575 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Mon, 15 Mar 2010 16:02:06 -0500 Subject: Only setup signals if we're building the proxy for the first time. --- src/session-service.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) (limited to 'src') diff --git a/src/session-service.c b/src/session-service.c index 3ee1f6c..9cde4b0 100644 --- a/src/session-service.c +++ b/src/session-service.c @@ -266,19 +266,19 @@ setup_up (void) { UP_ADDRESS, UP_OBJECT, DBUS_INTERFACE_PROPERTIES); + /* Connect to changed signal */ + dbus_g_proxy_add_signal(up_main_proxy, + "Changed", + G_TYPE_INVALID); + + dbus_g_proxy_connect_signal(up_main_proxy, + "Changed", + G_CALLBACK(up_changed_cb), + NULL, + NULL); } g_return_if_fail(up_prop_proxy != NULL); - /* Connect to changed signal */ - dbus_g_proxy_add_signal(up_main_proxy, - "Changed", - G_TYPE_INVALID); - - dbus_g_proxy_connect_signal(up_main_proxy, - "Changed", - G_CALLBACK(up_changed_cb), - NULL, - NULL); /* Force an original "changed" event */ up_changed_cb(up_main_proxy, NULL); -- cgit v1.2.3 From cef6711749d305967d0341920f08aef46d6390d7 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Mon, 15 Mar 2010 16:16:53 -0500 Subject: Switching the suspend/hibernate handling to a cached value. And that way we can regen the menus without looking up the values. --- src/session-service.c | 39 ++++++++++++++++++++++++--------------- 1 file changed, 24 insertions(+), 15 deletions(-) (limited to 'src') diff --git a/src/session-service.c b/src/session-service.c index 9cde4b0..9eb6d88 100644 --- a/src/session-service.c +++ b/src/session-service.c @@ -89,6 +89,9 @@ static DbusmenuMenuitem * logout_mi = NULL; static DbusmenuMenuitem * restart_mi = NULL; static DbusmenuMenuitem * shutdown_mi = NULL; +static gboolean can_hibernate = TRUE; +static gboolean can_suspend = TRUE; + static GConfClient * gconf_client = NULL; static void rebuild_items (DbusmenuMenuitem *root, UsersServiceDbus *service); @@ -175,8 +178,10 @@ 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_value(suspend_mi, DBUSMENU_MENUITEM_PROP_VISIBLE, &candoit); + gboolean local_can_suspend = g_value_get_boolean(&candoit); + if (local_can_suspend != can_suspend) { + can_suspend = local_can_suspend; + rebuild_items(root_menuitem, dbus_interface); } return; @@ -198,8 +203,10 @@ 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_value(hibernate_mi, DBUSMENU_MENUITEM_PROP_VISIBLE, &candoit); + gboolean local_can_hibernate = g_value_get_boolean(&candoit); + if (local_can_hibernate != can_hibernate) { + can_hibernate = local_can_hibernate; + rebuild_items(root_menuitem, dbus_interface); } return; @@ -559,17 +566,19 @@ rebuild_items (DbusmenuMenuitem *root, dbusmenu_menuitem_child_append(root, logout_mi); g_signal_connect(G_OBJECT(logout_mi), DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED, G_CALLBACK(show_dialog), "logout"); - suspend_mi = dbusmenu_menuitem_new(); - dbusmenu_menuitem_property_set_bool(suspend_mi, DBUSMENU_MENUITEM_PROP_VISIBLE, FALSE); - dbusmenu_menuitem_property_set(suspend_mi, DBUSMENU_MENUITEM_PROP_LABEL, _("Sleep")); - dbusmenu_menuitem_child_append(root, suspend_mi); - g_signal_connect(G_OBJECT(suspend_mi), DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED, G_CALLBACK(machine_sleep), "Suspend"); - - hibernate_mi = dbusmenu_menuitem_new(); - dbusmenu_menuitem_property_set_bool(hibernate_mi, DBUSMENU_MENUITEM_PROP_VISIBLE, FALSE); - dbusmenu_menuitem_property_set(hibernate_mi, DBUSMENU_MENUITEM_PROP_LABEL, _("Hibernate")); - dbusmenu_menuitem_child_append(root, hibernate_mi); - g_signal_connect(G_OBJECT(hibernate_mi), DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED, G_CALLBACK(machine_sleep), "Hibernate"); + if (can_suspend) { + suspend_mi = dbusmenu_menuitem_new(); + dbusmenu_menuitem_property_set(suspend_mi, DBUSMENU_MENUITEM_PROP_LABEL, _("Sleep")); + dbusmenu_menuitem_child_append(root, suspend_mi); + g_signal_connect(G_OBJECT(suspend_mi), DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED, G_CALLBACK(machine_sleep), "Suspend"); + } + + if (can_hibernate) { + hibernate_mi = dbusmenu_menuitem_new(); + dbusmenu_menuitem_property_set(hibernate_mi, DBUSMENU_MENUITEM_PROP_LABEL, _("Hibernate")); + dbusmenu_menuitem_child_append(root, hibernate_mi); + g_signal_connect(G_OBJECT(hibernate_mi), DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED, G_CALLBACK(machine_sleep), "Hibernate"); + } restart_mi = dbusmenu_menuitem_new(); dbusmenu_menuitem_property_set(restart_mi, DBUSMENU_MENUITEM_PROP_TYPE, RESTART_ITEM_TYPE); -- cgit v1.2.3 From 03a2de405664a797b723dd8bd542b26817dd44e6 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Mon, 15 Mar 2010 16:55:39 -0500 Subject: Adding properties for allowing the suspend and hibernate --- src/session-service.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/session-service.c b/src/session-service.c index 4820f59..a915884 100644 --- a/src/session-service.c +++ b/src/session-service.c @@ -91,6 +91,8 @@ static DbusmenuMenuitem * shutdown_mi = NULL; static gboolean can_hibernate = TRUE; static gboolean can_suspend = TRUE; +static gboolean allow_hibernate = TRUE; +static gboolean allow_suspend = TRUE; static GConfClient * gconf_client = NULL; @@ -566,14 +568,14 @@ rebuild_items (DbusmenuMenuitem *root, dbusmenu_menuitem_child_append(root, logout_mi); g_signal_connect(G_OBJECT(logout_mi), DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED, G_CALLBACK(show_dialog), "logout"); - if (can_suspend) { + if (can_suspend && allow_suspend) { suspend_mi = dbusmenu_menuitem_new(); dbusmenu_menuitem_property_set(suspend_mi, DBUSMENU_MENUITEM_PROP_LABEL, _("Sleep")); dbusmenu_menuitem_child_append(root, suspend_mi); g_signal_connect(G_OBJECT(suspend_mi), DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED, G_CALLBACK(machine_sleep), "Suspend"); } - if (can_hibernate) { + if (can_hibernate && allow_hibernate) { hibernate_mi = dbusmenu_menuitem_new(); dbusmenu_menuitem_property_set(hibernate_mi, DBUSMENU_MENUITEM_PROP_LABEL, _("Hibernate")); dbusmenu_menuitem_child_append(root, hibernate_mi); -- cgit v1.2.3 From 05cd0a2405c81a1147ae519b9fa89e0579284abe Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Mon, 15 Mar 2010 17:02:31 -0500 Subject: Grabbing the upower definition file so that we can build a client for it. --- src/Makefile.am | 9 ++ src/upower.xml | 309 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 318 insertions(+) create mode 100644 src/upower.xml (limited to 'src') diff --git a/src/Makefile.am b/src/Makefile.am index 3037a3b..db41db6 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -33,6 +33,13 @@ users-service-client.h: $(srcdir)/users-service.xml --output=users-service-client.h \ $(srcdir)/users-service.xml +upower-client.h: $(srcdir)/upower.xml + dbus-binding-tool \ + --prefix=_upower_client \ + --mode=glib-client \ + --output=upower-client.h \ + $(srcdir)/upower.xml + session-dbus-client.h: $(srcdir)/session-dbus.xml dbus-binding-tool \ --prefix=_session_dbus_client \ @@ -108,6 +115,7 @@ BUILT_SOURCES = \ consolekit-manager-client.h \ session-dbus-client.h \ session-dbus-server.h \ + upower-client.h \ users-service-client.h \ users-service-marshal.h \ users-service-marshal.c @@ -115,6 +123,7 @@ BUILT_SOURCES = \ EXTRA_DIST = \ consolekit-manager.xml \ session-dbus.xml \ + upower.xml \ users-service.xml \ users-service.list diff --git a/src/upower.xml b/src/upower.xml new file mode 100644 index 0000000..a4066ff --- /dev/null +++ b/src/upower.xml @@ -0,0 +1,309 @@ + + + + + + + + The DeviceKit-power service is available via the system message + bus. To access the service, use + the org.freedesktop.UPower interface on + the /org/freedesktop/UPower object on + the D-Bus system bus service with the well-known + name org.freedesktop.UPower. + + + + +$ dbus-send --print-reply \ + --system \ + --dest=org.freedesktop.UPower \ + /org/freedesktop/UPower \ + org.freedesktop.UPower.EnumerateDevices + +method return sender=:1.386 -> dest=:1.451 reply_serial=2 + array [ + object path "/org/freedesktop/UPower/devices/line_power_AC" + object path "/org/freedesktop/UPower/devices/battery_BAT0" + ] + + + + + + + + + + + + An array of object paths for devices. + + + + + + Enumerate all power objects on the system. + + + + + + + + + + Object path of device that was added. + + + + + + Emitted when a device is added. + + + + + + + + + + Object path of device that was removed. + + + + + + Emitted when a device is removed. + + + + + + + + + + Object path of device that was changed. + + + + + + Emitted when a device changed. + + + + + + + + + + + + Emitted when one or more properties on the object changes. + + + + + + + + + + + + This signal is sent when the session is about to be suspended or + hibernated. + Session and system programs have one second to do anything required + before the sleep action is taken (such as sending out Avahi or + Jabber messages). + + + + + + + + + + + + This signal is sent when the session has just returned from + Suspend() or Hibernate(). + Session and system programs can then do anything required (such as + sending out Avahi or Jabber messages). + + + + + + + + + + + + + This method tells UPower that the Suspend() or Hibernate() method + is about to be called. + This allows UPower to emit the Suspending signal whilst + session activities are happening that have to be done before the + suspend process is started. + + + This method would typically be called by the session power + management daemon, before it locks the screen and waits for the + screen to fade to black. + The session power management component would then call Suspend() or + Hibernate() when these syncronous tasks have completed. + + + If this method is not called than nothing bad will happen and + Suspend() or Hibernate() will block for the required second. + + + + + + + + + + + + + Suspends the computer into a low power state. + System state is not preserved if the power is lost. + + + If AboutToRequestSleep() has not been called then UPower will send + the Sleeping() signal and block for one second. + + + If AboutToRequestSleep() has been called less than one second + before this method is called then UPower will block for the + remaining time to complete one second of delay. + + + + + + + + + + + TRUE if allowed, otherwise FALSE + + + + + Check if the caller has (or can get) the PolicyKit privilege to call + Suspend. + + + + + + + + + + + + + Hibernates the computer into a low power state. + System state is preserved if the power is lost. + + + If AboutToRequestSleep() has not been called then UPower will send + the Sleeping() signal and block for one second. + + + If AboutToRequestSleep() has been called less than one second + before this method is called then UPower will block for the + remaining time to complete one second of delay. + + + + + + + + + + + TRUE if allowed, otherwise FALSE + + + + + Check if the caller has (or can get) the PolicyKit privilege to call + Hibernate. + + + + + + + + + + Version of the running daemon, e.g. 002. + + + + + + Whether the system is able to suspend. + + + + + + Whether the system is able to hibernate. + + + + + + Indicates whether the system is running on battery power. + This property is provided for convenience. + + + + + + Indicates whether the system is running on battery power and if the battery is critically low. + This property is provided for convenience. + + + + + + + + Indicates if the laptop lid is closed where the display cannot be seen. + + + + + + + + + + If the system has a lid device. + + + + + + + + -- cgit v1.2.3 From 28ef20a9ad4b4b5e931b6eb4833accf44c65951f Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Mon, 15 Mar 2010 17:15:16 -0500 Subject: Use the upower allowed interface to check to see if PK is blocking suspend and hibernate --- src/session-service.c | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'src') diff --git a/src/session-service.c b/src/session-service.c index a915884..9dd50bf 100644 --- a/src/session-service.c +++ b/src/session-service.c @@ -47,6 +47,7 @@ with this program. If not, see . #include "session-dbus.h" #include "users-service-dbus.h" #include "lock-helper.h" +#include "upower-client.h" #define UP_ADDRESS "org.freedesktop.UPower" #define UP_OBJECT "/org/freedesktop/UPower" @@ -254,6 +255,20 @@ up_changed_cb (DBusGProxy * proxy, gpointer user_data) return; } +/* Handle the callback from the allow functions to check and + see if we're changing the value, and if so, rebuilding the + menus based on that info. */ +static void +allowed_cb (DBusGProxy *proxy, gboolean OUT_allowed, GError *error, gpointer userdata) +{ + gboolean * can_do = (gboolean *)userdata; + + if (OUT_allowed != *can_do) { + *can_do = OUT_allowed; + rebuild_items (root_menuitem, dbus_interface); + } +} + /* This function goes through and sets up what we need for DKp checking. We're even setting up the calls for the props we need */ @@ -292,6 +307,14 @@ setup_up (void) { /* Force an original "changed" event */ up_changed_cb(up_main_proxy, NULL); + /* Check to see if these are getting blocked by PolicyKit */ + org_freedesktop_UPower_suspend_allowed_async(up_main_proxy, + allowed_cb, + &allow_suspend); + org_freedesktop_UPower_hibernate_allowed_async(up_main_proxy, + allowed_cb, + &allow_hibernate); + return; } -- cgit v1.2.3 From 2d17c4577bdf36b417ede0eb12c771f89be74a99 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Mon, 15 Mar 2010 17:17:39 -0500 Subject: Checking the error to make sure we're getting back reasonable data or reporting the error. --- src/session-service.c | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'src') diff --git a/src/session-service.c b/src/session-service.c index 9dd50bf..7c7e513 100644 --- a/src/session-service.c +++ b/src/session-service.c @@ -261,6 +261,11 @@ up_changed_cb (DBusGProxy * proxy, gpointer user_data) static void allowed_cb (DBusGProxy *proxy, gboolean OUT_allowed, GError *error, gpointer userdata) { + if (error != NULL) { + g_warning("Unable to get information on what is allowed from UPower: %s", error->message); + return; + } + gboolean * can_do = (gboolean *)userdata; if (OUT_allowed != *can_do) { -- cgit v1.2.3 From c90b0b458471bf826dbe0402d13bfc9f95793ed7 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Mon, 15 Mar 2010 20:19:27 -0500 Subject: Lock the screen in the various activate functions. --- src/session-service.c | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'src') diff --git a/src/session-service.c b/src/session-service.c index fa90da2..aff963d 100644 --- a/src/session-service.c +++ b/src/session-service.c @@ -342,6 +342,9 @@ static void activate_guest_session (DbusmenuMenuitem * mi, guint timestamp, gpointer user_data) { GError * error = NULL; + + lock_screen(mi, timestamp, user_data); + if (!g_spawn_command_line_async(GUEST_SESSION_LAUNCHER, &error)) { g_warning("Unable to start guest session: %s", error->message); g_error_free(error); @@ -382,6 +385,9 @@ static void activate_new_session (DbusmenuMenuitem * mi, guint timestamp, gpointer user_data) { GError * error = NULL; + + lock_screen(mi, timestamp, user_data); + if (!g_spawn_command_line_async("gdmflexiserver --startnew", &error)) { g_warning("Unable to start new session: %s", error->message); g_error_free(error); @@ -397,6 +403,8 @@ activate_user_session (DbusmenuMenuitem *mi, guint timestamp, gpointer user_data UserData *user = (UserData *)user_data; UsersServiceDbus *service = user->service; + lock_screen(mi, timestamp, user_data); + users_service_dbus_activate_user_session (service, user); } -- cgit v1.2.3 From 40e7ac045c4c4cb93b71bf532187891f67825ce3 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Mon, 15 Mar 2010 20:46:01 -0500 Subject: Making a small little wrapper to check the lockdown key. --- src/session-service.c | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/session-service.c b/src/session-service.c index 3832e89..020aad3 100644 --- a/src/session-service.c +++ b/src/session-service.c @@ -129,6 +129,20 @@ ensure_gconf_client (void) return; } +/* Check to see if the lockdown key is protecting from + locking the screen. If not, lock it. */ +static void +lock_if_possible (void) { + ensure_gconf_client (); + + if (!gconf_client_get_bool (gconf_client, LOCKDOWN_KEY_SCREENSAVER, NULL)) { + lock_screen(NULL, 0, NULL); + } + + return; +} + + /* A return from the command to sleep the system. Make sure that we unthrottle the screensaver. */ static void @@ -150,7 +164,7 @@ machine_sleep (DbusmenuMenuitem * mi, guint timestamp, gpointer userdata) } screensaver_throttle(type); - lock_screen(NULL, 0, NULL); + lock_if_possible(); dbus_g_proxy_begin_call(up_main_proxy, type, @@ -341,7 +355,7 @@ activate_guest_session (DbusmenuMenuitem * mi, guint timestamp, gpointer user_da { GError * error = NULL; - lock_screen(mi, timestamp, user_data); + lock_if_possible(); if (!g_spawn_command_line_async(GUEST_SESSION_LAUNCHER, &error)) { g_warning("Unable to start guest session: %s", error->message); @@ -384,7 +398,7 @@ activate_new_session (DbusmenuMenuitem * mi, guint timestamp, gpointer user_data { GError * error = NULL; - lock_screen(mi, timestamp, user_data); + lock_if_possible(); if (!g_spawn_command_line_async("gdmflexiserver --startnew", &error)) { g_warning("Unable to start new session: %s", error->message); @@ -401,7 +415,7 @@ activate_user_session (DbusmenuMenuitem *mi, guint timestamp, gpointer user_data UserData *user = (UserData *)user_data; UsersServiceDbus *service = user->service; - lock_screen(mi, timestamp, user_data); + lock_if_possible(); users_service_dbus_activate_user_session (service, user); } -- cgit v1.2.3 From 9efeb48b00b52c8c2886c1c3a69d96d80b92d84d Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Mon, 15 Mar 2010 20:47:28 -0500 Subject: Switching the debug message to be more correct. --- src/lock-helper.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/lock-helper.c b/src/lock-helper.c index b38be65..47dcb71 100644 --- a/src/lock-helper.c +++ b/src/lock-helper.c @@ -182,7 +182,7 @@ lock_screen (DbusmenuMenuitem * mi, guint timestamp, gpointer data) { g_debug("Lock Screen"); if (!will_lock_screen()) { - g_debug("\tGDM set to autologin, blocking lock"); + g_debug("\tUser is guest, blocking lock"); return; } -- cgit v1.2.3 From 868fd5ed54d3d3e5ce8c054c9381602a2671e34d Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Mon, 15 Mar 2010 21:50:48 -0500 Subject: Update to handle the new key for showing the logout menu item. --- src/gconf-helper.c | 23 ++++++++++++++++++++++- src/gconf-helper.h | 8 +++++--- 2 files changed, 27 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/gconf-helper.c b/src/gconf-helper.c index 5efc439..588b11c 100644 --- a/src/gconf-helper.c +++ b/src/gconf-helper.c @@ -43,6 +43,14 @@ supress_confirmations (void) { return gconf_client_get_bool (gconf_client, SUPPRESS_KEY, NULL) ; } +gboolean +show_logout (void) { + if(!gconf_client) { + gconf_client = gconf_client_get_default (); + } + return !gconf_client_get_bool (gconf_client, LOGOUT_KEY, NULL) ; +} + static void update_menu_entries_callback (GConfClient *client, guint cnxn_id, GConfEntry *entry, gpointer data) { RestartShutdownLogoutMenuItems * restart_shutdown_logout_mi = (RestartShutdownLogoutMenuItems*) data; GConfValue * value = gconf_entry_get_value (entry); @@ -61,8 +69,19 @@ static void update_menu_entries_callback (GConfClient *client, guint cnxn_id, GC } } +static void +update_logout_callback (GConfClient *client, guint cnxn_id, GConfEntry *entry, gpointer data) { + DbusmenuMenuitem * mi = (DbusmenuMenuitem*) data; + GConfValue * value = gconf_entry_get_value (entry); + const gchar * key = gconf_entry_get_key (entry); + + if(g_strcmp0 (key, LOGOUT_KEY) == 0) { + dbusmenu_menuitem_property_set_bool(mi, DBUSMENU_MENUITEM_PROP_VISIBLE, !gconf_value_get_bool(value)); + } +} + void -update_menu_entries(RestartShutdownLogoutMenuItems * restart_shutdown_logout_mi) { +update_menu_entries(RestartShutdownLogoutMenuItems * restart_shutdown_logout_mi, DbusmenuMenuitem * logoutitem) { if(!gconf_client) { gconf_client = gconf_client_get_default (); } @@ -70,5 +89,7 @@ update_menu_entries(RestartShutdownLogoutMenuItems * restart_shutdown_logout_mi) GCONF_CLIENT_PRELOAD_ONELEVEL, NULL); gconf_client_notify_add (gconf_client, SUPPRESS_KEY, update_menu_entries_callback, restart_shutdown_logout_mi, NULL, NULL); + gconf_client_notify_add (gconf_client, LOGOUT_KEY, + update_logout_callback, logoutitem, NULL, NULL); } diff --git a/src/gconf-helper.h b/src/gconf-helper.h index 951bb0f..6f9bcb7 100644 --- a/src/gconf-helper.h +++ b/src/gconf-helper.h @@ -33,8 +33,9 @@ with this program. If not, see . #include #include -#define SUPPRESS_KEY "/apps/indicator-session/suppress_logout_restart_shutdown" -#define GLOBAL_DIR "/apps/indicator-session" +#define GLOBAL_DIR "/apps/indicator-session" +#define SUPPRESS_KEY GLOBAL_DIR "/suppress_logout_restart_shutdown" +#define LOGOUT_KEY GLOBAL_DIR "/suppress_logout_menuitem" typedef struct _RestartShutdownLogoutMenuItems { @@ -44,7 +45,8 @@ typedef struct _RestartShutdownLogoutMenuItems } RestartShutdownLogoutMenuItems; -void update_menu_entries(RestartShutdownLogoutMenuItems*); +void update_menu_entries(RestartShutdownLogoutMenuItems*, DbusmenuMenuitem * logoutitem); gboolean supress_confirmations (void); +gboolean show_logout (void); #endif /* __GCONF_HELPER__ */ -- cgit v1.2.3 From ae2c94b40826bfa0274a3eae8ae515d99b07adb5 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Mon, 15 Mar 2010 21:51:14 -0500 Subject: Add in checking whether the logout button is shown, and get it changing with the others. --- src/session-service.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/session-service.c b/src/session-service.c index fa90da2..6f27d2c 100644 --- a/src/session-service.c +++ b/src/session-service.c @@ -554,6 +554,7 @@ rebuild_items (DbusmenuMenuitem *root, } else { dbusmenu_menuitem_property_set(logout_mi, DBUSMENU_MENUITEM_PROP_LABEL, _("Log Out...")); } + dbusmenu_menuitem_property_set_bool(logout_mi, DBUSMENU_MENUITEM_PROP_VISIBLE, show_logout()); dbusmenu_menuitem_child_append(root, logout_mi); g_signal_connect(G_OBJECT(logout_mi), DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED, G_CALLBACK(show_dialog), "logout"); @@ -593,7 +594,7 @@ rebuild_items (DbusmenuMenuitem *root, restart_shutdown_logout_mi->restart_mi = restart_mi; restart_shutdown_logout_mi->shutdown_mi = shutdown_mi; - update_menu_entries(restart_shutdown_logout_mi); + update_menu_entries(restart_shutdown_logout_mi, logout_mi); if (g_file_test(DESKTOP_FILE, G_FILE_TEST_EXISTS)) { GAppInfo * appinfo = G_APP_INFO(g_desktop_app_info_new_from_filename(DESKTOP_FILE)); -- cgit v1.2.3