diff --git a/Ample/Base.lproj/MediaView.xib b/Ample/Base.lproj/MediaView.xib index cca813b..fd75d4a 100644 --- a/Ample/Base.lproj/MediaView.xib +++ b/Ample/Base.lproj/MediaView.xib @@ -91,19 +91,19 @@ - + diff --git a/Ample/MediaViewController.h b/Ample/MediaViewController.h index 7528eaf..89ce151 100644 --- a/Ample/MediaViewController.h +++ b/Ample/MediaViewController.h @@ -16,7 +16,7 @@ NS_ASSUME_NONNULL_BEGIN @property (nonatomic) NSDictionary *media; @property NSArray *args; -- (IBAction)deleteAction:(id)sender; +- (IBAction)ejectAction:(id)sender; - (IBAction)pathAction:(id)sender; @@ -28,7 +28,7 @@ NS_ASSUME_NONNULL_BEGIN @interface TablePathView : NSTableCellView @property (weak) IBOutlet NSPathControl *pathControl; -@property (weak) IBOutlet NSButton *deleteButton; +@property (weak) IBOutlet NSButton *ejectButton; @end diff --git a/Ample/MediaViewController.m b/Ample/MediaViewController.m index cf2e488..400c4bf 100644 --- a/Ample/MediaViewController.m +++ b/Ample/MediaViewController.m @@ -168,14 +168,19 @@ -(void)prepareView: (TablePathView *)view { NSPathControl *pc = [view pathControl]; + NSButton *button = [view ejectButton]; - [pc setURL: _url]; //??? will binding take care of it? [pc unbind: @"value"]; [pc bind: @"value" toObject: self withKeyPath: @"url" options: nil]; + [button unbind: @"enabled"]; + NSValueTransformer *t = [NSValueTransformer valueTransformerForName: NSIsNotNilTransformerName]; + NSDictionary *options = @{ NSValueTransformerBindingOption: t}; + [button bind: @"enabled" toObject: self withKeyPath: @"url" options: options]; + NSColor *tintColor = nil; if (!_valid) tintColor = [NSColor redColor]; - [[view deleteButton] setContentTintColor: tintColor]; + [button setContentTintColor: tintColor]; } -(CGFloat)height { @@ -405,7 +410,7 @@ enum { #pragma mark - IBActions -- (IBAction)deleteAction:(id)sender { +- (IBAction)ejectAction:(id)sender { NSInteger row = [_outlineView rowForView: sender]; if (row < 0) return; @@ -424,6 +429,7 @@ enum { } - (IBAction)pathAction:(id)sender { + // need to update the eject button... [self rebuildArgs]; } @end