gnome-control-center r9083 - in trunk: . capplets/keybindings
- From: matthiasc svn gnome org
- To: svn-commits-list gnome org
- Subject: gnome-control-center r9083 - in trunk: . capplets/keybindings
- Date: Mon, 20 Oct 2008 00:34:57 +0000 (UTC)
Author: matthiasc
Date: Mon Oct 20 00:34:57 2008
New Revision: 9083
URL: http://svn.gnome.org/viewvc/gnome-control-center?rev=9083&view=rev
Log:
2008-10-19 Matthias Clasen <mclasen redhat com>
Bug 556977 â avoid duplicate custom keybindings
* capplets/keybindings/gnome-keybinding-properties.c: Filter
out custom keybindings that are also listed in xml files.
Modified:
trunk/ChangeLog
trunk/capplets/keybindings/gnome-keybinding-properties.c
Modified: trunk/capplets/keybindings/gnome-keybinding-properties.c
==============================================================================
--- trunk/capplets/keybindings/gnome-keybinding-properties.c (original)
+++ trunk/capplets/keybindings/gnome-keybinding-properties.c Mon Oct 20 00:34:57 2008
@@ -361,6 +361,42 @@
gtk_widget_set_usize (WID ("actions_swindow"), -1, -1);
}
+typedef struct {
+ const char *key;
+ gboolean found;
+} KeyMatchData;
+
+static gboolean
+key_match (GtkTreeModel *model, GtkTreePath *path, GtkTreeIter *iter, gpointer data)
+{
+ KeyMatchData *match_data = data;
+ KeyEntry *element;
+
+ gtk_tree_model_get (model, iter,
+ KEYENTRY_COLUMN, &element,
+ -1);
+
+ if (element && g_strcmp0 (element->gconf_key, match_data->key) == 0)
+ {
+ match_data->found = TRUE;
+ return TRUE;
+ }
+
+ return FALSE;
+}
+
+static gboolean
+key_is_already_shown (GtkTreeModel *model, const KeyListEntry *entry)
+{
+ KeyMatchData data;
+
+ data.key = entry->name;
+ data.found = FALSE;
+ gtk_tree_model_foreach (model, key_match, &data);
+
+ return data.found;
+}
+
static gboolean
should_show_key (const KeyListEntry *entry)
{
@@ -432,6 +468,7 @@
GtkTreeModel *model;
gboolean found;
gint i, j;
+ gint rows_before;
client = gconf_client_get_default ();
model = gtk_tree_view_get_model (GTK_TREE_VIEW (WID ("shortcut_treeview")));
@@ -473,6 +510,7 @@
* then we need to scroll now */
ensure_scrollbar (dialog, i - 1);
+ rows_before = i;
for (j = 0; keys_list[j].name != NULL; j++)
{
GConfEntry *entry;
@@ -484,6 +522,9 @@
if (!should_show_key (&keys_list[j]))
continue;
+ if (key_is_already_shown (model, &keys_list[j]))
+ continue;
+
key_string = keys_list[j].name;
entry = gconf_client_get_entry (client,
@@ -556,9 +597,13 @@
-1);
gtk_tree_view_expand_all (GTK_TREE_VIEW (WID ("shortcut_treeview")));
}
-
+
g_object_unref (client);
+ /* Don't show an empty section */
+ if (i == rows_before)
+ gtk_tree_store_remove (GTK_TREE_STORE (model), &parent_iter);
+
if (i == 0)
gtk_widget_hide (WID ("shortcuts_vbox"));
else
@@ -850,6 +895,11 @@
}
g_list_free (list);
+ /* Load custom shortcuts _after_ system-provided ones,
+ * since some of the custom shortcuts may also be listed
+ * in a file. Loading the custom shortcuts last makes
+ * such keys not show up in the custom section.
+ */
append_keys_to_tree_from_gconf (dialog, GCONF_BINDING_DIR);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]