mirror of
https://github.com/gnustep/libs-gui.git
synced 2025-04-23 20:01:11 +00:00
Make NSOpenPanel and NSSavePanel consistently start up in the last
used directory by default. git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@27220 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
c476e3fa6d
commit
51ae4e18a6
4 changed files with 46 additions and 23 deletions
12
ChangeLog
12
ChangeLog
|
@ -1,6 +1,16 @@
|
|||
2008-12-06 Wolfgang Lux <wolfgang.lux@gmail.com>
|
||||
|
||||
* Headers/AppKit/NSDocument.h:
|
||||
* Source/NSSavePanel.m (-ok, -cancel:, -_setDefaultDirectory:,
|
||||
-_updateDefaultDirectory:, -_setupForDirectory:file:):
|
||||
* Source/NSOpenPanel.m (-ok:):
|
||||
* Source/NSDocumentController.m (-currentDirectory)
|
||||
(-reviewUnsavedDocumentsWithAlertTitle:cancelable:): Make open and
|
||||
save panels consistently start up in the last used directory by
|
||||
default.
|
||||
|
||||
2008-12-06 Wolfgang Lux <wolfgang.lux@gmail.com>
|
||||
|
||||
* Headers/AppKit/NSDocument.h:
|
||||
* Source/NSDocument.m (-isDocumentEdited, updateChangeCount:,
|
||||
hasUnautosavedChanges, changeWasDone): Fix bug where a document
|
||||
would appear unmodified after saving the document, undoing a
|
||||
|
|
|
@ -60,7 +60,6 @@ static NSString *CFBundleTypeName = @"CFBundleTypeName";
|
|||
static NSString *CFBundleTypeRole = @"CFBundleTypeRole";
|
||||
|
||||
static NSString *NSRecentDocuments = @"NSRecentDocuments";
|
||||
static NSString *NSDefaultOpenDirectory = @"NSDefaultOpenDirectory";
|
||||
|
||||
static NSDocumentController *sharedController = nil;
|
||||
|
||||
|
@ -728,10 +727,6 @@ static NSDictionary *TypeInfoForHumanReadableName (NSArray *types, NSString *typ
|
|||
NSString *cancelString = (cancellable)? ((NSString *)_(@"Cancel")) : ((NSString *)nil);
|
||||
int result;
|
||||
|
||||
/* Probably as good a place as any to do this */
|
||||
[[NSUserDefaults standardUserDefaults]
|
||||
setObject: [self currentDirectory] forKey: NSDefaultOpenDirectory];
|
||||
|
||||
if (![self hasEditedDocuments])
|
||||
{
|
||||
return YES;
|
||||
|
@ -850,13 +845,19 @@ static NSDictionary *TypeInfoForHumanReadableName (NSArray *types, NSString *typ
|
|||
{
|
||||
NSFileManager *manager = [NSFileManager defaultManager];
|
||||
NSDocument *document = [self currentDocument];
|
||||
NSString *directory;
|
||||
NSString *directory = nil;
|
||||
BOOL isDir = NO;
|
||||
|
||||
if (document)
|
||||
directory = [[document fileName] stringByDeletingLastPathComponent];
|
||||
else
|
||||
directory = [[NSOpenPanel openPanel] directory];
|
||||
{
|
||||
directory = [[document fileName] stringByDeletingLastPathComponent];
|
||||
}
|
||||
if (directory == nil || [directory isEqual: @""]
|
||||
|| [manager fileExistsAtPath: directory isDirectory: &isDir] == NO
|
||||
|| isDir == NO)
|
||||
{
|
||||
directory = [[NSOpenPanel openPanel] directory];
|
||||
}
|
||||
if (directory == nil || [directory isEqual: @""]
|
||||
|| [manager fileExistsAtPath: directory isDirectory: &isDir] == NO
|
||||
|| isDir == NO)
|
||||
|
|
|
@ -73,6 +73,7 @@ static NSOpenPanel *_gs_gui_open_panel = nil;
|
|||
// Pacify the compiler
|
||||
@interface NSSavePanel (GSPrivateMethods)
|
||||
- (void) _resetDefaults;
|
||||
- (void) _updateDefaultDirectory;
|
||||
- (void) _selectCellName: (NSString *)title;
|
||||
- (void) _selectTextInColumn: (int)column;
|
||||
- (void) _setupForDirectory: (NSString *)path file: (NSString *)filename;
|
||||
|
@ -579,6 +580,7 @@ static NSOpenPanel *_gs_gui_open_panel = nil;
|
|||
}
|
||||
}
|
||||
|
||||
[self _updateDefaultDirectory];
|
||||
[NSApp stopModalWithCode: NSOKButton];
|
||||
[_okButton setEnabled: NO];
|
||||
[self close];
|
||||
|
|
|
@ -108,6 +108,7 @@ setPath(NSBrowser *browser, NSString *path)
|
|||
- (id) _initWithoutGModel;
|
||||
- (void) _getOriginalSize;
|
||||
- (void) _setDefaultDirectory;
|
||||
- (void) _updateDefaultDirectory;
|
||||
- (void) _resetDefaults;
|
||||
// Methods invoked by buttons
|
||||
- (void) _setHomeDirectory;
|
||||
|
@ -386,20 +387,24 @@ setPath(NSBrowser *browser, NSString *path)
|
|||
{
|
||||
NSString *path;
|
||||
|
||||
if (_directory == nil)
|
||||
path = [[NSUserDefaults standardUserDefaults]
|
||||
objectForKey: @"NSDefaultOpenDirectory"];
|
||||
if (path == 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);
|
||||
}
|
||||
// FIXME: Should we use this or the home directory?
|
||||
ASSIGN(_directory, [_fm currentDirectoryPath]);
|
||||
}
|
||||
else
|
||||
{
|
||||
ASSIGN(_directory, path);
|
||||
}
|
||||
}
|
||||
|
||||
- (void) _updateDefaultDirectory
|
||||
{
|
||||
[[NSUserDefaults standardUserDefaults]
|
||||
setObject: _directory
|
||||
forKey: @"NSDefaultOpenDirectory"];
|
||||
}
|
||||
|
||||
- (void) _resetDefaults
|
||||
|
@ -552,7 +557,10 @@ selectCellWithString: (NSString*)title
|
|||
{
|
||||
if (path == nil)
|
||||
{
|
||||
[self _setDefaultDirectory];
|
||||
if (_directory == nil)
|
||||
{
|
||||
[self _setDefaultDirectory];
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -1093,6 +1101,7 @@ selectCellWithString: (NSString*)title
|
|||
- (void) cancel: (id)sender
|
||||
{
|
||||
ASSIGN(_directory, pathToColumn(_browser, [_browser lastColumn]));
|
||||
[self _updateDefaultDirectory];
|
||||
[NSApp stopModalWithCode: NSCancelButton];
|
||||
[_okButton setEnabled: NO];
|
||||
[self close];
|
||||
|
@ -1202,6 +1211,7 @@ selectCellWithString: (NSString*)title
|
|||
if (![_delegate panel: self isValidFilename: [self filename]])
|
||||
return;
|
||||
|
||||
[self _updateDefaultDirectory];
|
||||
[NSApp stopModalWithCode: NSOKButton];
|
||||
[_okButton setEnabled: NO];
|
||||
[self close];
|
||||
|
|
Loading…
Reference in a new issue