extensions: Provide separate implementations
For the time being this mostly means re-exporting functions from the shared module. However openPrefs() is now only available to extensions, and we stop exporting both getCurrentExtension() and setExtensionManager() to either extensions or prefs. Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/2837>
This commit is contained in:
parent
55cf8cf4bb
commit
6a46d338e7
@ -7,6 +7,7 @@
|
|||||||
<file>dbusService.js</file>
|
<file>dbusService.js</file>
|
||||||
|
|
||||||
<file>extensions/sharedInternals.js</file>
|
<file>extensions/sharedInternals.js</file>
|
||||||
|
<file>extensions/prefs.js</file>
|
||||||
|
|
||||||
<file>misc/config.js</file>
|
<file>misc/config.js</file>
|
||||||
<file>misc/extensionUtils.js</file>
|
<file>misc/extensionUtils.js</file>
|
||||||
|
28
js/extensions/extension.js
Normal file
28
js/extensions/extension.js
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
import {getCurrentExtension} from './sharedInternals.js';
|
||||||
|
|
||||||
|
export {
|
||||||
|
getSettings,
|
||||||
|
initTranslations,
|
||||||
|
gettext,
|
||||||
|
ngettext,
|
||||||
|
pgettext
|
||||||
|
} from './sharedInternals.js';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Open the preference dialog of the current extension
|
||||||
|
*/
|
||||||
|
export function openPrefs() {
|
||||||
|
const extension = getCurrentExtension();
|
||||||
|
|
||||||
|
if (!extension)
|
||||||
|
throw new Error('openPrefs() can only be called from extensions');
|
||||||
|
|
||||||
|
try {
|
||||||
|
const extensionManager = imports.ui.main.extensionManager;
|
||||||
|
extensionManager.openExtensionPrefs(extension.uuid, '', {});
|
||||||
|
} catch (e) {
|
||||||
|
if (e.name === 'ImportError')
|
||||||
|
throw new Error('openPrefs() cannot be called from preferences');
|
||||||
|
logError(e, 'Failed to open extension preferences');
|
||||||
|
}
|
||||||
|
}
|
7
js/extensions/prefs.js
Normal file
7
js/extensions/prefs.js
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
export {
|
||||||
|
getSettings,
|
||||||
|
initTranslations,
|
||||||
|
gettext,
|
||||||
|
ngettext,
|
||||||
|
pgettext
|
||||||
|
} from './sharedInternals.js';
|
@ -177,22 +177,3 @@ export function getSettings(schema) {
|
|||||||
|
|
||||||
return new Gio.Settings({settings_schema: schemaObj});
|
return new Gio.Settings({settings_schema: schemaObj});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Open the preference dialog of the current extension
|
|
||||||
*/
|
|
||||||
export function openPrefs() {
|
|
||||||
const extension = getCurrentExtension();
|
|
||||||
|
|
||||||
if (!extension)
|
|
||||||
throw new Error('openPrefs() can only be called from extensions');
|
|
||||||
|
|
||||||
try {
|
|
||||||
const extensionManager = imports.ui.main.extensionManager;
|
|
||||||
extensionManager.openExtensionPrefs(extension.uuid, '', {});
|
|
||||||
} catch (e) {
|
|
||||||
if (e.name === 'ImportError')
|
|
||||||
throw new Error('openPrefs() cannot be called from preferences');
|
|
||||||
logError(e, 'Failed to open extension preferences');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
@ -12,6 +12,7 @@
|
|||||||
<file>gdm/util.js</file>
|
<file>gdm/util.js</file>
|
||||||
|
|
||||||
<file>extensions/sharedInternals.js</file>
|
<file>extensions/sharedInternals.js</file>
|
||||||
|
<file>extensions/extension.js</file>
|
||||||
|
|
||||||
<file>misc/animationUtils.js</file>
|
<file>misc/animationUtils.js</file>
|
||||||
<file>misc/config.js</file>
|
<file>misc/config.js</file>
|
||||||
|
Loading…
Reference in New Issue
Block a user