diff --git a/ChangeLog b/ChangeLog index 8bf283ae80..6422b2dfa2 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,14 @@ +2006-05-11 Michael Natterer + + Applied modified patch from Michael J. Hammel which allows to + remove all keyboard shortcuts from the menus (fixes bug #331839): + + * app/dialogs/preferences-dialog.c: added "Remove all keyboard + shortcuts" button to the "Interface" section. + + * app/menus/menus.[ch]: added menus_remove() which does the + shortcut removal. + 2006-05-10 Michael Natterer * app/widgets/gimpviewrendererbrush.c diff --git a/app/dialogs/preferences-dialog.c b/app/dialogs/preferences-dialog.c index 16bc6a6c82..1d9d4ecaa4 100644 --- a/app/dialogs/preferences-dialog.c +++ b/app/dialogs/preferences-dialog.c @@ -44,6 +44,8 @@ #include "widgets/gimpdialogfactory.h" #include "widgets/gimpgrideditor.h" #include "widgets/gimphelp-ids.h" +#include "widgets/gimpmessagebox.h" +#include "widgets/gimpmessagedialog.h" #include "widgets/gimppropwidgets.h" #include "widgets/gimptemplateeditor.h" #include "widgets/gimpwidgets-utils.h" @@ -91,6 +93,8 @@ static void prefs_menus_save_callback (GtkWidget *widget, Gimp *gimp); static void prefs_menus_clear_callback (GtkWidget *widget, Gimp *gimp); +static void prefs_menus_remove_callback (GtkWidget *widget, + Gimp *gimp); static void prefs_session_save_callback (GtkWidget *widget, Gimp *gimp); static void prefs_session_clear_callback (GtkWidget *widget, @@ -509,6 +513,45 @@ prefs_menus_clear_callback (GtkWidget *widget, } } +static void +prefs_menus_remove_callback (GtkWidget *widget, + Gimp *gimp) +{ + GtkWidget *dialog; + + dialog = gimp_message_dialog_new (_("Remove all Keyboard Shortcuts"), + GIMP_STOCK_QUESTION, + gtk_widget_get_toplevel (widget), + GTK_DIALOG_MODAL | + GTK_DIALOG_DESTROY_WITH_PARENT, + gimp_standard_help_func, NULL, + + GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, + GTK_STOCK_CLEAR, GTK_RESPONSE_OK, + + NULL); + + gtk_dialog_set_alternative_button_order (GTK_DIALOG (dialog), + GTK_RESPONSE_OK, + GTK_RESPONSE_CANCEL, + -1); + + g_signal_connect_object (gtk_widget_get_toplevel (widget), "unmap", + G_CALLBACK (gtk_widget_destroy), + dialog, G_CONNECT_SWAPPED); + + gimp_message_box_set_primary_text (GIMP_MESSAGE_DIALOG (dialog)->box, + _("Do you really want to remove all " + "keyboard shortcuts from all menus?")); + + if (gimp_dialog_run (GIMP_DIALOG (dialog)) == GTK_RESPONSE_OK) + { + menus_remove (gimp); + } + + gtk_widget_destroy (dialog); +} + static void prefs_session_save_callback (GtkWidget *widget, Gimp *gimp) @@ -1451,6 +1494,13 @@ prefs_dialog_new (Gimp *gimp, g_object_set_data (G_OBJECT (button), "clear-button", button2); + button = prefs_button_add (GTK_STOCK_CLEAR, + _("Remove _All Keyboard Shortcuts"), + GTK_BOX (vbox2)); + g_signal_connect (button, "clicked", + G_CALLBACK (prefs_menus_remove_callback), + gimp); + /***********/ /* Theme */ diff --git a/app/menus/menus.c b/app/menus/menus.c index 51fb23d8af..a565c4b6b9 100644 --- a/app/menus/menus.c +++ b/app/menus/menus.c @@ -54,7 +54,12 @@ /* local function prototypes */ -static void menus_can_change_accels (GimpGuiConfig *config); +static void menus_can_change_accels (GimpGuiConfig *config); +static void menus_remove_accels (gpointer data, + const gchar *accel_path, + guint accel_key, + GdkModifierType accel_mods, + gboolean changed); /* global variables */ @@ -424,6 +429,14 @@ menus_clear (Gimp *gimp, return success; } +void +menus_remove (Gimp *gimp) +{ + g_return_if_fail (GIMP_IS_GIMP (gimp)); + + gtk_accel_map_foreach (gimp, menus_remove_accels); +} + /* private functions */ @@ -434,3 +447,13 @@ menus_can_change_accels (GimpGuiConfig *config) "gtk-can-change-accels", config->can_change_accels, NULL); } + +static void +menus_remove_accels (gpointer data, + const gchar *accel_path, + guint accel_key, + GdkModifierType accel_mods, + gboolean changed) +{ + gtk_accel_map_change_entry (accel_path, 0, 0, TRUE); +} diff --git a/app/menus/menus.h b/app/menus/menus.h index 7ef6a78cc8..050b55eb02 100644 --- a/app/menus/menus.h +++ b/app/menus/menus.h @@ -33,6 +33,7 @@ void menus_save (Gimp *gimp, gboolean menus_clear (Gimp *gimp, GError **error); +void menus_remove (Gimp *gimp); #endif /* __MENUS_H__ */