Directly use gsettings
This commit is contained in:
+55
-49
@@ -1,12 +1,14 @@
|
||||
// SPDX-FileCopyrightText: 2020, 2021 Romain Vigier <contact AT romainvigier.fr>
|
||||
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
const { Gio } = imports.gi;
|
||||
const { extensionUtils } = imports.misc;
|
||||
|
||||
const Me = extensionUtils.getCurrentExtension();
|
||||
|
||||
const e = Me.imports.extension;
|
||||
const { logDebug } = Me.imports.utils;
|
||||
const utils = Me.imports.utils;
|
||||
const { logDebug } = utils;
|
||||
|
||||
/**
|
||||
* The Backgrounder is responsible for changing the desktop background
|
||||
@@ -17,19 +19,20 @@ const { logDebug } = Me.imports.utils;
|
||||
*/
|
||||
var Backgrounder = class {
|
||||
constructor() {
|
||||
this._statusChangedConnect = null;
|
||||
this._backgroundChangedConnect = null;
|
||||
this._systemBackgroundChangedConnect = null;
|
||||
this._backgroundChangedConnect = null;
|
||||
this._backgroundsSettings = extensionUtils.getSettings(utils.getSettingsSchema('backgrounds'));
|
||||
this._systemBackgroundSettings = new Gio.Settings({ schema: 'org.gnome.desktop.background' });
|
||||
this._settingsConnections = [];
|
||||
this._statusConnection = null;
|
||||
this._timerConnection = null;
|
||||
}
|
||||
|
||||
enable() {
|
||||
logDebug('Enabling Backgrounder...');
|
||||
this._watchStatus();
|
||||
if (e.settings.backgrounds.enabled) {
|
||||
if (this._backgroundsSettings.get_boolean('enabled')) {
|
||||
this._connectSettings();
|
||||
this._connectTimer();
|
||||
this._changeSystemBackground(e.timer.time);
|
||||
this._updateSystemBackground(e.timer.time);
|
||||
}
|
||||
logDebug('Backgrounder enabled.');
|
||||
}
|
||||
@@ -45,83 +48,86 @@ var Backgrounder = class {
|
||||
|
||||
_watchStatus() {
|
||||
logDebug('Watching backgrounds status...');
|
||||
this._statusChangedConnect = e.settings.backgrounds.connect('status-changed', this._onStatusChanged.bind(this));
|
||||
this._statusConnection = this._backgroundsSettings.connect('changed::enabled', this._onStatusChanged.bind(this));
|
||||
}
|
||||
|
||||
_unwatchStatus() {
|
||||
if (this._statusChangedConnect) {
|
||||
e.settings.backgrounds.disconnect(this._statusChangedConnect);
|
||||
this._statusChangedConnect = null;
|
||||
if (this._statusConnection) {
|
||||
this._backgroundsSettings.disconnect(this._statusConnection);
|
||||
this._statusConnection = null;
|
||||
}
|
||||
logDebug('Stopped watching backgrounds status.');
|
||||
}
|
||||
|
||||
_connectSettings() {
|
||||
logDebug('Connecting Backgrounder to settings...');
|
||||
this._backgroundChangedConnect = e.settings.backgrounds.connect('background-changed', this._onBackgroundChanged.bind(this));
|
||||
this._systemBackgroundChangedConnect = e.settings.system.connect('background-changed', this._onSystemBackgroundChanged.bind(this));
|
||||
this._settingsConnections.push({
|
||||
settings: this._backgroundsSettings,
|
||||
id: this._backgroundsSettings.connect('changed::day', this._onDayBackgroundChanged.bind(this)),
|
||||
});
|
||||
this._settingsConnections.push({
|
||||
settings: this._backgroundsSettings,
|
||||
id: this._backgroundsSettings.connect('changed::night', this._onNightBackgroundChanged.bind(this)),
|
||||
});
|
||||
this._settingsConnections.push({
|
||||
settings: this._systemBackgroundSettings,
|
||||
id: this._systemBackgroundSettings.connect('changed::picture-uri', this._onSystemBackgroundChanged.bind(this)),
|
||||
});
|
||||
}
|
||||
|
||||
_disconnectSettings() {
|
||||
if (this._backgroundChangedConnect) {
|
||||
e.settings.backgrounds.disconnect(this._backgroundChangedConnect);
|
||||
this._backgroundChangedConnect = null;
|
||||
}
|
||||
if (this._systemBackgroundChangedConnect) {
|
||||
e.settings.system.disconnect(this._systemBackgroundChangedConnect);
|
||||
this._systemBackgroundChangedConnect = null;
|
||||
}
|
||||
this._settingsConnections.forEach(connection => connection.settings.disconnect(connection.id));
|
||||
this._settingsConnections = [];
|
||||
logDebug('Disconnected Backgrounder from settings.');
|
||||
}
|
||||
|
||||
_connectTimer() {
|
||||
logDebug('Connecting Backgrounder to Timer...');
|
||||
this._backgroundChangedConnect = e.timer.connect('time-changed', this._onTimeChanged.bind(this));
|
||||
this._timerConnection = e.timer.connect('time-changed', this._onTimeChanged.bind(this));
|
||||
}
|
||||
|
||||
_disconnectTimer() {
|
||||
if (this._backgroundChangedConnect) {
|
||||
e.timer.disconnect(this._backgroundChangedConnect);
|
||||
this._backgroundChangedConnect = null;
|
||||
if (this._timerConnection) {
|
||||
e.timer.disconnect(this._timerConnection);
|
||||
this._timerConnection = null;
|
||||
}
|
||||
logDebug('Disconnected Backgrounder from Timer.');
|
||||
}
|
||||
|
||||
|
||||
_onStatusChanged(_settings, _enabled) {
|
||||
_onStatusChanged() {
|
||||
logDebug(`Backgrounds switching has been ${this._backgroundsSettings.get_boolean('enabled') ? 'enabled' : 'disabled'}.`);
|
||||
this.disable();
|
||||
this.enable();
|
||||
}
|
||||
|
||||
_onBackgroundChanged(_settings, changedBackgroundTime) {
|
||||
if (changedBackgroundTime === e.timer.time)
|
||||
this._changeSystemBackground(changedBackgroundTime);
|
||||
_onDayBackgroundChanged() {
|
||||
logDebug(`Day background changed to '${this._backgroundsSettings.get_string('day')}'.`);
|
||||
this._updateSystemBackground();
|
||||
}
|
||||
|
||||
_onSystemBackgroundChanged(_settings, newBackground) {
|
||||
switch (e.timer.time) {
|
||||
case 'day':
|
||||
e.settings.backgrounds.day = newBackground;
|
||||
break;
|
||||
case 'night':
|
||||
e.settings.backgrounds.night = newBackground;
|
||||
}
|
||||
_onNightBackgroundChanged() {
|
||||
logDebug(`Night background changed to '${this._backgroundsSettings.get_string('night')}'.`);
|
||||
this._updateSystemBackground();
|
||||
}
|
||||
|
||||
_onTimeChanged(_timer, newTime) {
|
||||
this._changeSystemBackground(newTime);
|
||||
_onSystemBackgroundChanged() {
|
||||
logDebug(`System background changed to '${this._systemBackgroundSettings.get_string('picture-uri')}'.`);
|
||||
this._updateCurrentBackground();
|
||||
}
|
||||
|
||||
_onTimeChanged() {
|
||||
this._updateSystemBackground();
|
||||
}
|
||||
|
||||
|
||||
_changeSystemBackground(time) {
|
||||
switch (time) {
|
||||
case 'day':
|
||||
if (e.settings.backgrounds.day)
|
||||
e.settings.system.background = e.settings.backgrounds.day;
|
||||
break;
|
||||
case 'night':
|
||||
if (e.settings.backgrounds.night)
|
||||
e.settings.system.background = e.settings.backgrounds.night;
|
||||
}
|
||||
_updateCurrentBackground() {
|
||||
if (e.timer.time)
|
||||
this._backgroundsSettings.set_string(e.timer.time, this._systemBackgroundSettings.get_string('picture-uri'));
|
||||
}
|
||||
|
||||
_updateSystemBackground() {
|
||||
if (e.timer.time && this._backgroundsSettings.get_string(e.timer.time))
|
||||
this._systemBackgroundSettings.set_string('picture-uri', this._backgroundsSettings.get_string(e.timer.time));
|
||||
}
|
||||
};
|
||||
|
||||
+23
-18
@@ -7,7 +7,8 @@ const { extensionUtils } = imports.misc;
|
||||
const Me = extensionUtils.getCurrentExtension();
|
||||
|
||||
const e = Me.imports.extension;
|
||||
const { logDebug } = Me.imports.utils;
|
||||
const utils = Me.imports.utils;
|
||||
const { logDebug } = utils;
|
||||
|
||||
|
||||
/**
|
||||
@@ -15,14 +16,15 @@ const { logDebug } = Me.imports.utils;
|
||||
*/
|
||||
var Commander = class {
|
||||
constructor() {
|
||||
this._statusChangedConnect = null;
|
||||
this._timeChangedConnect = null;
|
||||
this._commandsSettings = extensionUtils.getSettings(utils.getSettingsSchema('commands'));
|
||||
this._statusConnection = null;
|
||||
this._timerConnection = null;
|
||||
}
|
||||
|
||||
enable() {
|
||||
logDebug('Enabling Commander...');
|
||||
this._watchStatus();
|
||||
if (e.settings.commands.enabled) {
|
||||
if (this._commandsSettings.get_boolean('enabled')) {
|
||||
this._connectTimer();
|
||||
this._spawnCommand(e.timer.time);
|
||||
}
|
||||
@@ -39,44 +41,47 @@ var Commander = class {
|
||||
|
||||
_watchStatus() {
|
||||
logDebug('Watching commands status...');
|
||||
this._statusChangedConnect = e.settings.commands.connect('status-changed', this._onStatusChanged.bind(this));
|
||||
this._statusConnection = this._commandsSettings.connect('changed::enabled', this._onStatusChanged.bind(this));
|
||||
}
|
||||
|
||||
_unwatchStatus() {
|
||||
if (this._statusChangedConnect) {
|
||||
e.settings.commands.disconnect(this._statusChangedConnect);
|
||||
this._statusChangedConnect = null;
|
||||
if (this._statusConnection) {
|
||||
this._commandsSettings.disconnect(this._statusConnection);
|
||||
this._statusConnection = null;
|
||||
}
|
||||
logDebug('Stopped watching commands status.');
|
||||
}
|
||||
|
||||
_connectTimer() {
|
||||
logDebug('Connecting Commander to Timer...');
|
||||
this._timeChangedConnect = e.timer.connect('time-changed', this._onTimeChanged.bind(this));
|
||||
this._timerConnection = e.timer.connect('time-changed', this._onTimeChanged.bind(this));
|
||||
}
|
||||
|
||||
_disconnectTimer() {
|
||||
if (this._timeChangedConnect) {
|
||||
e.timer.disconnect(this._timeChangedConnect);
|
||||
this._timeChangedConnect = null;
|
||||
if (this._timerConnection) {
|
||||
e.timer.disconnect(this._timerConnection);
|
||||
this._timerConnection = null;
|
||||
}
|
||||
logDebug('Disconnecting Commander from Timer.');
|
||||
}
|
||||
|
||||
|
||||
_onStatusChanged(_settings, _enabled) {
|
||||
_onStatusChanged() {
|
||||
logDebug(`Commands launching has been ${this._commandsSettings.get_boolean('enabled') ? 'enabled' : 'disabled'}.`);
|
||||
this.disable();
|
||||
this.enable();
|
||||
}
|
||||
|
||||
_onTimeChanged(_timer, newTime) {
|
||||
this._spawnCommand(newTime);
|
||||
_onTimeChanged() {
|
||||
this._spawnCommand();
|
||||
}
|
||||
|
||||
|
||||
_spawnCommand(time) {
|
||||
const command = time === 'day' ? e.settings.commands.sunrise : e.settings.commands.sunset;
|
||||
_spawnCommand() {
|
||||
if (!e.timer.time)
|
||||
return;
|
||||
const command = this._commandsSettings.get_string(e.timer.time === 'day' ? 'sunrise' : 'sunset');
|
||||
GLib.spawn_async(null, ['sh', '-c', command], null, GLib.SpawnFlags.SEARCH_PATH, null);
|
||||
logDebug(`Spawned ${time} command.`);
|
||||
logDebug(`Spawned ${e.timer.time} command.`);
|
||||
}
|
||||
};
|
||||
|
||||
+55
-51
@@ -1,13 +1,15 @@
|
||||
// SPDX-FileCopyrightText: 2020, 2021 Romain Vigier <contact AT romainvigier.fr>
|
||||
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
const { Gio } = imports.gi;
|
||||
const { extensionUtils } = imports.misc;
|
||||
const { main } = imports.ui;
|
||||
|
||||
const Me = extensionUtils.getCurrentExtension();
|
||||
|
||||
const e = Me.imports.extension;
|
||||
const { logDebug } = Me.imports.utils;
|
||||
const utils = Me.imports.utils;
|
||||
const { logDebug } = utils;
|
||||
|
||||
|
||||
/**
|
||||
@@ -16,19 +18,20 @@ const { logDebug } = Me.imports.utils;
|
||||
*/
|
||||
var CursorThemer = class {
|
||||
constructor() {
|
||||
this._statusChangedConnect = null;
|
||||
this._variantChangedConnect = null;
|
||||
this._systemCursorThemeChangedConnect = null;
|
||||
this._timeChangedConnect = null;
|
||||
this._cursorVariantsSettings = extensionUtils.getSettings(utils.getSettingsSchema('cursor-variants'));
|
||||
this._interfaceSettings = new Gio.Settings({ schema: 'org.gnome.desktop.interface' });
|
||||
this._settingsConnections = [];
|
||||
this._statusConnection = null;
|
||||
this._timerConnection = null;
|
||||
}
|
||||
|
||||
enable() {
|
||||
logDebug('Enabling Cursor Themer...');
|
||||
this._watchStatus();
|
||||
if (e.settings.cursorVariants.enabled) {
|
||||
if (this._cursorVariantsSettings.get_boolean('enabled')) {
|
||||
this._connectSettings();
|
||||
this._connectTimer();
|
||||
this._setSystemVariant(e.timer.time);
|
||||
this._updateSystemCursorTheme();
|
||||
}
|
||||
logDebug('Cursor Themer enabled.');
|
||||
}
|
||||
@@ -44,85 +47,86 @@ var CursorThemer = class {
|
||||
|
||||
_watchStatus() {
|
||||
logDebug('Watching cursor variants status...');
|
||||
this._statusChangedConnect = e.settings.cursorVariants.connect('status-changed', this._onStatusChanged.bind(this));
|
||||
this._statusConnection = this._cursorVariantsSettings.connect('changed::enabled', this._onStatusChanged.bind(this));
|
||||
}
|
||||
|
||||
_unwatchStatus() {
|
||||
if (this._statusChangedConnect) {
|
||||
e.settings.cursorVariants.disconnect(this._statusChangedConnect);
|
||||
this._statusChangedConnect = null;
|
||||
if (this._statusConnection) {
|
||||
this._cursorVariantsSettings.disconnect(this._statusConnection);
|
||||
this._statusConnection = null;
|
||||
}
|
||||
logDebug('Stopped watching cursor variants status.');
|
||||
}
|
||||
|
||||
_connectSettings() {
|
||||
logDebug('Connecting Cursor Themer to settings...');
|
||||
this._variantChangedConnect = e.settings.cursorVariants.connect('variant-changed', this._onVariantChanged.bind(this));
|
||||
this._systemCursorThemeChangedConnect = e.settings.system.connect('cursor-theme-changed', this._onSystemCursorThemeChanged.bind(this));
|
||||
this._settingsConnections.push({
|
||||
settings: this._cursorVariantsSettings,
|
||||
id: this._cursorVariantsSettings.connect('changed::day', this._onDayVariantChanged.bind(this)),
|
||||
});
|
||||
this._settingsConnections.push({
|
||||
settings: this._cursorVariantsSettings,
|
||||
id: this._cursorVariantsSettings.connect('changed::night', this._onNightVariantChanged.bind(this)),
|
||||
});
|
||||
this._settingsConnections.push({
|
||||
settings: this._interfaceSettings,
|
||||
id: this._interfaceSettings.connect('changed::cursor-theme', this._onSystemCursorThemeChanged.bind(this)),
|
||||
});
|
||||
}
|
||||
|
||||
_disconnectSettings() {
|
||||
if (this._variantChangedConnect) {
|
||||
e.settings.cursorVariants.disconnect(this._variantChangedConnect);
|
||||
this._variantChangedConnect = null;
|
||||
}
|
||||
if (this._systemCursorThemeChangedConnect) {
|
||||
e.settings.system.disconnect(this._systemCursorThemeChangedConnect);
|
||||
this._systemCursorThemeChangedConnect = null;
|
||||
}
|
||||
this._settingsConnections.forEach(connection => connection.settings.disconnect(connection.id));
|
||||
this._settingsConnections = [];
|
||||
logDebug('Disconnected Cursor Themer from settings.');
|
||||
}
|
||||
|
||||
_connectTimer() {
|
||||
logDebug('Connecting Cursor Themer to Timer...');
|
||||
this._timeChangedConnect = e.timer.connect('time-changed', this._onTimeChanged.bind(this));
|
||||
this._timerConnection = e.timer.connect('time-changed', this._onTimeChanged.bind(this));
|
||||
}
|
||||
|
||||
_disconnectTimer() {
|
||||
if (this._timeChangedConnect) {
|
||||
e.timer.disconnect(this._timeChangedConnect);
|
||||
this._timeChangedConnect = null;
|
||||
if (this._timerConnection) {
|
||||
e.timer.disconnect(this._timerConnection);
|
||||
this._timerConnection = null;
|
||||
}
|
||||
logDebug('Disconnected Cursor Themer from Timer.');
|
||||
}
|
||||
|
||||
|
||||
_onStatusChanged(_settings, _enabled) {
|
||||
_onStatusChanged() {
|
||||
logDebug(`Cursor variants switching has been ${this._cursorVariantsSettings.get_boolean('enabled') ? 'enabled' : 'disabled'}.`);
|
||||
this.disable();
|
||||
this.enable();
|
||||
}
|
||||
|
||||
_onVariantChanged(_settings, changedVariantTime) {
|
||||
if (changedVariantTime === e.timer.time)
|
||||
this._setSystemVariant(changedVariantTime);
|
||||
_onDayVariantChanged() {
|
||||
logDebug(`Day cursor variant changed to '${this._cursorVariantsSettings.get_string('day')}'.`);
|
||||
this._updateSystemCursorTheme();
|
||||
}
|
||||
|
||||
_onSystemCursorThemeChanged(_settings, newTheme) {
|
||||
switch (e.timer.time) {
|
||||
case 'day':
|
||||
e.settings.cursorVariants.day = newTheme;
|
||||
break;
|
||||
case 'night':
|
||||
e.settings.cursorVariants.night = newTheme;
|
||||
}
|
||||
this._setSystemVariant(e.timer.time);
|
||||
_onNightVariantChanged() {
|
||||
logDebug(`Night cursor variant changed to '${this._cursorVariantsSettings.get_string('night')}'.`);
|
||||
this._updateSystemCursorTheme();
|
||||
}
|
||||
|
||||
_onTimeChanged(_timer, newTime) {
|
||||
this._setSystemVariant(newTime);
|
||||
_onSystemCursorThemeChanged() {
|
||||
logDebug(`System cursor theme changed to '${this._interfaceSettings.get_string('cursor-theme')}'.`);
|
||||
this._updateCurrentVariant();
|
||||
}
|
||||
|
||||
_onTimeChanged() {
|
||||
this._updateSystemCursorTheme();
|
||||
}
|
||||
|
||||
|
||||
_setSystemVariant(time) {
|
||||
logDebug(`Setting the cursor ${time} variant...`);
|
||||
switch (time) {
|
||||
case 'day':
|
||||
if (e.settings.cursorVariants.day)
|
||||
e.settings.system.cursorTheme = e.settings.cursorVariants.day;
|
||||
break;
|
||||
case 'night':
|
||||
if (e.settings.cursorVariants.night)
|
||||
e.settings.system.cursorTheme = e.settings.cursorVariants.night;
|
||||
}
|
||||
_updateCurrentVariant() {
|
||||
if (e.timer.time)
|
||||
this._cursorVariantsSettings.set_string(e.timer.time, this._interfaceSettings.get_string('cursor-theme'));
|
||||
}
|
||||
|
||||
_updateSystemCursorTheme() {
|
||||
if (e.timer.time && this._cursorVariantsSettings.get_string(e.timer.time))
|
||||
this._interfaceSettings.set_string('cursor-theme', this._cursorVariantsSettings.get_string(e.timer.time));
|
||||
}
|
||||
};
|
||||
|
||||
+72
-50
@@ -1,13 +1,15 @@
|
||||
// SPDX-FileCopyrightText: 2020, 2021 Romain Vigier <contact AT romainvigier.fr>
|
||||
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
const { Gio } = imports.gi;
|
||||
const { extensionUtils } = imports.misc;
|
||||
const { main } = imports.ui;
|
||||
|
||||
const Me = extensionUtils.getCurrentExtension();
|
||||
|
||||
const e = Me.imports.extension;
|
||||
const { logDebug, notifyError, getInstalledGtkThemes } = Me.imports.utils;
|
||||
const utils = Me.imports.utils;
|
||||
const { logDebug, notifyError } = utils;
|
||||
const { GtkVariants } = Me.imports.modules.GtkVariants;
|
||||
|
||||
const Gettext = imports.gettext.domain(Me.metadata['gettext-domain']);
|
||||
@@ -27,22 +29,22 @@ const _ = Gettext.gettext;
|
||||
*/
|
||||
var GtkThemer = class {
|
||||
constructor() {
|
||||
this._statusChangedConnect = null;
|
||||
this._variantChangedConnect = null;
|
||||
this._manualChangedConnect = null;
|
||||
this._systemGtkThemeChangedConnect = null;
|
||||
this._timeChangedConnect = null;
|
||||
this._gtkVariantsSettings = extensionUtils.getSettings(utils.getSettingsSchema('gtk-variants'));
|
||||
this._interfaceSettings = new Gio.Settings({ schema: 'org.gnome.desktop.interface' });
|
||||
this._settingsConnections = [];
|
||||
this._statusConnection = null;
|
||||
this._timerConnection = null;
|
||||
}
|
||||
|
||||
enable() {
|
||||
logDebug('Enabling GTK Themer...');
|
||||
try {
|
||||
this._watchStatus();
|
||||
if (e.settings.gtkVariants.enabled) {
|
||||
if (this._gtkVariantsSettings.get_boolean('enabled')) {
|
||||
this._connectSettings();
|
||||
this._updateVariants();
|
||||
this._connectTimer();
|
||||
this._setSystemVariant(e.timer.time);
|
||||
this._updateSystemGtkTheme();
|
||||
}
|
||||
} catch (error) {
|
||||
notifyError(error);
|
||||
@@ -61,110 +63,130 @@ var GtkThemer = class {
|
||||
|
||||
_watchStatus() {
|
||||
logDebug('Watching GTK variants status...');
|
||||
this._statusChangedConnect = e.settings.gtkVariants.connect('status-changed', this._onStatusChanged.bind(this));
|
||||
this._statusConnection = this._gtkVariantsSettings.connect('changed::enabled', this._onStatusChanged.bind(this));
|
||||
}
|
||||
|
||||
_unwatchStatus() {
|
||||
if (this._statusChangedConnect) {
|
||||
e.settings.gtkVariants.disconnect(this._statusChangedConnect);
|
||||
this._statusChangedConnect = null;
|
||||
if (this._statusConnection) {
|
||||
this._gtkVariantsSettings.disconnect(this._statusConnection);
|
||||
this._statusConnection = null;
|
||||
}
|
||||
logDebug('Stopped watching GTK variants status.');
|
||||
}
|
||||
|
||||
_connectSettings() {
|
||||
logDebug('Connecting GTK Themer to settings...');
|
||||
this._variantChangedConnect = e.settings.gtkVariants.connect('variant-changed', this._onVariantChanged.bind(this));
|
||||
this._manualChangedConnect = e.settings.gtkVariants.connect('manual-changed', this._onManualChanged.bind(this));
|
||||
this._systemGtkThemeChangedConnect = e.settings.system.connect('gtk-theme-changed', this._onSystemGtkThemeChanged.bind(this));
|
||||
this._settingsConnections.push({
|
||||
settings: this._gtkVariantsSettings,
|
||||
id: this._gtkVariantsSettings.connect('changed::day', this._onDayVariantChanged.bind(this)),
|
||||
});
|
||||
this._settingsConnections.push({
|
||||
settings: this._gtkVariantsSettings,
|
||||
id: this._gtkVariantsSettings.connect('changed::night', this._onNightVariantChanged.bind(this)),
|
||||
});
|
||||
this._settingsConnections.push({
|
||||
settings: this._gtkVariantsSettings,
|
||||
id: this._gtkVariantsSettings.connect('changed::manual', this._onManualChanged.bind(this)),
|
||||
});
|
||||
this._settingsConnections.push({
|
||||
settings: this._interfaceSettings,
|
||||
id: this._interfaceSettings.connect('changed::gtk-theme', this._onSystemGtkThemeChanged.bind(this)),
|
||||
});
|
||||
}
|
||||
|
||||
_disconnectSettings() {
|
||||
if (this._variantChangedConnect) {
|
||||
e.settings.gtkVariants.disconnect(this._variantChangedConnect);
|
||||
this._variantChangedConnect = null;
|
||||
}
|
||||
if (this._manualChangedConnect) {
|
||||
e.settings.gtkVariants.disconnect(this._manualChangedConnect);
|
||||
this._manualChangedConnect = null;
|
||||
}
|
||||
if (this._systemGtkThemeChangedConnect) {
|
||||
e.settings.system.disconnect(this._systemGtkThemeChangedConnect);
|
||||
this._systemGtkThemeChangedConnect = null;
|
||||
}
|
||||
this._settingsConnections.forEach(connection => connection.settings.disconnect(connection.id));
|
||||
this._settingsConnections = [];
|
||||
logDebug('Disconnected GTK Themer from settings.');
|
||||
}
|
||||
|
||||
_connectTimer() {
|
||||
logDebug('Connecting GTK Themer to Timer...');
|
||||
this._timeChangedConnect = e.timer.connect('time-changed', this._onTimeChanged.bind(this));
|
||||
this._timerConnection = e.timer.connect('time-changed', this._onTimeChanged.bind(this));
|
||||
}
|
||||
|
||||
_disconnectTimer() {
|
||||
if (this._timeChangedConnect) {
|
||||
e.timer.disconnect(this._timeChangedConnect);
|
||||
this._timeChangedConnect = null;
|
||||
if (this._timerConnection) {
|
||||
e.timer.disconnect(this._timerConnection);
|
||||
this._timerConnection = null;
|
||||
}
|
||||
logDebug('Disconnected GTK Themer from Timer.');
|
||||
}
|
||||
|
||||
|
||||
_onStatusChanged(_settings, _enabled) {
|
||||
_onStatusChanged() {
|
||||
logDebug(`GTK variants switching has been ${this._gtkVariantsSettings.get_boolean('enabled') ? 'enabled' : 'disabled'}.`);
|
||||
this.disable();
|
||||
this.enable();
|
||||
}
|
||||
|
||||
_onVariantChanged(_settings, changedVariantTime) {
|
||||
if (changedVariantTime === e.timer.time)
|
||||
this._setSystemVariant(changedVariantTime);
|
||||
_onDayVariantChanged() {
|
||||
logDebug(`Day GTK variant changed to '${this._gtkVariantsSettings.get_string('day')}'.`);
|
||||
this._updateSystemGtkTheme();
|
||||
}
|
||||
|
||||
_onSystemGtkThemeChanged(_settings, _newTheme) {
|
||||
_onNightVariantChanged() {
|
||||
logDebug(`Night GTK variant changed to '${this._gtkVariantsSettings.get_string('night')}'.`);
|
||||
this._updateSystemGtkTheme();
|
||||
}
|
||||
|
||||
_onSystemGtkThemeChanged() {
|
||||
logDebug(`System GTK theme changed to '${this._interfaceSettings.get_string('gtk-theme')}'.`);
|
||||
try {
|
||||
this._updateVariants();
|
||||
this._setSystemVariant(e.timer.time);
|
||||
this._updateCurrentVariant();
|
||||
this._updateSystemGtkTheme();
|
||||
} catch (error) {
|
||||
notifyError(error);
|
||||
}
|
||||
}
|
||||
|
||||
_onManualChanged(_settings, _enabled) {
|
||||
_onManualChanged() {
|
||||
logDebug(`Manual GTK variants choice has been ${this._gtkVariantsSettings.get_boolean('manual') ? 'enabled' : 'disabled'}.`);
|
||||
this.disable();
|
||||
this.enable();
|
||||
}
|
||||
|
||||
_onTimeChanged(_timer, newTime) {
|
||||
this._setSystemVariant(newTime);
|
||||
_onTimeChanged() {
|
||||
this._updateSystemGtkTheme();
|
||||
}
|
||||
|
||||
|
||||
_areVariantsUpToDate() {
|
||||
return e.settings.system.gtkTheme === e.settings.gtkVariants.day || e.settings.system.gtkTheme === e.settings.gtkVariants.night;
|
||||
return (
|
||||
this._interfaceSettings.get_string('gtk-theme') === this._gtkVariantsSettings.get_string('day') ||
|
||||
this._interfaceSettings.get_string('gtk-theme') === this._gtkVariantsSettings.get_string('night')
|
||||
);
|
||||
}
|
||||
|
||||
_setSystemVariant(time) {
|
||||
if (!time)
|
||||
_updateCurrentVariant() {
|
||||
if (this._gtkVariantsSettings.get_boolean('manual') && e.timer.time)
|
||||
this._gtkVariantsSettings.set_string(e.timer.time, this._interfaceSettings.get_string('gtk-theme'));
|
||||
}
|
||||
|
||||
_updateSystemGtkTheme() {
|
||||
if (!e.timer.time)
|
||||
return;
|
||||
logDebug(`Setting the GTK ${time} variant...`);
|
||||
e.settings.system.gtkTheme = time === 'day' ? e.settings.gtkVariants.day : e.settings.gtkVariants.night;
|
||||
logDebug(`Setting the ${e.timer.time} GTK variant...`);
|
||||
this._interfaceSettings.set_string('gtk-theme', this._gtkVariantsSettings.get_string(e.timer.time));
|
||||
}
|
||||
|
||||
_updateVariants() {
|
||||
if (e.settings.gtkVariants.manual || this._areVariantsUpToDate())
|
||||
if (this._gtkVariantsSettings.get_boolean('manual') || this._areVariantsUpToDate())
|
||||
return;
|
||||
|
||||
logDebug('Updating GTK variants...');
|
||||
const originalTheme = e.settings.system.gtkTheme;
|
||||
const originalTheme = this._interfaceSettings.get_string('gtk-theme');
|
||||
const variants = GtkVariants.guessFrom(originalTheme);
|
||||
const installedThemes = getInstalledGtkThemes();
|
||||
const installedThemes = utils.getInstalledGtkThemes();
|
||||
|
||||
if (!installedThemes.has(variants.get('day')) || !installedThemes.has(variants.get('night'))) {
|
||||
const message = _('Unable to automatically detect the day and night variants for the "%s" GTK theme. Please manually choose them in the extension\'s preferences.').format(originalTheme);
|
||||
throw new Error(message);
|
||||
}
|
||||
|
||||
e.settings.gtkVariants.day = variants.get('day');
|
||||
e.settings.gtkVariants.night = variants.get('night');
|
||||
this._gtkVariantsSettings.set_string('day', variants.get('day'));
|
||||
this._gtkVariantsSettings.set_string('night', variants.get('night'));
|
||||
logDebug(`New GTK variants. { day: '${variants.get('day')}'; night: '${variants.get('night')}' }`);
|
||||
}
|
||||
};
|
||||
|
||||
+55
-51
@@ -1,13 +1,15 @@
|
||||
// SPDX-FileCopyrightText: 2020, 2021 Romain Vigier <contact AT romainvigier.fr>
|
||||
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
const { Gio } = imports.gi;
|
||||
const { extensionUtils } = imports.misc;
|
||||
const { main } = imports.ui;
|
||||
|
||||
const Me = extensionUtils.getCurrentExtension();
|
||||
|
||||
const e = Me.imports.extension;
|
||||
const { logDebug } = Me.imports.utils;
|
||||
const utils = Me.imports.utils;
|
||||
const { logDebug } = utils;
|
||||
|
||||
|
||||
/**
|
||||
@@ -16,19 +18,20 @@ const { logDebug } = Me.imports.utils;
|
||||
*/
|
||||
var IconThemer = class {
|
||||
constructor() {
|
||||
this._statusChangedConnect = null;
|
||||
this._variantChangedConnect = null;
|
||||
this._systemIconThemeChangedConnect = null;
|
||||
this._timeChangedConnect = null;
|
||||
this._iconVariantsSettings = extensionUtils.getSettings(utils.getSettingsSchema('icon-variants'));
|
||||
this._interfaceSettings = new Gio.Settings({ schema: 'org.gnome.desktop.interface' });
|
||||
this._settingsConnections = [];
|
||||
this._statusConnection = null;
|
||||
this._timerConnection = null;
|
||||
}
|
||||
|
||||
enable() {
|
||||
logDebug('Enabling Icon Themer...');
|
||||
this._watchStatus();
|
||||
if (e.settings.iconVariants.enabled) {
|
||||
if (this._iconVariantsSettings.get_boolean('enabled')) {
|
||||
this._connectSettings();
|
||||
this._connectTimer();
|
||||
this._setSystemVariant(e.timer.time);
|
||||
this._updateSystemIconTheme();
|
||||
}
|
||||
logDebug('Icon Themer enabled.');
|
||||
}
|
||||
@@ -44,85 +47,86 @@ var IconThemer = class {
|
||||
|
||||
_watchStatus() {
|
||||
logDebug('Watching icon variants status...');
|
||||
this._statusChangedConnect = e.settings.iconVariants.connect('status-changed', this._onStatusChanged.bind(this));
|
||||
this._statusConnection = this._iconVariantsSettings.connect('changed::enabled', this._onStatusChanged.bind(this));
|
||||
}
|
||||
|
||||
_unwatchStatus() {
|
||||
if (this._statusChangedConnect) {
|
||||
e.settings.iconVariants.disconnect(this._statusChangedConnect);
|
||||
this._statusChangedConnect = null;
|
||||
if (this._statusConnection) {
|
||||
this._iconVariantsSettings.disconnect(this._statusConnection);
|
||||
this._statusConnection = null;
|
||||
}
|
||||
logDebug('Stopped watching icon variants status.');
|
||||
}
|
||||
|
||||
_connectSettings() {
|
||||
logDebug('Connecting Icon Themer to settings...');
|
||||
this._variantChangedConnect = e.settings.iconVariants.connect('variant-changed', this._onVariantChanged.bind(this));
|
||||
this._systemIconThemeChangedConnect = e.settings.system.connect('icon-theme-changed', this._onSystemIconThemeChanged.bind(this));
|
||||
this._settingsConnections.push({
|
||||
settings: this._iconVariantsSettings,
|
||||
id: this._iconVariantsSettings.connect('changed::day', this._onDayVariantChanged.bind(this)),
|
||||
});
|
||||
this._settingsConnections.push({
|
||||
settings: this._iconVariantsSettings,
|
||||
id: this._iconVariantsSettings.connect('changed::night', this._onNightVariantChanged.bind(this)),
|
||||
});
|
||||
this._settingsConnections.push({
|
||||
settings: this._interfaceSettings,
|
||||
id: this._interfaceSettings.connect('changed::icon-theme', this._onSystemIconThemeChanged.bind(this)),
|
||||
});
|
||||
}
|
||||
|
||||
_disconnectSettings() {
|
||||
if (this._variantChangedConnect) {
|
||||
e.settings.iconVariants.disconnect(this._variantChangedConnect);
|
||||
this._variantChangedConnect = null;
|
||||
}
|
||||
if (this._systemIconThemeChangedConnect) {
|
||||
e.settings.system.disconnect(this._systemIconThemeChangedConnect);
|
||||
this._systemIconThemeChangedConnect = null;
|
||||
}
|
||||
this._settingsConnections.forEach(connection => connection.settings.disconnect(connection.id));
|
||||
this._settingsConnections = [];
|
||||
logDebug('Disconnected Icon Themer from settings.');
|
||||
}
|
||||
|
||||
_connectTimer() {
|
||||
logDebug('Connecting Icon Themer to Timer...');
|
||||
this._timeChangedConnect = e.timer.connect('time-changed', this._onTimeChanged.bind(this));
|
||||
this._timerConnection = e.timer.connect('time-changed', this._onTimeChanged.bind(this));
|
||||
}
|
||||
|
||||
_disconnectTimer() {
|
||||
if (this._timeChangedConnect) {
|
||||
e.timer.disconnect(this._timeChangedConnect);
|
||||
this._timeChangedConnect = null;
|
||||
if (this._timerConnection) {
|
||||
e.timer.disconnect(this._timerConnection);
|
||||
this._timerConnection = null;
|
||||
}
|
||||
logDebug('Disconnected Icon Themer from Timer.');
|
||||
}
|
||||
|
||||
|
||||
_onStatusChanged(_settings, _enabled) {
|
||||
_onStatusChanged() {
|
||||
logDebug(`Icon variants switching has been ${this._iconVariantsSettings.get_boolean('enabled') ? 'enabled' : 'disabled'}.`);
|
||||
this.disable();
|
||||
this.enable();
|
||||
}
|
||||
|
||||
_onVariantChanged(_settings, changedVariantTime) {
|
||||
if (changedVariantTime === e.timer.time)
|
||||
this._setSystemVariant(changedVariantTime);
|
||||
_onDayVariantChanged() {
|
||||
logDebug(`Day icon variant changed to '${this._iconVariantsSettings.get_string('day')}'.`);
|
||||
this._updateSystemIconTheme();
|
||||
}
|
||||
|
||||
_onSystemIconThemeChanged(_settings, newTheme) {
|
||||
switch (e.timer.time) {
|
||||
case 'day':
|
||||
e.settings.iconVariants.day = newTheme;
|
||||
break;
|
||||
case 'night':
|
||||
e.settings.iconVariants.night = newTheme;
|
||||
}
|
||||
this._setSystemVariant(e.timer.time);
|
||||
_onNightVariantChanged() {
|
||||
logDebug(`Night icon variant changed to '${this._iconVariantsSettings.get_string('night')}'.`);
|
||||
this._updateSystemIconTheme();
|
||||
}
|
||||
|
||||
_onTimeChanged(_timer, newTime) {
|
||||
this._setSystemVariant(newTime);
|
||||
_onSystemIconThemeChanged() {
|
||||
logDebug(`System icon theme changed to '${this._iconVariantsSettings.get_string('icon-theme')}'.`);
|
||||
this._updateCurrentVariant();
|
||||
}
|
||||
|
||||
_onTimeChanged() {
|
||||
this._updateSystemIconTheme();
|
||||
}
|
||||
|
||||
|
||||
_setSystemVariant(time) {
|
||||
logDebug(`Setting the icon ${time} variant...`);
|
||||
switch (time) {
|
||||
case 'day':
|
||||
if (e.settings.iconVariants.day)
|
||||
e.settings.system.iconTheme = e.settings.iconVariants.day;
|
||||
break;
|
||||
case 'night':
|
||||
if (e.settings.iconVariants.night)
|
||||
e.settings.system.iconTheme = e.settings.iconVariants.night;
|
||||
}
|
||||
_updateCurrentVariant() {
|
||||
if (e.timer.time)
|
||||
this._iconVariantsSettings.set_string(e.timer.time, this._interfaceSettings.get_string('icon-theme'));
|
||||
}
|
||||
|
||||
_updateSystemIconTheme() {
|
||||
if (e.timer.time && this._iconVariantsSettings.get_string(e.timer.time))
|
||||
this._interfaceSettings.set_string('icon-theme', this._iconVariantsSettings.get_string(e.timer.time));
|
||||
}
|
||||
};
|
||||
|
||||
+81
-54
@@ -1,6 +1,7 @@
|
||||
// SPDX-FileCopyrightText: 2020, 2021 Romain Vigier <contact AT romainvigier.fr>
|
||||
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
const { Gio } = imports.gi;
|
||||
const { extensionUtils } = imports.misc;
|
||||
const Signals = imports.signals;
|
||||
const { main } = imports.ui;
|
||||
@@ -8,7 +9,8 @@ const { main } = imports.ui;
|
||||
const Me = extensionUtils.getCurrentExtension();
|
||||
|
||||
const e = Me.imports.extension;
|
||||
const { logDebug, notifyError, getInstalledShellThemes, getShellThemeStylesheet, applyShellStylesheet } = Me.imports.utils;
|
||||
const utils = Me.imports.utils;
|
||||
const { logDebug, notifyError } = Me.imports.utils;
|
||||
const { ShellVariants } = Me.imports.modules.ShellVariants;
|
||||
|
||||
const Gettext = imports.gettext.domain(Me.metadata['gettext-domain']);
|
||||
@@ -27,22 +29,22 @@ const _ = Gettext.gettext;
|
||||
*/
|
||||
var ShellThemer = class {
|
||||
constructor() {
|
||||
this._statusChangedConnect = null;
|
||||
this._variantChangedConnect = null;
|
||||
this._manualChangedConnect = null;
|
||||
this._systemShellThemeChangedConnect = null;
|
||||
this._timeChangedConnect = null;
|
||||
this._shellVariantsSettings = extensionUtils.getSettings(utils.getSettingsSchema('shell-variants'));
|
||||
this._userthemesSettings = utils.getUserthemesSettings();
|
||||
this._settingsConnections = [];
|
||||
this._statusConnection = null;
|
||||
this._timerConnection = null;
|
||||
}
|
||||
|
||||
enable() {
|
||||
logDebug('Enabling Shell Themer...');
|
||||
try {
|
||||
this._watchStatus();
|
||||
if (e.settings.shellVariants.enabled) {
|
||||
if (this._shellVariantsSettings.get_boolean('enabled')) {
|
||||
this._connectSettings();
|
||||
this._updateVariants();
|
||||
this._connectTimer();
|
||||
this._setSystemVariant(e.timer.time);
|
||||
this._updateSystemShellTheme();
|
||||
}
|
||||
} catch (error) {
|
||||
notifyError(error);
|
||||
@@ -61,117 +63,142 @@ var ShellThemer = class {
|
||||
|
||||
_watchStatus() {
|
||||
logDebug('Watching shell variants status...');
|
||||
this._statusChangedConnect = e.settings.shellVariants.connect('status-changed', this._onStatusChanged.bind(this));
|
||||
this._statusConnection = this._shellVariantsSettings.connect('changed::enabled', this._onStatusChanged.bind(this));
|
||||
}
|
||||
|
||||
_unwatchStatus() {
|
||||
if (this._statusChangedConnect) {
|
||||
e.settings.shellVariants.disconnect(this._statusChangedConnect);
|
||||
this._statusChangedConnect = null;
|
||||
if (this._statusConnection) {
|
||||
this._shellVariantsSettings.disconnect(this._statusConnection);
|
||||
this._statusConnection = null;
|
||||
}
|
||||
logDebug('Stopped watching shell variants status.');
|
||||
}
|
||||
|
||||
_connectSettings() {
|
||||
logDebug('Connecting Shell Themer to settings...');
|
||||
this._variantChangedConnect = e.settings.shellVariants.connect('variant-changed', this._onVariantChanged.bind(this));
|
||||
this._manualChangedConnect = e.settings.shellVariants.connect('manual-changed', this._onManualChanged.bind(this));
|
||||
this._systemShellThemeChangedConnect = e.settings.system.connect('shell-theme-changed', this._onSystemShellThemeChanged.bind(this));
|
||||
this._settingsConnections.push({
|
||||
settings: this._shellVariantsSettings,
|
||||
id: this._shellVariantsSettings.connect('changed::day', this._onDayVariantChanged.bind(this)),
|
||||
});
|
||||
this._settingsConnections.push({
|
||||
settings: this._shellVariantsSettings,
|
||||
id: this._shellVariantsSettings.connect('changed::night', this._onNightVariantChanged.bind(this)),
|
||||
});
|
||||
this._settingsConnections.push({
|
||||
settings: this._shellVariantsSettings,
|
||||
id: this._shellVariantsSettings.connect('changed::manual', this._onManualChanged.bind(this)),
|
||||
});
|
||||
if (this._userthemesSettings) {
|
||||
this._settingsConnections.push({
|
||||
settings: this._userthemesSettings,
|
||||
id: this._userthemesSettings.connect('changed::name', this._onSystemShellThemeChanged.bind(this)),
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
_disconnectSettings() {
|
||||
if (this._variantChangedConnect) {
|
||||
e.settings.shellVariants.disconnect(this._variantChangedConnect);
|
||||
this._variantChangedConnect = null;
|
||||
}
|
||||
if (this._manualChangedConnect) {
|
||||
e.settings.shellVariants.disconnect(this._manualChangedConnect);
|
||||
this._manualChangedConnect = null;
|
||||
}
|
||||
if (this._systemShellThemeChangedConnect) {
|
||||
e.settings.system.disconnect(this._systemShellThemeChangedConnect);
|
||||
this._systemShellThemeChangedConnect = null;
|
||||
}
|
||||
this._settingsConnections.forEach(connection => connection.settings.disconnect(connection.id));
|
||||
this._settingsConnections = [];
|
||||
logDebug('Disconnected Shell Themer from settings.');
|
||||
}
|
||||
|
||||
_connectTimer() {
|
||||
logDebug('Connecting Shell Themer to Timer...');
|
||||
this._timeChangedConnect = e.timer.connect('time-changed', this._onTimeChanged.bind(this));
|
||||
this._timerConnection = e.timer.connect('time-changed', this._onTimeChanged.bind(this));
|
||||
}
|
||||
|
||||
_disconnectTimer() {
|
||||
if (this._timeChangedConnect) {
|
||||
e.timer.disconnect(this._timeChangedConnect);
|
||||
this._timeChangedConnect = null;
|
||||
if (this._timerConnection) {
|
||||
e.timer.disconnect(this._timerConnection);
|
||||
this._timerConnection = null;
|
||||
}
|
||||
logDebug('Disconnected Shell Themer from Timer.');
|
||||
}
|
||||
|
||||
|
||||
_onStatusChanged(_settings, _enabled) {
|
||||
_onStatusChanged() {
|
||||
logDebug(`Shell variants switching has been ${this._shellVariantsSettings.get_boolean('enabled') ? 'enabled' : 'disabled'}.`);
|
||||
this.disable();
|
||||
this.enable();
|
||||
}
|
||||
|
||||
_onVariantChanged(_settings, changedVariantTime) {
|
||||
if (changedVariantTime === e.timer.time)
|
||||
this._setSystemVariant(e.timer.time);
|
||||
_onDayVariantChanged() {
|
||||
logDebug(`Day Shell variant changed to '${this._shellVariantsSettings.get_string('day')}'.`);
|
||||
this._updateSystemShellTheme();
|
||||
}
|
||||
|
||||
_onNightVariantChanged() {
|
||||
logDebug(`Night Shell variant changed to '${this._shellVariantsSettings.get_string('night')}'.`);
|
||||
this._updateSystemShellTheme();
|
||||
}
|
||||
|
||||
_onSystemShellThemeChanged(_settings, _newTheme) {
|
||||
if (!this._userthemesSettings)
|
||||
return;
|
||||
logDebug(`System Shell theme changed to '${this._userthemesSettings.get_string('name')}'.`);
|
||||
try {
|
||||
this._updateVariants();
|
||||
this._setSystemVariant(e.timer.time);
|
||||
this._updateCurrentVariant();
|
||||
this._updateSystemShellTheme();
|
||||
} catch (error) {
|
||||
notifyError(error);
|
||||
}
|
||||
}
|
||||
|
||||
_onManualChanged(_settings, _enabled) {
|
||||
_onManualChanged() {
|
||||
logDebug(`Manual Shell variants choice has been ${this._shellVariantsSettings.get_boolean('manual') ? 'enabled' : 'disabled'}.`);
|
||||
this.disable();
|
||||
this.enable();
|
||||
}
|
||||
|
||||
_onTimeChanged(_timer, newTime) {
|
||||
this._setSystemVariant(newTime);
|
||||
_onTimeChanged() {
|
||||
this._updateSystemShellTheme();
|
||||
}
|
||||
|
||||
|
||||
_areVariantsUpToDate() {
|
||||
return e.settings.system.shellTheme === e.settings.shellVariants.day || e.settings.system.shellTheme === e.settings.shellVariants.night;
|
||||
if (!this._userthemesSettings)
|
||||
return true;
|
||||
return (
|
||||
this._userthemesSettings.get_string('name') === this._shellVariantsSettings.get_string('day') ||
|
||||
this._userthemesSettings.get_string('name') === this._shellVariantsSettings.get_string('night')
|
||||
);
|
||||
}
|
||||
|
||||
_setSystemVariant(time) {
|
||||
if (!time)
|
||||
_updateCurrentVariant() {
|
||||
if (this._userthemesSettings && this._shellVariantsSettings.get_boolean('manual') && e.timer.time)
|
||||
this._shellVariantsSettings.set_string(e.timer.time, this._userthemesSettings.get_string('name'));
|
||||
}
|
||||
|
||||
_updateSystemShellTheme() {
|
||||
if (!e.timer.time)
|
||||
return;
|
||||
logDebug(`Setting the shell ${time} variant...`);
|
||||
const shellTheme = time === 'day' ? e.settings.shellVariants.day : e.settings.shellVariants.night;
|
||||
if (e.settings.system.useUserthemes) {
|
||||
e.settings.system.shellTheme = shellTheme;
|
||||
logDebug(`Setting the ${e.timer.time} Shell variant...`);
|
||||
const shellTheme = this._shellVariantsSettings.get_string(e.timer.time);
|
||||
if (this._userthemesSettings) {
|
||||
this._userthemesSettings.set_string('name', shellTheme);
|
||||
} else {
|
||||
const stylesheet = getShellThemeStylesheet(shellTheme);
|
||||
applyShellStylesheet(stylesheet);
|
||||
const stylesheet = utils.getShellThemeStylesheet(shellTheme);
|
||||
utils.applyShellStylesheet(stylesheet);
|
||||
}
|
||||
}
|
||||
|
||||
_updateVariants() {
|
||||
if (!e.settings.system.useUserthemes || e.settings.shellVariants.manual || this._areVariantsUpToDate())
|
||||
if (!this._userthemesSettings || this._shellVariantsSettings.get_boolean('manual') || this._areVariantsUpToDate())
|
||||
return;
|
||||
|
||||
logDebug('Updating Shell variants...');
|
||||
const originalTheme = e.settings.system.shellTheme;
|
||||
const originalTheme = this._userthemesSettings.get_string('name');
|
||||
const variants = ShellVariants.guessFrom(originalTheme);
|
||||
const installedThemes = getInstalledShellThemes();
|
||||
const installedThemes = utils.getInstalledShellThemes();
|
||||
|
||||
if (!installedThemes.has(variants.get('day')) || !installedThemes.has(variants.get('night'))) {
|
||||
const message = _('Unable to automatically detect the day and night variants for the "%s" GNOME Shell theme. Please manually choose them in the extension\'s preferences.').format(originalTheme);
|
||||
throw new Error(message);
|
||||
}
|
||||
|
||||
e.settings.shellVariants.day = variants.get('day');
|
||||
e.settings.shellVariants.night = variants.get('night');
|
||||
this._shellVariantsSettings.set_string('day', variants.get('day'));
|
||||
this._shellVariantsSettings.set_string('night', variants.get('night'));
|
||||
logDebug(`New Shell variants. { day: '${variants.get('day')}'; night: '${variants.get('night')}' }`);
|
||||
}
|
||||
};
|
||||
Signals.addSignalMethods(ShellThemer.prototype);
|
||||
|
||||
+46
-43
@@ -1,13 +1,15 @@
|
||||
// SPDX-FileCopyrightText: 2020, 2021 Romain Vigier <contact AT romainvigier.fr>
|
||||
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
const { Gio } = imports.gi;
|
||||
const { extensionUtils } = imports.misc;
|
||||
const Signals = imports.signals;
|
||||
|
||||
const Me = extensionUtils.getCurrentExtension();
|
||||
|
||||
const e = Me.imports.extension;
|
||||
const { logDebug } = Me.imports.utils;
|
||||
const utils = Me.imports.utils;
|
||||
const { logDebug } = utils;
|
||||
|
||||
const { TimerNightlight } = Me.imports.modules.TimerNightlight;
|
||||
const { TimerLocation } = Me.imports.modules.TimerLocation;
|
||||
const { TimerSchedule } = Me.imports.modules.TimerSchedule;
|
||||
@@ -31,13 +33,13 @@ const { TimerOndemand } = Me.imports.modules.TimerOndemand;
|
||||
*/
|
||||
var Timer = class {
|
||||
constructor() {
|
||||
this._timeSettings = extensionUtils.getSettings(utils.getSettingsSchema('time'));
|
||||
this._colorSettings = new Gio.Settings({ schema: 'org.gnome.settings-daemon.plugins.color' });
|
||||
this._locationSettings = new Gio.Settings({ schema: 'org.gnome.system.location' });
|
||||
this._sources = [];
|
||||
this._previousTime = null;
|
||||
this._nightlightStatusChangedConnect = null;
|
||||
this._locationStatusChangedConnect = null;
|
||||
this._manualTimeSourceChangedConnect = null;
|
||||
this._timeSourceChangedConnect = null;
|
||||
this._timeChangedConnects = [];
|
||||
this._settingsConnections = [];
|
||||
this._timeConnections = [];
|
||||
}
|
||||
|
||||
enable() {
|
||||
@@ -65,30 +67,31 @@ var Timer = class {
|
||||
|
||||
_connectSettings() {
|
||||
logDebug('Connecting Timer to settings...');
|
||||
this._nightlightStatusChangedConnect = e.settings.system.connect('nightlight-status-changed', this._onSourceChanged.bind(this));
|
||||
this._locationStatusChangedConnect = e.settings.system.connect('location-status-changed', this._onSourceChanged.bind(this));
|
||||
this._manualTimeSourceChangedConnect = e.settings.time.connect('manual-time-source-changed', this._onSourceChanged.bind(this));
|
||||
this._alwaysEnableOndemandChangedConnect = e.settings.time.connect('always-enable-ondemand-changed', this._onSourceChanged.bind(this));
|
||||
this._timeSourceChangedConnect = e.settings.time.connect('time-source-changed', this._onTimeSourceChanged.bind(this));
|
||||
this._settingsConnections.push({
|
||||
settings: this._colorSettings,
|
||||
id: this._colorSettings.connect('changed::night-light-enabled', this._onSourceChanged.bind(this)),
|
||||
});
|
||||
this._settingsConnections.push({
|
||||
settings: this._locationSettings,
|
||||
id: this._locationSettings.connect('changed::enabled', this._onSourceChanged.bind(this)),
|
||||
});
|
||||
this._settingsConnections.push({
|
||||
settings: this._timeSettings,
|
||||
id: this._timeSettings.connect('changed::manual-time-source', this._onSourceChanged.bind(this)),
|
||||
});
|
||||
this._settingsConnections.push({
|
||||
settings: this._timeSettings,
|
||||
id: this._timeSettings.connect('changed::always-enable-ondemand', this._onSourceChanged.bind(this)),
|
||||
});
|
||||
this._settingsConnections.push({
|
||||
settings: this._timeSettings,
|
||||
id: this._timeSettings.connect('changed::time-source', this._onTimeSourceChanged.bind(this)),
|
||||
});
|
||||
}
|
||||
|
||||
_disconnectSettings() {
|
||||
if (this._nightlightStatusChangedConnect) {
|
||||
e.settings.system.disconnect(this._nightlightStatusChangedConnect);
|
||||
this._nightlightStatusChangedConnect = null;
|
||||
}
|
||||
if (this._locationStatusChangedConnect) {
|
||||
e.settings.system.disconnect(this._locationStatusChangedConnect);
|
||||
this._locationStatusChangedConnect = null;
|
||||
}
|
||||
if (this._manualTimeSourceChangedConnect) {
|
||||
e.settings.time.disconnect(this._manualTimeSourceChangedConnect);
|
||||
this._manualTimeSourceChangedConnect = null;
|
||||
}
|
||||
if (this._timeSourceChangedConnect) {
|
||||
e.settings.time.disconnect(this._timeSourceChangedConnect);
|
||||
this._timeSourceChangedConnect = null;
|
||||
}
|
||||
this._settingsConnections.forEach(connection => connection.settings.disconnect(connection.id));
|
||||
this._settingsConnections = [];
|
||||
logDebug('Disconnected Timer from settings.');
|
||||
}
|
||||
|
||||
@@ -109,7 +112,7 @@ var Timer = class {
|
||||
break;
|
||||
}
|
||||
|
||||
if (e.settings.time.alwaysEnableOndemand && ['nightlight', 'location', 'schedule'].includes(source))
|
||||
if (this._timeSettings.get_boolean('always-enable-ondemand') && ['nightlight', 'location', 'schedule'].includes(source))
|
||||
this._sources.unshift(new TimerOndemand());
|
||||
}
|
||||
|
||||
@@ -124,15 +127,15 @@ var Timer = class {
|
||||
|
||||
_connectSources() {
|
||||
logDebug('Connecting to time sources...');
|
||||
this._sources.forEach(source => this._timeChangedConnects.push({
|
||||
this._sources.forEach(source => this._timeConnections.push({
|
||||
source,
|
||||
connect: source.connect('time-changed', this._onTimeChanged.bind(this)),
|
||||
id: source.connect('time-changed', this._onTimeChanged.bind(this)),
|
||||
}));
|
||||
}
|
||||
|
||||
_disconnectSources() {
|
||||
this._timeChangedConnects.forEach(timeChangedConnect => timeChangedConnect.source.disconnect(timeChangedConnect.connect));
|
||||
this._timeChangedConnects = [];
|
||||
this._timeConnections.forEach(connection => connection.source.disconnect(connection.id));
|
||||
this._timeConnections = [];
|
||||
logDebug('Disconnected from time sources.');
|
||||
}
|
||||
|
||||
@@ -142,8 +145,8 @@ var Timer = class {
|
||||
this.enable();
|
||||
}
|
||||
|
||||
_onTimeSourceChanged(_settings, _newSource) {
|
||||
if (e.settings.time.manualTimeSource)
|
||||
_onTimeSourceChanged() {
|
||||
if (this._timeSettings.get_boolean('manual-time-source'))
|
||||
this._onSourceChanged();
|
||||
}
|
||||
|
||||
@@ -160,26 +163,26 @@ var Timer = class {
|
||||
logDebug('Getting time source...');
|
||||
|
||||
let source;
|
||||
if (e.settings.time.manualTimeSource) {
|
||||
source = e.settings.time.timeSource;
|
||||
if (this._timeSettings.get_boolean('manual-time-source')) {
|
||||
source = this._timeSettings.get_string('time-source');
|
||||
logDebug(`Time source is forced to ${source}.`);
|
||||
if (
|
||||
(source === 'nightlight' && !e.settings.system.nightlightEnabled) ||
|
||||
(source === 'location' && !e.settings.system.locationEnabled)
|
||||
(source === 'nightlight' && !this._colorSettings.get_boolean('night-light-enabled')) ||
|
||||
(source === 'location' && !this._locationSettings.get_boolean('enabled'))
|
||||
) {
|
||||
logDebug(`Unable to choose ${source} time source, falling back to manual schedule.`);
|
||||
source = 'schedule';
|
||||
e.settings.time.timeSource = source;
|
||||
this._timeSettings.set_string('time-source', source);
|
||||
}
|
||||
} else {
|
||||
if (e.settings.system.nightlightEnabled)
|
||||
if (this._colorSettings.get_boolean('night-light-enabled'))
|
||||
source = 'nightlight';
|
||||
else if (e.settings.system.locationEnabled)
|
||||
else if (this._locationSettings.get_boolean('enabled'))
|
||||
source = 'location';
|
||||
else
|
||||
source = 'schedule';
|
||||
logDebug(`Time source is ${source}.`);
|
||||
e.settings.time.timeSource = source;
|
||||
this._timeSettings.set_string('time-source', source);
|
||||
}
|
||||
return source;
|
||||
}
|
||||
|
||||
@@ -7,8 +7,8 @@ const Signals = imports.signals;
|
||||
|
||||
const Me = extensionUtils.getCurrentExtension();
|
||||
|
||||
const e = Me.imports.extension;
|
||||
const { logDebug } = Me.imports.utils;
|
||||
const utils = Me.imports.utils;
|
||||
const { logDebug } = utils;
|
||||
|
||||
|
||||
/**
|
||||
@@ -29,12 +29,13 @@ var TimerLocation = class {
|
||||
this._previouslyDaytime = null;
|
||||
// Before we have the location suntimes, we'll use the manual schedule
|
||||
// times
|
||||
const timeSettings = extensionUtils.getSettings(utils.getSettingsSchema('time'));
|
||||
this._suntimes = new Map([
|
||||
['sunrise', e.settings.time.scheduleSunrise],
|
||||
['sunset', e.settings.time.scheduleSunrise],
|
||||
['sunrise', timeSettings.get_double('schedule-sunrise')],
|
||||
['sunset', timeSettings.get_double('schedule-sunset')],
|
||||
]);
|
||||
this._geoclue = null;
|
||||
this._geoclueConnect = null;
|
||||
this._geoclueConnection = null;
|
||||
this._timeChangeTimer = null;
|
||||
this._regularlyUpdateSuntimesTimer = null;
|
||||
}
|
||||
@@ -73,9 +74,9 @@ var TimerLocation = class {
|
||||
|
||||
_disconnectFromGeoclue() {
|
||||
logDebug('Disconnecting from GeoClue...');
|
||||
if (this._geoclueConnect) {
|
||||
this._geoclue.disconnect(this._geoclueConnect);
|
||||
this._geoclueConnect = null;
|
||||
if (this._geoclueConnection) {
|
||||
this._geoclue.disconnect(this._geoclueConnection);
|
||||
this._geoclueConnection = null;
|
||||
}
|
||||
logDebug('Disconnected from GeoClue.');
|
||||
}
|
||||
@@ -83,7 +84,7 @@ var TimerLocation = class {
|
||||
|
||||
_onGeoclueReady(_, result) {
|
||||
this._geoclue = Geoclue.Simple.new_finish(result);
|
||||
this._geoclueConnect = this._geoclue.connect('notify::location', this._onLocationUpdated.bind(this));
|
||||
this._geoclueConnection = this._geoclue.connect('notify::location', this._onLocationUpdated.bind(this));
|
||||
logDebug('Connected to GeoClue.');
|
||||
this._onLocationUpdated();
|
||||
}
|
||||
|
||||
@@ -7,8 +7,8 @@ const Signals = imports.signals;
|
||||
|
||||
const Me = extensionUtils.getCurrentExtension();
|
||||
|
||||
const e = Me.imports.extension;
|
||||
const { logDebug } = Me.imports.utils;
|
||||
const utils = Me.imports.utils;
|
||||
const { logDebug } = utils;
|
||||
|
||||
|
||||
const COLOR_INTERFACE = `
|
||||
@@ -28,9 +28,10 @@ const COLOR_INTERFACE = `
|
||||
*/
|
||||
var TimerNightlight = class {
|
||||
constructor() {
|
||||
this._timeSettings = extensionUtils.getSettings(utils.getSettingsSchema('time'));
|
||||
this._colorDbusProxy = null;
|
||||
this._nightlightFollowDisableConnect = null;
|
||||
this._nightlightStateConnect = null;
|
||||
this._settingsConnections = [];
|
||||
this._nightlightStateConnection = null;
|
||||
this._previousNightlightActive = null;
|
||||
}
|
||||
|
||||
@@ -76,32 +77,33 @@ var TimerNightlight = class {
|
||||
|
||||
_connectSettings() {
|
||||
logDebug('Connecting Night Light Timer to settings...');
|
||||
this._nightlightFollowDisableConnect = e.settings.time.connect('nightlight-follow-disable-changed', this._onNightlightFollowDisableChanged.bind(this));
|
||||
this._settingsConnections.push({
|
||||
settings: this._timeSettings,
|
||||
id: this._timeSettings.connect('changed::nightlight-follow-disable', this._onNightlightFollowDisableChanged.bind(this)),
|
||||
});
|
||||
}
|
||||
|
||||
_disconnectSettings() {
|
||||
logDebug('Disconnecting Night Light Timer from settings...');
|
||||
if (this._nightlightFollowDisableConnect) {
|
||||
e.settings.time.disconnect(this._nightlightFollowDisableConnect);
|
||||
this._nightlightFollowDisableConnect = null;
|
||||
}
|
||||
this._settingsConnections.forEach(connection => connection.settings.disconnect(connection.id));
|
||||
this._settingsConnections = [];
|
||||
}
|
||||
|
||||
_listenToNightlightState() {
|
||||
logDebug('Listening to Night Light state...');
|
||||
this._nightlightStateConnect = this._colorDbusProxy.connect(
|
||||
this._nightlightStateConnection = this._colorDbusProxy.connect(
|
||||
'g-properties-changed',
|
||||
this._onNightlightStateChanged.bind(this)
|
||||
);
|
||||
}
|
||||
|
||||
_stopListeningToNightlightState() {
|
||||
this._colorDbusProxy.disconnect(this._nightlightStateConnect);
|
||||
this._colorDbusProxy.disconnect(this._nightlightStateConnection);
|
||||
logDebug('Stopped listening to Night Light state.');
|
||||
}
|
||||
|
||||
|
||||
_onNightlightFollowDisableChanged(_settings, _value) {
|
||||
_onNightlightFollowDisableChanged() {
|
||||
this._onNightlightStateChanged();
|
||||
}
|
||||
|
||||
@@ -115,7 +117,7 @@ var TimerNightlight = class {
|
||||
|
||||
|
||||
_isNightlightActive() {
|
||||
return e.settings.time.nightlightFollowDisable
|
||||
return this._timeSettings.get_boolean('nightlight-follow-disable')
|
||||
? !this._colorDbusProxy.DisabledUntilTomorrow && this._colorDbusProxy.NightLightActive
|
||||
: this._colorDbusProxy.NightLightActive;
|
||||
}
|
||||
|
||||
@@ -13,7 +13,8 @@ const { PopupBaseMenuItem } = imports.ui.popupMenu;
|
||||
const Me = extensionUtils.getCurrentExtension();
|
||||
|
||||
const e = Me.imports.extension;
|
||||
const { logDebug, findShellAggregateMenuItemPosition } = Me.imports.utils;
|
||||
const utils = Me.imports.utils;
|
||||
const { logDebug } = utils;
|
||||
|
||||
const Gettext = imports.gettext.domain(Me.metadata['gettext-domain']);
|
||||
const _ = Gettext.gettext;
|
||||
@@ -26,11 +27,11 @@ const _ = Gettext.gettext;
|
||||
*/
|
||||
var TimerOndemand = class {
|
||||
constructor() {
|
||||
this._timeSettings = extensionUtils.getSettings(utils.getSettingsSchema('time'));
|
||||
this._settingsConnections = [];
|
||||
this._button = null;
|
||||
this._previousKeybinding = null;
|
||||
this._ondemandKeybindingConnect = null;
|
||||
this._ondemandButtonPlacementConnect = null;
|
||||
this._timeChangedConnect = null;
|
||||
this._timerConnection = null;
|
||||
}
|
||||
|
||||
enable() {
|
||||
@@ -54,75 +55,74 @@ var TimerOndemand = class {
|
||||
|
||||
|
||||
get time() {
|
||||
return e.settings.time.ondemandTime;
|
||||
return this._timeSettings.get_string('ondemand-time');
|
||||
}
|
||||
|
||||
|
||||
_connectSettings() {
|
||||
logDebug('Connecting On-demand Timer to settings...');
|
||||
this._ondemandTimeConnect = e.settings.time.connect('ondemand-time-changed', this._onOndemandTimeChanged.bind(this));
|
||||
this._ondemandKeybindingConnect = e.settings.time.connect('ondemand-keybinding-changed', this._onOndemandKeybindingChanged.bind(this));
|
||||
this._ondemandButtonPlacementConnect = e.settings.time.connect('ondemand-button-placement-changed', this._onOndemandButtonPlacementChanged.bind(this));
|
||||
this._settingsConnections.push({
|
||||
settings: this._timeSettings,
|
||||
id: this._timeSettings.connect('changed::ondemand-time', this._onOndemandTimeChanged.bind(this)),
|
||||
});
|
||||
this._settingsConnections.push({
|
||||
settings: this._timeSettings,
|
||||
id: this._timeSettings.connect('changed::nightthemeswitcher-ondemand-keybinding', this._onOndemandKeybindingChanged.bind(this)),
|
||||
});
|
||||
this._settingsConnections.push({
|
||||
settings: this._timeSettings,
|
||||
id: this._timeSettings.connect('changed::ondemand-button-placement', this._onOndemandButtonPlacementChanged.bind(this)),
|
||||
});
|
||||
}
|
||||
|
||||
_disconnectSettings() {
|
||||
logDebug('Disconnecting On-demand Timer from settings...');
|
||||
if (this._ondemandTimeConnect) {
|
||||
e.settings.time.disconnect(this._ondemandTimeConnect);
|
||||
this._ondemandTimeConnect = null;
|
||||
}
|
||||
if (this._ondemandKeybindingConnect) {
|
||||
e.settings.time.disconnect(this._ondemandKeybindingConnect);
|
||||
this._ondemandKeybindingConnect = null;
|
||||
}
|
||||
if (this._ondemandButtonPlacementConnect) {
|
||||
e.settings.time.disconnect(this._ondemandButtonPlacementConnect);
|
||||
this._ondemandButtonPlacementConnect = null;
|
||||
}
|
||||
this._settingsConnections.forEach(connection => connection.settings.disconnect(connection.id));
|
||||
this._settingsConnections = [];
|
||||
}
|
||||
|
||||
_connectTimer() {
|
||||
logDebug('Connecting On-demand Timer to Timer...');
|
||||
this._timeChangedConnect = e.timer.connect('time-changed', this._onTimeChanged.bind(this));
|
||||
this._timerConnection = e.timer.connect('time-changed', this._onTimeChanged.bind(this));
|
||||
}
|
||||
|
||||
_disconnectTimer() {
|
||||
if (this._timeChangedConnect) {
|
||||
e.timer.disconnect(this._timeChangedConnect);
|
||||
this._timeChangedConnect = null;
|
||||
if (this._timerConnection) {
|
||||
e.timer.disconnect(this._timerConnection);
|
||||
this._timerConnection = null;
|
||||
}
|
||||
logDebug('Disconnected On-demand Timer from Timer.');
|
||||
}
|
||||
|
||||
|
||||
_onOndemandTimeChanged(_settings, _time) {
|
||||
_onOndemandTimeChanged() {
|
||||
this.emit('time-changed', this.time);
|
||||
}
|
||||
|
||||
_onOndemandKeybindingChanged(_settings, _keybinding) {
|
||||
_onOndemandKeybindingChanged() {
|
||||
this._removeKeybinding();
|
||||
this._addKeybinding();
|
||||
}
|
||||
|
||||
_onOndemandButtonPlacementChanged(_settings, _placement) {
|
||||
_onOndemandButtonPlacementChanged() {
|
||||
this._removeButton();
|
||||
this._addButton();
|
||||
}
|
||||
|
||||
_onTimeChanged(_timer, _newTime) {
|
||||
e.settings.time.ondemandTime = e.timer.time;
|
||||
this._timeSettings.set_string('ondemand-time', e.timer.time);
|
||||
this._updateButton();
|
||||
}
|
||||
|
||||
|
||||
_addKeybinding() {
|
||||
this._previousKeybinding = e.settings.time.ondemandKeybinding;
|
||||
if (!e.settings.time.ondemandKeybinding)
|
||||
this._previousKeybinding = this._timeSettings.get_strv('nightthemeswitcher-ondemand-keybinding')[0];
|
||||
if (!this._timeSettings.get_strv('nightthemeswitcher-ondemand-keybinding')[0])
|
||||
return;
|
||||
logDebug('Adding On-demand Timer keybinding...');
|
||||
main.wm.addKeybinding(
|
||||
'nightthemeswitcher-ondemand-keybinding',
|
||||
e.settings.time.settings,
|
||||
this._timeSettings,
|
||||
Meta.KeyBindingFlags.IGNORE_AUTOREPEAT,
|
||||
Shell.ActionMode.NORMAL | Shell.ActionMode.OVERVIEW,
|
||||
this._toggleTime.bind(this)
|
||||
@@ -139,13 +139,12 @@ var TimerOndemand = class {
|
||||
}
|
||||
|
||||
_addButton() {
|
||||
switch (e.settings.time.ondemandButtonPlacement) {
|
||||
switch (this._timeSettings.get_string('ondemand-button-placement')) {
|
||||
case 'panel':
|
||||
this._addButtonToPanel();
|
||||
break;
|
||||
case 'menu':
|
||||
this._addButtonToMenu();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -178,7 +177,7 @@ var TimerOndemand = class {
|
||||
_addButtonToMenu() {
|
||||
logDebug('Adding On-demand Timer button to the menu...');
|
||||
const aggregateMenu = main.panel.statusArea.aggregateMenu;
|
||||
const position = findShellAggregateMenuItemPosition(aggregateMenu._system.menu) - 1;
|
||||
const position = utils.findShellAggregateMenuItemPosition(aggregateMenu._system.menu) - 1;
|
||||
this._button = new NtsPopupMenuItem();
|
||||
this._button.connect('activate', () => {
|
||||
this._toggleTime();
|
||||
@@ -188,7 +187,7 @@ var TimerOndemand = class {
|
||||
}
|
||||
|
||||
_toggleTime() {
|
||||
e.settings.time.ondemandTime = e.timer.time === 'day' ? 'night' : 'day';
|
||||
this._timeSettings.set_string('ondemand-time', e.timer.time === 'day' ? 'night' : 'day');
|
||||
this.emit('time-changed', this.time);
|
||||
}
|
||||
};
|
||||
@@ -235,14 +234,14 @@ var NtsPopupMenuItem = GObject.registerClass(
|
||||
}
|
||||
);
|
||||
|
||||
const _getIconNameForTime = time => {
|
||||
var _getIconNameForTime = time => {
|
||||
return time === 'day' ? 'nightthemeswitcher-ondemand-off-symbolic' : 'nightthemeswitcher-ondemand-on-symbolic';
|
||||
};
|
||||
|
||||
const _getGiconForTime = time => {
|
||||
var _getGiconForTime = time => {
|
||||
return Gio.icon_new_for_string(GLib.build_filenamev([Me.path, 'icons', 'hicolor', 'scalable', 'status', `${this._getIconNameForTime(time)}.svg`]));
|
||||
};
|
||||
|
||||
const _getLabelForTime = time => {
|
||||
var _getLabelForTime = time => {
|
||||
return time === 'day' ? _('Switch to night theme') : _('Switch to day theme');
|
||||
};
|
||||
|
||||
@@ -7,8 +7,8 @@ const Signals = imports.signals;
|
||||
|
||||
const Me = extensionUtils.getCurrentExtension();
|
||||
|
||||
const e = Me.imports.extension;
|
||||
const { logDebug } = Me.imports.utils;
|
||||
const utils = Me.imports.utils;
|
||||
const { logDebug } = utils;
|
||||
|
||||
|
||||
/**
|
||||
@@ -21,6 +21,7 @@ const { logDebug } = Me.imports.utils;
|
||||
*/
|
||||
var TimerSchedule = class {
|
||||
constructor() {
|
||||
this._timeSettings = extensionUtils.getSettings(utils.getSettingsSchema('time'));
|
||||
this._previouslyDaytime = null;
|
||||
this._timeChangeTimer = null;
|
||||
}
|
||||
@@ -47,7 +48,7 @@ var TimerSchedule = class {
|
||||
_isDaytime() {
|
||||
const time = GLib.DateTime.new_now_local();
|
||||
const hour = time.get_hour() + time.get_minute() / 60 + time.get_second() / 3600;
|
||||
return hour >= e.settings.time.scheduleSunrise && hour <= e.settings.time.scheduleSunset;
|
||||
return hour >= this._timeSettings.get_double('schedule-sunrise') && hour <= this._timeSettings.get_double('schedule-sunset');
|
||||
}
|
||||
|
||||
_watchForTimeChange() {
|
||||
|
||||
Reference in New Issue
Block a user