Diff for /chimera/BookmarksService.mm between versions 1.28 and 1.32

version 1.28, 2002/04/19 19:28:43 version 1.32, 2002/04/20 01:20:53
Line 58 Line 58
   
 -(id) init  -(id) init
 {  {
    [super init];    if ( (self = [super init]) ) {
    mBookmarks = nsnull;        mBookmarks = nsnull;
    mCachedHref = nil;        mCachedHref = nil;
     }
     return self;      return self;
 }  }
   
Line 314 Line 315
   
 -(IBAction)openBookmark: (id)aSender  -(IBAction)openBookmark: (id)aSender
 {  {
    int index = [mOutlineView selectedRow];  int index = [mOutlineView selectedRow];
    if (index == -1)  if (index == -1)
        return;    return;
    
    id item = [mOutlineView itemAtRow: index];  id item = [mOutlineView itemAtRow: index];
    if (!item)  if (!item)
        return;    return;
        
    if ([mOutlineView isExpandable: item]) {  nsIContent* content = [item contentNode];
        if ([mOutlineView isItemExpanded: item])  nsCOMPtr<nsIDOMElement> elt(do_QueryInterface(content));
            [mOutlineView collapseItem: item];  nsAutoString group;
        else  elt->GetAttribute(NS_LITERAL_STRING("group"), group);
            [mOutlineView expandItem: item];  if (!group.IsEmpty())
     mBookmarks->OpenBookmarkGroup([mBrowserWindowController getTabBrowser], elt);
   else if ([mOutlineView isExpandable: item]) {
     if ([mOutlineView isItemExpanded: item])
       [mOutlineView collapseItem: item];
     else
       [mOutlineView expandItem: item];
   }
   else {
     nsAutoString href;
     content->GetAttr(kNameSpaceID_None, BookmarksService::gHrefAtom, href);
     if (!href.IsEmpty()) {
       nsCAutoString cstr; cstr.AssignWithConversion(href);
       NSString* url = [NSString stringWithCString: cstr.get()];
       [[[mBrowserWindowController getMyBrowserView] getBrowserView] loadURI:[NSURL URLWithString: url] flags:                   NSLoadFlagsNone];
       // Focus and activate our content area.
       [[[mBrowserWindowController getMyBrowserView] getBrowserView] setActive: YES];
     }      }
    else {  }
        nsIContent* content = [item contentNode]; 
        nsAutoString href; 
        content->GetAttr(kNameSpaceID_None, BookmarksService::gHrefAtom, href); 
        if (!href.IsEmpty()) { 
            nsCAutoString cstr; cstr.AssignWithConversion(href); 
            NSString* url = [NSString stringWithCString: cstr.get()]; 
            [[[mBrowserWindowController getMyBrowserView] getBrowserView] loadURI:[NSURL URLWithString: url] flags:NSLoadFlagsNone]; 
            // Focus and activate our content area. 
            [[[mBrowserWindowController getMyBrowserView] getBrowserView] setActive: YES]; 
        } 
    }  
 }  }
   
 - (BOOL)outlineView:(NSOutlineView *)outlineView shouldEditTableColumn:(NSTableColumn *)tableColumn item:(id)item  - (BOOL)outlineView:(NSOutlineView *)outlineView shouldEditTableColumn:(NSTableColumn *)tableColumn item:(id)item
Line 424 Line 430
                                                                                           atIndex:0                                                                                            atIndex:0
                                                                                    effectiveRange:nil] attachmentCell];                                                                                     effectiveRange:nil] attachmentCell];
         //Figure out which image to add, and set the cell's image.          //Figure out which image to add, and set the cell's image.
           // XXXdwh Use the bookmark groups image for groups.
         if ( [self outlineView:outlineView isItemExpandable:item] ) {          if ( [self outlineView:outlineView isItemExpandable:item] ) {
             [attachmentAttrStringCell setImage:[NSImage imageNamed:@"folder"]];              [attachmentAttrStringCell setImage:[NSImage imageNamed:@"folder"]];
         } else {          } else {
Line 906  BookmarksService::AddMenuBookmark(NSMenu Line 913  BookmarksService::AddMenuBookmark(NSMenu
   nsCOMPtr<nsIAtom> tagName;    nsCOMPtr<nsIAtom> tagName;
   aChild->GetTag(*getter_AddRefs(tagName));    aChild->GetTag(*getter_AddRefs(tagName));
   
  if (tagName == gFolderAtom) {  nsAutoString group;
   nsCOMPtr<nsIDOMElement> elt(do_QueryInterface(aChild));
   elt->GetAttribute(NS_LITERAL_STRING("group"), group);
   
   if (group.IsEmpty() && tagName == gFolderAtom) {
     NSMenu* menu = [[[NSMenu alloc] initWithTitle: title] autorelease];      NSMenu* menu = [[[NSMenu alloc] initWithTitle: title] autorelease];
     [aMenu setSubmenu: menu forItem: menuItem];      [aMenu setSubmenu: menu forItem: menuItem];
     [menu setAutoenablesItems: NO];      [menu setAutoenablesItems: NO];
Line 925  BookmarksService::AddMenuBookmark(NSMenu Line 936  BookmarksService::AddMenuBookmark(NSMenu
 void   void 
 BookmarksService::OpenMenuBookmark(BrowserWindowController* aController, id aMenuItem)  BookmarksService::OpenMenuBookmark(BrowserWindowController* aController, id aMenuItem)
 {  {
    // Get the corresponding bookmark item.  // Get the corresponding bookmark item.
    BookmarkItem* item = [gDictionary objectForKey: [NSNumber numberWithInt: [aMenuItem tag]]];  BookmarkItem* item = [gDictionary objectForKey: [NSNumber numberWithInt: [aMenuItem tag]]];
        
    // Get the content node.  // Get the content node.
    nsIContent* content = [item contentNode];  nsIContent* content = [item contentNode];
          nsCOMPtr<nsIDOMElement> elt(do_QueryInterface(content));
    // Get the href attribute.  This is the URL we want to load.  nsAutoString group;
    nsAutoString href;  elt->GetAttribute(NS_LITERAL_STRING("group"), group);
    content->GetAttr(kNameSpaceID_None, gHrefAtom, href);  if (!group.IsEmpty())
    nsCAutoString cref; cref.AssignWithConversion(href);    return OpenBookmarkGroup([aController getTabBrowser], elt);
    if (cref.IsEmpty())  
        return;  // Get the href attribute.  This is the URL we want to load.
          nsAutoString href;
    NSString* url = [NSString stringWithCString: cref.get()];  content->GetAttr(kNameSpaceID_None, gHrefAtom, href);
      nsCAutoString cref; cref.AssignWithConversion(href);
    // Now load the URL in the window.  if (cref.IsEmpty())
    [aController loadURL:[NSURL URLWithString: url]];    return;
 
   NSString* url = [NSString stringWithCString: cref.get()];
 
   // Now load the URL in the window.
   [aController loadURL:[NSURL URLWithString: url]];
 
   // Focus and activate our content area.
   [[[aController getMyBrowserView] getBrowserView] setActive: YES];
 }
 
 void
 BookmarksService::OpenBookmarkGroup(id aTabView, nsIDOMElement* aFolder)
 {
   // We might conceivably have to make new tabs in order to load all
   // the items in the group.
   int currentIndex = 0;
   int total = [aTabView numberOfTabViewItems];
   nsCOMPtr<nsIDOMNode> child;
   aFolder->GetFirstChild(getter_AddRefs(child));
   while (child) {
     nsCOMPtr<nsIDOMElement> elt(do_QueryInterface(child));
     if (elt) {
       nsAutoString href;
       elt->GetAttribute(NS_LITERAL_STRING("href"), href);
       if (!href.IsEmpty()) {
         nsCAutoString cref; cref.AssignWithConversion(href);
         NSString* url = [NSString stringWithCString: cref.get()];
         NSTabViewItem* tabViewItem = nil;
         if (currentIndex >= total) {
           // We need to make a new tab.
           tabViewItem = [[[NSTabViewItem alloc] initWithIdentifier: nil] autorelease];
           MyBrowserView* newView = [[[MyBrowserView alloc] initWithTab: tabViewItem andWindow: [aTabView window]] autorelease];
           [tabViewItem setLabel: @"Untitled"];
           [tabViewItem setView: newView];
           [aTabView addTabViewItem: tabViewItem];
         }
         else
           tabViewItem = [aTabView tabViewItemAtIndex: currentIndex];
 
         [[[tabViewItem view] getBrowserView] loadURI:[NSURL URLWithString: url]
                                                flags: NSLoadFlagsNone];
       }
     }
           
     // Focus and activate our content area.  
     [[[aController getMyBrowserView] getBrowserView] setActive: YES];  
 }  
   
       nsCOMPtr<nsIDOMNode> temp = child;
       temp->GetNextSibling(getter_AddRefs(child));
       currentIndex++;
     }
   
     // Select and activate the first tab.
     [aTabView selectTabViewItemAtIndex: 0];
     [[[[aTabView tabViewItemAtIndex: 0] view] getBrowserView] setActive: YES];
   }

Removed from v.1.28  
changed lines
  Added in v.1.32


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