Use system background switching

This commit is contained in:
Romain Vigier
2022-02-18 01:56:43 +01:00
parent b340033a06
commit 6e16cde3d0
4 changed files with 50 additions and 197 deletions
+4 -14
View File
@@ -1,4 +1,4 @@
// SPDX-FileCopyrightText: 2021 Romain Vigier <contact AT romainvigier.fr>
// SPDX-FileCopyrightText: 2021, 2022 Romain Vigier <contact AT romainvigier.fr>
// SPDX-License-Identifier: GPL-3.0-or-later
const { Gio, GLib, GObject, Gtk } = imports.gi;
@@ -6,14 +6,11 @@ const { extensionUtils } = imports.misc;
const Me = extensionUtils.getCurrentExtension();
const utils = Me.imports.utils;
var BackgroundsPreferences = GObject.registerClass({
GTypeName: 'BackgroundsPreferences',
Template: `file://${GLib.build_filenamev([Me.path, 'preferences', 'ui', 'BackgroundsPreferences.ui'])}`,
InternalChildren: [
'enabled_switch',
'day_button',
'night_button',
],
@@ -29,24 +26,17 @@ var BackgroundsPreferences = GObject.registerClass({
}, class BackgroundsPreferences extends Gtk.Box {
_init(props = {}) {
super._init(props);
this.settings = extensionUtils.getSettings(utils.getSettingsSchema('backgrounds'));
this.settings = new Gio.Settings({ schema: 'org.gnome.desktop.background' });
this.settings.bind(
'enabled',
this._enabled_switch,
'active',
Gio.SettingsBindFlags.DEFAULT
);
this.settings.bind(
'day',
'picture-uri',
this._day_button,
'path',
Gio.SettingsBindFlags.DEFAULT
);
this.settings.bind(
'night',
'picture-uri-dark',
this._night_button,
'path',
Gio.SettingsBindFlags.DEFAULT
+22 -39
View File
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
SPDX-FileCopyrightText: 2021 Romain Vigier <contact AT romainvigier.fr>
SPDX-FileCopyrightText: 2021, 2022 Romain Vigier <contact AT romainvigier.fr>
SPDX-License-Identifier: GPL-3.0-or-later
-->
<interface domain="nightthemeswitcher@romainvigier.fr">
@@ -8,48 +8,31 @@ SPDX-License-Identifier: GPL-3.0-or-later
<property name="orientation">vertical</property>
<property name="spacing">8</property>
<child>
<object class="GtkBox">
<property name="orientation">horizontal</property>
<child>
<object class="GtkLabel">
<property name="label" translatable="yes">Switch backgrounds</property>
<property name="valign">center</property>
<property name="hexpand">True</property>
<property name="xalign">0</property>
<style>
<class name="heading"/>
</style>
</object>
</child>
<child>
<object class="GtkSwitch" id="enabled_switch">
<property name="valign">center</property>
</object>
</child>
<object class="GtkLabel">
<property name="label" translatable="yes">Switch backgrounds</property>
<property name="xalign">0</property>
<style>
<class name="heading"/>
</style>
</object>
</child>
<child>
<object class="GtkRevealer">
<property name="reveal-child" bind-source="enabled_switch" bind-property="active" bind-flags="sync-create"/>
<object class="PreferencesList">
<property name="margin-bottom">36</property>
<child>
<object class="PreferencesList">
<property name="margin-bottom">36</property>
<child>
<object class="PreferenceRow">
<property name="title" translatable="yes">Day background</property>
<property name="activatable-widget">
<object class="BackgroundButton" id="day_button"/>
</property>
</object>
</child>
<child>
<object class="PreferenceRow">
<property name="title" translatable="yes">Night background</property>
<property name="activatable-widget">
<object class="BackgroundButton" id="night_button"/>
</property>
</object>
</child>
<object class="PreferenceRow">
<property name="title" translatable="yes">Day background</property>
<property name="activatable-widget">
<object class="BackgroundButton" id="day_button"/>
</property>
</object>
</child>
<child>
<object class="PreferenceRow">
<property name="title" translatable="yes">Night background</property>
<property name="activatable-widget">
<object class="BackgroundButton" id="night_button"/>
</property>
</object>
</child>
</object>