launch-new-instance: Use InjectionManager
The extension uses a straight-forward override that doesn't benefit a lot from the new InjectionManager class, but let's use the provided convenience API anyway. Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell-extensions/-/merge_requests/268>
This commit is contained in:
@@ -1,19 +1,23 @@
|
||||
const AppDisplay = imports.ui.appDisplay;
|
||||
import {InjectionManager} from 'resource:///org/gnome/shell/extensions/extension.js';
|
||||
|
||||
const {AppIcon} = imports.ui.appDisplay;
|
||||
|
||||
export default class Extension {
|
||||
constructor() {
|
||||
this._appIconProto = AppDisplay.AppIcon.prototype;
|
||||
this._activateOriginal = this._appIconProto.activate;
|
||||
this._injectionManager = new InjectionManager();
|
||||
}
|
||||
|
||||
enable() {
|
||||
const {_activateOriginal} = this;
|
||||
this._appIconProto.activate = function () {
|
||||
_activateOriginal.call(this, 2);
|
||||
};
|
||||
this._injectionManager.overrideMethod(AppIcon.prototype, 'activate',
|
||||
originalMethod => {
|
||||
return function () {
|
||||
// eslint-disable-next-line no-invalid-this
|
||||
originalMethod.call(this, 2);
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
disable() {
|
||||
this._appIconProto.activate = this._activateOriginal;
|
||||
this._injectionManager.clear();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user