diff options
author | Bastien Nocera <hadess@hadess.net> | 2011-04-13 12:51:00 +0100 |
---|---|---|
committer | Bastien Nocera <hadess@hadess.net> | 2011-04-13 12:51:54 +0100 |
commit | 995be4e6f00c3fde876ea6e74b60b1e4f53a3c17 (patch) | |
tree | 50fafe36caebc2f13e1783f3e60c50dadc25fe0e | |
parent | 0f3cf2286f3b8095f40ea7847d41947c7b3f3443 (diff) | |
download | gnome-control-center-995be4e6f00c3fde876ea6e74b60b1e4f53a3c17.tar.gz |
keyboard: Handle shortcuts conflict in different section
https://bugzilla.gnome.org/show_bug.cgi?id=646504
-rw-r--r-- | panels/keyboard/keyboard-shortcuts.c | 42 |
1 files changed, 31 insertions, 11 deletions
diff --git a/panels/keyboard/keyboard-shortcuts.c b/panels/keyboard/keyboard-shortcuts.c index 1a848f3aa..298200772 100644 --- a/panels/keyboard/keyboard-shortcuts.c +++ b/panels/keyboard/keyboard-shortcuts.c @@ -1213,18 +1213,12 @@ typedef struct { } CcUniquenessData; static gboolean -cb_check_for_uniqueness (GtkTreeModel *model, - GtkTreePath *path, - GtkTreeIter *iter, - CcUniquenessData *data) +compare_keys_for_uniqueness (CcKeyboardItem *element, + CcUniquenessData *data) { - CcKeyboardItem *element; CcKeyboardItem *orig_item; orig_item = data->orig_item; - gtk_tree_model_get (orig_item->model, iter, - DETAIL_KEYENTRY_COLUMN, &element, - -1); /* no conflict for : blanks, different modifiers, or ourselves */ if (element == NULL || data->new_mask != element->mask || @@ -1242,6 +1236,24 @@ cb_check_for_uniqueness (GtkTreeModel *model, return TRUE; } +static gboolean +cb_check_for_uniqueness (gpointer key, + GPtrArray *keys_array, + CcUniquenessData *data) +{ + guint i; + + for (i = 0; i < keys_array->len; i++) + { + CcKeyboardItem *item; + + item = keys_array->pdata[i]; + if (compare_keys_for_uniqueness (item, data)) + return TRUE; + } + return FALSE; +} + static void accel_edited_callback (GtkCellRendererText *cell, const char *path_string, @@ -1280,9 +1292,17 @@ accel_edited_callback (GtkCellRendererText *cell, data.conflict_item = NULL; if (keyval != 0 || keycode != 0) /* any number of shortcuts can be disabled */ - gtk_tree_model_foreach (model, - (GtkTreeModelForeachFunc) cb_check_for_uniqueness, - &data); + { + BindingGroupType i; + + for (i = BINDING_GROUP_SYSTEM; i <= BINDING_GROUP_USER && data.conflict_item == NULL; i++) + { + GHashTable *table; + + table = get_hash_for_group (i); + g_hash_table_find (table, (GHRFunc) cb_check_for_uniqueness, &data); + } + } /* Check for unmodified keys */ if (mask == 0 && keycode != 0) |