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