summaryrefslogtreecommitdiff
path: root/gtk/gtktextview.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/gtktextview.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/gtktextview.c')
-rw-r--r--gtk/gtktextview.c19
1 files changed, 8 insertions, 11 deletions
diff --git a/gtk/gtktextview.c b/gtk/gtktextview.c
index 75b50b95cb..65354007e3 100644
--- a/gtk/gtktextview.c
+++ b/gtk/gtktextview.c
@@ -7773,22 +7773,19 @@ gtk_text_view_set_attributes_from_style (GtkTextView *text_view,
GtkTextAttributes *values)
{
GtkStyleContext *context;
- 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);
context = gtk_widget_get_style_context (GTK_WIDGET (text_view));
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);