mirror of https://github.com/ksherlock/ample.git
media view - only enable eject button when there's something to eject.
This commit is contained in:
parent
69023c4af3
commit
3c77f0a309
|
@ -91,19 +91,19 @@
|
||||||
</connections>
|
</connections>
|
||||||
</pathControl>
|
</pathControl>
|
||||||
<button verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="zNo-ij-mUl">
|
<button verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="zNo-ij-mUl">
|
||||||
<rect key="frame" x="253" y="5" width="23" height="18"/>
|
<rect key="frame" x="253" y="3" width="23" height="18"/>
|
||||||
<autoresizingMask key="autoresizingMask" flexibleMinX="YES" flexibleMinY="YES" flexibleMaxY="YES"/>
|
<autoresizingMask key="autoresizingMask" flexibleMinX="YES" flexibleMinY="YES" flexibleMaxY="YES"/>
|
||||||
<buttonCell key="cell" type="bevel" bezelStyle="rounded" image="NSNavEjectButton.normalSelected" imagePosition="overlaps" alignment="center" controlSize="small" imageScaling="proportionallyDown" inset="2" id="IZA-Tu-olu">
|
<buttonCell key="cell" type="bevel" bezelStyle="rounded" image="NSNavEjectButton.normalSelected" imagePosition="overlaps" alignment="center" controlSize="small" imageScaling="proportionallyDown" inset="2" id="IZA-Tu-olu">
|
||||||
<behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
|
<behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
|
||||||
<font key="font" metaFont="smallSystem"/>
|
<font key="font" metaFont="smallSystem"/>
|
||||||
</buttonCell>
|
</buttonCell>
|
||||||
<connections>
|
<connections>
|
||||||
<action selector="deleteAction:" target="-2" id="XAl-eQ-nUj"/>
|
<action selector="ejectAction:" target="-2" id="XAl-eQ-nUj"/>
|
||||||
</connections>
|
</connections>
|
||||||
</button>
|
</button>
|
||||||
</subviews>
|
</subviews>
|
||||||
<connections>
|
<connections>
|
||||||
<outlet property="deleteButton" destination="zNo-ij-mUl" id="9br-3c-ddI"/>
|
<outlet property="ejectButton" destination="zNo-ij-mUl" id="uzY-tA-5Wf"/>
|
||||||
<outlet property="pathControl" destination="f7R-TO-fmF" id="oH7-N3-JC7"/>
|
<outlet property="pathControl" destination="f7R-TO-fmF" id="oH7-N3-JC7"/>
|
||||||
</connections>
|
</connections>
|
||||||
</tableCellView>
|
</tableCellView>
|
||||||
|
|
|
@ -16,7 +16,7 @@ NS_ASSUME_NONNULL_BEGIN
|
||||||
@property (nonatomic) NSDictionary *media;
|
@property (nonatomic) NSDictionary *media;
|
||||||
@property NSArray *args;
|
@property NSArray *args;
|
||||||
|
|
||||||
- (IBAction)deleteAction:(id)sender;
|
- (IBAction)ejectAction:(id)sender;
|
||||||
- (IBAction)pathAction:(id)sender;
|
- (IBAction)pathAction:(id)sender;
|
||||||
|
|
||||||
|
|
||||||
|
@ -28,7 +28,7 @@ NS_ASSUME_NONNULL_BEGIN
|
||||||
|
|
||||||
@interface TablePathView : NSTableCellView
|
@interface TablePathView : NSTableCellView
|
||||||
@property (weak) IBOutlet NSPathControl *pathControl;
|
@property (weak) IBOutlet NSPathControl *pathControl;
|
||||||
@property (weak) IBOutlet NSButton *deleteButton;
|
@property (weak) IBOutlet NSButton *ejectButton;
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
||||||
|
|
|
@ -168,14 +168,19 @@
|
||||||
|
|
||||||
-(void)prepareView: (TablePathView *)view {
|
-(void)prepareView: (TablePathView *)view {
|
||||||
NSPathControl *pc = [view pathControl];
|
NSPathControl *pc = [view pathControl];
|
||||||
|
NSButton *button = [view ejectButton];
|
||||||
|
|
||||||
[pc setURL: _url]; //??? will binding take care of it?
|
|
||||||
[pc unbind: @"value"];
|
[pc unbind: @"value"];
|
||||||
[pc bind: @"value" toObject: self withKeyPath: @"url" options: nil];
|
[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;
|
NSColor *tintColor = nil;
|
||||||
if (!_valid) tintColor = [NSColor redColor];
|
if (!_valid) tintColor = [NSColor redColor];
|
||||||
[[view deleteButton] setContentTintColor: tintColor];
|
[button setContentTintColor: tintColor];
|
||||||
}
|
}
|
||||||
|
|
||||||
-(CGFloat)height {
|
-(CGFloat)height {
|
||||||
|
@ -405,7 +410,7 @@ enum {
|
||||||
|
|
||||||
|
|
||||||
#pragma mark - IBActions
|
#pragma mark - IBActions
|
||||||
- (IBAction)deleteAction:(id)sender {
|
- (IBAction)ejectAction:(id)sender {
|
||||||
|
|
||||||
NSInteger row = [_outlineView rowForView: sender];
|
NSInteger row = [_outlineView rowForView: sender];
|
||||||
if (row < 0) return;
|
if (row < 0) return;
|
||||||
|
@ -424,6 +429,7 @@ enum {
|
||||||
}
|
}
|
||||||
|
|
||||||
- (IBAction)pathAction:(id)sender {
|
- (IBAction)pathAction:(id)sender {
|
||||||
|
// need to update the eject button...
|
||||||
[self rebuildArgs];
|
[self rebuildArgs];
|
||||||
}
|
}
|
||||||
@end
|
@end
|
||||||
|
|
Loading…
Reference in New Issue