From 348a8e49fe42b24c28145cf039fb00ef6cd25153 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20M=C3=BCllner?= Date: Mon, 10 Jul 2023 11:50:15 +0200 Subject: [PATCH] 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: --- .../src/templates/indicator/extension.js | 17 ++++------------- .../src/templates/plain/extension.js | 6 ++---- 2 files changed, 6 insertions(+), 17 deletions(-) diff --git a/subprojects/extensions-tool/src/templates/indicator/extension.js b/subprojects/extensions-tool/src/templates/indicator/extension.js index 35784d846..d3afaac08 100644 --- a/subprojects/extensions-tool/src/templates/indicator/extension.js +++ b/subprojects/extensions-tool/src/templates/indicator/extension.js @@ -16,18 +16,15 @@ * SPDX-License-Identifier: GPL-2.0-or-later */ -const GETTEXT_DOMAIN = 'my-indicator-extension'; - import GObject from 'gi://GObject'; 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 PanelMenu = imports.ui.panelMenu; const PopupMenu = imports.ui.popupMenu; -const _ = ExtensionUtils.gettext; - const Indicator = GObject.registerClass( class Indicator extends PanelMenu.Button { _init() { @@ -46,16 +43,10 @@ class Indicator extends PanelMenu.Button { } }); -export default class Extension { - constructor(metadata) { - this._uuid = metadata.uuid; - - ExtensionUtils.initTranslations(GETTEXT_DOMAIN); - } - +export default class IndicatorExampleExtension extends Extension { enable() { this._indicator = new Indicator(); - Main.panel.addToStatusArea(this._uuid, this._indicator); + Main.panel.addToStatusArea(this.uuid, this._indicator); } disable() { diff --git a/subprojects/extensions-tool/src/templates/plain/extension.js b/subprojects/extensions-tool/src/templates/plain/extension.js index 5abdf6792..7c73f8e58 100644 --- a/subprojects/extensions-tool/src/templates/plain/extension.js +++ b/subprojects/extensions-tool/src/templates/plain/extension.js @@ -15,11 +15,9 @@ * * SPDX-License-Identifier: GPL-2.0-or-later */ +import {Extension} from 'resource:///org/gnome/shell/extensions/extension.js'; -export default class Extension { - constructor() { - } - +export default class PlainExampleExtension extends Extension { enable() { }