js: Use StPasswordEntry for password entry fields

Use the new StPasswordEntry for password entry fields
and remove all direct handling of clutter text of the entry
 via clutter_text_set_password_char to show/hide the password
text. StPasswordEntry will provides a peek-password-icon which
will allow to show/hide the password present in the field to
the user in subsequent commits.

https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/619
This commit is contained in:
Umang Jain
2019-12-12 15:02:53 +05:30
committed by Florian Müllner
parent b166de08dc
commit 684b918915
8 changed files with 69 additions and 52 deletions

View File

@ -98,14 +98,23 @@ var AuthPrompt = GObject.registerClass({
});
this.add_child(this._label);
this._entry = new St.Entry({
let entryParams = {
style_class: 'login-dialog-prompt-entry',
can_focus: true,
x_expand: false,
y_expand: true,
});
ShellEntry.addContextMenu(this._entry, { isPassword: true, actionMode: Shell.ActionMode.NONE });
};
this._entry = null;
this._textEntry = new St.Entry(entryParams);
ShellEntry.addContextMenu(this._textEntry, { actionMode: Shell.ActionMode.NONE });
this._passwordEntry = new St.PasswordEntry(entryParams);
ShellEntry.addContextMenu(this._passwordEntry, { actionMode: Shell.ActionMode.NONE });
this._entry = this._passwordEntry;
this.add_child(this._entry);
this._entry.grab_key_focus();
@ -195,7 +204,17 @@ var AuthPrompt = GObject.registerClass({
});
}
_onAskQuestion(verifier, serviceName, question, passwordChar) {
_updateEntry(secret) {
if (secret && (this._entry != this._passwordEntry)) {
this.replace_child(this._entry, this._passwordEntry);
this._entry = this._passwordEntry;
} else if (!secret && (this._entry != this._textEntry)) {
this.replace_child(this._entry, this._textEntry);
this._entry = this._textEntry;
}
}
_onAskQuestion(verifier, serviceName, question, secret) {
if (this._queryingService)
this.clear();
@ -205,10 +224,11 @@ var AuthPrompt = GObject.registerClass({
this._preemptiveAnswer = null;
return;
}
this.setPasswordChar(passwordChar);
this._updateEntry(secret);
this.setQuestion(question);
if (passwordChar) {
if (secret) {
if (this._userVerifier.reauthenticating)
this.nextButton.label = _("Unlock");
else
@ -358,11 +378,6 @@ var AuthPrompt = GObject.registerClass({
this.stopSpinning();
}
setPasswordChar(passwordChar) {
this._entry.clutter_text.set_password_char(passwordChar);
this._entry.menu.isPassword = passwordChar != '';
}
setQuestion(question) {
this._label.set_text(question);