Listen to on-demand time setting changes
This commit is contained in:
@@ -60,12 +60,17 @@ var TimerOndemand = class {
|
|||||||
|
|
||||||
_connectSettings() {
|
_connectSettings() {
|
||||||
logDebug('Connecting On-demand Timer to settings...');
|
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._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._ondemandButtonPlacementConnect = e.settings.time.connect('ondemand-button-placement-changed', this._onOndemandButtonPlacementChanged.bind(this));
|
||||||
}
|
}
|
||||||
|
|
||||||
_disconnectSettings() {
|
_disconnectSettings() {
|
||||||
logDebug('Disconnecting On-demand Timer from settings...');
|
logDebug('Disconnecting On-demand Timer from settings...');
|
||||||
|
if (this._ondemandTimeConnect) {
|
||||||
|
e.settings.time.disconnect(this._ondemandTimeConnect);
|
||||||
|
this._ondemandTimeConnect = null;
|
||||||
|
}
|
||||||
if (this._ondemandKeybindingConnect) {
|
if (this._ondemandKeybindingConnect) {
|
||||||
e.settings.time.disconnect(this._ondemandKeybindingConnect);
|
e.settings.time.disconnect(this._ondemandKeybindingConnect);
|
||||||
this._ondemandKeybindingConnect = null;
|
this._ondemandKeybindingConnect = null;
|
||||||
@@ -90,6 +95,10 @@ var TimerOndemand = class {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
_onOndemandTimeChanged(_settings, _time) {
|
||||||
|
this.emit('time-changed', this.time);
|
||||||
|
}
|
||||||
|
|
||||||
_onOndemandKeybindingChanged(_settings, _keybinding) {
|
_onOndemandKeybindingChanged(_settings, _keybinding) {
|
||||||
this._removeKeybinding();
|
this._removeKeybinding();
|
||||||
this._addKeybinding();
|
this._addKeybinding();
|
||||||
@@ -101,6 +110,7 @@ var TimerOndemand = class {
|
|||||||
}
|
}
|
||||||
|
|
||||||
_onTimeChanged(_timer, _newTime) {
|
_onTimeChanged(_timer, _newTime) {
|
||||||
|
e.settings.time.ondemandTime = e.timer.time;
|
||||||
this._updateButton();
|
this._updateButton();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -22,6 +22,7 @@ var TimeSettings = class {
|
|||||||
this._manualTimeSourceChangedConnect = this.settings.connect('changed::manual-time-source', this._onManualTimeSourceChanged.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._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._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._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));
|
this._ondemandButtonPlacementChangedConnect = this.settings.connect('changed::ondemand-button-placement', this._onOndemandButtonPlacementChanged.bind(this));
|
||||||
logDebug('System time signals connected.');
|
logDebug('System time signals connected.');
|
||||||
@@ -33,6 +34,7 @@ var TimeSettings = class {
|
|||||||
this.settings.disconnect(this._manualTimeSourceChangedConnect);
|
this.settings.disconnect(this._manualTimeSourceChangedConnect);
|
||||||
this.settings.disconnect(this._nightlightFollowDisableConnect);
|
this.settings.disconnect(this._nightlightFollowDisableConnect);
|
||||||
this.settings.disconnect(this._alwaysEnableOndemandConnect);
|
this.settings.disconnect(this._alwaysEnableOndemandConnect);
|
||||||
|
this.settings.disconnect(this._ondemandTimeChangedConnect);
|
||||||
this.settings.disconnect(this._ondemandKeybindingChangedConnect);
|
this.settings.disconnect(this._ondemandKeybindingChangedConnect);
|
||||||
this.settings.disconnect(this._ondemandButtonPlacementChangedConnect);
|
this.settings.disconnect(this._ondemandButtonPlacementChangedConnect);
|
||||||
logDebug('Time settings signals disconnected.');
|
logDebug('Time settings signals disconnected.');
|
||||||
@@ -144,6 +146,11 @@ var TimeSettings = class {
|
|||||||
this.emit('always-enable-ondemand-changed', this.alwaysEnableOndemand);
|
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) {
|
_onOndemandKeybindingChanged(_settings, _changedKey) {
|
||||||
if (this.ondemandKeybinding)
|
if (this.ondemandKeybinding)
|
||||||
logDebug(`On-demand keybinding has changed to ${this.ondemandKeybinding}.`);
|
logDebug(`On-demand keybinding has changed to ${this.ondemandKeybinding}.`);
|
||||||
|
|||||||
Reference in New Issue
Block a user