Added back update notifications back to the file drawer.
Removed no-longer-used files. Removed debugging messages.
This commit is contained in:
parent
27d9ff122a
commit
4b814bdbf0
20 changed files with 141 additions and 412 deletions
|
@ -7,7 +7,7 @@
|
|||
@class PlaybackController;
|
||||
@class PlaylistController;
|
||||
@class PlaylistView;
|
||||
@class FileTreeController;
|
||||
@class FileTreeDataSource;
|
||||
@class FileOutlineView;
|
||||
@class AppleRemote;
|
||||
@class PlaylistLoader;
|
||||
|
@ -33,7 +33,7 @@
|
|||
IBOutlet NSDrawer *infoDrawer;
|
||||
IBOutlet NSDrawer *fileDrawer;
|
||||
|
||||
IBOutlet FileTreeController *fileTreeController;
|
||||
IBOutlet FileTreeDataSource *fileTreeDataSource;
|
||||
IBOutlet FileOutlineView *fileOutlineView;
|
||||
|
||||
IBOutlet PlaylistView *playlistView;
|
||||
|
|
|
@ -3,7 +3,6 @@
|
|||
#import "PlaybackController.h"
|
||||
#import "PlaylistController.h"
|
||||
#import "PlaylistView.h"
|
||||
#import "FileTreeController.h"
|
||||
#import "FileOutlineView.h"
|
||||
#import "NDHotKeyEvent.h"
|
||||
#import "AppleRemote.h"
|
||||
|
@ -400,7 +399,7 @@ increase/decrease as long as the user holds the left/right, plus/minus button */
|
|||
[self registerHotKeys];
|
||||
}
|
||||
else if ([keyPath isEqualToString:@"values.fileDrawerRootPath"]) {
|
||||
[fileTreeController setRootPath:[[[NSUserDefaultsController sharedUserDefaultsController] defaults] objectForKey:@"fileDrawerRootPath"]];
|
||||
[fileTreeDataSource setRootPath:[[[NSUserDefaultsController sharedUserDefaultsController] defaults] objectForKey:@"fileDrawerRootPath"]];
|
||||
}
|
||||
else if ([keyPath isEqualToString:@"values.remoteEnabled"] || [keyPath isEqualToString:@"values.remoteOnlyOnActive"]) {
|
||||
if([[NSUserDefaults standardUserDefaults] boolForKey:@"remoteEnabled"]) {
|
||||
|
|
|
@ -123,7 +123,6 @@
|
|||
8EFFCD610AA093AF00C458A5 /* FileIconCell.m in Sources */ = {isa = PBXBuildFile; fileRef = 8EFFCD450AA093AF00C458A5 /* FileIconCell.m */; };
|
||||
8EFFCD630AA093AF00C458A5 /* FileNode.m in Sources */ = {isa = PBXBuildFile; fileRef = 8EFFCD470AA093AF00C458A5 /* FileNode.m */; };
|
||||
8EFFCD650AA093AF00C458A5 /* FileOutlineView.m in Sources */ = {isa = PBXBuildFile; fileRef = 8EFFCD490AA093AF00C458A5 /* FileOutlineView.m */; };
|
||||
8EFFCD690AA093AF00C458A5 /* FileTreeWatcher.m in Sources */ = {isa = PBXBuildFile; fileRef = 8EFFCD4D0AA093AF00C458A5 /* FileTreeWatcher.m */; };
|
||||
8EFFCD6F0AA093AF00C458A5 /* PathNode.m in Sources */ = {isa = PBXBuildFile; fileRef = 8EFFCD530AA093AF00C458A5 /* PathNode.m */; };
|
||||
/* End PBXBuildFile section */
|
||||
|
||||
|
@ -613,10 +612,6 @@
|
|||
8EFFCD470AA093AF00C458A5 /* FileNode.m */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.objc; path = FileNode.m; sourceTree = "<group>"; };
|
||||
8EFFCD480AA093AF00C458A5 /* FileOutlineView.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = FileOutlineView.h; sourceTree = "<group>"; };
|
||||
8EFFCD490AA093AF00C458A5 /* FileOutlineView.m */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.objc; path = FileOutlineView.m; sourceTree = "<group>"; };
|
||||
8EFFCD4A0AA093AF00C458A5 /* FileTreeController.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = FileTreeController.h; sourceTree = "<group>"; };
|
||||
8EFFCD4B0AA093AF00C458A5 /* FileTreeController.m */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.objc; path = FileTreeController.m; sourceTree = "<group>"; };
|
||||
8EFFCD4C0AA093AF00C458A5 /* FileTreeWatcher.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = FileTreeWatcher.h; sourceTree = "<group>"; };
|
||||
8EFFCD4D0AA093AF00C458A5 /* FileTreeWatcher.m */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.objc; path = FileTreeWatcher.m; sourceTree = "<group>"; };
|
||||
8EFFCD520AA093AF00C458A5 /* PathNode.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = PathNode.h; sourceTree = "<group>"; };
|
||||
8EFFCD530AA093AF00C458A5 /* PathNode.m */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.objc; path = PathNode.m; sourceTree = "<group>"; };
|
||||
/* End PBXFileReference section */
|
||||
|
@ -1151,10 +1146,6 @@
|
|||
8EFFCD490AA093AF00C458A5 /* FileOutlineView.m */,
|
||||
1769D7CF0CC2BFF7003F455B /* FileTreeDataSource.h */,
|
||||
1769D7D00CC2BFF7003F455B /* FileTreeDataSource.m */,
|
||||
8EFFCD4A0AA093AF00C458A5 /* FileTreeController.h */,
|
||||
8EFFCD4B0AA093AF00C458A5 /* FileTreeController.m */,
|
||||
8EFFCD4C0AA093AF00C458A5 /* FileTreeWatcher.h */,
|
||||
8EFFCD4D0AA093AF00C458A5 /* FileTreeWatcher.m */,
|
||||
8EFFCD420AA093AF00C458A5 /* DirectoryNode.h */,
|
||||
8EFFCD430AA093AF00C458A5 /* DirectoryNode.m */,
|
||||
8EFFCD460AA093AF00C458A5 /* FileNode.h */,
|
||||
|
@ -1507,7 +1498,6 @@
|
|||
8EFFCD610AA093AF00C458A5 /* FileIconCell.m in Sources */,
|
||||
8EFFCD630AA093AF00C458A5 /* FileNode.m in Sources */,
|
||||
8EFFCD650AA093AF00C458A5 /* FileOutlineView.m in Sources */,
|
||||
8EFFCD690AA093AF00C458A5 /* FileTreeWatcher.m in Sources */,
|
||||
8EFFCD6F0AA093AF00C458A5 /* PathNode.m in Sources */,
|
||||
8E07AAF30AAC910500A4B32F /* SS_PrefsController.m in Sources */,
|
||||
8E07AB790AAC930B00A4B32F /* PreferencesController.m in Sources */,
|
||||
|
|
10
English.lproj/MainMenu.nib/classes.nib
generated
10
English.lproj/MainMenu.nib/classes.nib
generated
|
@ -25,11 +25,10 @@
|
|||
CLASS = AppController;
|
||||
LANGUAGE = ObjC;
|
||||
OUTLETS = {
|
||||
addURLPanel = NSPanel;
|
||||
fileButton = NSButton;
|
||||
fileDrawer = NSDrawer;
|
||||
fileOutlineView = FileOutlineView;
|
||||
fileTreeController = FileTreeController;
|
||||
fileTreeDataSource = FileTreeDataSource;
|
||||
infoButton = NSButton;
|
||||
infoDrawer = NSDrawer;
|
||||
mainWindow = NSPanel;
|
||||
|
@ -50,7 +49,6 @@
|
|||
showTrackColumn = NSMenuItem;
|
||||
showYearColumn = NSMenuItem;
|
||||
shuffleButton = NSButton;
|
||||
urlComboBox = NSComboBox;
|
||||
};
|
||||
SUPERCLASS = NSObject;
|
||||
},
|
||||
|
@ -82,10 +80,10 @@
|
|||
SUPERCLASS = NSOutlineView;
|
||||
},
|
||||
{
|
||||
CLASS = FileTreeController;
|
||||
CLASS = FileTreeDataSource;
|
||||
LANGUAGE = ObjC;
|
||||
OUTLETS = {playlistLoader = PlaylistLoader; };
|
||||
SUPERCLASS = NSTreeController;
|
||||
OUTLETS = {outlineView = NSOutlineView; };
|
||||
SUPERCLASS = NSObject;
|
||||
},
|
||||
{CLASS = FirstResponder; LANGUAGE = ObjC; SUPERCLASS = NSObject; },
|
||||
{CLASS = InfoController; LANGUAGE = ObjC; SUPERCLASS = NSObject; },
|
||||
|
|
2
English.lproj/MainMenu.nib/info.nib
generated
2
English.lproj/MainMenu.nib/info.nib
generated
|
@ -35,8 +35,8 @@
|
|||
<key>IBOpenObjects</key>
|
||||
<array>
|
||||
<integer>1063</integer>
|
||||
<integer>268</integer>
|
||||
<integer>29</integer>
|
||||
<integer>268</integer>
|
||||
<integer>21</integer>
|
||||
<integer>1156</integer>
|
||||
<integer>1324</integer>
|
||||
|
|
BIN
English.lproj/MainMenu.nib/keyedobjects.nib
generated
BIN
English.lproj/MainMenu.nib/keyedobjects.nib
generated
Binary file not shown.
|
@ -11,9 +11,6 @@
|
|||
#import "FileNode.h"
|
||||
#import "SmartFolderNode.h"
|
||||
|
||||
#import "FileTreeController.h"
|
||||
#import "FileTreeWatcher.h"
|
||||
|
||||
@implementation DirectoryNode
|
||||
|
||||
- (BOOL)isLeaf
|
||||
|
@ -21,19 +18,11 @@
|
|||
return NO;
|
||||
}
|
||||
|
||||
- (NSArray *)subpaths
|
||||
- (void)updatePath
|
||||
{
|
||||
if (subpaths == nil)
|
||||
{
|
||||
subpaths = [[NSMutableArray alloc] init];
|
||||
NSArray *contents = [[[NSFileManager defaultManager] directoryContentsAtPath:path] sortedArrayUsingSelector:@selector(caseInsensitiveCompare:)];
|
||||
NSLog(@"Contents: %@", contents);
|
||||
[self processPaths: contents];
|
||||
|
||||
// [[controller watcher] addPath:[self path]];
|
||||
}
|
||||
|
||||
return subpaths;
|
||||
NSArray *contents = [[[NSFileManager defaultManager] directoryContentsAtPath:path] sortedArrayUsingSelector:@selector(caseInsensitiveCompare:)];
|
||||
|
||||
[self processPaths: contents];
|
||||
}
|
||||
|
||||
@end
|
||||
|
|
|
@ -7,14 +7,14 @@
|
|||
//
|
||||
|
||||
#import "FileIconCell.h"
|
||||
|
||||
#import "PathNode.h"
|
||||
|
||||
@implementation FileIconCell
|
||||
|
||||
- (void)setObjectValue:(id)o
|
||||
{
|
||||
if ([o respondsToSelector:@selector(icon)]) {
|
||||
[super setObjectValue:[[o path] lastPathComponent]];
|
||||
if ([o respondsToSelector:@selector(icon)] && [o respondsToSelector:@selector(displayPath)]) {
|
||||
[super setObjectValue:[o displayPath]];
|
||||
[super setImage: [o icon]];
|
||||
}
|
||||
else {
|
||||
|
|
|
@ -31,9 +31,6 @@
|
|||
[c setDataCell: dataCell];
|
||||
NSLog(@"Setting data cell!");
|
||||
}
|
||||
|
||||
dataSource = [[FileTreeDataSource alloc] initWithRoot: [[[NSUserDefaultsController sharedUserDefaultsController] defaults] objectForKey:@"fileDrawerRootPath"] ];
|
||||
[self setDataSource: dataSource];
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -1,30 +0,0 @@
|
|||
//
|
||||
// FileTreeController.h
|
||||
// Cog
|
||||
//
|
||||
// Created by Vincent Spader on 8/20/2006.
|
||||
// Copyright 2006 Vincent Spader. All rights reserved.
|
||||
//
|
||||
|
||||
#import <Cocoa/Cocoa.h>
|
||||
|
||||
@class FileTreeWatcher;
|
||||
@class PlaylistLoader;
|
||||
|
||||
@interface FileTreeController : NSTreeController
|
||||
{
|
||||
IBOutlet PlaylistLoader *playlistLoader;
|
||||
|
||||
NSString *rootPath;
|
||||
|
||||
FileTreeWatcher *watcher;
|
||||
}
|
||||
|
||||
- (FileTreeWatcher *)watcher;
|
||||
|
||||
- (id)rootPath;
|
||||
- (void)setRootPath:(id)r;
|
||||
- (void)refreshRoot;
|
||||
- (NSArray *)acceptableFileTypes;
|
||||
|
||||
@end
|
|
@ -1,208 +0,0 @@
|
|||
//
|
||||
// FileTreeController.m
|
||||
// Cog
|
||||
//
|
||||
// Created by Vincent Spader on 8/20/2006.
|
||||
// Copyright 2006 Vincent Spader. All rights reserved.
|
||||
//
|
||||
|
||||
#import "FileTreeController.h"
|
||||
#import "FileTreeWatcher.h"
|
||||
#import "DirectoryNode.h"
|
||||
#import "ImageTextCell.h"
|
||||
#import "KFTypeSelectTableView.h"
|
||||
#import "PlaylistLoader.h"
|
||||
|
||||
@implementation FileTreeController
|
||||
|
||||
- (void)awakeFromNib
|
||||
{
|
||||
watcher = [[FileTreeWatcher alloc] init];
|
||||
[watcher setDelegate:self];
|
||||
|
||||
[self setRootPath: [[[NSUserDefaultsController sharedUserDefaultsController] defaults] objectForKey:@"fileDrawerRootPath"] ];
|
||||
}
|
||||
|
||||
- (void)dealloc
|
||||
{
|
||||
[rootPath release];
|
||||
[watcher release];
|
||||
|
||||
[super dealloc];
|
||||
}
|
||||
|
||||
- (id)rootPath
|
||||
{
|
||||
return rootPath;
|
||||
}
|
||||
|
||||
- (void)setRootPath:(id)r
|
||||
{
|
||||
[r retain];
|
||||
[rootPath release];
|
||||
rootPath = r;
|
||||
|
||||
[self refreshRoot];
|
||||
}
|
||||
|
||||
- (void) refreshRoot
|
||||
{
|
||||
DirectoryNode *base = [[DirectoryNode alloc] initWithPath:rootPath controller:self];
|
||||
// [self setContent: [base subpaths]];
|
||||
|
||||
[base release];
|
||||
|
||||
[watcher addPath:rootPath];
|
||||
}
|
||||
|
||||
//BUG IN NSTREECONTROLLER'S SETCONTENT. FIX YOUR SHIT, APPLE!
|
||||
- (void)setContent:(id)content
|
||||
{
|
||||
if(![content isEqual:[self content]])
|
||||
{
|
||||
NSArray *paths = [[self selectionIndexPaths] retain];
|
||||
[super setContent:nil];
|
||||
[super setContent:content];
|
||||
[self setSelectionIndexPaths:paths];
|
||||
[paths release];
|
||||
}
|
||||
}
|
||||
|
||||
- (void)refreshPath:(NSString *)path
|
||||
{
|
||||
if ([path compare:rootPath] == NSOrderedSame) {
|
||||
[self refreshRoot];
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
NSArray *pathComponents = [path pathComponents];
|
||||
NSArray *rootComponents = [rootPath pathComponents];
|
||||
int i = 0;
|
||||
while (i < [rootComponents count] && i < [pathComponents count] &&
|
||||
NSOrderedSame == [[rootComponents objectAtIndex: i] compare:[pathComponents objectAtIndex: i]])
|
||||
{
|
||||
i++;
|
||||
}
|
||||
|
||||
|
||||
id p;
|
||||
NSEnumerator *e = [[self content] objectEnumerator];
|
||||
while ((p = [e nextObject]))
|
||||
{
|
||||
id c = [pathComponents objectAtIndex:i];
|
||||
if (NSOrderedSame == [[[p path] lastPathComponent] compare:c]) {
|
||||
if (i == [pathComponents count] - 1) {
|
||||
[p setSubpaths:nil];
|
||||
// [self rearrangeObjects];
|
||||
}
|
||||
else {
|
||||
e = [[c subpaths] objectEnumerator];
|
||||
i++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
- (NSArray *)acceptableFileTypes
|
||||
{
|
||||
return [playlistLoader acceptableFileTypes];
|
||||
}
|
||||
|
||||
- (FileTreeWatcher *)watcher
|
||||
{
|
||||
return watcher;
|
||||
}
|
||||
|
||||
- (BOOL)outlineView:(NSOutlineView *)olv writeItems:(NSArray*)items toPasteboard:(NSPasteboard*)pboard {
|
||||
//Get selected paths
|
||||
NSMutableArray *paths = [NSMutableArray arrayWithCapacity:[items count]];
|
||||
NSEnumerator *e = [items objectEnumerator];
|
||||
id p;
|
||||
|
||||
while (p = [e nextObject]) {
|
||||
int i;
|
||||
id n = nil;
|
||||
NSIndexPath *ip = [p indexPath];
|
||||
|
||||
for (i = 0; i < [ip length]; i++)
|
||||
{
|
||||
NSArray *a = (n == nil) ? [self content] : [n subpaths];
|
||||
n = [a objectAtIndex:[ip indexAtPosition:i]];
|
||||
}
|
||||
|
||||
[paths addObject:[n path]];
|
||||
}
|
||||
|
||||
[pboard declareTypes:[NSArray arrayWithObjects:NSFilenamesPboardType,nil] owner:nil]; //add it to pboard
|
||||
[pboard setPropertyList:paths forType:NSFilenamesPboardType];
|
||||
|
||||
return YES;
|
||||
}
|
||||
|
||||
|
||||
// Required Protocol Bullshit (RPB) This is neccessary so it can be used as a datasource for drag/drop things.
|
||||
|
||||
- (id)outlineView:(NSOutlineView *)outlineView child:(int)index ofItem:(id)item
|
||||
{
|
||||
return nil;
|
||||
}
|
||||
|
||||
- (BOOL)outlineView:(NSOutlineView *)outlineView isItemExpandable:(id)item
|
||||
{
|
||||
return NO;
|
||||
}
|
||||
|
||||
- (int)outlineView:(NSOutlineView *)outlineView numberOfChildrenOfItem:(id)item
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
- (id)outlineView:(NSOutlineView *)outlineView objectValueForTableColumn:(NSTableColumn *)tableColumn byItem:(id)item
|
||||
{
|
||||
return nil;
|
||||
}
|
||||
|
||||
//End of RPB
|
||||
|
||||
|
||||
//For type-select
|
||||
|
||||
- (void)configureTypeSelectTableView:(KFTypeSelectTableView *)tableView
|
||||
{
|
||||
[tableView setSearchWraps:YES];
|
||||
}
|
||||
|
||||
- (int)typeSelectTableViewInitialSearchRow:(id)tableView
|
||||
{
|
||||
return [tableView selectedRow];
|
||||
}
|
||||
|
||||
// Return the string value used for type selection
|
||||
- (NSString *)typeSelectTableView:(KFTypeSelectTableView *)tableView stringValueForTableColumn:(NSTableColumn *)col row:(int)row
|
||||
{
|
||||
id item = [tableView itemAtRow:row];
|
||||
|
||||
//Reaching down into NSTreeController...yikes
|
||||
return [[[item observedObject] path] lastPathComponent];
|
||||
}
|
||||
|
||||
//End type-select
|
||||
|
||||
- (void)addSelectedToPlaylist {
|
||||
NSMutableArray *urls = [[NSMutableArray alloc] init];
|
||||
NSArray *nodes = [self selectedObjects];
|
||||
NSEnumerator *e = [nodes objectEnumerator];
|
||||
|
||||
id n;
|
||||
while (n = [e nextObject]) {
|
||||
NSURL *url = [[NSURL alloc] initFileURLWithPath:[n path]];
|
||||
[urls addObject:url];
|
||||
[url release];
|
||||
}
|
||||
|
||||
[playlistLoader addURLs:urls sort:YES];
|
||||
[urls release];
|
||||
}
|
||||
|
||||
|
||||
@end
|
|
@ -1,25 +0,0 @@
|
|||
//
|
||||
// FileTreeDelegate.h
|
||||
// BindTest
|
||||
//
|
||||
// Created by Vincent Spader on 8/20/06.
|
||||
// Copyright 2006 Vincent Spader. All rights reserved.
|
||||
//
|
||||
|
||||
#import <Cocoa/Cocoa.h>
|
||||
|
||||
@class UKKQueue;
|
||||
|
||||
@interface FileTreeWatcher : NSObject {
|
||||
UKKQueue *kqueue;
|
||||
id delegate;
|
||||
|
||||
NSMutableArray *watchedPaths;
|
||||
}
|
||||
|
||||
- (void)addPath: (NSString *)path;
|
||||
- (void)removePath: (NSString *)path;
|
||||
|
||||
-(void) setDelegate: (id)d;
|
||||
|
||||
@end
|
|
@ -1,62 +0,0 @@
|
|||
//
|
||||
// FileTreeDelegate.m
|
||||
// BindTest
|
||||
//
|
||||
// Created by Vincent Spader on 8/20/06.
|
||||
// Copyright 2006 Vincent Spader. All rights reserved.
|
||||
//
|
||||
|
||||
#import "FileTreeWatcher.h"
|
||||
|
||||
#import "UKKQueue.h"
|
||||
|
||||
@implementation FileTreeWatcher
|
||||
|
||||
- (id)init
|
||||
{
|
||||
self = [super init];
|
||||
if (self)
|
||||
{
|
||||
kqueue = [[UKKQueue alloc] init];
|
||||
[kqueue setDelegate:self];
|
||||
|
||||
watchedPaths = [[NSMutableArray alloc] init];
|
||||
}
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void)dealloc
|
||||
{
|
||||
[delegate release];
|
||||
[super dealloc];
|
||||
}
|
||||
|
||||
|
||||
- (void)addPath: (NSString *)path
|
||||
{
|
||||
if ([watchedPaths containsObject:path] == NO) {
|
||||
[watchedPaths addObject:path];
|
||||
|
||||
[kqueue addPath: path];
|
||||
}
|
||||
}
|
||||
|
||||
- (void)removePath: (NSString *)path
|
||||
{
|
||||
[watchedPaths removeObject:path];
|
||||
[kqueue removePath:path];
|
||||
}
|
||||
|
||||
-(void) setDelegate: (id)d
|
||||
{
|
||||
delegate = [d retain];
|
||||
}
|
||||
|
||||
|
||||
-(void) watcher: (id<UKFileWatcher>)kq receivedNotification: (NSString*)nm forPath: (NSString*)fpath
|
||||
{
|
||||
[delegate refreshPath: fpath];
|
||||
}
|
||||
|
||||
@end
|
|
@ -8,15 +8,21 @@
|
|||
|
||||
#import <Cocoa/Cocoa.h>
|
||||
|
||||
@class FileTreeDataSource;
|
||||
|
||||
@interface PathNode : NSObject
|
||||
{
|
||||
FileTreeDataSource *dataSource;
|
||||
|
||||
NSString *path;
|
||||
NSString *displayPath; //The pretty path to display.
|
||||
|
||||
NSImage *icon;
|
||||
|
||||
NSArray *subpaths;
|
||||
}
|
||||
|
||||
- (id)initWithPath:(NSString *)p;
|
||||
- (id)initWithDataSource:(FileTreeDataSource *)ds path:(NSString *)p;
|
||||
|
||||
- (NSString *)path;
|
||||
- (void)setPath:(NSString *)p;
|
||||
|
@ -26,6 +32,7 @@
|
|||
- (NSArray *)subpaths;
|
||||
- (void)setSubpaths:(NSArray *)s;
|
||||
|
||||
- (NSString *)displayPath;
|
||||
- (NSImage *)icon;
|
||||
|
||||
- (BOOL)isLeaf;
|
||||
|
|
|
@ -10,44 +10,76 @@
|
|||
|
||||
#import "CogAudio/AudioPlayer.h"
|
||||
|
||||
#import "FileTreeDataSource.h"
|
||||
|
||||
#import "UKKQueue.h"
|
||||
|
||||
@class FileNode;
|
||||
@class DirectoryNode;
|
||||
@class SmartFolderNode;
|
||||
|
||||
@implementation PathNode
|
||||
|
||||
- (id)initWithPath:(NSString *)p
|
||||
- (id)initWithDataSource:(FileTreeDataSource *)ds path:(NSString *)p
|
||||
{
|
||||
self = [super init];
|
||||
|
||||
if (self)
|
||||
{
|
||||
dataSource = ds;
|
||||
[self setPath: p];
|
||||
}
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void)dealloc
|
||||
- (void)stopWatching
|
||||
{
|
||||
[path release];
|
||||
[icon release];
|
||||
|
||||
if (subpaths) {
|
||||
[subpaths release];
|
||||
subpaths = nil;
|
||||
}
|
||||
if (path)
|
||||
{
|
||||
NSLog(@"Stopped watching...: %@", path);
|
||||
|
||||
[super dealloc];
|
||||
//Remove all in one go
|
||||
[[[NSWorkspace sharedWorkspace] notificationCenter] removeObserver:self];
|
||||
|
||||
[[UKKQueue sharedFileWatcher] removePath:path];
|
||||
}
|
||||
}
|
||||
|
||||
- (void)startWatching
|
||||
{
|
||||
if (path)
|
||||
{
|
||||
NSLog(@"WATCHING! %@ %i", path, path);
|
||||
|
||||
[[[NSWorkspace sharedWorkspace] notificationCenter] addObserver:self selector:@selector(updatePathNotification:) name:UKFileWatcherRenameNotification object:nil];
|
||||
[[[NSWorkspace sharedWorkspace] notificationCenter] addObserver:self selector:@selector(updatePathNotification:) name:UKFileWatcherWriteNotification object:nil];
|
||||
[[[NSWorkspace sharedWorkspace] notificationCenter] addObserver:self selector:@selector(updatePathNotification:) name:UKFileWatcherDeleteNotification object:nil];
|
||||
[[[NSWorkspace sharedWorkspace] notificationCenter] addObserver:self selector:@selector(updatePathNotification:) name:UKFileWatcherAttributeChangeNotification object:nil];
|
||||
[[[NSWorkspace sharedWorkspace] notificationCenter] addObserver:self selector:@selector(updatePathNotification:) name:UKFileWatcherSizeIncreaseNotification object:nil];
|
||||
[[[NSWorkspace sharedWorkspace] notificationCenter] addObserver:self selector:@selector(updatePathNotification:) name:UKFileWatcherLinkCountChangeNotification object:nil];
|
||||
[[[NSWorkspace sharedWorkspace] notificationCenter] addObserver:self selector:@selector(updatePathNotification:) name:UKFileWatcherAccessRevocationNotification object:nil];
|
||||
|
||||
[[UKKQueue sharedFileWatcher] addPath:path];
|
||||
}
|
||||
}
|
||||
|
||||
- (void)setPath:(NSString *)p
|
||||
{
|
||||
[p retain];
|
||||
[path release];
|
||||
|
||||
[self stopWatching];
|
||||
|
||||
[path release];
|
||||
|
||||
path = p;
|
||||
|
||||
[self startWatching];
|
||||
|
||||
[displayPath release];
|
||||
displayPath = [[NSFileManager defaultManager] displayNameAtPath:path];
|
||||
[displayPath retain];
|
||||
|
||||
[icon release];
|
||||
icon = [[NSWorkspace sharedWorkspace] iconForFile:path];
|
||||
[icon retain];
|
||||
|
@ -60,6 +92,28 @@
|
|||
return path;
|
||||
}
|
||||
|
||||
- (void)updatePath
|
||||
{
|
||||
}
|
||||
|
||||
- (void)updatePathNotification:(NSNotification *)notification
|
||||
{
|
||||
[self performSelectorOnMainThread:@selector(updatePathNotificationMainThread:) withObject:notification waitUntilDone:YES];
|
||||
}
|
||||
|
||||
- (void)updatePathNotificationMainThread:(NSNotification *)notification
|
||||
{
|
||||
NSString *p = [[notification userInfo] objectForKey:@"path"];
|
||||
if (p == path)
|
||||
{
|
||||
NSLog(@"Update path notification: %@", [NSThread currentThread]);
|
||||
|
||||
[self updatePath];
|
||||
|
||||
[dataSource reloadPathNode:self];
|
||||
}
|
||||
}
|
||||
|
||||
- (void)processPaths: (NSArray *)contents
|
||||
{
|
||||
NSMutableArray *newSubpaths = [[NSMutableArray alloc] init];
|
||||
|
@ -78,7 +132,7 @@
|
|||
|
||||
if ([[s pathExtension] caseInsensitiveCompare:@"savedSearch"] == NSOrderedSame)
|
||||
{
|
||||
newNode = [[SmartFolderNode alloc] initWithPath:newSubpath];
|
||||
newNode = [[SmartFolderNode alloc] initWithDataSource:dataSource path:newSubpath];
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -92,9 +146,13 @@
|
|||
}
|
||||
|
||||
if (isDir)
|
||||
newNode = [[DirectoryNode alloc] initWithPath: newSubpath];
|
||||
{
|
||||
newNode = [[DirectoryNode alloc] initWithDataSource:dataSource path: newSubpath];
|
||||
}
|
||||
else
|
||||
newNode = [[FileNode alloc] initWithPath: newSubpath];
|
||||
{
|
||||
newNode = [[FileNode alloc] initWithDataSource:dataSource path: newSubpath];
|
||||
}
|
||||
}
|
||||
|
||||
[newSubpaths addObject:newNode];
|
||||
|
@ -102,13 +160,18 @@
|
|||
[newNode release];
|
||||
}
|
||||
|
||||
[self setSubpaths:[[newSubpaths copy] autorelease]];
|
||||
[self setSubpaths:newSubpaths];
|
||||
|
||||
[newSubpaths release];
|
||||
}
|
||||
|
||||
- (NSArray *)subpaths
|
||||
{
|
||||
if (subpaths == nil)
|
||||
{
|
||||
[self updatePath];
|
||||
}
|
||||
|
||||
return subpaths;
|
||||
}
|
||||
|
||||
|
@ -125,11 +188,26 @@
|
|||
return YES;
|
||||
}
|
||||
|
||||
- (NSString *)displayPath
|
||||
{
|
||||
return displayPath;
|
||||
}
|
||||
|
||||
- (NSImage *)icon
|
||||
{
|
||||
return icon;
|
||||
}
|
||||
|
||||
- (void)dealloc
|
||||
{
|
||||
[self stopWatching];
|
||||
|
||||
[path release];
|
||||
[icon release];
|
||||
|
||||
[subpaths release];
|
||||
|
||||
[super dealloc];
|
||||
}
|
||||
|
||||
@end
|
||||
|
|
|
@ -17,26 +17,23 @@
|
|||
return NO;
|
||||
}
|
||||
|
||||
- (NSArray *)subpaths
|
||||
- (void)updatePath
|
||||
{
|
||||
if (subpaths == nil)
|
||||
{
|
||||
NSDictionary *doc = [NSDictionary dictionaryWithContentsOfFile:path];
|
||||
NSString *rawQuery = [doc objectForKey:@"RawQuery"];
|
||||
NSArray *searchPaths = [[doc objectForKey:@"SearchCriteria"] objectForKey:@"CurrentFolderPath"];
|
||||
|
||||
// Ugh, Carbon from now on...
|
||||
MDQueryRef query = MDQueryCreate(kCFAllocatorDefault, (CFStringRef)rawQuery, NULL, NULL);
|
||||
|
||||
MDQuerySetSearchScope(query, (CFArrayRef)searchPaths, 0);
|
||||
|
||||
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(queryFinished:) name:(NSString*)kMDQueryDidFinishNotification object:(id)query];
|
||||
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(queryUpdate:) name:(NSString*)kMDQueryDidUpdateNotification object:(id)query];
|
||||
|
||||
MDQueryExecute(query, kMDQueryWantsUpdates);
|
||||
}
|
||||
NSDictionary *doc = [NSDictionary dictionaryWithContentsOfFile:path];
|
||||
NSString *rawQuery = [doc objectForKey:@"RawQuery"];
|
||||
NSArray *searchPaths = [[doc objectForKey:@"SearchCriteria"] objectForKey:@"CurrentFolderPath"];
|
||||
|
||||
return subpaths;
|
||||
// Ugh, Carbon from now on...
|
||||
MDQueryRef query = MDQueryCreate(kCFAllocatorDefault, (CFStringRef)rawQuery, NULL, NULL);
|
||||
|
||||
MDQuerySetSearchScope(query, (CFArrayRef)searchPaths, 0);
|
||||
|
||||
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(queryFinished:) name:(NSString*)kMDQueryDidFinishNotification object:(id)query];
|
||||
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(queryUpdate:) name:(NSString*)kMDQueryDidUpdateNotification object:(id)query];
|
||||
|
||||
MDQueryExecute(query, kMDQueryWantsUpdates);
|
||||
|
||||
//Note: This is asynchronous!
|
||||
}
|
||||
|
||||
- (void)setSubpaths:(id)s
|
||||
|
|
|
@ -46,8 +46,11 @@
|
|||
[_url release];
|
||||
_url = nil;
|
||||
|
||||
fclose(_fd);
|
||||
_fd = NULL;
|
||||
if (_fd)
|
||||
{
|
||||
fclose(_fd);
|
||||
_fd = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
- (NSURL *)url
|
||||
|
@ -74,7 +77,7 @@
|
|||
}
|
||||
|
||||
- (void)dealloc {
|
||||
NSLog(@"DEALLOCATING SOURCE");
|
||||
[self close];
|
||||
|
||||
[super dealloc];
|
||||
}
|
||||
|
|
|
@ -566,12 +566,6 @@ static inline signed int scale (mad_fixed_t sample)
|
|||
mad_stream_finish(&_stream);
|
||||
}
|
||||
|
||||
- (void)dealloc
|
||||
{
|
||||
NSLog(@"Decoder dealloc");
|
||||
[super dealloc];
|
||||
}
|
||||
|
||||
- (double)seekToTime:(double)milliseconds
|
||||
{
|
||||
unsigned long new_position;
|
||||
|
|
3
TODO
3
TODO
|
@ -1 +1,2 @@
|
|||
Fix playback and leaks. Playback is very much busted when doing lots of next/forward/moving around.
|
||||
Ensure file drawer works with metadata search (Smart folders).
|
||||
Add alias support.
|
3
ThirdParty/UKKQueue/UKKQueue.m
vendored
3
ThirdParty/UKKQueue/UKKQueue.m
vendored
|
@ -355,7 +355,8 @@ static UKKQueue * gUKKQueueSharedQueueSingleton = nil;
|
|||
if( ev.fflags )
|
||||
{
|
||||
NSString* fpath = [[(NSString *)ev.udata retain] autorelease]; // In case one of the notified folks removes the path.
|
||||
//NSLog(@"UKKQueue: Detected file change: %@", fpath);
|
||||
|
||||
//NSLog(@"UKKQueue: Detected file change: %@ %i", fpath, fpath);
|
||||
[[NSWorkspace sharedWorkspace] noteFileSystemChanged: fpath];
|
||||
|
||||
//NSLog(@"ev.flags = %u",ev.fflags); // DEBUG ONLY!
|
||||
|
|
Loading…
Reference in a new issue