Directly use gsettings

This commit is contained in:
Romain Vigier
2021-08-25 15:17:41 +02:00
parent 8a638c7a3c
commit 4594ebfca7
25 changed files with 458 additions and 1583 deletions
-1
View File
@@ -18,7 +18,6 @@ build:
--extra-source=./modules/ \
--extra-source=./preferences/ \
--extra-source=./schemas/ \
--extra-source=./settings/ \
--podir=./po/ \
--gettext-domain=$(DOMAIN) \
--out-dir=./build \
-6
View File
@@ -10,7 +10,6 @@ const { extensionManager } = imports.ui.main;
const Me = extensionUtils.getCurrentExtension();
const { logDebug } = Me.imports.utils;
const { Settings } = Me.imports.settings.Settings;
const { Timer } = Me.imports.modules.Timer;
const { GtkThemer } = Me.imports.modules.GtkThemer;
const { ShellThemer } = Me.imports.modules.ShellThemer;
@@ -21,7 +20,6 @@ const { Commander } = Me.imports.modules.Commander;
var enabled = false;
var settings = null;
var timer = null;
var gtkThemer = null;
var shellThemer = null;
@@ -53,7 +51,6 @@ function enable() {
*/
function start() {
logDebug('Enabling extension...');
settings = new Settings();
timer = new Timer();
gtkThemer = new GtkThemer();
shellThemer = new ShellThemer();
@@ -62,7 +59,6 @@ function start() {
backgrounder = new Backgrounder();
commander = new Commander();
settings.enable();
timer.enable();
gtkThemer.enable();
shellThemer.enable();
@@ -89,9 +85,7 @@ function disable() {
backgrounder.disable();
commander.disable();
timer.disable();
settings.disable();
settings = null;
timer = null;
gtkThemer = null;
shellThemer = null;
+55 -49
View File
@@ -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
View File
@@ -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
View File
@@ -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
View File
@@ -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
View File
@@ -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
View File
@@ -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
View File
@@ -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;
}
+10 -9
View File
@@ -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();
}
+15 -13
View File
@@ -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;
}
+37 -38
View File
@@ -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');
};
+4 -3
View File
@@ -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() {
+5 -59
View File
@@ -8,7 +8,7 @@ msgid ""
msgstr ""
"Project-Id-Version: Night Theme Switcher\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2021-08-19 15:12+0200\n"
"POT-Creation-Date: 2021-08-25 14:58+0200\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
@@ -17,14 +17,14 @@ msgstr ""
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
#: src/modules/GtkThemer.js:162
#: src/modules/GtkThemer.js:184
#, javascript-format
msgid ""
"Unable to automatically detect the day and night variants for the \"%s\" GTK "
"theme. Please manually choose them in the extension's preferences."
msgstr ""
#: src/modules/ShellThemer.js:168
#: src/modules/ShellThemer.js:196
#, javascript-format
msgid ""
"Unable to automatically detect the day and night variants for the \"%s\" "
@@ -32,11 +32,11 @@ msgid ""
"preferences."
msgstr ""
#: src/modules/TimerOndemand.js:237
#: src/modules/TimerOndemand.js:246
msgid "Switch to night theme"
msgstr ""
#: src/modules/TimerOndemand.js:237
#: src/modules/TimerOndemand.js:246
msgid "Switch to day theme"
msgstr ""
@@ -69,215 +69,173 @@ msgid "The current extension settings version"
msgstr ""
#: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.gschema.xml:17
#: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.v0.gschema.xml:10
msgid "Switch GTK variants"
msgstr ""
#: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.gschema.xml:18
#: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.v0.gschema.xml:11
msgid "Enable GTK variants switching"
msgstr ""
#: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.gschema.xml:22
#: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.v0.gschema.xml:15
msgid "Day GTK theme"
msgstr ""
#: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.gschema.xml:23
#: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.v0.gschema.xml:16
msgid "The GTK theme to use during daytime"
msgstr ""
#: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.gschema.xml:27
#: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.v0.gschema.xml:20
msgid "Night GTK theme"
msgstr ""
#: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.gschema.xml:28
#: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.v0.gschema.xml:21
msgid "The GTK theme to use during nighttime"
msgstr ""
#: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.gschema.xml:32
#: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.v0.gschema.xml:25
msgid "Use manual GTK variants"
msgstr ""
#: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.gschema.xml:33
#: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.v0.gschema.xml:26
msgid "Disable automatic GTK theme variants detection"
msgstr ""
#: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.gschema.xml:39
#: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.v0.gschema.xml:30
msgid "Switch shell variants"
msgstr ""
#: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.gschema.xml:40
#: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.v0.gschema.xml:31
msgid "Enable shell variants switching"
msgstr ""
#: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.gschema.xml:44
#: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.v0.gschema.xml:35
msgid "Day shell theme"
msgstr ""
#: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.gschema.xml:45
#: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.v0.gschema.xml:36
msgid "The shell theme to use during daytime"
msgstr ""
#: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.gschema.xml:49
#: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.v0.gschema.xml:40
msgid "Night shell theme"
msgstr ""
#: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.gschema.xml:50
#: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.v0.gschema.xml:41
msgid "The shell theme to use during nighttime"
msgstr ""
#: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.gschema.xml:54
#: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.v0.gschema.xml:45
msgid "Use manual shell variants"
msgstr ""
#: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.gschema.xml:55
#: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.v0.gschema.xml:46
msgid "Disable automatic shell theme variants detection"
msgstr ""
#: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.gschema.xml:61
#: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.v0.gschema.xml:50
msgid "Switch icon variants"
msgstr ""
#: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.gschema.xml:62
#: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.v0.gschema.xml:51
msgid "Enable icon variants switching"
msgstr ""
#: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.gschema.xml:66
#: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.v0.gschema.xml:55
msgid "Day icon theme"
msgstr ""
#: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.gschema.xml:67
#: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.v0.gschema.xml:56
msgid "The icon theme to use during daytime"
msgstr ""
#: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.gschema.xml:71
#: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.v0.gschema.xml:60
msgid "Night icon theme"
msgstr ""
#: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.gschema.xml:72
#: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.v0.gschema.xml:61
msgid "The icon theme to use during nighttime"
msgstr ""
#: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.gschema.xml:78
#: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.v0.gschema.xml:65
msgid "Switch cursor variants"
msgstr ""
#: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.gschema.xml:79
#: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.v0.gschema.xml:66
msgid "Enable cursor variants switching"
msgstr ""
#: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.gschema.xml:83
#: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.v0.gschema.xml:70
msgid "Day cursor theme"
msgstr ""
#: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.gschema.xml:84
#: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.v0.gschema.xml:71
msgid "The cursor theme to use during daytime"
msgstr ""
#: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.gschema.xml:88
#: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.v0.gschema.xml:75
msgid "Night cursor theme"
msgstr ""
#: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.gschema.xml:89
#: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.v0.gschema.xml:76
msgid "The cursor theme to use during nighttime"
msgstr ""
#: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.gschema.xml:95
#: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.v0.gschema.xml:130
msgid "Enable commands"
msgstr ""
#: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.gschema.xml:96
#: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.v0.gschema.xml:131
msgid "Commands will be spawned on time change"
msgstr ""
#: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.gschema.xml:100
#: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.v0.gschema.xml:135
msgid "Sunrise command"
msgstr ""
#: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.gschema.xml:101
#: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.v0.gschema.xml:136
msgid "The command to spawn at sunrise"
msgstr ""
#: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.gschema.xml:105
#: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.v0.gschema.xml:140
msgid "Sunset command"
msgstr ""
#: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.gschema.xml:106
#: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.v0.gschema.xml:141
msgid "The command to spawn at sunset"
msgstr ""
#: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.gschema.xml:112
#: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.v0.gschema.xml:145
msgid "Enable backgrounds"
msgstr ""
#: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.gschema.xml:113
#: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.v0.gschema.xml:146
msgid "Background will be changed on time change"
msgstr ""
#: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.gschema.xml:117
#: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.v0.gschema.xml:150
#: src/preferences/ui/BackgroundsPreferences.ui:39
msgid "Day background"
msgstr ""
#: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.gschema.xml:118
#: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.v0.gschema.xml:151
msgid "Path to the day background"
msgstr ""
#: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.gschema.xml:122
#: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.v0.gschema.xml:155
#: src/preferences/ui/BackgroundsPreferences.ui:47
msgid "Night background"
msgstr ""
#: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.gschema.xml:123
#: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.v0.gschema.xml:156
msgid "Path to the night background"
msgstr ""
#: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.gschema.xml:135
#: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.v0.gschema.xml:86
#: src/preferences/ui/Schedule.ui:36
msgid "Time source"
msgstr ""
#: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.gschema.xml:136
#: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.v0.gschema.xml:87
msgid "The source used to check current time"
msgstr ""
@@ -298,62 +256,50 @@ msgid "The on-demand timer will always be enabled alongside other timers"
msgstr ""
#: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.gschema.xml:154
#: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.v0.gschema.xml:95
msgid "On-demand time"
msgstr ""
#: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.gschema.xml:155
#: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.v0.gschema.xml:96
msgid "The current time used in on-demand mode"
msgstr ""
#: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.gschema.xml:159
#: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.v0.gschema.xml:100
msgid "Key combination to toggle time"
msgstr ""
#: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.gschema.xml:160
#: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.v0.gschema.xml:101
msgid "The key combination that will toggle time in on-demand mode"
msgstr ""
#: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.gschema.xml:169
#: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.v0.gschema.xml:110
msgid "On-demand button placement"
msgstr ""
#: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.gschema.xml:170
#: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.v0.gschema.xml:111
msgid "Where the on-demand button will be placed"
msgstr ""
#: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.gschema.xml:174
#: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.v0.gschema.xml:115
msgid "Use manual time source"
msgstr ""
#: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.gschema.xml:175
#: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.v0.gschema.xml:116
msgid "Disable automatic time source detection"
msgstr ""
#: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.gschema.xml:179
#: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.v0.gschema.xml:120
msgid "Sunrise time"
msgstr ""
#: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.gschema.xml:180
#: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.v0.gschema.xml:121
msgid "When the day starts"
msgstr ""
#: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.gschema.xml:184
#: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.v0.gschema.xml:125
msgid "Sunset time"
msgstr ""
#: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.gschema.xml:185
#: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.v0.gschema.xml:126
msgid "When the day ends"
msgstr ""
@@ -1,159 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
SPDX-FileCopyrightText: 2021 Romain Vigier <contact AT romainvigier.fr>
SPDX-License-Identifier: GPL-3.0-or-later
-->
<schemalist gettext-domain="nightthemeswitcher@romainvigier.fr">
<schema id="org.gnome.shell.extensions.nightthemeswitcher.v0" path="/org/gnome/shell/extensions/nightthemeswitcher/">
<key name="gtk-variants-enabled" type="b">
<default>true</default>
<summary>Switch GTK variants</summary>
<description>Enable GTK variants switching</description>
</key>
<key name="gtk-variant-day" type="s">
<default>"Adwaita"</default>
<summary>Day GTK theme</summary>
<description>The GTK theme to use during daytime</description>
</key>
<key name="gtk-variant-night" type="s">
<default>"Adwaita-dark"</default>
<summary>Night GTK theme</summary>
<description>The GTK theme to use during nighttime</description>
</key>
<key name="manual-gtk-variants" type="b">
<default>false</default>
<summary>Use manual GTK variants</summary>
<description>Disable automatic GTK theme variants detection</description>
</key>
<key name="shell-variants-enabled" type="b">
<default>true</default>
<summary>Switch shell variants</summary>
<description>Enable shell variants switching</description>
</key>
<key name="shell-variant-day" type="s">
<default>""</default>
<summary>Day shell theme</summary>
<description>The shell theme to use during daytime</description>
</key>
<key name="shell-variant-night" type="s">
<default>""</default>
<summary>Night shell theme</summary>
<description>The shell theme to use during nighttime</description>
</key>
<key name="manual-shell-variants" type="b">
<default>false</default>
<summary>Use manual shell variants</summary>
<description>Disable automatic shell theme variants detection</description>
</key>
<key name="icon-variants-enabled" type="b">
<default>false</default>
<summary>Switch icon variants</summary>
<description>Enable icon variants switching</description>
</key>
<key name="icon-variant-day" type="s">
<default>""</default>
<summary>Day icon theme</summary>
<description>The icon theme to use during daytime</description>
</key>
<key name="icon-variant-night" type="s">
<default>""</default>
<summary>Night icon theme</summary>
<description>The icon theme to use during nighttime</description>
</key>
<key name="cursor-variants-enabled" type="b">
<default>false</default>
<summary>Switch cursor variants</summary>
<description>Enable cursor variants switching</description>
</key>
<key name="cursor-variant-day" type="s">
<default>""</default>
<summary>Day cursor theme</summary>
<description>The cursor theme to use during daytime</description>
</key>
<key name="cursor-variant-night" type="s">
<default>""</default>
<summary>Night cursor theme</summary>
<description>The cursor theme to use during nighttime</description>
</key>
<key name="time-source" type="s">
<choices>
<choice value="nightlight"/>
<choice value="location"/>
<choice value="schedule"/>
<choice value="ondemand"/>
</choices>
<default>"schedule"</default>
<summary>Time source</summary>
<description>The source used to check current time</description>
</key>
<key name="ondemand-time" type="s">
<choices>
<choice value="day"/>
<choice value="night"/>
</choices>
<default>"day"</default>
<summary>On-demand time</summary>
<description>The current time used in on-demand mode</description>
</key>
<key name="nightthemeswitcher-ondemand-keybinding" type="as">
<default><![CDATA[['<Shift><Super>t']]]></default>
<summary>Key combination to toggle time</summary>
<description>The key combination that will toggle time in on-demand mode</description>
</key>
<key name="ondemand-button-placement" type="s">
<choices>
<choice value="none"/>
<choice value="panel"/>
<choice value="menu"/>
</choices>
<default>"panel"</default>
<summary>On-demand button placement</summary>
<description>Where the on-demand button will be placed</description>
</key>
<key name="manual-time-source" type="b">
<default>false</default>
<summary>Use manual time source</summary>
<description>Disable automatic time source detection</description>
</key>
<key name="schedule-sunrise" type="d">
<default>6</default>
<summary>Sunrise time</summary>
<description>When the day starts</description>
</key>
<key name="schedule-sunset" type="d">
<default>20</default>
<summary>Sunset time</summary>
<description>When the day ends</description>
</key>
<key name="commands-enabled" type="b">
<default>false</default>
<summary>Enable commands</summary>
<description>Commands will be spawned on time change</description>
</key>
<key name="command-sunrise" type="s">
<default>""</default>
<summary>Sunrise command</summary>
<description>The command to spawn at sunrise</description>
</key>
<key name="command-sunset" type="s">
<default>""</default>
<summary>Sunset command</summary>
<description>The command to spawn at sunset</description>
</key>
<key name="backgrounds-enabled" type="b">
<default>false</default>
<summary>Enable backgrounds</summary>
<description>Background will be changed on time change</description>
</key>
<key name="background-day" type="s">
<default>""</default>
<summary>Day background</summary>
<description>Path to the day background</description>
</key>
<key name="background-night" type="s">
<default>""</default>
<summary>Night background</summary>
<description>Path to the night background</description>
</key>
</schema>
</schemalist>
-81
View File
@@ -1,81 +0,0 @@
// SPDX-FileCopyrightText: 2020, 2021 Romain Vigier <contact AT romainvigier.fr>
// SPDX-License-Identifier: GPL-3.0-or-later
const { extensionUtils } = imports.misc;
const Signals = imports.signals;
const Me = extensionUtils.getCurrentExtension();
const { logDebug, getSettingsSchema } = Me.imports.utils;
var BackgroundsSettings = class {
constructor() {
logDebug('Initializing backgrounds settings...');
this.settings = extensionUtils.getSettings(getSettingsSchema('backgrounds'));
logDebug('Backgrounds settings initialized.');
}
enable() {
logDebug('Connecting backgrounds settings signals...');
this._enabledChangedConnect = this.settings.connect('changed::enabled', this._onEnabledChanged.bind(this));
this._dayChangedConnect = this.settings.connect('changed::day', this._onDayChanged.bind(this));
this._nightChangedConnect = this.settings.connect('changed::night', this._onNightChanged.bind(this));
logDebug('Backgrounds settings signals connected.');
}
disable() {
logDebug('Disconnecting backgrounds settings signals...');
this.settings.disconnect(this._enabledChangedConnect);
this.settings.disconnect(this._dayChangedConnect);
this.settings.disconnect(this._nightChangedConnect);
logDebug('Backgrounds settings signals disconnected.');
}
get enabled() {
return this.settings.get_boolean('enabled');
}
set enabled(value) {
if (value !== this.enabled)
this.settings.set_boolean('enabled', value);
}
get day() {
return this.settings.get_string('day');
}
set day(value) {
if (value !== this.day)
this.settings.set_string('day', value);
}
get night() {
return this.settings.get_string('night');
}
set night(value) {
if (value !== this.night)
this.settings.set_string('night', value);
}
_onEnabledChanged(_settings, _changedKey) {
logDebug(`Backgrounds have been ${this.enabled ? 'ena' : 'disa'}bled.`);
this.emit('status-changed', this.enabled);
}
_onDayChanged(_settings, _changedKey) {
logDebug(`Day background has changed to '${this.day}'.`);
this.emit('background-changed', 'day');
this.emit('day-changed');
}
_onNightChanged(_settings, _changedKey) {
logDebug(`Night background has changed to '${this.night}'.`);
this.emit('background-changed', 'night');
this.emit('night-changed');
}
};
Signals.addSignalMethods(BackgroundsSettings.prototype);
-81
View File
@@ -1,81 +0,0 @@
// SPDX-FileCopyrightText: 2020, 2021 Romain Vigier <contact AT romainvigier.fr>
// SPDX-License-Identifier: GPL-3.0-or-later
const { extensionUtils } = imports.misc;
const Signals = imports.signals;
const Me = extensionUtils.getCurrentExtension();
const { logDebug, getSettingsSchema } = Me.imports.utils;
var CommandsSettings = class {
constructor() {
logDebug('Initializing commands settings...');
this.settings = extensionUtils.getSettings(getSettingsSchema('commands'));
logDebug('Commands settings initialized.');
}
enable() {
logDebug('Connecting commands settings signals...');
this._enabledChangedConnect = this.settings.connect('changed::enabled', this._onEnabledChanged.bind(this));
this._sunriseChangedConnect = this.settings.connect('changed::sunrise', this._onSunriseChanged.bind(this));
this._sunsetChangedConnect = this.settings.connect('changed::sunset', this._onSunsetChanged.bind(this));
logDebug('Commands settings signals connected.');
}
disable() {
logDebug('Disconnecting commands settings signals...');
this.settings.disconnect(this._enabledChangedConnect);
this.settings.disconnect(this._sunriseChangedConnect);
this.settings.disconnect(this._sunsetChangedConnect);
logDebug('Commands settings signals disconnected.');
}
get enabled() {
return this.settings.get_boolean('enabled');
}
set enabled(value) {
if (value !== this.enabled)
this.settings.set_boolean('enabled', value);
}
get sunrise() {
return this.settings.get_string('sunrise');
}
set sunrise(value) {
if (value !== this.sunrise)
this.settings.set_string('sunrise', value);
}
get sunset() {
return this.settings.get_string('sunset');
}
set sunset(value) {
if (value !== this.sunset)
this.settings.set_string('sunset', value);
}
_onEnabledChanged(_settings, _changedKey) {
logDebug(`Commands have been ${this.enabled ? 'ena' : 'disa'}bled.`);
this.emit('status-changed', this.enabled);
}
_onSunriseChanged(_settings, _changedKey) {
logDebug(`Sunrise command changed to '${this.sunrise}'.`);
this.emit('command-changed', 'sunrise');
this.emit('sunrise-changed');
}
_onSunsetChanged(_settings, _changedKey) {
logDebug(`Sunset command has changed to '${this.sunset}'.`);
this.emit('command-changed', 'sunset');
this.emit('sunset-changed');
}
};
Signals.addSignalMethods(CommandsSettings.prototype);
-83
View File
@@ -1,83 +0,0 @@
// SPDX-FileCopyrightText: 2020, 2021 Romain Vigier <contact AT romainvigier.fr>
// SPDX-License-Identifier: GPL-3.0-or-later
const { extensionUtils } = imports.misc;
const Signals = imports.signals;
const Me = extensionUtils.getCurrentExtension();
const { logDebug, getSettingsSchema } = Me.imports.utils;
var CursorVariantsSettings = class {
constructor() {
logDebug('Initializing cursor variants settings...');
this.settings = extensionUtils.getSettings(getSettingsSchema('cursor-variants'));
logDebug('Cursor variants settings initialized.');
}
enable() {
logDebug('Connecting cursor variants settings signals...');
this._enabledChangedConnect = this.settings.connect('changed::enabled', this._onEnabledChanged.bind(this));
this._dayChangedConnect = this.settings.connect('changed::day', this._onDayChanged.bind(this));
this._nightChangedConnect = this.settings.connect('changed::night', this._onNightChanged.bind(this));
logDebug('Cursor variants settings signals connected.');
}
disable() {
logDebug('Disconnecting cursor variants settings signals...');
this.settings.disconnect(this._enabledChangedConnect);
this.settings.disconnect(this._dayChangedConnect);
this.settings.disconnect(this._nightChangedConnect);
logDebug('Cursor variants settings signals disconnected.');
}
get enabled() {
return this.settings.get_boolean('enabled');
}
set enabled(value) {
if (value !== this.enabled)
this.settings.set_boolean('enabled', value);
}
get day() {
return this.settings.get_string('day');
}
set day(value) {
if (value !== this.day) {
this.settings.set_string('day', value);
logDebug(`The cursor day variant has been set to '${value}'.`);
}
}
get night() {
return this.settings.get_string('night');
}
set night(value) {
if (value !== this.night) {
this.settings.set_string('night', value);
logDebug(`The cursor night variant has been set to '${value}'.`);
}
}
_onEnabledChanged(_settings, _changedKey) {
logDebug(`Cursor variants have been ${this.enabled ? 'ena' : 'disa'}bled.`);
this.emit('status-changed', this.enabled);
}
_onDayChanged(_settings, _changedKey) {
logDebug(`Cursor day variant has changed to '${this.day}'.`);
this.emit('variant-changed', 'day');
}
_onNightChanged(_settings, _changedKey) {
logDebug(`Cursor night variant has changed to '${this.night}'.`);
this.emit('variant-changed', 'night');
}
};
Signals.addSignalMethods(CursorVariantsSettings.prototype);
-99
View File
@@ -1,99 +0,0 @@
// SPDX-FileCopyrightText: 2020, 2021 Romain Vigier <contact AT romainvigier.fr>
// SPDX-License-Identifier: GPL-3.0-or-later
const { extensionUtils } = imports.misc;
const Signals = imports.signals;
const Me = extensionUtils.getCurrentExtension();
const { logDebug, getSettingsSchema } = Me.imports.utils;
var GtkVariantsSettings = class {
constructor() {
logDebug('Initializing GTK variants settings...');
this.settings = extensionUtils.getSettings(getSettingsSchema('gtk-variants'));
logDebug('GTK variants settings initialized.');
}
enable() {
logDebug('Connecting GTK variants settings signals...');
this._enabledChangedConnect = this.settings.connect('changed::enabled', this._onEnabledChanged.bind(this));
this._dayChangedConnect = this.settings.connect('changed::day', this._onDayChanged.bind(this));
this._nightChangedConnect = this.settings.connect('changed::night', this._onNightChanged.bind(this));
this._manualChangedConnect = this.settings.connect('changed::manual', this._onManualChanged.bind(this));
logDebug('GTK variants settings signals connected.');
}
disable() {
logDebug('Disconnecting GTK variants settings signals...');
this.settings.disconnect(this._enabledChangedConnect);
this.settings.disconnect(this._dayChangedConnect);
this.settings.disconnect(this._nightChangedConnect);
this.settings.disconnect(this._manualChangedConnect);
logDebug('GTK variants settings signals disconnected.');
}
get enabled() {
return this.settings.get_boolean('enabled');
}
set enabled(value) {
if (value !== this.enabled)
this.settings.set_boolean('enabled', value);
}
get day() {
return this.settings.get_string('day');
}
set day(value) {
if (value !== this.day) {
this.settings.set_string('day', value);
logDebug(`The GTK day variant has been set to '${value}'.`);
}
}
get night() {
return this.settings.get_string('night');
}
set night(value) {
if (value !== this.night) {
this.settings.set_string('night', value);
logDebug(`The GTK night variant has been set to '${value}'.`);
}
}
get manual() {
return this.settings.get_boolean('manual');
}
set manual(value) {
if (value !== this.manual)
this.settings.set_boolean('manual', value);
}
_onEnabledChanged(_settings, _changedKey) {
logDebug(`GTK variants have been ${this.enabled ? 'ena' : 'disa'}bled.`);
this.emit('status-changed', this.enabled);
}
_onDayChanged(_settings, _changedKey) {
logDebug(`GTK day variant has changed to '${this.day}'.`);
this.emit('variant-changed', 'day');
}
_onNightChanged(_settings, _changedKey) {
logDebug(`GTK night variant has changed to '${this.night}'.`);
this.emit('variant-changed', 'night');
}
_onManualChanged(_settings, _changedKey) {
logDebug(`Manual GTK variants have been ${this.manual ? 'ena' : 'disa'}bled.`);
this.emit('manual-changed', this.manual);
}
};
Signals.addSignalMethods(GtkVariantsSettings.prototype);
-83
View File
@@ -1,83 +0,0 @@
// SPDX-FileCopyrightText: 2020, 2021 Romain Vigier <contact AT romainvigier.fr>
// SPDX-License-Identifier: GPL-3.0-or-later
const { extensionUtils } = imports.misc;
const Signals = imports.signals;
const Me = extensionUtils.getCurrentExtension();
const { logDebug, getSettingsSchema } = Me.imports.utils;
var IconVariantsSettings = class {
constructor() {
logDebug('Initializing icon variants settings...');
this.settings = extensionUtils.getSettings(getSettingsSchema('icon-variants'));
logDebug('Icon variants settings initialized.');
}
enable() {
logDebug('Connecting icon variants settings signals...');
this._enabledChangedConnect = this.settings.connect('changed::enabled', this._onEnabledChanged.bind(this));
this._dayChangedConnect = this.settings.connect('changed::day', this._onDayChanged.bind(this));
this._nightChangedConnect = this.settings.connect('changed::night', this._onNightChanged.bind(this));
logDebug('Icon variants settings signals connected.');
}
disable() {
logDebug('Disconnecting icon variants settings signals...');
this.settings.disconnect(this._enabledChangedConnect);
this.settings.disconnect(this._dayChangedConnect);
this.settings.disconnect(this._nightChangedConnect);
logDebug('Icon variants settings signals disconnected.');
}
get enabled() {
return this.settings.get_boolean('enabled');
}
set enabled(value) {
if (value !== this.enabled)
this.settings.set_boolean('enabled', value);
}
get day() {
return this.settings.get_string('day');
}
set day(value) {
if (value !== this.day) {
this.settings.set_string('day', value);
logDebug(`The icon day variant has been set to '${value}'.`);
}
}
get night() {
return this.settings.get_string('night');
}
set night(value) {
if (value !== this.night) {
this.settings.set_string('night', value);
logDebug(`The icon night variant has been set to '${value}'.`);
}
}
_onEnabledChanged(_settings, _changedKey) {
logDebug(`Icon variants have been ${this.enabled ? 'ena' : 'disa'}bled.`);
this.emit('status-changed', this.enabled);
}
_onDayChanged(_settings, _changedKey) {
logDebug(`Icon day variant has changed to '${this.day}'.`);
this.emit('variant-changed', 'day');
}
_onNightChanged(_settings, _changedKey) {
logDebug(`Icon night variant has changed to '${this.night}'.`);
this.emit('variant-changed', 'night');
}
};
Signals.addSignalMethods(IconVariantsSettings.prototype);
-76
View File
@@ -1,76 +0,0 @@
// SPDX-FileCopyrightText: 2020, 2021 Romain Vigier <contact AT romainvigier.fr>
// SPDX-License-Identifier: GPL-3.0-or-later
const { extensionUtils } = imports.misc;
const Me = extensionUtils.getCurrentExtension();
const { logDebug, notifyError, getSettingsSchema } = Me.imports.utils;
const { BackgroundsSettings } = Me.imports.settings.Backgrounds;
const { CommandsSettings } = Me.imports.settings.Commands;
const { CursorVariantsSettings } = Me.imports.settings.CursorVariants;
const { GtkVariantsSettings } = Me.imports.settings.GtkVariants;
const { IconVariantsSettings } = Me.imports.settings.IconVariants;
const { ShellVariantsSettings } = Me.imports.settings.ShellVariants;
const { SystemSettings } = Me.imports.settings.System;
const { TimeSettings } = Me.imports.settings.Time;
var Settings = class {
constructor() {
logDebug('Initializing settings...');
this.extension = extensionUtils.getSettings();
this.backgrounds = new BackgroundsSettings();
this.commands = new CommandsSettings();
this.cursorVariants = new CursorVariantsSettings();
this.gtkVariants = new GtkVariantsSettings();
this.iconVariants = new IconVariantsSettings();
this.shellVariants = new ShellVariantsSettings();
this.system = new SystemSettings();
this.time = new TimeSettings();
logDebug('Settings initialized.');
this._migrate();
}
enable() {
logDebug('Connecting settings signals...');
this.backgrounds.enable();
this.commands.enable();
this.cursorVariants.enable();
this.gtkVariants.enable();
this.iconVariants.enable();
this.shellVariants.enable();
this.system.enable();
this.time.enable();
logDebug('Settings signals connected.');
}
disable() {
logDebug('Disconnecting settings signals...');
this.backgrounds.disable();
this.commands.disable();
this.cursorVariants.disable();
this.gtkVariants.disable();
this.iconVariants.disable();
this.shellVariants.disable();
this.system.disable();
this.time.disable();
logDebug('Settings signals disconnected.');
}
_migrate() {
const settingsVersion = this.extension.get_int('settings-version');
if (settingsVersion === 0) {
try {
logDebug('Migrating settings from v0 to v1...');
Me.imports.settings.migrations.v0ToV1.migrate(this);
this.extension.set_int('settings-version', 1);
logDebug('Migrated settings from v0 to v1.');
} catch (e) {
notifyError(e);
}
}
}
};
-99
View File
@@ -1,99 +0,0 @@
// SPDX-FileCopyrightText: 2020, 2021 Romain Vigier <contact AT romainvigier.fr>
// SPDX-License-Identifier: GPL-3.0-or-later
const { extensionUtils } = imports.misc;
const Signals = imports.signals;
const Me = extensionUtils.getCurrentExtension();
const { logDebug, getSettingsSchema } = Me.imports.utils;
var ShellVariantsSettings = class {
constructor() {
logDebug('Initializing shell variants settings...');
this.settings = extensionUtils.getSettings(getSettingsSchema('shell-variants'));
logDebug('Shell variants settings initialized.');
}
enable() {
logDebug('Connecting shell variants settings signals...');
this._enabledChangedConnect = this.settings.connect('changed::enabled', this._onEnabledChanged.bind(this));
this._dayChangedConnect = this.settings.connect('changed::day', this._onDayChanged.bind(this));
this._nightChangedConnect = this.settings.connect('changed::night', this._onNightChanged.bind(this));
this._manualChangedConnect = this.settings.connect('changed::manual', this._onManualChanged.bind(this));
logDebug('Shell variants settings signals connected.');
}
disable() {
logDebug('Disconnecting shell variants settings signals...');
this.settings.disconnect(this._enabledChangedConnect);
this.settings.disconnect(this._dayChangedConnect);
this.settings.disconnect(this._nightChangedConnect);
this.settings.disconnect(this._manualChangedConnect);
logDebug('Shell variants settings signals disconnected.');
}
get enabled() {
return this.settings.get_boolean('enabled');
}
set enabled(value) {
if (value !== this.enabled)
this.settings.set_boolean('enabled', value);
}
get day() {
return this.settings.get_string('day');
}
set day(value) {
if (value !== this.day) {
this.settings.set_string('day', value);
logDebug(`The shell day variant has been set to '${value}'.`);
}
}
get night() {
return this.settings.get_string('night');
}
set night(value) {
if (value !== this.night) {
this.settings.set_string('night', value);
logDebug(`The shell night variant has been set to '${value}'.`);
}
}
get manual() {
return this.settings.get_boolean('manual');
}
set manual(value) {
if (value !== this.manual)
this.settings.set_boolean('manual', value);
}
_onEnabledChanged(_settings, _changedKey) {
logDebug(`Shell variants have been ${this.enabled ? 'ena' : 'disa'}bled.`);
this.emit('status-changed', this.enabled);
}
_onDayChanged(_settings, _changedKey) {
logDebug(`Shell day variant has changed to '${this.day}'.`);
this.emit('variant-changed', 'day');
}
_onNightChanged(_settings, _changedKey) {
logDebug(`Shell night variant has changed to '${this.night}'.`);
this.emit('variant-changed', 'night');
}
_onManualChanged(_settings, _changedKey) {
logDebug(`Manual Shell variants have been ${this.manual ? 'ena' : 'disa'}bled.`);
this.emit('manual-changed', this.manual);
}
};
Signals.addSignalMethods(ShellVariantsSettings.prototype);
-159
View File
@@ -1,159 +0,0 @@
// 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 { logDebug, getUserthemesExtension, getUserthemesSettings } = Me.imports.utils;
/**
* The Settings Manager centralizes all the different settings the extension
* needs. It handles getting and settings values as well as signaling any
* changes.
*/
var SystemSettings = class {
constructor() {
logDebug('Initializing system settings...');
this.colorSettings = new Gio.Settings({ schema: 'org.gnome.settings-daemon.plugins.color' });
this.locationSettings = new Gio.Settings({ schema: 'org.gnome.system.location' });
this.interfaceSettings = new Gio.Settings({ schema: 'org.gnome.desktop.interface' });
this.backgroundSettings = new Gio.Settings({ schema: 'org.gnome.desktop.background' });
this.userthemesSettings = getUserthemesSettings();
logDebug('System settings initialized.');
}
enable() {
logDebug('Connecting system settings signals...');
this._nightlightStatusConnect = this.colorSettings.connect('changed::night-light-enabled', this._onNightlightStatusChanged.bind(this));
this._locationStatusConnect = this.locationSettings.connect('changed::enabled', this._onLocationStatusChanged.bind(this));
this._gtkThemeChangedConnect = this.interfaceSettings.connect('changed::gtk-theme', this._onGtkThemeChanged.bind(this));
this._iconThemeChangedConnect = this.interfaceSettings.connect('changed::icon-theme', this._onIconThemeChanged.bind(this));
this._cursorThemeChangedConnect = this.interfaceSettings.connect('changed::cursor-theme', this._onCursorThemeChanged.bind(this));
this._backgroundChangedConnect = this.backgroundSettings.connect('changed::picture-uri', this._onBackgroundChanged.bind(this));
if (this.userthemesSettings)
this._shell_theme_changed_connect = this.userthemesSettings.connect('changed::name', this._onShellThemeChanged.bind(this));
logDebug('System settings signals connected.');
}
disable() {
logDebug('Disconnecting system settings signals...');
this.colorSettings.disconnect(this._nightlightStatusConnect);
this.locationSettings.disconnect(this._locationStatusConnect);
this.interfaceSettings.disconnect(this._gtkThemeChangedConnect);
this.interfaceSettings.disconnect(this._iconThemeChangedConnect);
this.interfaceSettings.disconnect(this._cursorThemeChangedConnect);
this.backgroundSettings.disconnect(this._backgroundChangedConnect);
if (this.userthemesSettings)
this.userthemesSettings.disconnect(this._shell_theme_changed_connect);
logDebug('System settings signals disconnected.');
}
get nightlightEnabled() {
return this.colorSettings.get_boolean('night-light-enabled');
}
get locationEnabled() {
return this.locationSettings.get_boolean('enabled');
}
get gtkTheme() {
return this.interfaceSettings.get_string('gtk-theme');
}
set gtkTheme(value) {
if (value !== this.gtkTheme) {
this.interfaceSettings.set_string('gtk-theme', value);
logDebug(`GTK theme has been set to '${value}'.`);
}
}
get shellTheme() {
if (this.userthemesSettings)
return this.userthemesSettings.get_string('name');
else
return '';
}
set shellTheme(value) {
if (this.userthemesSettings && value !== this.shellTheme)
this.userthemesSettings.set_string('name', value);
}
get useUserthemes() {
const extension = getUserthemesExtension();
return extension && extension.state === 1;
}
get iconTheme() {
return this.interfaceSettings.get_string('icon-theme');
}
set iconTheme(value) {
if (value !== this.iconTheme) {
this.interfaceSettings.set_string('icon-theme', value);
logDebug(`Icon theme has been set to '${value}'.`);
}
}
get cursorTheme() {
return this.interfaceSettings.get_string('cursor-theme');
}
set cursorTheme(value) {
if (value !== this.cursorTheme) {
this.interfaceSettings.set_string('cursor-theme', value);
logDebug(`Cursor theme has been set to '${value}'.`);
}
}
get background() {
return this.backgroundSettings.get_string('picture-uri');
}
set background(value) {
if (value !== this.background)
this.backgroundSettings.set_string('picture-uri', value);
}
_onNightlightStatusChanged(_settings, _changedKey) {
logDebug(`Night Light has been ${this.nightlightEnabled ? 'ena' : 'disa'}bled.`);
this.emit('nightlight-status-changed', this.nightlightEnabled);
}
_onLocationStatusChanged(_settings, _changedKey) {
logDebug(`Location has been ${this.locationEnabled ? 'ena' : 'disa'}bled.`);
this.emit('location-status-changed', this.locationEnabled);
}
_onGtkThemeChanged(_settings, _changedKey) {
logDebug(`GTK theme has changed to '${this.gtkTheme}'.`);
this.emit('gtk-theme-changed', this.gtkTheme);
}
_onShellThemeChanged(_settings, _changedKey) {
logDebug(`Shell theme has changed to '${this.shellTheme}'.`);
this.emit('shell-theme-changed', this.shellTheme);
}
_onIconThemeChanged(_settings, _changedKey) {
logDebug(`Cursor theme has changed to '${this.iconTheme}'.`);
this.emit('icon-theme-changed', this.iconTheme);
}
_onCursorThemeChanged(_settings, _changedKey) {
logDebug(`Cursor theme has changed to '${this.cursorTheme}'.`);
this.emit('cursor-theme-changed', this.cursorTheme);
}
_onBackgroundChanged(_settings, _changedKey) {
logDebug(`Background has changed to '${this.background}'.`);
this.emit('background-changed', this.background);
}
};
Signals.addSignalMethods(SystemSettings.prototype);
-167
View File
@@ -1,167 +0,0 @@
// SPDX-FileCopyrightText: 2020, 2021 Romain Vigier <contact AT romainvigier.fr>
// SPDX-License-Identifier: GPL-3.0-or-later
const { extensionUtils } = imports.misc;
const Signals = imports.signals;
const Me = extensionUtils.getCurrentExtension();
const { logDebug, getSettingsSchema } = Me.imports.utils;
var TimeSettings = class {
constructor() {
logDebug('Initializing time settings...');
this.settings = extensionUtils.getSettings(getSettingsSchema('time'));
logDebug('Time settings initialized.');
}
enable() {
logDebug('Connecting time settings signals...');
this._timeSourceChangedConnect = this.settings.connect('changed::time-source', this._onTimeSourceChanged.bind(this));
this._manualTimeSourceChangedConnect = this.settings.connect('changed::manual-time-source', this._onManualTimeSourceChanged.bind(this));
this._nightlightFollowDisableConnect = this.settings.connect('changed::nightlight-follow-disable', this._onNightlightFollowDisableChanged.bind(this));
this._alwaysEnableOndemandConnect = this.settings.connect('changed::always-enable-ondemand', this._onAlwaysEnableOndemandChanged.bind(this));
this._ondemandTimeChangedConnect = this.settings.connect('changed::ondemand-time', this._onOndemandTimeChanged.bind(this));
this._ondemandKeybindingChangedConnect = this.settings.connect('changed::nightthemeswitcher-ondemand-keybinding', this._onOndemandKeybindingChanged.bind(this));
this._ondemandButtonPlacementChangedConnect = this.settings.connect('changed::ondemand-button-placement', this._onOndemandButtonPlacementChanged.bind(this));
logDebug('System time signals connected.');
}
disable() {
logDebug('Disconnecting time settings signals...');
this.settings.disconnect(this._timeSourceChangedConnect);
this.settings.disconnect(this._manualTimeSourceChangedConnect);
this.settings.disconnect(this._nightlightFollowDisableConnect);
this.settings.disconnect(this._alwaysEnableOndemandConnect);
this.settings.disconnect(this._ondemandTimeChangedConnect);
this.settings.disconnect(this._ondemandKeybindingChangedConnect);
this.settings.disconnect(this._ondemandButtonPlacementChangedConnect);
logDebug('Time settings signals disconnected.');
}
get timeSource() {
return this.settings.get_string('time-source');
}
set timeSource(value) {
if (value !== this.timeSource) {
this.settings.set_string('time-source', value);
logDebug(`The time source has been set to ${value}.`);
}
}
get manualTimeSource() {
return this.settings.get_boolean('manual-time-source');
}
set manualTimeSource(value) {
if (value !== this.manualTimeSource)
this.settings.set_boolean('manual-time-source', value);
}
get nightlightFollowDisable() {
return this.settings.get_boolean('nightlight-follow-disable');
}
set nightlightFollowDisable(value) {
if (value !== this.nightlightFollowDisable)
this.settings.set_boolean('nightlight-follow-disable', value);
}
get alwaysEnableOndemand() {
return this.settings.get_boolean('always-enable-ondemand');
}
set alwaysEnableOndemand(value) {
if (value !== this.alwaysEnableOndemand)
this.settings.set_boolean('always-enable-ondemand', value);
}
get ondemandTime() {
return this.settings.get_string('ondemand-time');
}
set ondemandTime(value) {
if (value !== this.ondemandTime) {
this.settings.set_string('ondemand-time', value);
logDebug(`The on-demand time has been set to ${value}.`);
}
}
get ondemandKeybinding() {
return this.settings.get_strv('nightthemeswitcher-ondemand-keybinding')[0];
}
set ondemandKeybinding(keybinding) {
this.settings.set_strv('nightthemeswitcher-ondemand-keybinding', [keybinding]);
}
get ondemandButtonPlacement() {
return this.settings.get_string('ondemand-button-placement');
}
set ondemandButtonPlacement(value) {
if (value !== this.ondemandButtonPlacement)
this.settings.set_boolean('ondemand-button-placement', value);
}
get scheduleSunrise() {
return this.settings.get_double('schedule-sunrise');
}
set scheduleSunrise(value) {
if (value !== this.scheduleSunrise)
this.settings.set_double('schedule-sunrise', value);
}
get scheduleSunset() {
return this.settings.get_double('schedule-sunset');
}
set scheduleSunset(value) {
if (value !== this.scheduleSunset)
this.settings.set_double('schedule-sunset', value);
}
_onTimeSourceChanged(_settings, _changedKey) {
logDebug(`Time source has changed to ${this.timeSource}.`);
this.emit('time-source-changed', this.timeSource);
}
_onManualTimeSourceChanged(_settings, _changedKey) {
logDebug(`Manual time source has been ${this.manualTimeSource ? 'ena' : 'disa'}bled.`);
this.emit('manual-time-source-changed', this.manualTimeSource);
}
_onNightlightFollowDisableChanged(_settings, _changedKey) {
logDebug(`Follow Night Light "Disable until tomorrow" has been ${this.nightlightFollowDisable ? 'ena' : 'disa'}bled.`);
this.emit('nightlight-follow-disable-changed', this.nightlightFollowDisable);
}
_onAlwaysEnableOndemandChanged(_settings, _changedKey) {
logDebug(`Always enable on-demand timer has been ${this.alwaysEnableOndemand ? 'ena' : 'disa'}bled.`);
this.emit('always-enable-ondemand-changed', this.alwaysEnableOndemand);
}
_onOndemandTimeChanged(_settings, _changedKey) {
logDebug(`On-demand time has changed to ${this.ondemandTime}.`);
this.emit('ondemand-time-changed', this.ondemandTime);
}
_onOndemandKeybindingChanged(_settings, _changedKey) {
if (this.ondemandKeybinding)
logDebug(`On-demand keybinding has changed to ${this.ondemandKeybinding}.`);
else
logDebug('On-demand keybinding has been cleared.');
this.emit('ondemand-keybinding-changed', this.ondemandKeybinding);
}
_onOndemandButtonPlacementChanged(_settings, _changedKey) {
logDebug(`On-demand button placement has changed to ${this.ondemandButtonPlacement}`);
this.emit('ondemand-button-placement-changed', this.ondemandButtonPlacement);
}
};
Signals.addSignalMethods(TimeSettings.prototype);
-51
View File
@@ -1,51 +0,0 @@
// SPDX-FileCopyrightText: 2020, 2021 Romain Vigier <contact AT romainvigier.fr>
// SPDX-License-Identifier: GPL-3.0-or-later
const { extensionUtils } = imports.misc;
const Me = extensionUtils.getCurrentExtension();
const { getSettingsSchema } = Me.imports.utils;
/**
* Migrate settings from v0 to v1.
*
* @param {Settings} settings The current settings.
*/
function migrate(settings) {
const oldSettings = extensionUtils.getSettings(getSettingsSchema('v0'));
settings.gtkVariants.enabled = oldSettings.get_boolean('gtk-variants-enabled');
settings.gtkVariants.day = oldSettings.get_string('gtk-variant-day');
settings.gtkVariants.night = oldSettings.get_string('gtk-variant-night');
settings.gtkVariants.manual = oldSettings.get_boolean('manual-gtk-variants');
settings.shellVariants.enabled = oldSettings.get_boolean('shell-variants-enabled');
settings.shellVariants.day = oldSettings.get_string('shell-variant-day');
settings.shellVariants.night = oldSettings.get_string('shell-variant-night');
settings.shellVariants.manual = oldSettings.get_boolean('manual-shell-variants');
settings.iconVariants.enabled = oldSettings.get_boolean('icon-variants-enabled');
settings.iconVariants.day = oldSettings.get_string('icon-variant-day');
settings.iconVariants.night = oldSettings.get_string('icon-variant-night');
settings.cursorVariants.enabled = oldSettings.get_boolean('cursor-variants-enabled');
settings.cursorVariants.day = oldSettings.get_string('cursor-variant-day');
settings.cursorVariants.night = oldSettings.get_string('cursor-variant-night');
settings.commands.enabled = oldSettings.get_boolean('commands-enabled');
settings.commands.sunrise = oldSettings.get_string('command-sunrise');
settings.commands.sunset = oldSettings.get_string('command-sunset');
settings.backgrounds.enabled = oldSettings.get_boolean('backgrounds-enabled');
settings.backgrounds.day = oldSettings.get_string('background-day');
settings.backgrounds.night = oldSettings.get_string('background-night');
settings.time.timeSource = oldSettings.get_string('time-source');
settings.time.ondemandTime = oldSettings.get_string('ondemand-time');
settings.time.ondemandKeybinding = oldSettings.get_strv('nightthemeswitcher-ondemand-keybinding')[0];
settings.time.ondemandButtonPlacement = oldSettings.get_string('ondemand-button-placement');
settings.time.manualTimeSource = oldSettings.get_boolean('manual-time-source');
settings.time.scheduleSunrise = oldSettings.get_double('schedule-sunrise');
settings.time.scheduleSunset = oldSettings.get_double('schedule-sunset');
}