diff --git a/Application/AppController.m b/Application/AppController.m index c46cd3a70..c50926c2a 100644 --- a/Application/AppController.m +++ b/Application/AppController.m @@ -171,8 +171,8 @@ increase/decrease as long as the user holds the left/right, plus/minus button */ { if (returnCode == NSOKButton) { - [playlistLoader willInsertFiles:[panel URLs] origin:OpenFromOpenPanel]; - [playlistLoader didInsertFiles:[playlistLoader addURLs:[panel URLs] sort:YES] origin:OpenFromOpenPanel]; + [playlistLoader willInsertURLs:[panel URLs] origin:URLOriginInternal]; + [playlistLoader didInsertURLs:[playlistLoader addURLs:[panel URLs] sort:YES] origin:URLOriginInternal]; } } @@ -207,8 +207,8 @@ increase/decrease as long as the user holds the left/right, plus/minus button */ { if (returnCode == NSOKButton) { - [playlistLoader willInsertFiles:[NSArray arrayWithObject:[panel url]] origin:OpenFromOpenUrlPanel]; - [playlistLoader didInsertFiles:[playlistLoader addURLs:[NSArray arrayWithObject:[panel url]] sort:NO] origin:OpenFromOpenUrlPanel]; + [playlistLoader willInsertURLs:[NSArray arrayWithObject:[panel url]] origin:URLOriginExternal]; + [playlistLoader didInsertURLs:[playlistLoader addURLs:[NSArray arrayWithObject:[panel url]] sort:NO] origin:URLOriginExternal]; } } @@ -285,8 +285,8 @@ increase/decrease as long as the user holds the left/right, plus/minus button */ - (BOOL)application:(NSApplication *)theApplication openFile:(NSString *)filename { NSArray* urls = [NSArray arrayWithObject:[NSURL fileURLWithPath:filename]]; - [playlistLoader willInsertFiles:urls origin:OpenFromFinder]; - [playlistLoader didInsertFiles:[playlistLoader addURLs:urls sort:NO] origin:OpenFromFinder]; + [playlistLoader willInsertURLs:urls origin:URLOriginExternal]; + [playlistLoader didInsertURLs:[playlistLoader addURLs:urls sort:NO] origin:URLOriginExternal]; return YES; } @@ -299,8 +299,8 @@ increase/decrease as long as the user holds the left/right, plus/minus button */ { [urls addObject:[NSURL fileURLWithPath:filename]]; } - [playlistLoader willInsertFiles:urls origin:OpenFromFinder]; - [playlistLoader didInsertFiles:[playlistLoader addURLs:urls sort:YES] origin:OpenFromFinder]; + [playlistLoader willInsertURLs:urls origin:URLOriginExternal]; + [playlistLoader didInsertURLs:[playlistLoader addURLs:urls sort:YES] origin:URLOriginExternal]; [theApplication replyToOpenOrPrint:NSApplicationDelegateReplySuccess]; } diff --git a/Playlist/PlaylistController.h b/Playlist/PlaylistController.h index 0c2fa24fe..8153cfb64 100644 --- a/Playlist/PlaylistController.h +++ b/Playlist/PlaylistController.h @@ -24,19 +24,9 @@ typedef enum { } RepeatMode; typedef enum { - OpenPlaylist_related = 0, - LoadPlaylist, - DropOnPlaylist, - OpenFromOpenPanel, - OpenFromOpenUrlPanel, - OpenPlaylist_related_end, - - OpenFinder_Related, //meta-value - OpenFromFinder, - OpenFromFileTree, - OpenFromSpotlight, //? - OpenFinder_Related_end, -} AddedFilesSource; + URLOriginInternal = 0, + URLOriginExternal, +} URLOrigin; @interface PlaylistController : DNDArrayController { IBOutlet PlaylistLoader *playlistLoader; @@ -103,8 +93,8 @@ typedef enum { - (PlaylistEntry *)entryAtIndex:(int)i; // Event inlets: -- (void)willInsertFiles:(NSArray*)urls origin:(AddedFilesSource)src; -- (void)didInsertFiles:(NSArray*)entries origin:(AddedFilesSource)src; +- (void)willInsertURLs:(NSArray*)urls origin:(URLOrigin)origin; +- (void)didInsertURLs:(NSArray*)urls origin:(URLOrigin)origin; // queue methods - (IBAction)toggleQueued:(id)sender; diff --git a/Playlist/PlaylistController.m b/Playlist/PlaylistController.m index 16263f11b..6d49567bb 100644 --- a/Playlist/PlaylistController.m +++ b/Playlist/PlaylistController.m @@ -204,18 +204,18 @@ // Determine the type of object that was dropped - NSArray *supportedtypes = [NSArray arrayWithObjects:CogUrlsPboardType, NSFilenamesPboardType, iTunesDropType, nil]; + NSArray *supportedTypes = [NSArray arrayWithObjects:CogUrlsPboardType, NSFilenamesPboardType, iTunesDropType, nil]; NSPasteboard *pboard = [info draggingPasteboard]; - NSString *bestType = [pboard availableTypeFromArray:supportedtypes]; + NSString *bestType = [pboard availableTypeFromArray:supportedTypes]; - NSMutableArray *accept_urls = [[NSMutableArray alloc] init]; + NSMutableArray *acceptedURLs = [[NSMutableArray alloc] init]; // Get files from an file drawer drop if ([bestType isEqualToString:CogUrlsPboardType]) { NSArray *urls = [NSUnarchiver unarchiveObjectWithData:[[info draggingPasteboard] dataForType:CogUrlsPboardType]]; NSLog(@"URLS: %@", urls); //[playlistLoader insertURLs: urls atIndex:row sort:YES]; - [accept_urls addObjectsFromArray:urls]; + [acceptedURLs addObjectsFromArray:urls]; } // Get files from a normal file drop (such as from Finder) @@ -228,7 +228,7 @@ } //[playlistLoader insertURLs:urls atIndex:row sort:YES]; - [accept_urls addObjectsFromArray:urls]; + [acceptedURLs addObjectsFromArray:urls]; [urls release]; } @@ -245,20 +245,23 @@ } //[playlistLoader insertURLs:urls atIndex:row sort:YES]; - [accept_urls addObjectsFromArray:urls]; + [acceptedURLs addObjectsFromArray:urls]; [urls release]; } - if ([accept_urls count]) - { - [self willInsertFiles:accept_urls origin:DropOnPlaylist]; - if (![[entriesController entries] count]) + if ([acceptedURLs count]) + { + [self willInsertURLs:acceptedURLs origin:URLOriginInternal]; + + if (![[entriesController entries] count]) { row = 0; - NSArray* entries = [playlistLoader insertURLs:accept_urls atIndex:row sort:YES]; - [self didInsertFiles:entries origin:DropOnPlaylist]; } - [accept_urls release]; + NSArray* entries = [playlistLoader insertURLs:acceptedURLs atIndex:row sort:YES]; + [self didInsertURLs:entries origin:URLOriginInternal]; + } + + [acceptedURLs release]; if ([self shuffle] == YES) [self resetShuffleList]; @@ -787,7 +790,7 @@ } // Event inlets: -- (void)willInsertFiles:(NSArray*)urls origin:(AddedFilesSource)src +- (void)willInsertURLs:(NSArray*)urls origin:(URLOrigin)origin { if (![urls count]) return; @@ -802,18 +805,21 @@ NSLog(@"Behavior: %@", [[NSUserDefaults standardUserDefaults] valueForKey:@"openingFilesBehavior"]); NSLog(@"Altered Behavior: %@", [[NSUserDefaults standardUserDefaults] valueForKey:@"openingFilesAlteredBehavior"]); - if (src >= OpenFinder_Related && src <= OpenFinder_Related_end) + if (origin == URLOriginExternal) { //possible settings are "clearAndPlay", "enqueue", "enqueueAndPlay" should_clean = (!modifier1_pressed && ![[[NSUserDefaults standardUserDefaults] valueForKey:@"openingFilesBehavior"] compare:@"clearAndPlay"]) || ( modifier1_pressed && ![[[NSUserDefaults standardUserDefaults] valueForKey:@"openingFilesAlteredBehavior"] compare:@"clearAndPlay"]); - if (src >= OpenPlaylist_related && src <= OpenPlaylist_related_end) + } + else { should_clean = modifier1_pressed; - - if (should_clean) + } + + if (should_clean) { [self clear:self]; + } } -- (void)didInsertFiles:(NSArray*)entries origin:(AddedFilesSource)src +- (void)didInsertURLs:(NSArray*)entries origin:(URLOrigin)origin { if (![entries count]) return; @@ -825,19 +831,19 @@ modifier1_pressed |= ((mods & kCGEventFlagMaskShift)!=0); bool should_autoplay = false; - if (src >= OpenFinder_Related && src <= OpenFinder_Related_end) + if (origin == URLOriginExternal) should_autoplay = (!modifier1_pressed && (![[[NSUserDefaults standardUserDefaults] valueForKey:@"openingFilesBehavior"] compare:@"clearAndPlay"] - || ![[[NSUserDefaults standardUserDefaults] valueForKey:@"openingFilesBehavior"] compare:@"enqueueAndPlay"])) - || ( modifier1_pressed && (![[[NSUserDefaults standardUserDefaults] valueForKey:@"openingFilesAlteredBehavior"] compare:@"clearAndPlay"] - || ![[[NSUserDefaults standardUserDefaults] valueForKey:@"openingFilesAlteredBehavior"] compare:@"enqueueAndPlay"])); - if (src >= OpenPlaylist_related && src <= OpenPlaylist_related_end) + || ![[[NSUserDefaults standardUserDefaults] valueForKey:@"openingFilesBehavior"] compare:@"enqueueAndPlay"])) + || ( modifier1_pressed && (![[[NSUserDefaults standardUserDefaults] valueForKey:@"openingFilesAlteredBehavior"] compare:@"clearAndPlay"] + || ![[[NSUserDefaults standardUserDefaults] valueForKey:@"openingFilesAlteredBehavior"] compare:@"enqueueAndPlay"])); + if (origin == URLOriginInternal) should_autoplay = modifier1_pressed; //Auto start playback if (should_autoplay && [[entriesController entries] count] > 0) { [[entries objectAtIndex:0] setValuesForKeysWithDictionary:[playlistLoader readEntryInfo:[entries objectAtIndex:0]]]; [playbackController playEntry: [entries objectAtIndex:0]]; - } + } } diff --git a/Playlist/PlaylistLoader.h b/Playlist/PlaylistLoader.h index 59ba8cef8..2dd1fd67d 100755 --- a/Playlist/PlaylistLoader.h +++ b/Playlist/PlaylistLoader.h @@ -45,7 +45,7 @@ typedef enum { - (NSArray *)acceptableContainerTypes; // Event inlets (passed to playlist controler): -- (void)willInsertFiles:(NSArray*)urls origin:(AddedFilesSource)src; -- (void)didInsertFiles:(NSArray*)entries origin:(AddedFilesSource)src; +- (void)willInsertURLs:(NSArray*)urls origin:(URLOrigin)origin; +- (void)didInsertURLs:(NSArray*)entries origin:(URLOrigin)origin; @end diff --git a/Playlist/PlaylistLoader.m b/Playlist/PlaylistLoader.m index 07a4bcc34..75c729311 100755 --- a/Playlist/PlaylistLoader.m +++ b/Playlist/PlaylistLoader.m @@ -406,13 +406,13 @@ return [AudioPlayer containerTypes]; } -- (void)willInsertFiles:(NSArray*)urls origin:(AddedFilesSource)src +- (void)willInsertURLs:(NSArray*)urls origin:(URLOrigin)origin { - [playlistController willInsertFiles:urls origin:src]; + [playlistController willInsertURLs:urls origin:origin]; } -- (void)didInsertFiles:(NSArray*)entries origin:(AddedFilesSource)src +- (void)didInsertURLs:(NSArray*)urls origin:(URLOrigin)origin { - [playlistController didInsertFiles:entries origin:src]; + [playlistController didInsertURLs:urls origin:origin]; } @end diff --git a/SideView/SideViewController.m b/SideView/SideViewController.m index 73aae4fdd..ed6dcee23 100644 --- a/SideView/SideViewController.m +++ b/SideView/SideViewController.m @@ -75,8 +75,8 @@ - (void) addToPlaylist:(NSArray *)urls { - [playlistLoader willInsertFiles:urls origin:OpenFromFileTree]; - [playlistLoader didInsertFiles:[playlistLoader addURLs:urls sort:YES] origin:OpenFromFileTree]; + [playlistLoader willInsertURLs:urls origin:URLOriginExternal]; + [playlistLoader didInsertURLs:[playlistLoader addURLs:urls sort:YES] origin:URLOriginExternal]; } diff --git a/Spotlight/SpotlightWindowController.m b/Spotlight/SpotlightWindowController.m index 9edd91d61..a3e4c99d6 100644 --- a/Spotlight/SpotlightWindowController.m +++ b/Spotlight/SpotlightWindowController.m @@ -277,8 +277,8 @@ static NSPredicate * musicOnlyPredicate = nil; if ([tracks count] == 0) tracks = playlistController.arrangedObjects; - [playlistLoader willInsertFiles:[tracks valueForKey:@"URL"] origin:OpenFromSpotlight]; - [playlistLoader didInsertFiles:[playlistLoader addURLs:[tracks valueForKey:@"URL"] sort:NO] origin:OpenFromSpotlight]; + [playlistLoader willInsertURLs:[tracks valueForKey:@"URL"] origin:URLOriginExternal]; + [playlistLoader didInsertURLs:[playlistLoader addURLs:[tracks valueForKey:@"URL"] sort:NO] origin:URLOriginExternal]; [self.query enableUpdates]; }