From 796981d39058e2cd12808d71f510f1d551123af9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20M=C3=BCllner?= Date: Thu, 29 Jun 2017 18:55:40 +0200 Subject: keyboard: Special-case disabling of multi-bindings shortcuts For shortcuts that support multiple bindings, the disabled state is expressed as an empty list rather than a list with a single empty element. While the latter certainly works as expected as far as the actual keybinding is concerned, the shortcut will show up as modified even if it is disabled by default. Explicitly setting bindings to the empty list when a shortcut is disabled fixes this. https://bugzilla.gnome.org/show_bug.cgi?id=784620 --- panels/keyboard/cc-keyboard-item.c | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/panels/keyboard/cc-keyboard-item.c b/panels/keyboard/cc-keyboard-item.c index f68d64a13..a970a18f6 100644 --- a/panels/keyboard/cc-keyboard-item.c +++ b/panels/keyboard/cc-keyboard-item.c @@ -131,13 +131,18 @@ settings_set_binding (GSettings *settings, g_settings_set_string (settings, key, value ? value : ""); else if (g_variant_is_of_type (variant, G_VARIANT_TYPE_STRING_ARRAY)) { - char **str_array = g_new0 (char *, 2); - - /* clear any additional bindings by only setting the first one */ - *str_array = g_strdup (value); - - g_settings_set_strv (settings, key, (const char * const *)str_array); - g_strfreev (str_array); + if (value == NULL || *value == '\0') + g_settings_set_strv (settings, key, NULL); + else + { + char **str_array = g_new0 (char *, 2); + + /* clear any additional bindings by only setting the first one */ + *str_array = g_strdup (value); + + g_settings_set_strv (settings, key, (const char * const *)str_array); + g_strfreev (str_array); + } } g_variant_unref (variant); -- cgit v1.2.1