#!/bin/bash
#Lesser GPL licence v2 (http://www.fsf.org/licensing/licenses/lgpl.html)
#v3.02 Nov 2007 BK: updated. handle PET pkgs only.
#v3.99 apr2008 BK: run /usr/local/petget/pkg_chooser.sh instead of petget.
#v404 add choice of Universal Installer.
#w015 march 2009 BK: update for Woof.
#w018 may 2010 UR: i18n
# 18aug10 shinobar: frugalinstaller
# 3jan11 shinobar i18n with local eval_gettext, horisontal layout
TEXTDOMAINDIR=/usr/share/locale
TEXTDOMAIN=dotpup
export TEXTDOMAINDIR
export TEXTDOMAIN
export OUTPUT_CHARSET="UTF-8"
eval_gettext () {
  local myMESSAGE=$(gettext "$1")
  eval echo \"$myMESSAGE\"
}
F="/usr/bin/gettext.sh"
[ -s $F ] && $F

. /etc/DISTRO_SPECS

# has frugalinstaller? quickpet?
which frugalinstaller &>/dev/null && HASFRUGAL="yes" || HASFRUGAL=""
which quickpet &>/dev/null && HASQUICKPET="yes" || HASQUICKPET=""

ANYTHING=$(gettext "Puppy can be installed to just about anything, including internal hard drive, USB drive, and Zip/LS120 diskette. If for example you are now running Puppy from live-CD and fancy booting Puppy off a USB Flash drive, this is the right place.")
FRUGALORFULL=$(gettext "Puppy has 'frugal' style installation, putting some files on any type of partitions and leaving the previous contents untouched. Also Puppy can be 'full' installed, the ordinal style of regacy linuxes. The 'full' requires at least one exclusive partition for puppy.")

TOOLS=$(gettext "There are two tools, the Puppy Universal Installer, and BootFlash.")
FRUGALMSG=""
UNIVERSALMSG=""
BOOTFLASHMSG=$(gettext "BootFlash is your another choice, a specialised tool if you cannot get the computer to boot from a USB drive.")
RECOMMENDED="($(gettext 'recmmended'))"
FRUGALBUTTON=""
RECCOMEND_U=""
if [ "$HASFRUGAL" != "" ]; then
  TOOLS=$(gettext "The tools are the Frugal Installer, the Puppy Universal Installer, and BootFlash.")
  FRUGALMSG=$(gettext "The Frugal Installer is a nice tool for 'frugal' install. You must use the Univasal Installer if you like 'full' install.")
  FRUGALBUTTON="<hbox>
   <text><label>`gettext \"Click button to run the Frugal Installer:\"`$RECOMMENDED</label></text>
   <vbox>
    <button>
     <input file>/usr/local/lib/X11/mini-icons/mini-ray.xpm</input>
     <action>frugalinstaller &</action>
     <action>EXIT:13</action>
    </button>
   </vbox>
  </hbox>"
else
  RECOMMEND_U="$RECOMMENDED"
fi
QUICKMSG=""
if [ "$HASQUICKPET" != "" ]; then
  QUICKMSG="<text><label>$(gettext "You also have the tool 'Quickpet', easy to instal popular applications. Click 'Quickpet' icon on the desktop.")</label></text>"
fi
export MAIN_DIALOG="
 <window title=\"`gettext \"Install\"`\">
 <vbox>
 <text><label>`gettext \"The word 'install' can mean two different things, either to install additional applications in the current Puppy, or to install Puppy to some other media. Take your pick!\"`</label></text>
 <hbox>
 <frame `gettext \"Install Puppy\"`>
  <text><input>echo -en \"$ANYTHING\"</input></text>
   <text><input>echo -en \"$FRUGALORFULL\"</input></text>
  <text><input>echo -en \"$TOOLS $FRUGALMSG $UNIVERSALMSG $BOOTFLASHMSG\"</input></text>
   $FRUGALBUTTON
  <hbox>
   <text><label>`gettext \"Click button to run the Universal Installer:\"`$RECOMMEND_U</label></text>
   <vbox>
    <button>
     <input file>/usr/local/lib/X11/mini-icons/mini-ray.xpm</input>
     <action>/usr/sbin/puppyinstaller &</action>
     <action>EXIT:14</action>
    </button>
   </vbox>
  </hbox>
  <hbox>
   <text><label>`gettext \"Click button to run BootFlash USB installer:\"`</label></text>
   <vbox>
    <button>
     <input file>/usr/local/lib/X11/mini-icons/mini-ray.xpm</input>
     <action>/usr/sbin/bootflash &</action>
     <action>EXIT:14</action>
    </button>
   </vbox>
  </hbox>
 </frame>

 <frame `gettext \"Install applications\"`>
  <text><input>echo -en \"`eval_gettext \"The Puppy Package Manager is a tool for installing and uninstalling packages (applications). There are online repositories of \\\${DISTRO_BINARY_COMPAT} and Puppy packages -- the latter are known as PET packages and are identified by '.pet' on the end of their filename. Note that apart from the official \\\${DISTRO_BINARY_COMPAT} and PET repositories, Puppy enthusiasts have created many PETs at other locations, and all you need to do is download one and click on it to install it.\"`\"</input></text>
   <hbox>
   <text><label>`gettext \"Click button for Package Manager introduction webpage:\"`</label></text>
   <vbox>
    <button>
     <input file>/usr/local/lib/X11/mini-icons/info16.xpm</input>
     <action>defaultbrowser http://puppylinux.com/woof/ppm.htm &</action>
    </button>
   </vbox>
  </hbox>

  <hbox>
   <text><label>`gettext \"Click button to run the Puppy Package Manager:\"`</label></text>
   <vbox>
    <button>
     <input file>/usr/local/lib/X11/mini-icons/pet16.xpm</input>
     <action>/usr/local/petget/pkg_chooser.sh &</action>
     <action>EXIT:14</action>
    </button>
   </vbox>
  </hbox>
  $QUICKMSG
 </frame>
 
 </hbox></vbox></window>
"
gtkdialog3 || echo  "$MAIN_DIALOG" >&2

###END###
