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

export TEXTDOMAIN=pdict
export TEXTDOMAINDIR=/usr/share/locale
export OUTPUT_CHARSET=UTF-8
. gettext.sh


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

/usr/lib/gtkdialog/box_splash -placement center -close never -timeout 60 -fontsize large -text "$(gettext '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        $(gettext '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=\"$(gettext 'Pdict dictionary and thesaurus')\" icon-name=\"gtk-info\">
 <vbox>
  <hbox>
   <text><label>$(gettext 'enter a word:')</label></text>
   <entry activates-default=\"true\">
    <variable>WORD</variable>
   </entry>
   <button has-default=\"true\">
    <input file stock=\"gtk-find\"></input>
    <label>$(gettext 'dict')</label>
    <action>/tmp/pdict-func1 \$WORD \$MYCHOICE</action>
    <action>refresh:INFO</action>
   </button>
  </hbox>
  <text><label>$(gettext '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>$(gettext 'exit')</label>
    <input file stock=\"gtk-quit\"></input>
    <action type=\"exit\">EXIT</action>
   </button>
  </hbox>
 </vbox>
</window>
"


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

###END###
