static void sp_item_create_link(GtkMenuItem *menuitem, SPItem *item) { g_assert(SP_IS_ITEM(item)); g_assert(!SP_IS_ANCHOR(item)); SPDesktop *desktop = (SPDesktop*)gtk_object_get_data(GTK_OBJECT(menuitem), "desktop"); g_return_if_fail(desktop != NULL); Inkscape::XML::Document *xml_doc = sp_document_repr_doc(desktop->doc()); Inkscape::XML::Node *repr = xml_doc->createElement("svg:a"); SP_OBJECT_REPR(SP_OBJECT_PARENT(item))->addChild(repr, SP_OBJECT_REPR(item)); SPObject *object = SP_OBJECT_DOCUMENT(item)->getObjectByRepr(repr); g_return_if_fail(SP_IS_ANCHOR(object)); const char *id = SP_OBJECT_REPR(item)->attribute("id"); Inkscape::XML::Node *child = SP_OBJECT_REPR(item)->duplicate(xml_doc); SP_OBJECT(item)->deleteObject(false); repr->addChild(child, NULL); child->setAttribute("id", id); Inkscape::GC::release(repr); Inkscape::GC::release(child); sp_document_done(SP_OBJECT_DOCUMENT(object), SP_VERB_NONE, _("Create link")); sp_object_attributes_dialog(object, "SPAnchor"); sp_desktop_selection(desktop)->set(SP_ITEM(object)); }
// Create a mask element (using passed elements), add it to <defs> const gchar * sp_clippath_create (GSList *reprs, SPDocument *document, Geom::Matrix const* applyTransform) { Inkscape::XML::Node *defsrepr = SP_OBJECT_REPR (SP_DOCUMENT_DEFS (document)); Inkscape::XML::Document *xml_doc = sp_document_repr_doc(document); Inkscape::XML::Node *repr = xml_doc->createElement("svg:clipPath"); repr->setAttribute("clipPathUnits", "userSpaceOnUse"); defsrepr->appendChild(repr); const gchar *id = repr->attribute("id"); SPObject *clip_path_object = document->getObjectById(id); for (GSList *it = reprs; it != NULL; it = it->next) { Inkscape::XML::Node *node = (Inkscape::XML::Node *)(it->data); SPItem *item = SP_ITEM(clip_path_object->appendChildRepr(node)); if (NULL != applyTransform) { Geom::Matrix transform (item->transform); transform *= (*applyTransform); sp_item_write_transform(item, SP_OBJECT_REPR(item), transform); } } Inkscape::GC::release(repr); return id; }
static Inkscape::XML::Node * sp_textpath_write(SPObject *object, Inkscape::XML::Document *xml_doc, Inkscape::XML::Node *repr, guint flags) { SPTextPath *textpath = SP_TEXTPATH(object); if ((flags & SP_OBJECT_WRITE_BUILD) && !repr) { repr = xml_doc->createElement("svg:textPath"); } textpath->attributes.writeTo(repr); if (textpath->startOffset._set) { if (textpath->startOffset.unit == SVGLength::PERCENT) { Inkscape::SVGOStringStream os; os << (textpath->startOffset.computed * 100.0) << "%"; SP_OBJECT_REPR(textpath)->setAttribute("startOffset", os.str().c_str()); } else { /* FIXME: This logic looks rather undesirable if e.g. startOffset is to be in ems. */ sp_repr_set_svg_double(repr, "startOffset", textpath->startOffset.computed); } } if ( textpath->sourcePath->sourceHref ) repr->setAttribute("xlink:href", textpath->sourcePath->sourceHref); if ( flags&SP_OBJECT_WRITE_BUILD ) { GSList *l = NULL; for (SPObject* child = sp_object_first_child(object) ; child != NULL ; child = SP_OBJECT_NEXT(child) ) { Inkscape::XML::Node* c_repr=NULL; if ( SP_IS_TSPAN(child) || SP_IS_TREF(child) ) { c_repr = child->updateRepr(xml_doc, NULL, flags); } else if ( SP_IS_TEXTPATH(child) ) { //c_repr = child->updateRepr(xml_doc, NULL, flags); // shouldn't happen } else if ( SP_IS_STRING(child) ) { c_repr = xml_doc->createTextNode(SP_STRING(child)->string.c_str()); } if ( c_repr ) l = g_slist_prepend(l, c_repr); } while ( l ) { repr->addChild((Inkscape::XML::Node *) l->data, NULL); Inkscape::GC::release((Inkscape::XML::Node *) l->data); l = g_slist_remove(l, l->data); } } else { for (SPObject* child = sp_object_first_child(object) ; child != NULL ; child = SP_OBJECT_NEXT(child) ) { if ( SP_IS_TSPAN(child) || SP_IS_TREF(child) ) { child->updateRepr(flags); } else if ( SP_IS_TEXTPATH(child) ) { //c_repr = child->updateRepr(xml_doc, NULL, flags); // shouldn't happen } else if ( SP_IS_STRING(child) ) { SP_OBJECT_REPR(child)->setContent(SP_STRING(child)->string.c_str()); } } } if (((SPObjectClass *) textpath_parent_class)->write) ((SPObjectClass *) textpath_parent_class)->write(object, xml_doc, repr, flags); return repr; }
void sp_selected_path_reverse(SPDesktop *desktop) { Inkscape::Selection *selection = sp_desktop_selection(desktop); GSList *items = (GSList *) selection->itemList(); if (!items) { sp_desktop_message_stack(desktop)->flash(Inkscape::WARNING_MESSAGE, _("Select <b>path(s)</b> to reverse.")); return; } // set "busy" cursor desktop->setWaitingCursor(); bool did = false; desktop->messageStack()->flash(Inkscape::IMMEDIATE_MESSAGE, _("Reversing paths...")); for (GSList *i = items; i != NULL; i = i->next) { if (!SP_IS_PATH(i->data)) continue; did = true; SPPath *path = SP_PATH(i->data); SPCurve *rcurve = sp_path_get_curve_reference(path)->create_reverse(); gchar *str = sp_svg_write_path(rcurve->get_pathvector()); if ( sp_lpe_item_has_path_effect_recursive(SP_LPE_ITEM(path)) ) { SP_OBJECT_REPR(path)->setAttribute("inkscape:original-d", str); } else { SP_OBJECT_REPR(path)->setAttribute("d", str); } g_free(str); rcurve->unref(); // reverse nodetypes order (Bug #179866) gchar *nodetypes = g_strdup(SP_OBJECT_REPR(path)->attribute("sodipodi:nodetypes")); if ( nodetypes ) { SP_OBJECT_REPR(path)->setAttribute("sodipodi:nodetypes", g_strreverse(nodetypes)); g_free(nodetypes); } } desktop->clearWaitingCursor(); if (did) { sp_document_done(sp_desktop_document(desktop), SP_VERB_SELECTION_REVERSE, _("Reverse path")); } else { sp_desktop_message_stack(desktop)->flash(Inkscape::ERROR_MESSAGE, _("<b>No paths</b> to reverse in the selection.")); } }
static void sp_conn_end_deleted(SPObject *, SPObject *const owner, unsigned const handle_ix) { // todo: The first argument is the deleted object, or just NULL if // called by sp_conn_end_detach. g_return_if_fail(handle_ix < 2); char const * const attr_strs[] = {"inkscape:connection-start", "inkscape:connection-start-point", "inkscape:connection-end", "inkscape:connection-end-point"}; SP_OBJECT_REPR(owner)->setAttribute(attr_strs[2*handle_ix], NULL); SP_OBJECT_REPR(owner)->setAttribute(attr_strs[2*handle_ix+1], NULL); /* I believe this will trigger sp_conn_end_href_changed. */ }
bool item_attr_match (SPItem *item, const gchar *name, bool exact) { if (SP_OBJECT_REPR (item) == NULL) return false; if (exact) { const gchar *attr_value = (SP_OBJECT_REPR (item))->attribute(name); return ((bool) (attr_value != NULL)); } else { return SP_OBJECT_REPR (item)->matchAttributeName(name); } }
Inkscape::XML::Node * Parameter::document_param_node (SPDocument * doc) { Inkscape::XML::Document *xml_doc = sp_document_repr_doc(doc); Inkscape::XML::Node * defs = SP_OBJECT_REPR(SP_DOCUMENT_DEFS(doc)); Inkscape::XML::Node * params = NULL; GQuark const name_quark = g_quark_from_string("inkscape:extension-params"); for (Inkscape::XML::Node * child = defs->firstChild(); child != NULL; child = child->next()) { if ((GQuark)child->code() == name_quark && !strcmp(child->attribute("extension"), extension->get_id())) { params = child; break; } } if (params == NULL) { params = xml_doc->createElement("inkscape:extension-param"); params->setAttribute("extension", extension->get_id()); defs->appendChild(params); Inkscape::GC::release(params); } return params; }
bool item_style_match (SPItem *item, const gchar *text, bool exact) { if (SP_OBJECT_REPR (item) == NULL) return false; const gchar *item_text = (SP_OBJECT_REPR (item))->attribute("style"); if (item_text == NULL) return false; if (exact) { return ((bool) !strcmp(item_text, text)); } else { return ((bool) (strstr(item_text, text) != NULL)); } }
static void sp_fill_style_widget_fill_rule_activate (GtkWidget *w, SPWidget *spw) { const GSList *items, *i, *r; GSList *reprs; SPCSSAttr *css; if (g_object_get_data (G_OBJECT (spw), "update")) return; if (spw->inkscape) { reprs = NULL; items = sp_widget_get_item_list (spw); for (i = items; i != NULL; i = i->next) { reprs = g_slist_prepend (reprs, SP_OBJECT_REPR (i->data)); } } else { reprs = g_slist_prepend (NULL, spw->repr); items = NULL; } css = sp_repr_css_attr_new (); sp_repr_css_set_property (css, "fill-rule", (const gchar *)g_object_get_data (G_OBJECT (w), "fill-rule")); for (r = reprs; r != NULL; r = r->next) { sp_repr_css_change_recursive ((SPRepr *) r->data, css, "style"); } sp_repr_css_attr_unref (css); if (spw->inkscape) sp_document_done (SP_WIDGET_DOCUMENT (spw)); g_slist_free (reprs); }
static void sp_arc_modified (SPObject *object, guint flags) { if (flags & SP_OBJECT_MODIFIED_FLAG) { sp_arc_set_elliptical_path_attribute (SP_ARC (object), SP_OBJECT_REPR (object)); } if (((SPObjectClass *) arc_parent_class)->modified) ((SPObjectClass *) arc_parent_class)->modified (object, flags); }
void LPEObjectReference::start_listening(LivePathEffectObject* to) { if ( to == NULL ) { return; } lpeobject = to; lpeobject_repr = SP_OBJECT_REPR(to); _delete_connection = to->connectDelete(sigc::bind(sigc::ptr_fun(&lpeobjectreference_delete_self), this)); _modified_connection = to->connectModified(sigc::bind<2>(sigc::ptr_fun(&lpeobjectreference_source_modified), this)); }
bool item_id_match (SPItem *item, const gchar *id, bool exact) { if (SP_OBJECT_REPR (item) == NULL) return false; if (SP_IS_STRING(item)) // SPStrings have "on demand" ids which are useless for searching return false; const gchar *item_id = (SP_OBJECT_REPR (item))->attribute("id"); if (item_id == NULL) return false; if (exact) { return ((bool) !strcmp(item_id, id)); } else { // g_print ("strstr: %s %s: %s\n", item_id, id, strstr(item_id, id) != NULL? "yes":"no"); return ((bool) (strstr(item_id, id) != NULL)); } }
/* * \brief Writes it's settings to an incoming repr object, if any */ static Inkscape::XML::Node * sp_desc_write(SPObject *object, Inkscape::XML::Document *doc, Inkscape::XML::Node *repr, guint flags) { if (!repr) { repr = SP_OBJECT_REPR (object)->duplicate(doc); } if (((SPObjectClass *) desc_parent_class)->write) ((SPObjectClass *) desc_parent_class)->write(object, doc, repr, flags); return repr; }
void sp_textpath_to_text(SPObject *tp) { SPObject *text = SP_OBJECT_PARENT(tp); NRRect bbox; sp_item_invoke_bbox(SP_ITEM(text), &bbox, sp_item_i2doc_affine(SP_ITEM(text)), TRUE); Geom::Point xy(bbox.x0, bbox.y0); // make a list of textpath children GSList *tp_reprs = NULL; for (SPObject *o = SP_OBJECT(tp)->firstChild() ; o != NULL; o = o->next) { tp_reprs = g_slist_prepend(tp_reprs, SP_OBJECT_REPR(o)); } for ( GSList *i = tp_reprs ; i ; i = i->next ) { // make a copy of each textpath child Inkscape::XML::Node *copy = ((Inkscape::XML::Node *) i->data)->duplicate(SP_OBJECT_REPR(text)->document()); // remove the old repr from under textpath SP_OBJECT_REPR(tp)->removeChild((Inkscape::XML::Node *) i->data); // put its copy under text SP_OBJECT_REPR(text)->addChild(copy, NULL); // fixme: copy id } //remove textpath tp->deleteObject(); g_slist_free(tp_reprs); // set x/y on text /* fixme: Yuck, is this really the right test? */ if (xy[Geom::X] != 1e18 && xy[Geom::Y] != 1e18) { sp_repr_set_svg_double(SP_OBJECT_REPR(text), "x", xy[Geom::X]); sp_repr_set_svg_double(SP_OBJECT_REPR(text), "y", xy[Geom::Y]); } }
void text_remove_all_kerns_recursively(SPObject *o) { SP_OBJECT_REPR(o)->setAttribute("dx", NULL); SP_OBJECT_REPR(o)->setAttribute("dy", NULL); SP_OBJECT_REPR(o)->setAttribute("rotate", NULL); // if x contains a list, leave only the first value gchar *x = (gchar *) SP_OBJECT_REPR(o)->attribute("x"); if (x) { gchar **xa_space = g_strsplit(x, " ", 0); gchar **xa_comma = g_strsplit(x, ",", 0); if (xa_space && *xa_space && *(xa_space + 1)) { SP_OBJECT_REPR(o)->setAttribute("x", g_strdup(*xa_space)); } else if (xa_comma && *xa_comma && *(xa_comma + 1)) { SP_OBJECT_REPR(o)->setAttribute("x", g_strdup(*xa_comma)); } g_strfreev(xa_space); g_strfreev(xa_comma); } for (SPObject *i = sp_object_first_child(o); i != NULL; i = SP_OBJECT_NEXT(i)) { text_remove_all_kerns_recursively(i); } }
/* function which evaluates if item should be displayed */ bool sp_item_evaluate(SPItem const *item) { Inkscape::XML::Node *grepr = SP_OBJECT_REPR (item); for ( unsigned int i = 0 ; i < sizeof(_condition_handlers)/sizeof(_condition_handlers[0]) ; i++ ) { gchar const *value = grepr->attribute(_condition_handlers[i].attribute); if ( NULL == value ) continue; if (!_condition_handlers[i].evaluator(item, value)) return false; } return true; }
static Inkscape::XML::Node * sp_line_write (SPObject *object, Inkscape::XML::Document *xml_doc, Inkscape::XML::Node *repr, guint flags) { SPLine *line = SP_LINE (object); if ((flags & SP_OBJECT_WRITE_BUILD) && !repr) { repr = xml_doc->createElement("svg:line"); } if (repr != SP_OBJECT_REPR (object)) { repr->mergeFrom(SP_OBJECT_REPR (object), "id"); } sp_repr_set_svg_double(repr, "x1", line->x1.computed); sp_repr_set_svg_double(repr, "y1", line->y1.computed); sp_repr_set_svg_double(repr, "x2", line->x2.computed); sp_repr_set_svg_double(repr, "y2", line->y2.computed); if (((SPObjectClass *) (parent_class))->write) ((SPObjectClass *) (parent_class))->write (object, xml_doc, repr, flags); return repr; }
/** * Writes its settings to an incoming repr object, if any. */ static Inkscape::XML::Node * sp_feTile_write(SPObject *object, Inkscape::XML::Document *doc, Inkscape::XML::Node *repr, guint flags) { /* TODO: Don't just clone, but create a new repr node and write all * relevant values into it */ if (!repr) { repr = SP_OBJECT_REPR(object)->duplicate(doc); } if (((SPObjectClass *) feTile_parent_class)->write) { ((SPObjectClass *) feTile_parent_class)->write(object, doc, repr, flags); } return repr; }
static void sp_text_edit_dialog_apply( GtkButton */*button*/, GtkWidget *dlg ) { g_object_set_data (G_OBJECT (dlg), "blocked", GINT_TO_POINTER (TRUE)); GtkWidget *apply = (GtkWidget*)g_object_get_data (G_OBJECT (dlg), "apply"); GtkWidget *def = (GtkWidget*)g_object_get_data (G_OBJECT (dlg), "default"); SPDesktop *desktop = SP_ACTIVE_DESKTOP; unsigned items = 0; const GSList *item_list = sp_desktop_selection(desktop)->itemList(); SPCSSAttr *css = sp_get_text_dialog_style (); sp_desktop_set_style(desktop, css, true); for (; item_list != NULL; item_list = item_list->next) { // apply style to the reprs of all text objects in the selection if (SP_IS_TEXT (item_list->data)) { // backwards compatibility: SP_OBJECT_REPR(item_list->data)->setAttribute("sodipodi:linespacing", sp_repr_css_property (css, "line-height", NULL)); ++items; } else if (SP_IS_FLOWTEXT (item_list->data)) // no need to set sodipodi:linespacing, because Inkscape never supported it on flowtext ++items; } if (items == 0) { // no text objects; apply style to prefs for new objects Inkscape::Preferences *prefs = Inkscape::Preferences::get(); prefs->mergeStyle("/tools/text/style", css); gtk_widget_set_sensitive (def, FALSE); } else if (items == 1) { /* exactly one text object; now set its text, too */ SPItem *item = sp_desktop_selection(SP_ACTIVE_DESKTOP)->singleItem(); if (SP_IS_TEXT (item) || SP_IS_FLOWTEXT(item)) { sp_text_edit_dialog_update_object_text (item); } } // complete the transaction sp_document_done (sp_desktop_document (SP_ACTIVE_DESKTOP), SP_VERB_CONTEXT_TEXT, _("Set text style")); gtk_widget_set_sensitive (apply, FALSE); sp_repr_css_attr_unref (css); g_object_set_data (G_OBJECT (dlg), "blocked", GINT_TO_POINTER (FALSE)); }
static Inkscape::XML::Node * sp_tspan_write(SPObject *object, Inkscape::XML::Document *xml_doc, Inkscape::XML::Node *repr, guint flags) { SPTSpan *tspan = SP_TSPAN(object); if ((flags & SP_OBJECT_WRITE_BUILD) && !repr) { repr = xml_doc->createElement("svg:tspan"); } tspan->attributes.writeTo(repr); if ( flags&SP_OBJECT_WRITE_BUILD ) { GSList *l = NULL; for (SPObject* child = sp_object_first_child(object) ; child != NULL ; child = SP_OBJECT_NEXT(child) ) { Inkscape::XML::Node* c_repr=NULL; if ( SP_IS_TSPAN(child) || SP_IS_TREF(child) ) { c_repr = child->updateRepr(xml_doc, NULL, flags); } else if ( SP_IS_TEXTPATH(child) ) { //c_repr = child->updateRepr(xml_doc, NULL, flags); // shouldn't happen } else if ( SP_IS_STRING(child) ) { c_repr = xml_doc->createTextNode(SP_STRING(child)->string.c_str()); } if ( c_repr ) l = g_slist_prepend(l, c_repr); } while ( l ) { repr->addChild((Inkscape::XML::Node *) l->data, NULL); Inkscape::GC::release((Inkscape::XML::Node *) l->data); l = g_slist_remove(l, l->data); } } else { for (SPObject* child = sp_object_first_child(object) ; child != NULL ; child = SP_OBJECT_NEXT(child) ) { if ( SP_IS_TSPAN(child) || SP_IS_TREF(child) ) { child->updateRepr(flags); } else if ( SP_IS_TEXTPATH(child) ) { //c_repr = child->updateRepr(xml_doc, NULL, flags); // shouldn't happen } else if ( SP_IS_STRING(child) ) { SP_OBJECT_REPR(child)->setContent(SP_STRING(child)->string.c_str()); } } } if (((SPObjectClass *) tspan_parent_class)->write) ((SPObjectClass *) tspan_parent_class)->write(object, xml_doc, repr, flags); return repr; }
/** * Writes its settings to an incoming repr object, if any. */ static Inkscape::XML::Node * sp_feTurbulence_write(SPObject *object, Inkscape::XML::Document *doc, Inkscape::XML::Node *repr, guint flags) { /* TODO: Don't just clone, but create a new repr node and write all * relevant values into it */ if (!repr) { repr = SP_OBJECT_REPR(object)->duplicate(doc); } if (((SPObjectClass *) feTurbulence_parent_class)->write) { ((SPObjectClass *) feTurbulence_parent_class)->write(object, doc, repr, flags); } /* turbulence doesn't take input */ repr->setAttribute("in", 0); return repr; }
/** * Writes its settings to an incoming repr object, if any. */ static Inkscape::XML::Node * sp_feImage_write(SPObject *object, Inkscape::XML::Document *doc, Inkscape::XML::Node *repr, guint flags) { // Inkscape-only object, not copied during an "plain SVG" dump: if (flags & SP_OBJECT_WRITE_EXT) { if (repr) { // is this sane? //repr->mergeFrom(SP_OBJECT_REPR(object), "id"); } else { repr = SP_OBJECT_REPR(object)->duplicate(doc); } } if (((SPObjectClass *) feImage_parent_class)->write) { ((SPObjectClass *) feImage_parent_class)->write(object, doc, repr, flags); } return repr; }
void PathEffect::processPathEffects (SPDocument * doc, Inkscape::XML::Node * path) { gchar const * patheffectlist = path->attribute("inkscape:path-effects"); if (patheffectlist == NULL) return; gchar ** patheffects = g_strsplit(patheffectlist, ";", 128); Inkscape::XML::Node * defs = SP_OBJECT_REPR(SP_DOCUMENT_DEFS(doc)); for (int i = 0; patheffects[i] != NULL && i < 128; i++) { gchar * patheffect = patheffects[i]; // This is weird, they should all be references... but anyway if (patheffect[0] != '#') continue; Inkscape::XML::Node * prefs = sp_repr_lookup_child(defs, "id", &(patheffect[1])); if (prefs == NULL) { continue; } gchar const * ext_id = prefs->attribute("extension"); if (ext_id == NULL) { continue; } Inkscape::Extension::PathEffect * peffect; peffect = dynamic_cast<Inkscape::Extension::PathEffect *>(Inkscape::Extension::db.get(ext_id)); if (peffect != NULL) { continue; } peffect->processPath(doc, path, prefs); } g_strfreev(patheffects); return; }
static Inkscape::XML::Node * sp_flowpara_write (SPObject *object, Inkscape::XML::Document *xml_doc, Inkscape::XML::Node *repr, guint flags) { // SPFlowpara *group = SP_FLOWPARA (object); if ( flags&SP_OBJECT_WRITE_BUILD ) { if ( repr == NULL ) repr = xml_doc->createElement("svg:flowPara"); GSList *l = NULL; for (SPObject* child = sp_object_first_child(object) ; child != NULL ; child = SP_OBJECT_NEXT(child) ) { Inkscape::XML::Node* c_repr=NULL; if ( SP_IS_FLOWTSPAN (child) ) { c_repr = child->updateRepr(xml_doc, NULL, flags); } else if ( SP_IS_FLOWPARA (child) ) { c_repr = child->updateRepr(xml_doc, NULL, flags); } else if ( SP_IS_STRING(child) ) { c_repr = xml_doc->createTextNode(SP_STRING(child)->string.c_str()); } if ( c_repr ) l = g_slist_prepend (l, c_repr); } while ( l ) { repr->addChild((Inkscape::XML::Node *) l->data, NULL); Inkscape::GC::release((Inkscape::XML::Node *) l->data); l = g_slist_remove (l, l->data); } } else { for (SPObject* child = sp_object_first_child(object) ; child != NULL ; child = SP_OBJECT_NEXT(child) ) { if ( SP_IS_FLOWTSPAN (child) ) { child->updateRepr(flags); } else if ( SP_IS_FLOWPARA (child) ) { child->updateRepr(flags); } else if ( SP_IS_STRING(child) ) { SP_OBJECT_REPR (child)->setContent(SP_STRING(child)->string.c_str()); } } } if (((SPObjectClass *) (flowpara_parent_class))->write) ((SPObjectClass *) (flowpara_parent_class))->write (object, xml_doc, repr, flags); return repr; }
GSList * all_items (SPObject *r, GSList *l, bool hidden, bool locked) { SPDesktop *desktop = SP_ACTIVE_DESKTOP; if (SP_IS_DEFS(r)) return l; // we're not interested in items in defs if (!strcmp (SP_OBJECT_REPR (r)->name(), "svg:metadata")) return l; // we're not interested in metadata for (SPObject *child = sp_object_first_child(r); child; child = SP_OBJECT_NEXT (child)) { if (SP_IS_ITEM (child) && !SP_OBJECT_IS_CLONED (child) && !desktop->isLayer(SP_ITEM(child))) { if ((hidden || !desktop->itemIsHidden(SP_ITEM(child))) && (locked || !SP_ITEM(child)->isLocked())) { l = g_slist_prepend (l, child); } } l = all_items (child, l, hidden, locked); } return l; }
bool item_text_match (SPItem *item, const gchar *text, bool exact) { if (SP_OBJECT_REPR (item) == NULL) return false; if (SP_IS_TEXT(item) || SP_IS_FLOWTEXT(item)) { const gchar *item_text = sp_te_get_string_multiline (item); if (item_text == NULL) return false; bool ret; if (exact) { ret = ((bool) !strcasecmp(item_text, text)); } else { //FIXME: strcasestr ret = ((bool) (strstr(item_text, text) != NULL)); } g_free ((void*) item_text); return ret; } return false; }
/** * Writes its settings to an incoming repr object, if any. */ static Inkscape::XML::Node * sp_fepointlight_write(SPObject *object, Inkscape::XML::Document *doc, Inkscape::XML::Node *repr, guint flags) { SPFePointLight *fepointlight = SP_FEPOINTLIGHT(object); if (!repr) { repr = SP_OBJECT_REPR(object)->duplicate(doc); } if (fepointlight->x_set) sp_repr_set_css_double(repr, "x", fepointlight->x); if (fepointlight->y_set) sp_repr_set_css_double(repr, "y", fepointlight->y); if (fepointlight->z_set) sp_repr_set_css_double(repr, "z", fepointlight->z); if (((SPObjectClass *) fePointLight_parent_class)->write) { ((SPObjectClass *) fePointLight_parent_class)->write(object, doc, repr, flags); } return repr; }
static Inkscape::XML::Node *sp_glyph_write(SPObject *object, Inkscape::XML::Document *xml_doc, Inkscape::XML::Node *repr, guint flags) { // SPGlyph *glyph = SP_GLYPH(object); if ((flags & SP_OBJECT_WRITE_BUILD) && !repr) { repr = xml_doc->createElement("svg:glyph"); } /* I am commenting out this part because I am not certain how does it work. I will have to study it later. Juca repr->setAttribute("unicode", glyph->unicode); repr->setAttribute("glyph-name", glyph->glyph_name); repr->setAttribute("d", glyph->d); sp_repr_set_svg_double(repr, "orientation", (double) glyph->orientation); sp_repr_set_svg_double(repr, "arabic-form", (double) glyph->arabic_form); repr->setAttribute("lang", glyph->lang); sp_repr_set_svg_double(repr, "horiz-adv-x", glyph->horiz_adv_x); sp_repr_set_svg_double(repr, "vert-origin-x", glyph->vert_origin_x); sp_repr_set_svg_double(repr, "vert-origin-y", glyph->vert_origin_y); sp_repr_set_svg_double(repr, "vert-adv-y", glyph->vert_adv_y); */ if (repr != SP_OBJECT_REPR(object)) { COPY_ATTR(repr, object->repr, "unicode"); COPY_ATTR(repr, object->repr, "glyph-name"); COPY_ATTR(repr, object->repr, "d"); COPY_ATTR(repr, object->repr, "orientation"); COPY_ATTR(repr, object->repr, "arabic-form"); COPY_ATTR(repr, object->repr, "lang"); COPY_ATTR(repr, object->repr, "horiz-adv-x"); COPY_ATTR(repr, object->repr, "vert-origin-x"); COPY_ATTR(repr, object->repr, "vert-origin-y"); COPY_ATTR(repr, object->repr, "vert-adv-y"); } if (((SPObjectClass *) (parent_class))->write) { ((SPObjectClass *) (parent_class))->write(object, xml_doc, repr, flags); } return repr; }
static void sp_text_edit_dialog_apply (GtkButton *button, GtkWidget *dlg) { GtkWidget *apply, *def; SPText *text; SPRepr *repr; const GSList *item; unsigned items; g_object_set_data (G_OBJECT (dlg), "blocked", GINT_TO_POINTER (TRUE)); apply = (GtkWidget*)g_object_get_data (G_OBJECT (dlg), "apply"); def = (GtkWidget*)g_object_get_data (G_OBJECT (dlg), "default"); text = NULL; items = 0; item = sp_selection_item_list(SP_DT_SELECTION (SP_ACTIVE_DESKTOP)); for (; item != NULL; item = item->next) { if (!SP_IS_TEXT (item->data)) continue; text = SP_TEXT(item->data); repr = SP_OBJECT_REPR (text); sp_text_edit_dialog_update_object (NULL, repr); ++items; } if (items == 1) { sp_text_edit_dialog_update_object (text, NULL); } else if (items == 0) { repr = inkscape_get_repr (INKSCAPE, "tools.text"); sp_text_edit_dialog_update_object (NULL, repr); gtk_widget_set_sensitive (def, FALSE); } gtk_widget_set_sensitive (apply, FALSE); g_object_set_data (G_OBJECT (dlg), "blocked", NULL); }
static void sp_image_menu(SPObject *object, SPDesktop *desktop, GtkMenu *m) { SPItem *item = SP_ITEM(object); GtkWidget *w; /* Link dialog */ w = gtk_menu_item_new_with_mnemonic(_("Image _Properties")); gtk_object_set_data(GTK_OBJECT(w), "desktop", desktop); gtk_signal_connect(GTK_OBJECT(w), "activate", GTK_SIGNAL_FUNC(sp_image_image_properties), item); gtk_widget_show(w); gtk_menu_append(GTK_MENU(m), w); w = gtk_menu_item_new_with_mnemonic(_("Edit Externally...")); gtk_object_set_data(GTK_OBJECT(w), "desktop", desktop); gtk_signal_connect(GTK_OBJECT(w), "activate", GTK_SIGNAL_FUNC(sp_image_image_edit), item); gtk_widget_show(w); gtk_menu_append(GTK_MENU(m), w); Inkscape::XML::Node *ir = SP_OBJECT_REPR(object); const gchar *href = ir->attribute("xlink:href"); if ( (!href) || ((strncmp(href, "data:", 5) == 0)) ) { gtk_widget_set_sensitive( w, FALSE ); } }