#!/bin/sh

LOGFILE="$1"
BUTTONTEXT="$2" #ex: Cancel
X_POS=$3
Y_POS=$4
WIDTHPIXELS=$5
HEIGHTPIXELS=$6
TITLE="$7"

WIDTHCHARS=`expr $WIDTHPIXELS \/ 7`
HEIGHTCHARS=`expr $HEIGHTPIXELS \/ 8`

#mono text for log box...
echo 'style "specialmono"
{
  font_name="Mono 13"
}

class "GtkText*" style "specialmono"' > /tmp/gtkrc_mono
export GTK2_RC_FILES=/tmp/gtkrc_mono:/root/.gtkrc-2.0

XDIALOG=`which Xdialog`
ln -snf $XDIALOG /tmp/gtklogfileviewer #hack so pburn will kill it.

/tmp/gtklogfileviewer --title "$TITLE" --buttons-style text --fixed-font --no-ok --cancel-label "$BUTTONTEXT" --begin $X_POS $Y_POS --tailbox "$LOGFILE" $HEIGHTCHARS $WIDTHCHARS > /dev/null 2>&1
RETVAL=$?

if [ $RETVAL -eq 1 ];then
 echo 'exitbutton'
else
 echo 'windowclosed'
fi
