Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Adding badges to file icons in Finder

I'm working on a small project at home that would add a badge (aka icon overlay) to a specific file based on its state. Anyway, I've Googled the hell out of it and the only documentation I was able to find was on Apple's developers site (Obtaining and Using Icons With Icon Services).

The documentation expects the developer to be familiar with Objective-C file APIs, which I'm not. So, I'm wondering if someone can please give me some code examples for adding badges to a file and directory. Thanks in advance!!

like image 597
hishboy Avatar asked Aug 09 '09 07:08

hishboy


People also ask

How do I create a custom folder icon on Mac?

On your Mac, select the file or folder. Choose File > Get Info in the menu bar. At the top of the Info window, select the small custom icon.

How do I change app icons on Mac?

After pulling up Finder > Applications, find the app you'd like to change the icon for. Right click and select Get Info or use the keyboard shortcut command + I. Now just drag the new image you want to use on top of the existing icon (you can also copy the new image then paste it onto the existing icon).

How do you change a folder icon to a picture?

To do this: Right-click the folder that you want to create a shortcut to, and then click Create Shortcut. Right-click the shortcut you created, click Properties, and then click Change Icon. Click the picture of the icon you would like the shortcut to use, click OK, and then click OK.

Where are Mac icons stored?

If you're the curious type, you might want to take a peek at Mac OS X's system icons. The system icons bundle, found in the /System/Library/CoreServices directory, stores about 140 icons. Start by opening a Terminal window, then change directories to /System/Library/CoreServices/SystemIcons. bundle/Contents/Resources.


3 Answers

How about diving into the sources of SCPlugin. I believe they are doing something that works. The code is here http://scplugin.tigris.org/svn/scplugin/trunk, login with "guest" and no password. I won't say it's easy...

alt text
(source: tigris.org)

like image 118
epatel Avatar answered Sep 24 '22 20:09

epatel


The link you posted to is for the Carbon (pre-MacOSX) API. Whilst it might work in the Carbon finder of 10.5, the Finder in 10.6 is pure Cocoa and as a result of which might not support the concept of badges in that regard.

You can add badges to an application in the dock with NSDockTile but you won't have much luck in documents for applications on the whole. You'd either need to monitor the documents through some other mechanism and then use, say, a QuickLook plugin to generate a miniaturized view with whatever your state happens to be.

Failing that, you could write your own view for the documents (in which you could add such information) rather than using Finder.

like image 2
AlBlue Avatar answered Sep 20 '22 20:09

AlBlue


The Finder in 10.6 can be hack with a SIMBL plugin , you just have to use the swizzling method to reimplement the drawWithFrame method in the Finder.

like image 2
kavaliero Avatar answered Sep 21 '22 20:09

kavaliero