From a3fcb8c2842c861a9d006f6bd63b21d2534c50a3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20M=C3=BCllner?= Date: Thu, 17 May 2012 01:43:59 +0200 Subject: [PATCH] sessionMode: Add allowSettings property Add a sessionMode.allowSettings property, which determines whether menus in the top bar should allow access to System Settings or not. https://bugzilla.gnome.org/show_bug.cgi?id=676156 --- js/ui/popupMenu.js | 3 +-- js/ui/sessionMode.js | 2 ++ js/ui/status/keyboard.js | 6 +++++- js/ui/userMenu.js | 11 +++++++---- 4 files changed, 15 insertions(+), 7 deletions(-) diff --git a/js/ui/popupMenu.js b/js/ui/popupMenu.js index 1ec5e55ef..35843d901 100644 --- a/js/ui/popupMenu.js +++ b/js/ui/popupMenu.js @@ -888,8 +888,7 @@ const PopupMenuBase = new Lang.Class({ }, addSettingsAction: function(title, desktopFile) { - // Don't allow user settings to get edited unless we're in a user session - if (Main.sessionMode.sessionType != Shell.SessionType.USER) + if (!Main.sessionMode.allowSettings) return null; let menuItem = this.addAction(title, function() { diff --git a/js/ui/sessionMode.js b/js/ui/sessionMode.js index df2592313..257214934 100644 --- a/js/ui/sessionMode.js +++ b/js/ui/sessionMode.js @@ -11,11 +11,13 @@ const _modes = { 'gdm': { hasOverview: false, hasAppMenu: false, showCalendarEvents: false, + allowSettings: false, sessionType: Shell.SessionType.GDM }, 'user': { hasOverview: true, hasAppMenu: true, showCalendarEvents: true, + allowSettings: true, sessionType: Shell.SessionType.USER } }; diff --git a/js/ui/status/keyboard.js b/js/ui/status/keyboard.js index c5400bc6b..90dd8f6e6 100644 --- a/js/ui/status/keyboard.js +++ b/js/ui/status/keyboard.js @@ -63,7 +63,11 @@ const XKBIndicator = new Lang.Class({ this._syncConfig(); - if (Main.sessionMode.sessionType == Shell.SessionType.USER) { + // re-using "allowSettings" for the keyboard layout is a bit shady, + // but at least for now it is used as "allow popping up windows + // from shell menus"; we can always add a separate sessionMode + // option if need arises. + if (Main.sessionMode.allowSettings) { this.menu.addMenuItem(new PopupMenu.PopupSeparatorMenuItem()); this.menu.addAction(_("Show Keyboard Layout"), Lang.bind(this, function() { Main.overview.hide(); diff --git a/js/ui/userMenu.js b/js/ui/userMenu.js index 07c0a1960..bc21fdf22 100644 --- a/js/ui/userMenu.js +++ b/js/ui/userMenu.js @@ -624,7 +624,8 @@ const UserMenuButton = new Lang.Class({ let item; item = new IMStatusChooserItem(); - item.connect('activate', Lang.bind(this, this._onMyAccountActivate)); + if (Main.sessionMode.allowSettings) + item.connect('activate', Lang.bind(this, this._onMyAccountActivate)); this.menu.addMenuItem(item); this._statusChooser = item; @@ -636,9 +637,11 @@ const UserMenuButton = new Lang.Class({ item = new PopupMenu.PopupSeparatorMenuItem(); this.menu.addMenuItem(item); - item = new PopupMenu.PopupMenuItem(_("System Settings")); - item.connect('activate', Lang.bind(this, this._onPreferencesActivate)); - this.menu.addMenuItem(item); + if (Main.sessionMode.allowSettings) { + item = new PopupMenu.PopupMenuItem(_("System Settings")); + item.connect('activate', Lang.bind(this, this._onPreferencesActivate)); + this.menu.addMenuItem(item); + } item = new PopupMenu.PopupAlternatingMenuItem(_("Power Off"), _("Suspend"));