#!/bin/sh
#January, 2007 Nathan Fisher
#Grafburn is a simple graphical frontent to the cdrtools suite

# Determine the path to this application.
CURDIR="`pwd`"
APPDIR=`dirname "$0"`
cd "${APPDIR}"
APPDIR="`pwd`"
cd "${CURDIR}"

VERSION=`cat $APPDIR/.version`
if [ ! "`cat $HOME/.config/grafburnrc | grep VERSION | cut -f 2 -d '='`" = "$VERSION" ];then
 rm -f $HOME/.config/grafburnrc
fi

if [ ! -f ~/.config/grafburnrc ];then
  export CONFIGURE_DIALOG="
  <window title=\"Grafburn\" icon-name=\"gtk-dialog-error\" window-position=\"1\">
   <vbox>
    <frame>
     <text>
      <label>Grafburnは現在、未設定です。</label>
     </text>
     <text>
      <label>設定ダイアログを起動します。</label>
     </text>
    </frame>
    <hbox>
     <button ok></button>
    </hbox>
   </vbox>
  </window>"
  gtkdialog3 --program CONFIGURE_DIALOG
  $APPDIR/set_prefs
  export WELCOME_DIALOG="
  <window title=\"Grafburn: ようこそ！\" icon-name=\"gtk-cdrom\" window-position=\"1\">
   <vbox>
    <pixmap>
     <input file>$APPDIR/icons/big/grafburn.png</input>
    </pixmap>
    <text use-markup=\"true\">
     <label>\"<b>Grafburn-${VERSION}</b> にようこそ\"</label>
    </text>
    <hbox>
     <button ok></button>
    </hbox>
   </vbox>
  </window>"
  gtkdialog3 --program WELCOME_DIALOG
fi

case $1 in
	-n)
	exec $APPDIR/create_iso
	;;
	-a)
	exec $APPDIR/create_audio_cd
	;;
	-c)
	exec $APPDIR/copy_cd
	;;
	-b)
	exec $APPDIR/burn_iso -select
	;;
	-e)
	exec $APPDIR/blank_media
	;;
	-ab)
	exec $APPDIR/about
	;;
	-h)
	exec defaulttexteditor $APPDIR/help.txt
	;;
	-p)
	exec $APPDIR/set_prefs
	;;
	-f)
	exec $APPDIR/burn_file_list "$2"
	;;
esac

exec $APPDIR/grafburn
