Compare commits
6 Commits
css-border
...
wip/matthi
Author | SHA1 | Date | |
---|---|---|---|
|
b082e57874 | ||
|
a5a4fdb083 | ||
|
9967403b7d | ||
|
1578a15624 | ||
|
678e3d5f09 | ||
|
5f364751f1 |
@@ -53,7 +53,6 @@
|
||||
|
||||
<reference>
|
||||
<title>Deprecated</title>
|
||||
<xi:include href="xml/colors.xml" />
|
||||
<xi:include href="xml/gdkdevicemanager.xml" />
|
||||
</reference>
|
||||
|
||||
|
@@ -219,24 +219,6 @@ gdk_pixbuf_get_from_window
|
||||
gdk_pixbuf_get_from_surface
|
||||
</SECTION>
|
||||
|
||||
<SECTION>
|
||||
<TITLE>Colors</TITLE>
|
||||
<FILE>colors</FILE>
|
||||
GdkColor
|
||||
gdk_color_copy
|
||||
gdk_color_free
|
||||
gdk_color_parse
|
||||
gdk_color_equal
|
||||
gdk_color_hash
|
||||
gdk_color_to_string
|
||||
|
||||
<SUBSECTION Standard>
|
||||
GDK_TYPE_COLOR
|
||||
|
||||
<SUBSECTION Private>
|
||||
gdk_color_get_type
|
||||
</SECTION>
|
||||
|
||||
<SECTION>
|
||||
<TITLE>RGBA Colors</TITLE>
|
||||
<FILE>rgba_colors</FILE>
|
||||
|
@@ -3064,7 +3064,6 @@ gtk_text_iter_inside_sentence
|
||||
gtk_text_iter_is_cursor_position
|
||||
gtk_text_iter_get_chars_in_line
|
||||
gtk_text_iter_get_bytes_in_line
|
||||
gtk_text_iter_get_attributes
|
||||
gtk_text_iter_get_language
|
||||
gtk_text_iter_is_end
|
||||
gtk_text_iter_is_start
|
||||
@@ -3157,13 +3156,6 @@ gtk_text_tag_get_priority
|
||||
gtk_text_tag_set_priority
|
||||
gtk_text_tag_event
|
||||
gtk_text_tag_changed
|
||||
GtkTextAttributes
|
||||
GtkTextAppearance
|
||||
gtk_text_attributes_new
|
||||
gtk_text_attributes_copy
|
||||
gtk_text_attributes_copy_values
|
||||
gtk_text_attributes_unref
|
||||
gtk_text_attributes_ref
|
||||
<SUBSECTION Standard>
|
||||
GTK_TEXT_TAG
|
||||
GTK_IS_TEXT_TAG
|
||||
@@ -3171,11 +3163,9 @@ GTK_TYPE_TEXT_TAG
|
||||
GTK_TEXT_TAG_CLASS
|
||||
GTK_IS_TEXT_TAG_CLASS
|
||||
GTK_TEXT_TAG_GET_CLASS
|
||||
GTK_TYPE_TEXT_ATTRIBUTES
|
||||
<SUBSECTION Private>
|
||||
GtkTextTagPrivate
|
||||
gtk_text_tag_get_type
|
||||
gtk_text_attributes_get_type
|
||||
</SECTION>
|
||||
|
||||
<SECTION>
|
||||
@@ -3276,7 +3266,6 @@ gtk_text_view_set_tabs
|
||||
gtk_text_view_get_tabs
|
||||
gtk_text_view_set_accepts_tab
|
||||
gtk_text_view_get_accepts_tab
|
||||
gtk_text_view_get_default_attributes
|
||||
gtk_text_view_im_context_filter_keypress
|
||||
gtk_text_view_reset_im_context
|
||||
gtk_text_view_set_input_purpose
|
||||
|
@@ -92,12 +92,8 @@ gdk_public_h_sources = \
|
||||
gdkvisual.h \
|
||||
gdkwindow.h
|
||||
|
||||
deprecated_h_sources = \
|
||||
deprecated/gdkcolor.h
|
||||
|
||||
gdk_h_sources = \
|
||||
$(gdk_public_h_sources) \
|
||||
$(deprecated_h_sources)
|
||||
$(gdk_public_h_sources)
|
||||
|
||||
gdk_private_headers = \
|
||||
gdk-private.h \
|
||||
@@ -124,11 +120,7 @@ gdk_private_headers = \
|
||||
gdkvisualprivate.h \
|
||||
gdkx.h
|
||||
|
||||
deprecated_c_sources = \
|
||||
deprecated/gdkcolor.c
|
||||
|
||||
gdk_c_sources = \
|
||||
$(deprecated_c_sources) \
|
||||
gdk-private.c \
|
||||
gdk.c \
|
||||
gdkapplaunchcontext.c \
|
||||
|
@@ -1,202 +0,0 @@
|
||||
/* GDK - The GIMP Drawing Kit
|
||||
* Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
|
||||
*
|
||||
* This library 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 library 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 library. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Modified by the GTK+ Team and others 1997-2000. See the AUTHORS
|
||||
* file for a list of people on the GTK+ Team. See the ChangeLog
|
||||
* files for a list of changes. These files are distributed with
|
||||
* GTK+ at ftp://ftp.gtk.org/pub/gtk/.
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include "gdkcolor.h"
|
||||
|
||||
#include "gdkscreen.h"
|
||||
#include "gdkinternals.h"
|
||||
|
||||
#include <time.h>
|
||||
|
||||
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
|
||||
|
||||
/**
|
||||
* SECTION:colors
|
||||
* @Short_description: Manipulation of colors
|
||||
* @Title: Colors
|
||||
*
|
||||
* A #GdkColor represents a color.
|
||||
*
|
||||
* When working with cairo, it is often more convenient
|
||||
* to use a #GdkRGBA instead, and #GdkColor has been
|
||||
* deprecated in favor of #GdkRGBA.
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* gdk_color_copy:
|
||||
* @color: a #GdkColor
|
||||
*
|
||||
* Makes a copy of a #GdkColor.
|
||||
*
|
||||
* The result must be freed using gdk_color_free().
|
||||
*
|
||||
* Returns: a copy of @color
|
||||
*
|
||||
* Deprecated: 3.14: Use #GdkRGBA
|
||||
*/
|
||||
GdkColor*
|
||||
gdk_color_copy (const GdkColor *color)
|
||||
{
|
||||
GdkColor *new_color;
|
||||
|
||||
g_return_val_if_fail (color != NULL, NULL);
|
||||
|
||||
new_color = g_slice_new (GdkColor);
|
||||
*new_color = *color;
|
||||
return new_color;
|
||||
}
|
||||
|
||||
/**
|
||||
* gdk_color_free:
|
||||
* @color: a #GdkColor
|
||||
*
|
||||
* Frees a #GdkColor created with gdk_color_copy().
|
||||
*
|
||||
* Deprecated: 3.14: Use #GdkRGBA
|
||||
*/
|
||||
void
|
||||
gdk_color_free (GdkColor *color)
|
||||
{
|
||||
g_return_if_fail (color != NULL);
|
||||
|
||||
g_slice_free (GdkColor, color);
|
||||
}
|
||||
|
||||
/**
|
||||
* gdk_color_hash:
|
||||
* @color: a #GdkColor
|
||||
*
|
||||
* A hash function suitable for using for a hash
|
||||
* table that stores #GdkColors.
|
||||
*
|
||||
* Returns: The hash function applied to @color
|
||||
*
|
||||
* Deprecated: 3.14: Use #GdkRGBA
|
||||
*/
|
||||
guint
|
||||
gdk_color_hash (const GdkColor *color)
|
||||
{
|
||||
return ((color->red) +
|
||||
(color->green << 11) +
|
||||
(color->blue << 22) +
|
||||
(color->blue >> 6));
|
||||
}
|
||||
|
||||
/**
|
||||
* gdk_color_equal:
|
||||
* @colora: a #GdkColor
|
||||
* @colorb: another #GdkColor
|
||||
*
|
||||
* Compares two colors.
|
||||
*
|
||||
* Returns: %TRUE if the two colors compare equal
|
||||
*
|
||||
* Deprecated: 3.14: Use #GdkRGBA
|
||||
*/
|
||||
gboolean
|
||||
gdk_color_equal (const GdkColor *colora,
|
||||
const GdkColor *colorb)
|
||||
{
|
||||
g_return_val_if_fail (colora != NULL, FALSE);
|
||||
g_return_val_if_fail (colorb != NULL, FALSE);
|
||||
|
||||
return ((colora->red == colorb->red) &&
|
||||
(colora->green == colorb->green) &&
|
||||
(colora->blue == colorb->blue));
|
||||
}
|
||||
|
||||
G_DEFINE_BOXED_TYPE (GdkColor, gdk_color,
|
||||
gdk_color_copy,
|
||||
gdk_color_free)
|
||||
|
||||
/**
|
||||
* gdk_color_parse:
|
||||
* @spec: the string specifying the color
|
||||
* @color: (out): the #GdkColor to fill in
|
||||
*
|
||||
* Parses a textual specification of a color and fill in the
|
||||
* @red, @green, and @blue fields of a #GdkColor.
|
||||
*
|
||||
* The string can either one of a large set of standard names
|
||||
* (taken from the X11 `rgb.txt` file), or it can be a hexadecimal
|
||||
* value in the form “\#rgb” “\#rrggbb”, “\#rrrgggbbb” or
|
||||
* “\#rrrrggggbbbb” where “r”, “g” and “b” are hex digits of
|
||||
* the red, green, and blue components of the color, respectively.
|
||||
* (White in the four forms is “\#fff”, “\#ffffff”, “\#fffffffff”
|
||||
* and “\#ffffffffffff”).
|
||||
*
|
||||
* Returns: %TRUE if the parsing succeeded
|
||||
*
|
||||
* Deprecated: 3.14: Use #GdkRGBA
|
||||
*/
|
||||
gboolean
|
||||
gdk_color_parse (const gchar *spec,
|
||||
GdkColor *color)
|
||||
{
|
||||
PangoColor pango_color;
|
||||
|
||||
if (pango_color_parse (&pango_color, spec))
|
||||
{
|
||||
color->red = pango_color.red;
|
||||
color->green = pango_color.green;
|
||||
color->blue = pango_color.blue;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
else
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/**
|
||||
* gdk_color_to_string:
|
||||
* @color: a #GdkColor
|
||||
*
|
||||
* Returns a textual specification of @color in the hexadecimal
|
||||
* form “\#rrrrggggbbbb” where “r”, “g” and “b” are hex digits
|
||||
* representing the red, green and blue components respectively.
|
||||
*
|
||||
* The returned string can be parsed by gdk_color_parse().
|
||||
*
|
||||
* Returns: a newly-allocated text string
|
||||
*
|
||||
* Since: 2.12
|
||||
*
|
||||
* Deprecated: 3.14: Use #GdkRGBA
|
||||
*/
|
||||
gchar *
|
||||
gdk_color_to_string (const GdkColor *color)
|
||||
{
|
||||
PangoColor pango_color;
|
||||
|
||||
g_return_val_if_fail (color != NULL, NULL);
|
||||
|
||||
pango_color.red = color->red;
|
||||
pango_color.green = color->green;
|
||||
pango_color.blue = color->blue;
|
||||
|
||||
return pango_color_to_string (&pango_color);
|
||||
}
|
@@ -1,87 +0,0 @@
|
||||
/* GDK - The GIMP Drawing Kit
|
||||
* Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
|
||||
*
|
||||
* This library 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 library 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 library. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Modified by the GTK+ Team and others 1997-2000. See the AUTHORS
|
||||
* file for a list of people on the GTK+ Team. See the ChangeLog
|
||||
* files for a list of changes. These files are distributed with
|
||||
* GTK+ at ftp://ftp.gtk.org/pub/gtk/.
|
||||
*/
|
||||
|
||||
#ifndef __GDK_COLOR_H__
|
||||
#define __GDK_COLOR_H__
|
||||
|
||||
#if !defined (__GDK_H_INSIDE__) && !defined (GDK_COMPILATION)
|
||||
#error "Only <gdk/gdk.h> can be included directly."
|
||||
#endif
|
||||
|
||||
#include <cairo.h>
|
||||
#include <gdk/gdktypes.h>
|
||||
#include <gdk/gdkversionmacros.h>
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
|
||||
/**
|
||||
* GdkColor:
|
||||
* @pixel: For allocated colors, the pixel value used to
|
||||
* draw this color on the screen. Not used anymore.
|
||||
* @red: The red component of the color. This is
|
||||
* a value between 0 and 65535, with 65535 indicating
|
||||
* full intensity
|
||||
* @green: The green component of the color
|
||||
* @blue: The blue component of the color
|
||||
*
|
||||
* A #GdkColor is used to describe a color,
|
||||
* similar to the XColor struct used in the X11 drawing API.
|
||||
*
|
||||
* Deprecated: 3.14: Use #GdkRGBA
|
||||
*/
|
||||
struct _GdkColor
|
||||
{
|
||||
guint32 pixel;
|
||||
guint16 red;
|
||||
guint16 green;
|
||||
guint16 blue;
|
||||
};
|
||||
|
||||
#define GDK_TYPE_COLOR (gdk_color_get_type ())
|
||||
|
||||
GDK_DEPRECATED_IN_3_14_FOR(gdk_rgba_get_type)
|
||||
GType gdk_color_get_type (void) G_GNUC_CONST;
|
||||
|
||||
GDK_DEPRECATED_IN_3_14_FOR(gdk_rgba_copy)
|
||||
GdkColor *gdk_color_copy (const GdkColor *color);
|
||||
GDK_DEPRECATED_IN_3_14_FOR(gdk_rgba_free)
|
||||
void gdk_color_free (GdkColor *color);
|
||||
|
||||
GDK_DEPRECATED_IN_3_14_FOR(gdk_rgba_hash)
|
||||
guint gdk_color_hash (const GdkColor *color);
|
||||
GDK_DEPRECATED_IN_3_14_FOR(gdk_rgba_equal)
|
||||
gboolean gdk_color_equal (const GdkColor *colora,
|
||||
const GdkColor *colorb);
|
||||
|
||||
GDK_DEPRECATED_IN_3_14_FOR(gdk_rgba_parse)
|
||||
gboolean gdk_color_parse (const gchar *spec,
|
||||
GdkColor *color);
|
||||
GDK_DEPRECATED_IN_3_14_FOR(gdk_rgba_to_string)
|
||||
gchar * gdk_color_to_string (const GdkColor *color);
|
||||
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* __GDK_COLOR_H__ */
|
@@ -63,10 +63,6 @@
|
||||
#include <gdk/gdkvisual.h>
|
||||
#include <gdk/gdkwindow.h>
|
||||
|
||||
#ifndef GDK_DISABLE_DEPRECATED
|
||||
#include <gdk/deprecated/gdkcolor.h>
|
||||
#endif
|
||||
|
||||
#include <gdk/gdk-autocleanup.h>
|
||||
|
||||
#undef __GDK_H_INSIDE__
|
||||
|
@@ -23,7 +23,6 @@
|
||||
#endif
|
||||
|
||||
#include <gdk/gdkversionmacros.h>
|
||||
#include <gdk/deprecated/gdkcolor.h>
|
||||
#include <gdk/gdkrgba.h>
|
||||
#include <gdk/gdkdrawingcontext.h>
|
||||
#include <gdk/gdkpixbuf.h>
|
||||
|
@@ -129,7 +129,6 @@ typedef struct _GdkAtom *GdkAtom;
|
||||
#define GDK_NONE _GDK_MAKE_ATOM (0)
|
||||
|
||||
/* Forward declarations of commonly used types */
|
||||
typedef struct _GdkColor GdkColor;
|
||||
typedef struct _GdkRGBA GdkRGBA;
|
||||
typedef struct _GdkCursor GdkCursor;
|
||||
typedef struct _GdkVisual GdkVisual;
|
||||
|
@@ -302,7 +302,6 @@ gtk_public_h_sources = \
|
||||
gtkstyleprovider.h \
|
||||
gtkswitch.h \
|
||||
gtktestutils.h \
|
||||
gtktextattributes.h \
|
||||
gtktextbuffer.h \
|
||||
gtktextbufferrichtext.h \
|
||||
gtktextchild.h \
|
||||
@@ -348,11 +347,6 @@ gtk_unix_print_public_h_sources = \
|
||||
gtkunixprint.h
|
||||
endif
|
||||
|
||||
# Installed header files without compatibility guarantees
|
||||
# that are not included in gtk/gtk.h
|
||||
gtk_semi_private_h_sources = \
|
||||
gtktextlayout.h
|
||||
|
||||
gtk_private_type_h_sources = \
|
||||
gtkcsstypesprivate.h \
|
||||
gtktexthandleprivate.h
|
||||
@@ -552,13 +546,14 @@ gtk_private_h_sources = \
|
||||
gtkstylecontextprivate.h \
|
||||
gtkstylepropertyprivate.h \
|
||||
gtkstyleproviderprivate.h \
|
||||
gtktextattributesprivate.h \
|
||||
gtktextattributes.h \
|
||||
gtktextbtree.h \
|
||||
gtktextbufferprivate.h \
|
||||
gtktextbufferserialize.h \
|
||||
gtktextchildprivate.h \
|
||||
gtktexthandleprivate.h \
|
||||
gtktextiterprivate.h \
|
||||
gtktextlayout.h \
|
||||
gtktextmarkprivate.h \
|
||||
gtktextsegment.h \
|
||||
gtktexttagprivate.h \
|
||||
@@ -1364,7 +1359,7 @@ gtktestutils.c: gtktypefuncs.c
|
||||
lib_LTLIBRARIES = libgtk-4.la
|
||||
|
||||
gtkincludedir = $(includedir)/gtk-4.0/gtk
|
||||
gtkinclude_HEADERS = $(gtk_public_h_sources) $(gtk_semi_private_h_sources) $(gtk_built_public_sources) gtkversion.h
|
||||
gtkinclude_HEADERS = $(gtk_public_h_sources) $(gtk_built_public_sources) gtkversion.h
|
||||
|
||||
a11yincludedir = $(includedir)/gtk-4.0/gtk/a11y
|
||||
a11yinclude_HEADERS= $(a11y_h_sources)
|
||||
|
@@ -30,6 +30,7 @@
|
||||
#include <gtk/gtk.h>
|
||||
#include "gtktextviewaccessibleprivate.h"
|
||||
#include "gtktextbufferprivate.h"
|
||||
#include "gtktextviewprivate.h"
|
||||
#include "gtk/gtkwidgetprivate.h"
|
||||
|
||||
struct _GtkTextViewAccessiblePrivate
|
||||
@@ -1124,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);
|
||||
|
@@ -1585,9 +1585,7 @@ settings_install_property_parser (GtkSettingsClass *class,
|
||||
GtkRcPropertyParser
|
||||
_gtk_rc_property_parser_from_type (GType type)
|
||||
{
|
||||
if (type == g_type_from_name ("GdkColor"))
|
||||
return gtk_rc_property_parse_color;
|
||||
else if (type == GTK_TYPE_REQUISITION)
|
||||
if (type == GTK_TYPE_REQUISITION)
|
||||
return gtk_rc_property_parse_requisition;
|
||||
else if (type == GTK_TYPE_BORDER)
|
||||
return gtk_rc_property_parse_border;
|
||||
@@ -1718,268 +1716,6 @@ gtk_rc_scanner_new (void)
|
||||
|
||||
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
|
||||
|
||||
static void
|
||||
color_shade (const GdkColor *color,
|
||||
GdkColor *color_return,
|
||||
gdouble factor)
|
||||
{
|
||||
GdkRGBA rgba;
|
||||
GtkHSLA hsla;
|
||||
|
||||
rgba.red = color->red / 65535.;
|
||||
rgba.green = color->green / 65535.;
|
||||
rgba.blue = color->blue / 65535.;
|
||||
rgba.alpha = 1.0;
|
||||
|
||||
_gtk_hsla_init_from_rgba (&hsla, &rgba);
|
||||
_gtk_hsla_shade (&hsla, &hsla, factor);
|
||||
_gdk_rgba_init_from_hsla (&rgba, &hsla);
|
||||
|
||||
color_return->red = 65535. * rgba.red;
|
||||
color_return->green = 65535. * rgba.green;
|
||||
color_return->blue = 65535. * rgba.blue;
|
||||
}
|
||||
|
||||
/*
|
||||
* gtk_parse_color:
|
||||
* @scanner: a #GScanner
|
||||
* @color: (out): a pointer to a #GdkColor in which to store
|
||||
* the result
|
||||
*
|
||||
* Parses a color in the format expected
|
||||
* in a RC file. If @style is not %NULL, it will be consulted to resolve
|
||||
* references to symbolic colors.
|
||||
*
|
||||
* Returns: %G_TOKEN_NONE if parsing succeeded, otherwise the token
|
||||
* that was expected but not found
|
||||
*/
|
||||
static guint
|
||||
gtk_parse_color (GScanner *scanner,
|
||||
GdkColor *color)
|
||||
{
|
||||
guint token;
|
||||
|
||||
g_return_val_if_fail (scanner != NULL, G_TOKEN_ERROR);
|
||||
|
||||
/* we don't need to set our own scope here, because
|
||||
* we don't need own symbols
|
||||
*/
|
||||
|
||||
token = g_scanner_get_next_token (scanner);
|
||||
switch (token)
|
||||
{
|
||||
gint token_int;
|
||||
GdkColor c1, c2;
|
||||
gboolean negate;
|
||||
gdouble l;
|
||||
|
||||
case G_TOKEN_LEFT_CURLY:
|
||||
token = g_scanner_get_next_token (scanner);
|
||||
if (token == G_TOKEN_INT)
|
||||
token_int = scanner->value.v_int;
|
||||
else if (token == G_TOKEN_FLOAT)
|
||||
token_int = scanner->value.v_float * 65535.0;
|
||||
else
|
||||
return G_TOKEN_FLOAT;
|
||||
color->red = CLAMP (token_int, 0, 65535);
|
||||
|
||||
token = g_scanner_get_next_token (scanner);
|
||||
if (token != G_TOKEN_COMMA)
|
||||
return G_TOKEN_COMMA;
|
||||
|
||||
token = g_scanner_get_next_token (scanner);
|
||||
if (token == G_TOKEN_INT)
|
||||
token_int = scanner->value.v_int;
|
||||
else if (token == G_TOKEN_FLOAT)
|
||||
token_int = scanner->value.v_float * 65535.0;
|
||||
else
|
||||
return G_TOKEN_FLOAT;
|
||||
color->green = CLAMP (token_int, 0, 65535);
|
||||
|
||||
token = g_scanner_get_next_token (scanner);
|
||||
if (token != G_TOKEN_COMMA)
|
||||
return G_TOKEN_COMMA;
|
||||
|
||||
token = g_scanner_get_next_token (scanner);
|
||||
if (token == G_TOKEN_INT)
|
||||
token_int = scanner->value.v_int;
|
||||
else if (token == G_TOKEN_FLOAT)
|
||||
token_int = scanner->value.v_float * 65535.0;
|
||||
else
|
||||
return G_TOKEN_FLOAT;
|
||||
color->blue = CLAMP (token_int, 0, 65535);
|
||||
|
||||
token = g_scanner_get_next_token (scanner);
|
||||
if (token != G_TOKEN_RIGHT_CURLY)
|
||||
return G_TOKEN_RIGHT_CURLY;
|
||||
return G_TOKEN_NONE;
|
||||
|
||||
case G_TOKEN_STRING:
|
||||
if (!gdk_color_parse (scanner->value.v_string, color))
|
||||
{
|
||||
g_scanner_warn (scanner, "Invalid color constant '%s'",
|
||||
scanner->value.v_string);
|
||||
return G_TOKEN_STRING;
|
||||
}
|
||||
return G_TOKEN_NONE;
|
||||
|
||||
case G_TOKEN_IDENTIFIER:
|
||||
if (strcmp (scanner->value.v_identifier, "mix") == 0)
|
||||
{
|
||||
token = g_scanner_get_next_token (scanner);
|
||||
if (token != G_TOKEN_LEFT_PAREN)
|
||||
return G_TOKEN_LEFT_PAREN;
|
||||
|
||||
negate = FALSE;
|
||||
if (g_scanner_peek_next_token (scanner) == '-')
|
||||
{
|
||||
g_scanner_get_next_token (scanner); /* eat sign */
|
||||
negate = TRUE;
|
||||
}
|
||||
|
||||
token = g_scanner_get_next_token (scanner);
|
||||
if (token != G_TOKEN_FLOAT)
|
||||
return G_TOKEN_FLOAT;
|
||||
|
||||
l = negate ? -scanner->value.v_float : scanner->value.v_float;
|
||||
|
||||
token = g_scanner_get_next_token (scanner);
|
||||
if (token != G_TOKEN_COMMA)
|
||||
return G_TOKEN_COMMA;
|
||||
|
||||
token = gtk_parse_color (scanner, &c1);
|
||||
if (token != G_TOKEN_NONE)
|
||||
return token;
|
||||
|
||||
token = g_scanner_get_next_token (scanner);
|
||||
if (token != G_TOKEN_COMMA)
|
||||
return G_TOKEN_COMMA;
|
||||
|
||||
token = gtk_parse_color (scanner, &c2);
|
||||
if (token != G_TOKEN_NONE)
|
||||
return token;
|
||||
|
||||
token = g_scanner_get_next_token (scanner);
|
||||
if (token != G_TOKEN_RIGHT_PAREN)
|
||||
return G_TOKEN_RIGHT_PAREN;
|
||||
|
||||
color->red = l * c1.red + (1.0 - l) * c2.red;
|
||||
color->green = l * c1.green + (1.0 - l) * c2.green;
|
||||
color->blue = l * c1.blue + (1.0 - l) * c2.blue;
|
||||
|
||||
return G_TOKEN_NONE;
|
||||
}
|
||||
else if (strcmp (scanner->value.v_identifier, "shade") == 0)
|
||||
{
|
||||
token = g_scanner_get_next_token (scanner);
|
||||
if (token != G_TOKEN_LEFT_PAREN)
|
||||
return G_TOKEN_LEFT_PAREN;
|
||||
|
||||
negate = FALSE;
|
||||
if (g_scanner_peek_next_token (scanner) == '-')
|
||||
{
|
||||
g_scanner_get_next_token (scanner); /* eat sign */
|
||||
negate = TRUE;
|
||||
}
|
||||
|
||||
token = g_scanner_get_next_token (scanner);
|
||||
if (token != G_TOKEN_FLOAT)
|
||||
return G_TOKEN_FLOAT;
|
||||
|
||||
l = negate ? -scanner->value.v_float : scanner->value.v_float;
|
||||
|
||||
token = g_scanner_get_next_token (scanner);
|
||||
if (token != G_TOKEN_COMMA)
|
||||
return G_TOKEN_COMMA;
|
||||
|
||||
token = gtk_parse_color (scanner, &c1);
|
||||
if (token != G_TOKEN_NONE)
|
||||
return token;
|
||||
|
||||
token = g_scanner_get_next_token (scanner);
|
||||
if (token != G_TOKEN_RIGHT_PAREN)
|
||||
return G_TOKEN_RIGHT_PAREN;
|
||||
|
||||
color_shade (&c1, color, l);
|
||||
|
||||
return G_TOKEN_NONE;
|
||||
}
|
||||
else if (strcmp (scanner->value.v_identifier, "lighter") == 0 ||
|
||||
strcmp (scanner->value.v_identifier, "darker") == 0)
|
||||
{
|
||||
if (scanner->value.v_identifier[0] == 'l')
|
||||
l = 1.3;
|
||||
else
|
||||
l = 0.7;
|
||||
|
||||
token = g_scanner_get_next_token (scanner);
|
||||
if (token != G_TOKEN_LEFT_PAREN)
|
||||
return G_TOKEN_LEFT_PAREN;
|
||||
|
||||
token = gtk_parse_color (scanner, &c1);
|
||||
if (token != G_TOKEN_NONE)
|
||||
return token;
|
||||
|
||||
token = g_scanner_get_next_token (scanner);
|
||||
if (token != G_TOKEN_RIGHT_PAREN)
|
||||
return G_TOKEN_RIGHT_PAREN;
|
||||
|
||||
color_shade (&c1, color, l);
|
||||
|
||||
return G_TOKEN_NONE;
|
||||
}
|
||||
else
|
||||
return G_TOKEN_IDENTIFIER;
|
||||
|
||||
default:
|
||||
return G_TOKEN_STRING;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* gtk_rc_property_parse_color:
|
||||
* @pspec: a #GParamSpec
|
||||
* @gstring: the #GString to be parsed
|
||||
* @property_value: a #GValue which must hold #GdkColor values.
|
||||
*
|
||||
* A #GtkRcPropertyParser for use with gtk_settings_install_property_parser()
|
||||
* or gtk_widget_class_install_style_property_parser() which parses a
|
||||
* color given either by its name or in the form
|
||||
* `{ red, green, blue }` where red, green and
|
||||
* blue are integers between 0 and 65535 or floating-point numbers
|
||||
* between 0 and 1.
|
||||
*
|
||||
* Returns: %TRUE if @gstring could be parsed and @property_value
|
||||
* has been set to the resulting #GdkColor.
|
||||
**/
|
||||
gboolean
|
||||
gtk_rc_property_parse_color (const GParamSpec *pspec,
|
||||
const GString *gstring,
|
||||
GValue *property_value)
|
||||
{
|
||||
GdkColor color = { 0, 0, 0, 0, };
|
||||
GScanner *scanner;
|
||||
gboolean success;
|
||||
|
||||
g_return_val_if_fail (G_IS_PARAM_SPEC (pspec), FALSE);
|
||||
g_return_val_if_fail (G_VALUE_HOLDS (property_value, GDK_TYPE_COLOR), FALSE);
|
||||
|
||||
scanner = gtk_rc_scanner_new ();
|
||||
g_scanner_input_text (scanner, gstring->str, gstring->len);
|
||||
if (gtk_parse_color (scanner, &color) == G_TOKEN_NONE &&
|
||||
g_scanner_get_next_token (scanner) == G_TOKEN_EOF)
|
||||
{
|
||||
g_value_set_boxed (property_value, &color);
|
||||
success = TRUE;
|
||||
}
|
||||
else
|
||||
success = FALSE;
|
||||
g_scanner_destroy (scanner);
|
||||
|
||||
return success;
|
||||
}
|
||||
|
||||
/**
|
||||
* gtk_rc_property_parse_enum:
|
||||
* @pspec: a #GParamSpec
|
||||
|
@@ -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__ */
|
@@ -64,12 +64,6 @@ G_GNUC_BEGIN_IGNORE_DEPRECATIONS
|
||||
|
||||
return tmp;
|
||||
}
|
||||
else if (value->g_type == GDK_TYPE_COLOR)
|
||||
{
|
||||
GdkColor *color = g_value_get_boxed (value);
|
||||
|
||||
return g_strdup_printf ("%x:%x:%x", color->red, color->green, color->blue);
|
||||
}
|
||||
else
|
||||
{
|
||||
g_warning ("Type %s is not serializable", g_type_name (value->g_type));
|
||||
@@ -134,45 +128,6 @@ G_GNUC_BEGIN_IGNORE_DEPRECATIONS
|
||||
|
||||
g_value_set_double (value, v);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
else if (value->g_type == GDK_TYPE_COLOR)
|
||||
{
|
||||
GdkColor color;
|
||||
const gchar *old;
|
||||
gchar *tmp;
|
||||
|
||||
old = str;
|
||||
tmp = NULL;
|
||||
errno = 0;
|
||||
color.red = g_ascii_strtoll (old, &tmp, 16);
|
||||
|
||||
if (errno || tmp == old)
|
||||
return FALSE;
|
||||
|
||||
old = tmp;
|
||||
if (*old++ != ':')
|
||||
return FALSE;
|
||||
|
||||
tmp = NULL;
|
||||
errno = 0;
|
||||
color.green = g_ascii_strtoll (old, &tmp, 16);
|
||||
if (errno || tmp == old)
|
||||
return FALSE;
|
||||
|
||||
old = tmp;
|
||||
if (*old++ != ':')
|
||||
return FALSE;
|
||||
|
||||
tmp = NULL;
|
||||
errno = 0;
|
||||
color.blue = g_ascii_strtoll (old, &tmp, 16);
|
||||
|
||||
if (errno || tmp == old || *tmp != '\0')
|
||||
return FALSE;
|
||||
|
||||
g_value_set_boxed (value, &color);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
else if (G_VALUE_HOLDS_ENUM (value))
|
||||
|
@@ -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);
|
||||
}
|
||||
|
||||
|
@@ -1458,6 +1458,32 @@ gtk_text_iter_can_insert (const GtkTextIter *iter,
|
||||
}
|
||||
}
|
||||
|
||||
gboolean
|
||||
gtk_text_iter_get_attributes (const GtkTextIter *iter,
|
||||
GtkTextAttributes *values)
|
||||
{
|
||||
GtkTextTag** tags;
|
||||
gint tag_count = 0;
|
||||
|
||||
/* Get the tags at this spot */
|
||||
tags = _gtk_text_btree_get_tags (iter, &tag_count);
|
||||
|
||||
/* No tags, use default style */
|
||||
if (tags == NULL || tag_count == 0)
|
||||
{
|
||||
g_free (tags);
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
_gtk_text_attributes_fill_from_tags (values,
|
||||
tags,
|
||||
tag_count);
|
||||
|
||||
g_free (tags);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/**
|
||||
* gtk_text_iter_get_language:
|
||||
@@ -1743,49 +1769,6 @@ gtk_text_iter_get_bytes_in_line (const GtkTextIter *iter)
|
||||
return count;
|
||||
}
|
||||
|
||||
/**
|
||||
* gtk_text_iter_get_attributes:
|
||||
* @iter: an iterator
|
||||
* @values: (out): a #GtkTextAttributes to be filled in
|
||||
*
|
||||
* Computes the effect of any tags applied to this spot in the
|
||||
* text. The @values parameter should be initialized to the default
|
||||
* settings you wish to use if no tags are in effect. You’d typically
|
||||
* obtain the defaults from gtk_text_view_get_default_attributes().
|
||||
*
|
||||
* gtk_text_iter_get_attributes() will modify @values, applying the
|
||||
* effects of any tags present at @iter. If any tags affected @values,
|
||||
* the function returns %TRUE.
|
||||
*
|
||||
* Returns: %TRUE if @values was modified
|
||||
**/
|
||||
gboolean
|
||||
gtk_text_iter_get_attributes (const GtkTextIter *iter,
|
||||
GtkTextAttributes *values)
|
||||
{
|
||||
GtkTextTag** tags;
|
||||
gint tag_count = 0;
|
||||
|
||||
/* Get the tags at this spot */
|
||||
tags = _gtk_text_btree_get_tags (iter, &tag_count);
|
||||
|
||||
/* No tags, use default style */
|
||||
if (tags == NULL || tag_count == 0)
|
||||
{
|
||||
g_free (tags);
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
_gtk_text_attributes_fill_from_tags (values,
|
||||
tags,
|
||||
tag_count);
|
||||
|
||||
g_free (tags);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/*
|
||||
* Increments/decrements
|
||||
*/
|
||||
|
@@ -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);
|
||||
@@ -7928,21 +7925,6 @@ gtk_text_view_ensure_layout (GtkTextView *text_view)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* gtk_text_view_get_default_attributes:
|
||||
* @text_view: a #GtkTextView
|
||||
*
|
||||
* Obtains a copy of the default text attributes. These are the
|
||||
* attributes used for text unless a tag overrides them.
|
||||
* You’d typically pass the default attributes in to
|
||||
* gtk_text_iter_get_attributes() in order to get the
|
||||
* attributes in effect at a given text position.
|
||||
*
|
||||
* The return value is a copy owned by the caller of this function,
|
||||
* and should be freed with gtk_text_attributes_unref().
|
||||
*
|
||||
* Returns: a new #GtkTextAttributes
|
||||
**/
|
||||
GtkTextAttributes*
|
||||
gtk_text_view_get_default_attributes (GtkTextView *text_view)
|
||||
{
|
||||
|
@@ -431,10 +431,6 @@ void gtk_text_view_set_tabs (GtkTextView *text_vi
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
PangoTabArray* gtk_text_view_get_tabs (GtkTextView *text_view);
|
||||
|
||||
/* note that the return value of this changes with the theme */
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GtkTextAttributes* gtk_text_view_get_default_attributes (GtkTextView *text_view);
|
||||
|
||||
GDK_AVAILABLE_IN_3_6
|
||||
void gtk_text_view_set_input_purpose (GtkTextView *text_view,
|
||||
GtkInputPurpose purpose);
|
||||
|
@@ -20,6 +20,7 @@
|
||||
#define __GTK_TEXT_VIEW_PRIVATE_H__
|
||||
|
||||
#include "gtktextview.h"
|
||||
#include "gtktextattributes.h"
|
||||
#include "gtkcssnodeprivate.h"
|
||||
|
||||
G_BEGIN_DECLS
|
||||
@@ -27,6 +28,9 @@ G_BEGIN_DECLS
|
||||
GtkCssNode * gtk_text_view_get_text_node (GtkTextView *text_view);
|
||||
GtkCssNode * gtk_text_view_get_selection_node (GtkTextView *text_view);
|
||||
|
||||
GtkTextAttributes * gtk_text_view_get_default_attributes (GtkTextView *text_view);
|
||||
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* __GTK_TEXT_VIEW_PRIVATE_H__ */
|
||||
|
Reference in New Issue
Block a user