#! /bin/bash
$APPDIR/func -reset_gtk
export TEXTDOMAIN=pmusic
export GTK2_RC_FILES="$GTK2_RC_FILES:$APPDIR/themes/$THEME/gtkrc_splash"

if [ -f $WORKDIR/splash_cancelcode ]; then
	GUI_CANCEL='
	<hbox>
	 <button>
	  <input file icon="gtk-cancel"></input>
	  <action>'"$(<$WORKDIR/splash_cancelcode)"'</action>
	  <action>echo 100 > '$WORKDIR'/splash</action>
	  <action>exit:EXIT</action>
	 </button>
	</hbox>'
	rm $WORKDIR/splash_cancelcode
fi

[ -f $WORKDIR/splashtext2 ] && GUI_TXT='<text><input file>'$WORKDIR'/splashtext2</input></text>'

echo 0 > $WORKDIR/splash
echo "$(gettext 'Please wait') ..." > $WORKDIR/progresstext

S='
<window title="pMusic" icon-name="pmusic" allow-grow="false" skip_taskbar_hint="true" decorated="false" type-hint="4">
 <vbox>
  <eventbox name="svgsplash">
   <vbox>
    <text height-request="55"><label>""</label></text>
    <hbox>
     <text xpad="20" use-markup="true" justify="0" space-expand="false" space-fill="false"><label>"<i><big><span color='"'#D6B580'"'>'"$(<$WORKDIR/splashtext)"'</span></big></i>"</label></text>
     <text space-expand="true" space-fill="true"><label>""</label></text>
    </hbox>
    <hbox>
     <text height-request="30" xpad="20" use-markup="true" justify="0" space-expand="false" space-fill="false"><label>"<i><big><span color='"'#D6B580'"'>'$(gettext 'Please wait')'...</span></big></i>"</label></text>
     <text space-expand="true" space-fill="true"><label>""</label></text>
    </hbox>
    <hbox>
     <text space-expand="true" space-fill="true"><label>""</label></text>
     <text xpad="7" use-markup="true" justify="1" space-expand="false" space-fill="false"><label>"<small><span color='"'#aaaaaa'"'>GPL 2008-2015 - Sigmund Berglund</span></small>"</label></text>
    </hbox>
   </vbox>
  </eventbox>
  <progressbar'; [ ! "`echo "$*" | grep -F progress`" ] && S=$S' visible="false"'; S=$S'>
   <input>while [ "$I" != "100" ]; do I=`cat '$WORKDIR'/splash`; J=`cat '$WORKDIR'/progresstext`; echo $I; echo "$J (${I}%)"; sleep 0.5; done</input>
   <action type="exit">Ready</action>
  </progressbar>
  '$GUI_TXT'
  '$GUI_CANCEL'
 </vbox>
</window>'

export pmusic_splash="$S"
. $APPDIR/func -reset_gtk
$GTKDIALOG -p pmusic_splash --center

rm $WORKDIR/splashtext2
