Skip to content

Commit

Permalink
Implemented panel:shouldEnableURL: for the open dialog delegate.
Browse files Browse the repository at this point in the history
git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3@10317 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
  • Loading branch information
Manolo Gouy authored and Manolo Gouy committed Sep 16, 2014
1 parent 5ceae63 commit 9dae6e9
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions src/Fl_Native_File_Chooser_MAC.mm
Expand Up @@ -411,6 +411,7 @@ @interface FLopenDelegate : NSObject
}
- (FLopenDelegate*)setPopup:(NSPopUpButton*)popup filter_pattern:(char**)pattern;
- (BOOL)panel:(id)sender shouldShowFilename:(NSString *)filename;
- (BOOL)panel:(id)sender shouldEnableURL:(NSURL *)url;
@end
@implementation FLopenDelegate
- (FLopenDelegate*)setPopup:(NSPopUpButton*)popup filter_pattern:(char**)pattern
Expand All @@ -422,11 +423,16 @@ - (FLopenDelegate*)setPopup:(NSPopUpButton*)popup filter_pattern:(char**)pattern
- (BOOL)panel:(id)sender shouldShowFilename:(NSString *)filename
{
if ( [nspopup indexOfSelectedItem] == [nspopup numberOfItems] - 1) return YES;
const char *pathname = [filename fileSystemRepresentation];
if ( fl_filename_isdir(pathname) ) return YES;
if ( fl_filename_match(pathname, filter_pattern[ [nspopup indexOfSelectedItem] ]) ) return YES;
BOOL isdir = NO;
[[NSFileManager defaultManager] fileExistsAtPath:filename isDirectory:&isdir];
if (isdir) return YES;
if ( fl_filename_match([filename fileSystemRepresentation], filter_pattern[ [nspopup indexOfSelectedItem] ]) ) return YES;
return NO;
}
- (BOOL)panel:(id)sender shouldEnableURL:(NSURL *)url
{
return [self panel:sender shouldShowFilename:[url path]];
}
@end

@interface FLsaveDelegate : NSObject
Expand Down

0 comments on commit 9dae6e9

Please sign in to comment.