mirror of
https://github.com/gnustep/libs-gui.git
synced 2025-06-01 19:21:56 +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
eb23b8ada8
commit
1b9358f8d9
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>
|
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:,
|
* Source/NSDocument.m (-isDocumentEdited, updateChangeCount:,
|
||||||
hasUnautosavedChanges, changeWasDone): Fix bug where a document
|
hasUnautosavedChanges, changeWasDone): Fix bug where a document
|
||||||
would appear unmodified after saving the document, undoing a
|
would appear unmodified after saving the document, undoing a
|
||||||
|
|
|
@ -60,7 +60,6 @@ static NSString *CFBundleTypeName = @"CFBundleTypeName";
|
||||||
static NSString *CFBundleTypeRole = @"CFBundleTypeRole";
|
static NSString *CFBundleTypeRole = @"CFBundleTypeRole";
|
||||||
|
|
||||||
static NSString *NSRecentDocuments = @"NSRecentDocuments";
|
static NSString *NSRecentDocuments = @"NSRecentDocuments";
|
||||||
static NSString *NSDefaultOpenDirectory = @"NSDefaultOpenDirectory";
|
|
||||||
|
|
||||||
static NSDocumentController *sharedController = nil;
|
static NSDocumentController *sharedController = nil;
|
||||||
|
|
||||||
|
@ -728,10 +727,6 @@ static NSDictionary *TypeInfoForHumanReadableName (NSArray *types, NSString *typ
|
||||||
NSString *cancelString = (cancellable)? ((NSString *)_(@"Cancel")) : ((NSString *)nil);
|
NSString *cancelString = (cancellable)? ((NSString *)_(@"Cancel")) : ((NSString *)nil);
|
||||||
int result;
|
int result;
|
||||||
|
|
||||||
/* Probably as good a place as any to do this */
|
|
||||||
[[NSUserDefaults standardUserDefaults]
|
|
||||||
setObject: [self currentDirectory] forKey: NSDefaultOpenDirectory];
|
|
||||||
|
|
||||||
if (![self hasEditedDocuments])
|
if (![self hasEditedDocuments])
|
||||||
{
|
{
|
||||||
return YES;
|
return YES;
|
||||||
|
@ -850,13 +845,19 @@ static NSDictionary *TypeInfoForHumanReadableName (NSArray *types, NSString *typ
|
||||||
{
|
{
|
||||||
NSFileManager *manager = [NSFileManager defaultManager];
|
NSFileManager *manager = [NSFileManager defaultManager];
|
||||||
NSDocument *document = [self currentDocument];
|
NSDocument *document = [self currentDocument];
|
||||||
NSString *directory;
|
NSString *directory = nil;
|
||||||
BOOL isDir = NO;
|
BOOL isDir = NO;
|
||||||
|
|
||||||
if (document)
|
if (document)
|
||||||
directory = [[document fileName] stringByDeletingLastPathComponent];
|
{
|
||||||
else
|
directory = [[document fileName] stringByDeletingLastPathComponent];
|
||||||
directory = [[NSOpenPanel openPanel] directory];
|
}
|
||||||
|
if (directory == nil || [directory isEqual: @""]
|
||||||
|
|| [manager fileExistsAtPath: directory isDirectory: &isDir] == NO
|
||||||
|
|| isDir == NO)
|
||||||
|
{
|
||||||
|
directory = [[NSOpenPanel openPanel] directory];
|
||||||
|
}
|
||||||
if (directory == nil || [directory isEqual: @""]
|
if (directory == nil || [directory isEqual: @""]
|
||||||
|| [manager fileExistsAtPath: directory isDirectory: &isDir] == NO
|
|| [manager fileExistsAtPath: directory isDirectory: &isDir] == NO
|
||||||
|| isDir == NO)
|
|| isDir == NO)
|
||||||
|
|
|
@ -73,6 +73,7 @@ static NSOpenPanel *_gs_gui_open_panel = nil;
|
||||||
// Pacify the compiler
|
// Pacify the compiler
|
||||||
@interface NSSavePanel (GSPrivateMethods)
|
@interface NSSavePanel (GSPrivateMethods)
|
||||||
- (void) _resetDefaults;
|
- (void) _resetDefaults;
|
||||||
|
- (void) _updateDefaultDirectory;
|
||||||
- (void) _selectCellName: (NSString *)title;
|
- (void) _selectCellName: (NSString *)title;
|
||||||
- (void) _selectTextInColumn: (int)column;
|
- (void) _selectTextInColumn: (int)column;
|
||||||
- (void) _setupForDirectory: (NSString *)path file: (NSString *)filename;
|
- (void) _setupForDirectory: (NSString *)path file: (NSString *)filename;
|
||||||
|
@ -579,6 +580,7 @@ static NSOpenPanel *_gs_gui_open_panel = nil;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[self _updateDefaultDirectory];
|
||||||
[NSApp stopModalWithCode: NSOKButton];
|
[NSApp stopModalWithCode: NSOKButton];
|
||||||
[_okButton setEnabled: NO];
|
[_okButton setEnabled: NO];
|
||||||
[self close];
|
[self close];
|
||||||
|
|
|
@ -108,6 +108,7 @@ setPath(NSBrowser *browser, NSString *path)
|
||||||
- (id) _initWithoutGModel;
|
- (id) _initWithoutGModel;
|
||||||
- (void) _getOriginalSize;
|
- (void) _getOriginalSize;
|
||||||
- (void) _setDefaultDirectory;
|
- (void) _setDefaultDirectory;
|
||||||
|
- (void) _updateDefaultDirectory;
|
||||||
- (void) _resetDefaults;
|
- (void) _resetDefaults;
|
||||||
// Methods invoked by buttons
|
// Methods invoked by buttons
|
||||||
- (void) _setHomeDirectory;
|
- (void) _setHomeDirectory;
|
||||||
|
@ -386,20 +387,24 @@ setPath(NSBrowser *browser, NSString *path)
|
||||||
{
|
{
|
||||||
NSString *path;
|
NSString *path;
|
||||||
|
|
||||||
if (_directory == nil)
|
path = [[NSUserDefaults standardUserDefaults]
|
||||||
|
objectForKey: @"NSDefaultOpenDirectory"];
|
||||||
|
if (path == nil)
|
||||||
{
|
{
|
||||||
path = [[NSUserDefaults standardUserDefaults]
|
// FIXME: Should we use this or the home directory?
|
||||||
objectForKey: @"NSDefaultOpenDirectory"];
|
ASSIGN(_directory, [_fm currentDirectoryPath]);
|
||||||
if (path == nil)
|
|
||||||
{
|
|
||||||
// FIXME: Should we use this or the home directory?
|
|
||||||
ASSIGN(_directory, [_fm currentDirectoryPath]);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
ASSIGN(_directory, path);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
ASSIGN(_directory, path);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void) _updateDefaultDirectory
|
||||||
|
{
|
||||||
|
[[NSUserDefaults standardUserDefaults]
|
||||||
|
setObject: _directory
|
||||||
|
forKey: @"NSDefaultOpenDirectory"];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void) _resetDefaults
|
- (void) _resetDefaults
|
||||||
|
@ -552,7 +557,10 @@ selectCellWithString: (NSString*)title
|
||||||
{
|
{
|
||||||
if (path == nil)
|
if (path == nil)
|
||||||
{
|
{
|
||||||
[self _setDefaultDirectory];
|
if (_directory == nil)
|
||||||
|
{
|
||||||
|
[self _setDefaultDirectory];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -1093,6 +1101,7 @@ selectCellWithString: (NSString*)title
|
||||||
- (void) cancel: (id)sender
|
- (void) cancel: (id)sender
|
||||||
{
|
{
|
||||||
ASSIGN(_directory, pathToColumn(_browser, [_browser lastColumn]));
|
ASSIGN(_directory, pathToColumn(_browser, [_browser lastColumn]));
|
||||||
|
[self _updateDefaultDirectory];
|
||||||
[NSApp stopModalWithCode: NSCancelButton];
|
[NSApp stopModalWithCode: NSCancelButton];
|
||||||
[_okButton setEnabled: NO];
|
[_okButton setEnabled: NO];
|
||||||
[self close];
|
[self close];
|
||||||
|
@ -1202,6 +1211,7 @@ selectCellWithString: (NSString*)title
|
||||||
if (![_delegate panel: self isValidFilename: [self filename]])
|
if (![_delegate panel: self isValidFilename: [self filename]])
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
[self _updateDefaultDirectory];
|
||||||
[NSApp stopModalWithCode: NSOKButton];
|
[NSApp stopModalWithCode: NSOKButton];
|
||||||
[_okButton setEnabled: NO];
|
[_okButton setEnabled: NO];
|
||||||
[self close];
|
[self close];
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue