summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: a99c0a3)
raw | patch | inline | side by side (parent: a99c0a3)
author | buliabyak <buliabyak@users.sourceforge.net> | |
Wed, 15 Mar 2006 20:33:44 +0000 (20:33 +0000) | ||
committer | buliabyak <buliabyak@users.sourceforge.net> | |
Wed, 15 Mar 2006 20:33:44 +0000 (20:33 +0000) |
src/selection-chemistry.cpp | patch | blob | history |
index 36f3b1b3f1b4d8e635f19bb450b3ac88f100f438..cd6fb2823d161ed8379b4a1e4682c9fb268f796c 100644 (file)
return;
}
- // Check if more than one object is selected.
- if (g_slist_length((GSList *) selection->itemList()) > 1) {
- desktop->messageStack()->flash(Inkscape::ERROR_MESSAGE, _("If you want to clone several objects, <b>group</b> them and <b>clone the group</b>."));
- return;
- }
-
- Inkscape::XML::Node *sel_repr = SP_OBJECT_REPR(selection->singleItem());
- Inkscape::XML::Node *parent = sp_repr_parent(sel_repr);
-
- Inkscape::XML::Node *clone = sp_repr_new("svg:use");
- clone->setAttribute("x", "0");
- clone->setAttribute("y", "0");
- clone->setAttribute("xlink:href", g_strdup_printf("#%s", sel_repr->attribute("id")));
-
- // add the new clone to the top of the original's parent
- parent->appendChild(clone);
+ GSList *reprs = g_slist_copy((GSList *) selection->reprList());
+
+ selection->clear();
+
+ // sorting items from different parents sorts each parent's subset without possibly mixing them, just what we need
+ reprs = g_slist_sort(reprs, (GCompareFunc) sp_repr_compare_position);
+ GSList *newsel = NULL;
+
+ while (reprs) {
+ Inkscape::XML::Node *sel_repr = (Inkscape::XML::Node *) reprs->data;
+ Inkscape::XML::Node *parent = sp_repr_parent(sel_repr);
+
+ Inkscape::XML::Node *clone = sp_repr_new("svg:use");
+ sp_repr_set_attr(clone, "x", "0");
+ sp_repr_set_attr(clone, "y", "0");
+ sp_repr_set_attr(clone, "xlink:href", g_strdup_printf("#%s", sel_repr->attribute("id")));
+
+ // add the new clone to the top of the original's parent
+ parent->appendChild(clone);
+
+ newsel = g_slist_prepend(newsel, clone);
+ reprs = g_slist_remove(reprs, sel_repr);
+ Inkscape::GC::release(clone);
+ }
+
sp_document_done(SP_DT_DOCUMENT(desktop));
- selection->set(clone);
- Inkscape::GC::release(clone);
+ selection->setReprList(newsel);
+
+ g_slist_free(newsel);
}
void