diff --git a/build-aux/Dockerfile b/build-aux/Dockerfile index c047b7e..183db57 100644 --- a/build-aux/Dockerfile +++ b/build-aux/Dockerfile @@ -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 diff --git a/src/data/meson.build b/src/data/meson.build index 25a1d77..61c90ea 100644 --- a/src/data/meson.build +++ b/src/data/meson.build @@ -1,6 +1,14 @@ # SPDX-FileCopyrightText: 2022 Romain Vigier # 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') diff --git a/src/data/org.gnome.shell.extensions.nightthemeswitcher.gresource.xml b/src/data/org.gnome.shell.extensions.nightthemeswitcher.gresource.xml new file mode 100644 index 0000000..8bcc23a --- /dev/null +++ b/src/data/org.gnome.shell.extensions.nightthemeswitcher.gresource.xml @@ -0,0 +1,18 @@ + + + + + ui/BackgroundButton.ui + ui/BackgroundsPage.ui + ui/ClearableEntry.ui + ui/CommandsPage.ui + ui/ContributePage.ui + ui/SchedulePage.ui + ui/ShortcutButton.ui + ui/ThemesPage.ui + ui/TimeChooser.ui + + diff --git a/src/preferences/BackgroundButton.js b/src/preferences/BackgroundButton.js index 6cf6ff9..852b197 100644 --- a/src/preferences/BackgroundButton.js +++ b/src/preferences/BackgroundButton.js @@ -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( diff --git a/src/preferences/BackgroundsPage.js b/src/preferences/BackgroundsPage.js index 8a9b1c7..b8eed90 100644 --- a/src/preferences/BackgroundsPage.js +++ b/src/preferences/BackgroundsPage.js @@ -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', diff --git a/src/preferences/ClearableEntry.js b/src/preferences/ClearableEntry.js index 19d94c7..f087ba5 100644 --- a/src/preferences/ClearableEntry.js +++ b/src/preferences/ClearableEntry.js @@ -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) diff --git a/src/preferences/CommandsPage.js b/src/preferences/CommandsPage.js index 24a7ed6..a212de0 100644 --- a/src/preferences/CommandsPage.js +++ b/src/preferences/CommandsPage.js @@ -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', diff --git a/src/preferences/ContributePage.js b/src/preferences/ContributePage.js index feabce0..c48e63d 100644 --- a/src/preferences/ContributePage.js +++ b/src/preferences/ContributePage.js @@ -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 {}); diff --git a/src/preferences/SchedulePage.js b/src/preferences/SchedulePage.js index a0fb803..ea5d3dd 100644 --- a/src/preferences/SchedulePage.js +++ b/src/preferences/SchedulePage.js @@ -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', diff --git a/src/preferences/ShortcutButton.js b/src/preferences/ShortcutButton.js index 9e20847..ff29328 100644 --- a/src/preferences/ShortcutButton.js +++ b/src/preferences/ShortcutButton.js @@ -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( diff --git a/src/preferences/ThemesPage.js b/src/preferences/ThemesPage.js index cb2ab8b..a909ccb 100644 --- a/src/preferences/ThemesPage.js +++ b/src/preferences/ThemesPage.js @@ -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', diff --git a/src/preferences/TimeChooser.js b/src/preferences/TimeChooser.js index 54cb05c..3265d92 100644 --- a/src/preferences/TimeChooser.js +++ b/src/preferences/TimeChooser.js @@ -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( diff --git a/src/prefs.js b/src/prefs.js index 909bb33..ab11f3b 100644 --- a/src/prefs.js +++ b/src/prefs.js @@ -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); }