From 9e418d7aafeb1aa482255c723a095f2f92572c69 Mon Sep 17 00:00:00 2001 From: Nick Treleaven Date: Tue, 3 Apr 2012 16:56:32 +0100 Subject: [PATCH] Show overridden keybindings in bold for prefs dialog tree --- src/keybindings.c | 2 ++ src/keybindings.h | 2 ++ src/prefs.c | 18 +++++++++++++----- 3 files changed, 17 insertions(+), 5 deletions(-) diff --git a/src/keybindings.c b/src/keybindings.c index e58b7611..61c7582f 100644 --- a/src/keybindings.c +++ b/src/keybindings.c @@ -167,6 +167,8 @@ GeanyKeyBinding *keybindings_set_item(GeanyKeyGroup *group, gsize key_id, } kb->key = key; kb->mods = mod; + kb->default_key = key; + kb->default_mods = mod; kb->callback = callback; kb->menu_item = menu_item; kb->id = key_id; diff --git a/src/keybindings.h b/src/keybindings.h index 51e94e32..6af79aaa 100644 --- a/src/keybindings.h +++ b/src/keybindings.h @@ -42,6 +42,8 @@ typedef struct GeanyKeyBinding GeanyKeyCallback callback; GtkWidget *menu_item; /**< Optional widget to set an accelerator for, or @c NULL */ guint id; + guint default_key; + GdkModifierType default_mods; } GeanyKeyBinding; diff --git a/src/prefs.c b/src/prefs.c index e9e126b9..993d4829 100644 --- a/src/prefs.c +++ b/src/prefs.c @@ -140,7 +140,9 @@ enum KB_TREE_ACTION, KB_TREE_SHORTCUT, KB_TREE_INDEX, - KB_TREE_EDITABLE + KB_TREE_EDITABLE, + KB_TREE_WEIGHT, + KB_TREE_COLUMNS }; @@ -279,17 +281,20 @@ static void kb_init_tree(void) tree = GTK_TREE_VIEW(ui_lookup_widget(ui_widgets.prefs_dialog, "treeview7")); - store = gtk_tree_store_new(4, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_INT, G_TYPE_BOOLEAN); + store = gtk_tree_store_new(KB_TREE_COLUMNS, + G_TYPE_STRING, G_TYPE_STRING, G_TYPE_INT, G_TYPE_BOOLEAN, G_TYPE_INT); gtk_tree_view_set_model(GTK_TREE_VIEW(tree), GTK_TREE_MODEL(store)); g_object_unref(store); renderer = gtk_cell_renderer_text_new(); - column = gtk_tree_view_column_new_with_attributes(_("Action"), renderer, "text", KB_TREE_ACTION, NULL); + column = gtk_tree_view_column_new_with_attributes(_("Action"), renderer, + "text", KB_TREE_ACTION, "weight", KB_TREE_WEIGHT, NULL); gtk_tree_view_append_column(GTK_TREE_VIEW(tree), column); renderer = gtk_cell_renderer_text_new(); column = gtk_tree_view_column_new_with_attributes(_("Shortcut"), renderer, - "text", KB_TREE_SHORTCUT, "editable", KB_TREE_EDITABLE, NULL); + "text", KB_TREE_SHORTCUT, "editable", KB_TREE_EDITABLE, + "weight", KB_TREE_WEIGHT, NULL); gtk_tree_view_append_column(GTK_TREE_VIEW(tree), column); /* set policy settings for the scrolled window around the treeview again, because glade @@ -329,7 +334,10 @@ static void kb_init(void) key_string = gtk_accelerator_name(kb->key, kb->mods); gtk_tree_store_append(store, &iter, &parent); gtk_tree_store_set(store, &iter, KB_TREE_ACTION, label, - KB_TREE_SHORTCUT, key_string, KB_TREE_EDITABLE, TRUE, KB_TREE_INDEX, kb->id, -1); + KB_TREE_SHORTCUT, key_string, KB_TREE_EDITABLE, TRUE, + KB_TREE_INDEX, kb->id, -1); + if (kb->key != kb->default_key || kb->mods != kb->default_mods) + gtk_tree_store_set(store, &iter, KB_TREE_WEIGHT, PANGO_WEIGHT_BOLD, -1); g_free(key_string); g_free(label); }