Still twiddling with the default input sources api
This commit is contained in:
parent
fe26aecaf1
commit
f57e7c9fbe
@ -1,4 +1,4 @@
|
||||
From cf2af4acbea3e5db04d4708e1afd7cfa962af0cd Mon Sep 17 00:00:00 2001
|
||||
From 1d0f3209b31e2f38e948df8491cf94ae9437fc11 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
|
||||
|
@ -1,4 +1,4 @@
|
||||
From 34abb9b4f16cba6aac43c63ebd49084200a868d9 Mon Sep 17 00:00:00 2001
|
||||
From 5cd7069eed2ed5432b7b993c36cc7195bd16ced2 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
|
||||
|
@ -1,4 +1,4 @@
|
||||
From 77a6a304ad6b4d7febe12b3c92da4a00feb1a84e Mon Sep 17 00:00:00 2001
|
||||
From ad6f81e94341ace8d797a81662d13bca3a5a362a 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
|
||||
|
@ -1,4 +1,4 @@
|
||||
From 9f93dd73c5ed57bb2fb1b572c9282d499d1c7fd7 Mon Sep 17 00:00:00 2001
|
||||
From c914a6b36f120eeb72a64625e63cdaa051d920f9 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,15 +17,16 @@ 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 | 256 +++++++++++++++++++++++++++++
|
||||
libgnome-desktop/gnome-languages.h | 10 ++
|
||||
2 files changed, 266 insertions(+)
|
||||
libgnome-desktop/gnome-languages.c | 276 +++++++++++++++++++++++++++++
|
||||
libgnome-desktop/gnome-languages.h | 11 ++
|
||||
2 files changed, 287 insertions(+)
|
||||
|
||||
diff --git a/libgnome-desktop/gnome-languages.c b/libgnome-desktop/gnome-languages.c
|
||||
index cc9bd005..072e1b07 100644
|
||||
index cc9bd005..09507ca2 100644
|
||||
--- a/libgnome-desktop/gnome-languages.c
|
||||
+++ b/libgnome-desktop/gnome-languages.c
|
||||
@@ -17,80 +17,87 @@
|
||||
@@ -16,81 +16,89 @@
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* Written by : William Jon McCann <mccann@jhu.edu>
|
||||
@ -55,9 +56,10 @@ index cc9bd005..072e1b07 100644
|
||||
|
||||
#define GNOME_DESKTOP_USE_UNSTABLE_API
|
||||
#include "gnome-languages.h"
|
||||
|
||||
+#include "sd-locale1.h"
|
||||
+#include "gnome-xkb-info.h"
|
||||
+
|
||||
+#include "sd-locale1.h"
|
||||
|
||||
#include <langinfo.h>
|
||||
#ifndef __LC_LAST
|
||||
#define __LC_LAST 13
|
||||
@ -113,7 +115,7 @@ index cc9bd005..072e1b07 100644
|
||||
}
|
||||
|
||||
static char *
|
||||
@@ -1440,30 +1447,279 @@ gnome_get_input_source_from_locale (const char *locale,
|
||||
@@ -1440,30 +1448,298 @@ gnome_get_input_source_from_locale (const char *locale,
|
||||
}
|
||||
|
||||
/**
|
||||
@ -220,7 +222,7 @@ index cc9bd005..072e1b07 100644
|
||||
+ g_autoptr(GError) error = NULL;
|
||||
+ g_autoptr(GPtrArray) input_sources = NULL;
|
||||
+ g_autofree InputSource *locale_input_source = NULL;
|
||||
+
|
||||
+ g_autofree char *input_method_language = NULL;
|
||||
+ const char * const *locale_data;
|
||||
+ g_autofree char *system_locale = NULL;
|
||||
+ g_autofree char *layouts_string = NULL;
|
||||
@ -262,6 +264,7 @@ index cc9bd005..072e1b07 100644
|
||||
+ */
|
||||
+ if (g_strcmp0 (type, "ibus") == 0) {
|
||||
+ g_ptr_array_add (input_sources, g_steal_pointer (&locale_input_source));
|
||||
+ input_method_language = gnome_get_language_from_locale (system_locale, NULL);
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
@ -283,6 +286,7 @@ index cc9bd005..072e1b07 100644
|
||||
+ number_of_variants = g_strv_length (variants);
|
||||
+
|
||||
+ if (number_of_layouts == number_of_variants) {
|
||||
+ g_autoptr(GnomeXkbInfo) xkb_info = gnome_xkb_info_new ();
|
||||
+ for (i = 0; layouts[i] != NULL; i++) {
|
||||
+ g_autofree InputSource *input_source = g_new0 (InputSource, 1);
|
||||
+
|
||||
@ -292,9 +296,19 @@ index cc9bd005..072e1b07 100644
|
||||
+ variants[i][0] != '\0'? "+" : "",
|
||||
+ variants[i]);
|
||||
+
|
||||
+ if (!g_ptr_array_find_with_equal_func (input_sources, input_source, (GEqualFunc) input_source_equal, NULL)) {
|
||||
+ g_ptr_array_add (input_sources, g_steal_pointer (&input_source));
|
||||
+ if (g_ptr_array_find_with_equal_func (input_sources, input_source, (GEqualFunc) input_source_equal, NULL))
|
||||
+ continue;
|
||||
+
|
||||
+ if (input_method_language != NULL) {
|
||||
+ const char *layout_language = NULL;
|
||||
+
|
||||
+ gnome_xkb_info_get_layout_info (xkb_info, input_source->id, &layout_language, NULL, NULL, NULL);
|
||||
+
|
||||
+ if (g_strcmp0 (input_method_language, layout_language) == 0)
|
||||
+ continue;
|
||||
+ }
|
||||
+
|
||||
+ g_ptr_array_add (input_sources, g_steal_pointer (&input_source));
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
@ -350,21 +364,22 @@ index cc9bd005..072e1b07 100644
|
||||
+
|
||||
+/**
|
||||
+ * gnome_get_default_input_sources_finish:
|
||||
+ * @result: a #GAsyncResult
|
||||
+ * @ids: (out) (transfer full): an array of input sources (eg. "us+dvorak" or "anthy")
|
||||
+ * @types: (out) (transfer full): an array of types (either "xkb" or "ibus")
|
||||
+ * @options: (out) (transfer full): an options string to use with all input sources
|
||||
+ * @error: a #GError
|
||||
+ *
|
||||
+ * Returns: (transfer full): a list of default input sources based on locale and system
|
||||
+ * configuration. This is for when a user has no input sources configured
|
||||
+ * Returns a whether or not a list of default input sources based on locale and system
|
||||
+ * configuration could be retrieved. This is for when a user has no input sources configured
|
||||
+ * in GSettings.
|
||||
+ *
|
||||
+ * Since: 46
|
||||
+ */
|
||||
+char **
|
||||
+gboolean
|
||||
+gnome_get_default_input_sources_finish (GAsyncResult *result,
|
||||
+ char ***types,
|
||||
+ char ***options,
|
||||
+ GStrv *ids,
|
||||
+ GStrv *types,
|
||||
+ GStrv *options,
|
||||
+ GError **error)
|
||||
+{
|
||||
+ GnomeInputSourceDefaults *defaults = NULL;
|
||||
@ -375,29 +390,35 @@ index cc9bd005..072e1b07 100644
|
||||
+ defaults = g_task_propagate_pointer (G_TASK (result), error);
|
||||
+
|
||||
+ if (defaults == NULL) {
|
||||
+ return NULL;
|
||||
+ return FALSE;
|
||||
+ }
|
||||
+
|
||||
+ ids_builder = g_strv_builder_new ();
|
||||
+ types_builder = g_strv_builder_new ();
|
||||
+
|
||||
+ for (i = 0; defaults->input_sources[i] != NULL; i++) {
|
||||
+ g_strv_builder_add (types_builder, defaults->input_sources[i]->type);
|
||||
+ g_strv_builder_add (ids_builder, defaults->input_sources[i]->id);
|
||||
+ g_strv_builder_add (types_builder, defaults->input_sources[i]->type);
|
||||
+ }
|
||||
+
|
||||
+ if (ids != NULL)
|
||||
+ *ids = g_strv_builder_end (ids_builder);
|
||||
+
|
||||
+ if (types != NULL)
|
||||
+ *types = g_strv_builder_end (types_builder);
|
||||
+
|
||||
+ if (options != NULL)
|
||||
+ *options = g_strdupv (defaults->options);
|
||||
+ return g_strv_builder_end (ids_builder);
|
||||
+
|
||||
+ gnome_input_source_defaults_free (defaults);
|
||||
+
|
||||
+ return TRUE;
|
||||
+}
|
||||
diff --git a/libgnome-desktop/gnome-languages.h b/libgnome-desktop/gnome-languages.h
|
||||
index ed9242e7..e2cffa62 100644
|
||||
index ed9242e7..3e261c28 100644
|
||||
--- a/libgnome-desktop/gnome-languages.h
|
||||
+++ b/libgnome-desktop/gnome-languages.h
|
||||
@@ -1,61 +1,71 @@
|
||||
@@ -1,61 +1,72 @@
|
||||
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
|
||||
*
|
||||
* Copyright 2008 Red Hat, Inc.
|
||||
@ -462,9 +483,10 @@ index ed9242e7..e2cffa62 100644
|
||||
+ GAsyncReadyCallback callback,
|
||||
+ gpointer user_data);
|
||||
+
|
||||
+char ** gnome_get_default_input_sources_finish (GAsyncResult *result,
|
||||
+ char ***types,
|
||||
+ char ***options,
|
||||
+gboolean gnome_get_default_input_sources_finish (GAsyncResult *result,
|
||||
+ GStrv *ids,
|
||||
+ GStrv *types,
|
||||
+ GStrv *options,
|
||||
+ GError **error);
|
||||
G_END_DECLS
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user