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 "FileTreeController.h"
|
2022-02-07 05:49:27 +00:00
|
|
|
#import "PlaylistController.h"
|
2016-05-05 20:05:39 +00:00
|
|
|
#import "SideViewController.h"
|
2009-03-07 21:31:44 +00:00
|
|
|
|
|
|
|
@implementation FileTreeController
|
|
|
|
|
2022-02-07 05:49:27 +00:00
|
|
|
- (IBAction)addToPlaylist:(id)sender {
|
2013-10-12 21:31:28 +00:00
|
|
|
[self doAddToPlaylist:sender origin:URLOriginInternal];
|
|
|
|
}
|
|
|
|
|
2022-02-07 05:49:27 +00:00
|
|
|
- (void)doAddToPlaylist:(id)sender origin:(URLOrigin)origin {
|
|
|
|
NSUInteger 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 doAddToPlaylist:urls origin:origin];
|
2013-10-12 21:31:28 +00:00
|
|
|
}
|
|
|
|
|
2022-02-07 05:49:27 +00:00
|
|
|
- (void)addToPlaylistExternal:(id)sender {
|
|
|
|
[self doAddToPlaylist:sender origin:URLOriginExternal];
|
2009-03-07 21:31:44 +00:00
|
|
|
}
|
|
|
|
|
2022-02-07 05:49:27 +00:00
|
|
|
- (IBAction)setAsPlaylist:(id)sender {
|
2009-08-16 16:49:34 +00:00
|
|
|
[controller clear:sender];
|
|
|
|
[self addToPlaylist:sender];
|
|
|
|
}
|
|
|
|
|
2022-02-07 05:49:27 +00:00
|
|
|
- (IBAction)playPauseResume:(NSObject *)id {
|
2009-08-16 16:49:34 +00:00
|
|
|
[controller playPauseResume:id];
|
|
|
|
}
|
|
|
|
|
2022-02-07 05:49:27 +00:00
|
|
|
- (IBAction)showEntryInFinder:(id)sender {
|
2013-10-03 08:00:58 +00:00
|
|
|
NSUInteger index;
|
2022-02-07 05:49:27 +00:00
|
|
|
NSWorkspace *ws = [NSWorkspace sharedWorkspace];
|
2009-08-16 16:49:34 +00:00
|
|
|
NSIndexSet *selectedIndexes = [outlineView selectedRowIndexes];
|
2022-02-07 05:49:27 +00:00
|
|
|
|
|
|
|
for(index = [selectedIndexes firstIndex];
|
|
|
|
index != NSNotFound; index = [selectedIndexes indexGreaterThanIndex:index]) {
|
2009-08-16 16:49:34 +00:00
|
|
|
NSURL *url = [[outlineView itemAtRow:index] URL];
|
|
|
|
[ws selectFile:[url path] inFileViewerRootedAtPath:[url path]];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-02-07 05:49:27 +00:00
|
|
|
- (IBAction)setAsRoot:(id)sender {
|
2013-10-03 08:00:58 +00:00
|
|
|
NSUInteger index = [[outlineView selectedRowIndexes] firstIndex];
|
2022-02-07 05:49:27 +00:00
|
|
|
|
|
|
|
if(index != NSNotFound) {
|
2009-08-16 16:49:34 +00:00
|
|
|
[dataSource changeURL:[[outlineView itemAtRow:index] URL]];
|
|
|
|
}
|
|
|
|
}
|
2009-03-07 21:31:44 +00:00
|
|
|
|
2022-02-07 05:49:27 +00:00
|
|
|
- (BOOL)validateMenuItem:(NSMenuItem *)menuItem {
|
2010-04-05 17:40:17 +00:00
|
|
|
SEL action = [menuItem action];
|
|
|
|
|
2022-02-07 05:49:27 +00:00
|
|
|
if([outlineView numberOfSelectedRows] == 0)
|
2010-04-05 17:40:17 +00:00
|
|
|
return NO;
|
|
|
|
|
2022-02-07 05:49:27 +00:00
|
|
|
if(action == @selector(setAsRoot:)) {
|
2010-04-05 17:40:17 +00:00
|
|
|
BOOL isDir;
|
|
|
|
NSInteger row = [outlineView selectedRow];
|
|
|
|
|
2022-02-07 05:49:27 +00:00
|
|
|
if([outlineView numberOfSelectedRows] > 1)
|
2010-04-05 17:40:17 +00:00
|
|
|
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
|