|
@@ -65,6 +65,7 @@ USEKDIALOG="0";
|
65
|
65
|
QDBUS=`which qdbus`
|
66
|
66
|
DBUSSEND=`which dbus-send`
|
67
|
67
|
DCOP=`which dcop`
|
|
68
|
+BC=`which bc`
|
68
|
69
|
KDETYPE=""
|
69
|
70
|
if [ "${ISKDE}" != "" -o "${ZENITY}" = "" ]; then
|
70
|
71
|
# Check to see if we have the dcop or dbus binaries needed..
|
|
@@ -99,9 +100,16 @@ if [ "${1}" = "--watchdog" ]; then
|
99
|
100
|
exit 1;
|
100
|
101
|
fi;
|
101
|
102
|
|
|
103
|
+if [ "${1}" = "--pulsate" ]; then
|
|
104
|
+ shift;
|
|
105
|
+ PULSATE="1"
|
|
106
|
+else
|
|
107
|
+ PULSATE="0"
|
|
108
|
+fi;
|
|
109
|
+
|
102
|
110
|
CAPTION=${1}
|
103
|
111
|
FILESIZE=${2}
|
104
|
|
-WGETPID=${3}
|
|
112
|
+WGETPID=${4}
|
105
|
113
|
progresswindow=""
|
106
|
114
|
TYPE=""
|
107
|
115
|
PIPE="progresspipe_${$}"
|
|
@@ -125,16 +133,44 @@ readprogress() {
|
125
|
133
|
break;
|
126
|
134
|
fi;
|
127
|
135
|
fi;
|
|
136
|
+
|
128
|
137
|
input=`cat "${PIPE}" | tail ${TAILOPTS}1`
|
129
|
138
|
if [ "${input}" = "quit" ]; then
|
130
|
139
|
break;
|
131
|
140
|
elif [ "${input}" != "" ]; then
|
132
|
141
|
data=${input}
|
133
|
142
|
input=""
|
134
|
|
- res=`echo "scale=4 ; (${data}/${FILESIZE})*100" | bc`
|
135
|
|
- val=${res%%.*}
|
136
|
|
- if [ "${val}" = "" ]; then
|
137
|
|
- val=0
|
|
143
|
+ if [ "${PULSATE}" = "1" ]; then
|
|
144
|
+ val=-1
|
|
145
|
+
|
|
146
|
+ if [ "${data}" != "-1" ]; then
|
|
147
|
+ if [ "${TYPE}" = "KDE" ]; then
|
|
148
|
+ if [ "${KDETYPE}" = "dcop" ]; then
|
|
149
|
+ ${DCOP} ${progresswindow} setLabelText "${data}"
|
|
150
|
+ elif [ "${KDETYPE}" = "qdbus" ]; then
|
|
151
|
+ ${QDBUS} ${progresswindow} org.kde.kdialog.ProgressDialog.setLabelText "${data}"
|
|
152
|
+ elif [ "${KDETYPE}" = "dbussend" ]; then
|
|
153
|
+ ${DBUSSEND} --print-reply --dest=${progresswindow} org.kde.kdialog.ProgressDialog.setLabelText "string:\'${data}\'" > /dev/null
|
|
154
|
+ fi;
|
|
155
|
+ elif [ "${TYPE}" = "GNOME" ]; then
|
|
156
|
+ echo "${data}" | sed 's/^/# /g'
|
|
157
|
+ else
|
|
158
|
+ echo "${data}"
|
|
159
|
+ fi;
|
|
160
|
+ fi;
|
|
161
|
+
|
|
162
|
+ else
|
|
163
|
+ if [ "${BC}" != "" ]; then
|
|
164
|
+ res=`echo "scale=4 ; (${data}/${FILESIZE})*100" | bc`;
|
|
165
|
+ else
|
|
166
|
+ # Note, this will return 0 or 100, nothing else, better than spamming
|
|
167
|
+ # errors and never closing tho.
|
|
168
|
+ res=`echo $(( (${data}/${FILESIZE})*100 ))`;
|
|
169
|
+ fi;
|
|
170
|
+ val=${res%%.*}
|
|
171
|
+ if [ "${val}" = "" ]; then
|
|
172
|
+ val=0
|
|
173
|
+ fi;
|
138
|
174
|
fi;
|
139
|
175
|
if [ "${TYPE}" = "KDE" ]; then
|
140
|
176
|
if [ "${KDETYPE}" = "dcop" ]; then
|
|
@@ -161,6 +197,7 @@ readprogress() {
|
161
|
197
|
echo "-> "${val}"%"
|
162
|
198
|
fi;
|
163
|
199
|
fi;
|
|
200
|
+ echo "Val: ${val}";
|
164
|
201
|
if [ "${val}" = "100" ]; then
|
165
|
202
|
retval="0"
|
166
|
203
|
CONTINUE="0"
|
|
@@ -206,7 +243,7 @@ closeProgress() {
|
206
|
243
|
fi;
|
207
|
244
|
echo "Exiting with value: $retval"
|
208
|
245
|
if [ "${WGETPID}" != "" ]; then
|
209
|
|
- echo "Attempting to kill wget"
|
|
246
|
+ echo "Attempting to kill wget (${WGETPID})"
|
210
|
247
|
kill -9 ${WGETPID}
|
211
|
248
|
fi;
|
212
|
249
|
|
|
@@ -244,25 +281,34 @@ trap 'closeProgress' INT TERM EXIT
|
244
|
281
|
if [ "" != "${KDIALOG}" -a "" != "${DISPLAY}" -a "" = "${ISGNOME}" -a "${USEKDIALOG}" = "1" ]; then
|
245
|
282
|
echo "Progress dialog on Display: ${DISPLAY}"
|
246
|
283
|
progresswindow=`${KDIALOG} --title "DMDirc: ${CAPTION}" --progressbar "${CAPTION}" 100`
|
|
284
|
+ if [ "${PULSATE}" = "1" ]; then
|
|
285
|
+ SHOWCANCEL="false"
|
|
286
|
+ else
|
|
287
|
+ SHOWCANCEL="true"
|
|
288
|
+ fi;
|
247
|
289
|
if [ "${KDETYPE}" = "dcop" ]; then
|
248
|
290
|
${DCOP} ${progresswindow} setAutoClose true
|
249
|
|
- ${DCOP} ${progresswindow} showCancelButton true
|
|
291
|
+ ${DCOP} ${progresswindow} showCancelButton ${SHOWCANCEL}
|
250
|
292
|
elif [ "${KDETYPE}" = "qdbus" ]; then
|
251
|
293
|
${QDBUS} ${progresswindow} org.freedesktop.DBus.Properties.Set org.kde.kdialog.ProgressDialog autoClose true
|
252
|
|
- ${QDBUS} ${progresswindow} org.kde.kdialog.ProgressDialog.showCancelButton true
|
|
294
|
+ ${QDBUS} ${progresswindow} org.kde.kdialog.ProgressDialog.showCancelButton ${SHOWCANCEL}
|
253
|
295
|
elif [ "${KDETYPE}" = "dbussend" ]; then
|
254
|
|
- ${DBUSSEND} --print-reply --dest=${progresswindow} org.kde.kdialog.ProgressDialog.showCancelButton boolean:true >/dev/null
|
|
296
|
+ ${DBUSSEND} --print-reply --dest=${progresswindow} org.kde.kdialog.ProgressDialog.showCancelButton boolean:${SHOWCANCEL} >/dev/null
|
255
|
297
|
${DBUSSEND} --print-reply --dest=${progresswindow} org.freedesktop.DBus.Properties.Set string:'org.kde.kdialog.ProgressDialog' string:'autoClose' variant:boolean:true > /dev/null
|
256
|
298
|
fi;
|
257
|
299
|
TYPE="KDE"
|
258
|
300
|
readprogress
|
259
|
301
|
CONTINUE="0"
|
260
|
302
|
echo "Progress Bar Complete"
|
261
|
|
-elif [ "" != "${ZENITY}" -a "" != "${DISPLAY}" ]; then
|
|
303
|
+elif [ "" ! "${ZENITY}" -a "" != "${DISPLAY}" ]; then
|
262
|
304
|
# Else, if zenity exists and we have a display
|
263
|
305
|
echo "Progress dialog on Display: ${DISPLAY}"
|
264
|
306
|
TYPE="GNOME"
|
265
|
|
- readprogress | ${ZENITY} --progress --auto-close --auto-kill --title "DMDirc: ${CAPTION}" --text "${CAPTION}"
|
|
307
|
+ if [ "${PULSATE}" = "1" ]; then
|
|
308
|
+ readprogress | ${ZENITY} --progress --pulsate --auto-close --title "DMDirc: ${CAPTION}" --text "${CAPTION}"
|
|
309
|
+ else
|
|
310
|
+ readprogress | ${ZENITY} --progress --auto-close --auto-kill --title "DMDirc: ${CAPTION}" --text "${CAPTION}"
|
|
311
|
+ fi;
|
266
|
312
|
CONTINUE="0"
|
267
|
313
|
echo "Progress Bar Complete"
|
268
|
314
|
else
|