mirror of https://github.com/ksherlock/ample.git
version checks for features not present in 10.11
This commit is contained in:
parent
07dcf30f52
commit
e18aea7249
|
@ -96,10 +96,15 @@
|
||||||
@"xfz",
|
@"xfz",
|
||||||
path
|
path
|
||||||
];
|
];
|
||||||
[task setExecutableURL: [NSURL fileURLWithPath: @"/usr/bin/tar"]];
|
if (@available(macOS 10.13, *)) {
|
||||||
|
[task setExecutableURL: [NSURL fileURLWithPath: @"/usr/bin/tar"]];
|
||||||
|
[task setCurrentDirectoryURL: sd];
|
||||||
|
} else {
|
||||||
|
[task setLaunchPath: @"/usr/bin/tar"];
|
||||||
|
[task setCurrentDirectoryPath: SupportDirectoryPath()];
|
||||||
|
}
|
||||||
[task setArguments: argv];
|
[task setArguments: argv];
|
||||||
[task setCurrentDirectoryURL: sd];
|
|
||||||
|
|
||||||
|
|
||||||
dispatch_time_t when = dispatch_time(DISPATCH_TIME_NOW, (int64_t)(2 * NSEC_PER_SEC));
|
dispatch_time_t when = dispatch_time(DISPATCH_TIME_NOW, (int64_t)(2 * NSEC_PER_SEC));
|
||||||
[task setTerminationHandler: ^(NSTask *task){
|
[task setTerminationHandler: ^(NSTask *task){
|
||||||
|
|
|
@ -411,8 +411,11 @@ Todo --
|
||||||
|
|
||||||
-(void)_init {
|
-(void)_init {
|
||||||
_backgroundColor = [NSColor windowBackgroundColor];
|
_backgroundColor = [NSColor windowBackgroundColor];
|
||||||
_selectedColor = [NSColor selectedContentBackgroundColor];
|
if (@available(macOS 10.14, *)) {
|
||||||
|
_selectedColor = [NSColor selectedContentBackgroundColor];
|
||||||
|
} else {
|
||||||
|
_selectedColor = [NSColor selectedTextBackgroundColor];
|
||||||
|
}
|
||||||
NSTrackingAreaOptions options = NSTrackingMouseMoved | NSTrackingMouseEnteredAndExited | NSTrackingInVisibleRect | NSTrackingActiveInActiveApp;
|
NSTrackingAreaOptions options = NSTrackingMouseMoved | NSTrackingMouseEnteredAndExited | NSTrackingInVisibleRect | NSTrackingActiveInActiveApp;
|
||||||
_trackingArea = [[NSTrackingArea alloc] initWithRect: NSZeroRect
|
_trackingArea = [[NSTrackingArea alloc] initWithRect: NSZeroRect
|
||||||
options: options
|
options: options
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="15705" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES" customObjectInstantitationMethod="direct">
|
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="15705" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES" customObjectInstantitationMethod="direct">
|
||||||
<dependencies>
|
<dependencies>
|
||||||
<deployment identifier="macosx"/>
|
|
||||||
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="15705"/>
|
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="15705"/>
|
||||||
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
|
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
|
@ -67,8 +67,11 @@
|
||||||
[window setRestorable: YES];
|
[window setRestorable: YES];
|
||||||
[window setRestorationClass: [self class]];
|
[window setRestorationClass: [self class]];
|
||||||
|
|
||||||
|
if (@available(macOS 10.13, *)) {
|
||||||
[_tableView registerForDraggedTypes: @[NSPasteboardTypeFileURL]];
|
[_tableView registerForDraggedTypes: @[NSPasteboardTypeFileURL]];
|
||||||
|
} else {
|
||||||
|
[_tableView registerForDraggedTypes: @[NSURLPboardType]];
|
||||||
|
}
|
||||||
[_tableView setDraggingSourceOperationMask: NSDragOperationCopy forLocal: NO]; // enable drag/drop to othr apps.
|
[_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.
|
// Implement this method to handle any initialization after your window controller's window has been loaded from its nib file.
|
||||||
|
@ -95,6 +98,11 @@
|
||||||
[nc addObserver: self selector: @selector(willTerminate:) name: NSApplicationWillTerminateNotification object: nil];
|
[nc addObserver: self selector: @selector(willTerminate:) name: NSApplicationWillTerminateNotification object: nil];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
-(void)timerCallback: (NSTimer *)timer {
|
||||||
|
_timer = nil;
|
||||||
|
[self saveFile];
|
||||||
|
}
|
||||||
|
|
||||||
-(void)diskImageAdded: (NSNotification *)notification {
|
-(void)diskImageAdded: (NSNotification *)notification {
|
||||||
|
|
||||||
NSURL *url = [notification object];
|
NSURL *url = [notification object];
|
||||||
|
@ -105,11 +113,15 @@
|
||||||
-(void)markDirty {
|
-(void)markDirty {
|
||||||
_dirty = YES;
|
_dirty = YES;
|
||||||
if (_timer) [_timer invalidate];
|
if (_timer) [_timer invalidate];
|
||||||
|
_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) {
|
_timer = [NSTimer scheduledTimerWithTimeInterval: 5 * 60 repeats: NO block: ^(NSTimer *t) {
|
||||||
|
|
||||||
self->_timer = nil;
|
self->_timer = nil;
|
||||||
[self saveFile];
|
[self saveFile];
|
||||||
}];
|
}];
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
-(void)saveFile {
|
-(void)saveFile {
|
||||||
|
@ -306,11 +318,15 @@
|
||||||
for (NSPasteboardItem *item in [pb pasteboardItems]) {
|
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?
|
// need to convert from a string to a url back to a file in case it's a file id url?
|
||||||
NSString *s = [item stringForType: NSPasteboardTypeFileURL];
|
NSString *s;
|
||||||
|
if (@available(macOS 10.13, *)) {
|
||||||
|
s = [item stringForType: NSPasteboardTypeFileURL];
|
||||||
|
} else {
|
||||||
|
s = [item stringForType: NSURLPboardType];
|
||||||
|
}
|
||||||
if (!s) continue;
|
if (!s) continue;
|
||||||
NSURL *url = [NSURL URLWithString: s];
|
NSURL *url = [NSURL URLWithString: s];
|
||||||
if (!url) continue;
|
if (!url) continue;
|
||||||
|
|
||||||
ok |= [self addFile: url];
|
ok |= [self addFile: url];
|
||||||
}
|
}
|
||||||
return ok;
|
return ok;
|
||||||
|
|
|
@ -53,9 +53,16 @@ static NSMutableSet *LogWindows;
|
||||||
}
|
}
|
||||||
|
|
||||||
NSTask *task = [NSTask new];
|
NSTask *task = [NSTask new];
|
||||||
[task setExecutableURL: url];
|
|
||||||
|
if (@available(macOS 10.13, *)) {
|
||||||
|
[task setExecutableURL: url];
|
||||||
|
[task setCurrentDirectoryURL: MameWorkingDirectory()];
|
||||||
|
} else {
|
||||||
|
[task setLaunchPath: MamePath()];
|
||||||
|
[task setCurrentDirectoryPath: MameWorkingDirectoryPath()];
|
||||||
|
}
|
||||||
|
|
||||||
[task setArguments: args];
|
[task setArguments: args];
|
||||||
[task setCurrentDirectoryURL: MameWorkingDirectory()];
|
|
||||||
|
|
||||||
return [LogWindowController controllerForTask: task];
|
return [LogWindowController controllerForTask: task];
|
||||||
}
|
}
|
||||||
|
@ -84,20 +91,39 @@ static NSMutableSet *LogWindows;
|
||||||
|
|
||||||
if (_task) return nil;
|
if (_task) return nil;
|
||||||
|
|
||||||
NSError *error = nil;
|
|
||||||
NSPipe *pipe = [NSPipe pipe];
|
NSPipe *pipe = [NSPipe pipe];
|
||||||
|
|
||||||
// window not yet loaded until [self window] called.
|
// window not yet loaded until [self window] called.
|
||||||
const char *path = [[task executableURL] fileSystemRepresentation];
|
|
||||||
// if (cp) [self appendString: [NSString stringWithFormat: @"MAME path: %s", cp]];
|
const char *path = nil;
|
||||||
const char *wd = [[task currentDirectoryURL] fileSystemRepresentation];
|
const char *wd = nil;
|
||||||
// if (cp) [self appendString: [NSString stringWithFormat: @"Working Directory: %s", cp]];
|
|
||||||
|
|
||||||
[task setStandardError: pipe];
|
[task setStandardError: pipe];
|
||||||
[task setStandardOutput: pipe];
|
[task setStandardOutput: pipe];
|
||||||
[task launchAndReturnError: &error];
|
if (@available(macOS 10.13, *)) {
|
||||||
|
NSError *error = nil;
|
||||||
|
path = [[task executableURL] fileSystemRepresentation];
|
||||||
|
wd = [[task currentDirectoryURL] fileSystemRepresentation];
|
||||||
|
|
||||||
|
[task launchAndReturnError: &error];
|
||||||
|
if (error) {
|
||||||
|
NSLog(@"NSTask error. Path = %s error = %@", path, error);
|
||||||
|
}
|
||||||
|
return error;
|
||||||
|
} else {
|
||||||
|
path = [[task launchPath] fileSystemRepresentation];
|
||||||
|
wd = [[task currentDirectoryPath] fileSystemRepresentation];
|
||||||
|
@try {
|
||||||
|
[task launch];
|
||||||
|
} @catch (NSException *exception) {
|
||||||
|
|
||||||
|
NSLog(@"NSTask exception. Path = %s exception = %@", path, exception);
|
||||||
|
return nil; // ?
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#if 0
|
||||||
if (error) {
|
if (error) {
|
||||||
// NSURL *url = [task executableURL];
|
// NSURL *url = [task executableURL];
|
||||||
// NSString *path = [NSString stringWithCString: [url fileSystemRepresentation] encoding: NSUTF8StringEncoding];
|
// NSString *path = [NSString stringWithCString: [url fileSystemRepresentation] encoding: NSUTF8StringEncoding];
|
||||||
|
@ -106,6 +132,7 @@ static NSMutableSet *LogWindows;
|
||||||
// [self appendString: [error description]];
|
// [self appendString: [error description]];
|
||||||
return error;
|
return error;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
_task = task;
|
_task = task;
|
||||||
NSString *title = [NSString stringWithFormat: @"Ample Log - %u", [task processIdentifier]];
|
NSString *title = [NSString stringWithFormat: @"Ample Log - %u", [task processIdentifier]];
|
||||||
[[self window] setTitle: title];
|
[[self window] setTitle: title];
|
||||||
|
|
Loading…
Reference in New Issue