Add on-demand option for all automatic sources

This commit is contained in:
Romain
2020-11-06 10:36:50 +00:00
parent d7fed9aea3
commit 3cc980ff4e
8 changed files with 520 additions and 320 deletions
+48 -46
View File
@@ -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;
}
+35 -3
View File
@@ -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.');
+58 -37
View File
@@ -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 <romain@romainvigier.fr>\n"
"Language-Team: French <romain@romainvigier.fr>\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 lextension."
#: 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 dicô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 dhoraires 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 dhoraires"
#: 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 darriè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 dhoraires.</small>"
#: 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 ""
"<small>This allows you to override the current time when using a schedule.</"
"small>"
msgstr ""
"<small>Cela vous permet de contrôler le temps quand vous utiliser un horaire."
"</small>"
#: src/preferences/ui/schedule.ui:266
msgid "Manual time source"
msgstr "Source dhoraires 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 <i>Disable until tomorrow</i>"
msgstr "Suivre <i>Désactiver jusqu’à demain</i>"
#: src/preferences/ui/schedule.ui:362
#: src/preferences/ui/schedule.ui:454
msgid ""
"<small>When Night Light is temporarily disabled, the extension will switch "
"to day variants.</small>"
@@ -512,35 +533,35 @@ msgstr ""
"<small>Quand le mode nuit est temporairement désactivé, lextension va "
"permuter vers les variantes diurnes.</small>"
#: 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"
+53 -36
View File
@@ -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 <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\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.</small>"
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 ""
"<small>This allows you to override the current time when using a schedule.</"
"small>"
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 <i>Disable until tomorrow</i>"
msgstr ""
#: src/preferences/ui/schedule.ui:362
#: src/preferences/ui/schedule.ui:454
msgid ""
"<small>When Night Light is temporarily disabled, the extension will switch "
"to day variants.</small>"
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 ""
+16 -3
View File
@@ -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;
+289 -195
View File
@@ -59,7 +59,7 @@ Author: Romain Vigier
<property name="spacing">30</property>
<property name="baseline-position">top</property>
<child>
<object class="GtkFrame" id="auto">
<object class="GtkFrame" id="general">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="label-xalign">0</property>
@@ -148,6 +148,98 @@ Author: Romain Vigier
</child>
</object>
</child>
<child>
<object class="GtkListBoxRow">
<property name="visible">True</property>
<property name="can-focus">True</property>
<property name="activatable">False</property>
<property name="selectable">False</property>
<child>
<object class="GtkSeparator">
<property name="visible">True</property>
<property name="can-focus">False</property>
</object>
</child>
</object>
</child>
<child>
<object class="GtkListBoxRow">
<property name="visible">True</property>
<property name="can-focus">True</property>
<property name="activatable">False</property>
<child>
<object class="GtkBox">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="margin-left">16</property>
<property name="margin-right">16</property>
<property name="margin-start">16</property>
<property name="margin-end">16</property>
<property name="margin-top">16</property>
<property name="margin-bottom">16</property>
<property name="spacing">30</property>
<child>
<object class="GtkBox">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="orientation">vertical</property>
<child>
<object class="GtkLabel">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="halign">start</property>
<property name="label" translatable="yes">Always show on-demand controls</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkLabel">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="halign">start</property>
<property name="label" translatable="yes">&lt;small&gt;This allows you to override the current time when using a schedule.&lt;/small&gt;</property>
<property name="use-markup">True</property>
<property name="wrap">True</property>
<property name="max-width-chars">50</property>
<property name="xalign">0</property>
<style>
<class name="dim-label"/>
</style>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">1</property>
</packing>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkSwitch" id="always_enable_ondemand_switch">
<property name="visible">True</property>
<property name="can-focus">True</property>
<property name="halign">end</property>
<property name="valign">center</property>
</object>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
</object>
</child>
</object>
</child>
</object>
</child>
<child type="label_item">
@@ -671,200 +763,7 @@ Author: Romain Vigier
</packing>
</child>
<child>
<object class="GtkBox" id="ondemand">
<property name="width-request">600</property>
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="orientation">vertical</property>
<property name="spacing">8</property>
<child>
<object class="GtkLabel">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="halign">start</property>
<property name="label" translatable="yes">On-demand</property>
<attributes>
<attribute name="weight" value="bold"/>
</attributes>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkFrame">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="label-xalign">0</property>
<child>
<object class="GtkListBox">
<property name="width-request">600</property>
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="selection-mode">none</property>
<child>
<object class="GtkListBoxRow">
<property name="visible">True</property>
<property name="can-focus">True</property>
<property name="activatable">False</property>
<child>
<object class="GtkBox">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="margin-left">16</property>
<property name="margin-right">16</property>
<property name="margin-start">16</property>
<property name="margin-end">16</property>
<property name="margin-top">16</property>
<property name="margin-bottom">16</property>
<property name="spacing">30</property>
<child>
<object class="GtkLabel">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="label" translatable="yes">Keyboard shortcut</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkBox">
<property name="visible">True</property>
<property name="can-focus">False</property>
<child>
<object class="GtkButton" id="ondemand_shortcut_button">
<property name="label" translatable="yes">Choose</property>
<property name="visible">True</property>
<property name="can-focus">True</property>
<property name="receives-default">True</property>
<property name="halign">end</property>
<property name="valign">center</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkButton" id="ondemand_shortcut_clear_button">
<property name="label" translatable="yes">Clear</property>
<property name="visible">True</property>
<property name="can-focus">True</property>
<property name="receives-default">True</property>
<style>
<class name="destructive-action"/>
</style>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
<style>
<class name="linked"/>
</style>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="pack-type">end</property>
<property name="position">1</property>
</packing>
</child>
</object>
</child>
</object>
</child>
<child>
<object class="GtkListBoxRow">
<property name="visible">True</property>
<property name="can-focus">True</property>
<property name="activatable">False</property>
<property name="selectable">False</property>
<child>
<object class="GtkSeparator">
<property name="visible">True</property>
<property name="can-focus">False</property>
</object>
</child>
</object>
</child>
<child>
<object class="GtkListBoxRow">
<property name="visible">True</property>
<property name="can-focus">True</property>
<property name="activatable">False</property>
<child>
<object class="GtkBox">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="margin-left">16</property>
<property name="margin-right">16</property>
<property name="margin-start">16</property>
<property name="margin-end">16</property>
<property name="margin-top">16</property>
<property name="margin-bottom">16</property>
<property name="spacing">30</property>
<child>
<object class="GtkLabel">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="label" translatable="yes">Button location</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkComboBoxText" id="ondemand_button_placement_combo">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="halign">end</property>
<property name="active">1</property>
<property name="active-id">panel</property>
<items>
<item id="none" translatable="yes">None</item>
<item id="panel" translatable="yes">Top bar</item>
<item id="menu" translatable="yes">System menu</item>
</items>
</object>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
</object>
</child>
</object>
</child>
</object>
</child>
<child type="label_item">
<placeholder/>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
</object>
<packing>
<property name="name">ondemand</property>
<property name="title" translatable="yes">On-demand</property>
<property name="position">3</property>
</packing>
<placeholder/>
</child>
</object>
<packing>
@@ -873,5 +772,200 @@ Author: Romain Vigier
<property name="position">2</property>
</packing>
</child>
<child>
<object class="GtkBox" id="ondemand">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="orientation">vertical</property>
<property name="spacing">8</property>
<child>
<object class="GtkLabel">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="halign">start</property>
<property name="label" translatable="yes">On-demand</property>
<attributes>
<attribute name="weight" value="bold"/>
</attributes>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkFrame">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="label-xalign">0</property>
<child>
<object class="GtkListBox">
<property name="width-request">600</property>
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="selection-mode">none</property>
<child>
<object class="GtkListBoxRow">
<property name="visible">True</property>
<property name="can-focus">True</property>
<property name="activatable">False</property>
<child>
<object class="GtkBox">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="margin-left">16</property>
<property name="margin-right">16</property>
<property name="margin-start">16</property>
<property name="margin-end">16</property>
<property name="margin-top">16</property>
<property name="margin-bottom">16</property>
<property name="spacing">30</property>
<child>
<object class="GtkLabel">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="label" translatable="yes">Keyboard shortcut</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkBox">
<property name="visible">True</property>
<property name="can-focus">False</property>
<child>
<object class="GtkButton" id="ondemand_shortcut_button">
<property name="label" translatable="yes">Choose</property>
<property name="visible">True</property>
<property name="can-focus">True</property>
<property name="receives-default">True</property>
<property name="halign">end</property>
<property name="valign">center</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkButton" id="ondemand_shortcut_clear_button">
<property name="label" translatable="yes">Clear</property>
<property name="visible">True</property>
<property name="can-focus">True</property>
<property name="receives-default">True</property>
<style>
<class name="destructive-action"/>
</style>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
<style>
<class name="linked"/>
</style>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="pack-type">end</property>
<property name="position">1</property>
</packing>
</child>
</object>
</child>
</object>
</child>
<child>
<object class="GtkListBoxRow">
<property name="visible">True</property>
<property name="can-focus">True</property>
<property name="activatable">False</property>
<property name="selectable">False</property>
<child>
<object class="GtkSeparator">
<property name="visible">True</property>
<property name="can-focus">False</property>
</object>
</child>
</object>
</child>
<child>
<object class="GtkListBoxRow">
<property name="visible">True</property>
<property name="can-focus">True</property>
<property name="activatable">False</property>
<child>
<object class="GtkBox">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="margin-left">16</property>
<property name="margin-right">16</property>
<property name="margin-start">16</property>
<property name="margin-end">16</property>
<property name="margin-top">16</property>
<property name="margin-bottom">16</property>
<property name="spacing">30</property>
<child>
<object class="GtkLabel">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="label" translatable="yes">Button location</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkComboBoxText" id="ondemand_button_placement_combo">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="halign">end</property>
<property name="active">1</property>
<property name="active-id">panel</property>
<items>
<item id="none" translatable="yes">None</item>
<item id="panel" translatable="yes">Top bar</item>
<item id="menu" translatable="yes">System menu</item>
</items>
</object>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
</object>
</child>
</object>
</child>
</object>
</child>
<child type="label_item">
<placeholder/>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">3</property>
</packing>
</child>
</object>
</interface>
@@ -136,6 +136,11 @@
<summary>Follow Night Light "Disable until tomorrow"</summary>
<description>Switch back to day time when Night Light is temporarily disabled</description>
</key>
<key name="always-enable-ondemand" type="b">
<default>false</default>
<summary>Always enable the on-demand timer</summary>
<description>The on-demand timer will always be enabled alongside other timers</description>
</key>
<key name="ondemand-time" type="s">
<choices>
<choice value="day"/>
+16
View File
@@ -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}.`);