From: amphi Date: Fri, 2 Mar 2007 21:57:40 +0000 (+0000) Subject: made it callable by other extensions. the workaround is sorta ugly, but it should... X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=10b12a56e54aab63863f2484a8295001563b1c67;p=inkscape.git made it callable by other extensions. the workaround is sorta ugly, but it should do the trick for now. --- diff --git a/share/extensions/embedimage.py b/share/extensions/embedimage.py index 5277f0fa4..4cab6c0a9 100644 --- a/share/extensions/embedimage.py +++ b/share/extensions/embedimage.py @@ -19,7 +19,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA import inkex, os, base64 -class MyEffect(inkex.Effect): +class Embedder(inkex.Effect): def __init__(self): inkex.Effect.__init__(self) self.OptionParser.add_option("-s", "--selectedonly", @@ -28,19 +28,28 @@ class MyEffect(inkex.Effect): help="embed only selected images") def effect(self): - ctx = inkex.xml.xpath.Context.Context(self.document,processorNss=inkex.NSS) - # if slectedonly is enabled and there is a selection only embed selected # images. otherwise embed all images if (self.options.selectedonly): - if (self.options.ids): - for id, node in self.selected.iteritems(): - if node.tagName == 'image': - self.embedImage(node) + self.embedSelected(self.document, self.selected) else: - path = '//image' - for node in inkex.xml.xpath.Evaluate(path,self.document, context=ctx): - self.embedImage(node) + self.embedAll(self.document) + + def embedSelected(self, document, selected): + self.document=document + self.selected=selected + if (self.options.ids): + for id, node in selected.iteritems(): + if node.tagName == 'image': + self.embedImage(node) + + def embedAll(self, document): + self.document=document #not that nice... oh well + ctx = inkex.xml.xpath.Context.Context(self.document,processorNss=inkex.NSS) + path = '//image' + for node in inkex.xml.xpath.Evaluate(path, self.document, context=ctx): + self.embedImage(node) + def embedImage(self, node): xlink = node.attributes.getNamedItemNS(inkex.NSS[u'xlink'],'href') if (xlink.value[:4]!='data'): @@ -91,5 +100,7 @@ class MyEffect(inkex.Effect): inkex.debug("%s is not of type image/png, image/jpeg, image/bmp, image/gif or image/x-icon" % path) else: inkex.debug("Sorry we could not locate %s" % path) -e = MyEffect() -e.affect() + +if __name__ == '__main__': + e = Embedder() + e.affect()