diff options
| author | capellancitizen <thecapellancitizen@gmail.com> | 2024-07-02 22:29:29 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-07-02 22:29:29 -0400 |
| commit | 6c166dca61e17efbb3173dcf5ef484e3aa739a50 (patch) | |
| tree | d6bcbb4535ef61e26ff338609f35400dfb098392 /lib/extensions/object_commands.py | |
| parent | 54116a790ad166d37cbee9cc07d0fd5fa55ade8f (diff) | |
Trying to add commands to clones now shows an error. (#3034)
* Trying to add commands to clones now shows an error.
* warn about ignored clones and continue
---------
Co-authored-by: Kaalleen <reni@allenka.de>
Diffstat (limited to 'lib/extensions/object_commands.py')
| -rw-r--r-- | lib/extensions/object_commands.py | 19 |
1 files changed, 15 insertions, 4 deletions
diff --git a/lib/extensions/object_commands.py b/lib/extensions/object_commands.py index 4d692cae..c5a8240c 100644 --- a/lib/extensions/object_commands.py +++ b/lib/extensions/object_commands.py @@ -3,9 +3,10 @@ # Copyright (c) 2010 Authors # Licensed under the GNU GPL version 3.0 or later. See the file LICENSE for details. -import inkex +from inkex import errormsg from ..commands import OBJECT_COMMANDS, add_commands +from ..elements import Clone from ..i18n import _ from .commands import CommandsExtension @@ -18,7 +19,7 @@ class ObjectCommands(CommandsExtension): return if not self.svg.selection: - inkex.errormsg(_("Please select one or more objects to which to attach commands.")) + errormsg(_("Please select one or more objects to which to attach commands.")) return self.svg = self.document.getroot() @@ -26,14 +27,24 @@ class ObjectCommands(CommandsExtension): commands = [command for command in self.COMMANDS if getattr(self.options, command)] if not commands: - inkex.errormsg(_("Please choose one or more commands to attach.")) + errormsg(_("Please choose one or more commands to attach.")) return + # Clones currently can't really take any commands, so error if we try to add one to them. + clones = [e for e in self.elements if isinstance(e, Clone)] + if clones: + errormsg(_( + "Cannot attach commands to Clone element(s) {clones}. " + "They must be unlinked to add commands.\n" + "* Select the clone(s)\n" + "* Run: Extensions > Ink/Stitch > Edit > Unlink Clone" + ).format(clones=", ".join(c.node.get_id() for c in clones))) + # Each object (node) in the SVG may correspond to multiple Elements of different # types (e.g. stroke + fill). We only want to process each one once. seen_nodes = set() for element in self.elements: - if element.node not in seen_nodes and element.shape: + if element.node not in seen_nodes and element.shape and not isinstance(element, Clone): add_commands(element, commands) seen_nodes.add(element.node) |
