summaryrefslogtreecommitdiff
path: root/gtk/gtktextattributes.c
diff options
context:
space:
mode:
authorChristian Hergert <christian@hergert.me>2015-02-09 16:41:48 -0800
committerMatthias Clasen <mclasen@redhat.com>2015-03-17 23:24:13 -0400
commit28063ee2e42e7ce47b7bd5326f2d53875a377d57 (patch)
treece7c2ca0667be5fee723de429ff60d1195cbe822 /gtk/gtktextattributes.c
parent416c370da1d2eff2458e4a0c5b8e504cd8061559 (diff)
downloadgtk+-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/gtktextattributes.c')
-rw-r--r--gtk/gtktextattributes.c23
1 files changed, 22 insertions, 1 deletions
diff --git a/gtk/gtktextattributes.c b/gtk/gtktextattributes.c
index b864f39bd3..dc1360caf5 100644
--- a/gtk/gtktextattributes.c
+++ b/gtk/gtktextattributes.c
@@ -50,6 +50,7 @@
#include "config.h"
#include "gtktextattributes.h"
+#include "gtktextattributesprivate.h"
#include "gtktexttagprivate.h"
/**
@@ -363,9 +364,27 @@ G_GNUC_END_IGNORE_DEPRECATIONS
if (tag->priv->underline_set)
dest->appearance.underline = vals->appearance.underline;
+ if (GTK_TEXT_APPEARANCE_GET_UNDERLINE_RGBA_SET (&vals->appearance))
+ {
+ GdkRGBA rgba;
+
+ GTK_TEXT_APPEARANCE_GET_UNDERLINE_RGBA (&vals->appearance, &rgba);
+ GTK_TEXT_APPEARANCE_SET_UNDERLINE_RGBA (&dest->appearance, &rgba);
+ GTK_TEXT_APPEARANCE_SET_UNDERLINE_RGBA_SET (&dest->appearance, TRUE);
+ }
+
if (tag->priv->strikethrough_set)
dest->appearance.strikethrough = vals->appearance.strikethrough;
+ if (GTK_TEXT_APPEARANCE_GET_STRIKETHROUGH_RGBA_SET (&vals->appearance))
+ {
+ GdkRGBA rgba;
+
+ GTK_TEXT_APPEARANCE_GET_STRIKETHROUGH_RGBA (&vals->appearance, &rgba);
+ GTK_TEXT_APPEARANCE_SET_STRIKETHROUGH_RGBA (&dest->appearance, &rgba);
+ GTK_TEXT_APPEARANCE_SET_STRIKETHROUGH_RGBA_SET (&dest->appearance, TRUE);
+ }
+
if (tag->priv->invisible_set)
dest->invisible = vals->invisible;
@@ -425,5 +444,7 @@ _gtk_text_tag_affects_nonsize_appearance (GtkTextTag *tag)
priv->strikethrough_set ||
priv->bg_full_height_set ||
priv->pg_bg_color_set ||
- priv->fallback_set;
+ priv->fallback_set ||
+ GTK_TEXT_APPEARANCE_GET_UNDERLINE_RGBA_SET (&priv->values->appearance) ||
+ GTK_TEXT_APPEARANCE_GET_STRIKETHROUGH_RGBA_SET (&priv->values->appearance);
}