summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: bc58a07)
raw | patch | inline | side by side (parent: bc58a07)
author | Aurelio A. Heckert (a) <auriumgmaildotcom> | |
Wed, 17 Mar 2010 21:21:54 +0000 (18:21 -0300) | ||
committer | Aurelio A. Heckert (a) <auriumgmaildotcom> | |
Wed, 17 Mar 2010 21:21:54 +0000 (18:21 -0300) |
share/extensions/webslicer-create-group.py | patch | blob | history | |
share/extensions/webslicer-create-rect.py | patch | blob | history |
diff --git a/share/extensions/webslicer-create-group.py b/share/extensions/webslicer-create-group.py
index dcbf53fbe8ebd378681a3ac56e8938f63d9d4329..aadfded38e26b5a38099991a3a56e28f3b9b0b61 100755 (executable)
def get_base_elements(self):
- self.layer = self.document.xpath(
- '//*[@id="webslicer-layer" and @inkscape:groupmode="layer"]',
- namespaces=inkex.NSS)[0]
+ layerArr = self.document.xpath(
+ '//*[@id="webslicer-layer" and @inkscape:groupmode="layer"]',
+ namespaces=inkex.NSS)
+ if len(layerArr) > 0:
+ self.layer = layerArr[0]
+ else:
+ inkex.errormsg(_('You must to create and select some "Slicer rectangles" before try to group.'))
+ exit(3)
self.layer_descendants = self.get_descendants_in_array(self.layer)
inkex.errormsg(_('Opss... The element "%s" is not in the Web Slicer layer') % id)
exit(2)
g_parent = self.getParentNode(node)
- inkex.errormsg( g_parent.get('id') )
group = inkex.etree.SubElement(g_parent, 'g')
desc = inkex.etree.SubElement(group, 'desc')
conf_txt = ''
index 9761fd3a576b70bf85a9e129b5d09da6cb0c1a6d..957d6a8b20ace566e2601b251558041faf253b07 100755 (executable)
self.options.name = name+'-'+num_s
+ def validate_options(self):
+ self.options.format = self.options.ensure_value('format', 'png').lower()
+ if not is_empty( self.options.dimension ):
+ self.options.dimension
+
def effect(self):
+ self.validate_options()
layer = self.get_slicer_layer()
#TODO: get selected elements to define location and size
rect = inkex.etree.SubElement(layer, 'rect')
conf_txt += "dpi:" + str(self.options.dpi) +"\n"
if not is_empty(self.options.html_id):
conf_txt += "html-id:" + self.options.html_id
- desc.text = conf_txt
+ desc.text = "\n".join( self.get_full_conf_list() )
+
+
+
+ def get_conf_from_list(self, conf_atts):
+ conf_list = []
+ for att in conf_atts:
+ if not is_empty(getattr(self.options, att)):
+ conf_list.append( att +':'+ str(getattr(self.options, att)) )
+ return conf_list
+
+
+ def get_full_conf_list(self):
+ conf_list = [ 'format:'+self.options.format ]
+ if self.options.format == 'gif':
+ conf_list.extend( get_conf_from_list([ 'gif_type', 'palette_size' ]) )
+ if self.options.format == 'jpg':
+ conf_list.extend( get_conf_from_list([ 'quality' ]) )
+ conf_general_atts = [
+ 'dpi', 'dimension',
+ 'bg_color', 'html_id', 'html_class',
+ 'layout_disposition', 'layout_position_anchor'
+ ]
+ conf_list.extend( get_conf_from_list(conf_general_atts) )
+ return conf_list
+
def get_slicer_layer(self):
# Test if webslicer-layer layer existis
layer = layer[0]
return layer
+
if __name__ == '__main__':
e = WebSlicer_CreateRect()
e.affect()