* Headers/AppKit/NSSearchFieldCell.h: Add version #ifdef's.

* Source/NSSearchFieldCell.m (-encodeWithCoder:, -initWithCoder:):
  Correct encoding/decoding of maximumRecents.
  Based on patch by Quentin Mathe <quentin.mathe@gmail.com>.


git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@28623 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Fred Kiefer 2009-09-07 14:08:37 +00:00
parent fd8ebd6a78
commit ce6009fe8b
3 changed files with 44 additions and 16 deletions

View file

@ -1,3 +1,10 @@
2009-09-07 Fred Kiefer <FredKiefer@gmx.de>
* Headers/AppKit/NSSearchFieldCell.h: Add version #ifdef's.
* Source/NSSearchFieldCell.m (-encodeWithCoder:, -initWithCoder:):
Correct encoding/decoding of maximumRecents.
Based on patch by Quentin Mathe <quentin.mathe@gmail.com>.
2009-09-06 Fred Kiefer <FredKiefer@gmx.de>
* Source/NSPopUpButton.m (-selectedTag): Return the tag of the

View file

@ -30,6 +30,8 @@
#ifndef _GNUstep_H_NSSearchFieldCell
#define _GNUstep_H_NSSearchFieldCell
#if OS_API_VERSION(MAC_OS_X_VERSION_10_3, GS_API_LATEST)
#include <AppKit/NSTextFieldCell.h>
@class NSButtonCell;
@ -75,12 +77,14 @@ enum
// search mode
- (BOOL) sendsWholeSearchString;
- (void) setSendsWholeSearchString: (BOOL)flag;
#if OS_API_VERSION(MAC_OS_X_VERSION_10_4, GS_API_LATEST)
- (BOOL) sendsSearchStringImmediately;
- (void) setSendsSearchStringImmediately: (BOOL)flag;
#endif
// search results
- (int) maximumRecents;
- (void) setMaximumRecents: (int)max;
- (NSInteger) maximumRecents;
- (void) setMaximumRecents: (NSInteger)max;
- (NSArray *) recentSearches;
- (NSString *) recentsAutosaveName;
- (void) setRecentSearches: (NSArray *)searches;
@ -88,4 +92,5 @@ enum
@end
#endif
#endif /* _GNUstep_H_NSSearchFieldCell */

View file

@ -150,12 +150,12 @@
_sends_search_string_immediatly = flag;
}
- (int) maximumRecents
- (NSInteger) maximumRecents
{
return _max_recents;
}
- (void) setMaximumRecents: (int)max
- (void) setMaximumRecents: (NSInteger)max
{
if (max > 254)
{
@ -448,22 +448,35 @@
//
- (void) encodeWithCoder: (NSCoder*)aCoder
{
NSInteger max = [self maximumRecents];
[super encodeWithCoder: aCoder];
[aCoder encodeObject: _search_button_cell];
[aCoder encodeObject: _cancel_button_cell];
[aCoder encodeObject: _recents_autosave_name];
[aCoder encodeValueOfObjCType: @encode(BOOL)
at: &_sends_whole_search_string];
[aCoder encodeValueOfObjCType: @encode(unsigned int)
at: &_max_recents];
if ([aCoder allowsKeyedCoding])
{
[aCoder encodeObject: _search_button_cell forKey: @"NSSearchButtonCell"];
[aCoder encodeObject: _cancel_button_cell forKey: @"NSCancelButtonCell"];
[aCoder encodeObject: _recents_autosave_name forKey: @"NSRecentsAutosaveName"];
[aCoder encodeBool: _sends_whole_search_string forKey: @"NSSendsWholeSearchString"];
[aCoder encodeInt: max forKey: @"NSMaximumRecents"];
}
else
{
[aCoder encodeObject: _search_button_cell];
[aCoder encodeObject: _cancel_button_cell];
[aCoder encodeObject: _recents_autosave_name];
[aCoder encodeValueOfObjCType: @encode(BOOL)
at: &_sends_whole_search_string];
[aCoder encodeValueOfObjCType: @encode(unsigned int)
at: &max];
}
}
- (id) initWithCoder: (NSCoder*)aDecoder
{
self = [super initWithCoder: aDecoder];
if(self != nil)
if (self != nil)
{
if ([aDecoder allowsKeyedCoding])
{
@ -475,11 +488,14 @@
}
else
{
NSInteger max;
[self setSearchButtonCell: [aDecoder decodeObject]];
[self setCancelButtonCell: [aDecoder decodeObject]];
[self setRecentsAutosaveName: [aDecoder decodeObject]];
[aDecoder decodeValueOfObjCType: @encode(BOOL) at: &_sends_whole_search_string];
[aDecoder decodeValueOfObjCType: @encode(unsigned int) at: &_max_recents];
[aDecoder decodeValueOfObjCType: @encode(unsigned int) at: &max];
[self setMaximumRecents: max];
}
[self resetCancelButtonCell];
@ -586,13 +602,13 @@
for (j = 0; j < recentCount; j++)
{
NSMenuItem *searchItem = [popupmenu addItemWithTitle:
id <NSMenuItem> searchItem = [popupmenu addItemWithTitle:
[_recent_searches objectAtIndex: j]
action:
@selector(_searchForRecent:)
keyEquivalent:
[item keyEquivalent]];
[searchItem setTarget:self];
[searchItem setTarget: self];
}
}
else // copy all other items without special tags from the template into the popup
@ -602,7 +618,7 @@
if (newItem != nil)
{
[popupmenu addItem:newItem];
[popupmenu addItem: newItem];
}
}