diff options
| author | Felipe Corr??a da Silva Sanches <juca@members.fsf.org> | 2011-05-27 23:47:57 +0000 |
|---|---|---|
| committer | Felipe C. da S. Sanches <juca@members.fsf.org> | 2011-05-27 23:47:57 +0000 |
| commit | f4403f7422ce45b94a8b1e3462b9edb7ccae0c1d (patch) | |
| tree | 18ea0e417626e8515affd0ed48e8c4cc2456aef6 | |
| parent | Add "silent" option to extension inx file so that extension authors can opt-o... (diff) | |
| download | inkscape-f4403f7422ce45b94a8b1e3462b9edb7ccae0c1d.tar.gz inkscape-f4403f7422ce45b94a8b1e3462b9edb7ccae0c1d.zip | |
Extensions to alternate layer visibility for glyph layers.
These extensions are using the new "silent" option that I have introduced to the inx file sintax in the previous commit.
(bzr r10241)
| -rw-r--r-- | share/extensions/Makefile.am | 4 | ||||
| -rw-r--r-- | share/extensions/next_glyph_layer.inx | 16 | ||||
| -rw-r--r-- | share/extensions/next_glyph_layer.py | 54 | ||||
| -rw-r--r-- | share/extensions/previous_glyph_layer.inx | 16 | ||||
| -rw-r--r-- | share/extensions/previous_glyph_layer.py | 54 | ||||
| -rw-r--r-- | share/keys/default.xml | 6 |
6 files changed, 150 insertions, 0 deletions
diff --git a/share/extensions/Makefile.am b/share/extensions/Makefile.am index 78f05a827..6189427ca 100644 --- a/share/extensions/Makefile.am +++ b/share/extensions/Makefile.am @@ -102,6 +102,8 @@ extensions = \ measure.py \ motion.py \ new_glyph_layer.py \ + next_glyph_layer.py \ + previous_glyph_layer.py \ outline2svg.pl \ PathData.py \ param_curves.py \ @@ -274,6 +276,8 @@ modules = \ measure.inx \ motion.inx \ new_glyph_layer.inx \ + next_glyph_layer.inx \ + previous_glyph_layer.inx \ outline2svg.inx \ param_curves.inx \ pathalongpath.inx\ diff --git a/share/extensions/next_glyph_layer.inx b/share/extensions/next_glyph_layer.inx new file mode 100644 index 000000000..7a3b03670 --- /dev/null +++ b/share/extensions/next_glyph_layer.inx @@ -0,0 +1,16 @@ +<?xml version="1.0" encoding="UTF-8"?> +<inkscape-extension xmlns="http://www.inkscape.org/namespace/inkscape/extension"> + <_name>View Next Glyph</_name> + <id>org.inkscape.typography.nextglyphlayer</id> + <dependency type="executable" location="extensions">inkex.py</dependency> + <effect> + <object-type>all</object-type> + <effects-menu> + <submenu _name="Typography"/> + </effects-menu> + </effect> + <script> + <command reldir="extensions" interpreter="python">next_glyph_layer.py</command> + </script> + <options silent="true"></options> +</inkscape-extension> diff --git a/share/extensions/next_glyph_layer.py b/share/extensions/next_glyph_layer.py new file mode 100644 index 000000000..25f22cc9a --- /dev/null +++ b/share/extensions/next_glyph_layer.py @@ -0,0 +1,54 @@ +''' +Copyright (C) 2011 Felipe Correa da Silva Sanches + +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 +''' + +import inkex + +class NextLayer(inkex.Effect): + def __init__(self): + inkex.Effect.__init__(self) + + def effect(self): + + # Get access to main SVG document element + self.svg = self.document.getroot() + + groups = self.svg.findall(inkex.addNS('g', 'svg')) + + count=0 + glyphs=[] + for g in groups: + if "GlyphLayer-" in g.get(inkex.addNS('label', 'inkscape')): + glyphs.append(g) + if g.get("style")=="display:inline": + count+=1 + current = len(glyphs)-1 + + if count!=1 or len(glyphs)<2: + return + #TODO: inform the user? + + glyphs[current].set("style", "display:none") + glyphs[(current+1)%len(glyphs)].set("style", "display:inline") + return + +#TODO: loop + +if __name__ == '__main__': + e = NextLayer() + e.affect() + diff --git a/share/extensions/previous_glyph_layer.inx b/share/extensions/previous_glyph_layer.inx new file mode 100644 index 000000000..928016adc --- /dev/null +++ b/share/extensions/previous_glyph_layer.inx @@ -0,0 +1,16 @@ +<?xml version="1.0" encoding="UTF-8"?> +<inkscape-extension xmlns="http://www.inkscape.org/namespace/inkscape/extension"> + <_name>View Previous Glyph</_name> + <id>org.inkscape.typography.previousglyphlayer</id> + <dependency type="executable" location="extensions">inkex.py</dependency> + <effect> + <object-type>all</object-type> + <effects-menu> + <submenu _name="Typography"/> + </effects-menu> + </effect> + <script> + <command reldir="extensions" interpreter="python">previous_glyph_layer.py</command> + </script> + <options silent="true"></options> +</inkscape-extension> diff --git a/share/extensions/previous_glyph_layer.py b/share/extensions/previous_glyph_layer.py new file mode 100644 index 000000000..3ced9c571 --- /dev/null +++ b/share/extensions/previous_glyph_layer.py @@ -0,0 +1,54 @@ +''' +Copyright (C) 2011 Felipe Correa da Silva Sanches + +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 +''' + +import inkex + +class PreviousLayer(inkex.Effect): + def __init__(self): + inkex.Effect.__init__(self) + + def effect(self): + + # Get access to main SVG document element + self.svg = self.document.getroot() + + groups = self.svg.findall(inkex.addNS('g', 'svg')) + + count=0 + glyphs=[] + for g in groups: + if "GlyphLayer-" in g.get(inkex.addNS('label', 'inkscape')): + glyphs.append(g) + if g.get("style")=="display:inline": + count+=1 + current = len(glyphs)-1 + + if count!=1 or len(glyphs)<2: + return + #TODO: inform the user? + + glyphs[current].set("style", "display:none") + glyphs[current-1].set("style", "display:inline") + return + +#TODO: loop + +if __name__ == '__main__': + e = PreviousLayer() + e.affect() + diff --git a/share/keys/default.xml b/share/keys/default.xml index 9ac48d24f..e7e51f694 100644 --- a/share/keys/default.xml +++ b/share/keys/default.xml @@ -592,4 +592,10 @@ override) the bindings in the main default.xml. <bind key="g" modifiers="Ctrl,Alt" action="org.inkscape.typography.newglyphlayer" display="true"/> <bind key="G" modifiers="Ctrl,Alt" action="org.inkscape.typography.newglyphlayer"/> + <bind key="h" modifiers="Ctrl,Alt" action="org.inkscape.typography.previousglyphlayer" display="true"/> + <bind key="H" modifiers="Ctrl,Alt" action="org.inkscape.typography.previousglyphlayer"/> + + <bind key="j" modifiers="Ctrl,Alt" action="org.inkscape.typography.nextglyphlayer" display="true"/> + <bind key="J" modifiers="Ctrl,Alt" action="org.inkscape.typography.nextglyphlayer"/> + </keys> |
