Preferences: Load UI templates from resources
This commit is contained in:
@@ -4,4 +4,4 @@
|
||||
FROM debian:stable-slim
|
||||
|
||||
RUN apt update \
|
||||
&& apt install --no-install-recommends -y gettext libglib2.0-bin meson zip gzip brotli
|
||||
&& apt install --no-install-recommends -y gettext libglib2.0-bin libglib2.0-dev-bin meson zip gzip brotli
|
||||
|
||||
@@ -1,6 +1,14 @@
|
||||
# SPDX-FileCopyrightText: 2022 Romain Vigier <contact AT romainvigier.fr>
|
||||
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
gnome.compile_resources(
|
||||
DNS,
|
||||
DNS + '.gresource.xml',
|
||||
gresource_bundle: true,
|
||||
install: true,
|
||||
install_dir: INSTALL_DIR / 'resources',
|
||||
)
|
||||
|
||||
glib_compile_schemas_exe = find_program('glib-compile-schemas')
|
||||
custom_target(
|
||||
'gschemas',
|
||||
@@ -16,4 +24,3 @@ custom_target(
|
||||
)
|
||||
|
||||
install_subdir('icons', install_dir: INSTALL_DIR)
|
||||
install_subdir('ui', install_dir: INSTALL_DIR / 'preferences')
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!--
|
||||
SPDX-FileCopyrightText: 2022 Romain Vigier <contact AT romainvigier.fr>
|
||||
SPDX-License-Identifier: GPL-3.0-or-later
|
||||
-->
|
||||
<gresources>
|
||||
<gresource prefix="/org/gnome/shell/extensions/nightthemeswitcher">
|
||||
<file compressed="true" preprocess="xml-stripblanks">ui/BackgroundButton.ui</file>
|
||||
<file compressed="true" preprocess="xml-stripblanks">ui/BackgroundsPage.ui</file>
|
||||
<file compressed="true" preprocess="xml-stripblanks">ui/ClearableEntry.ui</file>
|
||||
<file compressed="true" preprocess="xml-stripblanks">ui/CommandsPage.ui</file>
|
||||
<file compressed="true" preprocess="xml-stripblanks">ui/ContributePage.ui</file>
|
||||
<file compressed="true" preprocess="xml-stripblanks">ui/SchedulePage.ui</file>
|
||||
<file compressed="true" preprocess="xml-stripblanks">ui/ShortcutButton.ui</file>
|
||||
<file compressed="true" preprocess="xml-stripblanks">ui/ThemesPage.ui</file>
|
||||
<file compressed="true" preprocess="xml-stripblanks">ui/TimeChooser.ui</file>
|
||||
</gresource>
|
||||
</gresources>
|
||||
@@ -10,7 +10,7 @@ const _ = extensionUtils.gettext;
|
||||
|
||||
var BackgroundButton = GObject.registerClass({
|
||||
GTypeName: 'BackgroundButton',
|
||||
Template: `file://${GLib.build_filenamev([Me.path, 'preferences', 'ui', 'BackgroundButton.ui'])}`,
|
||||
Template: 'resource:///org/gnome/shell/extensions/nightthemeswitcher/ui/BackgroundButton.ui',
|
||||
InternalChildren: ['filechooser'],
|
||||
Properties: {
|
||||
uri: GObject.ParamSpec.string(
|
||||
|
||||
@@ -9,7 +9,7 @@ const Me = extensionUtils.getCurrentExtension();
|
||||
|
||||
var BackgroundsPage = GObject.registerClass({
|
||||
GTypeName: 'BackgroundsPage',
|
||||
Template: `file://${GLib.build_filenamev([Me.path, 'preferences', 'ui', 'BackgroundsPage.ui'])}`,
|
||||
Template: 'resource:///org/gnome/shell/extensions/nightthemeswitcher/ui/BackgroundsPage.ui',
|
||||
InternalChildren: [
|
||||
'day_button',
|
||||
'night_button',
|
||||
|
||||
@@ -9,7 +9,7 @@ const Me = extensionUtils.getCurrentExtension();
|
||||
|
||||
var ClearableEntry = GObject.registerClass({
|
||||
GTypeName: 'ClearableEntry',
|
||||
Template: `file://${GLib.build_filenamev([Me.path, 'preferences', 'ui', 'ClearableEntry.ui'])}`,
|
||||
Template: 'resource:///org/gnome/shell/extensions/nightthemeswitcher/ui/ClearableEntry.ui',
|
||||
}, class ClearableEntry extends Gtk.Entry {
|
||||
onIconReleased(entry, position) {
|
||||
if (position === Gtk.EntryIconPosition.SECONDARY)
|
||||
|
||||
@@ -11,7 +11,7 @@ const utils = Me.imports.utils;
|
||||
|
||||
var CommandsPage = GObject.registerClass({
|
||||
GTypeName: 'CommandsPage',
|
||||
Template: `file://${GLib.build_filenamev([Me.path, 'preferences', 'ui', 'CommandsPage.ui'])}`,
|
||||
Template: 'resource:///org/gnome/shell/extensions/nightthemeswitcher/ui/CommandsPage.ui',
|
||||
InternalChildren: [
|
||||
'enabled_switch',
|
||||
'sunrise_entry',
|
||||
|
||||
@@ -9,5 +9,5 @@ const Me = extensionUtils.getCurrentExtension();
|
||||
|
||||
var ContributePage = GObject.registerClass({
|
||||
GTypeName: 'ContributePage',
|
||||
Template: `file://${GLib.build_filenamev([Me.path, 'preferences', 'ui', 'ContributePage.ui'])}`,
|
||||
Template: 'resource:///org/gnome/shell/extensions/nightthemeswitcher/ui/ContributePage.ui',
|
||||
}, class ContributePage extends Adw.PreferencesPage {});
|
||||
|
||||
@@ -14,7 +14,7 @@ const { DropDownChoice } = Me.imports.preferences.DropDownChoice;
|
||||
|
||||
var SchedulePage = GObject.registerClass({
|
||||
GTypeName: 'SchedulePage',
|
||||
Template: `file://${GLib.build_filenamev([Me.path, 'preferences', 'ui', 'SchedulePage.ui'])}`,
|
||||
Template: 'resource:///org/gnome/shell/extensions/nightthemeswitcher/ui/SchedulePage.ui',
|
||||
InternalChildren: [
|
||||
'transition_switch',
|
||||
'manual_time_source_switch',
|
||||
|
||||
@@ -11,7 +11,7 @@ const utils = Me.imports.utils;
|
||||
|
||||
var ShortcutButton = GObject.registerClass({
|
||||
GTypeName: 'ShortcutButton',
|
||||
Template: `file://${GLib.build_filenamev([Me.path, 'preferences', 'ui', 'ShortcutButton.ui'])}`,
|
||||
Template: 'resource:///org/gnome/shell/extensions/nightthemeswitcher/ui/ShortcutButton.ui',
|
||||
InternalChildren: ['choose_button', 'change_button', 'clear_button', 'dialog'],
|
||||
Properties: {
|
||||
keybinding: GObject.ParamSpec.string(
|
||||
|
||||
@@ -14,7 +14,7 @@ const { DropDownChoice } = Me.imports.preferences.DropDownChoice;
|
||||
|
||||
var ThemesPage = GObject.registerClass({
|
||||
GTypeName: 'ThemesPage',
|
||||
Template: `file://${GLib.build_filenamev([Me.path, 'preferences', 'ui', 'ThemesPage.ui'])}`,
|
||||
Template: 'resource:///org/gnome/shell/extensions/nightthemeswitcher/ui/ThemesPage.ui',
|
||||
InternalChildren: [
|
||||
'gtk_enabled_switch',
|
||||
'gtk_day_variant_combo_row',
|
||||
|
||||
@@ -9,7 +9,7 @@ const Me = extensionUtils.getCurrentExtension();
|
||||
|
||||
var TimeChooser = GObject.registerClass({
|
||||
GTypeName: 'TimeChooser',
|
||||
Template: `file://${GLib.build_filenamev([Me.path, 'preferences', 'ui', 'TimeChooser.ui'])}`,
|
||||
Template: 'resource:///org/gnome/shell/extensions/nightthemeswitcher/ui/TimeChooser.ui',
|
||||
InternalChildren: ['hours', 'minutes'],
|
||||
Properties: {
|
||||
time: GObject.ParamSpec.double(
|
||||
|
||||
+22
-12
@@ -3,23 +3,12 @@
|
||||
|
||||
'use strict';
|
||||
|
||||
const { Adw, Gdk, GLib, Gtk } = imports.gi;
|
||||
const { Adw, Gdk, Gio, GLib, GObject, Gtk } = imports.gi;
|
||||
const { extensionUtils } = imports.misc;
|
||||
|
||||
const Me = extensionUtils.getCurrentExtension();
|
||||
const _ = extensionUtils.gettext;
|
||||
|
||||
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;
|
||||
|
||||
|
||||
/**
|
||||
* Initialize the preferences.
|
||||
@@ -27,6 +16,20 @@ const { TimeChooser } = Me.imports.preferences.TimeChooser;
|
||||
function init() {
|
||||
extensionUtils.initTranslations();
|
||||
|
||||
const resource = Gio.Resource.load(GLib.build_filenamev([Me.path, 'resources', 'org.gnome.shell.extensions.nightthemeswitcher.gresource']));
|
||||
Gio.resources_register(resource);
|
||||
|
||||
GObject.type_ensure(Me.imports.preferences.BackgroundsPage.BackgroundsPage);
|
||||
GObject.type_ensure(Me.imports.preferences.CommandsPage.CommandsPage);
|
||||
GObject.type_ensure(Me.imports.preferences.ContributePage.ContributePage);
|
||||
GObject.type_ensure(Me.imports.preferences.SchedulePage.SchedulePage);
|
||||
GObject.type_ensure(Me.imports.preferences.ThemesPage.ThemesPage);
|
||||
|
||||
GObject.type_ensure(Me.imports.preferences.BackgroundButton.BackgroundButton);
|
||||
GObject.type_ensure(Me.imports.preferences.ClearableEntry.ClearableEntry);
|
||||
GObject.type_ensure(Me.imports.preferences.ShortcutButton.ShortcutButton);
|
||||
GObject.type_ensure(Me.imports.preferences.TimeChooser.TimeChooser);
|
||||
|
||||
const iconTheme = Gtk.IconTheme.get_for_display(Gdk.Display.get_default());
|
||||
iconTheme.add_search_path(GLib.build_filenamev([Me.path, 'icons']));
|
||||
}
|
||||
@@ -37,6 +40,12 @@ function init() {
|
||||
* @param {Adw.PreferencesWindow} window The PreferencesWindow to fill.
|
||||
*/
|
||||
function fillPreferencesWindow(window) {
|
||||
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;
|
||||
|
||||
[
|
||||
new SchedulePage(),
|
||||
new BackgroundsPage(),
|
||||
@@ -44,6 +53,7 @@ function fillPreferencesWindow(window) {
|
||||
new ThemesPage(),
|
||||
new ContributePage(),
|
||||
].forEach(page => window.add(page));
|
||||
|
||||
window.search_enabled = true;
|
||||
window.set_default_size(720, 490);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user