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 676550 - Adding underlines to Label with gtk_label_set_pattern() does not work
Adding underlines to Label with gtk_label_set_pattern() does not work
Status: RESOLVED DUPLICATE of bug 658111
Product: gtk+
Classification: Platform
Component: Widget: GtkLabel
2.24.x
Other All
: Normal normal
: ---
Assigned To: gtk-bugs
gtk-bugs
Depends on:
Blocks:
 
 
Reported: 2012-05-22 11:40 UTC by David C. Rankin
Modified: 2017-08-07 11:47 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Screenshot of example running on openSuSE (38.49 KB, image/jpeg)
2012-05-22 11:40 UTC, David C. Rankin
Details
linked demo running on GTK+ 3 (45.51 KB, image/png)
2017-08-06 17:50 UTC, Daniel Boles
Details
linked demo running on GTK+ 2 (47.41 KB, image/png)
2017-08-06 17:50 UTC, Daniel Boles
Details
original screenshot from demo documentation (16.95 KB, image/png)
2017-08-06 17:51 UTC, Daniel Boles
Details
screenshot of fixed GTK+ 2.24 (46.86 KB, image/png)
2017-08-06 18:57 UTC, Daniel Boles
Details

Description David C. Rankin 2012-05-22 11:40:39 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.
Comment 1 André Klapper 2012-05-22 20:30:04 UTC
(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.
Comment 2 Daniel Boles 2017-08-06 17:50:04 UTC
Created attachment 357063 [details]
linked demo running on GTK+ 3

The underlines work on GTK+ 3...
Comment 3 Daniel Boles 2017-08-06 17:50:27 UTC
Created attachment 357064 [details]
linked demo running on GTK+ 2

...but not on GTK+ 2.
Comment 4 Daniel Boles 2017-08-06 17:51:34 UTC
Created attachment 357065 [details]
original screenshot from demo documentation

Here's what you should have won:
Comment 5 Daniel Boles 2017-08-06 18:05:53 UTC
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 ***
Comment 6 Daniel Boles 2017-08-06 18:57:11 UTC
Created attachment 357067 [details]
screenshot of fixed GTK+ 2.24

because why not
Comment 7 David C. Rankin 2017-08-07 07:52:27 UTC
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.
Comment 8 Daniel Boles 2017-08-07 11:47:03 UTC
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.