Places:Bookmarks Containers: Difference between revisions

From MozillaWiki
Jump to navigation Jump to search
Line 1: Line 1:
== Introduction ==
== Introduction ==


The new places UI supports heirarchical 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.
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 ==
== Creating your own Bookmarks Container ==

Revision as of 15:34, 30 January 2006

Introduction

The new places UI supports hierarchical 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.