Diff for /chimera/BookmarksService.mm between versions 1.6 and 1.8

version 1.6, 2002/02/09 20:31:06 version 1.8, 2002/02/10 00:29:08
Line 69 Line 69
     nsCOMPtr<nsIContent> content;      nsCOMPtr<nsIContent> content;
     int index = [mOutlineView selectedRow];      int index = [mOutlineView selectedRow];
         
    if (index > 0) {    if (index >= 0) {
         BookmarkItem* item = [mOutlineView itemAtRow: index];          BookmarkItem* item = [mOutlineView itemAtRow: index];
         if ([mOutlineView isExpandable: item])           if ([mOutlineView isExpandable: item]) 
             content = [item contentNode];              content = [item contentNode];
Line 263 Line 263
 {  {
     mContentNode = aContentNode;      mContentNode = aContentNode;
 }  }
   
   - (id)copyWithZone:(NSZone *)aZone
   {
       BookmarkItem* copy = [[[self class] allocWithZone: aZone] init];
       [copy setContentNode: mContentNode];
       return copy;
   }
   
 @end  @end
   
 // Helper for stripping whitespace  // Helper for stripping whitespace
Line 293  StripWhitespaceNodes(nsIContent* aElemen Line 301  StripWhitespaceNodes(nsIContent* aElemen
 PRUint32 BookmarksService::gRefCnt = 0;  PRUint32 BookmarksService::gRefCnt = 0;
 nsIDocument* BookmarksService::gBookmarks = nsnull;  nsIDocument* BookmarksService::gBookmarks = nsnull;
 NSMutableDictionary* BookmarksService::gDictionary = nil;  NSMutableDictionary* BookmarksService::gDictionary = nil;
   MainController* BookmarksService::gMainController = nil;
 nsIAtom* BookmarksService::gFolderAtom = nsnull;  nsIAtom* BookmarksService::gFolderAtom = nsnull;
 nsIAtom* BookmarksService::gBookmarkAtom = nsnull;  nsIAtom* BookmarksService::gBookmarkAtom = nsnull;
 nsIAtom* BookmarksService::gHrefAtom = nsnull;  nsIAtom* BookmarksService::gHrefAtom = nsnull;
Line 384  BookmarksService::AddObserver() Line 393  BookmarksService::AddObserver()
         gNameAtom = NS_NewAtom("name");          gNameAtom = NS_NewAtom("name");
         gHrefAtom = NS_NewAtom("href");          gHrefAtom = NS_NewAtom("href");
         gInstances = new nsVoidArray();          gInstances = new nsVoidArray();
                        
         nsCOMPtr<nsIFile> profileDir;          nsCOMPtr<nsIFile> profileDir;
         NS_GetSpecialDirectory(NS_APP_USER_PROFILE_50_DIR, getter_AddRefs(profileDir));          NS_GetSpecialDirectory(NS_APP_USER_PROFILE_50_DIR, getter_AddRefs(profileDir));
         profileDir->Append("bookmarks.xml");          profileDir->Append("bookmarks.xml");
Line 440  BookmarksService::FlushBookmarks() Line 449  BookmarksService::FlushBookmarks()
     nsCOMPtr<nsIDOMSerializer> domSerializer(do_CreateInstance(NS_XMLSERIALIZER_CONTRACTID));      nsCOMPtr<nsIDOMSerializer> domSerializer(do_CreateInstance(NS_XMLSERIALIZER_CONTRACTID));
     domSerializer->SerializeToStream(domDoc, outputStream, nsnull);      domSerializer->SerializeToStream(domDoc, outputStream, nsnull);
 }  }
   
   void
   BookmarksService::ConstructBookmarksMenu(NSMenu* aMenu, nsIContent* aContent)
   {
       nsCOMPtr<nsIContent> content = aContent;
       if (!content) {
           GetRootContent(getter_AddRefs(content));
           GetWrapperFor(content);
       }
       
       // Now walk our children, and for folders also recur into them.
       PRInt32 childCount;
       content->ChildCount(childCount);
       
       for (PRInt32 i = 0; i < childCount; i++) {
           nsCOMPtr<nsIContent> child;
           content->ChildAt(i, *getter_AddRefs(child));
           
           // Obtain our name attribute.
           nsAutoString name;
           child->GetAttr(kNameSpaceID_None, gNameAtom, name);
           nsCAutoString nameCStr; nameCStr.AssignWithConversion(name);
           NSString* title = [NSString stringWithCString: nameCStr.get()];
                   
           // Create a menu or menu item for the child.
           NSMenuItem* menuItem = [[[NSMenuItem alloc] initWithTitle: title action: NULL keyEquivalent: @""] autorelease];
           GetWrapperFor(child);
           [aMenu addItem: menuItem];
           
           nsCOMPtr<nsIAtom> tag;
           child->GetTag(*getter_AddRefs(tag));
           
           if (tag == gFolderAtom) {
               NSMenu* menu = [[[NSMenu alloc] initWithTitle: title] autorelease];
               [aMenu setSubmenu: menu forItem: menuItem];
               [menu setAutoenablesItems: NO];
               ConstructBookmarksMenu(menu, child);
           }
           else {
               [menuItem setTarget: gMainController];
               [menuItem setAction: @selector(openMenuBookmark:)];
           }
           
           PRUint32 contentID;
           child->GetContentID(&contentID);
           [menuItem setTag: contentID];
       }
   }
   
   void 
   BookmarksService::OpenMenuBookmark(BrowserWindowController* aController, id aMenuItem)
   {
       // Get the corresponding bookmark item.
       BookmarkItem* item = [gDictionary objectForKey: [NSNumber numberWithInt: [aMenuItem tag]]];
           
       // Get the content node.
       nsIContent* content = [item contentNode];
           
       // Get the href attribute.  This is the URL we want to load.
       nsAutoString href;
       content->GetAttr(kNameSpaceID_None, gHrefAtom, href);
       nsCAutoString cref; cref.AssignWithConversion(href);
       if (cref.IsEmpty())
           return;
           
       NSString* url = [NSString stringWithCString: cref.get()];
       
       // Now load the URL in the window.
       [aController loadURL:[NSURL URLWithString: url]];
   }
   

Removed from v.1.6  
changed lines
  Added in v.1.8


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