* 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> 2009-09-06 Fred Kiefer <FredKiefer@gmx.de>
* Source/NSPopUpButton.m (-selectedTag): Return the tag of the * Source/NSPopUpButton.m (-selectedTag): Return the tag of the

View file

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

View file

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