1
0
Fork 0

prefs: Add get_keybinding_label() method

Commit 7e9d9c7eb9 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: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2899>
This commit is contained in:
Florian Müllner 2023-03-06 01:43:34 +01:00
parent 3ac82a58c5
commit f90749916a
2 changed files with 19 additions and 0 deletions

View file

@ -2186,6 +2186,22 @@ meta_prefs_get_keybinding_action (const char *name)
: META_KEYBINDING_ACTION_NONE; : 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 gint
meta_prefs_get_mouse_button_resize (void) meta_prefs_get_mouse_button_resize (void)
{ {

View file

@ -468,6 +468,9 @@ GType meta_key_binding_get_type (void);
META_EXPORT META_EXPORT
MetaKeyBindingAction meta_prefs_get_keybinding_action (const char *name); MetaKeyBindingAction meta_prefs_get_keybinding_action (const char *name);
META_EXPORT
char * meta_prefs_get_keybinding_label (const char *name);
META_EXPORT META_EXPORT
gboolean meta_prefs_get_visual_bell (void); gboolean meta_prefs_get_visual_bell (void);