#!/bin/sh

tailing (){
	echo "$TAIL_TITLE" 
	cat $WORKDIR/tail_percent
	sleep 1
	[ -s "$LOG" ] && tail -n 20 "$LOG" | tr '\r' '\n' | tail -n 20 > $WORKDIR/tail
	echo 100 > $WORKDIR/tail_percent
}
export -f tailing

echo 99 > $WORKDIR/tail_percent
echo -n > $WORKDIR/tail

export pburn_tail="
<window title=\"pBurn\" icon-name=\"media-optical\" decorated=\"false\">
<vbox>
 <progressbar>
  <input>"'while [ A != B ]; do tailing; done'"</input>
  <action>refresh:TAIL</action>
  <action>echo 99 > $WORKDIR/tail_percent</action>
 </progressbar>
 <edit>
  <variable>TAIL</variable>
  <input file>$WORKDIR/tail</input>
  <width>400</width><height>380</height>
 </edit>
 <hbox homogeneous=\"true\">
  <button image-position=\"2\" stock-icon-size=\"3\">
   <label>$TAIL_BUTTON</label>
   <input file stock=\"gtk-${TAIL_BUTTON_ICON}\"></input>
   <action>EXIT:tail_button</action>
  </button>
 </hbox>
</vbox>
</window>"

I=$IFS; IFS=""
for STATEMENTS in $($GTKDIALOG -p pburn_tail --center); do
	eval $STATEMENTS
done
IFS=$I
