home *** CD-ROM | disk | FTP | other *** search
/ Mac Easy 2010 May / Mac Life Ubuntu.iso / casper / filesystem.squashfs / usr / share / gimp / 2.0 / help / en / gimp-using-script-fu-tutorial-first-script.html < prev    next >
Encoding:
Extensible Markup Language  |  2008-05-03  |  30.0 KB  |  809 lines

  1. <?xml version="1.0" encoding="UTF-8" standalone="no"?>
  2. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  3. <html xmlns="http://www.w3.org/1999/xhtml">
  4.   <head>
  5.     <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
  6.     <title>3.4.¬† Your First Script-Fu Script</title>
  7.     <link rel="stylesheet" href="gimp-help-plain.css" type="text/css" />
  8.     <link rel="stylesheet" href="gimp-help-screen.css" type="text/css" />
  9.     <link rel="stylesheet" href="gimp-help-custom.css" type="text/css" />
  10.     <link rel="alternate stylesheet" href="gimp22.css" type="text/css" title="gimp22" />
  11.     <meta name="generator" content="DocBook XSL Stylesheets V1.73.2" />
  12.     <link rel="start" href="index.html" title="GNU Image Manipulation Program" />
  13.     <link rel="up" href="gimp-using-script-fu-tutorial.html" title="3.¬† A Script-Fu Tutorial" />
  14.     <link rel="prev" href="gimp-using-script-fu-tutorial-lists.html" title="3.3.¬† Lists, Lists And More Lists" />
  15.     <link rel="next" href="gimp-using-script-fu-tutorial-script.html" title="3.5.¬† Giving Our Script Some Guts" />
  16.   </head>
  17.   <body>
  18.     <div class="navheader">
  19.       <table width="100%" summary="Navigation header">
  20.         <tr>
  21.           <th colspan="3" align="center">3.4.¬†
  22.       <span lang="en" xml:lang="en">Your First Script-Fu Script</span>
  23.     </th>
  24.         </tr>
  25.         <tr>
  26.           <td width="20%" align="left"><a accesskey="p" href="gimp-using-script-fu-tutorial-lists.html"><img src="../images/prev.png" alt="Prev" /></a>¬†</td>
  27.           <th width="60%" align="center">3.¬†
  28.     <span lang="en" xml:lang="en">A Script-Fu Tutorial</span>
  29.   </th>
  30.           <td width="20%" align="right">¬†<a accesskey="n" href="gimp-using-script-fu-tutorial-script.html"><img src="../images/next.png" alt="Next" /></a></td>
  31.         </tr>
  32.       </table>
  33.       <hr />
  34.     </div>
  35.     <div class="sect2" lang="en" xml:lang="en">
  36.       <div class="titlepage">
  37.         <div>
  38.           <div>
  39.             <h3 class="title"><a id="gimp-using-script-fu-tutorial-first-script"></a>3.4.¬†
  40.       <span lang="en" xml:lang="en">Your First Script-Fu Script</span>
  41.     </h3>
  42.           </div>
  43.         </div>
  44.       </div>
  45.       <p>
  46.       Do you not need to stop and catch your breath? No? Well then,
  47.       let's proceed with your fourth lesson -- your first Script-Fu
  48.       Script.
  49.     </p>
  50.       <div class="sect3" lang="en" xml:lang="en">
  51.         <div class="titlepage">
  52.           <div>
  53.             <div>
  54.               <h4 class="title"><a id="id2617958"></a>3.4.1.¬†
  55.         <span lang="en" xml:lang="en">Creating A Text Box Script</span>
  56.       </h4>
  57.             </div>
  58.           </div>
  59.         </div>
  60.         <p>
  61.         One of the most common operations I perform in GIMP is
  62.         creating a box with some text in it for a web page, a logo or
  63.         whatever. However, you never quite know how big to make the
  64.         initial image when you start out. You don't know how much
  65.         space the text will fill with the font and font size you
  66.         want.
  67.       </p>
  68.         <p>
  69.         The Script-Fu Master (and student) will quickly realize that
  70.         this problem can easily be solved and automated with
  71.         Script-Fu.
  72.       </p>
  73.         <p>
  74.         We will, therefore, create a script, called Text Box, which
  75.         creates an image correctly sized to fit snugly around a line
  76.         of text the user inputs. We'll also let the user choose the
  77.         font, font size and text color.
  78.       </p>
  79.       </div>
  80.       <div class="sect3" lang="en" xml:lang="en">
  81.         <div class="titlepage">
  82.           <div>
  83.             <div>
  84.               <h4 class="title"><a id="id2617999"></a>3.4.2.¬†
  85.         <span lang="en" xml:lang="en">Editing And Storing Your Scripts</span>
  86.       </h4>
  87.             </div>
  88.           </div>
  89.         </div>
  90.         <p>
  91.         Up until now, we've been working in the Script-Fu Console. Now,
  92.         however, we're going to switch to editing script text files.
  93.       </p>
  94.         <p>
  95.         Where you place your scripts is a matter of preference -- if you have
  96.         access to GIMP's default script directory, you can place your scripts
  97.         there. However, I prefer keeping my personal scripts in my own script
  98.         directory, to keep them separate from the factory-installed scripts.
  99.       </p>
  100.         <p>
  101.         In the <code class="filename">.gimp-2.4</code> directory that GIMP made
  102.         off of your home directory, you should find a directory called
  103.         <code class="filename">scripts</code>. GIMP will automatically look in
  104.         your <code class="filename">.gimp-2.4</code> directory for a scripts
  105.         directory, and add the
  106.         scripts in this directory to the Script-Fu database. You
  107.         should place your personal scripts here.
  108.       </p>
  109.       </div>
  110.       <div class="sect3" lang="en" xml:lang="en">
  111.         <div class="titlepage">
  112.           <div>
  113.             <div>
  114.               <h4 class="title"><a id="id2618058"></a>3.4.3.¬†
  115.         <span lang="en" xml:lang="en">The Bare Essentials</span>
  116.       </h4>
  117.             </div>
  118.           </div>
  119.         </div>
  120.         <p>
  121.         Every Script-Fu script defines at least one function, which is the
  122.         script's main function. This is where you do the work.
  123.       </p>
  124.         <p>
  125.         Every script must also register with the procedural database, so you
  126.         can access it within GIMP.
  127.       </p>
  128.         <p>We'll define the main function first:</p>
  129.         <pre class="programlisting">
  130.         (define (script-fu-text-box inText inFont inFontSize inTextColor))
  131.       </pre>
  132.         <p>
  133.         Here, we've defined a new function called script-fu-text-box that
  134.         takes four parameters, which will later correspond to some text, a
  135.         font, the font size, and the text's color. The function is currently
  136.         empty and thus does nothing. So far, so good -- nothing new, nothing
  137.         fancy.
  138.       </p>
  139.       </div>
  140.       <div class="sect3" lang="en" xml:lang="en">
  141.         <div class="titlepage">
  142.           <div>
  143.             <div>
  144.               <h4 class="title"><a id="id2618108"></a>3.4.4.¬†
  145.         <span lang="en" xml:lang="en">Naming Conventions</span>
  146.       </h4>
  147.             </div>
  148.           </div>
  149.         </div>
  150.         <p>
  151.         Scheme's naming conventions seem to prefer lowercase letters with
  152.         hyphens, which I've followed in the naming of the function. However,
  153.         I've departed from the convention with the parameters. I like more
  154.         descriptive names for my parameters and variables, and thus add the
  155.         "in" prefix to the parameters so I can quickly see that they're values
  156.         passed into the script, rather than created within it. I use the
  157.         prefix "the" for variables defined within the script.
  158.       </p>
  159.         <p>
  160.         It's GIMP convention to name your script functions script-fu-abc,
  161.         because then when they're listed in the procedural database, they'll
  162.         all show up under script-fu when you're listing the functions. This
  163.         also helps distinguish them from plug-ins.
  164.       </p>
  165.       </div>
  166.       <div class="sect3" lang="en" xml:lang="en">
  167.         <div class="titlepage">
  168.           <div>
  169.             <div>
  170.               <h4 class="title"><a id="id2618144"></a>3.4.5.¬†
  171.         <span lang="en" xml:lang="en">Registering The Function</span>
  172.       </h4>
  173.             </div>
  174.           </div>
  175.         </div>
  176.         <p>
  177.         Now, let's register the function with GIMP. This is done by
  178.         calling the function <code class="code">script-fu-register</code>. When
  179.         GIMP reads in a
  180.         script, it will execute this function, which registers the
  181.         script with the procedural database. You can place this
  182.         function call wherever you wish in your script, but I usually
  183.         place it at the end, after all my other code.
  184.       </p>
  185.         <p>
  186.         Here's the listing for registering this function (I will
  187.         explain all its parameters in a minute):
  188.       </p>
  189.         <pre class="programlisting">
  190.         (script-fu-register
  191.           "script-fu-text-box"                        ;func name
  192.           "Text Box"                                  ;menu label
  193.           "Creates a simple text box, sized to fit\
  194.             around the user's choice of text,\
  195.             font, font size, and color."              ;description
  196.           "Michael Terry"                             ;author
  197.           "copyright 1997, Michael Terry"             ;copyright notice
  198.           "October 27, 1997"                          ;date created
  199.           ""                     ;image type that the script works on
  200.           SF-STRING      "Text:"         "Text Box"   ;a string variable
  201.           SF-FONT        "Font:"         "Charter"    ;a font variable
  202.           SF-ADJUSTMENT  "Font size"     '(50 1 1000 1 10 0 1)
  203.                                                       ;a spin-button
  204.           SF-COLOR       "Color:"        '(0 0 0)     ;color variable
  205.         )
  206.         (script-fu-menu-register "script-fu-text-box" "<Toolbox>/Xtns/Script-Fu/Text")
  207.       </pre>
  208.         <p>
  209.         If you save these functions in a text file with a
  210.         <code class="filename">.scm</code> suffix
  211.         in your script directory, then choose
  212.         <span class="guimenu">Xtns</span> ‚Üí <span class="guisubmenu">Script-Fu</span> ‚Üí <span class="guimenuitem">Refresh Scripts</span>,
  213.         this new script will appear as
  214.         <span class="guimenu"> Xtns</span> ‚Üí <span class="guisubmenu">Script-Fu</span> ‚Üí <span class="guisubmenu">Text</span> ‚Üí <span class="guimenuitem">Text Box</span>.
  215.       </p>
  216.         <p>
  217.         If you invoke this new script, it won't do anything, of course, but
  218.         you can view the prompts you created when registering the script (more
  219.         information about what we did is covered next).
  220.       </p>
  221.         <p>
  222.         Finally, if you invoke the Procedure Browser (
  223.         <span class="guimenu"> Xtns</span> ‚Üí <span class="guimenuitem">Procedure Browser</span>),
  224.         you'll notice that our script now
  225.         appears in the database.
  226.       </p>
  227.       </div>
  228.       <div class="sect3" lang="en" xml:lang="en">
  229.         <div class="titlepage">
  230.           <div>
  231.             <div>
  232.               <h4 class="title"><a id="id2618319"></a>3.4.6.¬†
  233.         <span lang="en" xml:lang="en">Steps For Registering The Script</span>
  234.       </h4>
  235.             </div>
  236.           </div>
  237.         </div>
  238.         <p>
  239.         To register our script with GIMP, we call the function
  240.         script-fu-register, fill in the seven required parameters and add our
  241.         script's own parameters, along with a description and default value
  242.         for each parameter.
  243.       </p>
  244.         <div class="itemizedlist">
  245.           <p class="title">
  246.             <b>
  247.           <span lang="en" xml:lang="en">The Required Parameters</span>
  248.         </b>
  249.           </p>
  250.           <ul type="disc">
  251.             <li>
  252.               <p>
  253.            The <span class="emphasis"><em>name</em></span> of the function we
  254.            defined. This is the function called when our script is invoked
  255.            (the entry-point into our script). This is necessary because we may
  256.            define additional functions within the same file, and GIMP needs to
  257.            know which of these functions to call. In our example, we only
  258.            defined one function, text-box, which we registered.
  259.           </p>
  260.             </li>
  261.             <li>
  262.               <p>
  263.             The <span class="emphasis"><em>location</em></span> in the menu where
  264.             the script will be inserted. The exact location of the script is
  265.             specified like a path in Unix, with the root of the path being
  266.             either toolbox or right-click.
  267.           </p>
  268.               <p>
  269.             If your script does not operate on an existing image (and thus
  270.             creates a new image, like our Text Box script will), you'll want
  271.             to insert it in the toolbox menu -- this is the menu in GIMP's
  272.             main window (where all the tools are located: the selection tools,
  273.             magnifying glass, etc.).
  274.           </p>
  275.               <p>
  276.             If your script is intended to work on an image being edited,
  277.             you'll want to insert it in the menu that appears when you
  278.             right-click on an open image. The rest of the path points to
  279.             the menu lists, menus and sub-menus. Thus, we registered our
  280.             Text Box script in the Text menu of the Script-Fu menu of
  281.             the Xtns menu of the toolbox (
  282.             <span class="guimenu"> Xtns</span> ‚Üí <span class="guisubmenu">Script-Fu</span> ‚Üí <span class="guisubmenu">Text</span> ‚Üí <span class="guimenuitem">Text Box</span> ).
  283.           </p>
  284.               <p>
  285.             If you notice, the Text sub-menu in the Script-Fu menu wasn't
  286.             there when we began -- GIMP automatically creates any menus not
  287.             already existing.
  288.           </p>
  289.             </li>
  290.             <li>
  291.               <p>
  292.             A <span class="emphasis"><em>description</em></span> of your
  293.             script, to be displayed in the Procedure Browser.
  294.           </p>
  295.             </li>
  296.             <li>
  297.               <p>
  298.             <span class="emphasis"><em>Your name</em></span> (the author of
  299.             the script).
  300.           </p>
  301.             </li>
  302.             <li>
  303.               <p>
  304.             <span class="emphasis"><em>Copyright</em></span> information.
  305.           </p>
  306.             </li>
  307.             <li>
  308.               <p>
  309.             The <span class="emphasis"><em>date</em></span> the script was
  310.             made, or the last revision of the script.
  311.           </p>
  312.             </li>
  313.             <li>
  314.               <p>
  315.             The <span class="emphasis"><em>types</em></span> of images the script
  316.             works on. This may be any of the following: RGB, RGBA, GRAY,
  317.             GRAYA, INDEXED, INDEXEDA. Or it may be none at all -- in our case,
  318.             we're creating an image, and thus don't need to define the type of
  319.             image on which we work.
  320.           </p>
  321.             </li>
  322.           </ul>
  323.         </div>
  324.         <div class="figure">
  325.           <a id="id2618524"></a>
  326.           <p class="title">
  327.             <b>Figure¬†12.4.¬†
  328.           <span lang="en" xml:lang="en">The menu of our script.</span>
  329.         </b>
  330.           </p>
  331.           <div class="figure-contents">
  332.             <div class="mediaobject">
  333.               <img src="../images/using/script-fu-menu.png" alt="The menu of our script." />
  334.             </div>
  335.           </div>
  336.         </div>
  337.         <br class="figure-break" />
  338.       </div>
  339.       <div class="sect3" lang="en" xml:lang="en">
  340.         <div class="titlepage">
  341.           <div>
  342.             <div>
  343.               <h4 class="title"><a id="id2618557"></a>3.4.7.¬†
  344.         <span lang="en" xml:lang="en">Registering The Script's Parameters</span>
  345.       </h4>
  346.             </div>
  347.           </div>
  348.         </div>
  349.         <p>
  350.         Once we have listed the required parameters, we then need to list the
  351.         parameters that correspond to the parameters our script needs. When we
  352.         list these params, we give hints as to what their types are. This is
  353.         for the dialog which pops up when the user selects our script. We also
  354.         provide a default value.
  355.       </p>
  356.         <p>
  357.         This section of the registration process has the following format:
  358.       </p>
  359.         <div class="informaltable">
  360.           <table border="1">
  361.             <colgroup>
  362.               <col />
  363.               <col />
  364.               <col />
  365.             </colgroup>
  366.             <thead>
  367.               <tr>
  368.                 <th>
  369.                 <p>Param Type</p>
  370.               </th>
  371.                 <th>
  372.                 <p>Description</p>
  373.               </th>
  374.                 <th>
  375.                 <p>Example</p>
  376.               </th>
  377.               </tr>
  378.             </thead>
  379.             <tbody>
  380.               <tr>
  381.                 <td>
  382.                 <p>SF-IMAGE</p>
  383.               </td>
  384.                 <td>
  385.                 <p>
  386.                   If your script operates on an open image, this should be the
  387.                   first parameter after the required parameters. GIMP will
  388.                   pass in a reference to the image in this parameter.
  389.                 </p>
  390.               </td>
  391.                 <td>
  392.                 <p>3</p>
  393.               </td>
  394.               </tr>
  395.               <tr>
  396.                 <td>
  397.                 <p>SF-DRAWABLE</p>
  398.               </td>
  399.                 <td>
  400.                 <p>
  401.                   If your script operates on an open image, this should be the
  402.                   second parameter after the SF-IMAGE param. It refers to the
  403.                   active layer. GIMP will pass in a reference to the active
  404.                   layer in this parameter.
  405.                 </p>
  406.               </td>
  407.                 <td>
  408.                 <p>17</p>
  409.               </td>
  410.               </tr>
  411.               <tr>
  412.                 <td>
  413.                 <p>SF-VALUE</p>
  414.               </td>
  415.                 <td>
  416.                 <p>
  417.                   Accepts numbers and strings. Note that quotes must be
  418.                   escaped for default text, so better use SF-STRING.
  419.                 </p>
  420.               </td>
  421.                 <td>
  422.                 <p>42</p>
  423.               </td>
  424.               </tr>
  425.               <tr>
  426.                 <td>
  427.                 <p>SF-STRING</p>
  428.               </td>
  429.                 <td>
  430.                 <p>Accepts strings.</p>
  431.               </td>
  432.                 <td>
  433.                 <p>"Some text"</p>
  434.               </td>
  435.               </tr>
  436.               <tr>
  437.                 <td>
  438.                 <p>SF-COLOR</p>
  439.               </td>
  440.                 <td>
  441.                 <p>
  442.                   Indicates that a color is requested in this parameter.
  443.                 </p>
  444.               </td>
  445.                 <td>
  446.                 <p>'(0 102 255)</p>
  447.               </td>
  448.               </tr>
  449.               <tr>
  450.                 <td>
  451.                 <p>SF-TOGGLE</p>
  452.               </td>
  453.                 <td>
  454.                 <p>
  455.                   A checkbox is displayed, to get a Boolean value.
  456.                 </p>
  457.               </td>
  458.                 <td>
  459.                 <p>TRUE or FALSE</p>
  460.               </td>
  461.               </tr>
  462.             </tbody>
  463.           </table>
  464.         </div>
  465.       </div>
  466.       <div class="sect3" lang="en" xml:lang="en">
  467.         <div class="titlepage">
  468.           <div>
  469.             <div>
  470.               <h4 class="title"><a id="gimp-using-script-fu-api"></a>3.4.8.¬†
  471.     <span lang="en" xml:lang="en">
  472.       The Script-Fu parameter API<sup>[<a id="id2618815" href="#ftn.id2618815" class="footnote">3</a>]</sup>
  473.     </span>
  474.   </h4>
  475.             </div>
  476.           </div>
  477.         </div>
  478.         <div class="note" style="margin-left: 0.5in; margin-right: 0.5in;">
  479.           <table border="0" summary="Note">
  480.             <tr>
  481.               <td rowspan="2" align="center" valign="top" width="25">
  482.                 <img alt="[Note]" src="../images/note.png" />
  483.               </td>
  484.               <th align="left">Note</th>
  485.             </tr>
  486.             <tr>
  487.               <td align="left" valign="top">
  488.                 <p>
  489.       Beside the above parameter types there are more types for the
  490.       interactive mode, each of them will create a widget in the control
  491.       dialog. You will find the description of these parameters and examples
  492.       in the test script
  493.       <code class="filename">plug-ins/script-fu/scripts/test-sphere.scm</code>
  494.       shipped with the <acronym class="acronym">GIMP</acronym> source code.
  495.     </p>
  496.               </td>
  497.             </tr>
  498.           </table>
  499.         </div>
  500.         <div class="informaltable">
  501.           <table border="1">
  502.             <colgroup>
  503.               <col />
  504.               <col />
  505.             </colgroup>
  506.             <thead>
  507.               <tr>
  508.                 <th>
  509.             <p>Param Type</p>
  510.           </th>
  511.                 <th>
  512.             <p>Description</p>
  513.           </th>
  514.               </tr>
  515.             </thead>
  516.             <tbody>
  517.               <tr>
  518.                 <td>
  519.             <p>SF-ADJUSTMENT</p>
  520.           </td>
  521.                 <td>
  522.             <p>
  523.               In interactive mode it creates an adjustment widget in the
  524.               dialog.
  525.             </p>
  526.             <p>
  527.               SF-ADJUSTMENT "label" '(value lower upper step_inc page_inc
  528.               digits type)
  529.             </p>
  530.             <p>"label" : Text printed before the widget.</p>
  531.             <p>value : Value print at the start.</p>
  532.             <p>
  533.               lower / upper : the lower / upper values (range of choice).
  534.             </p>
  535.             <p>step_inc : increment/decrement value.</p>
  536.             <p>
  537.               page_inc : increment/decrement value using page key.
  538.             </p>
  539.             <p>
  540.               digits : digits after the point (decimal part).
  541.             </p>
  542.             <p>
  543.               type : is one of: SF-SLIDER or 0, SF-SPINNER or 1
  544.             </p>
  545.           </td>
  546.               </tr>
  547.               <tr>
  548.                 <td>
  549.             <p>SF-COLOR</p>
  550.           </td>
  551.                 <td>
  552.             <p>Creates a color button in the dialog.</p>
  553.             <p>SF-COLOR "label" '(red green blue)</p>
  554.             <p>or</p>
  555.             <p>SF-COLOR "label" "color"</p>
  556.             <p>"label" : Text printed before the widget.</p>
  557.             <p>
  558.               '(red green blue) : list of three values for the red, green and
  559.               blue components.
  560.             </p>
  561.             <p>"color" : a color name in CSS notatation.</p>
  562.           </td>
  563.               </tr>
  564.               <tr>
  565.                 <td>
  566.             <p>SF-FONT</p>
  567.           </td>
  568.                 <td>
  569.             <p>
  570.               Creates a font-selection widget in the dialog. It returns a
  571.               fontname as a string. There are two new gimp-text procedures to
  572.               ease the use of this return parameter:
  573.             </p>
  574.             <p>
  575.               (gimp-text-fontname image drawable x-pos y-pos text border
  576.               antialias size unit font)
  577.             </p>
  578.             <p>
  579.               (gimp-text-get-extents-fontname text size unit font)
  580.             </p>
  581.             <p>
  582.               where font is the fontname you get. The size specified in the
  583.               fontname is silently ignored. It is only used in the
  584.               font-selector. So you are asked to set it to a useful value (24
  585.               pixels is a good choice).
  586.             </p>
  587.             <p>SF-FONT "label" "fontname"</p>
  588.             <p>"label" : Text printed before the widget.</p>
  589.             <p>"fontname" : name of the d√©fault font.</p>
  590.           </td>
  591.               </tr>
  592.               <tr>
  593.                 <td>
  594.             <p>SF-BRUSH</p>
  595.           </td>
  596.                 <td>
  597.             <p>
  598.               It will create a widget in the control dialog. The widget
  599.               consists of a preview area (which when pressed will produce a
  600.               popup preview ) and a button with the "..." label. The button
  601.               will popup a dialog where brushes can be selected and each of
  602.               the characteristics of the brush can be modified.
  603.             </p>
  604.             <p>SF-BRUSH "Brush" '("Circle (03)" 100 44 0)</p>
  605.             <p>
  606.               Here the brush dialog will be popped up with a default brush of
  607.               Circle (03) opacity 100 spacing 44 and paint mode of Normal
  608.               (value 0).
  609.             </p>
  610.             <p>
  611.               If this selection was unchanged the value passed to the function
  612.               as a parameter would be '("Circle (03)" 100 44 0).
  613.             </p>
  614.           </td>
  615.               </tr>
  616.               <tr>
  617.                 <td>
  618.             <p>SF-PATTERN</p>
  619.           </td>
  620.                 <td>
  621.             <p>
  622.               It will create a widget in the control dialog. The widget
  623.               consists of a preview area (which when pressed will produce a
  624.               popup preview ) and a button with the "..." label. The button
  625.               will popup a dialog where patterns can be selected.
  626.             </p>
  627.             <p>SF-PATTERN "Pattern" "Maple Leaves"</p>
  628.             <p>
  629.               The value returned when the script is invoked is a string
  630.               containing the pattern name. If the above selection was not
  631.               altered the string would contain "Maple Leaves".
  632.             </p>
  633.           </td>
  634.               </tr>
  635.               <tr>
  636.                 <td>
  637.             <p>SF-GRADIENT</p>
  638.           </td>
  639.                 <td>
  640.             <p>
  641.               It will create a widget in the control dialog. The widget
  642.               consists of a button containing a preview of the selected
  643.               gradient.
  644.             </p>
  645.             <p>
  646.               If the button is pressed a gradient selection dialog will popup.
  647.             </p>
  648.             <p>SF-GRADIENT "Gradient" "Deep Sea"</p>
  649.             <p>
  650.               The value returned when the script is invoked is a string
  651.               containing the gradient name. If the above selection was not
  652.               altered the string would contain "Deep Sea".
  653.             </p>
  654.             <p>
  655.               Cliquer sur celui-ci fait appara√Ætre la boite de dialogue des
  656.               d√©grad√©s.
  657.             </p>
  658.           </td>
  659.               </tr>
  660.               <tr>
  661.                 <td>
  662.             <p>SF-PALETTE</p>
  663.           </td>
  664.                 <td>
  665.             <p>
  666.               It will create a widget in the control dialog. The widget
  667.               consists of a button containing the name of the selected
  668.               palette.
  669.             </p>
  670.             <p>
  671.               If the button is pressed a palette selection dialog will popup.
  672.             </p>
  673.             <p>SF-PALETTE "Palette" "Named Colors"</p>
  674.             <p>
  675.               The value returned when the script is invoked is a string
  676.               containing the palette name. If the above selection was not
  677.               altered the string would contain "Named Colors".
  678.             </p>
  679.             <p>
  680.               Cliquer sur celui-ci fait appara√Ætre la boite de dialogue des
  681.               palettes.
  682.             </p>
  683.           </td>
  684.               </tr>
  685.               <tr>
  686.                 <td>
  687.             <p>SF-FILENAME</p>
  688.           </td>
  689.                 <td>
  690.             <p>
  691.               It will create a widget in the control dialog. The widget
  692.               consists of a button containing the name of a file.
  693.             </p>
  694.             <p>
  695.               If the button is pressed a file selection dialog will popup.
  696.             </p>
  697.             <p>
  698.               SF-FILENAME "Environment Map" (string-append ""
  699.               gimp-data-directory "/scripts/beavis.jpg")
  700.             </p>
  701.             <p>
  702.               The value returned when the script is invoked is a string
  703.               containing the filename.
  704.             </p>
  705.           </td>
  706.               </tr>
  707.               <tr>
  708.                 <td>
  709.             <p>SF-DIRNAME</p>
  710.           </td>
  711.                 <td>
  712.             <p>
  713.               Only useful in interactive mode. Very similar to SF-FILENAME,
  714.               but the created widget allows to choose a directory instead of a
  715.               file.
  716.             </p>
  717.             <p>
  718.               SF-DIRNAME "Image Directory" "/var/tmp/images"
  719.             </p>
  720.             <p>
  721.               The value returned when the script is invoked is a string
  722.               containing the dirname.
  723.             </p>
  724.           </td>
  725.               </tr>
  726.               <tr>
  727.                 <td>
  728.             <p>SF-OPTION</p>
  729.           </td>
  730.                 <td>
  731.             <p>
  732.               It will create a widget in the control dialog. The widget is a
  733.               combo-box showing the options that are passed as a list.
  734.             </p>
  735.             <p>The first option is the default choice.</p>
  736.             <p>
  737.               SF-OPTION "Orientation" '("Horizontal" "Vertical")
  738.             </p>
  739.             <p>
  740.               The value returned when the script is invoked is the number of
  741.               the chosen option, where the option first is counted as 0.
  742.             </p>
  743.           </td>
  744.               </tr>
  745.               <tr>
  746.                 <td>
  747.             <p>SF-ENUM</p>
  748.           </td>
  749.                 <td>
  750.             <p>
  751.               It will create a widget in the control dialog. The widget is a
  752.               combo-box showing all enum values for the given enum type. This
  753.               has to be the name of a registered enum, without the "Gimp"
  754.               prefix. The second parameter speficies the default value, using
  755.               the enum value's nick.
  756.             </p>
  757.             <p>
  758.               SF-ENUM "Interpolation" '("InterpolationType" "linear")
  759.             </p>
  760.             <p>
  761.               The value returned when the script is invoked corresponds to
  762.               chosen enum value.
  763.             </p>
  764.           </td>
  765.               </tr>
  766.             </tbody>
  767.           </table>
  768.         </div>
  769.       </div>
  770.       <div class="footnotes">
  771.         <br />
  772.         <hr width="100" align="left" />
  773.         <div class="footnote">
  774.           <p><sup>[<a id="ftn.id2618815" href="#id2618815" class="para">3</a>] </sup>
  775.         This section is not part of the original tutorial.
  776.       </p>
  777.         </div>
  778.       </div>
  779.     </div>
  780.     <div class="navfooter">
  781.       <hr />
  782.       <table width="100%" summary="Navigation footer">
  783.         <tr>
  784.           <td width="40%" align="left"><a accesskey="p" href="gimp-using-script-fu-tutorial-lists.html"><img src="../images/prev.png" alt="Prev" /></a>¬†</td>
  785.           <td width="20%" align="center">
  786.             <a accesskey="u" href="gimp-using-script-fu-tutorial.html">
  787.               <img src="../images/up.png" alt="Up" />
  788.             </a>
  789.           </td>
  790.           <td width="40%" align="right">¬†<a accesskey="n" href="gimp-using-script-fu-tutorial-script.html"><img src="../images/next.png" alt="Next" /></a></td>
  791.         </tr>
  792.         <tr>
  793.           <td width="40%" align="left" valign="top"><a accesskey="p" href="gimp-using-script-fu-tutorial-lists.html">3.3.¬†
  794.       <span lang="en" xml:lang="en">Lists, Lists And More Lists</span>
  795.     </a>¬†</td>
  796.           <td width="20%" align="center">
  797.             <a accesskey="h" href="index.html">
  798.               <img src="../images/home.png" alt="Home" />
  799.             </a>
  800.           </td>
  801.           <td width="40%" align="right" valign="top">¬†<a accesskey="n" href="gimp-using-script-fu-tutorial-script.html">3.5.¬†
  802.       <span lang="en" xml:lang="en">Giving Our Script Some Guts</span>
  803.     </a></td>
  804.         </tr>
  805.       </table>
  806.     </div>
  807.   </body>
  808. </html>
  809.