Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

added README and LICENSE, but also fixed drop-on-app-icon

  • Loading branch information...
commit 156289e874e2f3fc34478d4b8567bbf69c77cb7c 1 parent 95fa9f7
@rsms authored
View
6 English.lproj/MainMenu.xib
@@ -12,7 +12,7 @@
</object>
<object class="NSMutableArray" key="IBDocument.EditedObjectIDs">
<bool key="EncodedWithXMLCoder">YES</bool>
- <integer value="491"/>
+ <integer value="57"/>
<integer value="371"/>
</object>
<object class="NSArray" key="IBDocument.PluginDependencies">
@@ -78,7 +78,7 @@
</object>
<object class="NSMenuItem" id="609285721">
<reference key="NSMenu" ref="110575045"/>
- <string key="NSTitle">Authorize with Flickr...</string>
+ <string key="NSTitle">Authenticate with Flickr</string>
<string key="NSKeyEquiv"/>
<int key="NSMnemonicLoc">2147483647</int>
<reference key="NSOnImage" ref="35465992"/>
@@ -2700,7 +2700,7 @@
<object class="NSAffineTransform">
<bytes key="NSTransformStruct">P4AAAL+AAABDHgAAw5oAAA</bytes>
</object>
- <string>{{392, 653}, {244, 183}}</string>
+ <string>{{392, 653}, {265, 183}}</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<integer value="1"/>
<string>{{23, 794}, {245, 183}}</string>
View
37 Info.plist
@@ -41,5 +41,42 @@
</array>
</dict>
</array>
+ <key>CFBundleDocumentTypes</key>
+ <array>
+ <dict>
+ <key>CFBundleTypeExtensions</key><array>
+ <string>jpg</string>
+ <string>jpeg</string>
+ <string>jpg2</string>
+ </array><key>CFBundleTypeRole</key><string>Viewer</string>
+ </dict>
+ <dict>
+ <key>CFBundleTypeExtensions</key><array>
+ <string>gif</string>
+ </array><key>CFBundleTypeRole</key><string>Viewer</string>
+ </dict>
+ <dict>
+ <key>CFBundleTypeExtensions</key><array>
+ <string>png</string>
+ </array><key>CFBundleTypeRole</key><string>Viewer</string>
+ </dict>
+ <dict>
+ <key>CFBundleTypeExtensions</key><array>
+ <string>tif</string>
+ <string>tiff</string>
+ </array><key>CFBundleTypeRole</key><string>Viewer</string>
+ </dict>
+ <dict>
+ <key>CFBundleTypeExtensions</key><array>
+ <string>bmp</string>
+ <string>bm</string>
+ </array><key>CFBundleTypeRole</key><string>Viewer</string>
+ </dict>
+ <dict>
+ <key>CFBundleTypeExtensions</key><array>
+ <string>psd</string>
+ </array><key>CFBundleTypeRole</key><string>Viewer</string>
+ </dict>
+ </array>
</dict>
</plist>
View
2  src/AppDelegate.h
@@ -9,6 +9,8 @@
NSString *flickrUserName_;
NSString *lastUploadedTitle_;
NSString *lastUploadedId_;
+ BOOL applicationDidFinishLaunching_;
+ BOOL shouldTerminateWhenDone_;
IBOutlet NSProgressIndicator *progressIndicator_;
IBOutlet HImageView *imageDropView_;
IBOutlet NSTextView *textView_;
View
32 src/AppDelegate.m
@@ -86,6 +86,7 @@ - (void)applicationDidFinishLaunching:(NSNotification *)aNotification {
if (authToken) {
flickrContext_.authToken = authToken;
}
+ applicationDidFinishLaunching_ = YES;
}
@@ -99,9 +100,9 @@ - (IBAction)authorizeFlickr:(id)sender {
- (IBAction)uploadImage:(id)sender {
// todo: check if authorized
- NSImage *image = imageDropView_.image;
+ //NSImage *image = imageDropView_.image;
NSURL *imageURL = imageDropView_.url;
- NSLog(@"%@ %@ -- %@", NSStringFromSelector(_cmd), image, imageURL);
+ //NSLog(@"%@ %@ -- %@", NSStringFromSelector(_cmd), image, imageURL);
// filename
NSString *filename = [imageURL lastPathComponent];
@@ -151,6 +152,22 @@ - (IBAction)uploadImage:(id)sender {
suggestedFilename:filename
MIMEType:mimeType
arguments:params];
+ NSLog(@"uploading %@...", imageURL);
+}
+
+
+- (void)application:(NSApplication *)sender openFiles:(NSArray *)filenames {
+ NSLog(@"openFiles:%@", filenames);
+ if (filenames.count > 1) {
+ [self presentErrorMessage:@"Flup can only handle one image at the time. "
+ "Please drop single images on me. I like that."];
+ return;
+ }
+ shouldTerminateWhenDone_ = !applicationDidFinishLaunching_;
+ if (filenames.count != 0) {
+ imageDropView_.url = [NSURL fileURLWithPath:[filenames objectAtIndex:0]];
+ [self uploadImage:self];
+ }
}
@@ -173,6 +190,7 @@ - (void)flickrAPIRequest:(OFFlickrAPIRequest *)req
[req callAPIMethodWithGET:@"flickr.photos.getSizes"
arguments:[NSDictionary dictionaryWithObjectsAndKeys:
photoId, @"photo_id", nil]];
+ NSLog(@"fetching URLs for [%@] %@...", photoId, imageDropView_.url);
return;
} else if (req.sessionInfo == kGetImageSizesStep) {
NSArray *imageSizes = [params valueForKeyPath:@"sizes.size"];
@@ -227,6 +245,10 @@ - (void)flickrAPIRequest:(OFFlickrAPIRequest *)req
[pb clearContents];
[pb setString:sourceURLString forType:NSURLPboardType];
[pb setString:stringRep forType:NSStringPboardType];
+
+ // terminate?
+ if (shouldTerminateWhenDone_)
+ [NSApp terminate:self];
}
[progressIndicator_ stopAnimation:self];
[imageDropView_ setEditable:YES];
@@ -236,7 +258,8 @@ - (void)flickrAPIRequest:(OFFlickrAPIRequest *)req
- (void)flickrAPIRequest:(OFFlickrAPIRequest *)req
- didFailWithError:(NSError *)inError {
+ didFailWithError:(NSError *)error {
+ NSLog(@"Flickr API request failed: (%@) %@", req, error);
NSString *msg = @"Unspecified Flickr API error";
if (req.sessionInfo == kGetAuthTokenStep) {
msg = @"Failed to receive authentication token from Flickr";
@@ -246,6 +269,9 @@ - (void)flickrAPIRequest:(OFFlickrAPIRequest *)req
} else if (req.sessionInfo == kUploadImageStep) {
msg = @"Failed to upload image";
}
+ if (error) {
+ msg = [msg stringByAppendingFormat:@" -- %@", error];
+ }
[progressIndicator_ stopAnimation:self];
[imageDropView_ setEditable:YES];
[imageDropView_ setEnabled:YES];
View
2  src/HImageView.m
@@ -48,7 +48,7 @@ - (NSURL*)url {
return url_;
}
-- (void)setURL:(NSURL*)url {
+- (void)setUrl:(NSURL*)url {
[self setImage:nil];
if (url) {
NSImage *image = [[[NSImage alloc] initWithContentsOfURL:url] autorelease];
Please sign in to comment.
Something went wrong with that request. Please try again.