[gtk+/wip/cssvalue: 130/165] symboliccolor: Treat it as a CssValue
- From: Benjamin Otte <otte src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+/wip/cssvalue: 130/165] symboliccolor: Treat it as a CssValue
- Date: Fri, 13 Apr 2012 23:13:42 +0000 (UTC)
commit c1df08b7ef67a7b9ddc0d24c8718dd2474fdd0be
Author: Benjamin Otte <otte redhat com>
Date: Sat Apr 7 06:18:03 2012 +0200
symboliccolor: Treat it as a CssValue
.. now that it is one.
gtk/gtkcssimagegradient.c | 2 +-
gtk/gtkcssimagelinear.c | 10 ++++------
gtk/gtkcssprovider.c | 6 +++---
gtk/gtkcssrgbavalue.c | 5 ++---
gtk/gtkcssrgbavalueprivate.h | 2 +-
gtk/gtkcssshadowvalue.c | 11 ++++-------
gtk/gtkcssshorthandpropertyimpl.c | 30 ++++++++----------------------
gtk/gtkcssstylefuncs.c | 14 ++++++--------
gtk/gtkcssstylepropertyimpl.c | 22 ++++++++--------------
gtk/gtkcssvalueprivate.h | 2 --
gtk/gtkstylecontext.c | 4 ++--
gtk/gtkstylecontextprivate.h | 2 +-
gtk/gtksymboliccolor.c | 20 ++++++++++++++------
gtk/gtksymboliccolorprivate.h | 15 ++++++++++++++-
14 files changed, 68 insertions(+), 77 deletions(-)
---
diff --git a/gtk/gtkcssimagegradient.c b/gtk/gtkcssimagegradient.c
index 288ca0e..df350b3 100644
--- a/gtk/gtkcssimagegradient.c
+++ b/gtk/gtkcssimagegradient.c
@@ -288,7 +288,7 @@ _gtk_gradient_parse (GtkCssParser *parser)
return NULL;
}
- color = _gtk_css_parser_read_symbolic_color (parser);
+ color = _gtk_symbolic_color_new_take_value (_gtk_css_symbolic_value_new (parser));
if (color == NULL)
{
gtk_gradient_unref (gradient);
diff --git a/gtk/gtkcssimagelinear.c b/gtk/gtkcssimagelinear.c
index 6cc88e4..71554d9 100644
--- a/gtk/gtkcssimagelinear.c
+++ b/gtk/gtkcssimagelinear.c
@@ -315,10 +315,9 @@ gtk_css_image_linear_parse (GtkCssImage *image,
do {
GtkCssImageLinearColorStop stop;
- GtkSymbolicColor *symbolic;
- symbolic = _gtk_css_parser_read_symbolic_color (parser);
- if (symbolic == NULL)
+ stop.color = _gtk_css_symbolic_value_new (parser);
+ if (stop.color == NULL)
return FALSE;
if (_gtk_css_parser_has_number (parser))
@@ -328,7 +327,7 @@ gtk_css_image_linear_parse (GtkCssImage *image,
| GTK_CSS_PARSE_LENGTH);
if (stop.offset == NULL)
{
- gtk_symbolic_color_unref (symbolic);
+ _gtk_css_value_unref (stop.color);
return FALSE;
}
}
@@ -337,7 +336,6 @@ gtk_css_image_linear_parse (GtkCssImage *image,
stop.offset = NULL;
}
- stop.color = _gtk_css_value_new_take_symbolic_color (symbolic);
g_array_append_val (linear->stops, stop);
} while (_gtk_css_parser_try (parser, ",", TRUE));
@@ -426,7 +424,7 @@ gtk_css_image_linear_compute (GtkCssImage *image,
copy->angle = _gtk_css_number_value_compute (linear->angle, context);
- fallback = _gtk_css_value_new_take_symbolic_color (gtk_symbolic_color_new_literal (&transparent));
+ fallback = _gtk_css_symbolic_value_new_take_symbolic_color (gtk_symbolic_color_new_literal (&transparent));
g_array_set_size (copy->stops, linear->stops->len);
for (i = 0; i < linear->stops->len; i++)
{
diff --git a/gtk/gtkcssprovider.c b/gtk/gtkcssprovider.c
index 0136414..d7445b8 100644
--- a/gtk/gtkcssprovider.c
+++ b/gtk/gtkcssprovider.c
@@ -1942,7 +1942,7 @@ parse_import (GtkCssScanner *scanner)
static gboolean
parse_color_definition (GtkCssScanner *scanner)
{
- GtkSymbolicColor *symbolic;
+ GtkCssValue *symbolic;
char *name;
gtk_css_scanner_push_section (scanner, GTK_CSS_SECTION_COLOR_DEFINITION);
@@ -1966,7 +1966,7 @@ parse_color_definition (GtkCssScanner *scanner)
return TRUE;
}
- symbolic = _gtk_css_parser_read_symbolic_color (scanner->parser);
+ symbolic = _gtk_css_symbolic_value_new (scanner->parser);
if (symbolic == NULL)
{
g_free (name);
@@ -1978,7 +1978,7 @@ parse_color_definition (GtkCssScanner *scanner)
if (!_gtk_css_parser_try (scanner->parser, ";", TRUE))
{
g_free (name);
- gtk_symbolic_color_unref (symbolic);
+ _gtk_css_value_unref (symbolic);
gtk_css_provider_error_literal (scanner->provider,
scanner,
GTK_CSS_PROVIDER_ERROR,
diff --git a/gtk/gtkcssrgbavalue.c b/gtk/gtkcssrgbavalue.c
index 7ae1f18..0bae4de 100644
--- a/gtk/gtkcssrgbavalue.c
+++ b/gtk/gtkcssrgbavalue.c
@@ -95,15 +95,14 @@ _gtk_css_rgba_value_get_rgba (const GtkCssValue *rgba)
}
GtkCssValue *
-_gtk_css_rgba_value_compute_from_symbolic (GtkCssValue *rgba,
+_gtk_css_rgba_value_compute_from_symbolic (GtkCssValue *symbolic,
GtkCssValue *fallback,
GtkStyleContext *context,
gboolean for_color_property)
{
- GtkSymbolicColor *symbolic;
GtkCssValue *resolved, *current;
- g_return_val_if_fail (rgba != NULL, NULL);
+ g_return_val_if_fail (symbolic != NULL, NULL);
/* The computed value of the âcurrentColorâ keyword is the computed
* value of the âcolorâ property. If the âcurrentColorâ keyword is
diff --git a/gtk/gtkcssrgbavalueprivate.h b/gtk/gtkcssrgbavalueprivate.h
index d35846d..539473f 100644
--- a/gtk/gtkcssrgbavalueprivate.h
+++ b/gtk/gtkcssrgbavalueprivate.h
@@ -29,7 +29,7 @@ G_BEGIN_DECLS
GtkCssValue * _gtk_css_rgba_value_new_from_rgba (const GdkRGBA *rgba);
GtkCssValue * _gtk_css_rgba_value_compute_from_symbolic
- (GtkCssValue *rgba,
+ (GtkCssValue *symbolic,
GtkCssValue *fallback,
GtkStyleContext *context,
gboolean for_color_property);
diff --git a/gtk/gtkcssshadowvalue.c b/gtk/gtkcssshadowvalue.c
index 8efcbe4..2698525 100644
--- a/gtk/gtkcssshadowvalue.c
+++ b/gtk/gtkcssshadowvalue.c
@@ -234,13 +234,10 @@ _gtk_css_shadow_value_parse (GtkCssParser *parser)
}
else if (values[COLOR] == NULL)
{
- GtkSymbolicColor *symbolic;
+ values[COLOR] = _gtk_css_symbolic_value_new (parser);
- symbolic = _gtk_css_parser_read_symbolic_color (parser);
- if (symbolic == NULL)
+ if (values[COLOR] == NULL)
goto fail;
-
- values[COLOR] = _gtk_css_value_new_take_symbolic_color (symbolic);
}
else
{
@@ -253,7 +250,7 @@ _gtk_css_shadow_value_parse (GtkCssParser *parser)
while (values[HOFFSET] == NULL || !value_is_done_parsing (parser));
if (values[COLOR] == NULL)
- values[COLOR] = _gtk_css_value_new_take_symbolic_color (
+ values[COLOR] = _gtk_css_symbolic_value_new_take_symbolic_color (
gtk_symbolic_color_ref (
_gtk_symbolic_color_get_current_color ()));
@@ -278,7 +275,7 @@ _gtk_css_shadow_value_compute (GtkCssValue *shadow,
GtkCssValue *color;
color = _gtk_css_rgba_value_compute_from_symbolic (shadow->color,
- _gtk_css_value_new_take_symbolic_color (
+ _gtk_css_symbolic_value_new_take_symbolic_color (
gtk_symbolic_color_ref (
_gtk_symbolic_color_get_current_color ())),
context,
diff --git a/gtk/gtkcssshorthandpropertyimpl.c b/gtk/gtkcssshorthandpropertyimpl.c
index 32c27ab..7150c75 100644
--- a/gtk/gtkcssshorthandpropertyimpl.c
+++ b/gtk/gtkcssshorthandpropertyimpl.c
@@ -216,17 +216,14 @@ parse_border_color (GtkCssShorthandProperty *shorthand,
GtkCssParser *parser,
GFile *base)
{
- GtkSymbolicColor *symbolic;
guint i;
for (i = 0; i < 4; i++)
{
- symbolic = _gtk_css_parser_read_symbolic_color (parser);
- if (symbolic == NULL)
+ values[i] = _gtk_css_symbolic_value_new (parser);
+ if (values[i] == NULL)
return FALSE;
- values[i] = _gtk_css_value_new_take_symbolic_color (symbolic);
-
if (value_is_done_parsing (parser))
break;
}
@@ -358,13 +355,9 @@ parse_border_side (GtkCssShorthandProperty *shorthand,
}
else if (values[2] == NULL)
{
- GtkSymbolicColor *symbolic;
-
- symbolic = _gtk_css_parser_read_symbolic_color (parser);
- if (symbolic == NULL)
+ values[2] = _gtk_css_symbolic_value_new (parser);
+ if (values[2] == NULL)
return FALSE;
-
- values[2] = _gtk_css_value_new_take_symbolic_color (symbolic);
}
}
while (!value_is_done_parsing (parser));
@@ -402,13 +395,10 @@ parse_border (GtkCssShorthandProperty *shorthand,
}
else if (!G_IS_VALUE (&values[8]))
{
- GtkSymbolicColor *symbolic;
-
- symbolic = _gtk_css_parser_read_symbolic_color (parser);
- if (symbolic == NULL)
+ values[8] = _gtk_css_symbolic_value_new (parser);
+ if (values[8] == NULL)
return FALSE;
- values[8] = _gtk_css_value_new_take_symbolic_color (symbolic);
values[9] = _gtk_css_value_ref (values[8]);
values[10] = _gtk_css_value_ref (values[8]);
values[11] = _gtk_css_value_ref (values[8]);
@@ -516,13 +506,9 @@ parse_background (GtkCssShorthandProperty *shorthand,
}
else if (values[4] == NULL)
{
- GtkSymbolicColor *symbolic;
-
- symbolic = _gtk_css_parser_read_symbolic_color (parser);
- if (symbolic == NULL)
+ values[4] = _gtk_css_symbolic_value_new (parser);
+ if (values[4] == NULL)
return FALSE;
-
- values[4] = _gtk_css_value_new_take_symbolic_color (symbolic);
}
else
{
diff --git a/gtk/gtkcssstylefuncs.c b/gtk/gtkcssstylefuncs.c
index b1a097e..dcdd25d 100644
--- a/gtk/gtkcssstylefuncs.c
+++ b/gtk/gtkcssstylefuncs.c
@@ -169,7 +169,7 @@ rgba_value_parse (GtkCssParser *parser,
GtkSymbolicColor *symbolic;
GdkRGBA rgba;
- symbolic = _gtk_css_parser_read_symbolic_color (parser);
+ symbolic = _gtk_symbolic_color_new_take_value (_gtk_css_symbolic_value_new (parser));
if (symbolic == NULL)
return FALSE;
@@ -212,12 +212,10 @@ rgba_value_compute (GtkStyleContext *context,
if (_gtk_css_value_holds (specified, GTK_TYPE_SYMBOLIC_COLOR))
{
- GtkSymbolicColor *symbolic = _gtk_css_value_get_symbolic_color (specified);
+ GtkSymbolicColor *symbolic = _gtk_css_value_get_boxed (specified);
GdkRGBA rgba;
- if (symbolic == _gtk_symbolic_color_get_current_color ())
- rgba = *_gtk_css_rgba_value_get_rgba (_gtk_style_context_peek_property (context, GTK_CSS_PROPERTY_COLOR));
- else if (!gtk_symbolic_color_resolve (symbolic, NULL, &rgba))
+ if (!_gtk_style_context_resolve_color (context, symbolic, &rgba))
rgba = white;
return _gtk_css_value_new_from_boxed (GDK_TYPE_RGBA, &rgba);
@@ -234,7 +232,7 @@ color_value_parse (GtkCssParser *parser,
GtkSymbolicColor *symbolic;
GdkRGBA rgba;
- symbolic = _gtk_css_parser_read_symbolic_color (parser);
+ symbolic = _gtk_symbolic_color_new_take_value (_gtk_css_symbolic_value_new (parser));
if (symbolic == NULL)
return FALSE;
@@ -284,7 +282,7 @@ color_value_compute (GtkStyleContext *context,
if (_gtk_css_value_holds (specified, GTK_TYPE_SYMBOLIC_COLOR))
{
if (_gtk_style_context_resolve_color (context,
- _gtk_css_value_get_symbolic_color (specified),
+ _gtk_css_value_get_boxed (specified),
&rgba))
{
color.red = rgba.red * 65535. + 0.5;
@@ -305,7 +303,7 @@ symbolic_color_value_parse (GtkCssParser *parser,
{
GtkSymbolicColor *symbolic;
- symbolic = _gtk_css_parser_read_symbolic_color (parser);
+ symbolic = _gtk_symbolic_color_new_take_value (_gtk_css_symbolic_value_new (parser));
if (symbolic == NULL)
return FALSE;
diff --git a/gtk/gtkcssstylepropertyimpl.c b/gtk/gtkcssstylepropertyimpl.c
index f51e321..6342eff 100644
--- a/gtk/gtkcssstylepropertyimpl.c
+++ b/gtk/gtkcssstylepropertyimpl.c
@@ -181,13 +181,7 @@ color_parse (GtkCssStyleProperty *property,
GtkCssParser *parser,
GFile *base)
{
- GtkSymbolicColor *symbolic;
-
- symbolic = _gtk_css_parser_read_symbolic_color (parser);
- if (symbolic == NULL)
- return NULL;
-
- return _gtk_css_value_new_take_symbolic_color (symbolic);
+ return _gtk_css_symbolic_value_new (parser);
}
static GtkCssValue *
@@ -938,7 +932,7 @@ _gtk_css_style_property_init_properties (void)
color_query,
color_assign,
NULL,
- _gtk_css_value_new_take_symbolic_color (
+ _gtk_css_symbolic_value_new_take_symbolic_color (
gtk_symbolic_color_new_rgba (1, 1, 1, 1)));
gtk_css_style_property_register ("font-size",
GTK_CSS_PROPERTY_FONT_SIZE,
@@ -965,7 +959,7 @@ _gtk_css_style_property_init_properties (void)
color_query,
color_assign,
NULL,
- _gtk_css_value_new_take_symbolic_color (
+ _gtk_css_symbolic_value_new_take_symbolic_color (
gtk_symbolic_color_new_rgba (0, 0, 0, 0)));
gtk_css_style_property_register ("font-family",
@@ -1368,7 +1362,7 @@ _gtk_css_style_property_init_properties (void)
color_query,
color_assign,
NULL,
- _gtk_css_value_new_take_symbolic_color (
+ _gtk_css_symbolic_value_new_take_symbolic_color (
gtk_symbolic_color_ref (
_gtk_symbolic_color_get_current_color ())));
gtk_css_style_property_register ("border-right-color",
@@ -1381,7 +1375,7 @@ _gtk_css_style_property_init_properties (void)
color_query,
color_assign,
NULL,
- _gtk_css_value_new_take_symbolic_color (
+ _gtk_css_symbolic_value_new_take_symbolic_color (
gtk_symbolic_color_ref (
_gtk_symbolic_color_get_current_color ())));
gtk_css_style_property_register ("border-bottom-color",
@@ -1394,7 +1388,7 @@ _gtk_css_style_property_init_properties (void)
color_query,
color_assign,
NULL,
- _gtk_css_value_new_take_symbolic_color (
+ _gtk_css_symbolic_value_new_take_symbolic_color (
gtk_symbolic_color_ref (
_gtk_symbolic_color_get_current_color ())));
gtk_css_style_property_register ("border-left-color",
@@ -1407,7 +1401,7 @@ _gtk_css_style_property_init_properties (void)
color_query,
color_assign,
NULL,
- _gtk_css_value_new_take_symbolic_color (
+ _gtk_css_symbolic_value_new_take_symbolic_color (
gtk_symbolic_color_ref (
_gtk_symbolic_color_get_current_color ())));
gtk_css_style_property_register ("outline-color",
@@ -1420,7 +1414,7 @@ _gtk_css_style_property_init_properties (void)
color_query,
color_assign,
NULL,
- _gtk_css_value_new_take_symbolic_color (
+ _gtk_css_symbolic_value_new_take_symbolic_color (
gtk_symbolic_color_ref (
_gtk_symbolic_color_get_current_color ())));
diff --git a/gtk/gtkcssvalueprivate.h b/gtk/gtkcssvalueprivate.h
index 66453cc..1bcfe73 100644
--- a/gtk/gtkcssvalueprivate.h
+++ b/gtk/gtkcssvalueprivate.h
@@ -87,7 +87,6 @@ GtkCssValue *_gtk_css_value_new_take_strv (char
GtkCssValue *_gtk_css_value_new_from_boxed (GType type,
gpointer boxed);
GtkCssValue *_gtk_css_value_new_from_color (const GdkColor *v);
-GtkCssValue *_gtk_css_value_new_take_symbolic_color (GtkSymbolicColor *v);
GtkCssValue *_gtk_css_value_new_take_pattern (cairo_pattern_t *v);
GtkCssValue *_gtk_css_value_new_take_binding_sets (GPtrArray *array);
void _gtk_css_value_init_gvalue (const GtkCssValue *value,
@@ -99,7 +98,6 @@ gpointer _gtk_css_value_dup_object (const
gpointer _gtk_css_value_get_object (const GtkCssValue *value);
gpointer _gtk_css_value_get_boxed (const GtkCssValue *value);
const char ** _gtk_css_value_get_strv (const GtkCssValue *value);
-GtkSymbolicColor *_gtk_css_value_get_symbolic_color (const GtkCssValue *value);
GtkGradient *_gtk_css_value_get_gradient (const GtkCssValue *value);
G_END_DECLS
diff --git a/gtk/gtkstylecontext.c b/gtk/gtkstylecontext.c
index d3f3df7..862fbae 100644
--- a/gtk/gtkstylecontext.c
+++ b/gtk/gtkstylecontext.c
@@ -2525,13 +2525,13 @@ gtk_style_context_color_lookup_func (gpointer contextp,
GtkCssValue *
_gtk_style_context_resolve_color_value (GtkStyleContext *context,
GtkCssValue *current,
- GtkSymbolicColor *color)
+ GtkCssValue *color)
{
g_return_val_if_fail (GTK_IS_STYLE_CONTEXT (context), FALSE);
g_return_val_if_fail (current != NULL, FALSE);
g_return_val_if_fail (color != NULL, FALSE);
- return _gtk_symbolic_color_resolve_full (color,
+ return _gtk_symbolic_color_resolve_full ((GtkSymbolicColor *) color,
current,
gtk_style_context_color_lookup_func,
context);
diff --git a/gtk/gtkstylecontextprivate.h b/gtk/gtkstylecontextprivate.h
index c0a2881..08f21b3 100644
--- a/gtk/gtkstylecontextprivate.h
+++ b/gtk/gtkstylecontextprivate.h
@@ -46,7 +46,7 @@ gboolean _gtk_style_context_resolve_color (GtkStyleContext *
GdkRGBA *result);
GtkCssValue * _gtk_style_context_resolve_color_value (GtkStyleContext *context,
GtkCssValue *current,
- GtkSymbolicColor *color);
+ GtkCssValue *color);
void _gtk_style_context_get_cursor_color (GtkStyleContext *context,
GdkRGBA *primary_color,
GdkRGBA *secondary_color);
diff --git a/gtk/gtksymboliccolor.c b/gtk/gtksymboliccolor.c
index a660b88..1c346f8 100644
--- a/gtk/gtksymboliccolor.c
+++ b/gtk/gtksymboliccolor.c
@@ -872,6 +872,8 @@ typedef enum {
COLOR_WIN32
} ColorParseType;
+static GtkSymbolicColor * gtk_css_parser_read_symbolic_color (GtkCssParser *parser);
+
static GtkSymbolicColor *
gtk_css_parser_read_symbolic_color_function (GtkCssParser *parser,
ColorParseType color)
@@ -946,7 +948,7 @@ gtk_css_parser_read_symbolic_color_function (GtkCssParser *parser,
}
else
{
- child1 = _gtk_css_parser_read_symbolic_color (parser);
+ child1 = gtk_css_parser_read_symbolic_color (parser);
if (child1 == NULL)
return NULL;
@@ -959,7 +961,7 @@ gtk_css_parser_read_symbolic_color_function (GtkCssParser *parser,
return NULL;
}
- child2 = _gtk_css_parser_read_symbolic_color (parser);
+ child2 = gtk_css_parser_read_symbolic_color (parser);
if (child2 == NULL)
{
gtk_symbolic_color_unref (child1);
@@ -1027,8 +1029,8 @@ gtk_css_parser_read_symbolic_color_function (GtkCssParser *parser,
return symbolic;
}
-GtkSymbolicColor *
-_gtk_css_parser_read_symbolic_color (GtkCssParser *parser)
+static GtkSymbolicColor *
+gtk_css_parser_read_symbolic_color (GtkCssParser *parser)
{
GtkSymbolicColor *symbolic;
GdkRGBA rgba;
@@ -1037,8 +1039,6 @@ _gtk_css_parser_read_symbolic_color (GtkCssParser *parser)
GTK_WIN32_THEME_SYMBOLIC_COLOR_NAME};
char *name;
- g_return_val_if_fail (parser != NULL, NULL);
-
if (_gtk_css_parser_try (parser, "currentColor", TRUE))
return gtk_symbolic_color_ref (_gtk_symbolic_color_get_current_color ());
@@ -1099,3 +1099,11 @@ _gtk_css_parser_read_symbolic_color (GtkCssParser *parser)
return NULL;
}
+GtkCssValue *
+_gtk_css_symbolic_value_new (GtkCssParser *parser)
+{
+ g_return_val_if_fail (parser != NULL, NULL);
+
+ return _gtk_css_symbolic_value_new_take_symbolic_color (gtk_css_parser_read_symbolic_color (parser));
+}
+
diff --git a/gtk/gtksymboliccolorprivate.h b/gtk/gtksymboliccolorprivate.h
index a5b425c..03b3b32 100644
--- a/gtk/gtksymboliccolorprivate.h
+++ b/gtk/gtksymboliccolorprivate.h
@@ -33,7 +33,20 @@ GtkCssValue * _gtk_symbolic_color_resolve_full (GtkSymbolicColor
GtkSymbolicColor * _gtk_symbolic_color_get_current_color (void);
-GtkSymbolicColor * _gtk_css_parser_read_symbolic_color (GtkCssParser *parser);
+GtkCssValue * _gtk_css_symbolic_value_new (GtkCssParser *parser);
+
+/* I made these inline functions instead of macros to gain type safety for the arguments passed in. */
+static inline GtkSymbolicColor *
+_gtk_symbolic_color_new_take_value (GtkCssValue *value)
+{
+ return (GtkSymbolicColor *) value;
+}
+
+static inline GtkCssValue *
+_gtk_css_symbolic_value_new_take_symbolic_color (GtkSymbolicColor *color)
+{
+ return (GtkCssValue *) color;
+}
G_END_DECLS
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]