From d065dd0b182b88afc1c6f53cce6a189147e70b08 Mon Sep 17 00:00:00 2001 From: Alvin Penner Date: Mon, 11 May 2015 15:24:52 -0400 Subject: patch by tbnorth for Bug 1277649 Fixed bugs: - https://launchpad.net/bugs/1277649 (bzr r14146) --- share/extensions/layout_nup.inx | 1 - share/extensions/layout_nup.py | 216 ++++++++++++++++++++++++++++- share/extensions/layout_nup_pageframe.py | 230 ------------------------------- 3 files changed, 212 insertions(+), 235 deletions(-) delete mode 100755 share/extensions/layout_nup_pageframe.py (limited to 'share') diff --git a/share/extensions/layout_nup.inx b/share/extensions/layout_nup.inx index 2b7734fc3..1d4d1ef0f 100644 --- a/share/extensions/layout_nup.inx +++ b/share/extensions/layout_nup.inx @@ -3,7 +3,6 @@ <_name>N-up layout org.greygreen.inkscape.effects.nup layout_nup.py - layout_nup_pageframe.py inkex.py diff --git a/share/extensions/layout_nup.py b/share/extensions/layout_nup.py index 5f8451c45..20532f72a 100755 --- a/share/extensions/layout_nup.py +++ b/share/extensions/layout_nup.py @@ -19,7 +19,19 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA import inkex import sys -import layout_nup_pageframe +try: + import xml.etree.ElementTree as ElementTree +except: + try: + from lxml import etree as ElementTree + except: + try: + from elementtree.ElementTree import ElementTree + except: + sys.stderr.write("""Requires ElementTree module, included +in Python 2.5 or supplied by lxml or elementtree modules. + +""") class Nup(inkex.Effect): def __init__(self): @@ -64,7 +76,7 @@ class Nup(inkex.Effect): if getattr(self.options, i): showList.append(i.lower().replace('show', '')) o = self.options - self.pf = layout_nup_pageframe.GenerateNup( + self.pf = self.GenerateNup( unit=o.unit, pgSize=(o.pgSizeX,o.pgSizeY), pgMargin=(o.pgMarginTop,o.pgMarginRight,o.pgMarginBottom,o.pgMarginLeft), @@ -84,7 +96,203 @@ class Nup(inkex.Effect): def output(self): sys.stdout.write(self.pf) + def expandTuple(self, unit, x, length = 4): + try: + iter(x) + except: + return None + + if len(x) != length: x = x*2 + if len(x) != length: + raise Exception("expandTuple: requires 2 or 4 item tuple") + try: + return tuple(map(lambda ev: (self.unittouu(str(eval(str(ev)))+unit)), x)) + except: + return None + + def GenerateNup(self, + unit="px", + pgSize=("8.5*96","11*96"), + pgMargin=(0,0), + pgPadding=(0,0), + num=(2,2), + calculateSize=True, + size=None, + margin=(0,0), + padding=(20,20), + show=['default'], + container='svg', + returnTree = False, + ): + """Generate the SVG. Inputs are run through 'eval(str(x))' so you can use + '8.5*72' instead of 612. Margin / padding dimension tuples can be + (top & bottom, left & right) or (top, right, bottom, left). + + Keyword arguments: + pgSize -- page size, width x height + pgMargin -- extra space around each page + pgPadding -- added to pgMargin + n -- rows x cols + size -- override calculated size, width x height + margin -- white space around each piece + padding -- inner padding for each piece + show -- list of keywords indicating what to show + - 'crosses' - cutting guides + - 'inner' - inner boundary + - 'outer' - outer boundary + container -- 'svg' or 'g' + returnTree -- whether to return the ElementTree or the string + """ + + if 'default' in show: + show = set(show).union(['inner', 'innerbox', 'holder', 'crosses']) + + pgMargin = self.expandTuple(unit, pgMargin) + pgPadding = self.expandTuple(unit, pgPadding) + margin = self.expandTuple(unit, margin) + padding = self.expandTuple(unit, padding) + + pgSize = self.expandTuple(unit, pgSize, length = 2) + # num = tuple(map(lambda ev: eval(str(ev)), num)) + + pgEdge = map(sum,zip(pgMargin, pgPadding)) + + top, right, bottom, left = 0,1,2,3 + width, height = 0,1 + rows, cols = 0,1 + size = self.expandTuple(unit, size, length = 2) + if size == None or calculateSize == True or len(size) < 2 or size[0] == 0 or size[1] == 0: + size = ((pgSize[width] + - pgEdge[left] - pgEdge[right] + - num[cols]*(margin[left] + margin[right])) / num[cols], + (pgSize[height] + - pgEdge[top] - pgEdge[bottom] + - num[rows]*(margin[top] + margin[bottom])) / num[rows] + ) + else: + size = self.expandTuple(unit, size, length = 2) + + # sep is separation between same points on pieces + sep = (size[width]+margin[right]+margin[left], + size[height]+margin[top]+margin[bottom]) + + style = 'stroke:#000000;stroke-opacity:1;fill:none;fill-opacity:1;' + + padbox = 'rect', { + 'x': str(pgEdge[left] + margin[left] + padding[left]), + 'y': str(pgEdge[top] + margin[top] + padding[top]), + 'width': str(size[width] - padding[left] - padding[right]), + 'height': str(size[height] - padding[top] - padding[bottom]), + 'style': style, + } + margbox = 'rect', { + 'x': str(pgEdge[left] + margin[left]), + 'y': str(pgEdge[top] + margin[top]), + 'width': str(size[width]), + 'height': str(size[height]), + 'style': style, + } + + doc = ElementTree.ElementTree(ElementTree.Element(container, + {'xmlns:inkscape':"http://www.inkscape.org/namespaces/inkscape", + 'xmlns:xlink':"http://www.w3.org/1999/xlink", + 'width':str(pgSize[width]), + 'height':str(pgSize[height]), + })) + + sub = ElementTree.SubElement + + root = doc.getroot() + + def makeClones(under, to): + for r in range(0,num[rows]): + for c in range(0,num[cols]): + if r == 0 and c == 0: continue + sub(under, 'use', { + 'xlink:href': '#' + to, + 'transform': 'translate(%f,%f)' % + (c*sep[width], r*sep[height])}) + + # guidelayer ##################################################### + if set(['inner', 'outer']).intersection(show): + layer = sub(root, 'g', {'id':'guidelayer', + 'inkscape:groupmode':'layer'}) + if 'inner' in show: + padbox[1]['id'] = 'innerguide' + padbox[1]['style'] = padbox[1]['style'].replace('stroke:#000000', + 'stroke:#8080ff') + sub(layer, *padbox) + del padbox[1]['id'] + padbox[1]['style'] = padbox[1]['style'].replace('stroke:#8080ff', + 'stroke:#000000') + makeClones(layer, 'innerguide') + if 'outer' in show: + margbox[1]['id'] = 'outerguide' + margbox[1]['style'] = padbox[1]['style'].replace('stroke:#000000', + 'stroke:#8080ff') + sub(layer, *margbox) + del margbox[1]['id'] + margbox[1]['style'] = padbox[1]['style'].replace('stroke:#8080ff', + 'stroke:#000000') + makeClones(layer, 'outerguide') + + # crosslayer ##################################################### + if set(['crosses']).intersection(show): + layer = sub(root, 'g', {'id':'cutlayer', + 'inkscape:groupmode':'layer'}) + + if 'crosses' in show: + crosslen = 12 + group = sub(layer, 'g', id='cross') + x,y = 0,0 + path = 'M%f %f' % (x+pgEdge[left] + margin[left], + y+pgEdge[top] + margin[top]-crosslen) + path += ' L%f %f' % (x+pgEdge[left] + margin[left], + y+pgEdge[top] + margin[top]+crosslen) + path += ' M%f %f' % (x+pgEdge[left] + margin[left]-crosslen, + y+pgEdge[top] + margin[top]) + path += ' L%f %f' % (x+pgEdge[left] + margin[left]+crosslen, + y+pgEdge[top] + margin[top]) + sub(group, 'path', style=style+'stroke-width:0.05', + d = path, id = 'crossmarker') + for r in 0, 1: + for c in 0, 1: + if r or c: + x,y = c*size[width], r*size[height] + sub(group, 'use', { + 'xlink:href': '#crossmarker', + 'transform': 'translate(%f,%f)' % + (x,y)}) + makeClones(layer, 'cross') + + # clonelayer ##################################################### + layer = sub(root, 'g', {'id':'clonelayer', 'inkscape:groupmode':'layer'}) + makeClones(layer, 'main') + + # mainlayer ###################################################### + layer = sub(root, 'g', {'id':'mainlayer', 'inkscape:groupmode':'layer'}) + group = sub(layer, 'g', {'id':'main'}) + + if 'innerbox' in show: + sub(group, *padbox) + if 'outerbox' in show: + sub(group, *margbox) + if 'holder' in show: + x, y = (pgEdge[left] + margin[left] + padding[left], + pgEdge[top] + margin[top] + padding[top]) + w, h = (size[width] - padding[left] - padding[right], + size[height] - padding[top] - padding[bottom]) + path = 'M%f %f' % (x + w/2., y) + path += ' L%f %f' % (x + w, y + h/2.) + path += ' L%f %f' % (x + w/2., y + h) + path += ' L%f %f' % (x, y + h/2.) + path += ' Z' + sub(group, 'path', style=style, d = path) + + if returnTree: + return doc + else: + return ElementTree.tostring(root) + e = Nup() e.affect() - - diff --git a/share/extensions/layout_nup_pageframe.py b/share/extensions/layout_nup_pageframe.py deleted file mode 100755 index 471a75dd3..000000000 --- a/share/extensions/layout_nup_pageframe.py +++ /dev/null @@ -1,230 +0,0 @@ -#!/usr/bin/env python -#@+leo-ver=4-thin -#@+node:tbrown.20070622094435.1:@thin pageframe.py -"""Create n-up SVG layouts""" - -#@+others -#@+node:tbrown.20070622103716:imports -import sys, inkex - -try: - import xml.etree.ElementTree as ElementTree -except: - try: - from lxml import etree as ElementTree - except: - try: - from elementtree.ElementTree import ElementTree - except: - sys.stderr.write("""Requires ElementTree module, included -in Python 2.5 or supplied by lxml or elementtree modules. - -""") -#@-node:tbrown.20070622103716:imports -#@+node:tbrown.20070622103716.1:expandTuple -def expandTuple(unit, x, length = 4): - try: - iter(x) - except: - return None - - if len(x) != length: x = x*2 - if len(x) != length: - raise Exception("expandTuple: requires 2 or 4 item tuple") - try: - return tuple(map(lambda ev: (self.unittouu(str(eval(str(ev)))+unit)), x)) - except: - return None -#@-node:tbrown.20070622103716.1:expandTuple -#@+node:tbrown.20070622103716.2:GenerateNup -def GenerateNup(unit="px", - pgSize=("8.5*96","11*96"), - pgMargin=(0,0), - pgPadding=(0,0), - num=(2,2), - calculateSize=True, - size=None, - margin=(0,0), - padding=(20,20), - show=['default'], - container='svg', - returnTree = False, - ): - """Generate the SVG. Inputs are run through 'eval(str(x))' so you can use -'8.5*72' instead of 612. Margin / padding dimension tuples can be -(top & bottom, left & right) or (top, right, bottom, left). - -Keyword arguments: -pgSize -- page size, width x height -pgMargin -- extra space around each page -pgPadding -- added to pgMargin -n -- rows x cols -size -- override calculated size, width x height -margin -- white space around each piece -padding -- inner padding for each piece -show -- list of keywords indicating what to show - - 'crosses' - cutting guides - - 'inner' - inner boundary - - 'outer' - outer boundary -container -- 'svg' or 'g' -returnTree -- whether to return the ElementTree or the string -""" - - if 'default' in show: - show = set(show).union(['inner', 'innerbox', 'holder', 'crosses']) - - pgMargin = expandTuple(unit, pgMargin) - pgPadding = expandTuple(unit, pgPadding) - margin = expandTuple(unit, margin) - padding = expandTuple(unit, padding) - - pgSize = expandTuple(unit, pgSize, length = 2) -# num = tuple(map(lambda ev: eval(str(ev)), num)) - - pgEdge = map(sum,zip(pgMargin, pgPadding)) - - top, right, bottom, left = 0,1,2,3 - width, height = 0,1 - rows, cols = 0,1 - size = expandTuple(unit, size, length = 2) - if size == None or calculateSize == True or len(size) < 2 or size[0] == 0 or size[1] == 0: - size = ((pgSize[width] - - pgEdge[left] - pgEdge[right] - - num[cols]*(margin[left] + margin[right])) / num[cols], - (pgSize[height] - - pgEdge[top] - pgEdge[bottom] - - num[rows]*(margin[top] + margin[bottom])) / num[rows] - ) - else: - size = expandTuple(unit, size, length = 2) - - # sep is separation between same points on pieces - sep = (size[width]+margin[right]+margin[left], - size[height]+margin[top]+margin[bottom]) - - style = 'stroke:#000000;stroke-opacity:1;fill:none;fill-opacity:1;' - - padbox = 'rect', { - 'x': str(pgEdge[left] + margin[left] + padding[left]), - 'y': str(pgEdge[top] + margin[top] + padding[top]), - 'width': str(size[width] - padding[left] - padding[right]), - 'height': str(size[height] - padding[top] - padding[bottom]), - 'style': style, - } - margbox = 'rect', { - 'x': str(pgEdge[left] + margin[left]), - 'y': str(pgEdge[top] + margin[top]), - 'width': str(size[width]), - 'height': str(size[height]), - 'style': style, - } - - doc = ElementTree.ElementTree(ElementTree.Element(container, - {'xmlns:inkscape':"http://www.inkscape.org/namespaces/inkscape", - 'xmlns:xlink':"http://www.w3.org/1999/xlink", - 'width':str(pgSize[width]), - 'height':str(pgSize[height]), - })) - - sub = ElementTree.SubElement - - root = doc.getroot() - - def makeClones(under, to): - for r in range(0,num[rows]): - for c in range(0,num[cols]): - if r == 0 and c == 0: continue - sub(under, 'use', { - 'xlink:href': '#' + to, - 'transform': 'translate(%f,%f)' % - (c*sep[width], r*sep[height])}) - - # guidelayer ##################################################### - if set(['inner', 'outer']).intersection(show): - layer = sub(root, 'g', {'id':'guidelayer', - 'inkscape:groupmode':'layer'}) - if 'inner' in show: - padbox[1]['id'] = 'innerguide' - padbox[1]['style'] = padbox[1]['style'].replace('stroke:#000000', - 'stroke:#8080ff') - sub(layer, *padbox) - del padbox[1]['id'] - padbox[1]['style'] = padbox[1]['style'].replace('stroke:#8080ff', - 'stroke:#000000') - makeClones(layer, 'innerguide') - if 'outer' in show: - margbox[1]['id'] = 'outerguide' - margbox[1]['style'] = padbox[1]['style'].replace('stroke:#000000', - 'stroke:#8080ff') - sub(layer, *margbox) - del margbox[1]['id'] - margbox[1]['style'] = padbox[1]['style'].replace('stroke:#8080ff', - 'stroke:#000000') - makeClones(layer, 'outerguide') - - # crosslayer ##################################################### - if set(['crosses']).intersection(show): - layer = sub(root, 'g', {'id':'cutlayer', - 'inkscape:groupmode':'layer'}) - - if 'crosses' in show: - crosslen = 12 - group = sub(layer, 'g', id='cross') - x,y = 0,0 - path = 'M%f %f' % (x+pgEdge[left] + margin[left], - y+pgEdge[top] + margin[top]-crosslen) - path += ' L%f %f' % (x+pgEdge[left] + margin[left], - y+pgEdge[top] + margin[top]+crosslen) - path += ' M%f %f' % (x+pgEdge[left] + margin[left]-crosslen, - y+pgEdge[top] + margin[top]) - path += ' L%f %f' % (x+pgEdge[left] + margin[left]+crosslen, - y+pgEdge[top] + margin[top]) - sub(group, 'path', style=style+'stroke-width:0.05', - d = path, id = 'crossmarker') - for r in 0, 1: - for c in 0, 1: - if r or c: - x,y = c*size[width], r*size[height] - sub(group, 'use', { - 'xlink:href': '#crossmarker', - 'transform': 'translate(%f,%f)' % - (x,y)}) - makeClones(layer, 'cross') - - # clonelayer ##################################################### - layer = sub(root, 'g', {'id':'clonelayer', 'inkscape:groupmode':'layer'}) - makeClones(layer, 'main') - - # mainlayer ###################################################### - layer = sub(root, 'g', {'id':'mainlayer', 'inkscape:groupmode':'layer'}) - group = sub(layer, 'g', {'id':'main'}) - - if 'innerbox' in show: - sub(group, *padbox) - if 'outerbox' in show: - sub(group, *margbox) - if 'holder' in show: - x, y = (pgEdge[left] + margin[left] + padding[left], - pgEdge[top] + margin[top] + padding[top]) - w, h = (size[width] - padding[left] - padding[right], - size[height] - padding[top] - padding[bottom]) - path = 'M%f %f' % (x + w/2., y) - path += ' L%f %f' % (x + w, y + h/2.) - path += ' L%f %f' % (x + w/2., y + h) - path += ' L%f %f' % (x, y + h/2.) - path += ' Z' - sub(group, 'path', style=style, d = path) - - if returnTree: - return doc - else: - return ElementTree.tostring(root) - -if __name__ == '__main__': - print GenerateNup(num=(10,3), margin=(5,5), show=['default', 'outer']) -#@-node:tbrown.20070622103716.2:GenerateNup -#@-others -#@-node:tbrown.20070622094435.1:@thin pageframe.py -#@-leo - - -- cgit v1.2.3 From 188d2565925f2d015fd138e87c5e80e29085dcee Mon Sep 17 00:00:00 2001 From: Alvin Penner Date: Thu, 14 May 2015 07:31:23 -0400 Subject: extensions. layout_nup. convert units. (Bug 1453982) Fixed bugs: - https://launchpad.net/bugs/1453982 (bzr r14153) --- share/extensions/layout_nup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'share') diff --git a/share/extensions/layout_nup.py b/share/extensions/layout_nup.py index 20532f72a..266a3950d 100755 --- a/share/extensions/layout_nup.py +++ b/share/extensions/layout_nup.py @@ -106,7 +106,7 @@ class Nup(inkex.Effect): if len(x) != length: raise Exception("expandTuple: requires 2 or 4 item tuple") try: - return tuple(map(lambda ev: (self.unittouu(str(eval(str(ev)))+unit)), x)) + return tuple(map(lambda ev: (self.unittouu(str(eval(str(ev)))+unit)/self.unittouu('1px')), x)) except: return None -- cgit v1.2.3 From cca96cf13aa03a1ea90b64b69af8e4410d0f34d1 Mon Sep 17 00:00:00 2001 From: su_v Date: Wed, 20 May 2015 18:33:54 +0200 Subject: Add extension to set attributes for bitmap images (bug #1357808) Inkscape >= 0.91 adds the attribute 'preserveAspectRatio' to imported bitmap images, and sets it to 'none' (to support non-uniform scaling). Unlike older versions it also respects the attribute for rendering. This change may break Inkscape documents with embedded or linked bitmap images which had been created with older versions of Inkscape (the images do not have the attribute set, and thus default to 'xMidYMid' with enforced uniform scaling). The extension allows to add the attribute to selected or all bitmap images in the current document (including bitmap images used as masks, which are stored in the section). Fixed bugs: - https://launchpad.net/bugs/1357808 (bzr r14164) --- share/extensions/image_attributes.inx | 82 +++++++++++++++++ share/extensions/image_attributes.py | 169 ++++++++++++++++++++++++++++++++++ 2 files changed, 251 insertions(+) create mode 100644 share/extensions/image_attributes.inx create mode 100755 share/extensions/image_attributes.py (limited to 'share') diff --git a/share/extensions/image_attributes.inx b/share/extensions/image_attributes.inx new file mode 100644 index 000000000..d0c00f6a2 --- /dev/null +++ b/share/extensions/image_attributes.inx @@ -0,0 +1,82 @@ + + + + <_name>Set Image Attributes + org.inkscape.effect.image_attributes + + image_attributes.py + inkex.py + + + + + + Render all bitmap images like in older Inskcape versions. + +Available options: + true + false + + + + + + none + Unset + xMinYMin + xMidYMin + xMaxYMin + xMinYMid + xMidYMid + xMaxYMid + xMinYMax + xMidYMax + xMaxYMax + + + - + meet + slice + + + Change only selected image(s) + Change all images in selection + Change all images in document + + + + + + + Unset + auto + optimizeQuality + optimizeSpeed + inherit + + + Change only selected image(s) + Change all images in selection + Change all images in document + Apply attribute to parent group of selection + Apply attribute to SVG root + + + + + + + all + + + + + + + + + + + diff --git a/share/extensions/image_attributes.py b/share/extensions/image_attributes.py new file mode 100755 index 000000000..ddd5a8b87 --- /dev/null +++ b/share/extensions/image_attributes.py @@ -0,0 +1,169 @@ +#!/usr/bin/env python +''' +image_attributes.py - adjust image attributes which don't have global +GUI options yet + +Tool for Inkscape 0.91 to adjust rendering of drawings with linked +or embedded bitmap images created with older versions of Inkscape +or third-party applications. + +Copyright (C) 2015, ~suv + +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +''' + +# local library +import inkex +import simplestyle + +try: + inkex.localize() +except: + import gettext + _ = gettext.gettext + + +class SetAttrImage(inkex.Effect): + def __init__(self): + inkex.Effect.__init__(self) + # main options + self.OptionParser.add_option("--fix_scaling", + action="store", type="inkbool", + dest="fix_scaling", default=True, + help="") + self.OptionParser.add_option("--fix_rendering", + action="store", type="inkbool", + dest="fix_rendering", default=False, + help="") + self.OptionParser.add_option("--aspect_ratio", + action="store", type="string", + dest="aspect_ratio", default="none", + help="Value for attribute 'preserveAspectRatio'") + self.OptionParser.add_option("--aspect_clip", + action="store", type="string", + dest="aspect_clip", default="unset", + help="optional 'meetOrSlice' value") + self.OptionParser.add_option("--aspect_ratio_scope", + action="store", type="string", + dest="aspect_ratio_scope", default="selected_only", + help="scope within which to edit 'preserveAspectRatio' attribute") + self.OptionParser.add_option("--image_rendering", + action="store", type="string", + dest="image_rendering", default="unset", + help="Value for attribute 'image-rendering'") + self.OptionParser.add_option("--image_rendering_scope", + action="store", type="string", + dest="image_rendering_scope", default="selected_only", + help="scope within which to edit 'image-rendering' attribute") + # tabs + self.OptionParser.add_option("--tab_main", + action="store", type="string", + dest="tab_main") + + # core method + + def change_attribute(self, node, attribute): + for key, value in attribute.items(): + if key == 'preserveAspectRatio': + # set presentation attribute + if value != "unset": + node.set(key, str(value)) + else: + if node.get(key): + del node.attrib[key] + elif key == 'image-rendering': + node_style = simplestyle.parseStyle(node.get('style')) + if key not in node_style: + # set presentation attribute + if value != "unset": + node.set(key, str(value)) + else: + if node.get(key): + del node.attrib[key] + else: + # set style property + if value != "unset": + node_style[key] = str(value) + else: + del node_style[key] + node.set('style', simplestyle.formatStyle(node_style)) + else: + pass + + def change_all_images(self, node, attribute): + path = 'descendant-or-self::svg:image' + for img in node.xpath(path, namespaces=inkex.NSS): + self.change_attribute(img, attribute) + + # methods called via dispatcher + + def change_selected_only(self, selected, attribute): + if selected: + for node_id, node in selected.iteritems(): + if node.tag == inkex.addNS('image', 'svg'): + self.change_attribute(node, attribute) + + def change_in_selection(self, selected, attribute): + if selected: + for node_id, node in selected.iteritems(): + self.change_all_images(node, attribute) + + def change_in_document(self, selected, attribute): + self.change_all_images(self.document.getroot(), attribute) + + def change_on_parent_group(self, selected, attribute): + if selected: + for node_id, node in selected.iteritems(): + self.change_attribute(node.getparent(), attribute) + + def change_on_root_only(self, selected, attribute): + self.change_attribute(self.document.getroot(), attribute) + + # main + + def effect(self): + attr_val = [] + attr_dict = {} + cmd_scope = None + if self.options.tab_main == '"tab_basic"': + cmd_scope = "in_document" + attr_dict['preserveAspectRatio'] = ("none" if self.options.fix_scaling else "unset") + attr_dict['image-rendering'] = ("optimizeSpeed" if self.options.fix_rendering else "unset") + elif self.options.tab_main == '"tab_aspectRatio"': + attr_val = [self.options.aspect_ratio] + if self.options.aspect_clip != "unset": + attr_val.append(self.options.aspect_clip) + attr_dict['preserveAspectRatio'] = ' '.join(attr_val) + cmd_scope = self.options.aspect_ratio_scope + elif self.options.tab_main == '"tab_image_rendering"': + attr_dict['image-rendering'] = self.options.image_rendering + cmd_scope = self.options.image_rendering_scope + else: # help tab + pass + # dispatcher + if cmd_scope is not None: + try: + change_cmd = getattr(self, 'change_{0}'.format(cmd_scope)) + change_cmd(self.selected, attr_dict) + except AttributeError: + inkex.errormsg('Scope "{0}" not supported'.format(cmd_scope)) + + +if __name__ == '__main__': + e = SetAttrImage() + e.affect() + + +# vim: expandtab shiftwidth=4 tabstop=8 softtabstop=4 fileencoding=utf-8 textwidth=99 -- cgit v1.2.3 From b448141187609c91e294668e6a1bc2fef90097f7 Mon Sep 17 00:00:00 2001 From: su_v Date: Thu, 21 May 2015 04:41:20 +0200 Subject: image_attributes.inx: mark more strings for translation; update POTFILES.in (bzr r14165) --- share/extensions/image_attributes.inx | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) (limited to 'share') diff --git a/share/extensions/image_attributes.inx b/share/extensions/image_attributes.inx index d0c00f6a2..a353d17e5 100644 --- a/share/extensions/image_attributes.inx +++ b/share/extensions/image_attributes.inx @@ -11,9 +11,9 @@ - Render all bitmap images like in older Inskcape versions. + <_param name="basic_desc1" type="description">Render all bitmap images like in older Inskcape versions. -Available options: +Available options: true false @@ -22,7 +22,7 @@ Available options: none - Unset + <_item value="unset">Unset xMinYMin xMidYMin xMaxYMin @@ -39,27 +39,27 @@ Available options: slice - Change only selected image(s) - Change all images in selection - Change all images in document + <_item value="selected_only">Change only selected image(s) + <_item value="in_selection">Change all images in selection + <_item value="in_document">Change all images in document - Unset + <_item value="unset">Unset auto optimizeQuality optimizeSpeed inherit - Change only selected image(s) - Change all images in selection - Change all images in document - Apply attribute to parent group of selection - Apply attribute to SVG root + <_item value="selected_only">Change only selected image(s) + <_item value="in_selection">Change all images in selection + <_item value="in_document">Change all images in document + <_item value="on_parent_group">Apply attribute to parent group of selection + <_item value="on_root_only" >Apply attribute to SVG root -- cgit v1.2.3