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
This commit is contained in:
fredkiefer 2010-12-27 13:44:18 +00:00
parent 030f54c33b
commit 4b51be5d18
3 changed files with 46 additions and 35 deletions

View file

@ -1,3 +1,8 @@
2010-12-27 Fred Kiefer <FredKiefer@gmx.de>
* Source/NSSearchField.m,
* Source/NSSearchFieldCell.m: Some coding standard changes.
2010-12-27 Fred Kiefer <FredKiefer@gmx.de> 2010-12-27 Fred Kiefer <FredKiefer@gmx.de>
* Source/GSDragView.m: Check whether the drag source supports * Source/GSDragView.m: Check whether the drag source supports

View file

@ -27,10 +27,11 @@
Boston, MA 02110-1301, USA. Boston, MA 02110-1301, USA.
*/ */
#include <Foundation/NSString.h> #import <Foundation/NSString.h>
#include <Foundation/NSArray.h> #import <Foundation/NSArray.h>
#include <AppKit/NSSearchField.h>
#include <AppKit/NSSearchFieldCell.h> #import "AppKit/NSSearchField.h"
#import "AppKit/NSSearchFieldCell.h"
/* /*
* Class variables * Class variables
@ -92,16 +93,17 @@ static Class usedCellClass;
untilMouseUp: YES]; untilMouseUp: YES];
} }
- (void)delete:(id)sender - (void) delete: (id)sender
{ {
[self setStringValue:@""]; // this may need to do more (like send action), but start here... // this may need to do more (like send action), but start here...
[[self cell] performClick:self]; [self setStringValue: @""];
[[self cell] performClick: self];
} }
// Cocoa only defines these methods on the cell, but nib loading targets the field itself // 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 - (void) setSendsWholeSearchString: (BOOL)flag

View file

@ -29,19 +29,20 @@
Boston, MA 02110-1301, USA. Boston, MA 02110-1301, USA.
*/ */
#include <Foundation/NSArray.h> #import <Foundation/NSArray.h>
#include <Foundation/NSException.h> #import <Foundation/NSException.h>
#include <Foundation/NSNotification.h> #import <Foundation/NSNotification.h>
#include <Foundation/NSString.h> #import <Foundation/NSString.h>
#include <Foundation/NSUserDefaults.h> #import <Foundation/NSUserDefaults.h>
#include <AppKit/NSApplication.h>
#include <AppKit/NSButtonCell.h> #import "AppKit/NSApplication.h"
#include <AppKit/NSEvent.h> #import "AppKit/NSButtonCell.h"
#include <AppKit/NSImage.h> #import "AppKit/NSEvent.h"
#include <AppKit/NSMenu.h> #import "AppKit/NSImage.h"
#include "AppKit/NSMenuView.h" #import "AppKit/NSMenu.h"
#include <AppKit/NSSearchFieldCell.h> #import "AppKit/NSMenuView.h"
#include "AppKit/NSWindow.h" #import "AppKit/NSSearchFieldCell.h"
#import "AppKit/NSWindow.h"
@interface NSSearchFieldCell (Private) @interface NSSearchFieldCell (Private)
@ -82,8 +83,8 @@
//_recent_searches = [[NSMutableArray alloc] init]; //_recent_searches = [[NSMutableArray alloc] init];
//_recents_autosave_name = nil; //_recents_autosave_name = nil;
[self _loadSearches];
_max_recents = 10; _max_recents = 10;
[self _loadSearches];
} }
return self; return self;
@ -199,7 +200,7 @@
} }
else else
{ {
searches = [NSMutableArray arrayWithArray:searches]; searches = [NSMutableArray arrayWithArray: searches];
} }
ASSIGN(_recent_searches, searches); ASSIGN(_recent_searches, searches);
[self _saveSearches]; [self _saveSearches];
@ -212,9 +213,9 @@
ASSIGN(_recent_searches, [NSMutableArray array]); ASSIGN(_recent_searches, [NSMutableArray array]);
} }
if (searchTerm != nil && [searchTerm length] > 0 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]; [self _saveSearches];
} }
} }
@ -229,9 +230,9 @@
ASSIGN(_menu_template, menu); ASSIGN(_menu_template, menu);
if (menu) if (menu)
{ {
[[self searchButtonCell] setTarget:self]; [[self searchButtonCell] setTarget: self];
[[self searchButtonCell] setAction:@selector(_openPopup:)]; [[self searchButtonCell] setAction: @selector(_openPopup:)];
[[self searchButtonCell] sendActionOn:NSLeftMouseDownMask]; [[self searchButtonCell] sendActionOn: NSLeftMouseDownMask];
} }
else else
{ {
@ -295,7 +296,7 @@
// [c setTarget: [self target]]; // [c setTarget: [self target]];
[c setAction: @selector(performClick:)]; [c setAction: @selector(performClick:)];
[c setTarget: self]; [c setTarget: self];
[c sendActionOn:NSLeftMouseUpMask]; [c sendActionOn: NSLeftMouseUpMask];
[c setKeyEquivalent: @"\r"]; [c setKeyEquivalent: @"\r"];
[c setKeyEquivalentModifierMask: 0]; [c setKeyEquivalentModifierMask: 0];
} }
@ -361,7 +362,7 @@
- (void) endEditing: (NSText *)editor - (void) endEditing: (NSText *)editor
{ {
[self addToRecentSearches:[[[editor string] copy] autorelease]]; [self addToRecentSearches: [[[editor string] copy] autorelease]];
[super endEditing: editor]; [super endEditing: editor];
[[NSNotificationCenter defaultCenter] [[NSNotificationCenter defaultCenter]
removeObserver: self removeObserver: self
@ -558,6 +559,7 @@
{ {
return NO; return NO;
} }
- (void) selectItemAtIndex:(int)anIndex - (void) selectItemAtIndex:(int)anIndex
{ {
// do nothing // do nothing
@ -572,7 +574,6 @@
NSRect cellFrame; NSRect cellFrame;
int i; int i;
int recentCount = [_recent_searches count]; int recentCount = [_recent_searches count];
// NSRect textRect;
template = [self searchMenuTemplate]; template = [self searchMenuTemplate];
popupmenu = [[NSMenu alloc] init]; popupmenu = [[NSMenu alloc] init];
@ -652,15 +653,16 @@
// Last, display the window // Last, display the window
[[mr window] orderFrontRegardless]; [[mr window] orderFrontRegardless];
[mr mouseDown:[NSApp currentEvent]]; [mr mouseDown: [NSApp currentEvent]];
AUTORELEASE(popupmenu); AUTORELEASE(popupmenu);
} }
- (void) _searchForRecent: (id)sender - (void) _searchForRecent: (id)sender
{ {
NSString *searchTerm = [sender title]; 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 - (void) _clearSearches: (id)sender
@ -672,6 +674,7 @@
{ {
NSArray *list; NSArray *list;
NSString *name = [self recentsAutosaveName]; NSString *name = [self recentsAutosaveName];
if (name) if (name)
{ {
list = [[NSUserDefaults standardUserDefaults] list = [[NSUserDefaults standardUserDefaults]
@ -684,6 +687,7 @@
{ {
NSArray *list = [self recentSearches]; NSArray *list = [self recentSearches];
NSString *name = [self recentsAutosaveName]; NSString *name = [self recentsAutosaveName];
if (name && list) if (name && list)
{ {
[[NSUserDefaults standardUserDefaults] [[NSUserDefaults standardUserDefaults]