gnome-shell/js/extensions/prefs.js
Florian Müllner 3e4fd4b67a extensions: Add Extension/Preferences base classes
Extensions now must export a class that conforms to a particular
interface both for the actual extension as well as for prefs:

enable()/disable() methods for the former, fillPreferencesWindow()
for the latter.

This is quite similar to the previous method-based entry points,
but it also gives us a more structured way of providing convenience
API in form of base classes.

Do that in form of Extension and ExtensionPreferences classes on
top of a common ExtensionBase base class.

getSettings(), initTranslations() and the gettext wrappers are
now methods of the common base, while openPreferences() moves
to the Extension class.

Based on an original suggestion from Evan Welsh.

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/2838>
2023-07-29 15:20:20 +03:00

20 lines
575 B
JavaScript

import GObject from 'gi://GObject';
import {ExtensionBase, setExtensionManager} from './sharedInternals.js';
import {extensionManager} from '../extensionsService.js';
setExtensionManager(extensionManager);
export {gettext, ngettext, pgettext} from './sharedInternals.js';
export class ExtensionPreferences extends ExtensionBase {
/**
* Fill the preferences window with preferences.
*
* @param {Adw.PreferencesWindow} _window - the preferences window
*/
fillPreferencesWindow(_window) {
throw new GObject.NotImplementedError();
}
}