diff options
| author | Aurelio A. Heckert (a) <auriumgmaildotcom> | 2010-03-29 18:46:20 +0000 |
|---|---|---|
| committer | Aurelio A. Heckert (a) <auriumgmaildotcom> | 2010-03-29 18:46:20 +0000 |
| commit | d43f0f04589e66a600ec71b154519b34157ad784 (patch) | |
| tree | f91dce0c38dcc24aabbd2626cde3007091c524bb /share/extensions | |
| parent | Purge use of SP_ACTIVE_* and encapsulate by moving 'active' desktop tracking ... (diff) | |
| download | inkscape-d43f0f04589e66a600ec71b154519b34157ad784.tar.gz inkscape-d43f0f04589e66a600ec71b154519b34157ad784.zip | |
webslicer effects now extends a commom WebSlicer_Effect class
(bzr r9253)
Diffstat (limited to 'share/extensions')
| -rw-r--r-- | share/extensions/webslicer_create_group.inx (renamed from share/extensions/webslicer-create-group.inx) | 5 | ||||
| -rwxr-xr-x | share/extensions/webslicer_create_group.py (renamed from share/extensions/webslicer-create-group.py) | 0 | ||||
| -rw-r--r-- | share/extensions/webslicer_create_rect.inx (renamed from share/extensions/webslicer-create-rect.inx) | 5 | ||||
| -rwxr-xr-x | share/extensions/webslicer_create_rect.py (renamed from share/extensions/webslicer-create-rect.py) | 28 | ||||
| -rw-r--r-- | share/extensions/webslicer_effect.py | 52 | ||||
| -rw-r--r-- | share/extensions/webslicer_export.inx (renamed from share/extensions/webslicer-export.inx) | 5 | ||||
| -rwxr-xr-x | share/extensions/webslicer_export.py (renamed from share/extensions/webslicer-export.py) | 13 |
7 files changed, 73 insertions, 35 deletions
diff --git a/share/extensions/webslicer-create-group.inx b/share/extensions/webslicer_create_group.inx index b5c5b48ed..3e4a66dec 100644 --- a/share/extensions/webslicer-create-group.inx +++ b/share/extensions/webslicer_create_group.inx @@ -2,7 +2,8 @@ <inkscape-extension xmlns="http://www.inkscape.org/namespace/inkscape/extension"> <_name>Set a layout group</_name> <id>org.inkscape.web.slicer.create-group</id> - <dependency type="executable" location="extensions">webslicer-create-group.py</dependency> + <dependency type="executable" location="extensions">webslicer_effect.py</dependency> + <dependency type="executable" location="extensions">webslicer_create_group.py</dependency> <dependency type="executable" location="extensions">inkex.py</dependency> <_param name="about" type="description">Layout Group is only about to help a better code generation (if you need it). To use this, first you must to select some "Slicer rectangles".</_param> <param name="html-id" type="string" _gui-text="HTML id atribute"></param> @@ -26,6 +27,6 @@ </effects-menu> </effect> <script> - <command reldir="extensions" interpreter="python">webslicer-create-group.py</command> + <command reldir="extensions" interpreter="python">webslicer_create_group.py</command> </script> </inkscape-extension> diff --git a/share/extensions/webslicer-create-group.py b/share/extensions/webslicer_create_group.py index aadfded38..aadfded38 100755 --- a/share/extensions/webslicer-create-group.py +++ b/share/extensions/webslicer_create_group.py diff --git a/share/extensions/webslicer-create-rect.inx b/share/extensions/webslicer_create_rect.inx index 7ac681e69..776d269e8 100644 --- a/share/extensions/webslicer-create-rect.inx +++ b/share/extensions/webslicer_create_rect.inx @@ -2,7 +2,8 @@ <inkscape-extension xmlns="http://www.inkscape.org/namespace/inkscape/extension"> <_name>Create a slicer rectangle</_name> <id>org.inkscape.web.slicer.create-rect</id> - <dependency type="executable" location="extensions">webslicer-create-rect.py</dependency> + <dependency type="executable" location="extensions">webslicer_effect.py</dependency> + <dependency type="executable" location="extensions">webslicer_create_rect.py</dependency> <dependency type="executable" location="extensions">inkex.py</dependency> <param name="name" type="string" _gui-text="Name"></param> <param name="format" type="enum" _gui-text="Format"> @@ -61,6 +62,6 @@ </effects-menu> </effect> <script> - <command reldir="extensions" interpreter="python">webslicer-create-rect.py</command> + <command reldir="extensions" interpreter="python">webslicer_create_rect.py</command> </script> </inkscape-extension> diff --git a/share/extensions/webslicer-create-rect.py b/share/extensions/webslicer_create_rect.py index 957d6a8b2..8c1e5e5ac 100755 --- a/share/extensions/webslicer-create-rect.py +++ b/share/extensions/webslicer_create_rect.py @@ -17,6 +17,7 @@ along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA ''' +import webslicer_effect import inkex import gettext @@ -28,10 +29,10 @@ def is_empty(val): else: return len(str(val)) == 0 -class WebSlicer_CreateRect(inkex.Effect): +class WebSlicer_CreateRect(webslicer_effect.WebSlicer_Effect): def __init__(self): - inkex.Effect.__init__(self) + webslicer_effect.WebSlicer_Effect.__init__(self) self.OptionParser.add_option("--name", action="store", type="string", dest="name", @@ -107,7 +108,7 @@ class WebSlicer_CreateRect(inkex.Effect): def effect(self): self.validate_options() - layer = self.get_slicer_layer() + layer = self.get_slicer_layer(True) #TODO: get selected elements to define location and size rect = inkex.etree.SubElement(layer, 'rect') if is_empty(self.options.name): @@ -141,33 +142,18 @@ class WebSlicer_CreateRect(inkex.Effect): 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' ]) ) + conf_list.extend( self.get_conf_from_list([ 'gif_type', 'palette_size' ]) ) if self.options.format == 'jpg': - conf_list.extend( get_conf_from_list([ 'quality' ]) ) + conf_list.extend( self.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) ) + conf_list.extend( self.get_conf_from_list(conf_general_atts) ) return conf_list - def get_slicer_layer(self): - # Test if webslicer-layer layer existis - layer = self.document.xpath( - '//*[@id="webslicer-layer" and @inkscape:groupmode="layer"]', - namespaces=inkex.NSS) - if len(layer) is 0: - # Create a new layer - layer = inkex.etree.SubElement(self.document.getroot(), 'g') - layer.set('id', 'webslicer-layer') - layer.set(inkex.addNS('label', 'inkscape'), 'Web Slicer') - layer.set(inkex.addNS('groupmode', 'inkscape'), 'layer') - else: - layer = layer[0] - return layer - if __name__ == '__main__': e = WebSlicer_CreateRect() diff --git a/share/extensions/webslicer_effect.py b/share/extensions/webslicer_effect.py new file mode 100644 index 000000000..37bea447b --- /dev/null +++ b/share/extensions/webslicer_effect.py @@ -0,0 +1,52 @@ +#!/usr/bin/env python +''' +Copyright (C) 2010 Aurelio A. Heckert, aurium (a) gmail dot com + +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 + + +def is_empty(val): + if val is None: + return True + else: + return len(str(val)) == 0 + + +class WebSlicer_Effect(inkex.Effect): + + def __init__(self): + inkex.Effect.__init__(self) + + def get_slicer_layer(self, force_creation=False): + # Test if webslicer-layer layer existis + layer = self.document.xpath( + '//*[@id="webslicer-layer" and @inkscape:groupmode="layer"]', + namespaces=inkex.NSS) + if len(layer) is 0: + if force_creation: + # Create a new layer + layer = inkex.etree.SubElement(self.document.getroot(), 'g') + layer.set('id', 'webslicer-layer') + layer.set(inkex.addNS('label', 'inkscape'), 'Web Slicer') + layer.set(inkex.addNS('groupmode', 'inkscape'), 'layer') + else: + layer = None + else: + layer = layer[0] + return layer + diff --git a/share/extensions/webslicer-export.inx b/share/extensions/webslicer_export.inx index 9f7aac323..2434c9582 100644 --- a/share/extensions/webslicer-export.inx +++ b/share/extensions/webslicer_export.inx @@ -2,7 +2,8 @@ <inkscape-extension xmlns="http://www.inkscape.org/namespace/inkscape/extension"> <_name>Export layout pieces and HTML+CSS code</_name> <id>org.inkscape.web.slicer.export</id> - <dependency type="executable" location="extensions">webslicer-export.py</dependency> + <dependency type="executable" location="extensions">webslicer_effect.py</dependency> + <dependency type="executable" location="extensions">webslicer_export.py</dependency> <dependency type="executable" location="extensions">inkex.py</dependency> <_param name="about" type="description">All sliced images, and optionaly code, will be generated as you had configured and saved to one directory.</_param> <param name="dir" type="string" _gui-text="Directory path to export"></param> @@ -16,6 +17,6 @@ </effects-menu> </effect> <script> - <command reldir="extensions" interpreter="python">webslicer-export.py</command> + <command reldir="extensions" interpreter="python">webslicer_export.py</command> </script> </inkscape-extension> diff --git a/share/extensions/webslicer-export.py b/share/extensions/webslicer_export.py index c8e4cbb0d..1d5057a43 100755 --- a/share/extensions/webslicer-export.py +++ b/share/extensions/webslicer_export.py @@ -17,6 +17,7 @@ along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA ''' +import webslicer_effect import inkex import gettext import os.path @@ -24,16 +25,10 @@ import commands _ = gettext.gettext -def is_empty(val): - if val is None: - return True - else: - return len(str(val)) == 0 - -class WebSlicer_Export(inkex.Effect): +class WebSlicer_Export(webslicer_effect.WebSlicer_Effect): def __init__(self): - inkex.Effect.__init__(self) + webslicer_effect.WebSlicer_Effect.__init__(self) self.OptionParser.add_option("--with-code", action="store", type="string", dest="with_code", @@ -51,6 +46,8 @@ class WebSlicer_Export(inkex.Effect): inkex.errormsg(_('The directory "%s" does not exists.') % self.options.dir) return (status, output) = commands.getstatusoutput("inkscape -e ...") + inkex.errormsg( status ) + inkex.errormsg( output ) if __name__ == '__main__': |
