#!/bin/bash

# This example requires bash.

# Notice that the function print_this() is also being executed using /bin/bash
# within the action directive and the reason for this is that Gtkdialog is a
# C program and the C library will execute a system command using /bin/sh.
# Ubuntu users whose /bin/sh links to dash especially should be aware of this.

GTKDIALOG=gtkdialog

print_this() {
	echo "print: $1"
}; export -f print_this

export MAIN_DIALOG='
<window>
	<vbox>
		<button>
			<label>function</label>
			<action>bash -c "print_this button"</action>
		</button>
		<button>
			<label>Exit</label>
		</button>
	</vbox>
</window>
'

case $1 in
	-d | --dump) echo "$MAIN_DIALOG" ;;
	*) $GTKDIALOG --program=MAIN_DIALOG ;;
esac
