diff --git a/mozilla/camino/src/find/FindDlgController.h b/mozilla/camino/src/find/FindDlgController.h index f8153a5ca53..441d893e732 100644 --- a/mozilla/camino/src/find/FindDlgController.h +++ b/mozilla/camino/src/find/FindDlgController.h @@ -41,13 +41,16 @@ IBOutlet NSTextField* mSearchField; IBOutlet NSButton* mIgnoreCaseBox; IBOutlet NSButton* mWrapAroundBox; - IBOutlet NSButton* mSearchBackwardsBox; - IBOutlet NSButton* mFindButton; + IBOutlet NSButton* mFindNextButton; + IBOutlet NSButton* mFindPrevButton; } -- (IBAction) find: (id)aSender; +- (IBAction) findNextButton: (id)aSender; +- (IBAction) findPreviousButton: (id)aSender; +- (IBAction) findNextAndOrderOut: (id)aSender; // delegates for NSTextView - (void)controlTextDidChange:(NSNotification *)aNotification; - +- (void)loadFindStringFromPasteboard; +- (void)putFindStringOnPasteboard; @end diff --git a/mozilla/camino/src/find/FindDlgController.mm b/mozilla/camino/src/find/FindDlgController.mm index bdaa3bb12be..30910fcd29a 100644 --- a/mozilla/camino/src/find/FindDlgController.mm +++ b/mozilla/camino/src/find/FindDlgController.mm @@ -39,75 +39,121 @@ #import "Find.h" @interface FindDlgController(Private) - - (NSString*)getSearchText; +- (NSString*)getSearchText; +- (BOOL)find:(BOOL)searchBack; @end @implementation FindDlgController +- (void)loadFindStringFromPasteboard +{ + NSPasteboard *pasteboard = [NSPasteboard pasteboardWithName:NSFindPboard]; + if ([[pasteboard types] containsObject:NSStringPboardType]) { + NSString *string = [pasteboard stringForType:NSStringPboardType]; + if (string && [string length]) { + [mSearchField setStringValue: string]; + [mFindNextButton setEnabled:YES]; + [mFindPrevButton setEnabled:YES]; + } + } +} + +- (void)putFindStringOnPasteboard +{ + NSPasteboard *pasteboard = [NSPasteboard pasteboardWithName:NSFindPboard]; + [pasteboard declareTypes:[NSArray arrayWithObject:NSStringPboardType] owner:nil]; + [pasteboard setString:[mSearchField stringValue] forType:NSStringPboardType]; +} + // // -find // -// User clicked the find button, send the action to the window controller of the -// frontmost browser window. If we found something, hide the window. If not, beep. +// Performs the actual search. returns YES on success. // --(IBAction) find: (id)aSender + +-(BOOL) find:(BOOL)searchBack { NSWindowController* controller = [[NSApp mainWindow] windowController]; if ( [controller conformsToProtocol:@protocol(Find)] ) { id browserController = controller; BOOL ignoreCase = [mIgnoreCaseBox state]; BOOL wrapSearch = [mWrapAroundBox state]; - BOOL searchBack = [mSearchBackwardsBox state]; - - BOOL found = [browserController findInPageWithPattern:[mSearchField stringValue] - caseSensitive:!ignoreCase wrap:wrapSearch - backwards:searchBack]; - - if (! found ) - NSBeep(); - // we stay open - } + return [browserController findInPageWithPattern:[mSearchField stringValue] caseSensitive:!ignoreCase wrap:wrapSearch backwards:searchBack]; + } else + return NO; +} + +- (IBAction) findNextButton: (id)aSender +{ + [self putFindStringOnPasteboard]; + if (![self find:NO]) + NSBeep(); +} + +- (IBAction) findPreviousButton: (id)aSender +{ + [self putFindStringOnPasteboard]; + if (![self find:YES]) NSBeep(); } +- (IBAction) findNextAndOrderOut: (id)aSender +{ + [self putFindStringOnPasteboard]; + if (![self find:NO]) + NSBeep(); + else + [self close]; +} + // -// controlTextDidChange +// -controlTextDidChange: // // Check if there is anything in the text field, and if not, disable the find button // - (void)controlTextDidChange:(NSNotification *)aNotification { - if ( [[mSearchField stringValue] length] ) - [mFindButton setEnabled:YES]; - else - [mFindButton setEnabled:NO]; + if ( [[mSearchField stringValue] length] ) { + [mFindNextButton setEnabled:YES]; + [mFindPrevButton setEnabled:YES]; + } + else { + [mFindNextButton setEnabled:NO]; + [mFindPrevButton setEnabled:NO]; + } } +// +// -getSearchText +// // Retrieve the most recent search string +// - (NSString*)getSearchText { - NSWindowController* controller = [[NSApp mainWindow] windowController]; - if (![controller conformsToProtocol:@protocol(Find)]) - return nil; + NSPasteboard *findPboard = [NSPasteboard pasteboardWithName:NSFindPboard]; + if ([[findPboard types] indexOfObject:NSStringPboardType] != NSNotFound) + return [findPboard stringForType:NSStringPboardType]; - id browserController = controller; - return [browserController lastFindText]; + return [NSString string]; } +// +// -showWindow: +// +// override to set the current search text in the text area before showing +// the window +// - (IBAction)showWindow:(id)sender { - // Sync our text field with the most recent browser search string. - // We assume here that the frontmost window is a browser window. - - NSWindowController* controller = [[NSApp mainWindow] windowController]; - if ( [controller conformsToProtocol:@protocol(Find)] ) { - id browserController = controller; - [mSearchField setStringValue:[browserController lastFindText]]; - } - + [mSearchField setStringValue:[self getSearchText]]; [super showWindow:sender]; } +-(void)windowDidLoad +{ + [mSearchField setStringValue:[self getSearchText]]; +} + @end diff --git a/mozilla/chimera/resources/localized/English.lproj/FindDialog.nib/classes.nib b/mozilla/chimera/resources/localized/English.lproj/FindDialog.nib/classes.nib index b0d20da5dca..008505933ef 100644 --- a/mozilla/chimera/resources/localized/English.lproj/FindDialog.nib/classes.nib +++ b/mozilla/chimera/resources/localized/English.lproj/FindDialog.nib/classes.nib @@ -1,13 +1,13 @@ { IBClasses = ( { - ACTIONS = {find = id; }; + ACTIONS = {findNextAndOrderOut = id; findNextButton = id; findPreviousButton = id; }; CLASS = FindDlgController; LANGUAGE = ObjC; OUTLETS = { - mFindButton = NSButton; + mFindNextButton = NSButton; + mFindPrevButton = NSButton; mIgnoreCaseBox = NSButton; - mSearchBackwardsBox = NSButton; mSearchField = NSTextField; mWrapAroundBox = NSButton; }; diff --git a/mozilla/chimera/resources/localized/English.lproj/FindDialog.nib/info.nib b/mozilla/chimera/resources/localized/English.lproj/FindDialog.nib/info.nib index 681cc6970ac..162ee78befb 100644 --- a/mozilla/chimera/resources/localized/English.lproj/FindDialog.nib/info.nib +++ b/mozilla/chimera/resources/localized/English.lproj/FindDialog.nib/info.nib @@ -1,12 +1,16 @@ - - + + IBDocumentLocation - 180 86 356 240 0 0 1152 746 + 178 292 356 240 0 0 1152 848 IBFramework Version - 248.0 + 349.0 + IBOpenObjects + + 5 + IBSystem Version - 5S66 + 7B85 diff --git a/mozilla/chimera/resources/localized/English.lproj/FindDialog.nib/objects.nib b/mozilla/chimera/resources/localized/English.lproj/FindDialog.nib/objects.nib index 27568a170bd..7f30c0bd254 100644 Binary files a/mozilla/chimera/resources/localized/English.lproj/FindDialog.nib/objects.nib and b/mozilla/chimera/resources/localized/English.lproj/FindDialog.nib/objects.nib differ