2019-01-31 14:07:06 +00:00
|
|
|
/* exported KbdA11yDialog */
|
2019-02-09 03:21:36 +00:00
|
|
|
const { Clutter, Gio, GObject } = imports.gi;
|
|
|
|
|
2017-11-07 14:40:51 +00:00
|
|
|
const Dialog = imports.ui.dialog;
|
|
|
|
const ModalDialog = imports.ui.modalDialog;
|
|
|
|
|
|
|
|
const KEYBOARD_A11Y_SCHEMA = 'org.gnome.desktop.a11y.keyboard';
|
|
|
|
const KEY_STICKY_KEYS_ENABLED = 'stickykeys-enable';
|
|
|
|
const KEY_SLOW_KEYS_ENABLED = 'slowkeys-enable';
|
|
|
|
|
2019-01-31 19:38:24 +00:00
|
|
|
var KbdA11yDialog = GObject.registerClass(
|
2017-10-31 01:23:39 +00:00
|
|
|
class KbdA11yDialog extends GObject.Object {
|
2017-10-31 00:03:21 +00:00
|
|
|
_init() {
|
2017-10-31 01:23:39 +00:00
|
|
|
super._init();
|
|
|
|
|
2017-11-07 14:40:51 +00:00
|
|
|
this._a11ySettings = new Gio.Settings({ schema_id: KEYBOARD_A11Y_SCHEMA });
|
|
|
|
|
|
|
|
let deviceManager = Clutter.DeviceManager.get_default();
|
|
|
|
deviceManager.connect('kbd-a11y-flags-changed',
|
2017-12-02 00:27:35 +00:00
|
|
|
this._showKbdA11yDialog.bind(this));
|
2017-10-31 01:23:39 +00:00
|
|
|
}
|
2017-11-07 14:40:51 +00:00
|
|
|
|
2017-10-31 00:03:21 +00:00
|
|
|
_showKbdA11yDialog(deviceManager, newFlags, whatChanged) {
|
2017-11-07 14:40:51 +00:00
|
|
|
let dialog = new ModalDialog.ModalDialog();
|
|
|
|
let title, body;
|
|
|
|
let key, enabled;
|
|
|
|
|
|
|
|
if (whatChanged & Clutter.KeyboardA11yFlags.SLOW_KEYS_ENABLED) {
|
|
|
|
key = KEY_SLOW_KEYS_ENABLED;
|
2019-08-19 19:22:20 +00:00
|
|
|
enabled = (newFlags & Clutter.KeyboardA11yFlags.SLOW_KEYS_ENABLED) > 0;
|
2019-09-12 22:27:56 +00:00
|
|
|
title = enabled
|
|
|
|
? _("Slow Keys Turned On")
|
|
|
|
: _("Slow Keys Turned Off");
|
2017-11-07 14:40:51 +00:00
|
|
|
body = _("You just held down the Shift key for 8 seconds. This is the shortcut " +
|
|
|
|
"for the Slow Keys feature, which affects the way your keyboard works.");
|
|
|
|
|
|
|
|
} else if (whatChanged & Clutter.KeyboardA11yFlags.STICKY_KEYS_ENABLED) {
|
|
|
|
key = KEY_STICKY_KEYS_ENABLED;
|
2019-08-19 19:22:20 +00:00
|
|
|
enabled = (newFlags & Clutter.KeyboardA11yFlags.STICKY_KEYS_ENABLED) > 0;
|
2019-09-12 22:27:56 +00:00
|
|
|
title = enabled
|
|
|
|
? _("Sticky Keys Turned On")
|
|
|
|
: _("Sticky Keys Turned Off");
|
|
|
|
body = enabled
|
|
|
|
? _("You just pressed the Shift key 5 times in a row. This is the shortcut " +
|
|
|
|
"for the Sticky Keys feature, which affects the way your keyboard works.")
|
|
|
|
: _("You just pressed two keys at once, or pressed the Shift key 5 times in a row. " +
|
|
|
|
"This turns off the Sticky Keys feature, which affects the way your keyboard works.");
|
2017-11-07 14:40:51 +00:00
|
|
|
} else {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2020-01-13 12:39:41 +00:00
|
|
|
let contentParams = { title, body, styleClass: 'access-dialog' };
|
2017-11-07 14:40:51 +00:00
|
|
|
let content = new Dialog.MessageDialogContent(contentParams);
|
|
|
|
|
|
|
|
dialog.contentLayout.add_actor(content);
|
|
|
|
|
|
|
|
dialog.addButton({ label: enabled ? _("Leave On") : _("Turn On"),
|
|
|
|
action: () => {
|
|
|
|
this._a11ySettings.set_boolean(key, true);
|
|
|
|
dialog.close();
|
|
|
|
},
|
|
|
|
default: enabled,
|
2019-11-05 19:37:28 +00:00
|
|
|
key: !enabled ? Clutter.KEY_Escape : null });
|
2017-11-07 14:40:51 +00:00
|
|
|
|
|
|
|
dialog.addButton({ label: enabled ? _("Turn Off") : _("Leave Off"),
|
|
|
|
action: () => {
|
|
|
|
this._a11ySettings.set_boolean(key, false);
|
|
|
|
dialog.close();
|
|
|
|
},
|
|
|
|
default: !enabled,
|
2019-11-05 19:37:28 +00:00
|
|
|
key: enabled ? Clutter.KEY_Escape : null });
|
2017-11-07 14:40:51 +00:00
|
|
|
|
|
|
|
dialog.open();
|
|
|
|
}
|
|
|
|
});
|