Skip to content

Commit

Permalink
Anvil tweaks
Browse files Browse the repository at this point in the history
  • Loading branch information
elliottkember committed May 15, 2014
1 parent 9ea2e60 commit e6deaca
Show file tree
Hide file tree
Showing 14 changed files with 1,035 additions and 11 deletions.
19 changes: 13 additions & 6 deletions Anvil.xcodeproj/project.pbxproj
Expand Up @@ -11,6 +11,7 @@
4F0B716216234A82007246F9 /* index.html in Resources */ = {isa = PBXBuildFile; fileRef = 4F0B716116234A82007246F9 /* index.html */; };
4F0DA4BA1609CED500D21ABE /* BFImage.m in Sources */ = {isa = PBXBuildFile; fileRef = 4F0DA4B81609CED500D21ABE /* BFImage.m */; settings = {COMPILER_FLAGS = "-fno-objc-arc"; }; };
4F107C681610CF0E00624611 /* InstallPow.sh in Resources */ = {isa = PBXBuildFile; fileRef = 4F107C671610CF0E00624611 /* InstallPow.sh */; };
4F1247F11916D98400F1C105 /* CDEvents.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 4F1247F01916D98400F1C105 /* CDEvents.framework */; };
4F2CCA10176384060010AB4B /* NVGroupHeaderTableCellView.m in Sources */ = {isa = PBXBuildFile; fileRef = 4F2CCA0F176384060010AB4B /* NVGroupHeaderTableCellView.m */; };
4F361366160C9816008584A0 /* NVPopupButtonCell.m in Sources */ = {isa = PBXBuildFile; fileRef = 4F361365160C9816008584A0 /* NVPopupButtonCell.m */; };
4F4AFFED1778AACF0081BBD3 /* Anvil.icns in Resources */ = {isa = PBXBuildFile; fileRef = 4F4AFFEC1778AACF0081BBD3 /* Anvil.icns */; };
Expand Down Expand Up @@ -85,7 +86,7 @@
4FB9E81216061096005B50A4 /* NVTableRowView.m in Sources */ = {isa = PBXBuildFile; fileRef = 4FB9E81116061096005B50A4 /* NVTableRowView.m */; };
4FB9E815160610A1005B50A4 /* NVTableCellView.m in Sources */ = {isa = PBXBuildFile; fileRef = 4FB9E814160610A1005B50A4 /* NVTableCellView.m */; };
4FBABB051613442200D4174B /* Sparkle.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 4FBABB041613442200D4174B /* Sparkle.framework */; };
4FBABB081613443A00D4174B /* Sparkle.framework in CopyFiles */ = {isa = PBXBuildFile; fileRef = 4FBABB041613442200D4174B /* Sparkle.framework */; };
4FBABB081613443A00D4174B /* Sparkle.framework in Copy Files */ = {isa = PBXBuildFile; fileRef = 4FBABB041613442200D4174B /* Sparkle.framework */; };
4FBABB0A161344D600D4174B /* dsa_pub.pem in Resources */ = {isa = PBXBuildFile; fileRef = 4FBABB09161344D600D4174B /* dsa_pub.pem */; };
4FBFA35B15C6F85800BA8209 /* Cocoa.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 4FBFA35A15C6F85800BA8209 /* Cocoa.framework */; };
4FBFA36515C6F85800BA8209 /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = 4FBFA36315C6F85800BA8209 /* InfoPlist.strings */; };
Expand All @@ -109,14 +110,15 @@
/* End PBXBuildFile section */

/* Begin PBXCopyFilesBuildPhase section */
4FBABB071613443100D4174B /* CopyFiles */ = {
4FBABB071613443100D4174B /* Copy Files */ = {
isa = PBXCopyFilesBuildPhase;
buildActionMask = 2147483647;
dstPath = "";
dstSubfolderSpec = 10;
files = (
4FBABB081613443A00D4174B /* Sparkle.framework in CopyFiles */,
4FBABB081613443A00D4174B /* Sparkle.framework in Copy Files */,
);
name = "Copy Files";
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXCopyFilesBuildPhase section */
Expand All @@ -128,6 +130,7 @@
4F0DA4B81609CED500D21ABE /* BFImage.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = BFImage.m; sourceTree = "<group>"; };
4F0DA4B91609CED500D21ABE /* BFImage.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BFImage.h; sourceTree = "<group>"; };
4F107C671610CF0E00624611 /* InstallPow.sh */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.script.sh; path = InstallPow.sh; sourceTree = "<group>"; };
4F1247F01916D98400F1C105 /* CDEvents.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; path = CDEvents.framework; sourceTree = "<group>"; };
4F2CCA0E176384060010AB4B /* NVGroupHeaderTableCellView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NVGroupHeaderTableCellView.h; sourceTree = "<group>"; };
4F2CCA0F176384060010AB4B /* NVGroupHeaderTableCellView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = NVGroupHeaderTableCellView.m; sourceTree = "<group>"; };
4F361364160C9816008584A0 /* NVPopupButtonCell.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NVPopupButtonCell.h; sourceTree = "<group>"; };
Expand Down Expand Up @@ -269,6 +272,7 @@
files = (
4FAB52731611D78400BD03F8 /* QuartzCore.framework in Frameworks */,
4FBFA35B15C6F85800BA8209 /* Cocoa.framework in Frameworks */,
4F1247F11916D98400F1C105 /* CDEvents.framework in Frameworks */,
4FBABB051613442200D4174B /* Sparkle.framework in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
Expand Down Expand Up @@ -483,6 +487,7 @@
4FBFA35915C6F85800BA8209 /* Frameworks */ = {
isa = PBXGroup;
children = (
4F1247F01916D98400F1C105 /* CDEvents.framework */,
4FBABB041613442200D4174B /* Sparkle.framework */,
4FBFA35A15C6F85800BA8209 /* Cocoa.framework */,
4FBFA35C15C6F85800BA8209 /* Other Frameworks */,
Expand Down Expand Up @@ -694,7 +699,7 @@
4FBFA35215C6F85800BA8209 /* Sources */,
4FBFA35315C6F85800BA8209 /* Frameworks */,
4FBFA35415C6F85800BA8209 /* Resources */,
4FBABB071613443100D4174B /* CopyFiles */,
4FBABB071613443100D4174B /* Copy Files */,
);
buildRules = (
);
Expand Down Expand Up @@ -934,7 +939,8 @@
COMBINE_HIDPI_IMAGES = NO;
FRAMEWORK_SEARCH_PATHS = (
"$(inherited)",
"\"$(SRCROOT)\"",
"$(SRCROOT)",
"$(PROJECT_DIR)",
);
GCC_PRECOMPILE_PREFIX_HEADER = YES;
GCC_PREFIX_HEADER = "Anvil/Anvil-Prefix.pch";
Expand All @@ -953,7 +959,8 @@
COMBINE_HIDPI_IMAGES = NO;
FRAMEWORK_SEARCH_PATHS = (
"$(inherited)",
"\"$(SRCROOT)\"",
"$(SRCROOT)",
"$(PROJECT_DIR)",
);
GCC_PRECOMPILE_PREFIX_HEADER = YES;
GCC_PREFIX_HEADER = "Anvil/Anvil-Prefix.pch";
Expand Down
6 changes: 3 additions & 3 deletions Anvil/NVAppDelegate.m
Expand Up @@ -50,9 +50,9 @@ - (void)applicationDidFinishLaunching:(NSNotification *)notification {

// Initialize it
[self panelController];
NSTimer *mainLoopTimer = [NSTimer scheduledTimerWithTimeInterval:2.0 target:self selector:@selector(readSites) userInfo:nil repeats:YES];
[[NSRunLoop currentRunLoop] addTimer:mainLoopTimer forMode:NSEventTrackingRunLoopMode];
// NSTimer *mainLoopTimer = [NSTimer scheduledTimerWithTimeInterval:2.0 target:self selector:@selector(readSites) userInfo:nil repeats:YES];
// [[NSRunLoop currentRunLoop] addTimer:mainLoopTimer forMode:NSEventTrackingRunLoopMode];

// Todo: open window (unless the computer's just started up)
}

Expand Down
42 changes: 41 additions & 1 deletion Anvil/NVDataSource.m
Expand Up @@ -10,9 +10,12 @@
// It uses two separate arrays: apps and hammerApps.

#import "NVDataSource.h"
#import <CDEvents/CDEvents.h>

@interface NVDataSource ()

@property (strong, atomic) CDEvents *powEvents;
@property (strong, atomic) CDEvents *hammerEvents;
@property (strong, readwrite, nonatomic) NSMutableArray *apps;
@property (strong, readwrite, nonatomic) NSMutableArray *hammerApps;
@property (strong, nonatomic) NSFileManager *fileManager;
Expand Down Expand Up @@ -40,6 +43,8 @@ - (id)init {
if (!self.fileManager) self.fileManager = [NSFileManager defaultManager];
if (!self.apps) self.apps = [[NSMutableArray alloc] init];
if (!self.hammerApps) self.hammerApps = [[NSMutableArray alloc] init];

[self startWatching];
}

return self;
Expand Down Expand Up @@ -179,7 +184,7 @@ - (void)importNewHammerSites {
NSMutableArray *appsToRemove = [[NSMutableArray alloc] init];
NSMutableArray *urlsAdded = [[NSMutableArray alloc] init];

for (NVApp *app in self.hammerApps) {
for (NVApp *app in [self.hammerApps copy]) {

BOOL found = NO;
int i = 0;
Expand Down Expand Up @@ -402,4 +407,39 @@ - (NSInteger *)numberOfHammerSites {
return self.hammerApps.count;
}

#pragma mark - FSEvents

- (void)startWatching {

NSString *hammerPath = [[@"~/Library/Containers/com.riot.hammer/Data/Library/Application Support/Riot/Hammer/AppData/Apps.plist" stringByExpandingTildeInPath] stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
NSURL *hammerURL = [NSURL URLWithString:hammerPath];
NSArray *hammerURLs = [[NSMutableArray alloc] initWithObjects:hammerURL, nil];
CDEvents *hammerEvents = [[CDEvents alloc] initWithURLs:hammerURLs block:^(CDEvents *watcher, CDEvent *event) {

[self clearOldHammerSymlinks];
[self importNewHammerSites];
} onRunLoop:[NSRunLoop mainRunLoop]
sinceEventIdentifier:kFSEventStreamEventIdSinceNow
notificationLantency:0.5
ignoreEventsFromSubDirs:NO
excludeURLs:@[]
streamCreationFlags:kCDEventsDefaultEventStreamFlags|kFSEventStreamCreateFlagFileEvents];
self.hammerEvents = hammerEvents;

NSString *powPath = [@"~/.pow/" stringByExpandingTildeInPath];
NSURL *powURL = [NSURL URLWithString:powPath];
NSArray *urls = [[NSMutableArray alloc] initWithObjects:powURL, nil];
CDEvents *powEvents = [[CDEvents alloc] initWithURLs:urls block:^(CDEvents *watcher, CDEvent *event) {

[self importFromPowdirectory];
} onRunLoop:[NSRunLoop mainRunLoop]
sinceEventIdentifier:kFSEventStreamEventIdSinceNow
notificationLantency:0.5
ignoreEventsFromSubDirs:NO
excludeURLs:@[]
streamCreationFlags:kCDEventsDefaultEventStreamFlags|kFSEventStreamCreateFlagFileEvents];

self.powEvents = powEvents;
}

@end
2 changes: 1 addition & 1 deletion Anvil/NVPanelController.m
Expand Up @@ -149,7 +149,7 @@ - (void)awakeFromNib {

self.powCheckerTimer = [NSTimer scheduledTimerWithTimeInterval:5.0 target:self selector:@selector(switchSwitchViewToPowStatus) userInfo:nil repeats:YES];
[[NSRunLoop mainRunLoop] addTimer:self.powCheckerTimer forMode:NSRunLoopCommonModes];

// Draw it off-screen sure
// [self.window setFrameOrigin:NSMakePoint(10000, 10000)];
// [self.window makeKeyAndOrderFront:nil];
Expand Down
1 change: 1 addition & 0 deletions CDEvents.framework/CDEvents
1 change: 1 addition & 0 deletions CDEvents.framework/Headers
1 change: 1 addition & 0 deletions CDEvents.framework/Resources
Binary file added CDEvents.framework/Versions/A/CDEvents
Binary file not shown.

0 comments on commit e6deaca

Please sign in to comment.