Address niche edge case with certain bulgarian layouts

This commit is contained in:
Ray Strode 2023-09-20 09:30:53 -04:00
parent b1bdaaaf95
commit 697e80ee94
3 changed files with 47 additions and 21 deletions

View File

@ -1,4 +1,4 @@
From 7f2608dc9e9c3bedaf166f49eb3a39432665cbac Mon Sep 17 00:00:00 2001 From 242308344cceca729148507d787f130151b44ea0 Mon Sep 17 00:00:00 2001
From: Ray Strode <rstrode@redhat.com> From: Ray Strode <rstrode@redhat.com>
Date: Thu, 24 Aug 2023 17:37:37 -0400 Date: Thu, 24 Aug 2023 17:37:37 -0400
Subject: [PATCH 2/4] gnome-languages: Add function to detect non-latin layouts Subject: [PATCH 2/4] gnome-languages: Add function to detect non-latin layouts
@ -9,32 +9,37 @@ a way to input latin characters.
This commit adds a function to detect layouts that need supplemental This commit adds a function to detect layouts that need supplemental
layouts to tag along. layouts to tag along.
--- ---
.../generate-non-latin-input-sources.py | 39 +++++++++++++++++++ .../generate-non-latin-input-sources.py | 44 +++++++++++++++++++
libgnome-desktop/gnome-languages.c | 30 ++++++++++++++ libgnome-desktop/gnome-languages.c | 30 +++++++++++++
libgnome-desktop/gnome-languages.h | 2 + libgnome-desktop/gnome-languages.h | 2 +
libgnome-desktop/meson.build | 7 ++++ libgnome-desktop/meson.build | 7 +++
4 files changed, 78 insertions(+) 4 files changed, 83 insertions(+)
create mode 100644 libgnome-desktop/generate-non-latin-input-sources.py create mode 100644 libgnome-desktop/generate-non-latin-input-sources.py
diff --git a/libgnome-desktop/generate-non-latin-input-sources.py b/libgnome-desktop/generate-non-latin-input-sources.py diff --git a/libgnome-desktop/generate-non-latin-input-sources.py b/libgnome-desktop/generate-non-latin-input-sources.py
new file mode 100644 new file mode 100644
index 00000000..f0403268 index 00000000..d2b84f08
--- /dev/null --- /dev/null
+++ b/libgnome-desktop/generate-non-latin-input-sources.py +++ b/libgnome-desktop/generate-non-latin-input-sources.py
@@ -0,0 +1,39 @@ @@ -0,0 +1,44 @@
+import langtable +import langtable
+import locale
+ +
+all_locales = [locale.normalize(locale_id) for locale_id in locale.locale_alias.values()] +import locale
+import re
+
+if hasattr(langtable, 'list_all_keyboards'):
+ keyboards = langtable.list_all_keyboards()
+else:
+ from langtable.langtable import _keyboards_db
+ keyboards = _keyboards_db.keys()
+ +
+non_latin_keyboards = {} +non_latin_keyboards = {}
+ +
+for locale in all_locales: +for keyboard in keyboards:
+ keyboards = langtable.list_keyboards(languageId=locale) + # Check if the keyboard supports ASCII
+ for keyboard in keyboards: + if not langtable.supports_ascii(keyboardId=keyboard):
+ # Check if the keyboard supports ASCII + input_source = re.sub(r'\((.*?)\)', r'+\1', keyboard)
+ if not langtable.supports_ascii(keyboardId=keyboard): + non_latin_keyboards[input_source] = 'xkb'
+ non_latin_keyboards[keyboard] = 'xkb'
+ +
+sorted_non_latin_keyboards = sorted(non_latin_keyboards.items(), key=lambda x: x[0]) +sorted_non_latin_keyboards = sorted(non_latin_keyboards.items(), key=lambda x: x[0])
+ +

View File

@ -1,4 +1,4 @@
From 89a3384c5dbe31d05fcef377a9efb17202e5ca5a Mon Sep 17 00:00:00 2001 From 185c1f7541ee44095ec5d9348298510e28e37f2c Mon Sep 17 00:00:00 2001
From: Ray Strode <rstrode@redhat.com> From: Ray Strode <rstrode@redhat.com>
Date: Thu, 24 Aug 2023 17:43:00 -0400 Date: Thu, 24 Aug 2023 17:43:00 -0400
Subject: [PATCH 3/4] meson: Add codegen for localed Subject: [PATCH 3/4] meson: Add codegen for localed

View File

@ -1,4 +1,4 @@
From 85494f9909bd142f0000b7acd47a10f646739aa7 Mon Sep 17 00:00:00 2001 From f9dc0fefa8abfe37ea2029fefb6e49c2f3a0a696 Mon Sep 17 00:00:00 2001
From: Ray Strode <rstrode@redhat.com> From: Ray Strode <rstrode@redhat.com>
Date: Thu, 24 Aug 2023 19:58:17 -0400 Date: Thu, 24 Aug 2023 19:58:17 -0400
Subject: [PATCH 4/4] languages: Add functions for getting default input Subject: [PATCH 4/4] languages: Add functions for getting default input
@ -17,12 +17,12 @@ gnome_get_default_input_sources_finish
Note, these functions don't provide change notification, so there Note, these functions don't provide change notification, so there
is still some redundancy needed by callers. is still some redundancy needed by callers.
--- ---
libgnome-desktop/gnome-languages.c | 320 +++++++++++++++++++++++++++++ libgnome-desktop/gnome-languages.c | 341 +++++++++++++++++++++++++++++
libgnome-desktop/gnome-languages.h | 11 + libgnome-desktop/gnome-languages.h | 11 +
2 files changed, 331 insertions(+) 2 files changed, 352 insertions(+)
diff --git a/libgnome-desktop/gnome-languages.c b/libgnome-desktop/gnome-languages.c diff --git a/libgnome-desktop/gnome-languages.c b/libgnome-desktop/gnome-languages.c
index 3bd4823f..48e6883f 100644 index 3bd4823f..5d6c8b94 100644
--- a/libgnome-desktop/gnome-languages.c --- a/libgnome-desktop/gnome-languages.c
+++ b/libgnome-desktop/gnome-languages.c +++ b/libgnome-desktop/gnome-languages.c
@@ -16,81 +16,89 @@ @@ -16,81 +16,89 @@
@ -115,7 +115,7 @@ index 3bd4823f..48e6883f 100644
} }
static char * static char *
@@ -1447,30 +1455,342 @@ gnome_get_input_source_from_locale (const char *locale, @@ -1447,30 +1455,363 @@ gnome_get_input_source_from_locale (const char *locale,
} }
/** /**
@ -329,6 +329,10 @@ index 3bd4823f..48e6883f 100644
+ +
+ if (number_of_layouts == number_of_variants) { + if (number_of_layouts == number_of_variants) {
+ g_autoptr(GnomeXkbInfo) xkb_info = gnome_xkb_info_new (); + g_autoptr(GnomeXkbInfo) xkb_info = gnome_xkb_info_new ();
+ g_autofree char *system_language = NULL;
+
+ gnome_parse_locale (system_locale, &system_language, NULL, NULL, NULL);
+
+ for (i = 0; layouts[i] != NULL; i++) { + for (i = 0; layouts[i] != NULL; i++) {
+ g_autofree InputSource *input_source = g_new0 (InputSource, 1); + g_autofree InputSource *input_source = g_new0 (InputSource, 1);
+ +
@ -348,6 +352,20 @@ index 3bd4823f..48e6883f 100644
+ +
+ if (g_strcmp0 (input_method_language, layout_language) == 0) + if (g_strcmp0 (input_method_language, layout_language) == 0)
+ continue; + continue;
+ } else if (system_language != NULL) {
+ GList *languages = NULL, *node = NULL;
+ const char *system_language_name = get_language (system_language);
+
+ languages = gnome_xkb_info_get_languages_for_layout (xkb_info, layouts[i]);
+ for (node = languages; node != NULL; node = node->next) {
+ const char *language_name = get_language (node->data);
+
+ if (g_strcmp0 (system_language_name, language_name) == 0) {
+ g_clear_pointer (&locale_input_source, g_free);
+ break;
+ }
+ }
+ g_list_free (languages);
+ } + }
+ +
+ g_ptr_array_add (input_sources, g_steal_pointer (&input_source)); + g_ptr_array_add (input_sources, g_steal_pointer (&input_source));
@ -395,6 +413,9 @@ index 3bd4823f..48e6883f 100644
+ gpointer user_data) + gpointer user_data)
+{ +{
+ GTask *task; + GTask *task;
+
+ languages_init ();
+
+ task = g_task_new (NULL, + task = g_task_new (NULL,
+ cancellable, + cancellable,
+ callback, + callback,