Skip to content
Snippets Groups Projects
Commit d509ba22 authored by George Nachman's avatar George Nachman
Browse files

Change instructions for enabling access for assistive devices for 10.9 (and...

Change instructions for enabling access for assistive devices for 10.9 (and have it open the right part of prefs using scripting). Switch to 10.9 SDK.
parent 10f94145
No related branches found
No related tags found
No related merge requests found
/*
* SBSystemPreferences.h
*/
#import <AppKit/AppKit.h>
#import <ScriptingBridge/ScriptingBridge.h>
@class SBSystemPreferencesApplication, SBSystemPreferencesDocument, SBSystemPreferencesWindow, SBSystemPreferencesPane, SBSystemPreferencesAnchor;
enum SBSystemPreferencesSaveOptions {
SBSystemPreferencesSaveOptionsYes = 'yes ' /* Save the file. */,
SBSystemPreferencesSaveOptionsNo = 'no ' /* Do not save the file. */,
SBSystemPreferencesSaveOptionsAsk = 'ask ' /* Ask the user whether or not to save the file. */
};
typedef enum SBSystemPreferencesSaveOptions SBSystemPreferencesSaveOptions;
enum SBSystemPreferencesPrintingErrorHandling {
SBSystemPreferencesPrintingErrorHandlingStandard = 'lwst' /* Standard PostScript error handling */,
SBSystemPreferencesPrintingErrorHandlingDetailed = 'lwdt' /* print a detailed report of PostScript errors */
};
typedef enum SBSystemPreferencesPrintingErrorHandling SBSystemPreferencesPrintingErrorHandling;
/*
* Standard Suite
*/
// The application's top-level scripting object.
@interface SBSystemPreferencesApplication : SBApplication
- (SBElementArray *) documents;
- (SBElementArray *) windows;
@property (copy, readonly) NSString *name; // The name of the application.
@property (readonly) BOOL frontmost; // Is this the active application?
@property (copy, readonly) NSString *version; // The version number of the application.
- (id) open:(id)x; // Open a document.
- (void) print:(id)x withProperties:(NSDictionary *)withProperties printDialog:(BOOL)printDialog; // Print a document.
- (void) quitSaving:(SBSystemPreferencesSaveOptions)saving; // Quit the application.
- (BOOL) exists:(id)x; // Verify that an object exists.
@end
// A document.
@interface SBSystemPreferencesDocument : SBObject
@property (copy, readonly) NSString *name; // Its name.
@property (readonly) BOOL modified; // Has it been modified since the last save?
@property (copy, readonly) NSURL *file; // Its location on disk, if it has one.
- (void) closeSaving:(SBSystemPreferencesSaveOptions)saving savingIn:(NSURL *)savingIn; // Close a document.
- (void) saveIn:(NSURL *)in_ as:(id)as; // Save a document.
- (void) printWithProperties:(NSDictionary *)withProperties printDialog:(BOOL)printDialog; // Print a document.
- (void) delete; // Delete an object.
- (void) duplicateTo:(SBObject *)to withProperties:(NSDictionary *)withProperties; // Copy an object.
- (void) moveTo:(SBObject *)to; // Move an object to a new location.
@end
// A window.
@interface SBSystemPreferencesWindow : SBObject
@property (copy, readonly) NSString *name; // The title of the window.
- (NSInteger) id; // The unique identifier of the window.
@property NSInteger index; // The index of the window, ordered front to back.
@property NSRect bounds; // The bounding rectangle of the window.
@property (readonly) BOOL closeable; // Does the window have a close button?
@property (readonly) BOOL miniaturizable; // Does the window have a minimize button?
@property BOOL miniaturized; // Is the window minimized right now?
@property (readonly) BOOL resizable; // Can the window be resized?
@property BOOL visible; // Is the window visible right now?
@property (readonly) BOOL zoomable; // Does the window have a zoom button?
@property BOOL zoomed; // Is the window zoomed right now?
@property (copy, readonly) SBSystemPreferencesDocument *document; // The document whose contents are displayed in the window.
- (void) closeSaving:(SBSystemPreferencesSaveOptions)saving savingIn:(NSURL *)savingIn; // Close a document.
- (void) saveIn:(NSURL *)in_ as:(id)as; // Save a document.
- (void) printWithProperties:(NSDictionary *)withProperties printDialog:(BOOL)printDialog; // Print a document.
- (void) delete; // Delete an object.
- (void) duplicateTo:(SBObject *)to withProperties:(NSDictionary *)withProperties; // Copy an object.
- (void) moveTo:(SBObject *)to; // Move an object to a new location.
@end
/*
* System Preferences
*/
// System Preferences top level scripting object
@interface SBSystemPreferencesApplication (SystemPreferences)
- (SBElementArray *) panes;
@property (copy) SBSystemPreferencesPane *currentPane; // the currently selected pane
@property (copy, readonly) SBSystemPreferencesWindow *preferencesWindow; // the main preferences window
@property BOOL showAll; // Is SystemPrefs in show all view. (Setting to false will do nothing)
@end
// a preference pane
@interface SBSystemPreferencesPane : SBObject
- (SBElementArray *) anchors;
- (NSString *) id; // locale independent name of the preference pane; can refer to a pane using the expression: pane id "<name>"
@property (copy, readonly) NSString *localizedName; // localized name of the preference pane
@property (copy, readonly) NSString *name; // name of the preference pane as it appears in the title bar; can refer to a pane using the expression: pane "<name>"
- (void) closeSaving:(SBSystemPreferencesSaveOptions)saving savingIn:(NSURL *)savingIn; // Close a document.
- (void) saveIn:(NSURL *)in_ as:(id)as; // Save a document.
- (void) printWithProperties:(NSDictionary *)withProperties printDialog:(BOOL)printDialog; // Print a document.
- (void) delete; // Delete an object.
- (void) duplicateTo:(SBObject *)to withProperties:(NSDictionary *)withProperties; // Copy an object.
- (void) moveTo:(SBObject *)to; // Move an object to a new location.
- (id) reveal; // Reveals an anchor within a preference pane or preference pane itself
@end
// an anchor within a preference pane
@interface SBSystemPreferencesAnchor : SBObject
@property (copy, readonly) NSString *name; // name of the anchor within a preference pane
- (void) closeSaving:(SBSystemPreferencesSaveOptions)saving savingIn:(NSURL *)savingIn; // Close a document.
- (void) saveIn:(NSURL *)in_ as:(id)as; // Save a document.
- (void) printWithProperties:(NSDictionary *)withProperties printDialog:(BOOL)printDialog; // Print a document.
- (void) delete; // Delete an object.
- (void) duplicateTo:(SBObject *)to withProperties:(NSDictionary *)withProperties; // Copy an object.
- (void) moveTo:(SBObject *)to; // Move an object to a new location.
- (id) reveal; // Reveals an anchor within a preference pane or preference pane itself
@end
Loading
Loading
@@ -192,8 +192,8 @@
<key>SUPublicDSAKeyFile</key>
<string>dsa_pub.pem</string>
<key>SUFeedURLForTesting</key>
<string>http://iterm2.com/appcasts/legacy_testing.xml</string>
<string>http://iterm2.com/appcasts/testing.xml</string>
<key>SUFeedURLForFinal</key>
<string>http://iterm2.com/appcasts/legacy_final.xml</string>
<string>http://iterm2.com/appcasts/final.xml</string>
</dict>
</plist>
Loading
Loading
@@ -406,6 +406,8 @@
9DB3D6F1176CCABE0071CCF8 /* PrefsArrangements@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 9DB3D6EF176CCABE0071CCF8 /* PrefsArrangements@2x.png */; };
A073973E14C768E400786414 /* ColorsMenuItemView.h in Headers */ = {isa = PBXBuildFile; fileRef = A073973D14C768E400786414 /* ColorsMenuItemView.h */; };
A073974014C7694600786414 /* ColorsMenuItemView.m in Sources */ = {isa = PBXBuildFile; fileRef = A073973F14C7694600786414 /* ColorsMenuItemView.m */; };
A6AA395C18275EB800A19BD5 /* SBSystemPreferences.h in Headers */ = {isa = PBXBuildFile; fileRef = A6AA395B18275EB800A19BD5 /* SBSystemPreferences.h */; };
A6AA395E18275EF200A19BD5 /* ScriptingBridge.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = A6AA395D18275EF200A19BD5 /* ScriptingBridge.framework */; };
DDF0FD65062916F70080EF74 /* iTermApplication.h in Headers */ = {isa = PBXBuildFile; fileRef = DDF0FD63062916F70080EF74 /* iTermApplication.h */; };
DDF0FD66062916F70080EF74 /* iTermApplication.m in Sources */ = {isa = PBXBuildFile; fileRef = DDF0FD64062916F70080EF74 /* iTermApplication.m */; };
F638C2620AD483BF00BEE23D /* iTerm.strings in Resources */ = {isa = PBXBuildFile; fileRef = FB151F2903648AC401F955DB /* iTerm.strings */; };
Loading
Loading
@@ -746,6 +748,8 @@
9DB3D6EF176CCABE0071CCF8 /* PrefsArrangements@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = "PrefsArrangements@2x.png"; path = "images/PrefsArrangements@2x.png"; sourceTree = "<group>"; };
A073973D14C768E400786414 /* ColorsMenuItemView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ColorsMenuItemView.h; sourceTree = "<group>"; };
A073973F14C7694600786414 /* ColorsMenuItemView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ColorsMenuItemView.m; sourceTree = "<group>"; };
A6AA395B18275EB800A19BD5 /* SBSystemPreferences.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SBSystemPreferences.h; sourceTree = "<group>"; };
A6AA395D18275EF200A19BD5 /* ScriptingBridge.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = ScriptingBridge.framework; path = System/Library/Frameworks/ScriptingBridge.framework; sourceTree = SDKROOT; };
DD02572409CB9398008F320C /* PSMAquaTabStyle.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = PSMAquaTabStyle.h; sourceTree = "<group>"; };
DD02572509CB9398008F320C /* PSMAquaTabStyle.m */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.objc; path = PSMAquaTabStyle.m; sourceTree = "<group>"; };
DD02572609CB9398008F320C /* PSMMetalTabStyle.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = PSMMetalTabStyle.h; sourceTree = "<group>"; };
Loading
Loading
@@ -849,6 +853,7 @@
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
A6AA395E18275EF200A19BD5 /* ScriptingBridge.framework in Frameworks */,
874206530564169600CFC3F1 /* AppKit.framework in Frameworks */,
F6E2DEDA0AE2F67200D20B3B /* Sparkle.framework in Frameworks */,
1D13EADC12113A2D00909F9C /* libncurses.dylib in Frameworks */,
Loading
Loading
@@ -885,6 +890,7 @@
1DEB293D1288899A00B2CB9F /* Carbon.framework */,
1D94EAC712D641D3008225A9 /* AddressBook.framework */,
1DF0897013DBAF4C00A52AD8 /* Quartz.framework */,
A6AA395D18275EF200A19BD5 /* ScriptingBridge.framework */,
);
name = JTerminal;
sourceTree = "<group>";
Loading
Loading
@@ -892,6 +898,7 @@
0464AB0E006CD2EC7F000001 /* Classes */ = {
isa = PBXGroup;
children = (
A6F6C520182765990077ADC2 /* ScriptingBridgeGeneratedCode */,
1D06E7D014BC04110097C0ED /* Profiles */,
1D06E7CF14BC03BE0097C0ED /* GTM */,
1D3D21921483142800FAC8E7 /* tmux */,
Loading
Loading
@@ -1376,6 +1383,14 @@
name = Categories;
sourceTree = "<group>";
};
A6F6C520182765990077ADC2 /* ScriptingBridgeGeneratedCode */ = {
isa = PBXGroup;
children = (
A6AA395B18275EB800A19BD5 /* SBSystemPreferences.h */,
);
name = ScriptingBridgeGeneratedCode;
sourceTree = "<group>";
};
DD02571D09CB9363008F320C /* PSMTabBarControl */ = {
isa = PBXGroup;
children = (
Loading
Loading
@@ -1644,6 +1659,7 @@
A073973E14C768E400786414 /* ColorsMenuItemView.h in Headers */,
1DA26AC015007507004B5792 /* BackgroundThread.h in Headers */,
1D2F3B3D1516BA470044C337 /* iTermFontPanel.h in Headers */,
A6AA395C18275EB800A19BD5 /* SBSystemPreferences.h in Headers */,
1D48B32316706FC3000046EE /* NSView+iTerm.h in Headers */,
1D48B379167E809D000046EE /* CharacterRun.h in Headers */,
1D70BA351680158700824B72 /* PTYFontInfo.h in Headers */,
Loading
Loading
@@ -2353,7 +2369,7 @@
);
GCC_GENERATE_DEBUGGING_SYMBOLS = YES;
GCC_OPTIMIZATION_LEVEL = 3;
GCC_VERSION = com.apple.compilers.llvmgcc42;
GCC_VERSION = "";
GCC_WARN_ABOUT_MISSING_PROTOTYPES = YES;
GCC_WARN_FOUR_CHARACTER_CONSTANTS = NO;
GCC_WARN_MISSING_PARENTHESES = YES;
Loading
Loading
@@ -2379,7 +2395,7 @@
"-licucore",
);
PRODUCT_NAME = iTerm;
SDKROOT = macosx10.6;
SDKROOT = macosx;
VALID_ARCHS = "i386 x86_64";
WARNING_CFLAGS = "-Wall";
WRAPPER_EXTENSION = app;
Loading
Loading
@@ -2403,7 +2419,7 @@
GCC_GENERATE_DEBUGGING_SYMBOLS = YES;
GCC_MODEL_TUNING = G4;
GCC_OPTIMIZATION_LEVEL = 3;
GCC_VERSION = com.apple.compilers.llvmgcc42;
GCC_VERSION = "";
GCC_WARN_ABOUT_MISSING_PROTOTYPES = YES;
GCC_WARN_FOUR_CHARACTER_CONSTANTS = NO;
GCC_WARN_MISSING_PARENTHESES = YES;
Loading
Loading
Loading
Loading
@@ -32,27 +32,29 @@
#define DEBUG_METHOD_TRACE 0
 
#import "iTermController.h"
#import "FutureMethods.h"
#import "GTMCarbonEvent.h"
#import "ITAddressBookMgr.h"
#import "NSStringITerm.h"
#import "NSView+iTerm.h"
#import "PTYSession.h"
#import "PTYTab.h"
#import "PasteboardHistory.h"
#import "PreferencePanel.h"
#import "PseudoTerminal.h"
#import "PTYSession.h"
#import "PseudoTerminal.h"
#import "SBSystemPreferences.h"
#import "UKCrashReporter/UKCrashReporter.h"
#import "VT100Screen.h"
#import "NSStringITerm.h"
#import "ITAddressBookMgr.h"
#import <iTermGrowlDelegate.h>
#import "PasteboardHistory.h"
#import <Carbon/Carbon.h>
#import "iTermApplicationDelegate.h"
#import "WindowArrangements.h"
#import "iTerm.h"
#import "iTermApplication.h"
#import "UKCrashReporter/UKCrashReporter.h"
#import "PTYTab.h"
#import "iTermKeyBindingMgr.h"
#import "PseudoTerminal.h"
#import "iTermApplicationDelegate.h"
#import "iTermExpose.h"
#import "FutureMethods.h"
#import "GTMCarbonEvent.h"
#import "iTerm.h"
#import "WindowArrangements.h"
#import "NSView+iTerm.h"
#import "iTermKeyBindingMgr.h"
#import <Carbon/Carbon.h>
#import <ScriptingBridge/ScriptingBridge.h>
#import <iTermGrowlDelegate.h>
#include <objc/runtime.h>
 
//#define HOTKEY_WINDOW_VERBOSE_LOGGING
Loading
Loading
@@ -1946,6 +1948,90 @@ static CGEventRef OnTappedEvent(CGEventTapProxy proxy, CGEventType type, CGEvent
}
}
 
- (NSString *)accessibilityMessageForHotkey {
if (IsMavericksOrLater()) {
return @"You have assigned a \"hotkey\" that opens iTerm2 at any time. "
@"To use it, you must add iTerm2 to the list of applications allowed to control your "
@"computer. Open System Preferences > Security & Privacy, select the Privacy tab, "
@"select \"Accessibility\" on the left, and drag iTerm2's icon from Finder into the "
@"area on the right.";
} else {
return @"You have assigned a \"hotkey\" that opens iTerm2 at any time. "
@"To use it, you must turn on \"access for assistive devices\" in the Universal "
@"Access preferences panel in System Preferences and restart iTerm2.";
}
}
- (NSString *)accessibilityMessageForModifier {
if (IsMavericksOrLater()) {
return @"You have chosen to remap certain modifier keys. For this to work for all key "
@"combinations (such as cmd-tab), you must add iTerm2 to the list of applications allowed to control your "
@"computer. Open System Preferences > Security & Privacy, select the Privacy tab, "
@"select \"Accessibility\" on the left, and drag iTerm2's icon from Finder into the "
@"area on the right.";
} else {
return @"You have chosen to remap certain modifier keys. For this to work for all key "
@"combinations (such as cmd-tab), you must turn on \"access for assistive devices\" "
@"in the Universal Access preferences panel in System Preferences and restart iTerm2.";
}
}
- (void)openMavericksAccessibilityPane
{
[[NSWorkspace sharedWorkspace] openFile:@"/System/Library/PreferencePanes/Security.prefPane"];
SBSystemPreferencesApplication *systemPrefs =
[SBApplication applicationWithBundleIdentifier:@"com.apple.systempreferences"];
[systemPrefs activate];
SBElementArray *panes = [systemPrefs panes];
SBSystemPreferencesPane *speechPane = nil;
for (SBSystemPreferencesPane *pane in panes) {
if ([[pane id] isEqualToString:@"com.apple.preference.security"]) {
speechPane = pane;
break;
}
}
[systemPrefs setCurrentPane:speechPane];
SBElementArray *anchors = [speechPane anchors];
for (SBSystemPreferencesAnchor *anchor in anchors) {
if ([anchor.name isEqualToString:@"Privacy"]) {
[anchor reveal];
}
}
for (SBSystemPreferencesAnchor *anchor in anchors) {
if ([anchor.name isEqualToString:@"Privacy_Accessibility"]) {
[anchor reveal];
}
}
}
- (void)navigatePrefPane
{
if (IsMavericksOrLater()) {
NSString *myPath = [[NSBundle mainBundle] bundlePath];
[[NSWorkspace sharedWorkspace] activateFileViewerSelectingURLs:[NSArray arrayWithObject:[NSURL fileURLWithPath:myPath]]];
[self performSelector:@selector(openMavericksAccessibilityPane)
withObject:nil
afterDelay:2];
} else {
[[NSWorkspace sharedWorkspace] openFile:@"/System/Library/PreferencePanes/UniversalAccessPref.prefPane"];
}
}
- (NSString *)accessibilityActionMessage {
if (IsMavericksOrLater()) {
return @"Open System Prefs and Finder";
} else {
return @"Open System Preferences";
}
}
- (BOOL)registerHotkey:(int)keyCode modifiers:(int)modifiers
{
if (carbonHotKey_) {
Loading
Loading
@@ -1956,9 +2042,9 @@ static CGEventRef OnTappedEvent(CGEventTapProxy proxy, CGEventType type, CGEvent
#ifdef USE_EVENT_TAP_FOR_HOTKEY
if (![self startEventTap]) {
switch (NSRunAlertPanel(@"Could not enable hotkey",
@"You have assigned a \"hotkey\" that opens iTerm2 at any time. To use it, you must turn on \"access for assistive devices\" in the Universal Access preferences panel in System Preferences and restart iTerm2.",
[self accessibilityMessageForHotkey],
@"OK",
@"Open System Preferences",
[self accessibilityActionMessage],
@"Disable Hotkey",
nil)) {
case NSAlertOtherReturn:
Loading
Loading
@@ -1966,7 +2052,7 @@ static CGEventRef OnTappedEvent(CGEventTapProxy proxy, CGEventType type, CGEvent
break;
 
case NSAlertAlternateReturn:
[[NSWorkspace sharedWorkspace] openFile:@"/System/Library/PreferencePanes/UniversalAccessPref.prefPane"];
[self navigatePrefPane]
return NO;
}
}
Loading
Loading
@@ -1992,13 +2078,13 @@ static CGEventRef OnTappedEvent(CGEventTapProxy proxy, CGEventType type, CGEvent
{
if (![self startEventTap]) {
switch (NSRunAlertPanel(@"Could not remap modifiers",
@"You have chosen to remap certain modifier keys. For this to work for all key combinations (such as cmd-tab), you must turn on \"access for assistive devices\" in the Universal Access preferences panel in System Preferences and restart iTerm2.",
[self accessibilityMessageForModifier],
@"OK",
@"Open System Preferences",
[self accessibilityActionMessage],
nil,
nil)) {
case NSAlertAlternateReturn:
[[NSWorkspace sharedWorkspace] openFile:@"/System/Library/PreferencePanes/UniversalAccessPref.prefPane"];
[self navigatePrefPane];
break;
}
}
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment