#! /bin/bash

export CHOOSER="
<window title=\"Commodore Emulator\"icon-name=\"gtk-cdrom\">
<vbox>

<frame Choose a Commodore System>
<hbox>
  <combobox>
   <variable>SYSTEM</variable>
    <item>C64</item>
    <item>C64DTV</item>
    <item>C64SC</item>
    <item>C64SCPU</item>
    <item>C128</item>
    <item>CBM-II</item>
    <item>PET</item>
    <item>PLUS4</item>
    <item>VIC20</item>
    <item>VSID</item>
  </combobox>   
</hbox>
</frame>

<hbox>
<button>
<variable>CONTINUE</variable>
<input file icon=\"gtk-ok\"></input>
<label>Continue</label>
<action type=\"exit\">EXIT_OK</action>
</button>
<button>
<input file stock=\"gtk-cancel\"></input>
<label>Cancel</label>
<action type=\"exit\">EXIT_NOW</action>
</button>
</hbox>
</vbox>
</window>
"

CHOOSER2==`gtkdialog --program=CHOOSER --center`

if [ "`echo $CHOOSER2 | grep EXIT_OK`" = "" ]; then
exit 0
fi

#Get all of the variables
SYSTEM="`echo "$CHOOSER2" | sed 's/\"//g' | sed 's/=//g' | grep SYSTEM | sed 's/SYSTEM//'`"

# set graphics filter

case "$SYSTEM" in
  'C64')		SYSTEM="x64"		;;
  'C64DTV')		SYSTEM="x64dtv"		;;
  'C64SC')		SYSTEM="x64sc"		;;
  'C64SCPU')	SYSTEM="xscpu64"	;;
  'C128')		SYSTEM="x128"		;;
  'CBM-II')		SYSTEM="xcbm2"		;;
  'PET')		SYSTEM="xpet"		;;
  'PLUS4')		SYSTEM="xplus4"		;;
  'VIC20')		SYSTEM="xvic"		;;
  'VSID')		SYSTEM="vsid"		;;
  *)			SYSTEM="x64"		;;
esac


#based on the wonderful Technosaurus's guide to gtkdialog gui for bash
/usr/bin/$SYSTEM

unset CHOOSER
