Diff for /chimera/MyBrowserView.mm between versions 1.10 and 1.22

version 1.10, 2002/02/05 00:16:30 version 1.22, 2002/03/07 18:35:48
Line 3 Line 3
  */   */
   
 #import "MyBrowserView.h"  #import "MyBrowserView.h"
   #import "BrowserWindowController.h"
   
 #include "nsCOMPtr.h"  #include "nsCOMPtr.h"
 #include "nsIServiceManager.h"  #include "nsIServiceManager.h"
 #include "nsIIOService.h"  #include "nsIIOService.h"
   #include "ContentClickListener.h"
   #include "nsIDOMWindow.h"
   #include "nsIChromeEventHandler.h"
   #include "nsPIDOMWindow.h"
   #include "nsIDOMEventReceiver.h"
   
 #define DOCUMENT_DONE_STRING @"Document: Done"  #define DOCUMENT_DONE_STRING @"Document: Done"
 #define LOADING_STRING @"Loading..."  #define LOADING_STRING @"Loading..."
Line 25  static const char* ioServiceContractID = Line 31  static const char* ioServiceContractID =
   
 -(void)dealloc  -(void)dealloc
 {  {
       printf("My browser view died.\n");
       
       [[NSNotificationCenter defaultCenter] removeObserver: self];
       
         [defaultStatus release];          [defaultStatus release];
     [loadingStatus release];      [loadingStatus release];
           
Line 36  static const char* ioServiceContractID = Line 46  static const char* ioServiceContractID =
   [browserView loadURI:[NSURL URLWithString:[urlbar stringValue]] flags:NSLoadFlagsNone];    [browserView loadURI:[NSURL URLWithString:[urlbar stringValue]] flags:NSLoadFlagsNone];
 }  }
   
- (void)awakeFromNib -(void)disconnectView
 {  {
  browserView = [[[NSBrowserView alloc] initWithFrame:[self bounds]] autorelease];    urlbar = nil;
  [self addSubview:browserView];    status = nil;
  [browserView setContainer:self];    progress = nil;
  [browserView addListener:self];    progressSuper = nil;
     mIsPrimary = NO;
     [[NSNotificationCenter defaultCenter] removeObserver:self];
     
     [browserView setActive: NO];
 }
   
   - (id)initWithFrame:(NSRect)frameRect
   {
       [super initWithFrame: frameRect];
        browserView = [[[NSBrowserView alloc] initWithFrame:[self bounds]] autorelease];
       [self addSubview:browserView];
       [browserView setContainer:self];
       [browserView addListener:self];
       mIsBusy = NO;
       mListenersAttached = NO;
       return self;
   }
   
   -(void)makePrimaryBrowserView: (NSTabViewItem*)tab urlbar: (id)aUrlbar status: (id)aStatus
       progress: (id)aProgress windowController: aWindowController
   {
     mTab = tab;
     urlbar = aUrlbar;
     status = aStatus;
     progress = aProgress;
     progressSuper = [aProgress superview];
     mWindowController = aWindowController;
     
     if (!mIsBusy)
         [progress removeFromSuperview];
     
   defaultStatus = NULL;    defaultStatus = NULL;
   loadingStatus = DOCUMENT_DONE_STRING;    loadingStatus = DOCUMENT_DONE_STRING;
   [status setStringValue:loadingStatus];    [status setStringValue:loadingStatus];
   mIsBusy = NO;  
     
   [progress retain];  
   [progress removeFromSuperview];  
       
     mIsPrimary = YES;
    
   nsCOMPtr<nsIIOService> ioService(do_GetService(ioServiceContractID));    nsCOMPtr<nsIIOService> ioService(do_GetService(ioServiceContractID));
   if (!ioService)    if (!ioService)
     return;      return;
   PRBool offline = PR_FALSE;    PRBool offline = PR_FALSE;
   ioService->GetOffline(&offline);    ioService->GetOffline(&offline);
   mOffline = offline;    mOffline = offline;
     
     if (mWindowController) // Only register if we're the content area.
       [[NSNotificationCenter defaultCenter] addObserver:self
           selector:@selector(offlineModeChanged:)
           name:@"offlineModeChanged"
           object:nil];
           
     // Update the URL bar.
     [mWindowController updateLocationFields:[self getCurrentURLSpec]];
     
     if (mWindowController && !mListenersAttached) {
       mListenersAttached = YES;
       
       // We need to hook up our click and context menu listeners.
       ContentClickListener* clickListener = new ContentClickListener(mWindowController);
       if (!clickListener)
         return;
       
       nsCOMPtr<nsIDOMWindow> contentWindow = getter_AddRefs([[self getBrowserView] getContentWindow]);
       nsCOMPtr<nsPIDOMWindow> piWindow(do_QueryInterface(contentWindow));
       nsCOMPtr<nsIChromeEventHandler> chromeHandler;
       piWindow->GetChromeEventHandler(getter_AddRefs(chromeHandler));
       nsCOMPtr<nsIDOMEventReceiver> rec(do_QueryInterface(chromeHandler));
       rec->AddEventListenerByIID(clickListener, NS_GET_IID(nsIDOMMouseListener));
     }
   }
   
   -(NSString*)getCurrentURLSpec
   {
     return [browserView getCurrentURLSpec];
   }
   
   - (void)awakeFromNib 
   {
 }  }
   
 - (void)setFrame:(NSRect)frameRect  - (void)setFrame:(NSRect)frameRect
Line 79  static const char* ioServiceContractID = Line 151  static const char* ioServiceContractID =
   }    }
   
   [progressSuper addSubview:progress];    [progressSuper addSubview:progress];
   [progress release];  
   [progress setIndeterminate:YES];    [progress setIndeterminate:YES];
   [progress startAnimation:self];    [progress startAnimation:self];
   
Line 87  static const char* ioServiceContractID = Line 158  static const char* ioServiceContractID =
   [status setStringValue:loadingStatus];    [status setStringValue:loadingStatus];
   
   mIsBusy = YES;    mIsBusy = YES;
     [mTab setLabel: LOADING_STRING];
     
   if (mWindowController)    if (mWindowController)
     [mWindowController updateToolbarItems];      [mWindowController updateToolbarItems];
 }  }
Line 95  static const char* ioServiceContractID = Line 168  static const char* ioServiceContractID =
 {  {
   [progress setIndeterminate:YES];    [progress setIndeterminate:YES];
   [progress stopAnimation:self];    [progress stopAnimation:self];
   [progress retain];  
   [progress removeFromSuperview];    [progress removeFromSuperview];
   
   loadingStatus = DOCUMENT_DONE_STRING;    loadingStatus = DOCUMENT_DONE_STRING;
Line 130  static const char* ioServiceContractID = Line 202  static const char* ioServiceContractID =
   [mWindowController updateLocationFields:spec];    [mWindowController updateLocationFields:spec];
 }  }
   
   - (void)onStatusChange:(NSString*)aStatusString
   {
     [status setStringValue: aStatusString];
   }
   
 - (void)setStatus:(NSString *)statusString ofType:(NSStatusType)type   - (void)setStatus:(NSString *)statusString ofType:(NSStatusType)type 
 {  {
   if (type == NSStatusTypeScriptDefault) {    if (type == NSStatusTypeScriptDefault) {
Line 161  static const char* ioServiceContractID = Line 238  static const char* ioServiceContractID =
   
 - (void)setTitle:(NSString *)title  - (void)setTitle:(NSString *)title
 {  {
       if (!mWindowController)
           return; // Sidebar panels can't affect the window title.
       
       // We must be the primary content area.
       if (mIsPrimary) {
           if (mOffline) {
               NSString* newTitle;
               if (title && ![title isEqualToString:@""])
                   newTitle = [title stringByAppendingString: @" [Working Offline]"];
               else
                   newTitle = @"Untitled [Working Offline]";
               [[mWindowController window] setTitle: newTitle];
           }
           else {
               if (title && ![title isEqualToString:@""])
                   [[mWindowController window] setTitle:title];
               else
                   [[mWindowController window] setTitle:@"Untitled"];
           }
       }
       
       // Always set the tab.
       if (title && ![title isEqualToString:@""])
           [mTab setLabel:title];
       else
           [mTab setLabel:@"Untitled"];
   }
   
   - (void)offlineModeChanged: (NSNotification*)aNotification
   {
       nsCOMPtr<nsIIOService> ioService(do_GetService(ioServiceContractID));
       if (!ioService)
           return;
       PRBool offline = PR_FALSE;
       ioService->GetOffline(&offline);
       mOffline = offline;
       
     if (mOffline) {      if (mOffline) {
        NSString* newTitle;        NSString* newTitle = [[[mWindowController window] title] stringByAppendingString: @" [Working Offline]"];
        if (title && ![title isEqualToString:@""]) 
            newTitle = [title stringByAppendingString: @" [Working Offline]"]; 
        else 
            newTitle = @"Untitled [Working Offline]"; 
         [[mWindowController window] setTitle: newTitle];          [[mWindowController window] setTitle: newTitle];
     }      }
     else {      else {
        if (title && ![title isEqualToString:@""])        NSArray* titleItems = [[[mWindowController window] title] componentsSeparatedByString:@" [Working Offline]"];
            [[mWindowController window] setTitle:title];        [[mWindowController window] setTitle: [titleItems objectAtIndex: 0]];
        else 
            [[mWindowController window] setTitle:@"Untitled"]; 
     }      }
 }  }
   
Line 192  static const char* ioServiceContractID = Line 300  static const char* ioServiceContractID =
   
 - (NSBrowserView*)createBrowserWindow:(unsigned int)mask  - (NSBrowserView*)createBrowserWindow:(unsigned int)mask
 {  {
  // XXX not implemented   BrowserWindowController* controller = [[BrowserWindowController alloc] initWithWindowNibName: @"BrowserWindow"];
  return NULL;  [controller enterModalSession];
   return [[controller getMyBrowserView] getBrowserView];
 }  }
   
 - (NSBrowserView*)getBrowserView  - (NSBrowserView*)getBrowserView

Removed from v.1.10  
changed lines
  Added in v.1.22


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