Disable the login button when there is no input
You can't login until something has been entered in the password field. We should therefore make the login button insensitive until you have entered some text. https://bugzilla.gnome.org/show_bug.cgi?id=687112
This commit is contained in:
parent
a508bece36
commit
ae0821e07b
@ -731,6 +731,7 @@ const LoginDialog = new Lang.Class({
|
|||||||
x_align: St.Align.START });
|
x_align: St.Align.START });
|
||||||
this._promptEntry = new St.Entry({ style_class: 'login-dialog-prompt-entry',
|
this._promptEntry = new St.Entry({ style_class: 'login-dialog-prompt-entry',
|
||||||
can_focus: true });
|
can_focus: true });
|
||||||
|
this._promptEntryTextChangedId = 0;
|
||||||
this._promptBox.add(this._promptEntry,
|
this._promptBox.add(this._promptEntry,
|
||||||
{ expand: true,
|
{ expand: true,
|
||||||
x_fill: true,
|
x_fill: true,
|
||||||
@ -901,21 +902,31 @@ const LoginDialog = new Lang.Class({
|
|||||||
_showPrompt: function() {
|
_showPrompt: function() {
|
||||||
let hold = new Batch.Hold();
|
let hold = new Batch.Hold();
|
||||||
|
|
||||||
let buttons = [{ action: Lang.bind(this, this.cancel),
|
let cancelButtonInfo = { action: Lang.bind(this, this.cancel),
|
||||||
label: _("Cancel"),
|
label: _("Cancel"),
|
||||||
key: Clutter.Escape },
|
key: Clutter.Escape };
|
||||||
{ action: Lang.bind(this, function() {
|
let okButtonInfo = { action: Lang.bind(this, function() {
|
||||||
hold.release();
|
hold.release();
|
||||||
}),
|
}),
|
||||||
label: C_("button", "Sign In"),
|
label: C_("button", "Sign In"),
|
||||||
default: true }];
|
default: true };
|
||||||
|
|
||||||
let tasks = [function() {
|
let tasks = [function() {
|
||||||
return this._fadeInPrompt();
|
return this._fadeInPrompt();
|
||||||
},
|
},
|
||||||
|
|
||||||
function() {
|
function() {
|
||||||
this.setButtons(buttons);
|
this.setButtons([cancelButtonInfo, okButtonInfo]);
|
||||||
|
|
||||||
|
let updateOkButtonEnabled = Lang.bind(this, function() {
|
||||||
|
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', updateOkButtonEnabled);
|
||||||
},
|
},
|
||||||
|
|
||||||
hold];
|
hold];
|
||||||
@ -928,6 +939,11 @@ const LoginDialog = new Lang.Class({
|
|||||||
_hidePrompt: function() {
|
_hidePrompt: function() {
|
||||||
this.setButtons([]);
|
this.setButtons([]);
|
||||||
|
|
||||||
|
if (this._promptEntryTextChangedId > 0) {
|
||||||
|
this._promptEntry.clutter_text.disconnect(this._promptEntryTextChangedId);
|
||||||
|
this._promptEntryTextChangedId = 0;
|
||||||
|
}
|
||||||
|
|
||||||
let tasks = [function() {
|
let tasks = [function() {
|
||||||
return GdmUtil.fadeOutActor(this._promptBox);
|
return GdmUtil.fadeOutActor(this._promptBox);
|
||||||
},
|
},
|
||||||
|
@ -151,6 +151,9 @@ const UnlockDialog = new Lang.Class({
|
|||||||
ShellEntry.addContextMenu(this._promptEntry, { isPassword: true });
|
ShellEntry.addContextMenu(this._promptEntry, { isPassword: true });
|
||||||
this.setInitialKeyFocus(this._promptEntry);
|
this.setInitialKeyFocus(this._promptEntry);
|
||||||
this._promptEntry.clutter_text.connect('activate', Lang.bind(this, this._doUnlock));
|
this._promptEntry.clutter_text.connect('activate', Lang.bind(this, this._doUnlock));
|
||||||
|
this._promptEntry.clutter_text.connect('text-changed', Lang.bind(this, function() {
|
||||||
|
this._updateOkButtonSensitivity(this._promptEntry.text.length > 0);
|
||||||
|
}));
|
||||||
|
|
||||||
this._promptLayout.add(this._promptEntry,
|
this._promptLayout.add(this._promptEntry,
|
||||||
{ expand: true,
|
{ expand: true,
|
||||||
@ -203,6 +206,10 @@ const UnlockDialog = new Lang.Class({
|
|||||||
_updateSensitivity: function(sensitive) {
|
_updateSensitivity: function(sensitive) {
|
||||||
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);
|
||||||
|
},
|
||||||
|
|
||||||
|
_updateOkButtonSensitivity: function(sensitive) {
|
||||||
this._okButton.button.reactive = sensitive;
|
this._okButton.button.reactive = sensitive;
|
||||||
this._okButton.button.can_focus = sensitive;
|
this._okButton.button.can_focus = sensitive;
|
||||||
},
|
},
|
||||||
|
Loading…
Reference in New Issue
Block a user