From c7c52ea1ccf5271dce84cf58e37d0a069669ba8e Mon Sep 17 00:00:00 2001 From: "pinkerton%netscape.com" Date: Thu, 13 Nov 2003 18:21:02 +0000 Subject: [PATCH] make find panel more consistent with other cocoa apps (bug 160771) git-svn-id: svn://10.0.0.236/trunk@149256 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/camino/src/find/FindDlgController.h | 11 +- mozilla/camino/src/find/FindDlgController.mm | 112 ++++++++++++------ .../English.lproj/FindDialog.nib/classes.nib | 6 +- .../English.lproj/FindDialog.nib/info.nib | 14 ++- .../English.lproj/FindDialog.nib/objects.nib | Bin 2055 -> 2158 bytes 5 files changed, 98 insertions(+), 45 deletions(-) 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 27568a170bd6646209f30e9cffa7fa77bb12e25a..7f30c0bd254e0a3740c0db0904de91f89921c9f4 100644 GIT binary patch literal 2158 zcmaJ?-*4Mg6uxfL(5~s)tSi!{Aq5zqZoDuiG*yVDKU7u$X~7diARavDCNp#F;yBCt zFb!wd{sW@a)K5Wzzy`~pLs}nuH3=yXksvQT^Fs&_LK`5&0I_n8ZM z6`MNJoeCS#v6RnSIppoq?em1NwY3R6T3zCeT!mvVM^=DzD^innUi#ZJ=OAQO{;AvtXn{SC4&C?`M6P zj3jyZ99>@r&mr{e+OHEZdccG<<$7iIK2jFhrYvsF#R-{i= z4f4SbfUhiN_7IZUvjbq*H{p)mI{xA15(B^j>_XNsEt;5B^0W(flMUtbnozq#8v9CP zg!Gk8JpJOJQpyGr(_XyAqRq&&4Q)U{z@4f@VFH0hc# z*F%pwwr3Y6nbQ>A%zE{{>z6KG+}d(T-COmWRlipC8&$tm^*5@1HSjm9!Jr?&rU5a^ z{HExy=)C9G;I(()czy#jY)j+l6Q19K1sFnN2fS~XFb&1*V+ET32` z8ZeOk&E8!{L(#*g?HNjKm{0>CGkAcJzCgg?-5`!fV{b}MX{Q$pwoc*T7zTVUOv@pk zhociLowayneHG!yaxzsc^-Kr`<@(L~DrVoE6K4aD#*BHs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