Added SDL_SetAppMetadata() (#10404)

Removed duplicate hints SDL_HINT_APP_NAME, SDL_HINT_APP_ID, and
SDL_HINT_AUDIO_DEVICE_APP_NAME.

Wired up a few things to use the metadata; more to come!

Fixes https://github.com/libsdl-org/SDL/issues/4703
This commit is contained in:
Sam Lantinga
2024-07-28 07:22:46 -07:00
committed by GitHub
parent 35e42d0a25
commit a36fe632fd
13 changed files with 214 additions and 150 deletions

View File

@@ -362,12 +362,19 @@ static SDL3AppDelegate *appDelegate = nil;
static NSString *GetApplicationName(void)
{
NSString *appName;
NSString *appName = nil;
const char *metaname = SDL_GetStringProperty(SDL_GetGlobalProperties(), SDL_PROP_APP_METADATA_NAME_STRING, NULL);
if (metaname && *metaname) {
appName = [NSString stringWithUTF8String:metaname];
}
/* Determine the application name */
appName = [[NSBundle mainBundle] objectForInfoDictionaryKey:@"CFBundleDisplayName"];
if (!appName) {
appName = [[NSBundle mainBundle] objectForInfoDictionaryKey:@"CFBundleName"];
appName = [[NSBundle mainBundle] objectForInfoDictionaryKey:@"CFBundleDisplayName"];
if (!appName) {
appName = [[NSBundle mainBundle] objectForInfoDictionaryKey:@"CFBundleName"];
}
}
if (![appName length]) {
@@ -420,6 +427,10 @@ static void CreateApplicationMenus(void)
/* Add menu items */
title = [@"About " stringByAppendingString:appName];
// !!! FIXME: Menu items can't take parameters, just a basic selector, so this should instead call a selector
// !!! FIXME: that itself calls -[NSApplication orderFrontStandardAboutPanelWithOptions:optionsDictionary],
// !!! FIXME: filling in that NSDictionary with SDL_GetAppMetadataProperty()
[appleMenu addItemWithTitle:title action:@selector(orderFrontStandardAboutPanel:) keyEquivalent:@""];
[appleMenu addItem:[NSMenuItem separatorItem]];