# HG changeset patch # User nadvornik # Date 1245875490 0 # Node ID c7415c58435b20aa84534eb21da7033d69e73425 # Parent c59e8385328d5f445751b92908385923cbc80589 test if an accelerator can be stored gtk_accel_map_change_entry can't change accelerators to keys like arrows. Test this and show the keys in the list only if they can be really changed. https://sourceforge.net/tracker/?func=detail&aid=2805139&group_id=222125&atid=1054680 diff -r c59e8385328d -r c7415c58435b src/preferences.c --- a/src/preferences.c Tue Jun 23 19:20:48 2009 +0000 +++ b/src/preferences.c Wed Jun 24 20:31:30 2009 +0000 @@ -994,11 +994,24 @@ GtkTreeModel *model = (GtkTreeModel *)accel_store; GtkTreeIter iter; gchar *acc; + gchar *accel_path; + GtkAccelKey old_key, key; GtkTreePath *path = gtk_tree_path_new_from_string(path_string); gtk_tree_model_get_iter(model, &iter, path); - acc = gtk_accelerator_name(accel_key, accel_mods); + gtk_tree_model_get(model, &iter, AE_ACCEL, &accel_path, -1); + + /* test if the accelerator can be stored without conflicts*/ + gtk_accel_map_lookup_entry(accel_path, &old_key); + /* change the key and read it back (change may fail on keys hardcoded in gtk)*/ + gtk_accel_map_change_entry(accel_path, accel_key, accel_mods, TRUE); + gtk_accel_map_lookup_entry(accel_path, &key); + + /* restore the original for now, the key will be really changed when the changes are confirmed */ + gtk_accel_map_change_entry(accel_path, old_key.accel_key, old_key.accel_mods, TRUE); + + acc = gtk_accelerator_name(key.accel_key, key.accel_mods); gtk_tree_model_foreach(GTK_TREE_MODEL(accel_store), accel_remove_key_cb, acc); gtk_tree_store_set(accel_store, &iter, AE_KEY, acc, -1);