appDisplay: Fix completion handler for empty animations

If an onComplete handler is passed to animate(), it is set to run at
the end of the animation via the icon grid's ::animation-done signal.
Currently the signal is connected after starting the animation, with
the result that the handler doesn't run when the animation completes
immediately (because there are no icons to animate). Fix this by only
starting the animation after connecting the signal.

https://bugzilla.gnome.org/show_bug.cgi?id=774381
This commit is contained in:
Xiaoguang Wang 2016-11-18 16:00:01 +08:00 committed by Florian Müllner
parent e661d904de
commit 09e6bb5d56

View File

@ -210,6 +210,14 @@ const BaseAppView = new Lang.Class({
},
animate: function(animationDirection, onComplete) {
if (onComplete) {
let animationDoneId = this._grid.connect('animation-done', Lang.bind(this,
function () {
this._grid.disconnect(animationDoneId);
onComplete();
}));
}
if (animationDirection == IconGrid.AnimationDirection.IN) {
let toAnimate = this._grid.actor.connect('notify::allocation', Lang.bind(this,
function() {
@ -225,14 +233,6 @@ const BaseAppView = new Lang.Class({
} else {
this._doSpringAnimation(animationDirection);
}
if (onComplete) {
let animationDoneId = this._grid.connect('animation-done', Lang.bind(this,
function () {
this._grid.disconnect(animationDoneId);
onComplete();
}));
}
},
animateSwitch: function(animationDirection) {