From 8effcb317ca59f4bdbfd3d64d2f442843e37d81d Mon Sep 17 00:00:00 2001 From: Matthias Clasen Date: Fri, 21 Jan 2011 01:27:23 -0500 Subject: [PATCH] Avoid duplicate entries for custom keybindings The a11y keybindings live in /desktop/gnome/keybindings as well, and we don't want to show them twice. So filter them out. --- panels/keyboard/keyboard-shortcuts.c | 33 +++++++++++++++++++++++++--- 1 file changed, 30 insertions(+), 3 deletions(-) diff --git a/panels/keyboard/keyboard-shortcuts.c b/panels/keyboard/keyboard-shortcuts.c index 0deebc65e..5e9b8b547 100644 --- a/panels/keyboard/keyboard-shortcuts.c +++ b/panels/keyboard/keyboard-shortcuts.c @@ -144,6 +144,28 @@ free_key_array (GPtrArray *keys) } } +static gboolean +has_gconf_key (const gchar *name) +{ + GHashTableIter iter; + GPtrArray *keys; + gint i; + + g_hash_table_iter_init (&iter, kb_sections); + while (g_hash_table_iter_next (&iter, NULL, (gpointer *)&keys)) + { + for (i = 0; i < keys->len; i++) + { + KeyEntry *entry = g_ptr_array_index (keys, i); + + if (g_strcmp0 (name, entry->gconf_key) == 0) + return TRUE; + } + } + + return FALSE; +} + static gboolean should_show_key (const KeyListEntry *entry) { @@ -685,9 +707,14 @@ append_sections_from_gconf (GtkBuilder *builder, const gchar *gconf_path) for (l = custom_list; l != NULL; l = l->next) { key.name = g_strconcat (l->data, "/binding", NULL); - key.cmd_name = g_strconcat (l->data, "/action", NULL); - key.description_name = g_strconcat (l->data, "/name", NULL); - g_array_append_val (entries, key); + if (!has_gconf_key (key.name)) + { + key.cmd_name = g_strconcat (l->data, "/action", NULL); + key.description_name = g_strconcat (l->data, "/name", NULL); + g_array_append_val (entries, key); + } + else + g_free (key.name); g_free (l->data); }