[mutter/wip/carlosg/pad-ring-strip-action-labels: 3/5] core: Handle mixture of keycombo/no action in pad rings/strips




commit 101cae03f3ae3f74d0cfc64280f19e9ad23345ac
Author: Carlos Garnacho <carlosg gnome org>
Date:   Fri Jul 16 12:44:19 2021 +0200

    core: Handle mixture of keycombo/no action in pad rings/strips
    
    When generating the action label, we expect both directions of these
    features to have consistent settings (either both get a keycombo, or
    they don't) or these just return NULL altogether.
    
    Since one of the directions has an action associated, this is
    misleading, so be more lenient at the time of generating the action
    label.
    
    Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2001>

 src/core/meta-pad-action-mapper.c | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)
---
diff --git a/src/core/meta-pad-action-mapper.c b/src/core/meta-pad-action-mapper.c
index 7c78c40148..88634c32cb 100644
--- a/src/core/meta-pad-action-mapper.c
+++ b/src/core/meta-pad-action-mapper.c
@@ -704,12 +704,18 @@ compose_directional_action_label (GSettings *direction1,
                                   GSettings *direction2)
 {
   char *accel1, *accel2, *str = NULL;
+  /* TRANSLATORS: This is a (non) action on an input device gadget */
+  const char *none_label = N_("None");
 
   accel1 = g_settings_get_string (direction1, "keybinding");
   accel2 = g_settings_get_string (direction2, "keybinding");
 
-  if (accel1 && *accel1 && accel2 && *accel2)
-    str = g_strdup_printf ("%s / %s", accel1, accel2);
+  if ((accel1 && *accel1) || (accel2 && *accel2))
+    {
+      str = g_strdup_printf ("%s / %s",
+                             (accel1 && *accel1) ? accel1 : _(none_label),
+                             (accel2 && *accel2) ? accel2 : _(none_label));
+    }
 
   g_free (accel1);
   g_free (accel2);


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