extensions: Add static lookupByUUID() method
This allows the Extension/Preferences classes to provide the UUID -> extension lookup without exposing the underlying extension manager. Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/2838>
This commit is contained in:
parent
931ca5e4ab
commit
82237a398f
@ -4,6 +4,10 @@ const {extensionManager} = imports.ui.main;
|
|||||||
setExtensionManager(extensionManager);
|
setExtensionManager(extensionManager);
|
||||||
|
|
||||||
export class Extension extends ExtensionBase {
|
export class Extension extends ExtensionBase {
|
||||||
|
static lookupByUUID(uuid) {
|
||||||
|
return extensionManager.lookup(uuid)?.stateObj ?? null;
|
||||||
|
}
|
||||||
|
|
||||||
static defineTranslationFunctions(url) {
|
static defineTranslationFunctions(url) {
|
||||||
const wrapper = new GettextWrapper(this, url);
|
const wrapper = new GettextWrapper(this, url);
|
||||||
return wrapper.defineTranslationFunctions();
|
return wrapper.defineTranslationFunctions();
|
||||||
|
@ -6,6 +6,10 @@ import {extensionManager} from '../extensionsService.js';
|
|||||||
setExtensionManager(extensionManager);
|
setExtensionManager(extensionManager);
|
||||||
|
|
||||||
export class ExtensionPreferences extends ExtensionBase {
|
export class ExtensionPreferences extends ExtensionBase {
|
||||||
|
static lookupByUUID(uuid) {
|
||||||
|
return extensionManager.lookup(uuid)?.stateObj ?? null;
|
||||||
|
}
|
||||||
|
|
||||||
static defineTranslationFunctions(url) {
|
static defineTranslationFunctions(url) {
|
||||||
const wrapper = new GettextWrapper(this, url);
|
const wrapper = new GettextWrapper(this, url);
|
||||||
return wrapper.defineTranslationFunctions();
|
return wrapper.defineTranslationFunctions();
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
import Gio from 'gi://Gio';
|
import Gio from 'gi://Gio';
|
||||||
import GLib from 'gi://GLib';
|
import GLib from 'gi://GLib';
|
||||||
|
import GObject from 'gi://GObject';
|
||||||
|
|
||||||
import {bindtextdomain} from 'gettext';
|
import {bindtextdomain} from 'gettext';
|
||||||
|
|
||||||
@ -38,14 +39,23 @@ export class ExtensionBase {
|
|||||||
path = GLib.path_get_dirname(path);
|
path = GLib.path_get_dirname(path);
|
||||||
|
|
||||||
const dirName = GLib.path_get_basename(path);
|
const dirName = GLib.path_get_basename(path);
|
||||||
const extension = _extensionManager.lookup(dirName);
|
const extension = this.lookupByUUID(dirName);
|
||||||
if (extension !== undefined)
|
if (extension !== undefined)
|
||||||
return extension.stateObj;
|
return extension;
|
||||||
} while (path !== '/');
|
} while (path !== '/');
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Look up an extension by UUID
|
||||||
|
*
|
||||||
|
* @param {string} _uuid
|
||||||
|
*/
|
||||||
|
static lookupByUUID(_uuid) {
|
||||||
|
throw new GObject.NotImplementedError();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {object} metadata - metadata passed in when loading the extension
|
* @param {object} metadata - metadata passed in when loading the extension
|
||||||
*/
|
*/
|
||||||
|
Loading…
x
Reference in New Issue
Block a user