Revision: 15160
          http://bibdesk.svn.sourceforge.net/bibdesk/?rev=15160&view=rev
Author:   hofman
Date:     2009-04-22 23:49:13 +0000 (Wed, 22 Apr 2009)

Log Message:
-----------
Just check whether a drop contains URLs and avoid getting them during updates

Modified Paths:
--------------
    trunk/bibdesk_vendorsrc/amaxwell/FileView/FVFileView.h
    trunk/bibdesk_vendorsrc/amaxwell/FileView/FVFileView.m
    trunk/bibdesk_vendorsrc/amaxwell/FileView/FVUtilities.h
    trunk/bibdesk_vendorsrc/amaxwell/FileView/FVUtilities.m

Modified: trunk/bibdesk_vendorsrc/amaxwell/FileView/FVFileView.h
===================================================================
--- trunk/bibdesk_vendorsrc/amaxwell/FileView/FVFileView.h      2009-04-22 
23:20:40 UTC (rev 15159)
+++ trunk/bibdesk_vendorsrc/amaxwell/FileView/FVFileView.h      2009-04-22 
23:49:13 UTC (rev 15160)
@@ -408,12 +408,11 @@
  
  @param aFileView The requesting view
  @param info The dragging info for the drop
- @param draggedURLs The URLs on the pasteboard for the drop
  @param proposedIndex The proposedindex for the drop
  @param proposedDropOperation The proposed drop operation for the drop
  @param proposedDragOperation The propsed drag operation for the drop; this 
will be returned when this method is not implemented.
  */
-- (NSDragOperation)fileView:(FVFileView *)aFileView validateDrop:(id 
<NSDraggingInfo>)info draggedURLs:(NSArray *)draggedURLs 
proposedIndex:(NSUInteger)anIndex 
proposedDropOperation:(FVDropOperation)dropOperation 
proposedDragOperation:(NSDragOperation)dragOperation;
+- (NSDragOperation)fileView:(FVFileView *)aFileView validateDrop:(id 
<NSDraggingInfo>)info proposedIndex:(NSUInteger)anIndex 
proposedDropOperation:(FVDropOperation)dropOperation 
proposedDragOperation:(NSDragOperation)dragOperation;
 
 @end
 

Modified: trunk/bibdesk_vendorsrc/amaxwell/FileView/FVFileView.m
===================================================================
--- trunk/bibdesk_vendorsrc/amaxwell/FileView/FVFileView.m      2009-04-22 
23:20:40 UTC (rev 15159)
+++ trunk/bibdesk_vendorsrc/amaxwell/FileView/FVFileView.m      2009-04-22 
23:49:13 UTC (rev 15160)
@@ -2291,7 +2291,7 @@
     NSUInteger insertIndex, firstIndex, endIndex;
     
     // !!! this is quite expensive to call repeatedly in -draggingUpdated
-    NSArray *draggedURLs = FVURLsFromPasteboard([sender draggingPasteboard]);
+    BOOL hasURLs = FVPasteboardHasURL([sender draggingPasteboard]);
     
     // First determine the drop location, check whether the index is not 
NSNotFound, because the grid cell can be empty
     if ([self _getGridRow:&r column:&c atPoint:p] && NSNotFound != (_dropIndex 
= [self _indexForGridRow:r column:c])) {
@@ -2316,7 +2316,7 @@
     
     // We won't reset the drop location info when we propose 
NSDragOperationNone, because the delegate may want to override our decision, we 
will reset it at the end
     
-    if ([draggedURLs count] == 0) {
+    if (hasURLs == NO) {
         // We have to make sure the pasteboard really has a URL here, since 
most NSStrings aren't valid URLs, but the delegate may accept other types
         dragOp = NSDragOperationNone;
     }
@@ -2344,8 +2344,8 @@
     }
     
     // we could allow the delegate to change the _dropIndex and _dropOperation 
as NSTableView does, but we don't use that at present
-    if ([[self delegate] 
respondsToSelector:@selector(fileView:validateDrop:draggedURLs:proposedIndex:proposedDropOperation:proposedDragOperation:)])
-        dragOp = [[self delegate] fileView:self validateDrop:sender 
draggedURLs:draggedURLs proposedIndex:_dropIndex 
proposedDropOperation:_dropOperation proposedDragOperation:dragOp];
+    if ([[self delegate] 
respondsToSelector:@selector(fileView:validateDrop:proposedIndex:proposedDropOperation:proposedDragOperation:)])
+        dragOp = [[self delegate] fileView:self validateDrop:sender 
proposedIndex:_dropIndex proposedDropOperation:_dropOperation 
proposedDragOperation:dragOp];
     
     // make sure we're consistent, also see comment above
     if (dragOp == NSDragOperationNone) {

Modified: trunk/bibdesk_vendorsrc/amaxwell/FileView/FVUtilities.h
===================================================================
--- trunk/bibdesk_vendorsrc/amaxwell/FileView/FVUtilities.h     2009-04-22 
23:20:40 UTC (rev 15159)
+++ trunk/bibdesk_vendorsrc/amaxwell/FileView/FVUtilities.h     2009-04-22 
23:49:13 UTC (rev 15160)
@@ -87,6 +87,12 @@
 FV_PRIVATE_EXTERN void FVLog(NSString *format, ...);
 
 /** @internal
+ Checks the pasteboard for any URL data.  Converts an NSPasteboard to a Carbon 
PasteboardRef. 
+ @param pboard Any NSPasteboard instance.
+ @return YES if pboard has a URL type or a string that can be converted to a 
URL. */
+FV_PRIVATE_EXTERN BOOL FVPasteboardHasURL(NSPasteboard *pboard);
+
+/** @internal
  Reads URLs from the pasteboard, whether file: or other scheme.  Finder puts 
multiple URLs on the pasteboard, and also webloc files.  Converts an 
NSPasteboard to a Carbon PasteboardRef in order to work around NSPasteboard's 
terrible URL support.
  @param pboard Any NSPasteboard instance.
  @return An array of URLs from the pasteboard. */

Modified: trunk/bibdesk_vendorsrc/amaxwell/FileView/FVUtilities.m
===================================================================
--- trunk/bibdesk_vendorsrc/amaxwell/FileView/FVUtilities.m     2009-04-22 
23:20:40 UTC (rev 15159)
+++ trunk/bibdesk_vendorsrc/amaxwell/FileView/FVUtilities.m     2009-04-22 
23:49:13 UTC (rev 15160)
@@ -143,6 +143,18 @@
 
 #pragma mark Pasteboard URL functions
 
+BOOL FVPasteboardHasURL(NSPasteboard *pboard)
+{       
+    NSArray *types = [pboard types];
+    
+    // quicker test than URLsFromPasteboard(); at least on 10.5, NSPasteboard 
has the UTI types
+    if ([types containsObject:(id)kUTTypeURL] || [types 
containsObject:(id)kUTTypeFileURL] || [types containsObject:NSURLPboardType])
+        return YES;
+    
+    // also catches case of file URL, which conforms to kUTTypeURL, and 
strings that might be URLs
+    return [FVURLsFromPasteboard(pboard) count] > 0;
+}
+
 // NSPasteboard only lets us read a single webloc or NSURL instance from the 
pasteboard, which isn't very considerate of it.  Fortunately, we can create a 
Carbon pasteboard that isn't as fundamentally crippled (except in its 
moderately annoying API).  
 NSArray *FVURLsFromPasteboard(NSPasteboard *pboard)
 {


This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.

------------------------------------------------------------------------------
Stay on top of everything new and different, both inside and 
around Java (TM) technology - register by April 22, and save
$200 on the JavaOne (SM) conference, June 2-5, 2009, San Francisco.
300 plus technical and hands-on sessions. Register today. 
Use priority code J9JMT32. http://p.sf.net/sfu/p
_______________________________________________
Bibdesk-commit mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/bibdesk-commit

Reply via email to