mirror of
https://github.com/gnustep/libs-gui.git
synced 2025-05-31 20:40:47 +00:00
Update the browser of NSSavePanel and NSOpenPanel when the list of
allowed file extensions is changed. Also fix bug in NSSavePanel's _shouldShowExtension:isDir: introduced in previous check in. git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@27231 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
5d9dcbe460
commit
ffe7abb58c
3 changed files with 56 additions and 16 deletions
10
ChangeLog
10
ChangeLog
|
@ -1,4 +1,12 @@
|
||||||
2008-12-06 Wolfgang Lux <wlux@uni-muenster.de>
|
2008-12-06 Wolfgang Lux <wolfgang.lux@gmail.com>
|
||||||
|
|
||||||
|
* Source/NSSavePanel.m (-_reloadBrowser:, -setRequiredFileType:,
|
||||||
|
-setAllowedFileTypes:, -setTreatsFilePackagesAsDirectories:):
|
||||||
|
* Source/NSOpenPanel.m (-_setupForTypes:, -setCanChooseFiles:)
|
||||||
|
-runModal..., -beginSheet...): Update the panels' browser when the
|
||||||
|
list of visible file extensions is changed programmatically.
|
||||||
|
|
||||||
|
2008-12-06 Wolfgang Lux <wolfgang.lux@gmail.com>
|
||||||
|
|
||||||
* Headers/AppKit/NSSavePanel.h:
|
* Headers/AppKit/NSSavePanel.h:
|
||||||
* Source/NSSavePanel.m (-requiredFileType, -setRequiredFileType:,
|
* Source/NSSavePanel.m (-requiredFileType, -setRequiredFileType:,
|
||||||
|
|
|
@ -74,9 +74,11 @@ static NSOpenPanel *_gs_gui_open_panel = nil;
|
||||||
@interface NSSavePanel (GSPrivateMethods)
|
@interface NSSavePanel (GSPrivateMethods)
|
||||||
- (void) _resetDefaults;
|
- (void) _resetDefaults;
|
||||||
- (void) _updateDefaultDirectory;
|
- (void) _updateDefaultDirectory;
|
||||||
|
- (void) _reloadBrowser;
|
||||||
- (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;
|
||||||
|
- (void) _setupForTypes: (NSArray *)fileTypes; /* I'm cheating here... */
|
||||||
- (BOOL) _shouldShowExtension: (NSString *)extension isDir: (BOOL *)isDir;
|
- (BOOL) _shouldShowExtension: (NSString *)extension isDir: (BOOL *)isDir;
|
||||||
- (NSComparisonResult) _compareFilename: (NSString *)n1 with: (NSString *)n2;
|
- (NSComparisonResult) _compareFilename: (NSString *)n1 with: (NSString *)n2;
|
||||||
@end
|
@end
|
||||||
|
@ -236,6 +238,16 @@ static NSOpenPanel *_gs_gui_open_panel = nil;
|
||||||
[super _setupForDirectory: path file: filename];
|
[super _setupForDirectory: path file: filename];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (void) _setupForTypes: (NSArray *)fileTypes
|
||||||
|
{
|
||||||
|
if (_fileTypes != fileTypes)
|
||||||
|
{
|
||||||
|
BOOL reload = ![_fileTypes isEqual: fileTypes];
|
||||||
|
ASSIGN (_fileTypes, fileTypes);
|
||||||
|
if (reload)
|
||||||
|
[self _reloadBrowser];
|
||||||
|
}
|
||||||
|
}
|
||||||
@end
|
@end
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -348,7 +360,11 @@ static NSOpenPanel *_gs_gui_open_panel = nil;
|
||||||
*/
|
*/
|
||||||
- (void) setCanChooseFiles: (BOOL)flag
|
- (void) setCanChooseFiles: (BOOL)flag
|
||||||
{
|
{
|
||||||
_canChooseFiles = flag;
|
if (flag != _canChooseFiles)
|
||||||
|
{
|
||||||
|
_canChooseFiles = flag;
|
||||||
|
[self _reloadBrowser];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**<p>Returns YES if the user is allowed to choose files. The
|
/**<p>Returns YES if the user is allowed to choose files. The
|
||||||
|
@ -460,8 +476,7 @@ static NSOpenPanel *_gs_gui_open_panel = nil;
|
||||||
file: (NSString *)name
|
file: (NSString *)name
|
||||||
types: (NSArray *)fileTypes
|
types: (NSArray *)fileTypes
|
||||||
{
|
{
|
||||||
ASSIGN (_fileTypes, fileTypes);
|
[self _setupForTypes: fileTypes];
|
||||||
|
|
||||||
return [self runModalForDirectory: path
|
return [self runModalForDirectory: path
|
||||||
file: name];
|
file: name];
|
||||||
}
|
}
|
||||||
|
@ -471,8 +486,7 @@ static NSOpenPanel *_gs_gui_open_panel = nil;
|
||||||
types: (NSArray *)fileTypes
|
types: (NSArray *)fileTypes
|
||||||
relativeToWindow: (NSWindow*)window
|
relativeToWindow: (NSWindow*)window
|
||||||
{
|
{
|
||||||
ASSIGN (_fileTypes, fileTypes);
|
[self _setupForTypes: fileTypes];
|
||||||
|
|
||||||
return [self runModalForDirectory: path
|
return [self runModalForDirectory: path
|
||||||
file: name
|
file: name
|
||||||
relativeToWindow: window];
|
relativeToWindow: window];
|
||||||
|
@ -486,8 +500,7 @@ static NSOpenPanel *_gs_gui_open_panel = nil;
|
||||||
didEndSelector: (SEL)didEndSelector
|
didEndSelector: (SEL)didEndSelector
|
||||||
contextInfo: (void *)contextInfo
|
contextInfo: (void *)contextInfo
|
||||||
{
|
{
|
||||||
ASSIGN (_fileTypes, fileTypes);
|
[self _setupForTypes: fileTypes];
|
||||||
|
|
||||||
[self beginSheetForDirectory: path
|
[self beginSheetForDirectory: path
|
||||||
file: name
|
file: name
|
||||||
modalForWindow: docWindow
|
modalForWindow: docWindow
|
||||||
|
|
|
@ -110,6 +110,7 @@ setPath(NSBrowser *browser, NSString *path)
|
||||||
- (void) _setDefaultDirectory;
|
- (void) _setDefaultDirectory;
|
||||||
- (void) _updateDefaultDirectory;
|
- (void) _updateDefaultDirectory;
|
||||||
- (void) _resetDefaults;
|
- (void) _resetDefaults;
|
||||||
|
- (void) _reloadBrowser;
|
||||||
// Methods invoked by buttons
|
// Methods invoked by buttons
|
||||||
- (void) _setHomeDirectory;
|
- (void) _setHomeDirectory;
|
||||||
- (void) _mountMedia;
|
- (void) _mountMedia;
|
||||||
|
@ -418,6 +419,13 @@ setPath(NSBrowser *browser, NSString *path)
|
||||||
[self setAccessoryView: nil];
|
[self setAccessoryView: nil];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (void) _reloadBrowser
|
||||||
|
{
|
||||||
|
NSString *path = [_browser path];
|
||||||
|
[_browser loadColumnZero];
|
||||||
|
setPath(_browser, path);
|
||||||
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// Methods invoked by button press
|
// Methods invoked by button press
|
||||||
//
|
//
|
||||||
|
@ -590,7 +598,7 @@ selectCellWithString: (NSString*)title
|
||||||
{
|
{
|
||||||
if (_allowedFileTypes != nil
|
if (_allowedFileTypes != nil
|
||||||
&& [_allowedFileTypes indexOfObject: extension] == NSNotFound
|
&& [_allowedFileTypes indexOfObject: extension] == NSNotFound
|
||||||
&& [_allowedFileTypes indexOfObject: @""] != NSNotFound)
|
&& [_allowedFileTypes indexOfObject: @""] == NSNotFound)
|
||||||
return NO;
|
return NO;
|
||||||
}
|
}
|
||||||
else if ([extension length] == 0)
|
else if ([extension length] == 0)
|
||||||
|
@ -935,10 +943,13 @@ selectCellWithString: (NSString*)title
|
||||||
*/
|
*/
|
||||||
- (void) setRequiredFileType: (NSString*)fileType
|
- (void) setRequiredFileType: (NSString*)fileType
|
||||||
{
|
{
|
||||||
|
NSArray *fileTypes;
|
||||||
|
|
||||||
if ([fileType length] == 0)
|
if ([fileType length] == 0)
|
||||||
DESTROY(_allowedFileTypes);
|
fileTypes = nil;
|
||||||
else
|
else
|
||||||
ASSIGN(_allowedFileTypes, [NSArray arrayWithObject: fileType]);
|
fileTypes = [NSArray arrayWithObject: fileType];
|
||||||
|
[self setAllowedFileTypes: fileTypes];
|
||||||
}
|
}
|
||||||
|
|
||||||
/**<p>Returns the required file type. The default, indicated by an empty
|
/**<p>Returns the required file type. The default, indicated by an empty
|
||||||
|
@ -966,10 +977,14 @@ selectCellWithString: (NSString*)title
|
||||||
*/
|
*/
|
||||||
- (void) setAllowedFileTypes: (NSArray *)types
|
- (void) setAllowedFileTypes: (NSArray *)types
|
||||||
{
|
{
|
||||||
if ([types count] == 0)
|
if (types != _allowedFileTypes)
|
||||||
DESTROY(_allowedFileTypes);
|
{
|
||||||
else
|
if ([types count] == 0)
|
||||||
ASSIGN(_allowedFileTypes, types);
|
DESTROY(_allowedFileTypes);
|
||||||
|
else
|
||||||
|
ASSIGN(_allowedFileTypes, types);
|
||||||
|
[self _reloadBrowser];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**<p>Returns an array of the allowed file types. The default, indicated by
|
/**<p>Returns an array of the allowed file types. The default, indicated by
|
||||||
|
@ -1006,7 +1021,11 @@ selectCellWithString: (NSString*)title
|
||||||
*/
|
*/
|
||||||
- (void) setTreatsFilePackagesAsDirectories: (BOOL)flag
|
- (void) setTreatsFilePackagesAsDirectories: (BOOL)flag
|
||||||
{
|
{
|
||||||
_treatsFilePackagesAsDirectories = flag;
|
if (flag != _treatsFilePackagesAsDirectories)
|
||||||
|
{
|
||||||
|
_treatsFilePackagesAsDirectories = flag;
|
||||||
|
[self _reloadBrowser];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**<p> Validates and possibly reloads the browser columns that are visible
|
/**<p> Validates and possibly reloads the browser columns that are visible
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue