97 lines
2.9 KiB
Diff
97 lines
2.9 KiB
Diff
From b06e6e46b11e8e3ad16212d05ae24c3ff3184a3c Mon Sep 17 00:00:00 2001
|
|
From: Ray Strode <rstrode@redhat.com>
|
|
Date: Sat, 19 Aug 2023 15:31:03 -0400
|
|
Subject: [PATCH 5/7] keyboard: Don't add default input sources if input
|
|
sources already set
|
|
|
|
If the keyboard page gets skipped, it adds default input sources derived
|
|
from the users locale.
|
|
|
|
That is all fine and good, but may stomp on existiing site or distro configuration.
|
|
|
|
This commit checks for that kind of thing first, and skips adding the
|
|
default in that case.
|
|
---
|
|
gnome-initial-setup/pages/keyboard/gis-keyboard-page.c | 9 +++++++++
|
|
1 file changed, 9 insertions(+)
|
|
|
|
diff --git a/gnome-initial-setup/pages/keyboard/gis-keyboard-page.c b/gnome-initial-setup/pages/keyboard/gis-keyboard-page.c
|
|
index e5556483..2448cf2f 100644
|
|
--- a/gnome-initial-setup/pages/keyboard/gis-keyboard-page.c
|
|
+++ b/gnome-initial-setup/pages/keyboard/gis-keyboard-page.c
|
|
@@ -258,62 +258,71 @@ get_localed_input (GDBusProxy *proxy)
|
|
|
|
g_strfreev (variants);
|
|
g_strfreev (layouts);
|
|
|
|
return sources;
|
|
}
|
|
|
|
static void
|
|
add_default_keyboard_layout (GDBusProxy *proxy,
|
|
GVariantBuilder *builder)
|
|
{
|
|
GSList *sources = get_localed_input (proxy);
|
|
sources = g_slist_reverse (sources);
|
|
|
|
for (; sources; sources = sources->next)
|
|
g_variant_builder_add (builder, "(ss)", "xkb",
|
|
(const gchar *) sources->data);
|
|
|
|
g_slist_free_full (sources, g_free);
|
|
}
|
|
|
|
static void
|
|
add_default_input_sources (GisKeyboardPage *self,
|
|
GDBusProxy *proxy)
|
|
{
|
|
const gchar *type;
|
|
const gchar *id;
|
|
gchar *language;
|
|
GVariantBuilder builder;
|
|
GSettings *input_settings;
|
|
+ g_autoptr(GVariant) default_value = NULL;
|
|
+ g_autoptr(GVariant) value = NULL;
|
|
|
|
input_settings = g_settings_new (GNOME_DESKTOP_INPUT_SOURCES_DIR);
|
|
+
|
|
+ default_value = g_settings_get_default_value (input_settings, KEY_INPUT_SOURCES);
|
|
+ value = g_settings_get_value (input_settings, KEY_INPUT_SOURCES);
|
|
+
|
|
+ if (!g_variant_equal (default_value, value))
|
|
+ return;
|
|
+
|
|
g_variant_builder_init (&builder, G_VARIANT_TYPE ("a(ss)"));
|
|
|
|
add_default_keyboard_layout (proxy, &builder);
|
|
|
|
/* add other input sources */
|
|
language = cc_common_language_get_current_language ();
|
|
if (gnome_get_input_source_from_locale (language, &type, &id)) {
|
|
if (!g_str_equal (type, "xkb"))
|
|
g_variant_builder_add (&builder, "(ss)", type, id);
|
|
}
|
|
g_free (language);
|
|
|
|
g_settings_delay (input_settings);
|
|
g_settings_set_value (input_settings, KEY_INPUT_SOURCES, g_variant_builder_end (&builder));
|
|
g_settings_set_uint (input_settings, KEY_CURRENT_INPUT_SOURCE, 0);
|
|
g_settings_apply (input_settings);
|
|
|
|
g_object_unref (input_settings);
|
|
}
|
|
|
|
static void
|
|
skip_proxy_ready (GObject *source,
|
|
GAsyncResult *res,
|
|
gpointer data)
|
|
{
|
|
GisKeyboardPage *self = data;
|
|
GDBusProxy *proxy;
|
|
GError *error = NULL;
|
|
|
|
proxy = g_dbus_proxy_new_finish (res, &error);
|
|
--
|
|
2.41.0.rc2
|
|
|