forked from gnachman/iTerm2
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFutureMethods.m
More file actions
86 lines (73 loc) · 2.31 KB
/
FutureMethods.m
File metadata and controls
86 lines (73 loc) · 2.31 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
//
// FutureMethods.m
// iTerm
//
// Created by George Nachman on 8/29/11.
// Copyright 2011 Georgetech. All rights reserved.
//
#import "FutureMethods.h"
@implementation NSScreen (future)
+ (BOOL)futureScreensHaveSeparateSpaces {
if ([self respondsToSelector:@selector(screensHaveSeparateSpaces)]) {
return [self screensHaveSeparateSpaces];
} else {
return NO;
}
}
@end
static void *GetFunctionByName(NSString *library, char *func) {
CFBundleRef bundle;
CFURLRef bundleURL = CFURLCreateWithFileSystemPath(kCFAllocatorDefault, (CFStringRef) library, kCFURLPOSIXPathStyle, true);
CFStringRef functionName = CFStringCreateWithCString(kCFAllocatorDefault, func, kCFStringEncodingASCII);
bundle = CFBundleCreate(kCFAllocatorDefault, bundleURL);
void *f = NULL;
if (bundle) {
f = CFBundleGetFunctionPointerForName(bundle, functionName);
CFRelease(bundle);
}
CFRelease(functionName);
CFRelease(bundleURL);
return f;
}
CGSSetWindowBackgroundBlurRadiusFunction* GetCGSSetWindowBackgroundBlurRadiusFunction(void) {
static BOOL tried = NO;
static CGSSetWindowBackgroundBlurRadiusFunction *function = NULL;
if (!tried) {
function = GetFunctionByName(@"/System/Library/Frameworks/ApplicationServices.framework",
"CGSSetWindowBackgroundBlurRadius");
tried = YES;
}
return function;
}
@implementation NSOpenPanel (Utility)
- (NSArray *)legacyFilenames {
NSMutableArray *filenames = [NSMutableArray array];
for (NSURL *url in self.URLs) {
[filenames addObject:url.path];
}
return filenames;
}
@end
@implementation NSSavePanel (Utility)
- (NSInteger)legacyRunModalForDirectory:(NSString *)path file:(NSString *)name types:(NSArray *)fileTypes {
if (path) {
self.directoryURL = [NSURL fileURLWithPath:path];
}
if (name) {
self.nameFieldStringValue = name;
}
if (fileTypes) {
self.allowedFileTypes = fileTypes;
}
return [self runModal];
}
- (NSInteger)legacyRunModalForDirectory:(NSString *)path file:(NSString *)name {
return [self legacyRunModalForDirectory:path file:name types:nil];
}
- (NSString *)legacyDirectory {
return [[self directoryURL] path];
}
- (NSString *)legacyFilename {
return [[self URL] path];
}
@end