Camino only - Bug 330666: Switch to using NSSearchField in the toolbar and search sheet. r=hwaara sr=pink

git-svn-id: svn://10.0.0.236/trunk@232272 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
stuart.morgan%alumni.case.edu
2007-08-17 17:25:01 +00:00
parent 13a68bbb33
commit 90774053bf
9 changed files with 149 additions and 100 deletions

View File

@@ -7,6 +7,10 @@
objects = {
/* Begin PBXBuildFile section */
00335B8D0C655ABC00A607F2 /* WebSearchField.h in Headers */ = {isa = PBXBuildFile; fileRef = 00335B8B0C655ABC00A607F2 /* WebSearchField.h */; };
00335B8E0C655ABC00A607F2 /* WebSearchField.mm in Sources */ = {isa = PBXBuildFile; fileRef = 00335B8C0C655ABC00A607F2 /* WebSearchField.mm */; };
00335B8F0C655ABC00A607F2 /* WebSearchField.h in Headers */ = {isa = PBXBuildFile; fileRef = 00335B8B0C655ABC00A607F2 /* WebSearchField.h */; };
00335B900C655ABC00A607F2 /* WebSearchField.mm in Sources */ = {isa = PBXBuildFile; fileRef = 00335B8C0C655ABC00A607F2 /* WebSearchField.mm */; };
0081150B0B180DDE001CB3F0 /* libthebes.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 0081150A0B180DDE001CB3F0 /* libthebes.a */; };
0081150D0B180DFA001CB3F0 /* libgkgfxthebes.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 0081150C0B180DFA001CB3F0 /* libgkgfxthebes.a */; };
008115430B180F35001CB3F0 /* libthebes.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = 008115420B180F35001CB3F0 /* libthebes.dylib */; };
@@ -2318,6 +2322,8 @@
/* End PBXCopyFilesBuildPhase section */
/* Begin PBXFileReference section */
00335B8B0C655ABC00A607F2 /* WebSearchField.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = WebSearchField.h; path = src/browser/WebSearchField.h; sourceTree = "<group>"; };
00335B8C0C655ABC00A607F2 /* WebSearchField.mm */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.objcpp; name = WebSearchField.mm; path = src/browser/WebSearchField.mm; sourceTree = "<group>"; };
0081150A0B180DDE001CB3F0 /* libthebes.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libthebes.a; path = ../staticlib/libthebes.a; sourceTree = SOURCE_ROOT; };
0081150C0B180DFA001CB3F0 /* libgkgfxthebes.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libgkgfxthebes.a; path = ../gfx/src/thebes/libgkgfxthebes.a; sourceTree = SOURCE_ROOT; };
008115420B180F35001CB3F0 /* libthebes.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = libthebes.dylib; path = ../dist/Embed/libthebes.dylib; sourceTree = SOURCE_ROOT; };
@@ -2496,7 +2502,7 @@
3F42EFAC05EC13F90045A30C /* throbber-11.tif */ = {isa = PBXFileReference; lastKnownFileType = image.gif; name = "throbber-11.tif"; path = "resources/images/throbber/throbber-11.tif"; sourceTree = SOURCE_ROOT; };
3F42EFAD05EC13F90045A30C /* throbber-12.tif */ = {isa = PBXFileReference; lastKnownFileType = image.gif; name = "throbber-12.tif"; path = "resources/images/throbber/throbber-12.tif"; sourceTree = SOURCE_ROOT; };
3F44AD8705BDFB9F00CB4B08 /* Info-Camino.plist */ = {isa = PBXFileReference; lastKnownFileType = text.xml; path = "Info-Camino.plist"; sourceTree = "<group>"; };
3F44AD8805BDFB9F00CB4B08 /* Camino.app */ = {isa = PBXFileReference; includeInIndex = 0; lastKnownFileType = wrapper.application; path = Camino.app; sourceTree = BUILT_PRODUCTS_DIR; };
3F44AD8805BDFB9F00CB4B08 /* Camino.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Camino.app; sourceTree = BUILT_PRODUCTS_DIR; };
3F44AD9E05BDFB9F00CB4B08 /* Info-AppearancePrefPane.plist */ = {isa = PBXFileReference; lastKnownFileType = text.xml; path = "Info-AppearancePrefPane.plist"; sourceTree = "<group>"; };
3F44AD9F05BDFB9F00CB4B08 /* Appearance.prefPane */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = Appearance.prefPane; sourceTree = BUILT_PRODUCTS_DIR; };
3F44ADB205BDFBA000CB4B08 /* Info-NavigationPrefPane.plist */ = {isa = PBXFileReference; lastKnownFileType = text.xml; path = "Info-NavigationPrefPane.plist"; sourceTree = "<group>"; };
@@ -3890,6 +3896,8 @@
1F8407030C5705CC007B893D /* TabThumbnailGridView.mm */,
1F8407050C5705CC007B893D /* ThumbnailView.h */,
1F8407060C5705CC007B893D /* ThumbnailView.m */,
00335B8B0C655ABC00A607F2 /* WebSearchField.h */,
00335B8C0C655ABC00A607F2 /* WebSearchField.mm */,
3003B8890445124400B85BF3 /* SearchTextField */,
F558137B030AEF9B0176F207 /* Site icons */,
);
@@ -4735,6 +4743,7 @@
DE6D27E50C1A013800292043 /* CHPermissionManager.h in Headers */,
1F8407080C5705CC007B893D /* TabThumbnailGridView.h in Headers */,
1F8407090C5705CC007B893D /* ThumbnailView.h in Headers */,
00335B8D0C655ABC00A607F2 /* WebSearchField.h in Headers */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@@ -4892,6 +4901,7 @@
DE6D27E40C1A013800292043 /* CHPermissionManager.h in Headers */,
1F840B2B0C57D807007B893D /* TabThumbnailGridView.h in Headers */,
1F840B2D0C57D807007B893D /* ThumbnailView.h in Headers */,
00335B8F0C655ABC00A607F2 /* WebSearchField.h in Headers */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@@ -5743,6 +5753,7 @@
1F8407070C5705CC007B893D /* TabThumbnailGridView.mm in Sources */,
1F84070A0C5705CC007B893D /* ThumbnailView.m in Sources */,
33F3B70B0C63F5F7007DFBD0 /* ScriptingSupport.mm in Sources */,
00335B8E0C655ABC00A607F2 /* WebSearchField.mm in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@@ -5913,6 +5924,7 @@
1F840B2C0C57D807007B893D /* TabThumbnailGridView.mm in Sources */,
1F840B2E0C57D807007B893D /* ThumbnailView.m in Sources */,
33F3B70C0C63F5F7007DFBD0 /* ScriptingSupport.mm in Sources */,
00335B900C655ABC00A607F2 /* WebSearchField.mm in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};

View File

@@ -85,12 +85,7 @@
SUPERCLASS = NSTabView;
},
{CLASS = BrowserTabViewItem; LANGUAGE = ObjC; SUPERCLASS = IconTabViewItem; },
{
CLASS = BrowserWindow;
LANGUAGE = ObjC;
OUTLETS = {mAutoCompleteTextField = id; };
SUPERCLASS = NSWindow;
},
{CLASS = BrowserWindow; LANGUAGE = ObjC; SUPERCLASS = NSWindow; },
{
ACTIONS = {
addBookmark = id;
@@ -98,6 +93,7 @@
addBookmarkForLink = id;
addBookmarkSeparator = id;
addBookmarkWithoutPrompt = id;
addTabGroup = id;
addTabGroupWithoutPrompt = id;
addToAddressBook = id;
back = id;
@@ -131,7 +127,6 @@
openLinkInNewTab = id;
openLinkInNewWindow = id;
pageSetup = id;
performSearch = id;
previousTab = id;
printDocument = id;
reload = id;
@@ -142,6 +137,7 @@
saveImageAs = id;
saveLinkAs = id;
savePageAs = id;
searchFieldTriggered = id;
searchForSelection = id;
sendURL = id;
sendURLFromLink = id;
@@ -149,6 +145,7 @@
showPageInfo = id;
showSiteCertificate = id;
stop = id;
toggleStatusBar = id;
viewOnlyThisImage = id;
viewPageSource = id;
viewSource = id;
@@ -173,8 +170,8 @@
mPersonalToolbar = BookmarkToolbar;
mProgress = NSProgressIndicator;
mProxyIcon = PageProxyIcon;
mSearchBar = SearchTextField;
mSearchSheetTextField = SearchTextField;
mSearchBar = NSSearchField;
mSearchSheetTextField = NSSearchField;
mSearchSheetWindow = NSWindow;
mStatus = NSTextField;
mStatusBar = NSView;
@@ -288,7 +285,8 @@
{CLASS = StatusBarView; LANGUAGE = ObjC; SUPERCLASS = NSView; },
{CLASS = TabButtonCell; LANGUAGE = ObjC; SUPERCLASS = RolloverTrackingCell; },
{CLASS = ThrobberHandler; LANGUAGE = ObjC; SUPERCLASS = NSObject; },
{CLASS = TruncatingTextAndImageCell; LANGUAGE = ObjC; SUPERCLASS = NSCell; }
{CLASS = TruncatingTextAndImageCell; LANGUAGE = ObjC; SUPERCLASS = NSCell; },
{CLASS = WebSearchField; LANGUAGE = ObjC; SUPERCLASS = NSSearchField; }
);
IBVersion = 1;
}

View File

@@ -3,12 +3,20 @@
<plist version="1.0">
<dict>
<key>IBDocumentLocation</key>
<string>60 58 356 240 0 0 1680 1028 </string>
<string>67 57 356 240 0 0 1680 1028 </string>
<key>IBEditorPositions</key>
<dict>
<key>1066</key>
<string>679 653 370 64 0 0 1680 1028 </string>
<key>297</key>
<string>67 302 226 337 0 0 1680 1028 </string>
</dict>
<key>IBFramework Version</key>
<string>446.1</string>
<key>IBOpenObjects</key>
<array>
<integer>10</integer>
<integer>806</integer>
<integer>1066</integer>
</array>
<key>IBSystem Version</key>
<string>8P2137</string>

View File

@@ -42,8 +42,6 @@
@interface BrowserWindow : NSWindow
{
IBOutlet id mAutoCompleteTextField;
// mSuppressSetVisible is used to overcome a problem of communication between
// gecko and the front end. Gecko tries to make the window visible and frontmost
// on every focus() call, and we don't want that.

View File

@@ -104,8 +104,8 @@ typedef enum
@class BrowserContentView;
@class BrowserTabViewItem;
@class AutoCompleteTextField;
@class SearchTextField;
@class ExtendedSplitView;
@class WebSearchField;
@interface BrowserWindowController : NSWindowController<Find, BrowserUIDelegate, BrowserUICreationDelegate>
@@ -123,8 +123,8 @@ typedef enum
IBOutlet BookmarkToolbar* mPersonalToolbar;
IBOutlet SearchTextField* mSearchBar;
IBOutlet SearchTextField* mSearchSheetTextField;
IBOutlet WebSearchField* mSearchBar;
IBOutlet WebSearchField* mSearchSheetTextField;
IBOutlet NSWindow* mSearchSheetWindow;
// Context menu outlets.
@@ -215,7 +215,7 @@ typedef enum
- (IBAction)printDocument:(id)aSender;
- (IBAction)pageSetup:(id)aSender;
- (IBAction)performSearch:(id)aSender;
- (IBAction)searchFieldTriggered:(id)aSender;
- (IBAction)searchForSelection:(id)aSender;
- (IBAction)sendURL:(id)aSender;
- (IBAction)sendURLFromLink:(id)aSender;

View File

@@ -67,13 +67,11 @@
#import "UserDefaults.h"
#import "PageProxyIcon.h"
#import "AutoCompleteTextField.h"
#import "SearchTextField.h"
#import "SearchTextFieldCell.h"
#import "STFPopUpButtonCell.h"
#import "DraggableImageAndTextCell.h"
#import "MVPreferencesController.h"
#import "ViewCertificateDialogController.h"
#import "ExtendedSplitView.h"
#import "WebSearchField.h"
#import "wallet.h"
#include "nsString.h"
@@ -540,7 +538,7 @@ enum BWCOpenDest {
- (void)openNewWindowWithDescriptor:(nsISupports*)aDesc displayType:(PRUint32)aDisplayType loadInBackground:(BOOL)aLoadInBG;
- (void)openNewTabWithDescriptor:(nsISupports*)aDesc displayType:(PRUint32)aDisplayType loadInBackground:(BOOL)aLoadInBG;
- (BOOL)isPageTextFieldFocused;
- (void)performSearch:(SearchTextField *)inSearchField inView:(BWCOpenDest)inDest inBackground:(BOOL)inLoadInBG;
- (void)performSearch:(WebSearchField*)inSearchField inView:(BWCOpenDest)inDest inBackground:(BOOL)inLoadInBG;
- (int)historyIndexOfPageBeforeBookmarkManager;
- (void)goToLocationFromToolbarURLField:(AutoCompleteTextField *)inURLField inView:(BWCOpenDest)inDest inBackground:(BOOL)inLoadInBG;
@@ -578,6 +576,8 @@ enum BWCOpenDest {
- (void)focusedElement:(nsIDOMElement**)outElement;
- (void)focusController:(nsIFocusController**)outController;
- (void)setUpSearchFields;
@end
#pragma mark -
@@ -870,20 +870,8 @@ enum BWCOpenDest {
[mStatus setBackgroundColor:[NSColor windowBackgroundColor]];
[mStatus setDrawsBackground:YES];
// Set up the toolbar's search text field
NSMutableArray *searchTitles =
[NSMutableArray arrayWithArray:[[[BrowserWindowController searchURLDictionary] allKeys] sortedArrayUsingSelector:@selector(compare:)]];
[searchTitles removeObject:@"PreferredSearchEngine"];
[mSearchBar addPopUpMenuItemsWithTitles:searchTitles];
[[[mSearchBar cell] popUpButtonCell] selectItemWithTitle:
[[BrowserWindowController searchURLDictionary] objectForKey:@"PreferredSearchEngine"]];
// Set the sheet's search text field
[mSearchSheetTextField addPopUpMenuItemsWithTitles:searchTitles];
[[[mSearchSheetTextField cell] popUpButtonCell] selectItemWithTitle:
[[BrowserWindowController searchURLDictionary] objectForKey:@"PreferredSearchEngine"]];
// Set up the menus in the search fields
[self setUpSearchFields];
// Get our saved dimensions.
NSRect oldFrame = [[self window] frame];
@@ -1399,9 +1387,6 @@ enum BWCOpenDest {
[toolbarItem setMinSize:NSMakeSize(kMinimumLocationBarWidth, NSHeight([mLocationToolbarView frame]))];
[toolbarItem setMaxSize:NSMakeSize(FLT_MAX, NSHeight([mLocationToolbarView frame]))];
[mSearchBar setTarget:self];
[mSearchBar setAction:@selector(performSearch:)];
[menuFormRep setTarget:self];
[menuFormRep setAction:@selector(performAppropriateLocationAction)];
[menuFormRep setTitle:[toolbarItem label]];
@@ -1676,6 +1661,10 @@ enum BWCOpenDest {
{
SEL action = [aMenuItem action];
// Always allow the search engine menu to work
if (action == @selector(searchEngineChanged:))
return YES;
// Disable all window-specific menu items while a sheet is showing.
// We don't do this in validateActionBySelector: because toolbar items shouldn't
// suddenly get a disabled look when a sheet appears (they aren't clickable anyway).
@@ -2261,7 +2250,7 @@ enum BWCOpenDest {
{
[mSearchSheetWindow orderOut:self];
[NSApp endSheet:mSearchSheetWindow returnCode:1];
[self performSearch:mSearchSheetTextField];
[self performSearch:mSearchSheetTextField inView:kDestinationCurrentView inBackground:NO];
}
- (IBAction)cancelSearchSheet:(id)sender
@@ -2524,11 +2513,36 @@ enum BWCOpenDest {
[[mBrowserView getBrowserView] pageSetup];
}
- (IBAction)performSearch:(id)aSender
// -searchFieldTriggered:
//
// This should be used *only* as an action method for a WebSearchField, and
// never invoked programatically.
- (IBAction)searchFieldTriggered:(id)aSender
{
// If we have a valid SearchTextField, perform a search using its contents
if ([aSender isKindOfClass:[SearchTextField class]])
[self performSearch:(SearchTextField *)aSender inView:kDestinationCurrentView inBackground:NO];
// WebSearchField sends an action on clearing the search field, which isn't
// distinguishable from submitting an empty search, so we make sure the
// trigger was someone hitting return/enter if it's empty.
BOOL performSearch = NO;
if ([[aSender stringValue] length] > 0) {
performSearch = YES;
}
else {
NSEvent* currentEvent = [NSApp currentEvent];
if (([currentEvent type] == NSKeyDown) && [[currentEvent characters] length] > 0) {
unichar character = [[currentEvent characters] characterAtIndex:0];
if ((character == NSCarriageReturnCharacter) || (character == NSEnterCharacter))
performSearch = YES;
}
}
if (performSearch) {
// If it came from the search sheet, dismiss the sheet now
if (aSender == mSearchSheetTextField) {
[mSearchSheetWindow orderOut:self];
[NSApp endSheet:mSearchSheetWindow returnCode:1];
}
[self performSearch:aSender inView:kDestinationCurrentView inBackground:NO];
}
}
//
@@ -2554,7 +2568,7 @@ enum BWCOpenDest {
[self performSearch:mSearchBar inView:destination inBackground:[BrowserWindowController shouldLoadInBackground:nil]];
}
else
[self performSearch:mSearchBar];
[self performSearch:mSearchBar inView:kDestinationCurrentView inBackground:NO];
}
//
@@ -2563,25 +2577,16 @@ enum BWCOpenDest {
// performs a search using searchField and opens either in the current view, a new tab, or a new
// window. If it's a new tab or window, loadInBG determines whether the window/tab is opened in the background
//
-(void)performSearch:(SearchTextField *)inSearchField inView:(BWCOpenDest)inDest inBackground:(BOOL)inLoadInBG
-(void)performSearch:(WebSearchField*)inSearchField inView:(BWCOpenDest)inDest inBackground:(BOOL)inLoadInBG
{
// Get the search URL from our dictionary of sites and search urls
NSMutableString *searchURL = [NSMutableString stringWithString:
[[BrowserWindowController searchURLDictionary] objectForKey:
[inSearchField titleOfSelectedPopUpItem]]];
NSString *currentURL = [[self getBrowserWrapper] currentURI];
NSString *searchString = [inSearchField stringValue];
const char *aURLSpec = [currentURL lossyCString];
NSString *aDomain = @"";
nsCOMPtr<nsIURI> aURI;
NSMutableString *searchURL = [[[inSearchField currentSearchURL] mutableCopy] autorelease];
// If we have an about: type URL, remove " site:%d" from the search string
// This is a fix to deal with Google's Search this Site feature
// If other sites use %d to search the site, we'll have to have specific rules
// for those sites.
if ([currentURL hasPrefix:@"about:"]) {
if ([[[self getBrowserWrapper] currentURI] hasPrefix:@"about:"]) {
NSRange domainStringRange = [searchURL rangeOfString:@" site:%d"
options:NSBackwardsSearch];
@@ -2592,31 +2597,34 @@ enum BWCOpenDest {
// If they didn't type anything in the search field, visit the domain of
// the search site, i.e. www.google.com for the Google site
if ([[inSearchField stringValue] isEqualToString:@""]) {
aURLSpec = [searchURL lossyCString];
if ([searchString isEqualToString:@""]) {
const char *urlSpec = [searchURL lossyCString];
if (NS_NewURI(getter_AddRefs(aURI), aURLSpec) == NS_OK) {
nsCOMPtr<nsIURI> searchURI;
if (NS_NewURI(getter_AddRefs(searchURI), urlSpec) == NS_OK) {
nsCAutoString spec;
aURI->GetHost(spec);
searchURI->GetHost(spec);
aDomain = [NSString stringWithUTF8String:spec.get()];
NSString *searchDomain = [NSString stringWithUTF8String:spec.get()];
if (inDest == kDestinationNewTab)
[self openNewTabWithURL:aDomain referrer:nil loadInBackground:inLoadInBG allowPopups:NO setJumpback:NO];
[self openNewTabWithURL:searchDomain referrer:nil loadInBackground:inLoadInBG allowPopups:NO setJumpback:NO];
else if (inDest == kDestinationNewWindow)
[self openNewWindowWithURL:aDomain referrer:nil loadInBackground:inLoadInBG allowPopups:NO];
[self openNewWindowWithURL:searchDomain referrer:nil loadInBackground:inLoadInBG allowPopups:NO];
else // if it's not a new window or a new tab, load into the current view
[self loadURL:aDomain];
[self loadURL:searchDomain];
}
} else {
aURLSpec = [[[self getBrowserWrapper] currentURI] UTF8String];
const char *urlSpec = [[[self getBrowserWrapper] currentURI] UTF8String];
// Get the domain so that we can replace %d in our searchURL
if (NS_NewURI(getter_AddRefs(aURI), aURLSpec) == NS_OK) {
NSString *currentDomain = @"";
nsCOMPtr<nsIURI> currentURI;
if (NS_NewURI(getter_AddRefs(currentURI), urlSpec) == NS_OK) {
nsCAutoString spec;
aURI->GetHost(spec);
currentURI->GetHost(spec);
aDomain = [NSString stringWithUTF8String:spec.get()];
currentDomain = [NSString stringWithUTF8String:spec.get()];
}
// Escape the search string so the user can search for strings with
@@ -2624,7 +2632,7 @@ enum BWCOpenDest {
NSString *escapedSearchString = (NSString *) CFURLCreateStringByAddingPercentEscapes(NULL, (CFStringRef)searchString, NULL, CFSTR(";?:@&=+$,"), kCFStringEncodingUTF8);
// replace the conversion specifiers (%d, %s) in the search string
[self transformFormatString:searchURL domain:aDomain search:escapedSearchString];
[self transformFormatString:searchURL domain:currentDomain search:escapedSearchString];
[escapedSearchString release];
if (inDest == kDestinationNewTab)
@@ -4672,6 +4680,31 @@ enum BWCOpenDest {
return sBrokenIcon;
}
- (void)setUpSearchFields
{
NSDictionary* searchEngines = [BrowserWindowController searchURLDictionary];
NSArray* engineNames = [[searchEngines allKeys] sortedArrayUsingSelector:@selector(caseInsensitiveCompare:)];
NSMutableArray* engineList = [NSMutableArray arrayWithCapacity:([engineNames count] - 1)];
NSEnumerator* engineEnumerator = [engineNames objectEnumerator];
NSString* engineName;
while ((engineName = [engineEnumerator nextObject])) {
if ([engineName isEqualToString:@"PreferredSearchEngine"])
continue;
[engineList addObject:[NSDictionary dictionaryWithObjectsAndKeys:engineName,
kWebSearchEngineNameKey,
[searchEngines objectForKey:engineName],
kWebSearchEngineURLKey,
nil]];
}
[mSearchBar setSearchEngines:engineList];
[mSearchSheetTextField setSearchEngines:engineList];
NSString* defaultEngine = [searchEngines objectForKey:@"PreferredSearchEngine"];
[mSearchBar setCurrentSearchEngine:defaultEngine];
[mSearchSheetTextField setCurrentSearchEngine:defaultEngine];
}
+ (NSDictionary *)searchURLDictionary
{
static NSDictionary *searchURLDictionary = nil;
@@ -4680,42 +4713,27 @@ enum BWCOpenDest {
NSString *defaultSearchEngineList = [[NSBundle mainBundle] pathForResource:@"SearchURLList" ofType:@"plist"];
//
// We haven't read the search engine list yet attempt to read from user's profile directory
//
nsCOMPtr<nsIFile> aDir;
NS_GetSpecialDirectory(NS_APP_USER_PROFILE_50_DIR, getter_AddRefs(aDir));
if (aDir) {
nsCAutoString aDirPath;
nsresult rv = aDir->GetNativePath(aDirPath);
if (NS_SUCCEEDED(rv)) {
NSString *profileDir = [NSString stringWithUTF8String:aDirPath.get()];
// We haven't read the search engine list yet; attempt to read from user's profile directory
NSString *profileDir = [[PreferenceManager sharedInstance] profilePath];
if (profileDir) {
// If the file exists we read it from the profile directory
// If it doesn't we attempt to copy it there from our app bundle first
// (so that the user has something to edit in future)
NSString *searchEngineListPath = [profileDir stringByAppendingPathComponent:@"SearchURLList.plist"];
//
// If the file exists we read it from the profile directory
// If it doesn't we attempt to copy it there from our app bundle first
// (so that the user has something to edit in future)
//
NSString *searchEngineListPath = [profileDir stringByAppendingPathComponent:@"SearchURLList.plist"];
NSFileManager *fileManager = [NSFileManager defaultManager];
if ( [fileManager isReadableFileAtPath:searchEngineListPath] ||
[fileManager copyPath:defaultSearchEngineList toPath:searchEngineListPath handler:nil] )
searchURLDictionary = [[NSDictionary alloc] initWithContentsOfFile:searchEngineListPath];
else {
#if DEBUG
NSLog(@"Unable to copy search engine list to user profile directory");
#endif
}
}
NSFileManager *fileManager = [NSFileManager defaultManager];
if ([fileManager isReadableFileAtPath:searchEngineListPath] ||
[fileManager copyPath:defaultSearchEngineList toPath:searchEngineListPath handler:nil])
searchURLDictionary = [[NSDictionary alloc] initWithContentsOfFile:searchEngineListPath];
else {
#if DEBUG
NSLog(@"Unable to get profile directory");
NSLog(@"Unable to copy search engine list to user profile directory");
#endif
}
}
else {
#if DEBUG
NSLog(@"Unable to determine profile directory");
NSLog(@"Unable to get profile directory");
#endif
}
@@ -4875,7 +4893,8 @@ enum BWCOpenDest {
[self updateLocationFields:[mBrowserView currentURI] ignoreTyping:YES];
// see if command-return came in the search field
} else if ([mSearchBar isFirstResponder]) {
} else if ([[[self window] firstResponder] isKindOfClass:[NSView class]] &&
[(NSView*)[[self window] firstResponder] isDescendantOf:mSearchBar]) {
handled = YES;
[self performSearch:mSearchBar inView:destination inBackground:loadInBG];
}

View File

@@ -55,6 +55,9 @@ extern NSString* const NSMenuClosedNotification;
// turning on the one with the given unmasked tag value.
- (void)checkItemWithTag:(int)unmaskedTag inGroupWithMask:(int)tagMask;
// gets the first checked item in the menu, or nil if none are checked.
- (NSMenuItem*)firstCheckedItem;
// enable or disable all items in the menu including and after inFirstItem,
// optionally recursing into submenus.
- (void)setAllItemsEnabled:(BOOL)inEnable startingWithItemAtIndex:(int)inFirstItem includingSubmenus:(BOOL)includeSubmenus;

View File

@@ -133,6 +133,17 @@ static OSStatus MenuEventHandler(EventHandlerCallRef inHandlerCallRef, EventRef
}
}
- (NSMenuItem*)firstCheckedItem
{
NSEnumerator* itemsEnumerator = [[self itemArray] objectEnumerator];
NSMenuItem* currentItem;
while ((currentItem = [itemsEnumerator nextObject])) {
if ([currentItem state] == NSOnState)
return currentItem;
}
return nil;
}
- (void)setAllItemsEnabled:(BOOL)inEnable startingWithItemAtIndex:(int)inFirstItem includingSubmenus:(BOOL)includeSubmenus
{
NSArray* menuItems = [self itemArray];