From dbb6275d354ff5704cedc661929c0100fd9ef674 Mon Sep 17 00:00:00 2001 From: Romain Vigier Date: Wed, 25 Aug 2021 15:06:38 +0200 Subject: [PATCH] Replace logDebug with console.debug --- src/extension.js | 17 +++++++------- src/modules/Backgrounder.js | 29 ++++++++++++------------ src/modules/Commander.js | 21 +++++++++-------- src/modules/CursorThemer.js | 29 ++++++++++++------------ src/modules/GtkThemer.js | 38 +++++++++++++++---------------- src/modules/IconThemer.js | 29 ++++++++++++------------ src/modules/ShellThemer.js | 38 +++++++++++++++---------------- src/modules/Timer.js | 27 +++++++++++----------- src/modules/TimerLocation.js | 35 ++++++++++++++--------------- src/modules/TimerNightlight.js | 27 +++++++++++----------- src/modules/TimerOndemand.js | 41 +++++++++++++++++----------------- src/modules/TimerSchedule.js | 13 +++++------ src/utils.js | 16 +++---------- 13 files changed, 170 insertions(+), 190 deletions(-) diff --git a/src/extension.js b/src/extension.js index 2b4eee6..aaa253d 100644 --- a/src/extension.js +++ b/src/extension.js @@ -9,7 +9,6 @@ const { extensionManager } = imports.ui.main; const Me = extensionUtils.getCurrentExtension(); -const { logDebug } = Me.imports.utils; const { Timer } = Me.imports.modules.Timer; const { GtkThemer } = Me.imports.modules.GtkThemer; const { ShellThemer } = Me.imports.modules.ShellThemer; @@ -33,9 +32,9 @@ var commander = null; * Extension initialization. */ function init() { - logDebug('Initializing extension...'); + console.debug('Initializing extension...'); extensionUtils.initTranslations(Me.metadata['gettext-domain']); - logDebug('Extension initialized.'); + console.debug('Extension initialized.'); } /** @@ -50,7 +49,7 @@ function enable() { * When the extension is started, we create and enable all the modules. */ function start() { - logDebug('Enabling extension...'); + console.debug('Enabling extension...'); timer = new Timer(); gtkThemer = new GtkThemer(); shellThemer = new ShellThemer(); @@ -68,14 +67,14 @@ function start() { commander.enable(); enabled = true; - logDebug('Extension enabled.'); + console.debug('Extension enabled.'); } /** * When the extension is disabled, we disable and remove all the modules. */ function disable() { - logDebug('Disabling extension...'); + console.debug('Disabling extension...'); enabled = false; gtkThemer.disable(); @@ -93,7 +92,7 @@ function disable() { cursorThemer = null; backgrounder = null; commander = null; - logDebug('Extension disabled.'); + console.debug('Extension disabled.'); } /** @@ -101,13 +100,13 @@ function disable() { */ function _waitForExtensionManager() { return new Promise(resolve => { - logDebug('Waiting for Extension Manager initialization...'); + console.debug('Waiting for Extension Manager initialization...'); GLib.idle_add(GLib.PRIORITY_DEFAULT_IDLE, () => { while (!extensionManager._initialized) continue; return false; }); - logDebug('Extension Manager initialized.'); + console.debug('Extension Manager initialized.'); resolve(); }); } diff --git a/src/modules/Backgrounder.js b/src/modules/Backgrounder.js index 3a4b287..33ac7ce 100644 --- a/src/modules/Backgrounder.js +++ b/src/modules/Backgrounder.js @@ -8,7 +8,6 @@ const Me = extensionUtils.getCurrentExtension(); const e = Me.imports.extension; const utils = Me.imports.utils; -const { logDebug } = utils; /** * The Backgrounder is responsible for changing the desktop background @@ -27,27 +26,27 @@ var Backgrounder = class { } enable() { - logDebug('Enabling Backgrounder...'); + console.debug('Enabling Backgrounder...'); this._watchStatus(); if (this._backgroundsSettings.get_boolean('enabled')) { this._connectSettings(); this._connectTimer(); this._updateSystemBackground(e.timer.time); } - logDebug('Backgrounder enabled.'); + console.debug('Backgrounder enabled.'); } disable() { - logDebug('Disabling Backgrounder...'); + console.debug('Disabling Backgrounder...'); this._disconnectTimer(); this._disconnectSettings(); this._unwatchStatus(); - logDebug('Backgrounder disabled.'); + console.debug('Backgrounder disabled.'); } _watchStatus() { - logDebug('Watching backgrounds status...'); + console.debug('Watching backgrounds status...'); this._statusConnection = this._backgroundsSettings.connect('changed::enabled', this._onStatusChanged.bind(this)); } @@ -56,11 +55,11 @@ var Backgrounder = class { this._backgroundsSettings.disconnect(this._statusConnection); this._statusConnection = null; } - logDebug('Stopped watching backgrounds status.'); + console.debug('Stopped watching backgrounds status.'); } _connectSettings() { - logDebug('Connecting Backgrounder to settings...'); + console.debug('Connecting Backgrounder to settings...'); this._settingsConnections.push({ settings: this._backgroundsSettings, id: this._backgroundsSettings.connect('changed::day', this._onDayBackgroundChanged.bind(this)), @@ -78,11 +77,11 @@ var Backgrounder = class { _disconnectSettings() { this._settingsConnections.forEach(connection => connection.settings.disconnect(connection.id)); this._settingsConnections = []; - logDebug('Disconnected Backgrounder from settings.'); + console.debug('Disconnected Backgrounder from settings.'); } _connectTimer() { - logDebug('Connecting Backgrounder to Timer...'); + console.debug('Connecting Backgrounder to Timer...'); this._timerConnection = e.timer.connect('time-changed', this._onTimeChanged.bind(this)); } @@ -91,28 +90,28 @@ var Backgrounder = class { e.timer.disconnect(this._timerConnection); this._timerConnection = null; } - logDebug('Disconnected Backgrounder from Timer.'); + console.debug('Disconnected Backgrounder from Timer.'); } _onStatusChanged() { - logDebug(`Backgrounds switching has been ${this._backgroundsSettings.get_boolean('enabled') ? 'enabled' : 'disabled'}.`); + console.debug(`Backgrounds switching has been ${this._backgroundsSettings.get_boolean('enabled') ? 'enabled' : 'disabled'}.`); this.disable(); this.enable(); } _onDayBackgroundChanged() { - logDebug(`Day background changed to '${this._backgroundsSettings.get_string('day')}'.`); + console.debug(`Day background changed to '${this._backgroundsSettings.get_string('day')}'.`); this._updateSystemBackground(); } _onNightBackgroundChanged() { - logDebug(`Night background changed to '${this._backgroundsSettings.get_string('night')}'.`); + console.debug(`Night background changed to '${this._backgroundsSettings.get_string('night')}'.`); this._updateSystemBackground(); } _onSystemBackgroundChanged() { - logDebug(`System background changed to '${this._systemBackgroundSettings.get_string('picture-uri')}'.`); + console.debug(`System background changed to '${this._systemBackgroundSettings.get_string('picture-uri')}'.`); this._updateCurrentBackground(); } diff --git a/src/modules/Commander.js b/src/modules/Commander.js index 500af15..8c02064 100644 --- a/src/modules/Commander.js +++ b/src/modules/Commander.js @@ -8,7 +8,6 @@ const Me = extensionUtils.getCurrentExtension(); const e = Me.imports.extension; const utils = Me.imports.utils; -const { logDebug } = utils; /** @@ -22,25 +21,25 @@ var Commander = class { } enable() { - logDebug('Enabling Commander...'); + console.debug('Enabling Commander...'); this._watchStatus(); if (this._commandsSettings.get_boolean('enabled')) { this._connectTimer(); this._spawnCommand(e.timer.time); } - logDebug('Commander enabled.'); + console.debug('Commander enabled.'); } disable() { - logDebug('Disabling Commander...'); + console.debug('Disabling Commander...'); this._disconnectTimer(); this._unwatchStatus(); - logDebug('Commander disabled.'); + console.debug('Commander disabled.'); } _watchStatus() { - logDebug('Watching commands status...'); + console.debug('Watching commands status...'); this._statusConnection = this._commandsSettings.connect('changed::enabled', this._onStatusChanged.bind(this)); } @@ -49,11 +48,11 @@ var Commander = class { this._commandsSettings.disconnect(this._statusConnection); this._statusConnection = null; } - logDebug('Stopped watching commands status.'); + console.debug('Stopped watching commands status.'); } _connectTimer() { - logDebug('Connecting Commander to Timer...'); + console.debug('Connecting Commander to Timer...'); this._timerConnection = e.timer.connect('time-changed', this._onTimeChanged.bind(this)); } @@ -62,12 +61,12 @@ var Commander = class { e.timer.disconnect(this._timerConnection); this._timerConnection = null; } - logDebug('Disconnecting Commander from Timer.'); + console.debug('Disconnecting Commander from Timer.'); } _onStatusChanged() { - logDebug(`Commands launching has been ${this._commandsSettings.get_boolean('enabled') ? 'enabled' : 'disabled'}.`); + console.debug(`Commands launching has been ${this._commandsSettings.get_boolean('enabled') ? 'enabled' : 'disabled'}.`); this.disable(); this.enable(); } @@ -82,6 +81,6 @@ var Commander = class { return; const command = this._commandsSettings.get_string(e.timer.time === 'day' ? 'sunrise' : 'sunset'); GLib.spawn_async(null, ['sh', '-c', command], null, GLib.SpawnFlags.SEARCH_PATH, null); - logDebug(`Spawned ${e.timer.time} command.`); + console.debug(`Spawned ${e.timer.time} command.`); } }; diff --git a/src/modules/CursorThemer.js b/src/modules/CursorThemer.js index 502d7c4..b9a2ac2 100644 --- a/src/modules/CursorThemer.js +++ b/src/modules/CursorThemer.js @@ -9,7 +9,6 @@ const Me = extensionUtils.getCurrentExtension(); const e = Me.imports.extension; const utils = Me.imports.utils; -const { logDebug } = utils; /** @@ -26,27 +25,27 @@ var CursorThemer = class { } enable() { - logDebug('Enabling Cursor Themer...'); + console.debug('Enabling Cursor Themer...'); this._watchStatus(); if (this._cursorVariantsSettings.get_boolean('enabled')) { this._connectSettings(); this._connectTimer(); this._updateSystemCursorTheme(); } - logDebug('Cursor Themer enabled.'); + console.debug('Cursor Themer enabled.'); } disable() { - logDebug('Disabling Cursor Themer...'); + console.debug('Disabling Cursor Themer...'); this._disconnectTimer(); this._disconnectSettings(); this._unwatchStatus(); - logDebug('Cursor Themer disabled.'); + console.debug('Cursor Themer disabled.'); } _watchStatus() { - logDebug('Watching cursor variants status...'); + console.debug('Watching cursor variants status...'); this._statusConnection = this._cursorVariantsSettings.connect('changed::enabled', this._onStatusChanged.bind(this)); } @@ -55,11 +54,11 @@ var CursorThemer = class { this._cursorVariantsSettings.disconnect(this._statusConnection); this._statusConnection = null; } - logDebug('Stopped watching cursor variants status.'); + console.debug('Stopped watching cursor variants status.'); } _connectSettings() { - logDebug('Connecting Cursor Themer to settings...'); + console.debug('Connecting Cursor Themer to settings...'); this._settingsConnections.push({ settings: this._cursorVariantsSettings, id: this._cursorVariantsSettings.connect('changed::day', this._onDayVariantChanged.bind(this)), @@ -77,11 +76,11 @@ var CursorThemer = class { _disconnectSettings() { this._settingsConnections.forEach(connection => connection.settings.disconnect(connection.id)); this._settingsConnections = []; - logDebug('Disconnected Cursor Themer from settings.'); + console.debug('Disconnected Cursor Themer from settings.'); } _connectTimer() { - logDebug('Connecting Cursor Themer to Timer...'); + console.debug('Connecting Cursor Themer to Timer...'); this._timerConnection = e.timer.connect('time-changed', this._onTimeChanged.bind(this)); } @@ -90,28 +89,28 @@ var CursorThemer = class { e.timer.disconnect(this._timerConnection); this._timerConnection = null; } - logDebug('Disconnected Cursor Themer from Timer.'); + console.debug('Disconnected Cursor Themer from Timer.'); } _onStatusChanged() { - logDebug(`Cursor variants switching has been ${this._cursorVariantsSettings.get_boolean('enabled') ? 'enabled' : 'disabled'}.`); + console.debug(`Cursor variants switching has been ${this._cursorVariantsSettings.get_boolean('enabled') ? 'enabled' : 'disabled'}.`); this.disable(); this.enable(); } _onDayVariantChanged() { - logDebug(`Day cursor variant changed to '${this._cursorVariantsSettings.get_string('day')}'.`); + console.debug(`Day cursor variant changed to '${this._cursorVariantsSettings.get_string('day')}'.`); this._updateSystemCursorTheme(); } _onNightVariantChanged() { - logDebug(`Night cursor variant changed to '${this._cursorVariantsSettings.get_string('night')}'.`); + console.debug(`Night cursor variant changed to '${this._cursorVariantsSettings.get_string('night')}'.`); this._updateSystemCursorTheme(); } _onSystemCursorThemeChanged() { - logDebug(`System cursor theme changed to '${this._interfaceSettings.get_string('cursor-theme')}'.`); + console.debug(`System cursor theme changed to '${this._interfaceSettings.get_string('cursor-theme')}'.`); this._updateCurrentVariant(); } diff --git a/src/modules/GtkThemer.js b/src/modules/GtkThemer.js index d18ce98..6b8ff32 100644 --- a/src/modules/GtkThemer.js +++ b/src/modules/GtkThemer.js @@ -9,7 +9,7 @@ const Me = extensionUtils.getCurrentExtension(); const e = Me.imports.extension; const utils = Me.imports.utils; -const { logDebug, notifyError } = utils; +const { notifyError } = utils; const { GtkVariants } = Me.imports.modules.GtkVariants; const Gettext = imports.gettext.domain(Me.metadata['gettext-domain']); @@ -37,7 +37,7 @@ var GtkThemer = class { } enable() { - logDebug('Enabling GTK Themer...'); + console.debug('Enabling GTK Themer...'); try { this._watchStatus(); if (this._gtkVariantsSettings.get_boolean('enabled')) { @@ -49,20 +49,20 @@ var GtkThemer = class { } catch (error) { notifyError(error); } - logDebug('GTK Themer enabled.'); + console.debug('GTK Themer enabled.'); } disable() { - logDebug('Disabling GTK Themer...'); + console.debug('Disabling GTK Themer...'); this._disconnectTimer(); this._disconnectSettings(); this._unwatchStatus(); - logDebug('GTK Themer disabled.'); + console.debug('GTK Themer disabled.'); } _watchStatus() { - logDebug('Watching GTK variants status...'); + console.debug('Watching GTK variants status...'); this._statusConnection = this._gtkVariantsSettings.connect('changed::enabled', this._onStatusChanged.bind(this)); } @@ -71,11 +71,11 @@ var GtkThemer = class { this._gtkVariantsSettings.disconnect(this._statusConnection); this._statusConnection = null; } - logDebug('Stopped watching GTK variants status.'); + console.debug('Stopped watching GTK variants status.'); } _connectSettings() { - logDebug('Connecting GTK Themer to settings...'); + console.debug('Connecting GTK Themer to settings...'); this._settingsConnections.push({ settings: this._gtkVariantsSettings, id: this._gtkVariantsSettings.connect('changed::day', this._onDayVariantChanged.bind(this)), @@ -97,11 +97,11 @@ var GtkThemer = class { _disconnectSettings() { this._settingsConnections.forEach(connection => connection.settings.disconnect(connection.id)); this._settingsConnections = []; - logDebug('Disconnected GTK Themer from settings.'); + console.debug('Disconnected GTK Themer from settings.'); } _connectTimer() { - logDebug('Connecting GTK Themer to Timer...'); + console.debug('Connecting GTK Themer to Timer...'); this._timerConnection = e.timer.connect('time-changed', this._onTimeChanged.bind(this)); } @@ -110,28 +110,28 @@ var GtkThemer = class { e.timer.disconnect(this._timerConnection); this._timerConnection = null; } - logDebug('Disconnected GTK Themer from Timer.'); + console.debug('Disconnected GTK Themer from Timer.'); } _onStatusChanged() { - logDebug(`GTK variants switching has been ${this._gtkVariantsSettings.get_boolean('enabled') ? 'enabled' : 'disabled'}.`); + console.debug(`GTK variants switching has been ${this._gtkVariantsSettings.get_boolean('enabled') ? 'enabled' : 'disabled'}.`); this.disable(); this.enable(); } _onDayVariantChanged() { - logDebug(`Day GTK variant changed to '${this._gtkVariantsSettings.get_string('day')}'.`); + console.debug(`Day GTK variant changed to '${this._gtkVariantsSettings.get_string('day')}'.`); this._updateSystemGtkTheme(); } _onNightVariantChanged() { - logDebug(`Night GTK variant changed to '${this._gtkVariantsSettings.get_string('night')}'.`); + console.debug(`Night GTK variant changed to '${this._gtkVariantsSettings.get_string('night')}'.`); this._updateSystemGtkTheme(); } _onSystemGtkThemeChanged() { - logDebug(`System GTK theme changed to '${this._interfaceSettings.get_string('gtk-theme')}'.`); + console.debug(`System GTK theme changed to '${this._interfaceSettings.get_string('gtk-theme')}'.`); try { this._updateVariants(); this._updateCurrentVariant(); @@ -142,7 +142,7 @@ var GtkThemer = class { } _onManualChanged() { - logDebug(`Manual GTK variants choice has been ${this._gtkVariantsSettings.get_boolean('manual') ? 'enabled' : 'disabled'}.`); + console.debug(`Manual GTK variants choice has been ${this._gtkVariantsSettings.get_boolean('manual') ? 'enabled' : 'disabled'}.`); this.disable(); this.enable(); } @@ -167,7 +167,7 @@ var GtkThemer = class { _updateSystemGtkTheme() { if (!e.timer.time) return; - logDebug(`Setting the ${e.timer.time} GTK variant...`); + console.debug(`Setting the ${e.timer.time} GTK variant...`); this._interfaceSettings.set_string('gtk-theme', this._gtkVariantsSettings.get_string(e.timer.time)); } @@ -175,7 +175,7 @@ var GtkThemer = class { if (this._gtkVariantsSettings.get_boolean('manual') || this._areVariantsUpToDate()) return; - logDebug('Updating GTK variants...'); + console.debug('Updating GTK variants...'); const originalTheme = this._interfaceSettings.get_string('gtk-theme'); const variants = GtkVariants.guessFrom(originalTheme); const installedThemes = utils.getInstalledGtkThemes(); @@ -187,6 +187,6 @@ var GtkThemer = class { this._gtkVariantsSettings.set_string('day', variants.get('day')); this._gtkVariantsSettings.set_string('night', variants.get('night')); - logDebug(`New GTK variants. { day: '${variants.get('day')}'; night: '${variants.get('night')}' }`); + console.debug(`New GTK variants. { day: '${variants.get('day')}'; night: '${variants.get('night')}' }`); } }; diff --git a/src/modules/IconThemer.js b/src/modules/IconThemer.js index 176d1ca..01c2695 100644 --- a/src/modules/IconThemer.js +++ b/src/modules/IconThemer.js @@ -9,7 +9,6 @@ const Me = extensionUtils.getCurrentExtension(); const e = Me.imports.extension; const utils = Me.imports.utils; -const { logDebug } = utils; /** @@ -26,27 +25,27 @@ var IconThemer = class { } enable() { - logDebug('Enabling Icon Themer...'); + console.debug('Enabling Icon Themer...'); this._watchStatus(); if (this._iconVariantsSettings.get_boolean('enabled')) { this._connectSettings(); this._connectTimer(); this._updateSystemIconTheme(); } - logDebug('Icon Themer enabled.'); + console.debug('Icon Themer enabled.'); } disable() { - logDebug('Disabling Icon Themer...'); + console.debug('Disabling Icon Themer...'); this._disconnectTimer(); this._disconnectSettings(); this._unwatchStatus(); - logDebug('Icon Themer disabled.'); + console.debug('Icon Themer disabled.'); } _watchStatus() { - logDebug('Watching icon variants status...'); + console.debug('Watching icon variants status...'); this._statusConnection = this._iconVariantsSettings.connect('changed::enabled', this._onStatusChanged.bind(this)); } @@ -55,11 +54,11 @@ var IconThemer = class { this._iconVariantsSettings.disconnect(this._statusConnection); this._statusConnection = null; } - logDebug('Stopped watching icon variants status.'); + console.debug('Stopped watching icon variants status.'); } _connectSettings() { - logDebug('Connecting Icon Themer to settings...'); + console.debug('Connecting Icon Themer to settings...'); this._settingsConnections.push({ settings: this._iconVariantsSettings, id: this._iconVariantsSettings.connect('changed::day', this._onDayVariantChanged.bind(this)), @@ -77,11 +76,11 @@ var IconThemer = class { _disconnectSettings() { this._settingsConnections.forEach(connection => connection.settings.disconnect(connection.id)); this._settingsConnections = []; - logDebug('Disconnected Icon Themer from settings.'); + console.debug('Disconnected Icon Themer from settings.'); } _connectTimer() { - logDebug('Connecting Icon Themer to Timer...'); + console.debug('Connecting Icon Themer to Timer...'); this._timerConnection = e.timer.connect('time-changed', this._onTimeChanged.bind(this)); } @@ -90,28 +89,28 @@ var IconThemer = class { e.timer.disconnect(this._timerConnection); this._timerConnection = null; } - logDebug('Disconnected Icon Themer from Timer.'); + console.debug('Disconnected Icon Themer from Timer.'); } _onStatusChanged() { - logDebug(`Icon variants switching has been ${this._iconVariantsSettings.get_boolean('enabled') ? 'enabled' : 'disabled'}.`); + console.debug(`Icon variants switching has been ${this._iconVariantsSettings.get_boolean('enabled') ? 'enabled' : 'disabled'}.`); this.disable(); this.enable(); } _onDayVariantChanged() { - logDebug(`Day icon variant changed to '${this._iconVariantsSettings.get_string('day')}'.`); + console.debug(`Day icon variant changed to '${this._iconVariantsSettings.get_string('day')}'.`); this._updateSystemIconTheme(); } _onNightVariantChanged() { - logDebug(`Night icon variant changed to '${this._iconVariantsSettings.get_string('night')}'.`); + console.debug(`Night icon variant changed to '${this._iconVariantsSettings.get_string('night')}'.`); this._updateSystemIconTheme(); } _onSystemIconThemeChanged() { - logDebug(`System icon theme changed to '${this._iconVariantsSettings.get_string('icon-theme')}'.`); + console.debug(`System icon theme changed to '${this._iconVariantsSettings.get_string('icon-theme')}'.`); this._updateCurrentVariant(); } diff --git a/src/modules/ShellThemer.js b/src/modules/ShellThemer.js index f26021e..4c3778c 100644 --- a/src/modules/ShellThemer.js +++ b/src/modules/ShellThemer.js @@ -10,7 +10,7 @@ const Me = extensionUtils.getCurrentExtension(); const e = Me.imports.extension; const utils = Me.imports.utils; -const { logDebug, notifyError } = Me.imports.utils; +const { notifyError } = Me.imports.utils; const { ShellVariants } = Me.imports.modules.ShellVariants; const Gettext = imports.gettext.domain(Me.metadata['gettext-domain']); @@ -37,7 +37,7 @@ var ShellThemer = class { } enable() { - logDebug('Enabling Shell Themer...'); + console.debug('Enabling Shell Themer...'); try { this._watchStatus(); if (this._shellVariantsSettings.get_boolean('enabled')) { @@ -49,20 +49,20 @@ var ShellThemer = class { } catch (error) { notifyError(error); } - logDebug('Shell Themer enabled.'); + console.debug('Shell Themer enabled.'); } disable() { - logDebug('Disabling Shell Themer...'); + console.debug('Disabling Shell Themer...'); this._disconnectTimer(); this._disconnectSettings(); this._unwatchStatus(); - logDebug('Shell Themer disabled.'); + console.debug('Shell Themer disabled.'); } _watchStatus() { - logDebug('Watching shell variants status...'); + console.debug('Watching shell variants status...'); this._statusConnection = this._shellVariantsSettings.connect('changed::enabled', this._onStatusChanged.bind(this)); } @@ -71,11 +71,11 @@ var ShellThemer = class { this._shellVariantsSettings.disconnect(this._statusConnection); this._statusConnection = null; } - logDebug('Stopped watching shell variants status.'); + console.debug('Stopped watching shell variants status.'); } _connectSettings() { - logDebug('Connecting Shell Themer to settings...'); + console.debug('Connecting Shell Themer to settings...'); this._settingsConnections.push({ settings: this._shellVariantsSettings, id: this._shellVariantsSettings.connect('changed::day', this._onDayVariantChanged.bind(this)), @@ -99,11 +99,11 @@ var ShellThemer = class { _disconnectSettings() { this._settingsConnections.forEach(connection => connection.settings.disconnect(connection.id)); this._settingsConnections = []; - logDebug('Disconnected Shell Themer from settings.'); + console.debug('Disconnected Shell Themer from settings.'); } _connectTimer() { - logDebug('Connecting Shell Themer to Timer...'); + console.debug('Connecting Shell Themer to Timer...'); this._timerConnection = e.timer.connect('time-changed', this._onTimeChanged.bind(this)); } @@ -112,30 +112,30 @@ var ShellThemer = class { e.timer.disconnect(this._timerConnection); this._timerConnection = null; } - logDebug('Disconnected Shell Themer from Timer.'); + console.debug('Disconnected Shell Themer from Timer.'); } _onStatusChanged() { - logDebug(`Shell variants switching has been ${this._shellVariantsSettings.get_boolean('enabled') ? 'enabled' : 'disabled'}.`); + console.debug(`Shell variants switching has been ${this._shellVariantsSettings.get_boolean('enabled') ? 'enabled' : 'disabled'}.`); this.disable(); this.enable(); } _onDayVariantChanged() { - logDebug(`Day Shell variant changed to '${this._shellVariantsSettings.get_string('day')}'.`); + console.debug(`Day Shell variant changed to '${this._shellVariantsSettings.get_string('day')}'.`); this._updateSystemShellTheme(); } _onNightVariantChanged() { - logDebug(`Night Shell variant changed to '${this._shellVariantsSettings.get_string('night')}'.`); + console.debug(`Night Shell variant changed to '${this._shellVariantsSettings.get_string('night')}'.`); this._updateSystemShellTheme(); } _onSystemShellThemeChanged(_settings, _newTheme) { if (!this._userthemesSettings) return; - logDebug(`System Shell theme changed to '${this._userthemesSettings.get_string('name')}'.`); + console.debug(`System Shell theme changed to '${this._userthemesSettings.get_string('name')}'.`); try { this._updateVariants(); this._updateCurrentVariant(); @@ -146,7 +146,7 @@ var ShellThemer = class { } _onManualChanged() { - logDebug(`Manual Shell variants choice has been ${this._shellVariantsSettings.get_boolean('manual') ? 'enabled' : 'disabled'}.`); + console.debug(`Manual Shell variants choice has been ${this._shellVariantsSettings.get_boolean('manual') ? 'enabled' : 'disabled'}.`); this.disable(); this.enable(); } @@ -173,7 +173,7 @@ var ShellThemer = class { _updateSystemShellTheme() { if (!e.timer.time) return; - logDebug(`Setting the ${e.timer.time} Shell variant...`); + console.debug(`Setting the ${e.timer.time} Shell variant...`); const shellTheme = this._shellVariantsSettings.get_string(e.timer.time); if (this._userthemesSettings) { this._userthemesSettings.set_string('name', shellTheme); @@ -187,7 +187,7 @@ var ShellThemer = class { if (!this._userthemesSettings || this._shellVariantsSettings.get_boolean('manual') || this._areVariantsUpToDate()) return; - logDebug('Updating Shell variants...'); + console.debug('Updating Shell variants...'); const originalTheme = this._userthemesSettings.get_string('name'); const variants = ShellVariants.guessFrom(originalTheme); const installedThemes = utils.getInstalledShellThemes(); @@ -199,6 +199,6 @@ var ShellThemer = class { this._shellVariantsSettings.set_string('day', variants.get('day')); this._shellVariantsSettings.set_string('night', variants.get('night')); - logDebug(`New Shell variants. { day: '${variants.get('day')}'; night: '${variants.get('night')}' }`); + console.debug(`New Shell variants. { day: '${variants.get('day')}'; night: '${variants.get('night')}' }`); } }; diff --git a/src/modules/Timer.js b/src/modules/Timer.js index caf3585..70146bc 100644 --- a/src/modules/Timer.js +++ b/src/modules/Timer.js @@ -8,7 +8,6 @@ const Signals = imports.signals; const Me = extensionUtils.getCurrentExtension(); const utils = Me.imports.utils; -const { logDebug } = utils; const { TimerNightlight } = Me.imports.modules.TimerNightlight; const { TimerLocation } = Me.imports.modules.TimerLocation; @@ -43,20 +42,20 @@ var Timer = class { } enable() { - logDebug('Enabling Timer...'); + console.debug('Enabling Timer...'); this._connectSettings(); this._createSources(); this._connectSources(); this._enableSources(); - logDebug('Timer enabled.'); + console.debug('Timer enabled.'); } disable() { - logDebug('Disabling Timer...'); + console.debug('Disabling Timer...'); this._disconnectSources(); this._disableSources(); this._disconnectSettings(); - logDebug('Timer disabled.'); + console.debug('Timer disabled.'); } @@ -66,7 +65,7 @@ var Timer = class { _connectSettings() { - logDebug('Connecting Timer to settings...'); + console.debug('Connecting Timer to settings...'); this._settingsConnections.push({ settings: this._colorSettings, id: this._colorSettings.connect('changed::night-light-enabled', this._onSourceChanged.bind(this)), @@ -92,7 +91,7 @@ var Timer = class { _disconnectSettings() { this._settingsConnections.forEach(connection => connection.settings.disconnect(connection.id)); this._settingsConnections = []; - logDebug('Disconnected Timer from settings.'); + console.debug('Disconnected Timer from settings.'); } _createSources() { @@ -126,7 +125,7 @@ var Timer = class { } _connectSources() { - logDebug('Connecting to time sources...'); + console.debug('Connecting to time sources...'); this._sources.forEach(source => this._timeConnections.push({ source, id: source.connect('time-changed', this._onTimeChanged.bind(this)), @@ -136,7 +135,7 @@ var Timer = class { _disconnectSources() { this._timeConnections.forEach(connection => connection.source.disconnect(connection.id)); this._timeConnections = []; - logDebug('Disconnected from time sources.'); + console.debug('Disconnected from time sources.'); } @@ -152,7 +151,7 @@ var Timer = class { _onTimeChanged(_source, newTime) { if (newTime !== this._previousTime) { - logDebug(`Time has changed to ${newTime}.`); + console.debug(`Time has changed to ${newTime}.`); this._previousTime = newTime; this.emit('time-changed', newTime); } @@ -160,17 +159,17 @@ var Timer = class { _getSource() { - logDebug('Getting time source...'); + console.debug('Getting time source...'); let source; if (this._timeSettings.get_boolean('manual-time-source')) { source = this._timeSettings.get_string('time-source'); - logDebug(`Time source is forced to ${source}.`); + console.debug(`Time source is forced to ${source}.`); if ( (source === 'nightlight' && !this._colorSettings.get_boolean('night-light-enabled')) || (source === 'location' && !this._locationSettings.get_boolean('enabled')) ) { - logDebug(`Unable to choose ${source} time source, falling back to manual schedule.`); + console.debug(`Unable to choose ${source} time source, falling back to manual schedule.`); source = 'schedule'; this._timeSettings.set_string('time-source', source); } @@ -181,7 +180,7 @@ var Timer = class { source = 'location'; else source = 'schedule'; - logDebug(`Time source is ${source}.`); + console.debug(`Time source is ${source}.`); this._timeSettings.set_string('time-source', source); } return source; diff --git a/src/modules/TimerLocation.js b/src/modules/TimerLocation.js index 9379c18..64ce0f0 100644 --- a/src/modules/TimerLocation.js +++ b/src/modules/TimerLocation.js @@ -8,7 +8,6 @@ const Signals = imports.signals; const Me = extensionUtils.getCurrentExtension(); const utils = Me.imports.utils; -const { logDebug } = utils; /** @@ -41,19 +40,19 @@ var TimerLocation = class { } enable() { - logDebug('Enabling Location Timer...'); + console.debug('Enabling Location Timer...'); this._connectToGeoclue(); this._watchForTimeChange(); this._regularlyUpdateSuntimes(); - logDebug('Location Timer enabled.'); + console.debug('Location Timer enabled.'); } disable() { - logDebug('Disabling Location Timer...'); + console.debug('Disabling Location Timer...'); this._stopRegularlyUpdatingSuntimes(); this._stopWatchingForTimeChange(); this._disconnectFromGeoclue(); - logDebug('Location Timer disabled.'); + console.debug('Location Timer disabled.'); } @@ -63,7 +62,7 @@ var TimerLocation = class { _connectToGeoclue() { - logDebug('Connecting to GeoClue...'); + console.debug('Connecting to GeoClue...'); Geoclue.Simple.new( 'org.gnome.Shell', Geoclue.AccuracyLevel.CITY, @@ -73,24 +72,24 @@ var TimerLocation = class { } _disconnectFromGeoclue() { - logDebug('Disconnecting from GeoClue...'); + console.debug('Disconnecting from GeoClue...'); if (this._geoclueConnection) { this._geoclue.disconnect(this._geoclueConnection); this._geoclueConnection = null; } - logDebug('Disconnected from GeoClue.'); + console.debug('Disconnected from GeoClue.'); } _onGeoclueReady(_, result) { this._geoclue = Geoclue.Simple.new_finish(result); this._geoclueConnection = this._geoclue.connect('notify::location', this._onLocationUpdated.bind(this)); - logDebug('Connected to GeoClue.'); + console.debug('Connected to GeoClue.'); this._onLocationUpdated(); } _onLocationUpdated(_geoclue, _location) { - logDebug('Location has changed.'); + console.debug('Location has changed.'); this._updateLocation(); this._updateSuntimes(); } @@ -98,13 +97,13 @@ var TimerLocation = class { _updateLocation() { if (this._geoclue) { - logDebug('Updating location...'); + console.debug('Updating location...'); const { latitude, longitude } = this._geoclue.get_location(); this.location = new Map([ ['latitude', latitude], ['longitude', longitude], ]); - logDebug(`Current location: (${latitude};${longitude})`); + console.debug(`Current location: (${latitude};${longitude})`); } } @@ -112,7 +111,7 @@ var TimerLocation = class { if (!this.location) return; - logDebug('Updating sun times...'); + console.debug('Updating sun times...'); Math.rad = degrees => degrees * Math.PI / 180; Math.deg = radians => radians * 180 / Math.PI; @@ -154,11 +153,11 @@ var TimerLocation = class { this._suntimes.set('sunrise', sunrise); this._suntimes.set('sunset', sunset); - logDebug(`New sun times: (sunrise: ${sunrise}; sunset: ${sunset})`); + console.debug(`New sun times: (sunrise: ${sunrise}; sunset: ${sunset})`); } _regularlyUpdateSuntimes() { - logDebug('Regularly updating sun times...'); + console.debug('Regularly updating sun times...'); this._regularlyUpdateSuntimesTimer = GLib.timeout_add_seconds(GLib.PRIORITY_DEFAULT, 3600, () => { this._updateSuntimes(); return true; // Repeat the loop @@ -168,7 +167,7 @@ var TimerLocation = class { _stopRegularlyUpdatingSuntimes() { GLib.Source.remove(this._regularlyUpdateSuntimesTimer); this._regularlyUpdateSuntimesTimer = null; - logDebug('Stopped regularly updating sun times.'); + console.debug('Stopped regularly updating sun times.'); } _isDaytime() { @@ -178,7 +177,7 @@ var TimerLocation = class { } _watchForTimeChange() { - logDebug('Watching for time change...'); + console.debug('Watching for time change...'); this._timeChangeTimer = GLib.timeout_add_seconds(GLib.PRIORITY_DEFAULT, 1, () => { if (!Me.imports.extension.enabled) { // The extension doesn't exist anymore, quit the loop @@ -194,7 +193,7 @@ var TimerLocation = class { _stopWatchingForTimeChange() { GLib.Source.remove(this._timeChangeTimer); - logDebug('Stopped watching for time change.'); + console.debug('Stopped watching for time change.'); } }; Signals.addSignalMethods(TimerLocation.prototype); diff --git a/src/modules/TimerNightlight.js b/src/modules/TimerNightlight.js index 7019513..73eb069 100644 --- a/src/modules/TimerNightlight.js +++ b/src/modules/TimerNightlight.js @@ -8,7 +8,6 @@ const Signals = imports.signals; const Me = extensionUtils.getCurrentExtension(); const utils = Me.imports.utils; -const { logDebug } = utils; const COLOR_INTERFACE = ` @@ -36,20 +35,20 @@ var TimerNightlight = class { } enable() { - logDebug('Enabling Night Light Timer...'); + console.debug('Enabling Night Light Timer...'); this._connectToColorDbusProxy(); this._connectSettings(); this._listenToNightlightState(); this.emit('time-changed', this.time); - logDebug('Night Light Timer enabled.'); + console.debug('Night Light Timer enabled.'); } disable() { - logDebug('Disabling Night Light Timer...'); + console.debug('Disabling Night Light Timer...'); this._stopListeningToNightlightState(); this._disconnectSettings(); this._disconnectFromColorDbusProxy(); - logDebug('Night Light Timer disabled.'); + console.debug('Night Light Timer disabled.'); } @@ -59,24 +58,24 @@ var TimerNightlight = class { _connectToColorDbusProxy() { - logDebug('Connecting to Color DBus proxy...'); + console.debug('Connecting to Color DBus proxy...'); const ColorProxy = Gio.DBusProxy.makeProxyWrapper(COLOR_INTERFACE); this._colorDbusProxy = new ColorProxy( Gio.DBus.session, 'org.gnome.SettingsDaemon.Color', '/org/gnome/SettingsDaemon/Color' ); - logDebug('Connected to Color DBus proxy.'); + console.debug('Connected to Color DBus proxy.'); } _disconnectFromColorDbusProxy() { - logDebug('Disconnecting from Color DBus proxy...'); + console.debug('Disconnecting from Color DBus proxy...'); this._colorDbusProxy = null; - logDebug('Disconnected from Color DBus proxy.'); + console.debug('Disconnected from Color DBus proxy.'); } _connectSettings() { - logDebug('Connecting Night Light Timer to settings...'); + console.debug('Connecting Night Light Timer to settings...'); this._settingsConnections.push({ settings: this._timeSettings, id: this._timeSettings.connect('changed::nightlight-follow-disable', this._onNightlightFollowDisableChanged.bind(this)), @@ -84,13 +83,13 @@ var TimerNightlight = class { } _disconnectSettings() { - logDebug('Disconnecting Night Light Timer from settings...'); + console.debug('Disconnecting Night Light Timer from settings...'); this._settingsConnections.forEach(connection => connection.settings.disconnect(connection.id)); this._settingsConnections = []; } _listenToNightlightState() { - logDebug('Listening to Night Light state...'); + console.debug('Listening to Night Light state...'); this._nightlightStateConnection = this._colorDbusProxy.connect( 'g-properties-changed', this._onNightlightStateChanged.bind(this) @@ -99,7 +98,7 @@ var TimerNightlight = class { _stopListeningToNightlightState() { this._colorDbusProxy.disconnect(this._nightlightStateConnection); - logDebug('Stopped listening to Night Light state.'); + console.debug('Stopped listening to Night Light state.'); } @@ -109,7 +108,7 @@ var TimerNightlight = class { _onNightlightStateChanged(_sender, _dbusProperties) { if (this._isNightlightActive() !== this._previousNightlightActive) { - logDebug(`Night Light has become ${this._isNightlightActive() ? '' : 'in'}active.`); + console.debug(`Night Light has become ${this._isNightlightActive() ? '' : 'in'}active.`); this._previousNightlightActive = this._isNightlightActive(); this.emit('time-changed', this.time); } diff --git a/src/modules/TimerOndemand.js b/src/modules/TimerOndemand.js index 8a0a3f3..00c7703 100644 --- a/src/modules/TimerOndemand.js +++ b/src/modules/TimerOndemand.js @@ -14,7 +14,6 @@ const Me = extensionUtils.getCurrentExtension(); const e = Me.imports.extension; const utils = Me.imports.utils; -const { logDebug } = utils; const Gettext = imports.gettext.domain(Me.metadata['gettext-domain']); const _ = Gettext.gettext; @@ -35,22 +34,22 @@ var TimerOndemand = class { } enable() { - logDebug('Enabling On-demand Timer...'); + console.debug('Enabling On-demand Timer...'); this._connectSettings(); this._addKeybinding(); this._addButton(); this._connectTimer(); this.emit('time-changed', this.time); - logDebug('On-demand Timer enabled.'); + console.debug('On-demand Timer enabled.'); } disable() { - logDebug('Disabling On-demand Timer...'); + console.debug('Disabling On-demand Timer...'); this._disconnectTimer(); this._removeKeybinding(); this._removeButton(); this._disconnectSettings(); - logDebug('On-demand Timer disabled.'); + console.debug('On-demand Timer disabled.'); } @@ -60,7 +59,7 @@ var TimerOndemand = class { _connectSettings() { - logDebug('Connecting On-demand Timer to settings...'); + console.debug('Connecting On-demand Timer to settings...'); this._settingsConnections.push({ settings: this._timeSettings, id: this._timeSettings.connect('changed::ondemand-time', this._onOndemandTimeChanged.bind(this)), @@ -76,13 +75,13 @@ var TimerOndemand = class { } _disconnectSettings() { - logDebug('Disconnecting On-demand Timer from settings...'); + console.debug('Disconnecting On-demand Timer from settings...'); this._settingsConnections.forEach(connection => connection.settings.disconnect(connection.id)); this._settingsConnections = []; } _connectTimer() { - logDebug('Connecting On-demand Timer to Timer...'); + console.debug('Connecting On-demand Timer to Timer...'); this._timerConnection = e.timer.connect('time-changed', this._onTimeChanged.bind(this)); } @@ -91,7 +90,7 @@ var TimerOndemand = class { e.timer.disconnect(this._timerConnection); this._timerConnection = null; } - logDebug('Disconnected On-demand Timer from Timer.'); + console.debug('Disconnected On-demand Timer from Timer.'); } @@ -119,7 +118,7 @@ var TimerOndemand = class { this._previousKeybinding = this._timeSettings.get_strv('nightthemeswitcher-ondemand-keybinding')[0]; if (!this._timeSettings.get_strv('nightthemeswitcher-ondemand-keybinding')[0]) return; - logDebug('Adding On-demand Timer keybinding...'); + console.debug('Adding On-demand Timer keybinding...'); main.wm.addKeybinding( 'nightthemeswitcher-ondemand-keybinding', this._timeSettings, @@ -127,14 +126,14 @@ var TimerOndemand = class { Shell.ActionMode.NORMAL | Shell.ActionMode.OVERVIEW, this._toggleTime.bind(this) ); - logDebug('Added On-demand Timer keybinding.'); + console.debug('Added On-demand Timer keybinding.'); } _removeKeybinding() { if (this._previousKeybinding) { - logDebug('Removing On-demand Timer keybinding...'); + console.debug('Removing On-demand Timer keybinding...'); main.wm.removeKeybinding('nightthemeswitcher-ondemand-keybinding'); - logDebug('Removed On-demand Timer keybinding.'); + console.debug('Removed On-demand Timer keybinding.'); } } @@ -150,32 +149,32 @@ var TimerOndemand = class { _removeButton() { if (this._button) { - logDebug('Removing On-demand Timer button...'); + console.debug('Removing On-demand Timer button...'); this._button.destroy(); this._button = null; - logDebug('Removed On-demand Timer button.'); + console.debug('Removed On-demand Timer button.'); } } _updateButton() { if (this._button) { - logDebug('Updating On-demand Timer button state...'); + console.debug('Updating On-demand Timer button state...'); this._button.update(); - logDebug('Updated On-demand Timer button state.'); + console.debug('Updated On-demand Timer button state.'); } } _addButtonToPanel() { - logDebug('Adding On-demand Timer button to the panel...'); + console.debug('Adding On-demand Timer button to the panel...'); this._button = new NtsPanelMenuButton(); this._button.connect('button-press-event', () => this._toggleTime()); this._button.connect('touch-event', () => this._toggleTime()); main.panel.addToStatusArea('NightThemeSwitcherButton', this._button); - logDebug('Added On-demand Timer button to the panel.'); + console.debug('Added On-demand Timer button to the panel.'); } _addButtonToMenu() { - logDebug('Adding On-demand Timer button to the menu...'); + console.debug('Adding On-demand Timer button to the menu...'); const aggregateMenu = main.panel.statusArea.aggregateMenu; const position = utils.findShellAggregateMenuItemPosition(aggregateMenu._system.menu) - 1; this._button = new NtsPopupMenuItem(); @@ -183,7 +182,7 @@ var TimerOndemand = class { this._toggleTime(); }); aggregateMenu.menu.addMenuItem(this._button, position); - logDebug('Added On-demand Timer button to the menu.'); + console.debug('Added On-demand Timer button to the menu.'); } _toggleTime() { diff --git a/src/modules/TimerSchedule.js b/src/modules/TimerSchedule.js index 525cf6c..e6f060f 100644 --- a/src/modules/TimerSchedule.js +++ b/src/modules/TimerSchedule.js @@ -8,7 +8,6 @@ const Signals = imports.signals; const Me = extensionUtils.getCurrentExtension(); const utils = Me.imports.utils; -const { logDebug } = utils; /** @@ -27,16 +26,16 @@ var TimerSchedule = class { } enable() { - logDebug('Enabling Schedule Timer...'); + console.debug('Enabling Schedule Timer...'); this._watchForTimeChange(); this.emit('time-changed', this.time); - logDebug('Schedule Timer enabled.'); + console.debug('Schedule Timer enabled.'); } disable() { - logDebug('Disabling Schedule Timer...'); + console.debug('Disabling Schedule Timer...'); this._stopWatchingForTimeChange(); - logDebug('Schedule Timer disabled.'); + console.debug('Schedule Timer disabled.'); } @@ -52,7 +51,7 @@ var TimerSchedule = class { } _watchForTimeChange() { - logDebug('Watching for time change...'); + console.debug('Watching for time change...'); this._timeChangeTimer = GLib.timeout_add_seconds(GLib.PRIORITY_DEFAULT, 1, () => { if (!Me.imports.extension.enabled) { // The extension doesn't exist anymore, quit the loop @@ -68,7 +67,7 @@ var TimerSchedule = class { _stopWatchingForTimeChange() { GLib.Source.remove(this._timeChangeTimer); - logDebug('Stopped watching for time change.'); + console.debug('Stopped watching for time change.'); } }; Signals.addSignalMethods(TimerSchedule.prototype); diff --git a/src/utils.js b/src/utils.js index 8eda56e..bd043f6 100644 --- a/src/utils.js +++ b/src/utils.js @@ -11,16 +11,6 @@ const Gettext = imports.gettext.domain(Me.metadata['gettext-domain']); const _ = Gettext.gettext; -/** - * Output a debug message to the console if the debug config is active. - * - * @param {string} message The message to log. - */ -function logDebug(message) { - if (config.debug) - log(`[DEBUG] ${Me.metadata.name}: ${message}`); -} - /** * Log an error and show a notification if it has a message. * @@ -197,7 +187,7 @@ function getUserthemesSettings() { */ function getShellThemeStylesheet(theme) { const themeName = theme ? `'${theme}'` : 'default'; - logDebug(`Getting the ${themeName} theme shell stylesheet...`); + console.debug(`Getting the ${themeName} theme shell stylesheet...`); let stylesheet = null; if (theme) { const stylesheetPaths = getResourcesDirsPaths('themes').map(path => GLib.build_filenamev([path, theme, 'gnome-shell', 'gnome-shell.css'])); @@ -215,10 +205,10 @@ function getShellThemeStylesheet(theme) { * @param {string} stylesheet The shell stylesheet to apply. */ function applyShellStylesheet(stylesheet) { - logDebug('Applying shell stylesheet...'); + console.debug('Applying shell stylesheet...'); imports.ui.main.setThemeStylesheet(stylesheet); imports.ui.main.loadTheme(); - logDebug('Shell stylesheet applied.'); + console.debug('Shell stylesheet applied.'); } /**