Annotation of chimera/BookmarksButton.mm, revision 1.3

1.1       hyatt       1: //
                      2: //  BookmarksButton.mm
                      3: //  Chimera
                      4: //
                      5: //  Created by David Hyatt on Mon Apr 15 2002.
                      6: //  Copyright (c) 2001 __MyCompanyName__. All rights reserved.
                      7: //
                      8: 
                      9: #import "BookmarksButton.h"
1.2       hyatt      10: #include "nsIDOMElement.h"
                     11: #include "nsString.h"
1.1       hyatt      12: 
                     13: @implementation BookmarksButton
                     14: 
                     15: - (id)initWithFrame:(NSRect)frame {
                     16:   self = [super initWithFrame:frame];
                     17:   if (self) {
                     18:     // Initialization code here.
1.2       hyatt      19:     mElement = nsnull;
                     20:     [self setBezelStyle: NSRegularSquareBezelStyle];
                     21:     [self setBordered: NO];
                     22:     [self setImagePosition: NSImageLeft];
                     23:     [self setRefusesFirstResponder: YES];
                     24:     [self setFont: [NSFont labelFontOfSize: 11.0]];
1.1       hyatt      25:   }
1.2       hyatt      26:   return self;
                     27: }
1.1       hyatt      28: 
1.3     ! hyatt      29: -(IBAction)openBookmark:(id)aSender
        !            30: {
        !            31:   printf("Yo?\n");
        !            32:   
        !            33:   // Get the href attribute.  This is the URL we want to load.
        !            34:   nsAutoString href;
        !            35:   mElement->GetAttribute(NS_LITERAL_STRING("href"), href);
        !            36:   nsCAutoString cref; cref.AssignWithConversion(href);
        !            37:   if (cref.IsEmpty())
        !            38:     return;
        !            39: 
        !            40:   NSString* url = [NSString stringWithCString: cref.get()];
        !            41: 
        !            42:   // Now load the URL in the window.
        !            43:   [[[self window] windowController] loadURL:[NSURL URLWithString: url]];
        !            44: 
        !            45:   // Focus and activate our content area.
        !            46:   [[[[[self window] windowController] getMyBrowserView] getBrowserView] setActive: YES];
        !            47: }
        !            48: 
1.2       hyatt      49: -(void)setElement: (nsIDOMElement*)aElt
                     50: {
                     51:   mElement = aElt;
                     52:   nsAutoString tag;
                     53:   mElement->GetLocalName(tag);
                     54:   if (tag.Equals(NS_LITERAL_STRING("folder")))
                     55:     [self setImage: [NSImage imageNamed: @"folder"]];
1.3     ! hyatt      56:   else {
1.2       hyatt      57:     [self setImage: [NSImage imageNamed: @"smallbookmark"]];
1.3     ! hyatt      58:     [self setAction: @selector(openBookmark:)];
        !            59:     [self setTarget: self];
        !            60:   }
        !            61:   
1.2       hyatt      62:   nsAutoString name;
                     63:   mElement->GetAttribute(NS_LITERAL_STRING("name"), name);
                     64:   [self setTitle: [NSString stringWithCharacters: name.get() length: nsCRT::strlen(name.get())]];
1.1       hyatt      65: }
                     66: 
                     67: @end

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