commit defe24a7230f4ffb8f1d1ca8fc166db73ef8e9d5
Author: Simon Howard <fraggle@soulsphere.org>
AuthorDate: Sat Dec 6 02:17:57 2014 -0500
Commit: Simon Howard <fraggle@soulsphere.org>
CommitDate: Sat Dec 6 02:17:57 2014 -0500
Remove system specific code for error box.
Use SDL_ShowSimpleMessageBox() which performs the same operation
across many different platforms without needing to rely on
system-specific interfaces.
---
src/i_system.c | 135 ++-------------------------------------------------------
1 file changed, 3 insertions(+), 132 deletions(-)
diff --git a/src/i_system.c b/src/i_system.c
index a03ce734..28fa7656 100644
--- a/src/i_system.c
+++ b/src/i_system.c
@@ -49,10 +49,6 @@
#include "w_wad.h"
#include "z_zone.h"
-#ifdef __MACOSX__
-#include <CoreFoundation/CFUserNotification.h>
-#endif
-
#define DEFAULT_RAM 16 /* MiB */
#define MIN_RAM 4 /* MiB */
@@ -209,7 +205,7 @@ boolean I_ConsoleStdout(void)
{
#ifdef _WIN32
// SDL "helpfully" always redirects stdout to a file.
- return 0;
+ return false;
#else
return isatty(fileno(stdout));
#endif
@@ -256,91 +252,6 @@ void I_Quit (void)
exit(0);
}
-// SDL2-TODO: Fix the dialog box on OS X.
-#if !defined(_WIN32) && !defined(__DISABLED__MACOSX__)
-#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;
-}
-
-// Escape special characters in the given string so that they can be
-// safely enclosed in shell quotes.
-
-static char *EscapeShellString(char *string)
-{
- char *result;
- char *r, *s;
-
- // In the worst case, every character might be escaped.
- result = malloc(strlen(string) * 2 + 3);
- r = result;
-
- // Enclosing quotes.
- *r = '"';
- ++r;
-
- for (s = string; *s != '\0'; ++s)
- {
- // From the bash manual:
- //
- // "Enclosing characters in double quotes preserves the literal
- // value of all characters within the quotes, with the exception
- // of $, `, \, and, when history expansion is enabled, !."
- //
- // Therefore, escape these characters by prefixing with a backslash.
-
- if (strchr("$`\\!", *s) != NULL)
- {
- *r = '\\';
- ++r;
- }
-
- *r = *s;
- ++r;
- }
-
- // Enclosing quotes.
- *r = '"';
- ++r;
- *r = '\0';
-
- return result;
-}
-
-// Open a native error box with a message using zenity
-
-static int ZenityErrorBox(char *message)
-{
- int result;
- char *escaped_message;
- char *errorboxpath;
- static size_t errorboxpath_size;
-
- if (!ZenityAvailable())
- {
- return 0;
- }
-
- escaped_message = EscapeShellString(message);
-
- errorboxpath_size = strlen(ZENITY_BINARY) + strlen(escaped_message) + 19;
- errorboxpath = malloc(errorboxpath_size);
- M_snprintf(errorboxpath, errorboxpath_size, "%s --error --text=%s",
- ZENITY_BINARY, escaped_message);
-
- result = system(errorboxpath);
-
- free(errorboxpath);
- free(escaped_message);
-
- return result;
-}
-
-#endif /* !defined(_WIN32) && !defined(__MACOSX__) */
//
@@ -400,50 +311,10 @@ void I_Error (char *error, ...)
// game was not run from the console (and the user will
// therefore be unable to otherwise see the message).
if (exit_gui_popup && !I_ConsoleStdout())
-#ifdef _WIN32
- {
- wchar_t wmsgbuf[512];
-
- MultiByteToWideChar(CP_ACP, 0,
- msgbuf, strlen(msgbuf) + 1,
- wmsgbuf, sizeof(wmsgbuf));
-
- MessageBoxW(NULL, wmsgbuf, L"", MB_OK);
- }
-#elif defined(__DISABLED__MACOSX__)
{
- CFStringRef message;
- int i;
-
- // The CoreFoundation message box wraps text lines, so replace
- // newline characters with spaces so that multiline messages
- // are continuous.
-
- for (i = 0; msgbuf[i] != '\0'; ++i)
- {
- if (msgbuf[i] == '\n')
- {
- msgbuf[i] = ' ';
- }
- }
-
- message = CFStringCreateWithCString(NULL, msgbuf,
- kCFStringEncodingUTF8);
-
- CFUserNotificationDisplayNotice(0,
- kCFUserNotificationCautionAlertLevel,
- NULL,
- NULL,
- NULL,
- CFSTR(PACKAGE_STRING),
- message,
- NULL);
- }
-#else
- {
- ZenityErrorBox(msgbuf);
+ SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR,
+ PACKAGE_STRING, msgbuf, NULL);
}
-#endif
// abort();