🔧 Use dynamic imports for gettext

This commit is contained in:
Simon Schneegans
2023-09-09 06:46:09 +02:00
parent 0ccbb31d06
commit 734530fdab
23 changed files with 64 additions and 45 deletions
+2 -2
View File
@@ -14,8 +14,6 @@
'use strict';
const _ = imports.gettext.domain('burn-my-windows').gettext;
import * as utils from '../utils.js';
// We import the ShaderFactory only in the Shell process as it is not required in the
@@ -23,6 +21,8 @@ import * as utils from '../utils.js';
// only uses the static metadata of the effect.
const ShaderFactory = await utils.importInShellOnly('./ShaderFactory.js');
const _ = await utils.importGettext();
//////////////////////////////////////////////////////////////////////////////////////////
// This effect hides the actor by violently sucking it into the void of magic. //
//////////////////////////////////////////////////////////////////////////////////////////
+2 -2
View File
@@ -14,8 +14,6 @@
'use strict';
const _ = imports.gettext.domain('burn-my-windows').gettext;
import * as utils from '../utils.js';
// We import some modules only in the Shell process as they are not available in the
@@ -26,6 +24,8 @@ const Clutter = await utils.importInShellOnly('gi://Clutter');
const GdkPixbuf = await utils.importInShellOnly('gi://GdkPixbuf');
const Cogl = await utils.importInShellOnly('gi://Cogl');
const _ = await utils.importGettext();
//////////////////////////////////////////////////////////////////////////////////////////
// This effect shatters the window into pieces. For an explanation how this works, look //
// further down in this file into the documentation of the Shader class. This effect is //
+2 -3
View File
@@ -14,8 +14,6 @@
'use strict';
const _ = imports.gettext.domain('burn-my-windows').gettext;
import * as utils from '../utils.js';
// We import the ShaderFactory only in the Shell process as it is not required in the
@@ -23,6 +21,8 @@ import * as utils from '../utils.js';
// only uses the static metadata of the effect.
const ShaderFactory = await utils.importInShellOnly('./ShaderFactory.js');
const _ = await utils.importGettext();
//////////////////////////////////////////////////////////////////////////////////////////
// This effect melts your windows. Inspired by the legendary screen transitions of the //
// original Doom. //
@@ -32,7 +32,6 @@ const ShaderFactory = await utils.importInShellOnly('./ShaderFactory.js');
// GNOME Shell versions), to initialize the respective page of the settings dialog, as
// well as to create the actual shader for the effect.
export default class Effect {
// The constructor creates a ShaderFactory which will be used by extension.js to create
// shader instances for this effect. The shaders will be automagically created using the
// GLSL file in resources/shaders/<nick>.glsl. The callback will be called for each
+2 -2
View File
@@ -14,8 +14,6 @@
'use strict';
const _ = imports.gettext.domain('burn-my-windows').gettext;
import * as utils from '../utils.js';
// We import some modules only in the Shell process as they are not available in the
@@ -24,6 +22,8 @@ import * as utils from '../utils.js';
const ShaderFactory = await utils.importInShellOnly('./ShaderFactory.js');
const Clutter = await utils.importInShellOnly('gi://Clutter');
const _ = await utils.importGettext();
//////////////////////////////////////////////////////////////////////////////////////////
// This effect looks a bit like the transporter effect from TOS. //
//////////////////////////////////////////////////////////////////////////////////////////
+2 -2
View File
@@ -14,8 +14,6 @@
'use strict';
const _ = imports.gettext.domain('burn-my-windows').gettext;
import * as utils from '../utils.js';
// We import some modules only in the Shell process as they are not available in the
@@ -24,6 +22,8 @@ import * as utils from '../utils.js';
const ShaderFactory = await utils.importInShellOnly('./ShaderFactory.js');
const Clutter = await utils.importInShellOnly('gi://Clutter');
const _ = await utils.importGettext();
//////////////////////////////////////////////////////////////////////////////////////////
// This effect looks a bit like the transporter effect from TNG. //
//////////////////////////////////////////////////////////////////////////////////////////
+2 -2
View File
@@ -16,8 +16,6 @@
import Gio from 'gi://Gio';
const _ = imports.gettext.domain('burn-my-windows').gettext;
import * as utils from '../utils.js';
// We import some modules only in the Shell process as they are not available in the
@@ -26,6 +24,8 @@ import * as utils from '../utils.js';
const ShaderFactory = await utils.importInShellOnly('./ShaderFactory.js');
const Clutter = await utils.importInShellOnly('gi://Clutter');
const _ = await utils.importGettext();
//////////////////////////////////////////////////////////////////////////////////////////
// This effect is a homage to the good old Compiz days. However, it is implemented //
// quite differently. While Compiz used a particle system, this effect uses a noise //
+2 -2
View File
@@ -14,8 +14,6 @@
'use strict';
const _ = imports.gettext.domain('burn-my-windows').gettext;
import * as utils from '../utils.js';
// We import the ShaderFactory only in the Shell process as it is not required in the
@@ -23,6 +21,8 @@ import * as utils from '../utils.js';
// only uses the static metadata of the effect.
const ShaderFactory = await utils.importInShellOnly('./ShaderFactory.js');
const _ = await utils.importGettext();
//////////////////////////////////////////////////////////////////////////////////////////
// This very simple effect fades the window to transparency with subtle 3D effects. //
//////////////////////////////////////////////////////////////////////////////////////////
+2 -2
View File
@@ -14,8 +14,6 @@
'use strict';
const _ = imports.gettext.domain('burn-my-windows').gettext;
import * as utils from '../utils.js';
// We import some modules only in the Shell process as they are not available in the
@@ -24,6 +22,8 @@ import * as utils from '../utils.js';
const ShaderFactory = await utils.importInShellOnly('./ShaderFactory.js');
const Clutter = await utils.importInShellOnly('gi://Clutter');
const _ = await utils.importGettext();
//////////////////////////////////////////////////////////////////////////////////////////
// This effect applies some intentional graphics issues to your windows. //
//////////////////////////////////////////////////////////////////////////////////////////
+2 -2
View File
@@ -14,8 +14,6 @@
'use strict';
const _ = imports.gettext.domain('burn-my-windows').gettext;
import * as utils from '../utils.js';
// We import some modules only in the Shell process as they are not available in the
@@ -24,6 +22,8 @@ import * as utils from '../utils.js';
const ShaderFactory = await utils.importInShellOnly('./ShaderFactory.js');
const Clutter = await utils.importInShellOnly('gi://Clutter');
const _ = await utils.importGettext();
//////////////////////////////////////////////////////////////////////////////////////////
// This effect overlays a glowing hexagonal grid over the window. The grid cells then //
// gradually shrink until the window is fully dissolved. //
+2 -2
View File
@@ -14,8 +14,6 @@
'use strict';
const _ = imports.gettext.domain('burn-my-windows').gettext;
import * as utils from '../utils.js';
// We import some modules only in the Shell process as they are not available in the
@@ -24,6 +22,8 @@ import * as utils from '../utils.js';
const ShaderFactory = await utils.importInShellOnly('./ShaderFactory.js');
const Clutter = await utils.importInShellOnly('gi://Clutter');
const _ = await utils.importGettext();
//////////////////////////////////////////////////////////////////////////////////////////
// This effect burns windows to ashes. The fire starts at a random position at the //
// window's boundary and then burns through the window in a circular shape. //
+2 -2
View File
@@ -14,8 +14,6 @@
'use strict';
const _ = imports.gettext.domain('burn-my-windows').gettext;
import * as utils from '../utils.js';
// We import some modules only in the Shell process as they are not available in the
@@ -26,6 +24,8 @@ const Clutter = await utils.importInShellOnly('gi://Clutter');
const GdkPixbuf = await utils.importInShellOnly('gi://GdkPixbuf');
const Cogl = await utils.importInShellOnly('gi://Cogl');
const _ = await utils.importGettext();
//////////////////////////////////////////////////////////////////////////////////////////
// The Matrix shader multiplies a grid of random letters with some gradients which are //
// moving from top to bottom. The speed of the moving gradients is chosen randomly. //
+2 -2
View File
@@ -14,8 +14,6 @@
'use strict';
const _ = imports.gettext.domain('burn-my-windows').gettext;
import * as utils from '../utils.js';
// We import some modules only in the Shell process as they are not available in the
@@ -26,6 +24,8 @@ const Clutter = await utils.importInShellOnly('gi://Clutter');
const GdkPixbuf = await utils.importInShellOnly('gi://GdkPixbuf');
const Cogl = await utils.importInShellOnly('gi://Cogl');
const _ = await utils.importGettext();
//////////////////////////////////////////////////////////////////////////////////////////
// This effect paints your windows with a thick paint brush. //
// This effect is not available on GNOME 3.3x, due to the limitation described in the //
+2 -2
View File
@@ -14,8 +14,6 @@
'use strict';
const _ = imports.gettext.domain('burn-my-windows').gettext;
import * as utils from '../utils.js';
// We import the ShaderFactory only in the Shell process as it is not required in the
@@ -23,6 +21,8 @@ import * as utils from '../utils.js';
// only uses the static metadata of the effect.
const ShaderFactory = await utils.importInShellOnly('./ShaderFactory.js');
const _ = await utils.importGettext();
//////////////////////////////////////////////////////////////////////////////////////////
// This simple effect pixelates the window texture and hides the pixels in a wheel-like //
// fashion. //
+2 -2
View File
@@ -14,8 +14,6 @@
'use strict';
const _ = imports.gettext.domain('burn-my-windows').gettext;
import * as utils from '../utils.js';
// We import the ShaderFactory only in the Shell process as it is not required in the
@@ -23,6 +21,8 @@ import * as utils from '../utils.js';
// only uses the static metadata of the effect.
const ShaderFactory = await utils.importInShellOnly('./ShaderFactory.js');
const _ = await utils.importGettext();
//////////////////////////////////////////////////////////////////////////////////////////
// This effect pixelates the window texture and hides the pixels radially, starting //
// from the pointer position. //
+2 -2
View File
@@ -14,8 +14,6 @@
'use strict';
const _ = imports.gettext.domain('burn-my-windows').gettext;
import * as utils from '../utils.js';
// We import the ShaderFactory only in the Shell process as it is not required in the
@@ -23,6 +21,8 @@ import * as utils from '../utils.js';
// only uses the static metadata of the effect.
const ShaderFactory = await utils.importInShellOnly('./ShaderFactory.js');
const _ = await utils.importGettext();
//////////////////////////////////////////////////////////////////////////////////////////
// This very simple effect pixelates the window texture and randomly hides pixels until //
// the entire window is gone. //
+2 -2
View File
@@ -14,8 +14,6 @@
'use strict';
const _ = imports.gettext.domain('burn-my-windows').gettext;
import * as utils from '../utils.js';
// We import some modules only in the Shell process as they are not available in the
@@ -24,6 +22,8 @@ import * as utils from '../utils.js';
const ShaderFactory = await utils.importInShellOnly('./ShaderFactory.js');
const Clutter = await utils.importInShellOnly('gi://Clutter');
const _ = await utils.importGettext();
//////////////////////////////////////////////////////////////////////////////////////////
// This ridiculous effect teleports your windows from and to alternative dimensions. //
// It may resemble the portal from a well-known cartoon series... //
+2 -2
View File
@@ -14,8 +14,6 @@
'use strict';
const _ = imports.gettext.domain('burn-my-windows').gettext;
import * as utils from '../utils.js';
// We import some modules only in the Shell process as they are not available in the
@@ -26,6 +24,8 @@ const Clutter = await utils.importInShellOnly('gi://Clutter');
const GdkPixbuf = await utils.importInShellOnly('gi://GdkPixbuf');
const Cogl = await utils.importInShellOnly('gi://Cogl');
const _ = await utils.importGettext();
//////////////////////////////////////////////////////////////////////////////////////////
// This effects dissolves your windows into a cloud of dust. For this, it uses an //
// approach similar to the Broken Glass effect. A dust texture is used to segment the //
+2 -2
View File
@@ -14,8 +14,6 @@
'use strict';
const _ = imports.gettext.domain('burn-my-windows').gettext;
import * as utils from '../utils.js';
// We import some modules only in the Shell process as they are not available in the
@@ -26,6 +24,8 @@ const Clutter = await utils.importInShellOnly('gi://Clutter');
const GdkPixbuf = await utils.importInShellOnly('gi://GdkPixbuf');
const Cogl = await utils.importInShellOnly('gi://Cogl');
const _ = await utils.importGettext();
//////////////////////////////////////////////////////////////////////////////////////////
// This effect tears your windows apart with a series of violent scratches! //
// This effect is not available on GNOME 3.3x, due to the limitation described in the //
+2 -2
View File
@@ -14,8 +14,6 @@
'use strict';
const _ = imports.gettext.domain('burn-my-windows').gettext;
import * as utils from '../utils.js';
// We import some modules only in the Shell process as they are not available in the
@@ -24,6 +22,8 @@ import * as utils from '../utils.js';
const ShaderFactory = await utils.importInShellOnly('./ShaderFactory.js');
const Clutter = await utils.importInShellOnly('gi://Clutter');
const _ = await utils.importGettext();
//////////////////////////////////////////////////////////////////////////////////////////
// This effect hides the actor by making it first transparent from top and bottom //
// towards the middle and then hiding the resulting line from left and right towards //
+2 -2
View File
@@ -14,8 +14,6 @@
'use strict';
const _ = imports.gettext.domain('burn-my-windows').gettext;
import * as utils from '../utils.js';
// We import some modules only in the Shell process as they are not available in the
@@ -24,6 +22,8 @@ import * as utils from '../utils.js';
const ShaderFactory = await utils.importInShellOnly('./ShaderFactory.js');
const Clutter = await utils.importInShellOnly('gi://Clutter');
const _ = await utils.importGettext();
//////////////////////////////////////////////////////////////////////////////////////////
// This effect combines the Glitch and the TV Effect. Credits go to Kurt Wilson //
// (https://github.com/Kurtoid) for this idea! //
+2 -2
View File
@@ -14,8 +14,6 @@
'use strict';
const _ = imports.gettext.domain('burn-my-windows').gettext;
import * as utils from '../utils.js';
// We import some modules only in the Shell process as they are not available in the
@@ -24,6 +22,8 @@ import * as utils from '../utils.js';
const ShaderFactory = await utils.importInShellOnly('./ShaderFactory.js');
const Clutter = await utils.importInShellOnly('gi://Clutter');
const _ = await utils.importGettext();
//////////////////////////////////////////////////////////////////////////////////////////
// This effect lets your windows be carried to the realm of dreams by some little //
// fairies. It's implemented with several overlaid grids of randomly moving points. //
+20
View File
@@ -45,6 +45,26 @@ export async function importInShellOnly(module) {
return null;
}
// This method can be used to import a module in the preferences process only. This
// is useful if you want to use a module in the preferences process, but not in
// extension.js. This method returns null if it is called in the GNOME Shell process.
export async function importInPrefsOnly(module) {
if (typeof global === 'undefined') {
return (await import(module));
}
return null;
}
// This method can be used to import gettext. This is done differently in the
// GNOME Shell process and in the preferences process.
export async function importGettext() {
if (typeof global === 'undefined') {
return (await import('resource:///org/gnome/Shell/Extensions/js/extensions/prefs.js'))
.gettext;
}
return (await import('resource:///org/gnome/shell/extensions/extension.js')).gettext;
}
// Reads the contents of a file contained in the global resources archive. The data
// is returned as a string.
export function getStringResource(path) {