From 1410031e5741e214e04bd9cc8dda6eb41877c3fb Mon Sep 17 00:00:00 2001 From: Matthias Clasen Date: Mon, 7 Nov 2016 14:43:49 -0500 Subject: [PATCH] Drop support for symbolic colors -gtk-gradient was the last internal user of this code, so we can drop it now. --- gtk/Makefile.am | 2 +- gtk/deprecated/Makefile.inc | 9 +- gtk/deprecated/gtksymboliccolor.c | 347 ----------------------- gtk/deprecated/gtksymboliccolor.h | 68 ----- gtk/deprecated/gtksymboliccolorprivate.h | 33 --- gtk/gtk.h | 4 - gtk/gtkcssstylefuncs.c | 93 ------ gtk/gtkstylecontext.c | 30 -- 8 files changed, 4 insertions(+), 582 deletions(-) delete mode 100644 gtk/deprecated/gtksymboliccolor.c delete mode 100644 gtk/deprecated/gtksymboliccolor.h delete mode 100644 gtk/deprecated/gtksymboliccolorprivate.h diff --git a/gtk/Makefile.am b/gtk/Makefile.am index 91cd99cf9d..34bfab78bb 100644 --- a/gtk/Makefile.am +++ b/gtk/Makefile.am @@ -1343,7 +1343,7 @@ gtkprivatetypebuiltins.c: $(gtk_private_type_h_sources) gtkprivatetypebuiltins. && rm -f xgen-gptbc -gtktypefuncs.c: stamp-gtktypebuiltins.h stamp-gtkprivatetypebuiltins.h $(top_srcdir)/gtk/*.h $(top_srcdir)/gtk/a11y/*.h $(top_srcdir)/gtk/deprecated/*.h $(top_srcdir)/gdk/*.h Makefile +gtktypefuncs.c: stamp-gtktypebuiltins.h stamp-gtkprivatetypebuiltins.h $(top_srcdir)/gtk/*.h $(top_srcdir)/gtk/a11y/*.h $(top_srcdir)/gdk/*.h Makefile $(AM_V_GEN) (echo '#undef GTK_COMPILATION' && echo '#include ') > xgen-gtfsrc.c && \ echo 'G_GNUC_BEGIN_IGNORE_DEPRECATIONS' > xgen-gtf && \ ${CPP} $(DEFS) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) xgen-gtfsrc.c | \ diff --git a/gtk/deprecated/Makefile.inc b/gtk/deprecated/Makefile.inc index f8bedfea14..502df48533 100644 --- a/gtk/deprecated/Makefile.inc +++ b/gtk/deprecated/Makefile.inc @@ -1,8 +1,5 @@ -deprecated_h_sources = \ - deprecated/gtksymboliccolor.h +deprecated_h_sources = -deprecated_private_h_sources = \ - deprecated/gtksymboliccolorprivate.h +deprecated_private_h_sources = -deprecated_c_sources = \ - deprecated/gtksymboliccolor.c +deprecated_c_sources = diff --git a/gtk/deprecated/gtksymboliccolor.c b/gtk/deprecated/gtksymboliccolor.c deleted file mode 100644 index c2b9d49b8d..0000000000 --- a/gtk/deprecated/gtksymboliccolor.c +++ /dev/null @@ -1,347 +0,0 @@ -/* GTK - The GIMP Toolkit - * Copyright (C) 2010 Carlos Garnacho - * - * 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 . - */ - -#include "config.h" - -#define GDK_DISABLE_DEPRECATION_WARNINGS - -#include "gtkcsscolorvalueprivate.h" -#include "gtkcssrgbavalueprivate.h" -#include "gtkcssstylepropertyprivate.h" -#include "gtkhslaprivate.h" -#include "gtkstylepropertyprivate.h" -#include "gtksymboliccolorprivate.h" -#include "gtkintl.h" -#include "gtkwin32themeprivate.h" - -/** - * SECTION:gtksymboliccolor - * @Short_description: Symbolic colors - * @Title: GtkSymbolicColor - * - * GtkSymbolicColor is a boxed type that represents a symbolic color. - * It is the result of parsing a - * [color expression][gtkcssprovider-symbolic-colors]. - * To obtain the color represented by a GtkSymbolicColor, it has to - * be resolved with gtk_symbolic_color_resolve(), which replaces all - * symbolic color references by the colors they refer to (in a given - * context) and evaluates mix, shade and other expressions, resulting - * in a #GdkRGBA value. - * - * It is not normally necessary to deal directly with #GtkSymbolicColors, - * since they are mostly used behind the scenes by #GtkStyleContext and - * #GtkCssProvider. - * - * #GtkSymbolicColor is deprecated. Symbolic colors are considered an - * implementation detail of GTK+. - */ - -G_DEFINE_BOXED_TYPE (GtkSymbolicColor, gtk_symbolic_color, - gtk_symbolic_color_ref, gtk_symbolic_color_unref) - -struct _GtkSymbolicColor -{ - GtkCssValue *value; - gint ref_count; -}; - -static GtkSymbolicColor * -gtk_symbolic_color_new (GtkCssValue *value) -{ - GtkSymbolicColor *symbolic; - - symbolic = g_slice_new0 (GtkSymbolicColor); - symbolic->value = value; - symbolic->ref_count = 1; - - return symbolic; -} - -/** - * gtk_symbolic_color_new_literal: - * @color: a #GdkRGBA - * - * Creates a symbolic color pointing to a literal color. - * - * Returns: a newly created #GtkSymbolicColor - * - * Since: 3.0 - * - * Deprecated: 3.8: #GtkSymbolicColor is deprecated. - **/ -GtkSymbolicColor * -gtk_symbolic_color_new_literal (const GdkRGBA *color) -{ - g_return_val_if_fail (color != NULL, NULL); - - return gtk_symbolic_color_new (_gtk_css_color_value_new_literal (color)); -} - -/** - * gtk_symbolic_color_new_name: - * @name: color name - * - * Creates a symbolic color pointing to an unresolved named - * color. See gtk_style_context_lookup_color() and - * gtk_style_properties_lookup_color(). - * - * Returns: a newly created #GtkSymbolicColor - * - * Since: 3.0 - * - * Deprecated: 3.8: #GtkSymbolicColor is deprecated. - **/ -GtkSymbolicColor * -gtk_symbolic_color_new_name (const gchar *name) -{ - g_return_val_if_fail (name != NULL, NULL); - - return gtk_symbolic_color_new (_gtk_css_color_value_new_name (name)); -} - -/** - * gtk_symbolic_color_new_shade: (constructor) - * @color: another #GtkSymbolicColor - * @factor: shading factor to apply to @color - * - * Creates a symbolic color defined as a shade of - * another color. A factor > 1.0 would resolve to - * a brighter color, while < 1.0 would resolve to - * a darker color. - * - * Returns: A newly created #GtkSymbolicColor - * - * Since: 3.0 - * - * Deprecated: 3.8: #GtkSymbolicColor is deprecated. - **/ -GtkSymbolicColor * -gtk_symbolic_color_new_shade (GtkSymbolicColor *color, - gdouble factor) -{ - g_return_val_if_fail (color != NULL, NULL); - - return gtk_symbolic_color_new (_gtk_css_color_value_new_shade (color->value, - factor)); -} - -/** - * gtk_symbolic_color_new_alpha: (constructor) - * @color: another #GtkSymbolicColor - * @factor: factor to apply to @color alpha - * - * Creates a symbolic color by modifying the relative alpha - * value of @color. A factor < 1.0 would resolve to a more - * transparent color, while > 1.0 would resolve to a more - * opaque color. - * - * Returns: A newly created #GtkSymbolicColor - * - * Since: 3.0 - * - * Deprecated: 3.8: #GtkSymbolicColor is deprecated. - **/ -GtkSymbolicColor * -gtk_symbolic_color_new_alpha (GtkSymbolicColor *color, - gdouble factor) -{ - g_return_val_if_fail (color != NULL, NULL); - - return gtk_symbolic_color_new (_gtk_css_color_value_new_alpha (color->value, - factor)); -} - -/** - * gtk_symbolic_color_new_mix: (constructor) - * @color1: color to mix - * @color2: another color to mix - * @factor: mix factor - * - * Creates a symbolic color defined as a mix of another - * two colors. a mix factor of 0 would resolve to @color1, - * while a factor of 1 would resolve to @color2. - * - * Returns: A newly created #GtkSymbolicColor - * - * Since: 3.0 - * - * Deprecated: 3.8: #GtkSymbolicColor is deprecated. - **/ -GtkSymbolicColor * -gtk_symbolic_color_new_mix (GtkSymbolicColor *color1, - GtkSymbolicColor *color2, - gdouble factor) -{ - g_return_val_if_fail (color1 != NULL, NULL); - g_return_val_if_fail (color1 != NULL, NULL); - - return gtk_symbolic_color_new (_gtk_css_color_value_new_mix (color1->value, - color2->value, - factor)); -} - -/** - * gtk_symbolic_color_new_win32: (constructor) - * @theme_class: The theme class to pull color from - * @id: The color id - * - * Creates a symbolic color based on the current win32 - * theme. - * - * Note that while this call is available on all platforms - * the actual value returned is not reliable on non-win32 - * platforms. - * - * Returns: A newly created #GtkSymbolicColor - * - * Since: 3.4 - * - * Deprecated: 3.8: #GtkSymbolicColor is deprecated. - */ -GtkSymbolicColor * -gtk_symbolic_color_new_win32 (const gchar *theme_class, - gint id) -{ - g_return_val_if_fail (theme_class != NULL, NULL); - - return gtk_symbolic_color_new (_gtk_css_color_value_new_win32 (theme_class, id)); -} - -/** - * gtk_symbolic_color_ref: - * @color: a #GtkSymbolicColor - * - * Increases the reference count of @color - * - * Returns: the same @color - * - * Since: 3.0 - * - * Deprecated: 3.8: #GtkSymbolicColor is deprecated. - **/ -GtkSymbolicColor * -gtk_symbolic_color_ref (GtkSymbolicColor *color) -{ - g_return_val_if_fail (color != NULL, NULL); - - color->ref_count++; - - return color; -} - -/** - * gtk_symbolic_color_unref: - * @color: a #GtkSymbolicColor - * - * Decreases the reference count of @color, freeing its memory if the - * reference count reaches 0. - * - * Since: 3.0 - * - * Deprecated: 3.8: #GtkSymbolicColor is deprecated. - **/ -void -gtk_symbolic_color_unref (GtkSymbolicColor *color) -{ - g_return_if_fail (color != NULL); - - if (--color->ref_count) - return; - - _gtk_css_value_unref (color->value); - - g_slice_free (GtkSymbolicColor, color); -} - -/** - * gtk_symbolic_color_resolve: - * @color: a #GtkSymbolicColor - * @resolved_color: (out): return location for the resolved color - * - * If @color is resolvable, @resolved_color will be filled in - * with the resolved color, and %TRUE will be returned. - * - * Returns: %TRUE if the color has been resolved - * - * Since: 3.0 - * - * Deprecated: 3.8: #GtkSymbolicColor is deprecated. - **/ -gboolean -gtk_symbolic_color_resolve (GtkSymbolicColor *color, - GdkRGBA *resolved_color) -{ - GdkRGBA pink = { 1.0, 0.5, 0.5, 1.0 }; - GtkCssValue *v, *current; - - g_return_val_if_fail (color != NULL, FALSE); - g_return_val_if_fail (resolved_color != NULL, FALSE); - - current = _gtk_css_rgba_value_new_from_rgba (&pink); - v = _gtk_css_color_value_resolve (color->value, - NULL, - current, - NULL); - _gtk_css_value_unref (current); - if (v == NULL) - return FALSE; - - *resolved_color = *_gtk_css_rgba_value_get_rgba (v); - _gtk_css_value_unref (v); - return TRUE; -} - -/** - * gtk_symbolic_color_to_string: - * @color: color to convert to a string - * - * Converts the given @color to a string representation. This is useful - * both for debugging and for serialization of strings. The format of - * the string may change between different versions of GTK, but it is - * guaranteed that the GTK css parser is able to read the string and - * create the same symbolic color from it. - * - * Returns: a new string representing @color - * - * Deprecated: 3.8: #GtkSymbolicColor is deprecated. - **/ -char * -gtk_symbolic_color_to_string (GtkSymbolicColor *color) -{ - g_return_val_if_fail (color != NULL, NULL); - - return _gtk_css_value_to_string (color->value); -} - -GtkSymbolicColor * -_gtk_css_symbolic_value_new (GtkCssParser *parser) -{ - GtkCssValue *value; - - value = _gtk_css_color_value_parse (parser); - if (value == NULL) - return NULL; - - return gtk_symbolic_color_new (value); -} - -GtkCssValue * -_gtk_symbolic_color_get_css_value (GtkSymbolicColor *symbolic) -{ - return symbolic->value; -} - diff --git a/gtk/deprecated/gtksymboliccolor.h b/gtk/deprecated/gtksymboliccolor.h deleted file mode 100644 index 992dfa2b79..0000000000 --- a/gtk/deprecated/gtksymboliccolor.h +++ /dev/null @@ -1,68 +0,0 @@ -/* GTK - The GIMP Toolkit - * Copyright (C) 2010 Carlos Garnacho - * - * 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 . - */ - -#ifndef __GTK_SYMBOLIC_COLOR_H__ -#define __GTK_SYMBOLIC_COLOR_H__ - -#if !defined (__GTK_H_INSIDE__) && !defined (GTK_COMPILATION) -#error "Only can be included directly." -#endif - -#include - -G_BEGIN_DECLS - -typedef struct _GtkSymbolicColor GtkSymbolicColor; - -#define GTK_TYPE_SYMBOLIC_COLOR (gtk_symbolic_color_get_type ()) - -GDK_DEPRECATED_IN_3_8 -GType gtk_symbolic_color_get_type (void) G_GNUC_CONST; - -GDK_DEPRECATED_IN_3_8 -GtkSymbolicColor * gtk_symbolic_color_new_literal (const GdkRGBA *color); -GDK_DEPRECATED_IN_3_8 -GtkSymbolicColor * gtk_symbolic_color_new_name (const gchar *name); -GDK_DEPRECATED_IN_3_8 -GtkSymbolicColor * gtk_symbolic_color_new_shade (GtkSymbolicColor *color, - gdouble factor); -GDK_DEPRECATED_IN_3_8 -GtkSymbolicColor * gtk_symbolic_color_new_alpha (GtkSymbolicColor *color, - gdouble factor); -GDK_DEPRECATED_IN_3_8 -GtkSymbolicColor * gtk_symbolic_color_new_mix (GtkSymbolicColor *color1, - GtkSymbolicColor *color2, - gdouble factor); -GDK_DEPRECATED_IN_3_8 -GtkSymbolicColor * gtk_symbolic_color_new_win32 (const gchar *theme_class, - gint id); - -GDK_DEPRECATED_IN_3_8 -GtkSymbolicColor * gtk_symbolic_color_ref (GtkSymbolicColor *color); -GDK_DEPRECATED_IN_3_8 -void gtk_symbolic_color_unref (GtkSymbolicColor *color); - -GDK_DEPRECATED_IN_3_8 -char * gtk_symbolic_color_to_string (GtkSymbolicColor *color); - -GDK_DEPRECATED_IN_3_8 -gboolean gtk_symbolic_color_resolve (GtkSymbolicColor *color, - GdkRGBA *resolved_color); - -G_END_DECLS - -#endif /* __GTK_SYMBOLIC_COLOR_H__ */ diff --git a/gtk/deprecated/gtksymboliccolorprivate.h b/gtk/deprecated/gtksymboliccolorprivate.h deleted file mode 100644 index abbee19a89..0000000000 --- a/gtk/deprecated/gtksymboliccolorprivate.h +++ /dev/null @@ -1,33 +0,0 @@ -/* GTK - The GIMP Toolkit - * Copyright (C) 2011 Benjamin Otte - * - * 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 . - */ - -#ifndef __GTK_SYMBOLIC_COLOR_PRIVATE_H__ -#define __GTK_SYMBOLIC_COLOR_PRIVATE_H__ - -#include "gtk/deprecated/gtksymboliccolor.h" -#include "gtk/gtkcssparserprivate.h" -#include "gtk/gtkcssvalueprivate.h" - -G_BEGIN_DECLS - -GtkSymbolicColor * _gtk_css_symbolic_value_new (GtkCssParser *parser); - -GtkCssValue * _gtk_symbolic_color_get_css_value (GtkSymbolicColor *symbolic); - -G_END_DECLS - -#endif /* __GTK_SYMBOLIC_COLOR_PRIVATE_H__ */ diff --git a/gtk/gtk.h b/gtk/gtk.h index 89b927b2e1..a3f903dfdb 100644 --- a/gtk/gtk.h +++ b/gtk/gtk.h @@ -241,10 +241,6 @@ #include #include -#ifndef GTK_DISABLE_DEPRECATED -#include -#endif /* GTK_DISABLE_DEPRECATED */ - #include #undef __GTK_H_INSIDE__ diff --git a/gtk/gtkcssstylefuncs.c b/gtk/gtkcssstylefuncs.c index bd1e839ad4..1fe910865d 100644 --- a/gtk/gtkcssstylefuncs.c +++ b/gtk/gtkcssstylefuncs.c @@ -36,7 +36,6 @@ #include "gtktypebuiltins.h" #include "gtkcsswin32sizevalueprivate.h" -#include "deprecated/gtksymboliccolorprivate.h" /* this is in case round() is not provided by the compiler, * such as in the case of C89 compilers, like MSVC @@ -122,86 +121,6 @@ enum_print (int value, g_type_class_unref (enum_class); } -static gboolean -rgba_value_parse (GtkCssParser *parser, - GValue *value) -{ - GtkSymbolicColor *symbolic; - GdkRGBA rgba; - - G_GNUC_BEGIN_IGNORE_DEPRECATIONS; - - symbolic = _gtk_css_symbolic_value_new (parser); - if (symbolic == NULL) - return FALSE; - - if (gtk_symbolic_color_resolve (symbolic, &rgba)) - { - g_value_set_boxed (value, &rgba); - gtk_symbolic_color_unref (symbolic); - } - else - { - g_value_unset (value); - g_value_init (value, GTK_TYPE_SYMBOLIC_COLOR); - g_value_take_boxed (value, symbolic); - } - - G_GNUC_END_IGNORE_DEPRECATIONS; - - return TRUE; -} - -static void -rgba_value_print (const GValue *value, - GString *string) -{ - const GdkRGBA *rgba = g_value_get_boxed (value); - - if (rgba == NULL) - g_string_append (string, "none"); - else - { - char *s = gdk_rgba_to_string (rgba); - g_string_append (string, s); - g_free (s); - } -} - -static gboolean -symbolic_color_value_parse (GtkCssParser *parser, - GValue *value) -{ - GtkSymbolicColor *symbolic; - - symbolic = _gtk_css_symbolic_value_new (parser); - if (symbolic == NULL) - return FALSE; - - g_value_take_boxed (value, symbolic); - return TRUE; -} - -static void -symbolic_color_value_print (const GValue *value, - GString *string) -{ - GtkSymbolicColor *symbolic = g_value_get_boxed (value); - - G_GNUC_BEGIN_IGNORE_DEPRECATIONS; - - if (symbolic == NULL) - g_string_append (string, "none"); - else - { - char *s = gtk_symbolic_color_to_string (symbolic); - g_string_append (string, s); - g_free (s); - } - - G_GNUC_END_IGNORE_DEPRECATIONS; -} - static gboolean font_description_value_parse (GtkCssParser *parser, GValue *value) @@ -695,18 +614,6 @@ gtk_css_style_funcs_init (void) parse_funcs = g_hash_table_new (NULL, NULL); print_funcs = g_hash_table_new (NULL, NULL); - register_conversion_function (GDK_TYPE_RGBA, - rgba_value_parse, - rgba_value_print); - - G_GNUC_BEGIN_IGNORE_DEPRECATIONS; - - register_conversion_function (GTK_TYPE_SYMBOLIC_COLOR, - symbolic_color_value_parse, - symbolic_color_value_print); - - G_GNUC_END_IGNORE_DEPRECATIONS; - register_conversion_function (PANGO_TYPE_FONT_DESCRIPTION, font_description_value_parse, font_description_value_print); diff --git a/gtk/gtkstylecontext.c b/gtk/gtkstylecontext.c index 6b2eb19e02..64641f8bb4 100644 --- a/gtk/gtkstylecontext.c +++ b/gtk/gtkstylecontext.c @@ -55,9 +55,6 @@ #include "gtkwidgetpath.h" #include "gtkwidgetprivate.h" -#include "deprecated/gtksymboliccolorprivate.h" - -#include "fallback-c89.c" /** * SECTION:gtkstylecontext @@ -1392,33 +1389,6 @@ _gtk_style_context_peek_style_property (GtkStyleContext *context, gtk_widget_path_iter_get_state (path, -1), pspec, &pcache->value)) { - G_GNUC_BEGIN_IGNORE_DEPRECATIONS; - - /* Resolve symbolic colors to GdkRGBA */ - if (G_VALUE_TYPE (&pcache->value) == GTK_TYPE_SYMBOLIC_COLOR) - { - GtkSymbolicColor *color; - GdkRGBA rgba; - - color = g_value_dup_boxed (&pcache->value); - - g_value_unset (&pcache->value); - - g_assert (G_PARAM_SPEC_VALUE_TYPE (pspec) == GDK_TYPE_RGBA); - g_value_init (&pcache->value, GDK_TYPE_RGBA); - - if (_gtk_style_context_resolve_color (context, _gtk_symbolic_color_get_css_value (color), &rgba)) - g_value_set_boxed (&pcache->value, &rgba); - else - g_param_value_set_default (pspec, &pcache->value); - - gtk_symbolic_color_unref (color); - } - - G_GNUC_END_IGNORE_DEPRECATIONS; - - gtk_widget_path_unref (path); - return &pcache->value; } }