Code

added a "selected only" checkbox for fixing some obscure usability issue
authoramphi <amphi@users.sourceforge.net>
Tue, 9 Jan 2007 04:28:28 +0000 (04:28 +0000)
committeramphi <amphi@users.sourceforge.net>
Tue, 9 Jan 2007 04:28:28 +0000 (04:28 +0000)
share/extensions/embedimage.inx
share/extensions/embedimage.py

index eebd404a38ba3671d5f92e68c7bdad6760d22a2d..fd0c2e3b3f868a06a0a5889dc3f74a3bc419aa69 100644 (file)
@@ -3,6 +3,7 @@
     <id>org.ekips.filter.embedimage</id>
        <dependency type="executable" location="extensions">embedimage.py</dependency>
        <dependency type="executable" location="extensions">inkex.py</dependency>
+       <param name="selectedonly" type="boolean" _gui-text="Embed only selected images">false</param>
     <effect>
                <object-type>all</object-type>
                 <effects-menu>
index c7b00514b0ec7146916a9d9ab307ceb43de7f5fe..964d1a5ecfbeea57d4e583120710ee34b9c489a5 100644 (file)
@@ -22,16 +22,21 @@ import inkex, os, base64
 class MyEffect(inkex.Effect):
     def __init__(self):
         inkex.Effect.__init__(self)
+        self.OptionParser.add_option("-s", "--selectedonly",
+            action="store", type="inkbool", 
+            dest="selectedonly", default=False,
+            help="embed only selected images")
 
     def effect(self):
         ctx = inkex.xml.xpath.Context.Context(self.document,processorNss=inkex.NSS)
-        
-        # if there is a selection only embed selected images
-        # otherwise embed all images
-        if (self.options.ids):
-            for id, node in self.selected.iteritems():
-                if node.tagName == 'image':
-                    self.embedImage(node)
+
+        # 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)
         else:
             path = '//image'
             for node in inkex.xml.xpath.Evaluate(path,self.document, context=ctx):