#!/bin/sh

GTKDIALOG=gtkdialog

funcbtnCreate() {
	echo '<button image-position="'$2'">
			<label>"'"$3"'"</label>
			<input file stock="'$4'"></input>
			<action>echo "'"$5"' '$1'"</action>
			<action function="'"$3"'">'$1'</action>
		</button>'
}

funcchkCreate() {
	echo '<label>'"$2"'</label>
			<variable>'$1'</variable>
			<action>echo '$1' changed to $'$1'</action>
		</checkbox>'
}

MAIN_DIALOG='
<window title="CheckBox Advanced" resizable="false" border-width="0">
	<vbox spacing="0">
		<menubar>
			<menu label="_File" use-underline="true">
				<menuitem stock-id="gtk-quit" accel-key="0x51" accel-mods="4">
					<action>exit:Quit</action>
				</menuitem>
				<variable>mnuFile</variable>
			</menu>
		</menubar>
		<vbox border-width="20" spacing="10">
			<checkbox>
				<input>echo true</input>
				<action>if true enable:mnuFile</action>
				<action>if false disable:mnuFile</action>
				'"`funcchkCreate chk0 "Enable/disable the File menu"`"'
			<hbox homogeneous="true">
				'"`funcbtnCreate chk0 2 Disable gtk-no Disabling`"'
				'"`funcbtnCreate chk0 2 Enable gtk-yes Enabling`"'
				'"`funcbtnCreate chk0 2 Clear gtk-clear Clearing`"'
				'"`funcbtnCreate chk0 2 Refresh gtk-refresh Refreshing`"'
			</hbox>
			<hseparator></hseparator>
			<checkbox block-function-signals="true">
				<input>echo true</input>
				<action>if true enable:mnuFile</action>
				<action>if false disable:mnuFile</action>
				'"`funcchkCreate chk1 "Enable/disable the File menu (block-function-signals=\"true\")"`"'
			<hbox homogeneous="true">
				'"`funcbtnCreate chk1 2 Disable gtk-no Disabling`"'
				'"`funcbtnCreate chk1 2 Enable gtk-yes Enabling`"'
				'"`funcbtnCreate chk1 2 Clear gtk-clear Clearing`"'
				'"`funcbtnCreate chk1 2 Refresh gtk-refresh Refreshing`"'
			</hbox>
			<hseparator></hseparator>
			<hbox homogeneous="true">
				<checkbox active="false">
					'"`funcchkCreate chk2 "Initially active=\"false\""`"'
				<vseparator></vseparator>
				<checkbox active="true">
					'"`funcchkCreate chk3 "Initially active=\"true\""`"'
			</hbox>
			<hseparator></hseparator>
			<hbox homogeneous="true">
				<checkbox draw-indicator="false">
					'"`funcchkCreate chk4 "draw-indicator=\"false\""`"'
				<vseparator></vseparator>
				<checkbox inconsistent="true">
					'"`funcchkCreate chk5 "inconsistent=\"true\""`"'
			</hbox>
		</vbox>
	</vbox>
</window>
'
export MAIN_DIALOG

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