[gnome-shell/wip/rstrode/make-lock-down-keys-rule: 121/122] systemActions: Move mode check for logout and switch users to caller




commit e4d43d50e6bbc847d0a9d1d31ea0e0e3e8689801
Author: Ray Strode <rstrode redhat com>
Date:   Wed Jul 21 16:36:09 2021 -0400

    systemActions: Move mode check for logout and switch users to caller
    
    At the moment the systemActions are tied very closely to what gets
    displayed in the system menu.
    
    But some system actions, like user switching, may get presented
    elsewhere in the UI than the system menu depending on the session
    mode.
    
    This commit moves the session mode check from the system actions code,
    to the system menu code, so that the system actions code can get used
    for other parts of the UI in a later commit.

 js/misc/systemActions.js |  6 ++----
 js/ui/status/system.js   | 18 ++++++++++++++----
 2 files changed, 16 insertions(+), 8 deletions(-)
---
diff --git a/js/misc/systemActions.js b/js/misc/systemActions.js
index 10cab9a9e2..8454826c6f 100644
--- a/js/misc/systemActions.js
+++ b/js/misc/systemActions.js
@@ -363,9 +363,8 @@ const SystemActions = GObject.registerClass({
     _updateSwitchUser() {
         let allowSwitch = !this._lockdownSettings.get_boolean(DISABLE_USER_SWITCH_KEY);
         let multiUser = this._userManager.can_switch() && this._userManager.has_multiple_users;
-        let shouldShowInMode = !Main.sessionMode.isLocked && !Main.sessionMode.isGreeter;
 
-        let visible = allowSwitch && multiUser && shouldShowInMode;
+        let visible = allowSwitch && multiUser;
         this._actions.get(SWITCH_USER_ACTION_ID).available = visible;
         this.notify('can-switch-user');
 
@@ -381,9 +380,8 @@ const SystemActions = GObject.registerClass({
         let localAccount = user.local_account;
         let multiUser = this._userManager.has_multiple_users;
         let multiSession = Gdm.get_session_ids().length > 1;
-        let shouldShowInMode = !Main.sessionMode.isLocked && !Main.sessionMode.isGreeter;
 
-        let visible = allowLogout && (alwaysShow || multiUser || multiSession || systemAccount || 
!localAccount) && shouldShowInMode;
+        let visible = allowLogout && (alwaysShow || multiUser || multiSession || systemAccount || 
!localAccount);
         this._actions.get(LOGOUT_ACTION_ID).available = visible;
         this.notify('can-logout');
 
diff --git a/js/ui/status/system.js b/js/ui/status/system.js
index 6f71109c52..3ef9f28a62 100644
--- a/js/ui/status/system.js
+++ b/js/ui/status/system.js
@@ -108,9 +108,14 @@ class Indicator extends PanelMenu.SystemIndicator {
         });
         this.menu.addMenuItem(item);
         this._lockScreenItem = item;
-        this._systemActions.bind_property('can-lock-screen',
+        this._systemActions.bind_property_full('can-lock-screen',
             this._lockScreenItem, 'visible',
-            bindFlags);
+            bindFlags,
+            (binding, from, to) => {
+                let shouldShowInMode = !Main.sessionMode.isLocked && !Main.sessionMode.isGreeter;
+                to.set_boolean(from.get_boolean() && shouldShowInMode);
+                return true; },
+            () => false);
 
         this._sessionSubMenu = new PopupMenu.PopupSubMenuMenuItem(
             _('Power Off / Log Out'), true);
@@ -158,9 +163,14 @@ class Indicator extends PanelMenu.SystemIndicator {
         });
         this._sessionSubMenu.menu.addMenuItem(item);
         this._logoutItem = item;
-        this._systemActions.bind_property('can-logout',
+        this._systemActions.bind_property_full('can-logout',
             this._logoutItem, 'visible',
-            bindFlags);
+            bindFlags,
+            (binding, from, to) => {
+                let shouldShowInMode = !Main.sessionMode.isLocked && !Main.sessionMode.isGreeter;
+                to.set_boolean(from.get_boolean) && shouldShowInMode;
+                return true; },
+            () => false);
 
         item = new PopupMenu.PopupMenuItem(_('Switch User…'));
         item.connect('activate', () => {


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]