Allegro.cc - Online Community

Allegro.cc Forums » Programming Questions » [A5/OSX] Menu names

This thread is locked; no one can reply to it. rss feed Print
[A5/OSX] Menu names
X-G
Member #856
December 2000
avatar

Getting tired of me constantly asking questions about Allegro 5 on OSX yet? ;)

Is it possible to change the application name shown in the menu bar? Or is this something provided by OSX? Reason being, due to a bug/problem with Apple's submission procedure, you cannot have spaces in application names, so we're currently forced to name our bundle "IcyTower"; it looks kind of stupid in the menu though, and I'd like to fix it. But as far as I can tell, there appears to be no way to do this..?

--
Since 2008-Jun-18, democracy in Sweden is dead. | 悪霊退散!悪霊退散!怨霊、物の怪、困った時は ドーマン!セーマン!ドーマン!セーマン! 直ぐに呼びましょう陰陽師レッツゴー!

Evert
Member #794
November 2000
avatar

I've been thinking about that as well. Here's how we're doing it right now.

When an Allegro program starts on OS X, the magic main runs _al_osx_run_main, which is in src/macosx/osx_app_delegate.m. It first tries to load a "nib" for the main menu (I suspect that's an Interface Builder thingy, never looked at this myself). Failing that, it creates the standard menu entries programmatically. The name of the menu item is taken from the name of the bundle, or, failing that, from the name of the running process:

NSString* title = nil;
NSDictionary* app_dictionary = [[NSBundle mainBundle] infoDictionary];
if (app_dictionary) 
{
    title = [app_dictionary objectForKey: @"CFBundleName"];
}
if (title == nil) 
{
    title = [[NSProcessInfo processInfo] processName];
}

What I might expect is that Allegro's al_set_app_name() function would set the name here. The problem is, that runs from the user main() function, after the above code is called. I suppose it's possible to change the title later, but this would be a bit of a hassle.

That said, there are two ways for you to override the default name that Allegro assigns, which may be a better alternative in practice. The first is to create the menu yourself using the mentioned "nib", the second is to set the application name in the bundle's info.plist (see http://developer.apple.com/library/mac/#documentation/Cocoa/Conceptual/ObjCTutorial/08Configuring/08Configuring.html). That's probably what you will want to do.
Note I haven't actually tried either.

X-G
Member #856
December 2000
avatar

Unfortunately, setting the application name in the bundle's info.plist suffers from the same problem I described initially: Apple's submission software will automatically reject your program if it has spaces anywhere in it; executable name, bundle name, or even bundle display name. I'll look more into the other option, perhaps...

--
Since 2008-Jun-18, democracy in Sweden is dead. | 悪霊退散!悪霊退散!怨霊、物の怪、困った時は ドーマン!セーマン!ドーマン!セーマン! 直ぐに呼びましょう陰陽師レッツゴー!

Go to: