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




commit 9232bc5c89dd3243c898eac60848bd4384fc34ba
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 63cd40f6ce..d121fec689 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]