extension-tool: Use Extension base class in templates
The Extension/Preferences classes are where we will focus for future extension convenience API, so developers should be encouraged to use them as entry points. Adjust the existing templates to do that. Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/2838>
This commit is contained in:
parent
3e4fd4b67a
commit
348a8e49fe
@ -16,18 +16,15 @@
|
|||||||
* SPDX-License-Identifier: GPL-2.0-or-later
|
* SPDX-License-Identifier: GPL-2.0-or-later
|
||||||
*/
|
*/
|
||||||
|
|
||||||
const GETTEXT_DOMAIN = 'my-indicator-extension';
|
|
||||||
|
|
||||||
import GObject from 'gi://GObject';
|
import GObject from 'gi://GObject';
|
||||||
import St from 'gi://St';
|
import St from 'gi://St';
|
||||||
|
|
||||||
const ExtensionUtils = imports.misc.extensionUtils;
|
import {Extension, gettext as _} from 'resource:///org/gnome/shell/extensions/extension.js';
|
||||||
|
|
||||||
const Main = imports.ui.main;
|
const Main = imports.ui.main;
|
||||||
const PanelMenu = imports.ui.panelMenu;
|
const PanelMenu = imports.ui.panelMenu;
|
||||||
const PopupMenu = imports.ui.popupMenu;
|
const PopupMenu = imports.ui.popupMenu;
|
||||||
|
|
||||||
const _ = ExtensionUtils.gettext;
|
|
||||||
|
|
||||||
const Indicator = GObject.registerClass(
|
const Indicator = GObject.registerClass(
|
||||||
class Indicator extends PanelMenu.Button {
|
class Indicator extends PanelMenu.Button {
|
||||||
_init() {
|
_init() {
|
||||||
@ -46,16 +43,10 @@ class Indicator extends PanelMenu.Button {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
export default class Extension {
|
export default class IndicatorExampleExtension extends Extension {
|
||||||
constructor(metadata) {
|
|
||||||
this._uuid = metadata.uuid;
|
|
||||||
|
|
||||||
ExtensionUtils.initTranslations(GETTEXT_DOMAIN);
|
|
||||||
}
|
|
||||||
|
|
||||||
enable() {
|
enable() {
|
||||||
this._indicator = new Indicator();
|
this._indicator = new Indicator();
|
||||||
Main.panel.addToStatusArea(this._uuid, this._indicator);
|
Main.panel.addToStatusArea(this.uuid, this._indicator);
|
||||||
}
|
}
|
||||||
|
|
||||||
disable() {
|
disable() {
|
||||||
|
@ -15,11 +15,9 @@
|
|||||||
*
|
*
|
||||||
* SPDX-License-Identifier: GPL-2.0-or-later
|
* SPDX-License-Identifier: GPL-2.0-or-later
|
||||||
*/
|
*/
|
||||||
|
import {Extension} from 'resource:///org/gnome/shell/extensions/extension.js';
|
||||||
|
|
||||||
export default class Extension {
|
export default class PlainExampleExtension extends Extension {
|
||||||
constructor() {
|
|
||||||
}
|
|
||||||
|
|
||||||
enable() {
|
enable() {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user