Extension

Extension

Functions

Functions

getXletFromStack ()


getXletFromStack ();

Get the calling xlet by examining the stack trace.

Returns

The Extension object if found, null otherwise


getCurrentExtension ()


getCurrentExtension ();

Get the current xlet's Extension object. Can be called during module initialization or at runtime.

Usage in xlets: const Extension = imports.ui.extension; const Me = Extension.getCurrentExtension(); const MyModule = Me.imports.myModule;

Returns

The Extension object for the calling xlet


xletRequire ()


xletRequire (string   path);

DEPRECATED Use getCurrentExtension() to import local modules

Global require function for xlets. Supports:

  • Relative paths: './calendar' -> extension.imports.calendar

  • GI imports: 'gi.St' -> imports.gi.St

  • Cinnamon imports: 'ui.main' -> imports.ui.main

Parameters

path

The module path to require

 

Returns

The required module


installXletImporter ()


installXletImporter (Extension   extension);

Install native importer for xlet by temporarily modifying the search path.

Parameters

extension

The extension object

 

clearXletImportCache ()


clearXletImportCache (Extension   extension);

Clear import cache to allow reloading of the xlet. Clears all cached module properties from the xlet's sub-importer.

Parameters

extension

The extension object

 

versionCheck ()


versionCheck (required,
              current);

Check if a component is compatible for an extension. required is an array, and at least one version must be lower than the current version. current must be in the format <major>.<minor>.<point>.<micro> <micro> is always ignored <point> is ignored if not specified (so you can target the whole release) <minor> and <major> must match Each target version must be at least <major> and <minor>

Parameters

required

an array of minimum versions we are compatible with

 

current

the version we have

 

versionLeq ()


versionLeq (string   a,
            string   b);

Parameters

a

the first version

 

b

the second version

 

Returns

whether a <= b


loadExtension ()


loadExtension (string           uuid,
               Extension.Type   type);

Parameters

uuid

uuid of xlet

 

type

type of xlet

 

unloadExtension ()


unloadExtension (string           uuid,
                 Extension.Type   type,
                 bool             deleteConfig);

Parameters

uuid

uuid of xlet

 

type

type of xlet

 

deleteConfig

delete also config files, defaults to true

 

reloadExtension ()


reloadExtension (string           uuid,
                 Extension.Type   type);

Reloads an xlet. Useful when the source has changed.

Parameters

uuid

uuid of xlet

 

type

type of xlet

 

findExtensionSubdirectory ()


findExtensionSubdirectory (Gio.File   dir);

For extensions that are shipped with multiple versions in different directories, look for the largest available version that is less than or equal to the current running version. If no such version is found, the original directory is returned.

Parameters

dir

directory to search in

 

Returns

Promise that resolves to the directory