#!/bin/bash

# Copyright Jean-Philippe Guillemin <jp.guillemin@free.fr>. 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. Please take a look at http://www.gnu.org/copyleft/gpl.htm
# Copyright Jean-Philippe Guillemin <jp.guillemin@free.fr>. 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. Please take a look at http://www.gnu.org/copyleft/gpl.htm
#
# Xnetconf is a complete GTK network configuration tool for Zenwalk Linux
#

# version="1.1"

export MAIN='
<window title="Xnetconf" icon-name="xnetconf">
<vbox>
	<menubar>
		<menu>
			<menuitem icon="gtk-quit">
				<action type="exit">=quit</action>
				<label>Exit</label>
			</menuitem>
			<label>File</label>
		</menu>
		<menu>
			<menuitem icon="gtk-dialog-info">
				<action type="launch">ABOUT_DIALOG</action>
				<label>Info</label>				
			</menuitem>
			<label>Help</label>
		</menu>
	</menubar>
  
  
  
	<hbox>
		<vbox>
			<frame Interfaces>
				<tree icon="nic" exported_column="1">
					<label>Network Interfaces	| Status</label>
					<input>getIlist</input>
					<height>110</height><width>250</width>
					<variable>IF</variable>
					<action signal="cursor_changed" type="clear">INFO</action>
					<action signal="cursor_changed" type="refresh">INFO</action>
					<action signal="cursor_changed" type="clear">IP</action>
					<action signal="cursor_changed" type="refresh">IP</action>	
					<action signal="cursor_changed" type="clear">MASK</action>
					<action signal="cursor_changed" type="refresh">MASK</action>	
					<action signal="cursor_changed" type="clear">DHCP</action>
					<action signal="cursor_changed" type="refresh">DHCP</action>															
					<action type="refresh">IP</action>
					<action type="refresh">MASK</action>
					<action type="clear">INFO</action>
					<action type="refresh">INFO</action>
				</tree>
			</frame>
			<frame IP parameters>
				<hbox>
					<text>
						<label>Ip address</label>
					</text>
					<entry>
						<input>getIP</input>
						<variable>IP</variable>
					</entry>
				</hbox>     
				<hbox>               
					<text>
						<label>Network mask</label>
					</text>
					<entry>
						<input>getMASK</input>
						<variable>MASK</variable>
					</entry>
				</hbox>  
				<checkbox>
					<label>Use DHCP</label>
					<input>getDHCP</input>
					<variable>DHCP</variable>
					<action>if false enable:IP</action>
					<action>if false enable:MASK</action>
					<action>if false disable:DHCPDNS</action>	
					<action>if false disable:DHCPGW</action>											
					<action>if true disable:IP</action>
					<action>if true disable:MASK</action>	
					<action>if true enable:DHCPDNS</action>	
					<action>if true enable:DHCPGW</action>					
				</checkbox>  
			</frame>
			<frame Ethernet Information>
				<table>
					<variable>INFO</variable>
					<input>getINFO</input>      
					<height>90</height><width>250</width>
				</table>
			</frame> 	
		</vbox>  
		<vbox>	
			<frame DNS>  
				<hbox>               
					<text>
						<label>Name server 1</label>
					</text>
					<entry>
						<input>getDNS1</input>
						<variable>DNS1</variable>
					</entry>
				</hbox> 
				<hbox>               
					<text>
						<label>Name server 2</label>
					</text>
					<entry>
						<input>getDNS2</input>
						<variable>DNS2</variable>
					</entry>
				</hbox> 
				<checkbox>
					<label>Use DHCP</label>
					<input>getDHCPDNS</input>
					<variable>DHCPDNS</variable>
					<action>if false enable:DNS1</action>					
					<action>if true disable:DNS1</action>	
					<action>if false enable:DNS2</action>					
					<action>if true disable:DNS2</action>
					<visible>disabled</visible>		
					<action signal="show" type="refresh">DHCP</action>						
				</checkbox>  
			</frame>				
			<frame Gateway>  				
				<hbox>               
					<text>
						<label>Default gateway</label>
					</text>
					<entry>
						<input>getGATEWAY</input>
						<variable>GATEWAY</variable>
					</entry>
				</hbox>   
				<checkbox>
					<label>Use DHCP</label>
					<input>getDHCPGW</input>
					<variable>DHCPGW</variable>
					<action>if false enable:GATEWAY</action>					
					<action>if true disable:GATEWAY</action>		
					<visible>disabled</visible>		
					<action signal="show" type="refresh">DHCP</action>						
				</checkbox>    				
			</frame>
			<frame Host and domain>  
				<hbox>               
					<text>
						<label>Hostname</label>
					</text>
					<entry>
						<input>getHOST</input>
						<variable>HOST</variable>
					</entry>
				</hbox>   
				<hbox>               
					<text>
						<label>Domain</label>
					</text>
					<entry>
						<input>getDOMAIN</input>
						<variable>DOMAIN</variable>
					</entry>
				</hbox> 					
			</frame>
			<frame Firewall>              
				<checkbox>
					<label>Enable firewall</label>
					<input>getFW</input>
					<variable>FW</variable>		
				</checkbox>  					
			</frame>
			<button>
				<input file icon="gtk-apply"></input>
				<label> Apply configuration </label>
				<variable>APPLYBUTTON</variable>
				<action type="launch">APPLY</action> 
			</button>
		</vbox>
	</hbox>
</vbox>
<action signal="show" type="clear">INFO</action>
<action signal="show" type="refresh">INFO</action>
<action signal="delete-event" type="exit">=quit</action>
</window>
'


export APPLY='
<window title="Applying" icon-name="xnetconf">
	<vbox>
		<frame>
			<progressbar>
				<input>apply</input>
				<action type="clear">IP</action>
				<action type="refresh">IP</action> 
				<action type="clear">MASK</action>
				<action type="refresh">MASK</action>
				<action type="clear">GATEWAY</action>
				<action type="refresh">GATEWAY</action>		
				<action type="clear">DNS1</action>
				<action type="refresh">DNS1</action>			
				<action type="clear">DNS2</action>
				<action type="refresh">DNS2</action>		
				<action type="clear">HOST</action>
				<action type="refresh">HOST</action> 	
				<action type="clear">DOMAIN</action>
				<action type="refresh">DOMAIN</action> 								          
				<action type="enable">IF</action>
				<action type="clear">IF</action>
				<action type="refresh">IF</action>
				<action type="closewindow">APPLY</action>
			</progressbar>
    	</frame>  
  </vbox>
<action signal="show" type="disable">IF</action>
</window>
'

export ABOUT_DIALOG='
<window title="About" icon-name="xnetconf">
<vbox>          
	<pixmap>
		<input file>/usr/share/icons/hicolor/scalable/apps/xnetconf.svg</input>
	</pixmap>
	<frame xnetconf>
		<text wrap="true" width-chars="50">
			<label>"Xnetconf 1.0.
Xnetconf is a simple Network configuration tool. Copyright Jean-Philippe Guillemin <jp.guillemin@free.fr> - GNU General Public License."</label>
		</text>
	</frame>
	<hbox>
		<button>
			<input file icon="gtk-close"></input>
			<label>Close</label>
			<action type="closewindow">ABOUT_DIALOG</action>
		</button>
	</hbox>
</vbox>
</window>
'
