Timer: Remove on-demand timer

This commit is contained in:
Romain Vigier
2022-08-16 02:58:54 +02:00
parent 9788083be6
commit c29ae81b17
8 changed files with 98 additions and 465 deletions
@@ -70,31 +70,12 @@ SPDX-License-Identifier: GPL-3.0-or-later
<choice value="nightlight"/> <choice value="nightlight"/>
<choice value="location"/> <choice value="location"/>
<choice value="schedule"/> <choice value="schedule"/>
<choice value="ondemand"/>
</choices> </choices>
<default>"schedule"</default> <default>"schedule"</default>
</key> </key>
<key name="always-enable-ondemand" type="b">
<default>false</default>
</key>
<key name="ondemand-time" type="s">
<choices>
<choice value="day"/>
<choice value="night"/>
</choices>
<default>"day"</default>
</key>
<key name="nightthemeswitcher-ondemand-keybinding" type="as"> <key name="nightthemeswitcher-ondemand-keybinding" type="as">
<default><![CDATA[['<Shift><Super>t']]]></default> <default><![CDATA[['<Shift><Super>t']]]></default>
</key> </key>
<key name="ondemand-button-placement" type="s">
<choices>
<choice value="none"/>
<choice value="panel"/>
<choice value="menu"/>
</choices>
<default>"panel"</default>
</key>
<key name="manual-time-source" type="b"> <key name="manual-time-source" type="b">
<default>false</default> <default>false</default>
</key> </key>
+11 -34
View File
@@ -28,18 +28,6 @@ SPDX-License-Identifier: GPL-3.0-or-later
<property name="sensitive" bind-source="manual_time_source_switch" bind-property="active" bind-flags="sync-create"/> <property name="sensitive" bind-source="manual_time_source_switch" bind-property="active" bind-flags="sync-create"/>
</object> </object>
</child> </child>
<child>
<object class="AdwActionRow">
<property name="title" translatable="yes">Always show on-demand controls</property>
<property name="subtitle" translatable="yes">Allows you to override the current time when using a schedule.</property>
<property name="activatable-widget">always_show_ondemand_switch</property>
<child>
<object class="GtkSwitch" id="always_show_ondemand_switch">
<property name="valign">center</property>
</object>
</child>
</object>
</child>
</object> </object>
</child> </child>
<child> <child>
@@ -57,6 +45,17 @@ SPDX-License-Identifier: GPL-3.0-or-later
</child> </child>
</object> </object>
</child> </child>
<child>
<object class="AdwActionRow">
<property name="title" translatable="yes">Keyboard shortcut</property>
<property name="activatable-widget">keyboard_shortcut_button</property>
<child>
<object class="ShortcutButton" id="keyboard_shortcut_button">
<property name="valign">center</property>
</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>
@@ -87,28 +86,6 @@ SPDX-License-Identifier: GPL-3.0-or-later
</child> </child>
</object> </object>
</child> </child>
<child>
<object class="AdwExpanderRow">
<property name="title" translatable="yes">On-demand</property>
<property name="subtitle" translatable="yes">These settings only apply when using the on-demand time source.</property>
<child>
<object class="AdwActionRow">
<property name="title" translatable="yes">Keyboard shortcut</property>
<property name="activatable-widget">ondemand_shortcut_button</property>
<child>
<object class="ShortcutButton" id="ondemand_shortcut_button">
<property name="valign">center</property>
</object>
</child>
</object>
</child>
<child>
<object class="AdwComboRow" id="ondemand_button_location_combo_row">
<property name="title" translatable="yes">Button location</property>
</object>
</child>
</object>
</child>
</object> </object>
</child> </child>
</template> </template>
-1
View File
@@ -36,7 +36,6 @@ modules = [
'modules/Timer.js', 'modules/Timer.js',
'modules/TimerLocation.js', 'modules/TimerLocation.js',
'modules/TimerNightlight.js', 'modules/TimerNightlight.js',
'modules/TimerOndemand.js',
'modules/TimerSchedule.js', 'modules/TimerSchedule.js',
] ]
preferences = [ preferences = [
+63 -41
View File
@@ -1,7 +1,7 @@
// SPDX-FileCopyrightText: 2020-2022 Romain Vigier <contact AT romainvigier.fr> // SPDX-FileCopyrightText: 2020-2022 Romain Vigier <contact AT romainvigier.fr>
// SPDX-License-Identifier: GPL-3.0-or-later // SPDX-License-Identifier: GPL-3.0-or-later
const { Gio } = imports.gi; const { Gio, Meta, Shell } = imports.gi;
const { extensionUtils } = imports.misc; const { extensionUtils } = imports.misc;
const Signals = imports.signals; const Signals = imports.signals;
@@ -15,7 +15,6 @@ const { Time } = Me.imports.enums.Time;
const { TimerNightlight } = Me.imports.modules.TimerNightlight; const { TimerNightlight } = Me.imports.modules.TimerNightlight;
const { TimerLocation } = Me.imports.modules.TimerLocation; const { TimerLocation } = Me.imports.modules.TimerLocation;
const { TimerSchedule } = Me.imports.modules.TimerSchedule; const { TimerSchedule } = Me.imports.modules.TimerSchedule;
const { TimerOndemand } = Me.imports.modules.TimerOndemand;
/** /**
@@ -40,9 +39,10 @@ var Timer = class {
#locationSettings; #locationSettings;
#time; #time;
#sources = []; #source = null;
#sourceConnectionId = null;
#previousKeybinding = null;
#settingsConnections = []; #settingsConnections = [];
#timeConnections = [];
constructor() { constructor() {
this.#settings = extensionUtils.getSettings(`${Me.metadata['settings-schema']}.time`); this.#settings = extensionUtils.getSettings(`${Me.metadata['settings-schema']}.time`);
@@ -55,16 +55,18 @@ var Timer = class {
enable() { enable() {
debug.message('Enabling Timer...'); debug.message('Enabling Timer...');
this.#connectSettings(); this.#connectSettings();
this.#createSources(); this.#createSource();
this.#connectSources(); this.#connectSource();
this.#enableSources(); this.#enableSource();
this.#addKeybinding();
debug.message('Timer enabled.'); debug.message('Timer enabled.');
} }
disable() { disable() {
debug.message('Disabling Timer...'); debug.message('Disabling Timer...');
this.#removeKeybinding();
this.#disconnectSources(); this.#disconnectSources();
this.#disableSources(); this.#disableSource();
this.#disconnectSettings(); this.#disconnectSettings();
debug.message('Timer disabled.'); debug.message('Timer disabled.');
} }
@@ -96,18 +98,14 @@ var Timer = class {
settings: this.#locationSettings, settings: this.#locationSettings,
id: this.#locationSettings.connect('changed::enabled', this.#onSourceChanged.bind(this)), id: this.#locationSettings.connect('changed::enabled', this.#onSourceChanged.bind(this)),
}); });
this.#settingsConnections.push({
settings: this.#settings,
id: this.#settings.connect('changed::manual-time-source', this.#onSourceChanged.bind(this)),
});
this.#settingsConnections.push({
settings: this.#settings,
id: this.#settings.connect('changed::always-enable-ondemand', this.#onSourceChanged.bind(this)),
});
this.#settingsConnections.push({ this.#settingsConnections.push({
settings: this.#settings, settings: this.#settings,
id: this.#settings.connect('changed::time-source', this.#onTimeSourceChanged.bind(this)), id: this.#settings.connect('changed::time-source', this.#onTimeSourceChanged.bind(this)),
}); });
this.#settingsConnections.push({
settings: this.#settings,
id: this.#settings.connect('changed::nightthemeswitcher-ondemand-keybinding', this.#onOndemandKeybindingChanged.bind(this)),
});
this.#settingsConnections.push({ this.#settingsConnections.push({
settings: this.#interfaceSettings, settings: this.#interfaceSettings,
id: this.#interfaceSettings.connect('changed::color-scheme', this.#onColorSchemeChanged.bind(this)), id: this.#interfaceSettings.connect('changed::color-scheme', this.#onColorSchemeChanged.bind(this)),
@@ -120,48 +118,41 @@ var Timer = class {
debug.message('Disconnected Timer from settings.'); debug.message('Disconnected Timer from settings.');
} }
#createSources() { #createSource() {
const source = this.#getSource(); const source = this.#getSource();
switch (source) { switch (source) {
case 'nightlight': case 'nightlight':
this.#sources.push(new TimerNightlight()); this.#source = new TimerNightlight();
break; break;
case 'location': case 'location':
this.#sources.push(new TimerLocation()); this.#source = new TimerLocation();
break; break;
case 'schedule': case 'schedule':
this.#sources.push(new TimerSchedule()); this.#source = new TimerSchedule();
break;
case 'ondemand':
this.#sources.push(new TimerOndemand({ timer: this }));
break; break;
} }
if (this.#settings.get_boolean('always-enable-ondemand') && ['nightlight', 'location', 'schedule'].includes(source))
this.#sources.unshift(new TimerOndemand({ timer: this }));
} }
#enableSources() { #enableSource() {
this.#sources.forEach(source => source.enable()); this.#source.enable();
} }
#disableSources() { #disableSource() {
this.#sources.forEach(source => source.disable()); if (this.#source)
this.#sources = []; this.#source.disable();
this.#source = null;
} }
#connectSources() { #connectSource() {
debug.message('Connecting to time sources...'); debug.message('Connecting to time source...');
this.#sources.forEach(source => this.#timeConnections.push({ this.#sourceConnectionId = this.#source.connect('time-changed', this.#onTimeChanged.bind(this));
source,
id: source.connect('time-changed', this.#onTimeChanged.bind(this)),
}));
} }
#disconnectSources() { #disconnectSource() {
this.#timeConnections.forEach(connection => connection.source.disconnect(connection.id)); if (this.#sourceConnectionId && this.#source)
this.#timeConnections = []; this.#source.disconnect(this.#sourceConnectionId);
debug.message('Disconnected from time sources.'); this.#sourceConnectionId = null;
debug.message('Disconnected from time source.');
} }
@@ -175,6 +166,11 @@ var Timer = class {
this.#onSourceChanged(); this.#onSourceChanged();
} }
#onOndemandKeybindingChanged() {
this.#removeKeybinding();
this.#addKeybinding();
}
#onTimeChanged(_source, newTime) { #onTimeChanged(_source, newTime) {
this.time = newTime; this.time = newTime;
} }
@@ -211,5 +207,31 @@ var Timer = class {
} }
return source; return source;
} }
#addKeybinding() {
this.#previousKeybinding = this.#settings.get_strv('nightthemeswitcher-ondemand-keybinding')[0];
if (!this.#settings.get_strv('nightthemeswitcher-ondemand-keybinding')[0])
return;
debug.message('Adding keybinding...');
main.wm.addKeybinding(
'nightthemeswitcher-ondemand-keybinding',
this.#settings,
Meta.KeyBindingFlags.IGNORE_AUTOREPEAT,
Shell.ActionMode.NORMAL | Shell.ActionMode.OVERVIEW,
() => {
this.time = this.time === Time.NIGHT ? Time.DAY : Time.NIGHT;
}
);
debug.message('Added keybinding.');
}
#removeKeybinding() {
if (this.#previousKeybinding) {
debug.message('Removing keybinding...');
main.wm.removeKeybinding('nightthemeswitcher-ondemand-keybinding');
debug.message('Removed keybinding.');
}
}
}; };
Signals.addSignalMethods(Timer.prototype); Signals.addSignalMethods(Timer.prototype);
-250
View File
@@ -1,250 +0,0 @@
// SPDX-FileCopyrightText: 2020-2022 Romain Vigier <contact AT romainvigier.fr>
// SPDX-License-Identifier: GPL-3.0-or-later
const { Clutter, Gio, GLib, GObject, Meta, Shell, St } = imports.gi;
const { extensionUtils } = imports.misc;
const Signals = imports.signals;
const { main } = imports.ui;
const { Button: PanelMenuButton } = imports.ui.panelMenu;
const { PopupMenuItem, PopupSubMenuMenuItem } = imports.ui.popupMenu;
const Me = extensionUtils.getCurrentExtension();
const _ = extensionUtils.gettext;
const debug = Me.imports.debug;
const utils = Me.imports.utils;
const { Time } = Me.imports.enums.Time;
/**
* The On-demand Timer allows the user to manually switch between the day and
* night variants with a button in the top bar and a keybinding.
*
* The user can change the key combination in the extension's preferences.
*/
var TimerOndemand = class {
#timer;
#settings;
#settingsConnections = [];
#button = null;
#previousKeybinding = null;
#timerConnection = null;
constructor({ timer }) {
this.#timer = timer;
this.#settings = extensionUtils.getSettings(`${Me.metadata['settings-schema']}.time`);
}
enable() {
debug.message('Enabling On-demand Timer...');
this.#connectSettings();
this.#addKeybinding();
this.#addButton();
this.#connectTimer();
this.emit('time-changed', this.time);
debug.message('On-demand Timer enabled.');
}
disable() {
debug.message('Disabling On-demand Timer...');
this.#disconnectTimer();
this.#removeKeybinding();
this.#removeButton();
this.#disconnectSettings();
debug.message('On-demand Timer disabled.');
}
get time() {
return this.#settings.get_string('ondemand-time') === 'day' ? Time.DAY : Time.NIGHT;
}
#connectSettings() {
debug.message('Connecting On-demand Timer to settings...');
this.#settingsConnections.push({
settings: this.#settings,
id: this.#settings.connect('changed::ondemand-time', this.#onOndemandTimeChanged.bind(this)),
});
this.#settingsConnections.push({
settings: this.#settings,
id: this.#settings.connect('changed::nightthemeswitcher-ondemand-keybinding', this.#onOndemandKeybindingChanged.bind(this)),
});
this.#settingsConnections.push({
settings: this.#settings,
id: this.#settings.connect('changed::ondemand-button-placement', this.#onOndemandButtonPlacementChanged.bind(this)),
});
}
#disconnectSettings() {
debug.message('Disconnecting On-demand Timer from settings...');
this.#settingsConnections.forEach(connection => connection.settings.disconnect(connection.id));
this.#settingsConnections = [];
}
#connectTimer() {
debug.message('Connecting On-demand Timer to Timer...');
this.#timerConnection = this.#timer.connect('time-changed', this.#onTimeChanged.bind(this));
}
#disconnectTimer() {
if (this.#timerConnection) {
this.#timer.disconnect(this.#timerConnection);
this.#timerConnection = null;
}
debug.message('Disconnected On-demand Timer from Timer.');
}
#onOndemandTimeChanged() {
this.emit('time-changed', this.time);
}
#onOndemandKeybindingChanged() {
this.#removeKeybinding();
this.#addKeybinding();
}
#onOndemandButtonPlacementChanged() {
this.#removeButton();
this.#addButton();
}
#onTimeChanged(_timer, _newTime) {
this.#settings.set_string('ondemand-time', this.#timer.time);
this.#updateButton();
}
#addKeybinding() {
this.#previousKeybinding = this.#settings.get_strv('nightthemeswitcher-ondemand-keybinding')[0];
if (!this.#settings.get_strv('nightthemeswitcher-ondemand-keybinding')[0])
return;
debug.message('Adding On-demand Timer keybinding...');
main.wm.addKeybinding(
'nightthemeswitcher-ondemand-keybinding',
this.#settings,
Meta.KeyBindingFlags.IGNORE_AUTOREPEAT,
Shell.ActionMode.NORMAL | Shell.ActionMode.OVERVIEW,
this.#toggleTime.bind(this)
);
debug.message('Added On-demand Timer keybinding.');
}
#removeKeybinding() {
if (this.#previousKeybinding) {
debug.message('Removing On-demand Timer keybinding...');
main.wm.removeKeybinding('nightthemeswitcher-ondemand-keybinding');
debug.message('Removed On-demand Timer keybinding.');
}
}
#addButton() {
switch (this.#settings.get_string('ondemand-button-placement')) {
case 'panel':
this.#addButtonToPanel();
break;
case 'menu':
this.#addButtonToMenu();
}
}
#removeButton() {
if (this.#button) {
debug.message('Removing On-demand Timer button...');
this.#button.destroy();
this.#button = null;
debug.message('Removed On-demand Timer button.');
}
}
#updateButton() {
if (this.#button) {
debug.message('Updating On-demand Timer button state...');
this.#button.update();
debug.message('Updated On-demand Timer button state.');
}
}
#addButtonToPanel() {
debug.message('Adding On-demand Timer button to the panel...');
this.#button = new NtsPanelMenuButton({ timer: this.#timer, toggleCallback: this.#toggleTime.bind(this) });
main.panel.addToStatusArea('NightThemeSwitcherButton', this.#button);
debug.message('Added On-demand Timer button to the panel.');
}
#addButtonToMenu() {
debug.message('Adding On-demand Timer button to the menu...');
const aggregateMenu = main.panel.statusArea.aggregateMenu;
const position = utils.findShellAggregateMenuItemPosition(aggregateMenu._system.menu) - 1;
this.#button = new NtsPopupSubMenuMenuItem({ timer: this.#timer, toggleCallback: this.#toggleTime.bind(this) });
aggregateMenu.menu.addMenuItem(this.#button, position);
debug.message('Added On-demand Timer button to the menu.');
}
#toggleTime() {
this.#settings.set_string('ondemand-time', this.#timer.time === Time.DAY ? Time.NIGHT : Time.DAY);
this.emit('time-changed', this.time);
}
};
Signals.addSignalMethods(TimerOndemand.prototype);
var NtsPanelMenuButton = GObject.registerClass(
class NtsPanelMenuButton extends PanelMenuButton {
#timer;
constructor({ timer, toggleCallback }) {
super(0.0);
this.#timer = timer;
this.icon = new St.Icon({
style_class: 'system-status-icon',
});
this.add_child(this.icon);
this.connect('button-press-event', () => toggleCallback());
this.connect('touch-event', () => toggleCallback());
this.update();
}
update() {
this.icon.icon_name = _getIconNameForTime(this.#timer.time);
this.icon.fallback_gicon = _getGiconForTime(this.#timer.time);
this.accessible_name = this.#timer.time === Time.DAY ? _('Turn Night Mode On') : _('Turn Night Mode Off');
}
}
);
var NtsPopupSubMenuMenuItem = GObject.registerClass(
class NtsPopupSubMenuMenuItem extends PopupSubMenuMenuItem {
#timer;
constructor({ timer, toggleCallback }) {
super('', true);
this.#timer = timer;
this._toggleItem = new PopupMenuItem('');
this._toggleItem.connect('activate', () => toggleCallback());
this.menu.addMenuItem(this._toggleItem);
this._prefsItem = new PopupMenuItem(_('Extension Settings'));
this._prefsItem.connect('activate', () => main.extensionManager.openExtensionPrefs(Me.uuid, '', []));
this.menu.addMenuItem(this._prefsItem);
this.update();
}
update() {
this.icon.icon_name = _getIconNameForTime(this.#timer.time);
this.icon.fallback_gicon = _getGiconForTime(this.#timer.time);
this.label.text = this.#timer.time === Time.DAY ? _('Night Mode Off') : _('Night Mode On');
this._toggleItem.label.text = this.#timer.time === Time.DAY ? _('Turn On') : _('Turn Off');
}
}
);
var _getIconNameForTime = time => {
return time === Time.DAY ? 'nightthemeswitcher-ondemand-off-symbolic' : 'nightthemeswitcher-ondemand-on-symbolic';
};
var _getGiconForTime = time => {
return Gio.icon_new_for_string(GLib.build_filenamev([Me.path, 'icons', 'hicolor', 'scalable', 'status', `${this._getIconNameForTime(time)}.svg`]));
};
-1
View File
@@ -25,7 +25,6 @@ src/modules/SwitcherTheme.js
src/modules/Timer.js src/modules/Timer.js
src/modules/TimerLocation.js src/modules/TimerLocation.js
src/modules/TimerNightlight.js src/modules/TimerNightlight.js
src/modules/TimerOndemand.js
src/modules/TimerSchedule.js src/modules/TimerSchedule.js
src/preferences/BackgroundButton.js src/preferences/BackgroundButton.js
+19 -93
View File
@@ -8,7 +8,7 @@ msgid ""
msgstr "" msgstr ""
"Project-Id-Version: nightthemeswitcher@romainvigier.fr\n" "Project-Id-Version: nightthemeswitcher@romainvigier.fr\n"
"Report-Msgid-Bugs-To: \n" "Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2022-07-29 10:53+0200\n" "POT-Creation-Date: 2022-08-16 02:16+0200\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n" "Language-Team: LANGUAGE <LL@li.org>\n"
@@ -50,7 +50,7 @@ msgstr ""
msgid "Run commands" msgid "Run commands"
msgstr "" msgstr ""
#: src/data/ui/CommandsPage.ui:21 src/data/ui/SchedulePage.ui:84 #: src/data/ui/CommandsPage.ui:21 src/data/ui/SchedulePage.ui:65
msgid "Sunrise" msgid "Sunrise"
msgstr "" msgstr ""
@@ -59,7 +59,7 @@ msgstr ""
msgid "notify-send \"Hello sunshine!\"" msgid "notify-send \"Hello sunshine!\""
msgstr "" msgstr ""
#: src/data/ui/CommandsPage.ui:35 src/data/ui/SchedulePage.ui:96 #: src/data/ui/CommandsPage.ui:35 src/data/ui/SchedulePage.ui:77
msgid "Sunset" msgid "Sunset"
msgstr "" msgstr ""
@@ -103,67 +103,29 @@ msgstr ""
msgid "Time source" msgid "Time source"
msgstr "" msgstr ""
#: src/data/ui/SchedulePage.ui:33 #: src/data/ui/SchedulePage.ui:35
msgid "Always show on-demand controls"
msgstr ""
#: src/data/ui/SchedulePage.ui:34
msgid "Allows you to override the current time when using a schedule."
msgstr ""
#: src/data/ui/SchedulePage.ui:47
msgid "Advanced" msgid "Advanced"
msgstr "" msgstr ""
#: src/data/ui/SchedulePage.ui:50 #: src/data/ui/SchedulePage.ui:38
msgid "Transition" msgid "Transition"
msgstr "" msgstr ""
#: src/data/ui/SchedulePage.ui:51 #: src/data/ui/SchedulePage.ui:39
msgid "Smooth transition between day and night appearance." msgid "Smooth transition between day and night appearance."
msgstr "" msgstr ""
#: src/data/ui/SchedulePage.ui:62 src/preferences/SchedulePage.js:43 #: src/data/ui/SchedulePage.ui:50
msgid "Night Light"
msgstr ""
#: src/data/ui/SchedulePage.ui:63
msgid "These settings only apply when Night Light is the time source."
msgstr ""
#: src/data/ui/SchedulePage.ui:66
msgid "Follow <i>Disable until tomorrow</i>"
msgstr ""
#: src/data/ui/SchedulePage.ui:67
msgid ""
"When Night Light is temporarily disabled, the extension will switch to day "
"variants."
msgstr ""
#: src/data/ui/SchedulePage.ui:80 src/preferences/SchedulePage.js:56
msgid "Manual schedule"
msgstr ""
#: src/data/ui/SchedulePage.ui:81
msgid ""
"These settings only apply when using the manual schedule as the time source."
msgstr ""
#: src/data/ui/SchedulePage.ui:110 src/preferences/SchedulePage.js:57
msgid "On-demand"
msgstr ""
#: src/data/ui/SchedulePage.ui:111
msgid "These settings only apply when using the on-demand time source."
msgstr ""
#: src/data/ui/SchedulePage.ui:114
msgid "Keyboard shortcut" msgid "Keyboard shortcut"
msgstr "" msgstr ""
#: src/data/ui/SchedulePage.ui:125 #: src/data/ui/SchedulePage.ui:61 src/preferences/SchedulePage.js:51
msgid "Button location" msgid "Manual schedule"
msgstr ""
#: src/data/ui/SchedulePage.ui:62
msgid ""
"These settings only apply when using the manual schedule as the time source."
msgstr "" msgstr ""
#: src/data/ui/ShortcutButton.ui:15 #: src/data/ui/ShortcutButton.ui:15
@@ -225,34 +187,6 @@ msgstr ""
msgid ":" msgid ":"
msgstr "" msgstr ""
#: src/modules/TimerOndemand.js:214
msgid "Turn Night Mode Off"
msgstr ""
#: src/modules/TimerOndemand.js:214
msgid "Turn Night Mode On"
msgstr ""
#: src/modules/TimerOndemand.js:229
msgid "Extension Settings"
msgstr ""
#: src/modules/TimerOndemand.js:238
msgid "Night Mode Off"
msgstr ""
#: src/modules/TimerOndemand.js:238
msgid "Night Mode On"
msgstr ""
#: src/modules/TimerOndemand.js:239
msgid "Turn Off"
msgstr ""
#: src/modules/TimerOndemand.js:239
msgid "Turn On"
msgstr ""
#: src/preferences/BackgroundButton.js:69 #: src/preferences/BackgroundButton.js:69
msgid "Only JPEG, PNG, TIFF, SVG and XML files can be set as background image." msgid "Only JPEG, PNG, TIFF, SVG and XML files can be set as background image."
msgstr "" msgstr ""
@@ -262,22 +196,14 @@ msgstr ""
msgid "Version %d" msgid "Version %d"
msgstr "" msgstr ""
#: src/preferences/SchedulePage.js:48 #: src/preferences/SchedulePage.js:39
msgid "Night Light"
msgstr ""
#: src/preferences/SchedulePage.js:43
msgid "Location Services" msgid "Location Services"
msgstr "" msgstr ""
#: src/preferences/SchedulePage.js:90
msgid "None"
msgstr ""
#: src/preferences/SchedulePage.js:91
msgid "Top bar"
msgstr ""
#: src/preferences/SchedulePage.js:92
msgid "System menu"
msgstr ""
#: src/preferences/ThemesPage.js:50 #: src/preferences/ThemesPage.js:50
msgid "Default" msgid "Default"
msgstr "" msgstr ""
+5 -26
View File
@@ -16,14 +16,12 @@ var SchedulePage = GObject.registerClass({
GTypeName: 'SchedulePage', GTypeName: 'SchedulePage',
Template: 'resource:///org/gnome/shell/extensions/nightthemeswitcher/preferences/ui/SchedulePage.ui', Template: 'resource:///org/gnome/shell/extensions/nightthemeswitcher/preferences/ui/SchedulePage.ui',
InternalChildren: [ InternalChildren: [
'keyboard_shortcut_button',
'transition_switch', 'transition_switch',
'manual_time_source_switch', 'manual_time_source_switch',
'time_source_combo_row', 'time_source_combo_row',
'always_show_ondemand_switch',
'schedule_sunrise_time_chooser', 'schedule_sunrise_time_chooser',
'schedule_sunset_time_chooser', 'schedule_sunset_time_chooser',
'ondemand_shortcut_button',
'ondemand_button_location_combo_row',
], ],
}, class SchedulePage extends Adw.PreferencesPage { }, class SchedulePage extends Adw.PreferencesPage {
constructor(props = {}) { constructor(props = {}) {
@@ -51,7 +49,6 @@ var SchedulePage = GObject.registerClass({
nightlightChoice, nightlightChoice,
locationChoice, locationChoice,
new DropDownChoice({ id: 'schedule', title: _('Manual schedule') }), new DropDownChoice({ id: 'schedule', title: _('Manual schedule') }),
new DropDownChoice({ id: 'ondemand', title: _('On-demand') }),
]); ]);
this._time_source_combo_row.model = new Gtk.FilterListModel({ this._time_source_combo_row.model = new Gtk.FilterListModel({
@@ -67,33 +64,15 @@ var SchedulePage = GObject.registerClass({
settings.connect('changed::time-source', () => updateTimeSourceComboRowState()); settings.connect('changed::time-source', () => updateTimeSourceComboRowState());
updateTimeSourceComboRowState(); updateTimeSourceComboRowState();
settings.bind('always-enable-ondemand', this._always_show_ondemand_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);
settings.connect('changed::nightthemeswitcher-ondemand-keybinding', () => { settings.connect('changed::nightthemeswitcher-ondemand-keybinding', () => {
this._ondemand_shortcut_button.keybinding = settings.get_strv('nightthemeswitcher-ondemand-keybinding')[0]; this._keyboard_shortcut_button.keybinding = settings.get_strv('nightthemeswitcher-ondemand-keybinding')[0];
}); });
this._ondemand_shortcut_button.connect('notify::keybinding', () => { this._keyboard_shortcut_button.connect('notify::keybinding', () => {
settings.set_strv('nightthemeswitcher-ondemand-keybinding', [this._ondemand_shortcut_button.keybinding]); settings.set_strv('nightthemeswitcher-ondemand-keybinding', [this._keyboard_shortcut_button.keybinding]);
}); });
this._ondemand_shortcut_button.keybinding = settings.get_strv('nightthemeswitcher-ondemand-keybinding')[0]; this._keyboard_shortcut_button.keybinding = settings.get_strv('nightthemeswitcher-ondemand-keybinding')[0];
const ondemandButtonLocations = Gio.ListStore.new(DropDownChoice);
ondemandButtonLocations.splice(0, 0, [
new DropDownChoice({ id: 'none', title: _('None') }),
new DropDownChoice({ id: 'panel', title: _('Top bar') }),
new DropDownChoice({ id: 'menu', title: _('System menu') }),
]);
this._ondemand_button_location_combo_row.model = ondemandButtonLocations;
this._ondemand_button_location_combo_row.expression = Gtk.PropertyExpression.new(DropDownChoice, null, 'title');
this._ondemand_button_location_combo_row.connect('notify::selected-item', () => settings.set_string('ondemand-button-placement', this._ondemand_button_location_combo_row.selected_item.id));
const updateOndemandButtonLocationComboRowSelected = () => {
this._ondemand_button_location_combo_row.selected = utils.findItemPositionInModel(this._ondemand_button_location_combo_row.model, item => item.id === settings.get_string('ondemand-button-placement'));
};
settings.connect('changed::ondemand-button-placement', () => updateOndemandButtonLocationComboRowSelected());
updateOndemandButtonLocationComboRowSelected();
} }
}); });