diff options
author | Simon Howard | 2014-04-30 00:07:06 -0400 |
---|---|---|
committer | Simon Howard | 2014-04-30 00:07:06 -0400 |
commit | da2fa989eb7c776578d4e722f27189b4bfe2d477 (patch) | |
tree | ae69437fd0324449825a825b966cb8c1cd8d3d78 /src | |
parent | 242fa1ee46f90f451c625e90f16927e13030c0a0 (diff) | |
parent | 4d41e7e74d935a87fca669fa86c25ddb1d60695d (diff) | |
download | chocolate-doom-da2fa989eb7c776578d4e722f27189b4bfe2d477.tar.gz chocolate-doom-da2fa989eb7c776578d4e722f27189b4bfe2d477.tar.bz2 chocolate-doom-da2fa989eb7c776578d4e722f27189b4bfe2d477.zip |
Merge pull request #388 from willybarro/355_show_error_messagebox_on_linux
Add native notification box for errors on linux.
Diffstat (limited to 'src')
-rw-r--r-- | src/i_system.c | 42 |
1 files changed, 39 insertions, 3 deletions
diff --git a/src/i_system.c b/src/i_system.c index 041217b0..5b6989bf 100644 --- a/src/i_system.c +++ b/src/i_system.c @@ -262,6 +262,39 @@ void I_Quit (void) exit(0); } +#define ZENITY_BINARY "/usr/bin/zenity" + +// returns non-zero if zenity is available + +static int ZenityAvailable(void) +{ + return system(ZENITY_BINARY " --help >/dev/null 2>&1") == 0; +} + +// Open a native error box with a message using zenity + +static int ZenityErrorBox(char *message) +{ + int *result; + char *errorboxpath; + static size_t errorboxpath_size; + + if (!ZenityAvailable()) + { + return 0; + } + + errorboxpath_size = strlen(ZENITY_BINARY) + strlen(message) + 19; + errorboxpath = malloc(errorboxpath_size); + M_snprintf(errorboxpath, errorboxpath_size, "%s --error --text=\"%s\"", ZENITY_BINARY, message); + + result = system(errorboxpath); + + free(errorboxpath); + + return result; +} + // // I_Error // @@ -327,9 +360,7 @@ void I_Error (char *error, ...) MessageBoxW(NULL, wmsgbuf, L"", MB_OK); } -#endif - -#ifdef __MACOSX__ +#elif defined(__MACOSX__) if (exit_gui_popup && !I_ConsoleStdout()) { CFStringRef message; @@ -365,6 +396,11 @@ void I_Error (char *error, ...) message, NULL); } +#else + if (exit_gui_popup && !I_ConsoleStdout()) + { + ZenityErrorBox(error); + } #endif // abort(); |