From: Michael J. Rubinsky Date: Tue, 1 Sep 2009 16:21:52 +0000 (-0400) Subject: Port the remote gallery viewer from the iPhoto plugin. X-Git-Url: https://git.internetallee.de/?a=commitdiff_plain;h=2f2408b22724e136d0b76ecc20283dab4aff2295;p=horde.git Port the remote gallery viewer from the iPhoto plugin. --- diff --git a/ApertureToAnselExportPlugin/AnselGalleryViewItem.h b/ApertureToAnselExportPlugin/AnselGalleryViewItem.h new file mode 100644 index 000000000..068c07f07 --- /dev/null +++ b/ApertureToAnselExportPlugin/AnselGalleryViewItem.h @@ -0,0 +1,34 @@ +// +// AnselGalleryViewItem.h +// iPhoto2Ansel +// +// Created by Michael Rubinsky on 5/7/09. +// Copyright 2009 __MyCompanyName__. All rights reserved. +// +#import +#import + +@interface AnselGalleryViewItem: NSObject +{ + NSURL *image; + NSString *imageID; + NSString *imageTitle; + NSCalendarDate *imageDate; +} + +@property(readwrite,copy) NSURL * image; +@property(readwrite,copy) NSString * imageID; + +- (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 *)imageTitle; +- (NSString *)imageSubtitle; + +@end + diff --git a/ApertureToAnselExportPlugin/AnselGalleryViewItem.m b/ApertureToAnselExportPlugin/AnselGalleryViewItem.m new file mode 100644 index 000000000..e792d14dd --- /dev/null +++ b/ApertureToAnselExportPlugin/AnselGalleryViewItem.m @@ -0,0 +1,67 @@ +// +// AnselGalleryViewItem.m +// iPhoto2Ansel +// +// Implementation of the IKImageBrowserItem protocol + +// Created by Michael Rubinsky on 5/7/09. +// Copyright 2009 __MyCompanyName__. All rights reserved. +// + +#import "AnselGalleryViewItem.h" + +@implementation AnselGalleryViewItem +@synthesize image; +@synthesize imageID; + +- (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; +} + +- (void)dealloc +{ + [image release]; + [imageID release]; + [imageTitle release]; + [imageDate release]; + [super dealloc]; +} + +#pragma mark +#pragma mark Required methods +- (NSString *)imageUID +{ + return imageID; +} + +- (NSString *)imageRepresentationType +{ + return IKImageBrowserNSURLRepresentationType; +} + +- (id)imageRepresentation +{ + return [[image retain] autorelease]; +} + +#pragma mark +#pragma mark Optional methods. +- (NSString *)imageTitle +{ + return imageTitle; +} + +- (NSString *)imageSubtitle +{ + return [imageDate description]; +} + +@end diff --git a/ApertureToAnselExportPlugin/ApertureToAnselExportPlugin.h b/ApertureToAnselExportPlugin/ApertureToAnselExportPlugin.h index 91b91277b..96955aa18 100644 --- a/ApertureToAnselExportPlugin/ApertureToAnselExportPlugin.h +++ b/ApertureToAnselExportPlugin/ApertureToAnselExportPlugin.h @@ -8,7 +8,7 @@ #import #import -#import + #import "ApertureExportManager.h" #import "ApertureExportPlugIn.h" @@ -31,6 +31,10 @@ // The structure used to pass all progress information back to Aperture ApertureExportProgress exportProgress; + // TURAnsel objects + TURAnselGallery *_currentGallery; + TURAnsel *_anselController; + // Outlets to your plug-ins user interface IBOutlet NSView *settingsView; IBOutlet NSView *firstView; @@ -64,12 +68,11 @@ IBOutlet NSWindow *mviewGallerySheet; IBOutlet NSButton *closeGalleryView; IBOutlet IKImageBrowserView *browserView; + NSMutableArray *_browserData; + // Flags, counters etc... BOOL cancelExport; - TURAnselGallery *_currentGallery; int _currentImageCount; - TURAnsel *_anselController; - NSMutableArray *_browserData; BOOL isExporting; } diff --git a/ApertureToAnselExportPlugin/ApertureToAnselExportPlugin.m b/ApertureToAnselExportPlugin/ApertureToAnselExportPlugin.m index 1555f8bd2..4ba1b0b49 100644 --- a/ApertureToAnselExportPlugin/ApertureToAnselExportPlugin.m +++ b/ApertureToAnselExportPlugin/ApertureToAnselExportPlugin.m @@ -9,6 +9,8 @@ #import "ApertureToAnselExportPlugin.h" #import "TURAnsel.h" #import "TURAnselGallery.h" +#import "TURAnselGalleryPanelController.h" +#import "AnselGalleryViewItem.h" @interface ApertureToAnselExportPlugin (PrivateAPI) - (void)showNewServerSheet; @@ -479,10 +481,12 @@ NSString * const TURAnselServerPasswordKey = @"password"; } } } + +#pragma mark - +#pragma mark Actions // Server setup sheet -(IBAction)doAddServer: (id)sender { - // TODO: Sanity checks NSDictionary *newServer = [[NSDictionary alloc] initWithObjectsAndKeys: [mServerSheetServerNickName stringValue], TURAnselServerNickKey, [mServerSheetHostURL stringValue], TURAnselServerEndpointKey, @@ -537,6 +541,103 @@ NSString * const TURAnselServerPasswordKey = @"password"; } } +// Show the gallery's image browser +- (IBAction)clickViewGallery: (id)sender +{ + [spinner startAnimation: self]; + [self setStatusText: @"Getting image list..."]; + NSMutableArray *images = [_currentGallery listImages]; + if ([images count] == 0) { + [spinner stopAnimation: self]; + [self setStatusText: @"Connected" withColor: [NSColor greenColor]]; + return; + } + + for (NSDictionary *image in images) { + 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]; + } + + [NSApp beginSheet: mviewGallerySheet + modalForWindow: [self window] + modalDelegate: nil + didEndSelector: nil + contextInfo: nil]; + + [spinner stopAnimation: self]; + [self setStatusText: @"Connected" withColor: [NSColor greenColor]]; + + [browserView reloadData]; + +} + +- (IBAction) closeGalleryView: (id)sender +{ + [NSApp endSheet: mviewGallerySheet]; + [mviewGallerySheet orderOut: nil]; + [_browserData removeAllObjects]; + [browserView reloadData]; +} + +- (IBAction) closeServerList: (id)sender +{ + [serverTable setDelegate: nil]; + [NSApp endSheet: serverListPanel]; + [serverListPanel orderOut: nil]; +} + +// Remove the selected server from the saved list. +- (IBAction)removeServer: (id)sender +{ + NSTableColumn *theCol = [serverTable tableColumnWithIdentifier:@"nickname"]; + + // We are deleting the entry for the currently selected server - make sure + // we disconnect. + if ([_currentServer objectForKey:TURAnselServerNickKey] == [[theCol dataCell] stringValue]) { + [self disconnect]; + } + + NSUserDefaults *userPrefs = [NSUserDefaults standardUserDefaults]; + + // See if the removed server is the current default. + if ([[userPrefs objectForKey:TURAnselDefaultServerKey] objectForKey: TURAnselServerNickKey] == [[theCol dataCell] stringValue]) { + [userPrefs setObject: nil forKey:TURAnselDefaultServerKey]; + } + + // Remove it from the servers dictionary + [_anselServers removeObjectAtIndex: [serverTable selectedRow]]; + [userPrefs setObject:_anselServers forKey:TURAnselServersKey]; + + [userPrefs synchronize]; + [serverTable reloadData]; + [self updateServersPopupMenu]; +} + +// Put up the newGallerySheet NSPanel +- (IBAction)showNewGallery: (id)sender +{ + TURAnselGalleryPanelController *newGalleryController; + //NSString *albumName; + + // Make sure we're not doing this for nothing + if ([_anselController state] == TURAnselStateConnected) { + + //albumName = [mExportMgr albumNameAtIndex: 0]; + newGalleryController = [[TURAnselGalleryPanelController alloc] initWithController: _anselController + withGalleryName: nil]; + [newGalleryController setDelegate: self]; + [newGalleryController showSheetForWindow: [self window]]; + } +} + #pragma mark - #pragma mark PrivateAPI @@ -675,4 +776,16 @@ NSString * const TURAnselServerPasswordKey = @"password"; _anselController = nil; [self setStatusText:@"Not logged in" withColor: [NSColor redColor]]; } + +#pragma mark - +#pragma mark IKImageBrowserView Datasource methods +- (NSUInteger)numberOfItemsInImageBrowser:(IKImageBrowserView *) aBrowser +{ + return [_browserData count]; +} + +- (id)imageBrowser:(IKImageBrowserView *) aBrowser itemAtIndex:(NSUInteger)index +{ + return [_browserData objectAtIndex:index]; +} @end diff --git a/ApertureToAnselExportPlugin/ApertureToAnselExportPlugin.xcodeproj/project.pbxproj b/ApertureToAnselExportPlugin/ApertureToAnselExportPlugin.xcodeproj/project.pbxproj index 9804cc12e..f5592416e 100644 --- a/ApertureToAnselExportPlugin/ApertureToAnselExportPlugin.xcodeproj/project.pbxproj +++ b/ApertureToAnselExportPlugin/ApertureToAnselExportPlugin.xcodeproj/project.pbxproj @@ -3,7 +3,7 @@ archiveVersion = 1; classes = { }; - objectVersion = 42; + objectVersion = 45; objects = { /* Begin PBXBuildFile section */ @@ -45,6 +45,8 @@ B0D312691049AD7F006B06C6 /* README in Resources */ = {isa = PBXBuildFile; fileRef = B0D312171049A977006B06C6 /* README */; }; B0D3126A1049AD9A006B06C6 /* Localizable.strings in Resources */ = {isa = PBXBuildFile; fileRef = B0D312141049A977006B06C6 /* Localizable.strings */; }; B0D312A01049B26B006B06C6 /* XMLRPC.framework in CopyFiles */ = {isa = PBXBuildFile; fileRef = B0D312941049B24A006B06C6 /* XMLRPC.framework */; }; + B0DEA058104D7012001D1509 /* AnselGalleryViewItem.m in Sources */ = {isa = PBXBuildFile; fileRef = B0DEA057104D7012001D1509 /* AnselGalleryViewItem.m */; }; + B0DEA1CE104D7DE2001D1509 /* Quartz.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = B0DEA1CD104D7DE2001D1509 /* Quartz.framework */; }; D118EA660AC08CCB006DD2FE /* Localizable.strings in Resources */ = {isa = PBXBuildFile; fileRef = D118EA640AC08CCB006DD2FE /* Localizable.strings */; }; D15DEA4A0ABF639500CBE3A5 /* PluginManager.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = D15DEA490ABF639500CBE3A5 /* PluginManager.framework */; }; D15DEA4F0ABF63C600CBE3A5 /* ApertureToAnselExportPlugin.m in Sources */ = {isa = PBXBuildFile; fileRef = D15DEA4D0ABF63C600CBE3A5 /* ApertureToAnselExportPlugin.m */; }; @@ -116,6 +118,9 @@ B0D312311049A9F2006B06C6 /* XMLRPC-Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = "XMLRPC-Info.plist"; sourceTree = ""; }; B0D312391049AACC006B06C6 /* XMLRPC-Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = "XMLRPC-Info.plist"; sourceTree = ""; }; B0D312941049B24A006B06C6 /* XMLRPC.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = XMLRPC.framework; sourceTree = BUILT_PRODUCTS_DIR; }; + B0DEA056104D7012001D1509 /* AnselGalleryViewItem.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AnselGalleryViewItem.h; sourceTree = ""; }; + B0DEA057104D7012001D1509 /* AnselGalleryViewItem.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AnselGalleryViewItem.m; sourceTree = ""; }; + B0DEA1CD104D7DE2001D1509 /* Quartz.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Quartz.framework; path = /System/Library/Frameworks/Quartz.framework; sourceTree = ""; }; D118EA650AC08CCB006DD2FE /* English */ = {isa = PBXFileReference; fileEncoding = 10; lastKnownFileType = text.plist.strings; name = English; path = English.lproj/Localizable.strings; sourceTree = ""; }; D118EB0F0AC08EAE006DD2FE /* ApertureToAnselExportPlugin.ApertureExport */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = ApertureToAnselExportPlugin.ApertureExport; sourceTree = BUILT_PRODUCTS_DIR; }; D15DEA490ABF639500CBE3A5 /* PluginManager.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = PluginManager.framework; path = /Library/Frameworks/PluginManager.framework; sourceTree = ""; }; @@ -132,6 +137,7 @@ files = ( 8D5B49B4048680CD000E48DA /* Cocoa.framework in Frameworks */, D15DEA4A0ABF639500CBE3A5 /* PluginManager.framework in Frameworks */, + B0DEA1CE104D7DE2001D1509 /* Quartz.framework in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -186,6 +192,8 @@ 08FB77AFFE84173DC02AAC07 /* Classes */ = { isa = PBXGroup; children = ( + B0DEA056104D7012001D1509 /* AnselGalleryViewItem.h */, + B0DEA057104D7012001D1509 /* AnselGalleryViewItem.m */, D15DEA4E0ABF63C600CBE3A5 /* ApertureToAnselExportPlugin.h */, D15DEA4D0ABF63C600CBE3A5 /* ApertureToAnselExportPlugin.m */, ); @@ -195,6 +203,7 @@ 1058C7ACFEA557BF11CA2CBB /* Linked Frameworks */ = { isa = PBXGroup; children = ( + B0DEA1CD104D7DE2001D1509 /* Quartz.framework */, D15DEA490ABF639500CBE3A5 /* PluginManager.framework */, 1058C7ADFEA557BF11CA2CBB /* Cocoa.framework */, ); @@ -361,7 +370,7 @@ 089C1669FE841209C02AAC07 /* Project object */ = { isa = PBXProject; buildConfigurationList = 1DEB913E08733D840010E9CD /* Build configuration list for PBXProject "ApertureToAnselExportPlugin" */; - compatibilityVersion = "Xcode 2.4"; + compatibilityVersion = "Xcode 3.1"; hasScannedForEncodings = 1; mainGroup = 089C166AFE841209C02AAC07 /* MyApertureExportPlugIn */; productRefGroup = 089C166AFE841209C02AAC07 /* MyApertureExportPlugIn */; @@ -420,6 +429,7 @@ B0D3122D1049A977006B06C6 /* XMLRPCRequest.m in Sources */, B0D3122E1049A977006B06C6 /* XMLRPCResponse.m in Sources */, B0AE23391049F7770096565B /* TURAnselGalleryPanelController.m in Sources */, + B0DEA058104D7012001D1509 /* AnselGalleryViewItem.m in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -514,7 +524,7 @@ INFOPLIST_FILE = Info.plist; INSTALL_PATH = "/Users/mrubinsk/Library/Application Support/Aperture/Plug-Ins"; PRODUCT_NAME = ApertureToAnselExportPlugin; - SDKROOT = /Developer/SDKs/MacOSX10.5.sdk; + SDKROOT = macosx10.5; WRAPPER_EXTENSION = ApertureExport; ZERO_LINK = YES; }; @@ -546,7 +556,7 @@ GCC_WARN_ABOUT_RETURN_TYPE = YES; GCC_WARN_UNUSED_VARIABLE = YES; PREBINDING = NO; - SDKROOT = /Developer/SDKs/MacOSX10.4u.sdk; + SDKROOT = macosx10.4; }; name = Debug; }; @@ -561,7 +571,7 @@ GCC_WARN_ABOUT_RETURN_TYPE = YES; GCC_WARN_UNUSED_VARIABLE = YES; PREBINDING = NO; - SDKROOT = /Developer/SDKs/MacOSX10.4u.sdk; + SDKROOT = macosx10.4; }; name = Release; }; diff --git a/ApertureToAnselExportPlugin/English.lproj/ApertureToAnselExportPlugin.nib/info.nib b/ApertureToAnselExportPlugin/English.lproj/ApertureToAnselExportPlugin.nib/info.nib index e2ca72e43..dba68c5db 100644 --- a/ApertureToAnselExportPlugin/English.lproj/ApertureToAnselExportPlugin.nib/info.nib +++ b/ApertureToAnselExportPlugin/English.lproj/ApertureToAnselExportPlugin.nib/info.nib @@ -11,6 +11,7 @@ IBOpenObjects 63 + 176 IBSystem Version 9L30 diff --git a/ApertureToAnselExportPlugin/English.lproj/ApertureToAnselExportPlugin.nib/keyedobjects.nib b/ApertureToAnselExportPlugin/English.lproj/ApertureToAnselExportPlugin.nib/keyedobjects.nib index 796131938..b6e847895 100644 Binary files a/ApertureToAnselExportPlugin/English.lproj/ApertureToAnselExportPlugin.nib/keyedobjects.nib and b/ApertureToAnselExportPlugin/English.lproj/ApertureToAnselExportPlugin.nib/keyedobjects.nib differ