From 4b51be5d1813f8d81eb5b370f535e5c1c46dba30 Mon Sep 17 00:00:00 2001 From: fredkiefer Date: Mon, 27 Dec 2010 13:44:18 +0000 Subject: [PATCH] Some coding standard changes for NSSearchField git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@31788 72102866-910b-0410-8b05-ffd578937521 --- ChangeLog | 5 ++++ Source/NSSearchField.m | 20 ++++++++------ Source/NSSearchFieldCell.m | 56 ++++++++++++++++++++------------------ 3 files changed, 46 insertions(+), 35 deletions(-) diff --git a/ChangeLog b/ChangeLog index fb599ccc0..1c78a1623 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2010-12-27 Fred Kiefer + + * Source/NSSearchField.m, + * Source/NSSearchFieldCell.m: Some coding standard changes. + 2010-12-27 Fred Kiefer * Source/GSDragView.m: Check whether the drag source supports diff --git a/Source/NSSearchField.m b/Source/NSSearchField.m index 6e3b9a695..f08e1665a 100644 --- a/Source/NSSearchField.m +++ b/Source/NSSearchField.m @@ -27,10 +27,11 @@ Boston, MA 02110-1301, USA. */ -#include -#include -#include -#include +#import +#import + +#import "AppKit/NSSearchField.h" +#import "AppKit/NSSearchFieldCell.h" /* * Class variables @@ -92,16 +93,17 @@ static Class usedCellClass; untilMouseUp: YES]; } -- (void)delete:(id)sender +- (void) delete: (id)sender { - [self setStringValue:@""]; // this may need to do more (like send action), but start here... - [[self cell] performClick:self]; + // this may need to do more (like send action), but start here... + [self setStringValue: @""]; + [[self cell] performClick: self]; } // Cocoa only defines these methods on the cell, but nib loading targets the field itself -- (void) setSearchMenuTemplate:(NSMenu *)newTemplate +- (void) setSearchMenuTemplate: (NSMenu *)newTemplate { - [[self cell] setSearchMenuTemplate:newTemplate]; + [[self cell] setSearchMenuTemplate: newTemplate]; } - (void) setSendsWholeSearchString: (BOOL)flag diff --git a/Source/NSSearchFieldCell.m b/Source/NSSearchFieldCell.m index 642053848..d012be749 100644 --- a/Source/NSSearchFieldCell.m +++ b/Source/NSSearchFieldCell.m @@ -29,19 +29,20 @@ Boston, MA 02110-1301, USA. */ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "AppKit/NSMenuView.h" -#include -#include "AppKit/NSWindow.h" +#import +#import +#import +#import +#import + +#import "AppKit/NSApplication.h" +#import "AppKit/NSButtonCell.h" +#import "AppKit/NSEvent.h" +#import "AppKit/NSImage.h" +#import "AppKit/NSMenu.h" +#import "AppKit/NSMenuView.h" +#import "AppKit/NSSearchFieldCell.h" +#import "AppKit/NSWindow.h" @interface NSSearchFieldCell (Private) @@ -82,8 +83,8 @@ //_recent_searches = [[NSMutableArray alloc] init]; //_recents_autosave_name = nil; - [self _loadSearches]; _max_recents = 10; + [self _loadSearches]; } return self; @@ -199,7 +200,7 @@ } else { - searches = [NSMutableArray arrayWithArray:searches]; + searches = [NSMutableArray arrayWithArray: searches]; } ASSIGN(_recent_searches, searches); [self _saveSearches]; @@ -212,9 +213,9 @@ ASSIGN(_recent_searches, [NSMutableArray array]); } if (searchTerm != nil && [searchTerm length] > 0 - && [_recent_searches indexOfObject:searchTerm] == NSNotFound) + && [_recent_searches indexOfObject: searchTerm] == NSNotFound) { - [_recent_searches addObject:searchTerm]; + [_recent_searches addObject: searchTerm]; [self _saveSearches]; } } @@ -229,9 +230,9 @@ ASSIGN(_menu_template, menu); if (menu) { - [[self searchButtonCell] setTarget:self]; - [[self searchButtonCell] setAction:@selector(_openPopup:)]; - [[self searchButtonCell] sendActionOn:NSLeftMouseDownMask]; + [[self searchButtonCell] setTarget: self]; + [[self searchButtonCell] setAction: @selector(_openPopup:)]; + [[self searchButtonCell] sendActionOn: NSLeftMouseDownMask]; } else { @@ -295,7 +296,7 @@ // [c setTarget: [self target]]; [c setAction: @selector(performClick:)]; [c setTarget: self]; - [c sendActionOn:NSLeftMouseUpMask]; + [c sendActionOn: NSLeftMouseUpMask]; [c setKeyEquivalent: @"\r"]; [c setKeyEquivalentModifierMask: 0]; } @@ -361,7 +362,7 @@ - (void) endEditing: (NSText *)editor { - [self addToRecentSearches:[[[editor string] copy] autorelease]]; + [self addToRecentSearches: [[[editor string] copy] autorelease]]; [super endEditing: editor]; [[NSNotificationCenter defaultCenter] removeObserver: self @@ -558,6 +559,7 @@ { return NO; } + - (void) selectItemAtIndex:(int)anIndex { // do nothing @@ -572,7 +574,6 @@ NSRect cellFrame; int i; int recentCount = [_recent_searches count]; - // NSRect textRect; template = [self searchMenuTemplate]; popupmenu = [[NSMenu alloc] init]; @@ -652,15 +653,16 @@ // Last, display the window [[mr window] orderFrontRegardless]; - [mr mouseDown:[NSApp currentEvent]]; + [mr mouseDown: [NSApp currentEvent]]; AUTORELEASE(popupmenu); } - (void) _searchForRecent: (id)sender { NSString *searchTerm = [sender title]; - [(id)_control_view setStringValue:searchTerm]; - [self performClick:self]; // do the search + + [(id)_control_view setStringValue: searchTerm]; + [self performClick: self]; // do the search } - (void) _clearSearches: (id)sender @@ -672,6 +674,7 @@ { NSArray *list; NSString *name = [self recentsAutosaveName]; + if (name) { list = [[NSUserDefaults standardUserDefaults] @@ -684,6 +687,7 @@ { NSArray *list = [self recentSearches]; NSString *name = [self recentsAutosaveName]; + if (name && list) { [[NSUserDefaults standardUserDefaults]