From 239a9e4816af1545ad7b6c7f90660d0ea88d5ade Mon Sep 17 00:00:00 2001 From: Ray Strode Date: Sun, 28 Aug 2011 22:15:53 -0400 Subject: [PATCH] popupMenu: Hide settings menus outside user session The control-center contains user-pertinent settings panels. These panels don't make sense to show outside of a user's session, so hide them for session types other than SessionType.USER. https://bugzilla.gnome.org/show_bug.cgi?id=657082 --- js/ui/dateMenu.js | 13 +++++++------ js/ui/popupMenu.js | 4 ++++ 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/js/ui/dateMenu.js b/js/ui/dateMenu.js index dbab33648..37ce87b6d 100644 --- a/js/ui/dateMenu.js +++ b/js/ui/dateMenu.js @@ -97,13 +97,14 @@ DateMenuButton.prototype = { vbox.add(this._calendar.actor); item = this.menu.addSettingsAction(_("Date and Time Settings"), 'gnome-datetime-panel.desktop'); + if (item) { + let separator = new PopupMenu.PopupSeparatorMenuItem(); + separator.setColumnWidths(1); + vbox.add(separator.actor, {y_align: St.Align.END, expand: true, y_fill: false}); - let separator = new PopupMenu.PopupSeparatorMenuItem(); - separator.setColumnWidths(1); - vbox.add(separator.actor, {y_align: St.Align.END, expand: true, y_fill: false}); - - item.actor.can_focus = false; - item.actor.reparent(vbox); + item.actor.can_focus = false; + item.actor.reparent(vbox); + } if (params.showEvents) { // Add vertical separator diff --git a/js/ui/popupMenu.js b/js/ui/popupMenu.js index fc4956e25..afa851d44 100644 --- a/js/ui/popupMenu.js +++ b/js/ui/popupMenu.js @@ -813,6 +813,10 @@ PopupMenuBase.prototype = { }, addSettingsAction: function(title, desktopFile) { + // Don't allow user settings to get edited unless we're in a user session + if (global.session_type != Shell.SessionType.USER) + return null; + let menuItem = this.addAction(title, function() { let app = Shell.AppSystem.get_default().lookup_setting(desktopFile);