#!/bin/sh
##! /usr/sbin/gtkdialog3 -e
#BK nov 2007 gui frontend for dict.
#110126 improvements.

echo -n "" > /tmp/pdict-results.txt

yaf-splash -placement center -bg orange -close never -timeout 60 -fontsize large -text "Please wait, accessing online Dict server..." &
DICTLIST="`dict --dbs`"
killall yaf-splash
COMBOCONTENT="`echo "$DICTLIST" | tr "'" "_" | grep '^ ' | grep -v '^ \-' | sed -e 's/^ //' | sed -e 's/^/<item>/' | sed -e 's/$/<\/item>/'`" #'geany
COMBOCONTENT="<item>all        Search all databases</item>
${COMBOCONTENT}"

echo '#/bin/sh' > /tmp/pdict-func1
echo 'dict -d $2 $1  > /tmp/pdict-results.txt 2>&1'  >> /tmp/pdict-func1 #110126
chmod 755 /tmp/pdict-func1

export MAIN_DIALOG="
<window title=\"Pdict dictionary and thesaurus\" icon-name=\"gtk-info\">
 <vbox>
  <hbox>
   <text><label>enter a word:</label></text>
   <entry activates-default=\"true\">
    <variable>WORD</variable>
   </entry>
   <button has-default=\"true\">
    <input file stock=\"gtk-find\"></input>
    <label>dict</label>
    <action>/tmp/pdict-func1 \$WORD \$MYCHOICE</action>
    <action>refresh:INFO</action>
   </button>
  </hbox>
  <text><label>Choose which online database (default is all):</label></text>
  <combobox>
   <variable>MYCHOICE</variable>
$COMBOCONTENT
  </combobox>
  <frame result:>
   <edit>
    <variable>INFO</variable>
    <input file>/tmp/pdict-results.txt</input>
    <width>450</width>
    <height>300</height>
   </edit>
  </frame>
  <hbox>     
   <button>
    <label>exit</label>
    <input file stock=\"gtk-quit\"></input>
    <action type=\"exit\">EXIT</action>
   </button>
  </hbox>
 </vbox>
</window>
"

##i don't know enough about themes to do this any better...
##note, normal gtkrc is now ~/.gtkrc
#cp -f /etc/gtk-2.0/gtkrcMONOSPACED /etc/gtk-2.0/gtkrc
#echo '#!/bin/sh
# sleep 2
# rm -f /etc/gtk-2.0/gtkrc
#' > /tmp/delaygtkrc.sh
#chmod 755 /tmp/delaygtkrc.sh
#/tmp/delaygtkrc.sh &


RETSTRING="`gtkdialog3 --program=MAIN_DIALOG`"

###END###
