Logo Search packages:      
Sourcecode: inkscape version File versions

static void sp_offset_set ( SPObject object,
unsigned  key,
gchar const *  value 
) [static]

Set callback: the function that is called whenever a change is made to the description of the object.

Definition at line 332 of file sp-offset.cpp.

References bpath_to_liv_path(), SPOffset::isUpdating, SPOffset::knotSet, SPOffset::original, SPOffset::originalPath, SPOffset::rad, SPOffset::sourceDirty, SPOffset::sourceHref, SPOffset::sourceRef, sp_curve_new_from_bpath(), and sp_curve_unref().

Referenced by sp_offset_class_init().

{
    SPOffset *offset = SP_OFFSET (object);

    if ( offset->sourceDirty ) refresh_offset_source(offset);

    /* fixme: we should really collect updates */
    switch (key)
    {
        case SP_ATTR_INKSCAPE_ORIGINAL:
        case SP_ATTR_SODIPODI_ORIGINAL:
            if (value == NULL) {
            } else {
                if (offset->original) {
                    free (offset->original);
                    delete ((Path *) offset->originalPath);
                    offset->original = NULL;
                    offset->originalPath = NULL;
                }
                NArtBpath *bpath;
                SPCurve *curve;

                offset->original = strdup (value);

                bpath = sp_svg_read_path (offset->original);
                curve = sp_curve_new_from_bpath (bpath);    // curve se chargera de detruire bpath
                g_assert (curve != NULL);
                offset->originalPath = bpath_to_liv_path (SP_CURVE_BPATH(curve));
                sp_curve_unref (curve);

                offset->knotSet = false;
                if ( offset->isUpdating == false ) object->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG);
            }
            break;
        case SP_ATTR_INKSCAPE_RADIUS:
        case SP_ATTR_SODIPODI_RADIUS:
            if (!sp_svg_length_read_computed_absolute (value, &offset->rad)) {
                if (fabs (offset->rad) < 0.01)
                    offset->rad = (offset->rad < 0) ? -0.01 : 0.01;
                offset->knotSet = false; // knotset=false because it's not set from the context
            }
            if ( offset->isUpdating == false ) object->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG);
            break;
        case SP_ATTR_INKSCAPE_HREF:
        case SP_ATTR_XLINK_HREF:
            if ( value == NULL ) {
                sp_offset_quit_listening(offset);
                if ( offset->sourceHref ) g_free(offset->sourceHref);
                offset->sourceHref = NULL;
                offset->sourceRef->detach();
            } else {
                if ( offset->sourceHref && ( strcmp(value, offset->sourceHref) == 0 ) ) {
                } else {
                    if ( offset->sourceHref ) g_free(offset->sourceHref);
                    offset->sourceHref = g_strdup(value);
                    try {
                        offset->sourceRef->attach(Inkscape::URI(value));
                    } catch (Inkscape::BadURIException &e) {
                        g_warning("%s", e.what());
                        offset->sourceRef->detach();
                    }
                }
            }
            break;
        default:
            if (((SPObjectClass *) parent_class)->set)
                ((SPObjectClass *) parent_class)->set (object, key, value);
            break;
    }
}


Generated by  Doxygen 1.6.0   Back to index