Diff for /chimera/BookmarksService.mm between versions 1.11 and 1.15

version 1.11, 2002/02/11 10:23:03 version 1.15, 2002/03/07 03:18:55
Line 85 Line 85
                             getter_AddRefs(elt));                              getter_AddRefs(elt));
           
     // Fetch the title of the current page and the URL.      // Fetch the title of the current page and the URL.
    nsCOMPtr<nsIWebBrowser> webBrowser = getter_AddRefs([[mBrowserView getBrowserView] getWebBrowser]);    nsCOMPtr<nsIWebBrowser> webBrowser = getter_AddRefs([[[mBrowserWindowController getMyBrowserView] getBrowserView] getWebBrowser]);
     nsCOMPtr<nsIDOMWindow> window;      nsCOMPtr<nsIDOMWindow> window;
     webBrowser->GetContentDOMWindow(getter_AddRefs(window));      webBrowser->GetContentDOMWindow(getter_AddRefs(window));
     nsCOMPtr<nsIDOMDocument> htmlDoc;      nsCOMPtr<nsIDOMDocument> htmlDoc;
Line 96 Line 96
     if (pageDoc) {      if (pageDoc) {
         nsCOMPtr<nsIURI> url;          nsCOMPtr<nsIURI> url;
         pageDoc->GetDocumentURL(getter_AddRefs(url));          pageDoc->GetDocumentURL(getter_AddRefs(url));
        nsXPIDLCString spec;        nsCAutoString spec;
        url->GetSpec(getter_Copies(spec));        url->GetSpec(spec);
         href.AssignWithConversion(spec.get());          href.AssignWithConversion(spec.get());
     }      }
           
Line 167 Line 167
         if (!href.IsEmpty()) {          if (!href.IsEmpty()) {
             nsCAutoString cstr; cstr.AssignWithConversion(href);              nsCAutoString cstr; cstr.AssignWithConversion(href);
             NSString* url = [NSString stringWithCString: cstr.get()];              NSString* url = [NSString stringWithCString: cstr.get()];
            [[mBrowserView getBrowserView] loadURI:[NSURL URLWithString: url] flags:NSLoadFlagsNone];            [[[mBrowserWindowController getMyBrowserView] getBrowserView] loadURI:[NSURL URLWithString: url] flags:NSLoadFlagsNone];
         }          }
     }       } 
 }  }
Line 227 Line 227
   
 - (id)outlineView:(NSOutlineView *)outlineView objectValueForTableColumn:(NSTableColumn *)tableColumn byItem:(id)item  - (id)outlineView:(NSOutlineView *)outlineView objectValueForTableColumn:(NSTableColumn *)tableColumn byItem:(id)item
 {  {
       NSString                                    *columnName = [tableColumn identifier];
     NSMutableAttributedString   *cellValue = [[NSMutableAttributedString alloc] init];      NSMutableAttributedString   *cellValue = [[NSMutableAttributedString alloc] init];
       NSFileWrapper                               *fileWrapper = [[NSFileWrapper alloc] initRegularFileWithContents:nil];
       NSTextAttachment                    *textAttachment = [[NSTextAttachment alloc] initWithFileWrapper:fileWrapper];
     NSMutableAttributedString   *attachmentAttrString = nil;      NSMutableAttributedString   *attachmentAttrString = nil;
    NSString                                    *columnName = [tableColumn identifier];    NSCell                                              *attachmentAttrStringCell;
    NSCell                                              *attachmentCell; 
   
    if ( item ) {    if ([columnName isEqualToString: @"name"]) {
        NSLog(@"%@", item);        nsIContent* content = [item contentNode];
        if ([columnName isEqualToString: @"name"]) {        nsAutoString nameAttr;
            nsIContent* content = [item contentNode];        content->GetAttr(kNameSpaceID_None, BookmarksService::gNameAtom, nameAttr);
            nsAutoString nameAttr;        nsCAutoString cStr; cStr.AssignWithConversion(nameAttr);
            content->GetAttr(kNameSpaceID_None, BookmarksService::gNameAtom, nameAttr);        
            nsCAutoString cStr; cStr.AssignWithConversion(nameAttr);        //Set cell's textual contents
                    [cellValue replaceCharactersInRange:NSMakeRange(0, [cellValue length])
        //set cell's textual contents                                 withString:[NSString stringWithCString: cStr.get()]];
            [cellValue replaceCharactersInRange:NSMakeRange(0, [cellValue length])        
                                     withString:[NSString stringWithCString: cStr.get()]];        //Create an attributed string to hold the empty attachment, then release the components.
                    attachmentAttrString = [[NSMutableAttributedString attributedStringWithAttachment:textAttachment] retain];
        //Add image to cell's text in front of the text.        [textAttachment release];
            NSFileWrapper *wrapper = [[NSFileWrapper alloc] initRegularFileWithContents:nil];        [fileWrapper release];
            NSTextAttachment *attachment = [[NSTextAttachment allocWithZone:NULL] initWithFileWrapper:wrapper];
            attachmentAttrString = [[NSMutableAttributedString attributedStringWithAttachment:attachment] retain];        //Get the cell of the text attachment.
            [attachment release];        attachmentAttrStringCell = (NSCell *)[(NSTextAttachment *)[attachmentAttrString attribute:NSAttachmentAttributeName
            [wrapper release];                                                                                          atIndex:0
                                                                                   effectiveRange:nil] attachmentCell];
            attachmentCell = (NSCell *)[(NSTextAttachment *)[attachmentAttrString attribute:NSAttachmentAttributeName        //Figure out which image to add, and set the cell's image.
                                                                                    atIndex:0        if ( [self outlineView:outlineView isItemExpandable:item] ) {
                                                                             effectiveRange:NULL] attachmentCell];            [attachmentAttrStringCell setImage:[NSImage imageNamed:@"folder"]];
        } else {
            [attachmentCell setImage:[NSImage imageNamed:@"folder"]];            [attachmentAttrStringCell setImage:[NSImage imageNamed:@"smallDocument"]];
            [cellValue replaceCharactersInRange:NSMakeRange(0, 0) withAttributedString:attachmentAttrString]; 
            [cellValue addAttribute:NSBaselineOffsetAttributeName 
                              value:[NSNumber numberWithFloat:-3.0] 
                              range:NSMakeRange(0, 1)]; 
        //Done adding image 
         }          }
        return cellValue;        //Insert the image
    } else {        [cellValue replaceCharactersInRange:NSMakeRange(0, 0) withAttributedString:attachmentAttrString];
        return nil;        
         //Tweak the baseline to vertically center the text.
         [cellValue addAttribute:NSBaselineOffsetAttributeName
                           value:[NSNumber numberWithFloat:-3.0]
                           range:NSMakeRange(0, 1)];
     }      }
       return cellValue;
 }  }
   
 - (void)outlineView:(NSOutlineView *)outlineView setObjectValue:(id)object forTableColumn:(NSTableColumn *)tableColumn byItem:(id)item  - (void)outlineView:(NSOutlineView *)outlineView setObjectValue:(id)object forTableColumn:(NSTableColumn *)tableColumn byItem:(id)item
Line 428  BookmarksService::AddObserver() Line 430  BookmarksService::AddObserver()
         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");
           
        nsXPIDLCString bookmarksFileURL;        nsCAutoString bookmarksFileURL;
        NS_GetURLSpecFromFile(profileDir, getter_Copies(bookmarksFileURL));        NS_GetURLSpecFromFile(profileDir, bookmarksFileURL);
                   
         nsCOMPtr<nsIURI> uri;          nsCOMPtr<nsIURI> uri;
         NS_NewURI(getter_AddRefs(uri), bookmarksFileURL.get());          NS_NewURI(getter_AddRefs(uri), bookmarksFileURL.get());

Removed from v.1.11  
changed lines
  Added in v.1.15


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