#! /bin/bash
#
Encoding=UTF-8
#############################################################################
#																			#
# Author D.M-Wilhelm aka Leiche <kellerleicheorig@aol.com> at Nov 05 2010	#
# Website <kellerleiche.bplaced.net> 										#
# Designed for PCLinuxOS'10													#
# Release 2010-2017															#
# License GPL2																#
#																			#
#############################################################################
				

# i18n - Internationalization - Internationalisierung
export TEXTDOMAIN=pclos-flv-main
export TEXTDOMAINDIR="/usr/share/locale"
#
{
TITLE=$"FLV-Player and Converter"
dirname="$(dirname "$(readlink -e "$0")")"
VERSION=" `cat "$dirname"/Version`"
TMP_DIR=$HOME/.config/pclos-flv-player
D_STATUS=`cat "$TMP_DIR"/directory`
SAVE_STATUS=`cat "$TMP_DIR"/s_directory | grep /`
}
{
if [ $(grep -c xy "$TMP_DIR"/scale) -gt 0 2>/dev/null ]; then   
	S_STATUS=true
	SCALE_STATUS=`cat $TMP_DIR/scale | cut -d " " -f2`
else
	S_STATUS=false
fi
if [ $(grep -c geometry "$TMP_DIR"/position) -gt 0 2>/dev/null ]; then   
	P_STATUS=true
	POSITION_STATUS=`cat $TMP_DIR/position | cut -d " " -f2`
else
	P_STATUS=false
fi
if [ $(grep -c cookies "$TMP_DIR"/cookies) -gt 0 2>/dev/null ]; then   
	C_STATUS=true
	COOKIES_STATUS=`cat $TMP_DIR/cookies`
else
	C_STATUS=false
fi
if [ $(grep -c hold "$TMP_DIR"/terminal) -gt 0 2>/dev/null ]; then   
	H_STATUS=true
else
	H_STATUS=false
fi
}
{
export SETTINGS='
<window window_position="1" title="Default Settings" width_request="500"  icon-name="pclos_flv_main" skip_taskbar_hint="true">
	<vbox>
		<frame '$"Mplayer Settings"'>
			<text><label>'$"Scale Mplayer window "'</label></text>
				<hbox tooltip-text="'$"Assign Mplayer window a fixed size"'">
					<text><label>'$"Scale value: "'</label></text>
						<entry>
							<variable>SCALE</variable>
							<default>"'$SCALE_STATUS'"</default>
							<visible>true</visible>
						</entry>
					<checkbox  active="'$S_STATUS'">
						<label>'$"Scale"'</label>
						<variable>SCALE_ON</variable>
						<action>if true echo -xy $SCALE > '"$TMP_DIR"'/scale</action>
						<action>if true disable:SCALE</action>
						<action>if false echo > '"$TMP_DIR"'/scale</action>
						<action>if false enable:SCALE</action>
						<action type="refresh">SCALE_ON</action>
					</checkbox>
				</hbox>
			<text><label>'$"Set Mplayer position "'</label></text>
				<hbox tooltip-text="'$"Assign Mplayer a fixed position on desktop"'">
					<text><label>'$"Position value: "'</label></text>
						<entry>
							<variable>POSITION</variable>
							<default>"'$POSITION_STATUS'"</default>
							<visible>true</visible>
						</entry>
					<checkbox  active="'$P_STATUS'">
						<label>'$"Position"'</label>
						<variable>POSITION_ON</variable>
						<action>if true echo -geometry $POSITION > '"$TMP_DIR"'/position</action>
						<action>if true disable:POSITION</action>
						<action>if false echo > '"$TMP_DIR"'/position</action>
						<action>if false enable:POSITION</action>
						<action type="refresh">SCALE_ON</action>
					</checkbox>
				</hbox>
			</frame>	
			<frame '$"Default Settings"'>	
				<hbox tooltip-text="'$"Set a default directory to load"'">
					<text><label>'$"Directory:"'</label></text>
						<entry accept="directory">
						<default>'$D_STATUS'</default>
						<variable>DIRECTORY</variable>
						</entry>
					<button>
						<input file>/usr/share/PCLinuxOS-FLV-Player/icons/open24.png</input>
						<variable>FILE_BROWSE_FILENAME</variable>
						<action type="fileselect">DIRECTORY</action>
						<action>echo $DIRECTORY > '"$TMP_DIR"'/directory</action>
						<action>echo hide > '"$TMP_DIR"'/browser</action>
					</button>
				</hbox>
				<text><label>'$"Use cookies-from-browser CHROME "'</label></text>
				<hbox tooltip-text="'$"Sign in to confirm you’re not a bot."'">
					<entry>
						<variable>COOKIES</variable>
						<default>"'$COOKIES_STATUS'"</default>
						<visible>true</visible>
					</entry>
					<checkbox  active="'$C_STATUS'">
						<label>'$"Enable"'</label>
						<variable>COOKIES_ON</variable>
						<action>if true echo --cookies-from-browser chrome > '"$TMP_DIR"'/cookies</action>
						<action>if false echo > '"$TMP_DIR"'/cookies</action>
						<action type="refresh">COOKIES_ON</action>
					</checkbox>
				</hbox>
				<text><label>'$"Hold open the terminal "'</label></text>
				<hbox tooltip-text="'$"See the output of the download."'">
					<checkbox  active="'$H_STATUS'">
						<label>'$"Enable"'</label>
						<variable>HOLD_ON</variable>
						<action>if true echo -hold > '"$TMP_DIR"'/terminal</action>
						<action>if false echo > '"$TMP_DIR"'/terminal</action>
						<action type="refresh">HOLD_ON</action>
					</checkbox>
				</hbox>
			</frame>
			<hbox>
				<vbox>	
					<button>
						<label>'$"Close"'</label>
						<input file>/usr/share/PCLinuxOS-FLV-Player/icons/exit24.png</input>
						<variable>SETTINGS</variable>
						<action type="closewindow">SETTINGS</action>
					</button>
				</vbox>
			</hbox>
	</vbox>
</window>
'
}
gtkdialog --program=SETTINGS > /dev/null 2>&1
