forked from AuroraMiddleware/gtk
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.
This commit is contained in:
parent
e6d5a3dce2
commit
6e178aede2
@ -546,7 +546,6 @@ gtk_private_h_sources = \
|
||||
gtkstylecontextprivate.h \
|
||||
gtkstylepropertyprivate.h \
|
||||
gtkstyleproviderprivate.h \
|
||||
gtktextattributesprivate.h \
|
||||
gtktextattributes.h \
|
||||
gtktextbtree.h \
|
||||
gtktextbufferprivate.h \
|
||||
|
@ -1125,15 +1125,15 @@ gtk_text_view_accessible_get_default_attributes (AtkText *text)
|
||||
text_attrs->appearance.underline);
|
||||
|
||||
value = g_strdup_printf ("%u,%u,%u",
|
||||
text_attrs->appearance.bg_color.red,
|
||||
text_attrs->appearance.bg_color.green,
|
||||
text_attrs->appearance.bg_color.blue);
|
||||
(guint)(text_attrs->appearance.bg_rgba->red * 65535),
|
||||
(guint)(text_attrs->appearance.bg_rgba->green * 65535),
|
||||
(guint)(text_attrs->appearance.bg_rgba->blue * 65535));
|
||||
attributes = add_text_attribute (attributes, ATK_TEXT_ATTR_BG_COLOR, value);
|
||||
|
||||
value = g_strdup_printf ("%u,%u,%u",
|
||||
text_attrs->appearance.fg_color.red,
|
||||
text_attrs->appearance.fg_color.green,
|
||||
text_attrs->appearance.fg_color.blue);
|
||||
(guint)(text_attrs->appearance.fg_rgba->red),
|
||||
(guint)(text_attrs->appearance.fg_rgba->green),
|
||||
(guint)(text_attrs->appearance.fg_rgba->blue));
|
||||
attributes = add_text_attribute (attributes, ATK_TEXT_ATTR_FG_COLOR, value);
|
||||
|
||||
value = g_strdup_printf ("%g", text_attrs->font_scale);
|
||||
|
@ -50,7 +50,6 @@
|
||||
#include "config.h"
|
||||
|
||||
#include "gtktextattributes.h"
|
||||
#include "gtktextattributesprivate.h"
|
||||
#include "gtktexttagprivate.h"
|
||||
|
||||
/**
|
||||
@ -131,12 +130,18 @@ gtk_text_attributes_copy_values (GtkTextAttributes *src,
|
||||
|
||||
if (dest->pg_bg_rgba)
|
||||
gdk_rgba_free (dest->pg_bg_rgba);
|
||||
|
||||
if (dest->appearance.fg_rgba)
|
||||
gdk_rgba_free (dest->appearance.fg_rgba);
|
||||
|
||||
if (dest->appearance.rgba[0])
|
||||
gdk_rgba_free (dest->appearance.rgba[0]);
|
||||
if (dest->appearance.bg_rgba)
|
||||
gdk_rgba_free (dest->appearance.bg_rgba);
|
||||
|
||||
if (dest->appearance.rgba[1])
|
||||
gdk_rgba_free (dest->appearance.rgba[1]);
|
||||
if (dest->appearance.underline_rgba)
|
||||
gdk_rgba_free (dest->appearance.underline_rgba);
|
||||
|
||||
if (dest->appearance.strikethrough_rgba)
|
||||
gdk_rgba_free (dest->appearance.strikethrough_rgba);
|
||||
|
||||
if (dest->font_features)
|
||||
g_free (dest->font_features);
|
||||
@ -157,11 +162,17 @@ gtk_text_attributes_copy_values (GtkTextAttributes *src,
|
||||
if (src->pg_bg_rgba)
|
||||
dest->pg_bg_rgba = gdk_rgba_copy (src->pg_bg_rgba);
|
||||
|
||||
if (src->appearance.rgba[0])
|
||||
dest->appearance.rgba[0] = gdk_rgba_copy (src->appearance.rgba[0]);
|
||||
if (src->appearance.fg_rgba)
|
||||
dest->appearance.fg_rgba = gdk_rgba_copy (src->appearance.fg_rgba);
|
||||
|
||||
if (src->appearance.rgba[1])
|
||||
dest->appearance.rgba[1] = gdk_rgba_copy (src->appearance.rgba[1]);
|
||||
if (src->appearance.bg_rgba)
|
||||
dest->appearance.bg_rgba = gdk_rgba_copy (src->appearance.bg_rgba);
|
||||
|
||||
if (src->appearance.underline_rgba)
|
||||
dest->appearance.underline_rgba = gdk_rgba_copy (src->appearance.underline_rgba);
|
||||
|
||||
if (src->appearance.strikethrough_rgba)
|
||||
dest->appearance.strikethrough_rgba = gdk_rgba_copy (src->appearance.strikethrough_rgba);
|
||||
|
||||
if (src->font_features)
|
||||
dest->font_features = g_strdup (src->font_features);
|
||||
@ -213,11 +224,17 @@ gtk_text_attributes_unref (GtkTextAttributes *values)
|
||||
if (values->pg_bg_rgba)
|
||||
gdk_rgba_free (values->pg_bg_rgba);
|
||||
|
||||
if (values->appearance.rgba[0])
|
||||
gdk_rgba_free (values->appearance.rgba[0]);
|
||||
if (values->appearance.fg_rgba)
|
||||
gdk_rgba_free (values->appearance.fg_rgba);
|
||||
|
||||
if (values->appearance.rgba[1])
|
||||
gdk_rgba_free (values->appearance.rgba[1]);
|
||||
if (values->appearance.bg_rgba)
|
||||
gdk_rgba_free (values->appearance.bg_rgba);
|
||||
|
||||
if (values->appearance.underline_rgba)
|
||||
gdk_rgba_free (values->appearance.underline_rgba);
|
||||
|
||||
if (values->appearance.strikethrough_rgba)
|
||||
gdk_rgba_free (values->appearance.strikethrough_rgba);
|
||||
|
||||
if (values->font_features)
|
||||
g_free (values->font_features);
|
||||
@ -247,30 +264,54 @@ _gtk_text_attributes_fill_from_tags (GtkTextAttributes *dest,
|
||||
|
||||
if (tag->priv->bg_color_set)
|
||||
{
|
||||
if (dest->appearance.rgba[0])
|
||||
if (dest->appearance.bg_rgba)
|
||||
{
|
||||
gdk_rgba_free (dest->appearance.rgba[0]);
|
||||
dest->appearance.rgba[0] = NULL;
|
||||
gdk_rgba_free (dest->appearance.bg_rgba);
|
||||
dest->appearance.bg_rgba = NULL;
|
||||
}
|
||||
|
||||
if (vals->appearance.rgba[0])
|
||||
dest->appearance.rgba[0] = gdk_rgba_copy (vals->appearance.rgba[0]);
|
||||
if (vals->appearance.bg_rgba)
|
||||
dest->appearance.bg_rgba = gdk_rgba_copy (vals->appearance.bg_rgba);
|
||||
|
||||
dest->appearance.draw_bg = TRUE;
|
||||
}
|
||||
|
||||
if (tag->priv->fg_color_set)
|
||||
{
|
||||
if (dest->appearance.rgba[1])
|
||||
if (dest->appearance.fg_rgba)
|
||||
{
|
||||
gdk_rgba_free (dest->appearance.rgba[1]);
|
||||
dest->appearance.rgba[1] = NULL;
|
||||
gdk_rgba_free (dest->appearance.fg_rgba);
|
||||
dest->appearance.fg_rgba = NULL;
|
||||
}
|
||||
|
||||
if (vals->appearance.rgba[1])
|
||||
dest->appearance.rgba[1] = gdk_rgba_copy (vals->appearance.rgba[1]);
|
||||
if (vals->appearance.fg_rgba)
|
||||
dest->appearance.fg_rgba = gdk_rgba_copy (vals->appearance.fg_rgba);
|
||||
}
|
||||
|
||||
if (tag->priv->underline_rgba_set)
|
||||
{
|
||||
if (dest->appearance.underline_rgba)
|
||||
{
|
||||
gdk_rgba_free (dest->appearance.underline_rgba);
|
||||
dest->appearance.underline_rgba = NULL;
|
||||
}
|
||||
|
||||
if (vals->appearance.underline_rgba)
|
||||
dest->appearance.underline_rgba = gdk_rgba_copy (vals->appearance.underline_rgba);
|
||||
}
|
||||
|
||||
if (tag->priv->strikethrough_rgba_set)
|
||||
{
|
||||
if (dest->appearance.strikethrough_rgba)
|
||||
{
|
||||
gdk_rgba_free (dest->appearance.strikethrough_rgba);
|
||||
dest->appearance.strikethrough_rgba = NULL;
|
||||
}
|
||||
|
||||
if (vals->appearance.strikethrough_rgba)
|
||||
dest->appearance.strikethrough_rgba = gdk_rgba_copy (vals->appearance.strikethrough_rgba);
|
||||
}
|
||||
|
||||
if (tag->priv->pg_bg_color_set)
|
||||
{
|
||||
if (dest->pg_bg_rgba)
|
||||
@ -345,27 +386,9 @@ _gtk_text_attributes_fill_from_tags (GtkTextAttributes *dest,
|
||||
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;
|
||||
|
||||
@ -430,6 +453,6 @@ _gtk_text_tag_affects_nonsize_appearance (GtkTextTag *tag)
|
||||
priv->bg_full_height_set ||
|
||||
priv->pg_bg_color_set ||
|
||||
priv->fallback_set ||
|
||||
GTK_TEXT_APPEARANCE_GET_UNDERLINE_RGBA_SET (&priv->values->appearance) ||
|
||||
GTK_TEXT_APPEARANCE_GET_STRIKETHROUGH_RGBA_SET (&priv->values->appearance);
|
||||
priv->underline_rgba_set ||
|
||||
priv->strikethrough_rgba_set;
|
||||
}
|
||||
|
@ -88,9 +88,10 @@ typedef struct _GtkTextAppearance GtkTextAppearance;
|
||||
*/
|
||||
struct _GtkTextAppearance
|
||||
{
|
||||
/*< public >*/
|
||||
GdkColor bg_color; /* pixel is taken for underline color */
|
||||
GdkColor fg_color; /* pixel is taken for strikethrough color */
|
||||
GdkRGBA *bg_rgba;
|
||||
GdkRGBA *fg_rgba;
|
||||
GdkRGBA *underline_rgba;
|
||||
GdkRGBA *strikethrough_rgba;
|
||||
|
||||
/* super/subscript rise, can be negative */
|
||||
gint rise;
|
||||
@ -111,27 +112,6 @@ struct _GtkTextAppearance
|
||||
*/
|
||||
guint inside_selection : 1;
|
||||
guint is_text : 1;
|
||||
|
||||
/* For the sad story of this bit of code, see
|
||||
* https://bugzilla.gnome.org/show_bug.cgi?id=711158
|
||||
*/
|
||||
#ifdef __GI_SCANNER__
|
||||
/* The scanner should only see the transparent union, so that its
|
||||
* content does not vary across architectures.
|
||||
*/
|
||||
union {
|
||||
GdkRGBA *rgba[2];
|
||||
/*< private >*/
|
||||
guint padding[4];
|
||||
};
|
||||
#else
|
||||
GdkRGBA *rgba[2];
|
||||
#if (defined(__SIZEOF_INT__) && defined(__SIZEOF_POINTER__)) && (__SIZEOF_INT__ == __SIZEOF_POINTER__)
|
||||
/* unusable, just for ABI compat */
|
||||
/*< private >*/
|
||||
guint padding[2];
|
||||
#endif
|
||||
#endif
|
||||
};
|
||||
|
||||
/**
|
||||
@ -165,10 +145,8 @@ struct _GtkTextAppearance
|
||||
*/
|
||||
struct _GtkTextAttributes
|
||||
{
|
||||
/*< private >*/
|
||||
guint refcount;
|
||||
|
||||
/*< public >*/
|
||||
GtkTextAppearance appearance;
|
||||
|
||||
GtkJustification justification;
|
||||
@ -192,35 +170,16 @@ struct _GtkTextAttributes
|
||||
|
||||
PangoLanguage *language;
|
||||
|
||||
/*< public >*/
|
||||
guint invisible : 1;
|
||||
guint bg_full_height : 1;
|
||||
guint editable : 1;
|
||||
guint no_fallback: 1;
|
||||
|
||||
/*< private >*/
|
||||
GdkRGBA *pg_bg_rgba;
|
||||
|
||||
/*< public >*/
|
||||
gint letter_spacing;
|
||||
|
||||
#ifdef __GI_SCANNER__
|
||||
/* The scanner should only see the transparent union, so that its
|
||||
* content does not vary across architectures.
|
||||
*/
|
||||
union {
|
||||
gchar *font_features;
|
||||
/*< private >*/
|
||||
guint padding[2];
|
||||
};
|
||||
#else
|
||||
gchar *font_features;
|
||||
#if (defined(__SIZEOF_INT__) && defined(__SIZEOF_POINTER__)) && (__SIZEOF_INT__ == __SIZEOF_POINTER__)
|
||||
/* unusable, just for ABI compat */
|
||||
/*< private >*/
|
||||
guint padding[1];
|
||||
#endif
|
||||
#endif
|
||||
};
|
||||
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
|
@ -1,75 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2015 Christian Hergert <chergert@gnome.org>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or (at your
|
||||
* option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
|
||||
* License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with this program; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* Author: Christian Hergert <chergert@gnome.org>
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef __GTK_TEXT_ATTRIBUTE_PRIVATE_H__
|
||||
#define __GTK_TEXT_ATTRIBUTE_PRIVATE_H__
|
||||
|
||||
/*
|
||||
* The following macros are used to store and extract information about the
|
||||
* Pango underline and strikethrough colors in the unused pixel member of
|
||||
* the GdkColor members of GtkTextAppearance.
|
||||
*
|
||||
* In 4.0, we should revisit this.
|
||||
*/
|
||||
|
||||
#define GTK_TEXT_APPEARANCE_GET_UNDERLINE_RGBA_SET(appr) \
|
||||
(((guint8*)&(appr)->bg_color)[3] != 0)
|
||||
#define GTK_TEXT_APPEARANCE_SET_UNDERLINE_RGBA_SET(appr,val) \
|
||||
G_STMT_START { \
|
||||
((guint8*)&(appr)->bg_color)[3] = !!val; \
|
||||
} G_STMT_END
|
||||
#define GTK_TEXT_APPEARANCE_GET_UNDERLINE_RGBA(appr,rgba) \
|
||||
G_STMT_START { \
|
||||
(rgba)->red = ((guint8*)&(appr)->bg_color)[0] / 255.; \
|
||||
(rgba)->green = ((guint8*)&(appr)->bg_color)[1] / 255.; \
|
||||
(rgba)->blue = ((guint8*)&(appr)->bg_color)[2] / 255.; \
|
||||
(rgba)->alpha = 1.0; \
|
||||
} G_STMT_END
|
||||
#define GTK_TEXT_APPEARANCE_SET_UNDERLINE_RGBA(appr,rgba) \
|
||||
G_STMT_START { \
|
||||
((guint8*)&(appr)->bg_color)[0] = (rgba)->red * 255; \
|
||||
((guint8*)&(appr)->bg_color)[1] = (rgba)->green * 255; \
|
||||
((guint8*)&(appr)->bg_color)[2] = (rgba)->blue * 255; \
|
||||
} G_STMT_END
|
||||
|
||||
|
||||
#define GTK_TEXT_APPEARANCE_GET_STRIKETHROUGH_RGBA_SET(appr) \
|
||||
(((guint8*)&(appr)->fg_color)[3] != 0)
|
||||
#define GTK_TEXT_APPEARANCE_SET_STRIKETHROUGH_RGBA_SET(appr,val) \
|
||||
G_STMT_START { \
|
||||
((guint8*)&(appr)->fg_color)[3] = !!val; \
|
||||
} G_STMT_END
|
||||
#define GTK_TEXT_APPEARANCE_GET_STRIKETHROUGH_RGBA(appr,rgba) \
|
||||
G_STMT_START { \
|
||||
(rgba)->red = ((guint8*)&(appr)->fg_color)[0] / 255.; \
|
||||
(rgba)->green = ((guint8*)&(appr)->fg_color)[1] / 255.; \
|
||||
(rgba)->blue = ((guint8*)&(appr)->fg_color)[2] / 255.; \
|
||||
(rgba)->alpha = 1.0; \
|
||||
} G_STMT_END
|
||||
#define GTK_TEXT_APPEARANCE_SET_STRIKETHROUGH_RGBA(appr,rgba) \
|
||||
G_STMT_START { \
|
||||
((guint8*)&(appr)->fg_color)[0] = (rgba)->red * 255; \
|
||||
((guint8*)&(appr)->fg_color)[1] = (rgba)->green * 255; \
|
||||
((guint8*)&(appr)->fg_color)[2] = (rgba)->blue * 255; \
|
||||
} G_STMT_END
|
||||
|
||||
|
||||
#endif /* __GTK_TEXT_ATTRIBUTE_PRIVATE_H__ */
|
@ -75,7 +75,6 @@
|
||||
|
||||
#define GTK_TEXT_USE_INTERNAL_UNSUPPORTED_API
|
||||
#include "config.h"
|
||||
#include "gtktextattributesprivate.h"
|
||||
#include "gtktextdisplay.h"
|
||||
#include "gtktextviewprivate.h"
|
||||
#include "gtkwidgetprivate.h"
|
||||
@ -185,7 +184,7 @@ gtk_text_renderer_prepare_run (PangoRenderer *renderer,
|
||||
context = gtk_widget_get_style_context (text_renderer->widget);
|
||||
|
||||
if (appearance->draw_bg && text_renderer->state == NORMAL)
|
||||
bg_rgba = appearance->rgba[0];
|
||||
bg_rgba = appearance->bg_rgba;
|
||||
else
|
||||
bg_rgba = NULL;
|
||||
|
||||
@ -211,27 +210,17 @@ gtk_text_renderer_prepare_run (PangoRenderer *renderer,
|
||||
NULL);
|
||||
}
|
||||
else
|
||||
fg_rgba = appearance->rgba[1];
|
||||
fg_rgba = appearance->fg_rgba;
|
||||
|
||||
text_renderer_set_rgba (text_renderer, PANGO_RENDER_PART_FOREGROUND, fg_rgba);
|
||||
|
||||
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);
|
||||
}
|
||||
if (appearance->strikethrough_rgba)
|
||||
text_renderer_set_rgba (text_renderer, PANGO_RENDER_PART_STRIKETHROUGH, appearance->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);
|
||||
}
|
||||
if (appearance->underline_rgba)
|
||||
text_renderer_set_rgba (text_renderer, PANGO_RENDER_PART_UNDERLINE, appearance->underline_rgba);
|
||||
else if (appearance->underline == PANGO_UNDERLINE_ERROR)
|
||||
{
|
||||
if (!text_renderer->error_color)
|
||||
@ -245,7 +234,7 @@ gtk_text_renderer_prepare_run (PangoRenderer *renderer,
|
||||
else
|
||||
text_renderer_set_rgba (text_renderer, PANGO_RENDER_PART_UNDERLINE, fg_rgba);
|
||||
|
||||
if (fg_rgba != appearance->rgba[1])
|
||||
if (fg_rgba != appearance->fg_rgba)
|
||||
gdk_rgba_free (fg_rgba);
|
||||
}
|
||||
|
||||
|
@ -82,7 +82,6 @@
|
||||
#include "gtktextbtree.h"
|
||||
#include "gtktextbufferprivate.h"
|
||||
#include "gtktextiterprivate.h"
|
||||
#include "gtktextattributesprivate.h"
|
||||
#include "gtktextutil.h"
|
||||
#include "gtkintl.h"
|
||||
|
||||
@ -1445,11 +1444,17 @@ gtk_text_attr_appearance_destroy (PangoAttribute *attr)
|
||||
{
|
||||
GtkTextAttrAppearance *appearance_attr = (GtkTextAttrAppearance *)attr;
|
||||
|
||||
if (appearance_attr->appearance.rgba[0])
|
||||
gdk_rgba_free (appearance_attr->appearance.rgba[0]);
|
||||
if (appearance_attr->appearance.fg_rgba)
|
||||
gdk_rgba_free (appearance_attr->appearance.fg_rgba);
|
||||
|
||||
if (appearance_attr->appearance.rgba[1])
|
||||
gdk_rgba_free (appearance_attr->appearance.rgba[1]);
|
||||
if (appearance_attr->appearance.bg_rgba)
|
||||
gdk_rgba_free (appearance_attr->appearance.bg_rgba);
|
||||
|
||||
if (appearance_attr->appearance.underline_rgba)
|
||||
gdk_rgba_free (appearance_attr->appearance.underline_rgba);
|
||||
|
||||
if (appearance_attr->appearance.strikethrough_rgba)
|
||||
gdk_rgba_free (appearance_attr->appearance.strikethrough_rgba);
|
||||
|
||||
g_slice_free (GtkTextAttrAppearance, appearance_attr);
|
||||
}
|
||||
@ -1470,32 +1475,18 @@ static gboolean
|
||||
underline_equal (const GtkTextAppearance *appearance1,
|
||||
const GtkTextAppearance *appearance2)
|
||||
{
|
||||
GdkRGBA c1;
|
||||
GdkRGBA c2;
|
||||
|
||||
GTK_TEXT_APPEARANCE_GET_UNDERLINE_RGBA (appearance1, &c1);
|
||||
GTK_TEXT_APPEARANCE_GET_UNDERLINE_RGBA (appearance2, &c2);
|
||||
|
||||
return ((appearance1->underline == appearance2->underline) &&
|
||||
(GTK_TEXT_APPEARANCE_GET_UNDERLINE_RGBA_SET (appearance1) ==
|
||||
GTK_TEXT_APPEARANCE_GET_UNDERLINE_RGBA_SET (appearance2)) &&
|
||||
gdk_rgba_equal (&c1, &c2));
|
||||
return (appearance1->underline == appearance2->underline) &&
|
||||
rgba_equal ((const GdkRGBA *)appearance1->underline_rgba,
|
||||
(const GdkRGBA *)appearance2->underline_rgba);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
strikethrough_equal (const GtkTextAppearance *appearance1,
|
||||
const GtkTextAppearance *appearance2)
|
||||
{
|
||||
GdkRGBA c1;
|
||||
GdkRGBA c2;
|
||||
|
||||
GTK_TEXT_APPEARANCE_GET_STRIKETHROUGH_RGBA (appearance1, &c1);
|
||||
GTK_TEXT_APPEARANCE_GET_STRIKETHROUGH_RGBA (appearance2, &c2);
|
||||
|
||||
return ((appearance1->strikethrough == appearance2->strikethrough) &&
|
||||
(GTK_TEXT_APPEARANCE_GET_STRIKETHROUGH_RGBA_SET (appearance1) ==
|
||||
GTK_TEXT_APPEARANCE_GET_STRIKETHROUGH_RGBA_SET (appearance2)) &&
|
||||
gdk_rgba_equal (&c1, &c2));
|
||||
return (appearance1->strikethrough == appearance2->strikethrough) &&
|
||||
rgba_equal ((const GdkRGBA *)appearance1->strikethrough_rgba,
|
||||
(const GdkRGBA *)appearance2->strikethrough_rgba);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
@ -1505,8 +1496,8 @@ gtk_text_attr_appearance_compare (const PangoAttribute *attr1,
|
||||
const GtkTextAppearance *appearance1 = &((const GtkTextAttrAppearance *)attr1)->appearance;
|
||||
const GtkTextAppearance *appearance2 = &((const GtkTextAttrAppearance *)attr2)->appearance;
|
||||
|
||||
return (rgba_equal (appearance1->rgba[0], appearance2->rgba[0]) &&
|
||||
rgba_equal (appearance1->rgba[1], appearance2->rgba[1]) &&
|
||||
return (rgba_equal (appearance1->fg_rgba, appearance2->fg_rgba) &&
|
||||
rgba_equal (appearance1->bg_rgba, appearance2->bg_rgba) &&
|
||||
appearance1->draw_bg == appearance2->draw_bg &&
|
||||
strikethrough_equal (appearance1, appearance2) &&
|
||||
underline_equal (appearance1, appearance2));
|
||||
@ -1543,11 +1534,14 @@ gtk_text_attr_appearance_new (const GtkTextAppearance *appearance)
|
||||
|
||||
result->appearance = *appearance;
|
||||
|
||||
if (appearance->rgba[0])
|
||||
result->appearance.rgba[0] = gdk_rgba_copy (appearance->rgba[0]);
|
||||
if (appearance->fg_rgba)
|
||||
result->appearance.fg_rgba = gdk_rgba_copy (appearance->fg_rgba);
|
||||
|
||||
if (appearance->rgba[1])
|
||||
result->appearance.rgba[1] = gdk_rgba_copy (appearance->rgba[1]);
|
||||
if (appearance->bg_rgba)
|
||||
result->appearance.bg_rgba = gdk_rgba_copy (appearance->bg_rgba);
|
||||
|
||||
if (appearance->underline_rgba)
|
||||
result->appearance.underline_rgba = gdk_rgba_copy (appearance->underline_rgba);
|
||||
|
||||
return (PangoAttribute *)result;
|
||||
}
|
||||
@ -1573,15 +1567,11 @@ add_generic_attrs (GtkTextLayout *layout,
|
||||
pango_attr_list_insert (attrs, attr);
|
||||
}
|
||||
|
||||
if (GTK_TEXT_APPEARANCE_GET_UNDERLINE_RGBA_SET (appearance))
|
||||
if (appearance->underline_rgba)
|
||||
{
|
||||
GdkRGBA rgba;
|
||||
|
||||
GTK_TEXT_APPEARANCE_GET_UNDERLINE_RGBA (appearance, &rgba);
|
||||
|
||||
attr = pango_attr_underline_color_new (rgba.red * 65535,
|
||||
rgba.green * 65535,
|
||||
rgba.blue * 65535);
|
||||
attr = pango_attr_underline_color_new (appearance->underline_rgba->red * 65535,
|
||||
appearance->underline_rgba->green * 65535,
|
||||
appearance->underline_rgba->blue * 65535);
|
||||
|
||||
attr->start_index = start;
|
||||
attr->end_index = start + byte_count;
|
||||
@ -1599,15 +1589,11 @@ add_generic_attrs (GtkTextLayout *layout,
|
||||
pango_attr_list_insert (attrs, attr);
|
||||
}
|
||||
|
||||
if (GTK_TEXT_APPEARANCE_GET_STRIKETHROUGH_RGBA_SET (appearance))
|
||||
if (appearance->strikethrough_rgba)
|
||||
{
|
||||
GdkRGBA rgba;
|
||||
|
||||
GTK_TEXT_APPEARANCE_GET_STRIKETHROUGH_RGBA (appearance, &rgba);
|
||||
|
||||
attr = pango_attr_strikethrough_color_new (rgba.red * 65535,
|
||||
rgba.green * 65535,
|
||||
rgba.blue * 65535);
|
||||
attr = pango_attr_strikethrough_color_new (appearance->strikethrough_rgba->red * 65535,
|
||||
appearance->strikethrough_rgba->green * 65535,
|
||||
appearance->strikethrough_rgba->blue * 65535);
|
||||
|
||||
attr->start_index = start;
|
||||
attr->end_index = start + byte_count;
|
||||
@ -1997,10 +1983,14 @@ add_preedit_attrs (GtkTextLayout *layout,
|
||||
|
||||
pango_attr_iterator_get_font (iter, font_desc, &language, &extra_attrs);
|
||||
|
||||
if (appearance.rgba[0])
|
||||
appearance.rgba[0] = gdk_rgba_copy (appearance.rgba[0]);
|
||||
if (appearance.rgba[1])
|
||||
appearance.rgba[1] = gdk_rgba_copy (appearance.rgba[1]);
|
||||
if (appearance.fg_rgba)
|
||||
appearance.fg_rgba = gdk_rgba_copy (appearance.fg_rgba);
|
||||
if (appearance.bg_rgba)
|
||||
appearance.bg_rgba = gdk_rgba_copy (appearance.bg_rgba);
|
||||
if (appearance.underline_rgba)
|
||||
appearance.underline_rgba = gdk_rgba_copy (appearance.underline_rgba);
|
||||
if (appearance.strikethrough_rgba)
|
||||
appearance.strikethrough_rgba = gdk_rgba_copy (appearance.strikethrough_rgba);
|
||||
|
||||
tmp_list = extra_attrs;
|
||||
while (tmp_list)
|
||||
@ -2012,15 +2002,15 @@ add_preedit_attrs (GtkTextLayout *layout,
|
||||
{
|
||||
case PANGO_ATTR_FOREGROUND:
|
||||
convert_color (&rgba, (PangoAttrColor *)attr);
|
||||
if (appearance.rgba[1])
|
||||
gdk_rgba_free (appearance.rgba[1]);
|
||||
appearance.rgba[1] = gdk_rgba_copy (&rgba);
|
||||
if (appearance.fg_rgba)
|
||||
gdk_rgba_free (appearance.fg_rgba);
|
||||
appearance.fg_rgba = gdk_rgba_copy (&rgba);
|
||||
break;
|
||||
case PANGO_ATTR_BACKGROUND:
|
||||
convert_color (&rgba, (PangoAttrColor *)attr);
|
||||
if (appearance.rgba[0])
|
||||
gdk_rgba_free (appearance.rgba[0]);
|
||||
appearance.rgba[0] = gdk_rgba_copy (&rgba);
|
||||
if (appearance.bg_rgba)
|
||||
gdk_rgba_free (appearance.bg_rgba);
|
||||
appearance.bg_rgba = gdk_rgba_copy (&rgba);
|
||||
appearance.draw_bg = TRUE;
|
||||
break;
|
||||
case PANGO_ATTR_UNDERLINE:
|
||||
@ -2028,16 +2018,18 @@ add_preedit_attrs (GtkTextLayout *layout,
|
||||
break;
|
||||
case PANGO_ATTR_UNDERLINE_COLOR:
|
||||
convert_color (&rgba, (PangoAttrColor*)attr);
|
||||
GTK_TEXT_APPEARANCE_SET_UNDERLINE_RGBA_SET (&appearance, TRUE);
|
||||
GTK_TEXT_APPEARANCE_SET_UNDERLINE_RGBA (&appearance, &rgba);
|
||||
if (appearance.underline_rgba)
|
||||
gdk_rgba_free (appearance.underline_rgba);
|
||||
appearance.underline_rgba = gdk_rgba_copy (&rgba);
|
||||
break;
|
||||
case PANGO_ATTR_STRIKETHROUGH:
|
||||
appearance.strikethrough = ((PangoAttrInt *)attr)->value;
|
||||
break;
|
||||
case PANGO_ATTR_STRIKETHROUGH_COLOR:
|
||||
convert_color (&rgba, (PangoAttrColor*)attr);
|
||||
GTK_TEXT_APPEARANCE_SET_STRIKETHROUGH_RGBA_SET (&appearance, TRUE);
|
||||
GTK_TEXT_APPEARANCE_SET_STRIKETHROUGH_RGBA (&appearance, &rgba);
|
||||
if (appearance.strikethrough_rgba)
|
||||
gdk_rgba_free (appearance.strikethrough_rgba);
|
||||
appearance.strikethrough_rgba = gdk_rgba_copy (&rgba);
|
||||
case PANGO_ATTR_RISE:
|
||||
appearance.rise = ((PangoAttrInt *)attr)->value;
|
||||
break;
|
||||
@ -2070,10 +2062,14 @@ add_preedit_attrs (GtkTextLayout *layout,
|
||||
attrs, start + offset,
|
||||
size_only, TRUE);
|
||||
|
||||
if (appearance.rgba[0])
|
||||
gdk_rgba_free (appearance.rgba[0]);
|
||||
if (appearance.rgba[1])
|
||||
gdk_rgba_free (appearance.rgba[1]);
|
||||
if (appearance.fg_rgba)
|
||||
gdk_rgba_free (appearance.fg_rgba);
|
||||
if (appearance.bg_rgba)
|
||||
gdk_rgba_free (appearance.bg_rgba);
|
||||
if (appearance.underline_rgba)
|
||||
gdk_rgba_free (appearance.underline_rgba);
|
||||
if (appearance.strikethrough_rgba)
|
||||
gdk_rgba_free (appearance.strikethrough_rgba);
|
||||
|
||||
pango_font_description_free (font_desc);
|
||||
}
|
||||
|
103
gtk/gtktexttag.c
103
gtk/gtktexttag.c
@ -74,7 +74,6 @@
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "gtktextattributesprivate.h"
|
||||
#include "gtktexttag.h"
|
||||
#include "gtktexttypes.h"
|
||||
#include "gtktexttagtable.h"
|
||||
@ -881,40 +880,31 @@ gtk_text_tag_finalize (GObject *object)
|
||||
G_OBJECT_CLASS (gtk_text_tag_parent_class)->finalize (object);
|
||||
}
|
||||
|
||||
static void
|
||||
copy_rgba_to_gdk_color (GdkRGBA *src,
|
||||
GdkColor *dest)
|
||||
{
|
||||
dest->red = CLAMP (src->red, 0.0, 1.0) * 65535.0;
|
||||
dest->green = CLAMP (src->green, 0.0, 1.0) * 65535.0;
|
||||
dest->blue = CLAMP (src->blue, 0.0, 1.0) * 65535.0;
|
||||
}
|
||||
|
||||
static void
|
||||
set_underline_rgba (GtkTextTag *tag,
|
||||
const GdkRGBA *rgba)
|
||||
{
|
||||
GtkTextTagPrivate *priv = tag->priv;
|
||||
|
||||
if (priv->values->appearance.underline_rgba)
|
||||
gdk_rgba_free (priv->values->appearance.underline_rgba);
|
||||
priv->values->appearance.underline_rgba = NULL;
|
||||
|
||||
if (rgba)
|
||||
{
|
||||
GTK_TEXT_APPEARANCE_SET_UNDERLINE_RGBA (&priv->values->appearance, rgba);
|
||||
priv->values->appearance.underline_rgba = gdk_rgba_copy (rgba);
|
||||
|
||||
if (!GTK_TEXT_APPEARANCE_GET_UNDERLINE_RGBA_SET (&priv->values->appearance))
|
||||
if (!priv->underline_rgba_set)
|
||||
{
|
||||
GTK_TEXT_APPEARANCE_SET_UNDERLINE_RGBA_SET (&priv->values->appearance, TRUE);
|
||||
priv->underline_rgba_set = TRUE;
|
||||
g_object_notify (G_OBJECT (tag), "underline-rgba-set");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
GdkRGBA black = { 0 };
|
||||
|
||||
GTK_TEXT_APPEARANCE_SET_UNDERLINE_RGBA (&priv->values->appearance, &black);
|
||||
|
||||
if (GTK_TEXT_APPEARANCE_GET_UNDERLINE_RGBA_SET (&priv->values->appearance))
|
||||
if (priv->underline_rgba_set)
|
||||
{
|
||||
GTK_TEXT_APPEARANCE_SET_UNDERLINE_RGBA_SET (&priv->values->appearance, FALSE);
|
||||
priv->underline_rgba_set = FALSE;
|
||||
g_object_notify (G_OBJECT (tag), "underline-rgba-set");
|
||||
}
|
||||
}
|
||||
@ -926,25 +916,25 @@ set_strikethrough_rgba (GtkTextTag *tag,
|
||||
{
|
||||
GtkTextTagPrivate *priv = tag->priv;
|
||||
|
||||
if (priv->values->appearance.strikethrough_rgba)
|
||||
gdk_rgba_free (priv->values->appearance.strikethrough_rgba);
|
||||
priv->values->appearance.strikethrough_rgba = NULL;
|
||||
|
||||
if (rgba)
|
||||
{
|
||||
GTK_TEXT_APPEARANCE_SET_STRIKETHROUGH_RGBA (&priv->values->appearance, rgba);
|
||||
priv->values->appearance.strikethrough_rgba = gdk_rgba_copy (rgba);
|
||||
|
||||
if (!GTK_TEXT_APPEARANCE_GET_STRIKETHROUGH_RGBA_SET (&priv->values->appearance))
|
||||
if (!priv->strikethrough_rgba_set)
|
||||
{
|
||||
GTK_TEXT_APPEARANCE_SET_STRIKETHROUGH_RGBA_SET (&priv->values->appearance, TRUE);
|
||||
priv->strikethrough_rgba_set = TRUE;
|
||||
g_object_notify (G_OBJECT (tag), "strikethrough-rgba-set");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
GdkRGBA black = { 0 };
|
||||
|
||||
GTK_TEXT_APPEARANCE_SET_STRIKETHROUGH_RGBA (&priv->values->appearance, &black);
|
||||
|
||||
if (GTK_TEXT_APPEARANCE_GET_STRIKETHROUGH_RGBA_SET (&priv->values->appearance))
|
||||
if (priv->strikethrough_rgba_set)
|
||||
{
|
||||
GTK_TEXT_APPEARANCE_SET_STRIKETHROUGH_RGBA_SET (&priv->values->appearance, FALSE);
|
||||
priv->strikethrough_rgba_set = FALSE;
|
||||
g_object_notify (G_OBJECT (tag), "strikethrough-rgba-set");
|
||||
}
|
||||
}
|
||||
@ -955,10 +945,9 @@ set_bg_rgba (GtkTextTag *tag, GdkRGBA *rgba)
|
||||
{
|
||||
GtkTextTagPrivate *priv = tag->priv;
|
||||
|
||||
if (priv->values->appearance.rgba[0])
|
||||
gdk_rgba_free (priv->values->appearance.rgba[0]);
|
||||
|
||||
priv->values->appearance.rgba[0] = NULL;
|
||||
if (priv->values->appearance.bg_rgba)
|
||||
gdk_rgba_free (priv->values->appearance.bg_rgba);
|
||||
priv->values->appearance.bg_rgba = NULL;
|
||||
|
||||
if (rgba)
|
||||
{
|
||||
@ -968,9 +957,7 @@ set_bg_rgba (GtkTextTag *tag, GdkRGBA *rgba)
|
||||
g_object_notify (G_OBJECT (tag), "background-set");
|
||||
}
|
||||
|
||||
priv->values->appearance.rgba[0] = gdk_rgba_copy (rgba);
|
||||
|
||||
copy_rgba_to_gdk_color (rgba, &priv->values->appearance.bg_color);
|
||||
priv->values->appearance.bg_rgba = gdk_rgba_copy (rgba);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -987,10 +974,9 @@ set_fg_rgba (GtkTextTag *tag, GdkRGBA *rgba)
|
||||
{
|
||||
GtkTextTagPrivate *priv = tag->priv;
|
||||
|
||||
if (priv->values->appearance.rgba[1])
|
||||
gdk_rgba_free (priv->values->appearance.rgba[1]);
|
||||
|
||||
priv->values->appearance.rgba[1] = NULL;
|
||||
if (priv->values->appearance.fg_rgba)
|
||||
gdk_rgba_free (priv->values->appearance.fg_rgba);
|
||||
priv->values->appearance.fg_rgba = NULL;
|
||||
|
||||
if (rgba)
|
||||
{
|
||||
@ -1000,9 +986,7 @@ set_fg_rgba (GtkTextTag *tag, GdkRGBA *rgba)
|
||||
g_object_notify (G_OBJECT (tag), "foreground-set");
|
||||
}
|
||||
|
||||
priv->values->appearance.rgba[1] = gdk_rgba_copy (rgba);
|
||||
|
||||
copy_rgba_to_gdk_color (rgba, &priv->values->appearance.fg_color);
|
||||
priv->values->appearance.fg_rgba = gdk_rgba_copy (rgba);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -1021,7 +1005,6 @@ set_pg_bg_rgba (GtkTextTag *tag, GdkRGBA *rgba)
|
||||
|
||||
if (priv->values->pg_bg_rgba)
|
||||
gdk_rgba_free (priv->values->pg_bg_rgba);
|
||||
|
||||
priv->values->pg_bg_rgba = NULL;
|
||||
|
||||
if (rgba)
|
||||
@ -1616,8 +1599,7 @@ gtk_text_tag_set_property (GObject *object,
|
||||
break;
|
||||
|
||||
case PROP_STRIKETHROUGH_RGBA_SET:
|
||||
GTK_TEXT_APPEARANCE_SET_STRIKETHROUGH_RGBA_SET (&priv->values->appearance,
|
||||
g_value_get_boolean (value));
|
||||
priv->strikethrough_rgba_set = g_value_get_boolean (value);
|
||||
break;
|
||||
|
||||
case PROP_RIGHT_MARGIN_SET:
|
||||
@ -1630,8 +1612,7 @@ gtk_text_tag_set_property (GObject *object,
|
||||
break;
|
||||
|
||||
case PROP_UNDERLINE_RGBA_SET:
|
||||
GTK_TEXT_APPEARANCE_SET_UNDERLINE_RGBA_SET (&priv->values->appearance,
|
||||
g_value_get_boolean (value));
|
||||
priv->underline_rgba_set = g_value_get_boolean (value);
|
||||
break;
|
||||
|
||||
case PROP_RISE_SET:
|
||||
@ -1703,11 +1684,11 @@ gtk_text_tag_get_property (GObject *object,
|
||||
break;
|
||||
|
||||
case PROP_BACKGROUND_RGBA:
|
||||
g_value_set_boxed (value, priv->values->appearance.rgba[0]);
|
||||
g_value_set_boxed (value, priv->values->appearance.bg_rgba);
|
||||
break;
|
||||
|
||||
case PROP_FOREGROUND_RGBA:
|
||||
g_value_set_boxed (value, priv->values->appearance.rgba[1]);
|
||||
g_value_set_boxed (value, priv->values->appearance.fg_rgba);
|
||||
break;
|
||||
|
||||
case PROP_FONT:
|
||||
@ -1811,13 +1792,8 @@ gtk_text_tag_get_property (GObject *object,
|
||||
break;
|
||||
|
||||
case PROP_STRIKETHROUGH_RGBA:
|
||||
if (GTK_TEXT_APPEARANCE_GET_STRIKETHROUGH_RGBA_SET (&priv->values->appearance))
|
||||
{
|
||||
GdkRGBA rgba;
|
||||
|
||||
GTK_TEXT_APPEARANCE_GET_STRIKETHROUGH_RGBA (&priv->values->appearance, &rgba);
|
||||
g_value_set_boxed (value, &rgba);
|
||||
}
|
||||
if (priv->strikethrough_rgba_set)
|
||||
g_value_set_boxed (value, priv->values->appearance.strikethrough_rgba);
|
||||
break;
|
||||
|
||||
case PROP_RIGHT_MARGIN:
|
||||
@ -1829,13 +1805,8 @@ gtk_text_tag_get_property (GObject *object,
|
||||
break;
|
||||
|
||||
case PROP_UNDERLINE_RGBA:
|
||||
if (GTK_TEXT_APPEARANCE_GET_UNDERLINE_RGBA_SET (&priv->values->appearance))
|
||||
{
|
||||
GdkRGBA rgba;
|
||||
|
||||
GTK_TEXT_APPEARANCE_GET_UNDERLINE_RGBA (&priv->values->appearance, &rgba);
|
||||
g_value_set_boxed (value, &rgba);
|
||||
}
|
||||
if (priv->underline_rgba_set)
|
||||
g_value_set_boxed (value, priv->values->appearance.underline_rgba);
|
||||
break;
|
||||
|
||||
case PROP_RISE:
|
||||
@ -1943,8 +1914,7 @@ gtk_text_tag_get_property (GObject *object,
|
||||
break;
|
||||
|
||||
case PROP_STRIKETHROUGH_RGBA_SET:
|
||||
g_value_set_boolean (value,
|
||||
GTK_TEXT_APPEARANCE_GET_STRIKETHROUGH_RGBA_SET (&priv->values->appearance));
|
||||
g_value_set_boolean (value, priv->strikethrough_rgba_set);
|
||||
break;
|
||||
|
||||
case PROP_RIGHT_MARGIN_SET:
|
||||
@ -1956,8 +1926,7 @@ gtk_text_tag_get_property (GObject *object,
|
||||
break;
|
||||
|
||||
case PROP_UNDERLINE_RGBA_SET:
|
||||
g_value_set_boolean (value,
|
||||
GTK_TEXT_APPEARANCE_GET_UNDERLINE_RGBA_SET (&priv->values->appearance));
|
||||
g_value_set_boolean (value, priv->underline_rgba_set);
|
||||
break;
|
||||
|
||||
case PROP_RISE_SET:
|
||||
|
@ -57,6 +57,8 @@ struct _GtkTextTagPrivate
|
||||
*/
|
||||
guint bg_color_set : 1;
|
||||
guint fg_color_set : 1;
|
||||
guint underline_rgba_set : 1;
|
||||
guint strikethrough_rgba_set : 1;
|
||||
guint scale_set : 1;
|
||||
guint justification_set : 1;
|
||||
guint left_margin_set : 1;
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user