animation: Turn Spinner animate parameter into Params option

https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/832
This commit is contained in:
Joonas Henriksson 2019-11-18 22:18:29 +02:00
parent e3e1a27f2d
commit 6af25b282c
5 changed files with 19 additions and 6 deletions

View File

@ -3,6 +3,8 @@
const { Clutter, GLib, GObject, Gio, St } = imports.gi; const { Clutter, GLib, GObject, Gio, St } = imports.gi;
const Params = imports.misc.params;
var ANIMATED_ICON_UPDATE_TIMEOUT = 16; var ANIMATED_ICON_UPDATE_TIMEOUT = 16;
var SPINNER_ANIMATION_TIME = 300; var SPINNER_ANIMATION_TIME = 300;
var SPINNER_ANIMATION_DELAY = 1000; var SPINNER_ANIMATION_DELAY = 1000;
@ -136,12 +138,15 @@ class AnimatedIcon extends Animation {
var Spinner = GObject.registerClass( var Spinner = GObject.registerClass(
class Spinner extends AnimatedIcon { class Spinner extends AnimatedIcon {
_init(size, animate = false) { _init(size, params) {
params = Params.parse(params, {
animate: false,
});
let file = Gio.File.new_for_uri('resource:///org/gnome/shell/theme/process-working.svg'); let file = Gio.File.new_for_uri('resource:///org/gnome/shell/theme/process-working.svg');
super._init(file, size); super._init(file, size);
this.opacity = 0; this.opacity = 0;
this._animate = animate; this._animate = params.animate;
} }
_onDestroy() { _onDestroy() {

View File

@ -78,7 +78,9 @@ class KeyringDialog extends ModalDialog.ModalDialog {
ShellEntry.addContextMenu(this._passwordEntry, { isPassword: true }); ShellEntry.addContextMenu(this._passwordEntry, { isPassword: true });
this._passwordEntry.clutter_text.connect('activate', this._onPasswordActivate.bind(this)); 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) { if (rtl) {
layout.attach(this._workSpinner, 0, row, 1, 1); layout.attach(this._workSpinner, 0, row, 1, 1);

View File

@ -103,7 +103,9 @@ var AuthenticationDialog = GObject.registerClass({
GObject.BindingFlags.SYNC_CREATE); GObject.BindingFlags.SYNC_CREATE);
this._passwordBox.add_child(this._passwordEntry); this._passwordBox.add_child(this._passwordEntry);
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); this._passwordBox.add(this._workSpinner);
this._passwordBox.hide(); this._passwordBox.hide();

View File

@ -237,7 +237,9 @@ var AppMenuButton = GObject.registerClass({
this._overviewHidingId = Main.overview.connect('hiding', this._sync.bind(this)); this._overviewHidingId = Main.overview.connect('hiding', this._sync.bind(this));
this._overviewShowingId = Main.overview.connect('showing', 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); this._container.add_actor(this._spinner);
let menu = new AppMenu(this); let menu = new AppMenu(this);

View File

@ -362,7 +362,9 @@ var ShellMountPasswordDialog = GObject.registerClass({
this._passwordEntry.clutter_text.set_password_char('\u25cf'); // ● U+25CF BLACK CIRCLE this._passwordEntry.clutter_text.set_password_char('\u25cf'); // ● U+25CF BLACK CIRCLE
ShellEntry.addContextMenu(this._passwordEntry, { isPassword: true }); ShellEntry.addContextMenu(this._passwordEntry, { isPassword: true });
this.setInitialKeyFocus(this._passwordEntry); 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; this._passwordEntry.secondary_icon = this._workSpinner;
if (rtl) { if (rtl) {