[gnome-control-center/wip/gbsneto/new-keyboard-panel: 4/15] keyboard: add helper method for user-friendly accelerators
- From: Georges Basile Stavracas Neto <gbsneto src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-control-center/wip/gbsneto/new-keyboard-panel: 4/15] keyboard: add helper method for user-friendly accelerators
- Date: Tue, 26 Jul 2016 16:10:48 +0000 (UTC)
commit ad818e62875e8773aee77dcba0fdd3cc1cf99bbe
Author: Georges Basile Stavracas Neto <georges stavracas gmail com>
Date: Fri Jul 22 16:06:18 2016 -0300
keyboard: add helper method for user-friendly accelerators
The accelerator formatting method itself is copied from
GtkCellRendererAccel, and will be used throughout the code
to format the accelerators just like they used to be before
moving to the listbox.
https://bugzilla.gnome.org/show_bug.cgi?id=769063
panels/keyboard/keyboard-shortcuts.c | 29 +++++++++++++++++++++++++++++
panels/keyboard/keyboard-shortcuts.h | 4 ++++
2 files changed, 33 insertions(+), 0 deletions(-)
---
diff --git a/panels/keyboard/keyboard-shortcuts.c b/panels/keyboard/keyboard-shortcuts.c
index 5b59eba..46e1569 100644
--- a/panels/keyboard/keyboard-shortcuts.c
+++ b/panels/keyboard/keyboard-shortcuts.c
@@ -397,3 +397,32 @@ parse_keylist_from_file (const gchar *path)
return keylist;
}
+
+/*
+ * Stolen from GtkCellRendererAccel:
+ * https://git.gnome.org/browse/gtk+/tree/gtk/gtkcellrendereraccel.c#n261
+ */
+gchar*
+convert_keysym_state_to_string (guint keysym,
+ GdkModifierType mask,
+ guint keycode)
+{
+ gchar *name;
+
+ if (keysym == 0 && keycode == 0)
+ {
+ /* This label is displayed in a treeview cell displaying
+ * a disabled accelerator key combination.
+ */
+ name = g_strdup (_("Disabled"));
+ }
+ else
+ {
+ name = gtk_accelerator_get_label_with_keycode (NULL, keysym, keycode, mask);
+
+ if (name == NULL)
+ name = gtk_accelerator_name_with_keycode (NULL, keysym, keycode, mask);
+ }
+
+ return name;
+}
diff --git a/panels/keyboard/keyboard-shortcuts.h b/panels/keyboard/keyboard-shortcuts.h
index 4631b34..ddf8640 100644
--- a/panels/keyboard/keyboard-shortcuts.h
+++ b/panels/keyboard/keyboard-shortcuts.h
@@ -90,3 +90,7 @@ gboolean is_valid_binding (guint keyval,
guint keycode);
KeyList* parse_keylist_from_file (const gchar *path);
+
+gchar* convert_keysym_state_to_string (guint keysym,
+ GdkModifierType mask,
+ guint keycode);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]