diff --git a/src/data/extension.gresource.xml b/src/data/extension.gresource.xml
new file mode 100644
index 0000000..97494bf
--- /dev/null
+++ b/src/data/extension.gresource.xml
@@ -0,0 +1,11 @@
+
+
+
+
+ icons/ondemand-off-symbolic.svg
+ icons/ondemand-on-symbolic.svg
+
+
diff --git a/src/data/icons/nightthemeswitcher-ondemand-off-symbolic.svg b/src/data/icons/ondemand-off-symbolic.svg
similarity index 100%
rename from src/data/icons/nightthemeswitcher-ondemand-off-symbolic.svg
rename to src/data/icons/ondemand-off-symbolic.svg
diff --git a/src/data/icons/nightthemeswitcher-ondemand-on-symbolic.svg b/src/data/icons/ondemand-on-symbolic.svg
similarity index 100%
rename from src/data/icons/nightthemeswitcher-ondemand-on-symbolic.svg
rename to src/data/icons/ondemand-on-symbolic.svg
diff --git a/src/data/meson.build b/src/data/meson.build
index e418e65..bb21212 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(
+ 'extension',
+ 'extension.gresource.xml',
+ gresource_bundle: true,
+ install: true,
+ install_dir: INSTALL_DIR / 'resources',
+)
+
gnome.compile_resources(
'preferences',
'preferences.gresource.xml',
@@ -22,9 +30,3 @@ custom_target(
install: true,
install_dir: INSTALL_DIR / 'schemas'
)
-
-icons = [
- 'icons/nightthemeswitcher-ondemand-off-symbolic.svg',
- 'icons/nightthemeswitcher-ondemand-on-symbolic.svg'
-]
-install_data(icons, install_dir: INSTALL_DIR / 'icons' / 'hicolor' / 'scalable' / 'status')
diff --git a/src/extension.js b/src/extension.js
index 7c082fa..8d4dc96 100644
--- a/src/extension.js
+++ b/src/extension.js
@@ -3,7 +3,7 @@
'use strict';
-const { Gio } = imports.gi;
+const { Gio, GLib } = imports.gi;
const { extensionUtils } = imports.misc;
const Me = extensionUtils.getCurrentExtension();
@@ -16,6 +16,7 @@ const { Timer } = Me.imports.modules.Timer;
class NightThemeSwitcher {
+ #resource = null;
#timer = null;
#switcherThemeGtk = null;
#switcherThemeShell = null;
@@ -32,6 +33,10 @@ class NightThemeSwitcher {
enable() {
console.debug('Enabling extension...');
+
+ this.#resource = Gio.Resource.load(GLib.build_filenamev([Me.path, 'resources', 'extension.gresource']));
+ Gio.resources_register(this.#resource);
+
this.#timer = new Timer();
this.#switcherThemeGtk = new SwitcherThemeGtk({ timer: this.#timer });
this.#switcherThemeIcon = new SwitcherThemeIcon({ timer: this.#timer });
@@ -80,6 +85,9 @@ class NightThemeSwitcher {
this.#timer = null;
}
+ if (this.#resource)
+ Gio.resources_unregister(this.#resource);
+
console.debug('Extension disabled.');
}
diff --git a/src/modules/TimerOndemand.js b/src/modules/TimerOndemand.js
index d08a907..2ad4956 100644
--- a/src/modules/TimerOndemand.js
+++ b/src/modules/TimerOndemand.js
@@ -209,7 +209,6 @@ var NtsPanelMenuButton = GObject.registerClass(
update() {
this.icon.icon_name = _getIconNameForTime(this.#timer.time);
- this.icon.fallback_gicon = _getGiconForTime(this.#timer.time);
this.accessible_name = this.#timer.time === Time.DAY ? _('Turn Night Mode On') : _('Turn Night Mode Off');
}
}
@@ -233,7 +232,6 @@ var NtsPopupSubMenuMenuItem = GObject.registerClass(
update() {
this.icon.icon_name = _getIconNameForTime(this.#timer.time);
- this.icon.fallback_gicon = _getGiconForTime(this.#timer.time);
this.label.text = this.#timer.time === Time.DAY ? _('Night Mode Off') : _('Night Mode On');
this._toggleItem.label.text = this.#timer.time === Time.DAY ? _('Turn On') : _('Turn Off');
}
@@ -243,7 +241,3 @@ var NtsPopupSubMenuMenuItem = GObject.registerClass(
var _getIconNameForTime = time => {
return time === Time.DAY ? 'nightthemeswitcher-ondemand-off-symbolic' : 'nightthemeswitcher-ondemand-on-symbolic';
};
-
-var _getGiconForTime = time => {
- return Gio.icon_new_for_string(GLib.build_filenamev([Me.path, 'icons', 'hicolor', 'scalable', 'status', `${this._getIconNameForTime(time)}.svg`]));
-};