diff options
Diffstat (limited to 'lib/extensions')
| -rw-r--r-- | lib/extensions/__init__.py | 4 | ||||
| -rw-r--r-- | lib/extensions/update_svg.py | 39 |
2 files changed, 42 insertions, 1 deletions
diff --git a/lib/extensions/__init__.py b/lib/extensions/__init__.py index cc47f151..25d3214c 100644 --- a/lib/extensions/__init__.py +++ b/lib/extensions/__init__.py @@ -33,7 +33,6 @@ from .lettering_force_lock_stitches import LetteringForceLockStitches from .lettering_generate_json import LetteringGenerateJson from .lettering_remove_kerning import LetteringRemoveKerning from .letters_to_font import LettersToFont -from .zigzag_line_to_satin import ZigzagLineToSatin from .object_commands import ObjectCommands from .object_commands_toggle_visibility import ObjectCommandsToggleVisibility from .output import Output @@ -51,6 +50,8 @@ from .simulator import Simulator from .stitch_plan_preview import StitchPlanPreview from .stitch_plan_preview_undo import StitchPlanPreviewUndo from .stroke_to_lpe_satin import StrokeToLpeSatin +from .update_svg import UpdateSvg +from .zigzag_line_to_satin import ZigzagLineToSatin from .zip import Zip from.lettering_along_path import LetteringAlongPath @@ -91,6 +92,7 @@ __all__ = extensions = [StitchPlanPreview, Troubleshoot, RemoveEmbroiderySettings, Cleanup, + UpdateSvg, BreakApart, GradientBlocks, ApplyThreadlist, diff --git a/lib/extensions/update_svg.py b/lib/extensions/update_svg.py new file mode 100644 index 00000000..51960cb2 --- /dev/null +++ b/lib/extensions/update_svg.py @@ -0,0 +1,39 @@ +# Authors: see git history +# +# Copyright (c) 2010 Authors +# Licensed under the GNU GPL version 3.0 or later. See the file LICENSE for details. + +from inkex import errormsg + +from ..i18n import _ +from ..update import update_inkstitch_document +from .base import InkstitchExtension + + +class UpdateSvg(InkstitchExtension): + + def __init__(self, *args, **kwargs): + InkstitchExtension.__init__(self, *args, **kwargs) + # TODO: When there are more legacy versions than only one, this can be transformed in a user input + # inkstitch_svg_version history: 1 -> v2.3.0 + self.update_from = 0 + + def effect(self): + if not self.svg.selection: + errormsg(_('Please select at least one element to update. ' + 'This extension is designed to help you update copy and pasted elements from old designs.')) + + # set the file version to the update_from value, so that the updater knows where to start from + # the updater will then reset it to the current version after the update has finished + metadata = self.get_inkstitch_metadata() + metadata['inkstitch_svg_version'] = self.update_from + + update_inkstitch_document(self.document, self.get_selection()) + + def get_selection(self): + selection = [] + for element in self.svg.selection: + selection.append(element) + for descendant in element.iterdescendants(): + selection.append(descendant) + return selection |
