From: Michael J. Rubinsky Date: Sun, 7 Dec 2008 19:22:48 +0000 (-0500) Subject: First stab at using a seperate sheet for creating a new gallery. X-Git-Url: https://git.internetallee.de/?a=commitdiff_plain;h=3260ecf75bf539df5946d1523f5e84478be20b46;p=horde.git First stab at using a seperate sheet for creating a new gallery. Once this is hashed out and prettied up, the same will be done with the connection parameters, and the ability to add/remember multiple ansel servers will be included. --- diff --git a/iPhoto2Ansel/AnselExportController.h b/iPhoto2Ansel/AnselExportController.h index 85df06eff..92f8abdcd 100644 --- a/iPhoto2Ansel/AnselExportController.h +++ b/iPhoto2Ansel/AnselExportController.h @@ -11,6 +11,7 @@ @class TURAnsel, TURAnselGallery; @class FBProgressController; +@class TURNewGalleryController; @interface AnselExportController : NSObject { @@ -29,20 +30,29 @@ IBOutlet NSSecureTextField *password; IBOutlet NSComboBox *galleryCombo; IBOutlet NSTextField *connectedLabel; - IBOutlet NSTextField *newGalleryName; IBOutlet NSButton *beginButton; IBOutlet NSButton *newGalleryButton; IBOutlet NSProgressIndicator *spinner; + IBOutlet NSWindow *newGallerySheet; + + // New Gallery Panel + IBOutlet NSTextField *galleryNameTextField; + IBOutlet NSTextField *gallerySlugTextField; + IBOutlet NSTextField *galleryDescTextField; + // User choosen settings int size; - int quality; - + // Progress struct (This one is part of the protocol, but we don't use it) ExportPluginProgress progress; // This is our real progress controller (stolen from Facebook exporter). FBProgressController *progressController; + // New Gallery dialog controller (Can't get this to work with the modal + // iPhoto plugin interface??) + //TURNewGalleryController *newGalleryController; + // Mutex lock (required for the protocol, but not used) NSRecursiveLock *progressLock; @@ -54,11 +64,15 @@ } @property (readwrite, retain) TURAnselGallery *currentGallery; @property (readwrite) int size; -@property (readwrite) int quality; +// Getter/setter - (NSWindow *)window; + +// Actions - (IBAction) doConnect: (id)sender; - (IBAction) doNewGallery: (id)sender; +- (IBAction) showNewGallery: (id)sender; +- (IBAction) cancelNewGallery: (id)sender; // overrides - (void)awakeFromNib; diff --git a/iPhoto2Ansel/AnselExportController.m b/iPhoto2Ansel/AnselExportController.m index fe482c181..31d899042 100644 --- a/iPhoto2Ansel/AnselExportController.m +++ b/iPhoto2Ansel/AnselExportController.m @@ -5,9 +5,10 @@ // Created by Michael Rubinsky on 10/23/08. // Copyright 2008 __MyCompanyName__. All rights reserved. // -#import "TURAnsel.h" -#import "TURAnselGallery.h" -#import "AnselExportController.h" +#import "TURAnsel.h"; +#import "TURAnselGallery.h"; +#import "TURNewGalleryController.h"; +#import "AnselExportController.h"; #import "FBProgressController.h"; #import "ImageResizer.h"; @@ -23,7 +24,6 @@ @implementation AnselExportController @synthesize size; -@synthesize quality; @synthesize currentGallery; #pragma mark Overrides @@ -77,18 +77,43 @@ } -//TODO --(void)doNewGallery: (id)sender +// Start the process of creating a new gallery. This is called from an action +// from the newGallerySheet NSPanel. +- (void)doNewGallery: (id)sender +{ + [NSApplication detachDrawingThread: @selector(newGallery) + toTarget: self + withObject:nil]; +} + +// Put up the newGallerySheet NSPanel +- (IBAction)showNewGallery: (id)sender { // Make sure we're not doing this for nothing - if ([anselController state] == TURAnselStateConnected && - [[newGalleryName stringValue] length] > 0) { - [NSApplication detachDrawingThread: @selector(newGallery:) - toTarget: self - withObject: [newGalleryName stringValue]]; + if ([anselController state] == TURAnselStateConnected) { + + if (!newGallerySheet) { + + [NSBundle loadNibNamed: @"AnselGalleryPanel" + owner: self]; + + [galleryNameTextField setStringValue:@"Untitled"]; + } + + [NSApp beginSheet: newGallerySheet + modalForWindow: [self window] + modalDelegate: self + didEndSelector: @selector(sheetDidEnd:returnCode:contextInfo:) + contextInfo: self]; } } +- (IBAction)cancelNewGallery: (id)sender +{ + [NSApp endSheet: newGallerySheet]; + [newGallerySheet orderOut: nil]; +} + #pragma mark ExportPluginProtocol // Initialize - (id)initWithExportImageObj:(id )obj @@ -204,6 +229,51 @@ #pragma mark PrivateAPI +- (void)newGallery +{ + // Get Gallery Properties from the panel. + NSString *galleryName = [galleryNameTextField stringValue]; + NSString *gallerySlug = [gallerySlugTextField stringValue]; + NSString *galleryDescription = [galleryDescTextField stringValue]; + + if (!galleryName) { + NSAlert *alert = [[NSAlert alloc] init]; + [alert setMessageText:@"Gallery names cannot be empty"]; + [alert setAlertStyle: NSCriticalAlertStyle]; + [alert beginSheetModalForWindow: [self window] + modalDelegate: nil + didEndSelector: nil + contextInfo: nil]; + [alert release]; + return; + } + NSDictionary *params = [NSDictionary dictionaryWithObjectsAndKeys: + galleryName, @"name", + gallerySlug, @"slug", + galleryDescription, @"desc", nil]; + + NSDictionary *results = [[anselController createNewGallery: params] retain]; + + [NSApp endSheet: newGallerySheet]; + [newGallerySheet orderOut: nil]; + + if ([anselController state] != TURAnselStateError) { + NSAlert *alert = [[NSAlert alloc] init]; + [alert setMessageText: @"Gallery successfully created."]; + [alert beginSheetModalForWindow: [self window] + modalDelegate: nil + didEndSelector: nil + contextInfo: nil]; + + // Reload the NSComboBox and autoselect the last item. + [galleryCombo reloadData]; + [galleryCombo selectItemAtIndex: [galleryCombo numberOfItems] - 1]; + [alert release]; + } + + [results release]; +} + // See if we have everything we need to export... - (void)canExport { @@ -248,29 +318,6 @@ toTarget: self withObject: nil]; } - -// Create a new gallery on the Horde server -// TODO -- (void)newGallery: (NSString *)galleryName -{ - NSDictionary *results = [[anselController createNewGallery: [NSDictionary dictionaryWithObjectsAndKeys: galleryName, @"name", nil]] retain]; - - if ([anselController state] != TURAnselStateError) { - NSAlert *alert = [[NSAlert alloc] init]; - [alert setMessageText: @"Gallery successfully created."]; - [alert beginSheetModalForWindow: [self window] - modalDelegate: nil - didEndSelector: nil - contextInfo: nil]; - - // Reload the NSComboBox and autoselect the last item. - [galleryCombo reloadData]; - [galleryCombo selectItemAtIndex: [galleryCombo numberOfItems] - 1]; - [alert release]; - } - - [results release]; -} // Runs the actual export (This is run in it's own thread) - (void) runExport @@ -440,4 +487,9 @@ [currentGallery setDelegate: self]; [self canExport]; } + +- (void)sheetDidEnd:(NSWindow *)sheet returnCode:(int)returnCode contextInfo:(void *)contextInfo; +{ + NSLog(@"sheetDidEnd"); +} @end \ No newline at end of file diff --git a/iPhoto2Ansel/English.lproj/AnselGalleryPanel.nib/designable.nib b/iPhoto2Ansel/English.lproj/AnselGalleryPanel.nib/designable.nib new file mode 100644 index 000000000..52a258676 --- /dev/null +++ b/iPhoto2Ansel/English.lproj/AnselGalleryPanel.nib/designable.nib @@ -0,0 +1,776 @@ + + + + 1050 + 9F33 + 672 + 949.34 + 352.00 + + YES + + + + YES + com.apple.InterfaceBuilder.CocoaPlugin + + + YES + + AnselExportController + + + FirstResponder + + + NSApplication + + + 19 + 2 + {{797, 724}, {267, 276}} + -536866816 + New Gallery + NSPanel + + {3.40282e+38, 3.40282e+38} + + + 256 + + YES + + + 268 + {{20, 219}, {227, 22}} + + YES + + -1804468671 + 272630784 + + + LucidaGrande + 1.300000e+01 + 1044 + + + YES + + 6 + System + textBackgroundColor + + 3 + MQA + + + + 6 + System + textColor + + 3 + MAA + + + + + + + 268 + {{17, 240}, {88, 16}} + + YES + + 68288064 + 272630784 + Gallery Name + + LucidaGrande + 1.200000e+01 + 16 + + + + 6 + System + controlColor + + 3 + MC42NjY2NjY2OQA + + + + 6 + System + controlTextColor + + + + + + + 268 + {{17, 195}, {73, 16}} + + YES + + 68288064 + 272630784 + Gallery Slug + + + + + + + + + 268 + {{20, 174}, {227, 22}} + + YES + + -1804468671 + 272630784 + + + + YES + + + + + + + 268 + {{20, 103}, {227, 47}} + + YES + + -1805517311 + 272629760 + + + + YES + + + + + + + 268 + {{17, 150}, {124, 16}} + + YES + + 68288064 + 272630784 + Gallery Description + + + + + + + + + 268 + {{116, 12}, {68, 32}} + + YES + + 67239424 + 134217728 + Cancel + + + -2038284033 + 129 + + + 200 + 25 + + + + + 268 + {{184, 12}, {69, 32}} + + YES + + 67239424 + 134217728 + Save + + + -2038284033 + 129 + + + 200 + 25 + + + + + 268 + {{20, 56}, {230, 26}} + + YES + + 879885888 + 272630784 + + + + YES + + + 5 + YES + + + + 274 + {15, 0} + + + YES + + YES + + + 1.200000e+01 + 1.000000e+01 + 1.000000e+03 + + 75628032 + 0 + + + + 3 + MC4zMzMzMzI5OQA + + + + + 338820672 + 1024 + + + YES + + 6 + System + controlBackgroundColor + + + + + 3 + YES + + + + 3.000000e+00 + 2.000000e+00 + + + 6 + System + gridColor + + 3 + MC41AA + + + 1.900000e+01 + tableViewAction: + -767524864 + + + + 1 + 15 + 0 + YES + + + + + + 268 + {{17, 79}, {88, 16}} + + YES + + 68288064 + 272630784 + Gallery Parent + + + + + + + + {267, 276} + + + {{0, 0}, {1920, 1178}} + {3.40282e+38, 3.40282e+38} + + + + + YES + + + gallerySlugTextField + + + + 38 + + + + galleryParentCombo + + + + 39 + + + + galleryNameTextField + + + + 40 + + + + galleryDescTextField + + + + 41 + + + + newGallerySheet + + + + 43 + + + + doNewGallery: + + + + 46 + + + + cancelNewGallery: + + + + 47 + + + + + YES + + 0 + + YES + + + + + + -2 + + + RmlsZSdzIE93bmVyA + + + -1 + + + First Responder + + + -3 + + + Application + + + 1 + + + YES + + + + + + 2 + + + YES + + + + + + + + + + + + + + + 3 + + + YES + + + + + + 4 + + + + + 5 + + + YES + + + + + + 6 + + + + + 7 + + + YES + + + + + + 8 + + + + + 9 + + + YES + + + + + + 10 + + + + + 11 + + + YES + + + + + + 12 + + + + + 13 + + + YES + + + + + + 14 + + + + + 15 + + + YES + + + + + + 16 + + + + + 17 + + + YES + + + + + + 18 + + + + + 19 + + + YES + + + + + + 20 + + + + + 21 + + + YES + + + + + + 22 + + + + + + + YES + + YES + -1.IBPluginDependency + -2.IBPluginDependency + -3.IBPluginDependency + 1.IBEditorWindowLastContentRect + 1.IBPluginDependency + 1.IBWindowTemplateEditedContentRect + 1.NSWindowTemplate.visibleAtLaunch + 1.WindowOrigin + 1.editorWindowContentRectSynchronizationRect + 10.IBPluginDependency + 11.IBPluginDependency + 12.IBPluginDependency + 13.IBPluginDependency + 14.IBPluginDependency + 15.IBPluginDependency + 16.IBPluginDependency + 17.IBPluginDependency + 18.IBPluginDependency + 19.IBPluginDependency + 2.IBPluginDependency + 20.IBPluginDependency + 21.IBPluginDependency + 22.IBPluginDependency + 3.IBPluginDependency + 4.IBPluginDependency + 5.IBPluginDependency + 6.IBPluginDependency + 7.IBPluginDependency + 8.IBPluginDependency + 9.IBPluginDependency + + + YES + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + {{177, 722}, {267, 276}} + com.apple.InterfaceBuilder.CocoaPlugin + {{177, 722}, {267, 276}} + + {196, 240} + {{357, 418}, {480, 270}} + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + + + + YES + + YES + + + YES + + + + + YES + + YES + + + YES + + + + 47 + + + + YES + + AnselExportController + NSObject + + YES + + YES + cancelNewGallery: + doConnect: + doNewGallery: + showNewGallery: + + + YES + id + id + id + id + + + + YES + + YES + anselHostURL + beginButton + connectedLabel + firstView + galleryCombo + galleryDescTextField + galleryNameTextField + gallerySlugTextField + mExportMgr + mQualityPopUp + mSettingsBox + mSizePopUp + newGalleryButton + newGallerySheet + password + spinner + username + + + YES + NSTextField + NSButton + NSTextField + NSControl + NSComboBox + NSTextField + NSTextField + NSTextField + id + NSPopUpButton + NSBox + NSPopUpButton + NSButton + NSWindow + NSSecureTextField + NSProgressIndicator + NSTextField + + + + IBProjectSource + AnselExportController.h + + + + NSObject + + IBProjectSource + TURAnsel.h + + + + NSObject + + IBProjectSource + TURAnselGallery.h + + + + NSObject + + IBProjectSource + xmlrpc-1.5.1/XMLRPCConnection.h + + + + + 0 + ../iPhoto2Ansel.xcodeproj + 3 + + diff --git a/iPhoto2Ansel/English.lproj/AnselGalleryPanel.nib/keyedobjects.nib b/iPhoto2Ansel/English.lproj/AnselGalleryPanel.nib/keyedobjects.nib new file mode 100644 index 000000000..c850b23d8 Binary files /dev/null and b/iPhoto2Ansel/English.lproj/AnselGalleryPanel.nib/keyedobjects.nib differ diff --git a/iPhoto2Ansel/English.lproj/Panel.nib/classes.nib b/iPhoto2Ansel/English.lproj/Panel.nib/classes.nib index 624a92e28..f670f8ea0 100644 --- a/iPhoto2Ansel/English.lproj/Panel.nib/classes.nib +++ b/iPhoto2Ansel/English.lproj/Panel.nib/classes.nib @@ -20,10 +20,14 @@ ACTIONS + cancelNewGallery + id doConnect id doNewGallery id + showNewGallery + id CLASS AnselExportController @@ -41,6 +45,12 @@ NSControl galleryCombo NSComboBox + galleryDescTextField + NSTextField + galleryNameTextField + NSTextField + gallerySlugTextField + NSTextField galleryTableView NSTableView mExportMgr @@ -51,10 +61,12 @@ NSBox mSizePopUp NSPopUpButton + newGallery + NSPanel newGalleryButton NSButton - newGalleryName - NSTextField + newGallerySheet + NSWindow password NSSecureTextField spinner diff --git a/iPhoto2Ansel/English.lproj/Panel.nib/info.nib b/iPhoto2Ansel/English.lproj/Panel.nib/info.nib index fb256c095..d55a3324a 100644 --- a/iPhoto2Ansel/English.lproj/Panel.nib/info.nib +++ b/iPhoto2Ansel/English.lproj/Panel.nib/info.nib @@ -10,7 +10,7 @@ 5 IBOpenObjects - 7 + 6 IBSystem Version 9F33 diff --git a/iPhoto2Ansel/English.lproj/Panel.nib/keyedobjects.nib b/iPhoto2Ansel/English.lproj/Panel.nib/keyedobjects.nib index 33b9caf10..df43ae910 100644 Binary files a/iPhoto2Ansel/English.lproj/Panel.nib/keyedobjects.nib and b/iPhoto2Ansel/English.lproj/Panel.nib/keyedobjects.nib differ diff --git a/iPhoto2Ansel/TURAnsel.m b/iPhoto2Ansel/TURAnsel.m index 8eba03968..7c11fbe74 100644 --- a/iPhoto2Ansel/TURAnsel.m +++ b/iPhoto2Ansel/TURAnsel.m @@ -86,10 +86,15 @@ static NSString *ERR_DOMAIN = @"com.theupstairsroom.TURAnsel"; // and default perms etc... - (NSDictionary *)createNewGallery: (NSDictionary *)params { - NSDictionary *attributes = [NSDictionary dictionaryWithObjectsAndKeys: - [params valueForKey: @"name"], @"name", nil]; + NSLog(@"Calling createNewGallery"); + NSMutableDictionary *attributes = [[NSMutableDictionary alloc] init]; +// [attributes setValue: [params valueForKey: @"name"] forKey: @"name"]; +// [attributes setValue: [params valueForKey: @"desc"] forKey: @"desc"]; +// [attributes setValue: [params valueForKey: @"slug"] forKey: @"slug"]; +// [attributes setValue: [params valueForKey + NSArray *apiparams = [NSArray arrayWithObjects: - @"ansel", attributes, nil]; + @"ansel", params, nil]; XMLRPCResponse *response = [self callRPCMethod: @"images.createGallery" withParams: apiparams]; if (state != TURAnselStateError) { @@ -102,6 +107,7 @@ static NSString *ERR_DOMAIN = @"com.theupstairsroom.TURAnsel"; TURAnselGallery *newGallery = [[TURAnselGallery alloc] initWithObject: results controller: self]; [galleryList addObject: newGallery]; + //[attributes release]; return results; } diff --git a/iPhoto2Ansel/iPhoto2Ansel.xcodeproj/project.pbxproj b/iPhoto2Ansel/iPhoto2Ansel.xcodeproj/project.pbxproj index a9cfafaaf..a525ad8cd 100644 --- a/iPhoto2Ansel/iPhoto2Ansel.xcodeproj/project.pbxproj +++ b/iPhoto2Ansel/iPhoto2Ansel.xcodeproj/project.pbxproj @@ -9,6 +9,7 @@ /* Begin PBXBuildFile section */ 8D5B49B0048680CD000E48DA /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = 089C167DFE841241C02AAC07 /* InfoPlist.strings */; }; 8D5B49B4048680CD000E48DA /* Cocoa.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1058C7ADFEA557BF11CA2CBB /* Cocoa.framework */; }; + B04FC1A90EEB4A2B008EEB0E /* AnselGalleryPanel.nib in Resources */ = {isa = PBXBuildFile; fileRef = B04FC1A70EEB4A2B008EEB0E /* AnselGalleryPanel.nib */; }; B05C4A060EE9E001005B4B28 /* ImageResizer.m in Sources */ = {isa = PBXBuildFile; fileRef = B05C4A050EE9E001005B4B28 /* ImageResizer.m */; }; B06C1E030EB1644600BFAFCB /* AnselExportPluginBox.m in Sources */ = {isa = PBXBuildFile; fileRef = B06C1E020EB1644600BFAFCB /* AnselExportPluginBox.m */; }; B06C1E060EB164D900BFAFCB /* AnselExportController.m in Sources */ = {isa = PBXBuildFile; fileRef = B06C1E050EB164D900BFAFCB /* AnselExportController.m */; }; @@ -73,6 +74,7 @@ 8D5B49B6048680CD000E48DA /* iPhoto2Ansel.iPhotoExporter */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = iPhoto2Ansel.iPhotoExporter; sourceTree = BUILT_PRODUCTS_DIR; }; 8D5B49B7048680CD000E48DA /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; B03D3B590ED5BB3800CF5B92 /* XMLRPC-Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = "XMLRPC-Info.plist"; sourceTree = SOURCE_ROOT; }; + B04FC1A80EEB4A2B008EEB0E /* English */ = {isa = PBXFileReference; lastKnownFileType = wrapper.nib; name = English; path = English.lproj/AnselGalleryPanel.nib; sourceTree = ""; }; B05C4A040EE9E001005B4B28 /* ImageResizer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ImageResizer.h; sourceTree = ""; }; B05C4A050EE9E001005B4B28 /* ImageResizer.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ImageResizer.m; sourceTree = ""; }; B06C1E010EB1644600BFAFCB /* AnselExportPluginBox.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AnselExportPluginBox.h; sourceTree = ""; }; @@ -146,6 +148,7 @@ 089C167CFE841241C02AAC07 /* Resources */, 089C1671FE841209C02AAC07 /* Frameworks and Libraries */, 19C28FB8FE9D52D311CA2CBB /* Products */, + B04FC1A70EEB4A2B008EEB0E /* AnselGalleryPanel.nib */, ); name = iPhoto2Ansel; sourceTree = ""; @@ -372,6 +375,7 @@ 8D5B49B0048680CD000E48DA /* InfoPlist.strings in Resources */, B06C1E3D0EB17E3700BFAFCB /* Panel.nib in Resources */, B0C888490ED85DEA000E19FB /* ProgressSheet.nib in Resources */, + B04FC1A90EEB4A2B008EEB0E /* AnselGalleryPanel.nib in Resources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -435,6 +439,14 @@ name = InfoPlist.strings; sourceTree = ""; }; + B04FC1A70EEB4A2B008EEB0E /* AnselGalleryPanel.nib */ = { + isa = PBXVariantGroup; + children = ( + B04FC1A80EEB4A2B008EEB0E /* English */, + ); + name = AnselGalleryPanel.nib; + sourceTree = ""; + }; B0BFBC870ED5B32B006581A5 /* Localizable.strings */ = { isa = PBXVariantGroup; children = (