summaryrefslogtreecommitdiff
path: root/lib/extensions/object_commands_toggle_visibility.py
blob: e5d247e69dc5d25867266e71021b0e5d21593a66 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
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 command_group.style('display', 'inline') == 'none':
                    display = "inline"
            command_group.style['display'] = display