slitaz-tools rev 562

tazbox: Add out and out-dl to output command into a GTK window
author Christophe Lincoln <pankso@slitaz.org>
date Tue Apr 19 13:34:35 2011 +0200 (2011-04-19)
parents 32be2ab4ac50
children e9c74b6c3c6f
files tazbox/tazbox
line diff
     1.1 --- a/tazbox/tazbox	Mon Apr 18 19:13:07 2011 +0100
     1.2 +++ b/tazbox/tazbox	Tue Apr 19 13:34:35 2011 +0200
     1.3 @@ -9,11 +9,17 @@
     1.4  #    - Christophe Lincoln <pankso@slitaz.org>
     1.5  #
     1.6  
     1.7 +# Download dir (may be in a config file)
     1.8 +DOWNLOADS=$HOME/Downloads
     1.9 +
    1.10  # Internationalization
    1.11  . /usr/bin/gettext.sh
    1.12  TEXTDOMAIN='tazbox'
    1.13  export TEXTDOMAIN
    1.14  
    1.15 +# Icons for most windows
    1.16 +icon=/usr/share/pixmaps/slitaz-menu.png
    1.17 +
    1.18  #
    1.19  # Functions
    1.20  #
    1.21 @@ -25,16 +31,30 @@
    1.22  
    1.23  $(gettext "Commands:")
    1.24    usage      $(gettext "Display this short help usage")
    1.25 -  logout     $(gettext "Desktop logout box")
    1.26 +  logout     $(gettext "Desktop logout box with actions")
    1.27 +  out        $(gettext "Pipe a command output into a GTK window")
    1.28 +  out-dl     $(gettext "Pipe Wget output into a GTK window")
    1.29  
    1.30  EOT
    1.31  }
    1.32  
    1.33 +cancel_dl() {
    1.34 +	if [ "$?" == 1 ]; then
    1.35 +		echo "CANCEL"
    1.36 +		rm -f $DOWNLOADS/$(basename $url)
    1.37 +	fi
    1.38 +}
    1.39 +
    1.40 +# Outup a command in a GTK window
    1.41 +output_command() {	
    1.42 +	yad --text-info --title="TazBox Output" --window-icon=$icon \
    1.43 +		--geometry="560x210+0-24" --fore="#ffffff" --back="#000000"
    1.44 +}
    1.45 +
    1.46  # Logout GUI function
    1.47  logout_main() {
    1.48  	text=$(gettext "SliTaz Logout. Please choose an action:")
    1.49 -	yad --entry --title="SliTaz Logout" \
    1.50 -		--window-icon=/usr/share/pixmaps/slitaz-menu.png \
    1.51 +	yad --entry --title="SliTaz Logout" --window-icon=$icon \
    1.52  		--width=440 --height=150 --text="$text" \
    1.53  		--image="slitaz-menu" --image-on-top \
    1.54  		--center --on-top  --entry-text \
    1.55 @@ -48,10 +68,11 @@
    1.56  #
    1.57  case "$1" in
    1.58  	su)
    1.59 +		# Execute a command as root
    1.60  		echo "TODO" ;;
    1.61  	logout)
    1.62 -		# Store box results
    1.63 -		main=`logout_main`		
    1.64 +		# Lougout window with actions
    1.65 +		main=`logout_main`
    1.66  		# Deal with --button values
    1.67  		case $? in
    1.68  			1) exit 0 ;;
    1.69 @@ -63,6 +84,14 @@
    1.70  			*reboot) reboot ;;
    1.71  			*halt) poweroff ;;
    1.72  		esac ;;
    1.73 +	out)
    1.74 +		# Pipe a command into a GTK window
    1.75 +		output_command ;;
    1.76 +	dl-out)
    1.77 +		# A tiny GTK window for Busybox wget output
    1.78 +		url=$2
    1.79 +		busybox wget -c -P $DOWNLOADS $url 2>&1 | output_command
    1.80 +		cancel_dl ;;
    1.81  	*)
    1.82  		usage ;;
    1.83  esac