diff options
| author | Jabier Arraiza Cenoz <jabier.arraiza@marker.es> | 2014-11-10 20:46:54 +0000 |
|---|---|---|
| committer | Jabiertxof <jtx@jtx.marker.es> | 2014-11-10 20:46:54 +0000 |
| commit | a213372bccdad1d36a559e97482f4ce3ddcdc133 (patch) | |
| tree | a5e786d99385b61f00a9fadea6b317f70b4384f6 | |
| parent | Removed SP_USE/SP_IS_USE Gtk-ish macros and cleaned affected files. (diff) | |
| download | inkscape-a213372bccdad1d36a559e97482f4ce3ddcdc133.tar.gz inkscape-a213372bccdad1d36a559e97482f4ce3ddcdc133.zip | |
Add a extra info page pointed by suv in bug page
(bzr r13701)
| -rw-r--r-- | share/extensions/dpiswitcher.inx | 12 | ||||
| -rw-r--r-- | share/extensions/dpiswitcher.py | 68 |
2 files changed, 61 insertions, 19 deletions
diff --git a/share/extensions/dpiswitcher.inx b/share/extensions/dpiswitcher.inx index 145fd9357..a4f487c97 100644 --- a/share/extensions/dpiswitcher.inx +++ b/share/extensions/dpiswitcher.inx @@ -5,10 +5,18 @@ <id>org.inkscape.dpiswitcher</id> <dependency type="executable" location="extensions">dpiswitcher.py</dependency> <dependency type="executable" location="extensions">inkex.py</dependency> - <param name="switcher" type="enum" _gui-text="Type of convert:"> + <param name="action" type="notebook"> + <page name="dpi_swicher" _gui-text="Switch DPI"> + <param name="switcher" type="enum" _gui-text="Type of convert:"> <_item value="0">DPI Switch from 90 to 96</_item> <_item value="1">DPI Switch from 96 to 90</_item> - </param> + </param> + </page> + <page name="page_info" _gui-text="Show page info"> + <_param name="d" type="description">Choose this tab if you would like to see page info previously to apply DPI Switcher.</_param> + </page> + </param> + <effect needs-live-preview="false" needs-document="no"> <object-type>all</object-type> <effects-menu> diff --git a/share/extensions/dpiswitcher.py b/share/extensions/dpiswitcher.py index a1a7a1a52..b110c259f 100644 --- a/share/extensions/dpiswitcher.py +++ b/share/extensions/dpiswitcher.py @@ -34,6 +34,9 @@ class DPISwitcher(inkex.Effect): self.OptionParser.add_option("--switcher", action="store", type="string", dest="switcher", default="0", help="Select the DPI switch you want") + self.OptionParser.add_option("--action", action="store", + type="string", dest="action", + default=None, help="") self.factor = 90.0/96.0 self.units = "px" self.unitExponent = 1.0 @@ -174,28 +177,59 @@ class DPISwitcher(inkex.Effect): return "matrix(" + matrixVal[0] + "," + str(float(matrixVal[1]) * self.factor) + "," + str(float(matrixVal[2]) * self.factor) + ")" def effect(self): - if self.options.switcher == "0": - self.factor = 96.0/90.0 + action = self.options.action.strip("\"") # TODO Is this a bug? (Extra " characters) saveout = sys.stdout sys.stdout = sys.stderr svg = self.document.getroot() - namedview = svg.find(inkex.addNS('namedview', 'sodipodi')) - namedview.set(inkex.addNS('document-units', 'inkscape'), "px") - self.units = re.sub("[0-9]*\.?[0-9]", "", svg.get('width')) - if self.units and self.units <> "px": + if action == "page_info": + print ":::SVG document related info:::" + width = svg.get('width') + if width: + print "width: " + width + height = svg.get('height') + if height: + print "height: " + height + viewBox = svg.get('viewBox') + if viewBox: + print "viewBox: " + viewBox + namedview = svg.find(inkex.addNS('namedview', 'sodipodi')) + docunits= namedview.get(inkex.addNS('document-units', 'inkscape')) + if docunits: + print "document-units: " + docunits + units = namedview.get('units') + if units: + print "units: " + units + xpathStr = '//sodipodi:guide' + guides = svg.xpath(xpathStr, namespaces=inkex.NSS) + xpathStr = '//inkscape:grid' + if guides: + numberGuides = len(guides) + print "Document has " + str(numberGuides) + " guides" + grids = svg.xpath(xpathStr, namespaces=inkex.NSS) + i = 1 + for grid in grids: + print "Grid number " + str(i) + ": Units: " + grid.get("units") + i = i+1 + else: if self.options.switcher == "0": - self.unitExponent = 1.0/(self.factor/self.__uuconv[self.units]) + self.factor = 96.0/90.0 + namedview = svg.find(inkex.addNS('namedview', 'sodipodi')) + namedview.set(inkex.addNS('document-units', 'inkscape'), "px") + self.units = re.sub("[0-9]*\.?[0-9]", "", svg.get('width')) + if self.units and self.units <> "px": + if self.options.switcher == "0": + self.unitExponent = 1.0/(self.factor/self.__uuconv[self.units]) + else: + self.unitExponent = 1.0/(self.factor/self.__uuconvLegazy[self.units]) + ''' else: - self.unitExponent = 1.0/(self.factor/self.__uuconvLegazy[self.units]) - ''' - else: - self.scaleGuides(svg) - self.unitExponent = 1.0 - self.scaleGrid(svg) - sys.stdout = saveout - return - ''' - self.scaleRoot(svg); + self.scaleGuides(svg) + self.unitExponent = 1.0 + self.scaleGrid(svg) + sys.stdout = saveout + return + ''' + self.scaleRoot(svg); sys.stdout = saveout effect = DPISwitcher() |
