[gnome-settings-daemon/wip/benzea/multiple-keybindings: 13/15] media-keys: Drop user set value if it used to be the default



commit 28684f88ef9d36e91450c72aa7babd54aa7d459d
Author: Benjamin Berg <bberg redhat com>
Date:   Mon May 13 22:02:55 2019 +0200

    media-keys: Drop user set value if it used to be the default
    
    Drop the user defined key if it is equivalent to the default value. The
    reason to do is that we will migrate almost all old default values into
    other setting keys. This allows the user to both keep the default and
    set their own value.

 plugins/media-keys/gsd-media-keys-manager.c | 8 ++++++++
 1 file changed, 8 insertions(+)
---
diff --git a/plugins/media-keys/gsd-media-keys-manager.c b/plugins/media-keys/gsd-media-keys-manager.c
index d02d317b..0c3f8dfe 100644
--- a/plugins/media-keys/gsd-media-keys-manager.c
+++ b/plugins/media-keys/gsd-media-keys-manager.c
@@ -3180,6 +3180,7 @@ map_keybinding (GVariant *variant, GVariant *old_default, GVariant *new_default)
 {
         g_autoptr(GPtrArray) array = g_ptr_array_new ();
         g_autofree const gchar **defaults = NULL;
+        const gchar *old_default_value;
         const gchar **pos;
         const gchar *value;
 
@@ -3187,6 +3188,13 @@ map_keybinding (GVariant *variant, GVariant *old_default, GVariant *new_default)
         pos = defaults;
 
         value = g_variant_get_string (variant, NULL);
+        old_default_value = g_variant_get_string (old_default, NULL);
+
+        /* Reset the keybinding configuration even if the user has the default
+         * configured explicitly (as the key will be bound by the corresponding
+         * static binding now). */
+        if (g_strcmp0 (value, old_default_value) == 0)
+                return NULL;
 
         /* If the user has a custom value that is not in the list, then
          * insert it instead of the first default entry. */


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