Archive for June, 2007

AGShelfView – Mail-esque Split view

Mail and many other programs have been using this new kind of split view for a long while now. It typically has a main content area on the right side and a long table or outline view on the left side with a strip of a handful of buttons to add a new object, perform actions on it, and whatever else. Here’s an example of it seen in Araelium Edit:

AGShelfViewInAE

Writing the code to create this kind of view is fairly trivial if you know what you’re doing, but why bother reinventing the wheel? I give you AGShelfView.

Read more »

AGSidebarView Example

This is an example of how to put together a “Sidebar” like list. Mainly it demonstrates how to make top-level group rows taller than other rows so as to add padding between the groups, while keeping the custom-drawn outline cell (the reveal triangle) properly aligned. Download the project.

AGSidebarView Screenshot

Useful Nib Category Methods

If you’re loading a nib in your code that has a File’s Owner other than NSWindowController (or a subclass), then you (hopefully!) know that you need to release every top level object in the nib. If you use + [NSBundle loadNibNamed:owner:] then you need to create outlets to each of the top level objects, and release them when File’s Owner gets released.

That works fine and dandy if you do it, but if you forget to release a newly-added top level object, or forget to add an outlet to it so that you can release, you’ll leak memory. (That’s bad.) Is there an easy solution? You bet.

Read more »

Find Mac OS X System Images and Icons

Here’s a nifty little command line script to find all system images and icons and display them in an HTML file. View the file with Safari and you’ll be able to see icns icon files as well.

sudo find /System \( -name "*.png" -or -name "*.tiff" -or -name "*.jpg" -or -name "*.mov" -or -name "*.icns" \) | sed -e ’s/\(.*\)/<img src="file:\/\/\1"><\/img><br\/><p>\1<\/p><br\/><br\/>/’ > system_graphics.html

Thanks Ed

#pragma mark for Ruby in TextMate

I (unfortunately in some ways) have to use TextMate for a bunch of Ruby code and it drives me nuts that TextMate’s Ruby bundle doesn’t have a #pragma mark equivalent, so I spent a while trying to figure out how to add one. This works.

1
2
3
4
5
        {   name = 'comment.line.number-sign.ruby';
            match = '(?:^[ \t]+)?(#)(:\s+(.*)$\n?)?(.*$\n?)?';
            captures = { 1 = { name = 'punctuation.definition.comment.ruby'; };
            3 = { name = 'meta.toc-list.pragma-mark.ruby'; }; };
        },