Logo Search packages:      
Sourcecode: inkscape version File versions

void sp_desktop_set_style ( SPDesktop desktop,
SPCSSAttr *  css,
bool  change,
bool  write_current 
)

Apply style on selection on desktop.

Todo:
FIXME: in set_style, compensate pattern and gradient fills, stroke width, rect corners, font size for the object's own transform so that pasting fills does not depend on preserve/optimize.

Todo:
if the style is text-only, apply only to texts?

Definition at line 159 of file desktop-style.cpp.

References SPDesktop::_set_style_signal, SPDesktop::current, Inkscape::Selection::itemList(), SPDesktop::selection, sp_css_attr_unset_uris(), and sp_desktop_apply_css_recursive().

Referenced by sp_desktop_set_color().

{
    if (write_current) {
// 1. Set internal value
        sp_repr_css_merge(desktop->current, css);

// 1a. Write to prefs; make a copy and unset any URIs first
        SPCSSAttr *css_write = sp_repr_css_attr_new();
        sp_repr_css_merge(css_write, css);
        sp_css_attr_unset_uris(css_write);
        sp_repr_css_change(inkscape_get_repr(INKSCAPE, "desktop"), css_write, "style");
        for (const GSList *i = desktop->selection->itemList(); i != NULL; i = i->next) {
            /* last used styles for 3D box faces are stored separately */
            if (SP_IS_BOX3D_SIDE (i->data)) {
                const char * descr  = box3d_side_axes_string(SP_BOX3D_SIDE(i->data));
                if (descr != NULL) {
                    gchar *style_grp = g_strconcat ("desktop.", descr, NULL);
                    sp_repr_css_change(inkscape_get_repr(INKSCAPE, style_grp), css_write, "style");
                    g_free (style_grp);
                }
            }
        }
        sp_repr_css_attr_unref(css_write);
    }

    if (!change)
        return;

// 2. Emit signal
    bool intercepted = desktop->_set_style_signal.emit(css);

/** \todo
 * FIXME: in set_style, compensate pattern and gradient fills, stroke width,
 * rect corners, font size for the object's own transform so that pasting
 * fills does not depend on preserve/optimize.
 */

// 3. If nobody has intercepted the signal, apply the style to the selection
    if (!intercepted) {
        for (GSList const *i = desktop->selection->itemList(); i != NULL; i = i->next) {
            /// \todo if the style is text-only, apply only to texts?
            sp_desktop_apply_css_recursive(SP_OBJECT(i->data), css, true);
        }
    }
}


Generated by  Doxygen 1.6.0   Back to index