diff options
| author | bulia byak <buliabyak@gmail.com> | 2008-06-15 16:22:56 +0000 |
|---|---|---|
| committer | buliabyak <buliabyak@users.sourceforge.net> | 2008-06-15 16:22:56 +0000 |
| commit | 054adec9bea2b1473badbfcbb2ad0c4616269759 (patch) | |
| tree | d20c43acd49c36f5399cc1ffb64ff11cff56a0e4 /src/selection-chemistry.cpp | |
| parent | Extend the .inx RELAX NG schema to allow the appearance="minimal" option that... (diff) | |
| download | inkscape-054adec9bea2b1473badbfcbb2ad0c4616269759.tar.gz inkscape-054adec9bea2b1473badbfcbb2ad0c4616269759.zip | |
new command: relink clone to copied object
(bzr r5948)
Diffstat (limited to 'src/selection-chemistry.cpp')
| -rw-r--r-- | src/selection-chemistry.cpp | 52 |
1 files changed, 51 insertions, 1 deletions
diff --git a/src/selection-chemistry.cpp b/src/selection-chemistry.cpp index 0f92f9680..d4964c284 100644 --- a/src/selection-chemistry.cpp +++ b/src/selection-chemistry.cpp @@ -1865,6 +1865,56 @@ sp_selection_clone() } void +sp_selection_relink() +{ + SPDesktop *desktop = SP_ACTIVE_DESKTOP; + if (!desktop) + return; + + Inkscape::Selection *selection = sp_desktop_selection(desktop); + + if (selection->isEmpty()) { + desktop->messageStack()->flash(Inkscape::WARNING_MESSAGE, _("Select <b>clones</b> to relink.")); + return; + } + + Inkscape::UI::ClipboardManager *cm = Inkscape::UI::ClipboardManager::get(); + const gchar *newid = cm->getFirstObjectID(); + if (!newid) { + desktop->messageStack()->flash(Inkscape::WARNING_MESSAGE, _("Copy an <b>object</b> to clipboard to relink clones to.")); + return; + } + gchar *newref = g_strdup_printf ("#%s", newid); + + // Get a copy of current selection. + GSList *new_select = NULL; + bool relinked = false; + for (GSList *items = (GSList *) selection->itemList(); + items != NULL; + items = items->next) + { + SPItem *item = (SPItem *) items->data; + + if (!SP_IS_USE(item)) + continue; + + SP_OBJECT_REPR(item)->setAttribute("xlink:href", newref); + SP_OBJECT(item)->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG); + relinked = true; + } + + g_free(newref); + + if (!relinked) { + desktop->messageStack()->flash(Inkscape::ERROR_MESSAGE, _("<b>No clones to relink</b> in the selection.")); + } else { + sp_document_done(sp_desktop_document(desktop), SP_VERB_EDIT_UNLINK_CLONE, + _("Relink clone")); + } +} + + +void sp_selection_unlink() { SPDesktop *desktop = SP_ACTIVE_DESKTOP; @@ -1874,7 +1924,7 @@ sp_selection_unlink() Inkscape::Selection *selection = sp_desktop_selection(desktop); if (selection->isEmpty()) { - desktop->messageStack()->flash(Inkscape::WARNING_MESSAGE, _("Select a <b>clone</b> to unlink.")); + desktop->messageStack()->flash(Inkscape::WARNING_MESSAGE, _("Select <b>clones</b> to unlink.")); return; } |
