#!/bin/sh

GTKDIALOG=gtkdialog

export TMPDIR=/tmp/gtkdialog/examples/"$(basename $0)"
mkdir -p "$TMPDIR"

funcbtnCreate() {
	echo '<button>
			<label>'"$2"'</label>
			<input file stock="'$3'"></input>
			<action>echo "'"$4"' '$1'"</action>
			<action type="'"$2"'">'$1'</action>
		</button>'
}

funcclbCreate() {
	echo '<variable>'$1'</variable>
			<action>echo '$1' changed to $'$1'</action>
		</colorbutton>
		<entry editable="false" width-request="360">
			<default>'$2'</default>
		</entry>
	</hbox>'
	if [ $3 = 1 ]; then
		echo '<hseparator></hseparator>
			<hbox>'
	fi
}

echo " #44cc88 | 16384 " > "$TMPDIR"/inputfile

export MAIN_DIALOG='
<window title="ColorButton Advanced" resizable="false">
	<vbox>
		<vbox border-width="30">
			<hbox>
				<colorbutton>
					'"$(funcclbCreate clb0 "All defaults." 1)"'
				<colorbutton title="Choose something asthetically pleasing">
					<default>#cc4488</default>
					'"$(funcclbCreate clb1 "Colour from default directive, title from tag attribute." 1)"'
				<colorbutton use-alpha="true" alpha="49152">
					<default>#88cc44</default>
					'"$(funcclbCreate clb2 "Colour from default directive, alpha from tag attribute." 1)"'
				<colorbutton use-alpha="true">
					<default>#4488cc|32768</default>
					'"$(funcclbCreate clb3 "Colour and alpha from default directive." 1)"'
				<colorbutton>
					<input>echo "#cc8844"</input>
					'"$(funcclbCreate clb4 "Colour from input directive." 1)"'
				<colorbutton use-alpha="true">
					<input file>'"$TMPDIR"'/inputfile</input>
					<output file>'"$TMPDIR"'/outputfile</output>
					'"$(funcclbCreate clb5 "Colour and alpha from input file directive." 0)"'
		<hbox>
			'"$(funcbtnCreate clb5 Disable gtk-no Disabling)"'
			'"$(funcbtnCreate clb5 Enable gtk-yes Enabling)"'
			'"$(funcbtnCreate clb5 Refresh gtk-refresh Refreshing)"'
			'"$(funcbtnCreate clb5 Save gtk-save Saving)"'
		</hbox>
		</vbox>
		<hseparator></hseparator>
		<hbox homogeneous="true">
			<button ok></button>
		</hbox>
	</vbox>
	<action signal="hide">exit:Exit</action>
</window>
'

$GTKDIALOG --program=MAIN_DIALOG
