From ce6009fe8b04138d38759315a49bcb1422f768d5 Mon Sep 17 00:00:00 2001 From: Fred Kiefer Date: Mon, 7 Sep 2009 14:08:37 +0000 Subject: [PATCH] * Headers/AppKit/NSSearchFieldCell.h: Add version #ifdef's. * Source/NSSearchFieldCell.m (-encodeWithCoder:, -initWithCoder:): Correct encoding/decoding of maximumRecents. Based on patch by Quentin Mathe . git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@28623 72102866-910b-0410-8b05-ffd578937521 --- ChangeLog | 7 +++++ Headers/AppKit/NSSearchFieldCell.h | 9 ++++-- Source/NSSearchFieldCell.m | 44 ++++++++++++++++++++---------- 3 files changed, 44 insertions(+), 16 deletions(-) diff --git a/ChangeLog b/ChangeLog index 499490de6..8a83bf40b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2009-09-07 Fred Kiefer + + * Headers/AppKit/NSSearchFieldCell.h: Add version #ifdef's. + * Source/NSSearchFieldCell.m (-encodeWithCoder:, -initWithCoder:): + Correct encoding/decoding of maximumRecents. + Based on patch by Quentin Mathe . + 2009-09-06 Fred Kiefer * Source/NSPopUpButton.m (-selectedTag): Return the tag of the diff --git a/Headers/AppKit/NSSearchFieldCell.h b/Headers/AppKit/NSSearchFieldCell.h index 1268c853f..a8a09e722 100644 --- a/Headers/AppKit/NSSearchFieldCell.h +++ b/Headers/AppKit/NSSearchFieldCell.h @@ -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 @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 */ diff --git a/Source/NSSearchFieldCell.m b/Source/NSSearchFieldCell.m index 1d8faaf3f..5c83cd52c 100644 --- a/Source/NSSearchFieldCell.m +++ b/Source/NSSearchFieldCell.m @@ -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 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]; } }