Extension: Add debug mode
This commit is contained in:
+2
-1
@@ -72,7 +72,8 @@ extension:
|
||||
- apt update
|
||||
- apt install --no-install-recommends -y gettext libglib2.0-bin libglib2.0-dev-bin meson zip
|
||||
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
|
||||
artifacts:
|
||||
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 debug = Me.imports.debug;
|
||||
const utils = Me.imports.utils;
|
||||
|
||||
const { SwitcherCommands } = Me.imports.modules.SwitcherCommands;
|
||||
@@ -24,13 +25,13 @@ class NightThemeSwitcher {
|
||||
#switcherCommands = null;
|
||||
|
||||
constructor() {
|
||||
console.debug('Initializing extension...');
|
||||
debug.message('Initializing extension...');
|
||||
extensionUtils.initTranslations();
|
||||
console.debug('Extension initialized.');
|
||||
debug.message('Extension initialized.');
|
||||
}
|
||||
|
||||
enable() {
|
||||
console.debug('Enabling extension...');
|
||||
debug.message('Enabling extension...');
|
||||
this.#timer = new Timer();
|
||||
this.#switcherThemeGtk = new SwitcherThemeGtk({ timer: this.#timer });
|
||||
this.#switcherThemeIcon = new SwitcherThemeIcon({ timer: this.#timer });
|
||||
@@ -45,14 +46,14 @@ class NightThemeSwitcher {
|
||||
this.#switcherThemeCursor.enable();
|
||||
this.#switcherCommands.enable();
|
||||
|
||||
console.debug('Extension enabled.');
|
||||
debug.message('Extension enabled.');
|
||||
}
|
||||
|
||||
disable() {
|
||||
// Extension won't be disabled in `unlock-dialog` session mode. This is
|
||||
// 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.
|
||||
console.debug('Disabling extension...');
|
||||
debug.message('Disabling extension...');
|
||||
|
||||
if (this.#switcherThemeGtk) {
|
||||
this.#switcherThemeGtk.disable();
|
||||
@@ -79,7 +80,7 @@ class NightThemeSwitcher {
|
||||
this.#timer = null;
|
||||
}
|
||||
|
||||
console.debug('Extension disabled.');
|
||||
debug.message('Extension disabled.');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -12,6 +12,15 @@ configure_file(
|
||||
install_dir: INSTALL_DIR
|
||||
)
|
||||
|
||||
configure_file(
|
||||
input: 'debug.js',
|
||||
output: 'debug.js',
|
||||
configuration: {
|
||||
'BUILD_TYPE': get_option('buildtype')
|
||||
},
|
||||
install_dir: INSTALL_DIR
|
||||
)
|
||||
|
||||
main = [
|
||||
'extension.js',
|
||||
'prefs.js',
|
||||
|
||||
+10
-9
@@ -6,6 +6,7 @@ const { extensionUtils } = imports.misc;
|
||||
|
||||
const Me = extensionUtils.getCurrentExtension();
|
||||
|
||||
const debug = Me.imports.debug;
|
||||
const utils = Me.imports.utils;
|
||||
|
||||
const { Time } = Me.imports.enums.Time;
|
||||
@@ -45,25 +46,25 @@ var Switcher = class {
|
||||
}
|
||||
|
||||
enable() {
|
||||
console.debug(`Enabling ${this.#name} switcher...`);
|
||||
debug.message(`Enabling ${this.#name} switcher...`);
|
||||
this.#watchStatus();
|
||||
if (this.#settings.get_boolean('enabled')) {
|
||||
this.#connectTimer();
|
||||
this.#onTimeChanged();
|
||||
}
|
||||
console.debug(`${this.#name} switcher enabled.`);
|
||||
debug.message(`${this.#name} switcher enabled.`);
|
||||
}
|
||||
|
||||
disable() {
|
||||
console.debug(`Disabling ${this.#name} switcher...`);
|
||||
debug.message(`Disabling ${this.#name} switcher...`);
|
||||
this.#disconnectTimer();
|
||||
this.#unwatchStatus();
|
||||
console.debug(`${this.#name} switcher disabled.`);
|
||||
debug.message(`${this.#name} switcher disabled.`);
|
||||
}
|
||||
|
||||
|
||||
#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));
|
||||
}
|
||||
|
||||
@@ -72,11 +73,11 @@ var Switcher = class {
|
||||
this.#settings.disconnect(this.#statusConnection);
|
||||
this.#statusConnection = null;
|
||||
}
|
||||
console.debug(`Stopped watching ${this.#name} switching status.`);
|
||||
debug.message(`Stopped watching ${this.#name} switching status.`);
|
||||
}
|
||||
|
||||
#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));
|
||||
}
|
||||
|
||||
@@ -85,12 +86,12 @@ var Switcher = class {
|
||||
this.#timer.disconnect(this.#timerConnection);
|
||||
this.#timerConnection = null;
|
||||
}
|
||||
console.debug(`Disconnected ${this.#name} switcher from Timer.`);
|
||||
debug.message(`Disconnected ${this.#name} switcher from Timer.`);
|
||||
}
|
||||
|
||||
|
||||
#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.enable();
|
||||
}
|
||||
|
||||
@@ -6,6 +6,7 @@ const { extensionUtils } = imports.misc;
|
||||
|
||||
const Me = extensionUtils.getCurrentExtension();
|
||||
|
||||
const debug = Me.imports.debug;
|
||||
const utils = Me.imports.utils;
|
||||
|
||||
const { Switcher } = Me.imports.modules.Switcher;
|
||||
@@ -40,6 +41,6 @@ var SwitcherCommands = class extends Switcher {
|
||||
if (!command)
|
||||
return;
|
||||
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 debug = Me.imports.debug;
|
||||
const utils = Me.imports.utils;
|
||||
|
||||
const { Switcher } = Me.imports.modules.Switcher;
|
||||
@@ -77,7 +78,7 @@ var SwitcherTheme = class extends Switcher {
|
||||
}
|
||||
|
||||
#connectSettings() {
|
||||
console.debug(`Connecting ${this.#name} switcher to settings...`);
|
||||
debug.message(`Connecting ${this.#name} switcher to settings...`);
|
||||
this.#settingsConnections.push({
|
||||
settings: this.#settings,
|
||||
id: this.#settings.connect('changed::day', this.#onDayVariantChanged.bind(this)),
|
||||
@@ -97,22 +98,22 @@ var SwitcherTheme = class extends Switcher {
|
||||
#disconnectSettings() {
|
||||
this.#settingsConnections.forEach(connection => connection.settings.disconnect(connection.id));
|
||||
this.#settingsConnections = [];
|
||||
console.debug(`Disconnected ${this.#name} switcher from settings.`);
|
||||
debug.message(`Disconnected ${this.#name} switcher from settings.`);
|
||||
}
|
||||
|
||||
|
||||
#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();
|
||||
}
|
||||
|
||||
#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();
|
||||
}
|
||||
|
||||
#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();
|
||||
}
|
||||
|
||||
@@ -130,7 +131,7 @@ var SwitcherTheme = class extends Switcher {
|
||||
#updateSystemTheme() {
|
||||
if (this.#timer.time === Time.UNKNOWN)
|
||||
return;
|
||||
console.debug(`Setting the ${this.#timer.time} ${this.#name} variant...`);
|
||||
debug.message(`Setting the ${this.#timer.time} ${this.#name} variant...`);
|
||||
if (this.#systemSettings)
|
||||
this.#systemSettings.set_string(this.#themeKey, this.#settings.get_string(this.#timer.time));
|
||||
else if (this.#noSettingsUpdateSystemThemeCallback)
|
||||
|
||||
+14
-13
@@ -9,6 +9,7 @@ const { main } = imports.ui;
|
||||
|
||||
const Me = extensionUtils.getCurrentExtension();
|
||||
|
||||
const debug = Me.imports.debug;
|
||||
const utils = Me.imports.utils;
|
||||
|
||||
const { Time } = Me.imports.enums.Time;
|
||||
@@ -53,20 +54,20 @@ var Timer = class {
|
||||
}
|
||||
|
||||
enable() {
|
||||
console.debug('Enabling Timer...');
|
||||
debug.message('Enabling Timer...');
|
||||
this.#connectSettings();
|
||||
this.#createSources();
|
||||
this.#connectSources();
|
||||
this.#enableSources();
|
||||
console.debug('Timer enabled.');
|
||||
debug.message('Timer enabled.');
|
||||
}
|
||||
|
||||
disable() {
|
||||
console.debug('Disabling Timer...');
|
||||
debug.message('Disabling Timer...');
|
||||
this.#disconnectSources();
|
||||
this.#disableSources();
|
||||
this.#disconnectSettings();
|
||||
console.debug('Timer disabled.');
|
||||
debug.message('Timer disabled.');
|
||||
}
|
||||
|
||||
|
||||
@@ -77,7 +78,7 @@ var Timer = class {
|
||||
set time(time) {
|
||||
if (time === this.#time)
|
||||
return;
|
||||
console.debug(`Time has changed to ${time}.`);
|
||||
debug.message(`Time has changed to ${time}.`);
|
||||
this.#time = time;
|
||||
if (this.#settings.get_boolean('transition'))
|
||||
main.layoutManager.screenTransition.run();
|
||||
@@ -87,7 +88,7 @@ var Timer = class {
|
||||
|
||||
|
||||
#connectSettings() {
|
||||
console.debug('Connecting Timer to settings...');
|
||||
debug.message('Connecting Timer to settings...');
|
||||
this.#settingsConnections.push({
|
||||
settings: this.#colorSettings,
|
||||
id: this.#colorSettings.connect('changed::night-light-enabled', this.#onSourceChanged.bind(this)),
|
||||
@@ -117,7 +118,7 @@ var Timer = class {
|
||||
#disconnectSettings() {
|
||||
this.#settingsConnections.forEach(connection => connection.settings.disconnect(connection.id));
|
||||
this.#settingsConnections = [];
|
||||
console.debug('Disconnected Timer from settings.');
|
||||
debug.message('Disconnected Timer from settings.');
|
||||
}
|
||||
|
||||
#createSources() {
|
||||
@@ -151,7 +152,7 @@ var Timer = class {
|
||||
}
|
||||
|
||||
#connectSources() {
|
||||
console.debug('Connecting to time sources...');
|
||||
debug.message('Connecting to time sources...');
|
||||
this.#sources.forEach(source => this.#timeConnections.push({
|
||||
source,
|
||||
id: source.connect('time-changed', this.#onTimeChanged.bind(this)),
|
||||
@@ -161,7 +162,7 @@ var Timer = class {
|
||||
#disconnectSources() {
|
||||
this.#timeConnections.forEach(connection => connection.source.disconnect(connection.id));
|
||||
this.#timeConnections = [];
|
||||
console.debug('Disconnected from time sources.');
|
||||
debug.message('Disconnected from time sources.');
|
||||
}
|
||||
|
||||
|
||||
@@ -185,17 +186,17 @@ var Timer = class {
|
||||
|
||||
|
||||
#getSource() {
|
||||
console.debug('Getting time source...');
|
||||
debug.message('Getting time source...');
|
||||
|
||||
let source;
|
||||
if (this.#settings.get_boolean('manual-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 (
|
||||
(source === 'nightlight' && !this.#colorSettings.get_boolean('night-light-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';
|
||||
this.#settings.set_string('time-source', source);
|
||||
}
|
||||
@@ -206,7 +207,7 @@ var Timer = class {
|
||||
source = 'location';
|
||||
else
|
||||
source = 'schedule';
|
||||
console.debug(`Time source is ${source}.`);
|
||||
debug.message(`Time source is ${source}.`);
|
||||
this.#settings.set_string('time-source', source);
|
||||
}
|
||||
return source;
|
||||
|
||||
@@ -7,6 +7,7 @@ const Signals = imports.signals;
|
||||
|
||||
const Me = extensionUtils.getCurrentExtension();
|
||||
|
||||
const debug = Me.imports.debug;
|
||||
const utils = Me.imports.utils;
|
||||
|
||||
const { Time } = Me.imports.enums.Time;
|
||||
@@ -46,22 +47,22 @@ var TimerLocation = class {
|
||||
}
|
||||
|
||||
enable() {
|
||||
console.debug('Enabling Location Timer...');
|
||||
debug.message('Enabling Location Timer...');
|
||||
this.#cancellable = new Gio.Cancellable();
|
||||
this.#connectToGeoclue();
|
||||
this.#watchForTimeChange();
|
||||
this.#regularlyUpdateSuntimes();
|
||||
console.debug('Location Timer enabled.');
|
||||
debug.message('Location Timer enabled.');
|
||||
}
|
||||
|
||||
disable() {
|
||||
console.debug('Disabling Location Timer...');
|
||||
debug.message('Disabling Location Timer...');
|
||||
this.#stopRegularlyUpdatingSuntimes();
|
||||
this.#stopWatchingForTimeChange();
|
||||
this.#disconnectFromGeoclue();
|
||||
this.#cancellable.cancel();
|
||||
this.#cancellable = null;
|
||||
console.debug('Location Timer disabled.');
|
||||
debug.message('Location Timer disabled.');
|
||||
}
|
||||
|
||||
|
||||
@@ -71,7 +72,7 @@ var TimerLocation = class {
|
||||
|
||||
|
||||
#connectToGeoclue() {
|
||||
console.debug('Connecting to GeoClue...');
|
||||
debug.message('Connecting to GeoClue...');
|
||||
Geoclue.Simple.new(
|
||||
'org.gnome.Shell',
|
||||
Geoclue.AccuracyLevel.CITY,
|
||||
@@ -81,24 +82,24 @@ var TimerLocation = class {
|
||||
}
|
||||
|
||||
#disconnectFromGeoclue() {
|
||||
console.debug('Disconnecting from GeoClue...');
|
||||
debug.message('Disconnecting from GeoClue...');
|
||||
if (this.#geoclueConnection) {
|
||||
this.#geoclue.disconnect(this.#geoclueConnection);
|
||||
this.#geoclueConnection = null;
|
||||
}
|
||||
console.debug('Disconnected from GeoClue.');
|
||||
debug.message('Disconnected from GeoClue.');
|
||||
}
|
||||
|
||||
|
||||
#onGeoclueReady(_, result) {
|
||||
this.#geoclue = Geoclue.Simple.new_finish(result);
|
||||
this.#geoclueConnection = this.#geoclue.connect('notify::location', this.#onLocationUpdated.bind(this));
|
||||
console.debug('Connected to GeoClue.');
|
||||
debug.message('Connected to GeoClue.');
|
||||
this.#onLocationUpdated();
|
||||
}
|
||||
|
||||
#onLocationUpdated(_geoclue, _location) {
|
||||
console.debug('Location has changed.');
|
||||
debug.message('Location has changed.');
|
||||
this.#updateLocation();
|
||||
this.#updateSuntimes();
|
||||
}
|
||||
@@ -106,13 +107,13 @@ var TimerLocation = class {
|
||||
|
||||
#updateLocation() {
|
||||
if (this.#geoclue) {
|
||||
console.debug('Updating location...');
|
||||
debug.message('Updating location...');
|
||||
const { latitude, longitude } = this.#geoclue.get_location();
|
||||
this.location = new Map([
|
||||
['latitude', latitude],
|
||||
['longitude', longitude],
|
||||
]);
|
||||
console.debug(`Current location: (${latitude};${longitude})`);
|
||||
debug.message(`Current location: (${latitude};${longitude})`);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -120,7 +121,7 @@ var TimerLocation = class {
|
||||
if (!this.location)
|
||||
return;
|
||||
|
||||
console.debug('Updating sun times...');
|
||||
debug.message('Updating sun times...');
|
||||
|
||||
Math.rad = degrees => degrees * Math.PI / 180;
|
||||
Math.deg = radians => radians * 180 / Math.PI;
|
||||
@@ -162,11 +163,11 @@ var TimerLocation = class {
|
||||
|
||||
this.#suntimes.set('sunrise', sunrise);
|
||||
this.#suntimes.set('sunset', sunset);
|
||||
console.debug(`New sun times: (sunrise: ${sunrise}; sunset: ${sunset})`);
|
||||
debug.message(`New sun times: (sunrise: ${sunrise}; sunset: ${sunset})`);
|
||||
}
|
||||
|
||||
#regularlyUpdateSuntimes() {
|
||||
console.debug('Regularly updating sun times...');
|
||||
debug.message('Regularly updating sun times...');
|
||||
this.#regularlyUpdateSuntimesTimer = GLib.timeout_add_seconds(GLib.PRIORITY_DEFAULT, 3600, () => {
|
||||
this.#updateSuntimes();
|
||||
return GLib.SOURCE_CONTINUE;
|
||||
@@ -176,7 +177,7 @@ var TimerLocation = class {
|
||||
#stopRegularlyUpdatingSuntimes() {
|
||||
GLib.Source.remove(this.#regularlyUpdateSuntimesTimer);
|
||||
this.#regularlyUpdateSuntimesTimer = null;
|
||||
console.debug('Stopped regularly updating sun times.');
|
||||
debug.message('Stopped regularly updating sun times.');
|
||||
}
|
||||
|
||||
#isDaytime() {
|
||||
@@ -186,7 +187,7 @@ var TimerLocation = class {
|
||||
}
|
||||
|
||||
#watchForTimeChange() {
|
||||
console.debug('Watching for time change...');
|
||||
debug.message('Watching for time change...');
|
||||
this.#timeChangeTimer = GLib.timeout_add_seconds(GLib.PRIORITY_DEFAULT, 1, () => {
|
||||
if (this.#previouslyDaytime !== this.#isDaytime()) {
|
||||
this.#previouslyDaytime = this.#isDaytime();
|
||||
@@ -198,7 +199,7 @@ var TimerLocation = class {
|
||||
|
||||
#stopWatchingForTimeChange() {
|
||||
GLib.Source.remove(this.#timeChangeTimer);
|
||||
console.debug('Stopped watching for time change.');
|
||||
debug.message('Stopped watching for time change.');
|
||||
}
|
||||
};
|
||||
Signals.addSignalMethods(TimerLocation.prototype);
|
||||
|
||||
@@ -7,6 +7,7 @@ const Signals = imports.signals;
|
||||
|
||||
const Me = extensionUtils.getCurrentExtension();
|
||||
|
||||
const debug = Me.imports.debug;
|
||||
const utils = Me.imports.utils;
|
||||
|
||||
const { Time } = Me.imports.enums.Time;
|
||||
@@ -41,23 +42,23 @@ var TimerNightlight = class {
|
||||
}
|
||||
|
||||
async enable() {
|
||||
console.debug('Enabling Night Light Timer...');
|
||||
debug.message('Enabling Night Light Timer...');
|
||||
this.#cancellable = new Gio.Cancellable();
|
||||
this.#colorDbusProxy = await this.#createColorDbusProxy();
|
||||
this.#connectSettings();
|
||||
this.#listenToNightlightState();
|
||||
this.emit('time-changed', this.time);
|
||||
console.debug('Night Light Timer enabled.');
|
||||
debug.message('Night Light Timer enabled.');
|
||||
}
|
||||
|
||||
disable() {
|
||||
console.debug('Disabling Night Light Timer...');
|
||||
debug.message('Disabling Night Light Timer...');
|
||||
this.#stopListeningToNightlightState();
|
||||
this.#disconnectSettings();
|
||||
this.#colorDbusProxy = null;
|
||||
this.#cancellable.cancel();
|
||||
this.#cancellable = null;
|
||||
console.debug('Night Light Timer disabled.');
|
||||
debug.message('Night Light Timer disabled.');
|
||||
}
|
||||
|
||||
|
||||
@@ -67,7 +68,7 @@ var TimerNightlight = class {
|
||||
|
||||
|
||||
#createColorDbusProxy() {
|
||||
console.debug('Creating the Color DBus proxy...');
|
||||
debug.message('Creating the Color DBus proxy...');
|
||||
const ColorProxy = Gio.DBusProxy.makeProxyWrapper(COLOR_INTERFACE);
|
||||
return new Promise((resolve, reject) => {
|
||||
ColorProxy(
|
||||
@@ -76,7 +77,7 @@ var TimerNightlight = class {
|
||||
'/org/gnome/SettingsDaemon/Color',
|
||||
(proxy, error) => {
|
||||
if (error === null) {
|
||||
console.debug('Created the Color DBus proxy.');
|
||||
debug.message('Created the Color DBus proxy.');
|
||||
resolve(proxy);
|
||||
} else {
|
||||
reject(error);
|
||||
@@ -89,7 +90,7 @@ var TimerNightlight = class {
|
||||
}
|
||||
|
||||
#connectSettings() {
|
||||
console.debug('Connecting Night Light Timer to settings...');
|
||||
debug.message('Connecting Night Light Timer to settings...');
|
||||
this.#settingsConnections.push({
|
||||
settings: this.#settings,
|
||||
id: this.#settings.connect('changed::nightlight-follow-disable', this.#onNightlightFollowDisableChanged.bind(this)),
|
||||
@@ -97,13 +98,13 @@ var TimerNightlight = class {
|
||||
}
|
||||
|
||||
#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 = [];
|
||||
}
|
||||
|
||||
#listenToNightlightState() {
|
||||
console.debug('Listening to Night Light state...');
|
||||
debug.message('Listening to Night Light state...');
|
||||
this.#nightlightStateConnection = this.#colorDbusProxy.connect(
|
||||
'g-properties-changed',
|
||||
this.#onNightlightStateChanged.bind(this)
|
||||
@@ -115,7 +116,7 @@ var TimerNightlight = class {
|
||||
this.#colorDbusProxy.disconnect(this.#nightlightStateConnection);
|
||||
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) {
|
||||
const newState = this.#isNightlightActive();
|
||||
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.emit('time-changed', newState ? Time.NIGHT : Time.DAY);
|
||||
}
|
||||
|
||||
@@ -13,6 +13,7 @@ const { PopupMenuItem, PopupSubMenuMenuItem } = imports.ui.popupMenu;
|
||||
const Me = extensionUtils.getCurrentExtension();
|
||||
const _ = extensionUtils.gettext;
|
||||
|
||||
const debug = Me.imports.debug;
|
||||
const utils = Me.imports.utils;
|
||||
|
||||
const { Time } = Me.imports.enums.Time;
|
||||
@@ -38,22 +39,22 @@ var TimerOndemand = class {
|
||||
}
|
||||
|
||||
enable() {
|
||||
console.debug('Enabling On-demand Timer...');
|
||||
debug.message('Enabling On-demand Timer...');
|
||||
this.#connectSettings();
|
||||
this.#addKeybinding();
|
||||
this.#addButton();
|
||||
this.#connectTimer();
|
||||
this.emit('time-changed', this.time);
|
||||
console.debug('On-demand Timer enabled.');
|
||||
debug.message('On-demand Timer enabled.');
|
||||
}
|
||||
|
||||
disable() {
|
||||
console.debug('Disabling On-demand Timer...');
|
||||
debug.message('Disabling On-demand Timer...');
|
||||
this.#disconnectTimer();
|
||||
this.#removeKeybinding();
|
||||
this.#removeButton();
|
||||
this.#disconnectSettings();
|
||||
console.debug('On-demand Timer disabled.');
|
||||
debug.message('On-demand Timer disabled.');
|
||||
}
|
||||
|
||||
|
||||
@@ -63,7 +64,7 @@ var TimerOndemand = class {
|
||||
|
||||
|
||||
#connectSettings() {
|
||||
console.debug('Connecting On-demand Timer to settings...');
|
||||
debug.message('Connecting On-demand Timer to settings...');
|
||||
this.#settingsConnections.push({
|
||||
settings: this.#settings,
|
||||
id: this.#settings.connect('changed::ondemand-time', this.#onOndemandTimeChanged.bind(this)),
|
||||
@@ -79,13 +80,13 @@ var TimerOndemand = class {
|
||||
}
|
||||
|
||||
#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 = [];
|
||||
}
|
||||
|
||||
#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));
|
||||
}
|
||||
|
||||
@@ -94,7 +95,7 @@ var TimerOndemand = class {
|
||||
this.#timer.disconnect(this.#timerConnection);
|
||||
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];
|
||||
if (!this.#settings.get_strv('nightthemeswitcher-ondemand-keybinding')[0])
|
||||
return;
|
||||
console.debug('Adding On-demand Timer keybinding...');
|
||||
debug.message('Adding On-demand Timer keybinding...');
|
||||
main.wm.addKeybinding(
|
||||
'nightthemeswitcher-ondemand-keybinding',
|
||||
this.#settings,
|
||||
@@ -130,14 +131,14 @@ var TimerOndemand = class {
|
||||
Shell.ActionMode.NORMAL | Shell.ActionMode.OVERVIEW,
|
||||
this.#toggleTime.bind(this)
|
||||
);
|
||||
console.debug('Added On-demand Timer keybinding.');
|
||||
debug.message('Added On-demand Timer keybinding.');
|
||||
}
|
||||
|
||||
#removeKeybinding() {
|
||||
if (this.#previousKeybinding) {
|
||||
console.debug('Removing On-demand Timer keybinding...');
|
||||
debug.message('Removing On-demand Timer 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() {
|
||||
if (this.#button) {
|
||||
console.debug('Removing On-demand Timer button...');
|
||||
debug.message('Removing On-demand Timer button...');
|
||||
this.#button.destroy();
|
||||
this.#button = null;
|
||||
console.debug('Removed On-demand Timer button.');
|
||||
debug.message('Removed On-demand Timer button.');
|
||||
}
|
||||
}
|
||||
|
||||
#updateButton() {
|
||||
if (this.#button) {
|
||||
console.debug('Updating On-demand Timer button state...');
|
||||
debug.message('Updating On-demand Timer button state...');
|
||||
this.#button.update();
|
||||
console.debug('Updated On-demand Timer button state.');
|
||||
debug.message('Updated On-demand Timer button state.');
|
||||
}
|
||||
}
|
||||
|
||||
#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) });
|
||||
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() {
|
||||
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 position = utils.findShellAggregateMenuItemPosition(aggregateMenu._system.menu) - 1;
|
||||
this.#button = new NtsPopupSubMenuMenuItem({ timer: this.#timer, toggleCallback: this.#toggleTime.bind(this) });
|
||||
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() {
|
||||
|
||||
@@ -7,6 +7,7 @@ const Signals = imports.signals;
|
||||
|
||||
const Me = extensionUtils.getCurrentExtension();
|
||||
|
||||
const debug = Me.imports.debug;
|
||||
const utils = Me.imports.utils;
|
||||
|
||||
const { Time } = Me.imports.enums.Time;
|
||||
@@ -31,16 +32,16 @@ var TimerSchedule = class {
|
||||
}
|
||||
|
||||
enable() {
|
||||
console.debug('Enabling Schedule Timer...');
|
||||
debug.message('Enabling Schedule Timer...');
|
||||
this.#watchForTimeChange();
|
||||
this.emit('time-changed', this.time);
|
||||
console.debug('Schedule Timer enabled.');
|
||||
debug.message('Schedule Timer enabled.');
|
||||
}
|
||||
|
||||
disable() {
|
||||
console.debug('Disabling Schedule Timer...');
|
||||
debug.message('Disabling Schedule Timer...');
|
||||
this.#stopWatchingForTimeChange();
|
||||
console.debug('Schedule Timer disabled.');
|
||||
debug.message('Schedule Timer disabled.');
|
||||
}
|
||||
|
||||
|
||||
@@ -56,7 +57,7 @@ var TimerSchedule = class {
|
||||
}
|
||||
|
||||
#watchForTimeChange() {
|
||||
console.debug('Watching for time change...');
|
||||
debug.message('Watching for time change...');
|
||||
this.#timeChangeTimer = GLib.timeout_add_seconds(GLib.PRIORITY_DEFAULT, 1, () => {
|
||||
if (this.#previouslyDaytime !== this.#isDaytime()) {
|
||||
this.#previouslyDaytime = this.#isDaytime();
|
||||
@@ -68,7 +69,7 @@ var TimerSchedule = class {
|
||||
|
||||
#stopWatchingForTimeChange() {
|
||||
GLib.Source.remove(this.#timeChangeTimer);
|
||||
console.debug('Stopped watching for time change.');
|
||||
debug.message('Stopped watching for time change.');
|
||||
}
|
||||
};
|
||||
Signals.addSignalMethods(TimerSchedule.prototype);
|
||||
|
||||
Reference in New Issue
Block a user