#!/bin/sh
#called from dir2sfs
#200405 esmourguit: internationalized.

DEFnameonly="${1}"
DEFinstall="individual"
#export LANG=C
export TEXTDOMAIN=sfsget
export OUTPUT_CHARSET=UTF-8

export HLP_INSTALL="<window title=\"$(gettext 'Help: Container install mode')\" icon-name=\"gtk-index\" window_position=\"1\">
  <vbox>
    <text use-markup=\"true\">
      <label>\"$(gettext 'The SFS file will be installed as a container, with one of these modes:')

<b>$(gettext 'individual')</b>
$(gettext 'Each app in the SFS file will have its own icon on the desktop. This is only possible if there is at least one .desktop file in the SFS.
If there are no .desktop files, the install must be one of the following:')

<b>$(gettext 'desk')</b>
$(gettext 'There will be a single icon on the desktop. The container will run as a complete desktop, using the Xephyr X server.') 

<b>$(gettext 'terminal')</b>
$(gettext 'There will be a single icon on the desktop, that will open a terminal window in the container.') 

<b>$(gettext 'Technical notes')</b>
$(gettext '.desktop files are in /usr/share/applications in the SFS file. For individual mode, even if there are more than one .desktop files, it will still be one container, even though there will be multiple launch icons on the desktop.')\"
      </label>
      <variable>HLP_INSTALL</variable>
    </text>
    <hbox>
    <button>
      <label>$(gettext 'Close')</label>
      <action type=\"closewindow\">HLP_INSTALL</action>
    </button>
    </hbox>
  </vbox>
 </window>"

###install###
ITEMSINSTALL="<item>${DEFinstall}</item>"
for ONECHOICE in individual desk terminal
do
 [ "$ONECHOICE" = "${DEFinstall}" ] && continue
 ITEMSINSTALL="${ITEMSINSTALL}<item>${ONECHOICE}</item>"
done

export SFSSPEC_MODEDLG="
<window title=\"$(gettext 'SFS database-entry install-mode')\" icon-name=\"gtk-index\">
 <vbox>
 
  <text use-markup=\"true\"><label>\"$(gettext 'Before choosing all of the database settings for') <b>${DEFnameonly}</b> $(gettext 'SFS file, it is necessary to choose the installation mode')\"</label></text>

<frame $(gettext 'Container')>
  <hbox>
    <text>
      <label>$(gettext 'Container install mode:')</label>
    </text>
	<combobox>
      <variable>DB_install</variable>
	  ${ITEMSINSTALL}
    </combobox>
    <button>
      <input file>/usr/local/lib/X11/mini-icons/mini-question.xpm</input>
      <action type=\"launch\">HLP_INSTALL</action>
    </button>
  </hbox>
</frame>

  <hbox>
    <button>
     <label>OK</label>
     <action type=\"exit\">ok</action>
    </button>
    <button cancel></button>
  </hbox>
 </vbox>
</window>"

echo "$SFSSPEC_MAINDLG}" > /tmp/sfsget/SFSSPEC_MODEDLG #test
RETVALS="$(gtkdialog --program=SFSSPEC_MODEDLG --center)"
[ $? -ne 0 ] && exit 2
eval "$RETVALS"
[ "$EXIT" != "ok" ] && exit 3

echo -n "$DB_install" > /tmp/sfsget/sfsspec-install-mode
exit 0
###end###
