MacOSX/VLC_app: Set the representedPath of the main Window.
authorPierre d'Herbemont <pdherbemont@videolan.org>
Sun, 6 Jan 2008 17:36:36 +0000 (17:36 +0000)
committerPierre d'Herbemont <pdherbemont@videolan.org>
Sun, 6 Jan 2008 17:36:36 +0000 (17:36 +0000)
extras/MacOSX/VLC_app/Sources/VLCController.m
extras/MacOSX/VLC_app/Sources/VLCMainWindow.m
extras/MacOSX/VLC_app/Sources/VLCValueTransformer.h
extras/MacOSX/VLC_app/Sources/VLCValueTransformer.m

index 067bce0..2319dd5 100644 (file)
@@ -49,6 +49,9 @@
     VLCNonNilAsBoolTransformer *nonNilAsBool;
     nonNilAsBool = [[[VLCNonNilAsBoolTransformer alloc] init] autorelease];
     [NSValueTransformer setValueTransformer:(id)nonNilAsBool forName:@"NonNilAsBoolTransformer"];
+    VLCURLToRepresentedFileNameTransformer *urlToRepresentedFileName;
+    urlToRepresentedFileName = [[[VLCURLToRepresentedFileNameTransformer alloc] init] autorelease];
+    [NSValueTransformer setValueTransformer:(id)urlToRepresentedFileName forName:@"URLToRepresentedFileNameTransformer"];
 
     /***********************************
      * categories: Main content
index 124780a..bba82b9 100644 (file)
                                                   [NSNumber numberWithBool:NO], NSConditionallySetsEnabledBindingOption, nil ]];
     [mediaReadingProgressText bind:@"value" toObject:mediaPlayer withKeyPath:@"time.stringValue" options: nil];
     [mediaDescriptionText bind:@"value" toObject:mediaPlayer withKeyPath:@"description" options: nil];
+    [self bind:@"representedFilename" toObject:mediaPlayer withKeyPath:@"media.url" options: [NSDictionary dictionaryWithObject:@"URLToRepresentedFileNameTransformer" forKey:NSValueTransformerNameBindingOption]];
     [self bind:@"title" toObject:mediaPlayer withKeyPath:@"description" options: nil];
 
     [navigatorViewToggleButton bind:@"value" toObject:self withKeyPath:@"navigatorViewVisible" options: nil];
index dd2063a..2d08b4c 100644 (file)
@@ -32,3 +32,7 @@
 }
 @end
 
+@interface VLCURLToRepresentedFileNameTransformer : NSValueTransformer {
+}
+@end
+
index bc99bda..a2c705b 100644 (file)
 
 @end
 
+@implementation VLCURLToRepresentedFileNameTransformer
+
++ (Class)transformedValueClass
+{
+    return [NSURL class];
+}
+
++ (BOOL)allowsReverseTransformation
+{
+    return NO;
+}
+
+- (NSString *)transformedValue:(id)value
+{
+    NSLog(@"%@", value);
+    if( ![value isKindOfClass:[NSURL class]] || ![value isFileURL] )
+        return @"";
+
+    return [value path];
+}
+
+@end
+