[gnome-settings-daemon/wip/carlosg/oneshot-reset-im-module] keyboard: "Migrate" gtk-im-context setting before giving control to user
- From: Carlos Garnacho <carlosg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-settings-daemon/wip/carlosg/oneshot-reset-im-module] keyboard: "Migrate" gtk-im-context setting before giving control to user
- Date: Tue, 15 Mar 2022 12:39:55 +0000 (UTC)
commit 5e8aec37252a7e17abb26f1fdb01aa279381fed4
Author: Carlos Garnacho <carlosg gnome org>
Date: Tue Mar 15 13:31:23 2022 +0100
keyboard: "Migrate" gtk-im-context setting before giving control to user
This setting used to be modified by gsd-keyboard at runtime, but it no
longer does. We want to leave this setting in a pristine state before
we lend control to the user in order to avoid setting leftovers make
GTK and others use the unintended IM module.
Since the setting is actually staying on the same schema/path, there is
no nice mechanism that would help us in doing a one-time port, so rely
on a file at ~/.cache to make this happen once. In the common case, it
just adds one stat() more at startup.
After this migration is done, the gtk-im-module setting can be considered
in full control of the user.
plugins/keyboard/gsd-keyboard-manager.c | 35 +++++++++++++++++++++++++++++++++
1 file changed, 35 insertions(+)
---
diff --git a/plugins/keyboard/gsd-keyboard-manager.c b/plugins/keyboard/gsd-keyboard-manager.c
index d41393bc..e15b168b 100644
--- a/plugins/keyboard/gsd-keyboard-manager.c
+++ b/plugins/keyboard/gsd-keyboard-manager.c
@@ -67,6 +67,8 @@
#define DEFAULT_LAYOUT "us"
+#define GTK_IM_MODULE_PORTED_FILE ".gsd-keyboard.gtk-im-module.ported"
+
struct _GsdKeyboardManager
{
GObject parent;
@@ -541,6 +543,14 @@ gsd_keyboard_manager_finalize (GObject *object)
G_OBJECT_CLASS (gsd_keyboard_manager_parent_class)->finalize (object);
}
+static GVariant *
+reset_gtk_im_module (GVariant *variant,
+ GVariant *old_default,
+ GVariant *new_default)
+{
+ return NULL;
+}
+
static void
migrate_keyboard_settings (void)
{
@@ -550,12 +560,37 @@ migrate_keyboard_settings (void)
{ "delay", "delay", NULL },
{ "remember-numlock-state", "remember-numlock-state", NULL },
};
+ g_autofree char *filename = NULL;
gsd_settings_migrate_check ("org.gnome.settings-daemon.peripherals.keyboard.deprecated",
"/org/gnome/settings-daemon/peripherals/keyboard/",
"org.gnome.desktop.peripherals.keyboard",
"/org/gnome/desktop/peripherals/keyboard/",
entries, G_N_ELEMENTS (entries));
+
+ /* In prior versions to GNOME 42, the gtk-im-module setting was
+ * owned by gsd-keyboard. Reset it once before giving it back
+ * to the user.
+ */
+ filename = g_build_filename (g_get_user_cache_dir (),
+ GTK_IM_MODULE_PORTED_FILE,
+ NULL);
+
+ if (!g_file_test (filename, G_FILE_TEST_EXISTS)) {
+ GsdSettingsMigrateEntry im_entry[] = {
+ { "gtk-im-module", "gtk-im-module", reset_gtk_im_module },
+ };
+ g_autoptr(GError) error = NULL;
+
+ gsd_settings_migrate_check ("org.gnome.desktop.interface",
+ "/org/gnome/desktop/interface/",
+ "org.gnome.desktop.interface",
+ "/org/gnome/desktop/interface/",
+ im_entry, G_N_ELEMENTS (im_entry));
+
+ if (!g_file_set_contents (filename, "", -1, &error))
+ g_warning ("Error migrating gtk-im-module: %s", error->message);
+ }
}
GsdKeyboardManager *
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]