Night Light Timer: Remove 'Follow Disable until tomorrow'
This commit is contained in:
@@ -74,9 +74,6 @@ SPDX-License-Identifier: GPL-3.0-or-later
|
|||||||
</choices>
|
</choices>
|
||||||
<default>"schedule"</default>
|
<default>"schedule"</default>
|
||||||
</key>
|
</key>
|
||||||
<key name="nightlight-follow-disable" type="b">
|
|
||||||
<default>false</default>
|
|
||||||
</key>
|
|
||||||
<key name="always-enable-ondemand" type="b">
|
<key name="always-enable-ondemand" type="b">
|
||||||
<default>false</default>
|
<default>false</default>
|
||||||
</key>
|
</key>
|
||||||
|
|||||||
@@ -57,24 +57,6 @@ SPDX-License-Identifier: GPL-3.0-or-later
|
|||||||
</child>
|
</child>
|
||||||
</object>
|
</object>
|
||||||
</child>
|
</child>
|
||||||
<child>
|
|
||||||
<object class="AdwExpanderRow" id="nightlight_expander_row">
|
|
||||||
<property name="title" translatable="yes">Night Light</property>
|
|
||||||
<property name="subtitle" translatable="yes">These settings only apply when Night Light is the time source.</property>
|
|
||||||
<child>
|
|
||||||
<object class="AdwActionRow">
|
|
||||||
<property name="title" translatable="yes"><![CDATA[Follow <i>Disable until tomorrow</i>]]></property>
|
|
||||||
<property name="subtitle" translatable="yes">When Night Light is temporarily disabled, the extension will switch to day variants.</property>
|
|
||||||
<property name="activatable-widget">nightlight_follow_disable_switch</property>
|
|
||||||
<child>
|
|
||||||
<object class="GtkSwitch" id="nightlight_follow_disable_switch">
|
|
||||||
<property name="valign">center</property>
|
|
||||||
</object>
|
|
||||||
</child>
|
|
||||||
</object>
|
|
||||||
</child>
|
|
||||||
</object>
|
|
||||||
</child>
|
|
||||||
<child>
|
<child>
|
||||||
<object class="AdwExpanderRow">
|
<object class="AdwExpanderRow">
|
||||||
<property name="title" translatable="yes">Manual schedule</property>
|
<property name="title" translatable="yes">Manual schedule</property>
|
||||||
|
|||||||
@@ -28,23 +28,15 @@ const COLOR_INTERFACE = `
|
|||||||
* 'NightLightActive' property and will signal any change.
|
* 'NightLightActive' property and will signal any change.
|
||||||
*/
|
*/
|
||||||
var TimerNightlight = class {
|
var TimerNightlight = class {
|
||||||
#settings;
|
|
||||||
|
|
||||||
#cancellable = null;
|
#cancellable = null;
|
||||||
#colorDbusProxy = null;
|
#colorDbusProxy = null;
|
||||||
#settingsConnections = [];
|
|
||||||
#nightlightStateConnection = null;
|
#nightlightStateConnection = null;
|
||||||
#previousNightlightState = null;
|
#previousNightlightState = null;
|
||||||
|
|
||||||
constructor() {
|
|
||||||
this.#settings = extensionUtils.getSettings(`${Me.metadata['settings-schema']}.time`);
|
|
||||||
}
|
|
||||||
|
|
||||||
async enable() {
|
async enable() {
|
||||||
debug.message('Enabling Night Light Timer...');
|
debug.message('Enabling Night Light Timer...');
|
||||||
this.#cancellable = new Gio.Cancellable();
|
this.#cancellable = new Gio.Cancellable();
|
||||||
this.#colorDbusProxy = await this.#createColorDbusProxy();
|
this.#colorDbusProxy = await this.#createColorDbusProxy();
|
||||||
this.#connectSettings();
|
|
||||||
this.#listenToNightlightState();
|
this.#listenToNightlightState();
|
||||||
this.emit('time-changed', this.time);
|
this.emit('time-changed', this.time);
|
||||||
debug.message('Night Light Timer enabled.');
|
debug.message('Night Light Timer enabled.');
|
||||||
@@ -53,7 +45,6 @@ var TimerNightlight = class {
|
|||||||
disable() {
|
disable() {
|
||||||
debug.message('Disabling Night Light Timer...');
|
debug.message('Disabling Night Light Timer...');
|
||||||
this.#stopListeningToNightlightState();
|
this.#stopListeningToNightlightState();
|
||||||
this.#disconnectSettings();
|
|
||||||
this.#colorDbusProxy = null;
|
this.#colorDbusProxy = null;
|
||||||
this.#cancellable.cancel();
|
this.#cancellable.cancel();
|
||||||
this.#cancellable = null;
|
this.#cancellable = null;
|
||||||
@@ -88,20 +79,6 @@ var TimerNightlight = class {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
#connectSettings() {
|
|
||||||
debug.message('Connecting Night Light Timer to settings...');
|
|
||||||
this.#settingsConnections.push({
|
|
||||||
settings: this.#settings,
|
|
||||||
id: this.#settings.connect('changed::nightlight-follow-disable', this.#onNightlightFollowDisableChanged.bind(this)),
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
#disconnectSettings() {
|
|
||||||
debug.message('Disconnecting Night Light Timer from settings...');
|
|
||||||
this.#settingsConnections.forEach(connection => connection.settings.disconnect(connection.id));
|
|
||||||
this.#settingsConnections = [];
|
|
||||||
}
|
|
||||||
|
|
||||||
#listenToNightlightState() {
|
#listenToNightlightState() {
|
||||||
debug.message('Listening to Night Light state...');
|
debug.message('Listening to Night Light state...');
|
||||||
this.#nightlightStateConnection = this.#colorDbusProxy.connect(
|
this.#nightlightStateConnection = this.#colorDbusProxy.connect(
|
||||||
@@ -119,10 +96,6 @@ var TimerNightlight = class {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#onNightlightFollowDisableChanged() {
|
|
||||||
this.#onNightlightStateChanged();
|
|
||||||
}
|
|
||||||
|
|
||||||
#onNightlightStateChanged(_sender, _dbusProperties) {
|
#onNightlightStateChanged(_sender, _dbusProperties) {
|
||||||
const newState = this.#isNightlightActive();
|
const newState = this.#isNightlightActive();
|
||||||
if (newState !== this.#previousNightlightState) {
|
if (newState !== this.#previousNightlightState) {
|
||||||
@@ -134,9 +107,7 @@ var TimerNightlight = class {
|
|||||||
|
|
||||||
|
|
||||||
#isNightlightActive() {
|
#isNightlightActive() {
|
||||||
return this.#settings.get_boolean('nightlight-follow-disable')
|
return this.#colorDbusProxy.NightLightActive;
|
||||||
? !this.#colorDbusProxy.DisabledUntilTomorrow && this.#colorDbusProxy.NightLightActive
|
|
||||||
: this.#colorDbusProxy.NightLightActive;
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
Signals.addSignalMethods(TimerNightlight.prototype);
|
Signals.addSignalMethods(TimerNightlight.prototype);
|
||||||
|
|||||||
@@ -20,12 +20,10 @@ var SchedulePage = GObject.registerClass({
|
|||||||
'manual_time_source_switch',
|
'manual_time_source_switch',
|
||||||
'time_source_combo_row',
|
'time_source_combo_row',
|
||||||
'always_show_ondemand_switch',
|
'always_show_ondemand_switch',
|
||||||
'nightlight_follow_disable_switch',
|
|
||||||
'schedule_sunrise_time_chooser',
|
'schedule_sunrise_time_chooser',
|
||||||
'schedule_sunset_time_chooser',
|
'schedule_sunset_time_chooser',
|
||||||
'ondemand_shortcut_button',
|
'ondemand_shortcut_button',
|
||||||
'ondemand_button_location_combo_row',
|
'ondemand_button_location_combo_row',
|
||||||
'nightlight_expander_row',
|
|
||||||
],
|
],
|
||||||
}, class SchedulePage extends Adw.PreferencesPage {
|
}, class SchedulePage extends Adw.PreferencesPage {
|
||||||
constructor(props = {}) {
|
constructor(props = {}) {
|
||||||
@@ -42,7 +40,6 @@ var SchedulePage = GObject.registerClass({
|
|||||||
|
|
||||||
const nightlightChoice = new DropDownChoice({ id: 'nightlight', title: _('Night Light') });
|
const nightlightChoice = new DropDownChoice({ id: 'nightlight', title: _('Night Light') });
|
||||||
nightlightChoice.connect('notify::enabled', () => choiceFilter.changed(Gtk.FilterChange.DIFFERENT));
|
nightlightChoice.connect('notify::enabled', () => choiceFilter.changed(Gtk.FilterChange.DIFFERENT));
|
||||||
nightlightChoice.bind_property('enabled', this._nightlight_expander_row, 'visible', GObject.BindingFlags.DEFAULT);
|
|
||||||
colorSettings.bind('night-light-enabled', nightlightChoice, 'enabled', Gio.SettingsBindFlags.GET);
|
colorSettings.bind('night-light-enabled', nightlightChoice, 'enabled', Gio.SettingsBindFlags.GET);
|
||||||
|
|
||||||
const locationChoice = new DropDownChoice({ id: 'location', title: _('Location Services') });
|
const locationChoice = new DropDownChoice({ id: 'location', title: _('Location Services') });
|
||||||
@@ -72,8 +69,6 @@ var SchedulePage = GObject.registerClass({
|
|||||||
|
|
||||||
settings.bind('always-enable-ondemand', this._always_show_ondemand_switch, 'active', Gio.SettingsBindFlags.DEFAULT);
|
settings.bind('always-enable-ondemand', this._always_show_ondemand_switch, 'active', Gio.SettingsBindFlags.DEFAULT);
|
||||||
|
|
||||||
settings.bind('nightlight-follow-disable', this._nightlight_follow_disable_switch, 'active', Gio.SettingsBindFlags.DEFAULT);
|
|
||||||
|
|
||||||
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