From 409642a1e41b7a0d17877d6f8dc5d50822b8a73f Mon Sep 17 00:00:00 2001 From: Michael Natterer Date: Tue, 12 Oct 2004 13:56:08 +0000 Subject: [PATCH] instead of simply using the passed widget as mnemonic_widget for the 2004-10-12 Michael Natterer * libgimpwidgets/gimpwidgets.c (gimp_table_attach_aligned): instead of simply using the passed widget as mnemonic_widget for the GtkLabel, call the new utility function find_mnemonic_widget() which recursively searches the passed widget until it finds one that actually can be mnemonic-activated. Fixes lots of mnemonics where the attached widget is e.g. a GtkEventBox or GtkComboBox. --- ChangeLog | 9 ++++++++ libgimpwidgets/gimpwidgets.c | 42 +++++++++++++++++++++++++++++++++++- 2 files changed, 50 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 070933bda5..17cf406a31 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,12 @@ +2004-10-12 Michael Natterer + + * libgimpwidgets/gimpwidgets.c (gimp_table_attach_aligned): + instead of simply using the passed widget as mnemonic_widget for + the GtkLabel, call the new utility function find_mnemonic_widget() + which recursively searches the passed widget until it finds one + that actually can be mnemonic-activated. Fixes lots of mnemonics + where the attached widget is e.g. a GtkEventBox or GtkComboBox. + 2004-10-12 Michael Natterer * app/tools/gimptooloptions-gui.[ch]: removed the recently added diff --git a/libgimpwidgets/gimpwidgets.c b/libgimpwidgets/gimpwidgets.c index 4bf5ef0ff3..ac8dc628e5 100644 --- a/libgimpwidgets/gimpwidgets.c +++ b/libgimpwidgets/gimpwidgets.c @@ -1542,6 +1542,40 @@ gimp_unit_menu_update (GtkWidget *widget, * Helper Functions */ +static GtkWidget * +find_mnemonic_widget (GtkWidget *widget, + gint level) +{ + GtkWidget *mnemonic_widget = NULL; + + if (GTK_WIDGET_GET_CLASS (widget)->activate_signal || + GTK_WIDGET_CAN_FOCUS (widget) || + GTK_WIDGET_GET_CLASS (widget)->mnemonic_activate != + GTK_WIDGET_CLASS (g_type_class_peek (GTK_TYPE_WIDGET))->mnemonic_activate) + { + mnemonic_widget = widget; + } + else if (GTK_IS_CONTAINER (widget)) + { + GList *children; + GList *list; + + children = gtk_container_get_children (GTK_CONTAINER (widget)); + + for (list = children; list; list = g_list_next (list)) + { + mnemonic_widget = find_mnemonic_widget (list->data, level + 1); + + if (mnemonic_widget) + break; + } + + g_list_free (children); + } + + return mnemonic_widget; +} + /** * gimp_table_attach_aligned: * @table: The #GtkTable the widgets will be attached to. @@ -1575,6 +1609,8 @@ gimp_table_attach_aligned (GtkTable *table, if (label_text) { + GtkWidget *mnemonic_widget; + label = gtk_label_new_with_mnemonic (label_text); gtk_misc_set_alignment (GTK_MISC (label), xalign, yalign); gtk_label_set_justify (GTK_LABEL (label), GTK_JUSTIFY_LEFT); @@ -1583,7 +1619,11 @@ gimp_table_attach_aligned (GtkTable *table, row, row + 1, GTK_FILL, GTK_FILL, 0, 0); gtk_widget_show (label); - gtk_label_set_mnemonic_widget (GTK_LABEL (label), widget); + + mnemonic_widget = find_mnemonic_widget (widget, 0); + + if (mnemonic_widget) + gtk_label_set_mnemonic_widget (GTK_LABEL (label), mnemonic_widget); } if (left_align)