* 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, write to the
- * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- * Boston, MA 02111-1307, USA.
+ * License along with this library. If not, see <http://www.gnu.org/licenses/>.
*/
#include "config.h"
#include <gdk-pixbuf/gdk-pixbuf.h>
#include <cairo-gobject.h>
-#include "gtkanimationdescription.h"
+#include "gtkcsscolorvalueprivate.h"
+#include "gtkcssimagegradientprivate.h"
#include "gtkcssprovider.h"
+#include "gtkcssrgbavalueprivate.h"
+#include "gtkcsstypedvalueprivate.h"
#include "gtkcsstypesprivate.h"
-#include "gtkgradient.h"
#include "gtkprivatetypebuiltins.h"
-#include "gtkshadowprivate.h"
+#include "gtkstylecontextprivate.h"
#include "gtkthemingengine.h"
#include "gtktypebuiltins.h"
#include "gtkwin32themeprivate.h"
+#include "deprecated/gtkgradientprivate.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
*/
static GHashTable *parse_funcs = NULL;
static GHashTable *print_funcs = NULL;
-
-typedef gboolean (* GtkStyleParseFunc) (GtkCssParser *parser,
- GFile *base,
- GValue *value);
-typedef void (* GtkStylePrintFunc) (const GValue *value,
- GString *string);
+static GHashTable *compute_funcs = NULL;
+
+typedef gboolean (* GtkStyleParseFunc) (GtkCssParser *parser,
+ GValue *value);
+typedef void (* GtkStylePrintFunc) (const GValue *value,
+ GString *string);
+typedef GtkCssValue * (* GtkStyleComputeFunc) (GtkStyleProviderPrivate *provider,
+ GtkCssComputedValues *values,
+ GtkCssComputedValues *parent_values,
+ GtkCssValue *specified,
+ GtkCssDependencies *dependencies);
static void
-register_conversion_function (GType type,
- GtkStyleParseFunc parse,
- GtkStylePrintFunc print)
+register_conversion_function (GType type,
+ GtkStyleParseFunc parse,
+ GtkStylePrintFunc print,
+ GtkStyleComputeFunc compute)
{
if (parse)
g_hash_table_insert (parse_funcs, GSIZE_TO_POINTER (type), parse);
if (print)
g_hash_table_insert (print_funcs, GSIZE_TO_POINTER (type), print);
+ if (compute)
+ g_hash_table_insert (compute_funcs, GSIZE_TO_POINTER (type), compute);
}
static void
static gboolean
rgba_value_parse (GtkCssParser *parser,
- GFile *base,
GValue *value)
{
GtkSymbolicColor *symbolic;
GdkRGBA rgba;
- symbolic = _gtk_css_parser_read_symbolic_color (parser);
+ G_GNUC_BEGIN_IGNORE_DEPRECATIONS;
+
+ symbolic = _gtk_css_symbolic_value_new (parser);
if (symbolic == NULL)
return FALSE;
g_value_take_boxed (value, symbolic);
}
+ G_GNUC_END_IGNORE_DEPRECATIONS;
+
return TRUE;
}
}
}
+static GtkCssValue *
+rgba_value_compute (GtkStyleProviderPrivate *provider,
+ GtkCssComputedValues *values,
+ GtkCssComputedValues *parent_values,
+ GtkCssValue *specified,
+ GtkCssDependencies *dependencies)
+{
+ GdkRGBA white = { 1, 1, 1, 1 };
+ const GValue *value;
+
+ value = _gtk_css_typed_value_get (specified);
+
+ if (G_VALUE_HOLDS (value, GTK_TYPE_SYMBOLIC_COLOR))
+ {
+ GtkSymbolicColor *symbolic = g_value_get_boxed (value);
+ GtkCssValue *val;
+ GValue new_value = G_VALUE_INIT;
+ GdkRGBA rgba;
+
+ 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);
+ _gtk_css_value_unref (val);
+ }
+ else
+ rgba = white;
+
+ g_value_init (&new_value, GDK_TYPE_RGBA);
+ g_value_set_boxed (&new_value, &rgba);
+ return _gtk_css_typed_value_new_take (&new_value);
+ }
+ else
+ return _gtk_css_value_ref (specified);
+}
+
static gboolean
color_value_parse (GtkCssParser *parser,
- GFile *base,
GValue *value)
{
GtkSymbolicColor *symbolic;
GdkRGBA rgba;
- symbolic = _gtk_css_parser_read_symbolic_color (parser);
+ G_GNUC_BEGIN_IGNORE_DEPRECATIONS;
+
+ symbolic = _gtk_css_symbolic_value_new (parser);
if (symbolic == NULL)
return FALSE;
g_value_take_boxed (value, symbolic);
}
+ G_GNUC_END_IGNORE_DEPRECATIONS;
+
return TRUE;
}
}
}
+static GtkCssValue *
+color_value_compute (GtkStyleProviderPrivate *provider,
+ GtkCssComputedValues *values,
+ GtkCssComputedValues *parent_values,
+ GtkCssValue *specified,
+ GtkCssDependencies *dependencies)
+{
+ GdkColor color = { 0, 65535, 65535, 65535 };
+ const GValue *value;
+
+ value = _gtk_css_typed_value_get (specified);
+
+ if (G_VALUE_HOLDS (value, GTK_TYPE_SYMBOLIC_COLOR))
+ {
+ GValue new_value = G_VALUE_INIT;
+ GtkCssValue *val;
+
+ 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);
+ color.red = rgba->red * 65535. + 0.5;
+ color.green = rgba->green * 65535. + 0.5;
+ color.blue = rgba->blue * 65535. + 0.5;
+ _gtk_css_value_unref (val);
+ }
+
+ g_value_init (&new_value, GDK_TYPE_COLOR);
+ g_value_set_boxed (&new_value, &color);
+ return _gtk_css_typed_value_new_take (&new_value);
+ }
+ else
+ return _gtk_css_value_ref (specified);
+}
+
static gboolean
symbolic_color_value_parse (GtkCssParser *parser,
- GFile *base,
GValue *value)
{
GtkSymbolicColor *symbolic;
- symbolic = _gtk_css_parser_read_symbolic_color (parser);
+ symbolic = _gtk_css_symbolic_value_new (parser);
if (symbolic == NULL)
return FALSE;
{
GtkSymbolicColor *symbolic = g_value_get_boxed (value);
+ G_GNUC_BEGIN_IGNORE_DEPRECATIONS;
+
if (symbolic == NULL)
g_string_append (string, "none");
else
g_string_append (string, s);
g_free (s);
}
+
+ G_GNUC_END_IGNORE_DEPRECATIONS;
}
static gboolean
font_description_value_parse (GtkCssParser *parser,
- GFile *base,
GValue *value)
{
PangoFontDescription *font_desc;
static gboolean
boolean_value_parse (GtkCssParser *parser,
- GFile *base,
GValue *value)
{
if (_gtk_css_parser_try (parser, "true", TRUE) ||
static gboolean
int_value_parse (GtkCssParser *parser,
- GFile *base,
GValue *value)
{
gint i;
if (_gtk_css_parser_begins_with (parser, '-'))
{
- int res = _gtk_win32_theme_int_parse (parser, base, &i);
+ int res = _gtk_win32_theme_int_parse (parser, &i);
if (res >= 0)
{
g_value_set_int (value, i);
static gboolean
uint_value_parse (GtkCssParser *parser,
- GFile *base,
GValue *value)
{
guint u;
static gboolean
double_value_parse (GtkCssParser *parser,
- GFile *base,
GValue *value)
{
gdouble d;
static gboolean
float_value_parse (GtkCssParser *parser,
- GFile *base,
GValue *value)
{
gdouble d;
static gboolean
string_value_parse (GtkCssParser *parser,
- GFile *base,
GValue *value)
{
char *str = _gtk_css_parser_read_string (parser);
static gboolean
theming_engine_value_parse (GtkCssParser *parser,
- GFile *base,
GValue *value)
{
GtkThemingEngine *engine;
if (engine == NULL)
{
- _gtk_css_parser_error (parser, "Themeing engine '%s' not found", str);
+ _gtk_css_parser_error (parser, "Theming engine '%s' not found", str);
g_free (str);
return FALSE;
}
}
}
-static gboolean
-animation_description_value_parse (GtkCssParser *parser,
- GFile *base,
- GValue *value)
-{
- GtkAnimationDescription *desc;
- char *str;
-
- str = _gtk_css_parser_read_value (parser);
- if (str == NULL)
- return FALSE;
-
- desc = _gtk_animation_description_from_string (str);
- g_free (str);
-
- if (desc == NULL)
- {
- _gtk_css_parser_error (parser, "Invalid animation description");
- return FALSE;
- }
-
- g_value_take_boxed (value, desc);
- return TRUE;
-}
-
-static void
-animation_description_value_print (const GValue *value,
- GString *string)
-{
- GtkAnimationDescription *desc = g_value_get_boxed (value);
-
- if (desc == NULL)
- g_string_append (string, "none");
- else
- _gtk_animation_description_print (desc, string);
-}
-
static gboolean
border_value_parse (GtkCssParser *parser,
- GFile *base,
GValue *value)
{
GtkBorder border = { 0, };
- guint i, numbers[4];
+ guint i;
+ int numbers[4];
for (i = 0; i < G_N_ELEMENTS (numbers); i++)
{
{
/* These are strictly speaking signed, but we want to be able to use them
for unsigned types too, as the actual ranges of values make this safe */
- int res = _gtk_win32_theme_int_parse (parser, base, (int *)&numbers[i]);
+ int res = _gtk_win32_theme_int_parse (parser, &numbers[i]);
if (res == 0) /* Parse error, report */
return FALSE;
break;
}
else
- {
- if (!_gtk_css_parser_try_uint (parser, &numbers[i]))
- break;
-
- /* XXX: shouldn't allow spaces here? */
- _gtk_css_parser_try (parser, "px", TRUE);
- }
+ {
+ if (!_gtk_css_parser_try_length (parser, &numbers[i]))
+ break;
+ }
}
if (i == 0)
static gboolean
gradient_value_parse (GtkCssParser *parser,
- GFile *base,
GValue *value)
{
GtkGradient *gradient;
- cairo_pattern_type_t type;
- gdouble coords[6];
- guint i;
-
- if (!_gtk_css_parser_try (parser, "-gtk-gradient", TRUE))
- {
- _gtk_css_parser_error (parser,
- "Expected '-gtk-gradient'");
- return FALSE;
- }
-
- if (!_gtk_css_parser_try (parser, "(", TRUE))
- {
- _gtk_css_parser_error (parser,
- "Expected '(' after '-gtk-gradient'");
- return FALSE;
- }
-
- /* Parse gradient type */
- if (_gtk_css_parser_try (parser, "linear", TRUE))
- type = CAIRO_PATTERN_TYPE_LINEAR;
- else if (_gtk_css_parser_try (parser, "radial", TRUE))
- type = CAIRO_PATTERN_TYPE_RADIAL;
- else
- {
- _gtk_css_parser_error (parser,
- "Gradient type must be 'radial' or 'linear'");
- return FALSE;
- }
-
- /* Parse start/stop position parameters */
- for (i = 0; i < 2; i++)
- {
- if (! _gtk_css_parser_try (parser, ",", TRUE))
- {
- _gtk_css_parser_error (parser,
- "Expected ','");
- return FALSE;
- }
-
- if (_gtk_css_parser_try (parser, "left", TRUE))
- coords[i * 3] = 0;
- else if (_gtk_css_parser_try (parser, "right", TRUE))
- coords[i * 3] = 1;
- else if (_gtk_css_parser_try (parser, "center", TRUE))
- coords[i * 3] = 0.5;
- else if (!_gtk_css_parser_try_double (parser, &coords[i * 3]))
- {
- _gtk_css_parser_error (parser,
- "Expected a valid X coordinate");
- return FALSE;
- }
-
- if (_gtk_css_parser_try (parser, "top", TRUE))
- coords[i * 3 + 1] = 0;
- else if (_gtk_css_parser_try (parser, "bottom", TRUE))
- coords[i * 3 + 1] = 1;
- else if (_gtk_css_parser_try (parser, "center", TRUE))
- coords[i * 3 + 1] = 0.5;
- else if (!_gtk_css_parser_try_double (parser, &coords[i * 3 + 1]))
- {
- _gtk_css_parser_error (parser,
- "Expected a valid Y coordinate");
- return FALSE;
- }
-
- if (type == CAIRO_PATTERN_TYPE_RADIAL)
- {
- /* Parse radius */
- if (! _gtk_css_parser_try (parser, ",", TRUE))
- {
- _gtk_css_parser_error (parser,
- "Expected ','");
- return FALSE;
- }
-
- if (! _gtk_css_parser_try_double (parser, &coords[(i * 3) + 2]))
- {
- _gtk_css_parser_error (parser,
- "Expected a numer for the radius");
- return FALSE;
- }
- }
- }
-
- if (type == CAIRO_PATTERN_TYPE_LINEAR)
- gradient = gtk_gradient_new_linear (coords[0], coords[1], coords[3], coords[4]);
- else
- gradient = gtk_gradient_new_radial (coords[0], coords[1], coords[2],
- coords[3], coords[4], coords[5]);
-
- while (_gtk_css_parser_try (parser, ",", TRUE))
- {
- GtkSymbolicColor *color;
- gdouble position;
-
- if (_gtk_css_parser_try (parser, "from", TRUE))
- {
- position = 0;
-
- if (!_gtk_css_parser_try (parser, "(", TRUE))
- {
- gtk_gradient_unref (gradient);
- _gtk_css_parser_error (parser,
- "Expected '('");
- return FALSE;
- }
-
- }
- else if (_gtk_css_parser_try (parser, "to", TRUE))
- {
- position = 1;
-
- if (!_gtk_css_parser_try (parser, "(", TRUE))
- {
- gtk_gradient_unref (gradient);
- _gtk_css_parser_error (parser,
- "Expected '('");
- return FALSE;
- }
-
- }
- else if (_gtk_css_parser_try (parser, "color-stop", TRUE))
- {
- if (!_gtk_css_parser_try (parser, "(", TRUE))
- {
- gtk_gradient_unref (gradient);
- _gtk_css_parser_error (parser,
- "Expected '('");
- return FALSE;
- }
-
- if (!_gtk_css_parser_try_double (parser, &position))
- {
- gtk_gradient_unref (gradient);
- _gtk_css_parser_error (parser,
- "Expected a valid number");
- return FALSE;
- }
-
- if (!_gtk_css_parser_try (parser, ",", TRUE))
- {
- gtk_gradient_unref (gradient);
- _gtk_css_parser_error (parser,
- "Expected a comma");
- return FALSE;
- }
- }
- else
- {
- gtk_gradient_unref (gradient);
- _gtk_css_parser_error (parser,
- "Not a valid color-stop definition");
- return FALSE;
- }
- color = _gtk_css_parser_read_symbolic_color (parser);
- if (color == NULL)
- {
- gtk_gradient_unref (gradient);
- return FALSE;
- }
-
- gtk_gradient_add_color_stop (gradient, position, color);
- gtk_symbolic_color_unref (color);
-
- if (!_gtk_css_parser_try (parser, ")", TRUE))
- {
- gtk_gradient_unref (gradient);
- _gtk_css_parser_error (parser,
- "Expected ')'");
- return FALSE;
- }
- }
-
- if (!_gtk_css_parser_try (parser, ")", TRUE))
- {
- gtk_gradient_unref (gradient);
- _gtk_css_parser_error (parser,
- "Expected ')'");
- return FALSE;
- }
+ gradient = _gtk_gradient_parse (parser);
+ if (gradient == NULL)
+ return FALSE;
g_value_take_boxed (value, gradient);
return TRUE;
{
GtkGradient *gradient = g_value_get_boxed (value);
+ G_GNUC_BEGIN_IGNORE_DEPRECATIONS;
+
if (gradient == NULL)
g_string_append (string, "none");
else
g_string_append (string, s);
g_free (s);
}
-}
-
-static GFile *
-gtk_css_parse_url (GtkCssParser *parser,
- GFile *base)
-{
- gchar *path;
- GFile *file;
-
- if (_gtk_css_parser_try (parser, "url", FALSE))
- {
- if (!_gtk_css_parser_try (parser, "(", TRUE))
- {
- _gtk_css_parser_skip_whitespace (parser);
- if (_gtk_css_parser_try (parser, "(", TRUE))
- {
- GError *error;
-
- error = g_error_new_literal (GTK_CSS_PROVIDER_ERROR,
- GTK_CSS_PROVIDER_ERROR_DEPRECATED,
- "Whitespace between 'url' and '(' is deprecated");
-
- _gtk_css_parser_take_error (parser, error);
- }
- else
- {
- _gtk_css_parser_error (parser, "Expected '(' after 'url'");
- return NULL;
- }
- }
-
- path = _gtk_css_parser_read_string (parser);
- if (path == NULL)
- return NULL;
-
- if (!_gtk_css_parser_try (parser, ")", TRUE))
- {
- _gtk_css_parser_error (parser, "No closing ')' found for 'url'");
- g_free (path);
- return NULL;
- }
- }
- else
- {
- path = _gtk_css_parser_try_name (parser, TRUE);
- if (path == NULL)
- {
- _gtk_css_parser_error (parser, "Not a valid url");
- return NULL;
- }
- }
-
- file = g_file_resolve_relative_path (base, path);
- g_free (path);
- return file;
+ G_GNUC_END_IGNORE_DEPRECATIONS;
}
static gboolean
pattern_value_parse (GtkCssParser *parser,
- GFile *base,
GValue *value)
{
if (_gtk_css_parser_try (parser, "none", TRUE))
}
else if (_gtk_css_parser_begins_with (parser, '-'))
{
- int res;
- res = _gtk_win32_theme_part_parse (parser, base, value);
- if (res >= 0)
- return res > 0;
- /* < 0 => continue */
g_value_unset (value);
g_value_init (value, GTK_TYPE_GRADIENT);
- return gradient_value_parse (parser, base, value);
+ return gradient_value_parse (parser, value);
}
else
{
cairo_t *cr;
cairo_matrix_t matrix;
- file = gtk_css_parse_url (parser, base);
+ file = _gtk_css_parser_read_url (parser);
if (file == NULL)
return FALSE;
}
surface_print (surface, string);
break;
- case CAIRO_PATTERN_TYPE_SOLID:
case CAIRO_PATTERN_TYPE_LINEAR:
case CAIRO_PATTERN_TYPE_RADIAL:
+ g_string_append (string, "none /* FIXME: add support for printing gradients */");
+ break;
+ case CAIRO_PATTERN_TYPE_SOLID:
default:
g_assert_not_reached ();
break;
}
}
-static gboolean
-shadow_value_parse (GtkCssParser *parser,
- GFile *base,
- GValue *value)
+static GtkCssValue *
+pattern_value_compute (GtkStyleProviderPrivate *provider,
+ GtkCssComputedValues *values,
+ GtkCssComputedValues *parent_values,
+ GtkCssValue *specified,
+ GtkCssDependencies *dependencies)
{
- gboolean have_inset, have_color, have_lengths;
- gdouble hoffset, voffset, blur, spread;
- GtkSymbolicColor *color;
- GtkShadow *shadow;
- guint i;
-
- shadow = _gtk_shadow_new ();
-
- if (_gtk_css_parser_try (parser, "none", TRUE))
- return TRUE;
+ const GValue *value = _gtk_css_typed_value_get (specified);
- do
+ if (G_VALUE_HOLDS (value, GTK_TYPE_GRADIENT))
{
- 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);
-
+ GValue new_value = G_VALUE_INIT;
+ cairo_pattern_t *gradient;
+
+ gradient = _gtk_gradient_resolve_full (g_value_get_boxed (value), provider, values, parent_values, dependencies);
+
+ g_value_init (&new_value, CAIRO_GOBJECT_TYPE_PATTERN);
+ g_value_take_boxed (&new_value, gradient);
+ return _gtk_css_typed_value_new_take (&new_value);
}
- 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 gboolean
-background_repeat_value_parse (GtkCssParser *parser,
- GFile *file,
- GValue *value)
-{
- GtkCssBackgroundRepeat repeat;
- int style;
-
- if (!enum_parse (parser, GTK_TYPE_CSS_BACKGROUND_REPEAT_STYLE, &style))
- return FALSE;
-
- repeat.repeat = style;
-
- g_value_set_boxed (value, &repeat);
-
- return TRUE;
-}
-
-static void
-background_repeat_value_print (const GValue *value,
- GString *string)
-{
- GtkCssBackgroundRepeat *repeat;
-
- repeat = g_value_get_boxed (value);
-
- enum_print (repeat->repeat, GTK_TYPE_CSS_BACKGROUND_REPEAT_STYLE, string);
-}
-
-static gboolean
-border_image_repeat_value_parse (GtkCssParser *parser,
- GFile *file,
- GValue *value)
-{
- GtkCssBorderImageRepeat image_repeat;
- GtkCssBorderRepeatStyle styles[2];
- gint i, v;
-
- for (i = 0; i < 2; i++)
- {
- if (_gtk_css_parser_try_enum (parser, GTK_TYPE_CSS_BORDER_REPEAT_STYLE, &v))
- styles[i] = v;
- else if (i == 0)
- {
- styles[1] = styles[0] = GTK_CSS_REPEAT_STYLE_STRETCH;
- break;
- }
- else
- styles[i] = styles[0];
- }
-
- image_repeat.hrepeat = styles[0];
- image_repeat.vrepeat = styles[1];
-
- g_value_set_boxed (value, &image_repeat);
-
- return TRUE;
-}
-
-static void
-border_image_repeat_value_print (const GValue *value,
- GString *string)
-{
- GtkCssBorderImageRepeat *image_repeat;
-
- image_repeat = g_value_get_boxed (value);
-
- enum_print (image_repeat->hrepeat, GTK_TYPE_CSS_BORDER_REPEAT_STYLE, string);
- if (image_repeat->hrepeat != image_repeat->vrepeat)
- {
- g_string_append (string, " ");
- enum_print (image_repeat->vrepeat, GTK_TYPE_CSS_BORDER_REPEAT_STYLE, string);
- }
+ return _gtk_css_value_ref (specified);
}
static gboolean
enum_value_parse (GtkCssParser *parser,
- GFile *base,
GValue *value)
{
int v;
static gboolean
flags_value_parse (GtkCssParser *parser,
- GFile *base,
GValue *value)
{
GFlagsClass *flags_class;
parse_funcs = g_hash_table_new (NULL, NULL);
print_funcs = g_hash_table_new (NULL, NULL);
+ compute_funcs = g_hash_table_new (NULL, NULL);
register_conversion_function (GDK_TYPE_RGBA,
rgba_value_parse,
- rgba_value_print);
+ rgba_value_print,
+ rgba_value_compute);
register_conversion_function (GDK_TYPE_COLOR,
color_value_parse,
- color_value_print);
+ color_value_print,
+ color_value_compute);
register_conversion_function (GTK_TYPE_SYMBOLIC_COLOR,
symbolic_color_value_parse,
- symbolic_color_value_print);
+ symbolic_color_value_print,
+ NULL);
register_conversion_function (PANGO_TYPE_FONT_DESCRIPTION,
font_description_value_parse,
- font_description_value_print);
+ font_description_value_print,
+ NULL);
register_conversion_function (G_TYPE_BOOLEAN,
boolean_value_parse,
- boolean_value_print);
+ boolean_value_print,
+ NULL);
register_conversion_function (G_TYPE_INT,
int_value_parse,
- int_value_print);
+ int_value_print,
+ NULL);
register_conversion_function (G_TYPE_UINT,
uint_value_parse,
- uint_value_print);
+ uint_value_print,
+ NULL);
register_conversion_function (G_TYPE_DOUBLE,
double_value_parse,
- double_value_print);
+ double_value_print,
+ NULL);
register_conversion_function (G_TYPE_FLOAT,
float_value_parse,
- float_value_print);
+ float_value_print,
+ NULL);
register_conversion_function (G_TYPE_STRING,
string_value_parse,
- string_value_print);
+ string_value_print,
+ NULL);
register_conversion_function (GTK_TYPE_THEMING_ENGINE,
theming_engine_value_parse,
- theming_engine_value_print);
- register_conversion_function (GTK_TYPE_ANIMATION_DESCRIPTION,
- animation_description_value_parse,
- animation_description_value_print);
+ theming_engine_value_print,
+ NULL);
register_conversion_function (GTK_TYPE_BORDER,
border_value_parse,
- border_value_print);
+ border_value_print,
+ NULL);
register_conversion_function (GTK_TYPE_GRADIENT,
gradient_value_parse,
- gradient_value_print);
+ gradient_value_print,
+ NULL);
register_conversion_function (CAIRO_GOBJECT_TYPE_PATTERN,
pattern_value_parse,
- pattern_value_print);
- register_conversion_function (GTK_TYPE_CSS_BORDER_IMAGE_REPEAT,
- border_image_repeat_value_parse,
- border_image_repeat_value_print);
- register_conversion_function (GTK_TYPE_SHADOW,
- shadow_value_parse,
- shadow_value_print);
+ pattern_value_print,
+ pattern_value_compute);
register_conversion_function (G_TYPE_ENUM,
enum_value_parse,
- enum_value_print);
+ enum_value_print,
+ NULL);
register_conversion_function (G_TYPE_FLAGS,
flags_value_parse,
- flags_value_print);
- register_conversion_function (GTK_TYPE_CSS_BACKGROUND_REPEAT,
- background_repeat_value_parse,
- background_repeat_value_print);
+ flags_value_print,
+ NULL);
}
/**
* _gtk_css_style_parse_value:
* @value: the value to parse into. Must be a valid initialized #GValue
* @parser: the parser to parse from
- * @base: the base URL for @parser
*
* This is the generic parsing function used for CSS values. If the
* function fails to parse a value, it will emit an error on @parser,
**/
gboolean
_gtk_css_style_parse_value (GValue *value,
- GtkCssParser *parser,
- GFile *base)
+ GtkCssParser *parser)
{
GtkStyleParseFunc func;
return FALSE;
}
- return (*func) (parser, base, value);
+ return (*func) (parser, value);
}
/**
func (value, string);
}
+/**
+ * _gtk_css_style_compute_value:
+ * @provider: Style provider to look up information from
+ * @values: The values to compute for
+ * @parent_values: Values to look up inherited values from
+ * @target_type: Type the resulting value should have
+ * @specified: the value to use for the computation
+ * @dependencies: (out): Value initialized with 0 to take the dependencies
+ * of the returned value
+ *
+ * Converts the @specified value into the @computed value using the
+ * information in @context. The values must have matching types, ie
+ * @specified must be a result of a call to
+ * _gtk_css_style_parse_value() with the same type as @computed.
+ *
+ * Returns: the resulting value
+ **/
+GtkCssValue *
+_gtk_css_style_compute_value (GtkStyleProviderPrivate *provider,
+ GtkCssComputedValues *values,
+ GtkCssComputedValues *parent_values,
+ GType target_type,
+ GtkCssValue *specified,
+ GtkCssDependencies *dependencies)
+{
+ GtkStyleComputeFunc func;
+
+ 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);
+
+ gtk_css_style_funcs_init ();
+
+ func = g_hash_table_lookup (compute_funcs,
+ GSIZE_TO_POINTER (target_type));
+ if (func == NULL)
+ func = g_hash_table_lookup (compute_funcs,
+ GSIZE_TO_POINTER (g_type_fundamental (target_type)));
+
+ if (func)
+ return func (provider, values, parent_values, specified, dependencies);
+ else
+ return _gtk_css_value_ref (specified);
+}
+