Places:Bookmarks Containers: Difference between revisions

From MozillaWiki
Jump to navigation Jump to search
No edit summary
Line 7: Line 7:
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 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 folder.  To delete children, you can use the removeItem(), removeFolder(), and removeFolder() children methods of nsINavBookmarksService.
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 ==
== 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.
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.

Revision as of 02:20, 16 December 2005

Introduction

The new places UI supports heirarchical bookmarks through specialized tree, menu, and toolbar views. In a web browser, it's likely that other collections of links and titles besides bookmarks could make use of the same views. live bookmarks and 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 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 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.