Annotation of chimera/BookmarksService.h, revision 1.14

1.9       hyatt       1: /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
                      2: /* ***** BEGIN LICENSE BLOCK *****
                      3:  * Version: NPL 1.1/GPL 2.0/LGPL 2.1
1.1       hyatt       4:  *
1.9       hyatt       5:  * The contents of this file are subject to the Netscape Public License
                      6:  * Version 1.1 (the "License"); you may not use this file except in
                      7:  * compliance with the License. You may obtain a copy of the License at
                      8:  * http://www.mozilla.org/NPL/
1.1       hyatt       9:  *
1.9       hyatt      10:  * Software distributed under the License is distributed on an "AS IS" basis,
                     11:  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
                     12:  * for the specific language governing rights and limitations under the
                     13:  * License.
                     14:  *
                     15:  * The Original Code is mozilla.org code.
                     16:  *
                     17:  * The Initial Developer of the Original Code is 
                     18:  * Netscape Communications Corporation.
                     19:  * Portions created by the Initial Developer are Copyright (C) 2002
                     20:  * the Initial Developer. All Rights Reserved.
                     21:  *
                     22:  * Contributor(s):
                     23:  *
                     24:  * Alternatively, the contents of this file may be used under the terms of
                     25:  * either the GNU General Public License Version 2 or later (the "GPL"), or 
                     26:  * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
                     27:  * in which case the provisions of the GPL or the LGPL are applicable instead
                     28:  * of those above. If you wish to allow use of your version of this file only
                     29:  * under the terms of either the GPL or the LGPL, and not to allow others to
                     30:  * use your version of this file under the terms of the NPL, indicate your
                     31:  * decision by deleting the provisions above and replace them with the notice
                     32:  * and other provisions required by the GPL or the LGPL. If you do not delete
                     33:  * the provisions above, a recipient may use your version of this file under
                     34:  * the terms of any one of the NPL, the GPL or the LGPL.
                     35:  *
                     36:  * ***** END LICENSE BLOCK ***** */
1.1       hyatt      37: 
                     38: #include <Appkit/Appkit.h>
                     39: #include <Carbon/Carbon.h>
                     40: #include "nsCOMPtr.h"
                     41: #include "nsIDocument.h"
1.3       hyatt      42: #include "nsIDocumentObserver.h"
1.4       hyatt      43: #include "nsVoidArray.h"
1.7       hyatt      44: #import "MainController.h"
1.12      hyatt      45: #import "BookmarksToolbar.h"
1.1       hyatt      46: 
                     47: class BookmarksService;
                     48: class nsIAtom;
                     49: 
                     50: @interface BookmarksDataSource : NSObject
                     51: {
1.12      hyatt      52:   BookmarksService* mBookmarks;
1.11      hyatt      53: 
1.12      hyatt      54:   IBOutlet id mOutlineView;  
                     55:   IBOutlet id mBrowserWindowController;
                     56:   IBOutlet id mAddButton;  
                     57:   IBOutlet id mDeleteButton;
                     58: 
                     59:   NSString* mCachedHref;
                     60:   nsIContent* mCachedParent;
1.1       hyatt      61: }
                     62: 
                     63: -(id) init;
                     64: -(void) dealloc;
1.4       hyatt      65: -(void) windowClosing;
1.1       hyatt      66: 
                     67: -(void) ensureBookmarks;
1.2       hyatt      68: 
                     69: -(IBAction)addBookmark:(id)aSender;
1.11      hyatt      70: -(void)endAddBookmark: (int)aCode;
                     71: 
1.2       hyatt      72: -(IBAction)deleteBookmark: (id)aSender;
1.1       hyatt      73: 
1.14    ! hyatt      74: -(IBAction)addFolder:(id)aSender;
        !            75: 
        !            76: -(void)addBookmark:(id)aSender useSelection:(BOOL)aSel isFolder:(BOOL)aIsFolder;
1.10      hyatt      77: 
1.1       hyatt      78: // Datasource methods.
                     79: - (id)outlineView:(NSOutlineView *)outlineView child:(int)index ofItem:(id)item;
                     80: - (BOOL)outlineView:(NSOutlineView *)outlineView isItemExpandable:(id)item;
                     81: - (int)outlineView:(NSOutlineView *)outlineView numberOfChildrenOfItem:(id)item;
                     82: - (id)outlineView:(NSOutlineView *)outlineView objectValueForTableColumn:(NSTableColumn *)tableColumn byItem:(id)item;
                     83: - (void)outlineView:(NSOutlineView *)outlineView setObjectValue:(id)object forTableColumn:(NSTableColumn *)tableColumn byItem:(id)item;
                     84: 
1.4       hyatt      85: - (void)reloadDataForItem:(id)item reloadChildren: (BOOL)aReloadChildren;
                     86: 
1.1       hyatt      87: @end
                     88: 
                     89: @interface BookmarkItem : NSObject
                     90: {
1.12      hyatt      91:   nsIContent* mContentNode;
1.1       hyatt      92: }
                     93: 
                     94: -(nsIContent*)contentNode;
                     95: -(void)setContentNode: (nsIContent*)aContentNode;
1.6       hyatt      96: - (id)copyWithZone:(NSZone *)aZone;
1.1       hyatt      97: @end
                     98: 
1.4       hyatt      99: class BookmarksService
1.1       hyatt     100: {
                    101: public:
1.12      hyatt     102:   BookmarksService(BookmarksDataSource* aDataSource);
                    103:   BookmarksService(BookmarksToolbar* aToolbar);
                    104:   virtual ~BookmarksService();
                    105: 
                    106:   void AddObserver();
                    107:   void RemoveObserver();
                    108: 
                    109:   static void BookmarkAdded(nsIContent* aContainer, nsIContent* aChild);
                    110:   static void BookmarkChanged(nsIContent* aItem);
                    111:   static void BookmarkRemoved(nsIContent* aContainer, nsIContent* aChild);
                    112:   
1.3       hyatt     113: public:
1.12      hyatt     114:   static void GetRootContent(nsIContent** aResult);
                    115:   static BookmarkItem* GetWrapperFor(nsIContent* aItem);
                    116:   static void FlushBookmarks();
                    117: 
                    118:   static void ConstructBookmarksMenu(NSMenu* aMenu, nsIContent* aContent);
                    119:   static void OpenMenuBookmark(BrowserWindowController* aController, id aMenuItem);
                    120:   static void AddMenuBookmark(NSMenu* aMenu, nsIContent* aParent, nsIContent* aChild, PRInt32 aIndex);
                    121:   static NSMenu* LocateMenu(nsIContent* aContent);
1.10      hyatt     122: 
1.13      hyatt     123:   static void EnsureToolbarRoot();
1.12      hyatt     124:   
1.1       hyatt     125: private:
1.12      hyatt     126:   // Global counter and pointers to our singletons.
                    127:   static PRUint32 gRefCnt;
                    128: 
                    129:   // A dictionary that maps from content IDs (which uniquely identify content nodes)
                    130:   // to Obj-C bookmarkItem objects.  These objects are handed back to UI elements like
                    131:   // the outline view.
                    132:   static NSMutableDictionary* gDictionary;
                    133:   
1.1       hyatt     134: public:
1.12      hyatt     135:   static MainController* gMainController;
                    136:   static NSMenu* gBookmarksMenu;
1.13      hyatt     137:   static nsIDOMElement* gToolbarRoot;
1.12      hyatt     138:   static nsIAtom* gFolderAtom;
                    139:   static nsIAtom* gNameAtom;
                    140:   static nsIAtom* gHrefAtom;
                    141:   static nsIAtom* gBookmarkAtom;
                    142:   static nsIDocument* gBookmarks;
                    143:   static nsVoidArray* gInstances;
                    144:   
1.4       hyatt     145: private:
1.12      hyatt     146:   // There are three kinds of bookmarks data sources:
                    147:   // tree views (mDataSource), the personal toolbar (mToolbar)
                    148:   // and menus (gBookmarksMenu).
                    149:   BookmarksToolbar* mToolbar;
                    150:   BookmarksDataSource* mDataSource;
1.1       hyatt     151: };

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>