Diff for /chimera/BrowserWindowController.mm between versions 1.60 and 1.61

version 1.60, 2002/04/12 19:45:37 version 1.61, 2002/04/14 00:08:17
Line 40 Line 40
 #import "IconTabViewItem.h"  #import "IconTabViewItem.h"
   
 #include "nsIWebNavigation.h"  #include "nsIWebNavigation.h"
#include "nsIDOMNode.h"#include "nsIDOMElement.h"
 #include "nsIDOMEvent.h"  #include "nsIDOMEvent.h"
   #include "nsIPrefBranch.h"
 #include "nsIContextMenuListener.h"  #include "nsIContextMenuListener.h"
 #include "nsCocoaBrowserService.h"  #include "nsCocoaBrowserService.h"
   #include "nsString.h"
   #include "GeckoUtils.h"
   
 static NSString *BrowserToolbarIdentifier       = @"Browser Window Toolbar";  static NSString *BrowserToolbarIdentifier       = @"Browser Window Toolbar";
 static NSString *BackToolbarItemIdentifier      = @"Back Toolbar Item";  static NSString *BackToolbarItemIdentifier      = @"Back Toolbar Item";
Line 559  static NSString *PrintToolbarItemIdentif Line 562  static NSString *PrintToolbarItemIdentif
     if ( [[[self window] toolbar] isVisible] ) {      if ( [[[self window] toolbar] isVisible] ) {
         if ( ([[[self window] toolbar] displayMode] == NSToolbarDisplayModeIconAndLabel) ||          if ( ([[[self window] toolbar] displayMode] == NSToolbarDisplayModeIconAndLabel) ||
              ([[[self window] toolbar] displayMode] == NSToolbarDisplayModeIconOnly) ) {               ([[[self window] toolbar] displayMode] == NSToolbarDisplayModeIconOnly) ) {
          [[mBrowserView getBrowserView] setActive: NO];          if ([mTabBrowser numberOfTabViewItems] > 1) {
          [self focusURLBar];            [self focusURLBar];
             [[mBrowserView getBrowserView] setActive: NO];
           }
           else if ([[self window] isKeyWindow])
             [[mBrowserView getBrowserView] setActive: YES];
           else
             [[mBrowserView getBrowserView] setActive: NO];
         }          }
     }      }
 }  }
Line 613  static NSString *PrintToolbarItemIdentif Line 622  static NSString *PrintToolbarItemIdentif
   if (aLoadInBG)    if (aLoadInBG)
     [[browser window] orderWindow: NSWindowBelow relativeTo: [[self window] windowNumber]];      [[browser window] orderWindow: NSWindowBelow relativeTo: [[self window] windowNumber]];
   else    else
       // Focus the content area and show the window.
     [browser showWindow: self];      [browser showWindow: self];
   
   // XXXdwh Focus the content area.  
 }  }
   
 -(void)openNewTabWithURL: (NSURL*)aURL loadInBackground: (BOOL)aLoadInBG  -(void)openNewTabWithURL: (NSURL*)aURL loadInBackground: (BOOL)aLoadInBG
Line 634  static NSString *PrintToolbarItemIdentif Line 642  static NSString *PrintToolbarItemIdentif
   
     [[newView getBrowserView] loadURI:aURL flags:NSLoadFlagsNone];      [[newView getBrowserView] loadURI:aURL flags:NSLoadFlagsNone];
   
    if (!aLoadInBG)    if (!aLoadInBG) {
        [mTabBrowser selectTabViewItem: newTab];      [mTabBrowser selectTabViewItem: newTab];
              // Focus the content area.
    // XXXdwh Focus the content area.      [[newView getBrowserView] setActive: YES];
     }
 }  }
   
 -(void)setupSidebarTabs  -(void)setupSidebarTabs
Line 670  static NSString *PrintToolbarItemIdentif Line 679  static NSString *PrintToolbarItemIdentif
 {  {
   mContextMenuFlags = flags;    mContextMenuFlags = flags;
   mContextMenuNode = aNode;    mContextMenuNode = aNode;
   NS_IF_ADDREF(aNode);  
   mContextMenuEvent = aEvent;    mContextMenuEvent = aEvent;
   NS_IF_ADDREF(aEvent);  
 }  }
   
 - (NSMenu*)getContextMenu  - (NSMenu*)getContextMenu
Line 696  static NSString *PrintToolbarItemIdentif Line 703  static NSString *PrintToolbarItemIdentif
     result = mPageMenu;      result = mPageMenu;
   }    }
       
   NS_IF_RELEASE(mContextMenuNode);  
   mContextMenuNode = nsnull;  
   NS_IF_RELEASE(mContextMenuEvent);  
   mContextMenuEvent = nsnull;  
   return result;    return result;
 }  }
   
   // Context menu methods
   - (IBAction)openLinkInNewWindow:(id)aSender
   {
     [self openLinkInNewWindowOrTab: YES];
   }
   
   - (IBAction)openLinkInNewTab:(id)aSender
   {
     [self openLinkInNewWindowOrTab: NO];
   }
   
   -(void)openLinkInNewWindowOrTab: (BOOL)aUseWindow
   {
     nsCOMPtr<nsIDOMElement> linkContent;
     nsAutoString href;
     GeckoUtils::GetEnclosingLinkElementAndHref(mContextMenuNode, getter_AddRefs(linkContent), href);
   
     // XXXdwh Handle simple XLINKs if we want to be compatible with Mozilla, but who
     // really uses these anyway? :)
     if (!linkContent || href.IsEmpty())
       return;
   
     nsCOMPtr<nsIPrefBranch> pref(do_GetService("@mozilla.org/preferences-service;1"));
     if (!pref)
       return; // Something bad happened if we can't get prefs.
   
     NSString* hrefStr = [NSString stringWithCharacters: href.get() length:nsCRT::strlen(href.get())];
     NSURL* urlToLoad = [NSURL URLWithString: hrefStr];
   
     PRBool loadInBackground;
     pref->GetBoolPref("browser.tabs.loadInBackground", &loadInBackground);
   
     if (aUseWindow)
       [self openNewWindowWithURL: urlToLoad loadInBackground: loadInBackground];
     else
       [self openNewTabWithURL: urlToLoad loadInBackground: loadInBackground];
   }
   
   - (IBAction)saveLinkAs:(id)aSender
   {
   }
   
   - (IBAction)saveImageAs:(id)aSender
   {
   }
   
 @end  @end
   

Removed from v.1.60  
changed lines
  Added in v.1.61


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