Skip to content

Commit

Permalink
fix user plugins [Fixes #319]
Browse files Browse the repository at this point in the history
  • Loading branch information
nate-parrott committed Feb 11, 2015
1 parent 34d5e24 commit b477213
Show file tree
Hide file tree
Showing 9 changed files with 26 additions and 18 deletions.
2 changes: 1 addition & 1 deletion FlashlightApp/EasySIMBL/AppDelegate.m
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,7 @@ - (IBAction)requestAPlugin:(id)sender {
}
#pragma mark Links
- (IBAction)showPythonAPI:(id)sender {
[[NSWorkspace sharedWorkspace] openURL:[NSURL URLWithString:@"https://github.com/nate-parrott/Flashlight/blob/master/Docs/Tutorial.markdown"]];
[[NSWorkspace sharedWorkspace] openURL:[NSURL URLWithString:@"https://github.com/nate-parrott/Flashlight/wiki/Creating-a-Plugin"]];

}

Expand Down
14 changes: 13 additions & 1 deletion FlashlightApp/EasySIMBL/Base.lproj/MainMenu.xib
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="6250" systemVersion="14C109" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none">
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="6250" systemVersion="14D72i" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none">
<dependencies>
<deployment version="101000" identifier="macosx"/>
<development version="5000" identifier="xcode"/>
Expand Down Expand Up @@ -741,8 +741,20 @@
<action selector="openSettings:" target="FQb-yf-BXy" id="Mpy-la-wLc"/>
</connections>
</button>
<button verticalHuggingPriority="750" id="LNg-W2-VyP">
<rect key="frame" x="347" y="8" width="97" height="17"/>
<autoresizingMask key="autoresizingMask" flexibleMinX="YES" flexibleMaxY="YES"/>
<buttonCell key="cell" type="inline" title="Edit" bezelStyle="inline" imagePosition="overlaps" alignment="center" borderStyle="border" imageScaling="proportionallyDown" inset="2" id="pqr-Lb-xGV">
<behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
<font key="font" metaFont="smallSystemBold"/>
</buttonCell>
<connections>
<action selector="edit:" target="FQb-yf-BXy" id="nmg-Bk-cJc"/>
</connections>
</button>
</subviews>
<connections>
<outlet property="editButton" destination="LNg-W2-VyP" id="dIe-LV-X3I"/>
<outlet property="loader" destination="Agl-8K-jT3" id="Ewm-F1-sNa"/>
<outlet property="removeButton" destination="XCq-UX-7Ic" id="6Ja-6I-Mga"/>
<outlet property="settingsButton" destination="4lu-N2-9Kf" id="mxP-Y2-S4V"/>
Expand Down
7 changes: 6 additions & 1 deletion FlashlightApp/EasySIMBL/PluginCellView.m
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

@interface PluginCellView ()

@property (nonatomic) IBOutlet NSButton *settingsButton;
@property (nonatomic) IBOutlet NSButton *settingsButton, *editButton;

@end

Expand All @@ -33,6 +33,11 @@ - (void)setObjectValue:(id)objectValue {
[self.loader stopAnimation:nil];
}
self.settingsButton.hidden = [self.plugin installing] || ![self.plugin hasOptions];
self.editButton.hidden = !self.plugin.isAutomatorWorkflow;
}

- (IBAction)edit:(id)sender {
[self.listController editAutomatorPluginNamed:self.plugin.name];
}

- (IBAction)remove:(id)sender {
Expand Down
2 changes: 0 additions & 2 deletions FlashlightApp/EasySIMBL/PluginEditorWindowController.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@

#import <Cocoa/Cocoa.h>

NSString * const PluginDidChangeOnDiskNotification;

@interface PluginEditorWindowController : NSWindowController

@property (nonatomic) NSString *pluginPath;
Expand Down
7 changes: 2 additions & 5 deletions FlashlightApp/EasySIMBL/PluginEditorWindowController.m
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@
//

#import "PluginEditorWindowController.h"

NSString * const PluginDidChangeOnDiskNotification = @"PluginDidChangeOnDiskNotification";
#import <utime.h>

@interface PluginEditorWindowController () <NSTextViewDelegate, NSTextFieldDelegate>

Expand Down Expand Up @@ -38,11 +37,10 @@ - (void)save {
json[@"examples"] = [self.examples.string componentsSeparatedByString:@"\n"];
[[NSJSONSerialization dataWithJSONObject:json options:0 error:nil] writeToFile:[self.pluginPath stringByAppendingPathComponent:@"info.json"] atomically:YES];
[self.examples.string writeToFile:[self.pluginPath stringByAppendingPathComponent:@"examples.txt"] atomically:YES encoding:NSUTF8StringEncoding error:nil];
utime(self.pluginPath.stringByDeletingLastPathComponent.UTF8String, NULL);

self.saveTimer = nil;
self.pendingSave = NO;

[[NSNotificationCenter defaultCenter] postNotificationName:PluginDidChangeOnDiskNotification object:self];
}
#pragma mark Actions
- (IBAction)edited:(id)sender {
Expand All @@ -61,7 +59,6 @@ - (IBAction)deletePlugin:(id)sender {
self.pendingSave = NO;
[self.saveTimer invalidate];
self.saveTimer = nil;
[[NSNotificationCenter defaultCenter] postNotificationName:PluginDidChangeOnDiskNotification object:self];
[self close];
}
#pragma mark NSTextViewDelegate
Expand Down
2 changes: 2 additions & 0 deletions FlashlightApp/EasySIMBL/PluginListController.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,4 +43,6 @@

@property (nonatomic) BOOL enabled;

- (void)editAutomatorPluginNamed:(NSString *)name;

@end
5 changes: 1 addition & 4 deletions FlashlightApp/EasySIMBL/PluginListController.m
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,7 @@ - (void)startWatchingPluginsDir {
self.fileDesc = open([[self localPluginsPath] fileSystemRepresentation], O_EVTONLY);

// watch the file descriptor for writes
self.dispatchSource = dispatch_source_create(DISPATCH_SOURCE_TYPE_VNODE, self.fileDesc, DISPATCH_VNODE_DELETE | DISPATCH_VNODE_WRITE | DISPATCH_VNODE_EXTEND | DISPATCH_VNODE_RENAME | DISPATCH_VNODE_REVOKE, dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_BACKGROUND, 0));
self.dispatchSource = dispatch_source_create(DISPATCH_SOURCE_TYPE_VNODE, self.fileDesc, DISPATCH_VNODE_DELETE | DISPATCH_VNODE_WRITE | DISPATCH_VNODE_EXTEND | DISPATCH_VNODE_RENAME | DISPATCH_VNODE_REVOKE | DISPATCH_VNODE_ATTRIB, dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_BACKGROUND, 0));

// call the passed block if the source is modified
__weak PluginListController *weakSelf = self;
Expand All @@ -283,13 +283,10 @@ - (void)startWatchingPluginsDir {

// at this point the dispatch source is paused, so start watching
dispatch_resume(self.dispatchSource);

[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(reloadFromDisk) name:PluginDidChangeOnDiskNotification object:nil];
}

- (void)stopWatchingPluginsDir {
dispatch_cancel(self.dispatchSource);
[[NSNotificationCenter defaultCenter] removeObserver:self name:PluginDidChangeOnDiskNotification object:nil];
}

- (void)reloadFromDisk {
Expand Down
3 changes: 0 additions & 3 deletions FlashlightApp/EasySIMBL/SearchPluginEditorWindowController.m
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,6 @@ - (void)save {

self.saveTimer = nil;
self.pendingSave = NO;

[[NSNotificationCenter defaultCenter] postNotificationName:PluginDidChangeOnDiskNotification object:self];
}
#pragma mark Window
- (void)windowDidLoad {
Expand Down Expand Up @@ -101,7 +99,6 @@ - (IBAction)deletePlugin:(id)sender {
self.pendingSave = NO;
[self.saveTimer invalidate];
self.saveTimer = nil;
[[NSNotificationCenter defaultCenter] postNotificationName:PluginDidChangeOnDiskNotification object:self];
[self close];
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ - (void)startWatchingForFileChanges {

self.fileEventQueue = dispatch_queue_create("-[PSPluginExampleSource fileEventQueue]", dispatch_queue_attr_make_with_qos_class(0, QOS_CLASS_BACKGROUND, 0));
// watch the file descriptor for writes
self.dispatchSource = dispatch_source_create(DISPATCH_SOURCE_TYPE_VNODE, fileDesc, DISPATCH_VNODE_DELETE | DISPATCH_VNODE_WRITE | DISPATCH_VNODE_EXTEND | DISPATCH_VNODE_RENAME | DISPATCH_VNODE_REVOKE, self.fileEventQueue);
self.dispatchSource = dispatch_source_create(DISPATCH_SOURCE_TYPE_VNODE, fileDesc, DISPATCH_VNODE_DELETE | DISPATCH_VNODE_WRITE | DISPATCH_VNODE_EXTEND | DISPATCH_VNODE_RENAME | DISPATCH_VNODE_REVOKE | DISPATCH_VNODE_ATTRIB, self.fileEventQueue);

__weak PSPluginExampleSource *weak_self = self;
// call the passed block if the source is modified
Expand Down

0 comments on commit b477213

Please sign in to comment.