diff options
author | Sean Davis <smd.seandavis@gmail.com> | 2017-09-20 20:39:12 -0400 |
---|---|---|
committer | Sean Davis <smd.seandavis@gmail.com> | 2017-09-20 20:39:12 -0400 |
commit | 6f8277a6da9f097948e07b12dda6aafbae0acdcb (patch) | |
tree | 99152a5860d7aad9c49206098ec236ad7696efd0 | |
parent | 8ef0b29540eb3bf80c274ad9d29daf5f67b3e529 (diff) | |
download | lightdm-gtk-greeter-git-6f8277a6da9f097948e07b12dda6aafbae0acdcb.tar.gz |
Prevent Alt+F4 shutdown if power indicator is not present (LP: #1690129)
-rw-r--r-- | src/lightdm-gtk-greeter.c | 32 |
1 files changed, 29 insertions, 3 deletions
diff --git a/src/lightdm-gtk-greeter.c b/src/lightdm-gtk-greeter.c index 6cd8961..013f524 100644 --- a/src/lightdm-gtk-greeter.c +++ b/src/lightdm-gtk-greeter.c @@ -94,6 +94,9 @@ static GtkButton *power_ok_button, *power_cancel_button; static GtkLabel *power_title, *power_text; static GtkImage *power_icon; +static const gchar *DEFAULT_LAYOUT[] = {"~spacer", "~spacer", "~host", "~spacer", + "~session", "~a11y", "~clock", NULL}; + static const gchar *POWER_WINDOW_DATA_LOOP = "power-window-loop"; /* <GMainLoop*> */ static const gchar *POWER_WINDOW_DATA_RESPONSE = "power-window-response"; /* <GtkResponseType> */ @@ -459,6 +462,32 @@ show_power_prompt (const gchar *action, const gchar* icon, const gchar* title, c { gchar *new_message = NULL; + gchar **names; + gsize length; + gboolean power_present; + int i; + + /* Do anything only when power indicator is present */ + power_present = FALSE; + names = config_get_string_list (NULL, CONFIG_KEY_INDICATORS, NULL); + if (!names) + names = (gchar**)DEFAULT_LAYOUT; + length = g_strv_length (names); + for (i = 0; i < length; ++i) + { + if (g_strcmp0 (names[i], "~power") == 0) + { /* Power menu is present */ + power_present = TRUE; + break; + } + } + if (names && names != (gchar**)DEFAULT_LAYOUT) + g_strfreev (names); + + if (power_present != TRUE) { + return FALSE; + } + /* Check if there are still users logged in, count them and if so, display a warning */ gint logged_in_users = 0; GList *items = lightdm_user_list_get_users (lightdm_user_list_get_instance ()); @@ -1441,9 +1470,6 @@ init_indicators (void) gboolean inited = FALSE; #endif - const gchar *DEFAULT_LAYOUT[] = {"~host", "~spacer", "~clock", "~spacer", - "~session", "~language", "~a11y", "~power", NULL}; - gchar **names = config_get_string_list (NULL, CONFIG_KEY_INDICATORS, NULL); if (!names) names = (gchar**)DEFAULT_LAYOUT; |