Code

Extensions. New -Save Background- option and help tab in Gimp XCF export.
authorJazzyNico <nicoduf@yahoo.fr>
Thu, 12 Aug 2010 15:01:54 +0000 (17:01 +0200)
committerJazzyNico <nicoduf@yahoo.fr>
Thu, 12 Aug 2010 15:01:54 +0000 (17:01 +0200)
share/extensions/gimp_xcf.inx
share/extensions/gimp_xcf.py

index 6f24485f0b465563e4fbeabe0020fca6aa1eed20..399d2a0f812754aa7830bdc6273d4aed0ce9c1bc 100644 (file)
@@ -6,9 +6,21 @@
        <dependency type="executable" location="extensions">gimp_xcf.py</dependency>
        <dependency type="executable" location="extensions">inkex.py</dependency>
        <dependency type="executable" location="path">gimp</dependency>
-       
-       <param name="guides" type="boolean" _gui-text="Save Guides:">false</param>
-       <param name="grid" type="boolean" _gui-text="Save Grid:">false</param>
+       <param name="tab" type="notebook">
+        <page name="Options" _gui-text="Options">
+        <param name="guides" type="boolean" _gui-text="Save Guides:">false</param>
+        <param name="grid" type="boolean" _gui-text="Save Grid:">false</param>
+        <param name="background" type="boolean" _gui-text="Save Background:">false</param>
+        </page>
+        <page name="Help" _gui-text="Help">
+            <_param name="instructions" type="description" xml:space="preserve">This extension exports the document to Gimp XCF format according to the following options:
+    * Save Guides: convert all guides to Gimp guides.
+    * Save Grid: convert the first rectangular grid to a Gimp grid (note that the default Inkscape grid is very narrow when shown in Gimp).
+    * Save Background: add the document background to each converted layer.
+
+Each first level layer is converted to a Gimp layer. Sublayers are are concatenated and converted with their first level parent layer into a single Gimp layer.</_param>
+        </page>
+    </param>        
     <output>
                 <extension>.xcf</extension>
                 <mimetype>application/x-xcf</mimetype>
index 6522f94d5c60fa4f33f883da90b8d0aa70309d5d..02127059c990d60953aea22fed4b59f5c1b727c3 100755 (executable)
@@ -29,6 +29,9 @@ except:
 class MyEffect(inkex.Effect):
     def __init__(self):
         inkex.Effect.__init__(self)
+        self.OptionParser.add_option("--tab",
+                                     action="store", type="string",
+                                     dest="tab")
         self.OptionParser.add_option("-d", "--guides",
                                          action="store", type="inkbool",
                                          dest="saveGuides", default=False,
@@ -37,6 +40,11 @@ class MyEffect(inkex.Effect):
                                          action="store", type="inkbool",
                                          dest="saveGrid", default=False,
                                          help="Save the Grid with the .XCF")
+        self.OptionParser.add_option("-b", "--background",
+                                         action="store", type="inkbool",
+                                         dest="layerBackground", default=False,
+                                         help="Add background color to each layer")
+
     def output(self):
         pass
 
@@ -99,6 +107,11 @@ class MyEffect(inkex.Effect):
 
         # Layers
         area = '--export-area-page'
+        opacity = '--export-background-opacity='
+        if self.options.layerBackground:
+            opacity += "1"
+        else:
+            opacity += "0"
         pngs = []
         names = []
         path = "/svg:svg/*[name()='g' or @style][@id]"
@@ -110,7 +123,7 @@ class MyEffect(inkex.Effect):
                 else:
                     name = id
                 filename = os.path.join(tmp_dir, "%s.png" % id)
-                command = "inkscape -i %s -j %s -e %s %s " % (id, area, filename, svg_file)
+                command = "inkscape -i %s -j %s %s -e %s %s " % (id, area, opacity, filename, svg_file)
                 if bsubprocess:
                     p = Popen(command, shell=True, stdout=PIPE, stderr=PIPE)
                     return_code = p.wait()