summaryrefslogtreecommitdiff
path: root/gtk/gtktextutil.c
diff options
context:
space:
mode:
authorMatthias Clasen <mclasen@redhat.com>2016-10-28 16:58:12 -0400
committerMatthias Clasen <mclasen@redhat.com>2016-11-01 13:58:10 -0400
commit6e178aede26f903d573032f6dd4a679b30923cfc (patch)
tree0c6afcde29331a12a99436101a986f2d04289fab /gtk/gtktextutil.c
parente6d5a3dce2f189eb35a91cc4e96f6138ef39128d (diff)
downloadgtk+-6e178aede26f903d573032f6dd4a679b30923cfc.tar.gz
Use GdkRGBA for text attributes
Now that GtkTextAttributes is private, we can clean this struct up a bit. The first step is to switch from GdkColor to GdkRGBA, and adapt all users.
Diffstat (limited to 'gtk/gtktextutil.c')
-rw-r--r--gtk/gtktextutil.c19
1 files changed, 8 insertions, 11 deletions
diff --git a/gtk/gtktextutil.c b/gtk/gtktextutil.c
index 13ea2a552f..e4452db7e0 100644
--- a/gtk/gtktextutil.c
+++ b/gtk/gtktextutil.c
@@ -256,20 +256,17 @@ static void
set_attributes_from_style (GtkStyleContext *context,
GtkTextAttributes *values)
{
- GdkRGBA bg_color, fg_color;
+ const GdkRGBA black = { 0, };
+
+ if (!values->appearance.bg_rgba)
+ values->appearance.bg_rgba = gdk_rgba_copy (&black);
+ if (!values->appearance.fg_rgba)
+ values->appearance.fg_rgba = gdk_rgba_copy (&black);
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
- gtk_style_context_get_background_color (context, &bg_color);
+ gtk_style_context_get_background_color (context, values->appearance.bg_rgba);
G_GNUC_END_IGNORE_DEPRECATIONS
- gtk_style_context_get_color (context, &fg_color);
-
- values->appearance.bg_color.red = CLAMP (bg_color.red * 65535. + 0.5, 0, 65535);
- values->appearance.bg_color.green = CLAMP (bg_color.green * 65535. + 0.5, 0, 65535);
- values->appearance.bg_color.blue = CLAMP (bg_color.blue * 65535. + 0.5, 0, 65535);
-
- values->appearance.fg_color.red = CLAMP (fg_color.red * 65535. + 0.5, 0, 65535);
- values->appearance.fg_color.green = CLAMP (fg_color.green * 65535. + 0.5, 0, 65535);
- values->appearance.fg_color.blue = CLAMP (fg_color.blue * 65535. + 0.5, 0, 65535);
+ gtk_style_context_get_color (context, values->appearance.fg_rgba);
if (values->font)
pango_font_description_free (values->font);