diff --git a/Medianno/MAAddMediaSheet.h b/Medianno/MAAddMediaSheet.h index 33ba3d8..7d4b147 100644 --- a/Medianno/MAAddMediaSheet.h +++ b/Medianno/MAAddMediaSheet.h @@ -13,8 +13,7 @@ typedef void (^MAAddMediaBlock)(NSURL * url, NSDate * date); @interface MAAddMediaSheet : NSWindowController { } -@property (readonly) NSArray * urls; -@property (readonly) NSArray * dates; +@property (readonly) NSArray * media; @property BOOL copyMedia; - (void)runWithParentWindow:(NSWindow *)win media:(NSArray *)urls addMedia:(MAAddMediaBlock)block; diff --git a/Medianno/MAAddMediaSheet.mm b/Medianno/MAAddMediaSheet.mm index 6ca63b5..0f216ae 100644 --- a/Medianno/MAAddMediaSheet.mm +++ b/Medianno/MAAddMediaSheet.mm @@ -11,7 +11,7 @@ @implementation MAAddMediaSheet -@synthesize urls, dates, copyMedia; +@synthesize media, copyMedia; - (id)init { @@ -24,12 +24,15 @@ - (void)runWithParentWindow:(NSWindow *)win media:(NSArray *)mediaUrls addMedia:(MAAddMediaBlock)block { - urls = [mediaUrls retain]; + NSMutableArray * m = [[NSMutableArray alloc] initWithCapacity:[mediaUrls count]]; + for (NSURL * url in mediaUrls) + [m addObject:[NSMutableDictionary dictionaryWithObject:url forKey:@"url"]]; + media = m; [self useModificationDates:self]; [NSApp beginSheet:[self window] modalForWindow:win didEndBlock:^(NSInteger returnCode) { if (returnCode == NSAlertFirstButtonReturn) { - [urls enumerateObjectsUsingBlock:^(id obj, NSUInteger idx, BOOL *stop) { - block(obj, [dates objectAtIndex:idx]); + [media enumerateObjectsUsingBlock:^(id obj, NSUInteger idx, BOOL *stop) { + block([obj objectForKey:@"url"], [obj objectForKey:@"date"]); }]; } [[self window] orderOut:self]; @@ -39,20 +42,16 @@ - (void)dealloc { - [urls release]; - [dates release]; + [media release]; } - (IBAction)useModificationDates:(id)sender { - NSMutableArray * newDates = [[NSMutableArray alloc] initWithCapacity:[urls count]]; - for (NSURL * url in urls) { + for (NSMutableDictionary * m in media) { NSDate * modificationDate; - [url getResourceValue:&modificationDate forKey:NSURLContentModificationDateKey error:nil]; - [newDates addObject:(modificationDate ? modificationDate : [NSDate date])]; + [[m objectForKey:@"url"] getResourceValue:&modificationDate forKey:NSURLContentModificationDateKey error:nil]; + [m setObject:(modificationDate ? modificationDate : [NSDate date]) forKey:@"date"]; } - [dates release]; - dates = newDates; } - (IBAction)endSheet:(id)sender diff --git a/Medianno/en.lproj/MAAddMedia.xib b/Medianno/en.lproj/MAAddMedia.xib index 4f8fd27..76700e6 100644 --- a/Medianno/en.lproj/MAAddMedia.xib +++ b/Medianno/en.lproj/MAAddMedia.xib @@ -68,7 +68,7 @@ 256 YES - + 289 {{660, 12}, {107, 32}} @@ -78,17 +78,17 @@ _NS:161 1000 YES - + 67239424 134217728 Add Media - + LucidaGrande 13 1044 _NS:161 - + -2038284033 129 @@ -97,23 +97,23 @@ 25 - + 289 {{578, 12}, {82, 32}} - + _NS:161 1001 YES - + 67239424 134217728 Cancel - + _NS:161 - + -2038284033 129 @@ -122,34 +122,34 @@ 25 - + 268 YES - - + + 2304 YES - - + + 256 {781, 380} - + - + _NS:1197 YES - - + + 256 {781, 17} - + - + _NS:1199 - + @@ -159,8 +159,8 @@ YES - - 636.44140625 + + 600.68359375 40 1000 @@ -172,48 +172,48 @@ 11 3100 - + 3 MC4zMzMzMzI5ODU2AA - + 6 System headerTextColor - + 3 MAA - - 337772096 + + 67239488 2048 Text Cell - - - + + + 6 System controlBackgroundColor - + 3 MC42NjY2NjY2NjY3AA - + 6 System controlTextColor - + 3 YES - + - - 139 + + 174 40 1000 @@ -221,44 +221,42 @@ 2048 Date - - + + - - 337772096 + + 67239488 -2147481600 Text Cell - - + + YES YES dateFormat dateStyle - doesRelativeDateFormatting formatterBehavior timeStyle YES - yyyy-MM-dd H:mm - - + yyyy-MM-dd HH:mm + - yyyy-MM-dd H:mm + yyyy-MM-dd HH:mm NO - - - + + + 3 YES - + 3 @@ -277,7 +275,7 @@ 17 - -700448768 + -692060160 4 @@ -289,85 +287,85 @@ {{1, 17}, {781, 380}} - + - + _NS:1195 - - + + 4 - - + + -2147483392 {{224, 17}, {15, 102}} - + - + _NS:1214 - + _doScroller: 37 0.1947367936372757 - - + + -2147483392 {{1, 119}, {223, 15}} - + - + _NS:1216 1 - + _doScroller: 0.57142859697341919 - - + + 2304 YES - + {{1, 0}, {781, 17}} - + - + _NS:1200 - - + + 4 {{-1, 54}, {783, 398}} - + _NS:1193 133682 - - - - + + + + QSAAAEEgAABBmAAAQZgAAA - + 268 {{625, 458}, {138, 18}} - + _NS:239 YES - + -2080244224 0 Copy to Collection - + _NS:239 - + 1211912703 2 @@ -383,65 +381,65 @@ 25 - + 268 {{137, 456}, {371, 26}} - + _NS:179 YES - + -2076049856 2048 - + _NS:179 - + 109199615 129 400 75 - - + + Modification Date 1048576 2147483647 1 - + NSImage NSMenuCheckmark - + NSImage NSMenuMixedState _popUpItemAction: - + YES - + OtherViews YES - - - + + + YES YES 2147483647 - - + + _popUpItemAction: - + - + 1 YES @@ -449,61 +447,51 @@ 2 - + 268 {{17, 462}, {118, 17}} - + _NS:3936 YES - + 68288064 272630784 Derive Date From: - + _NS:3936 - + 6 System controlColor - + - + {781, 490} - + {{0, 0}, {2560, 1418}} {10000000000000, 10000000000000} YES - + YES - + YES - pathExtension + url + date - NSURL - YES - YES - YES - YES - YES - - - NSDate - - YES YES YES YES @@ -525,7 +513,7 @@ endSheet: - + 41 @@ -533,82 +521,57 @@ endSheet: - + 42 - contentArray: urls - + value: copyMedia + - + - contentArray: urls - contentArray - urls - 2 - - - 46 - - - - contentArray: dates - - - - - - contentArray: dates - contentArray - dates - 2 - - - 49 - - - - value: arrangedObjects - - - - - - value: arrangedObjects + value: copyMedia value - arrangedObjects + copyMedia + 2 + + + 68 + + + + contentArray: media + + + + + + contentArray: media + contentArray + media - YES - - YES - NSAllowsEditingMultipleValuesSelection - NSRaisesForNotApplicableKeys - - - YES - - - + NSConditionallySetsEditable + 2 - 65 + 74 - value: arrangedObjects.pathExtension - - + value: arrangedObjects.url.lastPathComponent + + - - - value: arrangedObjects.pathExtension + + + value: arrangedObjects.url.lastPathComponent value - arrangedObjects.pathExtension + arrangedObjects.url.lastPathComponent YES @@ -627,23 +590,23 @@ 2 - 66 + 75 - value: copyMedia - - + value: arrangedObjects.date + + - - - value: copyMedia + + + value: arrangedObjects.date value - copyMedia + arrangedObjects.date 2 - 68 + 76 @@ -687,199 +650,193 @@ YES - - - - - - + + + + + + 3 - + YES - + 4 - - + + 5 - + YES - + 6 - - + + 7 - + YES - - - - + + + + 8 - - + + 9 - - + + 10 - - + + 11 - + YES - - + + - + 12 - + YES - + - + 13 - + YES - + - + 14 - + YES - + - + 15 - - + + 16 - + YES - + 17 - - + + 18 - + YES - + 19 - + YES - + - + 20 - + YES - - + + - + 21 - - + + 25 - + YES - + 26 - - + + 27 - - + + 28 - - + + 32 - + 43 - + - URLs - - - 44 - - - Dates + Media @@ -915,7 +872,6 @@ 32.IBPluginDependency 4.IBPluginDependency 43.IBPluginDependency - 44.IBPluginDependency 5.IBPluginDependency 6.IBPluginDependency 7.IBPluginDependency @@ -957,7 +913,6 @@ com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin @@ -972,7 +927,7 @@ - 68 + 76