diff options
39 files changed, 314 insertions, 167 deletions
diff --git a/ccss-cairo/ccss-cairo-appearance-parser.c b/ccss-cairo/ccss-cairo-appearance-parser.c index e43e3fa..8214b4a 100644 --- a/ccss-cairo/ccss-cairo-appearance-parser.c +++ b/ccss-cairo/ccss-cairo-appearance-parser.c @@ -20,6 +20,7 @@ */ #include <gmodule.h> +#include <ccss/ccss-property-impl.h> #include "ccss-cairo-appearance.h" #include "ccss-cairo-appearance-parser.h" #include "config.h" diff --git a/ccss-cairo/ccss-cairo-background.c b/ccss-cairo/ccss-cairo-background.c index 80bc281..e7ba978 100644 --- a/ccss-cairo/ccss-cairo-background.c +++ b/ccss-cairo/ccss-cairo-background.c @@ -22,6 +22,7 @@ #include <math.h> #include <string.h> #include <glib.h> +#include <ccss/ccss-property-impl.h> #include "ccss-cairo-background.h" #include "ccss-cairo-image-cache.h" #include "config.h" diff --git a/ccss-cairo/ccss-cairo-border.c b/ccss-cairo/ccss-cairo-border.c index 716f992..259d99e 100644 --- a/ccss-cairo/ccss-cairo-border.c +++ b/ccss-cairo/ccss-cairo-border.c @@ -23,6 +23,7 @@ #include <stdio.h> #include <string.h> #include <glib.h> +#include <ccss/ccss-property-impl.h> #include "ccss-cairo-border.h" #include "config.h" diff --git a/ccss-cairo/ccss-cairo-style.c b/ccss-cairo/ccss-cairo-style.c index a099c49..d9e47ca 100644 --- a/ccss-cairo/ccss-cairo-style.c +++ b/ccss-cairo/ccss-cairo-style.c @@ -21,7 +21,8 @@ #include <string.h> #include <glib.h> -#include <ccss/ccss-style-priv.h> /* PONDERING: use only public headers? */ +#include <ccss/ccss-property-impl.h> +#include "ccss/ccss-style-priv.h" /* PONDERING: use only public headers? */ #include "ccss-cairo-appearance.h" #include "ccss-cairo-background.h" #include "ccss-cairo-border.h" diff --git a/ccss-doc/ccss-sections.txt b/ccss-doc/ccss-sections.txt index dcf10cd..e618a45 100644 --- a/ccss-doc/ccss-sections.txt +++ b/ccss-doc/ccss-sections.txt @@ -92,6 +92,7 @@ ccss_property_factory_f ccss_property_inherit_f ccss_property_serialize_f ccss_property_init +ccss_property_get_state </SECTION> <SECTION> diff --git a/ccss-gtk/ccss-gtk-property.c b/ccss-gtk/ccss-gtk-property.c index c460a73..5637625 100644 --- a/ccss-gtk/ccss-gtk-property.c +++ b/ccss-gtk/ccss-gtk-property.c @@ -21,6 +21,8 @@ #include <math.h> #include <string.h> +#include <ccss/ccss-color-impl.h> +#include <ccss/ccss-property-impl.h> #include "ccss-gtk-property.h" static ccss_property_class_t const * diff --git a/ccss-tests/test-parser.c b/ccss-tests/test-parser.c index f426e2e..3422968 100644 --- a/ccss-tests/test-parser.c +++ b/ccss-tests/test-parser.c @@ -86,7 +86,7 @@ test_color (void) "color", (ccss_property_t const **) &color); g_assert (ret); - g_assert (color->base.state == CCSS_PROPERTY_STATE_SET); + g_assert (ccss_property_get_state (&color->base) == CCSS_PROPERTY_STATE_SET); /* Only compare defined values (i.e. > 0). */ if (_values[i][0] >= 0.) diff --git a/ccss/Makefile.am b/ccss/Makefile.am index 545520a..4f9b5a4 100644 --- a/ccss/Makefile.am +++ b/ccss/Makefile.am @@ -44,6 +44,7 @@ libccss_1_la_SOURCES = \ ccss-padding-parser.c \ ccss-padding-parser.h \ ccss-position.c \ + ccss-position-parser.h \ ccss-property.c \ ccss-property-generic.h \ ccss-property-parser.c \ @@ -66,7 +67,7 @@ headers_DATA = \ ccss-border.h \ ccss-border-image.h \ ccss-color.h \ - ccss-color-parser.h \ + ccss-color-impl.h \ ccss-function.h \ ccss-grammar.h \ ccss.h \ @@ -75,6 +76,7 @@ headers_DATA = \ ccss-padding.h \ ccss-position.h \ ccss-property.h \ + ccss-property-impl.h \ ccss-style.h \ ccss-stylesheet.h \ $(NULL) diff --git a/ccss/ccss-background-parser.c b/ccss/ccss-background-parser.c index 4fcdf51..3ae4591 100644 --- a/ccss/ccss-background-parser.c +++ b/ccss/ccss-background-parser.c @@ -24,7 +24,9 @@ #include <glib.h> #include "ccss-background-parser.h" #include "ccss-background.h" -#include "ccss-color-parser.h" +#include "ccss-color-impl.h" +#include "ccss-position-parser.h" +#include "ccss-property-impl.h" #include "config.h" #define PROPERTY_SET(property_) \ diff --git a/ccss/ccss-background.h b/ccss/ccss-background.h index c511d76..a44f5d3 100644 --- a/ccss/ccss-background.h +++ b/ccss/ccss-background.h @@ -24,7 +24,6 @@ #include <stdbool.h> #include <stdint.h> -#include <libcroco/libcroco.h> #include <ccss/ccss-macros.h> #include <ccss/ccss-color.h> #include <ccss/ccss-position.h> diff --git a/ccss/ccss-block.c b/ccss/ccss-block.c index abca52e..0bd276b 100644 --- a/ccss/ccss-block.c +++ b/ccss/ccss-block.c @@ -21,6 +21,7 @@ #include <glib.h> #include "ccss-block-priv.h" +#include "ccss-property-impl.h" #include "config.h" ccss_block_t * diff --git a/ccss/ccss-border-image-parser.c b/ccss/ccss-border-image-parser.c index 00e3756..213bba8 100644 --- a/ccss/ccss-border-image-parser.c +++ b/ccss/ccss-border-image-parser.c @@ -23,6 +23,8 @@ #include "ccss-border-image.h" #include "ccss-border-image-parser.h" #include "ccss-grammar.h" +#include "ccss-position-parser.h" +#include "ccss-property-impl.h" #include "config.h" static ccss_property_class_t const * diff --git a/ccss/ccss-border-parser.c b/ccss/ccss-border-parser.c index 570e126..28b148b 100644 --- a/ccss/ccss-border-parser.c +++ b/ccss/ccss-border-parser.c @@ -26,7 +26,8 @@ #include <glib.h> #include "ccss-border.h" #include "ccss-border-parser.h" -#include "ccss-color-parser.h" +#include "ccss-color-impl.h" +#include "ccss-property-impl.h" #include "config.h" #define INSERT_BORDER_COLOR(block_, prop_name_, prop_, prop_ptr_) \ diff --git a/ccss/ccss-color-parser.h b/ccss/ccss-color-impl.h index 0c608be..676a575 100644 --- a/ccss/ccss-color-parser.h +++ b/ccss/ccss-color-impl.h @@ -19,8 +19,19 @@ * MA 02110-1301, USA. */ -#ifndef CCSS_COLOR_PARSER_H -#define CCSS_COLOR_PARSER_H +/* + * Declarations for the implementation of custom properties. + * This declarations are not to be considered part of the stable + * ccss interface. Use with care. + * + * FIXME: split out to a section of its own in the docs. + */ + +#ifndef CCSS_COLOR_IMPL_H +#define CCSS_COLOR_IMPL_H + +/* Allow standalone inclusion. */ +#define CCSS_STANDALONE_HEADER #include <stdbool.h> #include <libcroco/libcroco.h> @@ -56,5 +67,5 @@ ccss_color_parser_get_property_classes (void); CCSS_END_DECLS -#endif /* CCSS_COLOR_PARSER_H */ +#endif /* CCSS_COLOR_IMPL_H */ diff --git a/ccss/ccss-color-parser.c b/ccss/ccss-color-parser.c index 069bfab..d200885 100644 --- a/ccss/ccss-color-parser.c +++ b/ccss/ccss-color-parser.c @@ -24,7 +24,8 @@ #include <stdio.h> #include <string.h> #include <glib.h> -#include "ccss-color-parser.h" +#include "ccss-color-impl.h" +#include "ccss-property-impl.h" #include "config.h" static const struct { diff --git a/ccss/ccss-color.h b/ccss/ccss-color.h index 3aae8ba..44a4ee2 100644 --- a/ccss/ccss-color.h +++ b/ccss/ccss-color.h @@ -23,7 +23,6 @@ #define CCSS_COLOR_H #include <stdbool.h> -#include <libcroco/libcroco.h> #include <ccss/ccss-macros.h> #include <ccss/ccss-property.h> diff --git a/ccss/ccss-grammar-function.c b/ccss/ccss-grammar-function.c index ed958ec..a3ca58b 100644 --- a/ccss/ccss-grammar-function.c +++ b/ccss/ccss-grammar-function.c @@ -22,6 +22,7 @@ #include <string.h> #include <glib.h> #include "ccss-grammar-priv.h" +#include "ccss-property-impl.h" #include "config.h" static GSList * diff --git a/ccss/ccss-grammar-parse.c b/ccss/ccss-grammar-parse.c index 0366faa..9b05b07 100644 --- a/ccss/ccss-grammar-parse.c +++ b/ccss/ccss-grammar-parse.c @@ -25,7 +25,7 @@ #include <libcroco/libcroco.h> #include "ccss-block-priv.h" #include "ccss-grammar-priv.h" -#include "ccss-property.h" +#include "ccss-property-impl.h" #include "ccss-selector.h" #include "ccss-selector-group.h" #include "config.h" diff --git a/ccss/ccss-grammar.c b/ccss/ccss-grammar.c index a935b70..c05765e 100644 --- a/ccss/ccss-grammar.c +++ b/ccss/ccss-grammar.c @@ -27,8 +27,9 @@ #include "ccss-background-parser.h" #include "ccss-border-parser.h" #include "ccss-border-image-parser.h" -#include "ccss-color-parser.h" +#include "ccss-color-impl.h" #include "ccss-padding-parser.h" +#include "ccss-property-impl.h" #include "config.h" diff --git a/ccss/ccss-grammar.h b/ccss/ccss-grammar.h index 95d0d4a..71d5512 100644 --- a/ccss/ccss-grammar.h +++ b/ccss/ccss-grammar.h @@ -22,7 +22,6 @@ #ifndef CCSS_GRAMMAR_H #define CCSS_GRAMMAR_H -#include <libcroco/libcroco.h> #include <ccss/ccss-function.h> #include <ccss/ccss-macros.h> #include <ccss/ccss-property.h> @@ -76,12 +75,6 @@ ccss_grammar_create_stylesheet_from_file (ccss_grammar_t *self, char const *css_file, void *user_data); -char * -ccss_grammar_invoke_function (ccss_grammar_t const *self, - char const *function_name, - CRTerm const *values, - void *user_data); - CCSS_END_DECLS #endif /* CCSS_GRAMMAR_H */ diff --git a/ccss/ccss-macros.h b/ccss/ccss-macros.h index bb59b13..8af9668 100644 --- a/ccss/ccss-macros.h +++ b/ccss/ccss-macros.h @@ -23,18 +23,25 @@ #define CCSS_MACROS_H /* Every header needs this one, so force single includes here. */ -#ifndef CCSS_H - #ifndef CCSS_BUILD +#if !defined(CCSS_H) && !defined(CCSS_BUILD) + #ifdef CCSS_STANDALONE_HEADER + #error "Toplevel header <ccss/ccss.h> needs to be included before standalone header." + #else #error "Only <ccss/ccss.h> can be included directly." #endif #endif #ifdef __cplusplus -# define CCSS_BEGIN_DECLS extern "C" { -# define CCSS_END_DECLS } + #define CCSS_BEGIN_DECLS extern "C" { + #define CCSS_END_DECLS } #else -# define CCSS_BEGIN_DECLS -# define CCSS_END_DECLS + #define CCSS_BEGIN_DECLS + #define CCSS_END_DECLS +#endif + +/* Internally we'd like to use the struct fields directly. */ +#ifndef CCSS_DEPRECATED + #define CCSS_DEPRECATED(sym) sym #endif #endif /* CCSS_MACROS_H */ diff --git a/ccss/ccss-padding-parser.c b/ccss/ccss-padding-parser.c index bed8894..a0f6d78 100644 --- a/ccss/ccss-padding-parser.c +++ b/ccss/ccss-padding-parser.c @@ -20,9 +20,10 @@ */ #include <string.h> +#include "ccss-grammar.h" #include "ccss-padding.h" #include "ccss-padding-parser.h" -#include "ccss-grammar.h" +#include "ccss-property-impl.h" #include "config.h" #define INSERT_PADDING(block_, prop_name_, prop_, prop_ptr_) \ diff --git a/ccss/ccss-position-parser.h b/ccss/ccss-position-parser.h new file mode 100644 index 0000000..3c09e50 --- /dev/null +++ b/ccss/ccss-position-parser.h @@ -0,0 +1,41 @@ +/* vim: set ts=8 sw=8 noexpandtab: */ + +/* The `C' CSS Library. + * Copyright (C) 2008 Robert Staudinger + * + * 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, write to the Free + * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, + * MA 02110-1301, USA. + */ + +#ifndef CCSS_POSITION_PARSER_H +#define CCSS_POSITION_PARSER_H + +#include <stdbool.h> +#include <stdint.h> +#include <libcroco/libcroco.h> +#include <ccss/ccss-macros.h> +#include <ccss/ccss-position.h> + +CCSS_BEGIN_DECLS + +bool +ccss_position_parse (ccss_position_t *self, + uint32_t flags, + CRTerm const **value); + +CCSS_END_DECLS + +#endif /* CCSS_POSITION_PARSER_H */ + diff --git a/ccss/ccss-position.c b/ccss/ccss-position.c index 2325626..4beee74 100644 --- a/ccss/ccss-position.c +++ b/ccss/ccss-position.c @@ -20,7 +20,7 @@ */ #include <glib.h> -#include "ccss-position.h" +#include "ccss-position-parser.h" #include "config.h" static const struct { diff --git a/ccss/ccss-position.h b/ccss/ccss-position.h index 31558e4..fc7b584 100644 --- a/ccss/ccss-position.h +++ b/ccss/ccss-position.h @@ -24,7 +24,6 @@ #include <stdbool.h> #include <stdint.h> -#include <libcroco/libcroco.h> #include <ccss/ccss-macros.h> CCSS_BEGIN_DECLS @@ -65,11 +64,6 @@ typedef struct { double value; } ccss_position_t; -bool -ccss_position_parse (ccss_position_t *self, - uint32_t flags, - CRTerm const **value); - double ccss_position_get_pos (ccss_position_t const *self, double extent, diff --git a/ccss/ccss-property-impl.h b/ccss/ccss-property-impl.h new file mode 100644 index 0000000..39f9716 --- /dev/null +++ b/ccss/ccss-property-impl.h @@ -0,0 +1,177 @@ +/* vim: set ts=8 sw=8 noexpandtab: */ + +/* The `C' CSS Library. + * Copyright (C) 2008 Robert Staudinger + * + * 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, write to the Free + * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, + * MA 02110-1301, USA. + */ + +/* + * Declarations for the implementation of custom properties. + * This declarations are not to be considered part of the stable + * ccss interface. Use with care. + * + * FIXME: split out to a section of its own in the docs. + */ + +#ifndef CCSS_PROPERTY_IMPL_H +#define CCSS_PROPERTY_IMPL_H + +/* Allow standalone inclusion. */ +#define CCSS_STANDALONE_HEADER + +#include <libcroco/libcroco.h> +#include <ccss/ccss-property.h> + +CCSS_BEGIN_DECLS + +/* Avoid circular dependencies. */ +struct ccss_block_; +struct ccss_grammar_; +struct ccss_style_; + +/** + * ccss_property_create_f: + * @grammar: the grammar associated with this property. + * @values: libcroco CSS values to parse for the property, see #CRTerm. + * @user_data: user data passed to property- or function-handler. + * + * Hook function for instantiating a property. + * + * Returns: pointer to the allocated property instance or %NULL if parsing fails. + **/ +typedef ccss_property_t * (*ccss_property_create_f) (struct ccss_grammar_ const *grammar, + CRTerm const *values, + void *user_data); + +/** + * ccss_property_destroy_f: + * @self: pointer to property instance. + * + * Hook function for deallocating a property instance. + **/ +typedef void (*ccss_property_destroy_f) (ccss_property_t *self); + +/** + * ccss_property_convert_f: + * @self: pointer to property instance. + * @target: conversion target type, see #ccss_property_type_t. + * @value: pointer to memory location where to place the converted value. + * + * Hook function for converting a property instance. + * + * Returns: %TRUE if the conversion was successful. + **/ +typedef bool (*ccss_property_convert_f) (ccss_property_t const *self, + ccss_property_type_t target, + void *value); + +/** + * ccss_property_factory_f: + * @grammar: the grammar associated with this property. + * @block: the #ccss_block_t the properties will be associated to. + * @name: name of the property. + * @values: libcroco CSS values to parse for the property, see #CRTerm. + * @user_data: user data passed to property- or function-handler. + * + * Hook function to handle the creation of multiple properties from a single CSS property, e.g. `border'. + * + * Returns: %TRUE when sucessful. + **/ +typedef bool (*ccss_property_factory_f) (struct ccss_grammar_ const *grammar, + struct ccss_block_ *block, + char const *name, + CRTerm const *values, + void *user_data); + +/** + * ccss_property_inherit_f: + * @container_style: style to inherit from. + * @style: style to inherit to. + * + * Hook function to inherit multi-value properties like `border'. + * + * Returns: %TRUE if property inheritance could be resolved. + **/ +typedef bool (*ccss_property_inherit_f) (struct ccss_style_ const *container_style, + struct ccss_style_ *style); + +/** + * ccss_property_serialize_f: + * @self: pointer to property instance. + * + * Hook function to reformat a property to CSS syntax. + * + * Returns: %TRUE if property inheritance could be resolved. + **/ +typedef char * (*ccss_property_serialize_f) (ccss_property_t const *self); + +/** + * ccss_property_class_t: + * @name: property name. + * @create: allocation hook, see #ccss_property_create_f. + * @destroy: deallocation hook, see #ccss_property_destroy_f. + * @convert: conversion hook, see #ccss_property_convert_f. + * @factory: factory hook, see #ccss_property_factory_f. + * @inherit: inherit hook, see #ccss_property_inherit_f. + * @inherit: inherit hook, see #ccss_property_inherit_f. + * @serialize: serialize hook, see #ccss_property_serialize_f. + * + * Property interpretation vtable entry. + **/ +struct ccss_property_class_ { + char const *name; + ccss_property_create_f create; + ccss_property_destroy_f destroy; + ccss_property_convert_f convert; + ccss_property_factory_f factory; + ccss_property_inherit_f inherit; + ccss_property_serialize_f serialize; + /*< private >*/ + void (*_padding_0) (void); + void (*_padding_1) (void); + void (*_padding_2) (void); + void (*_padding_3) (void); + void (*_padding_4) (void); +}; + +ccss_property_state_t +ccss_property_parse_state (CRTerm const **value); + +void +ccss_property_init (ccss_property_t *self, + ccss_property_class_t const *property_class); + +void +ccss_property_destroy (ccss_property_t *self); + +bool +ccss_style_interpret_property (struct ccss_style_ const *self, + char const *property_name, + ccss_property_create_f property_ctor, + void *user_data, + ccss_property_t **property); + +char * +ccss_grammar_invoke_function (struct ccss_grammar_ const *self, + char const *function_name, + CRTerm const *values, + void *user_data); + +CCSS_END_DECLS + +#endif /* CCSS_PROPERTY_IMPL_H */ + diff --git a/ccss/ccss-property-parser.c b/ccss/ccss-property-parser.c index b0c8cd6..419d20d 100644 --- a/ccss/ccss-property-parser.c +++ b/ccss/ccss-property-parser.c @@ -24,6 +24,7 @@ #include <libcroco/libcroco.h> #include "ccss-grammar.h" #include "ccss-property-generic.h" +#include "ccss-property-impl.h" #include "ccss-property-parser.h" #include "config.h" diff --git a/ccss/ccss-property.c b/ccss/ccss-property.c index 5ec23eb..160b26c 100644 --- a/ccss/ccss-property.c +++ b/ccss/ccss-property.c @@ -22,7 +22,7 @@ #include <stdio.h> #include <string.h> #include <glib.h> -#include "ccss-property.h" +#include "ccss-property-impl.h" #include "config.h" /** @@ -55,6 +55,22 @@ ccss_property_destroy (ccss_property_t *self) } /** + * ccss_property_get_state: + * @self: a #ccss_property_t. + * + * Get the properties' state. + * + * Returns: a #ccss_property_state_t. + **/ +ccss_property_state_t +ccss_property_get_state (ccss_property_t const *self) +{ + g_return_val_if_fail (self, CCSS_PROPERTY_STATE_INVALID); + + return self->state; +} + +/** * ccss_property_parse_state: * @value: iterater of type #CRTerm. * diff --git a/ccss/ccss-property.h b/ccss/ccss-property.h index 5f18619..2400946 100644 --- a/ccss/ccss-property.h +++ b/ccss/ccss-property.h @@ -23,16 +23,10 @@ #define CCSS_PROPERTY_H #include <stdbool.h> -#include <libcroco/libcroco.h> #include <ccss/ccss-macros.h> CCSS_BEGIN_DECLS -/* Avoid circular dependencies. */ -struct ccss_block_; -struct ccss_grammar_; -struct ccss_style_; - /** * ccss_property_state_t: * @CCSS_PROPERTY_STATE_INVALID: error state, invalid property. @@ -68,112 +62,8 @@ typedef enum { CCSS_PROPERTY_TYPE_STRING } ccss_property_type_t; -typedef struct ccss_property_ ccss_property_t; - -/** - * ccss_property_create_f: - * @grammar: the grammar associated with this property. - * @values: libcroco CSS values to parse for the property, see #CRTerm. - * @user_data: user data passed to property- or function-handler. - * - * Hook function for instantiating a property. - * - * Returns: pointer to the allocated property instance or %NULL if parsing fails. - **/ -typedef ccss_property_t * (*ccss_property_create_f) (struct ccss_grammar_ const *grammar, - CRTerm const *values, - void *user_data); - -/** - * ccss_property_destroy_f: - * @self: pointer to property instance. - * - * Hook function for deallocating a property instance. - **/ -typedef void (*ccss_property_destroy_f) (ccss_property_t *self); - -/** - * ccss_property_convert_f: - * @self: pointer to property instance. - * @target: conversion target type, see #ccss_property_type_t. - * @value: pointer to memory location where to place the converted value. - * - * Hook function for converting a property instance. - * - * Returns: %TRUE if the conversion was successful. - **/ -typedef bool (*ccss_property_convert_f) (ccss_property_t const *self, - ccss_property_type_t target, - void *value); - -/** - * ccss_property_factory_f: - * @grammar: the grammar associated with this property. - * @block: the #ccss_block_t the properties will be associated to. - * @name: name of the property. - * @values: libcroco CSS values to parse for the property, see #CRTerm. - * @user_data: user data passed to property- or function-handler. - * - * Hook function to handle the creation of multiple properties from a single CSS property, e.g. `border'. - * - * Returns: %TRUE when sucessful. - **/ -typedef bool (*ccss_property_factory_f) (struct ccss_grammar_ const *grammar, - struct ccss_block_ *block, - char const *name, - CRTerm const *values, - void *user_data); - -/** - * ccss_property_inherit_f: - * @container_style: style to inherit from. - * @style: style to inherit to. - * - * Hook function to inherit multi-value properties like `border'. - * - * Returns: %TRUE if property inheritance could be resolved. - **/ -typedef bool (*ccss_property_inherit_f) (struct ccss_style_ const *container_style, - struct ccss_style_ *style); - -/** - * ccss_property_serialize_f: - * @self: pointer to property instance. - * - * Hook function to reformat a property to CSS syntax. - * - * Returns: %TRUE if property inheritance could be resolved. - **/ -typedef char * (*ccss_property_serialize_f) (ccss_property_t const *self); - -/** - * ccss_property_class_t: - * @name: property name. - * @create: allocation hook, see #ccss_property_create_f. - * @destroy: deallocation hook, see #ccss_property_destroy_f. - * @convert: conversion hook, see #ccss_property_convert_f. - * @factory: factory hook, see #ccss_property_factory_f. - * @inherit: inherit hook, see #ccss_property_inherit_f. - * @inherit: inherit hook, see #ccss_property_inherit_f. - * @serialize: serialize hook, see #ccss_property_serialize_f. - * - * Property interpretation vtable entry. - **/ -typedef struct { - char const *name; - ccss_property_create_f create; - ccss_property_destroy_f destroy; - ccss_property_convert_f convert; - ccss_property_factory_f factory; - ccss_property_inherit_f inherit; - ccss_property_serialize_f serialize; - /*< private >*/ - void (*_padding_0) (void); - void (*_padding_1) (void); - void (*_padding_2) (void); - void (*_padding_3) (void); - void (*_padding_4) (void); -} ccss_property_class_t; +typedef struct ccss_property_ ccss_property_t; +typedef struct ccss_property_class_ ccss_property_class_t; /** * ccss_property_t: @@ -183,19 +73,13 @@ typedef struct { * This structure has to be embedded at the beginning of every custom property. **/ struct ccss_property_ { - ccss_property_class_t const *vtable; - ccss_property_state_t state; + /*< private >*/ + CCSS_DEPRECATED (ccss_property_class_t const *vtable); + CCSS_DEPRECATED (ccss_property_state_t state); }; -void -ccss_property_init (ccss_property_t *self, - ccss_property_class_t const *property_class); - -void -ccss_property_destroy (ccss_property_t *self); - ccss_property_state_t -ccss_property_parse_state (CRTerm const **value); +ccss_property_get_state (ccss_property_t const *self); CCSS_END_DECLS diff --git a/ccss/ccss-style.c b/ccss/ccss-style.c index 1197c96..cadd3df 100644 --- a/ccss/ccss-style.c +++ b/ccss/ccss-style.c @@ -23,6 +23,7 @@ #include <string.h> #include <glib.h> #include "ccss-property-generic.h" +#include "ccss-property-impl.h" #include "ccss-style-priv.h" #include "config.h" diff --git a/ccss/ccss-style.h b/ccss/ccss-style.h index 4fe14ed..19ecc78 100644 --- a/ccss/ccss-style.h +++ b/ccss/ccss-style.h @@ -68,13 +68,6 @@ ccss_style_set_property (ccss_style_t *self, char const *property_name, ccss_property_t const *value); -bool -ccss_style_interpret_property (ccss_style_t const *self, - char const *property_name, - ccss_property_create_f property_ctor, - void *user_data, - ccss_property_t **property); - /** * ccss_style_iterator_f: * @self: a #ccss_style_t. diff --git a/ccss/ccss-stylesheet.c b/ccss/ccss-stylesheet.c index b0ec902..ab7f757 100644 --- a/ccss/ccss-stylesheet.c +++ b/ccss/ccss-stylesheet.c @@ -24,6 +24,7 @@ #include "ccss-block-priv.h" #include "ccss-grammar-priv.h" #include "ccss-node-priv.h" +#include "ccss-property-impl.h" #include "ccss-selector-group.h" #include "ccss-selector.h" #include "ccss-style-priv.h" diff --git a/ccss/ccss.h b/ccss/ccss.h index 4423870..fdb9846 100644 --- a/ccss/ccss.h +++ b/ccss/ccss.h @@ -22,12 +22,17 @@ #ifndef CCSS_H #define CCSS_H +#if defined(__GNUC__) && !defined(CCSS_DEPRECATED) + #define CCSS_DEPRECATED(sym) sym __attribute__ ((deprecated)) +#else + #define CCSS_DEPRECATED(sym) sym +#endif + #include <ccss/ccss-background.h> #include <ccss/ccss-block.h> #include <ccss/ccss-border.h> #include <ccss/ccss-border-image.h> #include <ccss/ccss-color.h> -#include <ccss/ccss-color-parser.h> #include <ccss/ccss-grammar.h> #include <ccss/ccss-macros.h> #include <ccss/ccss-node.h> diff --git a/ccss/ccss.sym b/ccss/ccss.sym index 6f031db..799840d 100644 --- a/ccss/ccss.sym +++ b/ccss/ccss.sym @@ -21,6 +21,7 @@ ccss_position_get_vsize ccss_position_parse ccss_position_serialize ccss_property_init +ccss_property_get_state ccss_property_parse_state ccss_style_destroy ccss_style_dump diff --git a/examples/example-10.c b/examples/example-10.c index b0c249e..fe080a8 100644 --- a/examples/example-10.c +++ b/examples/example-10.c @@ -3,6 +3,7 @@ #include <stdio.h> #include <stdlib.h> #include <ccss/ccss.h> +#include <glib.h> #include "config.h" static char const _css_1[] = " \ diff --git a/examples/example-4-2.c b/examples/example-4-2.c index 68f22c6..1a4c508 100644 --- a/examples/example-4-2.c +++ b/examples/example-4-2.c @@ -4,6 +4,7 @@ #include <string.h> #include <cairo.h> #include <ccss-cairo/ccss-cairo.h> +#include <ccss/ccss-property-impl.h> #include <gtk/gtk.h> #include "config.h" diff --git a/examples/example-4.c b/examples/example-4.c index e287b74..41f51b4 100644 --- a/examples/example-4.c +++ b/examples/example-4.c @@ -4,6 +4,7 @@ #include <string.h> #include <cairo.h> #include <ccss-cairo/ccss-cairo.h> +#include <ccss/ccss-property-impl.h> #include <gtk/gtk.h> #include "config.h" diff --git a/examples/example-6.c b/examples/example-6.c index c421e16..6b0ac45 100644 --- a/examples/example-6.c +++ b/examples/example-6.c @@ -3,6 +3,7 @@ #include <stdio.h> #include <stdlib.h> #include <ccss/ccss.h> +#include <glib.h> #include "config.h" static char const _css[] = " \ @@ -20,7 +21,7 @@ main (int argc, ccss_stylesheet_t *stylesheet; ccss_style_t *style; double padding; - gboolean ret; + bool ret; grammar = ccss_grammar_create_css (); stylesheet = ccss_grammar_create_stylesheet_from_buffer (grammar, diff --git a/examples/example-7.c b/examples/example-7.c index 19f52b7..b8b012f 100644 --- a/examples/example-7.c +++ b/examples/example-7.c @@ -3,6 +3,7 @@ #include <stdio.h> #include <stdlib.h> #include <ccss/ccss.h> +#include <glib.h> #include "config.h" static char const _css[] = " \ @@ -19,7 +20,7 @@ main (int argc, ccss_stylesheet_t *stylesheet; ccss_style_t *style; double spacing; - gboolean ret; + bool ret; grammar = ccss_grammar_create_css (); stylesheet = ccss_grammar_create_stylesheet_from_buffer (grammar, |