diff options
author | Christian Hergert <christian@hergert.me> | 2015-02-09 16:41:48 -0800 |
---|---|---|
committer | Matthias Clasen <mclasen@redhat.com> | 2015-03-17 23:24:13 -0400 |
commit | 28063ee2e42e7ce47b7bd5326f2d53875a377d57 (patch) | |
tree | ce7c2ca0667be5fee723de429ff60d1195cbe822 /gtk/gtktextdisplay.c | |
parent | 416c370da1d2eff2458e4a0c5b8e504cd8061559 (diff) | |
download | gtk+-28063ee2e42e7ce47b7bd5326f2d53875a377d57.tar.gz |
textview: add support for underline and strikethrough colors
This commit adds the GtkTextTag:underline-rgba and :strikethrough-rgba
properties and the necessary plumbing to apply these colors in GtkTextLayout.
With this change, you can alter the color of underlines including those
of type PANGO_UNDERLINE_ERROR.
You might want to alter the underline color to differentiate between
spelling and grammer mistakes. In code editors, it is convenient to
differentiate between errors and warnings.
Note that the GtkTextAppearance struct is public ABI and has no spare
room for new fields, so we are resorting to some tricky packing to store
the colors in the unused pixel field of the fg_color and bg_color structs.
This packing is accomplished by the macros in gtktextattributesprivate.h.
Signed-off-by: Christian Hergert <christian@hergert.me>
https://bugzilla.gnome.org/show_bug.cgi?id=402168
Diffstat (limited to 'gtk/gtktextdisplay.c')
-rw-r--r-- | gtk/gtktextdisplay.c | 21 |
1 files changed, 19 insertions, 2 deletions
diff --git a/gtk/gtktextdisplay.c b/gtk/gtktextdisplay.c index 6be8fe2c8c..f817801880 100644 --- a/gtk/gtktextdisplay.c +++ b/gtk/gtktextdisplay.c @@ -75,6 +75,7 @@ #define GTK_TEXT_USE_INTERNAL_UNSUPPORTED_API #include "config.h" +#include "gtktextattributesprivate.h" #include "gtktextdisplay.h" #include "gtkwidgetprivate.h" #include "gtkstylecontextprivate.h" @@ -204,9 +205,25 @@ gtk_text_renderer_prepare_run (PangoRenderer *renderer, fg_rgba = appearance->rgba[1]; text_renderer_set_rgba (text_renderer, PANGO_RENDER_PART_FOREGROUND, fg_rgba); - text_renderer_set_rgba (text_renderer, PANGO_RENDER_PART_STRIKETHROUGH, fg_rgba); - if (appearance->underline == PANGO_UNDERLINE_ERROR) + if (GTK_TEXT_APPEARANCE_GET_STRIKETHROUGH_RGBA_SET (appearance)) + { + GdkRGBA rgba; + + GTK_TEXT_APPEARANCE_GET_STRIKETHROUGH_RGBA (appearance, &rgba); + text_renderer_set_rgba (text_renderer, PANGO_RENDER_PART_STRIKETHROUGH, &rgba); + } + else + text_renderer_set_rgba (text_renderer, PANGO_RENDER_PART_STRIKETHROUGH, fg_rgba); + + if (GTK_TEXT_APPEARANCE_GET_UNDERLINE_RGBA_SET (appearance)) + { + GdkRGBA rgba; + + GTK_TEXT_APPEARANCE_GET_UNDERLINE_RGBA (appearance, &rgba); + text_renderer_set_rgba (text_renderer, PANGO_RENDER_PART_UNDERLINE, &rgba); + } + else if (appearance->underline == PANGO_UNDERLINE_ERROR) { if (!text_renderer->error_color) { |