Listen to on-demand time setting changes

This commit is contained in:
Romain Vigier
2021-08-20 11:37:24 +02:00
parent 7e0a9a46b6
commit dac232889e
2 changed files with 17 additions and 0 deletions
+10
View File
@@ -60,12 +60,17 @@ var TimerOndemand = class {
_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));
}
_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;
@@ -90,6 +95,10 @@ var TimerOndemand = class {
}
_onOndemandTimeChanged(_settings, _time) {
this.emit('time-changed', this.time);
}
_onOndemandKeybindingChanged(_settings, _keybinding) {
this._removeKeybinding();
this._addKeybinding();
@@ -101,6 +110,7 @@ var TimerOndemand = class {
}
_onTimeChanged(_timer, _newTime) {
e.settings.time.ondemandTime = e.timer.time;
this._updateButton();
}
+7
View File
@@ -22,6 +22,7 @@ var TimeSettings = class {
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.');
@@ -33,6 +34,7 @@ var TimeSettings = class {
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.');
@@ -144,6 +146,11 @@ var TimeSettings = class {
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}.`);