After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 674759 - GtkLabel: wrong value of "mnemonic-keyval" when "use-markup" is true
GtkLabel: wrong value of "mnemonic-keyval" when "use-markup" is true
Status: RESOLVED FIXED
Product: gtk+
Classification: Platform
Component: Widget: GtkLabel
3.7.x
Other Linux
: Normal normal
: ---
Assigned To: gtk-bugs
gtk-bugs
: 738274 (view as bug list)
Depends on:
Blocks:
 
 
Reported: 2012-04-24 20:52 UTC by Sébastien Wilmet
Modified: 2015-02-12 02:54 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
GtkLabel: fix mnemonic-keyval when use-markup is true (3.52 KB, patch)
2012-04-24 21:08 UTC, Sébastien Wilmet
committed Details | Review
GtkLabel: fix underlining of mnemonics (975 bytes, patch)
2013-03-23 15:51 UTC, Sébastien Wilmet
committed Details | Review

Description Sébastien Wilmet 2012-04-24 20:52:24 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.
Comment 1 Sébastien Wilmet 2012-04-24 21:08:11 UTC
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.
Comment 2 Sébastien Wilmet 2012-10-24 16:32:36 UTC
Still applies to the master branch.

The problem is that GtkLabel doesn't have an assigned maintainer:
https://live.gnome.org/GTK%2B/Areas
Comment 3 Matthias Clasen 2013-03-17 20:09:54 UTC
Attachment 212738 [details] pushed as 8e65fa1 - GtkLabel: fix mnemonic-keyval when use-markup is true
Comment 4 Lars Karlitski 2013-03-21 18:01:49 UTC
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,
Comment 5 Sébastien Wilmet 2013-03-23 15:51:30 UTC
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.
Comment 6 Sébastien Wilmet 2013-03-23 16:00:33 UTC
(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.
Comment 7 Matthias Clasen 2013-03-24 03:59:38 UTC
Review of attachment 239629 [details] [review]:

ok
Comment 8 Matthias Clasen 2013-03-24 03:59:49 UTC
Review of attachment 239629 [details] [review]:

ok
Comment 9 Sébastien Wilmet 2013-03-24 14:11:07 UTC
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).
Comment 10 Ryan Schoppmeyer 2015-02-12 02:54:11 UTC
*** Bug 738274 has been marked as a duplicate of this bug. ***