home *** CD-ROM | disk | FTP | other *** search
/ PCNET 2006 September - Disc 1 / PCNET_CD_2006_09.iso / linux / puppy-barebones-2.01r2.iso / pup_201.sfs / usr / share / doc / gtkdialog.txt < prev    next >
Encoding:
GNU Info File  |  2004-10-27  |  13.8 KB  |  458 lines

  1. This is gtkdialog.info, produced by makeinfo version 4.3 from
  2. gtkdialog.texi.
  3.  
  4. This manual documents version {No value for `VERSION'} of the Gtkdialog
  5. utility.
  6.  
  7.    Copyright (C) 2003 Laszlo Pere.
  8.  
  9.      Permission is granted to copy, distribute and/or modify this
  10.      document under the terms of the GNU Free Documentation License,
  11.      Version 1.1 or any later version published by the Free Software
  12.      Foundation; with no Invariant Sections, with no Front-Cover Texts,
  13.      and with no Back-Cover Texts.
  14.    
  15. 
  16. File: gtkdialog.info,  Node: Top,  Next: Getting Gtkdialog,  Up: (dir)
  17.  
  18. Gtkdialog User's Manual
  19. ***********************
  20.  
  21. This manual documents version {No value for `VERSION'} of the Gtkdialog
  22. utility.
  23.  
  24.    Copyright (C) 2003 Laszlo Pere.
  25.  
  26.      Permission is granted to copy, distribute and/or modify this
  27.      document under the terms of the GNU Free Documentation License,
  28.      Version 1.1 or any later version published by the Free Software
  29.      Foundation; with no Invariant Sections, with no Front-Cover Texts,
  30.      and with no Back-Cover Texts.
  31.    
  32. * Menu:
  33.  
  34. * Getting Gtkdialog::      How to find, download and install the program.
  35. * Introduction::           A brief description of the package.
  36. * Invoking the Program::   How to call the program from various languages.
  37. * Widgets::               The elements of dialog boxes.
  38. * Containers::           Dialog elements grouping widgets together.
  39. * Actions::           What is happening when something happening.
  40.  
  41. 
  42. File: gtkdialog.info,  Node: Getting Gtkdialog,  Next: Introduction,  Prev: Top,  Up: Top
  43.  
  44. Getting Gtkdialog
  45. *****************
  46.  
  47. Download
  48. ========
  49.  
  50.    The source of Gtkdialog can be downloaded from Anonymous FTP at URL
  51. `ftp://linux.pte.hu/pub/gtkdialog/'.
  52.  
  53. How to Install the Program
  54. ==========================
  55.  
  56.    The program can be installed using the standard `./configure',
  57. `make' and `make install' command sequence. Further details can be
  58. found in the `INSTALL' file included.
  59.  
  60. Copying
  61. =======
  62.  
  63.    Copyright (C) 2003 Laszlo Pere.
  64.  
  65.    The gtkdialog is free software; you can redistribute it and/or
  66. modify it under the terms of the GNU General Public License as
  67. published by the Free Software Foundation; either version 2.0 of the
  68. License, or (at your option) any later version.
  69.  
  70.    The program is distributed in the hope that it will be useful, but
  71. WITHOUT ANY WARRANTY; without even the implied warranty of
  72. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  73. General Public License for more details.
  74.  
  75.    You should have received a copy of the GNU General Public License
  76. along with this software; if not, write to the Free Software
  77. Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307,
  78. USA.
  79.  
  80. 
  81. File: gtkdialog.info,  Node: Introduction,  Next: Invoking the Program,  Prev: Getting Gtkdialog,  Up: Top
  82.  
  83. Introduction
  84. ************
  85.  
  86.    Gtkdialog is a small utility program based on the GTK+ library. The
  87. program mainly made for GUI development for shell scripts but can be
  88. used with many other programming languages. The programmer can easily
  89. create GUI not just for any shell script or UNIX command but for any
  90. interpreted or compiled program capable to start child process and use
  91. pipes.
  92.  
  93. 
  94. File: gtkdialog.info,  Node: Invoking the Program,  Next: Widgets,  Prev: Introduction,  Up: Top
  95.  
  96. Invoking the Program
  97. ********************
  98.  
  99. Examples
  100. ========
  101.  
  102.    Our first example program shows how to call the `gtkdialog' from a
  103. BASH script.
  104.  
  105.      #! /bin/bash
  106.      
  107.      export MAIN_DIALOG='
  108.       <vbox>
  109.        <text>
  110.          <label>This is a label...</label>
  111.        </text>
  112.        <hbox>
  113.         <button ok></button>
  114.         <button cancel></button>
  115.        </hbox>
  116.       </vbox>'
  117.      
  118.      gtkdialog --program MAIN_DIALOG
  119.  
  120.    This example uses a very plain way to open a dialog box. We store the
  121. description of the dialog box in the `MAIN_DIALOG' environment variable
  122. which is exported to the child processes with the BASH `export'
  123. built-in. Then we call the `gtkdialog' program with the `--program'
  124. option which is followed by the name of the variable holding the dialog
  125. box description. It is simple and easy to write BASH scripts in this
  126. manner.
  127.  
  128.    A similar calling method can be used when user input is needed. The
  129. `gtkdialog' send the state of the widgets to the standard output when
  130. exiting and this is how we can get user input for the BASH program. The
  131. next example code show the reading process.
  132.      #! /bin/bash
  133.      
  134.      export DIALOG='
  135.      <vbox>
  136.        <entry>
  137.          <variable>ENTRY</variable>
  138.        </entry>
  139.        <hbox>
  140.          <button ok></button>
  141.          <button cancel></button>
  142.        </hbox>
  143.      </vbox>'
  144.      
  145.      I=$IFS; IFS=""
  146.      for STATEMENTS in  $(gtkdialog --program DIALOG); do
  147.        eval $STATEMENTS
  148.      done
  149.      IFS=$I
  150.      
  151.      if [ "$EXIT" = "OK" ]; then
  152.        echo "You entered: $ENTRY."
  153.      else
  154.        echo "You pressed the Cancel button."
  155.      fi
  156.  
  157.    In the example script we use the `for' built-in to go through the
  158. list `gtkdialog' produced. Changing the field separator (IFS) is a
  159. little bit disturbing but necessary since this is the only way to
  160. protect the space characters in user input.
  161.  
  162.    In larger software projects it may be a good idea to break the code
  163. to separate files. Since `gtkdialog' can read the description program
  164. from file it is easy to write self executable programs with it. This is
  165. how the next example constructed.
  166.  
  167.      #! /usr/local/bin/gtkdialog -f
  168.      <vbox>
  169.        <checkbox>
  170.          <label>This is a checkbox</label>
  171.          <variable>CHECK1</variable>
  172.        </checkbox>
  173.        <checkbox>
  174.          <label>Another one</label>
  175.          <variable>CHECK2</variable>
  176.        </checkbox>
  177.        <button>
  178.          <label>OK</label>
  179.        </button>
  180.      </vbox>
  181.  
  182.    When used in this fashion the state of the widgets can get from the
  183. standard output of the script as usually.
  184.  
  185. 
  186. File: gtkdialog.info,  Node: Widgets,  Next: Containers,  Prev: Invoking the Program,  Up: Top
  187.  
  188. Widgets
  189. *******
  190.  
  191.    The dialog description language is a simple XML like language capable
  192. to denote any complex dialog box containing widgets and boxes.
  193.  
  194.    Widgets are simple GUI elements such as buttons, entry fields, lists,
  195. etc. Widget can have attributes, states and actions (*note Actions::).
  196.  
  197.    The widgets are grouped together with containers (*note
  198. Containers::), horizontal and vertical boxes or frames. Every widget
  199. should placed in one of the containers, no widgets can be alone for it
  200. is dangerous outside.
  201.  
  202. * Menu:
  203.  
  204. * Pushbutton::            Pushbutton widgets
  205. * Pre-defined pushbuttons::    Pushbuttons with pixmap and text label
  206. * Entry::            One line text entry widgets
  207. * Checkbox::            Checkbox widgets
  208. * Pixmap::            Static pixmap widgets
  209.  
  210. 
  211. File: gtkdialog.info,  Node: Pushbutton,  Next: Pre-defined pushbuttons,  Up: Widgets
  212.  
  213. Pushbutton
  214. ==========
  215.  
  216.    The pushbutton is a clickable widget defined with the
  217. `<button></button>' tags.
  218.  
  219. `<label></label>'
  220. -----------------
  221.  
  222.    The `<label>STRING</label>' directive sets the text label of the
  223. pushbutton. If no label and pixmap is given for the button, gtkdialog
  224. will use OK as default.
  225.  
  226. `<action></action>'
  227. -------------------
  228.  
  229.    The `<action>COMMAND</action>' directive tells the gtkdialog what to
  230. do, when the button is pressed. If the action is not given explicitly
  231. the gtkdialog uses the default action, which is to exit the program. In
  232. this case the printed variable list will contain a variable named EXIT,
  233. with the label of the activated button as value.
  234.  
  235.    The buttons can handle more than one actions simultaneously. If
  236. there are more `<action></action>' directive for the given button, they
  237. will be executed one by one, in the right order.
  238.  
  239. `<input file></input>'
  240. ----------------------
  241.  
  242.    When creating buttons, the `<input file>FILENAME</input>' tag can be
  243. used to insert a pixmap into the button. The FILENAME must be a pixmap
  244. file. Gtkdialog will find this file with the `locate' utility if
  245. necessary.
  246.  
  247. `<visible></visible>'
  248. ---------------------
  249.  
  250.    The `<visible>STATE</visible>' specify the initial visibility of the
  251. button. The STATE can be either `enabled' or `disabled'. When a button
  252. is disabled, it is shaded and can not be activated by mouse or keyboard.
  253.  
  254. 
  255. File: gtkdialog.info,  Node: Pre-defined pushbuttons,  Next: Entry,  Prev: Pushbutton,  Up: Widgets
  256.  
  257. Pre-defined pushbuttons
  258. =======================
  259.  
  260.    Gtkdialog supports a few pre-defined pushbuttons for simplify the
  261. creation of dialog boxes. The pre-defined buttons can be used the same
  262. manner the normal pushbuttons, but they have a default text, pixmap and
  263. output variable.  Here is the list of available pre-defined pushbuttons:
  264.  
  265.    * `<button ok></button>'
  266.  
  267.    * `<button cancel></button>'
  268.  
  269.    * `<button help></button>'
  270.  
  271.    * `<button yes></button>'
  272.  
  273.    * `<button no></button>'
  274.  
  275. 
  276. File: gtkdialog.info,  Node: Entry,  Next: Checkbox,  Prev: Pre-defined pushbuttons,  Up: Widgets
  277.  
  278. Entry
  279. =====
  280.  
  281.    The entry widget is a simple text input field, which can be used to
  282. get a string from the user.
  283.  
  284. `<default></default>'
  285. ---------------------
  286.  
  287.    The `<default>STRING</default>' directive sets the default content
  288. of the entry.
  289.  
  290. `<visible></visible>'
  291. ---------------------
  292.  
  293.    The `<visible>VISIBILITY</visible>' sets the initial state of the
  294. entry widget. The VISIBILITY can be `enabled', which means the entry
  295. can be used, `disabled', which means the content of the entry can not
  296. be altered or `password'.
  297.  
  298.    The entry widgets with the visibility set to `password' are
  299. editable, but unreadable as it is common with entries holding password
  300. style information.
  301.  
  302. `<action></action>'
  303. -------------------
  304.  
  305.    The entry widgets are activating actions after their contents are
  306. changed.
  307.  
  308. 
  309. File: gtkdialog.info,  Node: Checkbox,  Next: Pixmap,  Prev: Entry,  Up: Widgets
  310.  
  311. Checkbox
  312. ========
  313.  
  314.    The checkbox is a simple widget with a label and a check mark which
  315. can be turned on and off by the user. Checkboxes are made with the
  316. `<checkbox></checkbox>' directive.
  317.  
  318. `<label></label>'
  319. -----------------
  320.  
  321.    The label is the text shown beside the check mark. Every checkbox
  322. should have a label.
  323.  
  324. `<default></default>'
  325. ---------------------
  326.  
  327.    The initial state of the checkbox can be set by the
  328. `<default>STATE</default>' directive, where the STATE can be either
  329. `yes' or `no'.
  330.  
  331. `<action></action>'
  332. -------------------
  333.  
  334.    The `<action></action>' directive tells the gtkdialog what to do,
  335. when the state of the checkbox is changed. As every widgets, the
  336. checkbox can hold multiply actions which are executed serially in the
  337. order they are written.
  338.  
  339.    Actions of checkboxes can be written as conditional instructions with
  340. `if true' and `if false' prefixes as in the next example:
  341.  
  342.      <checkbox>
  343.          <label>This is a checkbox...</label>
  344.          <variable>CHECKBOX</variable>
  345.          <action>echo Checkbox is $CHECKBOX now.</action>
  346.          <action>if true enable:ENTRY</action>
  347.          <action>if false disable:ENTRY</action>
  348.      </checkbox>
  349.  
  350. `<visible></visible>'
  351. ---------------------
  352.  
  353.    The `<visible>STATE</visible>' specify the initial visibility of the
  354. checkbox. The STATE can be either `enabled' or `disabled'. When a
  355. checkbox is disabled, it is shaded and its state can not be altered
  356. anyway.
  357.  
  358. `<variable></variable>'
  359. -----------------------
  360.  
  361.    The value of a checkbox can be `true' or `false' and depends only on
  362. its state.
  363.  
  364. 
  365. File: gtkdialog.info,  Node: Pixmap,  Prev: Checkbox,  Up: Widgets
  366.  
  367. Pixmap
  368. ======
  369.  
  370.    The `<pixmap></pixmap>' defines a static pixmap widget.
  371.  
  372. `<input file></input>'
  373. ----------------------
  374.  
  375.    The widget must have an input file defined with the `<input
  376. file>FILENAME</input>' tags. The FILENAME is the graphic image file for
  377. the pixmap. Gtkdialog will load this file if it can be opened for read,
  378. or will try to find a file with similar name (using the `locate'
  379. utility program) if the file is unreadable.
  380.  
  381.    The next example defines a static pixmap:
  382.  
  383.      <pixmap>
  384.        <input file>help.png</input>
  385.      </pixmap>
  386.  
  387. 
  388. File: gtkdialog.info,  Node: Containers,  Next: Actions,  Prev: Widgets,  Up: Top
  389.  
  390. Containers
  391. **********
  392.  
  393. 
  394. File: gtkdialog.info,  Node: Actions,  Prev: Containers,  Up: Top
  395.  
  396. Actions
  397. *******
  398.  
  399.    When the user changes the state of a widget, gtkdialog checks if
  400. there is something to do with it. If the tampered widget have one or
  401. more actions, the program will execute them for the new situation to be
  402. handled.
  403.  
  404.    Every widget can have multiply actions, a list of commands must be
  405. executed when the widget changed. Gtkdialog executes the axtions in the
  406. order they found in the dialog description program, so one can write a
  407. complet program as a series of instructions.
  408.  
  409. * Menu:
  410.  
  411. * Shell commands::    Actions that starts programs as child processes
  412.  
  413. 
  414. File: gtkdialog.info,  Node: Shell commands,  Up: Actions
  415.  
  416. Shell commands
  417. ==============
  418.  
  419.    If the action of a widget is created with the simple
  420. `<action>COMMAND</action>' directive, gtkdialog will execute it in a
  421. subshell. That means it will start up `/bin/sh' to handle the
  422. operation. Here is how the subshell operation works:
  423.   1. First gtkdialog updates the environment variables holds the  state
  424.      and value of the widgets. This is how the child process will  know
  425.      what is happening in the GUI called it.
  426.  
  427.   2. Next the include file is checked. If the gtkdialog started  with
  428.      the `-i FILE' option gtkdialog will ask the  subshell to include
  429.      the FILE before the execution of command.
  430.  
  431.      This strange method is needed for the action driven programs, where
  432.      the subshell have to load the shell functions from the calling
  433.      script.
  434.  
  435.   3. At the third step gtkdialog starts the command and waits for  it
  436.      to complete. (Commands usually can be run in the background by
  437.      writing a `&' as last character, so the subshell will not wait
  438.      the program to complete.)
  439.  
  440.  
  441. 
  442. Tag Table:
  443. Node: Top79
  444. Node: Getting Gtkdialog1462
  445. Node: Introduction2689
  446. Node: Invoking the Program3184
  447. Node: Widgets5856
  448. Node: Pushbutton6695
  449. Node: Pre-defined pushbuttons8186
  450. Node: Entry8776
  451. Node: Checkbox9674
  452. Node: Pixmap11316
  453. Node: Containers11937
  454. Node: Actions12045
  455. Node: Shell commands12686
  456. 
  457. End Tag Table
  458.