Use default filename from user defaults.

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@20752 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Fred Kiefer 2005-02-19 17:00:00 +00:00
parent f9a7c84e10
commit f351b52085
3 changed files with 44 additions and 30 deletions

View file

@ -1,3 +1,17 @@
2005-02-19 Fred Kiefer <FredKiefer@gmx.de>
* Source/NSSavePanel.m (-_setDefaultDirectory): New method to get
default directory from user defaults (NSDefaultOpenDirectory).
(-_resetDefaults): Use it for setting of default directory.
(-_setupForDirectory:file:): Use the new method here as well if no
path is provided. Cleaned up this method.
(-cancel:) Don't clean up filename and set directory to current.
(-ok:) Don't set _OKButtonPressed.
* Source/NSOpenPanel.m (-ok:): Don't set _OKButtonPressed.
(-_setupForDirectory:file:): Removed code duplicating super class
implementation.
This fixes most of bug #7900.
2005-02-14 Fred Kiefer <FredKiefer@gmx.de>
* Source/NSPopupButton.m (-mouseDown:): Moved code from here ...

View file

@ -205,17 +205,8 @@ static NSOpenPanel *_gs_gui_open_panel = nil;
- (void) _setupForDirectory: (NSString *)path file: (NSString *)filename
{
if (path == nil)
{
if (_directory)
path = _directory;
else
path = [[NSFileManager defaultManager] currentDirectoryPath];
}
if (filename == nil)
filename = @"";
else if ([filename isEqual: @""] == NO)
// FIXME: Not sure if this is needed
if ((filename == nil) || ([filename isEqual: @""] == NO))
[_okButton setEnabled: YES];
if (_canChooseDirectories == NO)
@ -556,9 +547,7 @@ static NSOpenPanel *_gs_gui_open_panel = nil;
}
}
_OKButtonPressed = YES;
[NSApp stopModalWithCode: NSOKButton];
[self close];
}

View file

@ -79,6 +79,7 @@ static BOOL _gs_display_reading_progress = NO;
// Methods to manage default settings
- (id) _initWithoutGModel;
- (void) _getOriginalSize;
- (void) _setDefaultDirectory;
- (void) _resetDefaults;
// Methods invoked by buttons
- (void) _setHomeDirectory;
@ -340,10 +341,30 @@ static BOOL _gs_display_reading_progress = NO;
_originalSize = [[self contentView] frame].size;
}
/* Set the current directory to a useful default value */
- (void) _setDefaultDirectory
{
NSString *path;
if (_directory == nil)
{
path = [[NSUserDefaults standardUserDefaults]
objectForKey: @"NSDefaultOpenDirectory"];
if (path == nil)
{
// FIXME: Should we use this or the home directory?
ASSIGN(_directory, [_fm currentDirectoryPath]);
}
else
{
ASSIGN(_directory, path);
}
}
}
- (void) _resetDefaults
{
if (_directory == nil)
ASSIGN (_directory, [_fm currentDirectoryPath]);
[self _setDefaultDirectory];
[self setPrompt: @"Name:"];
[self setTitle: @"Save"];
[self setRequiredFileType: @""];
@ -490,30 +511,22 @@ selectCellWithString: (NSString*)title
{
if (path == nil)
{
if (_directory == nil)
ASSIGN(_directory, [_fm currentDirectoryPath]);
[self _setDefaultDirectory];
}
else
{
ASSIGN (_directory, path);
ASSIGN(_directory, path);
}
if (filename == nil)
filename = @"";
ASSIGN (_fullFileName, [path stringByAppendingPathComponent: filename]);
ASSIGN(_fullFileName, [_directory stringByAppendingPathComponent: filename]);
[_browser setPath: _fullFileName];
[self _selectCellName:filename];
[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]];
@ -1033,8 +1046,7 @@ selectCellWithString: (NSString*)title
- (void) cancel: (id)sender
{
_fullFileName = nil;
_directory = nil;
ASSIGN(_directory, [_browser pathToColumn:[_browser lastColumn]]);
[NSApp stopModalWithCode: NSCancelButton];
[self close];
}
@ -1144,7 +1156,6 @@ selectCellWithString: (NSString*)title
if (![_delegate panel: self isValidFilename: [self filename]])
return;
_OKButtonPressed = YES;
[NSApp stopModalWithCode: NSOKButton];
[self close];
}