diff --git a/src/icons/hicolor/scalable/categories/nightthemeswitcher-backgrounds-symbolic.svg b/src/icons/hicolor/scalable/categories/nightthemeswitcher-backgrounds-symbolic.svg
new file mode 100644
index 0000000..5c94b59
--- /dev/null
+++ b/src/icons/hicolor/scalable/categories/nightthemeswitcher-backgrounds-symbolic.svg
@@ -0,0 +1,9 @@
+
+
+
diff --git a/src/icons/hicolor/scalable/categories/nightthemeswitcher-contribute-symbolic.svg b/src/icons/hicolor/scalable/categories/nightthemeswitcher-contribute-symbolic.svg
new file mode 100644
index 0000000..67bb36f
--- /dev/null
+++ b/src/icons/hicolor/scalable/categories/nightthemeswitcher-contribute-symbolic.svg
@@ -0,0 +1,8 @@
+
+
+
diff --git a/src/icons/hicolor/scalable/categories/nightthemeswitcher-appearance-symbolic.svg b/src/icons/hicolor/scalable/categories/nightthemeswitcher-themes-symbolic.svg
similarity index 100%
rename from src/icons/hicolor/scalable/categories/nightthemeswitcher-appearance-symbolic.svg
rename to src/icons/hicolor/scalable/categories/nightthemeswitcher-themes-symbolic.svg
diff --git a/src/preferences/Appearance.js b/src/preferences/Appearance.js
deleted file mode 100644
index 14da725..0000000
--- a/src/preferences/Appearance.js
+++ /dev/null
@@ -1,13 +0,0 @@
-// SPDX-FileCopyrightText: 2021 Romain Vigier
-// SPDX-License-Identifier: GPL-3.0-or-later
-
-const { Gio, GLib, GObject, Gtk } = imports.gi;
-const { extensionUtils } = imports.misc;
-
-const Me = extensionUtils.getCurrentExtension();
-
-
-var Appearance = GObject.registerClass({
- GTypeName: 'Appearance',
- Template: `file://${GLib.build_filenamev([Me.path, 'preferences', 'ui', 'Appearance.ui'])}`,
-}, class Appearance extends Gtk.ScrolledWindow {});
diff --git a/src/preferences/BackgroundButton.js b/src/preferences/BackgroundButton.js
index 2da7393..f5dbc6e 100644
--- a/src/preferences/BackgroundButton.js
+++ b/src/preferences/BackgroundButton.js
@@ -21,6 +21,10 @@ var BackgroundButton = GObject.registerClass({
),
},
}, class BackgroundButton extends Gtk.Stack {
+ vfunc_mnemonic_activate() {
+ this.activate();
+ }
+
activate() {
if (this.path)
return this._change_button.activate();
diff --git a/src/preferences/BackgroundsPage.js b/src/preferences/BackgroundsPage.js
new file mode 100644
index 0000000..4cc94f1
--- /dev/null
+++ b/src/preferences/BackgroundsPage.js
@@ -0,0 +1,25 @@
+// SPDX-FileCopyrightText: 2020-2022 Romain Vigier
+// SPDX-License-Identifier: GPL-3.0-or-later
+
+const { Adw, Gio, GLib, GObject } = imports.gi;
+const { extensionUtils } = imports.misc;
+
+const Me = extensionUtils.getCurrentExtension();
+
+
+var BackgroundsPage = GObject.registerClass({
+ GTypeName: 'BackgroundsPage',
+ Template: `file://${GLib.build_filenamev([Me.path, 'preferences', 'ui', 'BackgroundsPage.ui'])}`,
+ InternalChildren: [
+ 'day_button',
+ 'night_button',
+ ],
+}, class BackgroundsPage extends Adw.PreferencesPage {
+ _init(props = {}) {
+ super._init(props);
+ const settings = new Gio.Settings({ schema: 'org.gnome.desktop.background' });
+
+ settings.bind('picture-uri', this._day_button, 'path', Gio.SettingsBindFlags.DEFAULT);
+ settings.bind('picture-uri-dark', this._night_button, 'path', Gio.SettingsBindFlags.DEFAULT);
+ }
+});
diff --git a/src/preferences/BackgroundsPreferences.js b/src/preferences/BackgroundsPreferences.js
deleted file mode 100644
index cb9a4e6..0000000
--- a/src/preferences/BackgroundsPreferences.js
+++ /dev/null
@@ -1,45 +0,0 @@
-// SPDX-FileCopyrightText: 2021, 2022 Romain Vigier
-// SPDX-License-Identifier: GPL-3.0-or-later
-
-const { Gio, GLib, GObject, Gtk } = imports.gi;
-const { extensionUtils } = imports.misc;
-
-const Me = extensionUtils.getCurrentExtension();
-
-
-var BackgroundsPreferences = GObject.registerClass({
- GTypeName: 'BackgroundsPreferences',
- Template: `file://${GLib.build_filenamev([Me.path, 'preferences', 'ui', 'BackgroundsPreferences.ui'])}`,
- InternalChildren: [
- 'day_button',
- 'night_button',
- ],
- Properties: {
- settings: GObject.ParamSpec.object(
- 'settings',
- 'Settings',
- 'Backgrounds GSettings',
- GObject.ParamFlags.READWRITE,
- Gio.Settings.$gtype
- ),
- },
-}, class BackgroundsPreferences extends Gtk.Box {
- _init(props = {}) {
- super._init(props);
- this.settings = new Gio.Settings({ schema: 'org.gnome.desktop.background' });
-
- this.settings.bind(
- 'picture-uri',
- this._day_button,
- 'path',
- Gio.SettingsBindFlags.DEFAULT
- );
-
- this.settings.bind(
- 'picture-uri-dark',
- this._night_button,
- 'path',
- Gio.SettingsBindFlags.DEFAULT
- );
- }
-});
diff --git a/src/preferences/Commands.js b/src/preferences/Commands.js
deleted file mode 100644
index 44cbf5f..0000000
--- a/src/preferences/Commands.js
+++ /dev/null
@@ -1,51 +0,0 @@
-// SPDX-FileCopyrightText: 2020, 2021 Romain Vigier
-// SPDX-License-Identifier: GPL-3.0-or-later
-
-const { Gio, GLib, GObject, Gtk } = imports.gi;
-const { extensionUtils } = imports.misc;
-
-const Me = extensionUtils.getCurrentExtension();
-
-const utils = Me.imports.utils;
-
-
-var Commands = GObject.registerClass({
- GTypeName: 'Commands',
- Template: `file://${GLib.build_filenamev([Me.path, 'preferences', 'ui', 'Commands.ui'])}`,
- InternalChildren: ['enabled_switch', 'sunrise_entry', 'sunset_entry'],
- Properties: {
- settings: GObject.ParamSpec.object(
- 'settings',
- 'Settings',
- 'Command GSettings',
- GObject.ParamFlags.READWRITE,
- Gio.Settings.$gtype
- ),
- },
-}, class Commands extends Gtk.ScrolledWindow {
- _init(props = {}) {
- super._init(props);
- this.settings = extensionUtils.getSettings(utils.getSettingsSchema('commands'));
-
- this.settings.bind(
- 'enabled',
- this._enabled_switch,
- 'active',
- Gio.SettingsBindFlags.DEFAULT
- );
-
- this.settings.bind(
- 'sunrise',
- this._sunrise_entry,
- 'text',
- Gio.SettingsBindFlags.DEFAULT
- );
-
- this.settings.bind(
- 'sunset',
- this._sunset_entry,
- 'text',
- Gio.SettingsBindFlags.DEFAULT
- );
- }
-});
diff --git a/src/preferences/CommandsPage.js b/src/preferences/CommandsPage.js
new file mode 100644
index 0000000..918399f
--- /dev/null
+++ b/src/preferences/CommandsPage.js
@@ -0,0 +1,29 @@
+// SPDX-FileCopyrightText: 2020-2022 Romain Vigier
+// SPDX-License-Identifier: GPL-3.0-or-later
+
+const { Adw, Gio, GLib, GObject } = imports.gi;
+const { extensionUtils } = imports.misc;
+
+const Me = extensionUtils.getCurrentExtension();
+
+const utils = Me.imports.utils;
+
+
+var CommandsPage = GObject.registerClass({
+ GTypeName: 'CommandsPage',
+ Template: `file://${GLib.build_filenamev([Me.path, 'preferences', 'ui', 'CommandsPage.ui'])}`,
+ InternalChildren: [
+ 'enabled_switch',
+ 'sunrise_entry',
+ 'sunset_entry',
+ ],
+}, class CommandsPage extends Adw.PreferencesPage {
+ _init(props = {}) {
+ super._init(props);
+ const settings = extensionUtils.getSettings(utils.getSettingsSchema('commands'));
+
+ settings.bind('enabled', this._enabled_switch, 'active', Gio.SettingsBindFlags.DEFAULT);
+ settings.bind('sunrise', this._sunrise_entry, 'text', Gio.SettingsBindFlags.DEFAULT);
+ settings.bind('sunset', this._sunset_entry, 'text', Gio.SettingsBindFlags.DEFAULT);
+ }
+});
diff --git a/src/preferences/ContributePage.js b/src/preferences/ContributePage.js
new file mode 100644
index 0000000..feabce0
--- /dev/null
+++ b/src/preferences/ContributePage.js
@@ -0,0 +1,13 @@
+// SPDX-FileCopyrightText: 2022 Romain Vigier
+// SPDX-License-Identifier: GPL-3.0-or-later
+
+const { Adw, GLib, GObject } = imports.gi;
+const { extensionUtils } = imports.misc;
+
+const Me = extensionUtils.getCurrentExtension();
+
+
+var ContributePage = GObject.registerClass({
+ GTypeName: 'ContributePage',
+ Template: `file://${GLib.build_filenamev([Me.path, 'preferences', 'ui', 'ContributePage.ui'])}`,
+}, class ContributePage extends Adw.PreferencesPage {});
diff --git a/src/preferences/CursorPreferences.js b/src/preferences/CursorPreferences.js
deleted file mode 100644
index 2ee1401..0000000
--- a/src/preferences/CursorPreferences.js
+++ /dev/null
@@ -1,64 +0,0 @@
-// SPDX-FileCopyrightText: 2021 Romain Vigier
-// SPDX-License-Identifier: GPL-3.0-or-later
-
-const { Gio, GLib, GObject, Gtk } = imports.gi;
-const { extensionUtils } = imports.misc;
-
-const Me = extensionUtils.getCurrentExtension();
-
-const utils = Me.imports.utils;
-
-const { DropDownChoice } = Me.imports.preferences.DropDownChoice;
-
-
-var CursorPreferences = GObject.registerClass({
- GTypeName: 'CursorPreferences',
- Template: `file://${GLib.build_filenamev([Me.path, 'preferences', 'ui', 'CursorPreferences.ui'])}`,
- InternalChildren: [
- 'enabled_switch',
- 'day_dropdown',
- 'night_dropdown',
- ],
- Properties: {
- settings: GObject.ParamSpec.object(
- 'settings',
- 'Settings',
- 'Cursor GSettings',
- GObject.ParamFlags.READWRITE,
- Gio.Settings.$gtype
- ),
- },
-}, class CursorPreferences extends Gtk.Box {
- _init(props = {}) {
- super._init(props);
- this.settings = extensionUtils.getSettings(utils.getSettingsSchema('cursor-variants'));
-
- this.settings.bind(
- 'enabled',
- this._enabled_switch,
- 'active',
- Gio.SettingsBindFlags.DEFAULT
- );
-
- const themeChoices = Gio.ListStore.new(DropDownChoice);
- themeChoices.splice(0, 0, Array.from(utils.getInstalledCursorThemes()).sort().map(theme => new DropDownChoice({ id: theme, title: theme })));
-
- this._day_dropdown.model = themeChoices;
- this._day_dropdown.expression = Gtk.PropertyExpression.new(DropDownChoice, null, 'title');
- this._day_dropdown.connect('notify::selected-item', () => this.settings.set_string('day', this._day_dropdown.selected_item.id));
- const updateDayDropDownSelected = () => {
- this._day_dropdown.selected = utils.findItemPositionInModel(this._day_dropdown.model, item => item.id === this.settings.get_string('day'));
- };
- this.settings.connect('changed::day', () => updateDayDropDownSelected());
- updateDayDropDownSelected();
-
- this._night_dropdown.model = themeChoices;
- this._night_dropdown.expression = Gtk.PropertyExpression.new(DropDownChoice, null, 'title');
- this._night_dropdown.connect('notify::selected-item', () => this.settings.set_string('night', this._night_dropdown.selected_item.id));
- const updateNightDropDownSelected = () => {
- this._night_dropdown.selected = utils.findItemPositionInModel(this._night_dropdown.model, item => item.id === this.settings.get_string('night'));
- };
- this.settings.connect('changed::night', () => updateNightDropDownSelected());
- updateNightDropDownSelected();
- }
-});
diff --git a/src/preferences/GtkPreferences.js b/src/preferences/GtkPreferences.js
deleted file mode 100644
index be61b6e..0000000
--- a/src/preferences/GtkPreferences.js
+++ /dev/null
@@ -1,72 +0,0 @@
-// SPDX-FileCopyrightText: 2021 Romain Vigier
-// SPDX-License-Identifier: GPL-3.0-or-later
-
-const { Gio, GLib, GObject, Gtk } = imports.gi;
-const { extensionUtils } = imports.misc;
-
-const Me = extensionUtils.getCurrentExtension();
-
-const utils = Me.imports.utils;
-
-const { DropDownChoice } = Me.imports.preferences.DropDownChoice;
-
-
-var GtkPreferences = GObject.registerClass({
- GTypeName: 'GtkPreferences',
- Template: `file://${GLib.build_filenamev([Me.path, 'preferences', 'ui', 'GtkPreferences.ui'])}`,
- InternalChildren: [
- 'enabled_switch',
- 'manual_switch',
- 'day_dropdown',
- 'night_dropdown',
- ],
- Properties: {
- settings: GObject.ParamSpec.object(
- 'settings',
- 'Settings',
- 'GTK GSettings',
- GObject.ParamFlags.READWRITE,
- Gio.Settings.$gtype
- ),
- },
-}, class GtkPreferences extends Gtk.Box {
- _init(props = {}) {
- super._init(props);
- this.settings = extensionUtils.getSettings(utils.getSettingsSchema('gtk-variants'));
-
- this.settings.bind(
- 'enabled',
- this._enabled_switch,
- 'active',
- Gio.SettingsBindFlags.DEFAULT
- );
-
- this.settings.bind(
- 'manual',
- this._manual_switch,
- 'active',
- Gio.SettingsBindFlags.DEFAULT
- );
-
- const themeChoices = Gio.ListStore.new(DropDownChoice);
- themeChoices.splice(0, 0, Array.from(utils.getInstalledGtkThemes()).sort().map(theme => new DropDownChoice({ id: theme, title: theme })));
-
- this._day_dropdown.model = themeChoices;
- this._day_dropdown.expression = Gtk.PropertyExpression.new(DropDownChoice, null, 'title');
- this._day_dropdown.connect('notify::selected-item', () => this.settings.set_string('day', this._day_dropdown.selected_item.id));
- const updateDayDropDownSelected = () => {
- this._day_dropdown.selected = utils.findItemPositionInModel(this._day_dropdown.model, item => item.id === this.settings.get_string('day'));
- };
- this.settings.connect('changed::day', () => updateDayDropDownSelected());
- updateDayDropDownSelected();
-
- this._night_dropdown.model = themeChoices;
- this._night_dropdown.expression = Gtk.PropertyExpression.new(DropDownChoice, null, 'title');
- this._night_dropdown.connect('notify::selected-item', () => this.settings.set_string('night', this._night_dropdown.selected_item.id));
- const updateNightDropDownSelected = () => {
- this._night_dropdown.selected = utils.findItemPositionInModel(this._night_dropdown.model, item => item.id === this.settings.get_string('night'));
- };
- this.settings.connect('changed::night', () => updateNightDropDownSelected());
- updateNightDropDownSelected();
- }
-});
diff --git a/src/preferences/Headerbar.js b/src/preferences/Headerbar.js
deleted file mode 100644
index b621cb3..0000000
--- a/src/preferences/Headerbar.js
+++ /dev/null
@@ -1,47 +0,0 @@
-// SPDX-FileCopyrightText: 2020, 2021 Romain Vigier
-// SPDX-License-Identifier: GPL-3.0-or-later
-
-const { GLib, GObject, Gtk } = imports.gi;
-const { extensionUtils } = imports.misc;
-
-const Me = extensionUtils.getCurrentExtension();
-
-
-var Headerbar = GObject.registerClass({
- GTypeName: 'Headerbar',
- Template: `file://${GLib.build_filenamev([Me.path, 'preferences', 'ui', 'Headerbar.ui'])}`,
- Properties: {
- preferences: GObject.ParamSpec.object(
- 'preferences',
- 'Preferences',
- 'A Preferences stack',
- GObject.ParamFlags.READWRITE,
- Gtk.Stack.$gtype
- ),
- },
-}, class Headerbar extends Gtk.HeaderBar {
- onPreferencesChanged(headerbar) {
- headerbar.title_widget = null;
- if (!headerbar.preferences)
- return;
- const pages = headerbar.preferences.pages;
- const box = new Gtk.Box({ orientation: 'horizontal', css_classes: ['linked'] });
- for (let i = 0; i < pages.get_n_items(); i++) {
- const page = pages.get_item(i);
- const button = new Gtk.ToggleButton({ active: pages.is_selected(i) });
- const buttonBox = new Gtk.Box({ orientation: 'horizontal', margin_start: 12, margin_end: 12, spacing: 6 });
- buttonBox.append(new Gtk.Image({ icon_name: page.icon_name }));
- buttonBox.append(new Gtk.Label({ label: page.title }));
- button.set_child(buttonBox);
- button.connect('clicked', () => {
- pages.select_item(i, true);
- button.active = true;
- });
- pages.connect('selection-changed', () => {
- button.active = pages.is_selected(i);
- });
- box.append(button);
- }
- headerbar.title_widget = box;
- }
-});
diff --git a/src/preferences/IconPreferences.js b/src/preferences/IconPreferences.js
deleted file mode 100644
index ed3b781..0000000
--- a/src/preferences/IconPreferences.js
+++ /dev/null
@@ -1,64 +0,0 @@
-// SPDX-FileCopyrightText: 2021 Romain Vigier
-// SPDX-License-Identifier: GPL-3.0-or-later
-
-const { Gio, GLib, GObject, Gtk } = imports.gi;
-const { extensionUtils } = imports.misc;
-
-const Me = extensionUtils.getCurrentExtension();
-
-const utils = Me.imports.utils;
-
-const { DropDownChoice } = Me.imports.preferences.DropDownChoice;
-
-
-var IconPreferences = GObject.registerClass({
- GTypeName: 'IconPreferences',
- Template: `file://${GLib.build_filenamev([Me.path, 'preferences', 'ui', 'IconPreferences.ui'])}`,
- InternalChildren: [
- 'enabled_switch',
- 'day_dropdown',
- 'night_dropdown',
- ],
- Properties: {
- settings: GObject.ParamSpec.object(
- 'settings',
- 'Settings',
- 'Icon GSettings',
- GObject.ParamFlags.READWRITE,
- Gio.Settings.$gtype
- ),
- },
-}, class IconPreferences extends Gtk.Box {
- _init(props = {}) {
- super._init(props);
- this.settings = extensionUtils.getSettings(utils.getSettingsSchema('icon-variants'));
-
- this.settings.bind(
- 'enabled',
- this._enabled_switch,
- 'active',
- Gio.SettingsBindFlags.DEFAULT
- );
-
- const themeChoices = Gio.ListStore.new(DropDownChoice);
- themeChoices.splice(0, 0, Array.from(utils.getInstalledIconThemes()).sort().map(theme => new DropDownChoice({ id: theme, title: theme })));
-
- this._day_dropdown.model = themeChoices;
- this._day_dropdown.expression = Gtk.PropertyExpression.new(DropDownChoice, null, 'title');
- this._day_dropdown.connect('notify::selected-item', () => this.settings.set_string('day', this._day_dropdown.selected_item.id));
- const updateDayDropDownSelected = () => {
- this._day_dropdown.selected = utils.findItemPositionInModel(this._day_dropdown.model, item => item.id === this.settings.get_string('day'));
- };
- this.settings.connect('changed::day', () => updateDayDropDownSelected());
- updateDayDropDownSelected();
-
- this._night_dropdown.model = themeChoices;
- this._night_dropdown.expression = Gtk.PropertyExpression.new(DropDownChoice, null, 'title');
- this._night_dropdown.connect('notify::selected-item', () => this.settings.set_string('night', this._night_dropdown.selected_item.id));
- const updateNightDropDownSelected = () => {
- this._night_dropdown.selected = utils.findItemPositionInModel(this._night_dropdown.model, item => item.id === this.settings.get_string('night'));
- };
- this.settings.connect('changed::night', () => updateNightDropDownSelected());
- updateNightDropDownSelected();
- }
-});
diff --git a/src/preferences/PreferenceRow.js b/src/preferences/PreferenceRow.js
deleted file mode 100644
index b809134..0000000
--- a/src/preferences/PreferenceRow.js
+++ /dev/null
@@ -1,58 +0,0 @@
-// SPDX-FileCopyrightText: 2021 Romain Vigier
-// SPDX-License-Identifier: GPL-3.0-or-later
-
-const { GLib, GObject, Gtk } = imports.gi;
-const { extensionUtils } = imports.misc;
-
-const Me = extensionUtils.getCurrentExtension();
-
-
-var PreferenceRow = GObject.registerClass({
- GTypeName: 'PreferenceRow',
- Template: `file://${GLib.build_filenamev([Me.path, 'preferences', 'ui', 'PreferenceRow.ui'])}`,
- InternalChildren: ['subtitle_label', 'end_box'],
- Properties: {
- title: GObject.ParamSpec.string(
- 'title',
- 'Title',
- 'Title of the preference',
- GObject.ParamFlags.READWRITE,
- null
- ),
- subtitle: GObject.ParamSpec.string(
- 'subtitle',
- 'Subtitle',
- 'Description of the preference',
- GObject.ParamFlags.READWRITE,
- null
- ),
- activatable_widget: GObject.ParamSpec.object(
- 'activatable-widget',
- 'Activatable widget',
- 'The widget to activate when the row is activated',
- GObject.ParamFlags.READWRITE,
- Gtk.Widget.$gtype
- ),
- },
-}, class PreferenceRow extends Gtk.ListBoxRow {
- activate() {
- if (this.activatable_widget)
- return this.activatable_widget.activate();
- else
- return false;
- }
-
- onSubtitleChanged(list) {
- list._subtitle_label.visible = !!list.subtitle;
- }
-
- onActivatableWidgetChanged(list) {
- while (list._end_box.get_last_child())
- list._end_box.remove(list._end_box.get_last_child());
- list.activatable = false;
- if (list.activatable_widget) {
- list._end_box.append(list.activatable_widget);
- list.activatable = true;
- }
- }
-});
diff --git a/src/preferences/Preferences.js b/src/preferences/Preferences.js
deleted file mode 100644
index 9505eee..0000000
--- a/src/preferences/Preferences.js
+++ /dev/null
@@ -1,28 +0,0 @@
-// SPDX-FileCopyrightText: 2020, 2021 Romain Vigier
-// SPDX-License-Identifier: GPL-3.0-or-later
-
-const { GLib, GObject, Gtk } = imports.gi;
-const { extensionUtils } = imports.misc;
-
-const Me = extensionUtils.getCurrentExtension();
-
-const { Appearance } = Me.imports.preferences.Appearance;
-const { BackgroundButton } = Me.imports.preferences.BackgroundButton;
-const { BackgroundsPreferences } = Me.imports.preferences.BackgroundsPreferences;
-const { ClearableEntry } = Me.imports.preferences.ClearableEntry;
-const { Commands } = Me.imports.preferences.Commands;
-const { CursorPreferences } = Me.imports.preferences.CursorPreferences;
-const { GtkPreferences } = Me.imports.preferences.GtkPreferences;
-const { IconPreferences } = Me.imports.preferences.IconPreferences;
-const { PreferenceRow } = Me.imports.preferences.PreferenceRow;
-const { PreferencesList } = Me.imports.preferences.PreferencesList;
-const { Schedule } = Me.imports.preferences.Schedule;
-const { ShellPreferences } = Me.imports.preferences.ShellPreferences;
-const { ShortcutButton } = Me.imports.preferences.ShortcutButton;
-const { TimeChooser } = Me.imports.preferences.TimeChooser;
-
-
-var Preferences = GObject.registerClass({
- GTypeName: 'Preferences',
- Template: `file://${GLib.build_filenamev([Me.path, 'preferences', 'ui', 'Preferences.ui'])}`,
-}, class Preferences extends Gtk.Stack {});
diff --git a/src/preferences/PreferencesList.js b/src/preferences/PreferencesList.js
deleted file mode 100644
index e41025e..0000000
--- a/src/preferences/PreferencesList.js
+++ /dev/null
@@ -1,17 +0,0 @@
-// SPDX-FileCopyrightText: 2021 Romain Vigier
-// SPDX-License-Identifier: GPL-3.0-or-later
-
-const { Gio, GLib, GObject, Gtk } = imports.gi;
-const { extensionUtils } = imports.misc;
-
-const Me = extensionUtils.getCurrentExtension();
-
-
-var PreferencesList = GObject.registerClass({
- GTypeName: 'PreferencesList',
- Template: `file://${GLib.build_filenamev([Me.path, 'preferences', 'ui', 'PreferencesList.ui'])}`,
-}, class PreferencesList extends Gtk.ListBox {
- onRowActivated(_list, row) {
- row.activate();
- }
-});
diff --git a/src/preferences/Schedule.js b/src/preferences/Schedule.js
deleted file mode 100644
index 8cf5a59..0000000
--- a/src/preferences/Schedule.js
+++ /dev/null
@@ -1,147 +0,0 @@
-// SPDX-FileCopyrightText: 2020, 2021 Romain Vigier
-// SPDX-License-Identifier: GPL-3.0-or-later
-
-const { Gio, GLib, GObject, Gtk } = imports.gi;
-const { extensionUtils } = imports.misc;
-
-const Me = extensionUtils.getCurrentExtension();
-const _ = extensionUtils.gettext;
-
-const utils = Me.imports.utils;
-
-const { DropDownChoice } = Me.imports.preferences.DropDownChoice;
-
-
-var Schedule = GObject.registerClass({
- GTypeName: 'Schedule',
- Template: `file://${GLib.build_filenamev([Me.path, 'preferences', 'ui', 'Schedule.ui'])}`,
- InternalChildren: [
- 'manual_time_source_switch',
- 'time_source_dropdown',
- 'always_show_ondemand_switch',
- 'nightlight_preferences_revealer',
- 'nightlight_follow_disable_switch',
- 'schedule_preferences_revealer',
- 'schedule_sunrise_time_chooser',
- 'schedule_sunset_time_chooser',
- 'ondemand_preferences_revealer',
- 'ondemand_shortcut_button',
- 'ondemand_button_location_combo',
- ],
- Properties: {
- settings: GObject.ParamSpec.object(
- 'settings',
- 'Settings',
- 'Time GSettings',
- GObject.ParamFlags.READWRITE,
- Gio.Settings.$gtype
- ),
- },
-}, class Schedule extends Gtk.ScrolledWindow {
- _init(props = {}) {
- super._init(props);
- this.settings = extensionUtils.getSettings(utils.getSettingsSchema('time'));
-
- this.settings.bind(
- 'manual-time-source',
- this._manual_time_source_switch,
- 'active',
- Gio.SettingsBindFlags.DEFAULT
- );
-
- const choiceFilter = new Gtk.BoolFilter({ expression: Gtk.PropertyExpression.new(DropDownChoice, null, 'enabled') });
-
- const colorSettings = new Gio.Settings({ schema: 'org.gnome.settings-daemon.plugins.color' });
- const nightlightChoice = new DropDownChoice({ id: 'nightlight', title: _('Night Light') });
- nightlightChoice.connect('notify::enabled', () => choiceFilter.changed(Gtk.FilterChange.DIFFERENT));
- colorSettings.bind(
- 'night-light-enabled',
- nightlightChoice,
- 'enabled',
- Gio.SettingsBindFlags.GET
- );
-
- const locationSettings = new Gio.Settings({ schema: 'org.gnome.system.location' });
- const locationChoice = new DropDownChoice({ id: 'location', title: _('Location Services') });
- locationChoice.connect('notify::enabled', () => choiceFilter.changed(Gtk.FilterChange.DIFFERENT));
- locationSettings.bind(
- 'enabled',
- locationChoice,
- 'enabled',
- Gio.SettingsBindFlags.GET
- );
-
- const timeSources = Gio.ListStore.new(DropDownChoice);
- timeSources.splice(0, 0, [
- nightlightChoice,
- locationChoice,
- new DropDownChoice({ id: 'schedule', title: _('Manual schedule') }),
- new DropDownChoice({ id: 'ondemand', title: _('On-demand') }),
- ]);
-
- this._time_source_dropdown.model = new Gtk.FilterListModel({
- model: timeSources,
- filter: choiceFilter,
- });
- this._time_source_dropdown.expression = Gtk.PropertyExpression.new(DropDownChoice, null, 'title');
- this._time_source_dropdown.connect('notify::selected-item', () => this.settings.set_string('time-source', this._time_source_dropdown.selected_item.id));
- const updateTimeSourceDropDownSelected = () => {
- this._time_source_dropdown.selected = utils.findItemPositionInModel(this._time_source_dropdown.model, item => item.id === this.settings.get_string('time-source'));
- };
- this.settings.connect('changed::time-source', () => updateTimeSourceDropDownSelected());
- updateTimeSourceDropDownSelected();
-
- this.settings.bind(
- 'always-enable-ondemand',
- this._always_show_ondemand_switch,
- 'active',
- Gio.SettingsBindFlags.DEFAULT
- );
-
- this.settings.bind(
- 'nightlight-follow-disable',
- this._nightlight_follow_disable_switch,
- 'active',
- Gio.SettingsBindFlags.DEFAULT
- );
-
- this.settings.bind(
- 'schedule-sunrise',
- this._schedule_sunrise_time_chooser,
- 'time',
- Gio.SettingsBindFlags.DEFAULT
- );
-
- this.settings.bind(
- 'schedule-sunset',
- this._schedule_sunset_time_chooser,
- 'time',
- Gio.SettingsBindFlags.DEFAULT
- );
-
- this.settings.connect('changed::nightthemeswitcher-ondemand-keybinding', () => {
- this._ondemand_shortcut_button.keybinding = this.settings.get_strv('nightthemeswitcher-ondemand-keybinding')[0];
- });
- this._ondemand_shortcut_button.connect('notify::keybinding', () => {
- this.settings.set_strv('nightthemeswitcher-ondemand-keybinding', [this._ondemand_shortcut_button.keybinding]);
- });
- this._ondemand_shortcut_button.keybinding = this.settings.get_strv('nightthemeswitcher-ondemand-keybinding')[0];
-
- this.settings.bind(
- 'ondemand-button-placement',
- this._ondemand_button_location_combo,
- 'active-id',
- Gio.SettingsBindFlags.DEFAULT
- );
-
- const updatePreferencesVisibility = () => {
- const timeSource = this.settings.get_string('time-source');
- this._nightlight_preferences_revealer.reveal_child = timeSource === 'nightlight';
- this._schedule_preferences_revealer.reveal_child = timeSource === 'schedule';
- this._ondemand_preferences_revealer.reveal_child = timeSource === 'ondemand' || this.settings.get_boolean('always-enable-ondemand');
- };
- this.settings.connect('changed::time-source', () => updatePreferencesVisibility());
- this.settings.connect('changed::always-enable-ondemand', () => updatePreferencesVisibility());
- updatePreferencesVisibility();
- }
-});
diff --git a/src/preferences/SchedulePage.js b/src/preferences/SchedulePage.js
new file mode 100644
index 0000000..9134583
--- /dev/null
+++ b/src/preferences/SchedulePage.js
@@ -0,0 +1,111 @@
+// SPDX-FileCopyrightText: 2020-2022 Romain Vigier
+// SPDX-License-Identifier: GPL-3.0-or-later
+
+const { Adw, Gio, GLib, GObject, Gtk } = imports.gi;
+const { extensionUtils } = imports.misc;
+
+const Me = extensionUtils.getCurrentExtension();
+const _ = extensionUtils.gettext;
+
+const utils = Me.imports.utils;
+
+const { DropDownChoice } = Me.imports.preferences.DropDownChoice;
+
+
+var SchedulePage = GObject.registerClass({
+ GTypeName: 'SchedulePage',
+ Template: `file://${GLib.build_filenamev([Me.path, 'preferences', 'ui', 'SchedulePage.ui'])}`,
+ InternalChildren: [
+ 'manual_time_source_switch',
+ 'time_source_combo_row',
+ 'always_show_ondemand_switch',
+ 'nightlight_follow_disable_switch',
+ 'schedule_sunrise_time_chooser',
+ 'schedule_sunset_time_chooser',
+ 'ondemand_shortcut_button',
+ 'ondemand_button_location_combo_row',
+ 'nightlight_preferences_group',
+ 'manual_schedule_preferences_group',
+ 'ondemand_preferences_group',
+ ],
+}, class SchedulePage extends Adw.PreferencesPage {
+ _init(props = {}) {
+ super._init(props);
+ const settings = extensionUtils.getSettings(utils.getSettingsSchema('time'));
+ const colorSettings = new Gio.Settings({ schema: 'org.gnome.settings-daemon.plugins.color' });
+ const locationSettings = new Gio.Settings({ schema: 'org.gnome.system.location' });
+
+ settings.bind('manual-time-source', this._manual_time_source_switch, 'active', Gio.SettingsBindFlags.DEFAULT);
+
+ const choiceFilter = new Gtk.BoolFilter({ expression: Gtk.PropertyExpression.new(DropDownChoice, null, 'enabled') });
+
+ const nightlightChoice = new DropDownChoice({ id: 'nightlight', title: _('Night Light') });
+ nightlightChoice.connect('notify::enabled', () => choiceFilter.changed(Gtk.FilterChange.DIFFERENT));
+ colorSettings.bind('night-light-enabled', nightlightChoice, 'enabled', Gio.SettingsBindFlags.GET);
+
+ const locationChoice = new DropDownChoice({ id: 'location', title: _('Location Services') });
+ locationChoice.connect('notify::enabled', () => choiceFilter.changed(Gtk.FilterChange.DIFFERENT));
+ locationSettings.bind('enabled', locationChoice, 'enabled', Gio.SettingsBindFlags.GET);
+
+ const timeSources = Gio.ListStore.new(DropDownChoice);
+ timeSources.splice(0, 0, [
+ 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({
+ model: timeSources,
+ filter: choiceFilter,
+ });
+ this._time_source_combo_row.expression = Gtk.PropertyExpression.new(DropDownChoice, null, 'title');
+ this._time_source_combo_row.connect('notify::selected-item', () => settings.set_string('time-source', this._time_source_combo_row.selected_item.id));
+ const updateTimeSourceComboRowSelected = () => {
+ this._time_source_combo_row.selected = utils.findItemPositionInModel(this._time_source_combo_row.model, item => item.id === settings.get_string('time-source'));
+ };
+ settings.connect('changed::time-source', () => updateTimeSourceComboRowSelected());
+ updateTimeSourceComboRowSelected();
+
+ settings.bind('always-enable-ondemand', this._always_show_ondemand_switch, 'active', Gio.SettingsBindFlags.DEFAULT);
+
+ settings.bind('nightlight-follow-disable', this._nightlight_follow_disable_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._ondemand_shortcut_button.connect('notify::keybinding', () => {
+ settings.set_strv('nightthemeswitcher-ondemand-keybinding', [this._ondemand_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();
+
+ 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();
+ }
+});
diff --git a/src/preferences/ShellPreferences.js b/src/preferences/ShellPreferences.js
deleted file mode 100644
index 62fcc2e..0000000
--- a/src/preferences/ShellPreferences.js
+++ /dev/null
@@ -1,73 +0,0 @@
-// SPDX-FileCopyrightText: 2021 Romain Vigier
-// SPDX-License-Identifier: GPL-3.0-or-later
-
-const { Gio, GLib, GObject, Gtk } = imports.gi;
-const { extensionUtils } = imports.misc;
-
-const Me = extensionUtils.getCurrentExtension();
-const _ = extensionUtils.gettext;
-
-const utils = Me.imports.utils;
-
-const { DropDownChoice } = Me.imports.preferences.DropDownChoice;
-
-
-var ShellPreferences = GObject.registerClass({
- GTypeName: 'ShellPreferences',
- Template: `file://${GLib.build_filenamev([Me.path, 'preferences', 'ui', 'ShellPreferences.ui'])}`,
- InternalChildren: [
- 'enabled_switch',
- 'manual_switch',
- 'day_dropdown',
- 'night_dropdown',
- ],
- Properties: {
- settings: GObject.ParamSpec.object(
- 'settings',
- 'Settings',
- 'Shell GSettings',
- GObject.ParamFlags.READWRITE,
- Gio.Settings.$gtype
- ),
- },
-}, class ShellPreferences extends Gtk.Box {
- _init(props = {}) {
- super._init(props);
- this.settings = extensionUtils.getSettings(utils.getSettingsSchema('shell-variants'));
-
- this.settings.bind(
- 'enabled',
- this._enabled_switch,
- 'active',
- Gio.SettingsBindFlags.DEFAULT
- );
-
- this.settings.bind(
- 'manual',
- this._manual_switch,
- 'active',
- Gio.SettingsBindFlags.DEFAULT
- );
-
- const themeChoices = Gio.ListStore.new(DropDownChoice);
- themeChoices.splice(0, 0, Array.from(utils.getInstalledShellThemes()).sort().map(theme => new DropDownChoice({ id: theme, title: theme || _('Default') })));
-
- this._day_dropdown.model = themeChoices;
- this._day_dropdown.expression = Gtk.PropertyExpression.new(DropDownChoice, null, 'title');
- this._day_dropdown.connect('notify::selected-item', () => this.settings.set_string('day', this._day_dropdown.selected_item.id));
- const updateDayDropDownSelected = () => {
- this._day_dropdown.selected = utils.findItemPositionInModel(this._day_dropdown.model, item => item.id === this.settings.get_string('day'));
- };
- this.settings.connect('changed::day', () => updateDayDropDownSelected());
- updateDayDropDownSelected();
-
- this._night_dropdown.model = themeChoices;
- this._night_dropdown.expression = Gtk.PropertyExpression.new(DropDownChoice, null, 'title');
- this._night_dropdown.connect('notify::selected-item', () => this.settings.set_string('night', this._night_dropdown.selected_item.id));
- const updateNightDropDownSelected = () => {
- this._night_dropdown.selected = utils.findItemPositionInModel(this._night_dropdown.model, item => item.id === this.settings.get_string('night'));
- };
- this.settings.connect('changed::night', () => updateNightDropDownSelected());
- updateNightDropDownSelected();
- }
-});
diff --git a/src/preferences/ShortcutButton.js b/src/preferences/ShortcutButton.js
index d8108af..9e20847 100644
--- a/src/preferences/ShortcutButton.js
+++ b/src/preferences/ShortcutButton.js
@@ -1,4 +1,4 @@
-// SPDX-FileCopyrightText: 2021 Romain Vigier
+// SPDX-FileCopyrightText: 2021, 2022 Romain Vigier
// SPDX-License-Identifier: GPL-3.0-or-later
const { Gdk, GLib, GObject, Gtk } = imports.gi;
@@ -23,6 +23,10 @@ var ShortcutButton = GObject.registerClass({
),
},
}, class ShortcutButton extends Gtk.Stack {
+ vfunc_mnemonic_activate() {
+ this.activate();
+ }
+
activate() {
if (this.keybinding)
return this._change_button.activate();
diff --git a/src/preferences/ThemesPage.js b/src/preferences/ThemesPage.js
new file mode 100644
index 0000000..7c2d1b3
--- /dev/null
+++ b/src/preferences/ThemesPage.js
@@ -0,0 +1,87 @@
+// SPDX-FileCopyrightText: 2020-2022 Romain Vigier
+// SPDX-License-Identifier: GPL-3.0-or-later
+
+const { Adw, Gio, GLib, GObject, Gtk } = imports.gi;
+const { extensionUtils } = imports.misc;
+
+const Me = extensionUtils.getCurrentExtension();
+const _ = extensionUtils.gettext;
+
+const utils = Me.imports.utils;
+
+const { DropDownChoice } = Me.imports.preferences.DropDownChoice;
+
+
+var ThemesPage = GObject.registerClass({
+ GTypeName: 'ThemesPage',
+ Template: `file://${GLib.build_filenamev([Me.path, 'preferences', 'ui', 'ThemesPage.ui'])}`,
+ InternalChildren: [
+ 'gtk_enabled_switch',
+ 'gtk_day_variant_combo_row',
+ 'gtk_night_variant_combo_row',
+ 'shell_enabled_switch',
+ 'shell_day_variant_combo_row',
+ 'shell_night_variant_combo_row',
+ 'icon_enabled_switch',
+ 'icon_day_variant_combo_row',
+ 'icon_night_variant_combo_row',
+ 'cursor_enabled_switch',
+ 'cursor_day_variant_combo_row',
+ 'cursor_night_variant_combo_row',
+ ],
+}, class ThemesPage extends Adw.PreferencesPage {
+ _init(props = {}) {
+ super._init(props);
+ const gtkSettings = extensionUtils.getSettings(utils.getSettingsSchema('gtk-variants'));
+ const shellSettings = extensionUtils.getSettings(utils.getSettingsSchema('shell-variants'));
+ const iconSettings = extensionUtils.getSettings(utils.getSettingsSchema('icon-variants'));
+ const cursorSettings = extensionUtils.getSettings(utils.getSettingsSchema('cursor-variants'));
+
+ gtkSettings.bind('enabled', this._gtk_enabled_switch, 'active', Gio.SettingsBindFlags.DEFAULT);
+
+ const gtkThemesStore = Gio.ListStore.new(DropDownChoice);
+ gtkThemesStore.splice(0, 0, Array.from(utils.getInstalledGtkThemes()).sort().map(theme => new DropDownChoice({ id: theme, title: theme })));
+ _setupComboRow(this._gtk_day_variant_combo_row, gtkThemesStore, gtkSettings, 'day');
+ _setupComboRow(this._gtk_night_variant_combo_row, gtkThemesStore, gtkSettings, 'night');
+
+ shellSettings.bind('enabled', this._shell_enabled_switch, 'active', Gio.SettingsBindFlags.DEFAULT);
+
+ const shellThemesStore = Gio.ListStore.new(DropDownChoice);
+ shellThemesStore.splice(0, 0, Array.from(utils.getInstalledShellThemes()).sort().map(theme => new DropDownChoice({ id: theme, title: theme || _('Default') })));
+ _setupComboRow(this._shell_day_variant_combo_row, shellThemesStore, shellSettings, 'day');
+ _setupComboRow(this._shell_night_variant_combo_row, shellThemesStore, shellSettings, 'night');
+
+ iconSettings.bind('enabled', this._icon_enabled_switch, 'active', Gio.SettingsBindFlags.DEFAULT);
+
+ const iconThemesStore = Gio.ListStore.new(DropDownChoice);
+ iconThemesStore.splice(0, 0, Array.from(utils.getInstalledIconThemes()).sort().map(theme => new DropDownChoice({ id: theme, title: theme })));
+ _setupComboRow(this._icon_day_variant_combo_row, iconThemesStore, iconSettings, 'day');
+ _setupComboRow(this._icon_night_variant_combo_row, iconThemesStore, iconSettings, 'night');
+
+ cursorSettings.bind('enabled', this._cursor_enabled_switch, 'active', Gio.SettingsBindFlags.DEFAULT);
+
+ const cursorThemesStore = Gio.ListStore.new(DropDownChoice);
+ cursorThemesStore.splice(0, 0, Array.from(utils.getInstalledCursorThemes()).sort().map(theme => new DropDownChoice({ id: theme, title: theme })));
+ _setupComboRow(this._cursor_day_variant_combo_row, cursorThemesStore, cursorSettings, 'day');
+ _setupComboRow(this._cursor_night_variant_combo_row, cursorThemesStore, cursorSettings, 'night');
+ }
+});
+
+/**
+ * Set up the model of a combo row.
+ *
+ * @param {Adw.ComboRow} row The row to set up.
+ * @param {Gio.ListModel} model A list model of DropDownChoice.
+ * @param {Gio.Settings} settings The settings to connect.
+ * @param {str} key The key to update.
+ */
+function _setupComboRow(row, model, settings, key) {
+ row.model = model;
+ row.expression = Gtk.PropertyExpression.new(DropDownChoice, null, 'title');
+ row.connect('notify::selected-item', () => settings.set_string(key, row.selected_item.id));
+ const updateComboRowSelected = () => {
+ row.selected = utils.findItemPositionInModel(row.model, item => item.id === settings.get_string(key));
+ };
+ settings.connect(`changed::${key}`, () => updateComboRowSelected());
+ updateComboRowSelected();
+}
diff --git a/src/preferences/ui/Appearance.ui b/src/preferences/ui/Appearance.ui
deleted file mode 100644
index 7223a8d..0000000
--- a/src/preferences/ui/Appearance.ui
+++ /dev/null
@@ -1,42 +0,0 @@
-
-
-
-
- True
- never
-
-
-
-
-
diff --git a/src/preferences/ui/BackgroundsPage.ui b/src/preferences/ui/BackgroundsPage.ui
new file mode 100644
index 0000000..d8084d5
--- /dev/null
+++ b/src/preferences/ui/BackgroundsPage.ui
@@ -0,0 +1,38 @@
+
+
+
+
+ backgrounds
+ Backgrounds
+ nightthemeswitcher-backgrounds-symbolic
+
+
+
+
+ Day background
+ day_button
+
+
+ center
+
+
+
+
+
+
+ Night background
+ night_button
+
+
+ center
+
+
+
+
+
+
+
+
diff --git a/src/preferences/ui/BackgroundsPreferences.ui b/src/preferences/ui/BackgroundsPreferences.ui
deleted file mode 100644
index 4cf0f3b..0000000
--- a/src/preferences/ui/BackgroundsPreferences.ui
+++ /dev/null
@@ -1,41 +0,0 @@
-
-
-
-
- vertical
- 8
-
-
- Switch backgrounds
- 0
-
-
-
-
-
- 36
-
-
- Day background
-
-
-
-
-
-
-
- Night background
-
-
-
-
-
-
-
-
-
diff --git a/src/preferences/ui/Commands.ui b/src/preferences/ui/Commands.ui
deleted file mode 100644
index ec6948a..0000000
--- a/src/preferences/ui/Commands.ui
+++ /dev/null
@@ -1,88 +0,0 @@
-
-
-
-
- True
- never
-
-
- True
-
-
- vertical
- 600
- center
- 36
- 36
- 36
- 36
-
-
- vertical
- 8
-
-
- horizontal
-
-
- Run commands
- center
- True
- 0
-
-
-
-
-
- center
-
-
-
-
-
-
-
-
-
- 36
-
-
- Sunrise
-
-
- notify-send "Hello sunshine!"
- terminal
- 28
-
-
-
-
-
-
- Sunset
-
-
- notify-send "Hello moonshine!"
- terminal
- 28
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/src/preferences/ui/CommandsPage.ui b/src/preferences/ui/CommandsPage.ui
new file mode 100644
index 0000000..4c83005
--- /dev/null
+++ b/src/preferences/ui/CommandsPage.ui
@@ -0,0 +1,50 @@
+
+
+
+
+ commands
+ Commands
+ nightthemeswitcher-commands-symbolic
+
+
+ Run commands
+
+
+ center
+
+
+
+
+ Sunrise
+ sunrise_entry
+
+
+ notify-send "Hello sunshine!"
+ terminal
+ 28
+ center
+
+
+
+
+
+
+ Sunset
+ sunset_entry
+
+
+ notify-send "Hello sunshine!"
+ terminal
+ 28
+ center
+
+
+
+
+
+
+
+
diff --git a/src/preferences/ui/ContributePage.ui b/src/preferences/ui/ContributePage.ui
new file mode 100644
index 0000000..a939440
--- /dev/null
+++ b/src/preferences/ui/ContributePage.ui
@@ -0,0 +1,55 @@
+
+
+
+
+ contribute
+ Contribute
+ nightthemeswitcher-contribute-symbolic
+
+
+
+
+ View the code and report issues
+ nightthemeswitcher-code-symbolic
+ gitlab_button
+
+
+ GitLab
+ https://gitlab.com/rmnvgr/nightthemeswitcher-gnome-shell-extension
+
+
+
+
+
+
+ Contribute to the translation
+ nightthemeswitcher-translate-symbolic
+ weblate_button
+
+
+ Weblate
+ https://hosted.weblate.org/engage/night-theme-switcher/
+
+
+
+
+
+
+ Support me with a donation
+ nightthemeswitcher-support-symbolic
+ liberapay_button
+
+
+ Liberapay
+ https://liberapay.com/rmnvgr/donate
+
+
+
+
+
+
+
+
diff --git a/src/preferences/ui/CursorPreferences.ui b/src/preferences/ui/CursorPreferences.ui
deleted file mode 100644
index d40e908..0000000
--- a/src/preferences/ui/CursorPreferences.ui
+++ /dev/null
@@ -1,62 +0,0 @@
-
-
-
-
- vertical
- 8
-
-
- horizontal
-
-
- Switch cursor theme variants
- center
- True
- 0
-
-
-
-
-
- center
-
-
-
-
-
-
-
-
-
- 36
-
-
- Day variant
-
-
- True
-
-
-
-
-
-
- Night variant
-
-
- True
-
-
-
-
-
-
-
-
-
-
diff --git a/src/preferences/ui/GtkPreferences.ui b/src/preferences/ui/GtkPreferences.ui
deleted file mode 100644
index cc8becf..0000000
--- a/src/preferences/ui/GtkPreferences.ui
+++ /dev/null
@@ -1,73 +0,0 @@
-
-
-
-
- vertical
- 8
-
-
- horizontal
-
-
- Switch GTK theme variants
- center
- True
- 0
-
-
-
-
-
- center
-
-
-
-
-
-
-
-
-
- 36
-
-
- Manual variants
- submit a request to get your theme supported.]]>
-
-
-
-
-
-
-
- Day variant
-
-
-
- True
-
-
-
-
-
-
- Night variant
-
-
-
- True
-
-
-
-
-
-
-
-
-
-
diff --git a/src/preferences/ui/Headerbar.ui b/src/preferences/ui/Headerbar.ui
deleted file mode 100644
index f3ac7ff..0000000
--- a/src/preferences/ui/Headerbar.ui
+++ /dev/null
@@ -1,108 +0,0 @@
-
-
-
-
-
diff --git a/src/preferences/ui/IconPreferences.ui b/src/preferences/ui/IconPreferences.ui
deleted file mode 100644
index 79e6ca4..0000000
--- a/src/preferences/ui/IconPreferences.ui
+++ /dev/null
@@ -1,62 +0,0 @@
-
-
-
-
- vertical
- 8
-
-
- horizontal
-
-
- Switch icon theme variants
- center
- True
- 0
-
-
-
-
-
- center
-
-
-
-
-
-
-
-
-
- 36
-
-
- Day variant
-
-
- True
-
-
-
-
-
-
- Night variant
-
-
- True
-
-
-
-
-
-
-
-
-
-
diff --git a/src/preferences/ui/PreferenceRow.ui b/src/preferences/ui/PreferenceRow.ui
deleted file mode 100644
index e8a86a9..0000000
--- a/src/preferences/ui/PreferenceRow.ui
+++ /dev/null
@@ -1,56 +0,0 @@
-
-
-
-
- False
-
-
-
-
- horizontal
- 6
- 6
- 6
- 6
- 72
-
-
- vertical
- center
- True
- 4
-
-
-
- True
- 0
-
-
-
-
- False
-
- True
- True
- 50
- 0
-
-
-
-
-
-
-
- center
-
-
-
-
-
-
diff --git a/src/preferences/ui/Preferences.ui b/src/preferences/ui/Preferences.ui
deleted file mode 100644
index 6b62e2e..0000000
--- a/src/preferences/ui/Preferences.ui
+++ /dev/null
@@ -1,42 +0,0 @@
-
-
-
-
- True
- True
- crossfade
-
-
- schedule
- Schedule
- nightthemeswitcher-schedule-symbolic
-
-
-
-
-
-
-
- appearance
- Appearance
- nightthemeswitcher-appearance-symbolic
-
-
-
-
-
-
-
- commands
- Commands
- nightthemeswitcher-commands-symbolic
-
-
-
-
-
-
-
diff --git a/src/preferences/ui/PreferencesList.ui b/src/preferences/ui/PreferencesList.ui
deleted file mode 100644
index 8d8a023..0000000
--- a/src/preferences/ui/PreferencesList.ui
+++ /dev/null
@@ -1,17 +0,0 @@
-
-
-
-
-
- True
- none
- True
-
-
-
diff --git a/src/preferences/ui/Schedule.ui b/src/preferences/ui/Schedule.ui
deleted file mode 100644
index 7801763..0000000
--- a/src/preferences/ui/Schedule.ui
+++ /dev/null
@@ -1,179 +0,0 @@
-
-
-
-
- True
- never
-
-
- True
-
-
- vertical
- 600
- center
- 36
- 36
- 36
- 36
-
-
- 36
-
-
- Manual time source
- The extension will try to use Night Light or Location Services to automatically set your current sunrise and sunset times if they are enabled. If you prefer, you can manually choose a time source.
-
-
-
-
-
-
-
- Time source
-
-
-
-
-
-
-
-
- Always show on-demand controls
- Allows you to override the current time when using a schedule.
-
-
-
-
-
-
-
-
-
-
-
- vertical
- 8
-
-
- Night Light
- 0
-
-
-
-
-
- 36
-
-
- Disable until tomorrow]]>
- When Night Light is temporarily disabled, the extension will switch to day variants.
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- vertical
- 8
-
-
- Manual schedule times
- 0
-
-
-
-
-
- 36
-
-
- Sunrise
-
-
-
-
-
-
-
- Sunset
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- vertical
- 8
-
-
- On-demand
- 0
-
-
-
-
-
- 36
-
-
- Keyboard shortcut
-
-
-
-
-
-
-
- Button location
-
-
- panel
-
- - None
- - Top bar
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/src/preferences/ui/SchedulePage.ui b/src/preferences/ui/SchedulePage.ui
new file mode 100644
index 0000000..4bf45c3
--- /dev/null
+++ b/src/preferences/ui/SchedulePage.ui
@@ -0,0 +1,113 @@
+
+
+
+
+ schedule
+ Schedule
+ nightthemeswitcher-schedule-symbolic
+
+
+
+
+ Manual time source
+ The extension will try to use Night Light or Location Services to automatically set your current sunrise and sunset times if they are enabled. If you prefer, you can manually choose a time source.
+ manual_time_source_switch
+
+
+ center
+
+
+
+
+
+
+ Time source
+
+
+
+
+
+ Always show on-demand controls
+ Allows you to override the current time when using a schedule.
+ always_show_ondemand_switch
+
+
+ center
+
+
+
+
+
+
+
+
+ Night Light
+
+
+ Disable until tomorrow]]>
+ When Night Light is temporarily disabled, the extension will switch to day variants.
+ nightlight_follow_disable_switch
+
+
+ center
+
+
+
+
+
+
+
+
+ Manual schedule times
+
+
+ Sunrise
+
+
+ 12
+ 12
+ center
+
+
+
+
+
+
+ Sunset
+
+
+ 12
+ 12
+ center
+
+
+
+
+
+
+
+
+ On-demand
+
+
+ Keyboard shortcut
+ ondemand_shortcut_button
+
+
+ center
+
+
+
+
+
+
+ Button location
+
+
+
+
+
+
diff --git a/src/preferences/ui/ShellPreferences.ui b/src/preferences/ui/ShellPreferences.ui
deleted file mode 100644
index 1a1f3bb..0000000
--- a/src/preferences/ui/ShellPreferences.ui
+++ /dev/null
@@ -1,73 +0,0 @@
-
-
-
-
- vertical
- 8
-
-
- horizontal
-
-
- Switch Shell theme variants
- center
- True
- 0
-
-
-
-
-
- center
-
-
-
-
-
-
-
-
-
- 36
-
-
- Manual variants
- submit a request to get your theme supported.]]>
-
-
-
-
-
-
-
- Day variant
-
-
-
- True
-
-
-
-
-
-
- Night variant
-
-
-
- True
-
-
-
-
-
-
-
-
-
-
diff --git a/src/preferences/ui/ShortcutButton.ui b/src/preferences/ui/ShortcutButton.ui
index 50ab3cf..2bf47ca 100644
--- a/src/preferences/ui/ShortcutButton.ui
+++ b/src/preferences/ui/ShortcutButton.ui
@@ -54,63 +54,41 @@ SPDX-License-Identifier: GPL-3.0-or-later
-
+
True
- 440
- 200
+ 440
True
- False
-
-
+
True
True
-
+
-
-
-
- True
- True
- 36
- 36
- 36
- 36
- Press your keyboard shortcut…
- center
- True
-
-
-
+
+ Press your keyboard shortcut…
+ preferences-desktop-keyboard-shortcuts-symbolic
+ true
+
-
+
diff --git a/src/preferences/ui/ThemesPage.ui b/src/preferences/ui/ThemesPage.ui
new file mode 100644
index 0000000..8f3c2ab
--- /dev/null
+++ b/src/preferences/ui/ThemesPage.ui
@@ -0,0 +1,93 @@
+
+
+
+
+ themes
+ Themes
+ nightthemeswitcher-themes-symbolic
+
+
+ GTK theme
+ Forcing a dark theme on applications not designed to support it can have undesirable side-effects such as unreadable text or invisible icons.
+
+
+ center
+
+
+
+
+ Day variant
+
+
+
+
+ Night variant
+
+
+
+
+
+
+ Shell theme
+
+
+ center
+
+
+
+
+ Day variant
+
+
+
+
+ Night variant
+
+
+
+
+
+
+ Icon theme
+
+
+ center
+
+
+
+
+ Day variant
+
+
+
+
+ Night variant
+
+
+
+
+
+
+ Cursor theme
+
+
+ center
+
+
+
+
+ Day variant
+
+
+
+
+ Night variant
+
+
+
+
+
+
diff --git a/src/preferences/ui/style.css b/src/preferences/ui/style.css
deleted file mode 100644
index 66a26ad..0000000
--- a/src/preferences/ui/style.css
+++ /dev/null
@@ -1,104 +0,0 @@
-/*
-SPDX-FileCopyrightText: 2020, 2021 Romain Vigier
-SPDX-License-Identifier: GPL-3.0-or-later
-*/
-
-window.nightthemeswitcher,
-window.toolbox
-{
- border-radius: 8px;
-}
-
-window.nightthemeswitcher headerbar
-{
- background: #000;
- color: alpha(#fff, 0.9);
- border: none;
-}
-
-window.nightthemeswitcher headerbar button
-{
- background: alpha(#fff, 0.2);
- color: inherit;
- border: none;
- font-weight: bold;
- transition: all 200ms;
-}
-
-window.nightthemeswitcher headerbar button.close
-{
- background: none;
-}
-
-window.nightthemeswitcher headerbar button:hover
-{
- background: alpha(#fff, 0.3);
-}
-
-window.nightthemeswitcher headerbar button:active
-{
- background: alpha(#fff, 0.4);
-}
-
-window.nightthemeswitcher headerbar button:checked
-{
- background: alpha(#fff, 0.1);
-}
-
-window.nightthemeswitcher headerbar .linked button.toggle
-{
- border-right: 1px solid alpha(#000, 0.4);
-}
-
-window.nightthemeswitcher headerbar .linked button.toggle:last-child
-{
- border-right: none;
-}
-
-window.nightthemeswitcher list.frame
-{
- border-radius: 8px;
-}
-
-window.nightthemeswitcher list.frame row:last-child
-{
- border-bottom: none;
-}
-
-window.nightthemeswitcher .support button
-{
- margin: 0;
-}
-
-window.nightthemeswitcher .support button.gitlab
-{
- background-color: rgba(250, 112, 53, 1);
- color: #fff;
-}
-
-window.nightthemeswitcher .support button.gitlab:hover
-{
- background-color: rgba(250, 112, 53, 1);
-}
-
-window.nightthemeswitcher .support button.liberapay
-{
- background-color: rgba(246, 201, 21, 0.8);
- color: #1a171b;
-}
-
-window.nightthemeswitcher .support button.liberapay:hover
-{
- background-color: rgba(246, 201, 21, 1);
-}
-
-window.nightthemeswitcher .support button.weblate
-{
- background-color: rgba(46, 204, 170, 0.8);
- color: #fff;
-}
-
-window.nightthemeswitcher .support button.weblate:hover
-{
- background-color: rgba(46, 204, 170, 1);
-}
diff --git a/src/prefs.js b/src/prefs.js
index 5e98ca6..9ad2426 100644
--- a/src/prefs.js
+++ b/src/prefs.js
@@ -1,15 +1,24 @@
-// SPDX-FileCopyrightText: 2020, 2021 Romain Vigier
+// SPDX-FileCopyrightText: 2020-2022 Romain Vigier
// SPDX-License-Identifier: GPL-3.0-or-later
'use strict';
-const { Gdk, GLib, Gtk } = imports.gi;
+const { Adw, Gdk, GLib, Gtk } = imports.gi;
const { extensionUtils } = imports.misc;
const Me = extensionUtils.getCurrentExtension();
+const _ = extensionUtils.gettext;
-const { Headerbar } = Me.imports.preferences.Headerbar;
-const { Preferences } = Me.imports.preferences.Preferences;
+const { BackgroundsPage } = Me.imports.preferences.BackgroundsPage;
+const { CommandsPage } = Me.imports.preferences.CommandsPage;
+const { ContributePage } = Me.imports.preferences.ContributePage;
+const { SchedulePage } = Me.imports.preferences.SchedulePage;
+const { ThemesPage } = Me.imports.preferences.ThemesPage;
+
+const { BackgroundButton } = Me.imports.preferences.BackgroundButton;
+const { ClearableEntry } = Me.imports.preferences.ClearableEntry;
+const { ShortcutButton } = Me.imports.preferences.ShortcutButton;
+const { TimeChooser } = Me.imports.preferences.TimeChooser;
/**
@@ -20,22 +29,20 @@ function init() {
const iconTheme = Gtk.IconTheme.get_for_display(Gdk.Display.get_default());
iconTheme.add_search_path(GLib.build_filenamev([Me.path, 'icons']));
-
- const styleProvider = new Gtk.CssProvider();
- styleProvider.load_from_path(GLib.build_filenamev([Me.path, 'preferences', 'ui', 'style.css']));
- Gtk.StyleContext.add_provider_for_display(Gdk.Display.get_default(), styleProvider, Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION);
}
/**
- * Build the preferences widget.
+ * Fill the PreferencesWindow.
+ *
+ * @param {Adw.PreferencesWindow} window The PreferencesWindow to fill.
*/
-function buildPrefsWidget() {
- const preferences = new Preferences();
- preferences.connect('notify::root', () => {
- const window = preferences.get_root();
- window.add_css_class('nightthemeswitcher');
- const headerbar = new Headerbar({ preferences });
- window.set_titlebar(headerbar);
- });
- return preferences;
+function fillPreferencesWindow(window) {
+ [
+ new SchedulePage(),
+ new BackgroundsPage(),
+ new CommandsPage(),
+ new ThemesPage(),
+ new ContributePage(),
+ ].forEach(page => window.add(page));
+ window.search_enabled = true;
}