Finder view; [small icon with filenames] in launch services database?

I simply want to create my own finder browser interface in 10.5. Simple enough with ‘filenames’ only. But where do I get the custom [small] icons? Getting properties will return {file type:“???”, creator type:“???”, icon: missing value}. I don’t understand why the icon doesn’t contain a reference.

I’ve read through the forums and read that the icon [ref] is stored in the launch services database, but I do not know if the icon can be obtained through applescript / studio, or if it will be fast enough. Is there AS studio example for a finder browser WITH ICONS out there somewhere? I’ll even take a cocoa example if it’s not to complicated…

Thanks tons in advance. I’ve never been able to do this before.


Using the sample code provided by apple (‘/Developer/Examples/Applescript Studio/Browser/’), you can add just a few lines of applescript code and one basic obj-c method. I edited the ‘will display browser cell’ handler and commented the necessary additions.

on will display browser cell theObject row theRow browser cell theCell in column theColumn
	set iconPath to "" --> Added
	if theColumn > 1 then
		tell browser "browser" of window "main"
			set thePath to path for column theColumn
		end tell
	end if
	tell application "Finder"
		if theColumn is 1 then
			set cellContents to displayed name of disk (item theRow of diskNames as string)
			set isLeaf to false
			set iconPath to cellContents --> Added
			set theItem to item theRow of item thePath
			if class of theItem is folder or class of theItem is disk then
				set isLeaf to false
				set isLeaf to true
			end if
			set cellContents to (displayed name of theItem as string)

			set iconPath to ((theItem as alias) as string) --> Added
		end if
	end tell
	set string value of theCell to cellContents
	set leaf of theCell to isLeaf
	(* Try to add an icon *)
		set imagePath to ((POSIX path of iconPath) as string)
		call method "setIconForFile:inCell:" of class "BCController" with parameters {imagePath, theCell}
	end try
end will display browser cell

Then, create a custom subclass (I called mine “BCController”) of nsobject to hold your custom method. You could also add this method to any other controller class you may already be using.

“WOW! It worked right out of the box!” :slight_smile:

That will make navigation MUCH easier, and files MUCH more identifiable.

Note: I did have some trouble with IB 3.0. I haven’t subclassed with IB 3.0 yet. I ended up creating the files elsewhere and “Adding existing files…”. Where is “Create files” menu item like in previous version of IB?

Many thanks.