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
+5 -26
View File
@@ -16,14 +16,12 @@ var SchedulePage = GObject.registerClass({
GTypeName: 'SchedulePage',
Template: 'resource:///org/gnome/shell/extensions/nightthemeswitcher/preferences/ui/SchedulePage.ui',
InternalChildren: [
'keyboard_shortcut_button',
'transition_switch',
'manual_time_source_switch',
'time_source_combo_row',
'always_show_ondemand_switch',
'schedule_sunrise_time_chooser',
'schedule_sunset_time_chooser',
'ondemand_shortcut_button',
'ondemand_button_location_combo_row',
],
}, class SchedulePage extends Adw.PreferencesPage {
constructor(props = {}) {
@@ -51,7 +49,6 @@ var SchedulePage = GObject.registerClass({
nightlightChoice,
locationChoice,
new DropDownChoice({ id: 'schedule', title: _('Manual schedule') }),
new DropDownChoice({ id: 'ondemand', title: _('On-demand') }),
]);
this._time_source_combo_row.model = new Gtk.FilterListModel({
@@ -67,33 +64,15 @@ var SchedulePage = GObject.registerClass({
settings.connect('changed::time-source', () => 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-sunset', this._schedule_sunset_time_chooser, 'time', Gio.SettingsBindFlags.DEFAULT);
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', () => {
settings.set_strv('nightthemeswitcher-ondemand-keybinding', [this._ondemand_shortcut_button.keybinding]);
this._keyboard_shortcut_button.connect('notify::keybinding', () => {
settings.set_strv('nightthemeswitcher-ondemand-keybinding', [this._keyboard_shortcut_button.keybinding]);
});
this._ondemand_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();
this._keyboard_shortcut_button.keybinding = settings.get_strv('nightthemeswitcher-ondemand-keybinding')[0];
}
});