Extension: Add debug mode
This commit is contained in:
+2
-1
@@ -72,7 +72,8 @@ extension:
|
|||||||
- apt update
|
- apt update
|
||||||
- apt install --no-install-recommends -y gettext libglib2.0-bin libglib2.0-dev-bin meson zip
|
- apt install --no-install-recommends -y gettext libglib2.0-bin libglib2.0-dev-bin meson zip
|
||||||
script:
|
script:
|
||||||
- meson builddir -Dpack=true -Dpackdir=.
|
- if [ -z "$CI_COMMIT_TAG" ]; then BUILD_TYPE=debug; else BUILD_TYPE=release; fi
|
||||||
|
- meson builddir -Dbuildtype=$BUILD_TYPE -Dpack=true -Dpackdir=.
|
||||||
- meson install -C builddir
|
- meson install -C builddir
|
||||||
artifacts:
|
artifacts:
|
||||||
name: $CI_COMMIT_REF_NAME
|
name: $CI_COMMIT_REF_NAME
|
||||||
|
|||||||
@@ -0,0 +1,16 @@
|
|||||||
|
// SPDX-FileCopyrightText: 2022 Romain Vigier <contact AT romainvigier.fr>
|
||||||
|
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||||
|
|
||||||
|
const { extensionUtils } = imports.misc;
|
||||||
|
|
||||||
|
const Me = extensionUtils.getCurrentExtension();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Print a message in debug builds.
|
||||||
|
*
|
||||||
|
* @param {string} msg Message to print.
|
||||||
|
*/
|
||||||
|
function message(msg) {
|
||||||
|
if ('@BUILD_TYPE@' === 'debug') // eslint-disable-line no-constant-condition
|
||||||
|
console.log(`[${Me.metadata.name}] ${msg}`);
|
||||||
|
}
|
||||||
+7
-6
@@ -8,6 +8,7 @@ const { extensionUtils } = imports.misc;
|
|||||||
|
|
||||||
const Me = extensionUtils.getCurrentExtension();
|
const Me = extensionUtils.getCurrentExtension();
|
||||||
|
|
||||||
|
const debug = Me.imports.debug;
|
||||||
const utils = Me.imports.utils;
|
const utils = Me.imports.utils;
|
||||||
|
|
||||||
const { SwitcherCommands } = Me.imports.modules.SwitcherCommands;
|
const { SwitcherCommands } = Me.imports.modules.SwitcherCommands;
|
||||||
@@ -24,13 +25,13 @@ class NightThemeSwitcher {
|
|||||||
#switcherCommands = null;
|
#switcherCommands = null;
|
||||||
|
|
||||||
constructor() {
|
constructor() {
|
||||||
console.debug('Initializing extension...');
|
debug.message('Initializing extension...');
|
||||||
extensionUtils.initTranslations();
|
extensionUtils.initTranslations();
|
||||||
console.debug('Extension initialized.');
|
debug.message('Extension initialized.');
|
||||||
}
|
}
|
||||||
|
|
||||||
enable() {
|
enable() {
|
||||||
console.debug('Enabling extension...');
|
debug.message('Enabling extension...');
|
||||||
this.#timer = new Timer();
|
this.#timer = new Timer();
|
||||||
this.#switcherThemeGtk = new SwitcherThemeGtk({ timer: this.#timer });
|
this.#switcherThemeGtk = new SwitcherThemeGtk({ timer: this.#timer });
|
||||||
this.#switcherThemeIcon = new SwitcherThemeIcon({ timer: this.#timer });
|
this.#switcherThemeIcon = new SwitcherThemeIcon({ timer: this.#timer });
|
||||||
@@ -45,14 +46,14 @@ class NightThemeSwitcher {
|
|||||||
this.#switcherThemeCursor.enable();
|
this.#switcherThemeCursor.enable();
|
||||||
this.#switcherCommands.enable();
|
this.#switcherCommands.enable();
|
||||||
|
|
||||||
console.debug('Extension enabled.');
|
debug.message('Extension enabled.');
|
||||||
}
|
}
|
||||||
|
|
||||||
disable() {
|
disable() {
|
||||||
// Extension won't be disabled in `unlock-dialog` session mode. This is
|
// Extension won't be disabled in `unlock-dialog` session mode. This is
|
||||||
// to enable the color scheme switch while the lock screen is displayed,
|
// to enable the color scheme switch while the lock screen is displayed,
|
||||||
// as the background image and the shell theme are visible in this mode.
|
// as the background image and the shell theme are visible in this mode.
|
||||||
console.debug('Disabling extension...');
|
debug.message('Disabling extension...');
|
||||||
|
|
||||||
if (this.#switcherThemeGtk) {
|
if (this.#switcherThemeGtk) {
|
||||||
this.#switcherThemeGtk.disable();
|
this.#switcherThemeGtk.disable();
|
||||||
@@ -79,7 +80,7 @@ class NightThemeSwitcher {
|
|||||||
this.#timer = null;
|
this.#timer = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
console.debug('Extension disabled.');
|
debug.message('Extension disabled.');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -12,6 +12,15 @@ configure_file(
|
|||||||
install_dir: INSTALL_DIR
|
install_dir: INSTALL_DIR
|
||||||
)
|
)
|
||||||
|
|
||||||
|
configure_file(
|
||||||
|
input: 'debug.js',
|
||||||
|
output: 'debug.js',
|
||||||
|
configuration: {
|
||||||
|
'BUILD_TYPE': get_option('buildtype')
|
||||||
|
},
|
||||||
|
install_dir: INSTALL_DIR
|
||||||
|
)
|
||||||
|
|
||||||
main = [
|
main = [
|
||||||
'extension.js',
|
'extension.js',
|
||||||
'prefs.js',
|
'prefs.js',
|
||||||
|
|||||||
+10
-9
@@ -6,6 +6,7 @@ const { extensionUtils } = imports.misc;
|
|||||||
|
|
||||||
const Me = extensionUtils.getCurrentExtension();
|
const Me = extensionUtils.getCurrentExtension();
|
||||||
|
|
||||||
|
const debug = Me.imports.debug;
|
||||||
const utils = Me.imports.utils;
|
const utils = Me.imports.utils;
|
||||||
|
|
||||||
const { Time } = Me.imports.enums.Time;
|
const { Time } = Me.imports.enums.Time;
|
||||||
@@ -45,25 +46,25 @@ var Switcher = class {
|
|||||||
}
|
}
|
||||||
|
|
||||||
enable() {
|
enable() {
|
||||||
console.debug(`Enabling ${this.#name} switcher...`);
|
debug.message(`Enabling ${this.#name} switcher...`);
|
||||||
this.#watchStatus();
|
this.#watchStatus();
|
||||||
if (this.#settings.get_boolean('enabled')) {
|
if (this.#settings.get_boolean('enabled')) {
|
||||||
this.#connectTimer();
|
this.#connectTimer();
|
||||||
this.#onTimeChanged();
|
this.#onTimeChanged();
|
||||||
}
|
}
|
||||||
console.debug(`${this.#name} switcher enabled.`);
|
debug.message(`${this.#name} switcher enabled.`);
|
||||||
}
|
}
|
||||||
|
|
||||||
disable() {
|
disable() {
|
||||||
console.debug(`Disabling ${this.#name} switcher...`);
|
debug.message(`Disabling ${this.#name} switcher...`);
|
||||||
this.#disconnectTimer();
|
this.#disconnectTimer();
|
||||||
this.#unwatchStatus();
|
this.#unwatchStatus();
|
||||||
console.debug(`${this.#name} switcher disabled.`);
|
debug.message(`${this.#name} switcher disabled.`);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#watchStatus() {
|
#watchStatus() {
|
||||||
console.debug(`Watching ${this.#name} switching status...`);
|
debug.message(`Watching ${this.#name} switching status...`);
|
||||||
this.#statusConnection = this.#settings.connect('changed::enabled', this.#onStatusChanged.bind(this));
|
this.#statusConnection = this.#settings.connect('changed::enabled', this.#onStatusChanged.bind(this));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -72,11 +73,11 @@ var Switcher = class {
|
|||||||
this.#settings.disconnect(this.#statusConnection);
|
this.#settings.disconnect(this.#statusConnection);
|
||||||
this.#statusConnection = null;
|
this.#statusConnection = null;
|
||||||
}
|
}
|
||||||
console.debug(`Stopped watching ${this.#name} switching status.`);
|
debug.message(`Stopped watching ${this.#name} switching status.`);
|
||||||
}
|
}
|
||||||
|
|
||||||
#connectTimer() {
|
#connectTimer() {
|
||||||
console.debug(`Connecting ${this.#name} switcher to Timer...`);
|
debug.message(`Connecting ${this.#name} switcher to Timer...`);
|
||||||
this.#timerConnection = this.#timer.connect('time-changed', this.#onTimeChanged.bind(this));
|
this.#timerConnection = this.#timer.connect('time-changed', this.#onTimeChanged.bind(this));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -85,12 +86,12 @@ var Switcher = class {
|
|||||||
this.#timer.disconnect(this.#timerConnection);
|
this.#timer.disconnect(this.#timerConnection);
|
||||||
this.#timerConnection = null;
|
this.#timerConnection = null;
|
||||||
}
|
}
|
||||||
console.debug(`Disconnected ${this.#name} switcher from Timer.`);
|
debug.message(`Disconnected ${this.#name} switcher from Timer.`);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#onStatusChanged() {
|
#onStatusChanged() {
|
||||||
console.debug(`${this.#name} switching has been ${this.#settings.get_boolean('enabled') ? 'enabled' : 'disabled'}.`);
|
debug.message(`${this.#name} switching has been ${this.#settings.get_boolean('enabled') ? 'enabled' : 'disabled'}.`);
|
||||||
this.disable();
|
this.disable();
|
||||||
this.enable();
|
this.enable();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ const { extensionUtils } = imports.misc;
|
|||||||
|
|
||||||
const Me = extensionUtils.getCurrentExtension();
|
const Me = extensionUtils.getCurrentExtension();
|
||||||
|
|
||||||
|
const debug = Me.imports.debug;
|
||||||
const utils = Me.imports.utils;
|
const utils = Me.imports.utils;
|
||||||
|
|
||||||
const { Switcher } = Me.imports.modules.Switcher;
|
const { Switcher } = Me.imports.modules.Switcher;
|
||||||
@@ -40,6 +41,6 @@ var SwitcherCommands = class extends Switcher {
|
|||||||
if (!command)
|
if (!command)
|
||||||
return;
|
return;
|
||||||
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);
|
||||||
console.debug(`Spawned ${time} command.`);
|
debug.message(`Spawned ${time} command.`);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ const { extensionManager } = imports.ui.main;
|
|||||||
|
|
||||||
const Me = extensionUtils.getCurrentExtension();
|
const Me = extensionUtils.getCurrentExtension();
|
||||||
|
|
||||||
|
const debug = Me.imports.debug;
|
||||||
const utils = Me.imports.utils;
|
const utils = Me.imports.utils;
|
||||||
|
|
||||||
const { Switcher } = Me.imports.modules.Switcher;
|
const { Switcher } = Me.imports.modules.Switcher;
|
||||||
@@ -77,7 +78,7 @@ var SwitcherTheme = class extends Switcher {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#connectSettings() {
|
#connectSettings() {
|
||||||
console.debug(`Connecting ${this.#name} switcher to settings...`);
|
debug.message(`Connecting ${this.#name} switcher to settings...`);
|
||||||
this.#settingsConnections.push({
|
this.#settingsConnections.push({
|
||||||
settings: this.#settings,
|
settings: this.#settings,
|
||||||
id: this.#settings.connect('changed::day', this.#onDayVariantChanged.bind(this)),
|
id: this.#settings.connect('changed::day', this.#onDayVariantChanged.bind(this)),
|
||||||
@@ -97,22 +98,22 @@ var SwitcherTheme = class extends Switcher {
|
|||||||
#disconnectSettings() {
|
#disconnectSettings() {
|
||||||
this.#settingsConnections.forEach(connection => connection.settings.disconnect(connection.id));
|
this.#settingsConnections.forEach(connection => connection.settings.disconnect(connection.id));
|
||||||
this.#settingsConnections = [];
|
this.#settingsConnections = [];
|
||||||
console.debug(`Disconnected ${this.#name} switcher from settings.`);
|
debug.message(`Disconnected ${this.#name} switcher from settings.`);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#onDayVariantChanged() {
|
#onDayVariantChanged() {
|
||||||
console.debug(`Day ${this.#name} variant changed to '${this.#settings.get_string('day')}'.`);
|
debug.message(`Day ${this.#name} variant changed to '${this.#settings.get_string('day')}'.`);
|
||||||
this.#updateSystemTheme();
|
this.#updateSystemTheme();
|
||||||
}
|
}
|
||||||
|
|
||||||
#onNightVariantChanged() {
|
#onNightVariantChanged() {
|
||||||
console.debug(`Night ${this.#name} variant changed to '${this.#settings.get_string('night')}'.`);
|
debug.message(`Night ${this.#name} variant changed to '${this.#settings.get_string('night')}'.`);
|
||||||
this.#updateSystemTheme();
|
this.#updateSystemTheme();
|
||||||
}
|
}
|
||||||
|
|
||||||
#onSystemThemeChanged() {
|
#onSystemThemeChanged() {
|
||||||
console.debug(`System ${this.#name} changed to '${this.#systemSettings.get_string(this.#themeKey)}'.`);
|
debug.message(`System ${this.#name} changed to '${this.#systemSettings.get_string(this.#themeKey)}'.`);
|
||||||
this.#updateCurrentVariant();
|
this.#updateCurrentVariant();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -130,7 +131,7 @@ var SwitcherTheme = class extends Switcher {
|
|||||||
#updateSystemTheme() {
|
#updateSystemTheme() {
|
||||||
if (this.#timer.time === Time.UNKNOWN)
|
if (this.#timer.time === Time.UNKNOWN)
|
||||||
return;
|
return;
|
||||||
console.debug(`Setting the ${this.#timer.time} ${this.#name} variant...`);
|
debug.message(`Setting the ${this.#timer.time} ${this.#name} variant...`);
|
||||||
if (this.#systemSettings)
|
if (this.#systemSettings)
|
||||||
this.#systemSettings.set_string(this.#themeKey, this.#settings.get_string(this.#timer.time));
|
this.#systemSettings.set_string(this.#themeKey, this.#settings.get_string(this.#timer.time));
|
||||||
else if (this.#noSettingsUpdateSystemThemeCallback)
|
else if (this.#noSettingsUpdateSystemThemeCallback)
|
||||||
|
|||||||
+14
-13
@@ -9,6 +9,7 @@ const { main } = imports.ui;
|
|||||||
|
|
||||||
const Me = extensionUtils.getCurrentExtension();
|
const Me = extensionUtils.getCurrentExtension();
|
||||||
|
|
||||||
|
const debug = Me.imports.debug;
|
||||||
const utils = Me.imports.utils;
|
const utils = Me.imports.utils;
|
||||||
|
|
||||||
const { Time } = Me.imports.enums.Time;
|
const { Time } = Me.imports.enums.Time;
|
||||||
@@ -53,20 +54,20 @@ var Timer = class {
|
|||||||
}
|
}
|
||||||
|
|
||||||
enable() {
|
enable() {
|
||||||
console.debug('Enabling Timer...');
|
debug.message('Enabling Timer...');
|
||||||
this.#connectSettings();
|
this.#connectSettings();
|
||||||
this.#createSources();
|
this.#createSources();
|
||||||
this.#connectSources();
|
this.#connectSources();
|
||||||
this.#enableSources();
|
this.#enableSources();
|
||||||
console.debug('Timer enabled.');
|
debug.message('Timer enabled.');
|
||||||
}
|
}
|
||||||
|
|
||||||
disable() {
|
disable() {
|
||||||
console.debug('Disabling Timer...');
|
debug.message('Disabling Timer...');
|
||||||
this.#disconnectSources();
|
this.#disconnectSources();
|
||||||
this.#disableSources();
|
this.#disableSources();
|
||||||
this.#disconnectSettings();
|
this.#disconnectSettings();
|
||||||
console.debug('Timer disabled.');
|
debug.message('Timer disabled.');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -77,7 +78,7 @@ var Timer = class {
|
|||||||
set time(time) {
|
set time(time) {
|
||||||
if (time === this.#time)
|
if (time === this.#time)
|
||||||
return;
|
return;
|
||||||
console.debug(`Time has changed to ${time}.`);
|
debug.message(`Time has changed to ${time}.`);
|
||||||
this.#time = time;
|
this.#time = time;
|
||||||
if (this.#settings.get_boolean('transition'))
|
if (this.#settings.get_boolean('transition'))
|
||||||
main.layoutManager.screenTransition.run();
|
main.layoutManager.screenTransition.run();
|
||||||
@@ -87,7 +88,7 @@ var Timer = class {
|
|||||||
|
|
||||||
|
|
||||||
#connectSettings() {
|
#connectSettings() {
|
||||||
console.debug('Connecting Timer to settings...');
|
debug.message('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)),
|
||||||
@@ -117,7 +118,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 = [];
|
||||||
console.debug('Disconnected Timer from settings.');
|
debug.message('Disconnected Timer from settings.');
|
||||||
}
|
}
|
||||||
|
|
||||||
#createSources() {
|
#createSources() {
|
||||||
@@ -151,7 +152,7 @@ var Timer = class {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#connectSources() {
|
#connectSources() {
|
||||||
console.debug('Connecting to time sources...');
|
debug.message('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)),
|
||||||
@@ -161,7 +162,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 = [];
|
||||||
console.debug('Disconnected from time sources.');
|
debug.message('Disconnected from time sources.');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -185,17 +186,17 @@ var Timer = class {
|
|||||||
|
|
||||||
|
|
||||||
#getSource() {
|
#getSource() {
|
||||||
console.debug('Getting time source...');
|
debug.message('Getting time source...');
|
||||||
|
|
||||||
let source;
|
let source;
|
||||||
if (this.#settings.get_boolean('manual-time-source')) {
|
if (this.#settings.get_boolean('manual-time-source')) {
|
||||||
source = this.#settings.get_string('time-source');
|
source = this.#settings.get_string('time-source');
|
||||||
console.debug(`Time source is forced to ${source}.`);
|
debug.message(`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'))
|
||||||
) {
|
) {
|
||||||
console.debug(`Unable to choose ${source} time source, falling back to manual schedule.`);
|
debug.message(`Unable to choose ${source} time source, falling back to manual schedule.`);
|
||||||
source = 'schedule';
|
source = 'schedule';
|
||||||
this.#settings.set_string('time-source', source);
|
this.#settings.set_string('time-source', source);
|
||||||
}
|
}
|
||||||
@@ -206,7 +207,7 @@ var Timer = class {
|
|||||||
source = 'location';
|
source = 'location';
|
||||||
else
|
else
|
||||||
source = 'schedule';
|
source = 'schedule';
|
||||||
console.debug(`Time source is ${source}.`);
|
debug.message(`Time source is ${source}.`);
|
||||||
this.#settings.set_string('time-source', source);
|
this.#settings.set_string('time-source', source);
|
||||||
}
|
}
|
||||||
return source;
|
return source;
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ const Signals = imports.signals;
|
|||||||
|
|
||||||
const Me = extensionUtils.getCurrentExtension();
|
const Me = extensionUtils.getCurrentExtension();
|
||||||
|
|
||||||
|
const debug = Me.imports.debug;
|
||||||
const utils = Me.imports.utils;
|
const utils = Me.imports.utils;
|
||||||
|
|
||||||
const { Time } = Me.imports.enums.Time;
|
const { Time } = Me.imports.enums.Time;
|
||||||
@@ -46,22 +47,22 @@ var TimerLocation = class {
|
|||||||
}
|
}
|
||||||
|
|
||||||
enable() {
|
enable() {
|
||||||
console.debug('Enabling Location Timer...');
|
debug.message('Enabling Location Timer...');
|
||||||
this.#cancellable = new Gio.Cancellable();
|
this.#cancellable = new Gio.Cancellable();
|
||||||
this.#connectToGeoclue();
|
this.#connectToGeoclue();
|
||||||
this.#watchForTimeChange();
|
this.#watchForTimeChange();
|
||||||
this.#regularlyUpdateSuntimes();
|
this.#regularlyUpdateSuntimes();
|
||||||
console.debug('Location Timer enabled.');
|
debug.message('Location Timer enabled.');
|
||||||
}
|
}
|
||||||
|
|
||||||
disable() {
|
disable() {
|
||||||
console.debug('Disabling Location Timer...');
|
debug.message('Disabling Location Timer...');
|
||||||
this.#stopRegularlyUpdatingSuntimes();
|
this.#stopRegularlyUpdatingSuntimes();
|
||||||
this.#stopWatchingForTimeChange();
|
this.#stopWatchingForTimeChange();
|
||||||
this.#disconnectFromGeoclue();
|
this.#disconnectFromGeoclue();
|
||||||
this.#cancellable.cancel();
|
this.#cancellable.cancel();
|
||||||
this.#cancellable = null;
|
this.#cancellable = null;
|
||||||
console.debug('Location Timer disabled.');
|
debug.message('Location Timer disabled.');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -71,7 +72,7 @@ var TimerLocation = class {
|
|||||||
|
|
||||||
|
|
||||||
#connectToGeoclue() {
|
#connectToGeoclue() {
|
||||||
console.debug('Connecting to GeoClue...');
|
debug.message('Connecting to GeoClue...');
|
||||||
Geoclue.Simple.new(
|
Geoclue.Simple.new(
|
||||||
'org.gnome.Shell',
|
'org.gnome.Shell',
|
||||||
Geoclue.AccuracyLevel.CITY,
|
Geoclue.AccuracyLevel.CITY,
|
||||||
@@ -81,24 +82,24 @@ var TimerLocation = class {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#disconnectFromGeoclue() {
|
#disconnectFromGeoclue() {
|
||||||
console.debug('Disconnecting from GeoClue...');
|
debug.message('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;
|
||||||
}
|
}
|
||||||
console.debug('Disconnected from GeoClue.');
|
debug.message('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));
|
||||||
console.debug('Connected to GeoClue.');
|
debug.message('Connected to GeoClue.');
|
||||||
this.#onLocationUpdated();
|
this.#onLocationUpdated();
|
||||||
}
|
}
|
||||||
|
|
||||||
#onLocationUpdated(_geoclue, _location) {
|
#onLocationUpdated(_geoclue, _location) {
|
||||||
console.debug('Location has changed.');
|
debug.message('Location has changed.');
|
||||||
this.#updateLocation();
|
this.#updateLocation();
|
||||||
this.#updateSuntimes();
|
this.#updateSuntimes();
|
||||||
}
|
}
|
||||||
@@ -106,13 +107,13 @@ var TimerLocation = class {
|
|||||||
|
|
||||||
#updateLocation() {
|
#updateLocation() {
|
||||||
if (this.#geoclue) {
|
if (this.#geoclue) {
|
||||||
console.debug('Updating location...');
|
debug.message('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],
|
||||||
]);
|
]);
|
||||||
console.debug(`Current location: (${latitude};${longitude})`);
|
debug.message(`Current location: (${latitude};${longitude})`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -120,7 +121,7 @@ var TimerLocation = class {
|
|||||||
if (!this.location)
|
if (!this.location)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
console.debug('Updating sun times...');
|
debug.message('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;
|
||||||
@@ -162,11 +163,11 @@ var TimerLocation = class {
|
|||||||
|
|
||||||
this.#suntimes.set('sunrise', sunrise);
|
this.#suntimes.set('sunrise', sunrise);
|
||||||
this.#suntimes.set('sunset', sunset);
|
this.#suntimes.set('sunset', sunset);
|
||||||
console.debug(`New sun times: (sunrise: ${sunrise}; sunset: ${sunset})`);
|
debug.message(`New sun times: (sunrise: ${sunrise}; sunset: ${sunset})`);
|
||||||
}
|
}
|
||||||
|
|
||||||
#regularlyUpdateSuntimes() {
|
#regularlyUpdateSuntimes() {
|
||||||
console.debug('Regularly updating sun times...');
|
debug.message('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 GLib.SOURCE_CONTINUE;
|
return GLib.SOURCE_CONTINUE;
|
||||||
@@ -176,7 +177,7 @@ var TimerLocation = class {
|
|||||||
#stopRegularlyUpdatingSuntimes() {
|
#stopRegularlyUpdatingSuntimes() {
|
||||||
GLib.Source.remove(this.#regularlyUpdateSuntimesTimer);
|
GLib.Source.remove(this.#regularlyUpdateSuntimesTimer);
|
||||||
this.#regularlyUpdateSuntimesTimer = null;
|
this.#regularlyUpdateSuntimesTimer = null;
|
||||||
console.debug('Stopped regularly updating sun times.');
|
debug.message('Stopped regularly updating sun times.');
|
||||||
}
|
}
|
||||||
|
|
||||||
#isDaytime() {
|
#isDaytime() {
|
||||||
@@ -186,7 +187,7 @@ var TimerLocation = class {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#watchForTimeChange() {
|
#watchForTimeChange() {
|
||||||
console.debug('Watching for time change...');
|
debug.message('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 (this.#previouslyDaytime !== this.#isDaytime()) {
|
if (this.#previouslyDaytime !== this.#isDaytime()) {
|
||||||
this.#previouslyDaytime = this.#isDaytime();
|
this.#previouslyDaytime = this.#isDaytime();
|
||||||
@@ -198,7 +199,7 @@ var TimerLocation = class {
|
|||||||
|
|
||||||
#stopWatchingForTimeChange() {
|
#stopWatchingForTimeChange() {
|
||||||
GLib.Source.remove(this.#timeChangeTimer);
|
GLib.Source.remove(this.#timeChangeTimer);
|
||||||
console.debug('Stopped watching for time change.');
|
debug.message('Stopped watching for time change.');
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
Signals.addSignalMethods(TimerLocation.prototype);
|
Signals.addSignalMethods(TimerLocation.prototype);
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ const Signals = imports.signals;
|
|||||||
|
|
||||||
const Me = extensionUtils.getCurrentExtension();
|
const Me = extensionUtils.getCurrentExtension();
|
||||||
|
|
||||||
|
const debug = Me.imports.debug;
|
||||||
const utils = Me.imports.utils;
|
const utils = Me.imports.utils;
|
||||||
|
|
||||||
const { Time } = Me.imports.enums.Time;
|
const { Time } = Me.imports.enums.Time;
|
||||||
@@ -41,23 +42,23 @@ var TimerNightlight = class {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async enable() {
|
async enable() {
|
||||||
console.debug('Enabling Night Light Timer...');
|
debug.message('Enabling Night Light Timer...');
|
||||||
this.#cancellable = new Gio.Cancellable();
|
this.#cancellable = new Gio.Cancellable();
|
||||||
this.#colorDbusProxy = await this.#createColorDbusProxy();
|
this.#colorDbusProxy = await this.#createColorDbusProxy();
|
||||||
this.#connectSettings();
|
this.#connectSettings();
|
||||||
this.#listenToNightlightState();
|
this.#listenToNightlightState();
|
||||||
this.emit('time-changed', this.time);
|
this.emit('time-changed', this.time);
|
||||||
console.debug('Night Light Timer enabled.');
|
debug.message('Night Light Timer enabled.');
|
||||||
}
|
}
|
||||||
|
|
||||||
disable() {
|
disable() {
|
||||||
console.debug('Disabling Night Light Timer...');
|
debug.message('Disabling Night Light Timer...');
|
||||||
this.#stopListeningToNightlightState();
|
this.#stopListeningToNightlightState();
|
||||||
this.#disconnectSettings();
|
this.#disconnectSettings();
|
||||||
this.#colorDbusProxy = null;
|
this.#colorDbusProxy = null;
|
||||||
this.#cancellable.cancel();
|
this.#cancellable.cancel();
|
||||||
this.#cancellable = null;
|
this.#cancellable = null;
|
||||||
console.debug('Night Light Timer disabled.');
|
debug.message('Night Light Timer disabled.');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -67,7 +68,7 @@ var TimerNightlight = class {
|
|||||||
|
|
||||||
|
|
||||||
#createColorDbusProxy() {
|
#createColorDbusProxy() {
|
||||||
console.debug('Creating the Color DBus proxy...');
|
debug.message('Creating the Color DBus proxy...');
|
||||||
const ColorProxy = Gio.DBusProxy.makeProxyWrapper(COLOR_INTERFACE);
|
const ColorProxy = Gio.DBusProxy.makeProxyWrapper(COLOR_INTERFACE);
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
ColorProxy(
|
ColorProxy(
|
||||||
@@ -76,7 +77,7 @@ var TimerNightlight = class {
|
|||||||
'/org/gnome/SettingsDaemon/Color',
|
'/org/gnome/SettingsDaemon/Color',
|
||||||
(proxy, error) => {
|
(proxy, error) => {
|
||||||
if (error === null) {
|
if (error === null) {
|
||||||
console.debug('Created the Color DBus proxy.');
|
debug.message('Created the Color DBus proxy.');
|
||||||
resolve(proxy);
|
resolve(proxy);
|
||||||
} else {
|
} else {
|
||||||
reject(error);
|
reject(error);
|
||||||
@@ -89,7 +90,7 @@ var TimerNightlight = class {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#connectSettings() {
|
#connectSettings() {
|
||||||
console.debug('Connecting Night Light Timer to settings...');
|
debug.message('Connecting Night Light Timer to settings...');
|
||||||
this.#settingsConnections.push({
|
this.#settingsConnections.push({
|
||||||
settings: this.#settings,
|
settings: this.#settings,
|
||||||
id: this.#settings.connect('changed::nightlight-follow-disable', this.#onNightlightFollowDisableChanged.bind(this)),
|
id: this.#settings.connect('changed::nightlight-follow-disable', this.#onNightlightFollowDisableChanged.bind(this)),
|
||||||
@@ -97,13 +98,13 @@ var TimerNightlight = class {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#disconnectSettings() {
|
#disconnectSettings() {
|
||||||
console.debug('Disconnecting Night Light Timer from settings...');
|
debug.message('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() {
|
||||||
console.debug('Listening to Night Light state...');
|
debug.message('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)
|
||||||
@@ -115,7 +116,7 @@ var TimerNightlight = class {
|
|||||||
this.#colorDbusProxy.disconnect(this.#nightlightStateConnection);
|
this.#colorDbusProxy.disconnect(this.#nightlightStateConnection);
|
||||||
this.#nightlightStateConnection = null;
|
this.#nightlightStateConnection = null;
|
||||||
}
|
}
|
||||||
console.debug('Stopped listening to Night Light state.');
|
debug.message('Stopped listening to Night Light state.');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -126,7 +127,7 @@ var TimerNightlight = class {
|
|||||||
#onNightlightStateChanged(_sender, _dbusProperties) {
|
#onNightlightStateChanged(_sender, _dbusProperties) {
|
||||||
const newState = this.#isNightlightActive();
|
const newState = this.#isNightlightActive();
|
||||||
if (newState !== this.#previousNightlightState) {
|
if (newState !== this.#previousNightlightState) {
|
||||||
console.debug(`Night Light has become ${newState ? '' : 'in'}active.`);
|
debug.message(`Night Light has become ${newState ? '' : 'in'}active.`);
|
||||||
this.#previousNightlightState = newState;
|
this.#previousNightlightState = newState;
|
||||||
this.emit('time-changed', newState ? Time.NIGHT : Time.DAY);
|
this.emit('time-changed', newState ? Time.NIGHT : Time.DAY);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ const { PopupMenuItem, PopupSubMenuMenuItem } = imports.ui.popupMenu;
|
|||||||
const Me = extensionUtils.getCurrentExtension();
|
const Me = extensionUtils.getCurrentExtension();
|
||||||
const _ = extensionUtils.gettext;
|
const _ = extensionUtils.gettext;
|
||||||
|
|
||||||
|
const debug = Me.imports.debug;
|
||||||
const utils = Me.imports.utils;
|
const utils = Me.imports.utils;
|
||||||
|
|
||||||
const { Time } = Me.imports.enums.Time;
|
const { Time } = Me.imports.enums.Time;
|
||||||
@@ -38,22 +39,22 @@ var TimerOndemand = class {
|
|||||||
}
|
}
|
||||||
|
|
||||||
enable() {
|
enable() {
|
||||||
console.debug('Enabling On-demand Timer...');
|
debug.message('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);
|
||||||
console.debug('On-demand Timer enabled.');
|
debug.message('On-demand Timer enabled.');
|
||||||
}
|
}
|
||||||
|
|
||||||
disable() {
|
disable() {
|
||||||
console.debug('Disabling On-demand Timer...');
|
debug.message('Disabling On-demand Timer...');
|
||||||
this.#disconnectTimer();
|
this.#disconnectTimer();
|
||||||
this.#removeKeybinding();
|
this.#removeKeybinding();
|
||||||
this.#removeButton();
|
this.#removeButton();
|
||||||
this.#disconnectSettings();
|
this.#disconnectSettings();
|
||||||
console.debug('On-demand Timer disabled.');
|
debug.message('On-demand Timer disabled.');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -63,7 +64,7 @@ var TimerOndemand = class {
|
|||||||
|
|
||||||
|
|
||||||
#connectSettings() {
|
#connectSettings() {
|
||||||
console.debug('Connecting On-demand Timer to settings...');
|
debug.message('Connecting On-demand Timer to settings...');
|
||||||
this.#settingsConnections.push({
|
this.#settingsConnections.push({
|
||||||
settings: this.#settings,
|
settings: this.#settings,
|
||||||
id: this.#settings.connect('changed::ondemand-time', this.#onOndemandTimeChanged.bind(this)),
|
id: this.#settings.connect('changed::ondemand-time', this.#onOndemandTimeChanged.bind(this)),
|
||||||
@@ -79,13 +80,13 @@ var TimerOndemand = class {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#disconnectSettings() {
|
#disconnectSettings() {
|
||||||
console.debug('Disconnecting On-demand Timer from settings...');
|
debug.message('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() {
|
||||||
console.debug('Connecting On-demand Timer to Timer...');
|
debug.message('Connecting On-demand Timer to Timer...');
|
||||||
this.#timerConnection = this.#timer.connect('time-changed', this.#onTimeChanged.bind(this));
|
this.#timerConnection = this.#timer.connect('time-changed', this.#onTimeChanged.bind(this));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -94,7 +95,7 @@ var TimerOndemand = class {
|
|||||||
this.#timer.disconnect(this.#timerConnection);
|
this.#timer.disconnect(this.#timerConnection);
|
||||||
this.#timerConnection = null;
|
this.#timerConnection = null;
|
||||||
}
|
}
|
||||||
console.debug('Disconnected On-demand Timer from Timer.');
|
debug.message('Disconnected On-demand Timer from Timer.');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -122,7 +123,7 @@ var TimerOndemand = class {
|
|||||||
this.#previousKeybinding = this.#settings.get_strv('nightthemeswitcher-ondemand-keybinding')[0];
|
this.#previousKeybinding = this.#settings.get_strv('nightthemeswitcher-ondemand-keybinding')[0];
|
||||||
if (!this.#settings.get_strv('nightthemeswitcher-ondemand-keybinding')[0])
|
if (!this.#settings.get_strv('nightthemeswitcher-ondemand-keybinding')[0])
|
||||||
return;
|
return;
|
||||||
console.debug('Adding On-demand Timer keybinding...');
|
debug.message('Adding On-demand Timer keybinding...');
|
||||||
main.wm.addKeybinding(
|
main.wm.addKeybinding(
|
||||||
'nightthemeswitcher-ondemand-keybinding',
|
'nightthemeswitcher-ondemand-keybinding',
|
||||||
this.#settings,
|
this.#settings,
|
||||||
@@ -130,14 +131,14 @@ var TimerOndemand = class {
|
|||||||
Shell.ActionMode.NORMAL | Shell.ActionMode.OVERVIEW,
|
Shell.ActionMode.NORMAL | Shell.ActionMode.OVERVIEW,
|
||||||
this.#toggleTime.bind(this)
|
this.#toggleTime.bind(this)
|
||||||
);
|
);
|
||||||
console.debug('Added On-demand Timer keybinding.');
|
debug.message('Added On-demand Timer keybinding.');
|
||||||
}
|
}
|
||||||
|
|
||||||
#removeKeybinding() {
|
#removeKeybinding() {
|
||||||
if (this.#previousKeybinding) {
|
if (this.#previousKeybinding) {
|
||||||
console.debug('Removing On-demand Timer keybinding...');
|
debug.message('Removing On-demand Timer keybinding...');
|
||||||
main.wm.removeKeybinding('nightthemeswitcher-ondemand-keybinding');
|
main.wm.removeKeybinding('nightthemeswitcher-ondemand-keybinding');
|
||||||
console.debug('Removed On-demand Timer keybinding.');
|
debug.message('Removed On-demand Timer keybinding.');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -153,35 +154,35 @@ var TimerOndemand = class {
|
|||||||
|
|
||||||
#removeButton() {
|
#removeButton() {
|
||||||
if (this.#button) {
|
if (this.#button) {
|
||||||
console.debug('Removing On-demand Timer button...');
|
debug.message('Removing On-demand Timer button...');
|
||||||
this.#button.destroy();
|
this.#button.destroy();
|
||||||
this.#button = null;
|
this.#button = null;
|
||||||
console.debug('Removed On-demand Timer button.');
|
debug.message('Removed On-demand Timer button.');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#updateButton() {
|
#updateButton() {
|
||||||
if (this.#button) {
|
if (this.#button) {
|
||||||
console.debug('Updating On-demand Timer button state...');
|
debug.message('Updating On-demand Timer button state...');
|
||||||
this.#button.update();
|
this.#button.update();
|
||||||
console.debug('Updated On-demand Timer button state.');
|
debug.message('Updated On-demand Timer button state.');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#addButtonToPanel() {
|
#addButtonToPanel() {
|
||||||
console.debug('Adding On-demand Timer button to the panel...');
|
debug.message('Adding On-demand Timer button to the panel...');
|
||||||
this.#button = new NtsPanelMenuButton({ timer: this.#timer, toggleCallback: this.#toggleTime.bind(this) });
|
this.#button = new NtsPanelMenuButton({ timer: this.#timer, toggleCallback: this.#toggleTime.bind(this) });
|
||||||
main.panel.addToStatusArea('NightThemeSwitcherButton', this.#button);
|
main.panel.addToStatusArea('NightThemeSwitcherButton', this.#button);
|
||||||
console.debug('Added On-demand Timer button to the panel.');
|
debug.message('Added On-demand Timer button to the panel.');
|
||||||
}
|
}
|
||||||
|
|
||||||
#addButtonToMenu() {
|
#addButtonToMenu() {
|
||||||
console.debug('Adding On-demand Timer button to the menu...');
|
debug.message('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 NtsPopupSubMenuMenuItem({ timer: this.#timer, toggleCallback: this.#toggleTime.bind(this) });
|
this.#button = new NtsPopupSubMenuMenuItem({ timer: this.#timer, toggleCallback: this.#toggleTime.bind(this) });
|
||||||
aggregateMenu.menu.addMenuItem(this.#button, position);
|
aggregateMenu.menu.addMenuItem(this.#button, position);
|
||||||
console.debug('Added On-demand Timer button to the menu.');
|
debug.message('Added On-demand Timer button to the menu.');
|
||||||
}
|
}
|
||||||
|
|
||||||
#toggleTime() {
|
#toggleTime() {
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ const Signals = imports.signals;
|
|||||||
|
|
||||||
const Me = extensionUtils.getCurrentExtension();
|
const Me = extensionUtils.getCurrentExtension();
|
||||||
|
|
||||||
|
const debug = Me.imports.debug;
|
||||||
const utils = Me.imports.utils;
|
const utils = Me.imports.utils;
|
||||||
|
|
||||||
const { Time } = Me.imports.enums.Time;
|
const { Time } = Me.imports.enums.Time;
|
||||||
@@ -31,16 +32,16 @@ var TimerSchedule = class {
|
|||||||
}
|
}
|
||||||
|
|
||||||
enable() {
|
enable() {
|
||||||
console.debug('Enabling Schedule Timer...');
|
debug.message('Enabling Schedule Timer...');
|
||||||
this.#watchForTimeChange();
|
this.#watchForTimeChange();
|
||||||
this.emit('time-changed', this.time);
|
this.emit('time-changed', this.time);
|
||||||
console.debug('Schedule Timer enabled.');
|
debug.message('Schedule Timer enabled.');
|
||||||
}
|
}
|
||||||
|
|
||||||
disable() {
|
disable() {
|
||||||
console.debug('Disabling Schedule Timer...');
|
debug.message('Disabling Schedule Timer...');
|
||||||
this.#stopWatchingForTimeChange();
|
this.#stopWatchingForTimeChange();
|
||||||
console.debug('Schedule Timer disabled.');
|
debug.message('Schedule Timer disabled.');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -56,7 +57,7 @@ var TimerSchedule = class {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#watchForTimeChange() {
|
#watchForTimeChange() {
|
||||||
console.debug('Watching for time change...');
|
debug.message('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 (this.#previouslyDaytime !== this.#isDaytime()) {
|
if (this.#previouslyDaytime !== this.#isDaytime()) {
|
||||||
this.#previouslyDaytime = this.#isDaytime();
|
this.#previouslyDaytime = this.#isDaytime();
|
||||||
@@ -68,7 +69,7 @@ var TimerSchedule = class {
|
|||||||
|
|
||||||
#stopWatchingForTimeChange() {
|
#stopWatchingForTimeChange() {
|
||||||
GLib.Source.remove(this.#timeChangeTimer);
|
GLib.Source.remove(this.#timeChangeTimer);
|
||||||
console.debug('Stopped watching for time change.');
|
debug.message('Stopped watching for time change.');
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
Signals.addSignalMethods(TimerSchedule.prototype);
|
Signals.addSignalMethods(TimerSchedule.prototype);
|
||||||
|
|||||||
Reference in New Issue
Block a user