Me: bounce! / OS X: how high?
October 7th, 2004 at 12:27 pm
Preamble: I was sitting in my room some weeks ago working away on my Powerbook, when one of the other guys in my flat came by. We were talking, referenced a web site, and at some point I hit the key for Exposé: “Whoa, what was that?” I explained, and demonstrated. “Why did you show me that? Now I want a Mac! And instead I have to go back upstairs and use my stupid Windows computer!”
For some time after switching to OS X, I complained that only one thing prevented me from hiding the dock and reclaiming that several square inches of screen space: new mail notification. With Mail.app’s new mail badge hidden away, how could I be spurred to immediate unresponsiveness and procrastination upon the receipt of each new electronic missive?
While this might have been something of an exaggeration — there are other reasons to keep the dock in view, and other ways to get new mail notification — the real problem was that a solution seemed so close at hand: bounce the icon in the dock. Say what you will about bouncing dock icons, I like the feature, and why couldn’t the Mail.app icon bounce out from its hiding place periodically to indicate new mail? Well, because Apple didn’t include the feature. That’s why.
OK, so they’ve denied me a checkbox in Mail.app’s preferences pane. Instead, we have OS X, and I think that’s a fair trade. Because in OS X, I can write something along the lines of the following (inboxnce is my strikingly clever combination of “inbox” and “bounce”):
@implementation inboxnce
+ (void) initialize {
[super initialize];
[self registerBundle];
}
- (id) init {
[super init];
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(mailAccountFetchCompleted:)
name:@"MailAccountFetchCompleted"
object:nil];
return self;
}
- (void) mailAccountFetchCompleted:(NSNotification *)notification {
if ([[[notification userInfo] objectForKey:@"NewMailWasReceived"] boolValue]) {
[NSApp requestUserAttention:NSCriticalRequest];
}
}
@end
Where the class is specified as:
@interface inboxnce : MVMailBundle
{
}
@end
In other words, translating from the Objective C: “This class is a Mail.app bundle. It wants to know when a new mail fetch is completed. When such a fetch occurs, and results in new mail, request the user’s urgent attention — i.e., start bouncing the dock icon.”
Now, I’ve left out the ugly header file you need in order to compile this program, and I’ve neglected to mention that the linker must be instructed to ignore missing symbols, but nevertheless, first with fiwt and now with this little hack, I have been very impressed with Apple’s APIs (public and otherwise), with Objective C, with OS X’s application “package”ing mechanism, and in general with the compelling combination of whatever you want to call the things Apple has so compellingly combined in this operating system number ten. Because if you can this easily arbitrarily extend any existing application’s behavior in Windows (or Linux, for that matter) by writing an independent module of such brevity, I’ll eat my socks.
As for hiding the dock, I’m trying it out now, and we’ll see how it goes. Combined with command-tab and the highly recommended, thoroughly brilliant Quicksilver, inboxnce just might seal the deal. So keep it up, Apple. Keep it up.
maxg
Both comments and trackbacks are closed.
Interesting how the more bored you are the better my computing experance becomes.
Is there a reason you are teasing us with some code but not giving us what we need to compile it?
Next step is having it bounce only when there is email it knows I will want to read right away…
David | October 7th, 2004 at 05:50 pm