tazlito diff tazlito-wiz @ rev 399

Improve GUI; misc changes
author Aleksej Bobylev <al.bobylev@gmail.com>
date Fri Nov 20 17:05:51 2015 +0200 (2015-11-20)
parents 6e2c8b742f47
children e531b58ef2dc
line diff
     1.1 --- a/tazlito-wiz	Tue Nov 10 22:46:40 2015 +0100
     1.2 +++ b/tazlito-wiz	Fri Nov 20 17:05:51 2015 +0200
     1.3 @@ -2,108 +2,125 @@
     1.4  #
     1.5  # Live system creation wizard in GTK using Yad.
     1.6  #
     1.7 -# Copyright (C) 2012-2014 SliTaz GNU/Linux - GNU gpl v2
     1.8 +# Copyright (C) 2012-2015 SliTaz GNU/Linux - GNU gpl v2
     1.9  # Authors : Christophe Lincoln <pankso@slitaz.org>
    1.10  #
    1.11  
    1.12 -width="560"
    1.13 -icon="/usr/share/pixmaps/slitaz-icon.png"
    1.14 -opts="--height=300 --width=$width --image=$icon --center
    1.15 ---image-on-top --window-icon=$icon --title=LiveWizard"
    1.16 +default_icon="--image=slitaz-icon"
    1.17 +opts="--height=320 --width=600 --center --image-on-top --window-icon=slitaz-icon --title=LiveWizard"
    1.18  rel=$(cat /etc/slitaz-release)
    1.19  #[ "$rel" != "cooking" ] && rel=stable
    1.20 -live=/home/slitaz/$rel/live
    1.21 -db="/var/lib/tazpkg"
    1.22 +live="/home/slitaz/$rel/live"
    1.23 +db='/var/lib/tazpkg'
    1.24  list="$live/distro-packages.list"
    1.25  distro="/home/slitaz/$rel/distro"
    1.26  addfiles="$distro/addfiles"
    1.27  
    1.28 +
    1.29  # TazLito wizard is only for root.
    1.30 -if test $(id -u) != 0 ; then
    1.31 +
    1.32 +if [ $(id -u) -ne 0 ]; then
    1.33  	exec tazbox su $0
    1.34  	exit 0
    1.35  fi
    1.36  
    1.37 +
    1.38  # I18n
    1.39 -. /usr/bin/gettext.sh
    1.40 -TEXTDOMAIN='tazlito-wiz'
    1.41 -export TEXTDOMAIN
    1.42 +
    1.43 +. /lib/libtaz.sh
    1.44 +export TEXTDOMAIN='tazlito'
    1.45 +
    1.46  
    1.47  # Sanity check.
    1.48 +
    1.49  mkdir -p $live && cd $live
    1.50  #rm -rf *
    1.51  
    1.52 +
    1.53  #
    1.54  # Functions
    1.55  #
    1.56  
    1.57 -progress() {
    1.58 -	yad --progress --height="140" --width="$width" --center \
    1.59 -		--image=$icon --image-on-top --window-icon=$icon \
    1.60 -		--text="<b>$text</b>" --title="SliTaz Live progress" --auto-close
    1.61 +edit_list() {
    1.62 +	cat $list | yad --list $opts --image='system-software-update' \
    1.63 +		--text="<b>$(_ 'Edit the distro packages list')</b>" \
    1.64 +		--no-headers --print-all --separator='' \
    1.65 +		--editable --column=0:TEXT > "$live/list"
    1.66 +		mv -f "$live/list" "$list"
    1.67  }
    1.68  
    1.69 -edit_list() {
    1.70 -	text=$(gettext "Edit the distro packages list")
    1.71 -	cat $list | yad --list $opts --text="$text" \
    1.72 -		--no-headers --print-all --separator="" \
    1.73 -		--editable --column=0:TEXT > $live/list
    1.74 -		mv -f $live/list $list
    1.75 +
    1.76 +# Start page GUI
    1.77 +
    1.78 +start_main() {
    1.79 +	yad --form $opts $default_icon \
    1.80 +		--text="<b>$(_ 'SliTaz Live system creator wizard')</b>" \
    1.81 +		--field="$(_ "Distro name:")" \
    1.82 +		--field="$(_ "Based on:")":CB \
    1.83 +		--button='gtk-help:4' \
    1.84 +		--button="$(_ 'Write ISO')!iso-image-burn:3" \
    1.85 +		--button="$(_ 'TazPanel Live'):2" \
    1.86 +		--button='gtk-cancel:1' \
    1.87 +		--button='gtk-go-forward:0' \
    1.88 +		'custom' 'core!core64!gtkonly!justx!base'
    1.89  }
    1.90  
    1.91 -# Start page GUI
    1.92 -start_main() {
    1.93 -	text=$(gettext "SliTaz Live system creator wizard")
    1.94 -	yad --form $opts --text="<b>$text</b>" \
    1.95 -		--field="$(gettext "Distro name:")" \
    1.96 -		--field="$(gettext "Based on:")":CB \
    1.97 -		--button="Write ISO:3" \
    1.98 -		--button="TazPanel Live:2" \
    1.99 -		--button="gtk-cancel:1" \
   1.100 -		--button="gtk-ok:0" \
   1.101 -		" " "core!core64!gtkonly!justx!base"
   1.102 -}
   1.103  
   1.104  # Start page handler
   1.105 +
   1.106  start() {
   1.107  	# Store box results
   1.108  	main=$(start_main)
   1.109 +
   1.110  	# Deal with --button values
   1.111  	case $? in
   1.112 -		1) exit 0 ;;
   1.113 -		2) tazweb http://tazpanel:82/live.cgi && exit 0 ;;
   1.114 -		3) terminal -T "write-iso" -e "tazlito writeiso lzma" && exit 0 ;;
   1.115 -		*) continue ;;
   1.116 +		1) exit 0;;
   1.117 +		2) tazpanel live; exit 0;;
   1.118 +		3) terminal -T 'write-iso' -e 'tazlito writeiso lzma'; exit 0;;
   1.119 +		4) tazweb 'file:///usr/share/doc/tazlito/tazlito.html'; exit 0;;
   1.120 +		*) continue;;
   1.121  	esac
   1.122 +
   1.123  	# Deal with $main values
   1.124 -	text=$(gettext "Getting flavor file and packages list...")
   1.125 -	(echo "30" && \
   1.126 -	[ -z $(which xterm) ] && xterm='terminal' || xterm='xterm'
   1.127 -	$xterm -geometry 70x10-0-0 -e tazpkg recharge
   1.128 -	name=$(echo $main | cut -d "|" -f 1)
   1.129 -	skel=$(echo $main | cut -d "|" -f 2)
   1.130 -	echo "$skel" > $live/skel
   1.131 -	echo "60"
   1.132 -	[ "$name" ] || name="custom"
   1.133 -	$xterm -geometry 60x12-0-0 -e tazlito get-flavor $skel
   1.134 -	echo "90" && sleep 1
   1.135 -	sed -i s"/^ISO_NAME=.*/ISO_NAME=\"$name\"/" tazlito.conf
   1.136 -	sed -i s"/^VOLUM_NAME=.*/VOLUM_NAME=\"SliTaz $name\"/" \
   1.137 -		tazlito.conf) | progress
   1.138 +
   1.139 +	(
   1.140 +		export output='raw'
   1.141 +		# Numbers are moved the progressbar
   1.142 +		echo '30'
   1.143 +		# Lines started with '#' are displayed in the log
   1.144 +		tazpkg recharge | sed 's|^.*|#&|'
   1.145 +		name="$(echo $main | cut -d'|' -f1)"; name="${name:-custom}"
   1.146 +		skel="$(echo $main | cut -d'|' -f2)"
   1.147 +		echo "$skel" > $live/skel
   1.148 +		echo '60'
   1.149 +		tazlito get-flavor $skel | sed 's|^.*|#&|'
   1.150 +		echo '90'
   1.151 +		sed -i "s|^ISO_NAME=.*|ISO_NAME=\"$name\"|" tazlito.conf
   1.152 +		sed -i "s|^VOLUM_NAME=.*|VOLUM_NAME=\"SliTaz $name\"|" tazlito.conf
   1.153 +	) | \
   1.154 +	yad --progress $opts --image='system-software-update' \
   1.155 +		--text="<b>$(_ 'Getting flavor file and packages list...')</b>" \
   1.156 +		--enable-log="$(_ 'Log')" --log-expanded --button='gtk-go-forward:0'
   1.157 +
   1.158  }
   1.159  
   1.160 +
   1.161  # Packages page GUI
   1.162 +
   1.163  pkgs_main() {
   1.164  	pkgs=$(cat $list | wc -l)
   1.165  	skel=$(cat $live/skel)
   1.166 -	text=$(eval_gettext "Packages - The \$skel has \$pkgs packages")
   1.167 -	yad --form $opts --text="<b>$text</b>" --separator=" " \
   1.168 -		--field="$(gettext "Additional packages separated by space or by line:")\\n\(will be auto added to \'Edit packages list\'\)":TXT \
   1.169 -		--button="$(gettext "Edit packages list")!document-properties:2" \
   1.170 -		--button="gtk-cancel:1" --button="gtk-ok:0" --image=tazpkg
   1.171 +	text=$(_ 'Packages - The "$skel" has $pkgs packages')
   1.172 +	yad --form $opts --image='application-x-tazpkg' \
   1.173 +		--text="<b>$text</b>" --separator=' ' \
   1.174 +		--field="$(_ 'Additional packages separated by space or by line:')\\n$(_ '(will be auto added to "Edit packages list")')":TXT \
   1.175 +		--button="$(_ 'Edit packages list')!document-properties:2" \
   1.176 +		--button='gtk-cancel:1' --button='gtk-go-forward:0'
   1.177  }
   1.178  
   1.179 +
   1.180  # Packages page handler
   1.181 +
   1.182  pkgs() {
   1.183  	# Store box results
   1.184  	main=$(pkgs_main)
   1.185 @@ -115,10 +132,9 @@
   1.186  	esac
   1.187  }
   1.188  
   1.189 -add_to_list()
   1.190 -{
   1.191 -	for pkg in $(echo $main | sed s'/\\n/ /'g)
   1.192 -	do
   1.193 +
   1.194 +add_to_list() {
   1.195 +	for pkg in $(echo $main | sed s'/\\n/ /'g); do
   1.196  		vers=$(grep -E "^$pkg \|" $db/packages.desc | awk '{print $3}')
   1.197  		[ -z $vers ] || \
   1.198  		(grep -v -q "^$pkg-$vers" $list && \
   1.199 @@ -128,14 +144,19 @@
   1.200  	done
   1.201  }
   1.202  
   1.203 +
   1.204  # Wallpaper page GUI
   1.205 +
   1.206  wallpaper_main() {
   1.207 -	text=$(gettext "SliTaz desktop wallpaper")
   1.208 -	yad --form $opts --text="<b>$text</b>" --separator="" \
   1.209 -		--field="$(gettext "Wallpaper JPG image:")":FL
   1.210 +	yad --form $opts --image='preferences-desktop-wallpaper' \
   1.211 +		--text="<b>$(_ 'SliTaz desktop wallpaper')</b>" --separator='' \
   1.212 +		--field="$(_ 'Wallpaper JPG image:')":FL \
   1.213 +		--button='gtk-cancel:1' --button='gtk-go-forward:0'
   1.214  }
   1.215  
   1.216 +
   1.217  # Wallpaper page handler
   1.218 +
   1.219  wallpaper() {
   1.220  	# Store box results
   1.221  	main=$(wallpaper_main)
   1.222 @@ -150,49 +171,60 @@
   1.223  	fi
   1.224  }
   1.225  
   1.226 +
   1.227  # Last page GUI
   1.228 +
   1.229  gen_distro_main() {
   1.230 -	info=$(gettext "
   1.231 +	(
   1.232 +		_ "
   1.233  Now it's time to generate the distro. Last chance to start over or stop. \
   1.234  Creating a Live system uses quite a lot of resources and takes some time.
   1.235 -Note you can still add some files to the SliTaz root filesystem or on the \
   1.236 -cdrom.";echo
   1.237 -	echo $addfiles )
   1.238 -	text=$(gettext "<b>Generate the distribution</b>")
   1.239 -	echo "$info" | yad --text-info $opts --text="$text" \
   1.240 -		--wrap --margins=20 
   1.241 +Note you can still add some files to the SliTaz root filesystem or on the CD-ROM."
   1.242 +		echo
   1.243 +		echo $addfiles
   1.244 +	) | yad --text-info $opts $default_icon \
   1.245 +		--text="<b>$(_ 'Generate the distribution')</b>" --wrap --margins=20 \
   1.246 +		--button='gtk-cancel:1' --button='gtk-go-forward:0'
   1.247  }
   1.248  
   1.249 +
   1.250  # Last page handler
   1.251 +
   1.252  gen_distro() {
   1.253  	# Store box results
   1.254  	main=$(gen_distro_main)
   1.255 +
   1.256  	# Deal with --button values
   1.257  	case $? in
   1.258  		1) exit 0 ;;
   1.259  		*)
   1.260 -			export output=gtk
   1.261 +			export output='raw'
   1.262  			echo -e "\n" | tazlito gen-distro 2>&1 | yad \
   1.263 -			--text-info $opts --tail \
   1.264 -			--text="<b>$(gettext "Building the Live system...")</b>" ;;
   1.265 +			--text-info $opts $default_icon --tail \
   1.266 +			--text="<b>$(_ 'Building the Live system...')</b>" \
   1.267 +			--button='gtk-go-forward:0'
   1.268 +			;;
   1.269  	esac
   1.270  }
   1.271  
   1.272 +
   1.273  # Summary
   1.274 +
   1.275  summary() {
   1.276  	. tazlito.conf
   1.277  	iso_size=$(du -sh $distro/$ISO_NAME.iso | awk '{print $1}')
   1.278  	distro_size=$(du -sh $distro/rootfs | awk '{print $1}')
   1.279 -	text="$(gettext "Live system summary")"
   1.280 +	text="$(_ 'Live system summary')"
   1.281  	echo -e "\
   1.282 -$(gettext "Generated ISO ") \n$distro/$ISO_NAME.iso
   1.283 -$(gettext "Image size") \n$iso_size
   1.284 -$(gettext "Uncompressed size") \n$distro_size" | \
   1.285 -	yad --list $opts --text="<b>$text</b>" \
   1.286 -		--column="Information":0 --column="Value":1 \
   1.287 +$(_ 'Generated ISO') \n$distro/$ISO_NAME.iso
   1.288 +$(_ 'Image size') \n$iso_size
   1.289 +$(_ 'Uncompressed size') \n$distro_size" | \
   1.290 +	yad --list $opts $default_icon --text="<b>$text</b>" \
   1.291 +		--column="$(_ 'Information')":0 --column="$(_ 'Value')":1 \
   1.292  		--button="gtk-close":0
   1.293  }
   1.294  
   1.295 +
   1.296  #
   1.297  # Script commands
   1.298  #
   1.299 @@ -200,13 +232,12 @@
   1.300  case "$1" in
   1.301  	usage)
   1.302  		echo "Usage: $(basename $0) [command]" ;;
   1.303 -	*) 
   1.304 +	*)
   1.305  		start
   1.306  		pkgs
   1.307 -		wallpaper 
   1.308 +		wallpaper
   1.309  		gen_distro
   1.310  		summary ;;
   1.311  esac
   1.312  
   1.313  exit 0
   1.314 -