slitaz-tools rev 190
Add tazdialog
author | Pascal Bellard <pascal.bellard@slitaz.org> |
---|---|
date | Wed May 14 13:52:28 2008 +0000 (2008-05-14) |
parents | 4839a43b676e |
children | e0c14d4c1b52 |
files | installer/slitaz-installer tinyutils/soundconf tinyutils/tazdialog tinyutils/tazkeymap tinyutils/tazlocale tinyutils/tazx |
line diff
1.1 --- a/installer/slitaz-installer Mon May 12 14:47:37 2008 +0200 1.2 +++ b/installer/slitaz-installer Wed May 14 13:52:28 2008 +0000 1.3 @@ -10,7 +10,7 @@ 1.4 # Author : Christophe Lincoln <pankso@slitaz.org> 1.5 # 1.6 VERSION=1.0 1.7 -: ${DIALOG=dialog} 1.8 +: ${DIALOG=tazdialog} 1.9 1.10 # Installer actions can be specified on cmdline (install or upgrade). 1.11 if [ -n "$1" ]; then
2.1 --- a/tinyutils/soundconf Mon May 12 14:47:37 2008 +0200 2.2 +++ b/tinyutils/soundconf Wed May 14 13:52:28 2008 +0000 2.3 @@ -274,7 +274,9 @@ 2.4 cfgfile="/etc/modprobe.conf" 2.5 2.6 # Check for dialog 2.7 -if which dialog > /dev/null; then 2.8 +if which tazdialog > /dev/null; then 2.9 + DIALOG=tazdialog 2.10 +elif which dialog > /dev/null; then 2.11 DIALOG=dialog 2.12 else 2.13 xecho "Error, dialog or whiptail not found."
3.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 3.2 +++ b/tinyutils/tazdialog Wed May 14 13:52:28 2008 +0000 3.3 @@ -0,0 +1,144 @@ 3.4 +#!/bin/sh 3.5 +# tazdialog - SliTaz GNU/Linux dialog wrapper to gtkdialog. 3.6 +# 3.7 +# (C) 2008 SliTaz - GNU General Public License v3. 3.8 +# 3.9 +# Author : Pascal Bellard <pascal.bellard@slitaz.org> 3.10 +# 3.11 + 3.12 +toutf8() 3.13 +{ 3.14 +echo -e $1 | sed -e 's/\\Z.//g' | tr 'àâäçéèêëîïûü' 'aaaceeeeiiuu' 3.15 +} 3.16 + 3.17 +if [ -z "$XAUTHORITY" ]; then 3.18 + [ -n "$TEXTDIALOG" ] || TEXTDIALOG="dialog" 3.19 + export DIALOG=$TEXTDIALOG 3.20 + $TEXTDIALOG "$@" 3.21 + return $? 3.22 +else 3.23 + title="" 3.24 + backtitle="" 3.25 + lines="10" 3.26 + cols="10" 3.27 + [ -n "$ICON" ] || ICON="media-flash" 3.28 + buttonok="" 3.29 + buttoncancel="" 3.30 + buttonextra="" 3.31 + yeslabel="ok" 3.32 + nolabel="cancel" 3.33 + extralabel="rename" 3.34 + gauge="" 3.35 + inputbox="" 3.36 + default="" 3.37 + 3.38 + buttonhelp="" 3.39 + checklist="" 3.40 + menu="" 3.41 + textbox="" 3.42 + args="" 3.43 + while [ -n "$1" ]; do 3.44 + case "$1" in 3.45 + --title) title="$2"; shift 2;; 3.46 + --backtitle) backtitle="$2"; shift 2;; 3.47 + --clear|--colors) shift;; 3.48 + --yes-label) yeslabel="$2"; shift 2;; 3.49 + --no-label) nolabel="$2"; shift 2;; 3.50 + --extra-label) extralabel="$2"; shift 2;; 3.51 + --extra-button) buttonextra="1"; shift;; 3.52 + --help-button) buttonhelp="1"; shift;; 3.53 + --msgbox) msgbox="$2"; lines="$3"; cols="$4" 3.54 + buttonok="1"; break;; 3.55 + --yesno) msgbox="$2"; lines="$3"; cols="$4" 3.56 + buttonok="1"; buttoncancel="1"; break;; 3.57 + --gauge) msgbox="$2"; lines="$3"; cols="$4" 3.58 + percent="$5"; gauge="1"; break;; 3.59 + --inputbox) msgbox="$2"; lines="$3"; cols="$4" 3.60 + default="$5" 3.61 + buttonok="1"; buttoncancel="1" 3.62 + inputbox="1"; break;; 3.63 + 3.64 + --checklist) msgbox="$2"; lines="$3"; cols="$4"; inlines="$5" 3.65 + buttonok="1"; checklist="1"; shift 5; args="$@"; break;; 3.66 + --menu) msgbox="$2"; lines="$3"; cols="$4"; inlines="$5" 3.67 + buttonok="1"; buttoncancel="1" 3.68 + menu="1"; shift 5; args="$@"; break;; 3.69 + --textbox) textbox="$2"; lines="$3"; cols="$4" 3.70 + buttonok="1"; break;; 3.71 + *) echo "Unknown arg $1"; return 255;; 3.72 + esac 3.73 + done 3.74 +fi 3.75 +msgbox="$(toutf8 "$msgbox")" 3.76 +textbox="$(toutf8 "$textbox")" 3.77 +BOX="<window" 3.78 +[ -n "$backtitle" ] && BOX="$BOX title=\"$backtitle\"" 3.79 +[ -n "$ICON" ] && BOX="$BOX icon-name=\"$ICON\"" 3.80 +BOX="$BOX> <vbox>" 3.81 +[ -n "$title" ] && BOX="$BOX <text use-markup=\"true\"> \ 3.82 +<label> \"<b>$title</b>\" </label> </text>" 3.83 +#[ -n "$msgbox" ] && BOX="$BOX <text wrap=\"true\" \ 3.84 +#width-chars=\"$cols\" use-markup=\"true\"><label> \"$msgbox\" </label></text>" 3.85 +[ -n "$msgbox" ] && BOX="$BOX <text wrap=\"true\" \ 3.86 +use-markup=\"true\"><label> \"$msgbox\" </label></text>" 3.87 +[ -n "$gauge" ] && BOX="$BOX <progressbar><input>while read data; do \ 3.88 +echo \$data; done</input><action type=\"exit\">0</action></progressbar>" 3.89 +[ -n "$default" ] && default="<default>$default</default>" 3.90 +[ -n "$inputbox" ] && BOX="$BOX <entry>$default<variable>OUTPUT</variable> \ 3.91 +</entry>" 3.92 +#[ -n "$textbox" ] && BOX="$BOX <text><input file width-chars=\"$cols\" \ 3.93 +#height=\"$lines\" wrap=\"true\">$textbox</input></text>" 3.94 +[ -n "$textbox" ] && BOX="$BOX <text><input file \ 3.95 +wrap=\"true\">$textbox</input></text>" 3.96 +[ -n "$menu" ] && BOX="$BOX <list>$( 3.97 + set -- $args | while [ -n "$1" ]; do 3.98 + echo "<item>$1 $2</item>" 3.99 + shift 2 3.100 + done) <variable>LIST</variable> </list>" 3.101 +[ -n "$checklist" ] && BOX="$BOX $( 3.102 + i=0; set -- $args | while [ -n "$1" ]; do 3.103 + [ "$3" = "on" ] && c=" active=\"true\"" || c="" 3.104 + echo "<checkbox$c><label>$1 $2</label><variable>CHECK$i</variable></checkbox>" 3.105 + i=$(($i+1)) 3.106 + shift 3 3.107 + done)" 3.108 +[ "$yeslabel" = "ok" ] && yeslabel="" || yeslabel="<label>$yeslabel</label>" 3.109 +[ "$nolabel" = "cancel" ] && nolabel="" || nolabel="<label>$nolabel</label>" 3.110 +[ -n "$buttonok$buttonextra$buttoncancel" ] && BOX="$BOX <hbox>" 3.111 +[ -n "$buttonok" ] && BOX="$BOX <button ok>$yeslabel \ 3.112 +<action type=\"exit\">0</action> </button>" 3.113 +[ -n "$buttonextra" ] && BOX="$BOX <button><label>$extralabel</label> \ 3.114 +<input file icon=\"forward\"> </input> <action type=\"exit\">3</action> \ 3.115 +</button>" 3.116 +[ -n "$buttoncancel" ] && BOX="$BOX <button cancel>$nolabel \ 3.117 +<action type=\"exit\">1</action> </button>" 3.118 +[ -n "$buttonhelp" ] && BOX="$BOX <button help> <action type=\"exit\">2\ 3.119 +</action> </button>" 3.120 +[ -n "$buttonok$buttonextra$buttoncancel" ] && BOX="$BOX </hbox>" 3.121 +BOX="$BOX </vbox></window>" 3.122 +export BOX 3.123 +status=$(if [ -n "$gauge" ]; then 3.124 + ( while read line; do 3.125 + case "$line" in 3.126 + [0-9]*) echo $line;; 3.127 + *);; 3.128 + esac 3.129 + done ; echo 100) | gtkdialog --center --program=BOX 3.130 +else 3.131 + gtkdialog --center --program=BOX 3.132 +fi 2> /dev/null | while read line; do 3.133 + case "$line" in 3.134 + *OUTPUT*) eval $line 3.135 + echo "$OUTPUT" 1>&2 ;; 3.136 + *CHECK*true*) line=${line%=*}; line=${line#CHECK} 3.137 + set -- $args 3.138 + [ $line -eq 0 ] || shift $(($line * 3)) 3.139 + echo -n "\"$1\" " 1>&2 ;; 3.140 + *LIST=*) eval $line; set -- $LIST 3.141 + echo "$1" 1>&2 ;; 3.142 + *EXIT*abort*) echo 255;; 3.143 + *EXIT*) eval $line 3.144 + echo $EXIT ;; 3.145 + esac 3.146 +done) 3.147 +exit $status
4.1 --- a/tinyutils/tazkeymap Mon May 12 14:47:37 2008 +0200 4.2 +++ b/tinyutils/tazkeymap Wed May 14 13:52:28 2008 +0000 4.3 @@ -5,7 +5,7 @@ 4.4 # 4.5 # (C) SliTaz GNU/Linux - 20080427 <pankso@slitaz.org> - GNU gpl. 4.6 # 4.7 -: ${DIALOG=dialog} 4.8 +: ${DIALOG=tazdialog} 4.9 4.10 # Script functions. 4.11 status()