#!/bin/bash
#
#This box shows text in /tmp/box_help
#markup/span is valid
#
#usage :
# box_help HEADING [URL|ICON]
#
# HEADING is a short description. Maybe the app-name of the sender.
# URL is a link to a html-page (local or web), or a clean text file.
# ICON is a svg file. If path is not defined, /usr/share/pixmaps/puppy/ will be used
# 
#Sigmund Berglund, dec 2013
#GPL

export TEXTDOMAIN=libstardust

ICON=help.svg
ICON_WM=gtk-help
HEADING="$(gettext 'Puppy Help')"

if [ "`grep "svg$" <<< "$2"`" ]; then
	ICON="$2"
elif [ "`grep "svg$" <<< "$3"`" ]; then
	ICON="$3"
elif [ "$2" ]; then
	XML_URL='
	<vbox space-expand="false" space-fill="false">
	<hbox border-width="10" space-expand="true" space-fill="true">
	  <text space-expand="true" space-fill="true"><label>""</label></text>
	  <eventbox space-expand="false" space-fill="false">
	    <text use-markup="true" space-expand="false" space-fill="false">
	      <variable>URL</variable>
	      <label>"<b><u><span color='"'#004BDD'"'>'$(gettext 'Further reading')'</span></u></b>"</label>
	    </text>
	    <action signal="enter-notify-event">disable:URL</action>
	    <action signal="leave-notify-event">enable:URL</action>
	   <action signal="button-release-event">defaulthtmlviewer '$2'</action>
	  </eventbox>
	</hbox>
	</vbox>'
fi
if [ "`grep -F 'info.svg' <<< "$ICON"`" ]; then
	ICON_WM=gtk-file
	HEADING="$(gettext 'Puppy Info')"
fi

export Help='
<window title="'$HEADING'" icon-name="'$ICON_WM'" default-height="500" default-width="500">
<vbox space-expand="true" space-fill="true">
  '"`/usr/lib/gtkdialog/xml_info fixed $ICON 60 "<b>$HEADING</b>" "$1"`"'
  '$XML_URL'
  <vbox space-expand="true" space-fill="true">
    <vbox scrollable="true" shadow-type="3" space-expand="true" space-fill="true">
      <vbox space-expand="false" space-fill="false">
        <text xpad="10" ypad="15" use-markup="true"><input file>/tmp/box_help</input></text>
      </vbox>
    </vbox>
  </vbox>
  <hbox space-expand="false" space-fill="false">
    <button>
      '"`/usr/lib/gtkdialog/xml_button-icon ok`"'
      <label>'$(gettext 'Ok')'</label>
    </button>
  </hbox>
</vbox>
</window>'

. /usr/lib/gtkdialog/xml_info gtk
gtkdialog --center -p Help
