From 29fbe5dda08df05b193c0a064a58e5f0d9a66a4a Mon Sep 17 00:00:00 2001 From: Ray Strode 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. --- gnome-initial-setup/pages/keyboard/gis-keyboard-page.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/gnome-initial-setup/pages/keyboard/gis-keyboard-page.c b/gnome-initial-setup/pages/keyboard/gis-keyboard-page.c index 44d48fd0..a3be7287 100644 --- a/gnome-initial-setup/pages/keyboard/gis-keyboard-page.c +++ b/gnome-initial-setup/pages/keyboard/gis-keyboard-page.c @@ -222,60 +222,70 @@ update_input (GisKeyboardPage *self) const gchar *id; 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); + g_autoptr(GVariant) default_value = NULL; + g_autoptr(GVariant) value = NULL; + + default_value = g_settings_get_default_value (priv->input_settings, KEY_INPUT_SOURCES); + value = g_settings_get_value (priv->input_settings, KEY_INPUT_SOURCES); + + if (!g_variant_equal (default_value, value)) + return; + set_input_settings (self, NULL, NULL); } 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 preselect_input_source (GisKeyboardPage *self) { GisKeyboardPagePrivate *priv = gis_keyboard_page_get_instance_private (self); cc_input_chooser_set_input (CC_INPUT_CHOOSER (priv->input_chooser), priv->default_input_source_ids[0], priv->default_input_source_types[0]); } static void update_page_complete (GisKeyboardPage *self) { GisKeyboardPagePrivate *priv = gis_keyboard_page_get_instance_private (self); gboolean complete; -- 2.41.0.rc2