sessionMode: Allow changing the session mode at runtime
Since we eventually want to add a system for changing the top panel contents depending on the current state of the shell, let's use the "session mode" feature for this, and add a mechanism for updating the session mode at runtime. Add support for every key besides the two functional keys, and make all the components update automatically when the session mode is changed. Add a new lock-screen mode, and make the lock screen change to this when locked. https://bugzilla.gnome.org/show_bug.cgi?id=683156
This commit is contained in:
@ -870,6 +870,12 @@ const PopupMenuBase = new Lang.Class({
|
||||
this._activeMenuItem = null;
|
||||
this._childMenus = [];
|
||||
this._settingsActions = { };
|
||||
|
||||
this._sessionUpdatedId = Main.sessionMode.connect('updated', Lang.bind(this, this._sessionUpdated));
|
||||
},
|
||||
|
||||
_sessionUpdated: function() {
|
||||
this._setSettingsVisibility(Main.sessionMode.allowSettings);
|
||||
},
|
||||
|
||||
addAction: function(title, callback) {
|
||||
@ -883,9 +889,6 @@ const PopupMenuBase = new Lang.Class({
|
||||
},
|
||||
|
||||
addSettingsAction: function(title, desktopFile) {
|
||||
if (!Main.sessionMode.allowSettings)
|
||||
return null;
|
||||
|
||||
let menuItem = this.addAction(title, function() {
|
||||
let app = Shell.AppSystem.get_default().lookup_setting(desktopFile);
|
||||
|
||||
@ -903,7 +906,7 @@ const PopupMenuBase = new Lang.Class({
|
||||
return menuItem;
|
||||
},
|
||||
|
||||
setSettingsVisibility: function(visible) {
|
||||
_setSettingsVisibility: function(visible) {
|
||||
for (let id in this._settingsActions) {
|
||||
let item = this._settingsActions[id];
|
||||
item.actor.visible = visible;
|
||||
@ -1172,6 +1175,9 @@ const PopupMenuBase = new Lang.Class({
|
||||
this.actor.destroy();
|
||||
|
||||
this.emit('destroy');
|
||||
|
||||
Main.sessionMode.disconnect(this._sessionUpdatedId);
|
||||
this._sessionUpdatedId = 0;
|
||||
}
|
||||
});
|
||||
Signals.addSignalMethods(PopupMenuBase.prototype);
|
||||
@ -2041,6 +2047,9 @@ const PopupMenuManager = new Lang.Class({
|
||||
},
|
||||
|
||||
addMenu: function(menu, position) {
|
||||
if (this._findMenu(menu) > -1)
|
||||
return;
|
||||
|
||||
let menudata = {
|
||||
menu: menu,
|
||||
openStateChangeId: menu.connect('open-state-changed', Lang.bind(this, this._onMenuOpenState)),
|
||||
|
Reference in New Issue
Block a user