Add support for the sodipodi:insensitive attribute
authorAntonio Ospite <ao2@ao2.it>
Sat, 30 Jun 2018 21:59:30 +0000 (23:59 +0200)
committerAntonio Ospite <ao2@ao2.it>
Sat, 30 Jun 2018 21:59:30 +0000 (23:59 +0200)
The sodipodi:insensitive attributes makes it possible to block layers.

svgwrite_inkscape_drawing.py

index 0d9c4b5..b307544 100755 (executable)
@@ -20,6 +20,10 @@ class InkscapeDrawing(svgwrite.Drawing):
                                            anim=False,
                                            types=[],
                                            const=frozenset(['http://www.inkscape.org/namespaces/inkscape'])),
+            'xmlns:sodipodi': SVGAttribute('xmlns:sodipodi',
+                                           anim=False,
+                                           types=[],
+                                           const=frozenset(['http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd'])),
             'inkscape:groupmode': SVGAttribute('inkscape:groupmode',
                                                anim=False,
                                                types=[],
@@ -27,6 +31,10 @@ class InkscapeDrawing(svgwrite.Drawing):
             'inkscape:label': SVGAttribute('inkscape:label',
                                            anim=False,
                                            types=frozenset(['string']),
+                                           const=[]),
+            'sodipodi:insensitive': SVGAttribute('sodipodi:insensitive',
+                                           anim=False,
+                                           types=frozenset(['string']),
                                            const=[])
         }
 
@@ -36,14 +44,17 @@ class InkscapeDrawing(svgwrite.Drawing):
 
         svg_attributes = set(elements['svg'].valid_attributes)
         svg_attributes.add('xmlns:inkscape')
+        svg_attributes.add('xmlns:sodipodi')
         elements['svg'].valid_attributes = frozenset(svg_attributes)
 
         g_attributes = set(elements['g'].valid_attributes)
         g_attributes.add('inkscape:groupmode')
         g_attributes.add('inkscape:label')
+        g_attributes.add('sodipodi:insensitive')
         elements['g'].valid_attributes = frozenset(g_attributes)
 
         self['xmlns:inkscape'] = 'http://www.inkscape.org/namespaces/inkscape'
+        self['xmlns:sodipodi'] = 'http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd'
 
     def layer(self, **kwargs):
         """Create an inkscape layer.
@@ -65,6 +76,7 @@ def main():
     svg = InkscapeDrawing('inkscape-test.svg', profile='full', size=(640, 480))
 
     layer = svg.layer(label="Layer one")
+    layer["sodipodi:insensitive"] = "true"
     svg.add(layer)
 
     line = svg.line((100, 100), (300, 100),