diff options
author | Robert Staudinger <robsta@gnome.org> | 2008-11-28 14:04:26 +0100 |
---|---|---|
committer | Robert Staudinger <robsta@gnome.org> | 2008-11-28 14:04:26 +0100 |
commit | 5c2e7fff3d7c0e8e12df88dcfe5a9f5d2fad5816 (patch) | |
tree | 355f09660728ca005a62442b36aeecc8a4bea685 /ccss-cairo/ccss-cairo-style.c | |
parent | 335f84959aa5d55f74277b77e762f1779cbc0ded (diff) |
* ccss-cairo/ccss-background-parser.c (background_inherit):
* ccss-cairo/ccss-border-parser.c (border_color_inherit),
(border_style_inherit), (border_width_inherit),
(border_side_inherit_impl), (border_radius_inherit):
* ccss-cairo/ccss-cairo-style.c (ccss_cairo_style_get_double),
(ccss_cairo_style_get_string), (ccss_cairo_style_get_property):
* ccss-cairo/ccss-cairo-style.h:
* ccss-doc/tmpl/style.sgml:
* ccss/ccss-style-priv.h:
* ccss/ccss-style.c (ccss_style_get_double),
(ccss_style_get_string), (ccss_style_get_property):
* ccss/ccss-style.h:
* ccss/ccss-stylesheet.c (inherit_container_style):
* examples/example-4.c (expose_cb):
* examples/example-5.svg:
Provide API to query ccss-cairo properties with fallbacks.
Diffstat (limited to 'ccss-cairo/ccss-cairo-style.c')
-rw-r--r-- | ccss-cairo/ccss-cairo-style.c | 112 |
1 files changed, 112 insertions, 0 deletions
diff --git a/ccss-cairo/ccss-cairo-style.c b/ccss-cairo/ccss-cairo-style.c index 2cb8253..f6c3c52 100644 --- a/ccss-cairo/ccss-cairo-style.c +++ b/ccss-cairo/ccss-cairo-style.c @@ -800,3 +800,115 @@ ccss_cairo_style_draw_rectangle_with_gap (ccss_style_t const *self, } } +/** + * ccss_cairo_style_get_double: + * @self: a #ccss_style_t. + * @property_name: name of the property. + * @value: location to store the converted property. + * + * Query a numeric property with fallbacks, e.g. `border-color' if `border-left-color' is not given. + * + * Returns: %TRUE if the property was found and could be converted. + **/ +bool +ccss_cairo_style_get_double (ccss_style_t const *self, + char const *property_name, + double *value) +{ + GQuark property_id; + ccss_property_base_t const *property; + + g_return_val_if_fail (self && property_name && value, false); + + property_id = g_quark_try_string (property_name); + if (0 == property_id) { + /* Property unknown, no need to look up. */ + return false; + } + + property = lookup_property_r (self, property_id); + if (NULL == property) + return false; + + /* Have conversion function? */ + g_return_val_if_fail (property->property_class, false); + if (NULL == property->property_class->property_convert) { + return false; + } + + return property->property_class->property_convert (property, + CCSS_PROPERTY_TYPE_DOUBLE, + value); +} + +/** + * ccss_cairo_style_get_string: + * @self: a #ccss_style_t. + * @property_name: name of the property. + * @value: location to store the converted property. + * + * Query a string property with fallbacks, e.g. `border-color' if `border-left-color' is not given. + * + * Returns: %TRUE if the property was found and could be converted. + **/ +bool +ccss_cairo_style_get_string (ccss_style_t const *self, + char const *property_name, + char **value) +{ + GQuark property_id; + ccss_property_base_t const *property; + + g_return_val_if_fail (self && property_name && value, false); + + property_id = g_quark_try_string (property_name); + if (0 == property_id) { + /* Property unknown, no need to look up. */ + return false; + } + + property = lookup_property_r (self, property_id); + if (NULL == property) + return false; + + /* Have conversion function? */ + g_return_val_if_fail (property->property_class, false); + if (NULL == property->property_class->property_convert) { + return false; + } + + return property->property_class->property_convert (property, + CCSS_PROPERTY_TYPE_STRING, + value); +} + +/** + * ccss_cairo_style_get_property: + * @self: a #ccss_style_t. + * @property_name: name of the property. + * @value: location to store the property. + * + * Query a custom property with fallbacks, e.g. `border-color' if `border-left-color' is not given. + * + * Returns: %TRUE if the property was found. + **/ +bool +ccss_cairo_style_get_property (ccss_style_t const *self, + char const *property_name, + ccss_property_base_t const **property) +{ + GQuark property_id; + + g_return_val_if_fail (self && property_name && property, false); + + property_id = g_quark_try_string (property_name); + if (0 == property_id) { + /* Property unknown, no need to look up. */ + return false; + } + + *property = lookup_property_r (self, property_id); + + return (bool) *property; +} + |