[gnome-shell] user-status: Honor lockdown settings



commit 0eaf141ae4595d862ca1c68097ac1253bac18fce
Author: Florian Müllner <fmuellner gnome org>
Date:   Mon Mar 21 13:51:46 2011 +0100

    user-status: Honor lockdown settings
    
    Right now, the user status menu always contains actions to logout
    and lock the screen, and the user switching action only depends on
    the technical availability of the functionality.
    All those items should honor the lockdown settings defined in
    org.gnome.desktop.lockdown.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=645335

 js/ui/statusMenu.js |   52 ++++++++++++++++++++++++++++++++++++++++++++++++++-
 1 files changed, 51 insertions(+), 1 deletions(-)
---
diff --git a/js/ui/statusMenu.js b/js/ui/statusMenu.js
index 26a4fe4..d91e46e 100644
--- a/js/ui/statusMenu.js
+++ b/js/ui/statusMenu.js
@@ -2,6 +2,7 @@
 
 const Gdm = imports.gi.Gdm;
 const DBus = imports.dbus;
+const Gio = imports.gi.Gio;
 const GLib = imports.gi.GLib;
 const Lang = imports.lang;
 const Shell = imports.gi.Shell;
@@ -20,6 +21,11 @@ const Util = imports.misc.util;
 const BUS_NAME = 'org.gnome.ScreenSaver';
 const OBJECT_PATH = '/org/gnome/ScreenSaver';
 
+const LOCKDOWN_SCHEMA = 'org.gnome.desktop.lockdown';
+const DISABLE_USER_SWITCH_KEY = 'disable-user-switching';
+const DISABLE_LOCK_SCREEN_KEY = 'disable-lock-screen';
+const DISABLE_LOG_OUT_KEY = 'disable-log-out';
+
 const ScreenSaverInterface = {
     name: BUS_NAME,
     methods: [ { name: 'Lock', inSignature: '' } ]
@@ -44,6 +50,8 @@ StatusMenuButton.prototype = {
         let box = new St.BoxLayout({ name: 'panelStatusMenu' });
         this.actor.set_child(box);
 
+        this._lockdownSettings = new Gio.Settings({ schema: LOCKDOWN_SCHEMA });
+
         this._gdm = Gdm.UserManager.ref_default();
         this._gdm.queue_load();
 
@@ -79,6 +87,15 @@ StatusMenuButton.prototype = {
         this._gdm.connect('notify::is-loaded', Lang.bind(this, this._updateSwitchUser));
         this._gdm.connect('user-added', Lang.bind(this, this._updateSwitchUser));
         this._gdm.connect('user-removed', Lang.bind(this, this._updateSwitchUser));
+        this._lockdownSettings.connect('changed::' + DISABLE_USER_SWITCH_KEY,
+                                       Lang.bind(this, this._updateSwitchUser));
+        this._lockdownSettings.connect('changed::' + DISABLE_LOG_OUT_KEY,
+                                       Lang.bind(this, this._updateLogout));
+        this._lockdownSettings.connect('changed::' + DISABLE_LOCK_SCREEN_KEY,
+                                       Lang.bind(this, this._updateLockScreen));
+        this._updateSwitchUser();
+        this._updateLogout();
+        this._updateLockScreen();
 
         this._upClient.connect('notify::can-suspend', Lang.bind(this, this._updateSuspendOrPowerOff));
     },
@@ -95,11 +112,41 @@ StatusMenuButton.prototype = {
           this._name.set_text("");
     },
 
+    _updateSessionSeparator: function() {
+        let showSeparator = this._loginScreenItem.actor.visible ||
+                            this._logoutItem.actor.visible ||
+                            this._lockScreenItem.actor.visible;
+        if (showSeparator)
+            this._sessionSeparator.actor.show();
+        else
+            this._sessionSeparator.actor.hide();
+    },
+
     _updateSwitchUser: function() {
-        if (this._gdm.can_switch ())
+        let allowSwitch = !this._lockdownSettings.get_boolean(DISABLE_USER_SWITCH_KEY);
+        if (allowSwitch && this._gdm.can_switch ())
             this._loginScreenItem.actor.show();
         else
             this._loginScreenItem.actor.hide();
+        this._updateSessionSeparator();
+    },
+
+    _updateLogout: function() {
+        let allowLogout = !this._lockdownSettings.get_boolean(DISABLE_LOG_OUT_KEY);
+        if (allowLogout)
+            this._logoutItem.actor.show();
+        else
+            this._logoutItem.actor.hide();
+        this._updateSessionSeparator();
+    },
+
+    _updateLockScreen: function() {
+        let allowLockScreen = !this._lockdownSettings.get_boolean(DISABLE_LOCK_SCREEN_KEY);
+        if (allowLockScreen)
+            this._lockScreenItem.actor.show();
+        else
+            this._lockScreenItem.actor.hide();
+        this._updateSessionSeparator();
     },
 
     _updateSuspendOrPowerOff: function() {
@@ -161,6 +208,7 @@ StatusMenuButton.prototype = {
         item = new PopupMenu.PopupMenuItem(_("Lock Screen"));
         item.connect('activate', Lang.bind(this, this._onLockScreenActivate));
         this.menu.addMenuItem(item);
+        this._lockScreenItem = item;
 
         item = new PopupMenu.PopupMenuItem(_("Switch User"));
         item.connect('activate', Lang.bind(this, this._onLoginScreenActivate));
@@ -170,9 +218,11 @@ StatusMenuButton.prototype = {
         item = new PopupMenu.PopupMenuItem(_("Log Out..."));
         item.connect('activate', Lang.bind(this, this._onQuitSessionActivate));
         this.menu.addMenuItem(item);
+        this._logoutItem = item;
 
         item = new PopupMenu.PopupSeparatorMenuItem();
         this.menu.addMenuItem(item);
+        this._sessionSeparator = item;
 
         item = new PopupMenu.PopupAlternatingMenuItem(_("Suspend"),
                                                       _("Power Off..."));



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