Timer: Remove night light timer
This commit is contained in:
@@ -65,18 +65,10 @@ SPDX-License-Identifier: GPL-3.0-or-later
|
|||||||
</key>
|
</key>
|
||||||
</schema>
|
</schema>
|
||||||
<schema id="org.gnome.shell.extensions.nightthemeswitcher.time" path="/org/gnome/shell/extensions/nightthemeswitcher/time/">
|
<schema id="org.gnome.shell.extensions.nightthemeswitcher.time" path="/org/gnome/shell/extensions/nightthemeswitcher/time/">
|
||||||
<key name="time-source" type="s">
|
|
||||||
<choices>
|
|
||||||
<choice value="nightlight"/>
|
|
||||||
<choice value="location"/>
|
|
||||||
<choice value="schedule"/>
|
|
||||||
</choices>
|
|
||||||
<default>"schedule"</default>
|
|
||||||
</key>
|
|
||||||
<key name="nightthemeswitcher-ondemand-keybinding" type="as">
|
<key name="nightthemeswitcher-ondemand-keybinding" type="as">
|
||||||
<default><![CDATA[['<Shift><Super>t']]]></default>
|
<default><![CDATA[['<Shift><Super>t']]]></default>
|
||||||
</key>
|
</key>
|
||||||
<key name="manual-time-source" type="b">
|
<key name="manual-schedule" type="b">
|
||||||
<default>false</default>
|
<default>false</default>
|
||||||
</key>
|
</key>
|
||||||
<key name="schedule-sunrise" type="d">
|
<key name="schedule-sunrise" type="d">
|
||||||
|
|||||||
+19
-37
@@ -10,44 +10,13 @@ SPDX-License-Identifier: GPL-3.0-or-later
|
|||||||
<property name="icon-name">nightthemeswitcher-schedule-symbolic</property>
|
<property name="icon-name">nightthemeswitcher-schedule-symbolic</property>
|
||||||
<child>
|
<child>
|
||||||
<object class="AdwPreferencesGroup">
|
<object class="AdwPreferencesGroup">
|
||||||
<child>
|
|
||||||
<object class="AdwActionRow">
|
|
||||||
<property name="title" translatable="yes">Manual time source</property>
|
|
||||||
<property name="subtitle" translatable="yes">The extension will try to use Night Light or Location Services to automatically set your current sunrise and sunset times if they are enabled. If you prefer, you can manually choose a time source.</property>
|
|
||||||
<property name="activatable-widget">manual_time_source_switch</property>
|
|
||||||
<child>
|
|
||||||
<object class="GtkSwitch" id="manual_time_source_switch">
|
|
||||||
<property name="valign">center</property>
|
|
||||||
</object>
|
|
||||||
</child>
|
|
||||||
</object>
|
|
||||||
</child>
|
|
||||||
<child>
|
|
||||||
<object class="AdwComboRow" id="time_source_combo_row">
|
|
||||||
<property name="title" translatable="yes">Time source</property>
|
|
||||||
<property name="sensitive" bind-source="manual_time_source_switch" bind-property="active" bind-flags="sync-create"/>
|
|
||||||
</object>
|
|
||||||
</child>
|
|
||||||
</object>
|
|
||||||
</child>
|
|
||||||
<child>
|
|
||||||
<object class="AdwPreferencesGroup">
|
|
||||||
<property name="title" translatable="yes">Advanced</property>
|
|
||||||
<child>
|
|
||||||
<object class="AdwActionRow">
|
|
||||||
<property name="title" translatable="yes">Keyboard shortcut</property>
|
|
||||||
<property name="activatable-widget">keyboard_shortcut_button</property>
|
|
||||||
<child>
|
|
||||||
<object class="ShortcutButton" id="keyboard_shortcut_button">
|
|
||||||
<property name="valign">center</property>
|
|
||||||
</object>
|
|
||||||
</child>
|
|
||||||
</object>
|
|
||||||
</child>
|
|
||||||
<child>
|
|
||||||
<object class="AdwExpanderRow">
|
|
||||||
<property name="title" translatable="yes">Manual schedule</property>
|
<property name="title" translatable="yes">Manual schedule</property>
|
||||||
<property name="subtitle" translatable="yes">These settings only apply when using the manual schedule as the time source.</property>
|
<property name="description" translatable="yes">Your location will be used to calculate the current sunrise and sunset times. If you prefer, you can set a manual schedule. It will also be used when your location is unavailable.</property>
|
||||||
|
<child type="header-suffix">
|
||||||
|
<object class="GtkSwitch" id="manual_schedule_switch">
|
||||||
|
<property name="valign">start</property>
|
||||||
|
</object>
|
||||||
|
</child>
|
||||||
<child>
|
<child>
|
||||||
<object class="AdwActionRow">
|
<object class="AdwActionRow">
|
||||||
<property name="title" translatable="yes">Sunrise</property>
|
<property name="title" translatable="yes">Sunrise</property>
|
||||||
@@ -74,6 +43,19 @@ SPDX-License-Identifier: GPL-3.0-or-later
|
|||||||
</child>
|
</child>
|
||||||
</object>
|
</object>
|
||||||
</child>
|
</child>
|
||||||
|
<child>
|
||||||
|
<object class="AdwPreferencesGroup">
|
||||||
|
<child>
|
||||||
|
<object class="AdwActionRow">
|
||||||
|
<property name="title" translatable="yes">Keyboard shortcut</property>
|
||||||
|
<property name="activatable-widget">keyboard_shortcut_button</property>
|
||||||
|
<child>
|
||||||
|
<object class="ShortcutButton" id="keyboard_shortcut_button">
|
||||||
|
<property name="valign">center</property>
|
||||||
|
</object>
|
||||||
|
</child>
|
||||||
|
</object>
|
||||||
|
</child>
|
||||||
</object>
|
</object>
|
||||||
</child>
|
</child>
|
||||||
</template>
|
</template>
|
||||||
|
|||||||
@@ -35,7 +35,6 @@ modules = [
|
|||||||
'modules/SwitcherTheme.js',
|
'modules/SwitcherTheme.js',
|
||||||
'modules/Timer.js',
|
'modules/Timer.js',
|
||||||
'modules/TimerLocation.js',
|
'modules/TimerLocation.js',
|
||||||
'modules/TimerNightlight.js',
|
|
||||||
'modules/TimerSchedule.js',
|
'modules/TimerSchedule.js',
|
||||||
]
|
]
|
||||||
preferences = [
|
preferences = [
|
||||||
|
|||||||
+7
-46
@@ -12,7 +12,6 @@ const Me = extensionUtils.getCurrentExtension();
|
|||||||
const debug = Me.imports.debug;
|
const debug = Me.imports.debug;
|
||||||
|
|
||||||
const { Time } = Me.imports.enums.Time;
|
const { Time } = Me.imports.enums.Time;
|
||||||
const { TimerNightlight } = Me.imports.modules.TimerNightlight;
|
|
||||||
const { TimerLocation } = Me.imports.modules.TimerLocation;
|
const { TimerLocation } = Me.imports.modules.TimerLocation;
|
||||||
const { TimerSchedule } = Me.imports.modules.TimerSchedule;
|
const { TimerSchedule } = Me.imports.modules.TimerSchedule;
|
||||||
|
|
||||||
@@ -23,19 +22,13 @@ const { TimerSchedule } = Me.imports.modules.TimerSchedule;
|
|||||||
* They can connect to its 'time-changed' signal and ask its 'time' property
|
* They can connect to its 'time-changed' signal and ask its 'time' property
|
||||||
* for the current time.
|
* for the current time.
|
||||||
*
|
*
|
||||||
* It will try to use one of these three different time sources, in this order
|
* It will try to use the current location as a time source but will fall back
|
||||||
* of preference:
|
* to a manual schedule if the location services are disabled or if the user
|
||||||
* - Night Light
|
* forced the manual schedule in the preferences.
|
||||||
* - Location Services
|
|
||||||
* - Manual schedule
|
|
||||||
*
|
|
||||||
* The user can manually force a specific time source and set the manual
|
|
||||||
* schedule in the extensions's preferences.
|
|
||||||
*/
|
*/
|
||||||
var Timer = class {
|
var Timer = class {
|
||||||
#settings;
|
#settings;
|
||||||
#interfaceSettings;
|
#interfaceSettings;
|
||||||
#colorSettings;
|
|
||||||
#locationSettings;
|
#locationSettings;
|
||||||
#time;
|
#time;
|
||||||
|
|
||||||
@@ -47,7 +40,6 @@ var Timer = class {
|
|||||||
constructor() {
|
constructor() {
|
||||||
this.#settings = extensionUtils.getSettings(`${Me.metadata['settings-schema']}.time`);
|
this.#settings = extensionUtils.getSettings(`${Me.metadata['settings-schema']}.time`);
|
||||||
this.#interfaceSettings = new Gio.Settings({ schema: 'org.gnome.desktop.interface' });
|
this.#interfaceSettings = new Gio.Settings({ schema: 'org.gnome.desktop.interface' });
|
||||||
this.#colorSettings = new Gio.Settings({ schema: 'org.gnome.settings-daemon.plugins.color' });
|
|
||||||
this.#locationSettings = new Gio.Settings({ schema: 'org.gnome.system.location' });
|
this.#locationSettings = new Gio.Settings({ schema: 'org.gnome.system.location' });
|
||||||
this.#time = this.#interfaceSettings.get_string('color-scheme') === 'prefer-dark' ? Time.NIGHT : Time.DAY;
|
this.#time = this.#interfaceSettings.get_string('color-scheme') === 'prefer-dark' ? Time.NIGHT : Time.DAY;
|
||||||
}
|
}
|
||||||
@@ -65,7 +57,7 @@ var Timer = class {
|
|||||||
disable() {
|
disable() {
|
||||||
debug.message('Disabling Timer...');
|
debug.message('Disabling Timer...');
|
||||||
this.#removeKeybinding();
|
this.#removeKeybinding();
|
||||||
this.#disconnectSources();
|
this.#disconnectSource();
|
||||||
this.#disableSource();
|
this.#disableSource();
|
||||||
this.#disconnectSettings();
|
this.#disconnectSettings();
|
||||||
debug.message('Timer disabled.');
|
debug.message('Timer disabled.');
|
||||||
@@ -89,17 +81,13 @@ var Timer = class {
|
|||||||
|
|
||||||
#connectSettings() {
|
#connectSettings() {
|
||||||
debug.message('Connecting Timer to settings...');
|
debug.message('Connecting Timer to settings...');
|
||||||
this.#settingsConnections.push({
|
|
||||||
settings: this.#colorSettings,
|
|
||||||
id: this.#colorSettings.connect('changed::night-light-enabled', this.#onSourceChanged.bind(this)),
|
|
||||||
});
|
|
||||||
this.#settingsConnections.push({
|
this.#settingsConnections.push({
|
||||||
settings: this.#locationSettings,
|
settings: this.#locationSettings,
|
||||||
id: this.#locationSettings.connect('changed::enabled', this.#onSourceChanged.bind(this)),
|
id: this.#locationSettings.connect('changed::enabled', this.#onSourceChanged.bind(this)),
|
||||||
});
|
});
|
||||||
this.#settingsConnections.push({
|
this.#settingsConnections.push({
|
||||||
settings: this.#settings,
|
settings: this.#settings,
|
||||||
id: this.#settings.connect('changed::time-source', this.#onTimeSourceChanged.bind(this)),
|
id: this.#settings.connect('changed::manual-schedule', this.#onSourceChanged.bind(this)),
|
||||||
});
|
});
|
||||||
this.#settingsConnections.push({
|
this.#settingsConnections.push({
|
||||||
settings: this.#settings,
|
settings: this.#settings,
|
||||||
@@ -120,9 +108,6 @@ var Timer = class {
|
|||||||
#createSource() {
|
#createSource() {
|
||||||
const source = this.#getSource();
|
const source = this.#getSource();
|
||||||
switch (source) {
|
switch (source) {
|
||||||
case 'nightlight':
|
|
||||||
this.#source = new TimerNightlight();
|
|
||||||
break;
|
|
||||||
case 'location':
|
case 'location':
|
||||||
this.#source = new TimerLocation();
|
this.#source = new TimerLocation();
|
||||||
break;
|
break;
|
||||||
@@ -160,11 +145,6 @@ var Timer = class {
|
|||||||
this.enable();
|
this.enable();
|
||||||
}
|
}
|
||||||
|
|
||||||
#onTimeSourceChanged() {
|
|
||||||
if (this.#settings.get_boolean('manual-time-source'))
|
|
||||||
this.#onSourceChanged();
|
|
||||||
}
|
|
||||||
|
|
||||||
#onOndemandKeybindingChanged() {
|
#onOndemandKeybindingChanged() {
|
||||||
this.#removeKeybinding();
|
this.#removeKeybinding();
|
||||||
this.#addKeybinding();
|
this.#addKeybinding();
|
||||||
@@ -181,29 +161,10 @@ var Timer = class {
|
|||||||
|
|
||||||
#getSource() {
|
#getSource() {
|
||||||
debug.message('Getting time source...');
|
debug.message('Getting time source...');
|
||||||
|
let source = 'schedule';
|
||||||
let source;
|
if (this.#locationSettings.get_boolean('enabled') && !this.#settings.get_boolean('manual-schedule'))
|
||||||
if (this.#settings.get_boolean('manual-time-source')) {
|
|
||||||
source = this.#settings.get_string('time-source');
|
|
||||||
debug.message(`Time source is forced to ${source}.`);
|
|
||||||
if (
|
|
||||||
(source === 'nightlight' && !this.#colorSettings.get_boolean('night-light-enabled')) ||
|
|
||||||
(source === 'location' && !this.#locationSettings.get_boolean('enabled'))
|
|
||||||
) {
|
|
||||||
debug.message(`Unable to choose ${source} time source, falling back to manual schedule.`);
|
|
||||||
source = 'schedule';
|
|
||||||
this.#settings.set_string('time-source', source);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if (this.#colorSettings.get_boolean('night-light-enabled'))
|
|
||||||
source = 'nightlight';
|
|
||||||
else if (this.#locationSettings.get_boolean('enabled'))
|
|
||||||
source = 'location';
|
source = 'location';
|
||||||
else
|
|
||||||
source = 'schedule';
|
|
||||||
debug.message(`Time source is ${source}.`);
|
debug.message(`Time source is ${source}.`);
|
||||||
this.#settings.set_string('time-source', source);
|
|
||||||
}
|
|
||||||
return source;
|
return source;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,113 +0,0 @@
|
|||||||
// SPDX-FileCopyrightText: 2020-2022 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 debug = Me.imports.debug;
|
|
||||||
|
|
||||||
const { Time } = Me.imports.enums.Time;
|
|
||||||
|
|
||||||
|
|
||||||
const COLOR_INTERFACE = `
|
|
||||||
<node>
|
|
||||||
<interface name="org.gnome.SettingsDaemon.Color">
|
|
||||||
<property name="DisabledUntilTomorrow" type="b" access="readwrite"/>
|
|
||||||
<property name="NightLightActive" type="b" access="read"/>
|
|
||||||
</interface>
|
|
||||||
</node>`;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The Night Light Timer uses Night Light as a time source.
|
|
||||||
*
|
|
||||||
* It connects to the Color SettingsDaemon DBus proxy to listen to the
|
|
||||||
* 'NightLightActive' property and will signal any change.
|
|
||||||
*/
|
|
||||||
var TimerNightlight = class {
|
|
||||||
#cancellable = null;
|
|
||||||
#colorDbusProxy = null;
|
|
||||||
#nightlightStateConnection = null;
|
|
||||||
#previousNightlightState = null;
|
|
||||||
|
|
||||||
async enable() {
|
|
||||||
debug.message('Enabling Night Light Timer...');
|
|
||||||
this.#cancellable = new Gio.Cancellable();
|
|
||||||
this.#colorDbusProxy = await this.#createColorDbusProxy();
|
|
||||||
this.#listenToNightlightState();
|
|
||||||
this.emit('time-changed', this.time);
|
|
||||||
debug.message('Night Light Timer enabled.');
|
|
||||||
}
|
|
||||||
|
|
||||||
disable() {
|
|
||||||
debug.message('Disabling Night Light Timer...');
|
|
||||||
this.#stopListeningToNightlightState();
|
|
||||||
this.#colorDbusProxy = null;
|
|
||||||
this.#cancellable.cancel();
|
|
||||||
this.#cancellable = null;
|
|
||||||
debug.message('Night Light Timer disabled.');
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
get time() {
|
|
||||||
return this.#isNightlightActive() ? Time.NIGHT : Time.DAY;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
#createColorDbusProxy() {
|
|
||||||
debug.message('Creating the Color DBus proxy...');
|
|
||||||
const ColorProxy = Gio.DBusProxy.makeProxyWrapper(COLOR_INTERFACE);
|
|
||||||
return new Promise((resolve, reject) => {
|
|
||||||
ColorProxy(
|
|
||||||
Gio.DBus.session,
|
|
||||||
'org.gnome.SettingsDaemon.Color',
|
|
||||||
'/org/gnome/SettingsDaemon/Color',
|
|
||||||
(proxy, error) => {
|
|
||||||
if (error === null) {
|
|
||||||
debug.message('Created the Color DBus proxy.');
|
|
||||||
resolve(proxy);
|
|
||||||
} else {
|
|
||||||
reject(error);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
this.#cancellable,
|
|
||||||
Gio.DBusProxyFlags.NONE
|
|
||||||
);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
#listenToNightlightState() {
|
|
||||||
debug.message('Listening to Night Light state...');
|
|
||||||
this.#nightlightStateConnection = this.#colorDbusProxy.connect(
|
|
||||||
'g-properties-changed',
|
|
||||||
this.#onNightlightStateChanged.bind(this)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
#stopListeningToNightlightState() {
|
|
||||||
if (this.#colorDbusProxy && this.#nightlightStateConnection) {
|
|
||||||
this.#colorDbusProxy.disconnect(this.#nightlightStateConnection);
|
|
||||||
this.#nightlightStateConnection = null;
|
|
||||||
}
|
|
||||||
debug.message('Stopped listening to Night Light state.');
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
#onNightlightStateChanged(_sender, _dbusProperties) {
|
|
||||||
const newState = this.#isNightlightActive();
|
|
||||||
if (newState !== this.#previousNightlightState) {
|
|
||||||
debug.message(`Night Light has become ${newState ? '' : 'in'}active.`);
|
|
||||||
this.#previousNightlightState = newState;
|
|
||||||
this.emit('time-changed', newState ? Time.NIGHT : Time.DAY);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
#isNightlightActive() {
|
|
||||||
return this.#colorDbusProxy.NightLightActive;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
Signals.addSignalMethods(TimerNightlight.prototype);
|
|
||||||
@@ -24,7 +24,6 @@ src/modules/SwitcherCommands.js
|
|||||||
src/modules/SwitcherTheme.js
|
src/modules/SwitcherTheme.js
|
||||||
src/modules/Timer.js
|
src/modules/Timer.js
|
||||||
src/modules/TimerLocation.js
|
src/modules/TimerLocation.js
|
||||||
src/modules/TimerNightlight.js
|
|
||||||
src/modules/TimerSchedule.js
|
src/modules/TimerSchedule.js
|
||||||
|
|
||||||
src/preferences/BackgroundButton.js
|
src/preferences/BackgroundButton.js
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ msgid ""
|
|||||||
msgstr ""
|
msgstr ""
|
||||||
"Project-Id-Version: nightthemeswitcher@romainvigier.fr\n"
|
"Project-Id-Version: nightthemeswitcher@romainvigier.fr\n"
|
||||||
"Report-Msgid-Bugs-To: \n"
|
"Report-Msgid-Bugs-To: \n"
|
||||||
"POT-Creation-Date: 2022-08-16 02:19+0200\n"
|
"POT-Creation-Date: 2022-08-16 03:46+0200\n"
|
||||||
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
|
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
|
||||||
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
|
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
|
||||||
"Language-Team: LANGUAGE <LL@li.org>\n"
|
"Language-Team: LANGUAGE <LL@li.org>\n"
|
||||||
@@ -50,7 +50,7 @@ msgstr ""
|
|||||||
msgid "Run commands"
|
msgid "Run commands"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: src/data/ui/CommandsPage.ui:21 src/data/ui/SchedulePage.ui:53
|
#: src/data/ui/CommandsPage.ui:21 src/data/ui/SchedulePage.ui:22
|
||||||
msgid "Sunrise"
|
msgid "Sunrise"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
@@ -59,7 +59,7 @@ msgstr ""
|
|||||||
msgid "notify-send \"Hello sunshine!\""
|
msgid "notify-send \"Hello sunshine!\""
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: src/data/ui/CommandsPage.ui:35 src/data/ui/SchedulePage.ui:65
|
#: src/data/ui/CommandsPage.ui:35 src/data/ui/SchedulePage.ui:34
|
||||||
msgid "Sunset"
|
msgid "Sunset"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
@@ -88,36 +88,19 @@ msgstr ""
|
|||||||
msgid "Schedule"
|
msgid "Schedule"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: src/data/ui/SchedulePage.ui:15
|
#: src/data/ui/SchedulePage.ui:13
|
||||||
msgid "Manual time source"
|
|
||||||
msgstr ""
|
|
||||||
|
|
||||||
#: src/data/ui/SchedulePage.ui:16
|
|
||||||
msgid ""
|
|
||||||
"The extension will try to use Night Light or Location Services to "
|
|
||||||
"automatically set your current sunrise and sunset times if they are enabled. "
|
|
||||||
"If you prefer, you can manually choose a time source."
|
|
||||||
msgstr ""
|
|
||||||
|
|
||||||
#: src/data/ui/SchedulePage.ui:27
|
|
||||||
msgid "Time source"
|
|
||||||
msgstr ""
|
|
||||||
|
|
||||||
#: src/data/ui/SchedulePage.ui:35
|
|
||||||
msgid "Advanced"
|
|
||||||
msgstr ""
|
|
||||||
|
|
||||||
#: src/data/ui/SchedulePage.ui:38
|
|
||||||
msgid "Keyboard shortcut"
|
|
||||||
msgstr ""
|
|
||||||
|
|
||||||
#: src/data/ui/SchedulePage.ui:49 src/preferences/SchedulePage.js:48
|
|
||||||
msgid "Manual schedule"
|
msgid "Manual schedule"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: src/data/ui/SchedulePage.ui:50
|
#: src/data/ui/SchedulePage.ui:14
|
||||||
msgid ""
|
msgid ""
|
||||||
"These settings only apply when using the manual schedule as the time source."
|
"Your location will be used to calculate the current sunrise and sunset "
|
||||||
|
"times. If you prefer, you can set a manual schedule. It will also be used "
|
||||||
|
"when your location is unavailable."
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#: src/data/ui/SchedulePage.ui:50
|
||||||
|
msgid "Keyboard shortcut"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: src/data/ui/ShortcutButton.ui:15
|
#: src/data/ui/ShortcutButton.ui:15
|
||||||
@@ -188,14 +171,6 @@ msgstr ""
|
|||||||
msgid "Version %d"
|
msgid "Version %d"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: src/preferences/SchedulePage.js:36
|
|
||||||
msgid "Night Light"
|
|
||||||
msgstr ""
|
|
||||||
|
|
||||||
#: src/preferences/SchedulePage.js:40
|
|
||||||
msgid "Location Services"
|
|
||||||
msgstr ""
|
|
||||||
|
|
||||||
#: src/preferences/ThemesPage.js:50
|
#: src/preferences/ThemesPage.js:50
|
||||||
msgid "Default"
|
msgid "Default"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|||||||
@@ -5,20 +5,14 @@ const { Adw, Gio, GLib, GObject, Gtk } = imports.gi;
|
|||||||
const { extensionUtils } = imports.misc;
|
const { extensionUtils } = imports.misc;
|
||||||
|
|
||||||
const Me = extensionUtils.getCurrentExtension();
|
const Me = extensionUtils.getCurrentExtension();
|
||||||
const _ = extensionUtils.gettext;
|
|
||||||
|
|
||||||
const utils = Me.imports.utils;
|
|
||||||
|
|
||||||
const { DropDownChoice } = Me.imports.preferences.DropDownChoice;
|
|
||||||
|
|
||||||
|
|
||||||
var SchedulePage = GObject.registerClass({
|
var SchedulePage = GObject.registerClass({
|
||||||
GTypeName: 'SchedulePage',
|
GTypeName: 'SchedulePage',
|
||||||
Template: 'resource:///org/gnome/shell/extensions/nightthemeswitcher/preferences/ui/SchedulePage.ui',
|
Template: 'resource:///org/gnome/shell/extensions/nightthemeswitcher/preferences/ui/SchedulePage.ui',
|
||||||
InternalChildren: [
|
InternalChildren: [
|
||||||
|
'manual_schedule_switch',
|
||||||
'keyboard_shortcut_button',
|
'keyboard_shortcut_button',
|
||||||
'manual_time_source_switch',
|
|
||||||
'time_source_combo_row',
|
|
||||||
'schedule_sunrise_time_chooser',
|
'schedule_sunrise_time_chooser',
|
||||||
'schedule_sunset_time_chooser',
|
'schedule_sunset_time_chooser',
|
||||||
],
|
],
|
||||||
@@ -26,40 +20,8 @@ var SchedulePage = GObject.registerClass({
|
|||||||
constructor(props = {}) {
|
constructor(props = {}) {
|
||||||
super(props);
|
super(props);
|
||||||
const settings = extensionUtils.getSettings(`${Me.metadata['settings-schema']}.time`);
|
const settings = extensionUtils.getSettings(`${Me.metadata['settings-schema']}.time`);
|
||||||
const colorSettings = new Gio.Settings({ schema: 'org.gnome.settings-daemon.plugins.color' });
|
|
||||||
const locationSettings = new Gio.Settings({ schema: 'org.gnome.system.location' });
|
|
||||||
|
|
||||||
settings.bind('manual-time-source', this._manual_time_source_switch, 'active', Gio.SettingsBindFlags.DEFAULT);
|
settings.bind('manual-schedule', this._manual_schedule_switch, 'active', Gio.SettingsBindFlags.DEFAULT);
|
||||||
|
|
||||||
const choiceFilter = new Gtk.BoolFilter({ expression: Gtk.PropertyExpression.new(DropDownChoice, null, 'enabled') });
|
|
||||||
|
|
||||||
const nightlightChoice = new DropDownChoice({ id: 'nightlight', title: _('Night Light') });
|
|
||||||
nightlightChoice.connect('notify::enabled', () => choiceFilter.changed(Gtk.FilterChange.DIFFERENT));
|
|
||||||
colorSettings.bind('night-light-enabled', nightlightChoice, 'enabled', Gio.SettingsBindFlags.GET);
|
|
||||||
|
|
||||||
const locationChoice = new DropDownChoice({ id: 'location', title: _('Location Services') });
|
|
||||||
locationChoice.connect('notify::enabled', () => choiceFilter.changed(Gtk.FilterChange.DIFFERENT));
|
|
||||||
locationSettings.bind('enabled', locationChoice, 'enabled', Gio.SettingsBindFlags.GET);
|
|
||||||
|
|
||||||
const timeSources = Gio.ListStore.new(DropDownChoice);
|
|
||||||
timeSources.splice(0, 0, [
|
|
||||||
nightlightChoice,
|
|
||||||
locationChoice,
|
|
||||||
new DropDownChoice({ id: 'schedule', title: _('Manual schedule') }),
|
|
||||||
]);
|
|
||||||
|
|
||||||
this._time_source_combo_row.model = new Gtk.FilterListModel({
|
|
||||||
model: timeSources,
|
|
||||||
filter: choiceFilter,
|
|
||||||
});
|
|
||||||
this._time_source_combo_row.expression = Gtk.PropertyExpression.new(DropDownChoice, null, 'title');
|
|
||||||
this._time_source_combo_row.connect('notify::selected-item', () => settings.set_string('time-source', this._time_source_combo_row.selected_item.id));
|
|
||||||
const updateTimeSourceComboRowState = () => {
|
|
||||||
this._time_source_combo_row.selected = utils.findItemPositionInModel(this._time_source_combo_row.model, item => item.id === settings.get_string('time-source'));
|
|
||||||
this._time_source_combo_row.sensitive = settings.get_boolean('manual-time-source');
|
|
||||||
};
|
|
||||||
settings.connect('changed::time-source', () => updateTimeSourceComboRowState());
|
|
||||||
updateTimeSourceComboRowState();
|
|
||||||
|
|
||||||
settings.bind('schedule-sunrise', this._schedule_sunrise_time_chooser, 'time', Gio.SettingsBindFlags.DEFAULT);
|
settings.bind('schedule-sunrise', this._schedule_sunrise_time_chooser, 'time', Gio.SettingsBindFlags.DEFAULT);
|
||||||
settings.bind('schedule-sunset', this._schedule_sunset_time_chooser, 'time', Gio.SettingsBindFlags.DEFAULT);
|
settings.bind('schedule-sunset', this._schedule_sunset_time_chooser, 'time', Gio.SettingsBindFlags.DEFAULT);
|
||||||
|
|||||||
Reference in New Issue
Block a user