diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-27 15:07:22 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-27 15:07:22 +0000 |
commit | f9d480cfe50ca1d7a0f0b5a2b8bb9932962bfbe7 (patch) | |
tree | ce9e8db2d4e8799780fa72ae8f1953039373e2ee /js/ui/kbdA11yDialog.js | |
parent | Initial commit. (diff) | |
download | gnome-shell-f9d480cfe50ca1d7a0f0b5a2b8bb9932962bfbe7.tar.xz gnome-shell-f9d480cfe50ca1d7a0f0b5a2b8bb9932962bfbe7.zip |
Adding upstream version 3.38.6.upstream/3.38.6upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'js/ui/kbdA11yDialog.js')
-rw-r--r-- | js/ui/kbdA11yDialog.js | 73 |
1 files changed, 73 insertions, 0 deletions
diff --git a/js/ui/kbdA11yDialog.js b/js/ui/kbdA11yDialog.js new file mode 100644 index 0000000..3cf56b1 --- /dev/null +++ b/js/ui/kbdA11yDialog.js @@ -0,0 +1,73 @@ +/* exported KbdA11yDialog */ +const { Clutter, Gio, GObject } = imports.gi; + +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'; + +var KbdA11yDialog = GObject.registerClass( +class KbdA11yDialog extends GObject.Object { + _init() { + super._init(); + + this._a11ySettings = new Gio.Settings({ schema_id: KEYBOARD_A11Y_SCHEMA }); + + let seat = Clutter.get_default_backend().get_default_seat(); + seat.connect('kbd-a11y-flags-changed', + this._showKbdA11yDialog.bind(this)); + } + + _showKbdA11yDialog(seat, newFlags, whatChanged) { + let dialog = new ModalDialog.ModalDialog(); + let title, description; + let key, enabled; + + if (whatChanged & Clutter.KeyboardA11yFlags.SLOW_KEYS_ENABLED) { + key = KEY_SLOW_KEYS_ENABLED; + enabled = (newFlags & Clutter.KeyboardA11yFlags.SLOW_KEYS_ENABLED) > 0; + title = enabled + ? _("Slow Keys Turned On") + : _("Slow Keys Turned Off"); + description = _('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; + enabled = (newFlags & Clutter.KeyboardA11yFlags.STICKY_KEYS_ENABLED) > 0; + title = enabled + ? _("Sticky Keys Turned On") + : _("Sticky Keys Turned Off"); + description = 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."); + } else { + return; + } + + let content = new Dialog.MessageDialogContent({ title, description }); + dialog.contentLayout.add_child(content); + + dialog.addButton({ label: enabled ? _("Leave On") : _("Turn On"), + action: () => { + this._a11ySettings.set_boolean(key, true); + dialog.close(); + }, + default: enabled, + key: !enabled ? Clutter.KEY_Escape : null }); + + dialog.addButton({ label: enabled ? _("Turn Off") : _("Leave Off"), + action: () => { + this._a11ySettings.set_boolean(key, false); + dialog.close(); + }, + default: !enabled, + key: enabled ? Clutter.KEY_Escape : null }); + + dialog.open(); + } +}); |