#!/bin/sh
# Didier Spaier 2016-2020
if [ $UID -eq 0 ]; then
  echo "Please execute this script as a regular user, not as root."
  exit
fi
ROOT=`dirname "$0"`
TMP=$(mktemp -d) || exit 1
export TEXTDOMAIN=slint
. gettext.sh

Accessibility() {
REPLY=dummy
while [ ! -z $REPLY ]; do
    dialog --title "`gettext "Slint for the visually impaired"`" --nocancel --nook --menu \
    "`gettext "Navigate in this sub-menu with the up and down arrow keys.
Press Enter to read a highlighted document.
Press Q to stop reading a document and go back to this sub-menu.
Press Escape to return to the main menu."`" 0 0 14 \
    "Accessibility" "`gettext "Accessibility HowTo"`" \
    "Brltty" "`gettext "Brltty HowTo"`" \
    "CompizKeyBindings" "`gettext "Key bindings for Compiz "`" \
    "MateKeyBindings" "`gettext "Key bindings for Mate"`" \
    "README.espeakup" "`gettext "Espeakup usage"`" \
    "README.fenrir" "`gettext "Fenrir usage"`" \
    "README.mbrola" "`gettext "How-to use the MBROLA voices"`" \
    "README.speechd-el" "`gettext "SpeechD-El usage"`" \
    "README.speechd-up" "`gettext "SpeechD-Up usage"`" \
    "SlintSpeaks" "`gettext "How-to make Slint speak (or not)."`" \
    "SpeakupDesktopKeys" "`gettext "Speakup key bindings with a numeric keypad"`" \
    "SpeakupLaptopKeys" "`gettext "Speakup key bindings without numeric keypad"`" \
    "Voices" "`gettext "Voices and TTS in Slint"`" \
    "spkguide.txt" "`gettext "Speakup guide (kernel documentation)"`" \
    2>$TMP/reply
    REPLY="$(cat $TMP/reply)"
    rm -f $TMP/reply
    if [ ! -z $REPLY ]; then
      most $ROOT/Accessibility/$REPLY
    fi
done
REPLY=dummy
}
Localization() {
REPLY=dummy
while [ ! -z $REPLY ]; do
    dialog --title "`gettext "How to localize shell scripts"`" --nocancel --nook --menu \
    "`gettext "Navigate in this sub-menu with the up and down arrow keys.
Press Enter to read a highlighted document.
Press Q to stop reading a document and go back to this sub-menu.
Press Escape to return to the main menu."`" 0 0 6 \
    "1_PRESENTATION" "`gettext "General presentation"`" \
    "2_DIAGRAMS" "`gettext "Processes diagrams"`" \
    "3_INTERNATIONALIZATION" "`gettext "Internationalization process"`" \
    "4_LOCALIZATION" "`gettext "Localization, usage and maintenance processes"`" \
    "5_MAINTAINERS" "`gettext "Recommendations for developers and maintainers"`" \
    "6_TRANSLATORS" "`gettext "Recommendations for translators"`" \
    2>$TMP/reply
    REPLY="$(cat $TMP/reply)"
    rm -f $TMP/reply
    if [ ! -z $REPLY ]; then
      most $ROOT/Localization/$REPLY
    fi
done
REPLY=dummy
}
Persian() {
REPLY=dummy
while [ ! -z $REPLY ]; do
    dialog --title "`gettext " How to display man pages in Persian "`" --nocancel --nook --menu \
    "`gettext "Navigate in this sub-menu with the up and down arrow keys.
Press Enter to read a highlighted document.
Press Q to stop reading a document and go back to this sub-menu.
Press Escape to return to the main menu."`" 0 0 2 \
    "man_en.pdf" "`gettext "How to in English (Portable Document)"`" \
    "man_fa.pdf" "`gettext "How to in Persian (Portable Document)"`" \
    2>$TMP/reply
    REPLY="$(cat $TMP/reply)"
    rm -f $TMP/reply
    if [ ! -z $REPLY ]; then
		if [ "$(which acroread)" = "/usr/bin/acroread" ]; then
			/usr/bin/acroread $ROOT/Persian/$REPLY & 1>/dev/null 2>/dev/null
		elif [ "$(which atril)" = "/usr/bin/atril" ]; then
			/usr/bin/atril $ROOT/Persian/$REPLY & 1>/dev/null 2>/dev/null
		elif [ "$(which evince)" = "/usr/bin/evince" ]; then
			/usr/bin/evince $ROOT/Persian/$REPLY & 1>/dev/null 2>/dev/null
		elif [ "$(which xpdf)" = "/usr/bin/xpdf" ]; then
			/usr/bin/xpdf $ROOT/persian/$REPLY & 1>/dev/null 2>/dev/nullP
		fi		   
    fi
done
REPLY=dummy
}
REPLY=dummy
while [ ! -z $REPLY ]; do
    dialog --title "`gettext " Slint documentation "`" --nocancel --nook --menu \
    "`gettext "Navigate in this menu with the up and down arrow keys.
Press Enter to read a highlighted document.
Press Q to stop reading a document and go back to the menu.
Press Escape to quit."`" 0 0 14\
    "AboutSlint" "`gettext "Presentation of the Slint project"`" \
    "Accessibility" "`gettext ">> Slint for the visually impaired (sub-menu)"`" \
    "Announce" "`gettext "Announce of Slint64-14.2.1.2"`" \
    "Introduction"  "`gettext "Introduction - Slint documentation"`" \
    "KernelUpgrade" "`gettext "How to upgrade the kernels provided by Slint"`" \
    "Localization" "`gettext ">> How-to localize shell scrips (sub-menu)"`" \
    "Persian" "`gettext ">> How-to display man pages in Persian (sub-menu)"`" \
    "Network" "`gettext "How to manage network connections"`" \
    "New" "`gettext "What's new in Slint64-14.2.1.2"`" \
    "Presentation" "`gettext "Presentation of Slint64-14.2.1.2"`" \
    "SlintPortable" "`gettext "Create and maintain a portable Slint"`" \
    "SoftwareManagement" "`gettext "Software Management in Slint"`" \
    "Sound" "`gettext "Manage the sound in Slint"`" \
    "Utilities" "`gettext "Utilities to manage your Slint system"`" \
    2>$TMP/reply
    REPLY="$(cat $TMP/reply)"
    rm -f $TMP/reply
    if [ ! -z $REPLY ]; then
        if [ "$REPLY" = "AboutSlint" ] || \
        [ "$REPLY" = "Announce" ] || \
        [ "$REPLY" = "Introduction" ] || \
        [ "$REPLY" = "KernelUpgrade" ] || \
        [ "$REPLY" = "Network" ] || \
        [ "$REPLY" = "New" ] || \
        [ "$REPLY" = "Presentation" ] || \
        [ "$REPLY" = "SlintPortable" ] || \
        [ "$REPLY" = "SoftwareManagement" ] || \
        [ "$REPLY" = "Sound" ] || \
        [ "$REPLY" = "Utilities" ]; then
			most $ROOT/Main/$REPLY
		else
		    $REPLY
		fi
	  
    fi
done
rm -rf $TMP

