noframes
Autostartmanager - Step 2

Eventhandling

First we want to display something in the list.
We add
      <input>cat autostart.cfg</input>

"cat" is a shell command, that lists a file. It is so short, that we dont't need wxbs here.
In Fact, one of the great advantages of Gtkdialog is to embed short shellcommands.

We create a new file that includes 2 Programs, that shall be run when the X-Window-System (Short: X) starts.

autostart.cfg
beaver &
xcalc &

The "&" in the end is important, because it runs programs in "background".
If you forget this, your X-Windowsystem will not start.

The enhanced template:

autostart.tpl
Autostart_Manager='

<frame existing entries>

    <list>
      <variable>LIST1</variable>
      <input>cat autostart.cfg</input>
      <action>refresh:ENTRY1</action>
      <width>400</width>
      <height>300</height>
    </list>

      <entry>
        <variable>ENTRY1</variable>
        <input>echo $LIST1</input>
      </entry>

    <button>
      <label>Exit</label>
      <action>EXIT=EXIT</action>
    </button>

</frame>
'


You see a new element, an "entry", which is a small Textarea to enter 1 line of text.
There are some more new lines, that use the variable LIST1, that was unused in Chapter 1.

When the list is clicked, its selected value (that is stored in $LIST1), will be printed in the Entry (echo $LIST1).
This technique is called "Eventhandling".


In autostart.wxbs we delete the xmessage, as we don't really need it.

autostart.wxbs
#!/usr/bin/wxbasicscript
include "/usr/lib/wxbasicscript/basefunctions.inc"
shell( "cd " & STARTDIR )

//-- generate the GTK-Dialog --

dialog = readtemplate( STARTDIR & "/autostart.tpl" )
gtkdialog2 ( dialog )