Commit c8981ef0 authored by Carlos Garnacho's avatar Carlos Garnacho
Browse files

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.
parent 911e529c
Pipeline #379244 passed with stages
in 4 minutes and 28 seconds
......@@ -67,6 +67,8 @@
#define DEFAULT_LAYOUT "us"
#define SETTINGS_PORTED_FILE ".gsd-keyboard.settings-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_config_dir (),
SETTINGS_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 *
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment