summaryrefslogtreecommitdiff
path: root/gtk/deprecated
diff options
context:
space:
mode:
authorBenjamin Otte <otte@redhat.com>2012-11-25 04:16:43 +0100
committerBenjamin Otte <otte@redhat.com>2012-11-25 04:16:43 +0100
commit41486895d5c59ebe049a57e2083f3987fe15ddf6 (patch)
tree60ef8d771d7bc4ee729554125039dacfc7af574f /gtk/deprecated
parent0862afadedf1a8e0188c21d213fdc0906477a625 (diff)
downloadgtk+-41486895d5c59ebe049a57e2083f3987fe15ddf6.tar.gz
deprecations: Move files into deprecated/ dir
Diffstat (limited to 'gtk/deprecated')
-rw-r--r--gtk/deprecated/gtkgradient.c551
-rw-r--r--gtk/deprecated/gtkgradient.h74
-rw-r--r--gtk/deprecated/gtkgradientprivate.h39
-rw-r--r--gtk/deprecated/gtksymboliccolor.c359
-rw-r--r--gtk/deprecated/gtksymboliccolor.h67
-rw-r--r--gtk/deprecated/gtksymboliccolorprivate.h33
6 files changed, 1123 insertions, 0 deletions
diff --git a/gtk/deprecated/gtkgradient.c b/gtk/deprecated/gtkgradient.c
new file mode 100644
index 0000000000..78cf7a3bfc
--- /dev/null
+++ b/gtk/deprecated/gtkgradient.c
@@ -0,0 +1,551 @@
+/* GTK - The GIMP Toolkit
+ * Copyright (C) 2010 Carlos Garnacho <carlosg@gnome.org>
+ *
+ * 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/>.
+ */
+
+#include "config.h"
+
+#define GDK_DISABLE_DEPRECATION_WARNINGS
+
+#include "gtkgradientprivate.h"
+
+#include "gtkcsscolorvalueprivate.h"
+#include "gtkcssrgbavalueprivate.h"
+#include "gtkstylecontextprivate.h"
+#include "gtkstyleproperties.h"
+#include "gtksymboliccolorprivate.h"
+
+/**
+ * SECTION:gtkgradient
+ * @Short_description: Gradients
+ * @Title: GtkGradient
+ *
+ * GtkGradient is a boxed type that represents a gradient.
+ * It is the result of parsing a
+ * <link linkend="gtkcssprovider-gradients">gradient expression</link>.
+ * To obtain the gradient represented by a GtkGradient, it has to
+ * be resolved with gtk_gradient_resolve(), which replaces all
+ * symbolic color references by the colors they refer to (in a given
+ * context) and constructs a #cairo_pattern_t value.
+ *
+ * It is not normally necessary to deal directly with #GtkGradients,
+ * since they are mostly used behind the scenes by #GtkStyleContext and
+ * #GtkCssProvider.
+ *
+ * #GtkGradient is deprecated. It was used internally by GTK's CSS engine
+ * to represent gradients. As its handling is not conforming to modern
+ * web standards, it is not used anymore. If you want to use gradients in
+ * your own code, please use Cairo directly.
+ */
+
+G_DEFINE_BOXED_TYPE (GtkGradient, gtk_gradient,
+ gtk_gradient_ref, gtk_gradient_unref)
+
+typedef struct ColorStop ColorStop;
+
+struct ColorStop
+{
+ gdouble offset;
+ GtkSymbolicColor *color;
+};
+
+struct _GtkGradient
+{
+ gdouble x0;
+ gdouble y0;
+ gdouble x1;
+ gdouble y1;
+ gdouble radius0;
+ gdouble radius1;
+
+ GArray *stops;
+
+ guint ref_count;
+};
+
+/**
+ * gtk_gradient_new_linear:
+ * @x0: X coordinate of the starting point
+ * @y0: Y coordinate of the starting point
+ * @x1: X coordinate of the end point
+ * @y1: Y coordinate of the end point
+ *
+ * Creates a new linear gradient along the line defined by (x0, y0) and (x1, y1). Before using the gradient
+ * a number of stop colors must be added through gtk_gradient_add_color_stop().
+ *
+ * Returns: A newly created #GtkGradient
+ *
+ * Since: 3.0
+ *
+ * Deprecated: 3.8: #GtkGradient is deprecated.
+ **/
+GtkGradient *
+gtk_gradient_new_linear (gdouble x0,
+ gdouble y0,
+ gdouble x1,
+ gdouble y1)
+{
+ GtkGradient *gradient;
+
+ gradient = g_slice_new (GtkGradient);
+ gradient->stops = g_array_new (FALSE, FALSE, sizeof (ColorStop));
+
+ gradient->x0 = x0;
+ gradient->y0 = y0;
+ gradient->x1 = x1;
+ gradient->y1 = y1;
+ gradient->radius0 = 0;
+ gradient->radius1 = 0;
+
+ gradient->ref_count = 1;
+
+ return gradient;
+}
+
+/**
+ * gtk_gradient_new_radial:
+ * @x0: X coordinate of the start circle
+ * @y0: Y coordinate of the start circle
+ * @radius0: radius of the start circle
+ * @x1: X coordinate of the end circle
+ * @y1: Y coordinate of the end circle
+ * @radius1: radius of the end circle
+ *
+ * Creates a new radial gradient along the two circles defined by (x0, y0, radius0) and
+ * (x1, y1, radius1). Before using the gradient a number of stop colors must be added
+ * through gtk_gradient_add_color_stop().
+ *
+ * Returns: A newly created #GtkGradient
+ *
+ * Since: 3.0
+ *
+ * Deprecated: 3.8: #GtkGradient is deprecated.
+ **/
+GtkGradient *
+gtk_gradient_new_radial (gdouble x0,
+ gdouble y0,
+ gdouble radius0,
+ gdouble x1,
+ gdouble y1,
+ gdouble radius1)
+{
+ GtkGradient *gradient;
+
+ gradient = g_slice_new (GtkGradient);
+ gradient->stops = g_array_new (FALSE, FALSE, sizeof (ColorStop));
+
+ gradient->x0 = x0;
+ gradient->y0 = y0;
+ gradient->x1 = x1;
+ gradient->y1 = y1;
+ gradient->radius0 = radius0;
+ gradient->radius1 = radius1;
+
+ gradient->ref_count = 1;
+
+ return gradient;
+}
+
+/**
+ * gtk_gradient_add_color_stop:
+ * @gradient: a #GtkGradient
+ * @offset: offset for the color stop
+ * @color: color to use
+ *
+ * Adds a stop color to @gradient.
+ *
+ * Since: 3.0
+ *
+ * Deprecated: 3.8: #GtkGradient is deprecated.
+ **/
+void
+gtk_gradient_add_color_stop (GtkGradient *gradient,
+ gdouble offset,
+ GtkSymbolicColor *color)
+{
+ ColorStop stop;
+
+ g_return_if_fail (gradient != NULL);
+
+ stop.offset = offset;
+ stop.color = gtk_symbolic_color_ref (color);
+
+ g_array_append_val (gradient->stops, stop);
+}
+
+/**
+ * gtk_gradient_ref:
+ * @gradient: a #GtkGradient
+ *
+ * Increases the reference count of @gradient.
+ *
+ * Returns: The same @gradient
+ *
+ * Since: 3.0
+ *
+ * Deprecated: 3.8: #GtkGradient is deprecated.
+ **/
+GtkGradient *
+gtk_gradient_ref (GtkGradient *gradient)
+{
+ g_return_val_if_fail (gradient != NULL, NULL);
+
+ gradient->ref_count++;
+
+ return gradient;
+}
+
+/**
+ * gtk_gradient_unref:
+ * @gradient: a #GtkGradient
+ *
+ * Decreases the reference count of @gradient, freeing its memory
+ * if the reference count reaches 0.
+ *
+ * Since: 3.0
+ *
+ * Deprecated: 3.8: #GtkGradient is deprecated.
+ **/
+void
+gtk_gradient_unref (GtkGradient *gradient)
+{
+ g_return_if_fail (gradient != NULL);
+
+ gradient->ref_count--;
+
+ if (gradient->ref_count == 0)
+ {
+ guint i;
+
+ for (i = 0; i < gradient->stops->len; i++)
+ {
+ ColorStop *stop;
+
+ stop = &g_array_index (gradient->stops, ColorStop, i);
+ gtk_symbolic_color_unref (stop->color);
+ }
+
+ g_array_free (gradient->stops, TRUE);
+ g_slice_free (GtkGradient, gradient);
+ }
+}
+
+/**
+ * gtk_gradient_resolve:
+ * @gradient: a #GtkGradient
+ * @props: #GtkStyleProperties to use when resolving named colors
+ * @resolved_gradient: (out): return location for the resolved pattern
+ *
+ * If @gradient is resolvable, @resolved_gradient will be filled in
+ * with the resolved gradient as a cairo_pattern_t, and %TRUE will
+ * be returned. Generally, if @gradient can't be resolved, it is
+ * due to it being defined on top of a named color that doesn't
+ * exist in @props.
+ *
+ * Returns: %TRUE if the gradient has been resolved
+ *
+ * Since: 3.0
+ *
+ * Deprecated: 3.8: #GtkGradient is deprecated.
+ **/
+gboolean
+gtk_gradient_resolve (GtkGradient *gradient,
+ GtkStyleProperties *props,
+ cairo_pattern_t **resolved_gradient)
+{
+ cairo_pattern_t *pattern;
+ guint i;
+
+ g_return_val_if_fail (gradient != NULL, FALSE);
+ g_return_val_if_fail (GTK_IS_STYLE_PROPERTIES (props), FALSE);
+ g_return_val_if_fail (resolved_gradient != NULL, FALSE);
+
+ if (gradient->radius0 == 0 && gradient->radius1 == 0)
+ pattern = cairo_pattern_create_linear (gradient->x0, gradient->y0,
+ gradient->x1, gradient->y1);
+ else
+ pattern = cairo_pattern_create_radial (gradient->x0, gradient->y0,
+ gradient->radius0,
+ gradient->x1, gradient->y1,
+ gradient->radius1);
+
+ for (i = 0; i < gradient->stops->len; i++)
+ {
+ ColorStop *stop;
+ GdkRGBA color;
+
+ stop = &g_array_index (gradient->stops, ColorStop, i);
+
+ if (!gtk_symbolic_color_resolve (stop->color, props, &color))
+ {
+ cairo_pattern_destroy (pattern);
+ return FALSE;
+ }
+
+ cairo_pattern_add_color_stop_rgba (pattern, stop->offset,
+ color.red, color.green,
+ color.blue, color.alpha);
+ }
+
+ *resolved_gradient = pattern;
+ return TRUE;
+}
+
+cairo_pattern_t *
+_gtk_gradient_resolve_full (GtkGradient *gradient,
+ GtkStyleProviderPrivate *provider,
+ GtkCssComputedValues *values,
+ GtkCssComputedValues *parent_values,
+ GtkCssDependencies *dependencies)
+{
+ cairo_pattern_t *pattern;
+ guint i;
+
+ g_return_val_if_fail (gradient != NULL, NULL);
+ g_return_val_if_fail (GTK_IS_STYLE_PROVIDER (provider), NULL);
+ g_return_val_if_fail (GTK_IS_CSS_COMPUTED_VALUES (values), NULL);
+ g_return_val_if_fail (parent_values == NULL || GTK_IS_CSS_COMPUTED_VALUES (parent_values), NULL);
+ g_return_val_if_fail (*dependencies == 0, NULL);
+
+ if (gradient->radius0 == 0 && gradient->radius1 == 0)
+ pattern = cairo_pattern_create_linear (gradient->x0, gradient->y0,
+ gradient->x1, gradient->y1);
+ else
+ pattern = cairo_pattern_create_radial (gradient->x0, gradient->y0,
+ gradient->radius0,
+ gradient->x1, gradient->y1,
+ gradient->radius1);
+
+ for (i = 0; i < gradient->stops->len; i++)
+ {
+ ColorStop *stop;
+ GtkCssValue *val;
+ GdkRGBA rgba;
+ GtkCssDependencies stop_deps;
+
+ stop = &g_array_index (gradient->stops, ColorStop, i);
+
+ /* if color resolving fails, assume transparency */
+ val = _gtk_css_color_value_resolve (_gtk_symbolic_color_get_css_value (stop->color),
+ provider,
+ _gtk_css_computed_values_get_value (values, GTK_CSS_PROPERTY_COLOR),
+ GTK_CSS_DEPENDS_ON_COLOR,
+ &stop_deps);
+ if (val)
+ {
+ rgba = *_gtk_css_rgba_value_get_rgba (val);
+ *dependencies = _gtk_css_dependencies_union (*dependencies, stop_deps);
+ _gtk_css_value_unref (val);
+ }
+ else
+ {
+ rgba.red = rgba.green = rgba.blue = rgba.alpha = 0.0;
+ }
+
+ cairo_pattern_add_color_stop_rgba (pattern, stop->offset,
+ rgba.red, rgba.green,
+ rgba.blue, rgba.alpha);
+ }
+
+ return pattern;
+}
+
+static void
+append_number (GString *str,
+ double d,
+ const char *zero,
+ const char *half,
+ const char *one)
+{
+ if (zero && d == 0.0)
+ g_string_append (str, zero);
+ else if (half && d == 0.5)
+ g_string_append (str, half);
+ else if (one && d == 1.0)
+ g_string_append (str, one);
+ else
+ {
+ char buf[G_ASCII_DTOSTR_BUF_SIZE];
+
+ g_ascii_dtostr (buf, sizeof (buf), d);
+ g_string_append (str, buf);
+ }
+}
+
+/**
+ * gtk_gradient_to_string:
+ * @gradient: the gradient to print
+ *
+ * Creates a string representation for @gradient that is suitable
+ * for using in GTK CSS files.
+ *
+ * Returns: A string representation for @gradient
+ *
+ * Deprecated: 3.8: #GtkGradient is deprecated.
+ **/
+char *
+gtk_gradient_to_string (GtkGradient *gradient)
+{
+ GString *str;
+ guint i;
+
+ g_return_val_if_fail (gradient != NULL, NULL);
+
+ str = g_string_new ("-gtk-gradient (");
+
+ if (gradient->radius0 == 0 && gradient->radius1 == 0)
+ {
+ g_string_append (str, "linear, ");
+ append_number (str, gradient->x0, "left", "center", "right");
+ g_string_append_c (str, ' ');
+ append_number (str, gradient->y0, "top", "center", "bottom");
+ g_string_append (str, ", ");
+ append_number (str, gradient->x1, "left", "center", "right");
+ g_string_append_c (str, ' ');
+ append_number (str, gradient->y1, "top", "center", "bottom");
+ }
+ else
+ {
+ g_string_append (str, "radial, ");
+ append_number (str, gradient->x0, "left", "center", "right");
+ g_string_append_c (str, ' ');
+ append_number (str, gradient->y0, "top", "center", "bottom");
+ g_string_append (str, ", ");
+ append_number (str, gradient->radius0, NULL, NULL, NULL);
+ g_string_append (str, ", ");
+ append_number (str, gradient->x1, "left", "center", "right");
+ g_string_append_c (str, ' ');
+ append_number (str, gradient->y1, "top", "center", "bottom");
+ g_string_append (str, ", ");
+ append_number (str, gradient->radius1, NULL, NULL, NULL);
+ }
+
+ for (i = 0; i < gradient->stops->len; i++)
+ {
+ ColorStop *stop;
+ char *s;
+
+ stop = &g_array_index (gradient->stops, ColorStop, i);
+
+ g_string_append (str, ", ");
+
+ if (stop->offset == 0.0)
+ g_string_append (str, "from (");
+ else if (stop->offset == 1.0)
+ g_string_append (str, "to (");
+ else
+ {
+ g_string_append (str, "color-stop (");
+ append_number (str, stop->offset, NULL, NULL, NULL);
+ g_string_append (str, ", ");
+ }
+
+ s = gtk_symbolic_color_to_string (stop->color);
+ g_string_append (str, s);
+ g_free (s);
+
+ g_string_append (str, ")");
+ }
+
+ g_string_append (str, ")");
+
+ return g_string_free (str, FALSE);
+}
+
+static GtkGradient *
+gtk_gradient_fade (GtkGradient *gradient,
+ double opacity)
+{
+ GtkGradient *faded;
+ guint i;
+
+ faded = g_slice_new (GtkGradient);
+ faded->stops = g_array_new (FALSE, FALSE, sizeof (ColorStop));
+
+ faded->x0 = gradient->x0;
+ faded->y0 = gradient->y0;
+ faded->x1 = gradient->x1;
+ faded->y1 = gradient->y1;
+ faded->radius0 = gradient->radius0;
+ faded->radius1 = gradient->radius1;
+
+ faded->ref_count = 1;
+
+ for (i = 0; i < gradient->stops->len; i++)
+ {
+ GtkSymbolicColor *color;
+ ColorStop *stop;
+
+ stop = &g_array_index (gradient->stops, ColorStop, i);
+ color = gtk_symbolic_color_new_alpha (stop->color, opacity);
+ gtk_gradient_add_color_stop (faded, stop->offset, color);
+ gtk_symbolic_color_unref (color);
+ }
+
+ return faded;
+}
+
+GtkGradient *
+_gtk_gradient_transition (GtkGradient *start,
+ GtkGradient *end,
+ guint property_id,
+ double progress)
+{
+ GtkGradient *gradient;
+ guint i;
+
+ g_return_val_if_fail (start != NULL, NULL);
+
+ if (end == NULL)
+ return gtk_gradient_fade (start, 1.0 - CLAMP (progress, 0.0, 1.0));
+
+ if (start->stops->len != end->stops->len)
+ return NULL;
+
+ /* check both are radial/linear */
+ if ((start->radius0 == 0 && start->radius1 == 0) != (end->radius0 == 0 && end->radius1 == 0))
+ return NULL;
+
+ gradient = g_slice_new (GtkGradient);
+ gradient->stops = g_array_new (FALSE, FALSE, sizeof (ColorStop));
+
+ gradient->x0 = (1 - progress) * start->x0 + progress * end->x0;
+ gradient->y0 = (1 - progress) * start->y0 + progress * end->y0;
+ gradient->x1 = (1 - progress) * start->x1 + progress * end->x1;
+ gradient->y1 = (1 - progress) * start->y1 + progress * end->y1;
+ gradient->radius0 = (1 - progress) * start->radius0 + progress * end->radius0;
+ gradient->radius1 = (1 - progress) * start->radius1 + progress * end->radius1;
+
+ gradient->ref_count = 1;
+
+ for (i = 0; i < start->stops->len; i++)
+ {
+ ColorStop *start_stop, *end_stop;
+ GtkSymbolicColor *color;
+ double offset;
+
+ start_stop = &g_array_index (start->stops, ColorStop, i);
+ end_stop = &g_array_index (end->stops, ColorStop, i);
+
+ offset = (1 - progress) * start_stop->offset + progress * end_stop->offset;
+ color = gtk_symbolic_color_new_mix (start_stop->color,
+ end_stop->color,
+ progress);
+ gtk_gradient_add_color_stop (gradient, offset, color);
+ gtk_symbolic_color_unref (color);
+ }
+
+ return gradient;
+}
diff --git a/gtk/deprecated/gtkgradient.h b/gtk/deprecated/gtkgradient.h
new file mode 100644
index 0000000000..767461f4e4
--- /dev/null
+++ b/gtk/deprecated/gtkgradient.h
@@ -0,0 +1,74 @@
+/* GTK - The GIMP Toolkit
+ * Copyright (C) 2010 Carlos Garnacho <carlosg@gnome.org>
+ *
+ * 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/>.
+ */
+
+#if !defined (__GTK_H_INSIDE__) && !defined (GTK_COMPILATION)
+#error "Only <gtk/gtk.h> can be included directly."
+#endif
+
+#ifndef __GTK_GRADIENT_H__
+#define __GTK_GRADIENT_H__
+
+#include <gdk/gdk.h>
+#include <gtk/gtkstylecontext.h>
+#include <gtk/gtkstyleproperties.h>
+#include <gtk/deprecated/gtksymboliccolor.h>
+
+G_BEGIN_DECLS
+
+#define GTK_TYPE_GRADIENT (gtk_gradient_get_type ())
+
+GType gtk_gradient_get_type (void) G_GNUC_CONST;
+
+GDK_DEPRECATED_IN_3_8
+GtkGradient * gtk_gradient_new_linear (gdouble x0,
+ gdouble y0,
+ gdouble x1,
+ gdouble y1);
+GDK_DEPRECATED_IN_3_8
+GtkGradient * gtk_gradient_new_radial (gdouble x0,
+ gdouble y0,
+ gdouble radius0,
+ gdouble x1,
+ gdouble y1,
+ gdouble radius1);
+
+GDK_DEPRECATED_IN_3_8
+void gtk_gradient_add_color_stop (GtkGradient *gradient,
+ gdouble offset,
+ GtkSymbolicColor *color);
+
+GDK_DEPRECATED_IN_3_8
+GtkGradient * gtk_gradient_ref (GtkGradient *gradient);
+GDK_DEPRECATED_IN_3_8
+void gtk_gradient_unref (GtkGradient *gradient);
+
+GDK_DEPRECATED_IN_3_8
+gboolean gtk_gradient_resolve (GtkGradient *gradient,
+ GtkStyleProperties *props,
+ cairo_pattern_t **resolved_gradient);
+GDK_DEPRECATED_IN_3_8
+cairo_pattern_t *
+ gtk_gradient_resolve_for_context
+ (GtkGradient *gradient,
+ GtkStyleContext *context);
+
+GDK_DEPRECATED_IN_3_8
+char * gtk_gradient_to_string (GtkGradient *gradient);
+
+G_END_DECLS
+
+#endif /* __GTK_GRADIENT_H__ */
diff --git a/gtk/deprecated/gtkgradientprivate.h b/gtk/deprecated/gtkgradientprivate.h
new file mode 100644
index 0000000000..9cd37f2e71
--- /dev/null
+++ b/gtk/deprecated/gtkgradientprivate.h
@@ -0,0 +1,39 @@
+/* GTK - The GIMP Toolkit
+ * Copyright (C) 2012 Benjamin Otte <otte@gnome.org>
+ *
+ * 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/>.
+ */
+
+#ifndef __GTK_GRADIENT_PRIVATE_H__
+#define __GTK_GRADIENT_PRIVATE_H__
+
+#include "gtkgradient.h"
+#include "gtkcsstypesprivate.h"
+
+G_BEGIN_DECLS
+
+cairo_pattern_t * _gtk_gradient_resolve_full (GtkGradient *gradient,
+ GtkStyleProviderPrivate *provider,
+ GtkCssComputedValues *values,
+ GtkCssComputedValues *parent_values,
+ GtkCssDependencies *dependencies);
+
+GtkGradient * _gtk_gradient_transition (GtkGradient *start,
+ GtkGradient *end,
+ guint property_id,
+ double progress);
+
+G_END_DECLS
+
+#endif /* __GTK_STYLE_PROPERTIES_PRIVATE_H__ */
diff --git a/gtk/deprecated/gtksymboliccolor.c b/gtk/deprecated/gtksymboliccolor.c
new file mode 100644
index 0000000000..db85a3b1b6
--- /dev/null
+++ b/gtk/deprecated/gtksymboliccolor.c
@@ -0,0 +1,359 @@
+/* GTK - The GIMP Toolkit
+ * Copyright (C) 2010 Carlos Garnacho <carlosg@gnome.org>
+ *
+ * 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/>.
+ */
+
+#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 "gtkstyleproperties.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
+ * <link linkend="gtkcssprovider-symbolic-colors">color expression</link>.
+ * 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
+ * @props: (allow-none): #GtkStyleProperties to use when resolving
+ * named colors, or %NULL
+ * @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. Generally,
+ * if @color can't be resolved, it is due to it being defined on
+ * top of a named color that doesn't exist in @props.
+ *
+ * When @props is %NULL, resolving of named colors will fail, so if
+ * your @color is or references such a color, this function will
+ * return %FALSE.
+ *
+ * Returns: %TRUE if the color has been resolved
+ *
+ * Since: 3.0
+ *
+ * Deprecated: 3.8: #GtkSymbolicColor is deprecated.
+ **/
+gboolean
+gtk_symbolic_color_resolve (GtkSymbolicColor *color,
+ GtkStyleProperties *props,
+ 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);
+ g_return_val_if_fail (props == NULL || GTK_IS_STYLE_PROPERTIES (props), FALSE);
+
+ current = _gtk_css_rgba_value_new_from_rgba (&pink);
+ v = _gtk_css_color_value_resolve (color->value,
+ GTK_STYLE_PROVIDER_PRIVATE (props),
+ current,
+ 0,
+ 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
new file mode 100644
index 0000000000..937f93562f
--- /dev/null
+++ b/gtk/deprecated/gtksymboliccolor.h
@@ -0,0 +1,67 @@
+/* GTK - The GIMP Toolkit
+ * Copyright (C) 2010 Carlos Garnacho <carlosg@gnome.org>
+ *
+ * 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/>.
+ */
+
+#if !defined (__GTK_H_INSIDE__) && !defined (GTK_COMPILATION)
+#error "Only <gtk/gtk.h> can be included directly."
+#endif
+
+#ifndef __GTK_SYMBOLIC_COLOR_H__
+#define __GTK_SYMBOLIC_COLOR_H__
+
+#include <gdk/gdk.h>
+#include <gtk/gtkstyleproperties.h>
+
+G_BEGIN_DECLS
+
+#define GTK_TYPE_SYMBOLIC_COLOR (gtk_symbolic_color_get_type ())
+
+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,
+ GtkStyleProperties *props,
+ GdkRGBA *resolved_color);
+
+G_END_DECLS
+
+#endif /* __GTK_SYMBOLIC_COLOR_H__ */
diff --git a/gtk/deprecated/gtksymboliccolorprivate.h b/gtk/deprecated/gtksymboliccolorprivate.h
new file mode 100644
index 0000000000..abbee19a89
--- /dev/null
+++ b/gtk/deprecated/gtksymboliccolorprivate.h
@@ -0,0 +1,33 @@
+/* GTK - The GIMP Toolkit
+ * Copyright (C) 2011 Benjamin Otte <otte@gnome.org>
+ *
+ * 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/>.
+ */
+
+#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__ */