2009-03-07 21:31:44 +00:00
|
|
|
//
|
|
|
|
// FileTreeController.m
|
|
|
|
// Cog
|
|
|
|
//
|
|
|
|
// Created by Vincent Spader on 2/17/08.
|
|
|
|
// Copyright 2008 __MyCompanyName__. All rights reserved.
|
|
|
|
//
|
|
|
|
|
|
|
|
#import "PlaylistController.h"
|
|
|
|
#import "FileTreeController.h"
|
|
|
|
|
|
|
|
|
|
|
|
@implementation FileTreeController
|
|
|
|
|
|
|
|
- (IBAction)addToPlaylist:(id)sender
|
|
|
|
{
|
|
|
|
unsigned int index;
|
|
|
|
NSIndexSet *selectedIndexes = [outlineView selectedRowIndexes];
|
|
|
|
NSMutableArray *urls = [[NSMutableArray alloc] init];
|
|
|
|
|
|
|
|
for (index = [selectedIndexes firstIndex];
|
|
|
|
index != NSNotFound; index = [selectedIndexes indexGreaterThanIndex: index])
|
|
|
|
{
|
|
|
|
[urls addObject:[[outlineView itemAtRow:index] URL]];
|
|
|
|
}
|
|
|
|
|
|
|
|
[controller addToPlaylist:urls];
|
|
|
|
[urls release];
|
|
|
|
}
|
|
|
|
|
2009-08-16 16:49:34 +00:00
|
|
|
- (IBAction)setAsPlaylist:(id)sender
|
|
|
|
{
|
|
|
|
[controller clear:sender];
|
|
|
|
[self addToPlaylist:sender];
|
|
|
|
}
|
|
|
|
|
|
|
|
- (IBAction)playPauseResume:(NSObject *)id
|
|
|
|
{
|
|
|
|
[controller playPauseResume:id];
|
|
|
|
}
|
|
|
|
|
|
|
|
- (IBAction)showEntryInFinder:(id)sender
|
|
|
|
{
|
|
|
|
unsigned int index;
|
|
|
|
NSWorkspace* ws = [NSWorkspace sharedWorkspace];
|
|
|
|
NSIndexSet *selectedIndexes = [outlineView selectedRowIndexes];
|
|
|
|
|
|
|
|
for (index = [selectedIndexes firstIndex];
|
|
|
|
index != NSNotFound; index = [selectedIndexes indexGreaterThanIndex: index])
|
|
|
|
{
|
|
|
|
NSURL *url = [[outlineView itemAtRow:index] URL];
|
|
|
|
[ws selectFile:[url path] inFileViewerRootedAtPath:[url path]];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
- (IBAction)setAsRoot:(id)sender
|
|
|
|
{
|
|
|
|
unsigned int index = [[outlineView selectedRowIndexes] firstIndex];
|
|
|
|
|
|
|
|
if (index != NSNotFound)
|
|
|
|
{
|
|
|
|
[dataSource changeURL:[[outlineView itemAtRow:index] URL]];
|
|
|
|
}
|
|
|
|
}
|
2009-03-07 21:31:44 +00:00
|
|
|
|
2010-04-05 17:40:17 +00:00
|
|
|
-(BOOL)validateMenuItem:(NSMenuItem*)menuItem
|
|
|
|
{
|
|
|
|
SEL action = [menuItem action];
|
|
|
|
|
|
|
|
if ([outlineView numberOfSelectedRows] == 0)
|
|
|
|
return NO;
|
|
|
|
|
|
|
|
if (action == @selector(setAsRoot:))
|
|
|
|
{
|
|
|
|
BOOL isDir;
|
|
|
|
NSInteger row = [outlineView selectedRow];
|
|
|
|
|
|
|
|
if ([outlineView numberOfSelectedRows] > 1)
|
|
|
|
return NO;
|
|
|
|
|
|
|
|
// Only let directories be Set as Root
|
|
|
|
[[NSFileManager defaultManager] fileExistsAtPath:[[[outlineView itemAtRow:row] URL] path] isDirectory:&isDir];
|
|
|
|
return isDir;
|
|
|
|
}
|
|
|
|
|
|
|
|
return YES;
|
|
|
|
}
|
2009-03-07 21:31:44 +00:00
|
|
|
@end
|