Added back update notifications back to the file drawer.

Removed no-longer-used files.
Removed debugging messages.
CQTexperiment
vspader 2007-10-15 03:29:30 +00:00
parent 27d9ff122a
commit 4b814bdbf0
20 changed files with 141 additions and 412 deletions

View File

@ -7,7 +7,7 @@
@class PlaybackController; @class PlaybackController;
@class PlaylistController; @class PlaylistController;
@class PlaylistView; @class PlaylistView;
@class FileTreeController; @class FileTreeDataSource;
@class FileOutlineView; @class FileOutlineView;
@class AppleRemote; @class AppleRemote;
@class PlaylistLoader; @class PlaylistLoader;
@ -33,7 +33,7 @@
IBOutlet NSDrawer *infoDrawer; IBOutlet NSDrawer *infoDrawer;
IBOutlet NSDrawer *fileDrawer; IBOutlet NSDrawer *fileDrawer;
IBOutlet FileTreeController *fileTreeController; IBOutlet FileTreeDataSource *fileTreeDataSource;
IBOutlet FileOutlineView *fileOutlineView; IBOutlet FileOutlineView *fileOutlineView;
IBOutlet PlaylistView *playlistView; IBOutlet PlaylistView *playlistView;

View File

@ -3,7 +3,6 @@
#import "PlaybackController.h" #import "PlaybackController.h"
#import "PlaylistController.h" #import "PlaylistController.h"
#import "PlaylistView.h" #import "PlaylistView.h"
#import "FileTreeController.h"
#import "FileOutlineView.h" #import "FileOutlineView.h"
#import "NDHotKeyEvent.h" #import "NDHotKeyEvent.h"
#import "AppleRemote.h" #import "AppleRemote.h"
@ -400,7 +399,7 @@ increase/decrease as long as the user holds the left/right, plus/minus button */
[self registerHotKeys]; [self registerHotKeys];
} }
else if ([keyPath isEqualToString:@"values.fileDrawerRootPath"]) { 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"]) { else if ([keyPath isEqualToString:@"values.remoteEnabled"] || [keyPath isEqualToString:@"values.remoteOnlyOnActive"]) {
if([[NSUserDefaults standardUserDefaults] boolForKey:@"remoteEnabled"]) { if([[NSUserDefaults standardUserDefaults] boolForKey:@"remoteEnabled"]) {

View File

@ -123,7 +123,6 @@
8EFFCD610AA093AF00C458A5 /* FileIconCell.m in Sources */ = {isa = PBXBuildFile; fileRef = 8EFFCD450AA093AF00C458A5 /* FileIconCell.m */; }; 8EFFCD610AA093AF00C458A5 /* FileIconCell.m in Sources */ = {isa = PBXBuildFile; fileRef = 8EFFCD450AA093AF00C458A5 /* FileIconCell.m */; };
8EFFCD630AA093AF00C458A5 /* FileNode.m in Sources */ = {isa = PBXBuildFile; fileRef = 8EFFCD470AA093AF00C458A5 /* FileNode.m */; }; 8EFFCD630AA093AF00C458A5 /* FileNode.m in Sources */ = {isa = PBXBuildFile; fileRef = 8EFFCD470AA093AF00C458A5 /* FileNode.m */; };
8EFFCD650AA093AF00C458A5 /* FileOutlineView.m in Sources */ = {isa = PBXBuildFile; fileRef = 8EFFCD490AA093AF00C458A5 /* FileOutlineView.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 */; }; 8EFFCD6F0AA093AF00C458A5 /* PathNode.m in Sources */ = {isa = PBXBuildFile; fileRef = 8EFFCD530AA093AF00C458A5 /* PathNode.m */; };
/* End PBXBuildFile section */ /* End PBXBuildFile section */
@ -613,10 +612,6 @@
8EFFCD470AA093AF00C458A5 /* FileNode.m */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.objc; path = FileNode.m; sourceTree = "<group>"; }; 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>"; }; 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>"; }; 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>"; }; 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>"; }; 8EFFCD530AA093AF00C458A5 /* PathNode.m */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.objc; path = PathNode.m; sourceTree = "<group>"; };
/* End PBXFileReference section */ /* End PBXFileReference section */
@ -1151,10 +1146,6 @@
8EFFCD490AA093AF00C458A5 /* FileOutlineView.m */, 8EFFCD490AA093AF00C458A5 /* FileOutlineView.m */,
1769D7CF0CC2BFF7003F455B /* FileTreeDataSource.h */, 1769D7CF0CC2BFF7003F455B /* FileTreeDataSource.h */,
1769D7D00CC2BFF7003F455B /* FileTreeDataSource.m */, 1769D7D00CC2BFF7003F455B /* FileTreeDataSource.m */,
8EFFCD4A0AA093AF00C458A5 /* FileTreeController.h */,
8EFFCD4B0AA093AF00C458A5 /* FileTreeController.m */,
8EFFCD4C0AA093AF00C458A5 /* FileTreeWatcher.h */,
8EFFCD4D0AA093AF00C458A5 /* FileTreeWatcher.m */,
8EFFCD420AA093AF00C458A5 /* DirectoryNode.h */, 8EFFCD420AA093AF00C458A5 /* DirectoryNode.h */,
8EFFCD430AA093AF00C458A5 /* DirectoryNode.m */, 8EFFCD430AA093AF00C458A5 /* DirectoryNode.m */,
8EFFCD460AA093AF00C458A5 /* FileNode.h */, 8EFFCD460AA093AF00C458A5 /* FileNode.h */,
@ -1507,7 +1498,6 @@
8EFFCD610AA093AF00C458A5 /* FileIconCell.m in Sources */, 8EFFCD610AA093AF00C458A5 /* FileIconCell.m in Sources */,
8EFFCD630AA093AF00C458A5 /* FileNode.m in Sources */, 8EFFCD630AA093AF00C458A5 /* FileNode.m in Sources */,
8EFFCD650AA093AF00C458A5 /* FileOutlineView.m in Sources */, 8EFFCD650AA093AF00C458A5 /* FileOutlineView.m in Sources */,
8EFFCD690AA093AF00C458A5 /* FileTreeWatcher.m in Sources */,
8EFFCD6F0AA093AF00C458A5 /* PathNode.m in Sources */, 8EFFCD6F0AA093AF00C458A5 /* PathNode.m in Sources */,
8E07AAF30AAC910500A4B32F /* SS_PrefsController.m in Sources */, 8E07AAF30AAC910500A4B32F /* SS_PrefsController.m in Sources */,
8E07AB790AAC930B00A4B32F /* PreferencesController.m in Sources */, 8E07AB790AAC930B00A4B32F /* PreferencesController.m in Sources */,

View File

@ -25,11 +25,10 @@
CLASS = AppController; CLASS = AppController;
LANGUAGE = ObjC; LANGUAGE = ObjC;
OUTLETS = { OUTLETS = {
addURLPanel = NSPanel;
fileButton = NSButton; fileButton = NSButton;
fileDrawer = NSDrawer; fileDrawer = NSDrawer;
fileOutlineView = FileOutlineView; fileOutlineView = FileOutlineView;
fileTreeController = FileTreeController; fileTreeDataSource = FileTreeDataSource;
infoButton = NSButton; infoButton = NSButton;
infoDrawer = NSDrawer; infoDrawer = NSDrawer;
mainWindow = NSPanel; mainWindow = NSPanel;
@ -50,7 +49,6 @@
showTrackColumn = NSMenuItem; showTrackColumn = NSMenuItem;
showYearColumn = NSMenuItem; showYearColumn = NSMenuItem;
shuffleButton = NSButton; shuffleButton = NSButton;
urlComboBox = NSComboBox;
}; };
SUPERCLASS = NSObject; SUPERCLASS = NSObject;
}, },
@ -82,10 +80,10 @@
SUPERCLASS = NSOutlineView; SUPERCLASS = NSOutlineView;
}, },
{ {
CLASS = FileTreeController; CLASS = FileTreeDataSource;
LANGUAGE = ObjC; LANGUAGE = ObjC;
OUTLETS = {playlistLoader = PlaylistLoader; }; OUTLETS = {outlineView = NSOutlineView; };
SUPERCLASS = NSTreeController; SUPERCLASS = NSObject;
}, },
{CLASS = FirstResponder; LANGUAGE = ObjC; SUPERCLASS = NSObject; }, {CLASS = FirstResponder; LANGUAGE = ObjC; SUPERCLASS = NSObject; },
{CLASS = InfoController; LANGUAGE = ObjC; SUPERCLASS = NSObject; }, {CLASS = InfoController; LANGUAGE = ObjC; SUPERCLASS = NSObject; },

View File

@ -35,8 +35,8 @@
<key>IBOpenObjects</key> <key>IBOpenObjects</key>
<array> <array>
<integer>1063</integer> <integer>1063</integer>
<integer>268</integer>
<integer>29</integer> <integer>29</integer>
<integer>268</integer>
<integer>21</integer> <integer>21</integer>
<integer>1156</integer> <integer>1156</integer>
<integer>1324</integer> <integer>1324</integer>

Binary file not shown.

View File

@ -11,9 +11,6 @@
#import "FileNode.h" #import "FileNode.h"
#import "SmartFolderNode.h" #import "SmartFolderNode.h"
#import "FileTreeController.h"
#import "FileTreeWatcher.h"
@implementation DirectoryNode @implementation DirectoryNode
- (BOOL)isLeaf - (BOOL)isLeaf
@ -21,19 +18,11 @@
return NO; return NO;
} }
- (NSArray *)subpaths - (void)updatePath
{ {
if (subpaths == nil) NSArray *contents = [[[NSFileManager defaultManager] directoryContentsAtPath:path] sortedArrayUsingSelector:@selector(caseInsensitiveCompare:)];
{
subpaths = [[NSMutableArray alloc] init]; [self processPaths: contents];
NSArray *contents = [[[NSFileManager defaultManager] directoryContentsAtPath:path] sortedArrayUsingSelector:@selector(caseInsensitiveCompare:)];
NSLog(@"Contents: %@", contents);
[self processPaths: contents];
// [[controller watcher] addPath:[self path]];
}
return subpaths;
} }
@end @end

View File

@ -7,14 +7,14 @@
// //
#import "FileIconCell.h" #import "FileIconCell.h"
#import "PathNode.h"
@implementation FileIconCell @implementation FileIconCell
- (void)setObjectValue:(id)o - (void)setObjectValue:(id)o
{ {
if ([o respondsToSelector:@selector(icon)]) { if ([o respondsToSelector:@selector(icon)] && [o respondsToSelector:@selector(displayPath)]) {
[super setObjectValue:[[o path] lastPathComponent]]; [super setObjectValue:[o displayPath]];
[super setImage: [o icon]]; [super setImage: [o icon]];
} }
else { else {

View File

@ -31,9 +31,6 @@
[c setDataCell: dataCell]; [c setDataCell: dataCell];
NSLog(@"Setting data cell!"); NSLog(@"Setting data cell!");
} }
dataSource = [[FileTreeDataSource alloc] initWithRoot: [[[NSUserDefaultsController sharedUserDefaultsController] defaults] objectForKey:@"fileDrawerRootPath"] ];
[self setDataSource: dataSource];
} }

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -8,15 +8,21 @@
#import <Cocoa/Cocoa.h> #import <Cocoa/Cocoa.h>
@class FileTreeDataSource;
@interface PathNode : NSObject @interface PathNode : NSObject
{ {
FileTreeDataSource *dataSource;
NSString *path; NSString *path;
NSString *displayPath; //The pretty path to display.
NSImage *icon; NSImage *icon;
NSArray *subpaths; NSArray *subpaths;
} }
- (id)initWithPath:(NSString *)p; - (id)initWithDataSource:(FileTreeDataSource *)ds path:(NSString *)p;
- (NSString *)path; - (NSString *)path;
- (void)setPath:(NSString *)p; - (void)setPath:(NSString *)p;
@ -26,6 +32,7 @@
- (NSArray *)subpaths; - (NSArray *)subpaths;
- (void)setSubpaths:(NSArray *)s; - (void)setSubpaths:(NSArray *)s;
- (NSString *)displayPath;
- (NSImage *)icon; - (NSImage *)icon;
- (BOOL)isLeaf; - (BOOL)isLeaf;

View File

@ -10,44 +10,76 @@
#import "CogAudio/AudioPlayer.h" #import "CogAudio/AudioPlayer.h"
#import "FileTreeDataSource.h"
#import "UKKQueue.h"
@class FileNode; @class FileNode;
@class DirectoryNode; @class DirectoryNode;
@class SmartFolderNode; @class SmartFolderNode;
@implementation PathNode @implementation PathNode
- (id)initWithPath:(NSString *)p - (id)initWithDataSource:(FileTreeDataSource *)ds path:(NSString *)p
{ {
self = [super init]; self = [super init];
if (self) if (self)
{ {
dataSource = ds;
[self setPath: p]; [self setPath: p];
} }
return self; return self;
} }
- (void)dealloc - (void)stopWatching
{ {
[path release]; if (path)
[icon release]; {
NSLog(@"Stopped watching...: %@", path);
if (subpaths) {
[subpaths release];
subpaths = nil;
}
[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 - (void)setPath:(NSString *)p
{ {
[p retain]; [p retain];
[path release];
[self stopWatching];
[path release];
path = p; path = p;
[self startWatching];
[displayPath release];
displayPath = [[NSFileManager defaultManager] displayNameAtPath:path];
[displayPath retain];
[icon release]; [icon release];
icon = [[NSWorkspace sharedWorkspace] iconForFile:path]; icon = [[NSWorkspace sharedWorkspace] iconForFile:path];
[icon retain]; [icon retain];
@ -60,6 +92,28 @@
return path; 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 - (void)processPaths: (NSArray *)contents
{ {
NSMutableArray *newSubpaths = [[NSMutableArray alloc] init]; NSMutableArray *newSubpaths = [[NSMutableArray alloc] init];
@ -78,7 +132,7 @@
if ([[s pathExtension] caseInsensitiveCompare:@"savedSearch"] == NSOrderedSame) if ([[s pathExtension] caseInsensitiveCompare:@"savedSearch"] == NSOrderedSame)
{ {
newNode = [[SmartFolderNode alloc] initWithPath:newSubpath]; newNode = [[SmartFolderNode alloc] initWithDataSource:dataSource path:newSubpath];
} }
else else
{ {
@ -92,9 +146,13 @@
} }
if (isDir) if (isDir)
newNode = [[DirectoryNode alloc] initWithPath: newSubpath]; {
newNode = [[DirectoryNode alloc] initWithDataSource:dataSource path: newSubpath];
}
else else
newNode = [[FileNode alloc] initWithPath: newSubpath]; {
newNode = [[FileNode alloc] initWithDataSource:dataSource path: newSubpath];
}
} }
[newSubpaths addObject:newNode]; [newSubpaths addObject:newNode];
@ -102,13 +160,18 @@
[newNode release]; [newNode release];
} }
[self setSubpaths:[[newSubpaths copy] autorelease]]; [self setSubpaths:newSubpaths];
[newSubpaths release]; [newSubpaths release];
} }
- (NSArray *)subpaths - (NSArray *)subpaths
{ {
if (subpaths == nil)
{
[self updatePath];
}
return subpaths; return subpaths;
} }
@ -125,11 +188,26 @@
return YES; return YES;
} }
- (NSString *)displayPath
{
return displayPath;
}
- (NSImage *)icon - (NSImage *)icon
{ {
return icon; return icon;
} }
- (void)dealloc
{
[self stopWatching];
[path release];
[icon release];
[subpaths release];
[super dealloc];
}
@end @end

View File

@ -17,26 +17,23 @@
return NO; return NO;
} }
- (NSArray *)subpaths - (void)updatePath
{ {
if (subpaths == nil) NSDictionary *doc = [NSDictionary dictionaryWithContentsOfFile:path];
{ NSString *rawQuery = [doc objectForKey:@"RawQuery"];
NSDictionary *doc = [NSDictionary dictionaryWithContentsOfFile:path]; NSArray *searchPaths = [[doc objectForKey:@"SearchCriteria"] objectForKey:@"CurrentFolderPath"];
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);
}
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 - (void)setSubpaths:(id)s

View File

@ -46,8 +46,11 @@
[_url release]; [_url release];
_url = nil; _url = nil;
fclose(_fd); if (_fd)
_fd = NULL; {
fclose(_fd);
_fd = NULL;
}
} }
- (NSURL *)url - (NSURL *)url
@ -74,7 +77,7 @@
} }
- (void)dealloc { - (void)dealloc {
NSLog(@"DEALLOCATING SOURCE"); [self close];
[super dealloc]; [super dealloc];
} }

View File

@ -566,12 +566,6 @@ static inline signed int scale (mad_fixed_t sample)
mad_stream_finish(&_stream); mad_stream_finish(&_stream);
} }
- (void)dealloc
{
NSLog(@"Decoder dealloc");
[super dealloc];
}
- (double)seekToTime:(double)milliseconds - (double)seekToTime:(double)milliseconds
{ {
unsigned long new_position; unsigned long new_position;

3
TODO
View File

@ -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.

View File

@ -355,7 +355,8 @@ static UKKQueue * gUKKQueueSharedQueueSingleton = nil;
if( ev.fflags ) if( ev.fflags )
{ {
NSString* fpath = [[(NSString *)ev.udata retain] autorelease]; // In case one of the notified folks removes the path. 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]; [[NSWorkspace sharedWorkspace] noteFileSystemChanged: fpath];
//NSLog(@"ev.flags = %u",ev.fflags); // DEBUG ONLY! //NSLog(@"ev.flags = %u",ev.fflags); // DEBUG ONLY!