Search code examples
macoscocoaplistmacos-carbonfinder

Add Item to Finder Sidebar


I would like to add a new item to the Finder sidebar. I found out that the Finder keeps the list of "places" in `~/Library/Preferences/com.apple.sidebarlists.plist. I was able to read the file using Carbon API and saw that each item had Name, icon and alias.

Using a 3rd party application such as PlistEdit Pro I was able to update the alias. My question is how to update the alias using Carbon API. Was not able to find a way to create alias that will open in Finder. It seem that both Dropbox and PlistEditor Pro was able to find the way.


Solution

  • Take a look here:

    The Shared File List API is new to Launch Services in Mac OS X Leopard. This API provides access to several kinds of system-global and per-user persistent lists of file system objects, such as recent documents and applications, favorites, and login items. For details, see the new interface file LSSharedFileList.h.

    You want to look for the key kLSSharedFileListFavoriteItems, which handles the items under "Places" in the Sidebar. I guess you could try to do something similar to this, using LSSharedFileListCreate to create kLSSharedFileListFavoriteItems.

    Or you could use the applescript posted here, which would be way easier, but not the "Right Way"©