Allow building both Cocoa and dummy dialog implementations

This allows us to remove platformFilters from the Xcode project, which is not supported in Xcode 12.
This commit is contained in:
Sam Lantinga
2024-10-07 18:00:18 -07:00
parent c8526532de
commit 4627283eca
4 changed files with 13 additions and 8 deletions

View File

@@ -21,6 +21,8 @@
#include "SDL_internal.h"
#include "../SDL_dialog_utils.h"
#ifdef SDL_PLATFORM_MACOS
#import <Cocoa/Cocoa.h>
#import <UniformTypeIdentifiers/UTType.h>
@@ -33,10 +35,6 @@ typedef enum
void show_file_dialog(cocoa_FileDialogType type, SDL_DialogFileCallback callback, void* userdata, SDL_Window* window, const SDL_DialogFileFilter *filters, int nfilters, const char* default_location, bool allow_many)
{
#if defined(SDL_PLATFORM_TVOS) || defined(SDL_PLATFORM_IOS)
SDL_SetError("tvOS and iOS don't support path-based file dialogs");
callback(userdata, NULL, -1);
#else
if (filters) {
const char *msg = validate_filters(filters, nfilters);
@@ -175,7 +173,6 @@ void show_file_dialog(cocoa_FileDialogType type, SDL_DialogFileCallback callback
callback(userdata, files, -1);
}
}
#endif // defined(SDL_PLATFORM_TVOS) || defined(SDL_PLATFORM_IOS)
}
void SDL_ShowOpenFileDialog(SDL_DialogFileCallback callback, void* userdata, SDL_Window* window, const SDL_DialogFileFilter *filters, int nfilters, const char* default_location, bool allow_many)
@@ -192,3 +189,5 @@ void SDL_ShowOpenFolderDialog(SDL_DialogFileCallback callback, void* userdata, S
{
show_file_dialog(FDT_OPENFOLDER, callback, userdata, window, NULL, 0, default_location, allow_many);
}
#endif // SDL_PLATFORM_MACOS

View File

@@ -20,6 +20,8 @@
*/
#include "SDL_internal.h"
#ifdef SDL_DIALOG_DUMMY
void SDL_ShowOpenFileDialog(SDL_DialogFileCallback callback, void* userdata, SDL_Window* window, const SDL_DialogFileFilter *filters, int nfilters, const char* default_location, bool allow_many)
{
SDL_Unsupported();
@@ -37,3 +39,5 @@ void SDL_ShowOpenFolderDialog(SDL_DialogFileCallback callback, void* userdata, S
SDL_Unsupported();
callback(userdata, NULL, -1);
}
#endif // SDL_DIALOG_DUMMY