#!/bin/bash
#Pmusic - external menu
#Copyright 2013
#Sigmund Berglund



template(){
echo '<hbox spacing="0">
 <pixmap height-request="20" icon_size="1" space-expand="false" space-fill="false"><input file stock="gtk-'$3'"></input></pixmap>
 <button height-request="20" xalign="0" can-focus="no" relief="2" space-expand="true" space-fill="true">
  <label>" '$1'"</label>
  <action>echo '$2' > '$WORKDIR'/OUTPUT</action>
  <action>EXIT:exit</action>
 </button>
</hbox>'
}

export gtkdialog_menu='
<window decorated="false" skip_taskbar_hint="true" resizable="false" height-request="110" width-request="240" modal="true">
 <hbox scrollable="true" hscrollbar-policy="2" vscrollbar-policy="2" space-expand="true" space-fill="true">
  <text width-request="1" space-expand="false" space-fill="false"><label>""</label></text>
  <vbox spacing="2">
   <text height-request="2" space-expand="false" space-fill="false"><label>""</label></text>
   '"
   $(template " $(gettext 'Follow playque')" straight playmode_straight)
   $(template " $(gettext 'Repeat list after last track')" loop playmode_loop)
   $(template " $(gettext 'Play a random track')" shuffle playmode_shuffle)
   $(template " $(gettext 'Stop after this track')" stop playmode_stop)
   "'
  </vbox>
 </hbox>
 <action signal="focus-out-event">EXIT:exit</action>
</window>'

$GTKDIALOG -p gtkdialog_menu -G +"$(($PTR_X_ROOT-190))"+"$(($PTR_Y_ROOT-70))" > /dev/null
if [ -s "$WORKDIR/OUTPUT" ] ; then
	echo "$(<$WORKDIR/OUTPUT)" > $WORKDIR/PLAYMODE
	cp -f $APPDIR/themes/$THEME/icon_playmode_"$(<$WORKDIR/OUTPUT)".svg $WORKDIR/icon_playmode.svg
fi