summaryrefslogtreecommitdiff
path: root/lib/extensions/object_commands_toggle_visibility.py
diff options
context:
space:
mode:
Diffstat (limited to 'lib/extensions/object_commands_toggle_visibility.py')
-rw-r--r--lib/extensions/object_commands_toggle_visibility.py24
1 files changed, 24 insertions, 0 deletions
diff --git a/lib/extensions/object_commands_toggle_visibility.py b/lib/extensions/object_commands_toggle_visibility.py
new file mode 100644
index 00000000..569f4305
--- /dev/null
+++ b/lib/extensions/object_commands_toggle_visibility.py
@@ -0,0 +1,24 @@
+# Authors: see git history
+#
+# Copyright (c) 2022 Authors
+# Licensed under the GNU GPL version 3.0 or later. See the file LICENSE for details.
+
+from inkex import NSS
+
+from .base import InkstitchExtension
+
+
+class ObjectCommandsToggleVisibility(InkstitchExtension):
+
+ def effect(self):
+ svg = self.document.getroot()
+ # toggle object commands (in fact it's display or hide all of them)
+ command_groups = svg.xpath(".//svg:g[starts-with(@id,'command_group')]", namespaces=NSS)
+ display = "none"
+ first_iteration = True
+ for command_group in command_groups:
+ if first_iteration:
+ first_iteration = False
+ if not command_group.is_visible():
+ display = "inline"
+ command_group.style['display'] = display