#!/bin/bash
# simple gui for ghostess
# jamesbond 2010
# for fatdog64

function get_list_of_plugins() {
	for AFILE in $(ls /usr/lib64/dssi/*.so); do
		PLUGIN_ITEMS="$PLUGIN_ITEMS<item>$(basename $AFILE)</item>"
	done
	export PLUGIN_ITEMS
}

get_list_of_plugins

export MAIN_DIALOG="
<window title=\"Ghostess\" >
   <vbox>
	<frame>
		<text><label>\"Ghostess is a simple DSSI host. Please choose the list of DSSI plugins you want to load (maximum 5 - if you want to load more than 5, run ghostess from terminal).\"</label></text>
    </frame>
	
	<frame>
	<hbox>
		<text><label>Plugin</label></text>
		<combobox>
		  <variable>COMBO1</variable>
		  <item></item>
		  $PLUGIN_ITEMS
		</combobox>
	</hbox>
	<hbox>
		<text><label>Plugin</label></text>
		<combobox>
		  <variable>COMBO2</variable>
		  <item></item>
		  $PLUGIN_ITEMS
		</combobox>
	</hbox>   
	<hbox>
		<text><label>Plugin</label></text>
		<combobox>
		  <variable>COMBO3</variable>
		  <item></item>
		  $PLUGIN_ITEMS
		</combobox>
	</hbox>   
	<hbox>
		<text><label>Plugin</label></text>
		<combobox>
		  <variable>COMBO4</variable>
		  <item></item>
		  $PLUGIN_ITEMS
		</combobox>
	</hbox>   
	<hbox>
		<text><label>Plugin</label></text>
		<combobox>
		  <variable>COMBO5</variable>
		  <item></item>
		  $PLUGIN_ITEMS
		</combobox>
	</hbox>   
	<hbox>
	  <button cancel></button>
	  <button ok></button>
	</hbox>
  </frame>
  </vbox>
</window>
"

eval "$(gtkdialog3 --program=MAIN_DIALOG --center)"

if [[ $EXIT == OK ]] ; then
	if [ $COMBO1 ]; then
		ARG="$ARG $COMBO1"
	fi
	if [ $COMBO2 ]; then
		ARG="$ARG $COMBO2"
	fi
	if [ $COMBO3 ]; then
		ARG="$ARG $COMBO3"
	fi
	if [ $COMBO4 ]; then
		ARG="$ARG $COMBO4"
	fi
	if [ $COMBO5 ]; then
		ARG="$ARG $COMBO5"
	fi
	if [ "$ARG" ]; then
		ghostess $ARG
	fi	
fi	
