From 96ac00b53cdca3db2aa0f881b71c41b4a1e1c015 Mon Sep 17 00:00:00 2001 From: Joonas Henriksson Date: Mon, 18 Nov 2019 22:18:29 +0200 Subject: [PATCH] animation: Turn Spinner animate parameter into Params option https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/834 --- js/ui/animation.js | 13 +++++++++++-- js/ui/components/keyring.js | 4 +++- js/ui/components/polkitAgent.js | 4 +++- js/ui/panel.js | 4 +++- js/ui/shellMountOperation.js | 4 +++- 5 files changed, 23 insertions(+), 6 deletions(-) diff --git a/js/ui/animation.js b/js/ui/animation.js index 18c837e82..ed4637b72 100644 --- a/js/ui/animation.js +++ b/js/ui/animation.js @@ -3,6 +3,8 @@ const { Clutter, GLib, Gio, St } = imports.gi; +const Params = imports.misc.params; + var ANIMATED_ICON_UPDATE_TIMEOUT = 16; var SPINNER_ANIMATION_TIME = 300; var SPINNER_ANIMATION_DELAY = 1000; @@ -131,12 +133,19 @@ var AnimatedIcon = class extends Animation { }; var Spinner = class extends AnimatedIcon { - constructor(size, animate = false) { + constructor(size, params) { + // Compatibility with older callers + if (params === true || params === false) + params = { animate: params }; + + params = Params.parse(params, { + animate: false, + }); let file = Gio.File.new_for_uri('resource:///org/gnome/shell/theme/process-working.svg'); super(file, size); this.actor.opacity = 0; - this._animate = animate; + this._animate = params.animate; } _onDestroy() { diff --git a/js/ui/components/keyring.js b/js/ui/components/keyring.js index 66948b65d..24bcc6c3d 100644 --- a/js/ui/components/keyring.js +++ b/js/ui/components/keyring.js @@ -74,7 +74,9 @@ class KeyringDialog extends ModalDialog.ModalDialog { ShellEntry.addContextMenu(this._passwordEntry, { isPassword: true }); this._passwordEntry.clutter_text.connect('activate', this._onPasswordActivate.bind(this)); - this._workSpinner = new Animation.Spinner(WORK_SPINNER_ICON_SIZE, true); + this._workSpinner = new Animation.Spinner(WORK_SPINNER_ICON_SIZE, { + animate: true, + }); if (rtl) { layout.attach(this._workSpinner.actor, 0, row, 1, 1); diff --git a/js/ui/components/polkitAgent.js b/js/ui/components/polkitAgent.js index 1c1b8e610..991927c8a 100644 --- a/js/ui/components/polkitAgent.js +++ b/js/ui/components/polkitAgent.js @@ -105,7 +105,9 @@ var AuthenticationDialog = GObject.registerClass({ this._passwordBox.add(this._passwordEntry, { expand: true }); - this._workSpinner = new Animation.Spinner(WORK_SPINNER_ICON_SIZE, true); + this._workspinner = new Animation.Spinner(WORK_SPINNER_ICON_SIZE, { + animate: true, + }); this._passwordBox.add(this._workSpinner.actor); this.setInitialKeyFocus(this._passwordEntry); diff --git a/js/ui/panel.js b/js/ui/panel.js index 49c0038fa..2b2d66bf9 100644 --- a/js/ui/panel.js +++ b/js/ui/panel.js @@ -234,7 +234,9 @@ var AppMenuButton = GObject.registerClass({ this._overviewHidingId = Main.overview.connect('hiding', this._sync.bind(this)); this._overviewShowingId = Main.overview.connect('showing', this._sync.bind(this)); - this._spinner = new Animation.Spinner(PANEL_ICON_SIZE, true); + this._spinner = new Animation.Spinner(PANEL_ICON_SIZE, { + animate: true, + }); this._container.add_actor(this._spinner.actor); let menu = new AppMenu(this); diff --git a/js/ui/shellMountOperation.js b/js/ui/shellMountOperation.js index ff5cb2366..5c08c3671 100644 --- a/js/ui/shellMountOperation.js +++ b/js/ui/shellMountOperation.js @@ -359,7 +359,9 @@ var ShellMountPasswordDialog = GObject.registerClass({ this._passwordEntry.clutter_text.set_password_char('\u25cf'); // ● U+25CF BLACK CIRCLE ShellEntry.addContextMenu(this._passwordEntry, { isPassword: true }); this.setInitialKeyFocus(this._passwordEntry); - this._workSpinner = new Animation.Spinner(WORK_SPINNER_ICON_SIZE, true); + this._workSpinner = new Animation.Spinner(WORK_SPINNER_ICON_SIZE, { + animate: true, + }); this._passwordEntry.secondary_icon = this._workSpinner.actor; if (rtl) {