From 6482314390a26487c2a51431a2db4e7c0704224d Mon Sep 17 00:00:00 2001 From: JSCHILL1 Date: Mon, 19 Oct 2009 12:47:50 -0500 Subject: [PATCH] Bug 453737: Update Inkscape extension to provide a GUI for the options --- release-notes.html | 10 +++++++++ scour.inkscape.py | 53 +++++++++++++++++++++++++++++++++++++++++----- scour.inx | 33 +++++++++++++++++++++++++++-- scour.py | 8 +------ 4 files changed, 90 insertions(+), 14 deletions(-) diff --git a/release-notes.html b/release-notes.html index 7dcc6a0..d67d6ca 100644 --- a/release-notes.html +++ b/release-notes.html @@ -9,6 +9,16 @@

Copyright 2009, Jeff Schiller

+
+
+

Version 0.22

+
+

TBD

+ +
+

Version 0.21

diff --git a/scour.inkscape.py b/scour.inkscape.py index 531dfb4..9e87757 100755 --- a/scour.inkscape.py +++ b/scour.inkscape.py @@ -1,8 +1,51 @@ #!/usr/bin/env python # -*- coding: utf-8 -*- -import sys +import sys, inkex from scour import scourString -input = file(sys.argv[1], "r") -sys.stdout.write(scourString(input.read()).encode("UTF-8")) -input.close() -sys.stdout.close() + +class ScourInkscape (inkex.Effect): + + def __init__(self): + inkex.Effect.__init__(self) + self.OptionParser.add_option("--tab", + action="store", type="string", + dest="tab") + self.OptionParser.add_option("--simplify-colors", type="inkbool", + action="store", dest="simple_colors", default=True, + help="won't convert all colors to #RRGGBB format") + self.OptionParser.add_option("--style-to-xml", type="inkbool", + action="store", dest="style_to_xml", default=True, + help="won't convert styles into XML attributes") + self.OptionParser.add_option("--group-collapsing", type="inkbool", + action="store", dest="group_collapse", default=True, + help="won't collapse elements") + self.OptionParser.add_option("--enable-id-stripping", type="inkbool", + action="store", dest="strip_ids", default=False, + help="remove all un-referenced ID attributes") + self.OptionParser.add_option("--embed-rasters", type="inkbool", + action="store", dest="embed_rasters", default=True, + help="won't embed rasters as base64-encoded data") + self.OptionParser.add_option("--keep-editor-data", type="inkbool", + action="store", dest="keep_editor_data", default=False, + help="won't remove Inkscape, Sodipodi or Adobe Illustrator elements and attributes") + self.OptionParser.add_option("--strip-xml-prolog", type="inkbool", + action="store", dest="strip_xml_prolog", default=False, + help="won't output the prolog") + self.OptionParser.add_option("-p", "--set-precision", + action="store", type=int, dest="digits", default=5, + help="set number of significant digits (default: %default)") + self.OptionParser.add_option("--indent", + action="store", type="string", dest="indent_type", default="space", + help="indentation of the output: none, space, tab (default: %default)") + + + def effect(self): + input = file(sys.argv[11], "r") + sys.stdout.write(scourString(input.read(), self.options).encode("UTF-8")) + input.close() + sys.stdout.close() + + +if __name__ == '__main__': + e = ScourInkscape() + e.affect(output=False) diff --git a/scour.inx b/scour.inx index 6e9cd7a..d5cddee 100644 --- a/scour.inx +++ b/scour.inx @@ -1,14 +1,43 @@ - <_name>Scoured SVG Output + <_name>Optimized SVG Output org.inkscape.output.scour scour.py svg_regex.py yocto_css.py + + + true + true + true + false + true + false + false + 5 + + <_item value="space">Space + <_item value="tab">Tab + <_item value="none">None + + + + <_param name="instructions" type="description" xml:space="preserve">This extension optimize the SVG file according to the following options: + * Simplify colors: convert all colors to #RRGGBB format. + * Style to xml: convert styles into XML attributes. + * Group collapsing: collapse <g> elements. + * Enable id stripping: remove all un-referenced ID attributes. + * Embed rasters: embed rasters as base64-encoded data. + * Keep editor data: don't remove Inkscape, Sodipodi or Adobe Illustrator elements and attributes. + * Strip xml prolog: don't output the xml prolog. + * Set precision: set number of significant digits (default: 5). + * Indent: indentation of the output: none, space, tab (default: space). + + .svg image/svg+xml - <_filetypename>Scoured SVG (*.svg) + <_filetypename>Optimized SVG (*.svg) <_filetypetooltip>Scalable Vector Graphics