[gnome-shell/wip/carlosg/osk-updates: 52/77] keyboard: Handle GNOME_SHELL_TEST_OSK_FILE environment variable
- From: Carlos Garnacho <carlosg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-shell/wip/carlosg/osk-updates: 52/77] keyboard: Handle GNOME_SHELL_TEST_OSK_FILE environment variable
- Date: Thu, 2 Jun 2022 13:40:01 +0000 (UTC)
commit f4537c41da3c77e99d9eb6e3b39cad4bb2163f25
Author: Carlos Garnacho <carlosg gnome org>
Date: Wed Apr 13 15:56:42 2022 +0200
keyboard: Handle GNOME_SHELL_TEST_OSK_FILE environment variable
This will be used to clobber the OSK model with the one defined by
the file given in that environment variable.
js/ui/keyboard.js | 18 ++++++++++++++----
1 file changed, 14 insertions(+), 4 deletions(-)
---
diff --git a/js/ui/keyboard.js b/js/ui/keyboard.js
index 88dbb8be9c..f04c7d9ebb 100644
--- a/js/ui/keyboard.js
+++ b/js/ui/keyboard.js
@@ -534,6 +534,13 @@ var Key = GObject.registerClass({
var KeyboardModel = class {
constructor(groupName) {
+ const testFile = GLib.getenv('GNOME_SHELL_TEST_OSK_FILE');
+ if (testFile !== null) {
+ const file = Gio.File.new_for_path(testFile);
+ this._model = this._loadModelFile(file);
+ return;
+ }
+
let names = [groupName];
if (groupName.includes('+'))
names.push(groupName.replace(/\+.*/, ''));
@@ -548,15 +555,18 @@ var KeyboardModel = class {
}
}
- _loadModel(groupName) {
- const file = Gio.File.new_for_uri(
- `resource:///org/gnome/shell/osk-layouts/${groupName}.json`);
+ _loadModelFile(file) {
let [success_, contents] = file.load_contents(null);
-
const decoder = new TextDecoder();
return JSON.parse(decoder.decode(contents));
}
+ _loadModel(groupName) {
+ const file = Gio.File.new_for_uri(
+ `resource:///org/gnome/shell/osk-layouts/${groupName}.json`);
+ return this._loadModelFile(file);
+ }
+
getLevels() {
return this._model.levels;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]