diff --git a/ChangeLog b/ChangeLog index 10cbf5c8..f5ded007 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2011-04-03 Colomban Wendling + + * src/main.c, src/prefs.c, src/tools.c: + Fix loading and updating menu accelerators for custom commands. + + 2011-04-02 Colomban Wendling * src/tools.c, doc/geany.txt, doc/geany.html: diff --git a/src/main.c b/src/main.c index f5dcd003..403e528b 100644 --- a/src/main.c +++ b/src/main.c @@ -1038,7 +1038,6 @@ gint main(gint argc, gchar **argv) ui_create_insert_menu_items(); ui_create_insert_date_menu_items(); keybindings_init(); - tools_create_insert_custom_command_menu_items(); notebook_init(); filetypes_init(); templates_init(); @@ -1088,6 +1087,10 @@ gint main(gint argc, gchar **argv) /* load keybinding settings after plugins have added their groups */ keybindings_load_keyfile(); + /* create the custom command menu after the keybindings have been loaded to have the proper + * accelerator shown for the menu items */ + tools_create_insert_custom_command_menu_items(); + /* load any command line files or session files */ main_status.opening_session_files = TRUE; load_startup_files(argc, argv); diff --git a/src/prefs.c b/src/prefs.c index dce95a7c..60067ded 100644 --- a/src/prefs.c +++ b/src/prefs.c @@ -59,6 +59,7 @@ #include "templates.h" #include "search.h" #include "toolbar.h" +#include "tools.h" #include "stash.h" #include "keyfile.h" #include "filetypes.h" @@ -1120,6 +1121,7 @@ on_prefs_dialog_response(GtkDialog *dialog, gint response, gpointer user_data) if (edited) { kb_update(); + tools_create_insert_custom_command_menu_items(); keybindings_write_to_file(); } @@ -1342,7 +1344,7 @@ static gboolean kb_grab_key_dialog_key_press_cb(GtkWidget *dialog, GdkEventKey * gchar *str; gint state; - state = event->state & gtk_accelerator_get_default_mod_mask(); + state = event->state & gtk_accelerator_get_default_mod_mask(); if (event->keyval == GDK_Escape) return FALSE; /* close the dialog, don't allow escape when detecting keybindings. */ diff --git a/src/tools.c b/src/tools.c index a2f2d6b9..6d3dd4c5 100644 --- a/src/tools.c +++ b/src/tools.c @@ -660,13 +660,13 @@ static void cc_insert_custom_command_items(GtkMenu *me, gchar *label, gint idx) case 2: key_idx = GEANY_KEYS_FORMAT_SENDTOCMD3; break; } - if (key_idx != -1) - kb = keybindings_lookup_item(GEANY_KEY_GROUP_FORMAT, key_idx); - item = gtk_menu_item_new_with_label(label); if (key_idx != -1) + { + kb = keybindings_lookup_item(GEANY_KEY_GROUP_FORMAT, key_idx); gtk_widget_add_accelerator(item, "activate", gtk_accel_group_new(), kb->key, kb->mods, GTK_ACCEL_VISIBLE); + } gtk_container_add(GTK_CONTAINER(me), item); gtk_widget_show(item); g_signal_connect(item, "activate", G_CALLBACK(cc_on_custom_command_activate),