Diff for /chimera/BookmarksButton.mm between versions 1.2 and 1.7

version 1.2, 2002/04/17 08:31:11 version 1.7, 2002/04/17 23:16:53
Line 8 Line 8
   
 #import "BookmarksButton.h"  #import "BookmarksButton.h"
 #include "nsIDOMElement.h"  #include "nsIDOMElement.h"
   #include "nsIContent.h"
 #include "nsString.h"  #include "nsString.h"
   #import "BookmarksService.h"
   
 @implementation BookmarksButton  @implementation BookmarksButton
   
Line 26 Line 28
   return self;    return self;
 }  }
   
   -(IBAction)openBookmark:(id)aSender
   {
     printf("Yo?\n");
     
     // Get the href attribute.  This is the URL we want to load.
     nsAutoString href;
     mElement->GetAttribute(NS_LITERAL_STRING("href"), href);
     nsCAutoString cref; cref.AssignWithConversion(href);
     if (cref.IsEmpty())
       return;
   
     NSString* url = [NSString stringWithCString: cref.get()];
   
     // Now load the URL in the window.
     [[[self window] windowController] loadURL:[NSURL URLWithString: url]];
   
     // Focus and activate our content area.
     [[[[[self window] windowController] getMyBrowserView] getBrowserView] setActive: YES];
   }
   
   -(void)drawRect:(NSRect)aRect
   {
     [super drawRect: aRect];
   }
   
   -(NSMenu*)menuForEvent:(NSEvent*)aEvent
   {
     return [[self superview] menu];
   }
   
   -(void)mouseDown:(NSEvent*)aEvent
   {
     if (mIsFolder) {
       nsCOMPtr<nsIContent> content(do_QueryInterface(mElement));
       NSMenu* menu = BookmarksService::LocateMenu(content);
       [NSMenu popUpContextMenu: menu withEvent: aEvent forView: self];
     }
     else
       [super mouseDown: aEvent];
   }
   
 -(void)setElement: (nsIDOMElement*)aElt  -(void)setElement: (nsIDOMElement*)aElt
 {  {
   mElement = aElt;    mElement = aElt;
   nsAutoString tag;    nsAutoString tag;
   mElement->GetLocalName(tag);    mElement->GetLocalName(tag);
  if (tag.Equals(NS_LITERAL_STRING("folder")))  if (tag.Equals(NS_LITERAL_STRING("folder"))) {
     [self setImage: [NSImage imageNamed: @"folder"]];      [self setImage: [NSImage imageNamed: @"folder"]];
  else    mIsFolder = YES;
   }
   else {
     mIsFolder = NO;
     [self setImage: [NSImage imageNamed: @"smallbookmark"]];      [self setImage: [NSImage imageNamed: @"smallbookmark"]];
    [self setAction: @selector(openBookmark:)];
     [self setTarget: self];
   }
   
   nsAutoString name;    nsAutoString name;
   mElement->GetAttribute(NS_LITERAL_STRING("name"), name);    mElement->GetAttribute(NS_LITERAL_STRING("name"), name);
   [self setTitle: [NSString stringWithCharacters: name.get() length: nsCRT::strlen(name.get())]];    [self setTitle: [NSString stringWithCharacters: name.get() length: nsCRT::strlen(name.get())]];
 }  }
   
   -(nsIDOMElement*)element
   {
     return mElement;
   }
   
 @end  @end

Removed from v.1.2  
changed lines
  Added in v.1.7


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