cleanup: Use an extension object instead of globals

https://gitlab.gnome.org/GNOME/gnome-shell-extensions/issues/143
This commit is contained in:
Florian Müllner
2019-03-20 08:59:09 +00:00
committed by Florian Müllner
parent a024d9f005
commit 3671d5a299

View File

@@ -1,5 +1,5 @@
/* -*- mode: js2; js2-basic-offset: 4; indent-tabs-mode: nil -*- */
/* exported init enable disable */
/* exported init */
const { Clutter, St } = imports.gi;
const Main = imports.ui.main;
@@ -239,22 +239,26 @@ var MyWorkspacesView = class extends WorkspacesView.WorkspacesView {
}
};
let origWindowOverlay, origWorkspace, origWorkspacesView;
class Extension {
constructor() {
this._origWindowOverlay = Workspace.WindowOverlay;
this._origWorkspace = Workspace.Workspace;
this._origWorkspacesView = WorkspacesView.WorkspacesView;
}
enable() {
Workspace.WindowOverlay = MyWindowOverlay;
Workspace.Workspace = MyWorkspace;
WorkspacesView.WorkspacesView = MyWorkspacesView;
}
disable() {
Workspace.WindowOverlay = this._origWindowOverlay;
Workspace.Workspace = this._origWorkspace;
WorkspacesView.WorkspacesView = this._origWorkspacesView;
}
}
function init() {
origWindowOverlay = Workspace.WindowOverlay;
origWorkspace = Workspace.Workspace;
origWorkspacesView = WorkspacesView.WorkspacesView;
}
function enable() {
Workspace.WindowOverlay = MyWindowOverlay;
Workspace.Workspace = MyWorkspace;
WorkspacesView.WorkspacesView = MyWorkspacesView;
}
function disable() {
Workspace.WindowOverlay = origWindowOverlay;
Workspace.Workspace = origWorkspace;
WorkspacesView.WorkspacesView = origWorkspacesView;
return new Extension();
}