Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ Slate.xcodeproj/jigish.mode1v3
Slate.xcodeproj/jigish.pbxuser
Slate.xcodeproj/project.xcworkspace/xcuserdata/jigish.xcuserdatad/
Slate.xcodeproj/xcuserdata/jigish.xcuserdatad/
Slate.xcodeproj/project.xcworkspace/xcshareddata/
# don't version xcode artifacts
*.xcuserdatad
tmp
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,9 @@ Big thanks to [philc](https://github.com/philc) for the Window Hints idea (and i

**NEW Installation Instructions**

**Note:** You must turn on the Accessibility API by checking System Preferences > Universal Access > Enable access for assistive devices
**Note:** You must turn on the Accessibility API by checking System Preferences > Universal Access > Enable access for assistive devices. If
you are on Mavericks, you must turn it on by checking *Slate* in System Preferences > Security & Privacy > Privacy.


### Direct Download ###

Expand Down Expand Up @@ -683,6 +685,7 @@ Please send all questions, bug reports, suggestions, or general commentary to [J
pageUp
q
r
rdelete
return
right
s
Expand Down
2 changes: 2 additions & 0 deletions Slate/ASCIIToCode.plist
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>rdelete</key>
<integer>117</integer>
<key>&apos;</key>
<integer>39</integer>
<key>,</key>
Expand Down
2 changes: 1 addition & 1 deletion Slate/ActivateSnapshotOperation.m
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ - (void)parseOption:(NSString *)_name value:(id)value {
@throw([NSException exceptionWithName:[NSString stringWithFormat:@"Invalid %@", _name] reason:[NSString stringWithFormat:@"Invalid %@ '%@'", _name, value] userInfo:nil]);
return;
}
[self setName:_name];
[self setName:value];
} else if ([_name isEqualToString:OPT_DELETE]) {
if (![value isKindOfClass:[NSValue class]] && ![value isKindOfClass:[NSString class]] && ![value isKindOfClass:[NSNumber class]]) {
@throw([NSException exceptionWithName:[NSString stringWithFormat:@"Invalid %@", _name] reason:[NSString stringWithFormat:@"Invalid %@ '%@'", _name, value] userInfo:nil]);
Expand Down
2 changes: 2 additions & 0 deletions Slate/Constants.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ extern NSString *const SOURCE;
extern NSString *const IF_EXISTS;

// Config Keys
extern NSString *const MENU_BAR_ICON_HIDDEN;
extern NSString *const MENU_BAR_ICON_HIDDEN_DEFAULT;
extern NSString *const DEFAULT_TO_CURRENT_SCREEN;
extern NSString *const DEFAULT_TO_CURRENT_SCREEN_DEFAULT;
extern NSString *const NUDGE_PERCENT_OF;
Expand Down
4 changes: 3 additions & 1 deletion Slate/Constants.m
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@
NSString *const IF_EXISTS = @"if_exists";

// Config Keys
NSString *const MENU_BAR_ICON_HIDDEN = @"menuBarIconHidden";
NSString *const MENU_BAR_ICON_HIDDEN_DEFAULT = @"false";
NSString *const DEFAULT_TO_CURRENT_SCREEN = @"defaultToCurrentScreen";
NSString *const DEFAULT_TO_CURRENT_SCREEN_DEFAULT = @"false";
NSString *const NUDGE_PERCENT_OF = @"nudgePercentOf";
Expand Down Expand Up @@ -69,7 +71,7 @@
NSString *const WINDOW_HINTS_HEIGHT = @"windowHintsHeight";
NSString *const WINDOW_HINTS_HEIGHT_DEFAULT = @"100";
NSString *const WINDOW_HINTS_BACKGROUND_COLOR = @"windowHintsBackgroundColor";
NSString *const WINDOW_HINTS_BACKGROUND_COLOR_DEFAULT = @"50;53;58;0.9";
NSString *const WINDOW_HINTS_BACKGROUND_COLOR_DEFAULT = @"50;53;58;0.6";
NSString *const WINDOW_HINTS_DURATION = @"windowHintsDuration";
NSString *const WINDOW_HINTS_DURATION_DEFAULT = @"3";
NSString *const WINDOW_HINTS_ROUNDED_CORNER_SIZE = @"windowHintsRoundedCornerSize";
Expand Down
2 changes: 1 addition & 1 deletion Slate/DeleteSnapshotOperation.m
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ - (void)parseOption:(NSString *)_name value:(id)value {
@throw([NSException exceptionWithName:[NSString stringWithFormat:@"Invalid %@", _name] reason:[NSString stringWithFormat:@"Invalid %@ '%@'", _name, value] userInfo:nil]);
return;
}
[self setName:_name];
[self setName:value];
} else if ([_name isEqualToString:OPT_ALL]) {
if (![value isKindOfClass:[NSValue class]] && ![value isKindOfClass:[NSString class]] && ![value isKindOfClass:[NSNumber class]]) {
@throw([NSException exceptionWithName:[NSString stringWithFormat:@"Invalid %@", _name] reason:[NSString stringWithFormat:@"Invalid %@ '%@'", _name, value] userInfo:nil]);
Expand Down
12 changes: 6 additions & 6 deletions Slate/HintView.m
Original file line number Diff line number Diff line change
Expand Up @@ -83,17 +83,17 @@ - (void)drawRect:(NSRect)dirtyRect {
[[NSGraphicsContext currentContext] saveGraphicsState];
[[NSGraphicsContext currentContext] setShouldAntialias:YES];

// draw the icon behind the rounded rect, if specified
if (icon != nil) {
[icon drawInRect:[self bounds] fromRect:NSZeroRect operation:NSCompositeSourceOver fraction:hintIconAlpha];
}

// draw the rounded rect
[hintBackgroundColor set];
float cornerSize = [[SlateConfig getInstance] getFloatConfig:WINDOW_HINTS_ROUNDED_CORNER_SIZE];
NSBezierPath *path = [NSBezierPath bezierPathWithRoundedRect:[self bounds] xRadius:cornerSize yRadius:cornerSize];
NSBezierPath *path = [NSBezierPath bezierPathWithRoundedRect:CGRectMake(self.bounds.origin.x + (self.bounds.size.width / 4), self.bounds.origin.y + (self.bounds.size.height / 4), self.bounds.size.width / 2, self.bounds.size.height / 2) xRadius:cornerSize yRadius:cornerSize];
[path fill];

// draw the icon on top of the rounded rect, if specified
if (icon != nil) {
[icon drawInRect:[self bounds] fromRect:NSZeroRect operation:NSCompositeSourceOver fraction:hintIconAlpha];
}

// draw hint letter
[self drawCenteredText:text
bounds:self.bounds
Expand Down
5 changes: 5 additions & 0 deletions Slate/JSApplicationWrapper.m
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,10 @@ - (pid_t)pid {
return [app processIdentifier];
}

- (NSString *)bundleIdentifier {
return [app bundleIdentifier];
}

- (NSString *)name {
return [app localizedName];
}
Expand Down Expand Up @@ -114,6 +118,7 @@ + (void)setJsMethods {
if (jsawJsMethods == nil) {
jsawJsMethods = @{
NSStringFromSelector(@selector(pid)): @"pid",
NSStringFromSelector(@selector(bundleIdentifier)): @"bundleIdentifier",
NSStringFromSelector(@selector(name)): @"name",
NSStringFromSelector(@selector(eachWindow:)): @"eachWindow",
NSStringFromSelector(@selector(ewindow:)): @"ewindow",
Expand Down
5 changes: 4 additions & 1 deletion Slate/LayoutOperation.m
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,10 @@ + (BOOL)activateLayout:(NSString *)name screenWrapper:(ScreenWrapper *)sw {
if ([(ApplicationOptions *)[[layout appOptions] objectForKey:appName] repeat]) {
for (NSInteger i = 0; i < CFArrayGetCount(windows); i++) {
AccessibilityWrapper *aw = [[AccessibilityWrapper alloc] initWithApp:appRef window:CFArrayGetValueAtIndex(windows, i)];
appSuccess = [[operations objectAtIndex:((i-failedWindows) % [operations count])] doOperationWithAccessibilityWrapper:aw screenWrapper:sw] && appSuccess;
if ([operations count] > 0) {
appSuccess = [[operations objectAtIndex:((i-failedWindows) % [operations count])]
doOperationWithAccessibilityWrapper:aw screenWrapper:sw] && appSuccess;
}
if ([[SlateConfig getInstance] getBoolConfig:LAYOUT_FOCUS_ON_ACTIVATE]) { [aw focus]; }
if (![(ApplicationOptions *)[[layout appOptions] objectForKey:appName] ignoreFail] && !appSuccess)
failedWindows++;
Expand Down
12 changes: 6 additions & 6 deletions Slate/RunningApplications.m
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ static void registerForWindowDeath(AXUIElementRef element, RunningApplications *
// register for death event
AXError err;
AXObserverRef observer;
err = AXObserverCreate([AccessibilityWrapper processIdentifierOfUIElement:element], windowChanged, &observer);
AXObserverCreate([AccessibilityWrapper processIdentifierOfUIElement:element], windowChanged, &observer);
err = AXObserverAddNotification(observer, element, kAXUIElementDestroyedNotification, (__bridge void *)ref);
if (err != kAXErrorSuccess) {
AXObserverRemoveNotification(observer, element, kAXUIElementDestroyedNotification);
Expand Down Expand Up @@ -311,9 +311,9 @@ - (id)init {
AXError err;
AXUIElementRef sendingApp = AXUIElementCreateApplication([app processIdentifier]);
AXObserverRef observer;
err = AXObserverCreate([app processIdentifier], windowCallback, &observer);
err = AXObserverAddNotification(observer, sendingApp, kAXWindowCreatedNotification, (__bridge void *)self);
err = AXObserverAddNotification(observer, sendingApp, kAXFocusedWindowChangedNotification, (__bridge void *)self);
AXObserverCreate([app processIdentifier], windowCallback, &observer);
AXObserverAddNotification(observer, sendingApp, kAXWindowCreatedNotification, (__bridge void *)self);
AXObserverAddNotification(observer, sendingApp, kAXFocusedWindowChangedNotification, (__bridge void *)self);
err = AXObserverAddNotification(observer, sendingApp, kAXTitleChangedNotification, (__bridge void *)self);
if (err != kAXErrorSuccess) {
AXObserverRemoveNotification(observer, sendingApp, kAXWindowCreatedNotification);
Expand Down Expand Up @@ -447,8 +447,8 @@ - (void)applicationLaunched:(id)notification {
AXObserverRef observer;
err = AXObserverCreate([launchedApp processIdentifier], windowCallback, &observer);
if (err != kAXErrorSuccess) return;
err = AXObserverAddNotification(observer, sendingApp, kAXWindowCreatedNotification, (__bridge void *)self);
err = AXObserverAddNotification(observer, sendingApp, kAXFocusedWindowChangedNotification, (__bridge void *)self);
AXObserverAddNotification(observer, sendingApp, kAXWindowCreatedNotification, (__bridge void *)self);
AXObserverAddNotification(observer, sendingApp, kAXFocusedWindowChangedNotification, (__bridge void *)self);
err = AXObserverAddNotification(observer, sendingApp, kAXTitleChangedNotification, (__bridge void *)self);
if (err != kAXErrorSuccess) {
AXObserverRemoveNotification(observer, AXUIElementCreateApplication([launchedApp processIdentifier]), kAXWindowCreatedNotification);
Expand Down
1 change: 1 addition & 0 deletions Slate/SlateAppDelegate.h
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@
- (IBAction)currentWindowInfo;
- (IBAction)configurationHelper;
- (IBAction)aboutWindow;
- (IBAction)hideMenuBarIcon;
- (void)loadConfig;
- (void)registerHotKeys;
- (void)createSnapshotOperations;
Expand Down
49 changes: 33 additions & 16 deletions Slate/SlateAppDelegate.m
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ - (IBAction)configurationHelper {
- (void)loadConfig {
[self setHasUndoOperation:NO];
[[SlateConfig getInstance] load];
[self hideMenuBarIconIfNecessary];
}

- (void)registerHotKeys {
Expand Down Expand Up @@ -168,6 +169,15 @@ - (IBAction)aboutWindow {
}
}

- (IBAction)hideMenuBarIcon {
[[NSStatusBar systemStatusBar] removeStatusItem:statusItem];
}

- (void)hideMenuBarIconIfNecessary {
BOOL menuBarIconHidden = [[SlateConfig getInstance] getBoolConfig:MENU_BAR_ICON_HIDDEN];
if (menuBarIconHidden) [self hideMenuBarIcon];
}

- (OSStatus)timerActivateBinding:(NSTimer *)timer {
return [self activateBinding:currentHotKey isRepeat:YES];
}
Expand Down Expand Up @@ -468,25 +478,32 @@ - (void)awakeFromNib {

windowInfoController = [[NSWindowController alloc] initWithWindow:windowInfo];
configHelperController = [[NSWindowController alloc] initWithWindow:configHelper];

NSMenuItem *aboutItem = [statusMenu insertItemWithTitle:@"About Slate" action:@selector(aboutWindow) keyEquivalent:@"" atIndex:0];
[aboutItem setTarget:self];

NSMenuItem *takeSnapshotItem = [statusMenu insertItemWithTitle:@"Take Snapshot" action:@selector(takeSnapshot) keyEquivalent:@"" atIndex:3];
[takeSnapshotItem setTarget:self];

activateSnapshotItem = [statusMenu insertItemWithTitle:@"Activate Snapshot" action:@selector(activateSnapshot) keyEquivalent:@"" atIndex:4];

activateSnapshotItem = [statusMenu insertItemWithTitle:@"Activate Snapshot" action:@selector(activateSnapshot) keyEquivalent:@"" atIndex:0];
[activateSnapshotItem setTarget:self];

NSMenuItem *loadConfigItem = [statusMenu insertItemWithTitle:@"Relaunch and Load Config" action:@selector(relaunch) keyEquivalent:@"" atIndex:1];
[loadConfigItem setTarget:self];

launchOnLoginItem = [statusMenu insertItemWithTitle:@"Launch Slate on Login" action:@selector(updateLaunchState) keyEquivalent:@"" atIndex:2];

NSMenuItem *takeSnapshotItem = [statusMenu insertItemWithTitle:@"Take Snapshot" action:@selector(takeSnapshot) keyEquivalent:@"" atIndex:0];
[takeSnapshotItem setTarget:self];

[statusMenu insertItem:[NSMenuItem separatorItem] atIndex:0];

NSMenuItem *windowInfoItem = [statusMenu insertItemWithTitle:@"Current Window Info" action:@selector(currentWindowInfo) keyEquivalent:@"" atIndex:0];
[windowInfoItem setTarget:self];

[statusMenu insertItem:[NSMenuItem separatorItem] atIndex:0];

launchOnLoginItem = [statusMenu insertItemWithTitle:@"Launch Slate on Login" action:@selector(updateLaunchState) keyEquivalent:@"" atIndex:0];
[self setLaunchOnLoginItemStatus];
[launchOnLoginItem setTarget:self];

NSMenuItem *windowInfoItem = [statusMenu insertItemWithTitle:@"Current Window Info" action:@selector(currentWindowInfo) keyEquivalent:@"" atIndex:4];
[windowInfoItem setTarget:self];

NSMenuItem *loadConfigItem = [statusMenu insertItemWithTitle:@"Relaunch and Load Config" action:@selector(relaunch) keyEquivalent:@"" atIndex:0];
[loadConfigItem setTarget:self];

NSMenuItem *hideItem = [statusMenu insertItemWithTitle:@"Hide Menu Bar Icon" action:@selector(hideMenuBarIcon) keyEquivalent:@"" atIndex:0];
[hideItem setTarget:self];

NSMenuItem *aboutItem = [statusMenu insertItemWithTitle:@"About Slate" action:@selector(aboutWindow) keyEquivalent:@"" atIndex:0];
[aboutItem setTarget:self];

//NSMenuItem *configInfoItem = [statusMenu insertItemWithTitle:@"Configuration Helper" action:@selector(configurationHelper) keyEquivalent:@"" atIndex:2];
//[configInfoItem setTarget:self];
Expand Down
1 change: 1 addition & 0 deletions Slate/SlateConfig.m
Original file line number Diff line number Diff line change
Expand Up @@ -538,6 +538,7 @@ - (Snapshot *)popSnapshot:(NSString *)name remove:(BOOL)remove {

- (void)setupDefaultConfigs {
[self setConfigDefaults:[NSMutableDictionary dictionaryWithCapacity:10]];
[configDefaults setObject:MENU_BAR_ICON_HIDDEN_DEFAULT forKey:MENU_BAR_ICON_HIDDEN];
[configDefaults setObject:DEFAULT_TO_CURRENT_SCREEN_DEFAULT forKey:DEFAULT_TO_CURRENT_SCREEN];
[configDefaults setObject:NUDGE_PERCENT_OF_DEFAULT forKey:NUDGE_PERCENT_OF];
[configDefaults setObject:RESIZE_PERCENT_OF_DEFAULT forKey:RESIZE_PERCENT_OF];
Expand Down
2 changes: 1 addition & 1 deletion Slate/SnapshotOperation.m
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ - (void)parseOption:(NSString *)_name value:(id)value {
@throw([NSException exceptionWithName:[NSString stringWithFormat:@"Invalid %@", _name] reason:[NSString stringWithFormat:@"Invalid %@ '%@'", _name, value] userInfo:nil]);
return;
}
[self setName:_name];
[self setName:value];
} else if ([_name isEqualToString:OPT_SAVE]) {
if (![value isKindOfClass:[NSValue class]] && ![value isKindOfClass:[NSString class]] && ![value isKindOfClass:[NSNumber class]]) {
@throw([NSException exceptionWithName:[NSString stringWithFormat:@"Invalid %@", _name] reason:[NSString stringWithFormat:@"Invalid %@ '%@'", _name, value] userInfo:nil]);
Expand Down
Loading