From: Michael J. Rubinsky Date: Sat, 9 May 2009 15:09:27 +0000 (-0400) Subject: Add image cations (or titles) and original date to the image browser X-Git-Url: https://git.internetallee.de/?a=commitdiff_plain;h=13760ff3e2e504c740af7002d09e5bd9622938ac;p=horde.git Add image cations (or titles) and original date to the image browser when browsing Ansel galleries from iPhoto --- diff --git a/iPhoto2Ansel/AnselExportController.m b/iPhoto2Ansel/AnselExportController.m index 7dbbf390b..b1a56f08d 100644 --- a/iPhoto2Ansel/AnselExportController.m +++ b/iPhoto2Ansel/AnselExportController.m @@ -107,7 +107,15 @@ NSString * const TURAnselServerPasswordKey = @"password"; [browserData removeAllObjects]; NSMutableArray *images = [currentGallery listImages]; for (NSDictionary *image in images) { - AnselGalleryViewItem *item = [[AnselGalleryViewItem alloc] initWithURL: [NSURL URLWithString: [image objectForKey:@"url"]]]; + NSString *caption = [image objectForKey:@"caption"]; + if (caption == nil) { + caption = [image objectForKey:@"filename"]; + } + + NSDate *theDate = [NSDate dateWithTimeIntervalSince1970: [[image objectForKey:@"original_date"] doubleValue]]; + AnselGalleryViewItem *item = [[AnselGalleryViewItem alloc] initWithURL: [NSURL URLWithString: [image objectForKey:@"url"]] + withTitle: caption + withDate: theDate]; [browserData addObject: item]; } diff --git a/iPhoto2Ansel/AnselGalleryViewItem.h b/iPhoto2Ansel/AnselGalleryViewItem.h index 29729a9ff..e0eece1ff 100644 --- a/iPhoto2Ansel/AnselGalleryViewItem.h +++ b/iPhoto2Ansel/AnselGalleryViewItem.h @@ -10,19 +10,24 @@ @interface AnselGalleryViewItem: NSObject { - NSURL * image; - NSString * imageID; + NSURL *image; + NSString *imageID; + NSString *imageTitle; + NSCalendarDate *imageDate; } @property(readwrite,copy) NSURL * image; @property(readwrite,copy) NSString * imageID; -- (id)initWithURL: (NSURL *)theUrl; +- (id)initWithURL: (NSURL *)theUrl withTitle: (NSString *)theTitle withDate: (NSDate *)theDate; #pragma mark - #pragma mark Required Methods IKImageBrowserItem Informal Protocol -- (NSString *) imageUID; -- (NSString *) imageRepresentationType; -- (id) imageRepresentation; +- (NSString *)imageUID; +- (NSString *)imageRepresentationType; +- (id)imageRepresentation; + +- (NSString *)imageTitle; +- (NSString *)imageSubtitle; @end diff --git a/iPhoto2Ansel/AnselGalleryViewItem.m b/iPhoto2Ansel/AnselGalleryViewItem.m index b5bde8a97..b920f8c5b 100644 --- a/iPhoto2Ansel/AnselGalleryViewItem.m +++ b/iPhoto2Ansel/AnselGalleryViewItem.m @@ -2,6 +2,8 @@ // AnselGalleryViewItem.m // iPhoto2Ansel // +// Implementation of the IKImageBrowserItem protocol + // Created by Michael Rubinsky on 5/7/09. // Copyright 2009 __MyCompanyName__. All rights reserved. // @@ -12,11 +14,15 @@ @synthesize image; @synthesize imageID; -- (id)initWithURL:(NSURL *)theURL +- (id)initWithURL: (NSURL *)theURL + withTitle: (NSString *)theTitle + withDate: (NSDate *)theDate { [super init]; image = [theURL retain]; imageID = [[theURL absoluteString] retain]; + imageTitle = [theTitle retain]; + imageDate = [theDate retain]; return self; } @@ -24,9 +30,13 @@ { [image release]; [imageID release]; + [imageTitle release]; + [imageDate release]; [super dealloc]; } +#pragma mark +#pragma mark Required methods - (NSString *)imageUID { return imageID; @@ -41,4 +51,17 @@ { return image; } + +#pragma mark +#pragma mark Optional methods. +- (NSString *)imageTitle +{ + return imageTitle; +} + +- (NSString *)imageSubtitle +{ + return [imageDate description]; +} + @end diff --git a/iPhoto2Ansel/English.lproj/Panel.nib/designable.nib b/iPhoto2Ansel/English.lproj/Panel.nib/designable.nib index 939e60ff0..10fc594cc 100644 --- a/iPhoto2Ansel/English.lproj/Panel.nib/designable.nib +++ b/iPhoto2Ansel/English.lproj/Panel.nib/designable.nib @@ -9,6 +9,7 @@ YES + YES @@ -581,7 +582,7 @@ {3.40282e+38, 3.40282e+38} - + 256 YES @@ -740,9 +741,9 @@ {423, 251} NO - NO - NO - NO + YES + YES + YES YES NO NO @@ -754,6 +755,7 @@ {{1, 1}, {423, 251}} + 6 @@ -781,6 +783,7 @@ {{20, 60}, {440, 268}} + 50 @@ -789,6 +792,7 @@ {480, 327} + {{0, 0}, {1920, 1178}} {3.40282e+38, 3.40282e+38} diff --git a/iPhoto2Ansel/English.lproj/Panel.nib/keyedobjects.nib b/iPhoto2Ansel/English.lproj/Panel.nib/keyedobjects.nib index 5be88d567..b3a9b2472 100644 Binary files a/iPhoto2Ansel/English.lproj/Panel.nib/keyedobjects.nib and b/iPhoto2Ansel/English.lproj/Panel.nib/keyedobjects.nib differ