animation: Use appropriate spinner asset in light variant

Ideally we would replace the sliced-image based animation with a
themed `process-working-symbolic` icon and rotate it, so the spinner
simply picks up the current foreground color.

Unfortunately the `repeat-count` property does not work for rotations,
so to fix the broken spinner in the light variant
in the meantime, include assets for both variants and swap them
out at runtime.

Not everything in the light variant is actually light (overview,
OSDs, ...), so use a simple heuristic on the text color to decide
which asset to use.

Close https://gitlab.gnome.org/GNOME/gnome-shell/-/issues/6783

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/3080>
This commit is contained in:
Florian Müllner 2023-06-21 17:47:13 +02:00 committed by Marge Bot
parent 74445249db
commit 1dda339395
5 changed files with 22 additions and 3087 deletions

View File

@ -14,7 +14,8 @@
<file>gnome-shell-high-contrast.css</file>
<file>gnome-shell-start.svg</file>
<file>pad-osd.css</file>
<file>process-working.svg</file>
<file>process-working-light.svg</file>
<file>process-working-dark.svg</file>
<file>toggle-off.svg</file>
<file>toggle-off-hc.svg</file>
<file>toggle-off-light.svg</file>

File diff suppressed because one or more lines are too long

After

Width:  |  Height:  |  Size: 15 KiB

File diff suppressed because one or more lines are too long

After

Width:  |  Height:  |  Size: 15 KiB

File diff suppressed because it is too large Load Diff

Before

Width:  |  Height:  |  Size: 98 KiB

View File

@ -138,8 +138,24 @@ class Spinner extends AnimatedIcon {
animate: false,
hideOnStop: false,
});
let file = Gio.File.new_for_uri('resource:///org/gnome/shell/theme/process-working.svg');
super._init(file, size);
this._fileDark = Gio.File.new_for_uri(
'resource:///org/gnome/shell/theme/process-working-dark.svg');
this._fileLight = Gio.File.new_for_uri(
'resource:///org/gnome/shell/theme/process-working-light.svg');
super._init(this._fileDark, size);
this.connect('style-changed', () => {
const themeNode = this.get_theme_node();
const textColor = themeNode.get_foreground_color();
const [, luminance] = textColor.to_hls();
const file = luminance > 0.5
? this._fileDark
: this._fileLight;
if (file !== this._file) {
this._file = file;
this._loadFile();
}
});
this.opacity = 0;
this._animate = params.animate;