gnome-initial-setup/0007-keyboard-Don-t-add-default-input-sources-if-input-so.patch
2023-08-26 06:26:29 -04:00

100 lines
3.4 KiB
Diff

From 893ecb7194306ce1fb3637454849e3183a58f742 Mon Sep 17 00:00:00 2001
From: Ray Strode <rstrode@redhat.com>
Date: Sat, 19 Aug 2023 15:31:03 -0400
Subject: [PATCH 07/10] 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.
---
.../pages/keyboard/gis-keyboard-page.c | 11 +++++++++++
1 file changed, 11 insertions(+)
diff --git a/gnome-initial-setup/pages/keyboard/gis-keyboard-page.c b/gnome-initial-setup/pages/keyboard/gis-keyboard-page.c
index cb4f68d8..febd1483 100644
--- a/gnome-initial-setup/pages/keyboard/gis-keyboard-page.c
+++ b/gnome-initial-setup/pages/keyboard/gis-keyboard-page.c
@@ -214,63 +214,74 @@ update_input (GisKeyboardPage *self)
type = cc_input_chooser_get_input_type (CC_INPUT_CHOOSER (priv->input_chooser));
id = cc_input_chooser_get_input_id (CC_INPUT_CHOOSER (priv->input_chooser));
set_input_settings (self, type, id);
if (gis_driver_get_mode (GIS_PAGE (self)->driver) & GIS_DRIVER_MODE_SYSTEM) {
if (g_permission_get_allowed (priv->permission)) {
set_localed_input (self);
} else if (g_permission_get_can_acquire (priv->permission)) {
g_permission_acquire_async (priv->permission,
NULL,
change_locale_permission_acquired,
self);
}
}
}
static gboolean
gis_keyboard_page_apply (GisPage *page,
GCancellable *cancellable)
{
update_input (GIS_KEYBOARD_PAGE (page));
return FALSE;
}
static void
add_default_input_sources (GisKeyboardPage *self)
{
GisKeyboardPagePrivate *priv = gis_keyboard_page_get_instance_private (self);
GVariantBuilder builder;
+ GSettings *input_settings;
+ g_autoptr(GVariant) default_value = NULL;
+ g_autoptr(GVariant) value = NULL;
gboolean defaults_have_latin = FALSE;
size_t i;
+ 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)"));
for (i = 0; priv->default_input_source_ids[i] != NULL; i++) {
g_variant_builder_add (&builder, "(ss)", priv->default_input_source_types[i], priv->default_input_source_ids[i]);
if (!gnome_input_source_is_non_latin (priv->default_input_source_types[i], priv->default_input_source_ids[i]))
defaults_have_latin = TRUE;
}
if (!defaults_have_latin) {
g_variant_builder_add (&builder, "(ss)", "xkb", "us");
}
g_settings_set_value (priv->input_settings, KEY_INPUT_SOURCES, g_variant_builder_end (&builder));
g_settings_set_uint (priv->input_settings, KEY_CURRENT_INPUT_SOURCE, 0);
g_settings_apply (priv->input_settings);
}
static void
gis_keyboard_page_skip (GisPage *page)
{
GisKeyboardPage *self = GIS_KEYBOARD_PAGE (page);
GisKeyboardPagePrivate *priv = gis_keyboard_page_get_instance_private (self);
priv->should_skip = TRUE;
if (priv->default_input_source_ids != NULL)
add_default_input_sources (self);
}
static void
--
2.41.0.rc2