Annotation of chimera/BookmarksService.h, revision 1.9

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.1       hyatt      45: 
                     46: class BookmarksService;
                     47: class nsIAtom;
                     48: 
                     49: @interface BookmarksDataSource : NSObject
                     50: {
                     51:     BookmarksService* mBookmarks;
                     52:     IBOutlet id mOutlineView;
1.8       hyatt      53:     IBOutlet id mBrowserWindowController;
1.2       hyatt      54:     IBOutlet id mAddButton;
                     55:     IBOutlet id mDeleteButton;
1.1       hyatt      56: }
                     57: 
                     58: -(id) init;
                     59: -(void) dealloc;
1.4       hyatt      60: -(void) windowClosing;
1.1       hyatt      61: 
                     62: -(void) ensureBookmarks;
1.2       hyatt      63: 
                     64: -(IBAction)addBookmark:(id)aSender;
                     65: -(IBAction)deleteBookmark: (id)aSender;
1.1       hyatt      66: 
                     67: // Datasource methods.
                     68: - (id)outlineView:(NSOutlineView *)outlineView child:(int)index ofItem:(id)item;
                     69: - (BOOL)outlineView:(NSOutlineView *)outlineView isItemExpandable:(id)item;
                     70: - (int)outlineView:(NSOutlineView *)outlineView numberOfChildrenOfItem:(id)item;
                     71: - (id)outlineView:(NSOutlineView *)outlineView objectValueForTableColumn:(NSTableColumn *)tableColumn byItem:(id)item;
                     72: - (void)outlineView:(NSOutlineView *)outlineView setObjectValue:(id)object forTableColumn:(NSTableColumn *)tableColumn byItem:(id)item;
                     73: 
1.4       hyatt      74: - (void)reloadDataForItem:(id)item reloadChildren: (BOOL)aReloadChildren;
                     75: 
1.1       hyatt      76: @end
                     77: 
                     78: @interface BookmarkItem : NSObject
                     79: {
                     80:     nsIContent* mContentNode;
                     81: }
                     82: 
                     83: -(nsIContent*)contentNode;
                     84: -(void)setContentNode: (nsIContent*)aContentNode;
1.6       hyatt      85: - (id)copyWithZone:(NSZone *)aZone;
1.1       hyatt      86: @end
                     87: 
1.4       hyatt      88: class BookmarksService
1.1       hyatt      89: {
                     90: public:
1.4       hyatt      91:     BookmarksService(BookmarksDataSource* aDataSource);
1.3       hyatt      92:     virtual ~BookmarksService();
1.1       hyatt      93:     
1.3       hyatt      94:     void AddObserver();
                     95:     void RemoveObserver();
                     96: 
1.4       hyatt      97:     void NotifyObserver(nsIContent* aContainer, PRBool aReloadChildren);
                     98:     static void NotifyObservers(nsIContent* aContainer, PRBool aReloadChildren);
                     99: 
1.3       hyatt     100: public:
1.6       hyatt     101:     static void GetRootContent(nsIContent** aResult);
1.3       hyatt     102:     static BookmarkItem* GetWrapperFor(nsIContent* aItem);
1.5       hyatt     103:     static void FlushBookmarks();
1.1       hyatt     104:     
1.6       hyatt     105:     static void ConstructBookmarksMenu(NSMenu* aMenu, nsIContent* aContent);
1.7       hyatt     106:     static void OpenMenuBookmark(BrowserWindowController* aController, id aMenuItem);
1.6       hyatt     107:     
1.1       hyatt     108: private:
1.3       hyatt     109:     // Global counter and pointers to our singletons.
1.1       hyatt     110:     static PRUint32 gRefCnt;
1.6       hyatt     111:     
                    112:     // A dictionary that maps from content IDs (which uniquely identify content nodes)
                    113:     // to Obj-C bookmarkItem objects.  These objects are handed back to UI elements like
                    114:     // the outline view.
1.3       hyatt     115:     static NSMutableDictionary* gDictionary;
1.7       hyatt     116:         
1.1       hyatt     117: public:
1.7       hyatt     118:     static MainController* gMainController;
1.1       hyatt     119:     static nsIAtom* gFolderAtom;
                    120:     static nsIAtom* gNameAtom;
                    121:     static nsIAtom* gHrefAtom;
                    122:     static nsIAtom* gBookmarkAtom;
1.4       hyatt     123:     static nsIDocument* gBookmarks;
                    124:     static nsVoidArray* gInstances;
1.7       hyatt     125:         
1.4       hyatt     126: private:
                    127:     BookmarksDataSource* mDataSource;
1.1       hyatt     128: };

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