GNOME Bugzilla – Bug 674759
GtkLabel: wrong value of "mnemonic-keyval" when "use-markup" is true
Last modified: 2015-02-12 02:54:11 UTC
If the "use-markup" property is true, and if there is a mnemonic for the label, sometimes the "mnemonic-keyval" property have the value GDK_KEY_VoidSymbol, but it should always have the value defined by the text label. More precisely, it happens when the "gtk-auto-mnemonics" setting is true and when the Alt key is not pressed (so the "_" is not visible). If "use-markup" is false, this doesn't happen. I'll attach a patch soon.
Created attachment 212738 [details] [review] GtkLabel: fix mnemonic-keyval when use-markup is true To extract the mnemonic key value, the string must contain the underscore. But when the "gtk-auto-mnemonics" setting is true and when the Alt key is not pressed, the underscore must not be displayed. The problem was that the 'new_str' variable was used for both purposes: extract the text to display, and extract the accelerator character. When the underscore must not be visible, the underscores were removed from the 'new_str' variable before extracting the accelerator character. Now there are two strings, one for each purpose.
Still applies to the master branch. The problem is that GtkLabel doesn't have an assigned maintainer: https://live.gnome.org/GTK%2B/Areas
Attachment 212738 [details] pushed as 8e65fa1 - GtkLabel: fix mnemonic-keyval when use-markup is true
This breaks in at least one case: the global menu in unity now shows the underscores in front of the mnemonic instead of underlining it (e.g., _Save). It seems that str_for_display isn't passed into separate_uline_pattern() in all cases. For unity, enable_mnemonics, priv->mnemonics_visible, and auto_mnemonics are all true, and the widget is sensitive. This would also fix the issue: @@ -2570,7 +2570,7 @@ gtk_label_set_markup_internal (GtkLabel *label, /* Extract the text to display */ if (!pango_parse_markup (str_for_display, -1, - 0, + with_uline ? '_' : 0, &attrs, &text, NULL,
Created attachment 239629 [details] [review] GtkLabel: fix underlining of mnemonics The underscore was shown in front of the mnemonic instead of underlining it (e.g., _Save). Thanks to Lars Uebernickel.
(In reply to comment #4) > This breaks in at least one case: the global menu in unity now shows the > underscores in front of the mnemonic instead of underlining it (e.g., _Save). I can reproduce the bug, sorry for the inconvenience, I should have better tested the previous commit.
Review of attachment 239629 [details] [review]: ok
Comment on attachment 239629 [details] [review] GtkLabel: fix underlining of mnemonics Pushed to the master branch. I see that the previous commit was applied to gtk-3-8 too, so it should be fixed for 3.8.1 for example (or 3.8.0, but there is the hard code freeze).
*** Bug 738274 has been marked as a duplicate of this bug. ***