[gnome-shell/wip/gdm-shell: 6/6] wip: switch over to using batch object
- From: Ray Strode <halfline src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-shell/wip/gdm-shell: 6/6] wip: switch over to using batch object
- Date: Thu, 30 Jun 2011 02:06:01 +0000 (UTC)
commit 1a74316a8edcbcfb4cad4978d2baf2a25559e620
Author: Ray Strode <rstrode redhat com>
Date: Wed Jun 29 22:04:21 2011 -0400
wip: switch over to using batch object
js/ui/loginDialog.js | 140 +++++++++++++++++++++++++++++++++++++++++---------
1 files changed, 115 insertions(+), 25 deletions(-)
---
diff --git a/js/ui/loginDialog.js b/js/ui/loginDialog.js
index e0df9ba..4b40c04 100644
--- a/js/ui/loginDialog.js
+++ b/js/ui/loginDialog.js
@@ -37,6 +37,7 @@ const Shell = imports.gi.Shell;
const GdmGreeter = imports.gi.GdmGreeter;
const AccountsService = imports.gi.AccountsService;
+const Batch = imports.misc.batch;
const Dialog = imports.ui.dialog;
const Lightbox = imports.ui.lightbox;
const Main = imports.ui.main;
@@ -44,9 +45,49 @@ const ModalDialog = imports.ui.modalDialog;
const Tweener = imports.ui.tweener;
const _DIALOG_ICON_SIZE = 64;
+const _ANIMATION_TIME = 0.16;
let _loginDialog = null;
+function _fadeInActor(actor) {
+ let hold = new Batch.Hold();
+
+ if (actor.opacity == 255 && actor.visible)
+ return;
+
+ actor.opacity = 0;
+ actor.show();
+ Tweener.addTween(actor,
+ { opacity: 255,
+ time: _ANIMATION_TIME,
+ transition: 'easeOutQuad',
+ onComplete: function() {
+ hold.release();
+ },
+ onCompleteScope: this
+ });
+ return hold;
+}
+
+function _fadeOutActor(actor) {
+ let hold = new Batch.Hold();
+
+ if (actor.opacity == 0 || !actor.visible)
+ return;
+
+ Tweener.addTween(actor,
+ { opacity: 0,
+ time: _ANIMATION_TIME,
+ transition: 'easeOutQuad',
+ onComplete: function() {
+ actor.hide();
+ hold.release();
+ },
+ onCompleteScope: this
+ });
+ return hold;
+}
+
function ListItem(user, reason) {
this._init(user, reason);
}
@@ -159,17 +200,21 @@ UserList.prototype = {
this._items = {};
},
- _hideItem: function(item) {
- item.actor.hide();
- },
-
_showItem: function(item) {
- item.actor.show();
- item._nameLabel.show();
+ let tasks = [Lang.bind(this, function() {
+ _fadeInActor(item._nameLabel)
+ }),
+
+ Lang.bind(this, function() {
+ _fadeInActor(item.actor);
+ })];
+
+ let batch = new Batch.ConcurrentBatch(tasks);
+ return batch.run();
},
_shrinkItem: function(item) {
- item._nameLabel.hide();
+ return _fadeOutActor(item._nameLabel);
},
_growItem: function(item) {
@@ -177,22 +222,32 @@ UserList.prototype = {
},
_onItemActivated: function(activatedItem) {
+ this.emit('activate', activatedItem);
+ },
+
+ shrinkToItem: function(activatedItem) {
this.actor.set_policy(Gtk.PolicyType.NEVER,
Gtk.PolicyType.NEVER);
+ let tasks = [];
for (userName in this._items) {
let item = this._items[userName];
if (item != activatedItem) {
- this._hideItem(item);
+ tasks.push(Lang.bind(this, function() {
+ _fadeOutActor(item.actor);
+ }));
} else {
- this._shrinkItem(item);
+ tasks.push(Lang.bind(this, function() {
+ this._shrinkItem(item);
+ }));
}
}
- this.emit('activate', activatedItem);
+ let batch = new Batch.ConcurrentBatch(tasks);
+ return batch.run();
},
- hideAllUsers: function() {
+ hideAllItems: function() {
this.actor.set_policy(Gtk.PolicyType.NEVER,
Gtk.PolicyType.NEVER);
@@ -202,14 +257,22 @@ UserList.prototype = {
}
},
- showAllUsers: function() {
+ showAllItems: function() {
+ let tasks = [];
+
for (userName in this._items) {
let item = this._items[userName];
- this._showItem(item);
+ tasks.push(Lang.bind(this, function() {
+ this._showItem(item);
+ }));
}
- this.actor.set_policy(Gtk.PolicyType.NEVER,
- Gtk.PolicyType.AUTOMATIC);
+ let batch = new Batch.ConsecutiveBatch([new Batch.ConcurrentBatch(tasks),
+ Lang.bind(this, function() {
+ this.actor.set_policy(Gtk.PolicyType.NEVER,
+ Gtk.PolicyType.AUTOMATIC);
+ })]);
+ batch.run();
},
addUser: function(user) {
@@ -371,8 +434,8 @@ LoginDialog.prototype = {
}
this._userList.connect('activate',
- Lang.bind(this, function(userList, user) {
- this._onUserListActivated(user);
+ Lang.bind(this, function(userList, item) {
+ this._onUserListActivated(item);
}));
},
@@ -395,11 +458,11 @@ LoginDialog.prototype = {
this._promptLabel.hide();
this._promptLayout.hide();
- this._userList.showAllUsers();
+ this._userList.showAllItems();
this._userList.actor.grab_key_focus();
- this._notListedButton.show();
- this._titleLabel.show();
+ this._fadeInNotListedButton();
+ this._fadeInTitleLabel();
},
_onInfo: function(client, serviceName, info) {
@@ -483,15 +546,42 @@ LoginDialog.prototype = {
_onNotListedClicked: function(user) {
this._titleLabel.hide();
this._notListedButton.hide();
- this._userList.hideAllUsers();
+ this._userList.hideAllItems();
this._greeterClient.call_begin_verification('gdm-password');
},
+ _fadeInTitleLabel: function() {
+ return _fadeInActor(this._titleLabel);
+ },
+
+ _fadeOutTitleLabel: function() {
+ return _fadeOutActor(this._titleLabel);
+ },
+
+ _fadeInNotListedButton: function() {
+ return _fadeInActor(this._notListedButton);
+ },
+
+ _fadeOutNotListedButton: function() {
+ return _fadeOutActor(this._notListedButton);
+ },
+
_onUserListActivated: function(item) {
- this._titleLabel.hide();
- this._notListedButton.hide();
- this._greeterClient.call_begin_verification_for_user('gdm-password',
- item.user.get_user_name());
+ let tasks = [new Batch.ConcurrentBatch([Lang.bind(this, this._fadeOutTitleLabel),
+ Lang.bind(this, this._fadeOutNotListedButton)]),
+
+ Lang.bind(this, function() {
+ this._userList.shrinkToItem(item);
+ }),
+
+ Lang.bind(this, function() {
+ let userName = item.user.get_user_name();
+ this._greeterClient.call_begin_verification_for_user('gdm-password',
+ userName);
+ })];
+
+ let batch = new Batch.ConsecutiveBatch(tasks);
+ batch.run();
},
_onDestroy: function() {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]