dom0: fallback to zenity when kdialog not available
This can be the case on Xfce.
This commit is contained in:
		
							parent
							
								
									134dfa6d46
								
							
						
					
					
						commit
						51d0b3dba3
					
				| @ -46,7 +46,10 @@ class QfileDaemonDvm: | |||||||
|             qmemman_client.close() |             qmemman_client.close() | ||||||
|             errmsg = 'Not enough memory to create DVM. ' |             errmsg = 'Not enough memory to create DVM. ' | ||||||
|             errmsg +='Terminate some appVM and retry.' |             errmsg +='Terminate some appVM and retry.' | ||||||
|  |             if os.path.exists('/usr/bin/kdialog'): | ||||||
|                 subprocess.call(['/usr/bin/kdialog', '--sorry', errmsg]) |                 subprocess.call(['/usr/bin/kdialog', '--sorry', errmsg]) | ||||||
|  |             else: | ||||||
|  |                 subprocess.call(['/usr/bin/zenity', '--warning', errmsg]) | ||||||
|             return None |             return None | ||||||
| 
 | 
 | ||||||
|         self.tray_notify("Starting new DispVM...") |         self.tray_notify("Starting new DispVM...") | ||||||
| @ -74,7 +77,10 @@ class QfileDaemonDvm: | |||||||
|             '-l', str(label.index)]) |             '-l', str(label.index)]) | ||||||
|         qmemman_client.close() |         qmemman_client.close() | ||||||
|         if retcode != 0: |         if retcode != 0: | ||||||
|  |             if os.path.exists('/usr/bin/kdialog'): | ||||||
|                 subprocess.call(['/usr/bin/kdialog', '--sorry', 'DisposableVM creation failed, see qubes_restore.log']) |                 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() |             qvm_collection.unlock_db() | ||||||
|             return None |             return None | ||||||
|         f = open('/var/run/qubes/dispVM_xid', 'r'); |         f = open('/var/run/qubes/dispVM_xid', 'r'); | ||||||
|  | |||||||
| @ -1,19 +1,29 @@ | |||||||
| #!/bin/sh | #!/bin/sh | ||||||
| 
 | 
 | ||||||
| ref=`kdialog --title="Updating default DispVM savefile" \ | line1="<b>Please wait (up to 120s) while the DispVM savefile is being updated.</b>" | ||||||
| --progressbar \ | 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> | "<center> | ||||||
|     <font> |     <font> | ||||||
|         <b>Please wait (up to 120s) while the DispVM savefile is being updated.</b> |         $line1<br> | ||||||
|         <br> |         $line2<br> | ||||||
|         <i><small> |         $line3 | ||||||
|             This only happens when you have updated the template.<br> |  | ||||||
|             Next time will be much faster. |  | ||||||
|         </small></i> |  | ||||||
|     </font> |     </font> | ||||||
| </center>" 0`; | </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; | #qdbus $ref showCancelButton true; | ||||||
| 
 | 
 | ||||||
|  | |||||||
| @ -94,10 +94,16 @@ int ask_on_connect_timeout(int xid, int timeout) | |||||||
| { | { | ||||||
| 	char text[1024]; | 	char text[1024]; | ||||||
| 	int ret; | 	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), | 	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?'", | 			"'Timeout while trying connecting to qrexec agent (Xen domain ID: %d). Do you want to wait next %d seconds?'", | ||||||
| 			xid, timeout); | 			xid, timeout); | ||||||
|  | #undef KDIALOG_CMD | ||||||
|  | #undef ZENITY_CMD | ||||||
| 	ret = system(text); | 	ret = system(text); | ||||||
| 	ret = WEXITSTATUS(ret); | 	ret = WEXITSTATUS(ret); | ||||||
| 	//              fprintf(stderr, "ret=%d\n", ret);
 | 	//              fprintf(stderr, "ret=%d\n", ret);
 | ||||||
|  | |||||||
		Loading…
	
		Reference in New Issue
	
	Block a user
	 Marek Marczykowski
						Marek Marczykowski