[gnome-shell] polkitAgent: Make authenticate button insensitive if password is empty
- From: Florian Müllner <fmuellner src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-shell] polkitAgent: Make authenticate button insensitive if password is empty
- Date: Tue, 5 Nov 2019 18:03:50 +0000 (UTC)
commit cd36301d2bfd0c68fbe790e73ff3e80b1cc7af6d
Author: Jonas Dreßler <verdre v0yd nl>
Date: Mon Jun 24 12:36:47 2019 +0200
polkitAgent: Make authenticate button insensitive if password is empty
According to the mockups, make the polkit dialogs "Authenticate" button
insensitive and don't respond to pressing the enter key if no password
is supplied.
https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/788
js/ui/components/polkitAgent.js | 33 +++++++++++++++++++++------------
1 file changed, 21 insertions(+), 12 deletions(-)
---
diff --git a/js/ui/components/polkitAgent.js b/js/ui/components/polkitAgent.js
index 2393eff3e4..e304c2a463 100644
--- a/js/ui/components/polkitAgent.js
+++ b/js/ui/components/polkitAgent.js
@@ -98,6 +98,9 @@ var AuthenticationDialog = GObject.registerClass({
});
ShellEntry.addContextMenu(this._passwordEntry, { isPassword: true });
this._passwordEntry.clutter_text.connect('activate', this._onEntryActivate.bind(this));
+ this._passwordEntry.bind_property('reactive',
+ this._passwordEntry.clutter_text, 'editable',
+ GObject.BindingFlags.SYNC_CREATE);
this._passwordBox.add_child(this._passwordEntry);
this._workSpinner = new Animation.Spinner(WORK_SPINNER_ICON_SIZE, true);
@@ -134,7 +137,14 @@ var AuthenticationDialog = GObject.registerClass({
key: Clutter.Escape });
this._okButton = this.addButton({ label: _("Authenticate"),
action: this._onAuthenticateButtonPressed.bind(this),
- default: true });
+ reactive: false });
+ this._okButton.bind_property('reactive',
+ this._okButton, 'can-focus',
+ GObject.BindingFlags.SYNC_CREATE);
+
+ this._passwordEntry.clutter_text.connect('text-changed', text => {
+ this._okButton.reactive = text.get_text().length > 0;
+ });
this._doneEmitted = false;
@@ -189,18 +199,15 @@ var AuthenticationDialog = GObject.registerClass({
}
}
- _updateSensitivity(sensitive) {
- this._passwordEntry.reactive = sensitive;
- this._passwordEntry.clutter_text.editable = sensitive;
-
- this._okButton.can_focus = sensitive;
- this._okButton.reactive = sensitive;
- this._setWorking(!sensitive);
- }
-
_onEntryActivate() {
let response = this._passwordEntry.get_text();
- this._updateSensitivity(false);
+ if (response.length === 0)
+ return;
+
+ this._passwordEntry.reactive = false;
+ this._okButton.reactive = false;
+ this._setWorking(true);
+
this._session.response(response);
// When the user responds, dismiss already shown info and
// error texts (if any)
@@ -259,7 +266,9 @@ var AuthenticationDialog = GObject.registerClass({
this._passwordBox.show();
this._passwordEntry.set_text('');
- this._updateSensitivity(true);
+ this._passwordEntry.reactive = true;
+ this._okButton.reactive = false;
+ this._setWorking(false);
this._ensureOpen();
this._passwordEntry.grab_key_focus();
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]