From 8a0c29a52f023bbb84fbab8c158faa34c50f3bdf Mon Sep 17 00:00:00 2001
From: Simon Schneegans
Date: Wed, 12 Jul 2023 09:59:53 +0200
Subject: [PATCH 01/26] :construction: Start port to ESM
---
extension.js | 103 +++++++++-------
metadata.json | 8 +-
prefs.js | 180 ++++++++++++++--------------
src/ProfileManager.js | 11 +-
src/Shader.js | 27 ++---
src/ShaderFactory.js | 10 +-
src/WindowPicker.js | 13 +-
src/effects/Apparition.js | 7 +-
src/effects/BrokenGlass.js | 7 +-
src/effects/Doom.js | 9 +-
src/effects/EnergizeA.js | 9 +-
src/effects/EnergizeB.js | 9 +-
src/effects/Fire.js | 10 +-
src/effects/Glide.js | 9 +-
src/effects/Glitch.js | 9 +-
src/effects/Hexagon.js | 9 +-
src/effects/Incinerate.js | 9 +-
src/effects/Matrix.js | 9 +-
src/effects/PaintBrush.js | 9 +-
src/effects/PixelWheel.js | 9 +-
src/effects/PixelWipe.js | 9 +-
src/effects/Pixelate.js | 9 +-
src/effects/Portal.js | 9 +-
src/effects/SnapOfDisintegration.js | 9 +-
src/effects/TRexAttack.js | 9 +-
src/effects/TVEffect.js | 9 +-
src/effects/TVGlitch.js | 9 +-
src/effects/Wisps.js | 9 +-
src/migrate.js | 55 ++++-----
src/utils.js | 29 +++--
30 files changed, 266 insertions(+), 356 deletions(-)
diff --git a/extension.js b/extension.js
index 21d496e..f385b79 100644
--- a/extension.js
+++ b/extension.js
@@ -14,11 +14,38 @@
'use strict';
-const {Clutter, Gio, Meta} = imports.gi;
+import Gio from 'gi://Gio';
+import Meta from 'gi://Meta';
-const Main = imports.ui.main;
-const Workspace = imports.ui.workspace.Workspace;
-const WindowManager = imports.ui.windowManager.WindowManager;
+import {fromVersion26} from './src/migrate.js';
+import {ProfileManager} from './src/ProfileManager.js';
+import {WindowPicker} from './src/WindowPicker.js';
+import {getStringResource, shellVersionIs, shellVersionIsAtLeast} from './src/utils.js';
+
+import Apparition from './src/effects/Apparition.js';
+import BrokenGlass from './src/effects/BrokenGlass.js';
+import Doom from './src/effects/Doom.js';
+import EnergizeA from './src/effects/EnergizeA.js';
+import EnergizeB from './src/effects/EnergizeB.js';
+import Fire from './src/effects/Fire.js';
+import Glide from './src/effects/Glide.js';
+import Glitch from './src/effects/Glitch.js';
+import Hexagon from './src/effects/Hexagon.js';
+import Incinerate from './src/effects/Incinerate.js';
+import Matrix from './src/effects/Matrix.js';
+import PaintBrush from './src/effects/PaintBrush.js';
+import Pixelate from './src/effects/Pixelate.js';
+import PixelWheel from './src/effects/PixelWheel.js';
+import PixelWipe from './src/effects/PixelWipe.js';
+import Portal from './src/effects/Portal.js';
+import SnapOfDisintegration from './src/effects/SnapOfDisintegration.js';
+import TRexAttack from './src/effects/TRexAttack.js';
+import TVEffect from './src/effects/TVEffect.js';
+import TVGlitch from './src/effects/TVGlitch.js';
+import Wisps from './src/effects/Wisps.js';
+
+const Main = imports.ui.main;
+const Workspace = imports.ui.workspace.Workspace;
// The WindowPreview class is only available on GNOME Shell 3.38+;
let WindowPreview = null;
@@ -30,10 +57,6 @@ try {
const ExtensionUtils = imports.misc.extensionUtils;
const Me = imports.misc.extensionUtils.getCurrentExtension();
-const migrate = Me.imports.src.migrate;
-const utils = Me.imports.src.utils;
-const ProfileManager = Me.imports.src.ProfileManager.ProfileManager;
-const WindowPicker = Me.imports.src.WindowPicker.WindowPicker;
//////////////////////////////////////////////////////////////////////////////////////////
// This extensions modifies the window-close and window-open animations with all kinds //
@@ -44,7 +67,7 @@ const WindowPicker = Me.imports.src.WindowPicker.WindowPicker;
// to get this working. For more details, read the other comments in this file... //
//////////////////////////////////////////////////////////////////////////////////////////
-class Extension {
+export default class Extension {
// ------------------------------------------------------------------------ public stuff
@@ -54,27 +77,27 @@ class Extension {
// New effects must be registered here and in prefs.js.
this._ALL_EFFECTS = [
- new Me.imports.src.effects.Apparition.Apparition(),
- new Me.imports.src.effects.BrokenGlass.BrokenGlass(),
- new Me.imports.src.effects.Doom.Doom(),
- new Me.imports.src.effects.EnergizeA.EnergizeA(),
- new Me.imports.src.effects.EnergizeB.EnergizeB(),
- new Me.imports.src.effects.Fire.Fire(),
- new Me.imports.src.effects.Glide.Glide(),
- new Me.imports.src.effects.Glitch.Glitch(),
- new Me.imports.src.effects.Hexagon.Hexagon(),
- new Me.imports.src.effects.Incinerate.Incinerate(),
- new Me.imports.src.effects.Matrix.Matrix(),
- new Me.imports.src.effects.PaintBrush.PaintBrush(),
- new Me.imports.src.effects.Pixelate.Pixelate(),
- new Me.imports.src.effects.PixelWheel.PixelWheel(),
- new Me.imports.src.effects.PixelWipe.PixelWipe(),
- new Me.imports.src.effects.Portal.Portal(),
- new Me.imports.src.effects.SnapOfDisintegration.SnapOfDisintegration(),
- new Me.imports.src.effects.TRexAttack.TRexAttack(),
- new Me.imports.src.effects.TVEffect.TVEffect(),
- new Me.imports.src.effects.TVGlitch.TVGlitch(),
- new Me.imports.src.effects.Wisps.Wisps(),
+ new Apparition(),
+ new BrokenGlass(),
+ new Doom(),
+ new EnergizeA(),
+ new EnergizeB(),
+ new Fire(),
+ new Glide(),
+ new Glitch(),
+ new Hexagon(),
+ new Incinerate(),
+ new Matrix(),
+ new PaintBrush(),
+ new Pixelate(),
+ new PixelWheel(),
+ new PixelWipe(),
+ new Portal(),
+ new SnapOfDisintegration(),
+ new TRexAttack(),
+ new TVEffect(),
+ new TVGlitch(),
+ new Wisps(),
];
// Load all of our resources.
@@ -91,7 +114,7 @@ class Extension {
if (lastVersion <= 26) {
// If the profile migration fails for some reason, the callback will create a
// default profile instead.
- migrate.fromVersion26().finally(() => {
+ fromVersion26().finally(() => {
this._loadProfiles();
this._settings.set_int('last-extension-version', Me.metadata.version);
});
@@ -122,14 +145,14 @@ class Extension {
// This is used to get the battery state.
const UPowerProxy = Gio.DBusProxy.makeProxyWrapper(
- utils.getStringResource('/interfaces/org.freedesktop.UPower.xml'));
+ getStringResource('/interfaces/org.freedesktop.UPower.xml'));
this._upowerProxy = new UPowerProxy(Gio.DBus.system, 'org.freedesktop.UPower',
'/org/freedesktop/UPower');
// This is used to get the current power profile.
try {
const PowerProfilesProxy = Gio.DBusProxy.makeProxyWrapper(
- utils.getStringResource('/interfaces/net.hadess.PowerProfiles.xml'));
+ getStringResource('/interfaces/net.hadess.PowerProfiles.xml'));
this._powerProfilesProxy = new PowerProfilesProxy(
Gio.DBus.system, 'net.hadess.PowerProfiles', '/net/hadess/PowerProfiles');
} catch (e) {
@@ -239,10 +262,10 @@ class Extension {
// The parameters of this method changed a bit through the versions...
let realWindow, container;
- if (utils.shellVersionIs(3, 36)) {
+ if (shellVersionIs(3, 36)) {
container = clone[0];
realWindow = container.realWindow;
- } else if (utils.shellVersionIs(3, 38)) {
+ } else if (shellVersionIs(3, 38)) {
container = clone._windowContainer;
realWindow = params[0].get_compositor_private();
} else {
@@ -268,7 +291,7 @@ class Extension {
// the overview window layout. Therefore we call this method in addition.
// https://gitlab.gnome.org/GNOME/gnome-shell/-/blob/gnome-3-36/js/ui/workspace.js#L1877
// https://gitlab.gnome.org/GNOME/gnome-shell/-/blob/main/js/ui/workspace.js#L1363
- if (utils.shellVersionIs(3, 36)) {
+ if (shellVersionIs(3, 36)) {
container.connect('destroy', () => this._doRemoveWindow(container.metaWindow));
}
@@ -501,7 +524,7 @@ class Extension {
}
// If the profile is still matching, we also check the color scheme.
- if (matches && profileColorScheme != 0 && utils.shellVersionIsAtLeast(42, 0)) {
+ if (matches && profileColorScheme != 0 && shellVersionIsAtLeast(42, 0)) {
const colorScheme = this._shellSettings.get_string('color-scheme');
matches &= (profileColorScheme == 1 && colorScheme == 'default') ||
(profileColorScheme == 2 && colorScheme == 'prefer-dark');
@@ -580,7 +603,7 @@ class Extension {
// If we are in the overview, we have to enlarge the window's clone as well. We also
// disable the clone's overlay (e.g. its icon, name, and close button) during the
// animation.
- if (actor._bmwOverviewClone && utils.shellVersionIsAtLeast(3, 38)) {
+ if (actor._bmwOverviewClone && shellVersionIsAtLeast(3, 38)) {
actor._bmwOverviewClone.overlayEnabled = false;
actor._bmwOverviewCloneContainer.set_pivot_point(0.5, 0.5);
actor._bmwOverviewCloneContainer.scale_x = actorScale.x;
@@ -597,7 +620,7 @@ class Extension {
const endID = shader.connect('end-animation', () => {
shader.disconnect(endID);
- if (actor._bmwOverviewClone && utils.shellVersionIsAtLeast(3, 38)) {
+ if (actor._bmwOverviewClone && shellVersionIsAtLeast(3, 38)) {
actor._bmwOverviewClone.overlayEnabled = true;
actor._bmwOverviewCloneContainer.scale_x = 1.0;
actor._bmwOverviewCloneContainer.scale_y = 1.0;
@@ -636,7 +659,7 @@ class Extension {
}
// This was called "realWindow" in GNOME 3.36.
- const propertyName = utils.shellVersionIs(3, 36) ? 'realWindow' : '_windowActor';
+ const propertyName = shellVersionIs(3, 36) ? 'realWindow' : '_windowActor';
const actor = workspace._windows[index][propertyName];
const shader = actor.get_effect('burn-my-windows-effect');
diff --git a/metadata.json b/metadata.json
index cceac0e..a305fdb 100644
--- a/metadata.json
+++ b/metadata.json
@@ -10,13 +10,7 @@
"gettext-domain": "burn-my-windows",
"settings-schema": "org.gnome.shell.extensions.burn-my-windows",
"shell-version": [
- "3.36",
- "3.38",
- "40",
- "41",
- "42",
- "43",
- "44"
+ "45"
],
"url": "https://github.com/Schneegans/Burn-My-Windows",
"version": 36
diff --git a/prefs.js b/prefs.js
index c751fc1..8a44859 100644
--- a/prefs.js
+++ b/prefs.js
@@ -14,12 +14,40 @@
'use strict';
-const {Gio, Gtk, Gdk, GLib, GObject} = imports.gi;
+import Gio from 'gi://Gio';
+import Gtk from 'gi://Gtk';
+import GLib from 'gi://GLib';
+import Gdk from 'gi://Gdk';
+
+import {isADW, isGTK4, getUIDir, getStringResource, shellVersionIsAtLeast} from './utils.js';
+import {ProfileManager} from './ProfileManager.js';
+
+import Apparition from './src/effects/Apparition.js';
+import BrokenGlass from './src/effects/BrokenGlass.js';
+import Doom from './src/effects/Doom.js';
+import EnergizeA from './src/effects/EnergizeA.js';
+import EnergizeB from './src/effects/EnergizeB.js';
+import Fire from './src/effects/Fire.js';
+import Glide from './src/effects/Glide.js';
+import Glitch from './src/effects/Glitch.js';
+import Hexagon from './src/effects/Hexagon.js';
+import Incinerate from './src/effects/Incinerate.js';
+import Matrix from './src/effects/Matrix.js';
+import PaintBrush from './src/effects/PaintBrush.js';
+import Pixelate from './src/effects/Pixelate.js';
+import PixelWheel from './src/effects/PixelWheel.js';
+import PixelWipe from './src/effects/PixelWipe.js';
+import Portal from './src/effects/Portal.js';
+import SnapOfDisintegration from './src/effects/SnapOfDisintegration.js';
+import TRexAttack from './src/effects/TRexAttack.js';
+import TVEffect from './src/effects/TVEffect.js';
+import TVGlitch from './src/effects/TVGlitch.js';
+import Wisps from './src/effects/Wisps.js';
// libadwaita is available starting with GNOME Shell 42.
let Adw = null;
try {
- Adw = imports.gi.Adw;
+ Adw = await import('gi://Adw');
} catch (e) {
// Nothing to do.
}
@@ -28,8 +56,6 @@ const _ = imports.gettext.domain('burn-my-windows').gettext;
const ExtensionUtils = imports.misc.extensionUtils;
const Me = imports.misc.extensionUtils.getCurrentExtension();
-const utils = Me.imports.src.utils;
-const ProfileManager = Me.imports.src.ProfileManager.ProfileManager;
//////////////////////////////////////////////////////////////////////////////////////////
// The preferences dialog is organized in pages, each of which is loaded from a //
@@ -37,35 +63,41 @@ const ProfileManager = Me.imports.src.ProfileManager.ProfileManager;
// from the respective effects. //
//////////////////////////////////////////////////////////////////////////////////////////
-var PreferencesDialog = class PreferencesDialog {
+export default class ExtensionPreferences {
// ------------------------------------------------------------ constructor / destructor
+ // This is used for setting up the translations.
constructor() {
+ ExtensionUtils.initTranslations();
+ }
+
+ fillPreferencesWindow(window) {
+ window.set_default_size(650, 750);
// New effects must be registered here and in extension.js.
this._ALL_EFFECTS = [
- new Me.imports.src.effects.Apparition.Apparition(),
- new Me.imports.src.effects.BrokenGlass.BrokenGlass(),
- new Me.imports.src.effects.Doom.Doom(),
- new Me.imports.src.effects.EnergizeA.EnergizeA(),
- new Me.imports.src.effects.EnergizeB.EnergizeB(),
- new Me.imports.src.effects.Fire.Fire(),
- new Me.imports.src.effects.Glide.Glide(),
- new Me.imports.src.effects.Glitch.Glitch(),
- new Me.imports.src.effects.Hexagon.Hexagon(),
- new Me.imports.src.effects.Incinerate.Incinerate(),
- new Me.imports.src.effects.Matrix.Matrix(),
- new Me.imports.src.effects.PaintBrush.PaintBrush(),
- new Me.imports.src.effects.Pixelate.Pixelate(),
- new Me.imports.src.effects.PixelWheel.PixelWheel(),
- new Me.imports.src.effects.PixelWipe.PixelWipe(),
- new Me.imports.src.effects.Portal.Portal(),
- new Me.imports.src.effects.SnapOfDisintegration.SnapOfDisintegration(),
- new Me.imports.src.effects.TRexAttack.TRexAttack(),
- new Me.imports.src.effects.TVEffect.TVEffect(),
- new Me.imports.src.effects.TVGlitch.TVGlitch(),
- new Me.imports.src.effects.Wisps.Wisps(),
+ new Apparition(),
+ new BrokenGlass(),
+ new Doom(),
+ new EnergizeA(),
+ new EnergizeB(),
+ new Fire(),
+ new Glide(),
+ new Glitch(),
+ new Hexagon(),
+ new Incinerate(),
+ new Matrix(),
+ new PaintBrush(),
+ new Pixelate(),
+ new PixelWheel(),
+ new PixelWipe(),
+ new Portal(),
+ new SnapOfDisintegration(),
+ new TRexAttack(),
+ new TVEffect(),
+ new TVGlitch(),
+ new Wisps(),
];
// Load all of our resources.
@@ -74,9 +106,9 @@ var PreferencesDialog = class PreferencesDialog {
// Load the CSS file for the settings dialog. If using libadwaita, we do not need an
// additional style sheet.
- if (!utils.isADW()) {
+ if (!isADW()) {
const provider = Gtk.CssProvider.new();
- if (utils.isGTK4()) {
+ if (isGTK4()) {
provider.load_from_resource('/css/gtk4.css');
Gtk.StyleContext.add_provider_for_display(
Gdk.Display.get_default(), provider, Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION);
@@ -88,7 +120,7 @@ var PreferencesDialog = class PreferencesDialog {
}
// Make sure custom icons are found.
- if (utils.isGTK4()) {
+ if (isGTK4()) {
Gtk.IconTheme.get_for_display(Gdk.Display.get_default()).add_resource_path('/img');
} else {
Gtk.IconTheme.get_default().add_resource_path('/img');
@@ -97,7 +129,7 @@ var PreferencesDialog = class PreferencesDialog {
// Load the general user interface files.
this._builder = new Gtk.Builder();
this._builder.add_from_resource(`/ui/common/menus.ui`);
- this._builder.add_from_resource(`/ui/${utils.getUIDir()}/prefs.ui`);
+ this._builder.add_from_resource(`/ui/${getUIDir()}/prefs.ui`);
// Store a reference to the general settings object.
this._settings = ExtensionUtils.getSettings();
@@ -119,7 +151,7 @@ var PreferencesDialog = class PreferencesDialog {
let hasPowerProfiles = false;
try {
const PowerProfilesProxy = Gio.DBusProxy.makeProxyWrapper(
- utils.getStringResource('/interfaces/net.hadess.PowerProfiles.xml'));
+ getStringResource('/interfaces/net.hadess.PowerProfiles.xml'));
let powerProfilesProxy = new PowerProfilesProxy(
Gio.DBus.system, 'net.hadess.PowerProfiles', '/net/hadess/PowerProfiles');
@@ -129,7 +161,7 @@ var PreferencesDialog = class PreferencesDialog {
}
let powerProfileRow = this._builder.get_object('profile-power-profile');
- if (!utils.isADW()) {
+ if (!isADW()) {
powerProfileRow = powerProfileRow.get_parent().get_parent();
}
powerProfileRow.set_visible(hasPowerProfiles);
@@ -137,10 +169,10 @@ var PreferencesDialog = class PreferencesDialog {
// The global color scheme is only available starting with GNOME Shell 42. We hide the
// corresponding settings row on older versions.
let colorSchemeRow = this._builder.get_object('profile-color-scheme');
- if (!utils.isADW()) {
+ if (!isADW()) {
colorSchemeRow = colorSchemeRow.get_parent().get_parent();
}
- colorSchemeRow.set_visible(utils.shellVersionIsAtLeast(42, 0));
+ colorSchemeRow.set_visible(shellVersionIsAtLeast(42, 0));
// Wire up the window picker of the profile editor. Whenever the app-chooser button is
// clicked, we call a method of the extension which will initiate the window picking.
@@ -181,7 +213,7 @@ var PreferencesDialog = class PreferencesDialog {
// If using libadwaita, the visibility of the profile-editor Adw.Flap is controlled
// using bindings in the ui file. On GTK3 and GTK4 we have to wire up this toggling
// here since we are using a Gtk.Stack instead of an Adw.Flap.
- if (!utils.isADW()) {
+ if (!isADW()) {
const profileEditorButton = this._builder.get_object('edit-profile-button');
profileEditorButton.connect('toggled', b => {
if (b.active) {
@@ -204,7 +236,7 @@ var PreferencesDialog = class PreferencesDialog {
// accordion-like behavior of the effect settings.
this._effectRows = [];
- if (!utils.isADW()) {
+ if (!isADW()) {
group.connect('row-activated', (g, row) => {
this._effectRows.forEach(r => {
if (r == row) {
@@ -226,9 +258,9 @@ var PreferencesDialog = class PreferencesDialog {
// Now add all the rows.
this._ALL_EFFECTS.forEach(effect => {
const [minMajor, minMinor] = effect.getMinShellVersion();
- if (utils.shellVersionIsAtLeast(minMajor, minMinor)) {
+ if (shellVersionIsAtLeast(minMajor, minMinor)) {
- const uiFile = `/ui/${utils.getUIDir()}/${effect.getNick()}.ui`;
+ const uiFile = `/ui/${getUIDir()}/${effect.getNick()}.ui`;
// Is there a better way to test for the existence of a resource file?
let hasPrefs = false;
@@ -246,7 +278,7 @@ var PreferencesDialog = class PreferencesDialog {
// The preview button.
let previewButton;
- if (utils.isGTK4()) {
+ if (isGTK4()) {
previewButton = Gtk.Button.new_from_icon_name('bmw-preview-symbolic');
} else {
previewButton = Gtk.Button.new_from_icon_name('bmw-preview-symbolic', 1);
@@ -264,14 +296,14 @@ var PreferencesDialog = class PreferencesDialog {
button.set_valign(Gtk.Align.CENTER);
this._builder.expose_object(`${effect.getNick()}-enable-effect`, button);
- if (utils.isADW()) {
+ if (isADW()) {
let row;
if (hasPrefs) {
// Add the effect's preferences (if any).
row = this._builder.get_object(`${effect.getNick()}-prefs`);
- } else if (utils.isADW()) {
+ } else if (isADW()) {
row = Adw.ActionRow.new();
}
@@ -341,7 +373,7 @@ var PreferencesDialog = class PreferencesDialog {
row.set_activatable(false);
}
- if (utils.isGTK4()) {
+ if (isGTK4()) {
row.set_child(container);
group.append(row);
} else {
@@ -355,7 +387,7 @@ var PreferencesDialog = class PreferencesDialog {
// Some things can only be done once the widget is shown as we do not have access to
// the toplevel widget before.
this._widget.connect('realize', (widget) => {
- const window = utils.isGTK4() ? widget.get_root() : widget.get_toplevel();
+ const window = isGTK4() ? widget.get_root() : widget.get_toplevel();
// Show the version number in the title bar.
window.set_title(`Burn-My-Windows ${Me.metadata.version}`);
@@ -371,7 +403,7 @@ var PreferencesDialog = class PreferencesDialog {
GLib.timeout_add(GLib.PRIORITY_DEFAULT, 2000, () => {
this._showUpdateInfoTimeout = 0;
- if (utils.isADW()) {
+ if (isADW()) {
const toast = Adw.Toast.new(_('Burn-My-Windows has been updated!'));
toast.set_button_label(_('View Changelog'));
toast.set_action_name('prefs.changelog');
@@ -436,7 +468,7 @@ GitHub: https://github.com/spon
}
]);
- if (utils.isGTK4()) {
+ if (isGTK4()) {
dialog.show();
} else {
dialog.show_all();
@@ -455,7 +487,7 @@ GitHub: https://github.com/spon
// Starting with GNOME Shell 42, we have to hack our way through the widget tree
// of the Adw.PreferencesWindow...
- if (utils.isADW()) {
+ if (isADW()) {
const header = this._findWidgetByType(window.get_content(), Adw.HeaderBar);
header.pack_start(menu);
header.set_title_widget(this._builder.get_object('profile-button'));
@@ -479,7 +511,7 @@ GitHub: https://github.com/spon
flap.set_content(scrolledWindow);
- } else if (utils.isGTK4()) {
+ } else if (isGTK4()) {
window.get_titlebar().pack_start(menu);
window.get_titlebar().set_title_widget(
this._builder.get_object('profile-button'));
@@ -537,7 +569,7 @@ GitHub: https://github.com/spon
let dialog;
// We try to use the special Adw.AboutWindow if it is available.
- if (utils.isADW() && Adw.AboutWindow) {
+ if (isADW() && Adw.AboutWindow) {
let formatSponsors = (sponsors) => {
return sponsors.map(s => {
if (s.url == '')
@@ -608,7 +640,7 @@ GitHub: https://github.com/spon
dialog.set_website('https://github.com/Schneegans/Burn-My-Windows');
dialog.set_license_type(Gtk.License.GPL_3_0);
- if (utils.isGTK4()) {
+ if (isGTK4()) {
dialog.show();
} else {
dialog.show_all();
@@ -698,9 +730,11 @@ GitHub: https://github.com/spon
});
// Show the widgets on GTK3.
- if (!utils.isGTK4()) {
+ if (!isGTK4()) {
this._widget.show_all();
}
+
+ window.add(this._widget);
}
// -------------------------------------------------------------------- public interface
@@ -716,11 +750,6 @@ GitHub: https://github.com/spon
return this._activeProfile.settings;
}
- // Returns the widget used for the settings of this extension.
- getWidget() {
- return this._widget;
- }
-
// Connects an Adw.ComboRow (or anything else which has an 'selected' property) to a
// settings key. It also binds the corresponding reset button.
bindComboRow(settingsKey) {
@@ -790,7 +819,7 @@ GitHub: https://github.com/spon
// Appends the given child widget to the given Gtk.Box.
gtkBoxAppend(box, child) {
- if (utils.isGTK4()) {
+ if (isGTK4()) {
box.append(child);
} else {
box.pack_start(child, false, true, 0);
@@ -836,7 +865,7 @@ GitHub: https://github.com/spon
this.bindEntry('profile-app');
- if (utils.isADW()) {
+ if (isADW()) {
this.bindComboRow('profile-animation-type');
this.bindComboRow('profile-window-type');
this.bindComboRow('profile-color-scheme');
@@ -854,7 +883,7 @@ GitHub: https://github.com/spon
// Connect all effect settings.
this._ALL_EFFECTS.forEach(effect => {
const [minMajor, minMinor] = effect.getMinShellVersion();
- if (utils.shellVersionIsAtLeast(minMajor, minMinor)) {
+ if (shellVersionIsAtLeast(minMajor, minMinor)) {
this.bindSwitch(`${effect.getNick()}-enable-effect`);
effect.bindPreferences(this);
}
@@ -935,7 +964,7 @@ GitHub: https://github.com/spon
// Reads the contents of a JSON file contained in the global resources archive. The data
// is parsed and returned as a JavaScript object / array.
_getJSONResource(path) {
- return JSON.parse(utils.getStringResource(path));
+ return JSON.parse(getStringResource(path));
}
// This traverses the widget tree below the given parent recursively and returns the
@@ -967,12 +996,11 @@ GitHub: https://github.com/spon
default_width: 800,
default_height: 450,
modal: true,
- transient_for: utils.isGTK4() ? this._widget.get_root() :
- this._widget.get_toplevel()
+ transient_for: isGTK4() ? this._widget.get_root() : this._widget.get_toplevel()
});
// Add a header bar to the window.
- if (utils.isGTK4()) {
+ if (isGTK4()) {
const header = Gtk.HeaderBar.new();
window.set_titlebar(header);
}
@@ -998,7 +1026,7 @@ GitHub: https://github.com/spon
this.gtkBoxAppend(box, image);
this.gtkBoxAppend(box, label);
- if (utils.isGTK4()) {
+ if (isGTK4()) {
window.set_child(box);
window.show();
} else {
@@ -1015,7 +1043,7 @@ GitHub: https://github.com/spon
_createMessageDialog(title, message, window, buttons) {
let dialog;
- if (utils.isADW() && Adw.MessageDialog) {
+ if (isADW() && Adw.MessageDialog) {
dialog = new Adw.MessageDialog({
heading: title,
body: message,
@@ -1056,7 +1084,7 @@ GitHub: https://github.com/spon
});
}
- if (utils.isGTK4()) {
+ if (isGTK4()) {
dialog.set_hide_on_close(true);
}
@@ -1078,25 +1106,3 @@ GitHub: https://github.com/spon
return dialog;
}
}
-
-// This is used for setting up the translations.
-function init() {
- ExtensionUtils.initTranslations();
-}
-
-// This function is called when the preferences window is created to build and return a
-// Gtk widget. We create a new instance of the PreferencesDialog class each time this
-// method is called. This way we can actually open multiple settings windows and interact
-// with all of them properly.
-function buildPrefsWidget() {
- var dialog = new PreferencesDialog();
- return dialog.getWidget();
-}
-
-// If using libadwaita, this method is called. In this case, the primary widget of the
-// preferences dialog is an Adw.PreferencesPage, which we directly add to the window.
-function fillPreferencesWindow(window) {
- window.set_default_size(650, 750);
- var dialog = new PreferencesDialog();
- window.add(dialog.getWidget());
-}
\ No newline at end of file
diff --git a/src/ProfileManager.js b/src/ProfileManager.js
index 4de9aba..1d43014 100644
--- a/src/ProfileManager.js
+++ b/src/ProfileManager.js
@@ -12,15 +12,14 @@
// SPDX-FileCopyrightText: Simon Schneegans
// SPDX-License-Identifier: GPL-3.0-or-later
-'use strict';
+//'use strict';
-const {Gio, GLib, GObject} = imports.gi;
+import Gio from 'gi://Gio';
+import GLib from 'gi://GLib';
const _ = imports.gettext.domain('burn-my-windows').gettext;
-const ExtensionUtils = imports.misc.extensionUtils;
-const Me = imports.misc.extensionUtils.getCurrentExtension();
-const utils = Me.imports.src.utils;
+const Me = imports.misc.extensionUtils.getCurrentExtension();
//////////////////////////////////////////////////////////////////////////////////////////
// Burn-My-Windows allows applying different sets of effect settings under specific //
@@ -31,7 +30,7 @@ const utils = Me.imports.src.utils;
// via Gio.Settings objects. //
//////////////////////////////////////////////////////////////////////////////////////////
-var ProfileManager = class {
+export class ProfileManager {
// ------------------------------------------------------------------------- constructor
constructor() {
diff --git a/src/Shader.js b/src/Shader.js
index a910169..11369df 100644
--- a/src/Shader.js
+++ b/src/Shader.js
@@ -14,13 +14,13 @@
'use strict';
-const {Gio, Shell, GObject, Clutter, Meta} = imports.gi;
-const ByteArray = imports.byteArray;
+import Gio from 'gi://Gio';
+import Shell from 'gi://Shell';
+import GObject from 'gi://GObject';
+import Clutter from 'gi://Clutter';
+import Meta from 'gi://Meta';
-const Main = imports.ui.main;
-const ExtensionUtils = imports.misc.extensionUtils;
-const Me = imports.misc.extensionUtils.getCurrentExtension();
-const utils = Me.imports.src.utils;
+import {shellVersionIsAtLeast, getStringResource} from './utils.js';
//////////////////////////////////////////////////////////////////////////////////////////
// This is the base class for all shaders of Burn-My-Windows. It automagically loads //
@@ -47,7 +47,7 @@ const utils = Me.imports.src.utils;
// used to clean up any resources.
//////////////////////////////////////////////////////////////////////////////////////////
-var Shader = GObject.registerClass(
+export var Shader = GObject.registerClass(
{
Signals: {
'begin-animation': {
@@ -186,7 +186,7 @@ var Shader = GObject.registerClass(
// to undo this. It is a pity that we have to do this here, as it is not really
// required to be done each frame. But it's the only place where we can do it.
// https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/2650
- if (utils.shellVersionIsAtLeast(44, 2)) {
+ if (shellVersionIsAtLeast(44, 2)) {
this.get_pipeline().set_blend(
'RGBA = ADD (SRC_COLOR * (SRC_COLOR[A]), DST_COLOR * (1-SRC_COLOR[A]))');
}
@@ -197,18 +197,11 @@ var Shader = GObject.registerClass(
// --------------------------------------------------------------------- private stuff
- // This loads the file at 'path' contained in the extension's resources to a
- // JavaScript string.
- _loadStringResource(path) {
- const data = Gio.resources_lookup_data(path, 0);
- return ByteArray.toString(ByteArray.fromGBytes(data));
- }
-
// This loads a GLSL file from the extension's resources to a JavaScript string. The
// code from "common.glsl" is prepended automatically.
_loadShaderResource(path) {
- let common = this._loadStringResource('/shaders/common.glsl');
- let code = this._loadStringResource(path);
+ let common = getStringResource('/shaders/common.glsl');
+ let code = getStringResource(path);
// Add a trailing newline. Else the GLSL compiler complains...
return common + '\n' + code + '\n';
diff --git a/src/ShaderFactory.js b/src/ShaderFactory.js
index 003e541..123c2f8 100644
--- a/src/ShaderFactory.js
+++ b/src/ShaderFactory.js
@@ -14,10 +14,9 @@
'use strict';
-const GObject = imports.gi.GObject;
+import GObject from 'gi://GObject';
-const ExtensionUtils = imports.misc.extensionUtils;
-const Me = imports.misc.extensionUtils.getCurrentExtension();
+import {Shader} from './Shader.js';
//////////////////////////////////////////////////////////////////////////////////////////
// Each effect of Burn-My-Windows owns an instance of this class. It is used to created //
@@ -25,7 +24,7 @@ const Me = imports.misc.extensionUtils.getCurrentExtension();
// possible in order to avoid memory leaks. //
//////////////////////////////////////////////////////////////////////////////////////////
-var ShaderFactory = class {
+export class ShaderFactory {
// Creates a new ShaderFactory. Requires the nick of the effect and a callback function
// which will be called whenever a new shader is created.
@@ -62,8 +61,7 @@ var ShaderFactory = class {
// Only try to register the new type once.
if (GObject.type_from_name(typeName) == null) {
const outerThis = this;
- GObject.registerClass({GTypeName: typeName},
- class Shader extends Me.imports.src.Shader.Shader {
+ GObject.registerClass({GTypeName: typeName}, class ShaderImp extends Shader {
// This will actually load the GLSL source code from the resources.
_init() {
super._init(outerThis._nick);
diff --git a/src/WindowPicker.js b/src/WindowPicker.js
index ae4e861..0cd2945 100644
--- a/src/WindowPicker.js
+++ b/src/WindowPicker.js
@@ -15,12 +15,13 @@
'use strict';
-const {Gio, GLib} = imports.gi;
+import Gio from 'gi://Gio';
+import GLib from 'gi://GLib';
+
const Main = imports.ui.main;
const LookingGlass = imports.ui.lookingGlass;
-const Me = imports.misc.extensionUtils.getCurrentExtension();
-const utils = Me.imports.src.utils;
+import {getStringResource} from './utils.js';
//////////////////////////////////////////////////////////////////////////////////////////
// This is based on the window-picking functionality of the Blur-My-Shell extension. //
@@ -29,12 +30,12 @@ const utils = Me.imports.src.utils;
// picking. //
//////////////////////////////////////////////////////////////////////////////////////////
-var WindowPicker = class WindowPicker {
+export class WindowPicker {
// ------------------------------------------------------------------------- constructor
constructor() {
- const iFace = utils.getStringResource(
- '/interfaces/org.gnome.shell.extensions.burn-my-windows.xml');
+ const iFace =
+ getStringResource('/interfaces/org.gnome.shell.extensions.burn-my-windows.xml');
this._dbus = Gio.DBusExportedObject.wrapJSObject(iFace, this);
}
diff --git a/src/effects/Apparition.js b/src/effects/Apparition.js
index a1051fd..4ecb6b0 100644
--- a/src/effects/Apparition.js
+++ b/src/effects/Apparition.js
@@ -16,10 +16,7 @@
const _ = imports.gettext.domain('burn-my-windows').gettext;
-const ExtensionUtils = imports.misc.extensionUtils;
-const Me = imports.misc.extensionUtils.getCurrentExtension();
-const utils = Me.imports.src.utils;
-const ShaderFactory = Me.imports.src.ShaderFactory.ShaderFactory;
+import {ShaderFactory} from '../ShaderFactory.js';
//////////////////////////////////////////////////////////////////////////////////////////
// This effect hides the actor by violently sucking it into the void of magic. //
@@ -28,7 +25,7 @@ const ShaderFactory = Me.imports.src.ShaderFactory.ShaderFactory;
// The effect class can be used to get some metadata (like the effect's name or supported
// GNOME Shell versions), to initialize the respective page of the settings dialog, as
// well as to create the actual shader for the effect.
-var Apparition = class {
+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
diff --git a/src/effects/BrokenGlass.js b/src/effects/BrokenGlass.js
index 43c099d..67fc988 100644
--- a/src/effects/BrokenGlass.js
+++ b/src/effects/BrokenGlass.js
@@ -16,10 +16,7 @@
const _ = imports.gettext.domain('burn-my-windows').gettext;
-const ExtensionUtils = imports.misc.extensionUtils;
-const Me = imports.misc.extensionUtils.getCurrentExtension();
-const utils = Me.imports.src.utils;
-const ShaderFactory = Me.imports.src.ShaderFactory.ShaderFactory;
+import {ShaderFactory} from '../ShaderFactory.js';
//////////////////////////////////////////////////////////////////////////////////////////
// This effect shatters the window into pieces. For an explanation how this works, look //
@@ -40,7 +37,7 @@ const ShaderFactory = Me.imports.src.ShaderFactory.ShaderFactory;
// The effect class can be used to get some metadata (like the effect's name or supported
// GNOME Shell versions), to initialize the respective page of the settings dialog, as
// well as to create the actual shader for the effect.
-var BrokenGlass = class {
+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
diff --git a/src/effects/Doom.js b/src/effects/Doom.js
index ad77cd9..51b2d64 100644
--- a/src/effects/Doom.js
+++ b/src/effects/Doom.js
@@ -14,14 +14,9 @@
'use strict';
-const GObject = imports.gi.GObject;
-
const _ = imports.gettext.domain('burn-my-windows').gettext;
-const ExtensionUtils = imports.misc.extensionUtils;
-const Me = imports.misc.extensionUtils.getCurrentExtension();
-const utils = Me.imports.src.utils;
-const ShaderFactory = Me.imports.src.ShaderFactory.ShaderFactory;
+import {ShaderFactory} from '../ShaderFactory.js';
//////////////////////////////////////////////////////////////////////////////////////////
// This effect melts your windows. Inspired by the legendary screen transitions of the //
@@ -31,7 +26,7 @@ const ShaderFactory = Me.imports.src.ShaderFactory.ShaderFactory;
// The effect class can be used to get some metadata (like the effect's name or supported
// GNOME Shell versions), to initialize the respective page of the settings dialog, as
// well as to create the actual shader for the effect.
-var Doom = class {
+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
diff --git a/src/effects/EnergizeA.js b/src/effects/EnergizeA.js
index cb8c2a7..28cde65 100644
--- a/src/effects/EnergizeA.js
+++ b/src/effects/EnergizeA.js
@@ -14,14 +14,9 @@
'use strict';
-const GObject = imports.gi.GObject;
-
const _ = imports.gettext.domain('burn-my-windows').gettext;
-const ExtensionUtils = imports.misc.extensionUtils;
-const Me = imports.misc.extensionUtils.getCurrentExtension();
-const utils = Me.imports.src.utils;
-const ShaderFactory = Me.imports.src.ShaderFactory.ShaderFactory;
+import {ShaderFactory} from '../ShaderFactory.js';
//////////////////////////////////////////////////////////////////////////////////////////
// This effect looks a bit like the transporter effect from TOS. //
@@ -30,7 +25,7 @@ const ShaderFactory = Me.imports.src.ShaderFactory.ShaderFactory;
// The effect class can be used to get some metadata (like the effect's name or supported
// GNOME Shell versions), to initialize the respective page of the settings dialog, as
// well as to create the actual shader for the effect.
-var EnergizeA = class {
+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
diff --git a/src/effects/EnergizeB.js b/src/effects/EnergizeB.js
index 2b31c3a..bcb4dd7 100644
--- a/src/effects/EnergizeB.js
+++ b/src/effects/EnergizeB.js
@@ -14,14 +14,9 @@
'use strict';
-const GObject = imports.gi.GObject;
-
const _ = imports.gettext.domain('burn-my-windows').gettext;
-const ExtensionUtils = imports.misc.extensionUtils;
-const Me = imports.misc.extensionUtils.getCurrentExtension();
-const utils = Me.imports.src.utils;
-const ShaderFactory = Me.imports.src.ShaderFactory.ShaderFactory;
+import {ShaderFactory} from '../ShaderFactory.js';
//////////////////////////////////////////////////////////////////////////////////////////
// This effect looks a bit like the transporter effect from TNG. //
@@ -30,7 +25,7 @@ const ShaderFactory = Me.imports.src.ShaderFactory.ShaderFactory;
// The effect class can be used to get some metadata (like the effect's name or supported
// GNOME Shell versions), to initialize the respective page of the settings dialog, as
// well as to create the actual shader for the effect.
-var EnergizeB = class {
+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
diff --git a/src/effects/Fire.js b/src/effects/Fire.js
index 168ab24..b521428 100644
--- a/src/effects/Fire.js
+++ b/src/effects/Fire.js
@@ -14,14 +14,11 @@
'use strict';
-const {Gio} = imports.gi;
+import Gio from 'gi://Gio';
const _ = imports.gettext.domain('burn-my-windows').gettext;
-const ExtensionUtils = imports.misc.extensionUtils;
-const Me = imports.misc.extensionUtils.getCurrentExtension();
-const utils = Me.imports.src.utils;
-const ShaderFactory = Me.imports.src.ShaderFactory.ShaderFactory;
+import {ShaderFactory} from '../ShaderFactory.js';
//////////////////////////////////////////////////////////////////////////////////////////
// This effect is a homage to the good old Compiz days. However, it is implemented //
@@ -34,8 +31,7 @@ const ShaderFactory = Me.imports.src.ShaderFactory.ShaderFactory;
// The effect class can be used to get some metadata (like the effect's name or supported
// GNOME Shell versions), to initialize the respective page of the settings dialog, as
// well as to create the actual shader for the effect.
-var Fire = class {
-
+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
diff --git a/src/effects/Glide.js b/src/effects/Glide.js
index 14cfe4d..91165bd 100644
--- a/src/effects/Glide.js
+++ b/src/effects/Glide.js
@@ -14,14 +14,9 @@
'use strict';
-const GObject = imports.gi.GObject;
-
const _ = imports.gettext.domain('burn-my-windows').gettext;
-const ExtensionUtils = imports.misc.extensionUtils;
-const Me = imports.misc.extensionUtils.getCurrentExtension();
-const utils = Me.imports.src.utils;
-const ShaderFactory = Me.imports.src.ShaderFactory.ShaderFactory;
+import {ShaderFactory} from '../ShaderFactory.js';
//////////////////////////////////////////////////////////////////////////////////////////
// This very simple effect fades the window to transparency with subtle 3D effects. //
@@ -30,7 +25,7 @@ const ShaderFactory = Me.imports.src.ShaderFactory.ShaderFactory;
// The effect class can be used to get some metadata (like the effect's name or supported
// GNOME Shell versions), to initialize the respective page of the settings dialog, as
// well as to create the actual shader for the effect.
-var Glide = class {
+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
diff --git a/src/effects/Glitch.js b/src/effects/Glitch.js
index 6003f80..d060302 100644
--- a/src/effects/Glitch.js
+++ b/src/effects/Glitch.js
@@ -14,14 +14,9 @@
'use strict';
-const GObject = imports.gi.GObject;
-
const _ = imports.gettext.domain('burn-my-windows').gettext;
-const ExtensionUtils = imports.misc.extensionUtils;
-const Me = imports.misc.extensionUtils.getCurrentExtension();
-const utils = Me.imports.src.utils;
-const ShaderFactory = Me.imports.src.ShaderFactory.ShaderFactory;
+import {ShaderFactory} from '../ShaderFactory.js';
//////////////////////////////////////////////////////////////////////////////////////////
// This effect applies some intentional graphics issues to your windows. //
@@ -30,7 +25,7 @@ const ShaderFactory = Me.imports.src.ShaderFactory.ShaderFactory;
// The effect class can be used to get some metadata (like the effect's name or supported
// GNOME Shell versions), to initialize the respective page of the settings dialog, as
// well as to create the actual shader for the effect.
-var Glitch = class {
+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
diff --git a/src/effects/Hexagon.js b/src/effects/Hexagon.js
index 75c74d1..0286530 100644
--- a/src/effects/Hexagon.js
+++ b/src/effects/Hexagon.js
@@ -14,14 +14,9 @@
'use strict';
-const GObject = imports.gi.GObject;
-
const _ = imports.gettext.domain('burn-my-windows').gettext;
-const ExtensionUtils = imports.misc.extensionUtils;
-const Me = imports.misc.extensionUtils.getCurrentExtension();
-const utils = Me.imports.src.utils;
-const ShaderFactory = Me.imports.src.ShaderFactory.ShaderFactory;
+import {ShaderFactory} from '../ShaderFactory.js';
//////////////////////////////////////////////////////////////////////////////////////////
// This effect overlays a glowing hexagonal grid over the window. The grid cells then //
@@ -31,7 +26,7 @@ const ShaderFactory = Me.imports.src.ShaderFactory.ShaderFactory;
// The effect class can be used to get some metadata (like the effect's name or supported
// GNOME Shell versions), to initialize the respective page of the settings dialog, as
// well as to create the actual shader for the effect.
-var Hexagon = class {
+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
diff --git a/src/effects/Incinerate.js b/src/effects/Incinerate.js
index da5821e..5dbcead 100644
--- a/src/effects/Incinerate.js
+++ b/src/effects/Incinerate.js
@@ -14,14 +14,9 @@
'use strict';
-const GObject = imports.gi.GObject;
-
const _ = imports.gettext.domain('burn-my-windows').gettext;
-const ExtensionUtils = imports.misc.extensionUtils;
-const Me = imports.misc.extensionUtils.getCurrentExtension();
-const utils = Me.imports.src.utils;
-const ShaderFactory = Me.imports.src.ShaderFactory.ShaderFactory;
+import {ShaderFactory} from '../ShaderFactory.js';
//////////////////////////////////////////////////////////////////////////////////////////
// This effect burns windows to ashes. The fire starts at a random position at the //
@@ -31,7 +26,7 @@ const ShaderFactory = Me.imports.src.ShaderFactory.ShaderFactory;
// The effect class can be used to get some metadata (like the effect's name or supported
// GNOME Shell versions), to initialize the respective page of the settings dialog, as
// well as to create the actual shader for the effect.
-var Incinerate = class {
+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
diff --git a/src/effects/Matrix.js b/src/effects/Matrix.js
index 56690a3..6cb17d5 100644
--- a/src/effects/Matrix.js
+++ b/src/effects/Matrix.js
@@ -14,14 +14,9 @@
'use strict';
-const GObject = imports.gi.GObject;
-
const _ = imports.gettext.domain('burn-my-windows').gettext;
-const ExtensionUtils = imports.misc.extensionUtils;
-const Me = imports.misc.extensionUtils.getCurrentExtension();
-const utils = Me.imports.src.utils;
-const ShaderFactory = Me.imports.src.ShaderFactory.ShaderFactory;
+import {ShaderFactory} from '../ShaderFactory.js';
//////////////////////////////////////////////////////////////////////////////////////////
// The Matrix shader multiplies a grid of random letters with some gradients which are //
@@ -34,7 +29,7 @@ const ShaderFactory = Me.imports.src.ShaderFactory.ShaderFactory;
// The effect class can be used to get some metadata (like the effect's name or supported
// GNOME Shell versions), to initialize the respective page of the settings dialog, as
// well as to create the actual shader for the effect.
-var Matrix = class {
+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
diff --git a/src/effects/PaintBrush.js b/src/effects/PaintBrush.js
index f818e9d..2f66a96 100644
--- a/src/effects/PaintBrush.js
+++ b/src/effects/PaintBrush.js
@@ -14,14 +14,9 @@
'use strict';
-const GObject = imports.gi.GObject;
-
const _ = imports.gettext.domain('burn-my-windows').gettext;
-const ExtensionUtils = imports.misc.extensionUtils;
-const Me = imports.misc.extensionUtils.getCurrentExtension();
-const utils = Me.imports.src.utils;
-const ShaderFactory = Me.imports.src.ShaderFactory.ShaderFactory;
+import {ShaderFactory} from '../ShaderFactory.js';
//////////////////////////////////////////////////////////////////////////////////////////
// This effect paints your windows with a thick paint brush. //
@@ -32,7 +27,7 @@ const ShaderFactory = Me.imports.src.ShaderFactory.ShaderFactory;
// The effect class can be used to get some metadata (like the effect's name or supported
// GNOME Shell versions), to initialize the respective page of the settings dialog, as
// well as to create the actual shader for the effect.
-var PaintBrush = class {
+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
diff --git a/src/effects/PixelWheel.js b/src/effects/PixelWheel.js
index 60955ec..5f30210 100644
--- a/src/effects/PixelWheel.js
+++ b/src/effects/PixelWheel.js
@@ -14,14 +14,9 @@
'use strict';
-const GObject = imports.gi.GObject;
-
const _ = imports.gettext.domain('burn-my-windows').gettext;
-const ExtensionUtils = imports.misc.extensionUtils;
-const Me = imports.misc.extensionUtils.getCurrentExtension();
-const utils = Me.imports.src.utils;
-const ShaderFactory = Me.imports.src.ShaderFactory.ShaderFactory;
+import {ShaderFactory} from '../ShaderFactory.js';
//////////////////////////////////////////////////////////////////////////////////////////
// This simple effect pixelates the window texture and hides the pixels in a wheel-like //
@@ -31,7 +26,7 @@ const ShaderFactory = Me.imports.src.ShaderFactory.ShaderFactory;
// The effect class can be used to get some metadata (like the effect's name or supported
// GNOME Shell versions), to initialize the respective page of the settings dialog, as
// well as to create the actual shader for the effect.
-var PixelWheel = class {
+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
diff --git a/src/effects/PixelWipe.js b/src/effects/PixelWipe.js
index 88fcdb9..c683ef2 100644
--- a/src/effects/PixelWipe.js
+++ b/src/effects/PixelWipe.js
@@ -14,14 +14,9 @@
'use strict';
-const GObject = imports.gi.GObject;
-
const _ = imports.gettext.domain('burn-my-windows').gettext;
-const ExtensionUtils = imports.misc.extensionUtils;
-const Me = imports.misc.extensionUtils.getCurrentExtension();
-const utils = Me.imports.src.utils;
-const ShaderFactory = Me.imports.src.ShaderFactory.ShaderFactory;
+import {ShaderFactory} from '../ShaderFactory.js';
//////////////////////////////////////////////////////////////////////////////////////////
// This effect pixelates the window texture and hides the pixels radially, starting //
@@ -31,7 +26,7 @@ const ShaderFactory = Me.imports.src.ShaderFactory.ShaderFactory;
// The effect class can be used to get some metadata (like the effect's name or supported
// GNOME Shell versions), to initialize the respective page of the settings dialog, as
// well as to create the actual shader for the effect.
-var PixelWipe = class {
+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
diff --git a/src/effects/Pixelate.js b/src/effects/Pixelate.js
index a91285e..33554a3 100644
--- a/src/effects/Pixelate.js
+++ b/src/effects/Pixelate.js
@@ -14,14 +14,9 @@
'use strict';
-const GObject = imports.gi.GObject;
-
const _ = imports.gettext.domain('burn-my-windows').gettext;
-const ExtensionUtils = imports.misc.extensionUtils;
-const Me = imports.misc.extensionUtils.getCurrentExtension();
-const utils = Me.imports.src.utils;
-const ShaderFactory = Me.imports.src.ShaderFactory.ShaderFactory;
+import {ShaderFactory} from '../ShaderFactory.js';
//////////////////////////////////////////////////////////////////////////////////////////
// This very simple effect pixelates the window texture and randomly hides pixels until //
@@ -31,7 +26,7 @@ const ShaderFactory = Me.imports.src.ShaderFactory.ShaderFactory;
// The effect class can be used to get some metadata (like the effect's name or supported
// GNOME Shell versions), to initialize the respective page of the settings dialog, as
// well as to create the actual shader for the effect.
-var Pixelate = class {
+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
diff --git a/src/effects/Portal.js b/src/effects/Portal.js
index f17d46f..8ce59a8 100644
--- a/src/effects/Portal.js
+++ b/src/effects/Portal.js
@@ -14,14 +14,9 @@
'use strict';
-const GObject = imports.gi.GObject;
-
const _ = imports.gettext.domain('burn-my-windows').gettext;
-const ExtensionUtils = imports.misc.extensionUtils;
-const Me = imports.misc.extensionUtils.getCurrentExtension();
-const utils = Me.imports.src.utils;
-const ShaderFactory = Me.imports.src.ShaderFactory.ShaderFactory;
+import {ShaderFactory} from '../ShaderFactory.js';
//////////////////////////////////////////////////////////////////////////////////////////
// This ridiculous effect teleports your windows from and to alternative dimensions. //
@@ -31,7 +26,7 @@ const ShaderFactory = Me.imports.src.ShaderFactory.ShaderFactory;
// The effect class can be used to get some metadata (like the effect's name or supported
// GNOME Shell versions), to initialize the respective page of the settings dialog, as
// well as to create the actual shader for the effect.
-var Portal = class {
+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
diff --git a/src/effects/SnapOfDisintegration.js b/src/effects/SnapOfDisintegration.js
index 3b2b724..ac41568 100644
--- a/src/effects/SnapOfDisintegration.js
+++ b/src/effects/SnapOfDisintegration.js
@@ -14,14 +14,9 @@
'use strict';
-const GObject = imports.gi.GObject;
-
const _ = imports.gettext.domain('burn-my-windows').gettext;
-const ExtensionUtils = imports.misc.extensionUtils;
-const Me = imports.misc.extensionUtils.getCurrentExtension();
-const utils = Me.imports.src.utils;
-const ShaderFactory = Me.imports.src.ShaderFactory.ShaderFactory;
+import {ShaderFactory} from '../ShaderFactory.js';
//////////////////////////////////////////////////////////////////////////////////////////
// This effects dissolves your windows into a cloud of dust. For this, it uses an //
@@ -36,7 +31,7 @@ const ShaderFactory = Me.imports.src.ShaderFactory.ShaderFactory;
// The effect class can be used to get some metadata (like the effect's name or supported
// GNOME Shell versions), to initialize the respective page of the settings dialog, as
// well as to create the actual shader for the effect.
-var SnapOfDisintegration = class {
+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
diff --git a/src/effects/TRexAttack.js b/src/effects/TRexAttack.js
index 30f854f..02df7c1 100644
--- a/src/effects/TRexAttack.js
+++ b/src/effects/TRexAttack.js
@@ -14,14 +14,9 @@
'use strict';
-const GObject = imports.gi.GObject;
-
const _ = imports.gettext.domain('burn-my-windows').gettext;
-const ExtensionUtils = imports.misc.extensionUtils;
-const Me = imports.misc.extensionUtils.getCurrentExtension();
-const utils = Me.imports.src.utils;
-const ShaderFactory = Me.imports.src.ShaderFactory.ShaderFactory;
+import {ShaderFactory} from '../ShaderFactory.js';
//////////////////////////////////////////////////////////////////////////////////////////
// This effect tears your windows apart with a series of violent scratches! //
@@ -32,7 +27,7 @@ const ShaderFactory = Me.imports.src.ShaderFactory.ShaderFactory;
// The effect class can be used to get some metadata (like the effect's name or supported
// GNOME Shell versions), to initialize the respective page of the settings dialog, as
// well as to create the actual shader for the effect.
-var TRexAttack = class {
+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
diff --git a/src/effects/TVEffect.js b/src/effects/TVEffect.js
index 578f9a1..52dd25a 100644
--- a/src/effects/TVEffect.js
+++ b/src/effects/TVEffect.js
@@ -14,14 +14,9 @@
'use strict';
-const GObject = imports.gi.GObject;
-
const _ = imports.gettext.domain('burn-my-windows').gettext;
-const ExtensionUtils = imports.misc.extensionUtils;
-const Me = imports.misc.extensionUtils.getCurrentExtension();
-const utils = Me.imports.src.utils;
-const ShaderFactory = Me.imports.src.ShaderFactory.ShaderFactory;
+import {ShaderFactory} from '../ShaderFactory.js';
//////////////////////////////////////////////////////////////////////////////////////////
// This effect hides the actor by making it first transparent from top and bottom //
@@ -32,7 +27,7 @@ const ShaderFactory = Me.imports.src.ShaderFactory.ShaderFactory;
// The effect class can be used to get some metadata (like the effect's name or supported
// GNOME Shell versions), to initialize the respective page of the settings dialog, as
// well as to create the actual shader for the effect.
-var TVEffect = class {
+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
diff --git a/src/effects/TVGlitch.js b/src/effects/TVGlitch.js
index 155f97d..f1c944d 100644
--- a/src/effects/TVGlitch.js
+++ b/src/effects/TVGlitch.js
@@ -14,14 +14,9 @@
'use strict';
-const GObject = imports.gi.GObject;
-
const _ = imports.gettext.domain('burn-my-windows').gettext;
-const ExtensionUtils = imports.misc.extensionUtils;
-const Me = imports.misc.extensionUtils.getCurrentExtension();
-const utils = Me.imports.src.utils;
-const ShaderFactory = Me.imports.src.ShaderFactory.ShaderFactory;
+import {ShaderFactory} from '../ShaderFactory.js';
//////////////////////////////////////////////////////////////////////////////////////////
// This effect combines the Glitch and the TV Effect. Credits go to Kurt Wilson //
@@ -31,7 +26,7 @@ const ShaderFactory = Me.imports.src.ShaderFactory.ShaderFactory;
// The effect class can be used to get some metadata (like the effect's name or supported
// GNOME Shell versions), to initialize the respective page of the settings dialog, as
// well as to create the actual shader for the effect.
-var TVGlitch = class {
+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
diff --git a/src/effects/Wisps.js b/src/effects/Wisps.js
index 48078ba..f598cad 100644
--- a/src/effects/Wisps.js
+++ b/src/effects/Wisps.js
@@ -14,14 +14,9 @@
'use strict';
-const GObject = imports.gi.GObject;
-
const _ = imports.gettext.domain('burn-my-windows').gettext;
-const ExtensionUtils = imports.misc.extensionUtils;
-const Me = imports.misc.extensionUtils.getCurrentExtension();
-const utils = Me.imports.src.utils;
-const ShaderFactory = Me.imports.src.ShaderFactory.ShaderFactory;
+import {ShaderFactory} from '../ShaderFactory.js';
//////////////////////////////////////////////////////////////////////////////////////////
// This effect lets your windows be carried to the realm of dreams by some little //
@@ -31,7 +26,7 @@ const ShaderFactory = Me.imports.src.ShaderFactory.ShaderFactory;
// The effect class can be used to get some metadata (like the effect's name or supported
// GNOME Shell versions), to initialize the respective page of the settings dialog, as
// well as to create the actual shader for the effect.
-var Wisps = class {
+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
diff --git a/src/migrate.js b/src/migrate.js
index 5814c82..2a7d62b 100644
--- a/src/migrate.js
+++ b/src/migrate.js
@@ -14,18 +14,15 @@
'use strict';
-const ExtensionUtils = imports.misc.extensionUtils;
-const Me = imports.misc.extensionUtils.getCurrentExtension();
-const ProfileManager = Me.imports.src.ProfileManager.ProfileManager;
-const utils = Me.imports.src.utils;
+import {ProfileManager} from './ProfileManager.js';
+import {debug, executeCommand} from './utils.js';
// Migrating from pre-27 versions is pretty involved. Before, all settings were stored in
// the standard Gio.Settings backend. Now, there are effect profiles. Depending on the
// settings one or two profiles may be required.
-async function fromVersion26() {
- return utils
- .executeCommand(['dconf', 'dump', '/org/gnome/shell/extensions/burn-my-windows/'])
- .catch(r => utils.debug('Failed to get old settings for effect migration: ' + r))
+export async function fromVersion26() {
+ return executeCommand(['dconf', 'dump', '/org/gnome/shell/extensions/burn-my-windows/'])
+ .catch(r => debug('Failed to get old settings for effect migration: ' + r))
.then(r => {
// If there were no settings before, we do not have to migrate anything. Just use
// the new defaults.
@@ -33,7 +30,7 @@ async function fromVersion26() {
return;
}
- utils.debug('Starting Burn-My-Windows profile migration (old version <= 26)!');
+ debug('Starting Burn-My-Windows profile migration (old version <= 26)!');
// We use this to write the new profiles.
const profileManager = new ProfileManager();
@@ -41,19 +38,19 @@ async function fromVersion26() {
// The default value of this was false, so not-present is equal to false.
const destroyDialogs = r.includes('destroy-dialogs=true');
if (!destroyDialogs) {
- utils.debug('Only normal windows will be burned by the new profile(s).');
+ debug('Only normal windows will be burned by the new profile(s).');
}
// The default value of this was false, so not-present is equal to false.
const disableOnBattery = r.includes('disable-on-battery=true');
if (disableOnBattery) {
- utils.debug('The new profile(s) will not be active on battery.');
+ debug('The new profile(s) will not be active on battery.');
}
// The default value of this was false, so not-present is equal to false.
const disableOnPowerSave = r.includes('disable-on-power-save=true');
if (disableOnPowerSave) {
- utils.debug('The new profile(s) will not be active in power-save mode.');
+ debug('The new profile(s) will not be active in power-save mode.');
}
// Remove some unnecessary lines.
@@ -88,21 +85,21 @@ async function fromVersion26() {
}
// Print all effects we've found.
- utils.debug('Enabled open effects: ' + openEffects);
- utils.debug('Enabled close effects: ' + closeEffects);
+ debug('Enabled open effects: ' + openEffects);
+ debug('Enabled close effects: ' + closeEffects);
// If the same effects were used for opening and closing windows or there is either
// no opening or no closing animation configured, only one profile is required. Else
// we have to create two new profiles.
const numProfiles = openEffects.join() == closeEffects.join() ? 1 : 2;
if (numProfiles == 1) {
- utils.debug('Only one profile is required.');
+ debug('Only one profile is required.');
} else if (closeEffects.length == 0) {
- utils.debug('Only a window-open profile is required.');
+ debug('Only a window-open profile is required.');
} else if (openEffects.length == 0) {
- utils.debug('Only a window-close profile is required.');
+ debug('Only a window-close profile is required.');
} else {
- utils.debug('Two profiles are required.');
+ debug('Two profiles are required.');
}
// Remove all open / close lines.
@@ -143,8 +140,8 @@ async function fromVersion26() {
// Print and save the new profile.
const profile = profileLines.join('\n');
- utils.debug('The new profile:');
- utils.debug(profile);
+ debug('The new profile:');
+ debug(profile);
profileManager.createProfile(profile);
@@ -165,8 +162,8 @@ async function fromVersion26() {
// Print and save the new profile.
const profile = profileLines.join('\n');
- utils.debug('The new window-open profile:');
- utils.debug(profile);
+ debug('The new window-open profile:');
+ debug(profile);
profileManager.createProfile(profile);
@@ -187,8 +184,8 @@ async function fromVersion26() {
// Print and save the new profile.
const profile = profileLines.join('\n');
- utils.debug('The new window-close profile:');
- utils.debug(profile);
+ debug('The new window-close profile:');
+ debug(profile);
profileManager.createProfile(profile);
@@ -216,14 +213,14 @@ async function fromVersion26() {
const openProfile = openProfileLines.join('\n');
const closeProfile = closeProfileLines.join('\n');
- utils.debug('The new open-window profile:');
- utils.debug(openProfile);
- utils.debug('The new close-window profile:');
- utils.debug(closeProfile);
+ debug('The new open-window profile:');
+ debug(openProfile);
+ debug('The new close-window profile:');
+ debug(closeProfile);
profileManager.createProfile(openProfile);
profileManager.createProfile(closeProfile);
}
})
- .catch(r => utils.debug('Failed to migrate settings: ' + r));
+ .catch(r => debug('Failed to migrate settings: ' + r));
}
\ No newline at end of file
diff --git a/src/utils.js b/src/utils.js
index 5e9f5c9..a8b761d 100644
--- a/src/utils.js
+++ b/src/utils.js
@@ -14,13 +14,14 @@
'use strict';
-const {Gtk, Gio} = imports.gi;
-const ByteArray = imports.byteArray;
+import Gio from 'gi://Gio';
+import Gtk from 'gi://Gtk';
+import GLib from 'gi://GLib';
// libadwaita is available starting with GNOME Shell 42.
let Adw = null;
try {
- Adw = imports.gi.Adw;
+ Adw = await import('gi://Adw');
} catch (e) {
// Nothing to do.
}
@@ -39,12 +40,10 @@ function toNumericVersion(x) {
return x;
}
+const Me = imports.misc.extensionUtils.getCurrentExtension();
const Config = imports.misc.config;
const [GS_MAJOR, GS_MINOR] = Config.PACKAGE_VERSION.split('.').map(toNumericVersion);
-const ExtensionUtils = imports.misc.extensionUtils;
-const Me = imports.misc.extensionUtils.getCurrentExtension();
-
const _ = imports.gettext.domain('burn-my-windows').gettext;
// This method can be used to write a message to GNOME Shell's log. This is enhances
@@ -54,7 +53,7 @@ const _ = imports.gettext.domain('burn-my-windows').gettext;
// journalctl -f -o cat | grep -E 'particle-effects|'
// This method is based on a similar script from the Fly-Pie GNOME Shell extension which
// os published under the MIT License (https://github.com/Schneegans/Fly-Pie).
-function debug(message) {
+export function debug(message) {
const stack = new Error().stack.split('\n');
// Remove debug() function call from stack.
@@ -68,31 +67,31 @@ function debug(message) {
}
// This method simply returns true if we are currently using GTK4.
-function isGTK4() {
+export function isGTK4() {
return Gtk.get_major_version() == 4;
}
// Starting with GNOME Shell 42, the settings dialog uses libadwaita (at least most of
// the time - it seems that pop!_OS does not support libadwaita even on GNOME 42).
-function isADW() {
+export function isADW() {
return Adw && shellVersionIsAtLeast(42, 'beta');
}
// This method returns 'gtk3', 'gtk4', or 'adw' depending on the currently used GTK / and
// or libadwaita version.
-function getUIDir() {
+export function getUIDir() {
return isADW() ? 'adw' : (isGTK4() ? 'gtk4' : 'gtk3');
}
// This method returns true if the current GNOME Shell version matches the given
// arguments.
-function shellVersionIs(major, minor) {
+export function shellVersionIs(major, minor) {
return GS_MAJOR == major && GS_MINOR == toNumericVersion(minor);
}
// This method returns true if the current GNOME Shell version is at least as high as the
// given arguments. Supports "alpha" and "beta" for the minor version number.
-function shellVersionIsAtLeast(major, minor) {
+export function shellVersionIsAtLeast(major, minor) {
if (GS_MAJOR > major) {
return true;
}
@@ -106,9 +105,9 @@ function shellVersionIsAtLeast(major, minor) {
// Reads the contents of a file contained in the global resources archive. The data
// is returned as a string.
-function getStringResource(path) {
+export function getStringResource(path) {
const data = Gio.resources_lookup_data(path, 0);
- return ByteArray.toString(ByteArray.fromGBytes(data));
+ return new TextDecoder().decode(data.get_data());
}
// Executes a command asynchronously and returns the output from 'stdout' on success or
@@ -116,7 +115,7 @@ function getStringResource(path) {
// 'stdin' and cancellable can be used to stop the process before it finishes.
// This is directly taken from here:
// https://gjs.guide/guides/gio/subprocesses.html#complete-examples
-async function executeCommand(argv, input = null, cancellable = null) {
+export async function executeCommand(argv, input = null, cancellable = null) {
let cancelId = 0;
let flags = (Gio.SubprocessFlags.STDOUT_PIPE | Gio.SubprocessFlags.STDERR_PIPE);
From 7b90fd70bc2eda5e05cfc54a73a7735768c8b3c5 Mon Sep 17 00:00:00 2001
From: Simon Schneegans
Date: Wed, 12 Jul 2023 11:44:43 +0200
Subject: [PATCH 02/26] :construction: Continue port to ESM
---
prefs.js | 13 +++----------
src/effects/Fire.js | 3 ++-
src/utils.js | 9 +--------
3 files changed, 6 insertions(+), 19 deletions(-)
diff --git a/prefs.js b/prefs.js
index 8a44859..fe37e4f 100644
--- a/prefs.js
+++ b/prefs.js
@@ -18,9 +18,10 @@ import Gio from 'gi://Gio';
import Gtk from 'gi://Gtk';
import GLib from 'gi://GLib';
import Gdk from 'gi://Gdk';
+import Adw from 'gi://Adw';
-import {isADW, isGTK4, getUIDir, getStringResource, shellVersionIsAtLeast} from './utils.js';
-import {ProfileManager} from './ProfileManager.js';
+import {isADW, isGTK4, getUIDir, getStringResource, shellVersionIsAtLeast} from './src/utils.js';
+import {ProfileManager} from './src/ProfileManager.js';
import Apparition from './src/effects/Apparition.js';
import BrokenGlass from './src/effects/BrokenGlass.js';
@@ -44,14 +45,6 @@ import TVEffect from './src/effects/TVEffect.js';
import TVGlitch from './src/effects/TVGlitch.js';
import Wisps from './src/effects/Wisps.js';
-// libadwaita is available starting with GNOME Shell 42.
-let Adw = null;
-try {
- Adw = await import('gi://Adw');
-} catch (e) {
- // Nothing to do.
-}
-
const _ = imports.gettext.domain('burn-my-windows').gettext;
const ExtensionUtils = imports.misc.extensionUtils;
diff --git a/src/effects/Fire.js b/src/effects/Fire.js
index b521428..b819774 100644
--- a/src/effects/Fire.js
+++ b/src/effects/Fire.js
@@ -19,6 +19,7 @@ import Gio from 'gi://Gio';
const _ = imports.gettext.domain('burn-my-windows').gettext;
import {ShaderFactory} from '../ShaderFactory.js';
+import {isGTK4} from '../utils.js';
//////////////////////////////////////////////////////////////////////////////////////////
// This effect is a homage to the good old Compiz days. However, it is implemented //
@@ -224,7 +225,7 @@ export default class Effect {
dialog.getBuilder().get_object('fire-preset-button').set_menu_model(menu);
- const root = utils.isGTK4() ? widget.get_root() : widget.get_toplevel();
+ const root = isGTK4() ? widget.get_root() : widget.get_toplevel();
root.insert_action_group(groupName, group);
});
}
diff --git a/src/utils.js b/src/utils.js
index a8b761d..6999fa9 100644
--- a/src/utils.js
+++ b/src/utils.js
@@ -17,14 +17,7 @@
import Gio from 'gi://Gio';
import Gtk from 'gi://Gtk';
import GLib from 'gi://GLib';
-
-// libadwaita is available starting with GNOME Shell 42.
-let Adw = null;
-try {
- Adw = await import('gi://Adw');
-} catch (e) {
- // Nothing to do.
-}
+import Adw from 'gi://Adw';
// Returns the given argument, except for "alpha", "beta", and "rc". In these cases -3,
// -2, and -1 are returned respectively.
From d1cddb129df7bd20c586f877fcd3b15e0f11e76c Mon Sep 17 00:00:00 2001
From: Simon Schneegans
Date: Mon, 7 Aug 2023 12:57:38 +0200
Subject: [PATCH 03/26] :wrench: Port to ESM
---
extension.js | 123 ++++++++++++++++++------------------------
prefs.js | 93 +++++++++++++++++++++++---------
src/ProfileManager.js | 62 ++-------------------
src/WindowPicker.js | 4 +-
src/utils.js | 8 ++-
5 files changed, 131 insertions(+), 159 deletions(-)
diff --git a/extension.js b/extension.js
index f385b79..b32f939 100644
--- a/extension.js
+++ b/extension.js
@@ -44,19 +44,11 @@ import TVEffect from './src/effects/TVEffect.js';
import TVGlitch from './src/effects/TVGlitch.js';
import Wisps from './src/effects/Wisps.js';
-const Main = imports.ui.main;
-const Workspace = imports.ui.workspace.Workspace;
+import * as Main from 'resource:///org/gnome/shell/ui/main.js';
+import {Workspace} from 'resource:///org/gnome/shell/ui/workspace.js';
+import {WindowPreview} from 'resource:///org/gnome/shell/ui/windowPreview.js';
+import {Extension} from 'resource:///org/gnome/shell/extensions/extension.js';
-// The WindowPreview class is only available on GNOME Shell 3.38+;
-let WindowPreview = null;
-try {
- WindowPreview = imports.ui.windowPreview.WindowPreview;
-} catch (error) {
- // Nothing to be done, we are on GNOME Shell 3.36.
-}
-
-const ExtensionUtils = imports.misc.extensionUtils;
-const Me = imports.misc.extensionUtils.getCurrentExtension();
//////////////////////////////////////////////////////////////////////////////////////////
// This extensions modifies the window-close and window-open animations with all kinds //
@@ -67,7 +59,7 @@ const Me = imports.misc.extensionUtils.getCurrentExtension();
// to get this working. For more details, read the other comments in this file... //
//////////////////////////////////////////////////////////////////////////////////////////
-export default class Extension {
+export default class BurnMyWindows extends Extension {
// ------------------------------------------------------------------------ public stuff
@@ -101,22 +93,23 @@ export default class Extension {
];
// Load all of our resources.
- this._resources = Gio.Resource.load(Me.path + '/resources/burn-my-windows.gresource');
+ this._resources =
+ Gio.Resource.load(this.path + '/resources/burn-my-windows.gresource');
Gio.resources_register(this._resources);
// Store a reference to the settings object.
- this._settings = ExtensionUtils.getSettings();
+ this._settings = this.getSettings();
// Now we check whether the extension settings need to be migrated from a previous
// version. If this is the case, we defer the profile loading until this is finished.
const lastVersion = this._settings.get_int('last-extension-version');
- if (lastVersion < Me.metadata.version) {
+ if (lastVersion < this.metadata.version) {
if (lastVersion <= 26) {
// If the profile migration fails for some reason, the callback will create a
// default profile instead.
fromVersion26().finally(() => {
this._loadProfiles();
- this._settings.set_int('last-extension-version', Me.metadata.version);
+ this._settings.set_int('last-extension-version', this.metadata.version);
});
} else {
this._loadProfiles();
@@ -324,53 +317,50 @@ export default class Extension {
};
// With the code below, we hide the window-overlay (icon, label, close button) in the
- // overview once the close-animation is running. As the WindowPreview class is only
- // available on GNOME 3.38 and beyond, we cannot hide the overlay on GNOME 3.36.
- if (WindowPreview) {
+ // overview once the close-animation is running.
- // We will monkey-patch these methods.
- this._origDeleteAll = WindowPreview.prototype._deleteAll;
- this._origRestack = WindowPreview.prototype._restack;
- this._origInit = WindowPreview.prototype._init;
+ // We will monkey-patch these methods.
+ this._origDeleteAll = WindowPreview.prototype._deleteAll;
+ this._origRestack = WindowPreview.prototype._restack;
+ this._origInit = WindowPreview.prototype._init;
- // Whenever a WindowPreview is created, we connect to the referenced Meta.Window's
- // 'unmanaged' signal to hide the overlay.
- WindowPreview.prototype._init = function(...params) {
- extensionThis._origInit.apply(this, params);
+ // Whenever a WindowPreview is created, we connect to the referenced Meta.Window's
+ // 'unmanaged' signal to hide the overlay.
+ WindowPreview.prototype._init = function(...params) {
+ extensionThis._origInit.apply(this, params);
- // Hide the window's icon, name, and close button.
- const connectionID = this.metaWindow.connect('unmanaged', () => {
- if (this.window_container) {
- this.overlayEnabled = false;
- this._icon.visible = false;
- }
- });
-
- // Make sure to not call the callback above if the Meta.Window was not unmanaged
- // before leaving the overview.
- this.connect('destroy', () => {
- this.metaWindow.disconnect(connectionID);
- });
- };
-
- // The _deleteAll is called when the user clicks the X in the overview. We should
- // not attempt to close windows twice. Due to the animation in the overview, the
- // close button can be clicked twice which normally would lead to a crash.
- WindowPreview.prototype._deleteAll = function() {
- if (!this._closeRequested) {
- extensionThis._origDeleteAll.apply(this);
+ // Hide the window's icon, name, and close button.
+ const connectionID = this.metaWindow.connect('unmanaged', () => {
+ if (this.window_container) {
+ this.overlayEnabled = false;
+ this._icon.visible = false;
}
- };
+ });
- // This is required, else WindowPreview's _restack() which is called by the
- // "this.overlayEnabled = false", sometimes tries to access an already delete
- // WindowPreview.
- WindowPreview.prototype._restack = function() {
- if (!this._closeRequested) {
- extensionThis._origRestack.apply(this);
- }
- };
- }
+ // Make sure to not call the callback above if the Meta.Window was not unmanaged
+ // before leaving the overview.
+ this.connect('destroy', () => {
+ this.metaWindow.disconnect(connectionID);
+ });
+ };
+
+ // The _deleteAll is called when the user clicks the X in the overview. We should
+ // not attempt to close windows twice. Due to the animation in the overview, the
+ // close button can be clicked twice which normally would lead to a crash.
+ WindowPreview.prototype._deleteAll = function() {
+ if (!this._closeRequested) {
+ extensionThis._origDeleteAll.apply(this);
+ }
+ };
+
+ // This is required, else WindowPreview's _restack() which is called by the
+ // "this.overlayEnabled = false", sometimes tries to access an already delete
+ // WindowPreview.
+ WindowPreview.prototype._restack = function() {
+ if (!this._closeRequested) {
+ extensionThis._origRestack.apply(this);
+ }
+ };
}
// This function could be called after the extension is uninstalled, disabled in GNOME
@@ -395,11 +385,9 @@ export default class Extension {
Main.wm._shouldAnimateActor = this._origShouldAnimateActor;
Main.wm._waitForOverviewToHide = this._origWaitForOverviewToHide;
- if (WindowPreview) {
- WindowPreview.prototype._deleteAll = this._origDeleteAll;
- WindowPreview.prototype._restack = this._origRestack;
- WindowPreview.prototype._init = this._origInit;
- }
+ WindowPreview.prototype._deleteAll = this._origDeleteAll;
+ WindowPreview.prototype._restack = this._origRestack;
+ WindowPreview.prototype._init = this._origInit;
this._settings = null;
}
@@ -415,7 +403,7 @@ export default class Extension {
_loadProfiles() {
// Get all currently available profiles.
- const profileManager = new ProfileManager();
+ const profileManager = new ProfileManager(this.metadata);
this._profiles = profileManager.getProfiles();
// Whenever the properties of a profile is changed in the settings, we may have to
@@ -666,8 +654,3 @@ export default class Extension {
return shader == null;
}
}
-
-// This function is called once when the extension is loaded, not enabled.
-function init() {
- return new Extension();
-}
diff --git a/prefs.js b/prefs.js
index ecb9f64..d47c0cd 100644
--- a/prefs.js
+++ b/prefs.js
@@ -45,10 +45,7 @@ import TVEffect from './src/effects/TVEffect.js';
import TVGlitch from './src/effects/TVGlitch.js';
import Wisps from './src/effects/Wisps.js';
-const _ = imports.gettext.domain('burn-my-windows').gettext;
-
-const ExtensionUtils = imports.misc.extensionUtils;
-const Me = imports.misc.extensionUtils.getCurrentExtension();
+import {ExtensionPreferences, gettext as _} from 'resource:///org/gnome/Shell/Extensions/js/extensions/prefs.js';
//////////////////////////////////////////////////////////////////////////////////////////
// The preferences dialog is organized in pages, each of which is loaded from a //
@@ -56,15 +53,10 @@ const Me = imports.misc.extensionUtils.getCurrentExtension();
// from the respective effects. //
//////////////////////////////////////////////////////////////////////////////////////////
-export default class ExtensionPreferences {
+export default class BurnMyWindowsPreferences extends ExtensionPreferences {
// ------------------------------------------------------------ constructor / destructor
- // This is used for setting up the translations.
- constructor() {
- ExtensionUtils.initTranslations();
- }
-
fillPreferencesWindow(window) {
window.set_default_size(650, 750);
@@ -94,7 +86,8 @@ export default class ExtensionPreferences {
];
// Load all of our resources.
- this._resources = Gio.Resource.load(Me.path + '/resources/burn-my-windows.gresource');
+ this._resources =
+ Gio.Resource.load(this.path + '/resources/burn-my-windows.gresource');
Gio.resources_register(this._resources);
// Load the CSS file for the settings dialog. If using libadwaita, we do not need an
@@ -125,10 +118,10 @@ export default class ExtensionPreferences {
this._builder.add_from_resource(`/ui/${getUIDir()}/prefs.ui`);
// Store a reference to the general settings object.
- this._settings = ExtensionUtils.getSettings();
+ this._settings = this.getSettings();
// This tracks all available effect profiles.
- this._profileManager = new ProfileManager();
+ this._profileManager = new ProfileManager(this.metadata);
// This is used to track all connections to properties of the current effect profile.
// Whenever the current effect profile changes, all connections are disconnected.
@@ -396,7 +389,7 @@ export default class ExtensionPreferences {
const window = isGTK4() ? widget.get_root() : widget.get_toplevel();
// Show the version number in the title bar.
- window.set_title(`Burn-My-Windows ${Me.metadata.version}`);
+ window.set_title(`Burn-My-Windows ${this.metadata.version}`);
this._loadActiveProfile();
this._updateProfileMenu();
@@ -404,7 +397,7 @@ export default class ExtensionPreferences {
// Show an Adw.Toast or a Gtk.InfoBar whenever Burn-My-Windows was updated. We use a
// small timeout so that it is not shown instantaneously.
const lastVersion = this._settings.get_int('last-prefs-version');
- if (lastVersion < Me.metadata.version) {
+ if (lastVersion < this.metadata.version) {
this._showUpdateInfoTimeout =
GLib.timeout_add(GLib.PRIORITY_DEFAULT, 2000, () => {
this._showUpdateInfoTimeout = 0;
@@ -415,15 +408,15 @@ export default class ExtensionPreferences {
toast.set_action_name('prefs.changelog');
toast.set_timeout(0);
- toast.connect(
- 'dismissed',
- () => this._settings.set_int('last-prefs-version', Me.metadata.version));
+ toast.connect('dismissed',
+ () => this._settings.set_int('last-prefs-version',
+ this.metadata.version));
window.add_toast(toast);
} else {
const infoBar = this._builder.get_object('update-info');
infoBar.connect('response', i => {
- this._settings.set_int('last-prefs-version', Me.metadata.version);
+ this._settings.set_int('last-prefs-version', this.metadata.version);
i.set_revealed(false);
});
infoBar.set_revealed(true);
@@ -555,7 +548,7 @@ GitHub: https://github.com/spon
null,
'https://github.com/Schneegans/Burn-My-Windows/blob/main/docs/changelog.md',
Gdk.CURRENT_TIME);
- this._settings.set_int('last-prefs-version', Me.metadata.version)
+ this._settings.set_int('last-prefs-version', this.metadata.version)
});
group.add_action(changelogAction);
@@ -588,7 +581,7 @@ GitHub: https://github.com/spon
dialog = new Adw.AboutWindow({transient_for: window, modal: true});
dialog.set_application_icon('burn-my-windows-symbolic');
dialog.set_application_name('Burn-My-Windows');
- dialog.set_version(`${Me.metadata.version}`);
+ dialog.set_version(`${this.metadata.version}`);
dialog.set_developer_name('Simon Schneegans');
dialog.set_issue_url('https://github.com/Schneegans/Burn-My-Windows/issues');
if (sponsors.gold.length > 0) {
@@ -621,7 +614,7 @@ GitHub: https://github.com/spon
dialog = new Gtk.AboutDialog({transient_for: window, modal: true});
dialog.set_logo_icon_name('burn-my-windows-symbolic');
- dialog.set_program_name(`Burn-My-Windows ${Me.metadata.version}`);
+ dialog.set_program_name(`Burn-My-Windows ${this.metadata.version}`);
dialog.set_authors(['Simon Schneegans']);
if (sponsors.gold.length > 0) {
dialog.add_credit_section(_('Gold Sponsors'),
@@ -904,7 +897,7 @@ GitHub: https://github.com/spon
// configuration option of the profile is changed.
_updateProfileButton() {
this._builder.get_object('choose-profile-button').label =
- this._profileManager.getProfileName(this.getProfileSettings());
+ this._getProfileName(this.getProfileSettings());
}
// This updates the list of available profiles in the dropdown of the profile-selection
@@ -918,7 +911,7 @@ GitHub: https://github.com/spon
// Then add an entry for each available profile.
this._profileManager.getProfiles().forEach(profile => {
- const label = this._profileManager.getProfileName(profile.settings);
+ const label = this._getProfileName(profile.settings);
const item = Gio.MenuItem.new(label, 'prefs.active-profile');
item.set_action_and_target_value('prefs.active-profile',
GLib.Variant.new_string(profile.path));
@@ -926,6 +919,58 @@ GitHub: https://github.com/spon
});
}
+ // Profiles are named according to their configuration. This method returns a localized
+ // string describing the settings of the profile.
+ _getProfileName(settings) {
+ let items = [];
+
+ // If an app is configured, use it as first component for the profile's name.
+ const app = settings.get_string('profile-app');
+ if (app != '') {
+ items.push(app);
+ }
+
+ // Now add components to the name for each non-default profile option. Make sure that
+ // these are the same strings as used in the UI files!
+ const addComponent = (settingsKey, options) => {
+ const option = settings.get_int(settingsKey);
+ if (option > 0) {
+ items.push(options[option - 1]);
+ }
+ };
+
+ // clang-format off
+ addComponent('profile-animation-type', [_('Opening Windows'),
+ _('Closing Windows')]);
+ addComponent('profile-window-type', [_('Normal Windows'),
+ _('Dialog Windows')]);
+ addComponent('profile-color-scheme', [_('Default Color Scheme'),
+ _('Dark Color Scheme')]);
+ addComponent('profile-power-mode', [_('On Battery'),
+ _('Plugged In')]);
+ addComponent('profile-power-profile', [_('Power-Saver Mode'),
+ _('Balanced Mode'),
+ _('Performance Mode'),
+ _('Power Saver or Balanced'),
+ _('Balanced or Performance')]);
+ // clang-format on
+
+ // If the profile is a high-priority profile, also add this..
+ if (settings.get_boolean('profile-high-priority')) {
+ items.push(_('High Priority'));
+ }
+
+ let name = '';
+
+ if (items.length == 0) {
+ name = _('Standard Profile');
+ } else {
+ name = items.join(' · ');
+ }
+
+ return name;
+ }
+
// This wrapper connects a given callback to a profile settings key. Use this instead of
// the direct connect() call on the profile settings to make sure that the callback is
// disconnected when the active profile changes.
diff --git a/src/ProfileManager.js b/src/ProfileManager.js
index 1d43014..38201d1 100644
--- a/src/ProfileManager.js
+++ b/src/ProfileManager.js
@@ -17,10 +17,6 @@
import Gio from 'gi://Gio';
import GLib from 'gi://GLib';
-const _ = imports.gettext.domain('burn-my-windows').gettext;
-
-const Me = imports.misc.extensionUtils.getCurrentExtension();
-
//////////////////////////////////////////////////////////////////////////////////////////
// Burn-My-Windows allows applying different sets of effect settings under specific //
// circumstances. These settings are called "effect profiles". The ProfileManager //
@@ -33,7 +29,9 @@ const Me = imports.misc.extensionUtils.getCurrentExtension();
export class ProfileManager {
// ------------------------------------------------------------------------- constructor
- constructor() {
+ constructor(metadata) {
+ this._metadata = metadata;
+
this._makeProfilesDir();
this.reloadProfiles();
}
@@ -150,58 +148,6 @@ export class ProfileManager {
return priority;
}
- // Profiles are named according to their configuration. This method returns a localized
- // string describing the settings of the profile.
- getProfileName(settings) {
- let items = [];
-
- // If an app is configured, use it as first component for the profile's name.
- const app = settings.get_string('profile-app');
- if (app != '') {
- items.push(app);
- }
-
- // Now add components to the name for each non-default profile option. Make sure that
- // these are the same strings as used in the UI files!
- const addComponent = (settingsKey, options) => {
- const option = settings.get_int(settingsKey);
- if (option > 0) {
- items.push(options[option - 1]);
- }
- };
-
- // clang-format off
- addComponent('profile-animation-type', [_('Opening Windows'),
- _('Closing Windows')]);
- addComponent('profile-window-type', [_('Normal Windows'),
- _('Dialog Windows')]);
- addComponent('profile-color-scheme', [_('Default Color Scheme'),
- _('Dark Color Scheme')]);
- addComponent('profile-power-mode', [_('On Battery'),
- _('Plugged In')]);
- addComponent('profile-power-profile', [_('Power-Saver Mode'),
- _('Balanced Mode'),
- _('Performance Mode'),
- _('Power Saver or Balanced'),
- _('Balanced or Performance')]);
- // clang-format on
-
- // If the profile is a high-priority profile, also add this..
- if (settings.get_boolean('profile-high-priority')) {
- items.push(_('High Priority'));
- }
-
- let name = '';
-
- if (items.length == 0) {
- name = _('Standard Profile');
- } else {
- name = items.join(' · ');
- }
-
- return name;
- }
-
// ----------------------------------------------------------------------- private stuff
// Creates the directory ~/.config/burn-my-windows/profiles if it does not yet exist.
@@ -220,7 +166,7 @@ export class ProfileManager {
// Expect USER extensions to have a schemas/ subfolder, otherwise assume a
// SYSTEM extension that has been installed in the same prefix as the shell
- const schemaDir = Me.dir.get_child('schemas');
+ const schemaDir = this._metadata.dir.get_child('schemas');
let source;
if (schemaDir.query_exists(null)) {
source = Gio.SettingsSchemaSource.new_from_directory(
diff --git a/src/WindowPicker.js b/src/WindowPicker.js
index 0cd2945..157ef28 100644
--- a/src/WindowPicker.js
+++ b/src/WindowPicker.js
@@ -18,8 +18,8 @@
import Gio from 'gi://Gio';
import GLib from 'gi://GLib';
-const Main = imports.ui.main;
-const LookingGlass = imports.ui.lookingGlass;
+import * as Main from 'resource:///org/gnome/shell/ui/main.js';
+import * as LookingGlass from 'resource:///org/gnome/shell/ui/lookingGlass.js';
import {getStringResource} from './utils.js';
diff --git a/src/utils.js b/src/utils.js
index 6999fa9..1c5b0c6 100644
--- a/src/utils.js
+++ b/src/utils.js
@@ -33,12 +33,9 @@ function toNumericVersion(x) {
return x;
}
-const Me = imports.misc.extensionUtils.getCurrentExtension();
const Config = imports.misc.config;
const [GS_MAJOR, GS_MINOR] = Config.PACKAGE_VERSION.split('.').map(toNumericVersion);
-const _ = imports.gettext.domain('burn-my-windows').gettext;
-
// This method can be used to write a message to GNOME Shell's log. This is enhances
// the standard log() functionality by prepending the extension's name and the location
// where the message was logged. As the extensions name is part of the location, you
@@ -54,9 +51,10 @@ export function debug(message) {
// Find the index of the extension directory (e.g. particles@schneegans.github.com) in
// the stack entry. We do not want to print the entire absolute file path.
- const extensionRoot = stack[0].indexOf(Me.metadata.uuid);
+ // const extensionRoot = stack[0].indexOf(Extension.uuid);
- log('[' + stack[0].slice(extensionRoot) + '] ' + message);
+ log('[' + stack[0] + '] ' + message);
+ // log('[' + stack[0].slice(extensionRoot) + '] ' + message);
}
// This method simply returns true if we are currently using GTK4.
From f2768216db782933d804706bc51540d881628f5d Mon Sep 17 00:00:00 2001
From: Simon Schneegans
Date: Mon, 7 Aug 2023 13:21:50 +0200
Subject: [PATCH 04/26] :fire: Remove backwards compatibility code
---
extension.js | 42 +--
prefs.js | 490 ++++++++--------------------
resources/css/gtk3.css | 23 --
resources/css/gtk4.css | 26 --
resources/ui/gtk3/apparition.ui | 281 ----------------
resources/ui/gtk3/doom.ui | 229 -------------
resources/ui/gtk3/energize-a.ui | 167 ----------
resources/ui/gtk3/energize-b.ui | 168 ----------
resources/ui/gtk3/fire.ui | 337 -------------------
resources/ui/gtk3/glide.ui | 281 ----------------
resources/ui/gtk3/glitch.ui | 271 ----------------
resources/ui/gtk3/hexagon.ui | 320 ------------------
resources/ui/gtk3/incinerate.ui | 278 ----------------
resources/ui/gtk3/pixel-wheel.ui | 177 ----------
resources/ui/gtk3/pixel-wipe.ui | 132 --------
resources/ui/gtk3/pixelate.ui | 177 ----------
resources/ui/gtk3/portal.ui | 271 ----------------
resources/ui/gtk3/prefs.ui | 519 ------------------------------
resources/ui/gtk3/tv-glitch.ui | 271 ----------------
resources/ui/gtk3/tv.ui | 115 -------
resources/ui/gtk3/wisps.ui | 167 ----------
resources/ui/gtk4/apparition.ui | 249 --------------
resources/ui/gtk4/broken-glass.ui | 259 ---------------
resources/ui/gtk4/doom.ui | 203 ------------
resources/ui/gtk4/energize-a.ui | 150 ---------
resources/ui/gtk4/energize-b.ui | 150 ---------
resources/ui/gtk4/fire.ui | 295 -----------------
resources/ui/gtk4/glide.ui | 252 ---------------
resources/ui/gtk4/glitch.ui | 242 --------------
resources/ui/gtk4/hexagon.ui | 288 -----------------
resources/ui/gtk4/incinerate.ui | 251 ---------------
resources/ui/gtk4/matrix.ui | 279 ----------------
resources/ui/gtk4/paint-brush.ui | 113 -------
resources/ui/gtk4/pixel-wheel.ui | 159 ---------
resources/ui/gtk4/pixel-wipe.ui | 113 -------
resources/ui/gtk4/pixelate.ui | 159 ---------
resources/ui/gtk4/portal.ui | 242 --------------
resources/ui/gtk4/prefs.ui | 475 ---------------------------
resources/ui/gtk4/snap.ui | 150 ---------
resources/ui/gtk4/trex.ui | 242 --------------
resources/ui/gtk4/tv-glitch.ui | 242 --------------
resources/ui/gtk4/tv.ui | 104 ------
resources/ui/gtk4/wisps.ui | 150 ---------
src/ProfileManager.js | 2 +-
src/Shader.js | 8 +-
src/effects/Fire.js | 3 +-
src/utils.js | 29 +-
47 files changed, 145 insertions(+), 9406 deletions(-)
delete mode 100644 resources/css/gtk3.css
delete mode 100644 resources/css/gtk4.css
delete mode 100644 resources/ui/gtk3/apparition.ui
delete mode 100644 resources/ui/gtk3/doom.ui
delete mode 100644 resources/ui/gtk3/energize-a.ui
delete mode 100644 resources/ui/gtk3/energize-b.ui
delete mode 100644 resources/ui/gtk3/fire.ui
delete mode 100644 resources/ui/gtk3/glide.ui
delete mode 100644 resources/ui/gtk3/glitch.ui
delete mode 100644 resources/ui/gtk3/hexagon.ui
delete mode 100644 resources/ui/gtk3/incinerate.ui
delete mode 100644 resources/ui/gtk3/pixel-wheel.ui
delete mode 100644 resources/ui/gtk3/pixel-wipe.ui
delete mode 100644 resources/ui/gtk3/pixelate.ui
delete mode 100644 resources/ui/gtk3/portal.ui
delete mode 100644 resources/ui/gtk3/prefs.ui
delete mode 100644 resources/ui/gtk3/tv-glitch.ui
delete mode 100644 resources/ui/gtk3/tv.ui
delete mode 100644 resources/ui/gtk3/wisps.ui
delete mode 100644 resources/ui/gtk4/apparition.ui
delete mode 100644 resources/ui/gtk4/broken-glass.ui
delete mode 100644 resources/ui/gtk4/doom.ui
delete mode 100644 resources/ui/gtk4/energize-a.ui
delete mode 100644 resources/ui/gtk4/energize-b.ui
delete mode 100644 resources/ui/gtk4/fire.ui
delete mode 100644 resources/ui/gtk4/glide.ui
delete mode 100644 resources/ui/gtk4/glitch.ui
delete mode 100644 resources/ui/gtk4/hexagon.ui
delete mode 100644 resources/ui/gtk4/incinerate.ui
delete mode 100644 resources/ui/gtk4/matrix.ui
delete mode 100644 resources/ui/gtk4/paint-brush.ui
delete mode 100644 resources/ui/gtk4/pixel-wheel.ui
delete mode 100644 resources/ui/gtk4/pixel-wipe.ui
delete mode 100644 resources/ui/gtk4/pixelate.ui
delete mode 100644 resources/ui/gtk4/portal.ui
delete mode 100644 resources/ui/gtk4/prefs.ui
delete mode 100644 resources/ui/gtk4/snap.ui
delete mode 100644 resources/ui/gtk4/trex.ui
delete mode 100644 resources/ui/gtk4/tv-glitch.ui
delete mode 100644 resources/ui/gtk4/tv.ui
delete mode 100644 resources/ui/gtk4/wisps.ui
diff --git a/extension.js b/extension.js
index b32f939..c03e6a6 100644
--- a/extension.js
+++ b/extension.js
@@ -20,7 +20,7 @@ import Meta from 'gi://Meta';
import {fromVersion26} from './src/migrate.js';
import {ProfileManager} from './src/ProfileManager.js';
import {WindowPicker} from './src/WindowPicker.js';
-import {getStringResource, shellVersionIs, shellVersionIsAtLeast} from './src/utils.js';
+import {getStringResource} from './src/utils.js';
import Apparition from './src/effects/Apparition.js';
import BrokenGlass from './src/effects/BrokenGlass.js';
@@ -250,21 +250,9 @@ export default class BurnMyWindows extends Extension {
// of the actor. However, if we are in the overview, we have to enlarge the clone of
// the window as well.
Workspace.prototype._addWindowClone = function(...params) {
- const clone = extensionThis._origAddWindowClone.apply(this, params);
-
- // The parameters of this method changed a bit through the versions...
- let realWindow, container;
-
- if (shellVersionIs(3, 36)) {
- container = clone[0];
- realWindow = container.realWindow;
- } else if (shellVersionIs(3, 38)) {
- container = clone._windowContainer;
- realWindow = params[0].get_compositor_private();
- } else {
- container = clone.window_container;
- realWindow = params[0].get_compositor_private();
- }
+ const clone = extensionThis._origAddWindowClone.apply(this, params);
+ const container = clone.window_container;
+ const realWindow = params[0].get_compositor_private();
// Store the overview clone as temporary members of the real window actor. When we
// set up the effect, we will check for the existence of these and enlarge the clone
@@ -278,16 +266,6 @@ export default class BurnMyWindows extends Extension {
delete realWindow._bmwOverviewCloneContainer;
});
- // This is actually needed for the window-close animation on GNOME Shell 3.36.
- // On GNOME 3.36, the window clone's 'destroy' handler only calls _removeWindowClone
- // but not _doRemoveWindow. The latter is required to trigger the repositioning of
- // the overview window layout. Therefore we call this method in addition.
- // https://gitlab.gnome.org/GNOME/gnome-shell/-/blob/gnome-3-36/js/ui/workspace.js#L1877
- // https://gitlab.gnome.org/GNOME/gnome-shell/-/blob/main/js/ui/workspace.js#L1363
- if (shellVersionIs(3, 36)) {
- container.connect('destroy', () => this._doRemoveWindow(container.metaWindow));
- }
-
return clone;
};
@@ -512,7 +490,7 @@ export default class BurnMyWindows extends Extension {
}
// If the profile is still matching, we also check the color scheme.
- if (matches && profileColorScheme != 0 && shellVersionIsAtLeast(42, 0)) {
+ if (matches && profileColorScheme != 0) {
const colorScheme = this._shellSettings.get_string('color-scheme');
matches &= (profileColorScheme == 1 && colorScheme == 'default') ||
(profileColorScheme == 2 && colorScheme == 'prefer-dark');
@@ -591,7 +569,7 @@ export default class BurnMyWindows extends Extension {
// If we are in the overview, we have to enlarge the window's clone as well. We also
// disable the clone's overlay (e.g. its icon, name, and close button) during the
// animation.
- if (actor._bmwOverviewClone && shellVersionIsAtLeast(3, 38)) {
+ if (actor._bmwOverviewClone) {
actor._bmwOverviewClone.overlayEnabled = false;
actor._bmwOverviewCloneContainer.set_pivot_point(0.5, 0.5);
actor._bmwOverviewCloneContainer.scale_x = actorScale.x;
@@ -608,7 +586,7 @@ export default class BurnMyWindows extends Extension {
const endID = shader.connect('end-animation', () => {
shader.disconnect(endID);
- if (actor._bmwOverviewClone && shellVersionIsAtLeast(3, 38)) {
+ if (actor._bmwOverviewClone) {
actor._bmwOverviewClone.overlayEnabled = true;
actor._bmwOverviewCloneContainer.scale_x = 1.0;
actor._bmwOverviewCloneContainer.scale_y = 1.0;
@@ -646,10 +624,8 @@ export default class BurnMyWindows extends Extension {
return true;
}
- // This was called "realWindow" in GNOME 3.36.
- const propertyName = shellVersionIs(3, 36) ? 'realWindow' : '_windowActor';
- const actor = workspace._windows[index][propertyName];
- const shader = actor.get_effect('burn-my-windows-effect');
+ const actor = workspace._windows[index]._windowActor;
+ const shader = actor.get_effect('burn-my-windows-effect');
return shader == null;
}
diff --git a/prefs.js b/prefs.js
index d47c0cd..7e10ed7 100644
--- a/prefs.js
+++ b/prefs.js
@@ -20,7 +20,7 @@ import GLib from 'gi://GLib';
import Gdk from 'gi://Gdk';
import Adw from 'gi://Adw';
-import {isADW, isGTK4, getUIDir, getStringResource, shellVersionIsAtLeast} from './src/utils.js';
+import {getUIDir, getStringResource, shellVersionIsAtLeast} from './src/utils.js';
import {ProfileManager} from './src/ProfileManager.js';
import Apparition from './src/effects/Apparition.js';
@@ -90,27 +90,8 @@ export default class BurnMyWindowsPreferences extends ExtensionPreferences {
Gio.Resource.load(this.path + '/resources/burn-my-windows.gresource');
Gio.resources_register(this._resources);
- // Load the CSS file for the settings dialog. If using libadwaita, we do not need an
- // additional style sheet.
- if (!isADW()) {
- const provider = Gtk.CssProvider.new();
- if (isGTK4()) {
- provider.load_from_resource('/css/gtk4.css');
- Gtk.StyleContext.add_provider_for_display(
- Gdk.Display.get_default(), provider, Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION);
- } else {
- provider.load_from_resource('/css/gtk3.css');
- Gtk.StyleContext.add_provider_for_screen(Gdk.Screen.get_default(), provider,
- Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION);
- }
- }
-
// Make sure custom icons are found.
- if (isGTK4()) {
- Gtk.IconTheme.get_for_display(Gdk.Display.get_default()).add_resource_path('/img');
- } else {
- Gtk.IconTheme.get_default().add_resource_path('/img');
- }
+ Gtk.IconTheme.get_for_display(Gdk.Display.get_default()).add_resource_path('/img');
// Load the general user interface files.
this._builder = new Gtk.Builder();
@@ -147,19 +128,8 @@ export default class BurnMyWindowsPreferences extends ExtensionPreferences {
}
let powerProfileRow = this._builder.get_object('profile-power-profile');
- if (!isADW()) {
- powerProfileRow = powerProfileRow.get_parent().get_parent();
- }
powerProfileRow.set_visible(hasPowerProfiles);
- // The global color scheme is only available starting with GNOME Shell 42. We hide the
- // corresponding settings row on older versions.
- let colorSchemeRow = this._builder.get_object('profile-color-scheme');
- if (!isADW()) {
- colorSchemeRow = colorSchemeRow.get_parent().get_parent();
- }
- colorSchemeRow.set_visible(shellVersionIsAtLeast(42, 0));
-
// Wire up the window picker of the profile editor. Whenever the app-chooser button is
// clicked, we call a method of the extension which will initiate the window picking.
this._builder.get_object('profile-choose-app-button').connect('clicked', () => {
@@ -196,22 +166,6 @@ export default class BurnMyWindowsPreferences extends ExtensionPreferences {
}
});
- // If using libadwaita, the visibility of the profile-editor Adw.Flap is controlled
- // using bindings in the ui file. On GTK3 and GTK4 we have to wire up this toggling
- // here since we are using a Gtk.Stack instead of an Adw.Flap.
- if (!isADW()) {
- const profileEditorButton = this._builder.get_object('edit-profile-button');
- profileEditorButton.connect('toggled', b => {
- if (b.active) {
- this._builder.get_object('general-prefs')
- .set_visible_child(this._builder.get_object('profile-editor'));
- } else {
- this._builder.get_object('general-prefs')
- .set_visible_child(this._builder.get_object('effect-editor'));
- }
- });
- }
-
// This is our top-level widget which we will return later.
this._widget = this._builder.get_object('general-prefs');
@@ -235,25 +189,6 @@ export default class BurnMyWindowsPreferences extends ExtensionPreferences {
// accordion-like behavior of the effect settings.
this._effectRows = [];
- if (!isADW()) {
- group.connect('row-activated', (g, row) => {
- this._effectRows.forEach(r => {
- if (r == row) {
- if (r._revealer.get_reveal_child()) {
- r._revealer.set_reveal_child(false);
- r._arrow.get_style_context().remove_class('revealed');
- } else {
- r._revealer.set_reveal_child(true);
- r._arrow.get_style_context().add_class('revealed');
- }
- } else {
- r._revealer.set_reveal_child(false);
- r._arrow.get_style_context().remove_class('revealed');
- }
- });
- });
- }
-
// Now add all the rows.
this._ALL_EFFECTS.forEach(effect => {
const [minMajor, minMinor] = effect.getMinShellVersion();
@@ -276,12 +211,7 @@ export default class BurnMyWindowsPreferences extends ExtensionPreferences {
}
// The preview button.
- let previewButton;
- if (isGTK4()) {
- previewButton = Gtk.Button.new_from_icon_name('bmw-preview-symbolic');
- } else {
- previewButton = Gtk.Button.new_from_icon_name('bmw-preview-symbolic', 1);
- }
+ let previewButton = Gtk.Button.new_from_icon_name('bmw-preview-symbolic');
previewButton.get_style_context().add_class('circular');
previewButton.get_style_context().add_class('flat');
previewButton.set_tooltip_text(_('Preview this effect'));
@@ -295,98 +225,52 @@ export default class BurnMyWindowsPreferences extends ExtensionPreferences {
button.set_valign(Gtk.Align.CENTER);
this._builder.expose_object(`${effect.getNick()}-enable-effect`, button);
- if (isADW()) {
-
- let row;
- if (hasPrefs) {
-
- // Add the effect's preferences (if any).
- row = this._builder.get_object(`${effect.getNick()}-prefs`);
- } else if (isADW()) {
- row = Adw.ActionRow.new();
- }
-
- // On older versions of Adw (e.g. on GNOME Shell <43), the set_use_markup() does
- // not yet exist.
- if (row.set_use_markup) {
- row.set_title('' + effect.getLabel() + '');
- row.set_use_markup(true);
- } else {
- row.set_title(effect.getLabel());
- }
-
- // Un-expand any previously expanded effect row. This way we ensure that there
- // is only one expanded row at any time.
- if (hasPrefs) {
- row.connect('notify::expanded', currentRow => {
- if (currentRow.get_expanded()) {
- this._effectRows.forEach(row => {
- if (row != currentRow) {
- row.set_expanded(false);
- }
- });
- }
- });
- this._effectRows.push(row);
- row.add_action(button);
- } else {
- row.add_suffix(button);
- }
-
- row.add_prefix(previewButton);
-
- group.add(row);
-
+ let row;
+ if (hasPrefs) {
+ // Add the effect's preferences (if any).
+ row = this._builder.get_object(`${effect.getNick()}-prefs`);
} else {
-
- const row = new Gtk.ListBoxRow();
- row.get_style_context().add_class('effect-row');
-
- const container = new Gtk.Box({orientation: Gtk.Orientation.VERTICAL});
-
- const header = new Gtk.Box({spacing: 12});
- header.get_style_context().add_class('effect-row-header');
-
- const label = new Gtk.Label(
- {label: effect.getLabel(), hexpand: true, halign: Gtk.Align.START});
- label.get_style_context().add_class('heading');
-
- this.gtkBoxAppend(header, previewButton);
- this.gtkBoxAppend(header, label);
- this.gtkBoxAppend(header, button);
- this.gtkBoxAppend(container, header);
-
- if (hasPrefs) {
- const revealer = this._builder.get_object(`${effect.getNick()}-prefs`);
- const arrow = new Gtk.Image({icon_name: 'go-down-symbolic'});
- arrow.get_style_context().add_class('revealer-arrow');
- this.gtkBoxAppend(header, arrow);
- this.gtkBoxAppend(container, revealer);
- row._revealer = revealer;
- row._arrow = arrow;
-
- row.set_activatable(true);
- this._effectRows.push(row);
- } else {
- row.set_activatable(false);
- }
-
- if (isGTK4()) {
- row.set_child(container);
- group.append(row);
- } else {
- row.add(container);
- group.add(row);
- }
+ row = Adw.ActionRow.new();
}
+
+ // On older versions of Adw (e.g. on GNOME Shell <43), the set_use_markup() does
+ // not yet exist.
+ if (row.set_use_markup) {
+ row.set_title('' + effect.getLabel() + '');
+ row.set_use_markup(true);
+ } else {
+ row.set_title(effect.getLabel());
+ }
+
+ // Un-expand any previously expanded effect row. This way we ensure that there
+ // is only one expanded row at any time.
+ if (hasPrefs) {
+ row.connect('notify::expanded', currentRow => {
+ if (currentRow.get_expanded()) {
+ this._effectRows.forEach(row => {
+ if (row != currentRow) {
+ row.set_expanded(false);
+ }
+ });
+ }
+ });
+ this._effectRows.push(row);
+ row.add_action(button);
+ } else {
+ row.add_suffix(button);
+ }
+
+ row.add_prefix(previewButton);
+
+ group.add(row);
}
});
// Some things can only be done once the widget is shown as we do not have access to
// the toplevel widget before.
this._widget.connect('realize', (widget) => {
- const window = isGTK4() ? widget.get_root() : widget.get_toplevel();
+ const window = widget.get_root();
// Show the version number in the title bar.
window.set_title(`Burn-My-Windows ${this.metadata.version}`);
@@ -402,25 +286,16 @@ export default class BurnMyWindowsPreferences extends ExtensionPreferences {
GLib.timeout_add(GLib.PRIORITY_DEFAULT, 2000, () => {
this._showUpdateInfoTimeout = 0;
- if (isADW()) {
- const toast = Adw.Toast.new(_('Burn-My-Windows has been updated!'));
- toast.set_button_label(_('View Changelog'));
- toast.set_action_name('prefs.changelog');
- toast.set_timeout(0);
+ const toast = Adw.Toast.new(_('Burn-My-Windows has been updated!'));
+ toast.set_button_label(_('View Changelog'));
+ toast.set_action_name('prefs.changelog');
+ toast.set_timeout(0);
- toast.connect('dismissed',
- () => this._settings.set_int('last-prefs-version',
- this.metadata.version));
+ toast.connect(
+ 'dismissed',
+ () => this._settings.set_int('last-prefs-version', this.metadata.version));
- window.add_toast(toast);
- } else {
- const infoBar = this._builder.get_object('update-info');
- infoBar.connect('response', i => {
- this._settings.set_int('last-prefs-version', this.metadata.version);
- i.set_revealed(false);
- });
- infoBar.set_revealed(true);
- }
+ window.add_toast(toast);
return false;
});
@@ -467,11 +342,7 @@ GitHub: https://github.com/spon
}
]);
- if (isGTK4()) {
- dialog.show();
- } else {
- dialog.show_all();
- }
+ dialog.show();
}
});
@@ -486,39 +357,28 @@ GitHub: https://github.com/spon
// Starting with GNOME Shell 42, we have to hack our way through the widget tree
// of the Adw.PreferencesWindow...
- if (isADW()) {
- const header = this._findWidgetByType(window.get_content(), Adw.HeaderBar);
- header.pack_start(menu);
- header.set_title_widget(this._builder.get_object('profile-button'));
+ const header = this._findWidgetByType(window.get_content(), Adw.HeaderBar);
+ header.pack_start(menu);
+ header.set_title_widget(this._builder.get_object('profile-button'));
- // GNOME Shell extensions are forced to use a AdwPreferencesWindow. This already
- // includes a Gtk.ScrolledWindow as well as an Adw.Clamp. For the profile
- // editing, we want to use an Adw.Flap which reveals itself from the top. This
- // needs to be inserted in the widget hierarchy above the Adw.Clamp, else it
- // would look ugly. Therefore, we fiddle around with the internal widgets...
- const flap = this._builder.get_object('profile-editor-flap');
- const clamp = this._findWidgetByType(window.get_content(), Adw.Clamp);
- const viewport = clamp.get_parent();
- viewport.get_parent().set_policy(Gtk.PolicyType.NEVER, Gtk.PolicyType.NEVER);
- viewport.set_child(flap);
+ // GNOME Shell extensions are forced to use a AdwPreferencesWindow. This already
+ // includes a Gtk.ScrolledWindow as well as an Adw.Clamp. For the profile
+ // editing, we want to use an Adw.Flap which reveals itself from the top. This
+ // needs to be inserted in the widget hierarchy above the Adw.Clamp, else it
+ // would look ugly. Therefore, we fiddle around with the internal widgets...
+ const flap = this._builder.get_object('profile-editor-flap');
+ const clamp = this._findWidgetByType(window.get_content(), Adw.Clamp);
+ const viewport = clamp.get_parent();
+ viewport.get_parent().set_policy(Gtk.PolicyType.NEVER, Gtk.PolicyType.NEVER);
+ viewport.set_child(flap);
- const scrolledWindow = Gtk.ScrolledWindow.new();
- scrolledWindow.set_policy(Gtk.PolicyType.NEVER, Gtk.PolicyType.AUTOMATIC);
- scrolledWindow.set_propagate_natural_height(true);
- scrolledWindow.set_vexpand(true);
- scrolledWindow.set_child(clamp);
+ const scrolledWindow = Gtk.ScrolledWindow.new();
+ scrolledWindow.set_policy(Gtk.PolicyType.NEVER, Gtk.PolicyType.AUTOMATIC);
+ scrolledWindow.set_propagate_natural_height(true);
+ scrolledWindow.set_vexpand(true);
+ scrolledWindow.set_child(clamp);
- flap.set_content(scrolledWindow);
-
- } else if (isGTK4()) {
- window.get_titlebar().pack_start(menu);
- window.get_titlebar().set_title_widget(
- this._builder.get_object('profile-button'));
- } else {
- window.get_titlebar().pack_start(menu);
- window.get_titlebar().set_custom_title(
- this._builder.get_object('profile-button'));
- }
+ flap.set_content(scrolledWindow);
const addURIAction = (name, uri) => {
const action = Gio.SimpleAction.new(name, null);
@@ -567,71 +427,34 @@ GitHub: https://github.com/spon
const sponsors = this._getJSONResource('/credits/sponsors.json');
let dialog;
- // We try to use the special Adw.AboutWindow if it is available.
- if (isADW() && Adw.AboutWindow) {
- let formatSponsors = (sponsors) => {
- return sponsors.map(s => {
- if (s.url == '')
- return s.name;
- else
- return `${s.name} ${s.url}`;
- });
- };
+ let formatSponsors = (sponsors) => {
+ return sponsors.map(s => {
+ if (s.url == '')
+ return s.name;
+ else
+ return `${s.name} ${s.url}`;
+ });
+ };
- dialog = new Adw.AboutWindow({transient_for: window, modal: true});
- dialog.set_application_icon('burn-my-windows-symbolic');
- dialog.set_application_name('Burn-My-Windows');
- dialog.set_version(`${this.metadata.version}`);
- dialog.set_developer_name('Simon Schneegans');
- dialog.set_issue_url('https://github.com/Schneegans/Burn-My-Windows/issues');
- if (sponsors.gold.length > 0) {
- dialog.add_credit_section(_('Gold Sponsors'),
- formatSponsors(sponsors.gold));
- }
- if (sponsors.silver.length > 0) {
- dialog.add_credit_section(_('Silver Sponsors'),
- formatSponsors(sponsors.silver));
- }
- if (sponsors.bronze.length > 0) {
- dialog.add_credit_section(_('Bronze Sponsors'),
- formatSponsors(sponsors.bronze));
- }
- if (sponsors.past.length > 0) {
- dialog.add_credit_section(_('Past Sponsors'),
- formatSponsors(sponsors.past));
- }
-
- } else {
-
- let formatSponsors = (sponsors) => {
- return sponsors.map(s => {
- if (s.url == '')
- return s.name;
- else
- return `${s.name}`;
- });
- };
-
- dialog = new Gtk.AboutDialog({transient_for: window, modal: true});
- dialog.set_logo_icon_name('burn-my-windows-symbolic');
- dialog.set_program_name(`Burn-My-Windows ${this.metadata.version}`);
- dialog.set_authors(['Simon Schneegans']);
- if (sponsors.gold.length > 0) {
- dialog.add_credit_section(_('Gold Sponsors'),
- formatSponsors(sponsors.gold));
- }
- if (sponsors.silver.length > 0) {
- dialog.add_credit_section(_('Silver Sponsors'),
- formatSponsors(sponsors.silver));
- }
- if (sponsors.bronze.length > 0) {
- dialog.add_credit_section(_('Bronze Sponsors'),
- formatSponsors(sponsors.bronze));
- }
- if (sponsors.past.length > 0) {
- dialog.add_credit_section(_('Past Sponsors'),
- formatSponsors(sponsors.past));
- }
+ dialog = new Adw.AboutWindow({transient_for: window, modal: true});
+ dialog.set_application_icon('burn-my-windows-symbolic');
+ dialog.set_application_name('Burn-My-Windows');
+ dialog.set_version(`${this.metadata.version}`);
+ dialog.set_developer_name('Simon Schneegans');
+ dialog.set_issue_url('https://github.com/Schneegans/Burn-My-Windows/issues');
+ if (sponsors.gold.length > 0) {
+ dialog.add_credit_section(_('Gold Sponsors'), formatSponsors(sponsors.gold));
+ }
+ if (sponsors.silver.length > 0) {
+ dialog.add_credit_section(_('Silver Sponsors'),
+ formatSponsors(sponsors.silver));
+ }
+ if (sponsors.bronze.length > 0) {
+ dialog.add_credit_section(_('Bronze Sponsors'),
+ formatSponsors(sponsors.bronze));
+ }
+ if (sponsors.past.length > 0) {
+ dialog.add_credit_section(_('Past Sponsors'), formatSponsors(sponsors.past));
}
dialog.set_translator_credits([...translators].join('\n'));
@@ -639,11 +462,7 @@ GitHub: https://github.com/spon
dialog.set_website('https://github.com/Schneegans/Burn-My-Windows');
dialog.set_license_type(Gtk.License.GPL_3_0);
- if (isGTK4()) {
- dialog.show();
- } else {
- dialog.show_all();
- }
+ dialog.show();
});
group.add_action(aboutAction);
@@ -728,11 +547,6 @@ GitHub: https://github.com/spon
}
});
- // Show the widgets on GTK3.
- if (!isGTK4()) {
- this._widget.show_all();
- }
-
window.add(this._widget);
}
@@ -814,17 +628,6 @@ GitHub: https://github.com/spon
this._bindResetButton(settingsKey);
}
- // ----------------------------------------------------------------- GTK3 / GTK4 helpers
-
- // Appends the given child widget to the given Gtk.Box.
- gtkBoxAppend(box, child) {
- if (isGTK4()) {
- box.append(child);
- } else {
- box.pack_start(child, false, true, 0);
- }
- }
-
// ----------------------------------------------------------------------- private stuff
// This loads all settings from the profile given in the settings key 'active-profile'.
@@ -863,20 +666,11 @@ GitHub: https://github.com/spon
updateProfileButtonMenuIfChanged('profile-high-priority');
this.bindEntry('profile-app');
-
- if (isADW()) {
- this.bindComboRow('profile-animation-type');
- this.bindComboRow('profile-window-type');
- this.bindComboRow('profile-color-scheme');
- this.bindComboRow('profile-power-mode');
- this.bindComboRow('profile-power-profile');
- } else {
- this.bindComboBox('profile-animation-type');
- this.bindComboBox('profile-window-type');
- this.bindComboBox('profile-color-scheme');
- this.bindComboBox('profile-power-mode');
- this.bindComboBox('profile-power-profile');
- }
+ this.bindComboRow('profile-animation-type');
+ this.bindComboRow('profile-window-type');
+ this.bindComboRow('profile-color-scheme');
+ this.bindComboRow('profile-power-mode');
+ this.bindComboRow('profile-power-profile');
this.bindSwitch('profile-high-priority');
// Connect all effect settings.
@@ -1047,14 +841,12 @@ GitHub: https://github.com/spon
default_width: 800,
default_height: 450,
modal: true,
- transient_for: isGTK4() ? this._widget.get_root() : this._widget.get_toplevel()
+ transient_for: this._widget.get_root()
});
// Add a header bar to the window.
- if (isGTK4()) {
- const header = Gtk.HeaderBar.new();
- window.set_titlebar(header);
- }
+ const header = Gtk.HeaderBar.new();
+ window.set_titlebar(header);
const box = new Gtk.Box({
orientation: Gtk.Orientation.VERTICAL,
@@ -1074,16 +866,11 @@ GitHub: https://github.com/spon
pixel_size: 128,
});
- this.gtkBoxAppend(box, image);
- this.gtkBoxAppend(box, label);
+ box.append(image);
+ box.append(label);
- if (isGTK4()) {
- window.set_child(box);
- window.show();
- } else {
- window.add(box);
- window.show_all();
- }
+ window.set_child(box);
+ window.show();
}
// Helper function to show a message dialog. The dialog is modal and has a title, a
@@ -1092,53 +879,28 @@ GitHub: https://github.com/spon
// called when the button is clicked.
// This method works on GTK3, GTK4, and libadwaita.
_createMessageDialog(title, message, window, buttons) {
- let dialog;
+ let dialog = new Adw.MessageDialog({
+ heading: title,
+ body: message,
+ body_use_markup: true,
+ modal: true,
+ });
- if (isADW() && Adw.MessageDialog) {
- dialog = new Adw.MessageDialog({
- heading: title,
- body: message,
- body_use_markup: true,
- modal: true,
- });
+ buttons.forEach((button, i) => {
+ const response = i.toString();
+ dialog.add_response(response, button.label);
- buttons.forEach((button, i) => {
- const response = i.toString();
- dialog.add_response(response, button.label);
+ if (button.default) {
+ dialog.set_default_response(response);
+ dialog.set_close_response(response);
+ }
- if (button.default) {
- dialog.set_default_response(response);
- dialog.set_close_response(response);
- }
-
- if (button.destructive) {
- dialog.set_response_appearance(response, Adw.ResponseAppearance.DESTRUCTIVE);
- }
- });
-
- } else {
-
- dialog = new Gtk.MessageDialog({
- text: title,
- secondary_text: message,
- secondary_use_markup: true,
- modal: true,
- title: '',
- });
-
- buttons.forEach((button, i) => {
- dialog.add_button(button.label, i);
-
- if (button.default) {
- dialog.set_default_response(i);
- }
- });
- }
-
- if (isGTK4()) {
- dialog.set_hide_on_close(true);
- }
+ if (button.destructive) {
+ dialog.set_response_appearance(response, Adw.ResponseAppearance.DESTRUCTIVE);
+ }
+ });
+ dialog.set_hide_on_close(true);
dialog.set_transient_for(window);
// If the dialog is closed or a button is clicked, we hide the dialog and call the
diff --git a/resources/css/gtk3.css b/resources/css/gtk3.css
deleted file mode 100644
index 6a69c48..0000000
--- a/resources/css/gtk3.css
+++ /dev/null
@@ -1,23 +0,0 @@
-/*
-SPDX-FileCopyrightText: Simon Schneegans
-SPDX-License-Identifier: CC0-1.0
-*/
-
-row {
- padding: 8px;
-}
-
-.effect-row {
- padding: 0;
-}
-
-.effect-row-header,
-.effect-row list {
- padding: 8px;
- border: 0 solid @borders;
- border-bottom-width: 1px;
-}
-
-.revealer-arrow {
- margin-right: 6px;
-}
\ No newline at end of file
diff --git a/resources/css/gtk4.css b/resources/css/gtk4.css
deleted file mode 100644
index dece072..0000000
--- a/resources/css/gtk4.css
+++ /dev/null
@@ -1,26 +0,0 @@
-/*
-SPDX-FileCopyrightText: Simon Schneegans
-SPDX-License-Identifier: CC0-1.0
-*/
-
-/* These are only used if not using libadwaita */
-
-.effect-row {
- padding: 0;
-}
-
-.effect-row-header,
-.effect-row list {
- padding: 8px;
- border: 0 solid @borders;
- border-bottom-width: 1px;
-}
-
-.revealer-arrow {
- margin-right: 6px;
- transition: transform 250ms;
-}
-
-.revealer-arrow.revealed {
- transform: rotate(180deg);
-}
\ No newline at end of file
diff --git a/resources/ui/gtk3/apparition.ui b/resources/ui/gtk3/apparition.ui
deleted file mode 100644
index d217042..0000000
--- a/resources/ui/gtk3/apparition.ui
+++ /dev/null
@@ -1,281 +0,0 @@
-
-
-
-
-
// SPDX-License-Identifier: GPL-3.0-or-later
-//'use strict';
+'use strict';
import Gio from 'gi://Gio';
import GLib from 'gi://GLib';
diff --git a/src/Shader.js b/src/Shader.js
index 11369df..87126e5 100644
--- a/src/Shader.js
+++ b/src/Shader.js
@@ -20,7 +20,7 @@ import GObject from 'gi://GObject';
import Clutter from 'gi://Clutter';
import Meta from 'gi://Meta';
-import {shellVersionIsAtLeast, getStringResource} from './utils.js';
+import {getStringResource} from './utils.js';
//////////////////////////////////////////////////////////////////////////////////////////
// This is the base class for all shaders of Burn-My-Windows. It automagically loads //
@@ -186,10 +186,8 @@ export var Shader = GObject.registerClass(
// to undo this. It is a pity that we have to do this here, as it is not really
// required to be done each frame. But it's the only place where we can do it.
// https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/2650
- if (shellVersionIsAtLeast(44, 2)) {
- this.get_pipeline().set_blend(
- 'RGBA = ADD (SRC_COLOR * (SRC_COLOR[A]), DST_COLOR * (1-SRC_COLOR[A]))');
- }
+ this.get_pipeline().set_blend(
+ 'RGBA = ADD (SRC_COLOR * (SRC_COLOR[A]), DST_COLOR * (1-SRC_COLOR[A]))');
this.set_uniform_float(this._uProgress, 1, [this._progress]);
super.vfunc_paint_target(...params);
diff --git a/src/effects/Fire.js b/src/effects/Fire.js
index b819774..5237f2f 100644
--- a/src/effects/Fire.js
+++ b/src/effects/Fire.js
@@ -19,7 +19,6 @@ import Gio from 'gi://Gio';
const _ = imports.gettext.domain('burn-my-windows').gettext;
import {ShaderFactory} from '../ShaderFactory.js';
-import {isGTK4} from '../utils.js';
//////////////////////////////////////////////////////////////////////////////////////////
// This effect is a homage to the good old Compiz days. However, it is implemented //
@@ -225,7 +224,7 @@ export default class Effect {
dialog.getBuilder().get_object('fire-preset-button').set_menu_model(menu);
- const root = isGTK4() ? widget.get_root() : widget.get_toplevel();
+ const root = widget.get_root();
root.insert_action_group(groupName, group);
});
}
diff --git a/src/utils.js b/src/utils.js
index 1c5b0c6..6742f8c 100644
--- a/src/utils.js
+++ b/src/utils.js
@@ -15,9 +15,7 @@
'use strict';
import Gio from 'gi://Gio';
-import Gtk from 'gi://Gtk';
import GLib from 'gi://GLib';
-import Adw from 'gi://Adw';
// Returns the given argument, except for "alpha", "beta", and "rc". In these cases -3,
// -2, and -1 are returned respectively.
@@ -40,38 +38,21 @@ const [GS_MAJOR, GS_MINOR] = Config.PACKAGE_VERSION.split('.').map(toNumericVers
// the standard log() functionality by prepending the extension's name and the location
// where the message was logged. As the extensions name is part of the location, you
// can more effectively watch the log output of GNOME Shell:
-// journalctl -f -o cat | grep -E 'particle-effects|'
-// This method is based on a similar script from the Fly-Pie GNOME Shell extension which
-// os published under the MIT License (https://github.com/Schneegans/Fly-Pie).
+// journalctl -f -o cat | grep -E 'burn-my-windows|'
export function debug(message) {
const stack = new Error().stack.split('\n');
// Remove debug() function call from stack.
stack.shift();
- // Find the index of the extension directory (e.g. particles@schneegans.github.com) in
- // the stack entry. We do not want to print the entire absolute file path.
- // const extensionRoot = stack[0].indexOf(Extension.uuid);
-
log('[' + stack[0] + '] ' + message);
- // log('[' + stack[0].slice(extensionRoot) + '] ' + message);
}
-// This method simply returns true if we are currently using GTK4.
-export function isGTK4() {
- return Gtk.get_major_version() == 4;
-}
-
-// Starting with GNOME Shell 42, the settings dialog uses libadwaita (at least most of
-// the time - it seems that pop!_OS does not support libadwaita even on GNOME 42).
-export function isADW() {
- return Adw && shellVersionIsAtLeast(42, 'beta');
-}
-
-// This method returns 'gtk3', 'gtk4', or 'adw' depending on the currently used GTK / and
-// or libadwaita version.
+// Currently, the extension supports only one set of UI files. In the past, there were
+// three different sets for GTK3, GTK4, and Adwaita. This method returns the name of the
+// current UI directory. It's still here since it might be useful in the future.
export function getUIDir() {
- return isADW() ? 'adw' : (isGTK4() ? 'gtk4' : 'gtk3');
+ return 'adw';
}
// This method returns true if the current GNOME Shell version matches the given
From ee41968e172cd0654f90ffe8d10d0a9031d1dced Mon Sep 17 00:00:00 2001
From: Simon Schneegans
Date: Mon, 7 Aug 2023 13:58:22 +0200
Subject: [PATCH 05/26] :memo: Fix comment
---
src/ShaderFactory.js | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/ShaderFactory.js b/src/ShaderFactory.js
index 123c2f8..cac8e98 100644
--- a/src/ShaderFactory.js
+++ b/src/ShaderFactory.js
@@ -19,7 +19,7 @@ import GObject from 'gi://GObject';
import {Shader} from './Shader.js';
//////////////////////////////////////////////////////////////////////////////////////////
-// Each effect of Burn-My-Windows owns an instance of this class. It is used to created //
+// Each effect of Burn-My-Windows owns an instance of this class. It is used to create //
// shaders whenever a new one is required. It tries to re-use old shaders as much as //
// possible in order to avoid memory leaks. //
//////////////////////////////////////////////////////////////////////////////////////////
From 8147edfa060cba45dbebeae2c196694dda7fe11b Mon Sep 17 00:00:00 2001
From: Simon Schneegans
Date: Fri, 18 Aug 2023 06:13:39 +0200
Subject: [PATCH 06/26] :beetle: Fix config import
---
prefs.js | 41 ++++++++++++++++++++++++++++++++++++++++-
src/utils.js | 44 --------------------------------------------
2 files changed, 40 insertions(+), 45 deletions(-)
diff --git a/prefs.js b/prefs.js
index 5c893a1..3d96505 100644
--- a/prefs.js
+++ b/prefs.js
@@ -20,7 +20,7 @@ import GLib from 'gi://GLib';
import Gdk from 'gi://Gdk';
import Adw from 'gi://Adw';
-import {getUIDir, getStringResource, shellVersionIsAtLeast} from './src/utils.js';
+import {getStringResource} from './src/utils.js';
import {ProfileManager} from './src/ProfileManager.js';
import Apparition from './src/effects/Apparition.js';
@@ -46,6 +46,45 @@ import TVGlitch from './src/effects/TVGlitch.js';
import Wisps from './src/effects/Wisps.js';
import {ExtensionPreferences, gettext as _} from 'resource:///org/gnome/Shell/Extensions/js/extensions/prefs.js';
+import * as Config from 'resource:///org/gnome/Shell/Extensions/js/misc/config.js';
+
+const [GS_MAJOR, GS_MINOR] = Config.PACKAGE_VERSION.split('.').map(toNumericVersion);
+
+// Returns the given argument, except for "alpha", "beta", and "rc". In these cases -3,
+// -2, and -1 are returned respectively.
+function toNumericVersion(x) {
+ switch (x) {
+ case 'alpha':
+ return -3;
+ case 'beta':
+ return -2;
+ case 'rc':
+ return -1;
+ }
+ return x;
+}
+
+// Currently, the extension supports only one set of UI files. In the past, there were
+// three different sets for GTK3, GTK4, and Adwaita. This method returns the name of the
+// current UI directory. It's still here since it might be useful in the future.
+function getUIDir() {
+ return 'adw';
+}
+
+// This method returns true if the current GNOME Shell version is at least as high as the
+// given arguments. Supports "alpha" and "beta" for the minor version number.
+function shellVersionIsAtLeast(major, minor) {
+ if (GS_MAJOR > major) {
+ return true;
+ }
+
+ if (GS_MAJOR == major) {
+ return GS_MINOR >= toNumericVersion(minor);
+ }
+
+ return false;
+}
+
//////////////////////////////////////////////////////////////////////////////////////////
// The preferences dialog is organized in pages, each of which is loaded from a //
diff --git a/src/utils.js b/src/utils.js
index 6742f8c..85d7ed5 100644
--- a/src/utils.js
+++ b/src/utils.js
@@ -17,23 +17,6 @@
import Gio from 'gi://Gio';
import GLib from 'gi://GLib';
-// Returns the given argument, except for "alpha", "beta", and "rc". In these cases -3,
-// -2, and -1 are returned respectively.
-function toNumericVersion(x) {
- switch (x) {
- case 'alpha':
- return -3;
- case 'beta':
- return -2;
- case 'rc':
- return -1;
- }
- return x;
-}
-
-const Config = imports.misc.config;
-const [GS_MAJOR, GS_MINOR] = Config.PACKAGE_VERSION.split('.').map(toNumericVersion);
-
// This method can be used to write a message to GNOME Shell's log. This is enhances
// the standard log() functionality by prepending the extension's name and the location
// where the message was logged. As the extensions name is part of the location, you
@@ -48,33 +31,6 @@ export function debug(message) {
log('[' + stack[0] + '] ' + message);
}
-// Currently, the extension supports only one set of UI files. In the past, there were
-// three different sets for GTK3, GTK4, and Adwaita. This method returns the name of the
-// current UI directory. It's still here since it might be useful in the future.
-export function getUIDir() {
- return 'adw';
-}
-
-// This method returns true if the current GNOME Shell version matches the given
-// arguments.
-export function shellVersionIs(major, minor) {
- return GS_MAJOR == major && GS_MINOR == toNumericVersion(minor);
-}
-
-// This method returns true if the current GNOME Shell version is at least as high as the
-// given arguments. Supports "alpha" and "beta" for the minor version number.
-export function shellVersionIsAtLeast(major, minor) {
- if (GS_MAJOR > major) {
- return true;
- }
-
- if (GS_MAJOR == major) {
- return GS_MINOR >= toNumericVersion(minor);
- }
-
- return false;
-}
-
// Reads the contents of a file contained in the global resources archive. The data
// is returned as a string.
export function getStringResource(path) {
From c515e495f36396d9eb4eebbe8d50d41d77308628 Mon Sep 17 00:00:00 2001
From: Simon Schneegans
Date: Sat, 19 Aug 2023 07:20:17 +0200
Subject: [PATCH 07/26] :memo: Add changelog entry
---
docs/changelog.md | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/docs/changelog.md b/docs/changelog.md
index 93ab31a..407874c 100644
--- a/docs/changelog.md
+++ b/docs/changelog.md
@@ -5,6 +5,14 @@ SPDX-License-Identifier: CC-BY-4.0
# Changelog of the Burn-My-Windows Extension
+## [Burn My Windows 37](https://github.com/schneegans/Burn-My-Windows/releases/tag/v37)
+
+**Release Date:** TBD
+
+#### Changes
+
+- The extension has been ported to use ESM modules. This is a requirement for GNOME 45 and newer. As a consequence, the extension is no longer compatible with GNOME 44 and older.
+
## [Burn My Windows 36](https://github.com/schneegans/Burn-My-Windows/releases/tag/v36)
**Release Date:** 2023-08-18
From 44ce1a4825932b787293be03ce66eead9d76a785 Mon Sep 17 00:00:00 2001
From: Simon Schneegans
Date: Sat, 19 Aug 2023 07:21:46 +0200
Subject: [PATCH 08/26] :wrench: Revert to old debug method behavior
---
src/utils.js | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/src/utils.js b/src/utils.js
index 85d7ed5..2dc6733 100644
--- a/src/utils.js
+++ b/src/utils.js
@@ -28,7 +28,11 @@ export function debug(message) {
// Remove debug() function call from stack.
stack.shift();
- log('[' + stack[0] + '] ' + message);
+ // Find the index of the extension directory in the stack entry. We do not want to
+ // print the entire absolute file path.
+ const extensionRoot = stack[0].indexOf('burn-my-windows@schneegans.github.com');
+
+ log('[' + stack[0].slice(extensionRoot) + '] ' + message);
}
// Reads the contents of a file contained in the global resources archive. The data
From a8466a16f73d22373002b725e81b020d746a5a26 Mon Sep 17 00:00:00 2001
From: Simon Schneegans
Date: Sat, 19 Aug 2023 08:00:54 +0200
Subject: [PATCH 09/26] :memo: Update effect creation guide
---
docs/how-to-create-new-effects.md | 321 +++---------------------------
1 file changed, 30 insertions(+), 291 deletions(-)
diff --git a/docs/how-to-create-new-effects.md b/docs/how-to-create-new-effects.md
index ddbdb03..9a17254 100644
--- a/docs/how-to-create-new-effects.md
+++ b/docs/how-to-create-new-effects.md
@@ -38,7 +38,7 @@ journalctl -f -o cat | grep -E 'burn-my-windows|'
For the sake of this tutorial, we will create a **"Simple Fade"** effect.
Of course, you can replace any occurrence of this name and its nick `simple-fade` with your custom effect name.
-Three simple steps are required to create a new effect.
+Three simple steps are required to create a new effect.
You will have to ...
1. add preferences keys for enabling the effect,
@@ -103,13 +103,14 @@ Please study this code carefully, all of it is explained with inline comments.
// The content from common.glsl is automatically prepended to each shader effect. This
// provides the standard input:
-// vec2 iTexCoord: Texture coordinates for retrieving the window input color.
-// bool uForOpening: True if a window-open animation is ongoing, false otherwise.
-// float uProgress: A value which transitions from 0 to 1 during the animation.
-// float uDuration: The duration of the current animation in seconds.
-// vec2 uSize: The size of uTexture in pixels.
-// float uPadding: The empty area around the actual window (e.g. where the shadow
-// is drawn). For now, this will only be set on GNOME.
+// vec2 iTexCoord: Texture coordinates for retrieving the window input color.
+// bool uIsFullscreen: True if the window is maximized or in fullscreen mode.
+// bool uForOpening: True if a window-open animation is ongoing, false otherwise.
+// float uProgress: A value which transitions from 0 to 1 during the animation.
+// float uDuration: The duration of the current animation in seconds.
+// vec2 uSize: The size of uTexture in pixels.
+// float uPadding: The empty area around the actual window (e.g. where the shadow
+// is drawn). For now, this will only be set on GNOME.
// Furthermore, there are two global methods for reading the window input color and
// setting the shader output color. Both methods assume straight alpha:
@@ -162,16 +163,13 @@ void main() {
// SPDX-FileCopyrightText: Your Name Expand this to show the GTK3 code.
-
-```xml
-
-
-
-
-Expand this to show the GTK4 code.
-
-```xml
-
-
-
-
-Expand this to show the libadwaita code.
+ Expand this to show the UI code.
```xml
@@ -628,7 +367,7 @@ SPDX-License-Identifier: GPL-3.0-or-later
### Loading the Preferences Page
-In order to load the above `*.ui` files, add the following code to your effect's `bindPreferences()` method.
+In order to load the above `*.ui` file, add the following code to your effect's `bindPreferences()` method.
```javascript
bindPreferences(dialog) {
@@ -651,4 +390,4 @@ make install && pkill -f '.Extensions' && sleep 2 ; gnome-extensions prefs burn-
That's it!
If you have any questions, feel free to [ask them on the discussions board](https://github.com/Schneegans/Burn-My-Windows/discussions).
-If you are happy with your effect, submit a pull request, and it may get included in the next version!
\ No newline at end of file
+If you are happy with your effect, submit a pull request, and it may get included in the next version!
From 45dd8d992d396b0a872605a303fe3ad50fb42ac1 Mon Sep 17 00:00:00 2001
From: Simon Schneegans
Date: Sat, 19 Aug 2023 08:01:46 +0200
Subject: [PATCH 10/26] :wrench: Do not add compiled schemas
---
Makefile | 7 +------
1 file changed, 1 insertion(+), 6 deletions(-)
diff --git a/Makefile b/Makefile
index 7f0337c..50204f0 100644
--- a/Makefile
+++ b/Makefile
@@ -19,7 +19,7 @@ LOCALES_MO = $(patsubst po/%.po,locale/%/LC_MESSAGES/$(NAME).mo,$(LOCALES_PO
ZIP_CONTENT = $(JS_FILES) $(LOCALES_MO) resources/$(NAME).gresource \
schemas/org.gnome.shell.extensions.$(NAME).gschema.xml \
schemas/org.gnome.shell.extensions.$(NAME)-profile.gschema.xml \
- schemas/gschemas.compiled metadata.json LICENSE
+ metadata.json LICENSE
# These seven recipes can be invoked by the user.
.PHONY: zip install uninstall pot clean test references
@@ -92,11 +92,6 @@ $(ZIP_NAME): $(ZIP_CONTENT)
exit 1; \
fi
-# Compiles the gschemas.compiled file from the gschema.xml file.
-schemas/gschemas.compiled: schemas/org.gnome.shell.extensions.$(NAME).gschema.xml schemas/org.gnome.shell.extensions.$(NAME)-profile.gschema.xml
- @echo "Compiling schemas..."
- @glib-compile-schemas schemas
-
# Compiles the gresource file from the gresources.xml.
resources/$(NAME).gresource: resources/$(NAME).gresource.xml
@echo "Compiling resources..."
From bf068e24daec0409ba6c07df379bbd369844b55c Mon Sep 17 00:00:00 2001
From: Simon Schneegans
Date: Sat, 19 Aug 2023 08:02:24 +0200
Subject: [PATCH 11/26] :wrench: Only run tests on rawhide
---
.github/workflows/checks.yml | 77 ++++++++++++++++--------------------
1 file changed, 35 insertions(+), 42 deletions(-)
diff --git a/.github/workflows/checks.yml b/.github/workflows/checks.yml
index 28c0a41..78e2670 100644
--- a/.github/workflows/checks.yml
+++ b/.github/workflows/checks.yml
@@ -6,10 +6,10 @@ name: Checks
on:
push:
branches:
- - '**'
+ - "**"
pull_request:
branches:
- - '**'
+ - "**"
jobs:
clang_format:
@@ -33,9 +33,9 @@ jobs:
name: Check Compliance with REUSE Specification
runs-on: ubuntu-latest
steps:
- - uses: actions/checkout@v3
- - name: REUSE Compliance Check
- uses: fsfe/reuse-action@v1
+ - uses: actions/checkout@v3
+ - name: REUSE Compliance Check
+ uses: fsfe/reuse-action@v1
comment_percentage:
name: Check Comment Percentage
@@ -85,19 +85,19 @@ jobs:
if: >
github.event_name == 'push' && contains(github.event.head_commit.message, '[generate-references]')
steps:
- - uses: actions/checkout@v3
- - name: Download Dependencies
- run: |
- sudo apt update -qq
- sudo apt install gettext imagemagick -qq
- - name: Build Burn-My-Windows
- run: make
- - name: Generate References
- run: sudo make references
- - uses: actions/upload-artifact@v3
- with:
- name: references
- path: tests/references/
+ - uses: actions/checkout@v3
+ - name: Download Dependencies
+ run: |
+ sudo apt update -qq
+ sudo apt install gettext imagemagick -qq
+ - name: Build Burn-My-Windows
+ run: make
+ - name: Generate References
+ run: sudo make references
+ - uses: actions/upload-artifact@v3
+ with:
+ name: references
+ path: tests/references/
build:
name: Run Tests
@@ -110,29 +110,22 @@ jobs:
fail-fast: false
matrix:
version:
- - '32'
- - '33'
- - '34'
- - '35'
- - '36'
- - '37'
- - '38'
- - 'rawhide'
+ - "rawhide"
session:
- - 'gnome-xsession'
- - 'gnome-wayland-nested'
+ - "gnome-xsession"
+ - "gnome-wayland-nested"
steps:
- - uses: actions/checkout@v3
- - name: Download Dependencies
- run: |
- sudo apt update -qq
- sudo apt install gettext imagemagick -qq
- - name: Build Burn-My-Windows
- run: make
- - name: Test Burn-My-Windows
- run: sudo $GITHUB_WORKSPACE/tests/run-test.sh -v ${{ matrix.version }} -s ${{ matrix.session }}
- - uses: actions/upload-artifact@v3
- if: failure()
- with:
- name: result_${{ matrix.version }}_${{ matrix.session }}
- path: tests/output/
\ No newline at end of file
+ - uses: actions/checkout@v3
+ - name: Download Dependencies
+ run: |
+ sudo apt update -qq
+ sudo apt install gettext imagemagick -qq
+ - name: Build Burn-My-Windows
+ run: make
+ - name: Test Burn-My-Windows
+ run: sudo $GITHUB_WORKSPACE/tests/run-test.sh -v ${{ matrix.version }} -s ${{ matrix.session }}
+ - uses: actions/upload-artifact@v3
+ if: failure()
+ with:
+ name: result_${{ matrix.version }}_${{ matrix.session }}
+ path: tests/output/
From 27220c95f8de848fc7fcc48cb4550cae12a82304 Mon Sep 17 00:00:00 2001
From: Simon Schneegans
Date: Thu, 31 Aug 2023 07:39:56 +0200
Subject: [PATCH 12/26] :wrench: Only run tests on rawhide for GNOME 45
---
Makefile | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/Makefile b/Makefile
index c23bb9c..a0c6a2b 100644
--- a/Makefile
+++ b/Makefile
@@ -48,7 +48,7 @@ pot: $(JS_FILES) $(UI_FILES)
# This runs several tests in containerized versions of GNOME Shell.
test:
- @ for version in 32 33 34 35 36 37 38 ; do \
+ @ for version in "rawhide" ; do \
for session in "gnome-xsession" "gnome-wayland-nested" ; do \
echo ; \
echo "Running Tests on Fedora $$version ($$session)." ; \
@@ -59,7 +59,7 @@ test:
# This re-generates all reference images required by the tests.
references:
- @ for version in 32 33 34 35 36 37 38 ; do \
+ @ for version in "rawhide" ; do \
for session in "gnome-xsession" "gnome-wayland-nested" ; do \
echo ; \
echo "Generating References for Fedora $$version ($$session)." ; \
From e9ef77617ffc5f3ab393e84302cc47f6c3b83479 Mon Sep 17 00:00:00 2001
From: Simon Schneegans
Date: Sat, 2 Sep 2023 10:21:21 +0200
Subject: [PATCH 13/26] :wrench: Use console.log instead of log
---
src/utils.js | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/utils.js b/src/utils.js
index 2dc6733..4018c26 100644
--- a/src/utils.js
+++ b/src/utils.js
@@ -32,7 +32,7 @@ export function debug(message) {
// print the entire absolute file path.
const extensionRoot = stack[0].indexOf('burn-my-windows@schneegans.github.com');
- log('[' + stack[0].slice(extensionRoot) + '] ' + message);
+ console.log('[' + stack[0].slice(extensionRoot) + '] ' + message);
}
// Reads the contents of a file contained in the global resources archive. The data
From 9ae7f9c042ccb4c4d0eb417552660c44a952e14d Mon Sep 17 00:00:00 2001
From: Simon Schneegans
Date: Sat, 2 Sep 2023 10:21:40 +0200
Subject: [PATCH 14/26] :recycle: Use glob import for utils
---
extension.js | 6 +++---
prefs.js | 6 +++---
src/Shader.js | 6 +++---
src/WindowPicker.js | 6 +++---
src/migrate.js | 49 +++++++++++++++++++++++----------------------
5 files changed, 37 insertions(+), 36 deletions(-)
diff --git a/extension.js b/extension.js
index c03e6a6..c1e52da 100644
--- a/extension.js
+++ b/extension.js
@@ -20,7 +20,7 @@ import Meta from 'gi://Meta';
import {fromVersion26} from './src/migrate.js';
import {ProfileManager} from './src/ProfileManager.js';
import {WindowPicker} from './src/WindowPicker.js';
-import {getStringResource} from './src/utils.js';
+import * as utils from './src/utils.js';
import Apparition from './src/effects/Apparition.js';
import BrokenGlass from './src/effects/BrokenGlass.js';
@@ -138,14 +138,14 @@ export default class BurnMyWindows extends Extension {
// This is used to get the battery state.
const UPowerProxy = Gio.DBusProxy.makeProxyWrapper(
- getStringResource('/interfaces/org.freedesktop.UPower.xml'));
+ utils.getStringResource('/interfaces/org.freedesktop.UPower.xml'));
this._upowerProxy = new UPowerProxy(Gio.DBus.system, 'org.freedesktop.UPower',
'/org/freedesktop/UPower');
// This is used to get the current power profile.
try {
const PowerProfilesProxy = Gio.DBusProxy.makeProxyWrapper(
- getStringResource('/interfaces/net.hadess.PowerProfiles.xml'));
+ utils.getStringResource('/interfaces/net.hadess.PowerProfiles.xml'));
this._powerProfilesProxy = new PowerProfilesProxy(
Gio.DBus.system, 'net.hadess.PowerProfiles', '/net/hadess/PowerProfiles');
} catch (e) {
diff --git a/prefs.js b/prefs.js
index 3d96505..d2a9c94 100644
--- a/prefs.js
+++ b/prefs.js
@@ -20,7 +20,7 @@ import GLib from 'gi://GLib';
import Gdk from 'gi://Gdk';
import Adw from 'gi://Adw';
-import {getStringResource} from './src/utils.js';
+import * as utils from './src/utils.js';
import {ProfileManager} from './src/ProfileManager.js';
import Apparition from './src/effects/Apparition.js';
@@ -157,7 +157,7 @@ export default class BurnMyWindowsPreferences extends ExtensionPreferences {
let hasPowerProfiles = false;
try {
const PowerProfilesProxy = Gio.DBusProxy.makeProxyWrapper(
- getStringResource('/interfaces/net.hadess.PowerProfiles.xml'));
+ utils.getStringResource('/interfaces/net.hadess.PowerProfiles.xml'));
let powerProfilesProxy = new PowerProfilesProxy(
Gio.DBus.system, 'net.hadess.PowerProfiles', '/net/hadess/PowerProfiles');
@@ -849,7 +849,7 @@ GitHub: https://github.com/spon
// Reads the contents of a JSON file contained in the global resources archive. The data
// is parsed and returned as a JavaScript object / array.
_getJSONResource(path) {
- return JSON.parse(getStringResource(path));
+ return JSON.parse(utils.getStringResource(path));
}
// This traverses the widget tree below the given parent recursively and returns the
diff --git a/src/Shader.js b/src/Shader.js
index 5e274eb..2d53afe 100644
--- a/src/Shader.js
+++ b/src/Shader.js
@@ -20,7 +20,7 @@ import GObject from 'gi://GObject';
import Clutter from 'gi://Clutter';
import Meta from 'gi://Meta';
-import {getStringResource} from './utils.js';
+import * as utils from './utils.js';
//////////////////////////////////////////////////////////////////////////////////////////
// This is the base class for all shaders of Burn-My-Windows. It automagically loads //
@@ -203,8 +203,8 @@ export var Shader = GObject.registerClass(
// This loads a GLSL file from the extension's resources to a JavaScript string. The
// code from "common.glsl" is prepended automatically.
_loadShaderResource(path) {
- let common = getStringResource('/shaders/common.glsl');
- let code = getStringResource(path);
+ let common = utils.getStringResource('/shaders/common.glsl');
+ let code = utils.getStringResource(path);
// Add a trailing newline. Else the GLSL compiler complains...
return common + '\n' + code + '\n';
diff --git a/src/WindowPicker.js b/src/WindowPicker.js
index 157ef28..0f9b8d3 100644
--- a/src/WindowPicker.js
+++ b/src/WindowPicker.js
@@ -21,7 +21,7 @@ import GLib from 'gi://GLib';
import * as Main from 'resource:///org/gnome/shell/ui/main.js';
import * as LookingGlass from 'resource:///org/gnome/shell/ui/lookingGlass.js';
-import {getStringResource} from './utils.js';
+import * as utils from './utils.js';
//////////////////////////////////////////////////////////////////////////////////////////
// This is based on the window-picking functionality of the Blur-My-Shell extension. //
@@ -34,8 +34,8 @@ export class WindowPicker {
// ------------------------------------------------------------------------- constructor
constructor() {
- const iFace =
- getStringResource('/interfaces/org.gnome.shell.extensions.burn-my-windows.xml');
+ const iFace = utils.getStringResource(
+ '/interfaces/org.gnome.shell.extensions.burn-my-windows.xml');
this._dbus = Gio.DBusExportedObject.wrapJSObject(iFace, this);
}
diff --git a/src/migrate.js b/src/migrate.js
index 2a7d62b..6cc92b7 100644
--- a/src/migrate.js
+++ b/src/migrate.js
@@ -15,14 +15,15 @@
'use strict';
import {ProfileManager} from './ProfileManager.js';
-import {debug, executeCommand} from './utils.js';
+import * as utils from './utils.js';
// Migrating from pre-27 versions is pretty involved. Before, all settings were stored in
// the standard Gio.Settings backend. Now, there are effect profiles. Depending on the
// settings one or two profiles may be required.
export async function fromVersion26() {
- return executeCommand(['dconf', 'dump', '/org/gnome/shell/extensions/burn-my-windows/'])
- .catch(r => debug('Failed to get old settings for effect migration: ' + r))
+ return utils
+ .executeCommand(['dconf', 'dump', '/org/gnome/shell/extensions/burn-my-windows/'])
+ .catch(r => utils.debug('Failed to get old settings for effect migration: ' + r))
.then(r => {
// If there were no settings before, we do not have to migrate anything. Just use
// the new defaults.
@@ -30,7 +31,7 @@ export async function fromVersion26() {
return;
}
- debug('Starting Burn-My-Windows profile migration (old version <= 26)!');
+ utils.debug('Starting Burn-My-Windows profile migration (old version <= 26)!');
// We use this to write the new profiles.
const profileManager = new ProfileManager();
@@ -38,19 +39,19 @@ export async function fromVersion26() {
// The default value of this was false, so not-present is equal to false.
const destroyDialogs = r.includes('destroy-dialogs=true');
if (!destroyDialogs) {
- debug('Only normal windows will be burned by the new profile(s).');
+ utils.debug('Only normal windows will be burned by the new profile(s).');
}
// The default value of this was false, so not-present is equal to false.
const disableOnBattery = r.includes('disable-on-battery=true');
if (disableOnBattery) {
- debug('The new profile(s) will not be active on battery.');
+ utils.debug('The new profile(s) will not be active on battery.');
}
// The default value of this was false, so not-present is equal to false.
const disableOnPowerSave = r.includes('disable-on-power-save=true');
if (disableOnPowerSave) {
- debug('The new profile(s) will not be active in power-save mode.');
+ utils.debug('The new profile(s) will not be active in power-save mode.');
}
// Remove some unnecessary lines.
@@ -85,21 +86,21 @@ export async function fromVersion26() {
}
// Print all effects we've found.
- debug('Enabled open effects: ' + openEffects);
- debug('Enabled close effects: ' + closeEffects);
+ utils.debug('Enabled open effects: ' + openEffects);
+ utils.debug('Enabled close effects: ' + closeEffects);
// If the same effects were used for opening and closing windows or there is either
// no opening or no closing animation configured, only one profile is required. Else
// we have to create two new profiles.
const numProfiles = openEffects.join() == closeEffects.join() ? 1 : 2;
if (numProfiles == 1) {
- debug('Only one profile is required.');
+ utils.debug('Only one profile is required.');
} else if (closeEffects.length == 0) {
- debug('Only a window-open profile is required.');
+ utils.debug('Only a window-open profile is required.');
} else if (openEffects.length == 0) {
- debug('Only a window-close profile is required.');
+ utils.debug('Only a window-close profile is required.');
} else {
- debug('Two profiles are required.');
+ utils.debug('Two profiles are required.');
}
// Remove all open / close lines.
@@ -140,8 +141,8 @@ export async function fromVersion26() {
// Print and save the new profile.
const profile = profileLines.join('\n');
- debug('The new profile:');
- debug(profile);
+ utils.debug('The new profile:');
+ utils.debug(profile);
profileManager.createProfile(profile);
@@ -162,8 +163,8 @@ export async function fromVersion26() {
// Print and save the new profile.
const profile = profileLines.join('\n');
- debug('The new window-open profile:');
- debug(profile);
+ utils.debug('The new window-open profile:');
+ utils.debug(profile);
profileManager.createProfile(profile);
@@ -184,8 +185,8 @@ export async function fromVersion26() {
// Print and save the new profile.
const profile = profileLines.join('\n');
- debug('The new window-close profile:');
- debug(profile);
+ utils.debug('The new window-close profile:');
+ utils.debug(profile);
profileManager.createProfile(profile);
@@ -213,14 +214,14 @@ export async function fromVersion26() {
const openProfile = openProfileLines.join('\n');
const closeProfile = closeProfileLines.join('\n');
- debug('The new open-window profile:');
- debug(openProfile);
- debug('The new close-window profile:');
- debug(closeProfile);
+ utils.debug('The new open-window profile:');
+ utils.debug(openProfile);
+ utils.debug('The new close-window profile:');
+ utils.debug(closeProfile);
profileManager.createProfile(openProfile);
profileManager.createProfile(closeProfile);
}
})
- .catch(r => debug('Failed to migrate settings: ' + r));
+ .catch(r => utils.debug('Failed to migrate settings: ' + r));
}
\ No newline at end of file
From 3f05c946ec725be84cec5482b2ba7b78321b229a Mon Sep 17 00:00:00 2001
From: Simon Schneegans
Date: Tue, 5 Sep 2023 08:02:36 +0200
Subject: [PATCH 15/26] :memo: Tweak changelog entry
---
docs/changelog.md | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/docs/changelog.md b/docs/changelog.md
index d51cbb7..51dfff1 100644
--- a/docs/changelog.md
+++ b/docs/changelog.md
@@ -9,9 +9,9 @@ SPDX-License-Identifier: CC-BY-4.0
**Release Date:** TBD
-#### Changes
+#### Major Changes
-- The extension has been ported to use ESM modules. This is a requirement for GNOME 45 and newer. As a consequence, the extension is no longer compatible with GNOME 44 and older.
+- This is the first release of Burn-My-Windows supporting GNOME 45. This required a [major refactoring](https://github.com/Schneegans/Burn-My-Windows/pull/373/files) of the code base as GJS now uses ESM modules. As a consequence, this version is not compatible with older versions of GNOME Shell anymore. The old code base is still available on the `gnome-3.36-44` branch and if new features are added (especially translations), they can be backported to this branch.
## [Burn My Windows 37](https://github.com/schneegans/Burn-My-Windows/releases/tag/v37)
From 14cd1db7e9de77d406dce84e58ab73b47f157bbb Mon Sep 17 00:00:00 2001
From: Simon Schneegans
Date: Fri, 8 Sep 2023 20:45:58 +0200
Subject: [PATCH 16/26] :wrench: Do not import the ShaderFactory in the
preferences process
---
docs/how-to-create-new-effects.md | 14 +++++-----
extension.js | 14 ++++++----
prefs.js | 42 ++++++++++++++---------------
src/ShaderFactory.js | 2 +-
src/effects/Apparition.js | 15 ++++++-----
src/effects/BrokenGlass.js | 15 ++++++-----
src/effects/Doom.js | 13 ++++-----
src/effects/EnergizeA.js | 15 ++++++-----
src/effects/EnergizeB.js | 15 ++++++-----
src/effects/Fire.js | 15 ++++++-----
src/effects/Glide.js | 15 ++++++-----
src/effects/Glitch.js | 15 ++++++-----
src/effects/Hexagon.js | 15 ++++++-----
src/effects/Incinerate.js | 15 ++++++-----
src/effects/Matrix.js | 15 ++++++-----
src/effects/PaintBrush.js | 15 ++++++-----
src/effects/PixelWheel.js | 15 ++++++-----
src/effects/PixelWipe.js | 15 ++++++-----
src/effects/Pixelate.js | 15 ++++++-----
src/effects/Portal.js | 15 ++++++-----
src/effects/SnapOfDisintegration.js | 15 ++++++-----
src/effects/TRexAttack.js | 15 ++++++-----
src/effects/TVEffect.js | 15 ++++++-----
src/effects/TVGlitch.js | 15 ++++++-----
src/effects/Wisps.js | 15 ++++++-----
25 files changed, 205 insertions(+), 180 deletions(-)
diff --git a/docs/how-to-create-new-effects.md b/docs/how-to-create-new-effects.md
index 9a17254..fe5960e 100644
--- a/docs/how-to-create-new-effects.md
+++ b/docs/how-to-create-new-effects.md
@@ -185,7 +185,7 @@ export default class Effect {
// GLSL file in resources/shaders/
Date: Sat, 9 Sep 2023 05:52:15 +0200
Subject: [PATCH 17/26] :beetle: Fix Doom effect
---
src/effects/Doom.js | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/effects/Doom.js b/src/effects/Doom.js
index bbe7088..be02ff6 100644
--- a/src/effects/Doom.js
+++ b/src/effects/Doom.js
@@ -102,7 +102,7 @@ export default class Effect {
// bounds of the actor. This only works for GNOME 3.38+.
// For this effect, we scale the actor vertically so that it covers the entire screen.
// This ensures that the melted window will not be cut off.
- getActorScale(settings, forOpening, actor) {
+ static getActorScale(settings, forOpening, actor) {
let actorScale = 2.0 * Math.max(1.0, global.stage.height / actor.height);
return {x: 1.0, y: actorScale};
}
From 006cc593a39deffa46a1d048e461c57eb102988e Mon Sep 17 00:00:00 2001
From: Simon Schneegans
Date: Sat, 9 Sep 2023 05:52:39 +0200
Subject: [PATCH 18/26] :wrench: Add missing method inputs
---
docs/how-to-create-new-effects.md | 2 +-
src/effects/Apparition.js | 2 +-
src/effects/BrokenGlass.js | 2 +-
src/effects/EnergizeA.js | 2 +-
src/effects/EnergizeB.js | 2 +-
src/effects/Fire.js | 2 +-
src/effects/Glide.js | 2 +-
src/effects/Glitch.js | 2 +-
src/effects/Hexagon.js | 2 +-
src/effects/Incinerate.js | 2 +-
src/effects/Matrix.js | 2 +-
src/effects/PaintBrush.js | 2 +-
src/effects/PixelWheel.js | 2 +-
src/effects/PixelWipe.js | 2 +-
src/effects/Pixelate.js | 2 +-
src/effects/Portal.js | 2 +-
src/effects/SnapOfDisintegration.js | 2 +-
src/effects/TRexAttack.js | 2 +-
src/effects/TVEffect.js | 2 +-
src/effects/TVGlitch.js | 2 +-
src/effects/Wisps.js | 2 +-
21 files changed, 21 insertions(+), 21 deletions(-)
diff --git a/docs/how-to-create-new-effects.md b/docs/how-to-create-new-effects.md
index fe5960e..db50bdb 100644
--- a/docs/how-to-create-new-effects.md
+++ b/docs/how-to-create-new-effects.md
@@ -233,7 +233,7 @@ export default class Effect {
// The getActorScale() is called from extension.js to adjust the actor's size during the
// animation. This is useful if the effect requires drawing something beyond the usual
// bounds of the actor. This only works for GNOME 3.38+.
- static getActorScale(settings) {
+ static getActorScale(settings, forOpening, actor) {
return { x: 1.0, y: 1.0 };
}
}
diff --git a/src/effects/Apparition.js b/src/effects/Apparition.js
index dc678ad..07f830a 100644
--- a/src/effects/Apparition.js
+++ b/src/effects/Apparition.js
@@ -93,7 +93,7 @@ export default class Effect {
// The getActorScale() is called from extension.js to adjust the actor's size during the
// animation. This is useful if the effect requires drawing something beyond the usual
// bounds of the actor. This only works for GNOME 3.38+.
- static getActorScale(settings) {
+ static getActorScale(settings, forOpening, actor) {
return {x: 2.0, y: 2.0};
}
}
diff --git a/src/effects/BrokenGlass.js b/src/effects/BrokenGlass.js
index 8e453f8..5cc0f95 100644
--- a/src/effects/BrokenGlass.js
+++ b/src/effects/BrokenGlass.js
@@ -152,7 +152,7 @@ export default class Effect {
// The getActorScale() is called from extension.js to adjust the actor's size during the
// animation. This is useful if the effect requires drawing something beyond the usual
// bounds of the actor. This only works for GNOME 3.38+.
- static getActorScale(settings) {
+ static getActorScale(settings, forOpening, actor) {
return {x: 2.0, y: 2.0};
}
}
diff --git a/src/effects/EnergizeA.js b/src/effects/EnergizeA.js
index 1b0523c..2ee4535 100644
--- a/src/effects/EnergizeA.js
+++ b/src/effects/EnergizeA.js
@@ -91,7 +91,7 @@ export default class Effect {
// The getActorScale() is called from extension.js to adjust the actor's size during the
// animation. This is useful if the effect requires drawing something beyond the usual
// bounds of the actor. This only works for GNOME 3.38+.
- static getActorScale(settings) {
+ static getActorScale(settings, forOpening, actor) {
return {x: 1.0, y: 1.0};
}
}
\ No newline at end of file
diff --git a/src/effects/EnergizeB.js b/src/effects/EnergizeB.js
index 04e5ac7..1d2be49 100644
--- a/src/effects/EnergizeB.js
+++ b/src/effects/EnergizeB.js
@@ -92,7 +92,7 @@ export default class Effect {
// The getActorScale() is called from extension.js to adjust the actor's size during the
// animation. This is useful if the effect requires drawing something beyond the usual
// bounds of the actor. This only works for GNOME 3.38+.
- static getActorScale(settings) {
+ static getActorScale(settings, forOpening, actor) {
return {x: 1.0, y: 1.0};
}
}
diff --git a/src/effects/Fire.js b/src/effects/Fire.js
index 819de64..10a2b54 100644
--- a/src/effects/Fire.js
+++ b/src/effects/Fire.js
@@ -137,7 +137,7 @@ export default class Effect {
// The getActorScale() is called from extension.js to adjust the actor's size during the
// animation. This is useful if the effect requires drawing something beyond the usual
// bounds of the actor. This only works for GNOME 3.38+.
- static getActorScale(settings) {
+ static getActorScale(settings, forOpening, actor) {
return {x: 1.0, y: 1.0};
}
diff --git a/src/effects/Glide.js b/src/effects/Glide.js
index 61950b0..2edf1d8 100644
--- a/src/effects/Glide.js
+++ b/src/effects/Glide.js
@@ -91,7 +91,7 @@ export default class Effect {
// The getActorScale() is called from extension.js to adjust the actor's size during the
// animation. This is useful if the effect requires drawing something beyond the usual
// bounds of the actor. This only works for GNOME 3.38+.
- static getActorScale(settings) {
+ static getActorScale(settings, forOpening, actor) {
return {x: 1.0, y: 1.0};
}
}
diff --git a/src/effects/Glitch.js b/src/effects/Glitch.js
index a194385..767cb23 100644
--- a/src/effects/Glitch.js
+++ b/src/effects/Glitch.js
@@ -99,7 +99,7 @@ export default class Effect {
// The getActorScale() is called from extension.js to adjust the actor's size during the
// animation. This is useful if the effect requires drawing something beyond the usual
// bounds of the actor. This only works for GNOME 3.38+.
- static getActorScale(settings) {
+ static getActorScale(settings, forOpening, actor) {
return {x: 1.0, y: 1.0};
}
}
\ No newline at end of file
diff --git a/src/effects/Hexagon.js b/src/effects/Hexagon.js
index 44d4f60..9747897 100644
--- a/src/effects/Hexagon.js
+++ b/src/effects/Hexagon.js
@@ -108,7 +108,7 @@ export default class Effect {
// The getActorScale() is called from extension.js to adjust the actor's size during the
// animation. This is useful if the effect requires drawing something beyond the usual
// bounds of the actor. This only works for GNOME 3.38+.
- static getActorScale(settings) {
+ static getActorScale(settings, forOpening, actor) {
return {x: 1.0, y: 1.0};
}
}
diff --git a/src/effects/Incinerate.js b/src/effects/Incinerate.js
index df1554a..9838db7 100644
--- a/src/effects/Incinerate.js
+++ b/src/effects/Incinerate.js
@@ -144,7 +144,7 @@ export default class Effect {
// The getActorScale() is called from extension.js to adjust the actor's size during the
// animation. This is useful if the effect requires drawing something beyond the usual
// bounds of the actor. This only works for GNOME 3.38+.
- static getActorScale(settings) {
+ static getActorScale(settings, forOpening, actor) {
return {x: 1.0, y: 1.0};
}
}
\ No newline at end of file
diff --git a/src/effects/Matrix.js b/src/effects/Matrix.js
index b007142..fbfd153 100644
--- a/src/effects/Matrix.js
+++ b/src/effects/Matrix.js
@@ -128,7 +128,7 @@ export default class Effect {
// The getActorScale() is called from extension.js to adjust the actor's size during the
// animation. This is useful if the effect requires drawing something beyond the usual
// bounds of the actor. This only works for GNOME 3.38+.
- static getActorScale(settings) {
+ static getActorScale(settings, forOpening, actor) {
return {x: 1.0, y: 1.0 + settings.get_double('matrix-overshoot')};
}
}
diff --git a/src/effects/PaintBrush.js b/src/effects/PaintBrush.js
index fa8f46f..1f6ab7a 100644
--- a/src/effects/PaintBrush.js
+++ b/src/effects/PaintBrush.js
@@ -112,7 +112,7 @@ export default class Effect {
// The getActorScale() is called from extension.js to adjust the actor's size during the
// animation. This is useful if the effect requires drawing something beyond the usual
// bounds of the actor. This only works for GNOME 3.38+.
- static getActorScale(settings) {
+ static getActorScale(settings, forOpening, actor) {
return {x: 1.0, y: 1.0};
}
}
diff --git a/src/effects/PixelWheel.js b/src/effects/PixelWheel.js
index 3147e96..4983e4c 100644
--- a/src/effects/PixelWheel.js
+++ b/src/effects/PixelWheel.js
@@ -85,7 +85,7 @@ export default class Effect {
// The getActorScale() is called from extension.js to adjust the actor's size during the
// animation. This is useful if the effect requires drawing something beyond the usual
// bounds of the actor. This only works for GNOME 3.38+.
- static getActorScale(settings) {
+ static getActorScale(settings, forOpening, actor) {
return {x: 1.0, y: 1.0};
}
}
diff --git a/src/effects/PixelWipe.js b/src/effects/PixelWipe.js
index 3e46689..35cdf9c 100644
--- a/src/effects/PixelWipe.js
+++ b/src/effects/PixelWipe.js
@@ -111,7 +111,7 @@ export default class Effect {
// The getActorScale() is called from extension.js to adjust the actor's size during the
// animation. This is useful if the effect requires drawing something beyond the usual
// bounds of the actor. This only works for GNOME 3.38+.
- static getActorScale(settings) {
+ static getActorScale(settings, forOpening, actor) {
return {x: 1.0, y: 1.0};
}
}
diff --git a/src/effects/Pixelate.js b/src/effects/Pixelate.js
index f1971f5..0cc0c31 100644
--- a/src/effects/Pixelate.js
+++ b/src/effects/Pixelate.js
@@ -85,7 +85,7 @@ export default class Effect {
// The getActorScale() is called from extension.js to adjust the actor's size during the
// animation. This is useful if the effect requires drawing something beyond the usual
// bounds of the actor. This only works for GNOME 3.38+.
- static getActorScale(settings) {
+ static getActorScale(settings, forOpening, actor) {
return {x: 1.0, y: 1.0};
}
}
diff --git a/src/effects/Portal.js b/src/effects/Portal.js
index 9662274..e22cbce 100644
--- a/src/effects/Portal.js
+++ b/src/effects/Portal.js
@@ -101,7 +101,7 @@ export default class Effect {
// The getActorScale() is called from extension.js to adjust the actor's size during the
// animation. This is useful if the effect requires drawing something beyond the usual
// bounds of the actor. This only works for GNOME 3.38+.
- static getActorScale(settings) {
+ static getActorScale(settings, forOpening, actor) {
return {x: 1.0, y: 1.0};
}
}
diff --git a/src/effects/SnapOfDisintegration.js b/src/effects/SnapOfDisintegration.js
index a5f771a..5af84c1 100644
--- a/src/effects/SnapOfDisintegration.js
+++ b/src/effects/SnapOfDisintegration.js
@@ -125,7 +125,7 @@ export default class Effect {
// The getActorScale() is called from extension.js to adjust the actor's size during the
// animation. This is useful if the effect requires drawing something beyond the usual
// bounds of the actor. This only works for GNOME 3.38+.
- static getActorScale(settings) {
+ static getActorScale(settings, forOpening, actor) {
return {x: 1.2, y: 1.2};
}
}
diff --git a/src/effects/TRexAttack.js b/src/effects/TRexAttack.js
index 3d6dbe7..44ae5a1 100644
--- a/src/effects/TRexAttack.js
+++ b/src/effects/TRexAttack.js
@@ -125,7 +125,7 @@ export default class Effect {
// The getActorScale() is called from extension.js to adjust the actor's size during the
// animation. This is useful if the effect requires drawing something beyond the usual
// bounds of the actor. This only works for GNOME 3.38+.
- static getActorScale(settings) {
+ static getActorScale(settings, forOpening, actor) {
const scale = 1.0 + 0.5 * settings.get_double('trex-scratch-warp');
return {x: scale, y: scale};
}
diff --git a/src/effects/TVEffect.js b/src/effects/TVEffect.js
index 41e2d0d..846b900 100644
--- a/src/effects/TVEffect.js
+++ b/src/effects/TVEffect.js
@@ -88,7 +88,7 @@ export default class Effect {
// The getActorScale() is called from extension.js to adjust the actor's size during the
// animation. This is useful if the effect requires drawing something beyond the usual
// bounds of the actor. This only works for GNOME 3.38+.
- static getActorScale(settings) {
+ static getActorScale(settings, forOpening, actor) {
return {x: 1.0, y: 1.0};
}
}
diff --git a/src/effects/TVGlitch.js b/src/effects/TVGlitch.js
index d9bf0ed..9c7345b 100644
--- a/src/effects/TVGlitch.js
+++ b/src/effects/TVGlitch.js
@@ -100,7 +100,7 @@ export default class Effect {
// The getActorScale() is called from extension.js to adjust the actor's size during the
// animation. This is useful if the effect requires drawing something beyond the usual
// bounds of the actor. This only works for GNOME 3.38+.
- static getActorScale(settings) {
+ static getActorScale(settings, forOpening, actor) {
return {x: 1.0, y: 1.0};
}
}
diff --git a/src/effects/Wisps.js b/src/effects/Wisps.js
index 98ab12d..e59c083 100644
--- a/src/effects/Wisps.js
+++ b/src/effects/Wisps.js
@@ -114,7 +114,7 @@ export default class Effect {
// The getActorScale() is called from extension.js to adjust the actor's size during the
// animation. This is useful if the effect requires drawing something beyond the usual
// bounds of the actor. This only works for GNOME 3.38+.
- static getActorScale(settings) {
+ static getActorScale(settings, forOpening, actor) {
return {x: 1.0, y: 1.0};
}
}
From 767035e3131c1230a401407a41feffffefd21918 Mon Sep 17 00:00:00 2001
From: Simon Schneegans
Date: Sat, 9 Sep 2023 06:05:15 +0200
Subject: [PATCH 19/26] :recycle: Use utility method to import module in Shell
process only
---
docs/how-to-create-new-effects.md | 6 +++---
src/effects/Apparition.js | 5 +++--
src/effects/BrokenGlass.js | 5 +++--
src/effects/Doom.js | 5 +++--
src/effects/EnergizeA.js | 5 +++--
src/effects/EnergizeB.js | 5 +++--
src/effects/Fire.js | 5 +++--
src/effects/Glide.js | 5 +++--
src/effects/Glitch.js | 5 +++--
src/effects/Hexagon.js | 5 +++--
src/effects/Incinerate.js | 5 +++--
src/effects/Matrix.js | 5 +++--
src/effects/PaintBrush.js | 5 +++--
src/effects/PixelWheel.js | 5 +++--
src/effects/PixelWipe.js | 5 +++--
src/effects/Pixelate.js | 5 +++--
src/effects/Portal.js | 5 +++--
src/effects/SnapOfDisintegration.js | 5 +++--
src/effects/TRexAttack.js | 5 +++--
src/effects/TVEffect.js | 5 +++--
src/effects/TVGlitch.js | 5 +++--
src/effects/Wisps.js | 5 +++--
src/utils.js | 10 ++++++++++
23 files changed, 76 insertions(+), 45 deletions(-)
diff --git a/docs/how-to-create-new-effects.md b/docs/how-to-create-new-effects.md
index db50bdb..035e4cb 100644
--- a/docs/how-to-create-new-effects.md
+++ b/docs/how-to-create-new-effects.md
@@ -165,11 +165,11 @@ void main() {
"use strict";
-const GObject = imports.gi.GObject;
-
const _ = imports.gettext.domain("burn-my-windows").gettext;
-import { ShaderFactory } from "../ShaderFactory.js";
+import * as utils from "../utils.js";
+
+const ShaderFactory = await utils.importInShellOnly("./ShaderFactory.js");
//////////////////////////////////////////////////////////////////////////////////////////
// This effect ... //
diff --git a/src/effects/Apparition.js b/src/effects/Apparition.js
index 07f830a..9d5ea21 100644
--- a/src/effects/Apparition.js
+++ b/src/effects/Apparition.js
@@ -16,8 +16,9 @@
const _ = imports.gettext.domain('burn-my-windows').gettext;
-const ShaderFactory =
- typeof global !== 'undefined' ? (await import('../ShaderFactory.js'))?.default : null;
+import * as utils from '../utils.js';
+
+const ShaderFactory = await utils.importInShellOnly('./ShaderFactory.js');
//////////////////////////////////////////////////////////////////////////////////////////
// This effect hides the actor by violently sucking it into the void of magic. //
diff --git a/src/effects/BrokenGlass.js b/src/effects/BrokenGlass.js
index 5cc0f95..7b2928c 100644
--- a/src/effects/BrokenGlass.js
+++ b/src/effects/BrokenGlass.js
@@ -16,8 +16,9 @@
const _ = imports.gettext.domain('burn-my-windows').gettext;
-const ShaderFactory =
- typeof global !== 'undefined' ? (await import('../ShaderFactory.js'))?.default : null;
+import * as utils from '../utils.js';
+
+const ShaderFactory = await utils.importInShellOnly('./ShaderFactory.js');
//////////////////////////////////////////////////////////////////////////////////////////
// This effect shatters the window into pieces. For an explanation how this works, look //
diff --git a/src/effects/Doom.js b/src/effects/Doom.js
index be02ff6..2847cc7 100644
--- a/src/effects/Doom.js
+++ b/src/effects/Doom.js
@@ -16,8 +16,9 @@
const _ = imports.gettext.domain('burn-my-windows').gettext;
-const ShaderFactory =
- typeof global !== 'undefined' ? (await import('../ShaderFactory.js'))?.default : null;
+import * as utils from '../utils.js';
+
+const ShaderFactory = await utils.importInShellOnly('./ShaderFactory.js');
//////////////////////////////////////////////////////////////////////////////////////////
// This effect melts your windows. Inspired by the legendary screen transitions of the //
diff --git a/src/effects/EnergizeA.js b/src/effects/EnergizeA.js
index 2ee4535..3d91a01 100644
--- a/src/effects/EnergizeA.js
+++ b/src/effects/EnergizeA.js
@@ -16,8 +16,9 @@
const _ = imports.gettext.domain('burn-my-windows').gettext;
-const ShaderFactory =
- typeof global !== 'undefined' ? (await import('../ShaderFactory.js'))?.default : null;
+import * as utils from '../utils.js';
+
+const ShaderFactory = await utils.importInShellOnly('./ShaderFactory.js');
//////////////////////////////////////////////////////////////////////////////////////////
// This effect looks a bit like the transporter effect from TOS. //
diff --git a/src/effects/EnergizeB.js b/src/effects/EnergizeB.js
index 1d2be49..6a2354d 100644
--- a/src/effects/EnergizeB.js
+++ b/src/effects/EnergizeB.js
@@ -16,8 +16,9 @@
const _ = imports.gettext.domain('burn-my-windows').gettext;
-const ShaderFactory =
- typeof global !== 'undefined' ? (await import('../ShaderFactory.js'))?.default : null;
+import * as utils from '../utils.js';
+
+const ShaderFactory = await utils.importInShellOnly('./ShaderFactory.js');
//////////////////////////////////////////////////////////////////////////////////////////
// This effect looks a bit like the transporter effect from TNG. //
diff --git a/src/effects/Fire.js b/src/effects/Fire.js
index 10a2b54..b255ff0 100644
--- a/src/effects/Fire.js
+++ b/src/effects/Fire.js
@@ -18,8 +18,9 @@ import Gio from 'gi://Gio';
const _ = imports.gettext.domain('burn-my-windows').gettext;
-const ShaderFactory =
- typeof global !== 'undefined' ? (await import('../ShaderFactory.js'))?.default : null;
+import * as utils from '../utils.js';
+
+const ShaderFactory = await utils.importInShellOnly('./ShaderFactory.js');
//////////////////////////////////////////////////////////////////////////////////////////
// This effect is a homage to the good old Compiz days. However, it is implemented //
diff --git a/src/effects/Glide.js b/src/effects/Glide.js
index 2edf1d8..2c0c606 100644
--- a/src/effects/Glide.js
+++ b/src/effects/Glide.js
@@ -16,8 +16,9 @@
const _ = imports.gettext.domain('burn-my-windows').gettext;
-const ShaderFactory =
- typeof global !== 'undefined' ? (await import('../ShaderFactory.js'))?.default : null;
+import * as utils from '../utils.js';
+
+const ShaderFactory = await utils.importInShellOnly('./ShaderFactory.js');
//////////////////////////////////////////////////////////////////////////////////////////
// This very simple effect fades the window to transparency with subtle 3D effects. //
diff --git a/src/effects/Glitch.js b/src/effects/Glitch.js
index 767cb23..3483b51 100644
--- a/src/effects/Glitch.js
+++ b/src/effects/Glitch.js
@@ -16,8 +16,9 @@
const _ = imports.gettext.domain('burn-my-windows').gettext;
-const ShaderFactory =
- typeof global !== 'undefined' ? (await import('../ShaderFactory.js'))?.default : null;
+import * as utils from '../utils.js';
+
+const ShaderFactory = await utils.importInShellOnly('./ShaderFactory.js');
//////////////////////////////////////////////////////////////////////////////////////////
// This effect applies some intentional graphics issues to your windows. //
diff --git a/src/effects/Hexagon.js b/src/effects/Hexagon.js
index 9747897..9cc3c2b 100644
--- a/src/effects/Hexagon.js
+++ b/src/effects/Hexagon.js
@@ -16,8 +16,9 @@
const _ = imports.gettext.domain('burn-my-windows').gettext;
-const ShaderFactory =
- typeof global !== 'undefined' ? (await import('../ShaderFactory.js'))?.default : null;
+import * as utils from '../utils.js';
+
+const ShaderFactory = await utils.importInShellOnly('./ShaderFactory.js');
//////////////////////////////////////////////////////////////////////////////////////////
// This effect overlays a glowing hexagonal grid over the window. The grid cells then //
diff --git a/src/effects/Incinerate.js b/src/effects/Incinerate.js
index 9838db7..8fbffeb 100644
--- a/src/effects/Incinerate.js
+++ b/src/effects/Incinerate.js
@@ -16,8 +16,9 @@
const _ = imports.gettext.domain('burn-my-windows').gettext;
-const ShaderFactory =
- typeof global !== 'undefined' ? (await import('../ShaderFactory.js'))?.default : null;
+import * as utils from '../utils.js';
+
+const ShaderFactory = await utils.importInShellOnly('./ShaderFactory.js');
//////////////////////////////////////////////////////////////////////////////////////////
// This effect burns windows to ashes. The fire starts at a random position at the //
diff --git a/src/effects/Matrix.js b/src/effects/Matrix.js
index fbfd153..9a683e8 100644
--- a/src/effects/Matrix.js
+++ b/src/effects/Matrix.js
@@ -16,8 +16,9 @@
const _ = imports.gettext.domain('burn-my-windows').gettext;
-const ShaderFactory =
- typeof global !== 'undefined' ? (await import('../ShaderFactory.js'))?.default : null;
+import * as utils from '../utils.js';
+
+const ShaderFactory = await utils.importInShellOnly('./ShaderFactory.js');
//////////////////////////////////////////////////////////////////////////////////////////
// The Matrix shader multiplies a grid of random letters with some gradients which are //
diff --git a/src/effects/PaintBrush.js b/src/effects/PaintBrush.js
index 1f6ab7a..59a6e49 100644
--- a/src/effects/PaintBrush.js
+++ b/src/effects/PaintBrush.js
@@ -16,8 +16,9 @@
const _ = imports.gettext.domain('burn-my-windows').gettext;
-const ShaderFactory =
- typeof global !== 'undefined' ? (await import('../ShaderFactory.js'))?.default : null;
+import * as utils from '../utils.js';
+
+const ShaderFactory = await utils.importInShellOnly('./ShaderFactory.js');
//////////////////////////////////////////////////////////////////////////////////////////
// This effect paints your windows with a thick paint brush. //
diff --git a/src/effects/PixelWheel.js b/src/effects/PixelWheel.js
index 4983e4c..06d0b05 100644
--- a/src/effects/PixelWheel.js
+++ b/src/effects/PixelWheel.js
@@ -16,8 +16,9 @@
const _ = imports.gettext.domain('burn-my-windows').gettext;
-const ShaderFactory =
- typeof global !== 'undefined' ? (await import('../ShaderFactory.js'))?.default : null;
+import * as utils from '../utils.js';
+
+const ShaderFactory = await utils.importInShellOnly('./ShaderFactory.js');
//////////////////////////////////////////////////////////////////////////////////////////
// This simple effect pixelates the window texture and hides the pixels in a wheel-like //
diff --git a/src/effects/PixelWipe.js b/src/effects/PixelWipe.js
index 35cdf9c..50077e2 100644
--- a/src/effects/PixelWipe.js
+++ b/src/effects/PixelWipe.js
@@ -16,8 +16,9 @@
const _ = imports.gettext.domain('burn-my-windows').gettext;
-const ShaderFactory =
- typeof global !== 'undefined' ? (await import('../ShaderFactory.js'))?.default : null;
+import * as utils from '../utils.js';
+
+const ShaderFactory = await utils.importInShellOnly('./ShaderFactory.js');
//////////////////////////////////////////////////////////////////////////////////////////
// This effect pixelates the window texture and hides the pixels radially, starting //
diff --git a/src/effects/Pixelate.js b/src/effects/Pixelate.js
index 0cc0c31..dee05c2 100644
--- a/src/effects/Pixelate.js
+++ b/src/effects/Pixelate.js
@@ -16,8 +16,9 @@
const _ = imports.gettext.domain('burn-my-windows').gettext;
-const ShaderFactory =
- typeof global !== 'undefined' ? (await import('../ShaderFactory.js'))?.default : null;
+import * as utils from '../utils.js';
+
+const ShaderFactory = await utils.importInShellOnly('./ShaderFactory.js');
//////////////////////////////////////////////////////////////////////////////////////////
// This very simple effect pixelates the window texture and randomly hides pixels until //
diff --git a/src/effects/Portal.js b/src/effects/Portal.js
index e22cbce..5e9d3ce 100644
--- a/src/effects/Portal.js
+++ b/src/effects/Portal.js
@@ -16,8 +16,9 @@
const _ = imports.gettext.domain('burn-my-windows').gettext;
-const ShaderFactory =
- typeof global !== 'undefined' ? (await import('../ShaderFactory.js'))?.default : null;
+import * as utils from '../utils.js';
+
+const ShaderFactory = await utils.importInShellOnly('./ShaderFactory.js');
//////////////////////////////////////////////////////////////////////////////////////////
// This ridiculous effect teleports your windows from and to alternative dimensions. //
diff --git a/src/effects/SnapOfDisintegration.js b/src/effects/SnapOfDisintegration.js
index 5af84c1..6e7002f 100644
--- a/src/effects/SnapOfDisintegration.js
+++ b/src/effects/SnapOfDisintegration.js
@@ -16,8 +16,9 @@
const _ = imports.gettext.domain('burn-my-windows').gettext;
-const ShaderFactory =
- typeof global !== 'undefined' ? (await import('../ShaderFactory.js'))?.default : null;
+import * as utils from '../utils.js';
+
+const ShaderFactory = await utils.importInShellOnly('./ShaderFactory.js');
//////////////////////////////////////////////////////////////////////////////////////////
// This effects dissolves your windows into a cloud of dust. For this, it uses an //
diff --git a/src/effects/TRexAttack.js b/src/effects/TRexAttack.js
index 44ae5a1..1e8cfd0 100644
--- a/src/effects/TRexAttack.js
+++ b/src/effects/TRexAttack.js
@@ -16,8 +16,9 @@
const _ = imports.gettext.domain('burn-my-windows').gettext;
-const ShaderFactory =
- typeof global !== 'undefined' ? (await import('../ShaderFactory.js'))?.default : null;
+import * as utils from '../utils.js';
+
+const ShaderFactory = await utils.importInShellOnly('./ShaderFactory.js');
//////////////////////////////////////////////////////////////////////////////////////////
// This effect tears your windows apart with a series of violent scratches! //
diff --git a/src/effects/TVEffect.js b/src/effects/TVEffect.js
index 846b900..713ea15 100644
--- a/src/effects/TVEffect.js
+++ b/src/effects/TVEffect.js
@@ -16,8 +16,9 @@
const _ = imports.gettext.domain('burn-my-windows').gettext;
-const ShaderFactory =
- typeof global !== 'undefined' ? (await import('../ShaderFactory.js'))?.default : null;
+import * as utils from '../utils.js';
+
+const ShaderFactory = await utils.importInShellOnly('./ShaderFactory.js');
//////////////////////////////////////////////////////////////////////////////////////////
// This effect hides the actor by making it first transparent from top and bottom //
diff --git a/src/effects/TVGlitch.js b/src/effects/TVGlitch.js
index 9c7345b..083be22 100644
--- a/src/effects/TVGlitch.js
+++ b/src/effects/TVGlitch.js
@@ -16,8 +16,9 @@
const _ = imports.gettext.domain('burn-my-windows').gettext;
-const ShaderFactory =
- typeof global !== 'undefined' ? (await import('../ShaderFactory.js'))?.default : null;
+import * as utils from '../utils.js';
+
+const ShaderFactory = await utils.importInShellOnly('./ShaderFactory.js');
//////////////////////////////////////////////////////////////////////////////////////////
// This effect combines the Glitch and the TV Effect. Credits go to Kurt Wilson //
diff --git a/src/effects/Wisps.js b/src/effects/Wisps.js
index e59c083..478d487 100644
--- a/src/effects/Wisps.js
+++ b/src/effects/Wisps.js
@@ -16,8 +16,9 @@
const _ = imports.gettext.domain('burn-my-windows').gettext;
-const ShaderFactory =
- typeof global !== 'undefined' ? (await import('../ShaderFactory.js'))?.default : null;
+import * as utils from '../utils.js';
+
+const ShaderFactory = await utils.importInShellOnly('./ShaderFactory.js');
//////////////////////////////////////////////////////////////////////////////////////////
// This effect lets your windows be carried to the realm of dreams by some little //
diff --git a/src/utils.js b/src/utils.js
index 4018c26..b46df40 100644
--- a/src/utils.js
+++ b/src/utils.js
@@ -35,6 +35,16 @@ export function debug(message) {
console.log('[' + stack[0].slice(extensionRoot) + '] ' + message);
}
+// This method can be used to import a module in the GNOME Shell process only. This
+// is useful if you want to use a module in extension.js, but not in the preferences
+// process. This method returns null if it is called in the preferences process.
+export async function importInShellOnly(module) {
+ if (typeof global !== 'undefined') {
+ return (await import(module)).default;
+ }
+ return null;
+}
+
// Reads the contents of a file contained in the global resources archive. The data
// is returned as a string.
export function getStringResource(path) {
From 34a64e10fedf77737cd0f5f5f540dcdba02483eb Mon Sep 17 00:00:00 2001
From: Simon Schneegans
Date: Sat, 9 Sep 2023 06:09:40 +0200
Subject: [PATCH 20/26] :beetle: Fix fire presets
---
src/effects/Fire.js | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/src/effects/Fire.js b/src/effects/Fire.js
index b255ff0..d6b3720 100644
--- a/src/effects/Fire.js
+++ b/src/effects/Fire.js
@@ -116,8 +116,8 @@ export default class Effect {
dialog.bindColorButton('fire-color-5');
// Connect the buttons only once. The bindPreferences can be called multiple times...
- if (!this._isConnected) {
- this._isConnected = true;
+ if (!Effect._isConnected) {
+ Effect._isConnected = true;
// The fire-gradient-reset button needs to be bound explicitly.
dialog.getBuilder().get_object('reset-fire-colors').connect('clicked', () => {
@@ -129,7 +129,7 @@ export default class Effect {
});
// Initialize the fire-preset dropdown.
- this._createFirePresets(dialog);
+ Effect._createFirePresets(dialog);
}
}
@@ -145,7 +145,7 @@ export default class Effect {
// ----------------------------------------------------------------------- private stuff
// This populates the preset dropdown menu for the fire options.
- _createFirePresets(dialog) {
+ static _createFirePresets(dialog) {
dialog.getBuilder().get_object('fire-prefs').connect('realize', (widget) => {
const presets = [
{
From 0ccbb31d06f78a0b93d04d2eec2f2346be353f87 Mon Sep 17 00:00:00 2001
From: Simon Schneegans
Date: Sat, 9 Sep 2023 06:17:58 +0200
Subject: [PATCH 21/26] :recycle: Use more dynamic imports
---
docs/how-to-create-new-effects.md | 3 +++
src/effects/Apparition.js | 3 +++
src/effects/BrokenGlass.js | 10 ++++++----
src/effects/Doom.js | 3 +++
src/effects/EnergizeA.js | 9 ++++-----
src/effects/EnergizeB.js | 9 ++++-----
src/effects/Fire.js | 9 ++++-----
src/effects/Glide.js | 3 +++
src/effects/Glitch.js | 9 ++++-----
src/effects/Hexagon.js | 9 ++++-----
src/effects/Incinerate.js | 8 ++++----
src/effects/Matrix.js | 10 ++++++----
src/effects/PaintBrush.js | 10 ++++++----
src/effects/PixelWheel.js | 3 +++
src/effects/PixelWipe.js | 3 +++
src/effects/Pixelate.js | 3 +++
src/effects/Portal.js | 9 ++++-----
src/effects/SnapOfDisintegration.js | 10 ++++++----
src/effects/TRexAttack.js | 10 ++++++----
src/effects/TVEffect.js | 9 ++++-----
src/effects/TVGlitch.js | 9 ++++-----
src/effects/Wisps.js | 9 ++++-----
22 files changed, 91 insertions(+), 69 deletions(-)
diff --git a/docs/how-to-create-new-effects.md b/docs/how-to-create-new-effects.md
index 035e4cb..606cb2d 100644
--- a/docs/how-to-create-new-effects.md
+++ b/docs/how-to-create-new-effects.md
@@ -169,6 +169,9 @@ 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
+// preferences process. The preferences process does not create any shader instances, it
+// only uses the static metadata of the effect.
const ShaderFactory = await utils.importInShellOnly("./ShaderFactory.js");
//////////////////////////////////////////////////////////////////////////////////////////
diff --git a/src/effects/Apparition.js b/src/effects/Apparition.js
index 9d5ea21..46665f6 100644
--- a/src/effects/Apparition.js
+++ b/src/effects/Apparition.js
@@ -18,6 +18,9 @@ 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
+// preferences process. The preferences process does not create any shader instances, it
+// only uses the static metadata of the effect.
const ShaderFactory = await utils.importInShellOnly('./ShaderFactory.js');
//////////////////////////////////////////////////////////////////////////////////////////
diff --git a/src/effects/BrokenGlass.js b/src/effects/BrokenGlass.js
index 7b2928c..7239294 100644
--- a/src/effects/BrokenGlass.js
+++ b/src/effects/BrokenGlass.js
@@ -18,7 +18,13 @@ 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
+// preferences process. They are used only in the creator function of the ShaderFactory
+// which is only called within GNOME Shell's process.
const ShaderFactory = await utils.importInShellOnly('./ShaderFactory.js');
+const Clutter = await utils.importInShellOnly('gi://Clutter');
+const GdkPixbuf = await utils.importInShellOnly('gi://GdkPixbuf');
+const Cogl = await utils.importInShellOnly('gi://Cogl');
//////////////////////////////////////////////////////////////////////////////////////////
// This effect shatters the window into pieces. For an explanation how this works, look //
@@ -47,10 +53,6 @@ export default class Effect {
// newly created shader instance.
constructor() {
this.shaderFactory = new ShaderFactory(Effect.getNick(), (shader) => {
- // We import these modules in this function as they are not available in the
- // preferences process. This callback is only called within GNOME Shell's process.
- const {Clutter, GdkPixbuf, Cogl} = imports.gi;
-
// Create the texture in the first call.
if (!this._shardTexture) {
const shardData = GdkPixbuf.Pixbuf.new_from_resource('/img/shards.png');
diff --git a/src/effects/Doom.js b/src/effects/Doom.js
index 2847cc7..7a782d5 100644
--- a/src/effects/Doom.js
+++ b/src/effects/Doom.js
@@ -18,6 +18,9 @@ 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
+// preferences process. The preferences process does not create any shader instances, it
+// only uses the static metadata of the effect.
const ShaderFactory = await utils.importInShellOnly('./ShaderFactory.js');
//////////////////////////////////////////////////////////////////////////////////////////
diff --git a/src/effects/EnergizeA.js b/src/effects/EnergizeA.js
index 3d91a01..6476b3e 100644
--- a/src/effects/EnergizeA.js
+++ b/src/effects/EnergizeA.js
@@ -18,7 +18,11 @@ 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
+// preferences process. They are used only in the creator function of the ShaderFactory
+// which is only called within GNOME Shell's process.
const ShaderFactory = await utils.importInShellOnly('./ShaderFactory.js');
+const Clutter = await utils.importInShellOnly('gi://Clutter');
//////////////////////////////////////////////////////////////////////////////////////////
// This effect looks a bit like the transporter effect from TOS. //
@@ -35,11 +39,6 @@ export default class Effect {
// newly created shader instance.
constructor() {
this.shaderFactory = new ShaderFactory(Effect.getNick(), (shader) => {
- // We import Clutter in this function as it is not available in the preferences
- // process. This creator function of the ShaderFactory is only called within GNOME
- // Shell's process.
- const Clutter = imports.gi.Clutter;
-
// Store uniform locations of newly created shaders.
shader._uColor = shader.get_uniform_location('uColor');
shader._uScale = shader.get_uniform_location('uScale');
diff --git a/src/effects/EnergizeB.js b/src/effects/EnergizeB.js
index 6a2354d..d2649e9 100644
--- a/src/effects/EnergizeB.js
+++ b/src/effects/EnergizeB.js
@@ -18,7 +18,11 @@ 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
+// preferences process. They are used only in the creator function of the ShaderFactory
+// which is only called within GNOME Shell's process.
const ShaderFactory = await utils.importInShellOnly('./ShaderFactory.js');
+const Clutter = await utils.importInShellOnly('gi://Clutter');
//////////////////////////////////////////////////////////////////////////////////////////
// This effect looks a bit like the transporter effect from TNG. //
@@ -35,11 +39,6 @@ export default class Effect {
// newly created shader instance.
constructor() {
this.shaderFactory = new ShaderFactory(Effect.getNick(), (shader) => {
- // We import Clutter in this function as it is not available in the preferences
- // process. This creator function of the ShaderFactory is only called within GNOME
- // Shell's process.
- const Clutter = imports.gi.Clutter;
-
// Store uniform locations of newly created shaders.
shader._uColor = shader.get_uniform_location('uColor');
shader._uScale = shader.get_uniform_location('uScale');
diff --git a/src/effects/Fire.js b/src/effects/Fire.js
index d6b3720..34d1771 100644
--- a/src/effects/Fire.js
+++ b/src/effects/Fire.js
@@ -20,7 +20,11 @@ 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
+// preferences process. They are used only in the creator function of the ShaderFactory
+// which is only called within GNOME Shell's process.
const ShaderFactory = await utils.importInShellOnly('./ShaderFactory.js');
+const Clutter = await utils.importInShellOnly('gi://Clutter');
//////////////////////////////////////////////////////////////////////////////////////////
// This effect is a homage to the good old Compiz days. However, it is implemented //
@@ -41,11 +45,6 @@ export default class Effect {
// newly created shader instance.
constructor() {
this.shaderFactory = new ShaderFactory(Effect.getNick(), (shader) => {
- // We import Clutter in this function as it is not available in the preferences
- // process. This creator function of the ShaderFactory is only called within GNOME
- // Shell's process.
- const Clutter = imports.gi.Clutter;
-
// Store all uniform locations.
shader._uGradient = [
shader.get_uniform_location('uGradient1'),
diff --git a/src/effects/Glide.js b/src/effects/Glide.js
index 2c0c606..a567808 100644
--- a/src/effects/Glide.js
+++ b/src/effects/Glide.js
@@ -18,6 +18,9 @@ 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
+// preferences process. The preferences process does not create any shader instances, it
+// only uses the static metadata of the effect.
const ShaderFactory = await utils.importInShellOnly('./ShaderFactory.js');
//////////////////////////////////////////////////////////////////////////////////////////
diff --git a/src/effects/Glitch.js b/src/effects/Glitch.js
index 3483b51..8e675ea 100644
--- a/src/effects/Glitch.js
+++ b/src/effects/Glitch.js
@@ -18,7 +18,11 @@ 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
+// preferences process. They are used only in the creator function of the ShaderFactory
+// which is only called within GNOME Shell's process.
const ShaderFactory = await utils.importInShellOnly('./ShaderFactory.js');
+const Clutter = await utils.importInShellOnly('gi://Clutter');
//////////////////////////////////////////////////////////////////////////////////////////
// This effect applies some intentional graphics issues to your windows. //
@@ -35,11 +39,6 @@ export default class Effect {
// newly created shader instance.
constructor() {
this.shaderFactory = new ShaderFactory(Effect.getNick(), (shader) => {
- // We import Clutter in this function as it is not available in the preferences
- // process. This creator function of the ShaderFactory is only called within GNOME
- // Shell's process.
- const Clutter = imports.gi.Clutter;
-
// Store uniform locations of newly created shaders.
shader._uSeed = shader.get_uniform_location('uSeed');
shader._uColor = shader.get_uniform_location('uColor');
diff --git a/src/effects/Hexagon.js b/src/effects/Hexagon.js
index 9cc3c2b..ac39669 100644
--- a/src/effects/Hexagon.js
+++ b/src/effects/Hexagon.js
@@ -18,7 +18,11 @@ 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
+// preferences process. They are used only in the creator function of the ShaderFactory
+// which is only called within GNOME Shell's process.
const ShaderFactory = await utils.importInShellOnly('./ShaderFactory.js');
+const Clutter = await utils.importInShellOnly('gi://Clutter');
//////////////////////////////////////////////////////////////////////////////////////////
// This effect overlays a glowing hexagonal grid over the window. The grid cells then //
@@ -36,11 +40,6 @@ export default class Effect {
// newly created shader instance.
constructor() {
this.shaderFactory = new ShaderFactory(Effect.getNick(), (shader) => {
- // We import Clutter in this function as it is not available in the preferences
- // process. This creator function of the ShaderFactory is only called within GNOME
- // Shell's process.
- const Clutter = imports.gi.Clutter;
-
// Store uniform locations of newly created shaders.
shader._uAdditiveBlending = shader.get_uniform_location('uAdditiveBlending');
shader._uSeed = shader.get_uniform_location('uSeed');
diff --git a/src/effects/Incinerate.js b/src/effects/Incinerate.js
index 8fbffeb..cb52e8c 100644
--- a/src/effects/Incinerate.js
+++ b/src/effects/Incinerate.js
@@ -18,7 +18,11 @@ 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
+// preferences process. They are used only in the creator function of the ShaderFactory
+// which is only called within GNOME Shell's process.
const ShaderFactory = await utils.importInShellOnly('./ShaderFactory.js');
+const Clutter = await utils.importInShellOnly('gi://Clutter');
//////////////////////////////////////////////////////////////////////////////////////////
// This effect burns windows to ashes. The fire starts at a random position at the //
@@ -36,10 +40,6 @@ export default class Effect {
// newly created shader instance.
constructor() {
this.shaderFactory = new ShaderFactory(Effect.getNick(), (shader) => {
- // We import these modules in this function as they are not available in the
- // preferences process. This callback is only called within GNOME Shell's process.
- const {Clutter} = imports.gi;
-
// Store uniform locations of newly created shaders.
shader._uSeed = shader.get_uniform_location('uSeed');
shader._uColor = shader.get_uniform_location('uColor');
diff --git a/src/effects/Matrix.js b/src/effects/Matrix.js
index 9a683e8..f8f2559 100644
--- a/src/effects/Matrix.js
+++ b/src/effects/Matrix.js
@@ -18,7 +18,13 @@ 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
+// preferences process. They are used only in the creator function of the ShaderFactory
+// which is only called within GNOME Shell's process.
const ShaderFactory = await utils.importInShellOnly('./ShaderFactory.js');
+const Clutter = await utils.importInShellOnly('gi://Clutter');
+const GdkPixbuf = await utils.importInShellOnly('gi://GdkPixbuf');
+const Cogl = await utils.importInShellOnly('gi://Cogl');
//////////////////////////////////////////////////////////////////////////////////////////
// The Matrix shader multiplies a grid of random letters with some gradients which are //
@@ -39,10 +45,6 @@ export default class Effect {
// newly created shader instance.
constructor() {
this.shaderFactory = new ShaderFactory(Effect.getNick(), (shader) => {
- // We import these modules in this function as they are not available in the
- // preferences process. This callback is only called within GNOME Shell's process.
- const {Clutter, GdkPixbuf, Cogl} = imports.gi;
-
// Create the texture in the first call.
if (!this._fontTexture) {
const fontData = GdkPixbuf.Pixbuf.new_from_resource('/img/matrixFont.png');
diff --git a/src/effects/PaintBrush.js b/src/effects/PaintBrush.js
index 59a6e49..5d0d1ec 100644
--- a/src/effects/PaintBrush.js
+++ b/src/effects/PaintBrush.js
@@ -18,7 +18,13 @@ 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
+// preferences process. They are used only in the creator function of the ShaderFactory
+// which is only called within GNOME Shell's process.
const ShaderFactory = await utils.importInShellOnly('./ShaderFactory.js');
+const Clutter = await utils.importInShellOnly('gi://Clutter');
+const GdkPixbuf = await utils.importInShellOnly('gi://GdkPixbuf');
+const Cogl = await utils.importInShellOnly('gi://Cogl');
//////////////////////////////////////////////////////////////////////////////////////////
// This effect paints your windows with a thick paint brush. //
@@ -37,10 +43,6 @@ export default class Effect {
// newly created shader instance.
constructor() {
this.shaderFactory = new ShaderFactory(Effect.getNick(), (shader) => {
- // We import these modules in this function as they are not available in the
- // preferences process. This callback is only called within GNOME Shell's process.
- const {Clutter, GdkPixbuf, Cogl} = imports.gi;
-
// Create the texture in the first call.
if (!this._brushTexture) {
const brushData = GdkPixbuf.Pixbuf.new_from_resource('/img/brush.png');
diff --git a/src/effects/PixelWheel.js b/src/effects/PixelWheel.js
index 06d0b05..72352fa 100644
--- a/src/effects/PixelWheel.js
+++ b/src/effects/PixelWheel.js
@@ -18,6 +18,9 @@ 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
+// preferences process. The preferences process does not create any shader instances, it
+// only uses the static metadata of the effect.
const ShaderFactory = await utils.importInShellOnly('./ShaderFactory.js');
//////////////////////////////////////////////////////////////////////////////////////////
diff --git a/src/effects/PixelWipe.js b/src/effects/PixelWipe.js
index 50077e2..057af94 100644
--- a/src/effects/PixelWipe.js
+++ b/src/effects/PixelWipe.js
@@ -18,6 +18,9 @@ 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
+// preferences process. The preferences process does not create any shader instances, it
+// only uses the static metadata of the effect.
const ShaderFactory = await utils.importInShellOnly('./ShaderFactory.js');
//////////////////////////////////////////////////////////////////////////////////////////
diff --git a/src/effects/Pixelate.js b/src/effects/Pixelate.js
index dee05c2..406ad23 100644
--- a/src/effects/Pixelate.js
+++ b/src/effects/Pixelate.js
@@ -18,6 +18,9 @@ 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
+// preferences process. The preferences process does not create any shader instances, it
+// only uses the static metadata of the effect.
const ShaderFactory = await utils.importInShellOnly('./ShaderFactory.js');
//////////////////////////////////////////////////////////////////////////////////////////
diff --git a/src/effects/Portal.js b/src/effects/Portal.js
index 5e9d3ce..48a8e58 100644
--- a/src/effects/Portal.js
+++ b/src/effects/Portal.js
@@ -18,7 +18,11 @@ 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
+// preferences process. They are used only in the creator function of the ShaderFactory
+// which is only called within GNOME Shell's process.
const ShaderFactory = await utils.importInShellOnly('./ShaderFactory.js');
+const Clutter = await utils.importInShellOnly('gi://Clutter');
//////////////////////////////////////////////////////////////////////////////////////////
// This ridiculous effect teleports your windows from and to alternative dimensions. //
@@ -36,11 +40,6 @@ export default class Effect {
// newly created shader instance.
constructor() {
this.shaderFactory = new ShaderFactory(Effect.getNick(), (shader) => {
- // We import Clutter in this function as it is not available in the preferences
- // process. This creator function of the ShaderFactory is only called within GNOME
- // Shell's process.
- const Clutter = imports.gi.Clutter;
-
// Store uniform locations of newly created shaders.
shader._uSeed = shader.get_uniform_location('uSeed');
shader._uColor = shader.get_uniform_location('uColor');
diff --git a/src/effects/SnapOfDisintegration.js b/src/effects/SnapOfDisintegration.js
index 6e7002f..f8f595d 100644
--- a/src/effects/SnapOfDisintegration.js
+++ b/src/effects/SnapOfDisintegration.js
@@ -18,7 +18,13 @@ 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
+// preferences process. They are used only in the creator function of the ShaderFactory
+// which is only called within GNOME Shell's process.
const ShaderFactory = await utils.importInShellOnly('./ShaderFactory.js');
+const Clutter = await utils.importInShellOnly('gi://Clutter');
+const GdkPixbuf = await utils.importInShellOnly('gi://GdkPixbuf');
+const Cogl = await utils.importInShellOnly('gi://Cogl');
//////////////////////////////////////////////////////////////////////////////////////////
// This effects dissolves your windows into a cloud of dust. For this, it uses an //
@@ -41,10 +47,6 @@ export default class Effect {
// newly created shader instance.
constructor() {
this.shaderFactory = new ShaderFactory(Effect.getNick(), (shader) => {
- // We import these modules in this function as they are not available in the
- // preferences process. This callback is only called within GNOME Shell's process.
- const {Clutter, GdkPixbuf, Cogl} = imports.gi;
-
// Create the texture in the first call.
if (!this._dustTexture) {
const dustData = GdkPixbuf.Pixbuf.new_from_resource('/img/dust.png');
diff --git a/src/effects/TRexAttack.js b/src/effects/TRexAttack.js
index 1e8cfd0..aa94a9f 100644
--- a/src/effects/TRexAttack.js
+++ b/src/effects/TRexAttack.js
@@ -18,7 +18,13 @@ 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
+// preferences process. They are used only in the creator function of the ShaderFactory
+// which is only called within GNOME Shell's process.
const ShaderFactory = await utils.importInShellOnly('./ShaderFactory.js');
+const Clutter = await utils.importInShellOnly('gi://Clutter');
+const GdkPixbuf = await utils.importInShellOnly('gi://GdkPixbuf');
+const Cogl = await utils.importInShellOnly('gi://Cogl');
//////////////////////////////////////////////////////////////////////////////////////////
// This effect tears your windows apart with a series of violent scratches! //
@@ -37,10 +43,6 @@ export default class Effect {
// newly created shader instance.
constructor() {
this.shaderFactory = new ShaderFactory(Effect.getNick(), (shader) => {
- // We import these modules in this function as they are not available in the
- // preferences process. This callback is only called within GNOME Shell's process.
- const {Clutter, GdkPixbuf, Cogl} = imports.gi;
-
// Create the texture in the first call.
if (!this._clawTexture) {
const clawData = GdkPixbuf.Pixbuf.new_from_resource('/img/claws.png');
diff --git a/src/effects/TVEffect.js b/src/effects/TVEffect.js
index 713ea15..5dd2eae 100644
--- a/src/effects/TVEffect.js
+++ b/src/effects/TVEffect.js
@@ -18,7 +18,11 @@ 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
+// preferences process. They are used only in the creator function of the ShaderFactory
+// which is only called within GNOME Shell's process.
const ShaderFactory = await utils.importInShellOnly('./ShaderFactory.js');
+const Clutter = await utils.importInShellOnly('gi://Clutter');
//////////////////////////////////////////////////////////////////////////////////////////
// This effect hides the actor by making it first transparent from top and bottom //
@@ -37,11 +41,6 @@ export default class Effect {
// newly created shader instance.
constructor() {
this.shaderFactory = new ShaderFactory(Effect.getNick(), (shader) => {
- // We import Clutter in this function as it is not available in the preferences
- // process. This creator function of the ShaderFactory is only called within GNOME
- // Shell's process.
- const Clutter = imports.gi.Clutter;
-
// Store uniform locations of newly created shaders.
shader._uColor = shader.get_uniform_location('uColor');
diff --git a/src/effects/TVGlitch.js b/src/effects/TVGlitch.js
index 083be22..7082d31 100644
--- a/src/effects/TVGlitch.js
+++ b/src/effects/TVGlitch.js
@@ -18,7 +18,11 @@ 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
+// preferences process. They are used only in the creator function of the ShaderFactory
+// which is only called within GNOME Shell's process.
const ShaderFactory = await utils.importInShellOnly('./ShaderFactory.js');
+const Clutter = await utils.importInShellOnly('gi://Clutter');
//////////////////////////////////////////////////////////////////////////////////////////
// This effect combines the Glitch and the TV Effect. Credits go to Kurt Wilson //
@@ -36,11 +40,6 @@ export default class Effect {
// newly created shader instance.
constructor() {
this.shaderFactory = new ShaderFactory(Effect.getNick(), (shader) => {
- // We import Clutter in this function as it is not available in the preferences
- // process. This creator function of the ShaderFactory is only called within GNOME
- // Shell's process.
- const Clutter = imports.gi.Clutter;
-
// Store uniform locations of newly created shaders.
shader._uSeed = shader.get_uniform_location('uSeed');
shader._uColor = shader.get_uniform_location('uColor');
diff --git a/src/effects/Wisps.js b/src/effects/Wisps.js
index 478d487..5eb466c 100644
--- a/src/effects/Wisps.js
+++ b/src/effects/Wisps.js
@@ -18,7 +18,11 @@ 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
+// preferences process. They are used only in the creator function of the ShaderFactory
+// which is only called within GNOME Shell's process.
const ShaderFactory = await utils.importInShellOnly('./ShaderFactory.js');
+const Clutter = await utils.importInShellOnly('gi://Clutter');
//////////////////////////////////////////////////////////////////////////////////////////
// This effect lets your windows be carried to the realm of dreams by some little //
@@ -36,11 +40,6 @@ export default class Effect {
// newly created shader instance.
constructor() {
this.shaderFactory = new ShaderFactory(Effect.getNick(), (shader) => {
- // We import Clutter in this function as it is not available in the preferences
- // process. This creator function of the ShaderFactory is only called within GNOME
- // Shell's process.
- const Clutter = imports.gi.Clutter;
-
// Store uniform locations of newly created shaders.
shader._uSeed = shader.get_uniform_location('uSeed');
shader._uScale = shader.get_uniform_location('uScale');
From 734530fdab98ba8369f6b698d0ff46f3a83c172e Mon Sep 17 00:00:00 2001
From: Simon Schneegans
Date: Sat, 9 Sep 2023 06:46:09 +0200
Subject: [PATCH 22/26] :wrench: Use dynamic imports for gettext
---
docs/how-to-create-new-effects.md | 4 ++--
src/effects/Apparition.js | 4 ++--
src/effects/BrokenGlass.js | 4 ++--
src/effects/Doom.js | 5 ++---
src/effects/EnergizeA.js | 4 ++--
src/effects/EnergizeB.js | 4 ++--
src/effects/Fire.js | 4 ++--
src/effects/Glide.js | 4 ++--
src/effects/Glitch.js | 4 ++--
src/effects/Hexagon.js | 4 ++--
src/effects/Incinerate.js | 4 ++--
src/effects/Matrix.js | 4 ++--
src/effects/PaintBrush.js | 4 ++--
src/effects/PixelWheel.js | 4 ++--
src/effects/PixelWipe.js | 4 ++--
src/effects/Pixelate.js | 4 ++--
src/effects/Portal.js | 4 ++--
src/effects/SnapOfDisintegration.js | 4 ++--
src/effects/TRexAttack.js | 4 ++--
src/effects/TVEffect.js | 4 ++--
src/effects/TVGlitch.js | 4 ++--
src/effects/Wisps.js | 4 ++--
src/utils.js | 20 ++++++++++++++++++++
23 files changed, 64 insertions(+), 45 deletions(-)
diff --git a/docs/how-to-create-new-effects.md b/docs/how-to-create-new-effects.md
index 606cb2d..36a8aac 100644
--- a/docs/how-to-create-new-effects.md
+++ b/docs/how-to-create-new-effects.md
@@ -165,8 +165,6 @@ void main() {
"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
@@ -174,6 +172,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 ... //
// <- Please add a description of your effect here -> //
diff --git a/src/effects/Apparition.js b/src/effects/Apparition.js
index 46665f6..f770e71 100644
--- a/src/effects/Apparition.js
+++ b/src/effects/Apparition.js
@@ -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. //
//////////////////////////////////////////////////////////////////////////////////////////
diff --git a/src/effects/BrokenGlass.js b/src/effects/BrokenGlass.js
index 7239294..f31efb7 100644
--- a/src/effects/BrokenGlass.js
+++ b/src/effects/BrokenGlass.js
@@ -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 //
diff --git a/src/effects/Doom.js b/src/effects/Doom.js
index 7a782d5..7afa97c 100644
--- a/src/effects/Doom.js
+++ b/src/effects/Doom.js
@@ -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/
Date: Sat, 9 Sep 2023 06:55:32 +0200
Subject: [PATCH 23/26] :fire: Remove unused method
---
src/utils.js | 10 ----------
1 file changed, 10 deletions(-)
diff --git a/src/utils.js b/src/utils.js
index 8a4731e..a0c146a 100644
--- a/src/utils.js
+++ b/src/utils.js
@@ -45,16 +45,6 @@ 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() {
From e62a9cdf8506d2a49e947e07b300ca314b6a1037 Mon Sep 17 00:00:00 2001
From: Simon Schneegans
Date: Sat, 9 Sep 2023 12:33:34 +0200
Subject: [PATCH 24/26] :memo: Add branch hint
---
README.md | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/README.md b/README.md
index 0a560a2..27dad22 100644
--- a/README.md
+++ b/README.md
@@ -173,6 +173,12 @@ git clone https://github.com/Schneegans/Burn-My-Windows.git
cd Burn-My-Windows
```
+If your GNOME Shell version is <= 45, you will have to checkout the `gnome-3.36-44` branch:
+
+```bash
+git checkout gnome-3.36-44
+```
+
Now you will have to install the extension.
The `make` command below compiles the locales, schemas and resources, creates a zip file of the extension and finally installs it with the `gnome-extensions` tool.
From 8ec804bc86aa18ea274a8e34743d43434f64085d Mon Sep 17 00:00:00 2001
From: Simon Schneegans
Date: Sat, 9 Sep 2023 12:33:59 +0200
Subject: [PATCH 25/26] :tada: Set release date
---
docs/changelog.md | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/docs/changelog.md b/docs/changelog.md
index 51dfff1..b43edb2 100644
--- a/docs/changelog.md
+++ b/docs/changelog.md
@@ -7,7 +7,7 @@ SPDX-License-Identifier: CC-BY-4.0
## [Burn My Windows 38](https://github.com/schneegans/Burn-My-Windows/releases/tag/v38)
-**Release Date:** TBD
+**Release Date:** 2023-09-09
#### Major Changes
From d6120de2b96543c6da0f75be15b6c3d514959196 Mon Sep 17 00:00:00 2001
From: Simon Schneegans
Date: Sat, 9 Sep 2023 12:34:35 +0200
Subject: [PATCH 26/26] :sparkles: Format README
---
README.md | 125 ++++++++++++++++++++++++++----------------------------
1 file changed, 60 insertions(+), 65 deletions(-)
diff --git a/README.md b/README.md
index 27dad22..c05f60e 100644
--- a/README.md
+++ b/README.md
@@ -24,30 +24,30 @@ This extension is not only more useless than the cube, but it is also much more
**🖼️ The wallpapers used in the previews below were all generated using AI and are available in [this GitHub repository](https://github.com/Schneegans/ai-wallpapers).**
-Effect | Preview
------|--------
-**Apparition**
This effect hides your windows by violently sucking them into the void of magic! |
-**Broken Glass**
Shatter your windows into a shower sharp shards! This effect can be configured so that the shards fly away from your mouse pointer position!|
-**Doom**
Melt your windows. Inspired by the legendary screen transitions of the original Doom. |
-**Energize A**
Beam your windows away! |
-**Energize B**
Using different transporter technology results in an alternative visual effect. |
-**Fire**
The classic effect inspired by Compiz. However, this is implemented using a GLSL shader and not with a particle system like in the old days. |
-**Glide**
This very simple effect fades the window to transparency with subtle 3D effects. |
-**Glitch**
This effect applies some intentional graphics issues to your windows. |
-**Hexagon**
With glowing lines and hexagon-shaped tiles, this effect looks very sci-fi. |
-**Incinerate**
A less snappy but definitely more fancy take on the fire effect. |
-**Matrix**
Turn your windows into a shower of green letters! The color is actually configurable.|
-**Paint Brush**
Paint or erase your windows with a thick paint brush. |
-**Pixelate**
Pixelate your windows and randomly hide pixels until the entire window is gone.|
-**Pixel Wheel**
This simple effect pixelates the window and hides the pixels in a wheel-like fashion.|
-**Pixel Wipe**
This effect pixelates the window and hides the pixels radially, starting from the pointer position.|
-**Portal**
This ridiculous effect teleports your windows from and to alternative dimensions. It may resemble the portal from a well-known cartoon series... |
-**Snap of Disintegration**
Dissolve your windows into a cloud of dust.|
-**T-Rex Attack**
Destroy your windows with a series of violent slashes!|
-**TV Effect**
This is a very simple effect to demonstrate that this extension could also be used in a more professional environment. |
-**TV Glitch**
This effect combines the Glitch and the TV Effect. |
-**Wisps**
Let your windows be carried away to the realm of dreams by these little fairies! |
-**Your Effect!**
The extension is very modular and with a bit of creativity and GLSL knowledge, [you can easily create your own effects](docs/how-to-create-new-effects.md). | [](docs/how-to-create-new-effects.md)
+| Effect | Preview |
+| --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------- |
+| **Apparition**
This effect hides your windows by violently sucking them into the void of magic! |
|
+| **Broken Glass**
Shatter your windows into a shower sharp shards! This effect can be configured so that the shards fly away from your mouse pointer position! |
|
+| **Doom**
Melt your windows. Inspired by the legendary screen transitions of the original Doom. |
|
+| **Energize A**
Beam your windows away! |
|
+| **Energize B**
Using different transporter technology results in an alternative visual effect. |
|
+| **Fire**
The classic effect inspired by Compiz. However, this is implemented using a GLSL shader and not with a particle system like in the old days. |
|
+| **Glide**
This very simple effect fades the window to transparency with subtle 3D effects. |
|
+| **Glitch**
This effect applies some intentional graphics issues to your windows. |
|
+| **Hexagon**
With glowing lines and hexagon-shaped tiles, this effect looks very sci-fi. |
|
+| **Incinerate**
A less snappy but definitely more fancy take on the fire effect. |
|
+| **Matrix**
Turn your windows into a shower of green letters! The color is actually configurable. |
|
+| **Paint Brush**
Paint or erase your windows with a thick paint brush. |
|
+| **Pixelate**
Pixelate your windows and randomly hide pixels until the entire window is gone. |
|
+| **Pixel Wheel**
This simple effect pixelates the window and hides the pixels in a wheel-like fashion. |
|
+| **Pixel Wipe**
This effect pixelates the window and hides the pixels radially, starting from the pointer position. |
|
+| **Portal**
This ridiculous effect teleports your windows from and to alternative dimensions. It may resemble the portal from a well-known cartoon series... |
|
+| **Snap of Disintegration**
Dissolve your windows into a cloud of dust. |
|
+| **T-Rex Attack**
Destroy your windows with a series of violent slashes! |
|
+| **TV Effect**
This is a very simple effect to demonstrate that this extension could also be used in a more professional environment. |
|
+| **TV Glitch**
This effect combines the Glitch and the TV Effect. |
|
+| **Wisps**
Let your windows be carried away to the realm of dreams by these little fairies! |
|
+| **Your Effect!**
The extension is very modular and with a bit of creativity and GLSL knowledge, [you can easily create your own effects](docs/how-to-create-new-effects.md). | [](docs/how-to-create-new-effects.md) |
## ✅ Supported Versions
@@ -84,7 +84,6 @@ Below is a table which summarizes the current availability for all effects.
-
## 💞 These People _love_ this Extension
While [coding new features](docs/how-to-create-new-effects.md) or [translating the extension](https://hosted.weblate.org/engage/burn-my-windows/) are the most awesome ways to contribute, providing financial support will help me stay motivated to invest my spare time to keep the project alive in the future.
@@ -125,7 +124,6 @@ While [coding new features](docs/how-to-create-new-effects.md) or [translating t
@RickStanleyWisps ✅ ✅ ✅ ✅