ui: Add keyboard accessibility dialog
Show a dialog informing the user each time the keyboard accessibility flags are changed by one of the clutter backends (either from toggle keys or two-keys-off modifiers). https://bugzilla.gnome.org/show_bug.cgi?id=788564
This commit is contained in:
parent
f91fbd7728
commit
bc5be10d78
@ -61,6 +61,7 @@
|
||||
<file>ui/ibusCandidatePopup.js</file>
|
||||
<file>ui/iconGrid.js</file>
|
||||
<file>ui/inhibitShortcutsDialog.js</file>
|
||||
<file>ui/kbdA11yDialog.js</file>
|
||||
<file>ui/keyboard.js</file>
|
||||
<file>ui/layout.js</file>
|
||||
<file>ui/lightbox.js</file>
|
||||
|
77
js/ui/kbdA11yDialog.js
Normal file
77
js/ui/kbdA11yDialog.js
Normal file
@ -0,0 +1,77 @@
|
||||
const Clutter = imports.gi.Clutter;
|
||||
const Gio = imports.gi.Gio;
|
||||
const GObject = imports.gi.GObject;
|
||||
const Lang = imports.lang;
|
||||
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 = new Lang.Class({
|
||||
Name: 'KbdA11yDialog',
|
||||
Extends: GObject.Object,
|
||||
|
||||
_init: function() {
|
||||
this._a11ySettings = new Gio.Settings({ schema_id: KEYBOARD_A11Y_SCHEMA });
|
||||
|
||||
let deviceManager = Clutter.DeviceManager.get_default();
|
||||
deviceManager.connect('kbd-a11y-flags-changed',
|
||||
Lang.bind(this, this._showKbdA11yDialog));
|
||||
},
|
||||
|
||||
_showKbdA11yDialog: function(deviceManager, newFlags, whatChanged) {
|
||||
let dialog = new ModalDialog.ModalDialog();
|
||||
let title, body;
|
||||
let key, enabled;
|
||||
|
||||
if (whatChanged & Clutter.KeyboardA11yFlags.SLOW_KEYS_ENABLED) {
|
||||
key = KEY_SLOW_KEYS_ENABLED;
|
||||
enabled = (newFlags & Clutter.KeyboardA11yFlags.SLOW_KEYS_ENABLED) ? true : false;
|
||||
title = enabled ?
|
||||
_("Slow Keys Turned On") :
|
||||
_("Slow Keys Turned Off");
|
||||
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;
|
||||
enabled = (newFlags & Clutter.KeyboardA11yFlags.STICKY_KEYS_ENABLED) ? true : false;
|
||||
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.");
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
|
||||
let icon = new Gio.ThemedIcon({ name: 'preferences-desktop-accessibility-symbolic' });
|
||||
let contentParams = { icon, title, body, styleClass: 'access-dialog' };
|
||||
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,
|
||||
key: !enabled ? Clutter.Escape : null });
|
||||
|
||||
dialog.addButton({ label: enabled ? _("Turn Off") : _("Leave Off"),
|
||||
action: () => {
|
||||
this._a11ySettings.set_boolean(key, false);
|
||||
dialog.close();
|
||||
},
|
||||
default: !enabled,
|
||||
key: enabled ? Clutter.Escape : null });
|
||||
|
||||
dialog.open();
|
||||
}
|
||||
});
|
@ -44,6 +44,7 @@ const WindowManager = imports.ui.windowManager;
|
||||
const Magnifier = imports.ui.magnifier;
|
||||
const XdndHandler = imports.ui.xdndHandler;
|
||||
const Util = imports.misc.util;
|
||||
const KbdA11yDialog = imports.ui.kbdA11yDialog;
|
||||
|
||||
const A11Y_SCHEMA = 'org.gnome.desktop.a11y.keyboard';
|
||||
const STICKY_KEYS_ENABLE = 'stickykeys-enable';
|
||||
@ -78,6 +79,7 @@ var magnifier = null;
|
||||
var xdndHandler = null;
|
||||
var keyboard = null;
|
||||
var layoutManager = null;
|
||||
var kbdA11yDialog = null;
|
||||
let _startDate;
|
||||
let _defaultCssStylesheet = null;
|
||||
let _cssStylesheet = null;
|
||||
@ -163,6 +165,7 @@ function _initializeUI() {
|
||||
osdWindowManager = new OsdWindow.OsdWindowManager();
|
||||
osdMonitorLabeler = new OsdMonitorLabeler.OsdMonitorLabeler();
|
||||
overview = new Overview.Overview();
|
||||
kbdA11yDialog = new KbdA11yDialog.KbdA11yDialog();
|
||||
wm = new WindowManager.WindowManager();
|
||||
magnifier = new Magnifier.Magnifier();
|
||||
if (LoginManager.canLock())
|
||||
|
@ -32,6 +32,7 @@ js/ui/endSessionDialog.js
|
||||
js/ui/extensionDownloader.js
|
||||
js/ui/extensionSystem.js
|
||||
js/ui/inhibitShortcutsDialog.js
|
||||
js/ui/kbdA11yDialog.js
|
||||
js/ui/keyboard.js
|
||||
js/ui/lookingGlass.js
|
||||
js/ui/main.js
|
||||
|
Loading…
Reference in New Issue
Block a user