#!/bin/bash
#Ptimer
#Copyright 2007,2008
#Sigmund Berglund

#------------------------------
#This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation version 2.

#This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. <http://www.gnu.org/licenses/>.
#------------------------------

VERSION="0.1"
APPDIR="`dirname $0`"
[ "$APPDIR" = "." ] && APPDIR="`pwd`"
export APPDIR="$APPDIR"

export Ptimer="
<window title=\"Ptimer $VERSION\"icon-name=\"gtk-execute\">
 <vbox>
  <notebook labels=\" Stop watch | Clock | Suit\">
   <vbox>
    <frame Timer>
     <checkbox>
      <variable>TIMER</variable>
      <label>Alarm after given time</label>
      <action>if false disable:ENTRY_TIMER</action>
      <action>if true enable:ENTRY_TIMER</action>
      <action>if false disable:TEXT_TIMER</action>
      <action>if true enable:TEXT_TIMER</action>
     </checkbox>
     <hbox>
      <entry>
       <variable>ENTRY_TIMER</variable>
       <input>echo '00:00'</input>
       <visible>disabled</visible>
      </entry>
      <text>
       <variable>TEXT_TIMER</variable>
       <label>Minutes:Seconds</label>
       <visible>disabled</visible>
      </text>
     </hbox>
    </frame>
    <frame Count>
     <checkbox>
      <variable>TENTH</variable>
      <default>true</default>
      <label>Count tenth</label>
      <action>if true disable:COUNTDOWN</action>
      <action>if false enable:COUNTDOWN</action>
     </checkbox>
     <checkbox>
      <variable>COUNTDOWN</variable>
      <default>true</default>
      <visible>disabled</visible>
      <label>Countdown - Sync with system time</label>
      <action>if true enable:TENTH</action>
      <action>if false disable:TENTH</action>
     </checkbox>
    </frame>
    <hbox>
     <checkbox>
      <variable>AUTOSTART</variable>
      <default>true</default>
      <label>Auto start</label>
     </checkbox>
    </hbox>
    <button>
     <label>Start</label>
     <action>. $APPDIR/func -stopwatch</action>
    </button>
   </vbox>
   <vbox>
    <frame Alarm>
     <checkbox>
      <variable>CLOCK_ALARM</variable>
      <label>Alarm at given time</label>
      <action>if false disable:ENTRY_ALARM</action>
      <action>if true enable:ENTRY_ALARM</action>
      <action>if false disable:TEXT_ALARM</action>
      <action>if true enable:TEXT_ALARM</action>
     </checkbox>
     <hbox>
      <entry>
       <variable>ENTRY_ALARM</variable>
       <input>echo '00:00'</input>
       <visible>disabled</visible>
      </entry>
      <text>
       <variable>ALARM_TIMER</variable>
       <label>Hours:Minutes</label>
       <visible>disabled</visible>
      </text>
     </hbox>
    </frame>
    <button>
     <label>Start</label>
     <action>. $APPDIR/func -clock</action>
    </button>
   </vbox>
   <vbox>
    <frame Sound>
     <hbox>
      <text><label>Alarm</label></text>
      <entry>
       <variable>SOUND_ALARM</variable>
       <input>echo 'aplay /usr/share/audio/beep_high.wav'</input>
      </entry>
     </hbox>
    <hbox>
      <text><label>Beep High</label></text>
      <entry>
       <variable>SOUND_BEEP_HIGH</variable>
       <input>echo 'aplay /usr/share/audio/beep_high.wav'</input>
      </entry>
     </hbox>
    <hbox>
      <text><label>Beep Low</label></text>
      <entry>
       <variable>SOUND_BEEP_LOW</variable>
       <input>echo 'aplay /usr/share/audio/beep_low.wav'</input>
      </entry>
     </hbox>
    </frame>
    <frame Font>
     <hbox>
      <entry>
       <variable>ENTRY_FONT</variable>
       <input>echo 'Mono'</input>
      </entry>
      <entry>
       <variable>ENTRY_FONTSIZE</variable>
       <input>echo '60'</input>
       <width>40</width><height>25</height>
      </entry>
     </hbox>
    </frame>
    <frame Window size (X:Y)>
     <entry>
      <variable>ENTRY_WINDOWSIZE</variable>
     </entry>
    </frame>
   </vbox>
  </notebook>
 </vbox>
</window>"
I=$IFS; IFS=""
for STATEMENTS in  $(gtkdialog3 --program=Ptimer --center); do
	eval $STATEMENTS
done
IFS=$I
case $EXIT in
	*)			exit;;
esac
