summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAur??lio A. Heckert <aurium@gmail.com>2009-04-14 21:15:48 +0000
committeraurium <aurium@users.sourceforge.net>2009-04-14 21:15:48 +0000
commit05d01276087b77dfe55025ad6033eb53732cc4c1 (patch)
tree27cac8c27499d03e983938bce5bcc85c5c1969a8
parentUpdated translation template (sorry guys - connection problems for last few d... (diff)
downloadinkscape-05d01276087b77dfe55025ad6033eb53732cc4c1.tar.gz
inkscape-05d01276087b77dfe55025ad6033eb53732cc4c1.zip
a better set attribute for inkweb
(bzr r7713)
-rw-r--r--share/extensions/inkweb.js58
-rw-r--r--share/extensions/web-set-att.inx5
-rwxr-xr-xshare/extensions/web-set-att.py37
-rw-r--r--share/extensions/web-transmit-att.inx4
-rw-r--r--share/extensions/web-transmit-att.py4
5 files changed, 71 insertions, 37 deletions
diff --git a/share/extensions/inkweb.js b/share/extensions/inkweb.js
index 85f356a28..5cb48869f 100644
--- a/share/extensions/inkweb.js
+++ b/share/extensions/inkweb.js
@@ -3,23 +3,30 @@
**
** Copyright (C) 2009 Aurelio A. Heckert, aurium (a) gmail dot com
**
+** ********* Bugs and New Fetures *************************************
+** If you found any bug on this script or if you want to propose a
+** new feature, please report it in the inkscape bug traker
+** https://bugs.launchpad.net/inkscape/+filebug
+** and assign that to Aurium.
+** ********************************************************************
+**
** 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 3 of the License, or
+** it under the terms of the GNU Lesser General Public License as published
+** by the Free Software Foundation, either version 3 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.
+** GNU Lesser General Public License for more details.
**
-** You should have received a copy of the GNU General Public License
+** You should have received a copy of the GNU Lesser General Public License
** along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
var InkWeb = {
- version: 0.02,
+ version: 0.03,
NS: {
svg: "http://www.w3.org/2000/svg",
@@ -88,27 +95,30 @@ InkWeb.transmitAtt = function (conf) {
}
InkWeb.setAtt = function (conf) {
- if ( typeof(conf.el) == "string" )
- conf.el = document.getElementById( conf.el );
+ if ( ! conf.el.join )
+ conf.to = [ conf.el ];
conf.att = conf.att.split( /\s+/ );
conf.val = conf.val.split( /\s+/ );
- var att;
- for ( var i=0; att=conf.att[i]; i++ ) {
- if (
- att == "width" ||
- att == "height" ||
- att == "x" ||
- att == "y" ||
- att == "cx" ||
- att == "cy" ||
- att == "r" ||
- att == "rx" ||
- att == "ry" ||
- att == "transform"
- ) {
- conf.el.setAttribute( att, conf.val[i] );
- } else {
- this.setStyle( conf.el, att, conf.val[i] );
+ for ( var el,elN=0; el=conf.el[elN]; elN++ ) {
+ if ( typeof(el) == "string" )
+ el = document.getElementById( el );
+ for ( var att,i=0; att=conf.att[i]; i++ ) {
+ if (
+ att == "width" ||
+ att == "height" ||
+ att == "x" ||
+ att == "y" ||
+ att == "cx" ||
+ att == "cy" ||
+ att == "r" ||
+ att == "rx" ||
+ att == "ry" ||
+ att == "transform"
+ ) {
+ el.setAttribute( att, conf.val[i] );
+ } else {
+ this.setStyle( el, att, conf.val[i] );
+ }
}
}
}
diff --git a/share/extensions/web-set-att.inx b/share/extensions/web-set-att.inx
index 9c32cd99c..af6461aa1 100644
--- a/share/extensions/web-set-att.inx
+++ b/share/extensions/web-set-att.inx
@@ -29,6 +29,11 @@
<_item value="prepend">Run it before</_item>
<_item value="replace">Replace</_item>
</param>
+ <_param name="help" type="description">The next parameter is useful when you select more than two elements</_param>
+ <param name="from-and-to" type="enum" _gui-text="Source and destination of setting">
+ <_item value="g-to-one">All selected ones set an attribute in the last one</_item>
+ <_item value="one-to-g">The first selected set an attribute in all others</_item>
+ </param>
<effect>
<object-type>all</object-type>
<effects-menu>
diff --git a/share/extensions/web-set-att.py b/share/extensions/web-set-att.py
index 520120f7e..183615ba8 100755
--- a/share/extensions/web-set-att.py
+++ b/share/extensions/web-set-att.py
@@ -40,6 +40,10 @@ class InkWebTransmitAtt(inkwebeffect.InkWebEffect):
action="store", type="string",
dest="compatibility", default="append",
help="Compatibility with previews code to this event.")
+ self.OptionParser.add_option("-t", "--from-and-to",
+ action="store", type="string",
+ dest="from_and_to", default="g-to-one",
+ help='Who transmit to Who? "g-to-one" All set the last. "one-to-g" The first set all.')
def effect(self):
self.ensureInkWebSupport()
@@ -48,20 +52,33 @@ class InkWebTransmitAtt(inkwebeffect.InkWebEffect):
inkwebeffect.inkex.errormsg(_("You must to select at least two elements."))
exit(1)
- elFrom = self.selected[ self.options.ids[0] ]
- idTo = self.options.ids[1]
+ elFrom = []
+ idTo = []
+ if self.options.from_and_to == "g-to-one":
+ # All set the last
+ for selId in self.options.ids[:-1]:
+ elFrom.append( self.selected[selId] )
+ idTo.append( self.options.ids[-1] )
+ else:
+ # The first set all
+ elFrom.append( self.selected[ self.options.ids[0] ] )
+ for selId in self.options.ids[1:]:
+ idTo.append( selId )
- prevEvCode = elFrom.get( self.options.when )
- if prevEvCode == None: prevEvCode = ""
+ evCode = "InkWeb.setAtt({el:['"+ "','".join(idTo) +"'], " + \
+ "att:'"+ self.options.att +"', " + \
+ "val:'"+ self.options.val +"'})"
- evCode = "InkWeb.setAtt({el:'"+idTo+"', att:'"+self.options.att+"', val:'"+self.options.val+"'})"
+ for el in elFrom:
+ prevEvCode = el.get( self.options.when )
+ if prevEvCode == None: prevEvCode = ""
- if self.options.compatibility == 'append':
- evCode = prevEvCode +";\n"+ evCode
- if self.options.compatibility == 'prepend':
- evCode = evCode +";\n"+ prevEvCode
+ if self.options.compatibility == 'append':
+ elEvCode = prevEvCode +";\n"+ evCode
+ if self.options.compatibility == 'prepend':
+ elEvCode = evCode +";\n"+ prevEvCode
- elFrom.set( self.options.when, evCode )
+ el.set( self.options.when, elEvCode )
if __name__ == '__main__':
e = InkWebTransmitAtt()
diff --git a/share/extensions/web-transmit-att.inx b/share/extensions/web-transmit-att.inx
index b563f8498..c1d5895b3 100644
--- a/share/extensions/web-transmit-att.inx
+++ b/share/extensions/web-transmit-att.inx
@@ -29,8 +29,8 @@
</param>
<_param name="help" type="description">The next parameter is useful when you select more than two elements</_param>
<param name="from-and-to" type="enum" _gui-text="Source and destination of transmitting">
- <_item value="g-to-one">All attributes transmit to the last one</_item>
- <_item value="one-to-g">The first attribute transmits to all</_item>
+ <_item value="g-to-one">All selected ones transmits to the last one</_item>
+ <_item value="one-to-g">The first selected transmits to all others</_item>
</param>
<effect>
<object-type>all</object-type>
diff --git a/share/extensions/web-transmit-att.py b/share/extensions/web-transmit-att.py
index 9c7844dfc..1e75e1b9b 100644
--- a/share/extensions/web-transmit-att.py
+++ b/share/extensions/web-transmit-att.py
@@ -61,7 +61,9 @@ class InkWebTransmitAtt(inkwebeffect.InkWebEffect):
for selId in self.options.ids[1:]:
idTo.append( selId )
- evCode = "InkWeb.transmitAtt({from:this, to:['"+ "','".join(idTo) +"'], att:'"+self.options.att+"'})"
+ evCode = "InkWeb.transmitAtt({from:this, " + \
+ "to:['"+ "','".join(idTo) +"'], " + \
+ "att:'"+ self.options.att +"'})"
for el in elFrom:
prevEvCode = el.get( self.options.when )