bluetooth: Enforce a PIN length of 6 digits
Bluetooth PINs are required to have 6 digits, so enforce that condition by making the PIN request notification's confirm button insensitive unless the entered PIN has the correct length. https://bugzilla.gnome.org/show_bug.cgi?id=651251
This commit is contained in:
parent
6190d6c962
commit
48d6eb168f
@ -416,6 +416,7 @@ const PinNotification = new Lang.Class({
|
|||||||
this._entry.connect('key-release-event', Lang.bind(this, function(entry, event) {
|
this._entry.connect('key-release-event', Lang.bind(this, function(entry, event) {
|
||||||
let key = event.get_key_symbol();
|
let key = event.get_key_symbol();
|
||||||
if (key == Clutter.KEY_Return) {
|
if (key == Clutter.KEY_Return) {
|
||||||
|
if (this._canActivateOkButton())
|
||||||
this.emit('action-invoked', 'ok');
|
this.emit('action-invoked', 'ok');
|
||||||
return true;
|
return true;
|
||||||
} else if (key == Clutter.KEY_Escape) {
|
} else if (key == Clutter.KEY_Escape) {
|
||||||
@ -429,6 +430,12 @@ const PinNotification = new Lang.Class({
|
|||||||
this.addButton('ok', _("OK"));
|
this.addButton('ok', _("OK"));
|
||||||
this.addButton('cancel', _("Cancel"));
|
this.addButton('cancel', _("Cancel"));
|
||||||
|
|
||||||
|
this.setButtonSensitive('ok', this._canActivateOkButton());
|
||||||
|
this._entry.clutter_text.connect('text-changed', Lang.bind(this,
|
||||||
|
function() {
|
||||||
|
this.setButtonSensitive('ok', this._canActivateOkButton());
|
||||||
|
}));
|
||||||
|
|
||||||
this.connect('action-invoked', Lang.bind(this, function(self, action) {
|
this.connect('action-invoked', Lang.bind(this, function(self, action) {
|
||||||
if (action == 'ok') {
|
if (action == 'ok') {
|
||||||
if (this._numeric) {
|
if (this._numeric) {
|
||||||
@ -451,6 +458,11 @@ const PinNotification = new Lang.Class({
|
|||||||
}));
|
}));
|
||||||
},
|
},
|
||||||
|
|
||||||
|
_canActivateOkButton: function() {
|
||||||
|
// PINs have a fixed length of 6
|
||||||
|
return this._entry.clutter_text.text.length == 6;
|
||||||
|
},
|
||||||
|
|
||||||
grabFocus: function(lockTray) {
|
grabFocus: function(lockTray) {
|
||||||
this.parent(lockTray);
|
this.parent(lockTray);
|
||||||
global.stage.set_key_focus(this._entry);
|
global.stage.set_key_focus(this._entry);
|
||||||
|
Loading…
Reference in New Issue
Block a user