File:  [mozdev] / chimera /
Revision 1.3: download - view: text, annotated - select for diffs - revision graph
Wed Apr 17 08:56:57 2002 UTC (15 years, 11 months ago) by hyatt
Branches: MAIN
CVS tags: HEAD
Personal toolbar works. Kick ass.

//  Chimera
//  Created by David Hyatt on Mon Apr 15 2002.
//  Copyright (c) 2001 __MyCompanyName__. All rights reserved.

#import "BookmarksButton.h"
#include "nsIDOMElement.h"
#include "nsString.h"

@implementation BookmarksButton

- (id)initWithFrame:(NSRect)frame {
  self = [super initWithFrame:frame];
  if (self) {
    // Initialization code here.
    mElement = nsnull;
    [self setBezelStyle: NSRegularSquareBezelStyle];
    [self setBordered: NO];
    [self setImagePosition: NSImageLeft];
    [self setRefusesFirstResponder: YES];
    [self setFont: [NSFont labelFontOfSize: 11.0]];
  return self;

  // 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())

  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)setElement: (nsIDOMElement*)aElt
  mElement = aElt;
  nsAutoString tag;
  if (tag.Equals(NS_LITERAL_STRING("folder")))
    [self setImage: [NSImage imageNamed: @"folder"]];
  else {
    [self setImage: [NSImage imageNamed: @"smallbookmark"]];
    [self setAction: @selector(openBookmark:)];
    [self setTarget: self];
  nsAutoString name;
  mElement->GetAttribute(NS_LITERAL_STRING("name"), name);
  [self setTitle: [NSString stringWithCharacters: name.get() length: nsCRT::strlen(name.get())]];


FreeBSD-CVSweb <>