Diff for /chimera/MyBrowserView.mm between versions 1.6 and 1.13

version 1.6, 2002/01/31 07:14:20 version 1.13, 2002/02/10 01:12:05
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
   {
       // Break the cycle.
       [browserView setContainer: nil];
       [browserView removeListener: self];
       [browserView destroyWebBrowser];
   }
   
 -(void)dealloc  -(void)dealloc
 {  {
        [browserView release];    printf("My browser view died.\n");
     
     [[NSNotificationCenter defaultCenter] removeObserver: self];
     
         [defaultStatus release];          [defaultStatus release];
     [loadingStatus release];      [loadingStatus release];
           
Line 25 Line 42
   
 - (void)awakeFromNib   - (void)awakeFromNib 
 {  {
  browserView = [[NSBrowserView alloc] initWithFrame:[self bounds]];  browserView = [[[NSBrowserView alloc] initWithFrame:[self bounds]] autorelease];
   [self addSubview:browserView];    [self addSubview:browserView];
   [browserView setContainer:self];    [browserView setContainer:self];
   [browserView addListener:self];    [browserView addListener:self];
Line 37 Line 54
       
   [progress retain];    [progress retain];
   [progress removeFromSuperview];    [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];
 }  }
   
 - (void)setFrame:(NSRect)frameRect  - (void)setFrame:(NSRect)frameRect
Line 69 Line 99
   mIsBusy = YES;    mIsBusy = YES;
   if (mWindowController)    if (mWindowController)
     [mWindowController updateToolbarItems];      [mWindowController updateToolbarItems];
       
 #ifdef DEBUG_vidur  
   printf("Starting to load\n");  
 #endif  
 }  }
   
 - (void)onLoadingCompleted:(BOOL)succeeded  - (void)onLoadingCompleted:(BOOL)succeeded
Line 94 Line 120
       
   if (mWindowController)    if (mWindowController)
     [mWindowController updateToolbarItems];      [mWindowController updateToolbarItems];
     
 #ifdef DEBUG_vidur  
   printf("Loading completed\n");  
 #endif  
 }  }
   
 - (void)onProgressChange:(int)currentBytes outOf:(int)maxBytes   - (void)onProgressChange:(int)currentBytes outOf:(int)maxBytes 
Line 109 Line 131
     }      }
     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 119 Line 138
 {  {
   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 157 Line 176
   
 - (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"];    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"];
     }
 }
 
 - (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.6  
changed lines
  Added in v.1.13


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