Group advanced settings and use expander rows

This commit is contained in:
Romain Vigier
2022-02-23 22:56:34 +01:00
parent 1b7e63d9d1
commit 4ad8f217c3
3 changed files with 95 additions and 105 deletions
+2 -13
View File
@@ -25,9 +25,7 @@ var SchedulePage = GObject.registerClass({
'schedule_sunset_time_chooser',
'ondemand_shortcut_button',
'ondemand_button_location_combo_row',
'nightlight_preferences_group',
'manual_schedule_preferences_group',
'ondemand_preferences_group',
'nightlight_expander_row',
],
}, class SchedulePage extends Adw.PreferencesPage {
constructor(props = {}) {
@@ -44,6 +42,7 @@ var SchedulePage = GObject.registerClass({
const nightlightChoice = new DropDownChoice({ id: 'nightlight', title: _('Night Light') });
nightlightChoice.connect('notify::enabled', () => choiceFilter.changed(Gtk.FilterChange.DIFFERENT));
nightlightChoice.bind_property('enabled', this._nightlight_expander_row, 'visible', GObject.BindingFlags.DEFAULT);
colorSettings.bind('night-light-enabled', nightlightChoice, 'enabled', Gio.SettingsBindFlags.GET);
const locationChoice = new DropDownChoice({ id: 'location', title: _('Location Services') });
@@ -101,15 +100,5 @@ var SchedulePage = GObject.registerClass({
};
settings.connect('changed::ondemand-button-placement', () => updateOndemandButtonLocationComboRowSelected());
updateOndemandButtonLocationComboRowSelected();
const updateGroupsVisibility = () => {
const timeSource = settings.get_string('time-source');
this._nightlight_preferences_group.visible = timeSource === 'nightlight';
this._manual_schedule_preferences_group.visible = timeSource === 'schedule';
this._ondemand_preferences_group.visible = timeSource === 'ondemand' || settings.get_boolean('always-enable-ondemand');
};
settings.connect('changed::time-source', () => updateGroupsVisibility());
settings.connect('changed::always-enable-ondemand', () => updateGroupsVisibility());
updateGroupsVisibility();
}
});
+64 -63
View File
@@ -8,22 +8,6 @@ SPDX-License-Identifier: GPL-3.0-or-later
<property name="name">schedule</property>
<property name="title" translatable="yes">Schedule</property>
<property name="icon-name">nightthemeswitcher-schedule-symbolic</property>
<child>
<object class="AdwPreferencesGroup">
<child>
<object class="AdwActionRow">
<property name="title" translatable="yes">Transition</property>
<property name="subtitle" translatable="yes">Smooth transition between day and night appearance.</property>
<property name="activatable-widget">transition_switch</property>
<child>
<object class="GtkSwitch" id="transition_switch">
<property name="valign">center</property>
</object>
</child>
</object>
</child>
</object>
</child>
<child>
<object class="AdwPreferencesGroup">
<child>
@@ -59,68 +43,85 @@ SPDX-License-Identifier: GPL-3.0-or-later
</object>
</child>
<child>
<object class="AdwPreferencesGroup" id="nightlight_preferences_group">
<property name="title" translatable="yes">Night Light</property>
<object class="AdwPreferencesGroup">
<property name="title" translatable="yes">Advanced Settings</property>
<child>
<object class="AdwActionRow">
<property name="title" translatable="yes"><![CDATA[Follow <i>Disable until tomorrow</i>]]></property>
<property name="subtitle" translatable="yes">When Night Light is temporarily disabled, the extension will switch to day variants.</property>
<property name="activatable-widget">nightlight_follow_disable_switch</property>
<property name="title" translatable="yes">Transition</property>
<property name="subtitle" translatable="yes">Smooth transition between day and night appearance.</property>
<property name="activatable-widget">transition_switch</property>
<child>
<object class="GtkSwitch" id="nightlight_follow_disable_switch">
<property name="valign">center</property>
</object>
</child>
</object>
</child>
</object>
</child>
<child>
<object class="AdwPreferencesGroup" id="manual_schedule_preferences_group">
<property name="title" translatable="yes">Manual schedule times</property>
<child>
<object class="AdwActionRow">
<property name="title" translatable="yes">Sunrise</property>
<child>
<object class="TimeChooser" id="schedule_sunrise_time_chooser">
<property name="margin-top">12</property>
<property name="margin-bottom">12</property>
<object class="GtkSwitch" id="transition_switch">
<property name="valign">center</property>
</object>
</child>
</object>
</child>
<child>
<object class="AdwActionRow">
<property name="title" translatable="yes">Sunset</property>
<object class="AdwExpanderRow" id="nightlight_expander_row">
<property name="title" translatable="yes">Night Light</property>
<child>
<object class="TimeChooser" id="schedule_sunset_time_chooser">
<property name="margin-top">12</property>
<property name="margin-bottom">12</property>
<property name="valign">center</property>
</object>
</child>
</object>
</child>
</object>
</child>
<child>
<object class="AdwPreferencesGroup" id="ondemand_preferences_group">
<property name="title" translatable="yes">On-demand</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 class="AdwActionRow">
<property name="title" translatable="yes"><![CDATA[Follow <i>Disable until tomorrow</i>]]></property>
<property name="subtitle" translatable="yes">When Night Light is temporarily disabled, the extension will switch to day variants.</property>
<property name="activatable-widget">nightlight_follow_disable_switch</property>
<child>
<object class="GtkSwitch" id="nightlight_follow_disable_switch">
<property name="valign">center</property>
</object>
</child>
</object>
</child>
</object>
</child>
<child>
<object class="AdwComboRow" id="ondemand_button_location_combo_row">
<property name="title" translatable="yes">Button location</property>
<object class="AdwExpanderRow">
<property name="title" translatable="yes">Manual schedule</property>
<child>
<object class="AdwActionRow">
<property name="title" translatable="yes">Sunrise</property>
<child>
<object class="TimeChooser" id="schedule_sunrise_time_chooser">
<property name="margin-top">12</property>
<property name="margin-bottom">12</property>
<property name="valign">center</property>
</object>
</child>
</object>
</child>
<child>
<object class="AdwActionRow">
<property name="title" translatable="yes">Sunset</property>
<child>
<object class="TimeChooser" id="schedule_sunset_time_chooser">
<property name="margin-top">12</property>
<property name="margin-bottom">12</property>
<property name="valign">center</property>
</object>
</child>
</object>
</child>
</object>
</child>
<child>
<object class="AdwExpanderRow">
<property name="title" translatable="yes">On-demand</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>