#!/bin/sh

export TEXTDOMAIN=pburn

case $1 in
-yesno)
	[ -z "$FRAME" ] && FRAME="$(gettext 'Information')"
	[ -z "$IMG" ] && IMG="dialog-question"
	BUTTONS="<button no></button><button yes></button>"
	;;
-input) #rename / new dir in burnlist
	BUTTONS="<button cancel></button>
			<button can-default=\"true\" has-default=\"true\" use-stock=\"true\">
			 <input file stock=\"gtk-apply\"></input>
			 <label>$(gettext 'Apply')</label>
			 <action>EXIT:Apply</action>
			</button>"
	EXTENDED_GTKDIALOG="<entry activates-default=\"true\"><variable>INPUT</variable><input>cat $WORKDIR/input</input></entry>"
	;;
-quest_blank) #option to blank not-empty-disc before burning  
	FRAME="$(gettext 'Blank (Erase) disc')"
 	IMG="dialog-question"
	TXT1="$(gettext '<b>Inserted disc is not blank or writable</b>

- Burning <b>Audio/Video</b> requires a blank disc.
- Burning <b>Data</b> requires a writeable or blank disc.')
- $(gettext "Burning <b>Image (iso/nrg)</b> may require a blank disc. You can mix data from the chosen image with the content on the disc, but if burning a bootable disc it might be corupted. An exception is when updating the LIVE-disc to a newer version. Files in the new image will replace similar files on the disc. Press 'Continue' to add more data from the image to the disc.")" 
	if [ "$2" != "CD" ]; then
		TMP="<button><label>$(gettext 'Blank CD/DVD-rw')</label><input file>$APPDIR/pburn20.png</input><action>EXIT:overwrite</action></button>"
	else	
		TMP="<button><label>$(gettext 'Blank (Erase) disc')</label><input file>$APPDIR/pburn20.png</input><action>EXIT:blank</action></button>"
	fi
	BUTTONS="$TMP
			<button><input file stock=\"gtk-cdrom\"></input><label>$(gettext 'Continue with valid disc')</label></button>
			<text><label>\"    \"</label></text>
			<button><input file stock=\"gtk-info\"></input><label>$(gettext 'Disc info')</label><action>. $APPDIR/func -disc_info</action></button>
			<button cancel></button>"
	;;
-quest_iso) #option to unpack iso-file or burn as is
	FRAME="$(gettext 'image')"
 	IMG="dialog-question"
	TXT1="$(gettext '<b>You have chosen to burn a filesystem image (*.iso or *.nrg).

Normally the filesystem should be unpacked onto the disc</b>, unless for some reason you want to put the image on the disc as a single file.

What would you like to do?')"
	BUTTONS="<button><label>$(gettext 'Unpack filesystem')</label><input file>$APPDIR/pburn20.png</input><action>EXIT:iso</action></button>
			<button><input file>$APPDIR/pburn20.png</input><label>$(gettext 'Single file')</label></button>
			<text><label>\"    \"</label></text>
			<button cancel></button>"
	;;
*) #ok box
	[ -z "$IMG" ] && IMG="dialog-error"
	[ -z "$FRAME" ] && FRAME="$(gettext 'Error')"
	BUTTONS="<button ok></button>"
	;;
esac
export pburn_box="
<window title=\"Pburn\" icon-name=\"gtk-cdrom\">
 <vbox>
  <frame $FRAME>
   <pixmap icon_size=\"6\"><input file stock=\"gtk-$IMG\"></input></pixmap>
   <text use-markup=\"true\" wrap=\"true\" width-chars=\"50\"><label>\"$TXT1\"</label></text>
   <text use-markup=\"true\" wrap=\"true\" width-chars=\"50\"><label>\"$TXT2\"</label></text>
   $EXTENDED_GTKDIALOG
  </frame>
  <hbox>
   $BUTTONS
  </hbox>
 </vbox>
</window>"
I=$IFS; IFS=""
for STATEMENTS in  $($GTKDIALOG -p pburn_box --center); do
	eval $STATEMENTS
done
IFS=$I

export EXIT=$EXIT
TXT1=""; TXT2=""; IMG=""; FRAME=""; DEFAULT=""; EXTENDED_GTKDIALOG=""; echo -n > $WORKDIR/input #reset to avoid alien values in next box