From 3cc980ff4ee952e22457ff2f37166fd3b6047995 Mon Sep 17 00:00:00 2001 From: Romain Date: Fri, 6 Nov 2020 10:36:50 +0000 Subject: [PATCH] Add on-demand option for all automatic sources --- src/modules/Timer.js | 94 ++-- src/modules/TimerOndemand.js | 38 +- src/po/fr.po | 95 ++-- src/po/nightthemeswitcher@romainvigier.fr.pot | 89 ++-- src/preferences/Schedule.js | 19 +- src/preferences/ui/schedule.ui | 484 +++++++++++------- ....extensions.nightthemeswitcher.gschema.xml | 5 + src/settings/Time.js | 16 + 8 files changed, 520 insertions(+), 320 deletions(-) diff --git a/src/modules/Timer.js b/src/modules/Timer.js index 24aa7d0..c039a8c 100644 --- a/src/modules/Timer.js +++ b/src/modules/Timer.js @@ -35,8 +35,8 @@ const { TimerOndemand } = Me.imports.modules.TimerOndemand; * They can connect to its 'time-changed' signal and ask its 'time' property * for the current time. * - * It will try to use one of this three different time sources, in this order of - * preference: + * It will try to use one of these three different time sources, in this order + * of preference: * - Night Light * - Location Services * - Manual schedule @@ -47,35 +47,35 @@ const { TimerOndemand } = Me.imports.modules.TimerOndemand; var Timer = class { constructor() { - this._source = null; + this._sources = []; this._previousTime = null; this._nightlightStatusChangedConnect = null; this._locationStatusChangedConnect = null; this._manualTimeSourceChangedConnect = null; this._timeSourceChangedConnect = null; - this._timeChangedConnect = null; + this._timeChangedConnects = []; } enable() { logDebug('Enabling Timer...'); this._connectSettings(); - this._createSource(); - this._connectSource(); - this._enableSource(); + this._createSources(); + this._connectSources(); + this._enableSources(); logDebug('Timer enabled.'); } disable() { logDebug('Disabling Timer...'); - this._disconnectSource(); - this._disableSource(); + this._disconnectSources(); + this._disableSources(); this._disconnectSettings(); logDebug('Timer disabled.'); } get time() { - return this._source ? this._source.time : null; + return this._previousTime; } @@ -84,6 +84,7 @@ var Timer = class { 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)); } @@ -107,45 +108,48 @@ var Timer = class { logDebug('Disconnected Timer from settings.'); } - _createSource() { - switch (this._getSource()) { + _createSources() { + const source = this._getSource(); + switch (source) { case 'nightlight': - this._source = new TimerNightlight(); + this._sources.push(new TimerNightlight()); break; case 'location': - this._source = new TimerLocation(); + this._sources.push(new TimerLocation()); break; case 'schedule': - this._source = new TimerSchedule(); + this._sources.push(new TimerSchedule()); break; case 'ondemand': - this._source = new TimerOndemand(); + this._sources.push(new TimerOndemand()); break; } + + if (e.settings.time.alwaysEnableOndemand && ['nightlight', 'location', 'schedule'].includes(source)) + this._sources.push(new TimerOndemand()); } - _enableSource() { - this._source.enable(); + _enableSources() { + this._sources.forEach(source => source.enable()); } - _disableSource() { - if (this._source) { - this._source.disable(); - this._source = null; - } + _disableSources() { + this._sources.forEach(source => source.disable()); + this._sources = []; } - _connectSource() { - logDebug('Connecting to time source...'); - this._timeChangedConnect = this._source.connect('time-changed', this._onTimeChanged.bind(this)); + _connectSources() { + logDebug('Connecting to time sources...'); + this._sources.forEach(source => this._timeChangedConnects.push({ + source, + connect: source.connect('time-changed', this._onTimeChanged.bind(this)), + })); } - _disconnectSource() { - if (this._timeChangedConnect) { - this._source.disconnect(this._timeChangedConnect); - this._timeChangedConnect = null; - } - logDebug('Disconnected from time source.'); + _disconnectSources() { + this._timeChangedConnects.forEach(timeChangedConnect => timeChangedConnect.source.disconnect(timeChangedConnect.connect)); + this._timeChangedConnects = []; + logDebug('Disconnected from time sources.'); } @@ -162,8 +166,8 @@ var Timer = class { _onTimeChanged(_source, newTime) { if (newTime !== this._previousTime) { logDebug(`Time has changed to ${newTime}.`); - this.emit('time-changed', newTime); this._previousTime = newTime; + this.emit('time-changed', newTime); } } @@ -171,8 +175,9 @@ var Timer = class { _getSource() { logDebug('Getting time source...'); + let source; if (e.settings.time.manualTimeSource) { - let source = e.settings.time.timeSource; + source = e.settings.time.timeSource; logDebug(`Time source is forced to ${source}.`); if ( (source === 'nightlight' && !e.settings.system.nightlightEnabled) || @@ -182,19 +187,16 @@ var Timer = class { source = 'schedule'; e.settings.time.timeSource = source; } - return source; + } else { + if (e.settings.system.nightlightEnabled) + source = 'nightlight'; + else if (e.settings.system.locationEnabled) + source = 'location'; + else + source = 'schedule'; + logDebug(`Time source is ${source}.`); + e.settings.time.timeSource = source; } - - let source; - if (e.settings.system.nightlightEnabled) - source = 'nightlight'; - else if (e.settings.system.locationEnabled) - source = 'location'; - else - source = 'schedule'; - - logDebug(`Time source is ${source}.`); - e.settings.time.timeSource = source; return source; } diff --git a/src/modules/TimerOndemand.js b/src/modules/TimerOndemand.js index 747f60d..b4dd65a 100644 --- a/src/modules/TimerOndemand.js +++ b/src/modules/TimerOndemand.js @@ -47,6 +47,7 @@ var TimerOndemand = class { this._previousKeybinding = null; this._ondemandKeybindingConnect = null; this._ondemandButtonPlacementConnect = null; + this._timeChangedConnect = null; } enable() { @@ -54,12 +55,14 @@ var TimerOndemand = class { this._connectSettings(); this._addKeybinding(); this._addButton(); + this._connectTimer(); this.emit('time-changed', this.time); logDebug('On-demand Timer enabled.'); } disable() { logDebug('Disabling On-demand Timer...'); + this._disconnectTimer(); this._removeKeybinding(); this._removeButton(); this._disconnectSettings(); @@ -90,6 +93,19 @@ var TimerOndemand = class { } } + _connectTimer() { + logDebug('Connecting On-demand Timer to Timer...'); + this._timeChangedConnect = e.timer.connect('time-changed', this._onTimeChanged.bind(this)); + } + + _disconnectTimer() { + if (this._timeChangedConnect) { + e.timer.disconnect(this._timeChangedConnect); + this._timeChangedConnect = null; + } + logDebug('Disconnected On-demand Timer from Timer.'); + } + _onOndemandKeybindingChanged(_settings, _keybinding) { this._removeKeybinding(); @@ -101,6 +117,10 @@ var TimerOndemand = class { this._addButton(); } + _onTimeChanged(_timer, _newTime) { + this._updateButton(); + } + _addKeybinding() { this._previousKeybinding = e.settings.time.ondemandKeybinding; @@ -145,6 +165,14 @@ var TimerOndemand = class { } } + _updateButton() { + if (this._button) { + logDebug('Updating On-demand Timer button state...'); + this._button.update(); + logDebug('Updated On-demand Timer button state.'); + } + } + _addButtonToPanel() { logDebug('Adding On-demand Timer button to the panel...'); const icon = new St.Icon({ @@ -154,9 +182,11 @@ var TimerOndemand = class { this._button = new PanelMenuButton(0.0); const buttonActor = getActor(this._button); buttonActor.add_actor(icon); + this._button.update = () => { + icon.gicon = this._getIconForTime(e.timer.time); + }; buttonActor.connect('button-press-event', () => { this._toggleTime(); - icon.gicon = this._getIconForTime(e.timer.time); }); main.panel.addToStatusArea('NightThemeSwitcherButton', this._button); logDebug('Added On-demand Timer button to the panel.'); @@ -167,10 +197,12 @@ var TimerOndemand = class { const aggregateMenu = main.panel.statusArea.aggregateMenu; const position = findShellAggregateMenuItemPosition(aggregateMenu._system.menu) - 1; this._button = new PopupImageMenuItem(this._getLabelForTime(e.timer.time), this._getIconForTime(e.timer.time)); - this._button.connect('activate', () => { - this._toggleTime(); + this._button.update = () => { this._button.label.text = this._getLabelForTime(e.timer.time); this._button.setIcon(this._getIconForTime(e.timer.time)); + }; + this._button.connect('activate', () => { + this._toggleTime(); }); aggregateMenu.menu.addMenuItem(this._button, position); logDebug('Added On-demand Timer button to the menu.'); diff --git a/src/po/fr.po b/src/po/fr.po index 4e3dbd6..5bc275a 100644 --- a/src/po/fr.po +++ b/src/po/fr.po @@ -7,8 +7,8 @@ msgid "" msgstr "" "Project-Id-Version: Night Theme Switcher 7\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2020-11-04 11:00+0100\n" -"PO-Revision-Date: 2020-11-04 11:02+0100\n" +"POT-Creation-Date: 2020-11-06 11:27+0100\n" +"PO-Revision-Date: 2020-11-06 11:29+0100\n" "Last-Translator: Romain Vigier \n" "Language-Team: French \n" "Language: fr\n" @@ -39,11 +39,11 @@ msgstr "" "pour le thème GNOME Shell \"%s\". Veuillez les sélectionner manuellement " "dans les préférences de l’extension." -#: src/modules/TimerOndemand.js:185 +#: src/modules/TimerOndemand.js:217 msgid "Switch to night theme" msgstr "Passer au thème nocturne" -#: src/modules/TimerOndemand.js:185 +#: src/modules/TimerOndemand.js:217 msgid "Switch to day theme" msgstr "Passer au thème diurne" @@ -73,7 +73,7 @@ msgstr "Thème d’icônes" msgid "Schedule" msgstr "Horaires" -#: src/preferences/Schedule.js:204 src/preferences/ui/schedule.ui:741 +#: src/preferences/Schedule.js:217 src/preferences/ui/schedule.ui:842 msgid "Choose" msgstr "Choisir" @@ -320,62 +320,72 @@ msgstr "" "Permuter vers les variantes diurnes lorsque le mode nuit est désactivé " "temporairement" -#: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.gschema.xml:145 +#: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.gschema.xml:141 +msgid "Always enable the on-demand timer" +msgstr "Toujours activer le gestionnaire à la demande" + +#: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.gschema.xml:142 +msgid "The on-demand timer will always be enabled alongside other timers" +msgstr "" +"Le gestionnaire à la demande sera toujours activés avec les autres " +"gestionnaires" + +#: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.gschema.xml:150 #: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.v0.gschema.xml:91 msgid "On-demand time" msgstr "Temps à la demande" -#: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.gschema.xml:146 +#: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.gschema.xml:151 #: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.v0.gschema.xml:92 msgid "The current time used in on-demand mode" msgstr "Le temps actuel utilisé dans le mode à la demande" -#: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.gschema.xml:150 +#: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.gschema.xml:155 #: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.v0.gschema.xml:96 msgid "Key combination to toggle time" msgstr "Combinaison de touches pour permuter le temps" -#: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.gschema.xml:151 +#: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.gschema.xml:156 #: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.v0.gschema.xml:97 msgid "The key combination that will toggle time in on-demand mode" msgstr "La combinaison de touches qui permutera le temps en mode à la demande" -#: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.gschema.xml:160 +#: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.gschema.xml:165 #: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.v0.gschema.xml:106 msgid "On-demand button placement" msgstr "Emplacement du bouton à la demande" -#: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.gschema.xml:161 +#: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.gschema.xml:166 #: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.v0.gschema.xml:107 msgid "Where the on-demand button will be placed" msgstr "Où le bouton du changement à la demande sera placé" -#: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.gschema.xml:165 +#: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.gschema.xml:170 #: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.v0.gschema.xml:111 msgid "Use manual time source" msgstr "Utiliser une source d’horaires manuelle" -#: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.gschema.xml:166 +#: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.gschema.xml:171 #: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.v0.gschema.xml:112 msgid "Disable automatic time source detection" msgstr "Désactive la détection automatique de la source d’horaires" -#: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.gschema.xml:170 +#: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.gschema.xml:175 #: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.v0.gschema.xml:116 msgid "Sunrise time" msgstr "Heure du lever" -#: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.gschema.xml:171 +#: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.gschema.xml:176 #: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.v0.gschema.xml:117 msgid "When the day starts" msgstr "Quand le jour se lève" -#: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.gschema.xml:175 +#: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.gschema.xml:180 #: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.v0.gschema.xml:121 msgid "Sunset time" msgstr "Heure du coucher" -#: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.gschema.xml:176 +#: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.gschema.xml:181 #: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.v0.gschema.xml:122 msgid "When the day ends" msgstr "Quand le jour se couche" @@ -390,7 +400,7 @@ msgstr "Sélectionnez votre image d’arrière-plan" #: src/preferences/ui/backgrounds.ui:220 src/preferences/ui/backgrounds.ui:312 #: src/preferences/ui/commands.ui:206 src/preferences/ui/commands.ui:300 -#: src/preferences/ui/schedule.ui:756 +#: src/preferences/ui/schedule.ui:857 msgid "Clear" msgstr "Effacer" @@ -451,7 +461,7 @@ msgid "Press your keyboard shortcut..." msgstr "Pressez votre raccourci clavier…" #: src/preferences/ui/ondemand_keyboard_shortcut_dialog.ui:76 -#: src/preferences/ui/schedule.ui:727 +#: src/preferences/ui/schedule.ui:828 msgid "Keyboard shortcut" msgstr "Raccourci clavier" @@ -474,37 +484,48 @@ msgstr "" "lever et de coucher du soleil. Si vous préférez, vous pouvez choisir " "manuellement une source d’horaires." -#: src/preferences/ui/schedule.ui:174 +#: src/preferences/ui/schedule.ui:191 +msgid "Always show on-demand controls" +msgstr "Toujours afficher les contrôles à la demande" + +#: src/preferences/ui/schedule.ui:204 +msgid "" +"This allows you to override the current time when using a schedule." +msgstr "" +"Cela vous permet de contrôler le temps quand vous utiliser un horaire." +"" + +#: src/preferences/ui/schedule.ui:266 msgid "Manual time source" msgstr "Source d’horaires manuelle" -#: src/preferences/ui/schedule.ui:194 src/preferences/ui/schedule.ui:300 -#: src/preferences/ui/schedule.ui:416 +#: src/preferences/ui/schedule.ui:286 src/preferences/ui/schedule.ui:392 +#: src/preferences/ui/schedule.ui:508 msgid "Night Light" msgstr "Mode nuit" -#: src/preferences/ui/schedule.ui:209 +#: src/preferences/ui/schedule.ui:301 msgid "Location Services" msgstr "Services de localisation" -#: src/preferences/ui/schedule.ui:224 +#: src/preferences/ui/schedule.ui:316 msgid "Manual schedule" msgstr "Horaire manuel" -#: src/preferences/ui/schedule.ui:239 src/preferences/ui/schedule.ui:685 -#: src/preferences/ui/schedule.ui:865 +#: src/preferences/ui/schedule.ui:331 src/preferences/ui/schedule.ui:786 msgid "On-demand" msgstr "À la demande" -#: src/preferences/ui/schedule.ui:287 +#: src/preferences/ui/schedule.ui:379 msgid "No preferences" msgstr "Pas de préférences" -#: src/preferences/ui/schedule.ui:348 +#: src/preferences/ui/schedule.ui:440 msgid "Follow Disable until tomorrow" msgstr "Suivre Désactiver jusqu’à demain" -#: src/preferences/ui/schedule.ui:362 +#: src/preferences/ui/schedule.ui:454 msgid "" "When Night Light is temporarily disabled, the extension will switch " "to day variants." @@ -512,35 +533,35 @@ msgstr "" "Quand le mode nuit est temporairement désactivé, l’extension va " "permuter vers les variantes diurnes." -#: src/preferences/ui/schedule.ui:432 src/preferences/ui/schedule.ui:669 +#: src/preferences/ui/schedule.ui:524 src/preferences/ui/schedule.ui:761 msgid "Manual schedule times" msgstr "Horaires manuels" -#: src/preferences/ui/schedule.ui:474 +#: src/preferences/ui/schedule.ui:566 msgid "Sunrise" msgstr "Lever du soleil" -#: src/preferences/ui/schedule.ui:510 src/preferences/ui/schedule.ui:617 +#: src/preferences/ui/schedule.ui:602 src/preferences/ui/schedule.ui:709 msgid ":" msgstr ":" -#: src/preferences/ui/schedule.ui:581 +#: src/preferences/ui/schedule.ui:673 msgid "Sunset" msgstr "Coucher du soleil" -#: src/preferences/ui/schedule.ui:819 +#: src/preferences/ui/schedule.ui:920 msgid "Button location" msgstr "Emplacement du bouton" -#: src/preferences/ui/schedule.ui:835 +#: src/preferences/ui/schedule.ui:936 msgid "None" msgstr "Aucun" -#: src/preferences/ui/schedule.ui:836 +#: src/preferences/ui/schedule.ui:937 msgid "Top bar" msgstr "Barre supérieure" -#: src/preferences/ui/schedule.ui:837 +#: src/preferences/ui/schedule.ui:938 msgid "System menu" msgstr "Menu système" diff --git a/src/po/nightthemeswitcher@romainvigier.fr.pot b/src/po/nightthemeswitcher@romainvigier.fr.pot index fedf406..2499b16 100644 --- a/src/po/nightthemeswitcher@romainvigier.fr.pot +++ b/src/po/nightthemeswitcher@romainvigier.fr.pot @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: Night Theme Switcher 39\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2020-11-04 11:00+0100\n" +"POT-Creation-Date: 2020-11-06 11:27+0100\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -32,11 +32,11 @@ msgid "" "preferences." msgstr "" -#: src/modules/TimerOndemand.js:185 +#: src/modules/TimerOndemand.js:217 msgid "Switch to night theme" msgstr "" -#: src/modules/TimerOndemand.js:185 +#: src/modules/TimerOndemand.js:217 msgid "Switch to day theme" msgstr "" @@ -66,7 +66,7 @@ msgstr "" msgid "Schedule" msgstr "" -#: src/preferences/Schedule.js:204 src/preferences/ui/schedule.ui:741 +#: src/preferences/Schedule.js:217 src/preferences/ui/schedule.ui:842 msgid "Choose" msgstr "" @@ -311,62 +311,70 @@ msgstr "" msgid "Switch back to day time when Night Light is temporarily disabled" msgstr "" -#: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.gschema.xml:145 +#: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.gschema.xml:141 +msgid "Always enable the on-demand timer" +msgstr "" + +#: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.gschema.xml:142 +msgid "The on-demand timer will always be enabled alongside other timers" +msgstr "" + +#: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.gschema.xml:150 #: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.v0.gschema.xml:91 msgid "On-demand time" msgstr "" -#: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.gschema.xml:146 +#: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.gschema.xml:151 #: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.v0.gschema.xml:92 msgid "The current time used in on-demand mode" msgstr "" -#: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.gschema.xml:150 +#: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.gschema.xml:155 #: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.v0.gschema.xml:96 msgid "Key combination to toggle time" msgstr "" -#: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.gschema.xml:151 +#: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.gschema.xml:156 #: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.v0.gschema.xml:97 msgid "The key combination that will toggle time in on-demand mode" msgstr "" -#: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.gschema.xml:160 +#: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.gschema.xml:165 #: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.v0.gschema.xml:106 msgid "On-demand button placement" msgstr "" -#: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.gschema.xml:161 +#: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.gschema.xml:166 #: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.v0.gschema.xml:107 msgid "Where the on-demand button will be placed" msgstr "" -#: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.gschema.xml:165 +#: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.gschema.xml:170 #: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.v0.gschema.xml:111 msgid "Use manual time source" msgstr "" -#: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.gschema.xml:166 +#: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.gschema.xml:171 #: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.v0.gschema.xml:112 msgid "Disable automatic time source detection" msgstr "" -#: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.gschema.xml:170 +#: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.gschema.xml:175 #: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.v0.gschema.xml:116 msgid "Sunrise time" msgstr "" -#: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.gschema.xml:171 +#: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.gschema.xml:176 #: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.v0.gschema.xml:117 msgid "When the day starts" msgstr "" -#: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.gschema.xml:175 +#: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.gschema.xml:180 #: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.v0.gschema.xml:121 msgid "Sunset time" msgstr "" -#: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.gschema.xml:176 +#: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.gschema.xml:181 #: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.v0.gschema.xml:122 msgid "When the day ends" msgstr "" @@ -381,7 +389,7 @@ msgstr "" #: src/preferences/ui/backgrounds.ui:220 src/preferences/ui/backgrounds.ui:312 #: src/preferences/ui/commands.ui:206 src/preferences/ui/commands.ui:300 -#: src/preferences/ui/schedule.ui:756 +#: src/preferences/ui/schedule.ui:857 msgid "Clear" msgstr "" @@ -435,7 +443,7 @@ msgid "Press your keyboard shortcut..." msgstr "" #: src/preferences/ui/ondemand_keyboard_shortcut_dialog.ui:76 -#: src/preferences/ui/schedule.ui:727 +#: src/preferences/ui/schedule.ui:828 msgid "Keyboard shortcut" msgstr "" @@ -454,71 +462,80 @@ msgid "" "If you prefer, you can manually choose a time source." msgstr "" -#: src/preferences/ui/schedule.ui:174 +#: src/preferences/ui/schedule.ui:191 +msgid "Always show on-demand controls" +msgstr "" + +#: src/preferences/ui/schedule.ui:204 +msgid "" +"This allows you to override the current time when using a schedule." +msgstr "" + +#: src/preferences/ui/schedule.ui:266 msgid "Manual time source" msgstr "" -#: src/preferences/ui/schedule.ui:194 src/preferences/ui/schedule.ui:300 -#: src/preferences/ui/schedule.ui:416 +#: src/preferences/ui/schedule.ui:286 src/preferences/ui/schedule.ui:392 +#: src/preferences/ui/schedule.ui:508 msgid "Night Light" msgstr "" -#: src/preferences/ui/schedule.ui:209 +#: src/preferences/ui/schedule.ui:301 msgid "Location Services" msgstr "" -#: src/preferences/ui/schedule.ui:224 +#: src/preferences/ui/schedule.ui:316 msgid "Manual schedule" msgstr "" -#: src/preferences/ui/schedule.ui:239 src/preferences/ui/schedule.ui:685 -#: src/preferences/ui/schedule.ui:865 +#: src/preferences/ui/schedule.ui:331 src/preferences/ui/schedule.ui:786 msgid "On-demand" msgstr "" -#: src/preferences/ui/schedule.ui:287 +#: src/preferences/ui/schedule.ui:379 msgid "No preferences" msgstr "" -#: src/preferences/ui/schedule.ui:348 +#: src/preferences/ui/schedule.ui:440 msgid "Follow Disable until tomorrow" msgstr "" -#: src/preferences/ui/schedule.ui:362 +#: src/preferences/ui/schedule.ui:454 msgid "" "When Night Light is temporarily disabled, the extension will switch " "to day variants." msgstr "" -#: src/preferences/ui/schedule.ui:432 src/preferences/ui/schedule.ui:669 +#: src/preferences/ui/schedule.ui:524 src/preferences/ui/schedule.ui:761 msgid "Manual schedule times" msgstr "" -#: src/preferences/ui/schedule.ui:474 +#: src/preferences/ui/schedule.ui:566 msgid "Sunrise" msgstr "" -#: src/preferences/ui/schedule.ui:510 src/preferences/ui/schedule.ui:617 +#: src/preferences/ui/schedule.ui:602 src/preferences/ui/schedule.ui:709 msgid ":" msgstr "" -#: src/preferences/ui/schedule.ui:581 +#: src/preferences/ui/schedule.ui:673 msgid "Sunset" msgstr "" -#: src/preferences/ui/schedule.ui:819 +#: src/preferences/ui/schedule.ui:920 msgid "Button location" msgstr "" -#: src/preferences/ui/schedule.ui:835 +#: src/preferences/ui/schedule.ui:936 msgid "None" msgstr "" -#: src/preferences/ui/schedule.ui:836 +#: src/preferences/ui/schedule.ui:937 msgid "Top bar" msgstr "" -#: src/preferences/ui/schedule.ui:837 +#: src/preferences/ui/schedule.ui:938 msgid "System menu" msgstr "" diff --git a/src/preferences/Schedule.js b/src/preferences/Schedule.js index 16e681f..5c2882f 100644 --- a/src/preferences/Schedule.js +++ b/src/preferences/Schedule.js @@ -49,6 +49,14 @@ var SchedulePreferences = class { Gio.SettingsBindFlags.INVERT_BOOLEAN ); + const alwaysEnableOndemandSwitch = this._builder.get_object('always_enable_ondemand_switch'); + settings.time.settings.bind( + 'always-enable-ondemand', + alwaysEnableOndemandSwitch, + 'active', + Gio.SettingsBindFlags.DEFAULT + ); + const manual = this._builder.get_object('manual'); settings.time.settings.bind( 'manual-time-source', @@ -122,9 +130,6 @@ var SchedulePreferences = class { case 'schedule': manualPrefsStack.set_visible_child_name('schedule_times'); break; - case 'ondemand': - manualPrefsStack.set_visible_child_name('ondemand'); - break; default: manualPrefsStack.set_visible_child_name('none'); } @@ -198,6 +203,14 @@ var SchedulePreferences = class { settings.time.scheduleSunset = newTime; }); + const ondemand = this._builder.get_object('ondemand'); + const updateOndemandVisibility = () => { + ondemand.visible = settings.time.alwaysEnableOndemand || settings.time.timeSource === 'ondemand'; + }; + settings.time.connect('always-enable-ondemand-changed', () => updateOndemandVisibility()); + settings.time.connect('time-source-changed', () => updateOndemandVisibility()); + updateOndemandVisibility(); + const ondemandShortcutButton = this._builder.get_object('ondemand_shortcut_button'); const updateOndemandShortcutButtonLabel = () => { const label = settings.time.ondemandKeybinding; diff --git a/src/preferences/ui/schedule.ui b/src/preferences/ui/schedule.ui index 49b8206..94761d2 100644 --- a/src/preferences/ui/schedule.ui +++ b/src/preferences/ui/schedule.ui @@ -59,7 +59,7 @@ Author: Romain Vigier 30 top - + True False 0 @@ -148,6 +148,98 @@ Author: Romain Vigier + + + True + True + False + False + + + True + False + + + + + + + True + True + False + + + True + False + 16 + 16 + 16 + 16 + 16 + 16 + 30 + + + True + False + vertical + + + True + False + start + Always show on-demand controls + + + False + True + 0 + + + + + True + False + start + <small>This allows you to override the current time when using a schedule.</small> + True + True + 50 + 0 + + + + False + False + 1 + + + + + False + True + 0 + + + + + True + True + end + center + + + True + True + 1 + + + + + + @@ -671,200 +763,7 @@ Author: Romain Vigier - - 600 - True - False - vertical - 8 - - - True - False - start - On-demand - - - - - - False - True - 0 - - - - - True - False - 0 - - - 600 - True - False - none - - - True - True - False - - - True - False - 16 - 16 - 16 - 16 - 16 - 16 - 30 - - - True - False - Keyboard shortcut - - - False - True - 0 - - - - - True - False - - - Choose - True - True - True - end - center - - - False - True - 0 - - - - - Clear - True - True - True - - - - False - True - 1 - - - - - - False - False - end - 1 - - - - - - - - - True - True - False - False - - - True - False - - - - - - - True - True - False - - - True - False - 16 - 16 - 16 - 16 - 16 - 16 - 30 - - - True - False - Button location - - - False - True - 0 - - - - - True - False - end - 1 - panel - - None - Top bar - System menu - - - - True - True - 1 - - - - - - - - - - - - - - False - True - 1 - - - - - ondemand - On-demand - 3 - + @@ -873,5 +772,200 @@ Author: Romain Vigier 2 + + + True + False + vertical + 8 + + + True + False + start + On-demand + + + + + + False + True + 0 + + + + + True + False + 0 + + + 600 + True + False + none + + + True + True + False + + + True + False + 16 + 16 + 16 + 16 + 16 + 16 + 30 + + + True + False + Keyboard shortcut + + + False + True + 0 + + + + + True + False + + + Choose + True + True + True + end + center + + + False + True + 0 + + + + + Clear + True + True + True + + + + False + True + 1 + + + + + + False + False + end + 1 + + + + + + + + + True + True + False + False + + + True + False + + + + + + + True + True + False + + + True + False + 16 + 16 + 16 + 16 + 16 + 16 + 30 + + + True + False + Button location + + + False + True + 0 + + + + + True + False + end + 1 + panel + + None + Top bar + System menu + + + + True + True + 1 + + + + + + + + + + + + + + False + True + 1 + + + + + False + True + 3 + + diff --git a/src/schemas/org.gnome.shell.extensions.nightthemeswitcher.gschema.xml b/src/schemas/org.gnome.shell.extensions.nightthemeswitcher.gschema.xml index 932d17d..34e1e5e 100644 --- a/src/schemas/org.gnome.shell.extensions.nightthemeswitcher.gschema.xml +++ b/src/schemas/org.gnome.shell.extensions.nightthemeswitcher.gschema.xml @@ -136,6 +136,11 @@ Follow Night Light "Disable until tomorrow" Switch back to day time when Night Light is temporarily disabled + + false + Always enable the on-demand timer + The on-demand timer will always be enabled alongside other timers + diff --git a/src/settings/Time.js b/src/settings/Time.js index 60195a8..c217a90 100644 --- a/src/settings/Time.js +++ b/src/settings/Time.js @@ -38,6 +38,7 @@ var TimeSettings = class { 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._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.'); @@ -48,6 +49,7 @@ var TimeSettings = class { this.settings.disconnect(this._timeSourceChangedConnect); this.settings.disconnect(this._manualTimeSourceChangedConnect); this.settings.disconnect(this._nightlightFollowDisableConnect); + this.settings.disconnect(this._alwaysEnableOndemandConnect); this.settings.disconnect(this._ondemandKeybindingChangedConnect); this.settings.disconnect(this._ondemandButtonPlacementChangedConnect); logDebug('Time settings signals disconnected.'); @@ -83,6 +85,15 @@ var TimeSettings = class { 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'); } @@ -145,6 +156,11 @@ var TimeSettings = class { 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); + } + _onOndemandKeybindingChanged(_settings, _changedKey) { if (this.ondemandKeybinding) logDebug(`On-demand keybinding has changed to ${this.ondemandKeybinding}.`);