mirror of
				https://github.com/godotengine/godot.git
				synced 2025-10-31 13:41:03 +00:00 
			
		
		
		
	Move alert function from DisplayServer to OS.
				
					
				
			This commit is contained in:
		
							parent
							
								
									5de991d57c
								
							
						
					
					
						commit
						618eb27e8b
					
				
					 36 changed files with 377 additions and 350 deletions
				
			
		|  | @ -51,6 +51,70 @@ | |||
| #include <sys/types.h> | ||||
| #include <unistd.h> | ||||
| 
 | ||||
| void OS_LinuxBSD::alert(const String &p_alert, const String &p_title) { | ||||
| 	const char *message_programs[] = { "zenity", "kdialog", "Xdialog", "xmessage" }; | ||||
| 
 | ||||
| 	String path = get_environment("PATH"); | ||||
| 	Vector<String> path_elems = path.split(":", false); | ||||
| 	String program; | ||||
| 
 | ||||
| 	for (int i = 0; i < path_elems.size(); i++) { | ||||
| 		for (uint64_t k = 0; k < sizeof(message_programs) / sizeof(char *); k++) { | ||||
| 			String tested_path = path_elems[i].plus_file(message_programs[k]); | ||||
| 
 | ||||
| 			if (FileAccess::exists(tested_path)) { | ||||
| 				program = tested_path; | ||||
| 				break; | ||||
| 			} | ||||
| 		} | ||||
| 
 | ||||
| 		if (program.length()) { | ||||
| 			break; | ||||
| 		} | ||||
| 	} | ||||
| 
 | ||||
| 	List<String> args; | ||||
| 
 | ||||
| 	if (program.ends_with("zenity")) { | ||||
| 		args.push_back("--error"); | ||||
| 		args.push_back("--width"); | ||||
| 		args.push_back("500"); | ||||
| 		args.push_back("--title"); | ||||
| 		args.push_back(p_title); | ||||
| 		args.push_back("--text"); | ||||
| 		args.push_back(p_alert); | ||||
| 	} | ||||
| 
 | ||||
| 	if (program.ends_with("kdialog")) { | ||||
| 		args.push_back("--error"); | ||||
| 		args.push_back(p_alert); | ||||
| 		args.push_back("--title"); | ||||
| 		args.push_back(p_title); | ||||
| 	} | ||||
| 
 | ||||
| 	if (program.ends_with("Xdialog")) { | ||||
| 		args.push_back("--title"); | ||||
| 		args.push_back(p_title); | ||||
| 		args.push_back("--msgbox"); | ||||
| 		args.push_back(p_alert); | ||||
| 		args.push_back("0"); | ||||
| 		args.push_back("0"); | ||||
| 	} | ||||
| 
 | ||||
| 	if (program.ends_with("xmessage")) { | ||||
| 		args.push_back("-center"); | ||||
| 		args.push_back("-title"); | ||||
| 		args.push_back(p_title); | ||||
| 		args.push_back(p_alert); | ||||
| 	} | ||||
| 
 | ||||
| 	if (program.length()) { | ||||
| 		execute(program, args); | ||||
| 	} else { | ||||
| 		print_line(p_alert); | ||||
| 	} | ||||
| } | ||||
| 
 | ||||
| void OS_LinuxBSD::initialize() { | ||||
| 	crash_handler.initialize(); | ||||
| 
 | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 bruvzg
						bruvzg