Diff for /chimera/MyBrowserView.mm between versions 1.7 and 1.17

version 1.7, 2002/02/04 06:52:38 version 1.17, 2002/02/12 00:18:34
Line 4 Line 4
   
 #import "MyBrowserView.h"  #import "MyBrowserView.h"
   
   #include "nsCOMPtr.h"
   #include "nsIServiceManager.h"
   #include "nsIIOService.h"
   
 #define DOCUMENT_DONE_STRING @"Document: Done"  #define DOCUMENT_DONE_STRING @"Document: Done"
 #define LOADING_STRING @"Loading..."  #define LOADING_STRING @"Loading..."
   
   static const char* ioServiceContractID = "@mozilla.org/network/io-service;1";
   
 @implementation MyBrowserView  @implementation MyBrowserView
   
 -(void)windowClosed  -(void)windowClosed
Line 14 Line 20
     // Break the cycle.      // Break the cycle.
     [browserView setContainer: nil];      [browserView setContainer: nil];
     [browserView removeListener: self];      [browserView removeListener: self];
       [browserView destroyWebBrowser];
 }  }
   
 -(void)dealloc  -(void)dealloc
 {  {
       printf("My browser view died.\n");
       
       [[NSNotificationCenter defaultCenter] removeObserver: self];
       
         [defaultStatus release];          [defaultStatus release];
     [loadingStatus release];      [loadingStatus release];
           
Line 29 Line 40
   [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];
 }
 
 - (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;
     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 retain];
     [progress removeFromSuperview];
   }
   
   defaultStatus = NULL;    defaultStatus = NULL;
   loadingStatus = DOCUMENT_DONE_STRING;    loadingStatus = DOCUMENT_DONE_STRING;
   [status setStringValue:loadingStatus];    [status setStringValue:loadingStatus];
   mIsBusy = NO;  
       
  [progress retain];  mIsPrimary = YES;
  [progress removeFromSuperview]; 
   nsCOMPtr<nsIIOService> ioService(do_GetService(ioServiceContractID));
   if (!ioService)
     return;
   PRBool offline = PR_FALSE;
   ioService->GetOffline(&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]];
 }
 
 -(NSString*)getCurrentURLSpec
 {
   return [browserView getCurrentURLSpec];
 }
 
 - (void)awakeFromNib 
 {
 }  }
   
 - (void)setFrame:(NSRect)frameRect  - (void)setFrame:(NSRect)frameRect
Line 73 Line 136
   [status setStringValue:loadingStatus];    [status setStringValue:loadingStatus];
   
   mIsBusy = YES;    mIsBusy = YES;
     [mTab setLabel: LOADING_STRING];
     
   if (mWindowController)    if (mWindowController)
     [mWindowController updateToolbarItems];      [mWindowController updateToolbarItems];
 }  }
Line 107 Line 172
     }      }
     double val = ((double)currentBytes / (double)maxBytes) * 100.0;      double val = ((double)currentBytes / (double)maxBytes) * 100.0;
     [progress setDoubleValue:val];      [progress setDoubleValue:val];
 #ifdef DEBUG_vidur  
     printf("Progress notification: %f%%\n", val);  
 #endif  
   }    }
 }  }
   
Line 117 Line 179
 {  {
   NSString* spec = [url absoluteString];    NSString* spec = [url absoluteString];
   [mWindowController updateLocationFields:spec];    [mWindowController updateLocationFields:spec];
  }
#ifdef DEBUG_vidur
  const char* str = [spec cString];- (void)onStatusChange:(NSString*)aStatusString
  printf("Location changed to: %s\n", str);{
#endif  [status setStringValue: aStatusString];
 }  }
   
 - (void)setStatus:(NSString *)statusString ofType:(NSStatusType)type   - (void)setStatus:(NSString *)statusString ofType:(NSStatusType)type 
Line 155 Line 217
   
 - (void)setTitle:(NSString *)title  - (void)setTitle:(NSString *)title
 {  {
    if ( (title) && (! [title isEqualToString:@""]) ) {    if (!mWindowController)
        [[mWindowController window] setTitle:title];        return; // Sidebar panels can't affect the window title.
    } else {    
        [[mWindowController window] setTitle:@"Untitled"];    // 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) {
         NSString* newTitle = [[[mWindowController window] title] stringByAppendingString: @" [Working Offline]"];
         [[mWindowController window] setTitle: newTitle];
     }
     else {
         NSArray* titleItems = [[[mWindowController window] title] componentsSeparatedByString:@" [Working Offline]"];
         [[mWindowController window] setTitle: [titleItems objectAtIndex: 0]];
     }      }
 }  }
   

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


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