summaryrefslogtreecommitdiffstats
path: root/share/extensions/webslicer-create-group.py
diff options
context:
space:
mode:
authorAurelio A. Heckert (a) <auriumgmaildotcom>2010-03-03 13:53:15 +0000
committerAurelio A. Heckert (a) <auriumgmaildotcom>2010-03-03 13:53:15 +0000
commitda7ca578eac6f2c00dd42ebdafbfbfcafc42e7e8 (patch)
tree39a4510b4753662983b82413054e56a7c1bad421 /share/extensions/webslicer-create-group.py
parentExtensions. Fix bug in svg+media when there are special characters in the path (diff)
downloadinkscape-da7ca578eac6f2c00dd42ebdafbfbfcafc42e7e8.tar.gz
inkscape-da7ca578eac6f2c00dd42ebdafbfbfcafc42e7e8.zip
A little more work to Web Slicer (not usable yet)
(bzr r9135)
Diffstat (limited to 'share/extensions/webslicer-create-group.py')
-rwxr-xr-xshare/extensions/webslicer-create-group.py28
1 files changed, 23 insertions, 5 deletions
diff --git a/share/extensions/webslicer-create-group.py b/share/extensions/webslicer-create-group.py
index 3c44b2cb4..8a496c4ba 100755
--- a/share/extensions/webslicer-create-group.py
+++ b/share/extensions/webslicer-create-group.py
@@ -50,17 +50,23 @@ class WebSlicer_CreateGroup(inkex.Effect):
help="")
def effect(self):
- if len(self.selected) == 0:
- inkex.errormsg(_('You must to select some "Slicer rectangles".'))
- return
layer = self.document.xpath(
'//*[@id="webslicer-layer" and @inkscape:groupmode="layer"]',
namespaces=inkex.NSS)[0]
- group = inkex.etree.SubElement(layer, 'g')
+ if len(self.selected) == 0:
+ inkex.errormsg(_('You must to select some "Slicer rectangles" or other "Layout groups".'))
+ exit(1)
+ descendants = get_descendants_in_array(layer)
+ for id,node in self.selected.iteritems():
+ if node not in descendants:
+ inkex.errormsg(_('Opss... The element "%s" is not in the Web Slicer layer') % id)
+ exit(2)
+ g_parent = self.find_node_parent(node)
+ group = inkex.etree.SubElement(g_parent, 'g')
desc = inkex.etree.SubElement(group, 'desc')
conf_txt = ''
if not is_empty(self.options.html_id):
- conf_txt += 'html-id:' + self.options.html_class +'\n'
+ conf_txt += 'html-id:' + self.options.html_id +'\n'
if not is_empty(self.options.html_class):
conf_txt += 'html-class:' + self.options.html_class +'\n'
conf_txt += 'width-unity:' + self.options.width_unity +'\n'
@@ -70,6 +76,18 @@ class WebSlicer_CreateGroup(inkex.Effect):
group.insert( 1, node )
+ def find_node_parent(self, node):
+ #TODO: make it real!
+ return self.document.xpath(
+ '//*[@id="webslicer-layer" and @inkscape:groupmode="layer"]',
+ namespaces=inkex.NSS)[0]
+
+def get_descendants_in_array(el):
+ descendants = el.getchildren()
+ for e in descendants:
+ descendants.extend( get_descendants_in_array(e) )
+ return descendants
+
if __name__ == '__main__':
e = WebSlicer_CreateGroup()
e.affect()