master
Camilla Löwy ago%!(EXTRA string=9 years)
parent c50aba1335
commit 7a8516d296
  1. 47
      src/cocoa_window.m

@ -826,48 +826,45 @@ static const NSRange kEmptyRange = { NSNotFound, 0 };
} }
@end @end
// Try to figure out what the calling application is called // Set up the menu bar (manually)
// This is nasty, nasty stuff -- calls to undocumented semi-private APIs that
// could go away at any moment, lots of stuff that really should be
// localize(d|able), etc. Add a nib to save us this horror.
// //
static NSString* findAppName(void) static void createMenuBar(void)
{ {
size_t i; size_t i;
NSDictionary* infoDictionary = [[NSBundle mainBundle] infoDictionary]; NSString* appName = nil;
NSDictionary* bundleInfo = [[NSBundle mainBundle] infoDictionary];
// Keys to search for as potential application names NSString* nameKeys[] =
NSString* GLFWNameKeys[] =
{ {
@"CFBundleDisplayName", @"CFBundleDisplayName",
@"CFBundleName", @"CFBundleName",
@"CFBundleExecutable", @"CFBundleExecutable",
}; };
for (i = 0; i < sizeof(GLFWNameKeys) / sizeof(GLFWNameKeys[0]); i++) // Try to figure out what the calling application is called
for (i = 0; i < sizeof(nameKeys) / sizeof(nameKeys[0]); i++)
{ {
id name = [infoDictionary objectForKey:GLFWNameKeys[i]]; id name = [bundleInfo objectForKey:nameKeys[i]];
if (name && if (name &&
[name isKindOfClass:[NSString class]] && [name isKindOfClass:[NSString class]] &&
![name isEqualToString:@""]) ![name isEqualToString:@""])
{ {
return name; appName = name;
break;
} }
} }
char** progname = _NSGetProgname(); if (!appName)
if (progname && *progname) {
return [NSString stringWithUTF8String:*progname]; char** progname = _NSGetProgname();
if (progname && *progname)
// Really shouldn't get here appName = [NSString stringWithUTF8String:*progname];
return @"GLFW Application"; else
} appName = @"GLFW Application";
}
// Set up the menu bar (manually)
// This is nasty, nasty stuff -- calls to undocumented semi-private APIs that
// could go away at any moment, lots of stuff that really should be
// localize(d|able), etc. Add a nib to save us this horror.
//
static void createMenuBar(void)
{
NSString* appName = findAppName();
NSMenu* bar = [[NSMenu alloc] init]; NSMenu* bar = [[NSMenu alloc] init];
[NSApp setMainMenu:bar]; [NSApp setMainMenu:bar];

Loading…
Cancel
Save