mirror of
https://github.com/gnustep/libs-gui.git
synced 2025-05-31 19:00:47 +00:00
Implemented [URL]. New methods [_setupForDirectory:file:] and
[_shouldShowExtension:isDir:]. Removed check for extension filter in [init]. Simplified [runModalForDirectory:file:]. Implemented [runModalForDirectory:...relativeToWindow:] and [beginSheetForDirectory:...]. In [browser:createRowsForColumn:inMatrix:] allways call [_shouldShowExtension:isDir:]. git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@10925 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
fc1f564fbb
commit
9f73eabf91
1 changed files with 79 additions and 55 deletions
|
@ -59,14 +59,6 @@ static NSFileManager *_fm = nil;
|
||||||
|
|
||||||
static BOOL _gs_display_reading_progress = NO;
|
static BOOL _gs_display_reading_progress = NO;
|
||||||
|
|
||||||
// Pacify the compiler
|
|
||||||
// Subclasses (read NSOpenPanel) may implement this
|
|
||||||
// to filter some extensions out of displayed files.
|
|
||||||
@interface NSObject (_SavePanelPrivate)
|
|
||||||
-(BOOL) _shouldShowExtension: (NSString*)extension isDir: (BOOL *)isDir;
|
|
||||||
@end
|
|
||||||
//
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// NSSavePanel private methods
|
// NSSavePanel private methods
|
||||||
//
|
//
|
||||||
|
@ -82,7 +74,8 @@ static BOOL _gs_display_reading_progress = NO;
|
||||||
- (void) _unmountMedia;
|
- (void) _unmountMedia;
|
||||||
- (void) _selectTextInColumn: (int)column;
|
- (void) _selectTextInColumn: (int)column;
|
||||||
- (void) _selectCellName: (NSString *)title;
|
- (void) _selectCellName: (NSString *)title;
|
||||||
|
- (void) _setupForDirectory: (NSString *)path file: (NSString *)name;
|
||||||
|
- (BOOL) _shouldShowExtension: (NSString *)extension isDir: (BOOL *)isDir;
|
||||||
@end /* NSSavePanel (PrivateMethods) */
|
@end /* NSSavePanel (PrivateMethods) */
|
||||||
|
|
||||||
@implementation NSSavePanel (_PrivateMethods)
|
@implementation NSSavePanel (_PrivateMethods)
|
||||||
|
@ -398,6 +391,47 @@ static BOOL _gs_display_reading_progress = NO;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (void) _setupForDirectory: (NSString *)path file: (NSString *)filename
|
||||||
|
{
|
||||||
|
if (path == nil || filename == nil)
|
||||||
|
[NSException raise: NSInvalidArgumentException
|
||||||
|
format: @"NSSavePanel runModalForDirectory:file: "
|
||||||
|
@"does not accept nil arguments."];
|
||||||
|
|
||||||
|
ASSIGN (_directory, path);
|
||||||
|
ASSIGN (_fullFileName, [path stringByAppendingPathComponent: filename]);
|
||||||
|
[_browser setPath: _fullFileName];
|
||||||
|
|
||||||
|
[self _selectCellName:filename];
|
||||||
|
[[_form cellAtIndex: 0] setStringValue: filename];
|
||||||
|
[_form selectTextAtIndex: 0];
|
||||||
|
[_form setNeedsDisplay: YES];
|
||||||
|
|
||||||
|
/*
|
||||||
|
* We need to take care of the possibility of
|
||||||
|
* the panel being aborted. We return NSCancelButton
|
||||||
|
* in that case.
|
||||||
|
*/
|
||||||
|
_OKButtonPressed = NO;
|
||||||
|
|
||||||
|
[self browser: _browser
|
||||||
|
selectCellWithString: [[_browser selectedCell] stringValue]
|
||||||
|
inColumn: [_browser selectedColumn]];
|
||||||
|
}
|
||||||
|
|
||||||
|
- (BOOL) _shouldShowExtension: (NSString *)extension
|
||||||
|
isDir: (BOOL *)isDir;
|
||||||
|
{
|
||||||
|
if (_treatsFilePackagesAsDirectories == NO && *isDir == YES &&
|
||||||
|
![extension isEqualToString: @""])
|
||||||
|
{
|
||||||
|
if ([extension isEqualToString: _requiredFileType] == YES)
|
||||||
|
*isDir = NO;
|
||||||
|
}
|
||||||
|
|
||||||
|
return YES;
|
||||||
|
}
|
||||||
|
|
||||||
@end /* NSSavePanel (PrivateMethods) */
|
@end /* NSSavePanel (PrivateMethods) */
|
||||||
|
|
||||||
//
|
//
|
||||||
|
@ -460,11 +494,6 @@ static BOOL _gs_display_reading_progress = NO;
|
||||||
_delegateHasShowFilenameFilter = NO;
|
_delegateHasShowFilenameFilter = NO;
|
||||||
_delegateHasValidNameFilter = NO;
|
_delegateHasValidNameFilter = NO;
|
||||||
|
|
||||||
if ([self respondsToSelector: @selector(_shouldShowExtension:isDir:)])
|
|
||||||
_selfHasShowExtensionFilter = YES;
|
|
||||||
else
|
|
||||||
_selfHasShowExtensionFilter = NO;
|
|
||||||
|
|
||||||
[self _getOriginalSize];
|
[self _getOriginalSize];
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
@ -670,37 +699,7 @@ static BOOL _gs_display_reading_progress = NO;
|
||||||
|
|
||||||
- (int) runModalForDirectory: (NSString*)path file: (NSString*)filename
|
- (int) runModalForDirectory: (NSString*)path file: (NSString*)filename
|
||||||
{
|
{
|
||||||
if (path == nil || filename == nil)
|
[self _setupForDirectory: path file: filename];
|
||||||
[NSException raise: NSInvalidArgumentException
|
|
||||||
format: @"NSSavePanel runModalForDirectory:file: "
|
|
||||||
@"does not accept nil arguments."];
|
|
||||||
|
|
||||||
ASSIGN (_directory, path);
|
|
||||||
ASSIGN (_fullFileName, [path stringByAppendingPathComponent: filename]);
|
|
||||||
[_browser setPath: _fullFileName];
|
|
||||||
|
|
||||||
[self _selectCellName:filename];
|
|
||||||
[[_form cellAtIndex: 0] setStringValue: filename];
|
|
||||||
[_form selectTextAtIndex:0];
|
|
||||||
[_form setNeedsDisplay: YES];
|
|
||||||
|
|
||||||
if([self isKindOfClass:[NSOpenPanel class]] == NO)
|
|
||||||
{
|
|
||||||
if([filename isEqual:@""] == NO)
|
|
||||||
[_okButton setEnabled:YES];
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* We need to take care of the possibility of
|
|
||||||
* the panel being aborted. We return NSCancelButton
|
|
||||||
* in that case.
|
|
||||||
*/
|
|
||||||
_OKButtonPressed = NO;
|
|
||||||
|
|
||||||
[self browser: _browser
|
|
||||||
selectCellWithString: [[_browser selectedCell] stringValue]
|
|
||||||
inColumn: [_browser selectedColumn]];
|
|
||||||
|
|
||||||
[NSApp runModalForWindow: self];
|
[NSApp runModalForWindow: self];
|
||||||
|
|
||||||
if (_OKButtonPressed)
|
if (_OKButtonPressed)
|
||||||
|
@ -709,6 +708,35 @@ static BOOL _gs_display_reading_progress = NO;
|
||||||
return NSCancelButton;
|
return NSCancelButton;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (int) runModalForDirectory: (NSString *)path
|
||||||
|
file: (NSString *)filename
|
||||||
|
relativeToWindow: (NSWindow*)window
|
||||||
|
{
|
||||||
|
[self _setupForDirectory: path file: filename];
|
||||||
|
[NSApp runModalForWindow: self
|
||||||
|
relativeToWindow: window];
|
||||||
|
|
||||||
|
if (_OKButtonPressed)
|
||||||
|
return NSOKButton;
|
||||||
|
else
|
||||||
|
return NSCancelButton;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void) beginSheetForDirectory: (NSString *)path
|
||||||
|
file: (NSString *)filename
|
||||||
|
modalForWindow: (NSWindow *)docWindow
|
||||||
|
modalDelegate: (id)delegate
|
||||||
|
didEndSelector: (SEL)didEndSelector
|
||||||
|
contextInfo: (void *)contextInfo
|
||||||
|
{
|
||||||
|
[self _setupForDirectory: path file: filename];
|
||||||
|
[NSApp beginSheet: self
|
||||||
|
modalForWindow: docWindow
|
||||||
|
modalDelegate: delegate
|
||||||
|
didEndSelector: didEndSelector
|
||||||
|
contextInfo: contextInfo];
|
||||||
|
}
|
||||||
|
|
||||||
- (NSString*) directory
|
- (NSString*) directory
|
||||||
{
|
{
|
||||||
if (_directory)
|
if (_directory)
|
||||||
|
@ -735,6 +763,11 @@ static BOOL _gs_display_reading_progress = NO;
|
||||||
return [_fullFileName stringByAppendingPathExtension: _requiredFileType];
|
return [_fullFileName stringByAppendingPathExtension: _requiredFileType];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (NSURL *) URL
|
||||||
|
{
|
||||||
|
return [NSURL fileURLWithPath: [self filename]];
|
||||||
|
}
|
||||||
|
|
||||||
- (void) cancel: (id)sender
|
- (void) cancel: (id)sender
|
||||||
{
|
{
|
||||||
_fullFileName = nil;
|
_fullFileName = nil;
|
||||||
|
@ -1077,16 +1110,7 @@ createRowsForColumn: (int)column
|
||||||
shouldShowFilename: pathAndFile];
|
shouldShowFilename: pathAndFile];
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_treatsFilePackagesAsDirectories == NO && isDir == YES && exists
|
if (exists)
|
||||||
&& ![extension isEqualToString: @""])
|
|
||||||
{
|
|
||||||
// Ones with more chance first
|
|
||||||
if ([self isMemberOfClass: [NSSavePanel class]] == YES)
|
|
||||||
if ([extension isEqualToString: _requiredFileType] == YES)
|
|
||||||
isDir = NO;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (_selfHasShowExtensionFilter && exists)
|
|
||||||
{
|
{
|
||||||
exists = [self _shouldShowExtension: extension isDir: &isDir];
|
exists = [self _shouldShowExtension: extension isDir: &isDir];
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue