endSessionDialog: don't use Tweener for the timer

We want to make Tweener short-circuit animations when resources are
constrained, so this is not going to work.
Instead, use a one-second timeout until the seconds left reach zero.

https://bugzilla.gnome.org/show_bug.cgi?id=655746
This commit is contained in:
Cosimo Cecchi 2013-01-26 03:01:41 -05:00
parent ec6ee27f29
commit 1c57c0e651

View File

@ -19,6 +19,7 @@
*/ */
const Lang = imports.lang; const Lang = imports.lang;
const Mainloop = imports.mainloop;
const Signals = imports.signals; const Signals = imports.signals;
const AccountsService = imports.gi.AccountsService; const AccountsService = imports.gi.AccountsService;
@ -409,22 +410,34 @@ const EndSessionDialog = new Lang.Class({
}, },
_startTimer: function() { _startTimer: function() {
let startTime = GLib.get_monotonic_time();
this._secondsLeft = this._totalSecondsToStayOpen; this._secondsLeft = this._totalSecondsToStayOpen;
Tweener.addTween(this,
{ _secondsLeft: 0, this._timerId = Mainloop.timeout_add_seconds(1, Lang.bind(this,
time: this._secondsLeft, function() {
transition: 'linear', let currentTime = GLib.get_monotonic_time();
onUpdate: Lang.bind(this, this._updateDescription), let secondsElapsed = ((currentTime - startTime) / 1000000);
onComplete: Lang.bind(this, function() {
let dialogContent = DialogContent[this._type]; this._secondsLeft = this._totalSecondsToStayOpen - secondsElapsed;
let button = dialogContent.confirmButtons[dialogContent.confirmButtons.length - 1]; if (this._secondsLeft > 0) {
this._confirm(button.signal); this._updateDescription();
}), return true;
}); }
let dialogContent = DialogContent[this._type];
let button = dialogContent.confirmButtons[dialogContent.confirmButtons.length - 1];
this._confirm(button.signal);
return false;
}));
}, },
_stopTimer: function() { _stopTimer: function() {
Tweener.removeTweens(this); if (this._timerId != 0) {
Mainloop.source_remove(this._timerId);
this._timerId = 0;
}
this._secondsLeft = 0; this._secondsLeft = 0;
}, },