Login: sensitivity fixes

The login dialog had these issues:
  - the entry was not really disabled, you could still edit text
  - the sensitivity state was not reset on verification failure
  - the session list was not disabled

The unlock dialog had these issues:
  - "Login as another user..." was not insensitive
  - redundant password char setting, overwriting the one given by the
    question

The entry insensitive style was also wrong.

https://bugzilla.gnome.org/show_bug.cgi?id=687113
This commit is contained in:
Stéphane Démurget 2012-11-18 22:36:17 +01:00
parent 4c55a6f436
commit c3cab28c9b
3 changed files with 57 additions and 21 deletions

View File

@ -405,11 +405,13 @@ StScrollBar StButton#vhandle:active {
padding: 0 4px; padding: 0 4px;
} }
.login-dialog-prompt-entry:insensitive { .modal-dialog StEntry:insensitive {
color: rgba(0,0,0,0.7); border-color: #666666;
border: 2px solid #565656; color: #9f9f9f;
background-gradient-start: rgb(200,200,200); border: 2px solid #9f9f9f;
background-gradient-end: rgb(210,210,210); background-gradient-direction: none;
background-color: rgba(102, 102, 102, 0.15);
box-shadow: inset 0 0 rgba(0,0,0,1.0);
} }
/* Panel */ /* Panel */

View File

@ -604,6 +604,14 @@ const SessionList = new Lang.Class({
this.close(); this.close();
}, },
updateSensitivity: function(sensitive) {
this._button.reactive = sensitive;
this._button.can_focus = sensitive;
for (let id in this._items)
this._items[id].actor.reactive = sensitive;
},
setActiveSession: function(sessionId) { setActiveSession: function(sessionId) {
if (sessionId == this._activeSessionId) if (sessionId == this._activeSessionId)
return; return;
@ -685,6 +693,7 @@ const LoginDialog = new Lang.Class({
this._userVerifier = new GdmUtil.ShellUserVerifier(this._greeterClient); this._userVerifier = new GdmUtil.ShellUserVerifier(this._greeterClient);
this._userVerifier.connect('ask-question', Lang.bind(this, this._askQuestion)); this._userVerifier.connect('ask-question', Lang.bind(this, this._askQuestion));
this._userVerifier.connect('show-message', Lang.bind(this, this._showMessage)); this._userVerifier.connect('show-message', Lang.bind(this, this._showMessage));
this._userVerifier.connect('verification-failed', Lang.bind(this, this._verificationFailed));
this._userVerifier.connect('reset', Lang.bind(this, this._reset)); this._userVerifier.connect('reset', Lang.bind(this, this._reset));
this._userVerifier.connect('show-login-hint', Lang.bind(this, this._showLoginHint)); this._userVerifier.connect('show-login-hint', Lang.bind(this, this._showLoginHint));
this._userVerifier.connect('hide-login-hint', Lang.bind(this, this._hideLoginHint)); this._userVerifier.connect('hide-login-hint', Lang.bind(this, this._hideLoginHint));
@ -750,6 +759,8 @@ const LoginDialog = new Lang.Class({
this._promptLoginHint.hide(); this._promptLoginHint.hide();
this._promptBox.add(this._promptLoginHint); this._promptBox.add(this._promptLoginHint);
this._signInButton = null;
this._sessionList = new SessionList(); this._sessionList = new SessionList();
this._sessionList.connect('session-activated', this._sessionList.connect('session-activated',
Lang.bind(this, function(list, sessionId) { Lang.bind(this, function(list, sessionId) {
@ -829,6 +840,7 @@ const LoginDialog = new Lang.Class({
}, },
_reset: function() { _reset: function() {
this._updateSensitivity(true);
this._promptMessage.hide(); this._promptMessage.hide();
this._user = null; this._user = null;
this._verifyingUser = false; this._verifyingUser = false;
@ -839,6 +851,12 @@ const LoginDialog = new Lang.Class({
this._showUserList(); this._showUserList();
}, },
_verificationFailed: function() {
this._promptEntry.text = '';
this._updateSensitivity(true);
},
_onDefaultSessionChanged: function(client, sessionId) { _onDefaultSessionChanged: function(client, sessionId) {
this._sessionList.setActiveSession(sessionId); this._sessionList.setActiveSession(sessionId);
}, },
@ -928,16 +946,15 @@ const LoginDialog = new Lang.Class({
function() { function() {
this.setButtons(buttons); this.setButtons(buttons);
this._signInButton = okButtonInfo.button;
let updateOkButtonEnabled = Lang.bind(this, function() { this._updateSignInButtonSensitivity(this._promptEntry.text.length > 0);
let sensitive = this._promptEntry.text.length > 0;
okButtonInfo.button.reactive = sensitive;
okButtonInfo.button.can_focus = sensitive;
});
updateOkButtonEnabled(); this._promptEntryTextChangedId =
this._promptEntry.clutter_text.connect('text-changed',
this._promptEntryTextChangedId = this._promptEntry.clutter_text.connect('text-changed', updateOkButtonEnabled); Lang.bind(this, function() {
this._updateSignInButtonSensitivity(this._promptEntry.text.length > 0);
}));
}, },
hold]; hold];
@ -947,6 +964,20 @@ const LoginDialog = new Lang.Class({
return batch.run(); return batch.run();
}, },
_updateSensitivity: function(sensitive) {
this._promptEntry.reactive = sensitive;
this._promptEntry.clutter_text.editable = sensitive;
this._sessionList.updateSensitivity(sensitive);
this._updateSignInButtonSensitivity(sensitive);
},
_updateSignInButtonSensitivity: function(sensitive) {
if (this._signInButton) {
this._signInButton.reactive = sensitive;
this._signInButton.can_focus = sensitive;
}
},
_hidePrompt: function() { _hidePrompt: function() {
this.setButtons([]); this.setButtons([]);
@ -961,8 +992,11 @@ const LoginDialog = new Lang.Class({
function() { function() {
this._promptLoginHint.hide(); this._promptLoginHint.hide();
this._promptEntry.reactive = true;
this._updateSensitivity(true);
this._promptEntry.set_text(''); this._promptEntry.set_text('');
this._signInButton = null;
}]; }];
let batch = new Batch.ConsecutiveBatch(this, tasks); let batch = new Batch.ConsecutiveBatch(this, tasks);
@ -981,9 +1015,9 @@ const LoginDialog = new Lang.Class({
}, },
function() { function() {
let _text = this._promptEntry.get_text(); let text = this._promptEntry.get_text();
this._promptEntry.reactive = false; this._updateSensitivity(false);
this._userVerifier.answerQuery(serviceName, _text); this._userVerifier.answerQuery(serviceName, text);
}]; }];
let batch = new Batch.ConsecutiveBatch(this, tasks); let batch = new Batch.ConsecutiveBatch(this, tasks);

View File

@ -176,8 +176,6 @@ const UnlockDialog = new Lang.Class({
default: true }; default: true };
this.setButtons([cancelButton, this._okButton]); this.setButtons([cancelButton, this._okButton]);
this._updateSensitivity(true);
let otherUserLabel = new St.Label({ text: _("Log in as another user"), let otherUserLabel = new St.Label({ text: _("Log in as another user"),
style_class: 'login-dialog-not-listed-label' }); style_class: 'login-dialog-not-listed-label' });
this._otherUserButton = new St.Button({ style_class: 'login-dialog-not-listed-button', this._otherUserButton = new St.Button({ style_class: 'login-dialog-not-listed-button',
@ -191,6 +189,8 @@ const UnlockDialog = new Lang.Class({
{ x_align: St.Align.START, { x_align: St.Align.START,
x_fill: false }); x_fill: false });
this._updateSensitivity(true);
let batch = new Batch.Hold(); let batch = new Batch.Hold();
this._userVerifier.begin(this._userName, batch); this._userVerifier.begin(this._userName, batch);
@ -209,6 +209,8 @@ const UnlockDialog = new Lang.Class({
this._promptEntry.reactive = sensitive; this._promptEntry.reactive = sensitive;
this._promptEntry.clutter_text.editable = sensitive; this._promptEntry.clutter_text.editable = sensitive;
this._updateOkButtonSensitivity(sensitive && this._promptEntry.text.length > 0); this._updateOkButtonSensitivity(sensitive && this._promptEntry.text.length > 0);
this._otherUserButton.reactive = sensitive;
this._otherUserButton.can_focus = sensitive;
}, },
_updateOkButtonSensitivity: function(sensitive) { _updateOkButtonSensitivity: function(sensitive) {
@ -292,8 +294,6 @@ const UnlockDialog = new Lang.Class({
this._firstQuestion = true; this._firstQuestion = true;
this._promptEntry.text = ''; this._promptEntry.text = '';
this._promptEntry.clutter_text.set_password_char('\u25cf');
this._promptEntry.menu.isPassword = true;
this._updateSensitivity(false); this._updateSensitivity(false);
}, },