Replace logDebug with console.debug

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