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
|
||||
*/
|
||||
|
||||
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() {
|
||||
|
@ -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() {
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user