[gtk+/wip/cssvalue: 184/218] css: Move shadow parse/print/compute funcs
- From: Benjamin Otte <otte src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+/wip/cssvalue: 184/218] css: Move shadow parse/print/compute funcs
- Date: Fri, 30 Mar 2012 02:41:21 +0000 (UTC)
commit 19566895074e041dda60a362893910c68ab609ca
Author: Benjamin Otte <otte redhat com>
Date: Tue Mar 27 07:15:23 2012 +0200
css: Move shadow parse/print/compute funcs
They don't belong in the style funcs, as those are for custom
properties, and the shadow type is private.
gtk/gtkcssstylefuncs.c | 119 ------------------------------------
gtk/gtkcssstylepropertyimpl.c | 134 ++++++++++++++++++++++++++++++++++++++---
2 files changed, 125 insertions(+), 128 deletions(-)
---
diff --git a/gtk/gtkcssstylefuncs.c b/gtk/gtkcssstylefuncs.c
index f3b58e5..6a0bed7 100644
--- a/gtk/gtkcssstylefuncs.c
+++ b/gtk/gtkcssstylefuncs.c
@@ -890,121 +890,6 @@ pattern_value_compute (GtkStyleContext *context,
}
static gboolean
-shadow_value_parse (GtkCssParser *parser,
- GFile *base,
- GValue *value)
-{
- gboolean have_inset, have_color, have_lengths;
- gdouble hoffset, voffset, blur, spread;
- GtkSymbolicColor *color;
- GtkShadow *shadow;
- guint i;
-
- if (_gtk_css_parser_try (parser, "none", TRUE))
- return TRUE;
-
- shadow = _gtk_shadow_new ();
-
- do
- {
- have_inset = have_lengths = have_color = FALSE;
-
- for (i = 0; i < 3; i++)
- {
- if (!have_inset &&
- _gtk_css_parser_try (parser, "inset", TRUE))
- {
- have_inset = TRUE;
- continue;
- }
-
- if (!have_lengths &&
- _gtk_css_parser_try_double (parser, &hoffset))
- {
- have_lengths = TRUE;
-
- if (!_gtk_css_parser_try_double (parser, &voffset))
- {
- _gtk_css_parser_error (parser, "Horizontal and vertical offsets are required");
- _gtk_shadow_unref (shadow);
- return FALSE;
- }
-
- if (!_gtk_css_parser_try_double (parser, &blur))
- blur = 0;
-
- if (!_gtk_css_parser_try_double (parser, &spread))
- spread = 0;
-
- continue;
- }
-
- if (!have_color)
- {
- have_color = TRUE;
-
- /* XXX: the color is optional and UA-defined if it's missing,
- * but it doesn't really make sense for us...
- */
- color = _gtk_css_parser_read_symbolic_color (parser);
-
- if (color == NULL)
- {
- _gtk_shadow_unref (shadow);
- return FALSE;
- }
- }
- }
-
- if (!have_color || !have_lengths)
- {
- _gtk_css_parser_error (parser, "Must specify at least color and offsets");
- _gtk_shadow_unref (shadow);
- return FALSE;
- }
-
- _gtk_shadow_append (shadow,
- hoffset, voffset,
- blur, spread,
- have_inset, color);
-
- gtk_symbolic_color_unref (color);
-
- }
- while (_gtk_css_parser_try (parser, ",", TRUE));
-
- g_value_take_boxed (value, shadow);
- return TRUE;
-}
-
-static void
-shadow_value_print (const GValue *value,
- GString *string)
-{
- GtkShadow *shadow;
-
- shadow = g_value_get_boxed (value);
-
- if (shadow == NULL)
- g_string_append (string, "none");
- else
- _gtk_shadow_print (shadow, string);
-}
-
-static GtkCssValue *
-shadow_value_compute (GtkStyleContext *context,
- GtkCssValue *specified)
-{
- GtkShadow *shadow;
-
- shadow = _gtk_css_value_get_shadow (specified);
- if (shadow)
- shadow = _gtk_shadow_resolve (shadow, context);
-
- return _gtk_css_value_new_take_shadow (shadow);
-}
-
-static gboolean
border_image_repeat_value_parse (GtkCssParser *parser,
GFile *file,
GValue *value)
@@ -1228,10 +1113,6 @@ gtk_css_style_funcs_init (void)
border_image_repeat_value_parse,
border_image_repeat_value_print,
NULL);
- register_conversion_function (GTK_TYPE_SHADOW,
- shadow_value_parse,
- shadow_value_print,
- shadow_value_compute);
register_conversion_function (GTK_TYPE_CSS_NUMBER,
NULL,
css_number_print,
diff --git a/gtk/gtkcssstylepropertyimpl.c b/gtk/gtkcssstylepropertyimpl.c
index 314eef9..22388b3 100644
--- a/gtk/gtkcssstylepropertyimpl.c
+++ b/gtk/gtkcssstylepropertyimpl.c
@@ -397,6 +397,122 @@ bindings_value_print (GtkCssStyleProperty *property,
}
static GtkCssValue *
+shadow_value_parse (GtkCssStyleProperty *property,
+ GtkCssParser *parser,
+ GFile *base)
+{
+ gboolean have_inset, have_color, have_lengths;
+ gdouble hoffset, voffset, blur, spread;
+ GtkSymbolicColor *color;
+ GtkShadow *shadow;
+ guint i;
+
+ if (_gtk_css_parser_try (parser, "none", TRUE))
+ return _gtk_css_value_new_take_shadow (NULL);
+
+ shadow = _gtk_shadow_new ();
+
+ do
+ {
+ have_inset = have_lengths = have_color = FALSE;
+
+ for (i = 0; i < 3; i++)
+ {
+ if (!have_inset &&
+ _gtk_css_parser_try (parser, "inset", TRUE))
+ {
+ have_inset = TRUE;
+ continue;
+ }
+
+ if (!have_lengths &&
+ _gtk_css_parser_try_double (parser, &hoffset))
+ {
+ have_lengths = TRUE;
+
+ if (!_gtk_css_parser_try_double (parser, &voffset))
+ {
+ _gtk_css_parser_error (parser, "Horizontal and vertical offsets are required");
+ _gtk_shadow_unref (shadow);
+ return NULL;
+ }
+
+ if (!_gtk_css_parser_try_double (parser, &blur))
+ blur = 0;
+
+ if (!_gtk_css_parser_try_double (parser, &spread))
+ spread = 0;
+
+ continue;
+ }
+
+ if (!have_color)
+ {
+ have_color = TRUE;
+
+ /* XXX: the color is optional and UA-defined if it's missing,
+ * but it doesn't really make sense for us...
+ */
+ color = _gtk_css_parser_read_symbolic_color (parser);
+
+ if (color == NULL)
+ {
+ _gtk_shadow_unref (shadow);
+ return NULL;
+ }
+ }
+ }
+
+ if (!have_color || !have_lengths)
+ {
+ _gtk_css_parser_error (parser, "Must specify at least color and offsets");
+ _gtk_shadow_unref (shadow);
+ return NULL;
+ }
+
+ _gtk_shadow_append (shadow,
+ hoffset, voffset,
+ blur, spread,
+ have_inset, color);
+
+ gtk_symbolic_color_unref (color);
+
+ }
+ while (_gtk_css_parser_try (parser, ",", TRUE));
+
+ return _gtk_css_value_new_take_shadow (shadow);
+}
+
+static void
+shadow_value_print (GtkCssStyleProperty *property,
+ const GtkCssValue *value,
+ GString *string)
+{
+ GtkShadow *shadow;
+
+ shadow = _gtk_css_value_get_shadow (value);
+
+ if (shadow == NULL)
+ g_string_append (string, "none");
+ else
+ _gtk_shadow_print (shadow, string);
+}
+
+static GtkCssValue *
+shadow_value_compute (GtkCssStyleProperty *property,
+ GtkStyleContext *context,
+ GtkCssValue *specified)
+{
+ GtkShadow *shadow;
+
+ shadow = _gtk_css_value_get_shadow (specified);
+ if (shadow)
+ shadow = _gtk_shadow_resolve (shadow, context);
+
+ return _gtk_css_value_new_take_shadow (shadow);
+}
+
+static GtkCssValue *
border_corner_radius_value_parse (GtkCssStyleProperty *property,
GtkCssParser *parser,
GFile *base)
@@ -1038,9 +1154,9 @@ _gtk_css_style_property_init_properties (void)
GTK_TYPE_SHADOW,
GTK_TYPE_SHADOW,
GTK_STYLE_PROPERTY_INHERIT,
- NULL,
- NULL,
- NULL,
+ shadow_value_parse,
+ shadow_value_print,
+ shadow_value_compute,
NULL,
_gtk_css_value_new_take_shadow (NULL));
@@ -1049,9 +1165,9 @@ _gtk_css_style_property_init_properties (void)
GTK_TYPE_SHADOW,
GTK_TYPE_SHADOW,
GTK_STYLE_PROPERTY_INHERIT,
- NULL,
- NULL,
- NULL,
+ shadow_value_parse,
+ shadow_value_print,
+ shadow_value_compute,
NULL,
_gtk_css_value_new_take_shadow (NULL));
@@ -1060,9 +1176,9 @@ _gtk_css_style_property_init_properties (void)
GTK_TYPE_SHADOW,
GTK_TYPE_SHADOW,
0,
- NULL,
- NULL,
- NULL,
+ shadow_value_parse,
+ shadow_value_print,
+ shadow_value_compute,
NULL,
_gtk_css_value_new_take_shadow (NULL));
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]