From f90749916a0b4474ed35e881193beb9ddf9f5328 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20M=C3=BCllner?= Date: Mon, 6 Mar 2023 01:43:34 +0100 Subject: [PATCH] prefs: Add get_keybinding_label() method Commit 7e9d9c7eb91 added new API to replace GTK for accelerator parsing. Unfortunately there is another case in gnome-shell, where we have to get the label from the logical binding name rather than the modifier+keysym combination. Add another small method to cover that use case. Part-of: --- src/core/prefs.c | 16 ++++++++++++++++ src/meta/prefs.h | 3 +++ 2 files changed, 19 insertions(+) diff --git a/src/core/prefs.c b/src/core/prefs.c index 82bf58d8c..25a1524af 100644 --- a/src/core/prefs.c +++ b/src/core/prefs.c @@ -2186,6 +2186,22 @@ meta_prefs_get_keybinding_action (const char *name) : META_KEYBINDING_ACTION_NONE; } +/** + * meta_prefs_get_keybinding_label: + * Returns: (transfer full) (nullable) + */ +char * +meta_prefs_get_keybinding_label (const char *name) +{ + MetaKeyPref *pref = g_hash_table_lookup (key_bindings, name); + MetaKeyCombo *combo = NULL; + + if (pref && pref->combos) + combo = pref->combos->data; + + return combo ? meta_accelerator_name (combo->modifiers, combo->keysym) : NULL; +} + gint meta_prefs_get_mouse_button_resize (void) { diff --git a/src/meta/prefs.h b/src/meta/prefs.h index f1c9e5805..d6dd93d74 100644 --- a/src/meta/prefs.h +++ b/src/meta/prefs.h @@ -468,6 +468,9 @@ GType meta_key_binding_get_type (void); META_EXPORT MetaKeyBindingAction meta_prefs_get_keybinding_action (const char *name); +META_EXPORT +char * meta_prefs_get_keybinding_label (const char *name); + META_EXPORT gboolean meta_prefs_get_visual_bell (void);