Leopard AppKit additions

Leopard just arrived this morning (TNT messed up yesterday) and thus far I’m loving it. Time Machine is in the process of performing its initial backup, so I’ll reserve judgement on speed until later, but the UI feels extremely responsive even with the backup going on.

Anyway, to the point of this post. I’ve briefly looked over the new developer documentation and have uncovered the following gems:

NSGradient
Looks like CTGradient won’t be necessary anymore, as Apple has added an NSGradient class to AppKit. This move is extremely welcome if long overdue — creating gradients previously involved a whole mess of core graphics shading calls (or using CTGradient).

NSCollectionView
Renamed from NSGridView in the developer seeds, NSCollectionView has apparently “been added to facilitate interesting animations”. I would have said it’s been added to display a collection of objects, but motives aside, this is really great AppKit addition, allowing for straightforward creation of iPhoto-style grids of basically anything you want. Each item in the grid is (unsurprisingly) an NSCollectionViewItem, created from a prototype view containing anything that knows how to draw itself, for example, an NSImageView and an NSTextField combined together in an NSBox.

NSRuleEditor and NSPredicatedEditor
NSPredicateEditor is a pre-built “criteria-builder” for things like smart folders:
predicate_editor.png
This ties into bindings and looks massively powerful.

HUD style windows
The head-up display style windows as found in iLife, iWork and now QuickLook are now a standard option of NSPanel, exposed in Interface Builder.

NSPathControl
Awesome. A standard control for showing file paths, probably powering the Finder’s “bread-crumb trail”:
path_control.png

NSToolbar enhancements
NSToolbars can now be edited directly in InterfaceBuilder!

NSSplitView enhancements
Loads of (overdue) improvements to NSSplitView, including divider-position-and-subview-collapse-autosave, the addition of -setDividerStyle: (for thick or thin dividers), programmatic subview collapse, easier double-click-view-collapse support, the ability to hide the divider when a subview is completely collapsed and a beautiful host of bug fixes.

Accessory views in NSAlert
NSAlert now supports the straightforward addition of a suppression checkbox (i.e. a “Do not show me this message again” option) and a -setAccessoryView: method for, surprisingly, adding an accessory view.

NSDockTile
-setBadgeLabel: and -setContentView: support for NSApplication AND NSWindow (for either the app or minimised windows)!

There is just so much new stuff, I can’t wait to get properly stuck in!

Printing in Leopard

Printing is not the most sexy of tasks, but Apple has paid a great deal of attention to printing in Leopard. Understandably, most of the new printing features have gone unnoticed by the mainstream press, overshadowed by Time Machine, Quick Look and Spaces.

The Common UNIX Printing System (CUPS)
The open source CUPS project was introduced as the underlying printing system in Mac OS X 10.2 (Jaguar). In a slightly surprising move, Apple acquired the open source CUPS project and hired its main developer, Michael Sweet, in February of this year.

No surprise, then, that CUPS in Leopard has been brought bang up-to-date, moving from version 1.1 in Tiger to version 1.3. The increase in version brings a range of new features, including:

  • An overhauled web interface (found at localhost:631), which adds printer searching, many admin options and more-consistent interface
  • Support for launchd — cupsd is now launched on demand
  • Thread-safety — in-keeping with Apple’s focus on multicore optimisations, the entire CUPS API is now thread-safe
  • IPv6 support
  • 16-bit per channel colour on supported devices
  • Greater support for IPP, including IPP notifications
  • Printer sharing via LDAP v3, optionally with SSL (I’m not sure if this is exposed in System Preferences, but it’s definitely there under-the-hood)
  • Greatly improved security and authentication, including Kerberos authentication, complete support for the Mac OS X Authorization Services framework and awareness of POSIX ACLs
  • Command line configuration from the new cupsctl command

And this list barely scratches the surface – printing in Leopard really is massively improved.

New print dialogs
This was mentioned in MacWorld’s ten overlooked Leopard gems and rightly so; Leopard finally brings navigable print-previews and page orientation settings to the print dialog box:
leopard-print-preview.png

Miscellany
Leopard also adds “Location-Aware Printing”, which will automatically set the default printer based, presumably, on the currently available network. And finally, Apple will be distributing third-party printer drivers through Software Update from Leopard onwards.

Some critics have (in my opinion, inaccurately) commented that Leopard focusses too much on eye-candy and visual superfluities. That clearly isn’t the case with printing, which has seen massive under-the-hood improvements in addition to some highly functional improvements to the user interface.

Leopard-mas Eve

‘Twas the night before Leopard, when all round the globe
People were waiting for DTrace and Xcode;

The reviews had been written by Pogue and by Walt,
Leopard looks great, with nary a fault;

But for me, the real power lies under the hood,
ImageKit, Ruby and other such goods;

Leopard’s looking like a developer’s dream,
Now UNIX certified, it’s the OS supreme.

But on a less poetic note, as a new OS X developer with no access to the pre-release seeds, I am massively excited about delving into the new goodness to be found at all levels of Leopard.

I think Pogue, Mossberg and others have already covered the majority of “user” additions to Leopard fairly comprehensively, but what about the changes from a developers perspective?

I’ve already written at quite some length on a number of the new developer additions in Leopard, including things like the scripting bridge, Objective-C 2.0 with garbage collection, new XCode and Interface Builder, PDFKit, ImageKit, the QTKit capture APIs, NSGridView and pervasive 64-bitness. Then there’s more features that I didn’t mention in that last article like DTrace, MPI, Ruby (including rails, Mongrel and Capistrano), new IOStream classes, NSOperation and NSOperationQueue and the list goes on. But what excites me most is the fact that there are yet more developer-related goodies that Apple hasn’t made public.

I’m aware of two of those goodies through people who have broken their NDAs: NSRuleEditor and an off-the-shelf CoverFlow view (most probably NSCoverFlowView). NSRuleEditor provides a view like those found in iTunes and Mail for selecting smart folder/playlist criteria that will presumably form an NSPredicate based on what the user selects. The CoverFlow is fairly self-explanatory. With two such powerful (but secret) additions to the OS X developer toolkit, it makes me wonder what other awesomeness we’re in store for tomorrow… 22 hours and 30 minutes to go!