dom0: fallback to zenity when kdialog not available

This can be the case on Xfce.
This commit is contained in:
Marek Marczykowski 2013-02-12 01:41:06 +01:00
parent 134dfa6d46
commit 51d0b3dba3
3 changed files with 34 additions and 12 deletions

View File

@ -46,7 +46,10 @@ class QfileDaemonDvm:
qmemman_client.close()
errmsg = 'Not enough memory to create DVM. '
errmsg +='Terminate some appVM and retry.'
subprocess.call(['/usr/bin/kdialog', '--sorry', errmsg])
if os.path.exists('/usr/bin/kdialog'):
subprocess.call(['/usr/bin/kdialog', '--sorry', errmsg])
else:
subprocess.call(['/usr/bin/zenity', '--warning', errmsg])
return None
self.tray_notify("Starting new DispVM...")
@ -74,7 +77,10 @@ class QfileDaemonDvm:
'-l', str(label.index)])
qmemman_client.close()
if retcode != 0:
subprocess.call(['/usr/bin/kdialog', '--sorry', 'DisposableVM creation failed, see qubes_restore.log'])
if os.path.exists('/usr/bin/kdialog'):
subprocess.call(['/usr/bin/kdialog', '--sorry', 'DisposableVM creation failed, see qubes_restore.log'])
else:
subprocess.call(['/usr/bin/zenity', '--warning', 'DisposableVM creation failed, see qubes_restore.log'])
qvm_collection.unlock_db()
return None
f = open('/var/run/qubes/dispVM_xid', 'r');

View File

@ -1,19 +1,29 @@
#!/bin/sh
ref=`kdialog --title="Updating default DispVM savefile" \
--progressbar \
line1="<b>Please wait (up to 120s) while the DispVM savefile is being updated.</b>"
line2="<i><small>This only happens when you have updated the template.</small></i>"
line3="<i><small>Next time will be much faster.</small></i>"
if type kdialog &> /dev/null; then
ref=`kdialog --title="Updating default DispVM savefile" \
--progressbar \
"<center>
<font>
<b>Please wait (up to 120s) while the DispVM savefile is being updated.</b>
<br>
<i><small>
This only happens when you have updated the template.<br>
Next time will be much faster.
</small></i>
$line1<br>
$line2<br>
$line3
</font>
</center>" 0`;
trap "qdbus $ref close" EXIT
trap "qdbus $ref close" EXIT
else
pipe=/tmp/qvm-create-default-dvm-$$.progress
mkfifo $pipe
zenity --progress --pulsate --auto-close --text "$line1\n$line2\n$line3" < $pipe &
exec 5>$pipe
echo 0 >&5
trap "echo 100 >&5" EXIT
fi
#qdbus $ref showCancelButton true;

View File

@ -94,10 +94,16 @@ int ask_on_connect_timeout(int xid, int timeout)
{
char text[1024];
int ret;
struct stat buf;
ret=stat("/usr/bin/kdialog", &buf);
#define KDIALOG_CMD "kdialog --title 'Qrexec daemon' --warningyesno "
#define ZENITY_CMD "zenity --title 'Qrexec daemon' --question --text "
snprintf(text, sizeof(text),
"kdialog --title 'Qrexec daemon' --warningyesno "
ret==0 ? KDIALOG_CMD : ZENITY_CMD
"'Timeout while trying connecting to qrexec agent (Xen domain ID: %d). Do you want to wait next %d seconds?'",
xid, timeout);
#undef KDIALOG_CMD
#undef ZENITY_CMD
ret = system(text);
ret = WEXITSTATUS(ret);
// fprintf(stderr, "ret=%d\n", ret);