ample/Ample/DiskImagesWindowController.m

331 lines
9.0 KiB
Mathematica
Raw Normal View History

//
// DiskImagesWindowController.m
// Ample
//
// Created by Kelvin Sherlock on 9/13/2020.
// Copyright © 2020 Kelvin Sherlock. All rights reserved.
//
#import "DiskImagesWindowController.h"
#import "TableCellView.h"
#import "Ample.h"
@interface DiskImagesWindowController ()
@property (weak) IBOutlet NSTableView *tableView;
@property (strong) IBOutlet NSArrayController *arrayController;
@property (strong) NSMutableArray *content;
@end
@implementation DiskImagesWindowController {
BOOL _dirty;
NSSet *_extensions;
NSTimer *_timer;
}
+(instancetype)sharedInstance {
static DiskImagesWindowController *me;
if (!me) {
me = [self new];
}
return me;
}
+ (void)restoreWindowWithIdentifier:(NSUserInterfaceItemIdentifier)identifier state:(NSCoder *)state completionHandler:(void (^)(NSWindow *, NSError *))completionHandler {
NSLog(@"restore disk images window");
NSWindowController *controller = [self sharedInstance];
NSWindow *w = [controller window];
[w restoreStateWithCoder: state];
completionHandler(w, nil);
}
-(instancetype)init {
if ((self = [super init])) {
[self loadRecentDiskImages];
_extensions = [NSSet setWithObjects:
2020-09-29 02:59:27 +00:00
@"2img", @"2mg", @"chd", @"dc", @"do", @"dsk", @"hd", @"hdv", @"image", @"nib", @"po", @"wav", @"woz", @"iso", @"raw", nil
];
}
return self;
}
-(NSString *)windowNibName {
return @"DiskImages";
}
- (void)windowDidLoad {
if (!_content)
[self setContent: [NSMutableArray new]];
[super windowDidLoad];
NSWindow *window = [self window];
[window setRestorable: YES];
[window setRestorationClass: [self class]];
Updates to work with 10.11 (El Capitan) and newer. There are still a couple minor UI degradations eg: mame cheat sheet, recent disk images window, auto complete window. Squashed commit of the following: commit fb115024f805da38b747fd1905573fabb7bff24e Author: Kelvin Sherlock <ksherlock@gmail.com> Date: Sun May 30 18:00:13 2021 -0400 ? commit 8405f4df95ae8f5bc5dc33598dc0b3f8972b32cd Author: Kelvin Sherlock <ksherlock@gmail.com> Date: Sun May 30 17:59:43 2021 -0400 tintColor not present before 10.14 commit 86a6102cee4f30cac2972259ef55fda3c32b8f9a Author: Kelvin Sherlock <ksherlock@gmail.com> Date: Sun May 30 17:59:19 2021 -0400 [menu setItemArray:] apparently has problems before 10.14 commit 65227a00743fbf143c623af8a76698d57bdc4573 Author: Kelvin Sherlock <ksherlock@gmail.com> Date: Sun May 30 17:58:15 2021 -0400 NSCache doesn't like null objects. commit 8a4c3a4662647d5ee0b609bde9f3aaa5c0d99776 Author: Kelvin Sherlock <ksherlock@gmail.com> Date: Sun May 30 16:00:05 2021 -0400 organize copy bundle resources. multiple-sized png images are converted to a single tiff (with multiple sizes). This is fine BUT EL capitan grabs the first image so if the @3x image is first, it will be used. commit 44b94cdfd47117864b6529214b1c91a0c2e41327 Author: Kelvin Sherlock <ksherlock@gmail.com> Date: Sun May 30 15:57:37 2021 -0400 add NewSlotViewController.m to Ample Lite. commit 2fa1b7418783e48ca625ab3490e43cbff9e5619a Author: Kelvin Sherlock <ksherlock@gmail.com> Date: Sun May 30 13:57:19 2021 -0400 Ample Lite was missing reference to New Slot View nib. commit 65f268e77a65f8c57019702d8f0c2b66577c5ee7 Author: Kelvin Sherlock <ksherlock@gmail.com> Date: Sun May 30 13:56:04 2021 -0400 based on testing, 10.11 still has public.file-url, which is kUTTypeFileURL. 10.13 added NSURLPBoardType as a synonym. commit cde123b16eb336b7695b444931b9e9bb9802d772 Author: Kelvin Sherlock <ksherlock@gmail.com> Date: Sun May 30 13:54:02 2021 -0400 set everything to 10.11 commit e7a670efd3298e8ce1409cde1cce559ba46879f4 Author: Kelvin Sherlock <ksherlock@gmail.com> Date: Sat May 29 23:33:31 2021 -0400 script to download SDL2.Framework commit 9f38f2972ab0e38fbdaebb3e3f35281978303519 Author: Kelvin Sherlock <ksherlock@gmail.com> Date: Sat May 29 22:15:32 2021 -0400 WKWebView apparently has a bug prior to 10.12 so it can't be created via a nib. commit e18aea724978b86cb0c04853649aeb613ac225ce Author: Kelvin Sherlock <ksherlock@gmail.com> Date: Sat May 29 22:14:38 2021 -0400 version checks for features not present in 10.11 commit 07dcf30f5225564ec19d1aad3856828fdeaeb0f0 Author: Kelvin Sherlock <ksherlock@gmail.com> Date: Fri May 28 21:30:53 2021 -0400 lower target to 10.11
2021-05-30 22:00:34 +00:00
if (@available(macOS 10.13, *)) {
[_tableView registerForDraggedTypes: @[NSPasteboardTypeFileURL]];
} else {
[_tableView registerForDraggedTypes: @[ (NSString *)kUTTypeFileURL ]];
}
[_tableView setDraggingSourceOperationMask: NSDragOperationCopy forLocal: NO]; // enable drag/drop to othr apps.
// Implement this method to handle any initialization after your window controller's window has been loaded from its nib file.
}
-(void)loadRecentDiskImages {
// NSError *error;
NSURL *sd = SupportDirectory();
NSURL *url = [sd URLByAppendingPathComponent: @"RecentDiskImages.plist"];
NSData *data = [NSData dataWithContentsOfURL: url];
if (data) {
_content = [NSPropertyListSerialization propertyListWithData:data options:NSPropertyListMutableContainers format:nil error: nil];
}
if (!_content)
_content = [NSMutableArray new];
NSNotificationCenter *nc = [NSNotificationCenter defaultCenter];
[nc addObserver: self selector: @selector(diskImageAdded:) name: kNotificationDiskImageAdded object: nil];
[nc addObserver: self selector: @selector(willTerminate:) name: NSApplicationWillTerminateNotification object: nil];
}
Updates to work with 10.11 (El Capitan) and newer. There are still a couple minor UI degradations eg: mame cheat sheet, recent disk images window, auto complete window. Squashed commit of the following: commit fb115024f805da38b747fd1905573fabb7bff24e Author: Kelvin Sherlock <ksherlock@gmail.com> Date: Sun May 30 18:00:13 2021 -0400 ? commit 8405f4df95ae8f5bc5dc33598dc0b3f8972b32cd Author: Kelvin Sherlock <ksherlock@gmail.com> Date: Sun May 30 17:59:43 2021 -0400 tintColor not present before 10.14 commit 86a6102cee4f30cac2972259ef55fda3c32b8f9a Author: Kelvin Sherlock <ksherlock@gmail.com> Date: Sun May 30 17:59:19 2021 -0400 [menu setItemArray:] apparently has problems before 10.14 commit 65227a00743fbf143c623af8a76698d57bdc4573 Author: Kelvin Sherlock <ksherlock@gmail.com> Date: Sun May 30 17:58:15 2021 -0400 NSCache doesn't like null objects. commit 8a4c3a4662647d5ee0b609bde9f3aaa5c0d99776 Author: Kelvin Sherlock <ksherlock@gmail.com> Date: Sun May 30 16:00:05 2021 -0400 organize copy bundle resources. multiple-sized png images are converted to a single tiff (with multiple sizes). This is fine BUT EL capitan grabs the first image so if the @3x image is first, it will be used. commit 44b94cdfd47117864b6529214b1c91a0c2e41327 Author: Kelvin Sherlock <ksherlock@gmail.com> Date: Sun May 30 15:57:37 2021 -0400 add NewSlotViewController.m to Ample Lite. commit 2fa1b7418783e48ca625ab3490e43cbff9e5619a Author: Kelvin Sherlock <ksherlock@gmail.com> Date: Sun May 30 13:57:19 2021 -0400 Ample Lite was missing reference to New Slot View nib. commit 65f268e77a65f8c57019702d8f0c2b66577c5ee7 Author: Kelvin Sherlock <ksherlock@gmail.com> Date: Sun May 30 13:56:04 2021 -0400 based on testing, 10.11 still has public.file-url, which is kUTTypeFileURL. 10.13 added NSURLPBoardType as a synonym. commit cde123b16eb336b7695b444931b9e9bb9802d772 Author: Kelvin Sherlock <ksherlock@gmail.com> Date: Sun May 30 13:54:02 2021 -0400 set everything to 10.11 commit e7a670efd3298e8ce1409cde1cce559ba46879f4 Author: Kelvin Sherlock <ksherlock@gmail.com> Date: Sat May 29 23:33:31 2021 -0400 script to download SDL2.Framework commit 9f38f2972ab0e38fbdaebb3e3f35281978303519 Author: Kelvin Sherlock <ksherlock@gmail.com> Date: Sat May 29 22:15:32 2021 -0400 WKWebView apparently has a bug prior to 10.12 so it can't be created via a nib. commit e18aea724978b86cb0c04853649aeb613ac225ce Author: Kelvin Sherlock <ksherlock@gmail.com> Date: Sat May 29 22:14:38 2021 -0400 version checks for features not present in 10.11 commit 07dcf30f5225564ec19d1aad3856828fdeaeb0f0 Author: Kelvin Sherlock <ksherlock@gmail.com> Date: Fri May 28 21:30:53 2021 -0400 lower target to 10.11
2021-05-30 22:00:34 +00:00
-(void)timerCallback: (NSTimer *)timer {
_timer = nil;
[self saveFile];
}
-(void)diskImageAdded: (NSNotification *)notification {
NSURL *url = [notification object];
if (!url) return;
[self addFile: url];
}
-(void)markDirty {
_dirty = YES;
if (_timer) [_timer invalidate];
Updates to work with 10.11 (El Capitan) and newer. There are still a couple minor UI degradations eg: mame cheat sheet, recent disk images window, auto complete window. Squashed commit of the following: commit fb115024f805da38b747fd1905573fabb7bff24e Author: Kelvin Sherlock <ksherlock@gmail.com> Date: Sun May 30 18:00:13 2021 -0400 ? commit 8405f4df95ae8f5bc5dc33598dc0b3f8972b32cd Author: Kelvin Sherlock <ksherlock@gmail.com> Date: Sun May 30 17:59:43 2021 -0400 tintColor not present before 10.14 commit 86a6102cee4f30cac2972259ef55fda3c32b8f9a Author: Kelvin Sherlock <ksherlock@gmail.com> Date: Sun May 30 17:59:19 2021 -0400 [menu setItemArray:] apparently has problems before 10.14 commit 65227a00743fbf143c623af8a76698d57bdc4573 Author: Kelvin Sherlock <ksherlock@gmail.com> Date: Sun May 30 17:58:15 2021 -0400 NSCache doesn't like null objects. commit 8a4c3a4662647d5ee0b609bde9f3aaa5c0d99776 Author: Kelvin Sherlock <ksherlock@gmail.com> Date: Sun May 30 16:00:05 2021 -0400 organize copy bundle resources. multiple-sized png images are converted to a single tiff (with multiple sizes). This is fine BUT EL capitan grabs the first image so if the @3x image is first, it will be used. commit 44b94cdfd47117864b6529214b1c91a0c2e41327 Author: Kelvin Sherlock <ksherlock@gmail.com> Date: Sun May 30 15:57:37 2021 -0400 add NewSlotViewController.m to Ample Lite. commit 2fa1b7418783e48ca625ab3490e43cbff9e5619a Author: Kelvin Sherlock <ksherlock@gmail.com> Date: Sun May 30 13:57:19 2021 -0400 Ample Lite was missing reference to New Slot View nib. commit 65f268e77a65f8c57019702d8f0c2b66577c5ee7 Author: Kelvin Sherlock <ksherlock@gmail.com> Date: Sun May 30 13:56:04 2021 -0400 based on testing, 10.11 still has public.file-url, which is kUTTypeFileURL. 10.13 added NSURLPBoardType as a synonym. commit cde123b16eb336b7695b444931b9e9bb9802d772 Author: Kelvin Sherlock <ksherlock@gmail.com> Date: Sun May 30 13:54:02 2021 -0400 set everything to 10.11 commit e7a670efd3298e8ce1409cde1cce559ba46879f4 Author: Kelvin Sherlock <ksherlock@gmail.com> Date: Sat May 29 23:33:31 2021 -0400 script to download SDL2.Framework commit 9f38f2972ab0e38fbdaebb3e3f35281978303519 Author: Kelvin Sherlock <ksherlock@gmail.com> Date: Sat May 29 22:15:32 2021 -0400 WKWebView apparently has a bug prior to 10.12 so it can't be created via a nib. commit e18aea724978b86cb0c04853649aeb613ac225ce Author: Kelvin Sherlock <ksherlock@gmail.com> Date: Sat May 29 22:14:38 2021 -0400 version checks for features not present in 10.11 commit 07dcf30f5225564ec19d1aad3856828fdeaeb0f0 Author: Kelvin Sherlock <ksherlock@gmail.com> Date: Fri May 28 21:30:53 2021 -0400 lower target to 10.11
2021-05-30 22:00:34 +00:00
_timer = [NSTimer scheduledTimerWithTimeInterval: 5 * 60 target: self selector: @selector(timerCallback:) userInfo: nil repeats: NO];
#if 0
// 10.12+
_timer = [NSTimer scheduledTimerWithTimeInterval: 5 * 60 repeats: NO block: ^(NSTimer *t) {
self->_timer = nil;
[self saveFile];
}];
Updates to work with 10.11 (El Capitan) and newer. There are still a couple minor UI degradations eg: mame cheat sheet, recent disk images window, auto complete window. Squashed commit of the following: commit fb115024f805da38b747fd1905573fabb7bff24e Author: Kelvin Sherlock <ksherlock@gmail.com> Date: Sun May 30 18:00:13 2021 -0400 ? commit 8405f4df95ae8f5bc5dc33598dc0b3f8972b32cd Author: Kelvin Sherlock <ksherlock@gmail.com> Date: Sun May 30 17:59:43 2021 -0400 tintColor not present before 10.14 commit 86a6102cee4f30cac2972259ef55fda3c32b8f9a Author: Kelvin Sherlock <ksherlock@gmail.com> Date: Sun May 30 17:59:19 2021 -0400 [menu setItemArray:] apparently has problems before 10.14 commit 65227a00743fbf143c623af8a76698d57bdc4573 Author: Kelvin Sherlock <ksherlock@gmail.com> Date: Sun May 30 17:58:15 2021 -0400 NSCache doesn't like null objects. commit 8a4c3a4662647d5ee0b609bde9f3aaa5c0d99776 Author: Kelvin Sherlock <ksherlock@gmail.com> Date: Sun May 30 16:00:05 2021 -0400 organize copy bundle resources. multiple-sized png images are converted to a single tiff (with multiple sizes). This is fine BUT EL capitan grabs the first image so if the @3x image is first, it will be used. commit 44b94cdfd47117864b6529214b1c91a0c2e41327 Author: Kelvin Sherlock <ksherlock@gmail.com> Date: Sun May 30 15:57:37 2021 -0400 add NewSlotViewController.m to Ample Lite. commit 2fa1b7418783e48ca625ab3490e43cbff9e5619a Author: Kelvin Sherlock <ksherlock@gmail.com> Date: Sun May 30 13:57:19 2021 -0400 Ample Lite was missing reference to New Slot View nib. commit 65f268e77a65f8c57019702d8f0c2b66577c5ee7 Author: Kelvin Sherlock <ksherlock@gmail.com> Date: Sun May 30 13:56:04 2021 -0400 based on testing, 10.11 still has public.file-url, which is kUTTypeFileURL. 10.13 added NSURLPBoardType as a synonym. commit cde123b16eb336b7695b444931b9e9bb9802d772 Author: Kelvin Sherlock <ksherlock@gmail.com> Date: Sun May 30 13:54:02 2021 -0400 set everything to 10.11 commit e7a670efd3298e8ce1409cde1cce559ba46879f4 Author: Kelvin Sherlock <ksherlock@gmail.com> Date: Sat May 29 23:33:31 2021 -0400 script to download SDL2.Framework commit 9f38f2972ab0e38fbdaebb3e3f35281978303519 Author: Kelvin Sherlock <ksherlock@gmail.com> Date: Sat May 29 22:15:32 2021 -0400 WKWebView apparently has a bug prior to 10.12 so it can't be created via a nib. commit e18aea724978b86cb0c04853649aeb613ac225ce Author: Kelvin Sherlock <ksherlock@gmail.com> Date: Sat May 29 22:14:38 2021 -0400 version checks for features not present in 10.11 commit 07dcf30f5225564ec19d1aad3856828fdeaeb0f0 Author: Kelvin Sherlock <ksherlock@gmail.com> Date: Fri May 28 21:30:53 2021 -0400 lower target to 10.11
2021-05-30 22:00:34 +00:00
#endif
}
-(void)saveFile {
[_timer invalidate];
_timer = nil;
NSURL *sd = SupportDirectory();
NSURL *url = [sd URLByAppendingPathComponent: @"RecentDiskImages.plist"];
if (_content && url) {
[_content writeToURL: url atomically: YES];
}
_dirty = NO;
}
-(void)willTerminate: (NSNotification *)notification {
// if dirty, write data....
if (!_dirty) return;
[self saveFile];
}
-(BOOL)addFile: (NSObject *)pathOrURL {
NSString *path = nil;
NSURL *url = nil;
if ([pathOrURL isKindOfClass: [NSString class]]) {
path = (NSString *)pathOrURL;
} else if ([pathOrURL isKindOfClass: [NSURL class]]){
url = (NSURL *)pathOrURL;
path = [NSString stringWithCString: [url fileSystemRepresentation] encoding: NSUTF8StringEncoding];
}
if (!path) return NO;
// todo -- check if file is in the list already...
BOOL found = NO;
// should really compare the volume id / ino I suppose.
for (NSMutableDictionary *d in _content) {
NSString *s = [d objectForKey: @"path"];
if ([path compare: s] == NSOrderedSame) {
found = YES;
[d setObject: [NSDate new] forKey: @"date"];
[self markDirty];
break;
}
}
if (found) return NO;
NSFileManager *fm = [NSFileManager defaultManager];
NSError *error;
2021-07-11 03:34:00 +00:00
NSDictionary *attr = [fm attributesOfItemAtPath: path error: &error];
if (error) {
NSLog(@"%@ : %@", path, error);
return NO;
}
NSNumber *size = [attr objectForKey: NSFileSize];
NSMutableDictionary *d = [NSMutableDictionary dictionaryWithObjectsAndKeys:
path, @"path",
size, @"size",
[NSDate new], @"date",
nil];
@synchronized (self) {
if (_arrayController)
[_arrayController addObject: d];
else
[_content addObject: d];
}
[self markDirty];
return YES;
}
-(NSMutableDictionary *)clickedItem {
NSArray *array = [_arrayController arrangedObjects];
NSInteger row = [_tableView clickedRow];
if (row < 0 || row >= [array count]) return nil;
return [array objectAtIndex: row];
}
#pragma mark - IBActions
- (IBAction)showInFinder:(id)sender {
NSMutableDictionary *item = [self clickedItem];
if (!item) return;
NSString *path = [item objectForKey: @"path"];
NSURL *url = [NSURL fileURLWithPath: path];
if (!url) return;
NSWorkspace *ws = [NSWorkspace sharedWorkspace];
[ws activateFileViewerSelectingURLs: @[url]];
}
- (IBAction)eject:(id)sender {
NSMutableDictionary *item = [self clickedItem];
if (!item) return;
@synchronized (self) {
if (_arrayController) {
[_arrayController removeObject: item];
} else {
[_content removeObject: item];
}
[self markDirty];
}
}
-(IBAction)doubleClick: (id)sender {
NSDictionary *d = [self clickedItem];
NSNotificationCenter *nc = [NSNotificationCenter defaultCenter];
[nc postNotificationName: kNotificationDiskImageMagicRoute object: nil userInfo: d];
}
@end
@implementation DiskImagesWindowController (TableView)
-(id<NSPasteboardWriting>)tableView:(NSTableView *)tableView pasteboardWriterForRow:(NSInteger)row {
id objects = [_arrayController arrangedObjects];
NSDictionary *d = [objects objectAtIndex: row];
NSString *path = [d objectForKey: @"path"];
NSURL *url = [NSURL fileURLWithPath: path];
return url;
#if 0
NSPasteboardItem *item = [NSPasteboardItem new];
[item setString: [url absoluteString] forType: NSPasteboardTypeFileURL]; // FileURL
[item setString: path forType: NSPasteboardTypeString]; // for Terminal.app
return item;
#endif
}
-(NSDragOperation)tableView:(NSTableView *)tableView validateDrop:(id<NSDraggingInfo>)info proposedRow:(NSInteger)row proposedDropOperation:(NSTableViewDropOperation)dropOperation {
if ([info draggingSource] == _tableView) return NSDragOperationNone;
// option key will ignore all filetype restrictions.
if ([NSEvent modifierFlags] & NSEventModifierFlagOption) return NSDragOperationCopy;
// this only checks the first dragged item...
NSPasteboard * pb = [info draggingPasteboard];
NSURL *url = [NSURL URLFromPasteboard: pb];
NSString *ext = [url pathExtension];
ext = [ext lowercaseString];
if ([_extensions containsObject: ext])
return NSDragOperationCopy;
return NSDragOperationNone;
}
-(BOOL)tableView:(NSTableView *)tableView acceptDrop:(id<NSDraggingInfo>)info row:(NSInteger)row dropOperation:(NSTableViewDropOperation)dropOperation {
if ([info draggingSource] == _tableView) return NO;
NSPasteboard * pb = [info draggingPasteboard];
BOOL ok = NO;
for (NSPasteboardItem *item in [pb pasteboardItems]) {
// need to convert from a string to a url back to a file in case it's a file id url?
Updates to work with 10.11 (El Capitan) and newer. There are still a couple minor UI degradations eg: mame cheat sheet, recent disk images window, auto complete window. Squashed commit of the following: commit fb115024f805da38b747fd1905573fabb7bff24e Author: Kelvin Sherlock <ksherlock@gmail.com> Date: Sun May 30 18:00:13 2021 -0400 ? commit 8405f4df95ae8f5bc5dc33598dc0b3f8972b32cd Author: Kelvin Sherlock <ksherlock@gmail.com> Date: Sun May 30 17:59:43 2021 -0400 tintColor not present before 10.14 commit 86a6102cee4f30cac2972259ef55fda3c32b8f9a Author: Kelvin Sherlock <ksherlock@gmail.com> Date: Sun May 30 17:59:19 2021 -0400 [menu setItemArray:] apparently has problems before 10.14 commit 65227a00743fbf143c623af8a76698d57bdc4573 Author: Kelvin Sherlock <ksherlock@gmail.com> Date: Sun May 30 17:58:15 2021 -0400 NSCache doesn't like null objects. commit 8a4c3a4662647d5ee0b609bde9f3aaa5c0d99776 Author: Kelvin Sherlock <ksherlock@gmail.com> Date: Sun May 30 16:00:05 2021 -0400 organize copy bundle resources. multiple-sized png images are converted to a single tiff (with multiple sizes). This is fine BUT EL capitan grabs the first image so if the @3x image is first, it will be used. commit 44b94cdfd47117864b6529214b1c91a0c2e41327 Author: Kelvin Sherlock <ksherlock@gmail.com> Date: Sun May 30 15:57:37 2021 -0400 add NewSlotViewController.m to Ample Lite. commit 2fa1b7418783e48ca625ab3490e43cbff9e5619a Author: Kelvin Sherlock <ksherlock@gmail.com> Date: Sun May 30 13:57:19 2021 -0400 Ample Lite was missing reference to New Slot View nib. commit 65f268e77a65f8c57019702d8f0c2b66577c5ee7 Author: Kelvin Sherlock <ksherlock@gmail.com> Date: Sun May 30 13:56:04 2021 -0400 based on testing, 10.11 still has public.file-url, which is kUTTypeFileURL. 10.13 added NSURLPBoardType as a synonym. commit cde123b16eb336b7695b444931b9e9bb9802d772 Author: Kelvin Sherlock <ksherlock@gmail.com> Date: Sun May 30 13:54:02 2021 -0400 set everything to 10.11 commit e7a670efd3298e8ce1409cde1cce559ba46879f4 Author: Kelvin Sherlock <ksherlock@gmail.com> Date: Sat May 29 23:33:31 2021 -0400 script to download SDL2.Framework commit 9f38f2972ab0e38fbdaebb3e3f35281978303519 Author: Kelvin Sherlock <ksherlock@gmail.com> Date: Sat May 29 22:15:32 2021 -0400 WKWebView apparently has a bug prior to 10.12 so it can't be created via a nib. commit e18aea724978b86cb0c04853649aeb613ac225ce Author: Kelvin Sherlock <ksherlock@gmail.com> Date: Sat May 29 22:14:38 2021 -0400 version checks for features not present in 10.11 commit 07dcf30f5225564ec19d1aad3856828fdeaeb0f0 Author: Kelvin Sherlock <ksherlock@gmail.com> Date: Fri May 28 21:30:53 2021 -0400 lower target to 10.11
2021-05-30 22:00:34 +00:00
NSString *s;
if (@available(macOS 10.13, *)) {
s = [item stringForType: NSPasteboardTypeFileURL];
} else {
// El Capitan still has kUTTypeFileURL aka public.file-url but doesn't have NSPasteboardTypeFileURL
s = [item stringForType: (NSString *)kUTTypeFileURL];
}
if (!s) continue;
NSURL *url = [NSURL URLWithString: s];
if (!url) continue;
ok |= [self addFile: url];
}
return ok;
}
@end