From dc35777245bc50fa826cbad4dd86f6ec61f3a7fd Mon Sep 17 00:00:00 2001 From: Romain Vigier Date: Fri, 8 Apr 2022 13:46:23 +0200 Subject: [PATCH] Revert "Extension: Load icons from resources" This reverts commit 5d6804ab0d7cbdacbd8e66ee25438a7725157fc7. --- src/data/extension.gresource.xml | 11 ----------- ...> nightthemeswitcher-ondemand-off-symbolic.svg} | 0 ...=> nightthemeswitcher-ondemand-on-symbolic.svg} | 0 src/data/meson.build | 14 ++++++-------- src/extension.js | 10 +--------- src/modules/TimerOndemand.js | 6 ++++++ 6 files changed, 13 insertions(+), 28 deletions(-) delete mode 100644 src/data/extension.gresource.xml rename src/data/icons/{ondemand-off-symbolic.svg => nightthemeswitcher-ondemand-off-symbolic.svg} (100%) rename src/data/icons/{ondemand-on-symbolic.svg => nightthemeswitcher-ondemand-on-symbolic.svg} (100%) diff --git a/src/data/extension.gresource.xml b/src/data/extension.gresource.xml deleted file mode 100644 index 97494bf..0000000 --- a/src/data/extension.gresource.xml +++ /dev/null @@ -1,11 +0,0 @@ - - - - - icons/ondemand-off-symbolic.svg - icons/ondemand-on-symbolic.svg - - diff --git a/src/data/icons/ondemand-off-symbolic.svg b/src/data/icons/nightthemeswitcher-ondemand-off-symbolic.svg similarity index 100% rename from src/data/icons/ondemand-off-symbolic.svg rename to src/data/icons/nightthemeswitcher-ondemand-off-symbolic.svg diff --git a/src/data/icons/ondemand-on-symbolic.svg b/src/data/icons/nightthemeswitcher-ondemand-on-symbolic.svg similarity index 100% rename from src/data/icons/ondemand-on-symbolic.svg rename to src/data/icons/nightthemeswitcher-ondemand-on-symbolic.svg diff --git a/src/data/meson.build b/src/data/meson.build index bb21212..e418e65 100644 --- a/src/data/meson.build +++ b/src/data/meson.build @@ -1,14 +1,6 @@ # 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', @@ -30,3 +22,9 @@ 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 8d4dc96..7c082fa 100644 --- a/src/extension.js +++ b/src/extension.js @@ -3,7 +3,7 @@ 'use strict'; -const { Gio, GLib } = imports.gi; +const { Gio } = imports.gi; const { extensionUtils } = imports.misc; const Me = extensionUtils.getCurrentExtension(); @@ -16,7 +16,6 @@ const { Timer } = Me.imports.modules.Timer; class NightThemeSwitcher { - #resource = null; #timer = null; #switcherThemeGtk = null; #switcherThemeShell = null; @@ -33,10 +32,6 @@ 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 }); @@ -85,9 +80,6 @@ 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 2ad4956..d08a907 100644 --- a/src/modules/TimerOndemand.js +++ b/src/modules/TimerOndemand.js @@ -209,6 +209,7 @@ 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'); } } @@ -232,6 +233,7 @@ 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'); } @@ -241,3 +243,7 @@ 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`])); +};