I feel pretty bad.. it’s been a long time since I’ve posted. I had such good intentions about doing this regularly, didn’t quite keep that up. To allay my guilt, here’s something (I think is) useful.
Why can’t I just have some kind of substitution token for my App name in my menus? It would be so nice if this was just handled for you. Or even just use preprocessor macros. Or something so I don’t have to build things programmatically.
I’m working on a project which produces various targets, why would I want a separate MainMenu.nib for each target, when except for the App name they are the same (or at least nearly so).
So here’s what I did in my AppController’s AwakeFromNib:
NSEnumerator *menuEnumerator = [[[NSApp mainMenu] itemArray] objectEnumerator];
id menuItem;
while (menuItem = [menuEnumerator nextObject]) {
if ([menuItem hasSubmenu]) {
NSEnumerator *subMenuEnumerator = [[[menuItem submenu] itemArray] objectEnumerator];
id subMenuItem;
while (subMenuItem = [subMenuEnumerator nextObject]) {
NSString *menuTitle = [subMenuItem title];
[subMenuItem setTitle:[[menuTitle
componentsSeparatedByString:@”NewApplication”]
componentsJoinedByString:[[NSProcessInfo processInfo] processName]]];
}
}
}
Maybe you’ll find a use for it somewhere.
posted by ganyard at 10:30 pm
(Alright, I found something that was broken that I had overlooked in my implementation. Thanks to Matt Gemmell for helping me resolve the error of my ways.)
StyledWindow now plays properly with Toolbars.
Download
posted by ganyard at 2:06 pm
Pixie is a great tool. If you’re interested in using StyledWindow to recreate existing Polished Metal implementations here are some values for you.
iWeb:
[styledWindow setBorderStartColor:[NSColor colorWithDeviceWhite:0.7686 alpha:1.0]];
[styledWindow setBorderEndColor:[NSColor colorWithDeviceWhite:0.5922 alpha:1.0]];
[styledWindow setBorderEdgeColor: [NSColor colorWithDeviceWhite:0.2510 alpha:1.0]];
iMovie HD & iDVD:
[styledWindow setBorderStartColor:[NSColor colorWithDeviceWhite:0.7686 alpha:1.0]];
[styledWindow setBorderEndColor:[NSColor colorWithDeviceWhite:0.5922 alpha:1.0]];
[styledWindow setBorderEdgeColor:[NSColor colorWithDeviceWhite:0.2549 alpha:1.0]];
iPhoto:
[styledWindow setBorderStartColor:[NSColor colorWithDeviceWhite:0.7686 alpha:1.0]];
[styledWindow setBorderEndColor:[NSColor colorWithDeviceWhite:0.5922 alpha:1.0]];
[styledWindow setBorderEdgeColor:[NSColor colorWithDeviceWhite:0.4039 alpha:1.0]];
iTunes 7:
[styledWindow setBorderStartColor:[NSColor colorWithDeviceWhite:0.7725 alpha:1.0]];
[styledWindow setBorderEndColor:[NSColor colorWithDeviceWhite:0.5882 alpha:1.0]];
[styledWindow setBorderEdgeColor:[NSColor colorWithDeviceWhite:0.2510 alpha:1.0]];
You can use the Demo App to figure out the heights of the borders.
posted by ganyard at 12:14 pm
An Automator Workflow to make your Xcode Projects (or anything else I guess) ready to share. Install at ~/Library/Workflows/Applications/Finder/ (create the path if needed).
Download
Update: rev’d to remove .DS_Store files and “build” (in addition to “Build”) folders
posted by ganyard at 6:24 pm
A Category on NSImage to produce a reflection, with the ability to set how much of the reflection is shown.

Download
Note: it uses Chad Weider’s extremely convenient CTGradient class.
posted by ganyard at 7:42 am
NSWindow. Very flexible stuff. It’s used *everywhere*. I mean it, everywhere, look for yourself, hit cmd-shift-4 and then press the spacebar. Move that camera icon around, over Desktop icons, Dock items, Menu Extras, etc, etc. Everywhere.
Pretty versatile.
But most of us still just use what IB provides. Matt Gemmell released TunesWindow a while back and it provided a great solution to making something a bit more unique. I just thought it could be even more flexible so I built StyledWindow based on it. (thanks Matt!)
And since John Gruber delivered the obituary on the Apple HIG at C4 (and everyone is talking about it: Daniel Jalkut, Uli Kusterer, Michael Tsai, Scott Stevenson, et al), it seems time to release this so everyone can now define their own HIG.
Download and Enjoy.
posted by ganyard at 4:18 pm
A flexible NSWindow subclass.

Download
Note: it uses Chad Weider’s extremely convenient CTGradient class.
Update: Default values are now set to something closer to Apple’s Polished Metal Window. Added some comments to AppController.m awakeFromNib method - look there to see how to set things up.
posted by ganyard at 4:16 pm