Update to use slightly tweaked default input sources api from gnome-desktop

This commit is contained in:
Ray Strode 2023-08-26 10:21:33 -04:00
parent 92466bbe4b
commit 10dec1d365
11 changed files with 108 additions and 103 deletions

View File

@ -1,4 +1,4 @@
From 02dbaf7ffc27804325573b6e2ccf732696c2a7f0 Mon Sep 17 00:00:00 2001
From 810635287685db53ab320be75c992265370ff215 Mon Sep 17 00:00:00 2001
From: Ray Strode <rstrode@redhat.com>
Date: Thu, 24 Aug 2023 21:19:40 -0400
Subject: [PATCH 01/10] keyboard: Get default input sources from gnome-desktop
@ -16,14 +16,22 @@ The same time if leverages a gnome-desktop API to fix a bug
where cyrillic layouts were getting added without a latin
counterpart.
---
.../pages/keyboard/gis-keyboard-page.c | 304 ++++++------------
1 file changed, 104 insertions(+), 200 deletions(-)
.../pages/keyboard/gis-keyboard-page.c | 313 ++++++------------
1 file changed, 105 insertions(+), 208 deletions(-)
diff --git a/gnome-initial-setup/pages/keyboard/gis-keyboard-page.c b/gnome-initial-setup/pages/keyboard/gis-keyboard-page.c
index fa41230f..2583c447 100644
index fa41230f..61556b99 100644
--- a/gnome-initial-setup/pages/keyboard/gis-keyboard-page.c
+++ b/gnome-initial-setup/pages/keyboard/gis-keyboard-page.c
@@ -25,495 +25,399 @@
@@ -17,503 +17,400 @@
* Author: Sergey Udaltsov <svu@gnome.org>
* Michael Wood <michael.g.wood@intel.com>
*
* Based on gnome-control-center cc-region-panel.c
*/
#define PAGE_ID "keyboard"
#include "config.h"
#include <locale.h>
@ -46,6 +54,7 @@ index fa41230f..2583c447 100644
#define GNOME_DESKTOP_INPUT_SOURCES_DIR "org.gnome.desktop.input-sources"
#define KEY_CURRENT_INPUT_SOURCE "current"
#define KEY_INPUT_SOURCES "sources"
+#define KEY_INPUT_OPTIONS "xkb-options"
struct _GisKeyboardPagePrivate {
GtkWidget *input_chooser;
@ -56,6 +65,7 @@ index fa41230f..2583c447 100644
GSettings *input_settings;
+ char **default_input_source_ids;
+ char **default_input_source_types;
+ char **default_input_options;
- GSList *system_sources;
+ gboolean should_skip;
@ -81,6 +91,7 @@ index fa41230f..2583c447 100644
- g_slist_free_full (priv->system_sources, g_free);
+ g_clear_pointer (&priv->default_input_source_ids, g_strfreev);
+ g_clear_pointer (&priv->default_input_source_types, g_strfreev);
+ g_clear_pointer (&priv->default_input_options, g_strfreev);
G_OBJECT_CLASS (gis_keyboard_page_parent_class)->finalize (object);
}
@ -94,40 +105,43 @@ index fa41230f..2583c447 100644
GisKeyboardPagePrivate *priv = gis_keyboard_page_get_instance_private (self);
- const gchar *type;
- const gchar *id;
+
GVariantBuilder builder;
- GVariantBuilder builder;
- GSList *l;
+
+ GVariantBuilder input_source_builder;
+ GVariantBuilder input_options_builder;
+ size_t i;
+ gboolean has_latin_layout = FALSE;
gboolean is_xkb_source = FALSE;
- 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));
-
g_variant_builder_init (&builder, G_VARIANT_TYPE ("a(ss)"));
+ g_variant_builder_init (&input_source_builder, G_VARIANT_TYPE ("a(ss)"));
+ g_variant_builder_init (&input_options_builder, G_VARIANT_TYPE ("as"));
- g_variant_builder_init (&builder, G_VARIANT_TYPE ("a(ss)"));
+ if (type != NULL && id != NULL) {
+ has_latin_layout = !gnome_input_source_is_non_latin (type, id);
+ if (g_str_equal (type, "xkb")) {
+ g_variant_builder_add (&input_source_builder, "(ss)", type, id);
- if (g_str_equal (type, "xkb")) {
- g_variant_builder_add (&builder, "(ss)", type, id);
- is_xkb_source = TRUE;
- }
+ if (type != NULL && id != NULL) {
+ has_latin_layout = !gnome_input_source_is_non_latin (type, id);
+ if (g_str_equal (type, "xkb")) {
+ g_variant_builder_add (&builder, "(ss)", type, id);
+ is_xkb_source = TRUE;
+ }
}
- for (l = priv->system_sources; l; l = l->next) {
- const gchar *sid = l->data;
+ is_xkb_source = TRUE;
+ }
+ }
-
- if (g_str_equal (id, sid) && g_str_equal (type, "xkb"))
+ for (i = 0; priv->default_input_source_ids && priv->default_input_source_ids[i] != NULL; i++) {
+ if (g_str_equal (id, priv->default_input_source_ids[i]) && g_str_equal (type, priv->default_input_source_types[i]))
continue;
- g_variant_builder_add (&builder, "(ss)", "xkb", sid);
+ g_variant_builder_add (&builder, "(ss)", priv->default_input_source_types[i], priv->default_input_source_ids[i]);
+ g_variant_builder_add (&input_source_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]))
+ has_latin_layout = TRUE;
@ -137,18 +151,23 @@ index fa41230f..2583c447 100644
- g_variant_builder_add (&builder, "(ss)", type, id);
+ if (type != NULL && id != NULL) {
+ if (!is_xkb_source) {
+ g_variant_builder_add (&builder, "(ss)", type, id);
+ g_variant_builder_add (&input_source_builder, "(ss)", type, id);
+ }
+ }
- 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);
+ if (!has_latin_layout) {
+ g_variant_builder_add (&builder, "(ss)", "xkb", "us");
+ g_variant_builder_add (&input_source_builder, "(ss)", "xkb", "us");
+ }
- g_settings_apply (priv->input_settings);
+ g_settings_set_value (priv->input_settings, KEY_INPUT_SOURCES, g_variant_builder_end (&builder));
+ for (i = 0; priv->default_input_options[i] != NULL; i++) {
+ g_variant_builder_add (&input_options_builder, "s", priv->default_input_options[i]);
+ }
+
+ g_settings_set_value (priv->input_settings, KEY_INPUT_SOURCES, g_variant_builder_end (&input_source_builder));
+ g_settings_set_value (priv->input_settings, KEY_INPUT_OPTIONS, g_variant_builder_end (&input_options_builder));
+ g_settings_set_uint (priv->input_settings, KEY_CURRENT_INPUT_SOURCE, 0);
+ g_settings_apply (priv->input_settings);
}
@ -240,11 +259,11 @@ index fa41230f..2583c447 100644
GisKeyboardPagePrivate *priv = gis_keyboard_page_get_instance_private (self);
+ const gchar *type;
+ 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 = 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_NEW_USER) {
@ -314,10 +333,11 @@ index fa41230f..2583c447 100644
- return sources;
-}
-
-static void
static void
-add_default_keyboard_layout (GDBusProxy *proxy,
- GVariantBuilder *builder)
-{
+add_default_input_sources (GisKeyboardPage *self)
{
- GSList *sources = get_localed_input (proxy);
- sources = g_slist_reverse (sources);
-
@ -328,23 +348,19 @@ index fa41230f..2583c447 100644
- g_slist_free_full (sources, g_free);
-}
-
static void
-static void
-add_default_input_sources (GisKeyboardPage *self,
- GDBusProxy *proxy)
+add_default_input_sources (GisKeyboardPage *self)
{
-{
- const gchar *type;
- const gchar *id;
- gchar *language;
+ GisKeyboardPagePrivate *priv = gis_keyboard_page_get_instance_private (self);
GVariantBuilder builder;
- GVariantBuilder builder;
- GSettings *input_settings;
+ gboolean defaults_have_latin = FALSE;
+ size_t i;
-
- input_settings = g_settings_new (GNOME_DESKTOP_INPUT_SOURCES_DIR);
g_variant_builder_init (&builder, G_VARIANT_TYPE ("a(ss)"));
- g_variant_builder_init (&builder, G_VARIANT_TYPE ("a(ss)"));
-
- add_default_keyboard_layout (proxy, &builder);
-
- /* add other input sources */
@ -352,13 +368,9 @@ index fa41230f..2583c447 100644
- if (gnome_get_input_source_from_locale (language, &type, &id)) {
- if (!g_str_equal (type, "xkb"))
- g_variant_builder_add (&builder, "(ss)", type, id);
+ 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;
}
- }
- 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);
@ -386,14 +398,9 @@ index fa41230f..2583c447 100644
- }
-
- add_default_input_sources (self, proxy);
+ if (!defaults_have_latin) {
+ g_variant_builder_add (&builder, "(ss)", "xkb", "us");
+ }
-
- g_object_unref (proxy);
+ 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);
+ set_input_settings (self, NULL, NULL);
}
static void
@ -542,8 +549,9 @@ index fa41230f..2583c447 100644
+ g_autoptr (GError) error = NULL;
+ g_auto (GStrv) ids = NULL;
+ g_auto (GStrv) types = NULL;
+ g_auto (GStrv) options = NULL;
+
+ ids = gnome_get_default_input_sources_finish (res, &types, &error);
+ ids = gnome_get_default_input_sources_finish (res, &types, &options, &error);
+
+ if (!ids) {
+ if (!g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED))
@ -553,6 +561,7 @@ index fa41230f..2583c447 100644
+
+ priv->default_input_source_ids = g_steal_pointer (&ids);
+ priv->default_input_source_types = g_steal_pointer (&types);
+ priv->default_input_options = g_steal_pointer (&options);
+
+ if (priv->should_skip) {
+ add_default_input_sources (self);

View File

@ -1,4 +1,4 @@
From 5efa8fe5b0abbe7cb951f0581a5511c0d682f290 Mon Sep 17 00:00:00 2001
From c8246d78f920af9bc2b2971616ca4e199301a2b6 Mon Sep 17 00:00:00 2001
From: Ray Strode <rstrode@redhat.com>
Date: Tue, 15 Aug 2023 10:53:41 -0400
Subject: [PATCH 02/10] gnome-initial-setup: Bump GLib required version to 2.70

View File

@ -1,4 +1,4 @@
From b511ec8b34d3120fc4a9dbf2202f40f335a2802f Mon Sep 17 00:00:00 2001
From 658a673feac93493a74a83434abce93e39bff170 Mon Sep 17 00:00:00 2001
From: Ray Strode <rstrode@redhat.com>
Date: Sun, 13 Aug 2023 09:09:56 -0400
Subject: [PATCH 03/10] driver: Specify mode via flags instead of boolean

View File

@ -1,4 +1,4 @@
From dc25c47c1300e6b31dd0c9d5723f026a23e57ac3 Mon Sep 17 00:00:00 2001
From 97433b89c94c39c9059344a0e4a562b6ef251675 Mon Sep 17 00:00:00 2001
From: Ray Strode <rstrode@redhat.com>
Date: Wed, 16 Aug 2023 10:47:13 -0400
Subject: [PATCH 04/10] initial-setup: Don't show duplicated pages between

View File

@ -1,4 +1,4 @@
From 42d8bdfc0d37460cedf6fb3fe59bdfc0769c48ec Mon Sep 17 00:00:00 2001
From 43db755e9027bde74626b9d2f15ee9013c8f7dc6 Mon Sep 17 00:00:00 2001
From: Ray Strode <rstrode@redhat.com>
Date: Fri, 25 Aug 2023 21:30:42 -0400
Subject: [PATCH 05/10] summary: Write uid file with other state files

View File

@ -1,4 +1,4 @@
From a7112122b3f1c68ab96e644e4c62715f02d5af69 Mon Sep 17 00:00:00 2001
From 64e82b502c7ed692f360c82478dc35dad55ed051 Mon Sep 17 00:00:00 2001
From: Ray Strode <rstrode@redhat.com>
Date: Sun, 13 Aug 2023 09:39:07 -0400
Subject: [PATCH 06/10] gnome-initial-setup: Add live user mode
@ -1288,10 +1288,10 @@ index 00000000..e5084e5e
+ 'gis-install-page.h'
+)
diff --git a/gnome-initial-setup/pages/keyboard/gis-keyboard-page.c b/gnome-initial-setup/pages/keyboard/gis-keyboard-page.c
index 2583c447..cb4f68d8 100644
index 61556b99..44d48fd0 100644
--- a/gnome-initial-setup/pages/keyboard/gis-keyboard-page.c
+++ b/gnome-initial-setup/pages/keyboard/gis-keyboard-page.c
@@ -189,61 +189,61 @@ change_locale_permission_acquired (GObject *source,
@@ -199,61 +199,61 @@ change_locale_permission_acquired (GObject *source,
{
GisKeyboardPage *page = GIS_KEYBOARD_PAGE (data);
GisKeyboardPagePrivate *priv = gis_keyboard_page_get_instance_private (page);
@ -1346,15 +1346,15 @@ index 2583c447..cb4f68d8 100644
static void
add_default_input_sources (GisKeyboardPage *self)
{
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);
GVariantBuilder builder;
gboolean defaults_have_latin = FALSE;
size_t i;
g_variant_builder_init (&builder, G_VARIANT_TYPE ("a(ss)"));
for (i = 0; priv->default_input_source_ids[i] != NULL; i++) {
@@ -365,61 +365,61 @@ static void
@@ -358,61 +358,61 @@ static void
gis_keyboard_page_constructed (GObject *object)
{
GisKeyboardPage *self = GIS_KEYBOARD_PAGE (object);

View File

@ -1,4 +1,4 @@
From 893ecb7194306ce1fb3637454849e3183a58f742 Mon Sep 17 00:00:00 2001
From 29fbe5dda08df05b193c0a064a58e5f0d9a66a4a 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
@ -12,14 +12,16 @@ That is all fine and good, but may stomp on existiing site or distro configurati
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(+)
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 cb4f68d8..febd1483 100644
index 44d48fd0..a3be7287 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)
@@ -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));
@ -48,37 +50,17 @@ index cb4f68d8..febd1483 100644
static void
add_default_input_sources (GisKeyboardPage *self)
{
GisKeyboardPagePrivate *priv = gis_keyboard_page_get_instance_private (self);
GVariantBuilder builder;
+ GSettings *input_settings;
+ GisKeyboardPagePrivate *priv = gis_keyboard_page_get_instance_private (self);
+ 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);
+ 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;
+
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);
set_input_settings (self, NULL, NULL);
}
static void
@ -94,6 +76,20 @@ index cb4f68d8..febd1483 100644
}
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

View File

@ -1,4 +1,4 @@
From 79e3d56cf0670854cb32e1884cb9c4e14664aad1 Mon Sep 17 00:00:00 2001
From e5a05979db85f7a76b1292efb466b3d49e1e0564 Mon Sep 17 00:00:00 2001
From: Ray Strode <rstrode@redhat.com>
Date: Sun, 13 Aug 2023 10:30:11 -0400
Subject: [PATCH 08/10] gnome-initial-setup: Add OEM mode

View File

@ -1,4 +1,4 @@
From 58a26e35a2d367dd501faf8dcecac3569fab274d Mon Sep 17 00:00:00 2001
From 87950841dceb637f6f6da001e283b53527bf5312 Mon Sep 17 00:00:00 2001
From: Ray Strode <rstrode@redhat.com>
Date: Sun, 13 Aug 2023 16:33:49 -0400
Subject: [PATCH 09/10] polkit: Add fedora specfic rules

View File

@ -1,4 +1,4 @@
From 26543a5a3a9e54c88f72b6d4cd0fe019933765ae Mon Sep 17 00:00:00 2001
From 4c263eb0ab00dbdcea4589fca4dc3a82f18de5eb Mon Sep 17 00:00:00 2001
From: Ray Strode <rstrode@redhat.com>
Date: Tue, 22 Aug 2023 13:51:40 -0400
Subject: [PATCH 10/10] gnome-initial-setup: Read /etc/sysconfig/anaconda

View File

@ -3,7 +3,7 @@
%global glib_required_version 2.63.1
%global gtk_required_version 4.6
%global geoclue_version 2.3.1
%global gnome_desktop_version 44.0-5
%global gnome_desktop_version 44.0-6
%global tarball_version %%(echo %{version} | tr '~' '.')