wok diff tazndis/stuff/tazndisbox @ rev 2274

tazndis: Add GUI interface (tazndisbox)
author Christophe Lincoln <pankso@slitaz.org>
date Wed Feb 18 16:27:01 2009 +0100 (2009-02-18)
parents
children e45ae1cf64ea
line diff
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/tazndis/stuff/tazndisbox	Wed Feb 18 16:27:01 2009 +0100
     1.3 @@ -0,0 +1,158 @@
     1.4 +#!/bin/sh
     1.5 +#
     1.6 +# GTKdialog interface to tazndis: let users manage easly Windows drivers.
     1.7 +# Use tabs to indent, split commands from the GUI and use functions.
     1.8 +#
     1.9 +# (c) 2009 SliTaz GNU/Linux - GNU gpl v3
    1.10 +#
    1.11 +
    1.12 +# Languages messages translations
    1.13 +
    1.14 +case $LANG in
    1.15 +	fr*)
    1.16 +		REMOVE_DRIVER_MSG="Double clique sur un driver pour le supprimer."
    1.17 +		FILE_ENTRY_MSG="Fichier (.inf):"
    1.18 +		BUTTON_MSG="Installer"
    1.19 +		MODULE_STATUS_MSG="Module noyau ndiswrapper"
    1.20 +		LOADED_STATUS_MSG="chargé"
    1.21 +		UNLOADED_STATUS_MSG="déchargé"
    1.22 +		LOAD_BUTTON="Charger"
    1.23 +		UNLOAD_BUTTON="Décharger"
    1.24 +		EXIT_BUTTON="Quitter" ;;
    1.25 +	*)
    1.26 +		REMOVE_DRIVER_MSG="Please double clic on a driver to remove it."
    1.27 +		FILE_ENTRY_MSG="File (.inf):"
    1.28 +		BUTTON_MSG="Install"
    1.29 +		MODULE_STATUS_MSG="Ndiswrapper Kernel module"
    1.30 +		LOADED_STATUS_MSG="loaded"
    1.31 +		UNLOADED_STATUS_MSG="unloaded"
    1.32 +		LOAD_BUTTON="Load"
    1.33 +		UNLOAD_BUTTON="Unload"
    1.34 +		EXIT_BUTTON="Exit" ;;
    1.35 +esac
    1.36 +
    1.37 +# Tazndisbox is only for root.
    1.38 +if test $(id -u) != 0 ; then
    1.39 +	exec subox tazndisbox
    1.40 +	exit 0
    1.41 +fi
    1.42 +
    1.43 +# Functions
    1.44 +
    1.45 +list_drivers()
    1.46 +{
    1.47 +	tazndis -l | sed 's/:/|/'
    1.48 +}
    1.49 +
    1.50 +install_driver()
    1.51 +{
    1.52 +	xterm -bg gray93 -fg black -geometry 60x12 -title "Tazndis install" \
    1.53 +		-e "echo N | tazndis -i $NEW_DRIVER"	
    1.54 +}
    1.55 +
    1.56 +remove_driver()
    1.57 +{
    1.58 +	tazndis -r $DRIVER
    1.59 +}
    1.60 +
    1.61 +module_status()
    1.62 +{
    1.63 +	if lsmod | grep -q ndiswrapper; then
    1.64 +		STATUS="$LOADED_STATUS_MSG"
    1.65 +	else
    1.66 +		STATUS="$UNLOADED_STATUS_MSG"
    1.67 +	fi
    1.68 +	echo -n "$MODULE_STATUS_MSG ($STATUS)"
    1.69 +}
    1.70 +
    1.71 +load_module()
    1.72 +{
    1.73 +	if ! lsmod | grep -q ^ndiswrapper; then
    1.74 +		modprobe ndiswrapper
    1.75 +	fi
    1.76 +}
    1.77 +
    1.78 +unload_module()
    1.79 +{
    1.80 +	if lsmod | grep -q ^ndiswrapper; then
    1.81 +		rmmod ndiswrapper
    1.82 +	fi
    1.83 +}
    1.84 +
    1.85 +# GUI
    1.86 +
    1.87 +export MAIN_DIALOG="
    1.88 +<window title=\"Tazndisbox\" icon-name=\"system-installer\">
    1.89 +<vbox>
    1.90 +	
    1.91 +	<tree>
    1.92 +		<width>510</width><height>140</height>
    1.93 +		<variable>DRIVER</variable>
    1.94 +		<label>Driver|Info</label>
    1.95 +		<input>$0 list_drivers</input>
    1.96 +		<action>$0 remove_driver</action>
    1.97 +		<action>refresh:DRIVER</action>
    1.98 +	</tree>
    1.99 +	
   1.100 +	<hbox>
   1.101 +		<text width-chars=\"56\">
   1.102 +			<label>\"$REMOVE_DRIVER_MSG\"</label>
   1.103 +		</text>
   1.104 +	</hbox>
   1.105 +
   1.106 +	<hbox>
   1.107 +		<text>
   1.108 +			<label>$FILE_ENTRY_MSG</label>
   1.109 +		</text>
   1.110 +		<entry accept=\"filename\">
   1.111 +			<label>Select a driver</label>
   1.112 +			<variable>NEW_DRIVER</variable>
   1.113 +		</entry>
   1.114 +		<button>
   1.115 +			<input file stock=\"gtk-open\"></input>
   1.116 +			<action type=\"fileselect\">NEW_DRIVER</action>
   1.117 +		</button>
   1.118 +		<button>
   1.119 +			<label>$BUTTON_MSG</label>
   1.120 +			<input file icon=\"forward\"></input>
   1.121 +			<action>$0 install_driver</action>
   1.122 +			<action>refresh:DRIVER</action>
   1.123 +			<action>refresh:MODULE</action>
   1.124 +			<action>clear:NEW_DRIVER</action>
   1.125 +		</button>
   1.126 +	</hbox>
   1.127 +	
   1.128 +	<hbox>
   1.129 +		<text>
   1.130 +			<variable>MODULE</variable>
   1.131 +			<input>$0 module_status</input>
   1.132 +		</text>
   1.133 +		<button>
   1.134 +			<label>$LOAD_BUTTON</label>
   1.135 +			<input file icon=\"forward\"></input>
   1.136 +			<action>$0 load_module</action>
   1.137 +			<action>refresh:MODULE</action>
   1.138 +		</button>
   1.139 +		<button>
   1.140 +			<label>$UNLOAD_BUTTON</label>
   1.141 +			<input file icon=\"undo\"></input>
   1.142 +			<action>$0 unload_module</action>
   1.143 +			<action>refresh:MODULE</action>
   1.144 +		</button>
   1.145 +		<button>
   1.146 +			<label>$EXIT_BUTTON</label>
   1.147 +			<input file icon=\"exit\"></input>
   1.148 +			<action type=\"exit\">Exit</action>
   1.149 +		</button>
   1.150 +	</hbox>
   1.151 +	
   1.152 +</vbox>
   1.153 +</window>"
   1.154 +
   1.155 +if [ -n "$1" ]; then
   1.156 +	$1
   1.157 +else
   1.158 +	gtkdialog --center --program=MAIN_DIALOG #>/dev/null
   1.159 +fi
   1.160 +
   1.161 +exit 0