slitaz-tools diff lib/gui_functions @ rev 722
Make POT and msgmerge
author | Christophe Lincoln <pankso@slitaz.org> |
---|---|
date | Sat Mar 24 14:35:09 2012 +0100 (2012-03-24) |
parents | |
children |
line diff
1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/lib/gui_functions Sat Mar 24 14:35:09 2012 +0100 1.3 @@ -0,0 +1,211 @@ 1.4 +#!/bin/sh 1.5 +# 1.6 +# 1.7 +# Tab display engine 1.8 +# 1.9 +###################################################### 1.10 + 1.11 +use_tab() 1.12 +{ 1.13 +local tmp='' 1.14 +case "$2" in 1.15 +header|body) 1.16 + $1 | while read exe name call; do 1.17 + case "$exe" in 1.18 + \#*) continue;; 1.19 + /*) [ -e $exe ] || continue;; 1.20 + *) which $exe > /dev/null || continue 1.21 + esac 1.22 + if [ "$2" == "header" ]; then 1.23 + echo -n "$tmp$name" 1.24 + tmp='|' 1.25 + else 1.26 + $call 1.27 + fi 1.28 + done 1.29 + ;; 1.30 +*) 1.31 + tmp=$(use_tab $1 header) 1.32 + echo "$tmp" | grep -q \| && cat <<EOT 1.33 +<notebook labels="$tmp"> 1.34 +EOT 1.35 + [ -n "$tmp" ] && cat <<EOT 1.36 +$(use_tab $1 body) 1.37 +EOT 1.38 + echo "$tmp" | grep -q \| && cat <<EOT 1.39 +</notebook> 1.40 +EOT 1.41 + ;; 1.42 +esac 1.43 +} 1.44 + 1.45 +# 1.46 +# GUI functions 1.47 +# 1.48 +############################################################ 1.49 + 1.50 +xterm="xterm -fa MiscFixed -fs 11" 1.51 +helpbutton() 1.52 +{ 1.53 + local label; 1.54 + label="<label>$3</label>" 1.55 + [ -n "$3" ] || label="" 1.56 + cat << EOT 1.57 +<button> 1.58 + <input file icon="help"></input>$label 1.59 + <action>$xterm -geometry $2 -title "$1 help (q to quit)" -e "( echo ; $(which $1) --help 2>&1 ) | less"</action> 1.60 +</button> 1.61 +EOT 1.62 +} 1.63 + 1.64 +editbutton() 1.65 +{ 1.66 + cat << EOT 1.67 +<button> 1.68 + <input file icon="accessories-text-editor"></input> 1.69 + <action type="lauch">leafpad $1</action> 1.70 +</button> 1.71 +EOT 1.72 +} 1.73 + 1.74 +manbutton() 1.75 +{ 1.76 + cat << EOT 1.77 +<button> 1.78 + <input file icon="browser"></input> 1.79 + <label>man</label> 1.80 + <action>$xterm -geometry 80x24 -title "$2 man (q to quit)" -e ". /etc/profile; man $1 $2"</action> 1.81 +</button> 1.82 +EOT 1.83 +} 1.84 + 1.85 +helpdaemon() 1.86 +{ 1.87 + cat << EOT 1.88 +<hbox> 1.89 + <text use-markup="true"> 1.90 + <label>"<b>$3</b>"</label> 1.91 + </text> 1.92 + <entry editable="false"> 1.93 +EOT 1.94 + eval tmp=\$$3 1.95 + [ -n "$tmp" ] && cat << EOT 1.96 + <default>$tmp</default> 1.97 +EOT 1.98 + cat << EOT 1.99 + <variable>$4</variable> 1.100 + </entry> 1.101 +EOT 1.102 + [ -n "$6" ] || cat << EOT 1.103 +$(helpbutton $1 $2) 1.104 +EOT 1.105 + [ -n "$5" ] && cat << EOT 1.106 +$(manbutton $5 $1) 1.107 +EOT 1.108 + cat << EOT 1.109 +$(editbutton /etc/daemons.conf) 1.110 +</hbox> 1.111 +EOT 1.112 +} 1.113 + 1.114 +datafile() 1.115 +{ 1.116 + cat << EOT 1.117 +<hbox> 1.118 + <text use-markup="true"> 1.119 + <label>"<b>$3</b>"</label> 1.120 + </text> 1.121 + <entry editable="false"> 1.122 +EOT 1.123 + [ -n "$1" ] && cat << EOT 1.124 + <default>$1</default> 1.125 +EOT 1.126 + cat << EOT 1.127 + <variable>$2</variable> 1.128 + </entry> 1.129 +EOT 1.130 + [ -n "$4" ] && cat << EOT 1.131 +$(manbutton $4) 1.132 +EOT 1.133 + cat << EOT 1.134 +$(editbutton \$$2) 1.135 +</hbox> 1.136 +EOT 1.137 +} 1.138 + 1.139 +configfile() 1.140 +{ 1.141 + datafile "$1" $2 'Configuration:' "$3" 1.142 +} 1.143 + 1.144 +BROWSER='' 1.145 +for i in firefox opera dillo midori netsurf links ; do 1.146 + which $i > /dev/null && BROWSER="$i" && break 1.147 +done 1.148 +case "$BROWSER" in 1.149 +links) BROWSER="links -g ";; 1.150 +esac 1.151 + 1.152 +webbutton() 1.153 +{ 1.154 + [ -f "/var/lib/tazpkg/installed/$1/receipt" ] && 1.155 + [ -n "$BROWSER" ] && cat << EOT 1.156 +<button> 1.157 + <input file icon="browser"></input> 1.158 + <label>web</label> 1.159 + <action>. /var/lib/tazpkg/installed/$1/receipt ; $BROWSER \$WEB_SITE &</action> 1.160 +</button> 1.161 +EOT 1.162 +} 1.163 + 1.164 +wikibutton() 1.165 +{ 1.166 +[ -n "$BROWSER" ] && cat <<EOT 1.167 + <button> 1.168 + <input file icon="browser"></input> 1.169 + <label>Wiki</label> 1.170 + <action>$BROWSER $1 &</action> 1.171 + </button> 1.172 +EOT 1.173 +} 1.174 + 1.175 +startstopdaemon() 1.176 +{ 1.177 + local pkg 1.178 + pkg=$1 1.179 + [ -n "$2" ] && pkg=$2 1.180 + if [ ! -d /var/lib/tazpkg/installed/${pkg} ]; then 1.181 + installbox $pkg 1.182 + fi 1.183 + webbutton $pkg 1.184 + cat << EOT 1.185 +<button> 1.186 + <label>Start</label> 1.187 + <input file icon="forward"></input> 1.188 + <action>sed -i "s/RUN_DAEMONS=\\"\\(.*\\)$1 \?\\(.*\\)\\"/RUN_DAEMONS=\\"\1\2\\"/" /etc/rcS.conf</action> 1.189 + <action>sed -i "s/RUN_DAEMONS=\\"\\(.*\\)\\"/RUN_DAEMONS=\\"$1 \1\\"/" /etc/rcS.conf</action> 1.190 + <action>/etc/init.d/$1 start</action> 1.191 +</button> 1.192 +<button> 1.193 + <label>Stop</label> 1.194 + <input file icon="stop"></input> 1.195 + <action>sed -i "s/RUN_DAEMONS=\\"\\(.*\\)$1 \?\\(.*\\)\\"/RUN_DAEMONS=\\"\1\2\\"/" /etc/rcS.conf</action> 1.196 + <action>/etc/init.d/$1 stop</action> 1.197 +</button> 1.198 +EOT 1.199 +} 1.200 + 1.201 +installbox() 1.202 +{ 1.203 + cat << EOT 1.204 +<hbox> 1.205 + 1.206 + <button> 1.207 + <input file icon="go-jump"></input> 1.208 + <label>Install</label> 1.209 + <action>$xterm -geometry 80x17 -title "$1 install" -e "yes y | tazpkg get-install $1 ; echo -e \"----\n\nENTER to continue...\" && read close"</action> 1.210 + <action type="exit">restart</action> 1.211 + </button> 1.212 +</hbox> 1.213 +EOT 1.214 +}