From de5fe2857f41c849bd475b51584ad25ccaa3fee7 Mon Sep 17 00:00:00 2001 From: Chris Moeller Date: Thu, 17 Oct 2013 20:46:11 -0700 Subject: [PATCH] MIDI page now displays the filename of the currently selected SoundFont, or None if none has been loaded yet --- .../General/English.lproj/Preferences.xib | 28 ++++++++++++++++++- .../General/General.xcodeproj/project.pbxproj | 14 ++++++++++ .../General/GeneralPreferencesPlugin.m | 10 ++++++- Preferences/General/PathToFileTransformer.h | 13 +++++++++ Preferences/General/PathToFileTransformer.m | 22 +++++++++++++++ 5 files changed, 85 insertions(+), 2 deletions(-) create mode 100644 Preferences/General/PathToFileTransformer.h create mode 100644 Preferences/General/PathToFileTransformer.m diff --git a/Preferences/General/English.lproj/Preferences.xib b/Preferences/General/English.lproj/Preferences.xib index b6821bd55..a4d68e8d0 100644 --- a/Preferences/General/English.lproj/Preferences.xib +++ b/Preferences/General/English.lproj/Preferences.xib @@ -453,7 +453,7 @@ + + + + + + + + + + + + + + + + + + + + None + PathToFileTransformer + + + + + diff --git a/Preferences/General/General.xcodeproj/project.pbxproj b/Preferences/General/General.xcodeproj/project.pbxproj index 85fca02fa..2e505c8ce 100644 --- a/Preferences/General/General.xcodeproj/project.pbxproj +++ b/Preferences/General/General.xcodeproj/project.pbxproj @@ -31,6 +31,7 @@ 83F27E6E1810DD3A00CEF538 /* midi@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 83F27E681810DD3A00CEF538 /* midi@2x.png */; }; 83F27E6F1810DD3A00CEF538 /* playlist@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 83F27E691810DD3A00CEF538 /* playlist@2x.png */; }; 83F27E701810DD3A00CEF538 /* updates@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 83F27E6A1810DD3A00CEF538 /* updates@2x.png */; }; + 83F27E741810E45D00CEF538 /* PathToFileTransformer.m in Sources */ = {isa = PBXBuildFile; fileRef = 83F27E731810E45D00CEF538 /* PathToFileTransformer.m */; }; 8D5B49B4048680CD000E48DA /* Cocoa.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1058C7ADFEA557BF11CA2CBB /* Cocoa.framework */; }; 8E07AA880AAC8EA200A4B32F /* HotKeyPane.m in Sources */ = {isa = PBXBuildFile; fileRef = 8E07AA810AAC8EA200A4B32F /* HotKeyPane.m */; }; 8E07AA890AAC8EA200A4B32F /* GeneralPreferencePane.m in Sources */ = {isa = PBXBuildFile; fileRef = 8E07AA830AAC8EA200A4B32F /* GeneralPreferencePane.m */; }; @@ -108,6 +109,8 @@ 83F27E681810DD3A00CEF538 /* midi@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = "midi@2x.png"; path = "Icons/midi@2x.png"; sourceTree = ""; }; 83F27E691810DD3A00CEF538 /* playlist@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = "playlist@2x.png"; path = "Icons/playlist@2x.png"; sourceTree = ""; }; 83F27E6A1810DD3A00CEF538 /* updates@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = "updates@2x.png"; path = "Icons/updates@2x.png"; sourceTree = ""; }; + 83F27E721810E45D00CEF538 /* PathToFileTransformer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PathToFileTransformer.h; sourceTree = ""; }; + 83F27E731810E45D00CEF538 /* PathToFileTransformer.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = PathToFileTransformer.m; sourceTree = ""; }; 8D5B49B6048680CD000E48DA /* General.preferencePane */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = General.preferencePane; sourceTree = BUILT_PRODUCTS_DIR; }; 8D5B49B7048680CD000E48DA /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 8E07AA800AAC8EA200A4B32F /* HotKeyPane.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = HotKeyPane.h; sourceTree = ""; }; @@ -175,6 +178,7 @@ 08FB77AFFE84173DC02AAC07 /* Classes */ = { isa = PBXGroup; children = ( + 83F27E711810E41A00CEF538 /* Transformers */, 8384913618081ECB00E7332D /* Logging.h */, 17D503410ABDB1660022D1E8 /* Custom */, 17D5033F0ABDB1570022D1E8 /* Panes */, @@ -261,6 +265,15 @@ name = Products; sourceTree = ""; }; + 83F27E711810E41A00CEF538 /* Transformers */ = { + isa = PBXGroup; + children = ( + 83F27E721810E45D00CEF538 /* PathToFileTransformer.h */, + 83F27E731810E45D00CEF538 /* PathToFileTransformer.m */, + ); + name = Transformers; + sourceTree = ""; + }; 8E07ABD90AAC95AF00A4B32F /* Icons */ = { isa = PBXGroup; children = ( @@ -390,6 +403,7 @@ files = ( 83B06729180D85B8008E3612 /* MIDIPane.m in Sources */, 8E07AA880AAC8EA200A4B32F /* HotKeyPane.m in Sources */, + 83F27E741810E45D00CEF538 /* PathToFileTransformer.m in Sources */, 8E07AA890AAC8EA200A4B32F /* GeneralPreferencePane.m in Sources */, 8E07AA8A0AAC8EA200A4B32F /* GeneralPreferencesPlugin.m in Sources */, 8E6C13A00AACBAB500819171 /* HotKeyControl.m in Sources */, diff --git a/Preferences/General/GeneralPreferencesPlugin.m b/Preferences/General/GeneralPreferencesPlugin.m index 832137fc7..2304b9c1b 100644 --- a/Preferences/General/GeneralPreferencesPlugin.m +++ b/Preferences/General/GeneralPreferencesPlugin.m @@ -7,15 +7,23 @@ // #import "GeneralPreferencesPlugin.h" +#import "PathToFileTransformer.h" @implementation GeneralPreferencesPlugin ++ (void)initialize +{ + NSValueTransformer *pathToFileTransformer = [[[PathToFileTransformer alloc] init]autorelease]; + [NSValueTransformer setValueTransformer:pathToFileTransformer + forName:@"PathToFileTransformer"]; +} + + (NSArray *)preferencePanes { GeneralPreferencesPlugin *plugin = [[[GeneralPreferencesPlugin alloc] init] autorelease]; [NSBundle loadNibNamed:@"Preferences" owner:plugin]; - return [NSArray arrayWithObjects: + return [NSArray arrayWithObjects: [plugin playlistPane], [plugin hotKeyPane], [plugin remotePane], diff --git a/Preferences/General/PathToFileTransformer.h b/Preferences/General/PathToFileTransformer.h new file mode 100644 index 000000000..6ea7e39b6 --- /dev/null +++ b/Preferences/General/PathToFileTransformer.h @@ -0,0 +1,13 @@ +// +// PathToFileTransformer.h +// General +// +// Created by Christopher Snowhill on 10/17/13. +// +// + +#import + +@interface PathToFileTransformer : NSValueTransformer + +@end diff --git a/Preferences/General/PathToFileTransformer.m b/Preferences/General/PathToFileTransformer.m new file mode 100644 index 000000000..1eff49f2d --- /dev/null +++ b/Preferences/General/PathToFileTransformer.m @@ -0,0 +1,22 @@ +// +// PathToFileTransformer.m +// General +// +// Created by Christopher Snowhill on 10/17/13. +// +// + +#import "PathToFileTransformer.h" + +@implementation PathToFileTransformer + ++ (Class)transformedValueClass { return [NSString class]; } ++ (BOOL)allowsReverseTransformation { return NO; } + +// Convert from string to NSURL +- (id)transformedValue:(id)value { + if (value == nil) return nil; + + return [value lastPathComponent]; +} +@end