[gnome-boxes/get-preferred-keyboard: 7/7] unattended-installer: Pass a better keyboard id to osinfo
- From: Felipe Borges <felipeborges src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-boxes/get-preferred-keyboard: 7/7] unattended-installer: Pass a better keyboard id to osinfo
- Date: Mon, 21 Jan 2019 09:21:54 +0000 (UTC)
commit 06bcf191bce59417f60b544024ba0f8ce6891b9c
Author: Felipe Borges <felipeborges gnome org>
Date: Tue Jan 15 17:53:05 2019 +0100
unattended-installer: Pass a better keyboard id to osinfo
We used to pass the same LANG identifier for both language and
keyboard.
These changes lookup into the user system's default input source
and uses it only if it is available in the osinfo-db keyboard
datamap. If not, we search the database for a keyboard that
matches the user's LANG. If none of these two cases work, we
just use the literal LANG string as before.
This should fix #240 and https://bugzilla.redhat.com/1666320
src/os-database.vala | 4 ++++
src/unattended-installer.vala | 22 +++++++++++++++++++++-
2 files changed, 25 insertions(+), 1 deletion(-)
---
diff --git a/src/os-database.vala b/src/os-database.vala
index e1c9dda6..3e5ffb57 100644
--- a/src/os-database.vala
+++ b/src/os-database.vala
@@ -199,6 +199,10 @@ public Resources get_resources_for_os (Os? os, string? architecture) {
return get_prefered_resources (list, prefs);
}
+ public Datamap? get_datamap (string id) {
+ return db.get_datamap (id);
+ }
+
private Resources get_resources_from_os_resources (Resources? minimum, Resources? recommended) {
var resources = get_default_resources ();
diff --git a/src/unattended-installer.vala b/src/unattended-installer.vala
index e3fd115b..7de5c622 100644
--- a/src/unattended-installer.vala
+++ b/src/unattended-installer.vala
@@ -108,7 +108,7 @@ private static string escape_mkisofs_path (string path) {
timezone = get_timezone ();
lang = get_preferred_language ();
- kbd = lang;
+ kbd = get_preferred_keyboard (lang);
var product_key_format = get_product_key_format ();
setup_box = new UnattendedSetupBox (this, product_key_format, needs_internet);
@@ -665,6 +665,26 @@ else if (compatibility == CPUArchCompatibility.COMPATIBLE && drivers.lookup (loc
return scripts;
}
+ private string get_preferred_keyboard (string lang) {
+ var input_settings = new GLib.Settings ("org.gnome.desktop.input-sources");
+ var sources = input_settings.get_value ("sources");
+
+ string kbd_layout = null;
+ if (sources != null)
+ kbd_layout = sources.get_child_value (0).get_child_value (1).get_string ();
+
+ var os_db = MediaManager.get_instance ().os_db;
+ var datamap = os_db.get_datamap ("http://x.org/x11-keyboard");
+
+ if (datamap.reverse_lookup (kbd_layout) != null)
+ return kbd_layout;
+
+ kbd_layout = datamap.lookup (lang);
+ if (kbd_layout != null)
+ return kbd_layout;
+
+ return lang;
+ }
private string get_preferred_language () {
var system_langs = Intl.get_language_names ();
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]