Sort the input sources list
This commit is contained in:
parent
f57e7c9fbe
commit
b1bdaaaf95
@ -1,4 +1,4 @@
|
||||
From 1d0f3209b31e2f38e948df8491cf94ae9437fc11 Mon Sep 17 00:00:00 2001
|
||||
From a7322f90defc31abeee242ad984d5b3debb86f68 Mon Sep 17 00:00:00 2001
|
||||
From: Ray Strode <rstrode@redhat.com>
|
||||
Date: Fri, 25 Aug 2023 09:47:47 -0400
|
||||
Subject: [PATCH 1/4] meson: Add python3 to build scripts
|
||||
@ -137,5 +137,5 @@ index 51a59e33..0419aa3c 100644
|
||||
supported_os = ['linux']
|
||||
unsupported_cpus = ['alpha', 'ia64', 'm68k', 'sh4', 'sparc', 'sparc64']
|
||||
--
|
||||
2.41.0.rc2
|
||||
2.41.0
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
From 5cd7069eed2ed5432b7b993c36cc7195bd16ced2 Mon Sep 17 00:00:00 2001
|
||||
From 7f2608dc9e9c3bedaf166f49eb3a39432665cbac Mon Sep 17 00:00:00 2001
|
||||
From: Ray Strode <rstrode@redhat.com>
|
||||
Date: Thu, 24 Aug 2023 17:37:37 -0400
|
||||
Subject: [PATCH 2/4] gnome-languages: Add function to detect non-latin layouts
|
||||
@ -62,7 +62,7 @@ index 00000000..f0403268
|
||||
+
|
||||
+ file.write(header_epilog)
|
||||
diff --git a/libgnome-desktop/gnome-languages.c b/libgnome-desktop/gnome-languages.c
|
||||
index adfc4eee..cc9bd005 100644
|
||||
index 8a0485c8..3bd4823f 100644
|
||||
--- a/libgnome-desktop/gnome-languages.c
|
||||
+++ b/libgnome-desktop/gnome-languages.c
|
||||
@@ -26,60 +26,61 @@
|
||||
@ -127,7 +127,7 @@ index adfc4eee..cc9bd005 100644
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1410,30 +1411,59 @@ gnome_get_input_source_from_locale (const char *locale,
|
||||
@@ -1417,30 +1418,59 @@ gnome_get_input_source_from_locale (const char *locale,
|
||||
DefaultInputSource *dis;
|
||||
g_autofree gchar *l_code = NULL;
|
||||
g_autofree gchar *c_code = NULL;
|
||||
@ -419,5 +419,5 @@ index 708a4ae8..d41e0cc0 100644
|
||||
gnome_desktop_deps = [
|
||||
gdk_pixbuf_dep,
|
||||
--
|
||||
2.41.0.rc2
|
||||
2.41.0
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
From ad6f81e94341ace8d797a81662d13bca3a5a362a Mon Sep 17 00:00:00 2001
|
||||
From 89a3384c5dbe31d05fcef377a9efb17202e5ca5a Mon Sep 17 00:00:00 2001
|
||||
From: Ray Strode <rstrode@redhat.com>
|
||||
Date: Thu, 24 Aug 2023 17:43:00 -0400
|
||||
Subject: [PATCH 3/4] meson: Add codegen for localed
|
||||
@ -253,5 +253,5 @@ index 00000000..bc23d3a1
|
||||
+ </interface>
|
||||
+</node>
|
||||
--
|
||||
2.41.0.rc2
|
||||
2.41.0
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
From c914a6b36f120eeb72a64625e63cdaa051d920f9 Mon Sep 17 00:00:00 2001
|
||||
From 85494f9909bd142f0000b7acd47a10f646739aa7 Mon Sep 17 00:00:00 2001
|
||||
From: Ray Strode <rstrode@redhat.com>
|
||||
Date: Thu, 24 Aug 2023 19:58:17 -0400
|
||||
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
|
||||
is still some redundancy needed by callers.
|
||||
---
|
||||
libgnome-desktop/gnome-languages.c | 276 +++++++++++++++++++++++++++++
|
||||
libgnome-desktop/gnome-languages.h | 11 ++
|
||||
2 files changed, 287 insertions(+)
|
||||
libgnome-desktop/gnome-languages.c | 320 +++++++++++++++++++++++++++++
|
||||
libgnome-desktop/gnome-languages.h | 11 +
|
||||
2 files changed, 331 insertions(+)
|
||||
|
||||
diff --git a/libgnome-desktop/gnome-languages.c b/libgnome-desktop/gnome-languages.c
|
||||
index cc9bd005..09507ca2 100644
|
||||
index 3bd4823f..48e6883f 100644
|
||||
--- a/libgnome-desktop/gnome-languages.c
|
||||
+++ b/libgnome-desktop/gnome-languages.c
|
||||
@@ -16,81 +16,89 @@
|
||||
@ -115,7 +115,7 @@ index cc9bd005..09507ca2 100644
|
||||
}
|
||||
|
||||
static char *
|
||||
@@ -1440,30 +1448,298 @@ gnome_get_input_source_from_locale (const char *locale,
|
||||
@@ -1447,30 +1455,342 @@ gnome_get_input_source_from_locale (const char *locale,
|
||||
}
|
||||
|
||||
/**
|
||||
@ -213,6 +213,48 @@ index cc9bd005..09507ca2 100644
|
||||
+ g_free (defaults);
|
||||
+}
|
||||
+
|
||||
+static int
|
||||
+sort_input_sources (InputSource *a,
|
||||
+ InputSource *b)
|
||||
+{
|
||||
+ gboolean a_is_input_method, b_is_input_method;
|
||||
+ gboolean a_is_latin, b_is_latin;
|
||||
+
|
||||
+ /* Make sure NULL gets put at the end */
|
||||
+ if (a == NULL) {
|
||||
+ return 1;
|
||||
+ }
|
||||
+
|
||||
+ if (b == NULL) {
|
||||
+ return -1;
|
||||
+ }
|
||||
+
|
||||
+ /* Make sure latin get put at the front */
|
||||
+ a_is_input_method = g_str_equal (a->type, "ibus");
|
||||
+ b_is_input_method = g_str_equal (b->type, "ibus");
|
||||
+ a_is_latin = !gnome_input_source_is_non_latin (a->type, a->id);
|
||||
+ b_is_latin = !gnome_input_source_is_non_latin (b->type, b->id);
|
||||
+
|
||||
+ if (a_is_latin && !b_is_latin) {
|
||||
+ return -1;
|
||||
+ }
|
||||
+
|
||||
+ if (b_is_latin && !a_is_latin) {
|
||||
+ return 1;
|
||||
+ }
|
||||
+
|
||||
+ /* and input methods get put before raw keyboard layouts */
|
||||
+ if (a_is_input_method && !b_is_input_method) {
|
||||
+ return -1;
|
||||
+ }
|
||||
+
|
||||
+ if (b_is_input_method && !a_is_input_method) {
|
||||
+ return 1;
|
||||
+ }
|
||||
+
|
||||
+ return 0;
|
||||
+}
|
||||
+
|
||||
+static void
|
||||
+on_got_localed_proxy_for_getting_default_input_sources (GObject *object,
|
||||
+ GAsyncResult *result,
|
||||
@ -326,6 +368,8 @@ index cc9bd005..09507ca2 100644
|
||||
+ }
|
||||
+ g_ptr_array_add (input_sources, NULL);
|
||||
+
|
||||
+ g_ptr_array_sort_values (input_sources, (GCompareFunc) sort_input_sources);
|
||||
+
|
||||
+ defaults = g_new0 (GnomeInputSourceDefaults, 1);
|
||||
+ defaults->input_sources = (InputSource **) g_ptr_array_steal (input_sources, NULL);
|
||||
+ defaults->options = g_steal_pointer (&options);
|
||||
@ -408,7 +452,7 @@ index cc9bd005..09507ca2 100644
|
||||
+ *types = g_strv_builder_end (types_builder);
|
||||
+
|
||||
+ if (options != NULL)
|
||||
+ *options = g_strdupv (defaults->options);
|
||||
+ *options = g_steal_pointer (&defaults->options);
|
||||
+
|
||||
+ gnome_input_source_defaults_free (defaults);
|
||||
+
|
||||
@ -492,5 +536,5 @@ index ed9242e7..3e261c28 100644
|
||||
|
||||
#endif /* __GNOME_LANGUAGES_H */
|
||||
--
|
||||
2.41.0.rc2
|
||||
2.41.0
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user