GNOME Bugzilla – Bug 676550
Adding underlines to Label with gtk_label_set_pattern() does not work
Last modified: 2017-08-07 11:47:03 UTC
Created attachment 214647 [details] Screenshot of example running on openSuSE Guys, I have really enjoyed the tutorial at http://developer.gnome.org/gtk-tutorial/2.90/ I think I have found an example that needs to be revisited. The example code at http://developer.gnome.org/gtk-tutorial/2.90/c753.html does not produce the format for the labels explained in the comments. Specifically, it produces no underlines at all. I have tested this on both Archlinux and openSuSE 11.4 and with different gtk styles. I have attached screenshots for both. On Archlinux, I have the following installed: gtk 1.2.10-11 gtk2 2.24.10-3 gtk2fontsel 0.1-4 gtk2-perl 1.241-1 gtk3 3.4.2-2 gtk-aurora-engine 1.5.1-3 gtk-engine-murrine 0.98.2-1 gtk-engines 2.20.2-2 On openSuSE: gtk2-data-2.22.1-13.15.1.noarch gtk2-devel-2.22.1-13.15.1.x86_64 gtk2-engine-equinox-1.30.2-5.1.x86_64 gtk2-engine-murrine-0.98.2-34.1.x86_64 gtk2-engine-murrine-32bit-0.98.2-34.1.x86_64 gtk2-engine-nimbus-32bit-0.1.4-6.1.x86_64 gtk2-engines-2.20.2-2.1.x86_64 gtk2-engines-32bit-2.20.2-2.1.x86_64 gtk2-tools-2.22.1-13.15.1.x86_64 gtk3-data-3.0.0-3.3.noarch gtk3-tools-3.0.0-3.3.x86_64 gtk3-tools-32bit-3.0.0-3.3.x86_64 libgtk-2_0-0-2.22.1-13.15.1.x86_64 libgtk-2_0-0-32bit-2.22.1-13.15.1.x86_64 libgtk-3-0-3.0.0-3.3.x86_64 libgtk-3-0-32bit-3.0.0-3.3.x86_64 Being new to coding with gtk, I can't tell what the labels are supposed to do exactly, but when I see: frame = gtk_frame_new ("Underlined label"); label = gtk_label_new ("This label is underlined!\n" "This one is underlined in quite a funky fashion"); gtk_label_set_justify (GTK_LABEL (label), GTK_JUSTIFY_LEFT); gtk_label_set_pattern (GTK_LABEL (label), "_________________________ _ _________ _ ______ __ _______ ___"); And there is NO underline -- something isn't working right. I'll attach the opensuse screenshot first, then the one from Arch.
(In reply to comment #0) > I'll attach the opensuse screenshot first, then the one from Arch. Looks like the second one is missing... Moving to gtk+ as I don't see any gtkmm bug here.
Created attachment 357063 [details] linked demo running on GTK+ 3 The underlines work on GTK+ 3...
Created attachment 357064 [details] linked demo running on GTK+ 2 ...but not on GTK+ 2.
Created attachment 357065 [details] original screenshot from demo documentation Here's what you should have won:
The reason this works on GTK+ 3 is probably because of the fix for https://bugzilla.gnome.org/show_bug.cgi?id=658111 which was not picked to GTK+ 2. That bug explains how adding the label to a container would cause the underline attributes to be lost, and the example you link does this. I repeated the horrifying procedure of building GTK+ 2 again, and cherry-picking that patch fixes this. You will see it pushed to the gtk-2-24 branch shortly. Thanks for reporting this! Shows how rarely people must try to use underline patterns... *** This bug has been marked as a duplicate of bug 658111 ***
Created attachment 357067 [details] screenshot of fixed GTK+ 2.24 because why not
Great work Daniel. That 2 fixes in less than 2 days on 2 of my bugs (even if it was a dup of a gtk3 fix not backported). All we were after were working underlines -- looks like the gtk3 fix applied to gtk2 will fit the bill. Thanks.
You're welcome. Btw, I really like the message on that commit, btw - I love when things say 'Make X work a little better' when, really, they mean 'Make X work at all in major situations'. :P I assume either no one else was actively using that in GTK+ 2, or perhaps (and likely coincidentally) their code was written so as to add all such labels to their container before setting the underline - or maybe that is the effective result when using .ui files and GtkBuilder.