[gnome-control-center] keyboard: Special-case disabling of multi-bindings shortcuts



commit 796981d39058e2cd12808d71f510f1d551123af9
Author: Florian Müllner <fmuellner gnome org>
Date:   Thu Jun 29 18:55:40 2017 +0200

    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 files changed, 12 insertions(+), 7 deletions(-)
---
diff --git a/panels/keyboard/cc-keyboard-item.c b/panels/keyboard/cc-keyboard-item.c
index f68d64a..a970a18 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);


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]