From 58a1e000fa70a07f46f5497a843a982fc8b7ae2f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20M=C3=BCllner?= Date: Wed, 27 Nov 2024 16:36:03 +0100 Subject: [PATCH] animation: Use new spinner content Change the dedicated Spinner widget to use the corresponding content instead of subclassing AnimatedIcon with appropriate assets. Other than the changed class hierarchy, the public API stays the same, so the impact on callers should be minimal. Closes: https://gitlab.gnome.org/GNOME/gnome-shell/-/issues/8055 Part-of: --- data/gnome-shell-theme.gresource.xml | 2 -- data/theme/process-working-dark.svg | 1 - data/theme/process-working-light.svg | 1 - js/ui/animation.js | 39 +++++++--------------------- 4 files changed, 9 insertions(+), 34 deletions(-) delete mode 100644 data/theme/process-working-dark.svg delete mode 100644 data/theme/process-working-light.svg diff --git a/data/gnome-shell-theme.gresource.xml b/data/gnome-shell-theme.gresource.xml index db1f4e91d..30d9dc452 100644 --- a/data/gnome-shell-theme.gresource.xml +++ b/data/gnome-shell-theme.gresource.xml @@ -8,8 +8,6 @@ gnome-shell-high-contrast.css gnome-shell-start.svg pad-osd.css - process-working-light.svg - process-working-dark.svg workspace-placeholder.svg diff --git a/data/theme/process-working-dark.svg b/data/theme/process-working-dark.svg deleted file mode 100644 index 6c7ad64a6..000000000 --- a/data/theme/process-working-dark.svg +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/data/theme/process-working-light.svg b/data/theme/process-working-light.svg deleted file mode 100644 index 903edde0f..000000000 --- a/data/theme/process-working-light.svg +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/js/ui/animation.js b/js/ui/animation.js index feffc19ce..25b40d4b8 100644 --- a/js/ui/animation.js +++ b/js/ui/animation.js @@ -1,7 +1,6 @@ import Clutter from 'gi://Clutter'; import GLib from 'gi://GLib'; import GObject from 'gi://GObject'; -import Gio from 'gi://Gio'; import St from 'gi://St'; import * as Params from '../misc/params.js'; @@ -130,48 +129,29 @@ class AnimatedIcon extends Animation { }); export const Spinner = GObject.registerClass( -class Spinner extends AnimatedIcon { - _init(size, params) { +class Spinner extends St.Widget { + constructor(size, params) { params = Params.parse(params, { animate: false, hideOnStop: false, }); - 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_hsl(); - const file = luminance > 0.5 - ? this._fileDark - : this._fileLight; - if (file !== this._file) { - this._file = file; - this._loadFile(); - } + super({ + width: size, + height: size, + opacity: 0, }); - this.opacity = 0; this._animate = params.animate; this._hideOnStop = params.hideOnStop; this.visible = !this._hideOnStop; } - _onDestroy() { - this._animate = false; - super._onDestroy(); - } - play() { this.remove_all_transitions(); + this.set_content(new St.SpinnerContent()); this.show(); if (this._animate) { - super.play(); this.ease({ opacity: 255, delay: SPINNER_ANIMATION_DELAY, @@ -180,7 +160,6 @@ class Spinner extends AnimatedIcon { }); } else { this.opacity = 255; - super.play(); } } @@ -193,14 +172,14 @@ class Spinner extends AnimatedIcon { duration: SPINNER_ANIMATION_TIME, mode: Clutter.AnimationMode.LINEAR, onComplete: () => { - super.stop(); + this.set_content(null); if (this._hideOnStop) this.hide(); }, }); } else { this.opacity = 0; - super.stop(); + this.set_content(null); if (this._hideOnStop) this.hide();