Revision: 11904
http://bibdesk.svn.sourceforge.net/bibdesk/?rev=11904&view=rev
Author: amaxwell
Date: 2007-12-13 13:40:07 -0800 (Thu, 13 Dec 2007)
Log Message:
-----------
Use WebView to get URL and title from the pasteboard when dropping on the main
window. Set type to webpage and set lastchecked date.
Modified Paths:
--------------
trunk/bibdesk/BibDocument.h
trunk/bibdesk/BibDocument.m
Modified: trunk/bibdesk/BibDocument.h
===================================================================
--- trunk/bibdesk/BibDocument.h 2007-12-13 19:44:53 UTC (rev 11903)
+++ trunk/bibdesk/BibDocument.h 2007-12-13 21:40:07 UTC (rev 11904)
@@ -388,7 +388,7 @@
- (NSArray *)newPublicationsForString:(NSString *)string type:(int)type
verbose:(BOOL)verbose error:(NSError **)error;
- (NSArray *)newPublicationsForFiles:(NSArray *)filenames error:(NSError
**)error;
- (NSArray *)extractPublicationsFromFiles:(NSArray *)filenames
unparseableFiles:(NSMutableArray *)unparseableFiles verbose:(BOOL)verbose
error:(NSError **)error;
-- (NSArray *)newPublicationForURL:(NSURL *)url error:(NSError **)error;
+- (NSArray *)newPublicationForURLFromPasteboard:(NSPasteboard *)pboard
error:(NSError **)error;
// Private methods
Modified: trunk/bibdesk/BibDocument.m
===================================================================
--- trunk/bibdesk/BibDocument.m 2007-12-13 19:44:53 UTC (rev 11903)
+++ trunk/bibdesk/BibDocument.m 2007-12-13 21:40:07 UTC (rev 11904)
@@ -120,6 +120,7 @@
#import "PDFDocument_BDSKExtensions.h"
#import <FileView/FileView.h>
#import "BDSKLinkedFile.h"
+#import "NSDate_BDSKExtensions.h"
// these are the same as in Info.plist
NSString *BDSKBibTeXDocumentType = @"BibTeX Database";
@@ -1922,13 +1923,13 @@
if([pbURL isFileURL])
newPubs = newFilePubs = [self newPublicationsForFiles:[NSArray
arrayWithObject:[pbURL path]] error:&error];
else
- newPubs = [self newPublicationForURL:pbURL error:&error];
+ newPubs = [self newPublicationForURLFromPasteboard:pb
error:&error];
}else if([type isEqualToString:NSURLPboardType]){
NSURL *pbURL = [NSURL URLFromPasteboard:pb];
if([pbURL isFileURL])
newPubs = newFilePubs = [self newPublicationsForFiles:[NSArray
arrayWithObject:[pbURL path]] error:&error];
else
- newPubs = [self newPublicationForURL:pbURL error:&error];
+ newPubs = [self newPublicationForURLFromPasteboard:pb
error:&error];
}else{
// errors are key, value
OFErrorWithInfo(&error, kBDSKParserFailed, NSLocalizedDescriptionKey,
NSLocalizedString(@"Did not find anything appropriate on the pasteboard",
@"Error description"), nil);
@@ -2170,17 +2171,26 @@
return newPubs;
}
-- (NSArray *)newPublicationForURL:(NSURL *)url error:(NSError **)error {
- if(url == nil){
+- (NSArray *)newPublicationForURLFromPasteboard:(NSPasteboard *)pboard
error:(NSError **)error {
+
+ NSMutableArray *pubs = nil;
+
+ NSURL *theURL = [WebView URLFromPasteboard:pboard];
+ if (theURL) {
+ BibItem *newBI = [[[BibItem alloc] init] autorelease];
+ pubs = [NSMutableArray array];
+ [newBI addFileForURL:theURL autoFile:NO];
+ [newBI setPubType:@"webpage"];
+ [newBI setField:@"Lastchecked" toValue:[[NSCalendarDate date]
dateDescription]];
+ NSString *title = [WebView URLTitleFromPasteboard:pboard];
+ if (title)
+ [newBI setField:BDSKTitleString toValue:title];
+ [pubs addObject:newBI];
+ } else {
OFErrorWithInfo(error, kBDSKParserFailed, NSLocalizedDescriptionKey,
NSLocalizedString(@"Did not find expected URL on the pasteboard", @"Error
description"), nil);
- return nil;
}
- BibItem *newBI = [[[BibItem alloc] init] autorelease];
-
- [newBI addFileForURL:url autoFile:NO];
-
- return [NSArray arrayWithObject:newBI];
+ return pubs;
}
#pragma mark -
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
-------------------------------------------------------------------------
SF.Net email is sponsored by:
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services
for just about anything Open Source.
http://ad.doubleclick.net/clk;164216239;13503038;w?http://sf.net/marketplace
_______________________________________________
Bibdesk-commit mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/bibdesk-commit