Places:Bookmarks Containers: Difference between revisions

From MozillaWiki
Jump to navigation Jump to search
(Replacing page with 'Please refer to: https://developer.mozilla.org/en/Manipulating_bookmarks_using_Places')
 
Line 1: Line 1:
== Introduction ==
Please refer to: https://developer.mozilla.org/en/Manipulating_bookmarks_using_Places
 
The new places UI supports hierarchical bookmarks through specialized tree, menu, and toolbar [[Places:Design_Overview#Views|views]].  In a web browser, it's likely that other collections of links and titles besides bookmarks could make use of the same views.  [[Places:Live_Bookmarks|live bookmarks]] and [[Places:File_System_Container|file system folders]] are examples.  Bookmarks Containers make that possible.
 
== Creating your own Bookmarks Container ==
 
You can make your own bookmarks container by implementing the [http://lxr.mozilla.org/seamonkey/source/browser/components/places/public/nsIBookmarksContainer.idl nsIBookmarksContainer] interface.  Your containers will be implemented as bookmark folders, and you'll get notifications when they are opened, closed, deleted, or moved.
 
You can add new containers through the createContainer() method of [http://lxr.mozilla.org/seamonkey/source/browser/components/places/public/nsINavBookmarksService.idl nsINavBookmarksService].  This method returns a container id that your opened, closed, deleted, and moved notifications will refer to.  To add children to your container, use the insertItem(), setItemTitle(), and createFolder() methods of nsINavBookmarksService, using the container id as the parent folder.  To delete children, you can use the removeItem(), removeFolder(), and removeFolder() children methods of nsINavBookmarksService.
 
== How Bookmarks Containers are Implemented ==
 
Bookmarks containers are normal bookmarks folders with a folderType string that contains the contract id of the class that created them.  When places opens, closes, moves or deletea one of these folders, it sends a notification to the class with the given contract id.  That way the class can update the contents of the folder and do any bookkeeping necessary.

Latest revision as of 19:23, 2 March 2009