[gnome-shell] ui: Add keyboard accessibility dialog
- From: Olivier Fourdan <ofourdan src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-shell] ui: Add keyboard accessibility dialog
- Date: Thu, 11 Jan 2018 08:17:18 +0000 (UTC)
commit bc5be10d781daf27b813f7a9fde9e5df87d3d8da
Author: Olivier Fourdan <ofourdan redhat com>
Date: Tue Nov 7 15:40:51 2017 +0100
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
js/js-resources.gresource.xml | 1 +
js/ui/kbdA11yDialog.js | 77 +++++++++++++++++++++++++++++++++++++++++
js/ui/main.js | 3 ++
po/POTFILES.in | 1 +
4 files changed, 82 insertions(+), 0 deletions(-)
---
diff --git a/js/js-resources.gresource.xml b/js/js-resources.gresource.xml
index 7a5c8ca..ba0d2f4 100644
--- a/js/js-resources.gresource.xml
+++ b/js/js-resources.gresource.xml
@@ -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>
diff --git a/js/ui/kbdA11yDialog.js b/js/ui/kbdA11yDialog.js
new file mode 100644
index 0000000..995cc76
--- /dev/null
+++ b/js/ui/kbdA11yDialog.js
@@ -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();
+ }
+});
diff --git a/js/ui/main.js b/js/ui/main.js
index e981db9..d581fd4 100644
--- a/js/ui/main.js
+++ b/js/ui/main.js
@@ -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())
diff --git a/po/POTFILES.in b/po/POTFILES.in
index 03ff3a5..e65dc2f 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -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
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]