std::string NodeTraits::get_type_string(Inkscape::XML::Node const &node) { std::string name; switch (node.type()) { case Inkscape::XML::TEXT_NODE: name = "string"; break; case Inkscape::XML::ELEMENT_NODE: { char const *const sptype = node.attribute("sodipodi:type"); if (sptype) { name = sptype; } else { name = node.name(); } break; } default: name = ""; break; } return name; }
/** * Fetches document from URI, or creates new, if NULL; public document * appears in document list. */ SPDocument * sp_document_new(gchar const *uri, unsigned int keepalive, bool make_new) { SPDocument *doc; Inkscape::XML::Document *rdoc; gchar *base = NULL; gchar *name = NULL; if (uri) { Inkscape::XML::Node *rroot; gchar *s, *p; /* Try to fetch repr from file */ rdoc = sp_repr_read_file(uri, SP_SVG_NS_URI); /* If file cannot be loaded, return NULL without warning */ if (rdoc == NULL) return NULL; rroot = rdoc->root(); /* If xml file is not svg, return NULL without warning */ /* fixme: destroy document */ if (strcmp(rroot->name(), "svg:svg") != 0) return NULL; s = g_strdup(uri); p = strrchr(s, '/'); if (p) { name = g_strdup(p + 1); p[1] = '\0'; base = g_strdup(s); } else { base = NULL; name = g_strdup(uri); } g_free(s); } else { rdoc = sp_repr_document_new("svg:svg"); } if (make_new) { base = NULL; uri = NULL; name = g_strdup_printf(_("New document %d"), ++doc_count); } //# These should be set by now g_assert(name); doc = sp_document_create(rdoc, uri, base, name, keepalive); g_free(base); g_free(name); return doc; }
Inkscape::XML::Node * Effect::find_menu (Inkscape::XML::Node * menustruct, const gchar *name) { if (menustruct == NULL) return NULL; for (Inkscape::XML::Node * child = menustruct; child != NULL; child = child->next()) { if (!strcmp(child->name(), name)) { return child; } Inkscape::XML::Node * firstchild = child->firstChild(); if (firstchild != NULL) { Inkscape::XML::Node *found = find_menu (firstchild, name); if (found) return found; } } return NULL; }
/** * Clears the gradient's svg:stop children from its repr. */ void sp_gradient_repr_clear_vector(SPGradient *gr) { Inkscape::XML::Node *repr = gr->getRepr(); /* Collect stops from original repr */ GSList *sl = NULL; for (Inkscape::XML::Node *child = repr->firstChild() ; child != NULL; child = child->next() ) { if (!strcmp(child->name(), "svg:stop")) { sl = g_slist_prepend(sl, child); } } /* Remove all stops */ while (sl) { /** \todo * fixme: This should work, unless we make gradient * into generic group. */ sp_repr_unparent((Inkscape::XML::Node *)sl->data); sl = g_slist_remove(sl, sl->data); } }
SPDocument * sp_document_new_from_mem(gchar const *buffer, gint length, unsigned int keepalive) { SPDocument *doc; Inkscape::XML::Document *rdoc; Inkscape::XML::Node *rroot; gchar *name; rdoc = sp_repr_read_mem(buffer, length, SP_SVG_NS_URI); /* If it cannot be loaded, return NULL without warning */ if (rdoc == NULL) return NULL; rroot = rdoc->root(); /* If xml file is not svg, return NULL without warning */ /* fixme: destroy document */ if (strcmp(rroot->name(), "svg:svg") != 0) return NULL; name = g_strdup_printf(_("Memory document %d"), ++doc_count); doc = sp_document_create(rdoc, NULL, NULL, name, keepalive); return doc; }
Effect::Effect (Inkscape::XML::Node * in_repr, Implementation::Implementation * in_imp) : Extension(in_repr, in_imp), _id_noprefs(Glib::ustring(get_id()) + ".noprefs"), _name_noprefs(Glib::ustring(_(get_name())) + _(" (No preferences)")), _verb(get_id(), get_name(), NULL, NULL, this, true), _verb_nopref(_id_noprefs.c_str(), _name_noprefs.c_str(), NULL, NULL, this, false), _menu_node(NULL), _workingDialog(true), _prefDialog(NULL) { Inkscape::XML::Node * local_effects_menu = NULL; // This is a weird hack if (!strcmp(this->get_id(), "org.inkscape.filter.dropshadow")) return; bool hidden = false; no_doc = false; no_live_preview = false; if (repr != NULL) { for (Inkscape::XML::Node *child = sp_repr_children(repr); child != NULL; child = child->next()) { if (!strcmp(child->name(), INKSCAPE_EXTENSION_NS "effect")) { if (child->attribute("needs-document") && !strcmp(child->attribute("needs-document"), "false")) { no_doc = true; } if (child->attribute("needs-live-preview") && !strcmp(child->attribute("needs-live-preview"), "false")) { no_live_preview = true; } for (Inkscape::XML::Node *effect_child = sp_repr_children(child); effect_child != NULL; effect_child = effect_child->next()) { if (!strcmp(effect_child->name(), INKSCAPE_EXTENSION_NS "effects-menu")) { // printf("Found local effects menu in %s\n", this->get_name()); local_effects_menu = sp_repr_children(effect_child); if (effect_child->attribute("hidden") && !strcmp(effect_child->attribute("hidden"), "true")) { hidden = true; } } if (!strcmp(effect_child->name(), INKSCAPE_EXTENSION_NS "menu-name") || !strcmp(effect_child->name(), INKSCAPE_EXTENSION_NS "_menu-name")) { // printf("Found local effects menu in %s\n", this->get_name()); _verb.set_name(sp_repr_children(effect_child)->content()); } if (!strcmp(effect_child->name(), INKSCAPE_EXTENSION_NS "menu-tip") || !strcmp(effect_child->name(), INKSCAPE_EXTENSION_NS "_menu-tip")) { // printf("Found local effects menu in %s\n", this->get_name()); _verb.set_tip(sp_repr_children(effect_child)->content()); } } // children of "effect" break; // there can only be one effect } // find "effect" } // children of "inkscape-extension" } // if we have an XML file if (INKSCAPE != NULL) { if (_effects_list == NULL) _effects_list = find_menu(inkscape_get_menus(INKSCAPE), EFFECTS_LIST); if (_filters_list == NULL) _filters_list = find_menu(inkscape_get_menus(INKSCAPE), FILTERS_LIST); } if ((_effects_list != NULL || _filters_list != NULL)) { Inkscape::XML::Document *xml_doc; xml_doc = _effects_list->document(); _menu_node = xml_doc->createElement("verb"); _menu_node->setAttribute("verb-id", this->get_id(), false); if (!hidden) { if (_filters_list && local_effects_menu && local_effects_menu->attribute("name") && !strcmp(local_effects_menu->attribute("name"), ("Filters"))) { merge_menu(_filters_list->parent(), _filters_list, sp_repr_children(local_effects_menu), _menu_node); } else if (_effects_list) { merge_menu(_effects_list->parent(), _effects_list, local_effects_menu, _menu_node); } } } return; }
void Effect::merge_menu (Inkscape::XML::Node * base, Inkscape::XML::Node * start, Inkscape::XML::Node * patern, Inkscape::XML::Node * mergee) { Glib::ustring mergename; Inkscape::XML::Node * tomerge = NULL; Inkscape::XML::Node * submenu = NULL; /* printf("Merge menu with '%s' '%s' '%s'\n", base != NULL ? base->name() : "NULL", patern != NULL ? patern->name() : "NULL", mergee != NULL ? mergee->name() : "NULL"); */ if (patern == NULL) { // Merge the verb name tomerge = mergee; mergename = _(this->get_name()); } else { gchar const * menuname = patern->attribute("name"); if (menuname == NULL) menuname = patern->attribute("_name"); if (menuname == NULL) return; Inkscape::XML::Document *xml_doc; xml_doc = base->document(); tomerge = xml_doc->createElement("submenu"); tomerge->setAttribute("name", menuname, false); mergename = _(menuname); } int position = -1; if (start != NULL) { Inkscape::XML::Node * menupass; for (menupass = start; menupass != NULL && strcmp(menupass->name(), "separator"); menupass = menupass->next()) { gchar const * compare_char = NULL; if (!strcmp(menupass->name(), "verb")) { gchar const * verbid = menupass->attribute("verb-id"); Inkscape::Verb * verb = Inkscape::Verb::getbyid(verbid); if (verb == NULL) { g_warning("Unable to find verb '%s' which is referred to in the menus.", verbid); continue; } compare_char = verb->get_name(); } else if (!strcmp(menupass->name(), "submenu")) { compare_char = menupass->attribute("name"); if (compare_char == NULL) compare_char = menupass->attribute("_name"); } position = menupass->position() + 1; /* This will cause us to skip tags we don't understand */ if (compare_char == NULL) { continue; } Glib::ustring compare(_(compare_char)); if (mergename == compare) { Inkscape::GC::release(tomerge); tomerge = NULL; submenu = menupass; break; } if (mergename < compare) { position = menupass->position(); break; } } // for menu items } // start != NULL if (tomerge != NULL) { base->appendChild(tomerge); Inkscape::GC::release(tomerge); if (position != -1) tomerge->setPosition(position); } if (patern != NULL) { if (submenu == NULL) submenu = tomerge; merge_menu(submenu, submenu->firstChild(), patern->firstChild(), mergee); } return; }
void text_put_on_path() { SPDesktop *desktop = SP_ACTIVE_DESKTOP; if (!desktop) return; Inkscape::Selection *selection = sp_desktop_selection(desktop); SPItem *text = text_or_flowtext_in_selection(selection); SPItem *shape = shape_in_selection(selection); Inkscape::XML::Document *xml_doc = sp_document_repr_doc(desktop->doc()); if (!text || !shape || g_slist_length((GSList *) selection->itemList()) != 2) { sp_desktop_message_stack(desktop)->flash(Inkscape::WARNING_MESSAGE, _("Select <b>a text and a path</b> to put text on path.")); return; } if (SP_IS_TEXT_TEXTPATH(text)) { sp_desktop_message_stack(desktop)->flash(Inkscape::ERROR_MESSAGE, _("This text object is <b>already put on a path</b>. Remove it from the path first. Use <b>Shift+D</b> to look up its path.")); return; } if (SP_IS_RECT(shape)) { // rect is the only SPShape which is not <path> yet, and thus SVG forbids us from putting text on it sp_desktop_message_stack(desktop)->flash(Inkscape::ERROR_MESSAGE, _("You cannot put text on a rectangle in this version. Convert rectangle to path first.")); return; } // if a flowed text is selected, convert it to a regular text object if (SP_IS_FLOWTEXT(text)) { if (!SP_FLOWTEXT(text)->layout.outputExists()) { sp_desktop_message_stack(desktop)-> flash(Inkscape::WARNING_MESSAGE, _("The flowed text(s) must be <b>visible</b> in order to be put on a path.")); } Inkscape::XML::Node *repr = SP_FLOWTEXT(text)->getAsText(); if (!repr) return; Inkscape::XML::Node *parent = SP_OBJECT_REPR(text)->parent(); parent->appendChild(repr); SPItem *new_item = (SPItem *) sp_desktop_document(desktop)->getObjectByRepr(repr); sp_item_write_transform(new_item, repr, text->transform); SP_OBJECT(new_item)->updateRepr(); Inkscape::GC::release(repr); text->deleteObject(); // delete the orignal flowtext sp_document_ensure_up_to_date(sp_desktop_document(desktop)); selection->clear(); text = new_item; // point to the new text } Inkscape::Text::Layout const *layout = te_get_layout(text); Inkscape::Text::Layout::Alignment text_alignment = layout->paragraphAlignment(layout->begin()); // remove transform from text, but recursively scale text's fontsize by the expansion SP_TEXT(text)->_adjustFontsizeRecursive (text, NR::expansion(SP_ITEM(text)->transform)); SP_OBJECT_REPR(text)->setAttribute("transform", NULL); // make a list of text children GSList *text_reprs = NULL; for (SPObject *o = SP_OBJECT(text)->children; o != NULL; o = o->next) { text_reprs = g_slist_prepend(text_reprs, SP_OBJECT_REPR(o)); } // create textPath and put it into the text Inkscape::XML::Node *textpath = xml_doc->createElement("svg:textPath"); // reference the shape textpath->setAttribute("xlink:href", g_strdup_printf("#%s", SP_OBJECT_REPR(shape)->attribute("id"))); if (text_alignment == Inkscape::Text::Layout::RIGHT) textpath->setAttribute("startOffset", "100%"); else if (text_alignment == Inkscape::Text::Layout::CENTER) textpath->setAttribute("startOffset", "50%"); SP_OBJECT_REPR(text)->addChild(textpath, NULL); for ( GSList *i = text_reprs ; i ; i = i->next ) { // Make a copy of each text child Inkscape::XML::Node *copy = ((Inkscape::XML::Node *) i->data)->duplicate(xml_doc); // We cannot have multiline in textpath, so remove line attrs from tspans if (!strcmp(copy->name(), "svg:tspan")) { copy->setAttribute("sodipodi:role", NULL); copy->setAttribute("x", NULL); copy->setAttribute("y", NULL); } // remove the old repr from under text SP_OBJECT_REPR(text)->removeChild((Inkscape::XML::Node *) i->data); // put its copy into under textPath textpath->addChild(copy, NULL); // fixme: copy id } // x/y are useless with textpath, and confuse Batik 1.5 SP_OBJECT_REPR(text)->setAttribute("x", NULL); SP_OBJECT_REPR(text)->setAttribute("y", NULL); sp_document_done(sp_desktop_document(desktop), SP_VERB_CONTEXT_TEXT, _("Put text on path")); g_slist_free(text_reprs); }
void sp_item_group_ungroup (SPGroup *group, GSList **children, bool do_done) { g_return_if_fail (group != NULL); g_return_if_fail (SP_IS_GROUP (group)); SPDocument *doc = group->document; SPRoot *root = doc->getRoot(); SPObject *defs = root->defs; SPItem *gitem = group; Inkscape::XML::Node *grepr = gitem->getRepr(); g_return_if_fail (!strcmp (grepr->name(), "svg:g") || !strcmp (grepr->name(), "svg:a") || !strcmp (grepr->name(), "svg:switch")); // this converts the gradient/pattern fill/stroke on the group, if any, to userSpaceOnUse gitem->adjust_paint_recursive (Geom::identity(), Geom::identity(), false); SPItem *pitem = SP_ITEM(gitem->parent); Inkscape::XML::Node *prepr = pitem->getRepr(); if (SP_IS_BOX3D(gitem)) { group = box3d_convert_to_group(SP_BOX3D(gitem)); gitem = group; } sp_lpe_item_remove_all_path_effects(SP_LPE_ITEM(group), false); /* Step 1 - generate lists of children objects */ GSList *items = NULL; GSList *objects = NULL; for (SPObject *child = group->firstChild() ; child; child = child->getNext() ) { if (SP_IS_ITEM (child)) { SPItem *citem = SP_ITEM (child); /* Merging of style */ // this converts the gradient/pattern fill/stroke, if any, to userSpaceOnUse; we need to do // it here _before_ the new transform is set, so as to use the pre-transform bbox citem->adjust_paint_recursive (Geom::identity(), Geom::identity(), false); sp_style_merge_from_dying_parent(child->style, gitem->style); /* * fixme: We currently make no allowance for the case where child is cloned * and the group has any style settings. * * (This should never occur with documents created solely with the current * version of inkscape without using the XML editor: we usually apply group * style changes to children rather than to the group itself.) * * If the group has no style settings, then * sp_style_merge_from_dying_parent should be a no-op. Otherwise (i.e. if * we change the child's style to compensate for its parent going away) * then those changes will typically be reflected in any clones of child, * whereas we'd prefer for Ungroup not to affect the visual appearance. * * The only way of preserving styling appearance in general is for child to * be put into a new group -- a somewhat surprising response to an Ungroup * command. We could add a new groupmode:transparent that would mostly * hide the existence of such groups from the user (i.e. editing behaves as * if the transparent group's children weren't in a group), though that's * extra complication & maintenance burden and this case is rare. */ child->updateRepr(); Inkscape::XML::Node *nrepr = child->getRepr()->duplicate(prepr->document()); // Merging transform Geom::Affine ctrans; Geom::Affine const g(gitem->transform); if (SP_IS_USE(citem) && sp_use_get_original (SP_USE(citem)) && sp_use_get_original( SP_USE(citem) )->parent == SP_OBJECT(group)) { // make sure a clone's effective transform is the same as was under group ctrans = g.inverse() * citem->transform * g; } else { // We should not apply the group's transformation to both a linked offset AND to its source if (SP_IS_OFFSET(citem)) { // Do we have an offset at hand (whether it's dynamic or linked)? SPItem *source = sp_offset_get_source(SP_OFFSET(citem)); // When dealing with a chain of linked offsets, the transformation of an offset will be // tied to the transformation of the top-most source, not to any of the intermediate // offsets. So let's find the top-most source while (source != NULL && SP_IS_OFFSET(source)) { source = sp_offset_get_source(SP_OFFSET(source)); } if (source != NULL && // If true then we must be dealing with a linked offset ... group->isAncestorOf(source) == false) { // ... of which the source is not in the same group ctrans = citem->transform * g; // then we should apply the transformation of the group to the offset } else { ctrans = citem->transform; } } else { ctrans = citem->transform * g; } } // FIXME: constructing a transform that would fully preserve the appearance of a // textpath if it is ungrouped with its path seems to be impossible in general // case. E.g. if the group was squeezed, to keep the ungrouped textpath squeezed // as well, we'll need to relink it to some "virtual" path which is inversely // stretched relative to the actual path, and then squeeze the textpath back so it // would both fit the actual path _and_ be squeezed as before. It's a bummer. // This is just a way to temporarily remember the transform in repr. When repr is // reattached outside of the group, the transform will be written more properly // (i.e. optimized into the object if the corresponding preference is set) gchar *affinestr=sp_svg_transform_write(ctrans); nrepr->setAttribute("transform", affinestr); g_free(affinestr); items = g_slist_prepend (items, nrepr); } else { Inkscape::XML::Node *nrepr = child->getRepr()->duplicate(prepr->document()); objects = g_slist_prepend (objects, nrepr); } } /* Step 2 - clear group */ // remember the position of the group gint pos = group->getRepr()->position(); // the group is leaving forever, no heir, clones should take note; its children however are going to reemerge group->deleteObject(true, false); /* Step 3 - add nonitems */ if (objects) { Inkscape::XML::Node *last_def = defs->getRepr()->lastChild(); while (objects) { Inkscape::XML::Node *repr = (Inkscape::XML::Node *) objects->data; if (!sp_repr_is_meta_element(repr)) { defs->getRepr()->addChild(repr, last_def); } Inkscape::GC::release(repr); objects = g_slist_remove (objects, objects->data); } } /* Step 4 - add items */ while (items) { Inkscape::XML::Node *repr = (Inkscape::XML::Node *) items->data; // add item prepr->appendChild(repr); // restore position; since the items list was prepended (i.e. reverse), we now add // all children at the same pos, which inverts the order once again repr->setPosition(pos > 0 ? pos : 0); // fill in the children list if non-null SPItem *item = static_cast<SPItem *>(doc->getObjectByRepr(repr)); item->doWriteTransform(repr, item->transform, NULL, false); Inkscape::GC::release(repr); if (children && SP_IS_ITEM (item)) *children = g_slist_prepend (*children, item); items = g_slist_remove (items, items->data); } if (do_done) { DocumentUndo::done(doc, SP_VERB_NONE, _("Ungroup")); } }
/** * \return The built module * \brief Creates a module from a Inkscape::XML::Document describing the module * \param doc The XML description of the module * * This function basically has two segments. The first is that it goes through the Repr tree * provided, and determines what kind of of module this is, and what kind of implementation to use. * All of these are then stored in two enums that are defined in this function. This makes it * easier to add additional types (which will happen in the future, I'm sure). * * Second, there is case statements for these enums. The first one is the type of module. This is * the one where the module is actually created. After that, then the implementation is applied to * get the load and unload functions. If there is no implementation then these are not set. This * case could apply to modules that are built in (like the SVG load/save functions). */ static Extension * build_from_reprdoc(Inkscape::XML::Document *doc, Implementation::Implementation *in_imp) { enum { MODULE_EXTENSION, MODULE_XSLT, /* MODULE_PLUGIN, */ MODULE_UNKNOWN_IMP } module_implementation_type = MODULE_UNKNOWN_IMP; enum { MODULE_INPUT, MODULE_OUTPUT, MODULE_FILTER, MODULE_PRINT, MODULE_PATH_EFFECT, MODULE_UNKNOWN_FUNC } module_functional_type = MODULE_UNKNOWN_FUNC; g_return_val_if_fail(doc != NULL, NULL); Inkscape::XML::Node *repr = doc->root(); if (strcmp(repr->name(), INKSCAPE_EXTENSION_NS "inkscape-extension")) { g_warning("Extension definition started with <%s> instead of <" INKSCAPE_EXTENSION_NS "inkscape-extension>. Extension will not be created. See http://wiki.inkscape.org/wiki/index.php/Extensions for reference.\n", repr->name()); return NULL; } Inkscape::XML::Node *child_repr = repr->firstChild(); while (child_repr != NULL) { char const *element_name = child_repr->name(); /* printf("Child: %s\n", child_repr->name()); */ if (!strcmp(element_name, INKSCAPE_EXTENSION_NS "input")) { module_functional_type = MODULE_INPUT; } else if (!strcmp(element_name, INKSCAPE_EXTENSION_NS "output")) { module_functional_type = MODULE_OUTPUT; } else if (!strcmp(element_name, INKSCAPE_EXTENSION_NS "effect")) { module_functional_type = MODULE_FILTER; } else if (!strcmp(element_name, INKSCAPE_EXTENSION_NS "print")) { module_functional_type = MODULE_PRINT; } else if (!strcmp(element_name, INKSCAPE_EXTENSION_NS "path-effect")) { module_functional_type = MODULE_PATH_EFFECT; } else if (!strcmp(element_name, INKSCAPE_EXTENSION_NS "script")) { module_implementation_type = MODULE_EXTENSION; } else if (!strcmp(element_name, INKSCAPE_EXTENSION_NS "xslt")) { module_implementation_type = MODULE_XSLT; #if 0 } else if (!strcmp(element_name, "plugin")) { module_implementation_type = MODULE_PLUGIN; #endif } //Inkscape::XML::Node *old_repr = child_repr; child_repr = child_repr->next(); //Inkscape::GC::release(old_repr); } Implementation::Implementation *imp; if (in_imp == NULL) { switch (module_implementation_type) { case MODULE_EXTENSION: { Implementation::Script *script = new Implementation::Script(); imp = static_cast<Implementation::Implementation *>(script); break; } case MODULE_XSLT: { Implementation::XSLT *xslt = new Implementation::XSLT(); imp = static_cast<Implementation::Implementation *>(xslt); break; } #if 0 case MODULE_PLUGIN: { Implementation::Plugin *plugin = new Implementation::Plugin(); imp = static_cast<Implementation::Implementation *>(plugin); break; } #endif default: { imp = NULL; break; } } } else { imp = in_imp; } Extension *module = NULL; switch (module_functional_type) { case MODULE_INPUT: { module = new Input(repr, imp); break; } case MODULE_OUTPUT: { module = new Output(repr, imp); break; } case MODULE_FILTER: { module = new Effect(repr, imp); break; } case MODULE_PRINT: { module = new Print(repr, imp); break; } case MODULE_PATH_EFFECT: { module = new PathEffect(repr, imp); break; } default: { break; } } return module; }
ParamComboBox::ParamComboBox(const gchar *name, const gchar *guitext, const gchar *desc, const Parameter::_scope_t scope, bool gui_hidden, const gchar *gui_tip, Inkscape::Extension::Extension *ext, Inkscape::XML::Node *xml) : Parameter(name, guitext, desc, scope, gui_hidden, gui_tip, ext) , _value(NULL) , _indent(0) , choices(NULL) { const char *xmlval = NULL; // the value stored in XML if (xml != NULL) { // Read XML tree to add enumeration items: for (Inkscape::XML::Node *node = xml->firstChild(); node; node = node->next()) { char const * chname = node->name(); if (!strcmp(chname, INKSCAPE_EXTENSION_NS "item") || !strcmp(chname, INKSCAPE_EXTENSION_NS "_item")) { Glib::ustring newguitext, newvalue; const char * contents = NULL; if (node->firstChild()) { contents = node->firstChild()->content(); } if (contents != NULL) { // don't translate when 'item' but do translate when '_item' // NOTE: internal extensions use build_from_mem and don't need _item but // still need to include if are to be localized if (!strcmp(chname, INKSCAPE_EXTENSION_NS "_item")) { if (node->attribute("msgctxt") != NULL) { newguitext = g_dpgettext2(NULL, node->attribute("msgctxt"), contents); } else { newguitext = _(contents); } } else { newguitext = contents; } } else continue; const char * val = node->attribute("value"); if (val != NULL) { newvalue = val; } else { newvalue = contents; } if ( (!newguitext.empty()) && (!newvalue.empty()) ) { // logical error if this is not true here choices = g_slist_append( choices, new enumentry(newvalue, newguitext) ); } } } // Initialize _value with the default value from xml // for simplicity : default to the contents of the first xml-child if (xml->firstChild() && xml->firstChild()->firstChild()) { xmlval = xml->firstChild()->attribute("value"); } const char *indent = xml->attribute("indent"); if (indent != NULL) { _indent = atoi(indent) * 12; } } gchar * pref_name = this->pref_name(); Inkscape::Preferences *prefs = Inkscape::Preferences::get(); Glib::ustring paramval = prefs ? prefs->getString(extension_pref_root + pref_name) : ""; g_free(pref_name); if (!paramval.empty()) { _value = g_strdup(paramval.data()); } else if (xmlval) { _value = g_strdup(xmlval); } }