Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do you programmatically put folder icons on the Finder sidebar, given that you have to use a custom icon for the folder?

Am currently working on a project, and though I can add sidebar items by adding to the com.apple.sidebarlists.plist file then restarting Finder, I can't seem to know how to make the folder icons show up using its assigned custom icon.

Can anyone point me to a link or a solution that would make me do this? Thanks a bunch in advance!

like image 577
jopes Avatar asked Jun 30 '09 10:06

jopes


2 Answers

There's no supported way to do this using pure Cocoa. Use the LSSharedFileList API, instead. It's the supported way to manage the sidebar lists, and you can provide a custom icon (as an IconRef from Icon Services) when you insert an item.

like image 142
Peter Hosey Avatar answered Oct 13 '22 20:10

Peter Hosey


I don't know about the icons but I add items to the sidebar using the EBLaunchServices wrapper which is available open source here:

https://github.com/Eric-Bro/EBLaunchServices

It is very easy to use. For instance to add a mounted OSXFUSE volume to the sidebar you call:

NSURL* volumeUrl = [NSURL fileURLWithPath:@"/Volumes/MyVolume"];
[EBLaunchServices addItemWithURL:volumeUrl toList:kLSSharedFileListFavoriteVolumes];
like image 29
codingFriend1 Avatar answered Oct 13 '22 20:10

codingFriend1