#!/bin/bash
#
###################################################################################################################
#Autor: 		Daniel Meiß-Wilhelm																				  #
#Freigegeben:	Januar 29 2014																					  #
#Distro:		PCLinuxOS 2014																					  #
#Lizenze:		GPL2																							  #
#Benötigt:		yad, gtkdialog, grep, ffmpeg, (Bestehende Internetverbindung) (Optional): mplayer, vlc 			  #							
#Beschreibung:	LXFreeTV ist eine freie Stream Anwendung zum anschauen von diversen Web-Streams.				  #
#				Nutzung erfolgt auf eigene Gefahr, bei Verlust von jeglichen Daten übernimmt der                  #
#				Autor keine Haftung.																			  #
#				Diesen Hinweis bitte nicht enfernen. Danke														  #
#Webseite:		http://www.pclinuxos.com/forum/index.php/topic,124226.0.html									  #
#Danksagung an:	Revoluz, Rogaven, discoverer, Just17, Ken														  #
###################################################################################################################
Encoding=UTF-8
#################### i18n - Internationalization - Internationalisierung ##########################################
export TEXTDOMAIN=lxfreetv.gui
export TEXTDOMAINDIR="/usr/share/locale"
#################################### einige variable ##############################################################
CONF_DIR=$HOME/.config/lxfreetv
if [ -f $CONF_DIR/channel ]; then
FILE="$CONF_DIR/channel"
else
FILE="/usr/share/lxfreetv/channel"
fi
##################################### Main Window #################################################################
EDITOR='
<window window_position="1" title="'$"Senderlisten Editor"'" resizable="true" icon-name="lxfreetv">
	<vbox>
		<vbox tooltip-text="'$"01|Mein Sendername|http://...
02|Mein anderer Sender|rtmp://...
03|Ein weiterer Sender|<rtmp://...> <pageUrl=http://...> <swfUrl=http://...> <playpath=...>"'">
		<text use-markup="True">
			<label>"'$"Eingabe sollte aussehen wie folgt: 
<b>01|Name|Url</b>"'"</label>
		</text>	
		</vbox>	
		<vbox wrap-mode="1" scrollable="true" width="800" height="200">
			<edit wrap-mode="0">
				<variable>EDIT</variable>
				<input file>'$FILE'</input>
			</edit>
		</vbox>	
		<hbox>
			<button use-stock="true" label="gtk-open">
				<action> '"sed -e '{s/#‎EXTM3U‬//;s/‪#‎EXTINF‬:-1//;s/#EXTINF:-1,//;/^\s*$/d;$!N;s/\n/|/;s/^/|/}' neu > channel1"'</action>
			</button>	
			<button use-stock="true" label="gtk-save">
				<variable>EDIT_DIALOG</variable>
				<action>mv '$CONF_DIR'/channel '$CONF_DIR'/channel.bak ; echo -e "$EDIT\n" | sed -e '/^\s*$/d' > '$CONF_DIR'/channel</action>
				<action type="refresh">EDIT</action>
				<action>yad --info --text="'$"Bitte LXFreeTV neustarten, um die aktuelle Senderliste zu nutzen!"'" --window-icon=gtk-dialog-info --image=gtk-dialog-info --title=INFO --button="gtk-ok:0"</action>
			</button>
		</hbox>
	<hseparator></hseparator>
		<hbox>
			<frame '$"Url prüfen"'>
				<entry>
					<variable>CHECK</variable>
				</entry>
			</frame>
		</hbox>
		<hbox>
		<hbox tooltip-text="'$"Bevor Sie eine Adresse hinzufügen, prüfen Sie diese auf Funktion."'">
			<button>
				<label>"'$"Prüfen"'"</label>
				<input file icon="gtk-execute"></input>
				<action>xterm -hold -e ffplay "$CHECK" &</action>
			</button>
		</hbox>
		<hbox>	
			<button use-stock="true" label="gtk-close"></button>
		</hbox>
		</hbox>
	</vbox>
</window>
'
#
export GUI="`echo "$EDITOR" | sed -e 's/##.*//'`" 
gtkdialog -p GUI #> /dev/null 2>&1

