#!/bin/bash
#=======================================================================
# Copyright (c) 2000-2001 Daniele Giacomini daniele@swlibero.org
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
#=======================================================================
# alml-extra-menu ARGUMENT
#
# Simple front-end for the alml-extra utility.
#=======================================================================


#-----------------------------------------------------------------------
# Variables.
#-----------------------------------------------------------------------
OPTION=""
ARGUMENT=$1
TEMPORARY_FILE=""
RESULT=""
CHOICHE=""

#======================================================================
# Start of program.
#======================================================================

TEMPORARY_FILE=`tempfile`

dialog	\
    --clear \
    --title "alml-extra OPTION $ARGUMENT" \
    --menu \
	"\nSelect the option:\n" \
	25 78 15 \
	"--a4-to-a5-2-a4"           "A4 to A5, no folding" \
	"--a4-to-a6-4-a4"           "A4 to A6, no folding" \
	"--a4-to-a5-2-a4-1h-1"      "A4 to A5, folded, signature 1" \
	"--a4-to-a5-2-a4-1h-10"     "A4 to A5, folded, signature 10" \
	"--a4-to-a6-4-a4-2h-2"      "A4 to A6, folded twice, signature 2" \
	"--a4-to-a6-4-a4-2h-4"      "A4 to A6, folded twice, signature 4" \
	"--a4-to-a6-4-a4-2h-6"      "A4 to A6, folded twice, signature 6" \
	"--a4-to-a6-4-a4-2h-8"      "A4 to A6, folded twice, signature 8" \
	"--a4-to-a6-4-a4-2h-10"     "A4 to A6, folded twice, signature 10" \
	"--a4-to-a6-4-a4-1v-1"      "A4 to A6, folded vertically, signature 1" \
	"--a7x4-to-a7x4-2-a4-1v-1"  "A7x4 to A7x4, folded vertically, signature 1" \
	"--a7x4-to-a7x4-2-a4-1v-10" "A7x4 to A7x4, folded vertically, signature 10" \
    2> $TEMPORARY_FILE

RESULT=$?

CHOICHE=`cat $TEMPORARY_FILE`
rm -f $TEMPORARY_FILE

case $RESULT
in
    0)
	OPTION=$CHOICHE;;
    1)
	exit 1;;
    255)
	exit 255;;
    *)
	exit 255;;
esac

echo alml-extra $OPTION $ARGUMENT
alml-extra $OPTION $ARGUMENT
