mirror of
https://github.com/ksherlock/ample.git
synced 2024-06-10 00:29:55 +00:00
use string instead of url for bitbanger slots.
This commit is contained in:
parent
4c003007f5
commit
7abb2f68a0
|
@ -91,11 +91,7 @@
|
|||
</buttonCell>
|
||||
<connections>
|
||||
<action selector="ejectAction:" target="-2" id="XAl-eQ-nUj"/>
|
||||
<binding destination="yGq-lc-RCM" name="enabled" keyPath="objectValue.url" id="suf-EI-g6t">
|
||||
<dictionary key="options">
|
||||
<string key="NSValueTransformerName">NSIsNotNil</string>
|
||||
</dictionary>
|
||||
</binding>
|
||||
<binding destination="yGq-lc-RCM" name="enabled" keyPath="objectValue.occupied" id="4a4-L7-ztC"/>
|
||||
</connections>
|
||||
</button>
|
||||
</subviews>
|
||||
|
@ -105,6 +101,51 @@
|
|||
<outlet property="pathControl" destination="f7R-TO-fmF" id="oH7-N3-JC7"/>
|
||||
</connections>
|
||||
</tableCellView>
|
||||
<tableCellView identifier="BBItemView" id="2Nq-Xz-tkV" customClass="TablePathView">
|
||||
<rect key="frame" x="1" y="46" width="296" height="22"/>
|
||||
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
|
||||
<subviews>
|
||||
<imageView horizontalHuggingPriority="251" verticalHuggingPriority="251" id="47E-Ef-Ott">
|
||||
<rect key="frame" x="0.0" y="1" width="20" height="20"/>
|
||||
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
|
||||
<imageCell key="cell" refusesFirstResponder="YES" alignment="left" imageAlignment="left" image="drag-handle-4x10" id="vwE-Ev-NBf"/>
|
||||
</imageView>
|
||||
<button verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="zxn-1E-o34" customClass="EjectButton">
|
||||
<rect key="frame" x="277" y="3" width="16" height="16"/>
|
||||
<autoresizingMask key="autoresizingMask" flexibleMinX="YES" flexibleMinY="YES"/>
|
||||
<buttonCell key="cell" type="bevel" bezelStyle="regularSquare" image="eject-16x16" imagePosition="only" alignment="center" alternateImage="eject-hover-16x16" imageScaling="proportionallyDown" inset="2" id="Os7-NH-tnx">
|
||||
<behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
|
||||
<font key="font" metaFont="system"/>
|
||||
</buttonCell>
|
||||
<connections>
|
||||
<action selector="ejectAction:" target="-2" id="uy2-92-9La"/>
|
||||
<binding destination="2Nq-Xz-tkV" name="enabled" keyPath="objectValue.occupied" id="SNi-sQ-J2W"/>
|
||||
</connections>
|
||||
</button>
|
||||
<textField verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="pNE-yJ-EK8">
|
||||
<rect key="frame" x="20" y="0.0" width="244" height="21"/>
|
||||
<autoresizingMask key="autoresizingMask" widthSizable="YES" flexibleMinY="YES"/>
|
||||
<textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" selectable="YES" editable="YES" sendsActionOnEndEditing="YES" borderStyle="bezel" placeholderString="socket.address:port or /path/to/file" drawsBackground="YES" id="h2U-ig-Cms">
|
||||
<font key="font" metaFont="system"/>
|
||||
<color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/>
|
||||
<color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>
|
||||
</textFieldCell>
|
||||
<connections>
|
||||
<action selector="textAction:" target="-2" id="lmX-t8-mEc"/>
|
||||
<binding destination="2Nq-Xz-tkV" name="enabled" keyPath="objectValue.valid" id="ZTM-E3-Y9P"/>
|
||||
<binding destination="2Nq-Xz-tkV" name="value" keyPath="objectValue.string" id="2dZ-JJ-asM">
|
||||
<dictionary key="options">
|
||||
<string key="NSNullPlaceholder">socket.address:port or /path/to/file</string>
|
||||
</dictionary>
|
||||
</binding>
|
||||
</connections>
|
||||
</textField>
|
||||
</subviews>
|
||||
<connections>
|
||||
<outlet property="dragHandle" destination="47E-Ef-Ott" id="bnY-rz-24V"/>
|
||||
<outlet property="ejectButton" destination="zxn-1E-o34" id="eC6-Mf-tN6"/>
|
||||
</connections>
|
||||
</tableCellView>
|
||||
</prototypeCellViews>
|
||||
</tableColumn>
|
||||
</tableColumns>
|
||||
|
|
|
@ -9,11 +9,25 @@
|
|||
#import "MediaViewController.h"
|
||||
#import "TableCellView.h"
|
||||
|
||||
enum {
|
||||
kIndexFloppy525 = 0,
|
||||
kIndexFloppy35,
|
||||
kIndexHardDrive,
|
||||
kIndexCDROM,
|
||||
kIndexCassette,
|
||||
kIndexDiskImage,
|
||||
kIndexBitBanger,
|
||||
};
|
||||
|
||||
#define CATEGORY_COUNT 7
|
||||
#define SIZEOF(x) (sizeof(x) / sizeof(x[0]))
|
||||
|
||||
|
||||
@protocol MediaNode
|
||||
-(BOOL)isGroupItem;
|
||||
-(BOOL)isExpandable;
|
||||
-(NSInteger) count;
|
||||
-(NSInteger)category;
|
||||
|
||||
-(NSString *)viewIdentifier;
|
||||
-(void)prepareView: (NSTableCellView *)view;
|
||||
|
@ -28,6 +42,7 @@
|
|||
@property NSMutableArray *children; // URLs?
|
||||
@property NSString *title;
|
||||
@property NSInteger index;
|
||||
@property NSInteger category;
|
||||
|
||||
-(NSInteger)count;
|
||||
-(id)objectAtIndex:(NSInteger)index;
|
||||
|
@ -36,9 +51,13 @@
|
|||
|
||||
@interface MediaItem : NSObject <MediaNode>
|
||||
|
||||
@property NSString *string;
|
||||
@property NSURL *url;
|
||||
@property BOOL valid;
|
||||
@property NSInteger index;
|
||||
@property NSInteger category;
|
||||
|
||||
@property (readonly) BOOL occupied;
|
||||
|
||||
-(NSInteger)count;
|
||||
-(id)objectAtIndex:(NSInteger)index;
|
||||
|
@ -102,6 +121,7 @@
|
|||
for (unsigned i = count; i < newCount; ++i) {
|
||||
MediaItem *item = [MediaItem new];
|
||||
[item setIndex: i];
|
||||
[item setCategory: _category];
|
||||
[_children addObject: item];
|
||||
}
|
||||
|
||||
|
@ -113,7 +133,7 @@
|
|||
|
||||
for (unsigned i = newCount; i < count; ++i) {
|
||||
MediaItem *item = [_children lastObject];
|
||||
if ([item url]) break;
|
||||
if ([item occupied]) break;
|
||||
|
||||
[_children removeLastObject];
|
||||
}
|
||||
|
@ -129,7 +149,7 @@
|
|||
|
||||
for (NSInteger i = _validCount; i < count; ++i) {
|
||||
MediaItem *item = [_children lastObject];
|
||||
if ([item url]) break;
|
||||
if ([item occupied]) break;
|
||||
|
||||
[_children removeLastObject];
|
||||
[set addIndex: [_children count]];
|
||||
|
@ -182,10 +202,34 @@
|
|||
|
||||
|
||||
-(instancetype)initWithURL: (NSURL *)url {
|
||||
[self setUrl: url];
|
||||
_url = url;
|
||||
return self;
|
||||
}
|
||||
|
||||
-(instancetype)initWithString: (NSString *)string {
|
||||
_string = string;
|
||||
return self;
|
||||
}
|
||||
|
||||
-(NSString *)argument {
|
||||
if (_string)
|
||||
return _string;
|
||||
|
||||
// todo -- have setURL also update _string?
|
||||
if (_url)
|
||||
return [NSString stringWithCString: [_url fileSystemRepresentation] encoding: NSUTF8StringEncoding];
|
||||
|
||||
return nil;
|
||||
}
|
||||
|
||||
+(NSSet *)keyPathsForValuesAffectingOccupied {
|
||||
return [NSSet setWithObjects: @"url", @"string", nil];
|
||||
}
|
||||
|
||||
-(BOOL)occupied {
|
||||
return _url || _string;
|
||||
}
|
||||
|
||||
-(NSInteger) count {
|
||||
return 0;
|
||||
}
|
||||
|
@ -203,6 +247,7 @@
|
|||
}
|
||||
|
||||
-(NSString *)viewIdentifier {
|
||||
if (_category == kIndexBitBanger) return @"BBItemView";
|
||||
return @"ItemView";
|
||||
}
|
||||
|
||||
|
@ -221,8 +266,7 @@
|
|||
@end
|
||||
|
||||
|
||||
#define CATEGORY_COUNT 7
|
||||
#define SIZEOF(x) (sizeof(x) / sizeof(x[0]))
|
||||
|
||||
|
||||
@interface MediaViewController () {
|
||||
|
||||
|
@ -237,15 +281,6 @@
|
|||
|
||||
@implementation MediaViewController
|
||||
|
||||
enum {
|
||||
kIndexFloppy525 = 0,
|
||||
kIndexFloppy35,
|
||||
kIndexHardDrive,
|
||||
kIndexCDROM,
|
||||
kIndexCassette,
|
||||
kIndexDiskImage,
|
||||
kIndexBitBanger,
|
||||
};
|
||||
|
||||
|
||||
-(void)awakeFromNib {
|
||||
|
@ -263,6 +298,9 @@ enum {
|
|||
_data[kIndexDiskImage] = [MediaCategory categoryWithTitle: @"Hard Disk Images"]; // Mac Nubus psuedo image device
|
||||
_data[kIndexBitBanger] = [MediaCategory categoryWithTitle: @"Serial Bit Banger"]; // null_modem
|
||||
|
||||
for (unsigned i = 0; i < CATEGORY_COUNT; ++i)
|
||||
[_data[i] setCategory: i];
|
||||
|
||||
_root = @[];
|
||||
|
||||
}
|
||||
|
@ -287,12 +325,12 @@ enum {
|
|||
counts[j]++;
|
||||
|
||||
MediaItem *item = [cat objectAtIndex: i];
|
||||
NSURL *url = [item url];
|
||||
if (!url) continue;
|
||||
[args addObject: [NSString stringWithFormat: @"-%s%u", prefix[j], counts[j]]];
|
||||
NSString *s = [NSString stringWithCString: [url fileSystemRepresentation] encoding: NSUTF8StringEncoding];
|
||||
|
||||
[args addObject: s];
|
||||
NSString *arg = [item argument];
|
||||
|
||||
if (arg) {
|
||||
[args addObject: [NSString stringWithFormat: @"-%s%u", prefix[j], counts[j]]];
|
||||
[args addObject: arg];
|
||||
}
|
||||
}
|
||||
if (j == 0) counts[1] = counts[0]; // 3.5/5.25
|
||||
}
|
||||
|
@ -360,9 +398,9 @@ x = media.name; cat = _data[index]; delta |= [cat setItemCount: x]
|
|||
for (NSInteger i = 0; i < count; ++i) {
|
||||
|
||||
MediaItem *item = [cat objectAtIndex: i];
|
||||
NSURL *url = [item url];
|
||||
if (!url) continue;
|
||||
if (![item occupied]) continue;
|
||||
[item setUrl: nil];
|
||||
[item setString: nil];
|
||||
delta = YES;
|
||||
}
|
||||
if ([cat pruneChildrenWithOutlineView: _outlineView]) delta = YES;
|
||||
|
@ -399,8 +437,6 @@ static NSString *kDragType = @"private.ample.media";
|
|||
|
||||
}
|
||||
|
||||
//- (NSTableRowView *)outlineView:(NSOutlineView *)outlineView rowViewForItem:(id)item;
|
||||
|
||||
- (NSView *)outlineView:(NSOutlineView *)outlineView viewForTableColumn:(NSTableColumn *)tableColumn item:(id<MediaNode>)item {
|
||||
|
||||
NSString *ident = [item viewIdentifier];
|
||||
|
@ -440,12 +476,6 @@ static NSString *kDragType = @"private.ample.media";
|
|||
}
|
||||
|
||||
|
||||
- (NSCell *)outlineView:(NSOutlineView *)outlineView dataCellForTableColumn:(NSTableColumn *)tableColumn item:(id)item {
|
||||
//return nil;
|
||||
return [[item cellClass] new];
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
#pragma mark - NSOutlineViewDataSource
|
||||
|
@ -608,10 +638,9 @@ static NSString *kDragType = @"private.ample.media";
|
|||
NSInteger row = [_outlineView rowForView: sender];
|
||||
if (row < 0) return;
|
||||
|
||||
//TablePathView *pv = [_outlineView viewAtColumn: 0 row: row makeIfNecessary: NO];
|
||||
MediaItem *item = [_outlineView itemAtRow: row];
|
||||
[item setUrl: nil];
|
||||
//[[pv pathControl] setURL: nil];
|
||||
[item setString: nil];
|
||||
|
||||
// if item is invalid, should attempt to remove...
|
||||
if (![item valid]) {
|
||||
|
@ -628,11 +657,11 @@ static NSString *kDragType = @"private.ample.media";
|
|||
}
|
||||
|
||||
- (IBAction)pathAction:(id)sender {
|
||||
// need to update the eject button...
|
||||
|
||||
NSURL *url = [(NSPathControl *)sender URL];
|
||||
|
||||
if (url) {
|
||||
NSInteger tag = [sender tag];
|
||||
// TODO - don't add to recent disks if this is a bitbanger / midi / printer device.
|
||||
if (url && tag == 0) {
|
||||
NSNotificationCenter *nc = [NSNotificationCenter defaultCenter];
|
||||
[nc postNotificationName: @"DiskImageAdded" object: url];
|
||||
}
|
||||
|
@ -640,6 +669,10 @@ static NSString *kDragType = @"private.ample.media";
|
|||
[self rebuildArgs];
|
||||
}
|
||||
|
||||
-(IBAction)textAction: (id)sender {
|
||||
[self rebuildArgs];
|
||||
}
|
||||
|
||||
-(IBAction)resetMedia:(id)sender {
|
||||
[self resetDiskImages];
|
||||
}
|
||||
|
@ -673,7 +706,7 @@ static NSString *kDragType = @"private.ample.media";
|
|||
NSLog(@"MediaViewController: too many categories.");
|
||||
break;
|
||||
}
|
||||
MediaCategory *cat = _data[ix++];
|
||||
MediaCategory *cat = _data[ix];
|
||||
NSInteger count = [cat count];
|
||||
unsigned i = 0;
|
||||
for (NSString *path in a) {
|
||||
|
@ -682,12 +715,16 @@ static NSString *kDragType = @"private.ample.media";
|
|||
break; //
|
||||
}
|
||||
MediaItem *item = [cat objectAtIndex: i++];
|
||||
NSURL *url = nil;
|
||||
if ([path length])
|
||||
url = [NSURL fileURLWithPath: path];
|
||||
if (![path length]) continue;
|
||||
|
||||
[item setUrl: url];
|
||||
if (ix == kIndexBitBanger) {
|
||||
[item setString: path];
|
||||
} else {
|
||||
NSURL *url = [NSURL fileURLWithPath: path];
|
||||
[item setUrl: url];
|
||||
}
|
||||
}
|
||||
++ix;
|
||||
}
|
||||
return YES;
|
||||
|
||||
|
@ -706,10 +743,9 @@ static NSString *kDragType = @"private.ample.media";
|
|||
for (NSInteger i = 0; i < count; ++i) {
|
||||
|
||||
MediaItem *item = [cat objectAtIndex: i];
|
||||
NSURL *url = [item url];
|
||||
NSString *s = @"";
|
||||
if (url)
|
||||
s = [NSString stringWithCString: [url fileSystemRepresentation] encoding: NSUTF8StringEncoding];
|
||||
// todo - bitbanger.
|
||||
NSString *s = [item argument];
|
||||
if (!s) s = @"";
|
||||
|
||||
[array addObject: s];
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user