slitaz-tools rev 630
Move tazdialog to oldstuff
author | Christophe Lincoln <pankso@slitaz.org> |
---|---|
date | Thu Jun 16 19:00:56 2011 +0200 (2011-06-16) |
parents | 0c915e47ea57 |
children | 4e09b69a4f57 |
files | Makefile oldstuff/tazdialog tinyutils/tazdialog |
line diff
1.1 --- a/Makefile Thu Jun 16 18:59:15 2011 +0200 1.2 +++ b/Makefile Thu Jun 16 19:00:56 2011 +0200 1.3 @@ -87,7 +87,7 @@ 1.4 touch $(DESTDIR)/$$file; \ 1.5 done; 1.6 # /usr/bin tools. 1.7 - for app in tazx startx history tazdialog editor browser terminal file-manager; \ 1.8 + for app in tazx startx history editor browser terminal file-manager; \ 1.9 do \ 1.10 install -m 0755 tinyutils/$$app $(DESTDIR)$(PREFIX)/bin; \ 1.11 done;
2.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 2.2 +++ b/oldstuff/tazdialog Thu Jun 16 19:00:56 2011 +0200 2.3 @@ -0,0 +1,216 @@ 2.4 +#!/bin/sh 2.5 +# tazdialog - SliTaz GNU/Linux dialog wrapper to gtkdialog. 2.6 +# 2.7 +# (C) 2008 SliTaz - GNU General Public License v3. 2.8 +# 2.9 +# Author : Pascal Bellard <pascal.bellard@slitaz.org> 2.10 +# 2.11 + 2.12 +toutf8() 2.13 +{ 2.14 +echo -e $1 | sed -e 's/\\Z.//g' | tr 'àâäçéèêëîïûü' 'aaaceeeeiiuu' 2.15 +} 2.16 + 2.17 +fake_gauge() 2.18 +{ 2.19 +[ -n "$percent" ] && echo $percent 2.20 +while read line; do 2.21 + case "$line" in 2.22 + [0-9]*) echo $line;; 2.23 + *);; 2.24 + esac 2.25 +done 2.26 +echo 100 2.27 +} 2.28 + 2.29 +fake_dialog() 2.30 +{ 2.31 +if [ -n "$gauge" ]; then 2.32 + fake_gauge | gtkdialog --center --program=BOX 2.33 +else 2.34 + gtkdialog --center --program=BOX 2.35 +fi 2> /dev/null | while read line; do 2.36 + case "$line" in 2.37 + *OUTPUT*) eval $line 2.38 + echo "$OUTPUT" 1>&2 ;; 2.39 + *CHECK*true*) line=${line%=*}; line=${line#CHECK} 2.40 + [ $line -eq 0 ] || shift $((3 * $line)) 2.41 + echo -n "\"$1\" " 1>&2;; 2.42 + *LIST=*) eval $line; set -- $LIST 2.43 + echo "$1" 1>&2 ;; 2.44 + *EXIT*abort*) echo 255;; 2.45 + *EXIT*) eval $line 2.46 + echo $EXIT ;; 2.47 + esac 2.48 +done 2.49 +} 2.50 + 2.51 +if [ -z "$XAUTHORITY" ]; then 2.52 + [ -n "$TEXTDIALOG" ] || TEXTDIALOG="dialog" 2.53 + export DIALOG=$TEXTDIALOG 2.54 + exec $TEXTDIALOG "$@" 2.55 +else 2.56 + title="" 2.57 + backtitle="" 2.58 + lines="10" 2.59 + cols="10" 2.60 + [ -n "$ICON" ] || ICON="applications-other" 2.61 + buttonok="" 2.62 + buttoncancel="" 2.63 + buttonextra="" 2.64 + yeslabel="ok" 2.65 + nolabel="cancel" 2.66 + extralabel="rename" 2.67 + gauge="" 2.68 + inputbox="" 2.69 + default="" 2.70 + buttonhelp="" 2.71 + checklist="" 2.72 + menu="" 2.73 + textbox="" 2.74 + radiolist="" 2.75 + fselect="" 2.76 + while [ -n "$1" ]; do 2.77 + case "$1" in 2.78 + --title) title="$2"; shift 2;; 2.79 + --backtitle) backtitle="$2"; shift 2;; 2.80 + --clear|--colors) shift;; 2.81 + --yes-label) yeslabel="$2"; shift 2;; 2.82 + --no-label) nolabel="$2"; shift 2;; 2.83 + --extra-label) extralabel="$2"; shift 2;; 2.84 + --extra-button) buttonextra="1"; shift;; 2.85 + --help-button) buttonhelp="1"; shift;; 2.86 + --msgbox) msgbox="$2"; lines="$3"; cols="$4" 2.87 + buttonok="1"; break;; 2.88 + --yesno) msgbox="$2"; lines="$3"; cols="$4" 2.89 + buttonok="1"; buttoncancel="1"; break;; 2.90 + --gauge) msgbox="$2"; lines="$3"; cols="$4" 2.91 + percent="$5"; gauge="1"; break;; 2.92 + --inputbox) msgbox="$2"; lines="$3"; cols="$4"; default="$5" 2.93 + buttonok="1"; buttoncancel="1"; inputbox="1"; break;; 2.94 + --checklist) msgbox="$2"; lines="$3"; cols="$4"; inlines="$5" 2.95 + buttonok="1"; checklist="1"; shift 5; break;; 2.96 + --menu) msgbox="$2"; lines="$3"; cols="$4"; inlines="$5" 2.97 + buttonok="1"; buttoncancel="1" 2.98 + menu="1"; shift 5; break;; 2.99 + --textbox) textbox="$2"; lines="$3"; cols="$4" 2.100 + buttonok="1"; break;; 2.101 + --radiolist) textbox="$2"; lines="$3"; cols="$4"; inlines="$5" 2.102 + buttonok="1"; buttoncancel="1" 2.103 + radiolist="1"; shift 5; break;; 2.104 + --fselect) fselect="$2"; lines="$3"; cols="$4" 2.105 + buttonok="1"; buttoncancel="1"; break;; 2.106 + *) echo "Unknown arg $1"; exit 255;; 2.107 + esac 2.108 + done 2.109 +fi 2.110 +msgbox="$(toutf8 "$msgbox")" 2.111 +textbox="$(toutf8 "$textbox")" 2.112 +title="$(toutf8 "$title")" 2.113 +backtitle="$(toutf8 "$backtitle")" 2.114 +yeslabel="$(toutf8 "$yeslabel")" 2.115 +nolabel="$(toutf8 "$nolabel")" 2.116 +extralabel="$(toutf8 "$extralabel")" 2.117 +default="$(toutf8 "$default")" 2.118 +BOX="<window" 2.119 +[ -n "$backtitle" ] && BOX="$BOX title=\"$backtitle\"" 2.120 +[ -n "$ICON" ] && BOX="$BOX icon-name=\"$ICON\"" 2.121 +BOX="$BOX> 2.122 + <vbox> 2.123 +" 2.124 +[ -n "$title" ] && BOX="$BOX <text use-markup=\"true\" width-chars=\"44\"> 2.125 + <label>\"<b>$title</b>\" </label> 2.126 + </text> 2.127 +" 2.128 +[ -n "$msgbox" ] && BOX="$BOX <text wrap=\"true\" use-markup=\"true\"> 2.129 + <label> \"$msgbox\" </label> 2.130 + </text> 2.131 +" 2.132 +[ -n "$gauge" ] && BOX="$BOX <progressbar> 2.133 + <input>while read data; do echo \$data; done</input> 2.134 + <action type=\"exit\">0</action> 2.135 + </progressbar> 2.136 +" 2.137 +[ -n "$default" ] && default="<default>$default</default> 2.138 + " 2.139 +[ -n "$inputbox" ] && BOX="$BOX <entry> 2.140 + $default<variable>OUTPUT</variable> 2.141 + </entry> 2.142 +" 2.143 +#[ -n "$textbox" ] && BOX="$BOX <text><input file width-chars=\"$cols\" \ 2.144 +#height=\"$lines\" wrap=\"true\">$textbox</input></text>" 2.145 +[ -n "$textbox" ] && BOX="$BOX <text> 2.146 + <input file wrap=\"true\">$textbox</input> 2.147 + </text> 2.148 +" 2.149 +[ -n "$menu" ] && BOX="$BOX <list> 2.150 +$(while [ -n "$1" ]; do 2.151 + echo " <item>$1 $2</item> 2.152 +" 2.153 + shift 2 2.154 + done) <variable>LIST</variable> 2.155 + </list> 2.156 +" 2.157 +[ -n "$radiolist" ] && BOX="$BOX$( 2.158 + i=0; while [ -n "$1" ]; do 2.159 + [ "$3" = "on" ] && c=" active=\"true\"" || c="" 2.160 + echo " <radiobutton$c> 2.161 + <label>$1 $2</label> 2.162 + <variable>CHECK$i</variable> 2.163 + </radiobutton> 2.164 +" 2.165 + i=$(($i+1)) 2.166 + shift 3 2.167 + done)" 2.168 +[ -n "$checklist" ] && BOX="$BOX $( 2.169 + i=0; while [ -n "$1" ]; do 2.170 + [ "$3" = "on" ] && c=" active=\"true\"" || c="" 2.171 + echo " <checkbox$c> 2.172 + <label>$1 $2</label> 2.173 + <variable>CHECK$i</variable> 2.174 + </checkbox> 2.175 +" 2.176 + i=$(($i+1)) 2.177 + shift 3 2.178 + done)" 2.179 +[ -n "$fselect" ] && BOX="$BOX <hbox> 2.180 + <entry> 2.181 + <variable>OUTPUT</variable> 2.182 + </entry> 2.183 + <button> 2.184 + <input file stock=\"gtk-open\"></input> 2.185 + <variable>FILE_BROWSE</variable> 2.186 + <action type=\"fileselect\">OUTPUT</action> 2.187 + </button> 2.188 + </hbox> 2.189 +" 2.190 +[ "$yeslabel" = "ok" ] && yeslabel="" || yeslabel=" 2.191 + <label>$yeslabel</label>" 2.192 +[ "$nolabel" = "cancel" ] && nolabel="" || nolabel=" 2.193 + <label>$nolabel</label>" 2.194 +[ -n "$buttonok$buttonextra$buttoncancel" ] && BOX="$BOX <hbox>" 2.195 +[ -n "$buttonok" ] && BOX="$BOX <button ok>$yeslabel 2.196 + <action type=\"exit\">0</action> 2.197 + </button> 2.198 +" 2.199 +[ -n "$buttonextra" ] && BOX="$BOX <button> 2.200 + <label>$extralabel</label> 2.201 + <input file icon=\"forward\"> </input> 2.202 + <action type=\"exit\">3</action> 2.203 + </button> 2.204 +" 2.205 +[ -n "$buttoncancel" ] && BOX="$BOX <button cancel>$nolabel 2.206 + <action type=\"exit\">1</action> 2.207 + </button> 2.208 +" 2.209 +[ -n "$buttonhelp" ] && BOX="$BOX <button help> 2.210 + <action type=\"exit\">2</action> 2.211 + </button> 2.212 +" 2.213 +[ -n "$buttonok$buttonextra$buttoncancel" ] && BOX="$BOX </hbox> 2.214 +" 2.215 +BOX="$BOX </vbox> 2.216 +</window> 2.217 +" 2.218 +export BOX 2.219 +exit $(fake_dialog)
3.1 --- a/tinyutils/tazdialog Thu Jun 16 18:59:15 2011 +0200 3.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 3.3 @@ -1,216 +0,0 @@ 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 -fake_gauge() 3.18 -{ 3.19 -[ -n "$percent" ] && echo $percent 3.20 -while read line; do 3.21 - case "$line" in 3.22 - [0-9]*) echo $line;; 3.23 - *);; 3.24 - esac 3.25 -done 3.26 -echo 100 3.27 -} 3.28 - 3.29 -fake_dialog() 3.30 -{ 3.31 -if [ -n "$gauge" ]; then 3.32 - fake_gauge | gtkdialog --center --program=BOX 3.33 -else 3.34 - gtkdialog --center --program=BOX 3.35 -fi 2> /dev/null | while read line; do 3.36 - case "$line" in 3.37 - *OUTPUT*) eval $line 3.38 - echo "$OUTPUT" 1>&2 ;; 3.39 - *CHECK*true*) line=${line%=*}; line=${line#CHECK} 3.40 - [ $line -eq 0 ] || shift $((3 * $line)) 3.41 - echo -n "\"$1\" " 1>&2;; 3.42 - *LIST=*) eval $line; set -- $LIST 3.43 - echo "$1" 1>&2 ;; 3.44 - *EXIT*abort*) echo 255;; 3.45 - *EXIT*) eval $line 3.46 - echo $EXIT ;; 3.47 - esac 3.48 -done 3.49 -} 3.50 - 3.51 -if [ -z "$XAUTHORITY" ]; then 3.52 - [ -n "$TEXTDIALOG" ] || TEXTDIALOG="dialog" 3.53 - export DIALOG=$TEXTDIALOG 3.54 - exec $TEXTDIALOG "$@" 3.55 -else 3.56 - title="" 3.57 - backtitle="" 3.58 - lines="10" 3.59 - cols="10" 3.60 - [ -n "$ICON" ] || ICON="applications-other" 3.61 - buttonok="" 3.62 - buttoncancel="" 3.63 - buttonextra="" 3.64 - yeslabel="ok" 3.65 - nolabel="cancel" 3.66 - extralabel="rename" 3.67 - gauge="" 3.68 - inputbox="" 3.69 - default="" 3.70 - buttonhelp="" 3.71 - checklist="" 3.72 - menu="" 3.73 - textbox="" 3.74 - radiolist="" 3.75 - fselect="" 3.76 - while [ -n "$1" ]; do 3.77 - case "$1" in 3.78 - --title) title="$2"; shift 2;; 3.79 - --backtitle) backtitle="$2"; shift 2;; 3.80 - --clear|--colors) shift;; 3.81 - --yes-label) yeslabel="$2"; shift 2;; 3.82 - --no-label) nolabel="$2"; shift 2;; 3.83 - --extra-label) extralabel="$2"; shift 2;; 3.84 - --extra-button) buttonextra="1"; shift;; 3.85 - --help-button) buttonhelp="1"; shift;; 3.86 - --msgbox) msgbox="$2"; lines="$3"; cols="$4" 3.87 - buttonok="1"; break;; 3.88 - --yesno) msgbox="$2"; lines="$3"; cols="$4" 3.89 - buttonok="1"; buttoncancel="1"; break;; 3.90 - --gauge) msgbox="$2"; lines="$3"; cols="$4" 3.91 - percent="$5"; gauge="1"; break;; 3.92 - --inputbox) msgbox="$2"; lines="$3"; cols="$4"; default="$5" 3.93 - buttonok="1"; buttoncancel="1"; inputbox="1"; break;; 3.94 - --checklist) msgbox="$2"; lines="$3"; cols="$4"; inlines="$5" 3.95 - buttonok="1"; checklist="1"; shift 5; break;; 3.96 - --menu) msgbox="$2"; lines="$3"; cols="$4"; inlines="$5" 3.97 - buttonok="1"; buttoncancel="1" 3.98 - menu="1"; shift 5; break;; 3.99 - --textbox) textbox="$2"; lines="$3"; cols="$4" 3.100 - buttonok="1"; break;; 3.101 - --radiolist) textbox="$2"; lines="$3"; cols="$4"; inlines="$5" 3.102 - buttonok="1"; buttoncancel="1" 3.103 - radiolist="1"; shift 5; break;; 3.104 - --fselect) fselect="$2"; lines="$3"; cols="$4" 3.105 - buttonok="1"; buttoncancel="1"; break;; 3.106 - *) echo "Unknown arg $1"; exit 255;; 3.107 - esac 3.108 - done 3.109 -fi 3.110 -msgbox="$(toutf8 "$msgbox")" 3.111 -textbox="$(toutf8 "$textbox")" 3.112 -title="$(toutf8 "$title")" 3.113 -backtitle="$(toutf8 "$backtitle")" 3.114 -yeslabel="$(toutf8 "$yeslabel")" 3.115 -nolabel="$(toutf8 "$nolabel")" 3.116 -extralabel="$(toutf8 "$extralabel")" 3.117 -default="$(toutf8 "$default")" 3.118 -BOX="<window" 3.119 -[ -n "$backtitle" ] && BOX="$BOX title=\"$backtitle\"" 3.120 -[ -n "$ICON" ] && BOX="$BOX icon-name=\"$ICON\"" 3.121 -BOX="$BOX> 3.122 - <vbox> 3.123 -" 3.124 -[ -n "$title" ] && BOX="$BOX <text use-markup=\"true\" width-chars=\"44\"> 3.125 - <label>\"<b>$title</b>\" </label> 3.126 - </text> 3.127 -" 3.128 -[ -n "$msgbox" ] && BOX="$BOX <text wrap=\"true\" use-markup=\"true\"> 3.129 - <label> \"$msgbox\" </label> 3.130 - </text> 3.131 -" 3.132 -[ -n "$gauge" ] && BOX="$BOX <progressbar> 3.133 - <input>while read data; do echo \$data; done</input> 3.134 - <action type=\"exit\">0</action> 3.135 - </progressbar> 3.136 -" 3.137 -[ -n "$default" ] && default="<default>$default</default> 3.138 - " 3.139 -[ -n "$inputbox" ] && BOX="$BOX <entry> 3.140 - $default<variable>OUTPUT</variable> 3.141 - </entry> 3.142 -" 3.143 -#[ -n "$textbox" ] && BOX="$BOX <text><input file width-chars=\"$cols\" \ 3.144 -#height=\"$lines\" wrap=\"true\">$textbox</input></text>" 3.145 -[ -n "$textbox" ] && BOX="$BOX <text> 3.146 - <input file wrap=\"true\">$textbox</input> 3.147 - </text> 3.148 -" 3.149 -[ -n "$menu" ] && BOX="$BOX <list> 3.150 -$(while [ -n "$1" ]; do 3.151 - echo " <item>$1 $2</item> 3.152 -" 3.153 - shift 2 3.154 - done) <variable>LIST</variable> 3.155 - </list> 3.156 -" 3.157 -[ -n "$radiolist" ] && BOX="$BOX$( 3.158 - i=0; while [ -n "$1" ]; do 3.159 - [ "$3" = "on" ] && c=" active=\"true\"" || c="" 3.160 - echo " <radiobutton$c> 3.161 - <label>$1 $2</label> 3.162 - <variable>CHECK$i</variable> 3.163 - </radiobutton> 3.164 -" 3.165 - i=$(($i+1)) 3.166 - shift 3 3.167 - done)" 3.168 -[ -n "$checklist" ] && BOX="$BOX $( 3.169 - i=0; while [ -n "$1" ]; do 3.170 - [ "$3" = "on" ] && c=" active=\"true\"" || c="" 3.171 - echo " <checkbox$c> 3.172 - <label>$1 $2</label> 3.173 - <variable>CHECK$i</variable> 3.174 - </checkbox> 3.175 -" 3.176 - i=$(($i+1)) 3.177 - shift 3 3.178 - done)" 3.179 -[ -n "$fselect" ] && BOX="$BOX <hbox> 3.180 - <entry> 3.181 - <variable>OUTPUT</variable> 3.182 - </entry> 3.183 - <button> 3.184 - <input file stock=\"gtk-open\"></input> 3.185 - <variable>FILE_BROWSE</variable> 3.186 - <action type=\"fileselect\">OUTPUT</action> 3.187 - </button> 3.188 - </hbox> 3.189 -" 3.190 -[ "$yeslabel" = "ok" ] && yeslabel="" || yeslabel=" 3.191 - <label>$yeslabel</label>" 3.192 -[ "$nolabel" = "cancel" ] && nolabel="" || nolabel=" 3.193 - <label>$nolabel</label>" 3.194 -[ -n "$buttonok$buttonextra$buttoncancel" ] && BOX="$BOX <hbox>" 3.195 -[ -n "$buttonok" ] && BOX="$BOX <button ok>$yeslabel 3.196 - <action type=\"exit\">0</action> 3.197 - </button> 3.198 -" 3.199 -[ -n "$buttonextra" ] && BOX="$BOX <button> 3.200 - <label>$extralabel</label> 3.201 - <input file icon=\"forward\"> </input> 3.202 - <action type=\"exit\">3</action> 3.203 - </button> 3.204 -" 3.205 -[ -n "$buttoncancel" ] && BOX="$BOX <button cancel>$nolabel 3.206 - <action type=\"exit\">1</action> 3.207 - </button> 3.208 -" 3.209 -[ -n "$buttonhelp" ] && BOX="$BOX <button help> 3.210 - <action type=\"exit\">2</action> 3.211 - </button> 3.212 -" 3.213 -[ -n "$buttonok$buttonextra$buttoncancel" ] && BOX="$BOX </hbox> 3.214 -" 3.215 -BOX="$BOX </vbox> 3.216 -</window> 3.217 -" 3.218 -export BOX 3.219 -exit $(fake_dialog)