Code: Select all
#!/bin/dash
# or busybox sh/ash even bash
func_test() {
set -x
yad --center --button=gtk-ok --buttons-layout=center "--text=
func_test arguments: $1, $2, $3
. using exported variable: $VARIABLE
. click OK to exit"
}
VARIABLE="hi there!"; export VARIABLE
MAIN_DIALOG='
<window>
<vbox>
<frame Test>
<hbox>
<button>
<label>Click me</label>
<action>. "'"$0"'" @test 1 2 3</action>
<action function="exit">Exit by button</action>
</button>
</hbox>
<hbox>
<button ok></button>
<button cancel></button>
</hbox>
</frame>
</vbox>
</window>
'
export MAIN_DIALOG
case $1 in
-d | --dump) echo "$MAIN_DIALOG" ;;
@*) sub=func_${1#@}; shift; $sub "$@"; exit $? ;; # relay func'tions
*) gtkdialog --program=MAIN_DIALOG ;;
esac
echo done