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 402168 - Add underline-color and strikethrough-color to GtkTextTag properties
Add underline-color and strikethrough-color to GtkTextTag properties
Status: RESOLVED FIXED
Product: gtk+
Classification: Platform
Component: Widget: GtkTextView
unspecified
Other Linux
: Normal enhancement
: ---
Assigned To: gtk-bugs
gtk-bugs
Depends on:
Blocks: 742900
 
 
Reported: 2007-01-29 18:06 UTC by P. Henrique Silva
Modified: 2015-03-24 13:30 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Add underline-color and strikethrough-color to GtkTextTag (14.40 KB, patch)
2007-01-30 16:22 UTC, P. Henrique Silva
needs-work Details | Review
add support for setting pango underline color (16.83 KB, patch)
2015-02-10 00:53 UTC, Christian Hergert
none Details | Review

Description P. Henrique Silva 2007-01-29 18:06:53 UTC
GtkTextTag have underline and strikethrough gobject properties but there is not a easy way to select a color to display these items. By default they use the foreground color, but sometimes you want to use a different color (use different colors to underline different errors on a source file for example).

GtkTextView have "underline-error-color" style property that deals with the underline-color problem. But this is a style property, so I have to deal with rc files or GtkRCStyle and so on. An direct gobject property would be very nice. And this deals only with PANGO_UNDERLINE_ERROR.

Pango supports this using pango_renderer_set_color and the appropriate PangoRenderPart.
Comment 1 P. Henrique Silva 2007-01-30 16:22:04 UTC
Created attachment 81524 [details] [review]
Add underline-color and strikethrough-color to GtkTextTag

Add underline-color and strikethrough-color to GtkTextTag.

There is a couple of issues with these patch.

Well, it works (in a limited case). I can set underline-color and strikethrough-color and see the corresponding feature in bright colors, but:

 - (Probably) these patch breaks ABI
 - I can't figure from GtkTextAppearance which property user setted on the tag, so I can't fallback to reasonable default (like foreground color to strikethrough and normal underlines, red or underline-error-color style property to PANGO_UNDERLINE_ERROR.

It's a working in progress... just a start... I know that a (much) better patch will be needed to CLOSE this issue.
Comment 2 Matthias Clasen 2007-01-30 17:11:32 UTC
Yes, we can't grow the public structs like this. 

If you want to do something like this, you will probably have
to add a different GtkTextAppearanceExt struct and duplicate
the machinery used to transport properties from tags down to
the renderer for this new struct. Doable, just a fair amount
of work.
Comment 3 P. Henrique Silva 2007-01-30 18:44:50 UTC
I was looking how properties goes from tags to renderer (gtklayout.c, gtkdisplay.c, gtktexttag.c, gtktextview.c) . Everything seems really doable but I can't figure out where to put these new GtkTextAppearanceExt struct. 

These struct need a way to be connected with GtkTextTag.

Maybe add GtkTextAppearanceExt as private data of GtkTextAppearance? (don't look a *good thing* but could works).

Once I figure out how exactly todo this I will try a new patch... I will learn a little bit of GTK+ text rendering internals doing this. :)
Comment 4 Matthias Clasen 2007-01-30 18:51:44 UTC
Yes, GtkTextTag is a GObject, so I would use private data.
Comment 5 Matthias Clasen 2015-01-20 03:33:12 UTC
I actually looked into doing this a while ago while fixing bug 740954, but I ran into some issues and eventually gave up on it.
Comment 6 Christian Hergert 2015-02-10 00:53:57 UTC
Created attachment 296428 [details] [review]
add support for setting pango underline color

This does not address the strikethrough, but it does add "underline-rgba" without modifying public headers.

It does so by stealing a few bytes from padding around GdkColor (sizeof(GdkColor) == 12, but only 10 bytes are used).

I've used a couple of macros to make accessing these bits non-ugly.

We could go the route of the extended structure, but i need this today in Builder and this sort of gets me there.
Comment 7 Matthias Clasen 2015-02-10 19:40:44 UTC
I have to say, I think this is too ugly and fragile. At the very least, it would need some unit test or static assertion to ensure that the abi is unaffected.
Comment 8 Matthias Clasen 2015-03-18 03:26:56 UTC
I changed my mind, and added strikethrough color to this as well.
Comment 9 Murray Cumming 2015-03-24 11:48:59 UTC
This API addition was added to the stable branch after the 3.16.0 release. Was that intentional?
Comment 10 Matthias Clasen 2015-03-24 13:30:05 UTC
I hoped nobody would notice