From: buliabyak Date: Sat, 7 Oct 2006 19:43:42 +0000 (+0000) Subject: add generic set-property-to-this-object-url method X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=6405aaf88620c2c65e0340aa0d16b357cdf84ea6;p=inkscape.git add generic set-property-to-this-object-url method --- diff --git a/src/style.cpp b/src/style.cpp index bd880b857..048801ae4 100644 --- a/src/style.cpp +++ b/src/style.cpp @@ -3693,6 +3693,31 @@ sp_style_filter_clear(SPStyle *style, SPIFilter *f) } +// FIXME: Everything below this line belongs in a different file - css-chemistry? + +void +sp_style_set_property_url (SPObject *item, gchar const *property, SPObject *linked, bool recursive) +{ + Inkscape::XML::Node *repr = SP_OBJECT_REPR(item); + + if (repr == NULL) return; + + g_return_if_fail(linked != NULL); + + gchar *val = g_strdup_printf("url(#%s)", SP_OBJECT_ID(linked)); + + SPCSSAttr *css = sp_repr_css_attr_new(); + sp_repr_css_set_property(css, property, val); + g_free(val); + if (recursive) { + sp_repr_css_change_recursive(repr, css, "style"); + } else { + sp_repr_css_change(repr, css, "style"); + } + sp_repr_css_attr_unref(css); +} + + /** * Clear all style property attributes in object. */ diff --git a/src/style.h b/src/style.h index a7572317e..b7932404c 100644 --- a/src/style.h +++ b/src/style.h @@ -536,6 +536,8 @@ SPCSSAttr *sp_css_attr_scale(SPCSSAttr *css, double ex); void sp_style_unset_property_attrs(SPObject *o); +void sp_style_set_property_url (SPObject *item, gchar const *property, SPObject *linked, bool recursive); + #endif