Mercurial > geeqie.yaz
comparison src/preferences.c @ 1658:d7e07c7fa31b
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
author | nadvornik |
---|---|
date | Wed, 24 Jun 2009 20:31:30 +0000 |
parents | 376b63fd9434 |
children | ae0b1f854f22 |
comparison
equal
deleted
inserted
replaced
1657:376b63fd9434 | 1658:d7e07c7fa31b |
---|---|
991 static void accel_store_edited_cb(GtkCellRendererAccel *accel, gchar *path_string, guint accel_key, GdkModifierType accel_mods, guint hardware_keycode, gpointer user_data) | 991 static void accel_store_edited_cb(GtkCellRendererAccel *accel, gchar *path_string, guint accel_key, GdkModifierType accel_mods, guint hardware_keycode, gpointer user_data) |
992 { | 992 { |
993 GtkTreeModel *model = (GtkTreeModel *)accel_store; | 993 GtkTreeModel *model = (GtkTreeModel *)accel_store; |
994 GtkTreeIter iter; | 994 GtkTreeIter iter; |
995 gchar *acc; | 995 gchar *acc; |
996 gchar *accel_path; | |
997 GtkAccelKey old_key, key; | |
996 GtkTreePath *path = gtk_tree_path_new_from_string(path_string); | 998 GtkTreePath *path = gtk_tree_path_new_from_string(path_string); |
997 | 999 |
998 gtk_tree_model_get_iter(model, &iter, path); | 1000 gtk_tree_model_get_iter(model, &iter, path); |
999 acc = gtk_accelerator_name(accel_key, accel_mods); | 1001 gtk_tree_model_get(model, &iter, AE_ACCEL, &accel_path, -1); |
1000 | 1002 |
1003 /* test if the accelerator can be stored without conflicts*/ | |
1004 gtk_accel_map_lookup_entry(accel_path, &old_key); | |
1005 | |
1006 /* change the key and read it back (change may fail on keys hardcoded in gtk)*/ | |
1007 gtk_accel_map_change_entry(accel_path, accel_key, accel_mods, TRUE); | |
1008 gtk_accel_map_lookup_entry(accel_path, &key); | |
1009 | |
1010 /* restore the original for now, the key will be really changed when the changes are confirmed */ | |
1011 gtk_accel_map_change_entry(accel_path, old_key.accel_key, old_key.accel_mods, TRUE); | |
1012 | |
1013 acc = gtk_accelerator_name(key.accel_key, key.accel_mods); | |
1001 gtk_tree_model_foreach(GTK_TREE_MODEL(accel_store), accel_remove_key_cb, acc); | 1014 gtk_tree_model_foreach(GTK_TREE_MODEL(accel_store), accel_remove_key_cb, acc); |
1002 | 1015 |
1003 gtk_tree_store_set(accel_store, &iter, AE_KEY, acc, -1); | 1016 gtk_tree_store_set(accel_store, &iter, AE_KEY, acc, -1); |
1004 gtk_tree_path_free(path); | 1017 gtk_tree_path_free(path); |
1005 g_free(acc); | 1018 g_free(acc); |