Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Added Monkey's Audio support
  • Loading branch information
stephen_booth committed Mar 20, 2006
1 parent df3d858 commit 3850e9e
Show file tree
Hide file tree
Showing 14 changed files with 313 additions and 44 deletions.
Binary file modified English.lproj/Preferences.nib/keyedobjects.nib
Binary file not shown.
Binary file modified English.lproj/TagEditor.nib/keyedobjects.nib
Binary file not shown.
4 changes: 2 additions & 2 deletions FLACFile.h
Expand Up @@ -19,9 +19,9 @@
*/

#import <Cocoa/Cocoa.h>
#import "XiphCommentedFile.h"
#import "KeyValueTaggedFile.h"

@interface FLACFile : XiphCommentedFile
@interface FLACFile : KeyValueTaggedFile
{
}

Expand Down
4 changes: 2 additions & 2 deletions FileArrayController.h
Expand Up @@ -19,14 +19,14 @@
*/

#import <Cocoa/Cocoa.h>
#import "XiphCommentedFile.h"
#import "KeyValueTaggedFile.h"

@interface FileArrayController : NSArrayController
{
IBOutlet NSTableView *_tableView;
}

- (XiphCommentedFile *) findFile:(NSString *)filename;
- (KeyValueTaggedFile *) findFile:(NSString *)filename;
- (BOOL) containsFile:(NSString *)filename;

- (void) selectFile:(NSString *)filename;
Expand Down
8 changes: 4 additions & 4 deletions FileArrayController.m
Expand Up @@ -39,10 +39,10 @@ - (BOOL) containsFile:(NSString *)filename
return (nil == [self findFile:filename] ? NO : YES);
}

- (XiphCommentedFile *) findFile:(NSString *)filename
- (KeyValueTaggedFile *) findFile:(NSString *)filename
{
NSEnumerator *enumerator;
XiphCommentedFile *current;
KeyValueTaggedFile *current;

enumerator = [[self arrangedObjects] objectEnumerator];
while((current = [enumerator nextObject])) {
Expand All @@ -56,7 +56,7 @@ - (XiphCommentedFile *) findFile:(NSString *)filename

- (void) selectFile:(NSString *)filename
{
XiphCommentedFile *file = [self findFile:filename];
KeyValueTaggedFile *file = [self findFile:filename];
if(nil != file) {
[self setSelectionIndex:[[self arrangedObjects] indexOfObject:file]];
}
Expand Down Expand Up @@ -118,7 +118,7 @@ - (BOOL) tableView:(NSTableView*)tv acceptDrop:(id <NSDraggingInfo>)info row:(in
NSEnumerator *enumerator;
NSString *current;
NSMutableArray *newFiles = [NSMutableArray arrayWithCapacity:10];
XiphCommentedFile *file;
KeyValueTaggedFile *file;

enumerator = [[[info draggingPasteboard] propertyListForType:NSFilenamesPboardType] objectEnumerator];
while((current = [enumerator nextObject])) {
Expand Down
22 changes: 21 additions & 1 deletion Info.plist
Expand Up @@ -11,6 +11,8 @@
<array>
<string>ogg</string>
</array>
<key>CFBundleTypeIconFile</key>
<string>TagFile</string>
<key>CFBundleTypeName</key>
<string>Ogg Vorbis Audio</string>
<key>CFBundleTypeRole</key>
Expand All @@ -26,14 +28,32 @@
<string>flac</string>
</array>
<key>CFBundleTypeIconFile</key>
<string></string>
<string>TagFile</string>
<key>CFBundleTypeName</key>
<string>FLAC Audio</string>
<key>CFBundleTypeRole</key>
<string>Editor</string>
<key>LSTypeIsPackage</key>
<false/>
</dict>
<dict>
<key>CFBundleTypeExtensions</key>
<array>
<string>ape</string>
<string>apl</string>
<string>mac</string>
</array>
<key>CFBundleTypeIconFile</key>
<string>TagFile</string>
<key>CFBundleTypeName</key>
<string>Monkey's Audio</string>
<key>CFBundleTypeRole</key>
<string>Editor</string>
<key>LSTypeIsPackage</key>
<false/>
<key>NSPersistentStoreTypeKey</key>
<string>Binary</string>
</dict>
</array>
<key>CFBundleExecutable</key>
<string>${EXECUTABLE_NAME}</string>
Expand Down
4 changes: 2 additions & 2 deletions XiphCommentedFile.h → KeyValueTaggedFile.h
Expand Up @@ -20,15 +20,15 @@

#import <Cocoa/Cocoa.h>

@interface XiphCommentedFile : NSObject
@interface KeyValueTaggedFile : NSObject
{
NSMutableArray *_tags;
NSString *_filename;
NSString *_displayName;
int _changeCount;
}

+ (XiphCommentedFile *) parseFile:(NSString *)filename;
+ (KeyValueTaggedFile *) parseFile:(NSString *)filename;

- (id) initWithFile:(NSString *)filename;

Expand Down
18 changes: 13 additions & 5 deletions XiphCommentedFile.m → KeyValueTaggedFile.m
Expand Up @@ -18,16 +18,17 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/

#import "XiphCommentedFile.h"
#import "KeyValueTaggedFile.h"
#import "OggVorbisFile.h"
#import "FLACFile.h"
#import "MonkeysAudioFile.h"
#import "TagEditor.h"

@implementation XiphCommentedFile
@implementation KeyValueTaggedFile

+ (XiphCommentedFile *) parseFile:(NSString *)filename
+ (KeyValueTaggedFile *) parseFile:(NSString *)filename
{
XiphCommentedFile *result = nil;
KeyValueTaggedFile *result = nil;
NSString *extension = [filename pathExtension];

if([extension isEqualToString:@"ogg"]) {
Expand All @@ -36,8 +37,11 @@ + (XiphCommentedFile *) parseFile:(NSString *)filename
else if([extension isEqualToString:@"flac"]) {
result = [[FLACFile alloc] initWithFile:filename];
}
else if([extension isEqualToString:@"ape"] || [extension isEqualToString:@"apl"] || [extension isEqualToString:@"mac"]) {
result = [[MonkeysAudioFile alloc] initWithFile:filename];
}
else {
@throw [NSException exceptionWithName:@"FileFormatNotSupportedException" reason:NSLocalizedStringFromTable(@"The document does not appear to be a valid FLAC or Ogg Vorbis file.", @"Errors", @"") userInfo:nil];
@throw [NSException exceptionWithName:@"FileFormatNotSupportedException" reason:NSLocalizedStringFromTable(@"The document does not appear to be a valid FLAC, Ogg Vorbis or Monkey's Audio file.", @"Errors", @"") userInfo:nil];
}

return [result autorelease];
Expand Down Expand Up @@ -88,6 +92,8 @@ - (void) willChangeValueForTag:(NSString *)tag
TagEditor *editor = [TagEditor sharedEditor];
NSString *key = [[self tagMapping] valueForKey:tag];

[editor willChangeValueForKey:@"tags"];

if(nil != key) {
[editor willChangeValueForKey:key];
[self willChangeValueForKey:key];
Expand All @@ -103,6 +109,8 @@ - (void) didChangeValueForTag:(NSString *)tag
[self didChangeValueForKey:key];
[editor didChangeValueForKey:key];
}

[editor didChangeValueForKey:@"tags"];
}

- (void) setValue:(NSString *)value forTag:(NSString *)tag
Expand Down
28 changes: 28 additions & 0 deletions MonkeysAudioFile.h
@@ -0,0 +1,28 @@
/*
* $Id$
*
* Copyright (C) 2005, 2006 Stephen F. Booth <me@sbooth.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/

#import <Cocoa/Cocoa.h>
#import "KeyValueTaggedFile.h"

@interface MonkeysAudioFile : KeyValueTaggedFile
{
}

@end

0 comments on commit 3850e9e

Please sign in to comment.