From 0e82b86bbfd6d5656431edbf20fa8b6f79515a04 Mon Sep 17 00:00:00 2001 From: Maximilian Albert Date: Fri, 11 Jan 2008 19:01:50 +0000 Subject: Add possibility to convert objects (only rectangles and 3D boxes currently) to guidelines. Also see corresponding post on the mailing list; in particular, feel free to revert it if this is inappropriate during Frost phase. (bzr r4462) --- src/selection-chemistry.cpp | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) (limited to 'src/selection-chemistry.cpp') diff --git a/src/selection-chemistry.cpp b/src/selection-chemistry.cpp index 56ef7b01f..fc2a6a271 100644 --- a/src/selection-chemistry.cpp +++ b/src/selection-chemistry.cpp @@ -72,12 +72,14 @@ #include #include "helper/units.h" #include "sp-item.h" +#include "box3d.h" #include "unit-constants.h" #include "xml/simple-document.h" #include "sp-filter-reference.h" #include "gradient-drag.h" #include "uri-references.h" #include "live_effects/lpeobject.h" +#include "sp-rect.h" using NR::X; using NR::Y; @@ -2440,6 +2442,39 @@ void sp_selection_to_marker(bool apply) _("Objects to marker")); } +void sp_selection_to_guides() +{ + SPDesktop *desktop = SP_ACTIVE_DESKTOP; + if (desktop == NULL) + return; + + SPDocument *doc = sp_desktop_document(desktop); + Inkscape::Selection *selection = sp_desktop_selection(desktop); + // we need to copy the list because it gets reset when objects are deleted + GSList *items = g_slist_copy((GSList *) selection->itemList()); + + bool performed = false; + for (GSList const *i = items; i != NULL; i = i->next) { + if (SP_IS_RECT(i->data)) { + sp_rect_convert_to_guides(SP_RECT(i->data), false); + performed = true; + } else if (SP_IS_BOX3D(i->data)) { + box3d_convert_to_guides(SP_BOX3D(i->data), false); + performed = true; + } + } + + if (!performed) { + desktop->messageStack()->flash(Inkscape::WARNING_MESSAGE, _("Select object(s) to convert to guides (selection must contain at least one rectangle or 3D box).")); + return; + } + + if (performed) { + sp_document_done (doc, SP_VERB_EDIT_SELECTION_2_GUIDES, + _("Objects to guides")); + } +} + void sp_selection_tile(bool apply) { -- cgit v1.2.3