Commit 08ac1504 authored by Benjamin Otte's avatar Benjamin Otte

symboliccolor: Implement using GtkCssValue

parent b8e58015
......@@ -136,12 +136,12 @@ gtk_css_value_color_get_fallback (guint property_id,
}
}
static GtkCssValue *
gtk_css_color_value_resolve_full (GtkCssValue *color,
GtkStyleProviderPrivate *provider,
GtkCssValue *current,
GtkCssDependencies current_deps,
GtkCssDependencies *dependencies)
GtkCssValue *
_gtk_css_color_value_resolve (GtkCssValue *color,
GtkStyleProviderPrivate *provider,
GtkCssValue *current,
GtkCssDependencies current_deps,
GtkCssDependencies *dependencies)
{
GtkCssDependencies unused;
GtkCssValue *value;
......@@ -168,7 +168,7 @@ gtk_css_color_value_resolve_full (GtkCssValue *color,
if (!symbolic)
return NULL;
value = _gtk_symbolic_color_resolve_full (symbolic, provider, current, current_deps, dependencies);
value = _gtk_css_color_value_resolve (_gtk_symbolic_color_get_css_value (symbolic), provider, current, current_deps, dependencies);
}
break;
......@@ -178,7 +178,7 @@ gtk_css_color_value_resolve_full (GtkCssValue *color,
GtkHSLA hsla;
GdkRGBA shade;
val = gtk_css_color_value_resolve_full (color->sym_col.shade.color, provider, current, current_deps, dependencies);
val = _gtk_css_color_value_resolve (color->sym_col.shade.color, provider, current, current_deps, dependencies);
if (val == NULL)
return NULL;
......@@ -205,7 +205,7 @@ gtk_css_color_value_resolve_full (GtkCssValue *color,
GtkCssValue *val;
GdkRGBA alpha;
val = gtk_css_color_value_resolve_full (color->sym_col.alpha.color, provider, current, current_deps, dependencies);
val = _gtk_css_color_value_resolve (color->sym_col.alpha.color, provider, current, current_deps, dependencies);
if (val == NULL)
return NULL;
......@@ -225,13 +225,13 @@ gtk_css_color_value_resolve_full (GtkCssValue *color,
GdkRGBA color1, color2, res;
GtkCssDependencies dep1, dep2;
val = gtk_css_color_value_resolve_full (color->sym_col.mix.color1, provider, current, current_deps, &dep1);
val = _gtk_css_color_value_resolve (color->sym_col.mix.color1, provider, current, current_deps, &dep1);
if (val == NULL)
return NULL;
color1 = *_gtk_css_rgba_value_get_rgba (val);
_gtk_css_value_unref (val);
val = gtk_css_color_value_resolve_full (color->sym_col.mix.color2, provider, current, current_deps, &dep2);
val = _gtk_css_color_value_resolve (color->sym_col.mix.color2, provider, current, current_deps, &dep2);
if (val == NULL)
return NULL;
color2 = *_gtk_css_rgba_value_get_rgba (val);
......@@ -329,11 +329,11 @@ gtk_css_value_color_compute (GtkCssValue *value,
current_deps = GTK_CSS_DEPENDS_ON_COLOR;
}
resolved = gtk_css_color_value_resolve_full (value,
provider,
current,
current_deps,
dependencies);
resolved = _gtk_css_color_value_resolve (value,
provider,
current,
current_deps,
dependencies);
if (resolved == NULL)
return gtk_css_value_color_get_fallback (property_id, provider, values, parent_values);
......
......@@ -43,6 +43,12 @@ GtkCssValue * _gtk_css_color_value_new_current_color (void);
GtkCssValue * _gtk_css_color_value_parse (GtkCssParser *parser);
GtkCssValue * _gtk_css_color_value_resolve (GtkCssValue *color,
GtkStyleProviderPrivate *provider,
GtkCssValue *current,
GtkCssDependencies current_deps,
GtkCssDependencies *dependencies);
G_END_DECLS
......
......@@ -27,6 +27,7 @@
#include <gdk-pixbuf/gdk-pixbuf.h>
#include <cairo-gobject.h>
#include "gtkcsscolorvalueprivate.h"
#include "gtkcssimagegradientprivate.h"
#include "gtkcssprovider.h"
#include "gtkcssrgbavalueprivate.h"
......@@ -225,11 +226,11 @@ rgba_value_compute (GtkStyleProviderPrivate *provider,
GValue new_value = G_VALUE_INIT;
GdkRGBA rgba;
val = _gtk_symbolic_color_resolve_full (symbolic,
provider,
_gtk_css_computed_values_get_value (values, GTK_CSS_PROPERTY_COLOR),
GTK_CSS_DEPENDS_ON_COLOR,
dependencies);
val = _gtk_css_color_value_resolve (_gtk_symbolic_color_get_css_value (symbolic),
provider,
_gtk_css_computed_values_get_value (values, GTK_CSS_PROPERTY_COLOR),
GTK_CSS_DEPENDS_ON_COLOR,
dependencies);
if (val != NULL)
{
rgba = *_gtk_css_rgba_value_get_rgba (val);
......@@ -310,11 +311,11 @@ color_value_compute (GtkStyleProviderPrivate *provider,
GValue new_value = G_VALUE_INIT;
GtkCssValue *val;
val = _gtk_symbolic_color_resolve_full ((GtkSymbolicColor *) g_value_get_boxed (value),
provider,
_gtk_css_computed_values_get_value (values, GTK_CSS_PROPERTY_COLOR),
GTK_CSS_DEPENDS_ON_COLOR,
dependencies);
val = _gtk_css_color_value_resolve (_gtk_symbolic_color_get_css_value (g_value_get_boxed (value)),
provider,
_gtk_css_computed_values_get_value (values, GTK_CSS_PROPERTY_COLOR),
GTK_CSS_DEPENDS_ON_COLOR,
dependencies);
if (val != NULL)
{
const GdkRGBA *rgba = _gtk_css_rgba_value_get_rgba (val);
......
......@@ -19,6 +19,7 @@
#include "gtkgradientprivate.h"
#include "gtkcsscolorvalueprivate.h"
#include "gtkcssrgbavalueprivate.h"
#include "gtkstylecontextprivate.h"
#include "gtkstyleproperties.h"
......@@ -318,11 +319,11 @@ _gtk_gradient_resolve_full (GtkGradient *gradient,
stop = &g_array_index (gradient->stops, ColorStop, i);
/* if color resolving fails, assume transparency */
val = _gtk_symbolic_color_resolve_full (stop->color,
provider,
_gtk_css_computed_values_get_value (values, GTK_CSS_PROPERTY_COLOR),
GTK_CSS_DEPENDS_ON_COLOR,
&stop_deps);
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);
......
......@@ -24,6 +24,7 @@
#include "gtkstylecontextprivate.h"
#include "gtkcontainerprivate.h"
#include "gtkcsscolorvalueprivate.h"
#include "gtkcssenginevalueprivate.h"
#include "gtkcssnumbervalueprivate.h"
#include "gtkcssrgbavalueprivate.h"
......@@ -2713,11 +2714,11 @@ _gtk_style_context_resolve_color (GtkStyleContext *context,
g_return_val_if_fail (color != NULL, FALSE);
g_return_val_if_fail (result != NULL, FALSE);
val = _gtk_symbolic_color_resolve_full (color,
GTK_STYLE_PROVIDER_PRIVATE (context->priv->cascade),
_gtk_style_context_peek_property (context, GTK_CSS_PROPERTY_COLOR),
GTK_CSS_DEPENDS_ON_COLOR,
dependencies);
val = _gtk_css_color_value_resolve (_gtk_symbolic_color_get_css_value (color),
GTK_STYLE_PROVIDER_PRIVATE (context->priv->cascade),
_gtk_style_context_peek_property (context, GTK_CSS_PROPERTY_COLOR),
GTK_CSS_DEPENDS_ON_COLOR,
dependencies);
if (val == NULL)
return FALSE;
......
This diff is collapsed.
......@@ -24,16 +24,10 @@
G_BEGIN_DECLS
GtkCssValue * _gtk_symbolic_color_resolve_full (GtkSymbolicColor *color,
GtkStyleProviderPrivate *provider,
GtkCssValue *current,
GtkCssDependencies current_deps,
GtkCssDependencies *dependencies);
GtkSymbolicColor * _gtk_symbolic_color_get_current_color (void);
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__ */
......@@ -23,8 +23,6 @@
#include "gtkwin32themeprivate.h"
#include <gtksymboliccolor.h>
#ifdef G_OS_WIN32
#include <cairo-win32.h>
......@@ -383,41 +381,6 @@ _gtk_win32_theme_int_parse (GtkCssParser *parser,
return -1;
}
GtkSymbolicColor *
_gtk_win32_theme_color_parse (GtkCssParser *parser)
{
GtkSymbolicColor *color;
char *class;
int id;
class = _gtk_css_parser_try_name (parser, TRUE);
if (class == NULL)
{
_gtk_css_parser_error (parser,
"Expected name as first argument to '-gtk-win32-color'");
return NULL;
}
if (! _gtk_css_parser_try (parser, ",", TRUE))
{
g_free (class);
_gtk_css_parser_error (parser,
"Expected ','");
return NULL;
}
if (!_gtk_css_parser_try_int (parser, &id))
{
g_free (class);
_gtk_css_parser_error (parser, "Expected a valid integer value");
return NULL;
}
color = gtk_symbolic_color_new_win32 (class, id);
g_free (class);
return color;
}
gboolean
_gtk_win32_theme_color_resolve (const char *theme_class,
gint id,
......
......@@ -50,7 +50,6 @@ cairo_surface_t * _gtk_win32_theme_part_create_surface (HTHEME theme,
int _gtk_win32_theme_int_parse (GtkCssParser *parser,
int *value);
GtkSymbolicColor *_gtk_win32_theme_color_parse (GtkCssParser *parser);
gboolean _gtk_win32_theme_color_resolve (const char *theme_class,
gint id,
GdkRGBA *color);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment