#!/bin/sh

GTKDIALOG=gtkdialog

funcbtnCreate() {
	echo '<button>
			<label>presentwindow winLaunch'$1'</label>
			<action function="presentwindow">winLaunch'$1'</action>
		</button>'
}

# I'm automatically launching these windows and I'll describe how the
# launch system works to help you understand at least this example:
# 
# Firstly you should be aware that launching is a one way trip in that a
# launched window will not return to the window that launched it so for
# example any actions following a launch action will not be executed and
# launching directly from within a timer is definitely a no-no although
# gtkdialog checks for that and dumps a warning message to the terminal.
# 
# So, knowing the above you will understand that we can't launch three
# new windows successively within the same list of actions and we can't
# do it directly from within a timer, but we can make the timer activate
# other widgets which will indirectly launch the windows so this is why
# the timer within the following example is activating checkboxes with
# each launching one window. This is just one way to launch multiple
# windows at start-up -- feel free to design your own if you'd like.

interval=250

winLaunch0='
<window title="winLaunch0" width-request="250" resizable="false">
	<vbox>
		<timer milliseconds="true" interval="'$interval'" visible="false">
			<variable>tmrLaunch0</variable>
			<action>disable:tmrLaunch0</action>
			<action>activate:chkLaunch1</action>
			<action>activate:chkLaunch2</action>
			<action>activate:chkLaunch3</action>
		</timer>
		<checkbox visible="false">
			<variable>chkLaunch1</variable>
			<action>launch:winLaunch1</action>
			<action>echo "chkLaunch1 - You'"'"'ll never see this message."</action>
		</checkbox>
		<checkbox visible="false">
			<variable>chkLaunch2</variable>
			<action>launch:winLaunch2</action>
			<action>echo "chkLaunch2 - You'"'"'ll never see this message."</action>
		</checkbox>
		<checkbox visible="false">
			<variable>chkLaunch3</variable>
			<action>launch:winLaunch3</action>
			<action>echo "chkLaunch3 - You'"'"'ll never see this message."</action>
		</checkbox>
		'"`funcbtnCreate 1`"'
		'"`funcbtnCreate 2`"'
		'"`funcbtnCreate 3`"'
		<hbox homogeneous="true">
			<button use-stock="true" label="gtk-quit"></button>
		</hbox>
	</vbox>
	<variable>winLaunch0</variable>
</window>
'
export winLaunch0

winLaunch1='
<window title="winLaunch1" width-request="250" resizable="false">
	<vbox>
		'"`funcbtnCreate 0`"'
		'"`funcbtnCreate 2`"'
		'"`funcbtnCreate 3`"'
		<hbox homogeneous="true">
			<button use-stock="true" label="gtk-quit"></button>
		</hbox>
	</vbox>
	<variable>winLaunch1</variable>
	<action signal="show">echo "winLaunch1 - I'"'"'ve been launched!"</action>
</window>
'
export winLaunch1

winLaunch2='
<window title="winLaunch2" width-request="250" resizable="false">
	<vbox>
		'"`funcbtnCreate 0`"'
		'"`funcbtnCreate 1`"'
		'"`funcbtnCreate 3`"'
		<hbox homogeneous="true">
			<button use-stock="true" label="gtk-quit"></button>
		</hbox>
	</vbox>
	<variable>winLaunch2</variable>
	<action signal="show">echo "winLaunch2 - I'"'"'ve been launched!"</action>
</window>
'
export winLaunch2

winLaunch3='
<window title="winLaunch3" width-request="250" resizable="false">
	<vbox>
		'"`funcbtnCreate 0`"'
		'"`funcbtnCreate 1`"'
		'"`funcbtnCreate 2`"'
		<hbox homogeneous="true">
			<button use-stock="true" label="gtk-quit"></button>
		</hbox>
	</vbox>
	<variable>winLaunch3</variable>
	<action signal="show">echo "winLaunch3 - I'"'"'ve been launched!"</action>
</window>
'
export winLaunch3

case $1 in
	-d | --dump) echo "$winLaunch0" "$winLaunch1" "$winLaunch2" "$winLaunch3" ;;
	*) $GTKDIALOG --program=winLaunch0 ;;
esac
