[gnome-shell/wip/carlosg/osk-updates: 10/33] keyboard: Handle GNOME_SHELL_TEST_OSK_FILE environment variable




commit 97ea9422cb5ab67d37016f1be8e759019a50c070
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 5ed47bb699..4d4d1a8235 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]